ia64/linux-2.6.18-xen.hg

annotate scripts/Makefile.modpost @ 562:66faefe721eb

pvSCSI backend driver

Signed-off-by: Tomonari Horikoshi <t.horikoshi@jp.fujitsu.com>
Signed-off-by: Jun Kamada <kama@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jun 02 09:58:27 2008 +0100 (2008-06-02)
parents 831230e53067
children
rev   line source
ian@0 1 # ===========================================================================
ian@0 2 # Module versions
ian@0 3 # ===========================================================================
ian@0 4 #
ian@0 5 # Stage one of module building created the following:
ian@0 6 # a) The individual .o files used for the module
ian@0 7 # b) A <module>.o file which is the .o files above linked together
ian@0 8 # c) A <module>.mod file in $(MODVERDIR)/, listing the name of the
ian@0 9 # the preliminary <module>.o file, plus all .o files
ian@0 10
ian@0 11 # Stage 2 is handled by this file and does the following
ian@0 12 # 1) Find all modules from the files listed in $(MODVERDIR)/
ian@0 13 # 2) modpost is then used to
ian@0 14 # 3) create one <module>.mod.c file pr. module
ian@0 15 # 4) create one Module.symvers file with CRC for all exported symbols
ian@0 16 # 5) compile all <module>.mod.c files
ian@0 17 # 6) final link of the module to a <module.ko> file
ian@0 18
ian@0 19 # Step 3 is used to place certain information in the module's ELF
ian@0 20 # section, including information such as:
ian@0 21 # Version magic (see include/vermagic.h for full details)
ian@0 22 # - Kernel release
ian@0 23 # - SMP is CONFIG_SMP
ian@0 24 # - PREEMPT is CONFIG_PREEMPT
ian@0 25 # - GCC Version
ian@0 26 # Module info
ian@0 27 # - Module version (MODULE_VERSION)
ian@0 28 # - Module alias'es (MODULE_ALIAS)
ian@0 29 # - Module license (MODULE_LICENSE)
ian@0 30 # - See include/linux/module.h for more details
ian@0 31
ian@0 32 # Step 4 is solely used to allow module versioning in external modules,
ian@0 33 # where the CRC of each module is retrieved from the Module.symers file.
ian@0 34
ian@0 35 PHONY := _modpost
ian@0 36 _modpost: __modpost
ian@0 37
ian@0 38 include include/config/auto.conf
ian@0 39 include scripts/Kbuild.include
ian@0 40 include scripts/Makefile.lib
ian@0 41
ian@0 42 kernelsymfile := $(objtree)/Module.symvers
ian@0 43 modulesymfile := $(KBUILD_EXTMOD)/Module.symvers
ian@0 44
ian@0 45 # Step 1), find all modules listed in $(MODVERDIR)/
ian@0 46 __modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
ian@0 47 modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o)))
ian@0 48
ian@0 49 _modpost: $(modules)
ian@0 50
ian@0 51
ian@0 52 # Step 2), invoke modpost
ian@0 53 # Includes step 3,4
ian@0 54 quiet_cmd_modpost = MODPOST
ian@0 55 cmd_modpost = scripts/mod/modpost \
ian@0 56 $(if $(CONFIG_MODVERSIONS),-m) \
ian@0 57 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \
ian@0 58 $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
ian@0 59 $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
ian@0 60 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
ian@0 61 $(filter-out FORCE,$^)
ian@0 62
ian@0 63 PHONY += __modpost
ian@0 64 __modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE
ian@0 65 $(call cmd,modpost)
ian@0 66
ian@0 67 # Declare generated files as targets for modpost
ian@0 68 $(symverfile): __modpost ;
ian@0 69 $(modules:.ko=.mod.c): __modpost ;
ian@0 70
ian@0 71
ian@0 72 # Step 5), compile all *.mod.c files
ian@0 73
ian@0 74 # modname is set to make c_flags define KBUILD_MODNAME
ian@0 75 modname = $(notdir $(@:.mod.o=))
ian@0 76
ian@0 77 quiet_cmd_cc_o_c = CC $@
ian@0 78 cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \
ian@0 79 -c -o $@ $<
ian@0 80
ian@0 81 $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
ian@0 82 $(call if_changed_dep,cc_o_c)
ian@0 83
ian@0 84 targets += $(modules:.ko=.mod.o)
ian@0 85
ian@0 86 # Step 6), final link of the modules
ian@0 87 quiet_cmd_ld_ko_o = LD [M] $@
ian@0 88 cmd_ld_ko_o = $(LD) $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \
ian@0 89 $(filter-out FORCE,$^)
ian@0 90
ian@0 91 $(modules): %.ko :%.o %.mod.o FORCE
ian@0 92 $(call if_changed,ld_ko_o)
ian@0 93
ian@0 94 targets += $(modules)
ian@0 95
ian@0 96
ian@0 97 # Add FORCE to the prequisites of a target to force it to be always rebuilt.
ian@0 98 # ---------------------------------------------------------------------------
ian@0 99
ian@0 100 PHONY += FORCE
ian@0 101
ian@0 102 FORCE:
ian@0 103
ian@0 104 # Read all saved command lines and dependencies for the $(targets) we
ian@0 105 # may be building above, using $(if_changed{,_dep}). As an
ian@0 106 # optimization, we don't need to read them if the target does not
ian@0 107 # exist, we will rebuild anyway in that case.
ian@0 108
ian@0 109 targets := $(wildcard $(sort $(targets)))
ian@0 110 cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
ian@0 111
ian@0 112 ifneq ($(cmd_files),)
ian@0 113 include $(cmd_files)
ian@0 114 endif
ian@0 115
ian@0 116
ian@0 117 # Declare the contents of the .PHONY variable as phony. We keep that
ian@0 118 # information in a variable se we can use it in if_changed and friends.
ian@0 119
ian@0 120 .PHONY: $(PHONY)