Makefile.build (f7adc3124da019878186f1ebe98a13a1af041afd) | Makefile.build (3a025e1d1c2ea42fa497c9c6b21c284e0f69e28b) |
---|---|
1# SPDX-License-Identifier: GPL-2.0 | |
2# ========================================================================== 3# Building 4# ========================================================================== 5 6src := $(obj) 7 8PHONY := __build 9__build: --- 50 unchanged lines hidden (view full) --- 60endif 61endif 62 63# Do not include host rules unless needed 64ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),) 65include scripts/Makefile.host 66endif 67 | 1# ========================================================================== 2# Building 3# ========================================================================== 4 5src := $(obj) 6 7PHONY := __build 8__build: --- 50 unchanged lines hidden (view full) --- 59endif 60endif 61 62# Do not include host rules unless needed 63ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),) 64include scripts/Makefile.host 65endif 66 |
67ifneq ($(KBUILD_SRC),) 68# Create output directory if not already present 69_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) 70 71# Create directories for object files if directory does not exist 72# Needed when obj-y := dir/file.o syntax is used 73_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) 74endif 75 |
|
68ifndef obj 69$(warning kbuild: Makefile.build is included improperly) 70endif 71 72# =========================================================================== 73 74ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) 75lib-target := $(obj)/lib.a 76obj-y += $(obj)/lib-ksyms.o 77endif 78 | 76ifndef obj 77$(warning kbuild: Makefile.build is included improperly) 78endif 79 80# =========================================================================== 81 82ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) 83lib-target := $(obj)/lib.a 84obj-y += $(obj)/lib-ksyms.o 85endif 86 |
79ifneq ($(strip $(obj-y) $(need-builtin)),) | 87ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),) |
80builtin-target := $(obj)/built-in.o 81endif 82 83modorder-target := $(obj)/modules.order 84 85# We keep a list of all modules in $(MODVERDIR) 86 87__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ --- 7 unchanged lines hidden (view full) --- 95 quiet_cmd_force_checksrc = CHECK $< 96 cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; 97 else 98 quiet_cmd_checksrc = CHECK $< 99 cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; 100 endif 101endif 102 | 88builtin-target := $(obj)/built-in.o 89endif 90 91modorder-target := $(obj)/modules.order 92 93# We keep a list of all modules in $(MODVERDIR) 94 95__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ --- 7 unchanged lines hidden (view full) --- 103 quiet_cmd_force_checksrc = CHECK $< 104 cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; 105 else 106 quiet_cmd_checksrc = CHECK $< 107 cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; 108 endif 109endif 110 |
111ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) 112 cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< ; 113endif 114 |
|
103# Do section mismatch analysis for each module/built-in.o 104ifdef CONFIG_DEBUG_SECTION_MISMATCH 105 cmd_secanalysis = ; scripts/mod/modpost $@ 106endif 107 108# Compile C sources (.c) 109# --------------------------------------------------------------------------- 110 --- 134 unchanged lines hidden (view full) --- 245 fi; 246endif # CONFIG_FTRACE_MCOUNT_RECORD 247 248ifdef CONFIG_STACK_VALIDATION 249ifneq ($(SKIP_STACK_VALIDATION),1) 250 251__objtool_obj := $(objtree)/tools/objtool/objtool 252 | 115# Do section mismatch analysis for each module/built-in.o 116ifdef CONFIG_DEBUG_SECTION_MISMATCH 117 cmd_secanalysis = ; scripts/mod/modpost $@ 118endif 119 120# Compile C sources (.c) 121# --------------------------------------------------------------------------- 122 --- 134 unchanged lines hidden (view full) --- 257 fi; 258endif # CONFIG_FTRACE_MCOUNT_RECORD 259 260ifdef CONFIG_STACK_VALIDATION 261ifneq ($(SKIP_STACK_VALIDATION),1) 262 263__objtool_obj := $(objtree)/tools/objtool/objtool 264 |
253objtool_args = $(if $(CONFIG_UNWINDER_ORC),orc generate,check) | 265objtool_args = $(if $(CONFIG_ORC_UNWINDER),orc generate,check) |
254 255ifndef CONFIG_FRAME_POINTER 256objtool_args += --no-fp 257endif 258ifdef CONFIG_GCOV_KERNEL 259objtool_args += --no-unreachable | 266 267ifndef CONFIG_FRAME_POINTER 268objtool_args += --no-fp 269endif 270ifdef CONFIG_GCOV_KERNEL 271objtool_args += --no-unreachable |
260else 261objtool_args += $(call cc-ifversion, -lt, 0405, --no-unreachable) | |
262endif 263 264# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory 265# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file 266# 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file 267cmd_objtool = $(if $(patsubst y%,, \ 268 $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \ 269 $(__objtool_obj) $(objtool_args) "$(@)";) --- 8 unchanged lines hidden (view full) --- 278objtool_dep = $(objtool_obj) \ 279 $(wildcard include/config/orc/unwinder.h \ 280 include/config/stack/validation.h) 281 282define rule_cc_o_c 283 $(call echo-cmd,checksrc) $(cmd_checksrc) \ 284 $(call cmd_and_fixdep,cc_o_c) \ 285 $(cmd_modversions_c) \ | 272endif 273 274# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory 275# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file 276# 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file 277cmd_objtool = $(if $(patsubst y%,, \ 278 $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \ 279 $(__objtool_obj) $(objtool_args) "$(@)";) --- 8 unchanged lines hidden (view full) --- 288objtool_dep = $(objtool_obj) \ 289 $(wildcard include/config/orc/unwinder.h \ 290 include/config/stack/validation.h) 291 292define rule_cc_o_c 293 $(call echo-cmd,checksrc) $(cmd_checksrc) \ 294 $(call cmd_and_fixdep,cc_o_c) \ 295 $(cmd_modversions_c) \ |
296 $(cmd_checkdoc) \ |
|
286 $(call echo-cmd,objtool) $(cmd_objtool) \ 287 $(call echo-cmd,record_mcount) $(cmd_record_mcount) 288endef 289 290define rule_as_o_S 291 $(call cmd_and_fixdep,as_o_S) \ 292 $(cmd_modversions_S) \ 293 $(call echo-cmd,objtool) $(cmd_objtool) --- 112 unchanged lines hidden (view full) --- 406 $(call if_changed_rule,as_o_S) 407 408targets += $(real-objs-y) $(real-objs-m) $(lib-y) 409targets += $(extra-y) $(MAKECMDGOALS) $(always) 410 411# Linker scripts preprocessor (.lds.S -> .lds) 412# --------------------------------------------------------------------------- 413quiet_cmd_cpp_lds_S = LDS $@ | 297 $(call echo-cmd,objtool) $(cmd_objtool) \ 298 $(call echo-cmd,record_mcount) $(cmd_record_mcount) 299endef 300 301define rule_as_o_S 302 $(call cmd_and_fixdep,as_o_S) \ 303 $(cmd_modversions_S) \ 304 $(call echo-cmd,objtool) $(cmd_objtool) --- 112 unchanged lines hidden (view full) --- 417 $(call if_changed_rule,as_o_S) 418 419targets += $(real-objs-y) $(real-objs-m) $(lib-y) 420targets += $(extra-y) $(MAKECMDGOALS) $(always) 421 422# Linker scripts preprocessor (.lds.S -> .lds) 423# --------------------------------------------------------------------------- 424quiet_cmd_cpp_lds_S = LDS $@ |
414 cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -U$(ARCH) \ | 425 cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \ |
415 -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $< 416 417$(obj)/%.lds: $(src)/%.lds.S FORCE 418 $(call if_changed_dep,cpp_lds_S) 419 420# ASN.1 grammar 421# --------------------------------------------------------------------------- 422quiet_cmd_asn1_compiler = ASN.1 $@ --- 126 unchanged lines hidden (view full) --- 549 550$(multi-used-m): FORCE 551 $(call if_changed,link_multi-m) 552 @{ echo $(@:.o=.ko); echo $(link_multi_deps); \ 553 $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod) 554$(call multi_depend, $(multi-used-m), .o, -objs -y -m) 555 556targets += $(multi-used-y) $(multi-used-m) | 426 -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $< 427 428$(obj)/%.lds: $(src)/%.lds.S FORCE 429 $(call if_changed_dep,cpp_lds_S) 430 431# ASN.1 grammar 432# --------------------------------------------------------------------------- 433quiet_cmd_asn1_compiler = ASN.1 $@ --- 126 unchanged lines hidden (view full) --- 560 561$(multi-used-m): FORCE 562 $(call if_changed,link_multi-m) 563 @{ echo $(@:.o=.ko); echo $(link_multi_deps); \ 564 $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod) 565$(call multi_depend, $(multi-used-m), .o, -objs -y -m) 566 567targets += $(multi-used-y) $(multi-used-m) |
557targets := $(filter-out $(PHONY), $(targets)) | |
558 | 568 |
569 |
|
559# Descending 560# --------------------------------------------------------------------------- 561 562PHONY += $(subdir-ym) 563$(subdir-ym): | 570# Descending 571# --------------------------------------------------------------------------- 572 573PHONY += $(subdir-ym) 574$(subdir-ym): |
564 $(Q)$(MAKE) $(build)=$@ need-builtin=$(if $(findstring $@,$(subdir-obj-y)),1) | 575 $(Q)$(MAKE) $(build)=$@ |
565 566# Add FORCE to the prequisites of a target to force it to be always rebuilt. 567# --------------------------------------------------------------------------- 568 569PHONY += FORCE 570 571FORCE: 572 573# Read all saved command lines and dependencies for the $(targets) we 574# may be building above, using $(if_changed{,_dep}). As an 575# optimization, we don't need to read them if the target does not 576# exist, we will rebuild anyway in that case. 577 | 576 577# Add FORCE to the prequisites of a target to force it to be always rebuilt. 578# --------------------------------------------------------------------------- 579 580PHONY += FORCE 581 582FORCE: 583 584# Read all saved command lines and dependencies for the $(targets) we 585# may be building above, using $(if_changed{,_dep}). As an 586# optimization, we don't need to read them if the target does not 587# exist, we will rebuild anyway in that case. 588 |
578cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) | 589targets := $(wildcard $(sort $(targets))) 590cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) |
579 580ifneq ($(cmd_files),) 581 include $(cmd_files) 582endif 583 | 591 592ifneq ($(cmd_files),) 593 include $(cmd_files) 594endif 595 |
584ifneq ($(KBUILD_SRC),) 585# Create directories for object files if they do not exist 586obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets)))) 587# If cmd_files exist, their directories apparently exist. Skip mkdir. 588exist-dirs := $(sort $(patsubst %/,%, $(dir $(cmd_files)))) 589obj-dirs := $(strip $(filter-out $(exist-dirs), $(obj-dirs))) 590ifneq ($(obj-dirs),) 591$(shell mkdir -p $(obj-dirs)) 592endif 593endif 594 | |
595# Declare the contents of the .PHONY variable as phony. We keep that 596# information in a variable se we can use it in if_changed and friends. 597 598.PHONY: $(PHONY) | 596# Declare the contents of the .PHONY variable as phony. We keep that 597# information in a variable se we can use it in if_changed and friends. 598 599.PHONY: $(PHONY) |