Tom Rini | 614edd8 | 2024-02-29 12:33:36 -0500 | [diff] [blame] | 1 | |
| 2 | DTC ?= dtc |
| 3 | CPP ?= cpp |
| 4 | |
| 5 | # Disable noisy checks by default |
| 6 | ifeq ($(findstring 1,$(DTC_VERBOSE)),) |
| 7 | DTC_FLAGS += -Wno-unit_address_vs_reg \ |
| 8 | -Wno-unit_address_format \ |
| 9 | -Wno-avoid_unnecessary_addr_size \ |
| 10 | -Wno-alias_paths \ |
| 11 | -Wno-graph_child_address \ |
| 12 | -Wno-simple_bus_reg \ |
| 13 | -Wno-unique_unit_address \ |
| 14 | -Wno-pci_device_reg |
| 15 | endif |
| 16 | |
| 17 | ifneq ($(findstring 2,$(DTC_VERBOSE)),) |
| 18 | DTC_FLAGS += -Wnode_name_chars_strict \ |
| 19 | -Wproperty_name_chars_strict |
| 20 | endif |
| 21 | |
| 22 | MAKEFLAGS += -rR --no-print-directory |
| 23 | |
| 24 | ALL_ARCHES := $(patsubst src/%,%,$(wildcard src/*)) |
| 25 | |
| 26 | PHONY += all |
| 27 | all: $(foreach i,$(ALL_ARCHES),all_$(i)) |
| 28 | |
| 29 | PHONY += clean |
| 30 | clean: $(foreach i,$(ALL_ARCHES),clean_$(i)) |
| 31 | |
| 32 | # Do not: |
| 33 | # o use make's built-in rules and variables |
| 34 | # (this increases performance and avoids hard-to-debug behaviour); |
| 35 | # o print "Entering directory ..."; |
| 36 | MAKEFLAGS += -rR --no-print-directory |
| 37 | |
| 38 | # To put more focus on warnings, be less verbose as default |
| 39 | # Use 'make V=1' to see the full commands |
| 40 | |
| 41 | ifeq ("$(origin V)", "command line") |
| 42 | KBUILD_VERBOSE = $(V) |
| 43 | endif |
| 44 | ifndef KBUILD_VERBOSE |
| 45 | KBUILD_VERBOSE = 0 |
| 46 | endif |
| 47 | |
| 48 | # Beautify output |
| 49 | # --------------------------------------------------------------------------- |
| 50 | # |
| 51 | # Normally, we echo the whole command before executing it. By making |
| 52 | # that echo $($(quiet)$(cmd)), we now have the possibility to set |
| 53 | # $(quiet) to choose other forms of output instead, e.g. |
| 54 | # |
| 55 | # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ |
| 56 | # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< |
| 57 | # |
| 58 | # If $(quiet) is empty, the whole command will be printed. |
| 59 | # If it is set to "quiet_", only the short version will be printed. |
| 60 | # If it is set to "silent_", nothing will be printed at all, since |
| 61 | # the variable $(silent_cmd_cc_o_c) doesn't exist. |
| 62 | # |
| 63 | # A simple variant is to prefix commands with $(Q) - that's useful |
| 64 | # for commands that shall be hidden in non-verbose mode. |
| 65 | # |
| 66 | # $(Q)ln $@ :< |
| 67 | # |
| 68 | # If KBUILD_VERBOSE equals 0 then the above command will be hidden. |
| 69 | # If KBUILD_VERBOSE equals 1 then the above command is displayed. |
| 70 | |
| 71 | ifeq ($(KBUILD_VERBOSE),1) |
| 72 | quiet = |
| 73 | Q = |
| 74 | else |
| 75 | quiet=quiet_ |
| 76 | Q = @ |
| 77 | endif |
| 78 | |
| 79 | # If the user is running make -s (silent mode), suppress echoing of |
| 80 | # commands |
| 81 | |
| 82 | ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 |
| 83 | ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) |
| 84 | quiet=silent_ |
| 85 | endif |
| 86 | else # make-3.8x |
| 87 | ifneq ($(filter s% -s%,$(MAKEFLAGS)),) |
| 88 | quiet=silent_ |
| 89 | endif |
| 90 | endif |
| 91 | |
| 92 | export quiet Q KBUILD_VERBOSE |
| 93 | |
| 94 | all_%: |
| 95 | $(Q)$(MAKE) ARCH=$* all_arch |
| 96 | |
| 97 | clean_%: |
| 98 | $(Q)$(MAKE) ARCH=$* clean_arch |
| 99 | |
| 100 | ifeq ($(ARCH),) |
| 101 | |
| 102 | ALL_DTS := $(shell find src/* -name \*.dts) |
| 103 | |
| 104 | ALL_DTB := $(patsubst %.dts,%.dtb,$(ALL_DTS)) |
| 105 | |
| 106 | $(ALL_DTB): ARCH=$(word 2,$(subst /, ,$@)) |
| 107 | $(ALL_DTB): FORCE |
| 108 | $(Q)$(MAKE) ARCH=$(ARCH) $@ |
| 109 | |
| 110 | else |
| 111 | |
| 112 | ARCH_DTS := $(shell find src/$(ARCH) -name \*.dts) |
| 113 | |
| 114 | ARCH_DTB := $(patsubst %.dts,%.dtb,$(ARCH_DTS)) |
| 115 | |
| 116 | src := src/$(ARCH) |
| 117 | obj := src/$(ARCH) |
| 118 | |
| 119 | include scripts/Kbuild.include |
| 120 | |
| 121 | cmd_files := $(wildcard $(foreach f,$(ARCH_DTB),$(dir $(f)).$(notdir $(f)).cmd)) |
| 122 | |
| 123 | ifneq ($(cmd_files),) |
| 124 | include $(cmd_files) |
| 125 | endif |
| 126 | |
| 127 | quiet_cmd_clean = CLEAN $(obj) |
| 128 | cmd_clean = rm -f $(__clean-files) |
| 129 | |
| 130 | dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) |
| 131 | |
| 132 | dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ |
| 133 | -Iinclude -I$(src) -Isrc -Itestcase-data \ |
| 134 | -undef -D__DTS__ |
| 135 | |
| 136 | quiet_cmd_dtc = DTC $@ |
| 137 | cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ |
| 138 | $(DTC) -O dtb -o $@ -b 0 \ |
| 139 | -i $(src) $(DTC_FLAGS) \ |
| 140 | -d $(depfile).dtc.tmp $(dtc-tmp) ; \ |
| 141 | cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) |
| 142 | |
| 143 | $(obj)/%.dtb: $(src)/%.dts FORCE |
| 144 | $(call if_changed_dep,dtc) |
| 145 | |
| 146 | PHONY += all_arch |
| 147 | all_arch: $(ARCH_DTB) |
| 148 | @: |
| 149 | |
| 150 | RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \ |
| 151 | -o -name .pc -o -name .hg -o -name .git \) -prune -o |
| 152 | |
| 153 | PHONY += clean_arch |
| 154 | clean_arch: __clean-files = $(ARCH_DTB) |
| 155 | clean_arch: FORCE |
| 156 | $(call cmd,clean) |
| 157 | @find . $(RCS_FIND_IGNORE) \ |
| 158 | \( -name '.*.cmd' \ |
| 159 | -o -name '.*.d' \ |
| 160 | -o -name '.*.tmp' \ |
| 161 | \) -type f -print | xargs rm -f |
| 162 | |
| 163 | endif |
| 164 | |
| 165 | help: |
| 166 | @echo "Targets:" |
| 167 | @echo " all: Build all device tree binaries for all architectures" |
| 168 | @echo " clean: Clean all generated files" |
| 169 | @echo "" |
| 170 | @echo " all_<ARCH>: Build all device tree binaries for <ARCH>" |
| 171 | @echo " clean_<ARCH>: Clean all generated files for <ARCH>" |
| 172 | @echo "" |
| 173 | @echo " src/<ARCH>/<DTS>.dtb Build a single device tree binary" |
| 174 | @echo "" |
| 175 | @echo "Architectures: $(ALL_ARCHES)" |
| 176 | |
| 177 | PHONY += FORCE |
| 178 | FORCE: |
| 179 | |
| 180 | .PHONY: $(PHONY) |