1 2DTC ?= dtc 3CPP ?= cpp 4 5# Disable noisy checks by default 6ifeq ($(findstring 1,$(DTC_VERBOSE)),) 7DTC_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 15endif 16 17ifneq ($(findstring 2,$(DTC_VERBOSE)),) 18DTC_FLAGS += -Wnode_name_chars_strict \ 19 -Wproperty_name_chars_strict 20endif 21 22MAKEFLAGS += -rR --no-print-directory 23 24ALL_ARCHES := $(patsubst src/%,%,$(wildcard src/*)) 25 26PHONY += all 27all: $(foreach i,$(ALL_ARCHES),all_$(i)) 28 29PHONY += clean 30clean: $(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 ..."; 36MAKEFLAGS += -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 41ifeq ("$(origin V)", "command line") 42 KBUILD_VERBOSE = $(V) 43endif 44ifndef KBUILD_VERBOSE 45 KBUILD_VERBOSE = 0 46endif 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 71ifeq ($(KBUILD_VERBOSE),1) 72 quiet = 73 Q = 74else 75 quiet=quiet_ 76 Q = @ 77endif 78 79# If the user is running make -s (silent mode), suppress echoing of 80# commands 81 82ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 83ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) 84 quiet=silent_ 85endif 86else # make-3.8x 87ifneq ($(filter s% -s%,$(MAKEFLAGS)),) 88 quiet=silent_ 89endif 90endif 91 92export quiet Q KBUILD_VERBOSE 93 94all_%: 95 $(Q)$(MAKE) ARCH=$* all_arch 96 97clean_%: 98 $(Q)$(MAKE) ARCH=$* clean_arch 99 100ifeq ($(ARCH),) 101 102ALL_DTS := $(shell find src/* -name \*.dts) 103ALL_DTSO := $(shell find src/* -name \*.dtso) 104 105ALL_DTB := $(patsubst %.dts,%.dtb,$(ALL_DTS)) 106ALL_DTBO := $(patsubst %.dtso,%.dtbo,$(ALL_DTSO)) 107 108$(ALL_DTB) $(ALL_DTBO): ARCH=$(word 2,$(subst /, ,$@)) 109$(ALL_DTB) $(ALL_DTBO): FORCE 110 $(Q)$(MAKE) ARCH=$(ARCH) $@ 111 112else 113 114ARCH_DTS := $(shell find src/$(ARCH) -name \*.dts) 115ARCH_DTSO := $(shell find src/$(ARCH) -name \*.dtso) 116 117ARCH_DTB := $(patsubst %.dts,%.dtb,$(ARCH_DTS)) 118ARCH_DTBO := $(patsubst %.dtso,%.dtbo,$(ARCH_DTSO)) 119 120src := src/$(ARCH) 121obj := src/$(ARCH) 122 123include scripts/Kbuild.include 124 125cmd_files := $(wildcard $(foreach f,$(ARCH_DTB) $(ARCH_DTBO),$(dir $(f)).$(notdir $(f)).cmd)) 126 127ifneq ($(cmd_files),) 128 include $(cmd_files) 129endif 130 131quiet_cmd_clean = CLEAN $(obj) 132 cmd_clean = rm -f $(__clean-files) 133 134dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) 135 136dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ 137 -Iinclude -I$(src) -Isrc -Itestcase-data \ 138 -undef -D__DTS__ 139 140quiet_cmd_dtc = DTC $@ 141cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ 142 $(DTC) -O dtb -o $@ -b 0 \ 143 -i $(src) $(DTC_FLAGS) \ 144 -d $(depfile).dtc.tmp $(dtc-tmp) ; \ 145 cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) 146 147$(obj)/%.dtb: $(src)/%.dts FORCE 148 $(call if_changed_dep,dtc) 149 150quiet_cmd_dtco = DTCO $@ 151cmd_dtco = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ 152 $(DTC) -@ -O dtb -o $@ -b 0 \ 153 -i $(src) $(DTC_FLAGS) \ 154 -d $(depfile).dtc.tmp $(dtc-tmp) ; \ 155 cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) 156 157$(obj)/%.dtbo: $(src)/%.dtso FORCE 158 $(call if_changed_dep,dtco) 159 160PHONY += all_arch 161all_arch: $(ARCH_DTB) $(ARCH_DTBO) 162 @: 163 164RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \ 165 -o -name .pc -o -name .hg -o -name .git \) -prune -o 166 167PHONY += clean_arch 168clean_arch: __clean-files = $(ARCH_DTB) $(ARCH_DTBO) 169clean_arch: FORCE 170 $(call cmd,clean) 171 @find . $(RCS_FIND_IGNORE) \ 172 \( -name '.*.cmd' \ 173 -o -name '.*.d' \ 174 -o -name '.*.tmp' \ 175 \) -type f -print | xargs rm -f 176 177endif 178 179help: 180 @echo "Targets:" 181 @echo " all: Build all device tree binaries for all architectures" 182 @echo " clean: Clean all generated files" 183 @echo "" 184 @echo " all_<ARCH>: Build all device tree binaries for <ARCH>" 185 @echo " clean_<ARCH>: Clean all generated files for <ARCH>" 186 @echo "" 187 @echo " src/<ARCH>/<DTS>.dtb Build a single device tree binary" 188 @echo "" 189 @echo "Architectures: $(ALL_ARCHES)" 190 191PHONY += FORCE 192FORCE: 193 194.PHONY: $(PHONY) 195