Blame view
tools/build/Makefile.build
3.9 KB
b24413180 License cleanup: ... |
1 |
# SPDX-License-Identifier: GPL-2.0 |
c819e2cf2 tools build: Add ... |
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
### # Main build makefile. # # Lots of this code have been borrowed or heavily inspired from parts # of kbuild code, which is not credited, but mostly developed by: # # Copyright (C) Sam Ravnborg <sam@mars.ravnborg.org>, 2015 # Copyright (C) Linus Torvalds <torvalds@linux-foundation.org>, 2015 # PHONY := __build __build: ifeq ($(V),1) quiet = |
ceed252fe perf build: Displ... |
17 |
Q = |
c819e2cf2 tools build: Add ... |
18 19 |
else quiet=quiet_ |
ceed252fe perf build: Displ... |
20 |
Q=@ |
c819e2cf2 tools build: Add ... |
21 |
endif |
6f0fa58e4 kbuild: simplify ... |
22 |
ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) |
e572d0887 tools build: Add ... |
23 24 |
quiet=silent_ endif |
e572d0887 tools build: Add ... |
25 |
|
c819e2cf2 tools build: Add ... |
26 |
build-dir := $(srctree)/tools/build |
9fb81323e tools build: Make... |
27 28 29 30 31 32 |
# Define $(fixdep) for dep-cmd function ifeq ($(OUTPUT),) fixdep := $(build-dir)/fixdep else fixdep := $(OUTPUT)/fixdep endif |
c819e2cf2 tools build: Add ... |
33 34 |
# Generic definitions include $(build-dir)/Build.include |
fcfd6611f tools build: Add ... |
35 |
# do not force detected configuration |
642273795 perf tools: Creat... |
36 |
-include $(OUTPUT).config-detected |
fcfd6611f tools build: Add ... |
37 |
|
c819e2cf2 tools build: Add ... |
38 39 40 41 42 43 44 45 46 47 |
# Init all relevant variables used in build files so # 1) they have correct type # 2) they do not inherit any value from the environment subdir-y := obj-y := subdir-y := subdir-obj-y := # Build definitions build-file := $(dir)/Build |
d7a3d85e0 perf build: Do no... |
48 |
-include $(build-file) |
c819e2cf2 tools build: Add ... |
49 |
|
9352aabad perf build: Add l... |
50 51 |
quiet_cmd_flex = FLEX $@ quiet_cmd_bison = BISON $@ |
579ff6d40 tools build: Add ... |
52 53 54 55 |
# Create directory unless it exists quiet_cmd_mkdir = MKDIR $(dir $@) cmd_mkdir = mkdir -p $(dir $@) rule_mkdir = $(if $(wildcard $(dir $@)),,@$(call echo-cmd,mkdir) $(cmd_mkdir)) |
c819e2cf2 tools build: Add ... |
56 57 58 |
# Compile command quiet_cmd_cc_o_c = CC $@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< |
0c3b7e426 tools build: Add ... |
59 60 |
quiet_cmd_host_cc_o_c = HOSTCC $@ cmd_host_cc_o_c = $(HOSTCC) $(host_c_flags) -c -o $@ $< |
f61bdc330 tools build: Supp... |
61 62 |
quiet_cmd_cxx_o_c = CXX $@ cmd_cxx_o_c = $(CXX) $(cxx_flags) -c -o $@ $< |
23d438487 kbuild: rename cm... |
63 64 |
quiet_cmd_cpp_i_c = CPP $@ cmd_cpp_i_c = $(CC) $(c_flags) -E -o $@ $< |
1999307b4 perf build: Add s... |
65 66 67 |
quiet_cmd_cc_s_c = AS $@ cmd_cc_s_c = $(CC) $(c_flags) -S -o $@ $< |
237fae79f perf tools: Add I... |
68 |
quiet_cmd_gen = GEN $@ |
c819e2cf2 tools build: Add ... |
69 70 71 72 |
# Link agregate command # If there's nothing to link, create empty $@ object. quiet_cmd_ld_multi = LD $@ cmd_ld_multi = $(if $(strip $(obj-y)),\ |
0c3b7e426 tools build: Add ... |
73 74 75 76 77 78 79 80 81 |
$(LD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(AR) rcs $@) quiet_cmd_host_ld_multi = HOSTLD $@ cmd_host_ld_multi = $(if $(strip $(obj-y)),\ $(HOSTLD) -r -o $@ $(filter $(obj-y),$^),rm -f $@; $(HOSTAR) rcs $@) ifneq ($(filter $(obj),$(hostprogs)),) host = host_ endif |
c819e2cf2 tools build: Add ... |
82 83 84 |
# Build rules $(OUTPUT)%.o: %.c FORCE |
579ff6d40 tools build: Add ... |
85 |
$(call rule_mkdir) |
0c3b7e426 tools build: Add ... |
86 |
$(call if_changed_dep,$(host)cc_o_c) |
c819e2cf2 tools build: Add ... |
87 |
|
f61bdc330 tools build: Supp... |
88 89 90 |
$(OUTPUT)%.o: %.cpp FORCE $(call rule_mkdir) $(call if_changed_dep,cxx_o_c) |
c819e2cf2 tools build: Add ... |
91 |
$(OUTPUT)%.o: %.S FORCE |
579ff6d40 tools build: Add ... |
92 |
$(call rule_mkdir) |
0c3b7e426 tools build: Add ... |
93 |
$(call if_changed_dep,$(host)cc_o_c) |
c819e2cf2 tools build: Add ... |
94 |
|
1999307b4 perf build: Add s... |
95 96 |
$(OUTPUT)%.i: %.c FORCE $(call rule_mkdir) |
23d438487 kbuild: rename cm... |
97 |
$(call if_changed_dep,cpp_i_c) |
1999307b4 perf build: Add s... |
98 |
|
676787939 tools build: Use ... |
99 |
$(OUTPUT)%.s: %.S FORCE |
1999307b4 perf build: Add s... |
100 |
$(call rule_mkdir) |
23d438487 kbuild: rename cm... |
101 |
$(call if_changed_dep,cpp_i_c) |
1999307b4 perf build: Add s... |
102 103 104 105 |
$(OUTPUT)%.s: %.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_s_c) |
c819e2cf2 tools build: Add ... |
106 107 108 109 110 111 112 113 114 115 |
# Gather build data: # obj-y - list of build objects # subdir-y - list of directories to nest # subdir-obj-y - list of directories objects 'dir/$(obj)-in.o' obj-y := $($(obj)-y) subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) obj-y := $(patsubst %/, %/$(obj)-in.o, $(obj-y)) subdir-obj-y := $(filter %/$(obj)-in.o, $(obj-y)) # '$(OUTPUT)/dir' prefix to all objects |
75e84ab90 perf tools: Fix b... |
116 117 118 |
objprefix := $(subst ./,,$(OUTPUT)$(dir)/) obj-y := $(addprefix $(objprefix),$(obj-y)) subdir-obj-y := $(addprefix $(objprefix),$(subdir-obj-y)) |
c819e2cf2 tools build: Add ... |
119 120 |
# Final '$(obj)-in.o' object |
75e84ab90 perf tools: Fix b... |
121 |
in-target := $(objprefix)$(obj)-in.o |
c819e2cf2 tools build: Add ... |
122 123 124 125 |
PHONY += $(subdir-y) $(subdir-y): |
ceed252fe perf build: Displ... |
126 |
$(Q)$(MAKE) -f $(build-dir)/Makefile.build dir=$(dir)/$@ obj=$(obj) |
c819e2cf2 tools build: Add ... |
127 128 129 130 131 |
$(sort $(subdir-obj-y)): $(subdir-y) ; $(in-target): $(obj-y) FORCE $(call rule_mkdir) |
0c3b7e426 tools build: Add ... |
132 |
$(call if_changed,$(host)ld_multi) |
c819e2cf2 tools build: Add ... |
133 134 135 136 137 138 139 140 141 |
__build: $(in-target) @: PHONY += FORCE FORCE: # Include all cmd files to get all the dependency rules # for all objects included |
1999307b4 perf build: Add s... |
142 |
targets := $(wildcard $(sort $(obj-y) $(in-target) $(MAKECMDGOALS))) |
c819e2cf2 tools build: Add ... |
143 144 145 146 147 148 149 |
cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) ifneq ($(cmd_files),) include $(cmd_files) endif .PHONY: $(PHONY) |