tags:

views:

112

answers:

2

How can I store GNU make & configure files elsewhere? I have a project I am working on that I get compiled using:

./configure --prefix=/usr && make && su -c 'make install'

The thing is I don't want to pollute the current folder, which is a svn/git/hg/whatever sandbox with files generated by that command. I want to put those files in a separate location. I don't know if it's similar, but when I compile the linux kernel from source, I can specify where to put the ouput by passing the 'O' option to 'make', something like this:

make O=/home/user/linux-output
+4  A: 

The Makefile must support this feature.

I think the autoconf generated makefiles all support the following use:

mkdir ../build
cd ../build
../configure --prefix=/usr
make
make install

(It's certainly recommended for gcc builds).

Kristof Provost
This will move the Makefile, and generated binaries into a separate directory. However the configure script it self and Makefile.in will still 'pollute' the source tree.
Douglas Leeder
Yes, you are right Douglas, the .in, .m4 files (if used) will still be in the source tree.
hyperboreean
This is called a vpath build, and will only work if the developer writes the package properly. When you are the maintainer of the package, it is your responsibility to ensure that vpath builds work.
William Pursell
+1  A: 

As Kristof already pointed out, GNU autotools inherently support out out-of-tree builds at the configure level.

So you can have the Makefile and built binaries out of the source tree trivially.

To get all the auto-generated artefacts out of the source tree requires much more work however.

We have a script that copies changes from a source tree into a working_copy, carefully preserving the configure script etc in the working_copy, which allows the original source tree to be pristine. However it's very inefficient, so I wouldn't recommend it.

I would recommend a normal out-of-tree build, and then explicitly excluding the remaining auto-generated files in the source tree.

Douglas Leeder
Autoconf does not support vpath builds. Automake does, and although automake is often used in conjunction with autoconf, it is not always.
William Pursell
I didn't say vpath, I said out-of-tree. Clearly the bit that allows the creation of a Makefile that can do vpath is automake, but supporting running configure out-of-tree must be autoconf, I think?
Douglas Leeder
I'll change autoconf to autotools as it's a cooperative effort.
Douglas Leeder