summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2015-02-21 03:22:54 -0200
committerLucas De Marchi <lucas.demarchi@intel.com>2015-02-21 11:40:27 -0200
commit7efa3502dd97b91eefcdbce154c97cb371bd17fa (patch)
tree75894784e3f0f293ff90f15433e642e5debe4be9
parent2a38870e3da60438ab4548846a1b639be6504338 (diff)
downloadkmod-7efa3502dd97b91eefcdbce154c97cb371bd17fa.tar.gz
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.
-rw-r--r--testsuite/module-playground/.gitignore4
-rw-r--r--testsuite/module-playground/Makefile25
-rw-r--r--testsuite/module-playground/Makefile.arch14
-rwxr-xr-xtestsuite/populate-modules.sh3
4 files changed, 45 insertions, 1 deletions
diff --git a/testsuite/module-playground/.gitignore b/testsuite/module-playground/.gitignore
index dc6e6d8..436976f 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 215cc82..6d84523 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
@@ -25,14 +27,35 @@ 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 0000000..47bd9cb
--- /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 b61cbfa..938433d 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=(