Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DESTDIR and PREFIX of make

People also ask

What is Destdir in Makefile?

DESTDIR is a variable prepended to each installed target file, like this: $(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo $(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a. The DESTDIR variable is specified by the user on the make command line as an absolute file name. For example: make DESTDIR=/tmp/stage install.

What is prefix in Makefile?

The prefix is want is /usr for most packages. So --prefix=/usr will do the job, but not all packages come with configure, a lot of them have just a makefile.

What is install prefix?

A prefix is the path on your host computer a software package is installed under. Packages that have a prefix will place all parts under the prefix path. Packages for your host computer typically use a default prefix of /usr/local on FreeBSD and Linux.

Where does make install?

By default, ' make install ' installs the package's commands under /usr/local/bin , include files under /usr/local/include , etc. You can specify an installation prefix other than /usr/local by giving configure the option --prefix= prefix , where prefix must be an absolute file name.


./configure --prefix=***

Number 1 determines where the package will go when it is installed, and where it will look for its associated files when it is run. It's what you should use if you're just compiling something for use on a single host.


make install DESTDIR=***

Number 2 is for installing to a temporary directory which is not where the package will be run from. For example this is used when building deb packages. The person building the package doesn't actually install everything into its final place on his own system. He may have a different version installed already and not want to disturb it, or he may not even be root. So he uses

./configure --prefix=/usr

so the program will expect to be installed in /usr when it runs, then

make install DESTDIR=debian/tmp

to actually create the directory structure.


make install prefix=***

Number 3 is going to install it to a different place but not create all the directories as DESTDIR=/foo/bar/baz would. It's commonly used with GNU stow via

./configure --prefix=/usr/local && make && sudo make install prefix=/usr/local/stow/foo

, which would install binaries in /usr/local/stow/foo/bin. By comparison,

make install DESTDIR=/usr/local/stow/foo

would install binaries in /usr/local/stow/foo/usr/local/bin.


This can help illustrating the use of DESTDIR and --prefix (from here):

Multiple installs using --prefix and DESTDIR:

Sepcify a different --prefix location/option for each build - at configure time. For eg:

untar petsc tar ball
./configure --prefix=/opt/petsc/petsc-3.9.0-mpich --with-mpi-dir=/opt/mpich
make
make install DESTDIR=/tmp/petsc-pkg
untar petsc tar ball
./configure --prefix=/opt/petsc/petsc-3.9.0-openmpi --with-mpi-dir=/opt/openmpi
make
make install DESTDIR=/tmp/petsc-pkg