]> git.lizzy.rs Git - rust.git/blob - mk/main.mk
98b83530c8de05bced2bde3a80910e8b2d80617d
[rust.git] / mk / main.mk
1 # Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
4 #
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
10
11 ######################################################################
12 # Version numbers and strings
13 ######################################################################
14
15 # The version number
16 CFG_RELEASE_NUM=0.12.0
17 CFG_RELEASE_LABEL=-pre
18
19 CFG_FILENAME_EXTRA=4e7c5e5c
20
21 ifndef CFG_ENABLE_NIGHTLY
22 # This is the normal version string
23 CFG_RELEASE=$(CFG_RELEASE_NUM)$(CFG_RELEASE_LABEL)
24 CFG_PACKAGE_VERS=$(CFG_RELEASE)
25 else
26 # Modify the version label for nightly builds
27 CFG_RELEASE=$(CFG_RELEASE_NUM)$(CFG_RELEASE_LABEL)-nightly
28 # When building nightly distributables just reuse the same "rust-nightly" name
29 # so when we upload we'll always override the previous nighly. This doesn't actually
30 # impact the version reported by rustc - it's just for file naming.
31 CFG_PACKAGE_VERS=nightly
32 endif
33 # The name of the package to use for creating tarballs, installers etc.
34 CFG_PACKAGE_NAME=rust-$(CFG_PACKAGE_VERS)
35
36 # The version string plus commit information - this is what rustc reports
37 CFG_VERSION = $(CFG_RELEASE)
38 CFG_GIT_DIR := $(CFG_SRC_DIR).git
39 # since $(CFG_GIT) may contain spaces (especially on Windows),
40 # we need to escape them. (" " to r"\ ")
41 # Note that $(subst ...) ignores space after `subst`,
42 # so we use a hack: define $(SPACE) which contains space character.
43 SPACE :=
44 SPACE +=
45 ifneq ($(wildcard $(subst $(SPACE),\$(SPACE),$(CFG_GIT))),)
46 ifneq ($(wildcard $(subst $(SPACE),\$(SPACE),$(CFG_GIT_DIR))),)
47     CFG_VER_DATE = $(shell git --git-dir='$(CFG_GIT_DIR)' log -1 --pretty=format:'%ci')
48     CFG_VER_HASH = $(shell git --git-dir='$(CFG_GIT_DIR)' rev-parse HEAD)
49     CFG_SHORT_VER_HASH = $(shell git --git-dir='$(CFG_GIT_DIR)' rev-parse --short=9 HEAD)
50     CFG_VERSION += ($(CFG_SHORT_VER_HASH) $(CFG_VER_DATE))
51 endif
52 endif
53
54 # Windows exe's need numeric versions - don't use anything but
55 # numbers and dots here
56 CFG_VERSION_WIN = $(CFG_RELEASE_NUM)
57
58
59 ######################################################################
60 # More configuration
61 ######################################################################
62
63 # We track all of the object files we might build so that we can find
64 # and include all of the .d files in one fell swoop.
65 ALL_OBJ_FILES :=
66
67 MKFILE_DEPS := config.stamp $(call rwildcard,$(CFG_SRC_DIR)mk/,*)
68 MKFILES_FOR_TARBALL:=$(MKFILE_DEPS)
69 ifneq ($(NO_MKFILE_DEPS),)
70 MKFILE_DEPS :=
71 endif
72 NON_BUILD_HOST = $(filter-out $(CFG_BUILD),$(CFG_HOST))
73 NON_BUILD_TARGET = $(filter-out $(CFG_BUILD),$(CFG_TARGET))
74
75 ifneq ($(MAKE_RESTARTS),)
76 CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
77 endif
78
79 CFG_INFO := $(info cfg: build triple $(CFG_BUILD))
80 CFG_INFO := $(info cfg: host triples $(CFG_HOST))
81 CFG_INFO := $(info cfg: target triples $(CFG_TARGET))
82
83 ifneq ($(wildcard $(NON_BUILD_HOST)),)
84 CFG_INFO := $(info cfg: non-build host triples $(NON_BUILD_HOST))
85 endif
86 ifneq ($(wildcard $(NON_BUILD_TARGET)),)
87 CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET))
88 endif
89
90 CFG_RUSTC_FLAGS := $(RUSTFLAGS)
91 CFG_GCCISH_CFLAGS :=
92 CFG_GCCISH_LINK_FLAGS :=
93
94 ifdef CFG_DISABLE_OPTIMIZE
95   $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
96   CFG_RUSTC_FLAGS +=
97 else
98   # The rtopt cfg turns off runtime sanity checks
99   CFG_RUSTC_FLAGS += -O --cfg rtopt
100 endif
101
102 ifdef CFG_DISABLE_DEBUG
103   CFG_RUSTC_FLAGS += --cfg ndebug
104   CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
105 else
106   $(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
107   CFG_RUSTC_FLAGS += --cfg debug
108   CFG_GCCISH_CFLAGS += -DRUST_DEBUG
109 endif
110
111 ifdef SAVE_TEMPS
112   CFG_RUSTC_FLAGS += --save-temps
113 endif
114 ifdef ASM_COMMENTS
115   CFG_RUSTC_FLAGS += -Z asm-comments
116 endif
117 ifdef TIME_PASSES
118   CFG_RUSTC_FLAGS += -Z time-passes
119 endif
120 ifdef TIME_LLVM_PASSES
121   CFG_RUSTC_FLAGS += -Z time-llvm-passes
122 endif
123 ifdef TRACE
124   CFG_RUSTC_FLAGS += -Z trace
125 endif
126 ifdef CFG_ENABLE_RPATH
127 CFG_RUSTC_FLAGS += -C rpath
128 endif
129
130 # The executables crated during this compilation process have no need to include
131 # static copies of libstd and libextra. We also generate dynamic versions of all
132 # libraries, so in the interest of space, prefer dynamic linking throughout the
133 # compilation process.
134 #
135 # Note though that these flags are omitted for stage2+. This means that the
136 # snapshot will be generated with a statically linked rustc so we only have to
137 # worry about the distribution of one file (with its native dynamic
138 # dependencies)
139 RUSTFLAGS_STAGE0 += -C prefer-dynamic
140 RUSTFLAGS_STAGE1 += -C prefer-dynamic
141
142 # platform-specific auto-configuration
143 include $(CFG_SRC_DIR)mk/platform.mk
144
145 # Run the stage1/2 compilers under valgrind
146 ifdef VALGRIND_COMPILE
147   CFG_VALGRIND_COMPILE :=$(CFG_VALGRIND)
148 else
149   CFG_VALGRIND_COMPILE :=
150 endif
151
152 ifdef CFG_ENABLE_VALGRIND
153   $(info cfg: enabling valgrind (CFG_ENABLE_VALGRIND))
154 else
155   CFG_VALGRIND :=
156 endif
157 ifdef CFG_BAD_VALGRIND
158   $(info cfg: disabling valgrind due to its unreliability on this platform)
159   CFG_VALGRIND :=
160 endif
161
162
163 ######################################################################
164 # Target-and-rule "utility variables"
165 ######################################################################
166
167 define DEF_X
168 X_$(1) := $(CFG_EXE_SUFFIX_$(1))
169 endef
170 $(foreach target,$(CFG_TARGET),\
171   $(eval $(call DEF_X,$(target))))
172
173 # "Source" files we generate in builddir along the way.
174 GENERATED :=
175
176 # Delete the built-in rules.
177 .SUFFIXES:
178 %:: %,v
179 %:: RCS/%,v
180 %:: RCS/%
181 %:: s.%
182 %:: SCCS/s.%
183
184
185 ######################################################################
186 # Cleaning out old crates
187 ######################################################################
188
189 # $(1) is the path for directory to match against
190 # $(2) is the glob to use in the match
191 #
192 # Note that a common bug is to accidentally construct the glob denoted
193 # by $(2) with a space character prefix, which invalidates the
194 # construction $(1)$(2).
195 define CHECK_FOR_OLD_GLOB_MATCHES
196   $(Q)MATCHES="$(wildcard $(1))"; if [ -n "$$MATCHES" ] ; then echo "warning: there are previous" \'$(notdir $(2))\' "libraries:" $$MATCHES; fi
197 endef
198
199 # Same interface as above, but deletes rather than just listing the files.
200 ifdef VERBOSE
201 define REMOVE_ALL_OLD_GLOB_MATCHES
202   $(Q)MATCHES="$(wildcard $(1))"; if [ -n "$$MATCHES" ] ; then echo "warning: removing previous" \'$(notdir $(1))\' "libraries:" $$MATCHES; rm $$MATCHES ; fi
203 endef
204 else
205 define REMOVE_ALL_OLD_GLOB_MATCHES
206   $(Q)MATCHES="$(wildcard $(1))"; if [ -n "$$MATCHES" ] ; then rm $$MATCHES ; fi
207 endef
208 endif
209
210 # We use a different strategy for LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
211 # than in the macros above because it needs the result of running the
212 # `ls` command after other rules in the command list have run; the
213 # macro-expander for $(wildcard ...) would deliver its results too
214 # soon. (This is in contrast to the macros above, which are meant to
215 # be run at the outset of a command list in a rule.)
216 ifdef VERBOSE
217 define LIST_ALL_OLD_GLOB_MATCHES
218   @echo "info: now are following matches for" '$(notdir $(1))' "libraries:"
219   @( ls $(1) 2>/dev/null || true )
220 endef
221 else
222 define LIST_ALL_OLD_GLOB_MATCHES
223 endef
224 endif
225
226 ######################################################################
227 # LLVM macros
228 ######################################################################
229
230 # FIXME: x86-ism
231 LLVM_COMPONENTS=x86 arm mips ipo bitreader bitwriter linker asmparser jit mcjit \
232                 interpreter instrumentation
233
234 # Only build these LLVM tools
235 LLVM_TOOLS=bugpoint llc llvm-ar llvm-as llvm-dis llvm-mc opt llvm-extract
236
237 define DEF_LLVM_VARS
238 # The configure script defines these variables with the target triples
239 # separated by Z. This defines new ones with the expected format.
240 ifeq ($$(CFG_LLVM_ROOT),)
241 CFG_LLVM_BUILD_DIR_$(1):=$$(CFG_LLVM_BUILD_DIR_$(subst -,_,$(1)))
242 CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_INST_DIR_$(subst -,_,$(1)))
243 else
244 CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_ROOT)
245 endif
246
247 # Any rules that depend on LLVM should depend on LLVM_CONFIG
248 LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config$$(X_$(1))
249 LLVM_MC_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-mc$$(X_$(1))
250 LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
251 LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
252 LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
253 LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
254 LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS))
255 LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
256 # On FreeBSD, it may search wrong headers (that are for pre-installed LLVM),
257 # so we replace -I with -iquote to ensure that it searches bundled LLVM first.
258 LLVM_CXXFLAGS_$(1)=$$(subst -I, -iquote , $$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags))
259 LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target)
260
261 LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1))
262 LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))
263
264 endef
265
266 $(foreach host,$(CFG_HOST), \
267  $(eval $(call DEF_LLVM_VARS,$(host))))
268
269 ######################################################################
270 # Exports for sub-utilities
271 ######################################################################
272
273 # Note that any variable that re-configure should pick up needs to be
274 # exported
275
276 export CFG_SRC_DIR
277 export CFG_BUILD_DIR
278 ifdef CFG_VER_DATE
279 export CFG_VER_DATE
280 endif
281 ifdef CFG_VER_HASH
282 export CFG_VER_HASH
283 endif
284 export CFG_VERSION
285 export CFG_VERSION_WIN
286 export CFG_RELEASE
287 export CFG_PACKAGE_NAME
288 export CFG_BUILD
289 export CFG_LLVM_ROOT
290 export CFG_ENABLE_MINGW_CROSS
291 export CFG_PREFIX
292 export CFG_LIBDIR
293 export CFG_LIBDIR_RELATIVE
294 export CFG_DISABLE_INJECT_STD_VERSION
295
296 ######################################################################
297 # Per-stage targets and runner
298 ######################################################################
299
300 STAGES = 0 1 2 3
301
302 define SREQ
303 # $(1) is the stage number
304 # $(2) is the target triple
305 # $(3) is the host triple
306
307 # Destinations of artifacts for the host compiler
308 HROOT$(1)_H_$(3) = $(3)/stage$(1)
309 HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
310 HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
311
312 # Destinations of artifacts for target architectures
313 TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustlib/$(2)
314 TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
315 TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/lib
316
317 # Preqrequisites for using the stageN compiler
318 ifeq ($(1),0)
319 HSREQ$(1)_H_$(3) = $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))
320 else
321 HSREQ$(1)_H_$(3) = \
322         $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
323         $$(MKFILE_DEPS)
324 endif
325
326 # Prerequisites for using the stageN compiler to build target artifacts
327 TSREQ$(1)_T_$(2)_H_$(3) = \
328         $$(HSREQ$(1)_H_$(3)) \
329         $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a \
330         $$(TLIB$(1)_T_$(2)_H_$(3))/libcompiler-rt.a
331
332 # Prerequisites for a working stageN compiler and libraries, for a specific
333 # target
334 SREQ$(1)_T_$(2)_H_$(3) = \
335         $$(TSREQ$(1)_T_$(2)_H_$(3)) \
336         $$(foreach dep,$$(TARGET_CRATES),\
337             $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep))
338
339 # Prerequisites for a working stageN compiler and complete set of target
340 # libraries
341 CSREQ$(1)_T_$(2)_H_$(3) = \
342         $$(TSREQ$(1)_T_$(2)_H_$(3)) \
343         $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
344         $$(foreach dep,$$(CRATES),$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep))
345
346 ifeq ($(1),0)
347 # Don't run the stage0 compiler under valgrind - that ship has sailed
348 CFG_VALGRIND_COMPILE$(1) =
349 else
350 CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE)
351 endif
352
353 # Add RUSTFLAGS_STAGEN values to the build command
354 EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1))
355
356 CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
357
358 endef
359
360 # Same macro/variables as above, but defined in a separate loop so it can use
361 # all the variables above for all archs. The RPATH_VAR setup sometimes needs to
362 # reach across triples to get things in order.
363 #
364 # Defines (with the standard $(1)_T_$(2)_H_$(3) suffix):
365 # * `LD_LIBRARY_PATH_ENV_NAME`: the name for the key to use in the OS
366 #   environment to access or extend the lookup path for dynamic
367 #   libraries.  Note on Windows, that key is `$PATH`, and thus not
368 #   only conflates programs with dynamic libraries, but also often
369 #   contains spaces which confuse make.
370 # * `LD_LIBRARY_PATH_ENV_HOSTDIR`: the entry to add to lookup path for the host
371 # * `LD_LIBRARY_PATH_ENV_TARGETDIR`: the entry to add to lookup path for target
372 #
373 # Below that, HOST_RPATH_VAR and TARGET_RPATH_VAR are defined in terms of the
374 # above settings.
375 #
376 define SREQ_CMDS
377
378 ifeq ($$(OSTYPE_$(3)),apple-darwin)
379   LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3) := DYLD_LIBRARY_PATH
380 else
381 ifeq ($$(CFG_WINDOWSY_$(3)),1)
382   LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3) := PATH
383 else
384   LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3) := LD_LIBRARY_PATH
385 endif
386 endif
387
388 LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3) := \
389     $$(CURDIR)/$$(HLIB$(1)_H_$(3))
390 LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3) := \
391     $$(CURDIR)/$$(TLIB1_T_$(2)_H_$(CFG_BUILD))
392
393 HOST_RPATH_VAR$(1)_T_$(2)_H_$(3) := \
394   $$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))=$$(LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3)):$$$$$$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))
395 TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3) := \
396   $$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))=$$(LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3)):$$$$$$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))
397
398 RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(HOST_RPATH_VAR$(1)_T_$(2)_H_$(3))
399
400 # Pass --cfg stage0 only for the build->host part of stage0;
401 # if you're building a cross config, the host->* parts are
402 # effectively stage1, since it uses the just-built stage0.
403 #
404 # This logic is similar to how the LD_LIBRARY_PATH variable must
405 # change be slightly different when doing cross compilations.
406 # The build doesn't copy over all target libraries into
407 # a new directory, so we need to point the library path at
408 # the build directory where all the target libraries came
409 # from (the stage0 build host). Otherwise the relative rpaths
410 # inside of the rustc binary won't get resolved correctly.
411 ifeq ($(1),0)
412 ifneq ($(strip $(CFG_BUILD)),$(strip $(3)))
413 CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
414
415 RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3))
416 endif
417 endif
418
419 STAGE$(1)_T_$(2)_H_$(3) :=                                              \
420         $$(Q)$$(RPATH_VAR$(1)_T_$(2)_H_$(3))                            \
421                 $$(call CFG_RUN_TARG_$(3),$(1),                         \
422                 $$(CFG_VALGRIND_COMPILE$(1))                            \
423                 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))                     \
424                 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3))                     \
425                 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
426                 $$(RUSTC_FLAGS_$(2))
427
428 PERF_STAGE$(1)_T_$(2)_H_$(3) :=                                         \
429         $$(Q)$$(call CFG_RUN_TARG_$(3),$(1),                            \
430                 $$(CFG_PERF_TOOL)                                       \
431                 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))                     \
432                 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3))                     \
433                 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
434                 $$(RUSTC_FLAGS_$(2))
435
436 endef
437
438 $(foreach build,$(CFG_HOST), \
439  $(eval $(foreach target,$(CFG_TARGET), \
440   $(eval $(foreach stage,$(STAGES), \
441    $(eval $(call SREQ,$(stage),$(target),$(build))))))))
442
443 $(foreach build,$(CFG_HOST), \
444  $(eval $(foreach target,$(CFG_TARGET), \
445   $(eval $(foreach stage,$(STAGES), \
446    $(eval $(call SREQ_CMDS,$(stage),$(target),$(build))))))))
447
448 ######################################################################
449 # rustc-H-targets
450 #
451 # Builds a functional Rustc for the given host.
452 ######################################################################
453
454 define DEF_RUSTC_STAGE_TARGET
455 # $(1) == architecture
456 # $(2) == stage
457
458 rustc-stage$(2)-H-$(1):                                                 \
459         $$(foreach target,$$(CFG_TARGET),$$(SREQ$(2)_T_$$(target)_H_$(1)))
460
461 endef
462
463 $(foreach host,$(CFG_HOST),                                             \
464  $(eval $(foreach stage,1 2 3,                                          \
465   $(eval $(call DEF_RUSTC_STAGE_TARGET,$(host),$(stage))))))
466
467 rustc-stage1: rustc-stage1-H-$(CFG_BUILD)
468 rustc-stage2: rustc-stage2-H-$(CFG_BUILD)
469 rustc-stage3: rustc-stage3-H-$(CFG_BUILD)
470
471 define DEF_RUSTC_TARGET
472 # $(1) == architecture
473
474 rustc-H-$(1): rustc-stage2-H-$(1)
475 endef
476
477 $(foreach host,$(CFG_TARGET),                   \
478  $(eval $(call DEF_RUSTC_TARGET,$(host))))
479
480 rustc-stage1: rustc-stage1-H-$(CFG_BUILD)
481 rustc-stage2: rustc-stage2-H-$(CFG_BUILD)
482 rustc-stage3: rustc-stage3-H-$(CFG_BUILD)
483 rustc: rustc-H-$(CFG_BUILD)
484
485 rustc-H-all: $(foreach host,$(CFG_HOST),rustc-H-$(host))
486
487 ######################################################################
488 # Entrypoint rule
489 ######################################################################
490
491 .DEFAULT_GOAL := all
492
493 define ALL_TARGET_N
494 ifneq ($$(findstring $(1),$$(CFG_HOST)),)
495 # This is a host
496 all-target-$(1)-host-$(2): $$(CSREQ2_T_$(1)_H_$(2))
497 else
498 # This is a target only
499 all-target-$(1)-host-$(2): $$(SREQ2_T_$(1)_H_$(2))
500 endif
501 endef
502
503 $(foreach target,$(CFG_TARGET), \
504  $(foreach host,$(CFG_HOST), \
505  $(eval $(call ALL_TARGET_N,$(target),$(host)))))
506
507 ALL_TARGET_RULES = $(foreach target,$(CFG_TARGET), \
508         $(foreach host,$(CFG_HOST), \
509  all-target-$(target)-host-$(host)))
510
511 all: $(ALL_TARGET_RULES) $(GENERATED) docs
512
513 ######################################################################
514 # Build system documentation
515 ######################################################################
516
517 # $(1) is the name of the doc <section> in Makefile.in
518 # pick everything between tags | remove first line | remove last line
519 # | remove extra (?) line | strip leading `#` from lines
520 SHOW_DOCS = $(Q)awk '/<$(1)>/,/<\/$(1)>/' $(S)/Makefile.in | sed '1d' | sed '$$d' | sed 's/^\# \?//'
521
522 help:
523         $(call SHOW_DOCS,help)
524
525 tips:
526         $(call SHOW_DOCS,tips)
527
528 nitty-gritty:
529         $(call SHOW_DOCS,nitty-gritty)