Hello, I have fixed a few issues with building out-of-tree modules against read-only kernel sources. A read-only kernel source tree allows to build external modules against the tree without giving them a chance to mess things up (e.g., changing configurations, or who-knows what). Attached are two patches (containing descriptions) I found necessary. Is this the appropriate list for discussing such things?
Thanks, -- Andreas Gruenbacher <[EMAIL PROTECTED]> SUSE Labs, SUSE LINUX AG
kbuild keeps a list of kernel modules it created in .tmp_versions/. Adding out-of-tree modules to this list makes little sense, and breaks if the kernel sources are read-only. Don't add out-of-tree modules. Index: linux-2.6.0-test11/scripts/Makefile.build =================================================================== --- linux-2.6.0-test11.orig/scripts/Makefile.build 2003-12-12 23:50:53.000000000 +0100 +++ linux-2.6.0-test11/scripts/Makefile.build 2003-12-15 21:26:44.786167839 +0100 @@ -64,7 +64,12 @@ # We keep a list of all modules in $(MODVERDIR) -touch-module = @echo $(@:.o=.ko) > $(MODVERDIR)/$(@F:.o=.mod) +define touch-module + @DIR=$(@D); \ + if test "$${DIR:0:1}" != / -o "$${DIR#$$PWD}" != "$$DIR"; then \ + echo $(@:.o=.ko) > $(MODVERDIR)/$(@F:.o=.mod); \ + fi +endef __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ $(if $(KBUILD_MODULES),$(obj-m)) \
A few minor things that are easily fixed prevent building externel kernel modules against a read-only kernel source tree: (1) it makes no sense to add out-of-tree modules to the list of modules in .tmp_versions (=MODVERDIR); (2) create temporary files of filechk outside the kernel source tree. Index: linux-2.6.0-test11/Makefile =================================================================== --- linux-2.6.0-test11.orig/Makefile 2003-12-12 23:50:50.000000000 +0100 +++ linux-2.6.0-test11/Makefile 2003-12-15 21:26:44.725180950 +0100 @@ -592,12 +592,12 @@ ifdef KBUILD_MODULES ifeq ($(origin SUBDIRS),file) $(Q)rm -rf $(MODVERDIR) + $(if $(CONFIG_MODULES),$(Q)mkdir -p $(MODVERDIR)) else @echo '*** Warning: Overriding SUBDIRS on the command line can cause' @echo '*** inconsistencies' endif endif - $(if $(CONFIG_MODULES),$(Q)mkdir -p $(MODVERDIR)) # All the preparing.. prepare-all: prepare0 prepare @@ -1010,12 +1010,13 @@ @set -e; \ echo ' CHK $@'; \ mkdir -p $(dir $@); \ - $(filechk_$(1)) < $< > [EMAIL PROTECTED]; \ - if [ -r $@ ] && cmp -s $@ [EMAIL PROTECTED]; then \ - rm -f [EMAIL PROTECTED]; \ + tmp=$$(/bin/mktemp /tmp/kbuild.XXXXXX); \ + $(filechk_$(1)) < $< > $$tmp; \ + if [ -r $@ ] && cmp -s $@ $$tmp; then \ + rm -f $$tmp; \ else \ echo ' UPD $@'; \ - mv -f [EMAIL PROTECTED] $@; \ + mv -f $$tmp $@; \ fi endef