Implicit Destdir Considered Harmful

When compiling a piece of software (during the configure stage and build stage), one refers to common directory variables like $(bindir) and $(prefix). During these stages they refer to the variables relative to the root of the final running system.

During the install stage, one needs to refer to these variables as well, but we need to prefix the dir where our file tree is being built. This means that if we're building a tree of files to be packaged up as a separate filesystem, we need to prepend the $(DESTDIR) variable on the front, as in $(DESTDIR)$(bindir) and $(DESTDIR)$(prefix).

Now, working on the principle of least surprise, the system (for a time) implicitly added $(DESTDIR) to the beginning of these variables in four special cases:

  • pre-install
  • post-install
  • install-none (a common quick-and-dirty install target)
  • manifest-based installs.

But, as both Seth Schoen and Andrew Scott pointed out, this creates special cases, which are confusing to the user. Thus, this implicit munging is no more. On 5Apr2002, Nick Moffitt and Andrew Scott removed all of the implicit DESTDIR stuff from all the packages.

Thus, in your rules pertaining to the install stage, be sure to prefix your standard directory variables with $(DESTDIR)!