I had a discussion on #kde-devel today with a developer who didn’t know about how to build programs with a different build and source directory. It came as quite a shock to me, as I had assumed that it was common knowledge.
It never hurts to spread the word, though, so here’s how it works:
- You need to have already unpacked the source, let’s call that directory srcdir.
- If you need to run make -f Makefile.cvs, run that in $srcdir, not $builddir.
- You need to make sure your build directory has been created, and change directory to the build directory.
- While in the build directory, run the configure script from the $srcdir. It will perform the configure process like normal, with the exception that all of the Makefiles and other generated files end up in $builddir, not $srcdir.
- Go ahead and use make like normal.
That’s nice, you’re thinking, but why would you want to use builddir != srcdir you ask. The answer is because it makes it easier to do a clean rebuild, so that you can be sure a package that builds for you also builds for someone else, or maybe you’ve b0rked a Makefile beyond repair. If you use KDE CVS, you can run make cvs-clean to get an equivalent effect, but that wastes bandwidth and server time, and doesn’t work when the network or server is down. Also, I’m not sure whether or not make cvs-clean will wipe out any changes you’ve made to the source code.
There are other ways of performing the same idea. XFree86 and X.Org include a tool called lndir, which is probably installed on your system, that creates a mirror image of a source directory by using symlinks. This has the advantage of ensuring the updates to the source are reflected in the symlinked files, but I have no clue how well it works or not, as I have not used it myself.