1 # ===========================================================================
3 # ===========================================================================
9 include scripts/Makefile.lib
13 __modules := $(shell cat /dev/null $(wildcard $(MODVERDIR)/*.mod))
14 modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))
16 ifneq ($(filter-out $(modules),$(__modules)),)
17 $(warning *** Uh-oh, you have stale module entries. You messed with SUBDIRS,)
18 $(warning do not complain if something goes wrong.)
21 __modversions: $(modules)
24 # The final module link
26 quiet_cmd_ld_ko_o = LD [M] $@
27 cmd_ld_ko_o = $(LD) $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \
28 $(filter-out FORCE,$^)
30 $(modules): %.ko :%.o %.mod.o FORCE
31 $(call if_changed,ld_ko_o)
35 # Compile version info for unresolved symbols
37 quiet_cmd_cc_o_c = CC $@
38 cmd_cc_o_c = $(CC) -Wp,-MD,$(depfile) $(CFLAGS) $(CFLAGS_MODULE) \
41 $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
42 $(call if_changed_dep,cc_o_c)
44 targets += $(modules:.ko=.mod.o)
46 # All the .mod.c files are generated using the helper "modpost"
50 $(modules:.ko=.mod.c): __modpost ;
52 # Extract all checksums for all exported symbols
54 quiet_cmd_modpost = MODPOST
55 cmd_modpost = scripts/modpost $(filter-out FORCE,$^)
57 __modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE
58 $(call if_changed,modpost)
62 # Add FORCE to the prequisites of a target to force it to be always rebuilt.
63 # ---------------------------------------------------------------------------
69 # Read all saved command lines and dependencies for the $(targets) we
70 # may be building above, using $(if_changed{,_dep}). As an
71 # optimization, we don't need to read them if the target does not
72 # exist, we will rebuild anyway in that case.
74 targets := $(wildcard $(sort $(targets)))
75 cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))