Back to home page

LXR

 
 

    


0001 # ==========================================================================
0002 # Building
0003 # ==========================================================================
0004 
0005 src := $(obj)
0006 
0007 PHONY := __build
0008 __build:
0009 
0010 # Init all relevant variables used in kbuild files so
0011 # 1) they have correct type
0012 # 2) they do not inherit any value from the environment
0013 obj-y :=
0014 obj-m :=
0015 lib-y :=
0016 lib-m :=
0017 always :=
0018 targets :=
0019 subdir-y :=
0020 subdir-m :=
0021 EXTRA_AFLAGS   :=
0022 EXTRA_CFLAGS   :=
0023 EXTRA_CPPFLAGS :=
0024 EXTRA_LDFLAGS  :=
0025 asflags-y  :=
0026 ccflags-y  :=
0027 cppflags-y :=
0028 ldflags-y  :=
0029 
0030 subdir-asflags-y :=
0031 subdir-ccflags-y :=
0032 
0033 # Read auto.conf if it exists, otherwise ignore
0034 -include include/config/auto.conf
0035 
0036 include scripts/Kbuild.include
0037 
0038 # For backward compatibility check that these variables do not change
0039 save-cflags := $(CFLAGS)
0040 
0041 # The filename Kbuild has precedence over Makefile
0042 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
0043 kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
0044 include $(kbuild-file)
0045 
0046 # If the save-* variables changed error out
0047 ifeq ($(KBUILD_NOPEDANTIC),)
0048         ifneq ("$(save-cflags)","$(CFLAGS)")
0049                 $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use ccflags-y)
0050         endif
0051 endif
0052 
0053 include scripts/Makefile.lib
0054 
0055 ifdef host-progs
0056 ifneq ($(hostprogs-y),$(host-progs))
0057 $(warning kbuild: $(obj)/Makefile - Usage of host-progs is deprecated. Please replace with hostprogs-y!)
0058 hostprogs-y += $(host-progs)
0059 endif
0060 endif
0061 
0062 # Do not include host rules unless needed
0063 ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
0064 include scripts/Makefile.host
0065 endif
0066 
0067 ifneq ($(KBUILD_SRC),)
0068 # Create output directory if not already present
0069 _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
0070 
0071 # Create directories for object files if directory does not exist
0072 # Needed when obj-y := dir/file.o syntax is used
0073 _dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
0074 endif
0075 
0076 ifndef obj
0077 $(warning kbuild: Makefile.build is included improperly)
0078 endif
0079 
0080 # ===========================================================================
0081 
0082 ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
0083 lib-target := $(obj)/lib.a
0084 obj-y += $(obj)/lib-ksyms.o
0085 endif
0086 
0087 ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
0088 builtin-target := $(obj)/built-in.o
0089 endif
0090 
0091 modorder-target := $(obj)/modules.order
0092 
0093 # We keep a list of all modules in $(MODVERDIR)
0094 
0095 __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
0096          $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \
0097          $(subdir-ym) $(always)
0098         @:
0099 
0100 # Linus' kernel sanity checking tool
0101 ifneq ($(KBUILD_CHECKSRC),0)
0102   ifeq ($(KBUILD_CHECKSRC),2)
0103     quiet_cmd_force_checksrc = CHECK   $<
0104           cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
0105   else
0106       quiet_cmd_checksrc     = CHECK   $<
0107             cmd_checksrc     = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ;
0108   endif
0109 endif
0110 
0111 # Do section mismatch analysis for each module/built-in.o
0112 ifdef CONFIG_DEBUG_SECTION_MISMATCH
0113   cmd_secanalysis = ; scripts/mod/modpost $@
0114 endif
0115 
0116 # Compile C sources (.c)
0117 # ---------------------------------------------------------------------------
0118 
0119 # Default is built-in, unless we know otherwise
0120 modkern_cflags =                                          \
0121         $(if $(part-of-module),                           \
0122                 $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
0123                 $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
0124 quiet_modtag := $(empty)   $(empty)
0125 
0126 $(real-objs-m)        : part-of-module := y
0127 $(real-objs-m:.o=.i)  : part-of-module := y
0128 $(real-objs-m:.o=.s)  : part-of-module := y
0129 $(real-objs-m:.o=.lst): part-of-module := y
0130 
0131 $(real-objs-m)        : quiet_modtag := [M]
0132 $(real-objs-m:.o=.i)  : quiet_modtag := [M]
0133 $(real-objs-m:.o=.s)  : quiet_modtag := [M]
0134 $(real-objs-m:.o=.lst): quiet_modtag := [M]
0135 
0136 $(obj-m)              : quiet_modtag := [M]
0137 
0138 # Default for not multi-part modules
0139 modname = $(basetarget)
0140 
0141 $(multi-objs-m)         : modname = $(modname-multi)
0142 $(multi-objs-m:.o=.i)   : modname = $(modname-multi)
0143 $(multi-objs-m:.o=.s)   : modname = $(modname-multi)
0144 $(multi-objs-m:.o=.lst) : modname = $(modname-multi)
0145 $(multi-objs-y)         : modname = $(modname-multi)
0146 $(multi-objs-y:.o=.i)   : modname = $(modname-multi)
0147 $(multi-objs-y:.o=.s)   : modname = $(modname-multi)
0148 $(multi-objs-y:.o=.lst) : modname = $(modname-multi)
0149 
0150 quiet_cmd_cc_s_c = CC $(quiet_modtag)  $@
0151 cmd_cc_s_c       = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
0152 
0153 $(obj)/%.s: $(src)/%.c FORCE
0154         $(call if_changed_dep,cc_s_c)
0155 
0156 quiet_cmd_cpp_i_c = CPP $(quiet_modtag) $@
0157 cmd_cpp_i_c       = $(CPP) $(c_flags) -o $@ $<
0158 
0159 $(obj)/%.i: $(src)/%.c FORCE
0160         $(call if_changed_dep,cpp_i_c)
0161 
0162 # These mirror gensymtypes_S and co below, keep them in synch.
0163 cmd_gensymtypes_c =                                                         \
0164     $(CPP) -D__GENKSYMS__ $(c_flags) $< |                                   \
0165     $(GENKSYMS) $(if $(1), -T $(2))                                         \
0166      $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX))             \
0167      $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS))                             \
0168      $(if $(KBUILD_PRESERVE),-p)                                            \
0169      -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
0170 
0171 quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
0172 cmd_cc_symtypes_c =                                                         \
0173     set -e;                                                                 \
0174     $(call cmd_gensymtypes_c,true,$@) >/dev/null;                           \
0175     test -s $@ || rm -f $@
0176 
0177 $(obj)/%.symtypes : $(src)/%.c FORCE
0178         $(call cmd,cc_symtypes_c)
0179 
0180 # C (.c) files
0181 # The C file is compiled and updated dependency information is generated.
0182 # (See cmd_cc_o_c + relevant part of rule_cc_o_c)
0183 
0184 quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
0185 
0186 ifndef CONFIG_MODVERSIONS
0187 cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
0188 
0189 else
0190 # When module versioning is enabled the following steps are executed:
0191 # o compile a .tmp_<file>.o from <file>.c
0192 # o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does
0193 #   not export symbols, we just rename .tmp_<file>.o to <file>.o and
0194 #   are done.
0195 # o otherwise, we calculate symbol versions using the good old
0196 #   genksyms on the preprocessed source and postprocess them in a way
0197 #   that they are usable as a linker script
0198 # o generate <file>.o from .tmp_<file>.o using the linker to
0199 #   replace the unresolved symbols __crc_exported_symbol with
0200 #   the actual value of the checksum generated by genksyms
0201 
0202 cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
0203 
0204 cmd_modversions_c =                                                             \
0205         if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then             \
0206                 $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes))  \
0207                     > $(@D)/.tmp_$(@F:.o=.ver);                                 \
0208                                                                                 \
0209                 $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F)                      \
0210                         -T $(@D)/.tmp_$(@F:.o=.ver);                            \
0211                 rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver);                \
0212         else                                                                    \
0213                 mv -f $(@D)/.tmp_$(@F) $@;                                      \
0214         fi;
0215 endif
0216 
0217 ifdef CONFIG_FTRACE_MCOUNT_RECORD
0218 ifdef BUILD_C_RECORDMCOUNT
0219 ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
0220   RECORDMCOUNT_FLAGS = -w
0221 endif
0222 # Due to recursion, we must skip empty.o.
0223 # The empty.o file is created in the make process in order to determine
0224 #  the target endianness and word size. It is made before all other C
0225 #  files, including recordmcount.
0226 sub_cmd_record_mcount =                                 \
0227         if [ $(@) != "scripts/mod/empty.o" ]; then      \
0228                 $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)";   \
0229         fi;
0230 recordmcount_source := $(srctree)/scripts/recordmcount.c \
0231                     $(srctree)/scripts/recordmcount.h
0232 else
0233 sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
0234         "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
0235         "$(if $(CONFIG_64BIT),64,32)" \
0236         "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \
0237         "$(LD)" "$(NM)" "$(RM)" "$(MV)" \
0238         "$(if $(part-of-module),1,0)" "$(@)";
0239 recordmcount_source := $(srctree)/scripts/recordmcount.pl
0240 endif
0241 cmd_record_mcount =                                             \
0242         if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" =   \
0243              "$(CC_FLAGS_FTRACE)" ]; then                       \
0244                 $(sub_cmd_record_mcount)                        \
0245         fi;
0246 endif
0247 
0248 ifdef CONFIG_STACK_VALIDATION
0249 ifneq ($(SKIP_STACK_VALIDATION),1)
0250 
0251 __objtool_obj := $(objtree)/tools/objtool/objtool
0252 
0253 objtool_args = check
0254 ifndef CONFIG_FRAME_POINTER
0255 objtool_args += --no-fp
0256 endif
0257 
0258 # 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
0259 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
0260 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
0261 cmd_objtool = $(if $(patsubst y%,, \
0262         $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
0263         $(__objtool_obj) $(objtool_args) "$(@)";)
0264 objtool_obj = $(if $(patsubst y%,, \
0265         $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
0266         $(__objtool_obj))
0267 
0268 endif # SKIP_STACK_VALIDATION
0269 endif # CONFIG_STACK_VALIDATION
0270 
0271 define rule_cc_o_c
0272         $(call echo-cmd,checksrc) $(cmd_checksrc)                         \
0273         $(call cmd_and_fixdep,cc_o_c)                                     \
0274         $(cmd_modversions_c)                                              \
0275         $(cmd_objtool)                                                    \
0276         $(call echo-cmd,record_mcount) $(cmd_record_mcount)
0277 endef
0278 
0279 define rule_as_o_S
0280         $(call cmd_and_fixdep,as_o_S)                                     \
0281         $(cmd_modversions_S)                                              \
0282         $(cmd_objtool)
0283 endef
0284 
0285 # List module undefined symbols (or empty line if not enabled)
0286 ifdef CONFIG_TRIM_UNUSED_KSYMS
0287 cmd_undef_syms = $(NM) $@ | sed -n 's/^ \+U //p' | xargs echo
0288 else
0289 cmd_undef_syms = echo
0290 endif
0291 
0292 # Built-in and composite module parts
0293 $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE
0294         $(call cmd,force_checksrc)
0295         $(call if_changed_rule,cc_o_c)
0296 
0297 # Single-part modules are special since we need to mark them in $(MODVERDIR)
0298 
0299 $(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_obj) FORCE
0300         $(call cmd,force_checksrc)
0301         $(call if_changed_rule,cc_o_c)
0302         @{ echo $(@:.o=.ko); echo $@; \
0303            $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
0304 
0305 quiet_cmd_cc_lst_c = MKLST   $@
0306       cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
0307                      $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
0308                                      System.map $(OBJDUMP) > $@
0309 
0310 $(obj)/%.lst: $(src)/%.c FORCE
0311         $(call if_changed_dep,cc_lst_c)
0312 
0313 # Compile assembler sources (.S)
0314 # ---------------------------------------------------------------------------
0315 
0316 modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)
0317 
0318 $(real-objs-m)      : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
0319 $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
0320 
0321 # .S file exports must have their C prototypes defined in asm/asm-prototypes.h
0322 # or a file that it includes, in order to get versioned symbols. We build a
0323 # dummy C file that includes asm-prototypes and the EXPORT_SYMBOL lines from
0324 # the .S file (with trailing ';'), and run genksyms on that, to extract vers.
0325 #
0326 # This is convoluted. The .S file must first be preprocessed to run guards and
0327 # expand names, then the resulting exports must be constructed into plain
0328 # EXPORT_SYMBOL(symbol); to build our dummy C file, and that gets preprocessed
0329 # to make the genksyms input.
0330 #
0331 # These mirror gensymtypes_c and co above, keep them in synch.
0332 cmd_gensymtypes_S =                                                         \
0333     (echo "\#include <linux/kernel.h>" ;                                    \
0334      echo "\#include <asm/asm-prototypes.h>" ;                              \
0335     $(CPP) $(a_flags) $< |                                                  \
0336      grep "\<___EXPORT_SYMBOL\>" |                                          \
0337      sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ) | \
0338     $(CPP) -D__GENKSYMS__ $(c_flags) -xc - |                                \
0339     $(GENKSYMS) $(if $(1), -T $(2))                                         \
0340      $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX))             \
0341      $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS))                             \
0342      $(if $(KBUILD_PRESERVE),-p)                                            \
0343      -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
0344 
0345 quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@
0346 cmd_cc_symtypes_S =                                                         \
0347     set -e;                                                                 \
0348     $(call cmd_gensymtypes_S,true,$@) >/dev/null;                           \
0349     test -s $@ || rm -f $@
0350 
0351 $(obj)/%.symtypes : $(src)/%.S FORCE
0352         $(call cmd,cc_symtypes_S)
0353 
0354 
0355 quiet_cmd_cpp_s_S = CPP $(quiet_modtag) $@
0356 cmd_cpp_s_S       = $(CPP) $(a_flags) -o $@ $<
0357 
0358 $(obj)/%.s: $(src)/%.S FORCE
0359         $(call if_changed_dep,cpp_s_S)
0360 
0361 quiet_cmd_as_o_S = AS $(quiet_modtag)  $@
0362 
0363 ifndef CONFIG_MODVERSIONS
0364 cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
0365 
0366 else
0367 
0368 ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h)
0369 
0370 ifeq ($(ASM_PROTOTYPES),)
0371 cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
0372 
0373 else
0374 
0375 # versioning matches the C process described above, with difference that
0376 # we parse asm-prototypes.h C header to get function definitions.
0377 
0378 cmd_as_o_S = $(CC) $(a_flags) -c -o $(@D)/.tmp_$(@F) $<
0379 
0380 cmd_modversions_S =                                                             \
0381         if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then             \
0382                 $(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes))  \
0383                     > $(@D)/.tmp_$(@F:.o=.ver);                                 \
0384                                                                                 \
0385                 $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F)                      \
0386                         -T $(@D)/.tmp_$(@F:.o=.ver);                            \
0387                 rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver);                \
0388         else                                                                    \
0389                 mv -f $(@D)/.tmp_$(@F) $@;                                      \
0390         fi;
0391 endif
0392 endif
0393 
0394 $(obj)/%.o: $(src)/%.S $(objtool_obj) FORCE
0395         $(call if_changed_rule,as_o_S)
0396 
0397 targets += $(real-objs-y) $(real-objs-m) $(lib-y)
0398 targets += $(extra-y) $(MAKECMDGOALS) $(always)
0399 
0400 # Linker scripts preprocessor (.lds.S -> .lds)
0401 # ---------------------------------------------------------------------------
0402 quiet_cmd_cpp_lds_S = LDS     $@
0403       cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
0404                              -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
0405 
0406 $(obj)/%.lds: $(src)/%.lds.S FORCE
0407         $(call if_changed_dep,cpp_lds_S)
0408 
0409 # ASN.1 grammar
0410 # ---------------------------------------------------------------------------
0411 quiet_cmd_asn1_compiler = ASN.1   $@
0412       cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \
0413                                 $(subst .h,.c,$@) $(subst .c,.h,$@)
0414 
0415 .PRECIOUS: $(objtree)/$(obj)/%-asn1.c $(objtree)/$(obj)/%-asn1.h
0416 
0417 $(obj)/%-asn1.c $(obj)/%-asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
0418         $(call cmd,asn1_compiler)
0419 
0420 # Build the compiled-in targets
0421 # ---------------------------------------------------------------------------
0422 
0423 # To build objects in subdirs, we need to descend into the directories
0424 $(sort $(subdir-obj-y)): $(subdir-ym) ;
0425 
0426 #
0427 # Rule to compile a set of .o files into one .o file
0428 #
0429 ifdef builtin-target
0430 
0431 ifdef CONFIG_THIN_ARCHIVES
0432   cmd_make_builtin = rm -f $@; $(AR) rcST$(KBUILD_ARFLAGS)
0433   cmd_make_empty_builtin = rm -f $@; $(AR) rcST$(KBUILD_ARFLAGS)
0434   quiet_cmd_link_o_target = AR      $@
0435 else
0436   cmd_make_builtin = $(LD) $(ld_flags) -r -o
0437   cmd_make_empty_builtin = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS)
0438   quiet_cmd_link_o_target = LD      $@
0439 endif
0440 
0441 # If the list of objects to link is empty, just create an empty built-in.o
0442 cmd_link_o_target = $(if $(strip $(obj-y)),\
0443                       $(cmd_make_builtin) $@ $(filter $(obj-y), $^) \
0444                       $(cmd_secanalysis),\
0445                       $(cmd_make_empty_builtin) $@)
0446 
0447 $(builtin-target): $(obj-y) FORCE
0448         $(call if_changed,link_o_target)
0449 
0450 targets += $(builtin-target)
0451 endif # builtin-target
0452 
0453 #
0454 # Rule to create modules.order file
0455 #
0456 # Create commands to either record .ko file or cat modules.order from
0457 # a subdirectory
0458 modorder-cmds =                                         \
0459         $(foreach m, $(modorder),                       \
0460                 $(if $(filter %/modules.order, $m),     \
0461                         cat $m;, echo kernel/$m;))
0462 
0463 $(modorder-target): $(subdir-ym) FORCE
0464         $(Q)(cat /dev/null; $(modorder-cmds)) > $@
0465 
0466 #
0467 # Rule to compile a set of .o files into one .a file
0468 #
0469 ifdef lib-target
0470 quiet_cmd_link_l_target = AR      $@
0471 
0472 ifdef CONFIG_THIN_ARCHIVES
0473   cmd_link_l_target = rm -f $@; $(AR) rcsT$(KBUILD_ARFLAGS) $@ $(lib-y)
0474 else
0475   cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y)
0476 endif
0477 
0478 $(lib-target): $(lib-y) FORCE
0479         $(call if_changed,link_l_target)
0480 
0481 targets += $(lib-target)
0482 
0483 dummy-object = $(obj)/.lib_exports.o
0484 ksyms-lds = $(dot-target).lds
0485 ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
0486 ref_prefix = EXTERN(_
0487 else
0488 ref_prefix = EXTERN(
0489 endif
0490 
0491 quiet_cmd_export_list = EXPORTS $@
0492 cmd_export_list = $(OBJDUMP) -h $< | \
0493         sed -ne '/___ksymtab/s/.*+\([^ ]*\).*/$(ref_prefix)\1)/p' >$(ksyms-lds);\
0494         rm -f $(dummy-object);\
0495         echo | $(CC) $(a_flags) -c -o $(dummy-object) -x assembler -;\
0496         $(LD) $(ld_flags) -r -o $@ -T $(ksyms-lds) $(dummy-object);\
0497         rm $(dummy-object) $(ksyms-lds)
0498 
0499 $(obj)/lib-ksyms.o: $(lib-target) FORCE
0500         $(call if_changed,export_list)
0501 
0502 targets += $(obj)/lib-ksyms.o
0503 
0504 endif
0505 
0506 #
0507 # Rule to link composite objects
0508 #
0509 #  Composite objects are specified in kbuild makefile as follows:
0510 #    <composite-object>-objs := <list of .o files>
0511 #  or
0512 #    <composite-object>-y    := <list of .o files>
0513 #  or
0514 #    <composite-object>-m    := <list of .o files>
0515 #  The -m syntax only works if <composite object> is a module
0516 link_multi_deps =                     \
0517 $(filter $(addprefix $(obj)/,         \
0518 $($(subst $(obj)/,,$(@:.o=-objs)))    \
0519 $($(subst $(obj)/,,$(@:.o=-y)))       \
0520 $($(subst $(obj)/,,$(@:.o=-m)))), $^)
0521 
0522 cmd_link_multi-link = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
0523 
0524 ifdef CONFIG_THIN_ARCHIVES
0525   quiet_cmd_link_multi-y = AR      $@
0526   cmd_link_multi-y = rm -f $@; $(AR) rcST$(KBUILD_ARFLAGS) $@ $(link_multi_deps)
0527 else
0528   quiet_cmd_link_multi-y = LD      $@
0529   cmd_link_multi-y = $(cmd_link_multi-link)
0530 endif
0531 
0532 quiet_cmd_link_multi-m = LD [M]  $@
0533 cmd_link_multi-m = $(cmd_link_multi-link)
0534 
0535 $(multi-used-y): FORCE
0536         $(call if_changed,link_multi-y)
0537 $(call multi_depend, $(multi-used-y), .o, -objs -y)
0538 
0539 $(multi-used-m): FORCE
0540         $(call if_changed,link_multi-m)
0541         @{ echo $(@:.o=.ko); echo $(link_multi_deps); \
0542            $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
0543 $(call multi_depend, $(multi-used-m), .o, -objs -y -m)
0544 
0545 targets += $(multi-used-y) $(multi-used-m)
0546 
0547 
0548 # Descending
0549 # ---------------------------------------------------------------------------
0550 
0551 PHONY += $(subdir-ym)
0552 $(subdir-ym):
0553         $(Q)$(MAKE) $(build)=$@
0554 
0555 # Add FORCE to the prequisites of a target to force it to be always rebuilt.
0556 # ---------------------------------------------------------------------------
0557 
0558 PHONY += FORCE
0559 
0560 FORCE:
0561 
0562 # Read all saved command lines and dependencies for the $(targets) we
0563 # may be building above, using $(if_changed{,_dep}). As an
0564 # optimization, we don't need to read them if the target does not
0565 # exist, we will rebuild anyway in that case.
0566 
0567 targets := $(wildcard $(sort $(targets)))
0568 cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
0569 
0570 ifneq ($(cmd_files),)
0571   include $(cmd_files)
0572 endif
0573 
0574 # Declare the contents of the .PHONY variable as phony.  We keep that
0575 # information in a variable se we can use it in if_changed and friends.
0576 
0577 .PHONY: $(PHONY)