Incremental compilation with make-kpkg or HOWTO reconfigure linux and recreate kernel-image-XXX.deb in less than 1 min The problem ------------ Compiling the linux kernel from is awfully long, in particular because of the use of recursive makefiles[1]. For this reason (and others), It is tempting to compile on one (fast) machine and install the result on others. Debian's "make-kpkg" tool (package "kernel-package") makes this a breeze. For other good reasons to use make-kpkg, read: /usr/share/kernel-package/Rationale Cleverly designed makefile(s) usually allow selective re-compilation, speeding up the compilation process considerably. But make-kpkg does not allow selective compilation: for instance make-kpkg does "make clean" at the end of each call by default. make-kpkg is not designed for short development cycles (which is hard to blame). Below you will find explained how to tweak make-kpkg a little bit to do it anyway. WARNING: the only way to be 200% sure to get the working kernel you asked for is to follow the instructions, which imply frequents "make clean"-s. The few tricks shown below are DIRTY SHORTCUTS! The current and broken linux compilation system is currently being replaced (better ref.?) Hopefully this will make this page completely useless (...and the current make-kpkg software obsolete!) If you only want to patch the source, NOT changing .config ---------------------------------------------------------- 1) Never change your --revision=? number 2) Define the CLEAN_SOURCE variable $ CLEAN_SOURCE=no $ export CLEAN_SOURCE 3) and instead of doing: $ time fakeroot make-kpkg --revision=marc.1.0 --append_to_version superpatched kernel_image just erase the "stamp-build" file before: $ rm stamp-build $ time fakeroot make-kpkg --revision=marc.1.0 --append_to_version superpatched kernel_image If you also want to change the .config file ------------------------------------------- ... then it becomes a little bit trickier. make-kpkg will call "make dep" and "make clean" for (good!) safety reasons (remember, what I explain here is dangerous, you must know what you are doing). But if you are sure the modifications you made do not require "make dep" and "make clean" and want to shortcut them, you just have to comment two lines in the Makefile "debian/rules" as shown below. --- /usr/share/kernel-package/rules Sun Apr 14 18:59:49 2002 +++ debian/rules Thu Oct 24 13:36:54 2002 @@ -1153,8 +1153,8 @@ stamp-kernel-configure: stamp-debian .config $(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) $(CROSS_ARG) \ ARCH=$(KERNEL_ARCH) $(config_target) - +$(MAKE) -f ./debian/rules dummy_do_dep - $(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) $(CROSS_ARG) \ +# +$(MAKE) -f ./debian/rules dummy_do_dep +# $(MAKE) $(EXTRAV_ARG) $(FLAV_ARG) $(CROSS_ARG) \ ARCH=$(KERNEL_ARCH) clean touch $@ and then follow the same instructions as above when not changing .config. Congratulations, you just won a few minutes at each run compilation run. And lost some safety. Hopefully the next compilation system "kbuild" will offer both speed and safety in kernel 2.5 If you want to go even faster ----------------------------- 1) Put your linux tree on a local partition of your preferred SMP machine, 2) use CONCURRENCY_LEVEL=n (n being the number of CPUs) as follows: CONCURRENCY_LEVEL=2 time fakeroot make-kpkg \ --append_to_version foopatched --revision marc.1.0 \ --initrd kernel_image and your kernel compilation will take half the time to complete! You can also do "export CONCURRENCY_LEVEL=2" or even set this variable in /etc/kernel-pkg/conf on your SMP machine once for all. See kernel-pkg.conf(5) for more details. More about make-kpkg -------------------- man make-kpkg /usr/share/kernel-package/README and its whole directory. The heart of make-kpkg lies in the "rules" Makefile patched just above. Dive into it if you want to hack make-kpkg even more. Note about downloading debian linux kernels ------------------------------------------- There seem to be 2 ways for quickly downloading a kernel-source. [please find a authoritative documentation about all this and provide the pointer!] 0) apt-get source kernel-image-X.Y.Z <- does not work 1) apt-get source kernel-source-X.Y.Z 2) apt-get install kernel-source-X.Y.Z Differences: 1) can be run by any user, in any directory. 2) can be run only by root, and downloads always in /usr/src/ 1) performs everything: - full extract - apply debian patches, BUT ALSO downloads the patch (so you can patch -R or just see what happened) - the "debian/" directory is here, ready for make-kpkg 2) only puts a source.tar.bz2 file in /usr/src/. Inside this archive, the debian patches are applied, but the patch and the debian/ directory are NOT available. Conclusion: 2) is probably never useful Footnote -------- [1] "Recursive Make Considered Harmful" $Revision: 1.5 $