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