Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 1 | # ========================================================================== |
| 2 | # Building |
| 3 | # ========================================================================== |
| 4 | |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 5 | # Modified for U-Boot |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 6 | prefix := tpl |
| 7 | src := $(patsubst $(prefix)/%,%,$(obj)) |
| 8 | ifeq ($(obj),$(src)) |
| 9 | prefix := spl |
| 10 | src := $(patsubst $(prefix)/%,%,$(obj)) |
| 11 | ifeq ($(obj),$(src)) |
| 12 | prefix := . |
| 13 | endif |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 14 | endif |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 15 | |
| 16 | PHONY := __build |
| 17 | __build: |
| 18 | |
| 19 | # Init all relevant variables used in kbuild files so |
| 20 | # 1) they have correct type |
| 21 | # 2) they do not inherit any value from the environment |
| 22 | obj-y := |
| 23 | obj-m := |
| 24 | lib-y := |
| 25 | lib-m := |
| 26 | always := |
| 27 | targets := |
| 28 | subdir-y := |
| 29 | subdir-m := |
| 30 | EXTRA_AFLAGS := |
| 31 | EXTRA_CFLAGS := |
| 32 | EXTRA_CPPFLAGS := |
| 33 | EXTRA_LDFLAGS := |
| 34 | asflags-y := |
| 35 | ccflags-y := |
| 36 | cppflags-y := |
| 37 | ldflags-y := |
| 38 | |
| 39 | subdir-asflags-y := |
| 40 | subdir-ccflags-y := |
| 41 | |
| 42 | # Read auto.conf if it exists, otherwise ignore |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 43 | # Modified for U-Boot |
Masahiro Yamada | 72fb32b | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 44 | -include include/config/auto.conf |
Masahiro Yamada | 60bb734 | 2014-07-30 14:08:17 +0900 | [diff] [blame] | 45 | -include $(prefix)/include/autoconf.mk |
Masahiro Yamada | 72fb32b | 2015-02-24 22:26:20 +0900 | [diff] [blame] | 46 | include scripts/Makefile.uncmd_spl |
Masahiro Yamada | 5ac303c | 2014-02-04 17:24:32 +0900 | [diff] [blame] | 47 | |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 48 | include scripts/Kbuild.include |
| 49 | |
| 50 | # For backward compatibility check that these variables do not change |
| 51 | save-cflags := $(CFLAGS) |
| 52 | |
| 53 | # The filename Kbuild has precedence over Makefile |
| 54 | kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) |
| 55 | kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) |
| 56 | include $(kbuild-file) |
| 57 | |
Masahiro Yamada | 958fe8f | 2014-03-05 16:59:40 +0900 | [diff] [blame] | 58 | # Added for U-Boot |
| 59 | asflags-y += $(PLATFORM_CPPFLAGS) |
| 60 | ccflags-y += $(PLATFORM_CPPFLAGS) |
| 61 | cppflags-y += $(PLATFORM_CPPFLAGS) |
| 62 | |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 63 | # If the save-* variables changed error out |
| 64 | ifeq ($(KBUILD_NOPEDANTIC),) |
| 65 | ifneq ("$(save-cflags)","$(CFLAGS)") |
| 66 | $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use ccflags-y) |
| 67 | endif |
| 68 | endif |
| 69 | |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 70 | include scripts/Makefile.lib |
| 71 | |
| 72 | ifdef host-progs |
| 73 | ifneq ($(hostprogs-y),$(host-progs)) |
| 74 | $(warning kbuild: $(obj)/Makefile - Usage of host-progs is deprecated. Please replace with hostprogs-y!) |
| 75 | hostprogs-y += $(host-progs) |
| 76 | endif |
| 77 | endif |
| 78 | |
| 79 | # Do not include host rules unless needed |
| 80 | ifneq ($(hostprogs-y)$(hostprogs-m),) |
| 81 | include scripts/Makefile.host |
| 82 | endif |
| 83 | |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 84 | # Uncommented for U-Boot |
| 85 | # We need to create output dicrectory for SPL and TPL even for in-tree build |
| 86 | #ifneq ($(KBUILD_SRC),) |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 87 | # Create output directory if not already present |
| 88 | _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) |
| 89 | |
| 90 | # Create directories for object files if directory does not exist |
| 91 | # Needed when obj-y := dir/file.o syntax is used |
| 92 | _dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) |
Masahiro Yamada | 0d68fb1 | 2014-02-04 17:24:28 +0900 | [diff] [blame] | 93 | #endif |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 94 | |
| 95 | ifndef obj |
| 96 | $(warning kbuild: Makefile.build is included improperly) |
| 97 | endif |
| 98 | |
| 99 | # =========================================================================== |
| 100 | |
Masahiro Yamada | ede865b | 2014-10-30 11:06:13 +0900 | [diff] [blame] | 101 | ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 102 | lib-target := $(obj)/lib.a |
| 103 | endif |
| 104 | |
Masahiro Yamada | ede865b | 2014-10-30 11:06:13 +0900 | [diff] [blame] | 105 | ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),) |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 106 | builtin-target := $(obj)/built-in.o |
| 107 | endif |
| 108 | |
| 109 | modorder-target := $(obj)/modules.order |
| 110 | |
| 111 | # We keep a list of all modules in $(MODVERDIR) |
| 112 | |
| 113 | __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ |
| 114 | $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \ |
| 115 | $(subdir-ym) $(always) |
| 116 | @: |
| 117 | |
| 118 | # Linus' kernel sanity checking tool |
| 119 | ifneq ($(KBUILD_CHECKSRC),0) |
| 120 | ifeq ($(KBUILD_CHECKSRC),2) |
| 121 | quiet_cmd_force_checksrc = CHECK $< |
| 122 | cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; |
| 123 | else |
| 124 | quiet_cmd_checksrc = CHECK $< |
| 125 | cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; |
| 126 | endif |
| 127 | endif |
| 128 | |
| 129 | # Do section mismatch analysis for each module/built-in.o |
| 130 | ifdef CONFIG_DEBUG_SECTION_MISMATCH |
| 131 | cmd_secanalysis = ; scripts/mod/modpost $@ |
| 132 | endif |
| 133 | |
| 134 | # Compile C sources (.c) |
| 135 | # --------------------------------------------------------------------------- |
| 136 | |
| 137 | # Default is built-in, unless we know otherwise |
| 138 | modkern_cflags = \ |
| 139 | $(if $(part-of-module), \ |
| 140 | $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ |
| 141 | $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) |
| 142 | quiet_modtag := $(empty) $(empty) |
| 143 | |
| 144 | $(real-objs-m) : part-of-module := y |
| 145 | $(real-objs-m:.o=.i) : part-of-module := y |
| 146 | $(real-objs-m:.o=.s) : part-of-module := y |
| 147 | $(real-objs-m:.o=.lst): part-of-module := y |
| 148 | |
| 149 | $(real-objs-m) : quiet_modtag := [M] |
| 150 | $(real-objs-m:.o=.i) : quiet_modtag := [M] |
| 151 | $(real-objs-m:.o=.s) : quiet_modtag := [M] |
| 152 | $(real-objs-m:.o=.lst): quiet_modtag := [M] |
| 153 | |
| 154 | $(obj-m) : quiet_modtag := [M] |
| 155 | |
| 156 | # Default for not multi-part modules |
| 157 | modname = $(basetarget) |
| 158 | |
| 159 | $(multi-objs-m) : modname = $(modname-multi) |
| 160 | $(multi-objs-m:.o=.i) : modname = $(modname-multi) |
| 161 | $(multi-objs-m:.o=.s) : modname = $(modname-multi) |
| 162 | $(multi-objs-m:.o=.lst) : modname = $(modname-multi) |
| 163 | $(multi-objs-y) : modname = $(modname-multi) |
| 164 | $(multi-objs-y:.o=.i) : modname = $(modname-multi) |
| 165 | $(multi-objs-y:.o=.s) : modname = $(modname-multi) |
| 166 | $(multi-objs-y:.o=.lst) : modname = $(modname-multi) |
| 167 | |
| 168 | quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ |
Masahiro Yamada | 9cf2a45 | 2014-04-15 13:29:00 +0900 | [diff] [blame] | 169 | cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 170 | |
| 171 | $(obj)/%.s: $(src)/%.c FORCE |
| 172 | $(call if_changed_dep,cc_s_c) |
| 173 | |
| 174 | quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@ |
| 175 | cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $< |
| 176 | |
| 177 | $(obj)/%.i: $(src)/%.c FORCE |
| 178 | $(call if_changed_dep,cc_i_c) |
| 179 | |
| 180 | cmd_gensymtypes = \ |
| 181 | $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ |
| 182 | $(GENKSYMS) $(if $(1), -T $(2)) \ |
| 183 | $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ |
| 184 | $(if $(KBUILD_PRESERVE),-p) \ |
| 185 | -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) |
| 186 | |
| 187 | quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ |
| 188 | cmd_cc_symtypes_c = \ |
| 189 | set -e; \ |
| 190 | $(call cmd_gensymtypes,true,$@) >/dev/null; \ |
| 191 | test -s $@ || rm -f $@ |
| 192 | |
| 193 | $(obj)/%.symtypes : $(src)/%.c FORCE |
| 194 | $(call cmd,cc_symtypes_c) |
| 195 | |
| 196 | # C (.c) files |
| 197 | # The C file is compiled and updated dependency information is generated. |
| 198 | # (See cmd_cc_o_c + relevant part of rule_cc_o_c) |
| 199 | |
| 200 | quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ |
| 201 | |
| 202 | ifndef CONFIG_MODVERSIONS |
| 203 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< |
| 204 | |
| 205 | else |
| 206 | # When module versioning is enabled the following steps are executed: |
| 207 | # o compile a .tmp_<file>.o from <file>.c |
| 208 | # o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does |
| 209 | # not export symbols, we just rename .tmp_<file>.o to <file>.o and |
| 210 | # are done. |
| 211 | # o otherwise, we calculate symbol versions using the good old |
| 212 | # genksyms on the preprocessed source and postprocess them in a way |
| 213 | # that they are usable as a linker script |
| 214 | # o generate <file>.o from .tmp_<file>.o using the linker to |
| 215 | # replace the unresolved symbols __crc_exported_symbol with |
| 216 | # the actual value of the checksum generated by genksyms |
| 217 | |
| 218 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< |
| 219 | cmd_modversions = \ |
| 220 | if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ |
| 221 | $(call cmd_gensymtypes,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ |
| 222 | > $(@D)/.tmp_$(@F:.o=.ver); \ |
| 223 | \ |
| 224 | $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ |
| 225 | -T $(@D)/.tmp_$(@F:.o=.ver); \ |
| 226 | rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ |
| 227 | else \ |
| 228 | mv -f $(@D)/.tmp_$(@F) $@; \ |
| 229 | fi; |
| 230 | endif |
| 231 | |
| 232 | ifdef CONFIG_FTRACE_MCOUNT_RECORD |
| 233 | ifdef BUILD_C_RECORDMCOUNT |
| 234 | ifeq ("$(origin RECORDMCOUNT_WARN)", "command line") |
| 235 | RECORDMCOUNT_FLAGS = -w |
| 236 | endif |
| 237 | # Due to recursion, we must skip empty.o. |
| 238 | # The empty.o file is created in the make process in order to determine |
| 239 | # the target endianness and word size. It is made before all other C |
| 240 | # files, including recordmcount. |
| 241 | sub_cmd_record_mcount = \ |
| 242 | if [ $(@) != "scripts/mod/empty.o" ]; then \ |
| 243 | $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)"; \ |
| 244 | fi; |
| 245 | recordmcount_source := $(srctree)/scripts/recordmcount.c \ |
| 246 | $(srctree)/scripts/recordmcount.h |
| 247 | else |
| 248 | sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ |
| 249 | "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \ |
| 250 | "$(if $(CONFIG_64BIT),64,32)" \ |
| 251 | "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \ |
| 252 | "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ |
| 253 | "$(if $(part-of-module),1,0)" "$(@)"; |
| 254 | recordmcount_source := $(srctree)/scripts/recordmcount.pl |
| 255 | endif |
| 256 | cmd_record_mcount = \ |
| 257 | if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \ |
| 258 | $(sub_cmd_record_mcount) \ |
| 259 | fi; |
| 260 | endif |
| 261 | |
| 262 | define rule_cc_o_c |
| 263 | $(call echo-cmd,checksrc) $(cmd_checksrc) \ |
| 264 | $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ |
| 265 | $(cmd_modversions) \ |
| 266 | $(call echo-cmd,record_mcount) \ |
| 267 | $(cmd_record_mcount) \ |
| 268 | scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ |
| 269 | $(dot-target).tmp; \ |
| 270 | rm -f $(depfile); \ |
| 271 | mv -f $(dot-target).tmp $(dot-target).cmd |
| 272 | endef |
| 273 | |
| 274 | # Built-in and composite module parts |
| 275 | $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE |
| 276 | $(call cmd,force_checksrc) |
| 277 | $(call if_changed_rule,cc_o_c) |
| 278 | |
| 279 | # Single-part modules are special since we need to mark them in $(MODVERDIR) |
| 280 | |
| 281 | $(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE |
| 282 | $(call cmd,force_checksrc) |
| 283 | $(call if_changed_rule,cc_o_c) |
| 284 | @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) |
| 285 | |
| 286 | quiet_cmd_cc_lst_c = MKLST $@ |
| 287 | cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ |
| 288 | $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ |
| 289 | System.map $(OBJDUMP) > $@ |
| 290 | |
| 291 | $(obj)/%.lst: $(src)/%.c FORCE |
| 292 | $(call if_changed_dep,cc_lst_c) |
| 293 | |
| 294 | # Compile assembler sources (.S) |
| 295 | # --------------------------------------------------------------------------- |
| 296 | |
| 297 | modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) |
| 298 | |
| 299 | $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
| 300 | $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
| 301 | |
| 302 | quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ |
Masahiro Yamada | 33eb5e7 | 2014-06-16 18:56:38 +0900 | [diff] [blame] | 303 | cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 304 | |
| 305 | $(obj)/%.s: $(src)/%.S FORCE |
| 306 | $(call if_changed_dep,as_s_S) |
| 307 | |
| 308 | quiet_cmd_as_o_S = AS $(quiet_modtag) $@ |
| 309 | cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< |
| 310 | |
| 311 | $(obj)/%.o: $(src)/%.S FORCE |
| 312 | $(call if_changed_dep,as_o_S) |
| 313 | |
| 314 | targets += $(real-objs-y) $(real-objs-m) $(lib-y) |
| 315 | targets += $(extra-y) $(MAKECMDGOALS) $(always) |
| 316 | |
| 317 | # Linker scripts preprocessor (.lds.S -> .lds) |
| 318 | # --------------------------------------------------------------------------- |
| 319 | quiet_cmd_cpp_lds_S = LDS $@ |
| 320 | cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \ |
| 321 | -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $< |
| 322 | |
| 323 | $(obj)/%.lds: $(src)/%.lds.S FORCE |
| 324 | $(call if_changed_dep,cpp_lds_S) |
| 325 | |
| 326 | # ASN.1 grammar |
| 327 | # --------------------------------------------------------------------------- |
| 328 | quiet_cmd_asn1_compiler = ASN.1 $@ |
| 329 | cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \ |
| 330 | $(subst .h,.c,$@) $(subst .c,.h,$@) |
| 331 | |
| 332 | .PRECIOUS: $(objtree)/$(obj)/%-asn1.c $(objtree)/$(obj)/%-asn1.h |
| 333 | |
| 334 | $(obj)/%-asn1.c $(obj)/%-asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler |
| 335 | $(call cmd,asn1_compiler) |
| 336 | |
| 337 | # Build the compiled-in targets |
| 338 | # --------------------------------------------------------------------------- |
| 339 | |
| 340 | # To build objects in subdirs, we need to descend into the directories |
| 341 | $(sort $(subdir-obj-y)): $(subdir-ym) ; |
| 342 | |
| 343 | # |
| 344 | # Rule to compile a set of .o files into one .o file |
| 345 | # |
| 346 | ifdef builtin-target |
| 347 | quiet_cmd_link_o_target = LD $@ |
| 348 | # If the list of objects to link is empty, just create an empty built-in.o |
| 349 | cmd_link_o_target = $(if $(strip $(obj-y)),\ |
| 350 | $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \ |
| 351 | $(cmd_secanalysis),\ |
| 352 | rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@) |
| 353 | |
| 354 | $(builtin-target): $(obj-y) FORCE |
| 355 | $(call if_changed,link_o_target) |
| 356 | |
| 357 | targets += $(builtin-target) |
| 358 | endif # builtin-target |
| 359 | |
| 360 | # |
| 361 | # Rule to create modules.order file |
| 362 | # |
| 363 | # Create commands to either record .ko file or cat modules.order from |
| 364 | # a subdirectory |
| 365 | modorder-cmds = \ |
| 366 | $(foreach m, $(modorder), \ |
| 367 | $(if $(filter %/modules.order, $m), \ |
| 368 | cat $m;, echo kernel/$m;)) |
| 369 | |
| 370 | $(modorder-target): $(subdir-ym) FORCE |
| 371 | $(Q)(cat /dev/null; $(modorder-cmds)) > $@ |
| 372 | |
| 373 | # |
| 374 | # Rule to compile a set of .o files into one .a file |
| 375 | # |
| 376 | ifdef lib-target |
| 377 | quiet_cmd_link_l_target = AR $@ |
| 378 | cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y) |
| 379 | |
| 380 | $(lib-target): $(lib-y) FORCE |
| 381 | $(call if_changed,link_l_target) |
| 382 | |
| 383 | targets += $(lib-target) |
| 384 | endif |
| 385 | |
| 386 | # |
| 387 | # Rule to link composite objects |
| 388 | # |
| 389 | # Composite objects are specified in kbuild makefile as follows: |
| 390 | # <composite-object>-objs := <list of .o files> |
| 391 | # or |
| 392 | # <composite-object>-y := <list of .o files> |
| 393 | link_multi_deps = \ |
| 394 | $(filter $(addprefix $(obj)/, \ |
| 395 | $($(subst $(obj)/,,$(@:.o=-objs))) \ |
| 396 | $($(subst $(obj)/,,$(@:.o=-y)))), $^) |
Masahiro Yamada | 33eb5e7 | 2014-06-16 18:56:38 +0900 | [diff] [blame] | 397 | |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 398 | quiet_cmd_link_multi-y = LD $@ |
| 399 | cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis) |
| 400 | |
| 401 | quiet_cmd_link_multi-m = LD [M] $@ |
| 402 | cmd_link_multi-m = $(cmd_link_multi-y) |
| 403 | |
Masahiro Yamada | 8c4532f | 2014-10-30 11:06:10 +0900 | [diff] [blame] | 404 | $(multi-used-y): FORCE |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 405 | $(call if_changed,link_multi-y) |
Masahiro Yamada | 8c4532f | 2014-10-30 11:06:10 +0900 | [diff] [blame] | 406 | $(call multi_depend, $(multi-used-y), .o, -objs -y) |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 407 | |
Masahiro Yamada | 8c4532f | 2014-10-30 11:06:10 +0900 | [diff] [blame] | 408 | $(multi-used-m): FORCE |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 409 | $(call if_changed,link_multi-m) |
| 410 | @{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod) |
Masahiro Yamada | 8c4532f | 2014-10-30 11:06:10 +0900 | [diff] [blame] | 411 | $(call multi_depend, $(multi-used-m), .o, -objs -y) |
Masahiro Yamada | 47b65f7 | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 412 | |
| 413 | targets += $(multi-used-y) $(multi-used-m) |
| 414 | |
| 415 | |
| 416 | # Descending |
| 417 | # --------------------------------------------------------------------------- |
| 418 | |
| 419 | PHONY += $(subdir-ym) |
| 420 | $(subdir-ym): |
| 421 | $(Q)$(MAKE) $(build)=$@ |
| 422 | |
| 423 | # Add FORCE to the prequisites of a target to force it to be always rebuilt. |
| 424 | # --------------------------------------------------------------------------- |
| 425 | |
| 426 | PHONY += FORCE |
| 427 | |
| 428 | FORCE: |
| 429 | |
| 430 | # Read all saved command lines and dependencies for the $(targets) we |
| 431 | # may be building above, using $(if_changed{,_dep}). As an |
| 432 | # optimization, we don't need to read them if the target does not |
| 433 | # exist, we will rebuild anyway in that case. |
| 434 | |
| 435 | targets := $(wildcard $(sort $(targets))) |
| 436 | cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) |
| 437 | |
| 438 | ifneq ($(cmd_files),) |
| 439 | include $(cmd_files) |
| 440 | endif |
| 441 | |
| 442 | # Declare the contents of the .PHONY variable as phony. We keep that |
| 443 | # information in a variable se we can use it in if_changed and friends. |
| 444 | |
| 445 | .PHONY: $(PHONY) |