DESTDIR and PREFIX of make

99,560

Solution 1

./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.

Solution 2

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
Share:
99,560

Related videos on Youtube

Sean
Author by

Sean

Updated on July 08, 2022

Comments

  • Sean
    Sean almost 2 years

    I am trying to make software install to a specific directory. I found several ways, but not sure what are the differences between them.

    1. ./configure --prefix=***
    2. make install DESTDIR=***
    3. make install prefix=***

    I am confused about the functions of these three. Do they achieve the same goal?

  • Ryan Pavlik
    Ryan Pavlik over 11 years
    For what it's worth, in a cmake-based build you can emulate "case 4" (for stow, etc) by running cmake -DCMAKE_INSTALL_PREFIX=/foo/bar/baz -P cmake_install.cmake in the build directory.
  • thinkski
    thinkski over 9 years
    @JackKelly: Thanks! I've been using DESTDIR with GNU stow and have had to fix-up the directory structure with a mv usr/local/* . && rmdir usr/local && rmdir usr typically -- using prefix= is much better!
  • timotheecour
    timotheecour almost 6 years
    Note: some software doesn't support DESTDIR=/tmp/foo make install ; for cmake based projects, I had more luck with cmake -DCMAKE_INSTALL_PREFIX=/tmp/test1 -P cmake_install.cmake which installs to /tmp/foo/{bin,...} ; see github.com/opencv/opencv/issues/11833#issuecomment-401164056 for an example.
  • Good Will
    Good Will over 5 years
    In case the ./configure file is not provided, one can still install to user-specific directory using: make prefix=/path/to/your/lib/libaio install
  • albert
    albert about 5 years
    One more note: DESTDIR and prefix can be used on make install together, i.e. make install DESTDIR=/foo/bar/tmp perfix=/local.
  • Филя Усков
    Филя Усков almost 3 years
    So if I run ./configure --prefix=path1 and then make install prefix=path2, path2 overrides path1, right? Is there any other differences between path1 and path2?