summaryrefslogtreecommitdiff
path: root/scripts/Makefile.modpost
blob: a7ab45ec783969187e33082dfb4ec7ee2d91cb5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# ===========================================================================
# Module versions
# ===========================================================================

.PHONY: __modversions
__modversions:

include .config
include scripts/Makefile.lib

#

__modules := $(shell cat /dev/null $(wildcard $(MODVERDIR)/*.mod))
modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))

ifneq ($(filter-out $(modules),$(__modules)),)
  $(warning *** Uh-oh, you have stale module entries. You messed with SUBDIRS,)
  $(warning     do not complain if something goes wrong.)
endif

__modversions: $(modules)
	@:

# The final module link

quiet_cmd_ld_ko_o = LD [M]  $@
      cmd_ld_ko_o = $(LD) $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ 		\
			  $(filter-out FORCE,$^)

$(modules): %.ko :%.o %.mod.o FORCE
	$(call if_changed,ld_ko_o)

targets += $(modules)

# Compile version info for unresolved symbols

quiet_cmd_cc_o_c = CC      $@
      cmd_cc_o_c = $(CC) $(CFLAGS) $(CFLAGS_MODULE) -c -o $@ $<

#	We have a fake dependency on compile.h to make sure that we
#	notice if the compiler version changes under us.

$(modules:.ko=.mod.o): %.mod.o: %.mod.c include/linux/compile.h FORCE
	$(call if_changed,cc_o_c)

targets += $(modules:.ko=.mod.o)

# All the .mod.c files are generated using the helper "modpost"

.PHONY: __modpost

$(modules:.ko=.mod.c): __modpost ;

# Extract all checksums for all exported symbols

quiet_cmd_modpost = MODPOST
      cmd_modpost = scripts/modpost $^

__modpost: $(wildcard vmlinux) $(modules:.ko=.o)
	$(call if_changed,modpost)

targets += __modpost

# Add FORCE to the prequisites of a target to force it to be always rebuilt.
# ---------------------------------------------------------------------------

.PHONY: FORCE

FORCE:

# Read all saved command lines and dependencies for the $(targets) we
# may be building above, using $(if_changed{,_dep}). As an
# optimization, we don't need to read them if the target does not
# exist, we will rebuild anyway in that case.

targets := $(wildcard $(sort $(targets)))
cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))

ifneq ($(cmd_files),)
  include $(cmd_files)
endif