• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1ifneq ($(KERNELRELEASE),)
2# kbuild part of makefile
3
4ifneq ($(KMOD_TESTSUITE_ARCH_BUILD),1)
5obj-m := mod-simple.o
6
7# mod-foo depends on foo-x, and foo-x modules don't depend
8# on anyone
9obj-m += mod-foo-a.o
10obj-m += mod-foo-b.o
11obj-m += mod-foo-c.o
12obj-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
22obj-m += mod-loop-a.o
23obj-m += mod-loop-b.o
24obj-m += mod-loop-c.o
25obj-m += mod-loop-d.o
26obj-m += mod-loop-e.o
27obj-m += mod-loop-f.o
28obj-m += mod-loop-g.o
29obj-m += mod-loop-h.o
30obj-m += mod-loop-i.o
31obj-m += mod-loop-j.o
32obj-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
36obj-m += mod-fake-hpsa.o
37obj-m += mod-fake-scsi-mod.o
38obj-m += mod-fake-cciss.o
39
40else
41# only build ARCH-specific module
42ifeq ($(ARCH),)
43    $(error ARCH must be set to a valid architecture)
44endif
45obj-m := mod-simple-$(ARCH).o
46endif
47
48else
49# normal makefile
50KDIR ?= /lib/modules/`uname -r`/build
51KVER ?= `uname -r`
52ifeq ($(FAKE_BUILD),)
53    FAKE_BUILD=0
54endif
55
56ARCH_SPECIFIC_MODULES := mod-simple-x86_64.ko mod-simple-i386.ko mod-simple-sparc64.ko
57MY_MODULES := $(filter-out $(ARCH_SPECIFIC_MODULES),$(wildcard *.ko))
58
59default: modules arch-modules
60
61mod-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
65ifeq ($(FAKE_BUILD),0)
66modules:
67	$(MAKE) -C $(KDIR) M=$$PWD
68else
69modules:
70	@echo "  CP       cache/*.ko"
71	@cp cache/*.ko .
72endif
73
74arch-modules: $(ARCH_SPECIFIC_MODULES)
75
76clean:
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
83endif
84