If you're using a build tool like autoconf, it handles these details for you. But, if you're building your app with a simple Makefile, there are a few ways you can make it easier to package your app.

Debian/Ubuntu use the DESTDIR variable in Makefiles to set a temporary install location for building packages. So, in your install target, anywhere you might use an install path like '/usr/bin/', make sure you put DESTDIR in front like '$(DESTDIR)/usr/bin'. (See for more details.)

Another useful trick is to use a PREFIX variable for the system install path, instead of literal install paths like /usr, or /usr/local, or /opt/ You can start your Makefile with something like:

PREFIX ?= /usr
bindir = $(PREFIX)/bin
libdir = $(PREFIX)/lib
datadir = $(PREFIX)/share

And then in the install and uninstall targets, replace literal paths like:


With a path that uses the defined variables:


That way, the debian/rules file can just set the install path once by setting PREFIX:

        dh_auto_install -- PREFIX=/opt/

AppReviewBoard/Submissions/MakefileTips (last edited 2012-04-02 00:36:41 by allison)