From: Lucas De Marchi Date: Sat, 21 Feb 2015 05:22:54 +0000 (-0200) Subject: module-playground: allow to cross-compile modules X-Git-Tag: v20~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7efa3502dd97b91eefcdbce154c97cb371bd17fa;p=thirdparty%2Fkmod.git module-playground: allow to cross-compile modules This adds the needed infra to cross-compile modules so we can test them in our testsuite. Right now we are only compiling mod-simple.ko for x86, x86_64 and sparc64. The makefiles are organized in a way it's easy to force a rebuild of a module by calling the Makefile.arch directly and that allows the rule in Makefile to not trigger in case we want to ship the modules pre-compiled. --- diff --git a/testsuite/module-playground/.gitignore b/testsuite/module-playground/.gitignore index dc6e6d83..436976fe 100644 --- a/testsuite/module-playground/.gitignore +++ b/testsuite/module-playground/.gitignore @@ -4,3 +4,7 @@ .tmp_versions modules.order Module.symvers + +mod-simple-x86_64.c +mod-simple-i386.c +mod-simple-sparc64.c diff --git a/testsuite/module-playground/Makefile b/testsuite/module-playground/Makefile index 215cc82d..6d845237 100644 --- a/testsuite/module-playground/Makefile +++ b/testsuite/module-playground/Makefile @@ -1,5 +1,7 @@ ifneq ($(KERNELRELEASE),) # kbuild part of makefile + +ifneq ($(KMOD_TESTSUITE_ARCH_BUILD),1) obj-m := mod-simple.o # mod-foo depends on foo-x, and foo-x modules don't depend @@ -24,15 +26,36 @@ obj-m += mod-fake-hpsa.o obj-m += mod-fake-scsi-mod.o obj-m += mod-fake-cciss.o +else +# only build ARCH-specific module +ifeq ($(ARCH),) + $(error ARCH must be set to a valid architecture) +endif +obj-m := mod-simple-$(ARCH).o +endif + else # normal makefile KDIR ?= /lib/modules/`uname -r`/build KVER ?= `uname -r` -default: +ARCH_SPECIFIC_MODULES := mod-simple-x86_64.ko mod-simple-i386.ko mod-simple-sparc64.ko + +default: modules arch-modules + +mod-simple-%.ko: mod-simple-%.c Makefile.arch + $(eval arch=$(patsubst mod-simple-%.ko,%,$@)) + $(MAKE) KDIR=$(KDIR_$(arch)) ARCH=$(arch) CROSS_COMPILE=$(CROSS_COMPILE_$(arch)) -f Makefile.arch + +modules: $(MAKE) -C $(KDIR) M=$$PWD +arch-modules: $(ARCH_SPECIFIC_MODULES) + clean: $(MAKE) -C $(KDIR) M=$$PWD clean + $(MAKE) KDIR=$(KDIR_x86_64) ARCH=x86_64 CROSS_COMPILE=$(CROSS_COMPILE_x86_64) -f Makefile.arch clean + $(MAKE) KDIR=$(KDIR_i386) ARCH=i386 CROSS_COMPILE=$(CROSS_COMPILE_i386) -f Makefile.arch clean + $(MAKE) KDIR=$(KDIR_sparc64) ARCH=sparc64 CROSS_COMPILE=$(CROSS_COMPILE_sparc64) -f Makefile.arch clean endif diff --git a/testsuite/module-playground/Makefile.arch b/testsuite/module-playground/Makefile.arch new file mode 100644 index 00000000..47bd9cbb --- /dev/null +++ b/testsuite/module-playground/Makefile.arch @@ -0,0 +1,14 @@ +ifeq ($(ARCH),) + $(error ARCH must be set to a valid architecture) +endif + +default: + @cmp --quiet mod-simple.c mod-simple-$(ARCH).c || ( \ + ln -sf mod-simple.c mod-simple-$(ARCH).c; \ + /bin/false \ + ) + $(MAKE) -C $(KDIR_$(ARCH)) CROSS_COMPILE=$(CROSS_COMPILE_$(ARCH)) M=$$PWD KMOD_TESTSUITE_ARCH_BUILD=1 + +clean: + $(MAKE) -C $(KDIR_$(ARCH)) CROSS_COMPILE=$(CROSS_COMPILE_$(ARCH)) M=$$PWD KMOD_TESTSUITE_ARCH_BUILD=1 clean + rm -f mod-simple-$(ARCH).c diff --git a/testsuite/populate-modules.sh b/testsuite/populate-modules.sh index b61cbfa0..938433d5 100755 --- a/testsuite/populate-modules.sh +++ b/testsuite/populate-modules.sh @@ -37,6 +37,9 @@ map=( ["test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/block/cciss.ko"]="mod-fake-cciss.ko" ["test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/scsi/hpsa.ko"]="mod-fake-hpsa.ko" ["test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/scsi/scsi_mod.ko"]="mod-fake-scsi-mod.ko" + ["test-modinfo/mod-simple-i386.ko"]="mod-simple-i386.ko" + ["test-modinfo/mod-simple-x86_64.ko"]="mod-simple-x86_64.ko" + ["test-modinfo/mod-simple-sparc64.ko"]="mod-simple-sparc64.ko" ) gzip_array=(