1 ifneq ($(KERNELRELEASE),) 2 # kbuild part of makefile 3 4 ifneq ($(KMOD_TESTSUITE_ARCH_BUILD),1) 5 obj-m := mod-simple.o 6 7 # mod-foo depends on foo-x, and foo-x modules don't depend 8 # on anyone 9 obj-m += mod-foo-a.o 10 obj-m += mod-foo-b.o 11 obj-m += mod-foo-c.o 12 obj-m += mod-foo.o 13 14 # mod-loop: create loops in dependencies: 15 # 1) mod-loop-a -> mod-loop-b -> mod-loop-c -> mod-loop-a 16 # |-> mod-loop-f |-> mod-loop-f 17 # \-> mod-loop-g \-> mod-loop-g 18 # 2) mod-loop-d -> mod-loop-e -> mod-loop-d 19 # 3.1) mod-loop-h -> mod-loop-i -> mod-loop-j -> mod-loop-h 20 # 3.2) mod-loop-h -> mod-loop-i -> mod-loop-j -> mod-loop-k -> mod-loop-h 21 22 obj-m += mod-loop-a.o 23 obj-m += mod-loop-b.o 24 obj-m += mod-loop-c.o 25 obj-m += mod-loop-d.o 26 obj-m += mod-loop-e.o 27 obj-m += mod-loop-f.o 28 obj-m += mod-loop-g.o 29 obj-m += mod-loop-h.o 30 obj-m += mod-loop-i.o 31 obj-m += mod-loop-j.o 32 obj-m += mod-loop-k.o 33 34 # mod-fake-*: fake the respective modules in kernel with these aliases. Aliases 35 # list was taken from 3.5.4 36 obj-m += mod-fake-hpsa.o 37 obj-m += mod-fake-scsi-mod.o 38 obj-m += mod-fake-cciss.o 39 40 else 41 # only build ARCH-specific module 42 ifeq ($(ARCH),) 43 $(error ARCH must be set to a valid architecture) 44 endif 45 obj-m := mod-simple-$(ARCH).o 46 endif 47 48 else 49 # normal makefile 50 KDIR ?= /lib/modules/`uname -r`/build 51 KVER ?= `uname -r` 52 ifeq ($(FAKE_BUILD),) 53 FAKE_BUILD=0 54 endif 55 56 ARCH_SPECIFIC_MODULES := mod-simple-x86_64.ko mod-simple-i386.ko mod-simple-sparc64.ko 57 MY_MODULES := $(filter-out $(ARCH_SPECIFIC_MODULES),$(wildcard *.ko)) 58 59 default: modules arch-modules 60 61 mod-simple-%.ko: mod-simple-%.c Makefile.arch 62 $(eval arch=$(patsubst mod-simple-%.ko,%,$@)) 63 $(MAKE) KDIR=$(KDIR_$(arch)) ARCH=$(arch) CROSS_COMPILE=$(CROSS_COMPILE_$(arch)) -f Makefile.arch 64 65 ifeq ($(FAKE_BUILD),0) 66 modules: 67 $(MAKE) -C $(KDIR) M=$$PWD 68 else 69 modules: 70 @echo " CP cache/*.ko" 71 @cp cache/*.ko . 72 endif 73 74 arch-modules: $(ARCH_SPECIFIC_MODULES) 75 76 clean: 77 test -z "$(MY_MODULES)" || rm -rf $(MY_MODULES) || true 78 rm -rf .tmp_versions || true 79 rm -rf .*.cmd *.mod.c || true 80 rm -rf *.o || true 81 rm -rf Module.symvers modules.order 82 83 endif 84