CVS head is 2.6.5 now.
[linux-flexiantxendom0-3.2.10.git] / scripts / Makefile.modpost
1 # ===========================================================================
2 # Module versions
3 # ===========================================================================
4
5 .PHONY: __modversions
6 __modversions:
7
8 include .config
9 include scripts/Makefile.lib
10
11 #
12
13 __modules := $(shell head -q -n1 /dev/null $(wildcard $(MODVERDIR)/*.mod))
14 modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))
15
16 ifneq ($(filter-out $(modules),$(__modules)),)
17   $(warning Trouble: $(filter-out $(modules),$(__modules)))
18   $(warning *** Uh-oh, you have stale module entries. You messed with SUBDIRS,)
19   $(warning     do not complain if something goes wrong.)
20 endif
21
22 __modversions: $(modules)
23         @:
24
25 # The final module link
26
27 quiet_cmd_ld_ko_o = LD [M]  $@
28       cmd_ld_ko_o = $(LD) $(LDFLAGS) $(LDFLAGS_MODULE) -o $@            \
29                           $(filter-out FORCE,$^)
30
31 $(modules): %.ko :%.o %.mod.o FORCE
32         $(call if_changed,ld_ko_o)
33
34 targets += $(modules)
35
36 # Compile version info for unresolved symbols
37
38 quiet_cmd_cc_o_c = CC      $@
39       cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE)    \
40                    -c -o $@ $<
41
42 $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
43         $(call if_changed_dep,cc_o_c)
44
45 targets += $(modules:.ko=.mod.o)
46
47 # All the .mod.c files are generated using the helper "modpost"
48
49 .PHONY: __modpost
50
51 $(modules:.ko=.mod.c): __modpost ;
52
53 # Extract all checksums for all exported symbols
54
55 # Are we building out-of-tree modules?
56
57 ifeq ($(filter ../% /%,$(SUBDIRS)),)
58 modver_file := modversions-$(shell echo $(ARCH)-$(CONFIG_CFGNAME))
59 quiet_cmd_modpost = MODPOST
60       cmd_modpost = scripts/modpost $(filter-out FORCE,$^) $(if $(CONFIG_MODVERSIONS),-o $(modver_file))
61 __modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE
62         $(call if_changed,modpost)
63 else
64 modver_file := $(wildcard $(srctree)/modversions-$(shell echo $(ARCH)-$(CONFIG_CFGNAME)))
65 quiet_cmd_modpost = MODPOST
66       cmd_modpost = scripts/modpost $(if $(modver_file),-i $(modver_file)) $^
67 __modpost: $(modules:.ko=.o)
68         $(call cmd,modpost)
69 endif
70
71 targets += __modpost
72
73 # Add FORCE to the prequisites of a target to force it to be always rebuilt.
74 # ---------------------------------------------------------------------------
75
76 .PHONY: FORCE
77
78 FORCE:
79
80 # Read all saved command lines and dependencies for the $(targets) we
81 # may be building above, using $(if_changed{,_dep}). As an
82 # optimization, we don't need to read them if the target does not
83 # exist, we will rebuild anyway in that case.
84
85 targets := $(wildcard $(sort $(targets)))
86 cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
87
88 ifneq ($(cmd_files),)
89   include $(cmd_files)
90 endif