cloneconfig/oldconfig/… considered harmful (orig.: “No cloneconfig needed!”)

Because a lot of articles, howtos, readmes and other sorts of text get it wrong, here's the stance:

It is often said to run

cd /usr/src/linux
make cloneconfig
make prepare

or something similar (like mrproper, oldconfig, prepare-all, etc.). This is not required for SUSE Linux (and perhaps other distros). When the binary kernel package and kernel-source is installed, the parts that would have to be configured are already present. A simple call to make (see below) is sufficient. Every external module package (that is sane) will do everything right automatically.

In fact, running `make cloneconfig` or any build operation inside /usr/src/linux will make it unclean so that (sane!) external modules' build process will abort with:

/usr/src/linux is not clean, please run 'make mrproper'
in the '/usr/src/linux' directory.

All of this is correct, since /usr/src/linux is ONLY a source directory, NOT the build directory. A few external module packages are, however, so broken that they fail to make this distinction and run into one of two problems: (1) they cannot find some header file, (2) says you have yet to configure your kernel (which is wrong of course).


There are however, some exceptions. The proprietary NVIDIA module is one of such a kind, which needs some undocumented extra options when calling `make`. (BAD BAD BAD).

make SYSSRC=/lib/modules/`uname -r`/source SYSOUT=/lib/modules/`uname -r`/build -f Makefile.kbuild

This one applies to the NVIDIA graphics driver kernel module only. Other packages might have even more braindead Makefiles that won't even let you set a SYSOUT directory.

For reference...

If you happen to write a kernel Makefile for an out-of-tree module, please, just do it the right way (i.e. with make -C objectdir):

MODULES_DIR := /lib/modules/$(shell uname -r)
        make -C ${KERNEL_DIR} M=$${PWD};
modules modules_install clean:
        make -C ${KERNEL_DIR} M=$${PWD} $@;

Both $${PWD} or `pwd` work, the latter is slower due to the extra shell invocation.

About root

root is not needed for compilation, only for installing. Stick to it.

Posted 2007-04-12 10:04 / Tags: / link