I wish to do the following:

Make from an open source project to compile/link into libraries etc. However, I don't want to actually run this locally. I want to package it up into an rpm so that it can be installed into the correct directories on other machines (which would of course have similar architecture). I want it to compile and link and create symbolic links as if it were going to install under /usr/local, but I don't actually want this to go to a directory under /usr/local/ but to some temporary directory that can be wiped out without deleting files placed there by other packages.

Is there some parameter to make install that would let this happen - that is build as if it were to be installed under /usr/local but actually place the "installation" under ~/tmp/usr/local, for example.

I've looked into simply NOT running make install but stop at make, but this intermingles executables, object code, and libraries in the source directory.

  • It would help if you say which open source project, so we can have a look at figure out how it works for this particular one (autoconf, cmake, plain makefile, whatever). Because as already has been said, it depends. In general, it usually can be done (and I always do it that way, because I use stow to manage my /usr/local).
    – dirkt
    Commented Sep 23, 2016 at 7:22

1 Answer 1


The answer to this question depends on which open source project you're attempting to install this way. The general answer is that some open source projects have Makefiles which provide optional variables for this purpose. One specific example of this is gdb, whose top level Makefile uses (but does not seem to assign) a DESTDIR variable, and if I run this command in the gdb build directory,

make DESTDIR=/tmp install

it prepends /tmp to each destination path before copying the file.

Another more difficult approach is to do the entire build, install and all, in a chroot environment. Using something like OverlayFS can make that easier, but this is not typically the path of least resistance.

Another possibility, which is probably easier if you're already using a Debian flavor (which includes Ubuntu among many others), is to fetch the Debian source package corresponding to the open source project (this approach is unlikely to be easy if there is no such source package) and follow the instructions to build the Debian package from that source. If you really need a .rpm rather than a .deb you can convert the .deb to a .rpm, or perhaps you can construct a .rpm from the directory structure left behind in the process of building the .deb. This answer is one source of information about building a Debian package from the source.

For the latest openssl (mentioned in a comment but not yet mentioned in the question) the INSTALL file says this:

 Package builders who want to configure the library for standard
 locations, but have the package installed somewhere else so that
 it can easily be packaged, can use

   $ make DESTDIR=/tmp/package-root install         # Unix
   $ mms/macro="DESTDIR=TMP:[PACKAGE-ROOT]" install ! OpenVMS

 The specified destination directory will be prepended to all
 installation target paths.

That varies across different versions of openssl; for 1.0.2 INSTALL says this:

 Package builders who want to configure the library for standard
 locations, but have the package installed somewhere else so that
 it can easily be packaged, can use

   $ make INSTALL_PREFIX=/tmp/package-root install

 (or specify "--install_prefix=/tmp/package-root" as a configure
 option).  The specified prefix will be prepended to all
 installation target filenames.

The idea is very much the same, with slightly different details.

  • Thanks, Eirik, after I looked into this some more, I realized the point you are trying to make - it all depends how the makefile and configure script are written. The open source project I am trying to do this with is OpenSSL. Our practice has been to build this as an rpm, running a script supplied from somewhere(?) that does configure, make, and make install. What I think I'll try next is: run the script through make install. build rpm, then make uninstall. There is supposed to be another option, to build into a different directory. Then you could skip make install. But it doesn't work Commented Sep 23, 2016 at 15:50
  • Thanks again, Eirik - you are a more thorough reader of INSTALL docs than I am. INSTALL_PREFIX was the answer. Too bad they felt the need to change this to DESTDIR in the newer versions. Commented Sep 26, 2016 at 19:03
  • I found INSTALL_PREFIX before I found DESTDIR, and I initially found it in a Makefile (from the Debian sources), not from the documentation. I went looking for the github sources because I wanted to be sure Debian didn't add the INSTALL_PREFIX, at which point I noticed the name change. The Debian approach eliminates (or, perhaps, conceals) such variations for any source package provided by the distribution, by providing a uniform way to build packages from source. Commented Sep 26, 2016 at 19:11
  • Learn something about make? Not every day, but good days.
    – wogsland
    Commented May 16, 2017 at 21:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .