Opened 8 years ago

Closed 7 years ago

Last modified 6 years ago

#764 closed feature request (duplicate)

DESTDIR Makefile variable

Reported by: guest Owned by: igloo
Priority: low Milestone: 6.6.1
Component: Build System Version: 6.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I'd like the Makefile to have a DESTDIR parameter. This is destined to ease package creation. After the ./configure step the system should be configured to be installed in $(prefix)/bin and other locations. In the "make install" step you would specify a different root directory, like "make install DESTDIR=/tmp/fake-rootdir" to get all files copied to /tmp/fake-rootdir$(prefix)/bin (etc) instead of the real destination directories.

This is nothing new. Most famous free software packages provide some way or another of doing this. The DESTDIR name is the typical one in software using the autotools package.

Thanks in advance and keep up the good work.

Change History (9)

comment:1 Changed 8 years ago by panne

  • Resolution set to invalid
  • Status changed from new to closed

GHC's build system already has this feature, see e.g. the RPM spec file ghc/ghc.spec.in:

make prefix=/foo/bar/baz install

or

make datadir=/blah install-docs

comment:2 Changed 8 years ago by guest

I wouldn't say that the way the RPM .spec file handles this is entirely straightforward. There is a large comment about how to selectively remove the RPM_BUILD_ROOT prefix, which ends with the plea: "isn't there an easier way to do all this?" The answer is yes, there is. DESTDIR is the mechanism.

Everywhere the 'make install' target actually copies something to its final destination, just use the target path $(DESTDIR)$(prefix)/blah instead of $(prefix)/blah. Most of the time DESTDIR is empty, so this is equivalent to the ordinary current case. Only when you need to package everything into a sandbox, the caller sets DESTDIR to the root of the sandbox. The Makefile for rts/gmp already does the DESTDIR thing right. It could be done elsewhere too. For instance, all the binary distribution packaging rules could use DESTDIR rather than all the $(BIN_DIST_TMPDIR) stuff.

(Oh, and remove the dead but conflicting definition of DESTDIR in compiler/Makefile)

comment:3 Changed 8 years ago by dcoutts@…

Just to note what we do with Gentoo (which isn't ideal):

For configure we use the normal stuff.

Then for install we use:

make -j1 ${insttarget} \
        prefix="${D}/usr" \
        datadir="${D}/usr/share/doc/${PF}" \
        infodir="${D}/usr/share/info" \
        mandir="${D}/usr/share/man" \
        libdir0="${D}/usr/$(get_libdir)"
# the libdir0 setting is needed for amd64, and does not
# harm for other arches

And this still doesn't quite work because the temporary ${D} path gets baked into ghcprof and we have to fix that up using sed.

#need to remove ${D} from ghcprof script
sed -i -e 's:$FPTOOLS_TOP_ABS:#$FPTOOLS_TOP_ABS:' "${D}/usr/bin/ghcprof"

Ideally if DESTDIR were supported then we'd just do:

make -j1 ${insttarget} DESTDIR="${D}"

Note that for some reason we need this hack while building:

make all datadir="/usr/share/doc/${PF}"
# the explicit datadir is required to make the haddock entries
# in the package.conf file point to the right place ...

That was for 6.4.1, I don't know if it's still needed in 6.4.2.

comment:4 Changed 8 years ago by guest

  • Resolution invalid deleted
  • Status changed from closed to reopened

comment:5 Changed 7 years ago by igloo

  • Milestone set to 6.6.1
  • Owner set to igloo
  • Status changed from reopened to new

comment:6 Changed 7 years ago by igloo

  • Priority changed from normal to low

comment:7 Changed 7 years ago by igloo

  • Resolution set to duplicate
  • Status changed from new to closed

Dupe of #1163

comment:8 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:9 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.