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