1 | # $Id: header.kmk 1501 2008-04-07 23:52:19Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild - File included at top of a makefile.
|
---|
5 | #
|
---|
6 | # Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@anduin.net>
|
---|
7 | #
|
---|
8 | #
|
---|
9 | # This file is part of kBuild.
|
---|
10 | #
|
---|
11 | # kBuild is free software; you can redistribute it and/or modify
|
---|
12 | # it under the terms of the GNU General Public License as published by
|
---|
13 | # the Free Software Foundation; either version 2 of the License, or
|
---|
14 | # (at your option) any later version.
|
---|
15 | #
|
---|
16 | # kBuild is distributed in the hope that it will be useful,
|
---|
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | # GNU General Public License for more details.
|
---|
20 | #
|
---|
21 | # You should have received a copy of the GNU General Public License
|
---|
22 | # along with kBuild; if not, write to the Free Software
|
---|
23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
24 | #
|
---|
25 | #
|
---|
26 |
|
---|
27 | ifndef __header_kmk__
|
---|
28 | # start-of-file-content
|
---|
29 | ifdef KBUILD_PROFILE_SELF
|
---|
30 | _KBUILD_TS_HEADER_START := $(nanots ) # just a dummy warm up query
|
---|
31 | $(info prof: since start - since previous - event description)
|
---|
32 | $(info stat: $(make-stats ))
|
---|
33 | _KBUILD_TS_HEADER_START := $(nanots )
|
---|
34 | _KBUILD_TS_PREV := $(_KBUILD_TS_HEADER_START)
|
---|
35 | endif
|
---|
36 |
|
---|
37 |
|
---|
38 | #
|
---|
39 | # Check make version before we do anything else.
|
---|
40 | #
|
---|
41 | ifndef KMK_VERSION
|
---|
42 | $(error kBuild: The kmk default variable KMK_VERSION isn't defined! Make sure you are using 'kmk' and not 'make', 'gmake', 'kmk_gmake', 'dmake' or any other make program)
|
---|
43 | endif
|
---|
44 | ifneq ($(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR),0.1)
|
---|
45 | ifneq ($(KBUILD_VERSION_MAJOR),0)
|
---|
46 | $(warning kBuild: kmk major version mismatch! Expected '0' but found '$(KBUILD_VERSION_MAJOR)'!)
|
---|
47 | else
|
---|
48 | $(warning kBuild: kmk minor version mismatch! Expected '1' but found '$(KBUILD_VERSION_MINOR)'!)
|
---|
49 | endif
|
---|
50 | else
|
---|
51 | ifneq ($(int-ge $(KBUILD_VERSION_PATCH),2),1)
|
---|
52 | $(warning kBuild: kmk version mismatch! Expected 0.1.2 or later. Actual version is $(KBUILD_VERSION_MAJOR).$(KBUILD_VERSION_MINOR).$(KBUILD_VERSION_PATCH).)
|
---|
53 | endif
|
---|
54 | endif
|
---|
55 |
|
---|
56 | #
|
---|
57 | # The revision in which this file was last modified.
|
---|
58 | # This can be useful when using development versions of kBuild.
|
---|
59 | #
|
---|
60 | KMK_REVISION := $(patsubst %:,, $Rev: 1501 $ )
|
---|
61 |
|
---|
62 |
|
---|
63 | #
|
---|
64 | # Define the default goal.
|
---|
65 | #
|
---|
66 | .PHONY: all all_recursive
|
---|
67 | all: all_recursive
|
---|
68 |
|
---|
69 | #
|
---|
70 | # The phony FORCE target.
|
---|
71 | #
|
---|
72 | .PHONY: FORCE
|
---|
73 | FORCE:
|
---|
74 |
|
---|
75 |
|
---|
76 | #
|
---|
77 | # Enable delete on error and second expansion of prerequisites.
|
---|
78 | #
|
---|
79 | .DELETE_ON_ERROR:
|
---|
80 |
|
---|
81 | .SECONDEXPANSION:
|
---|
82 |
|
---|
83 |
|
---|
84 | #
|
---|
85 | # General purpose macros.
|
---|
86 | #
|
---|
87 |
|
---|
88 | ##
|
---|
89 | # Newline character(s).
|
---|
90 | define NL
|
---|
91 |
|
---|
92 |
|
---|
93 | endef
|
---|
94 |
|
---|
95 | ##
|
---|
96 | # Tab character.
|
---|
97 | TAB := $(subst ., ,.)
|
---|
98 |
|
---|
99 | ##
|
---|
100 | # Newline + tab characters (for generating commands).
|
---|
101 | NLTAB = $(NL)$(TAB)
|
---|
102 |
|
---|
103 | ##
|
---|
104 | # Space character.
|
---|
105 | SP := $(subst ., ,.)
|
---|
106 |
|
---|
107 | ##
|
---|
108 | # Hash character.
|
---|
109 | define HASH
|
---|
110 | #
|
---|
111 | endef
|
---|
112 |
|
---|
113 | ##
|
---|
114 | # Colon character.
|
---|
115 | COLON := :
|
---|
116 |
|
---|
117 | ##
|
---|
118 | # Semicolon character.
|
---|
119 | SEMICOLON := ;
|
---|
120 |
|
---|
121 | ##
|
---|
122 | # Comma character.
|
---|
123 | COMMA := ,
|
---|
124 |
|
---|
125 | ##
|
---|
126 | # Dot character.
|
---|
127 | DOT := .
|
---|
128 |
|
---|
129 | ##
|
---|
130 | # Dollar character.
|
---|
131 | DOLLAR := $$
|
---|
132 |
|
---|
133 | ##
|
---|
134 | # Equal character.
|
---|
135 | EQUAL := =
|
---|
136 |
|
---|
137 |
|
---|
138 | #
|
---|
139 | # The list of standard build types in kBuild.
|
---|
140 | #
|
---|
141 | # This list can be extended in Config.kmk and it's possible to extend
|
---|
142 | # (inherit) another build type.
|
---|
143 | #
|
---|
144 | KBUILD_BLD_TYPES := release profile debug
|
---|
145 |
|
---|
146 |
|
---|
147 | #
|
---|
148 | # The OSes, Architectures and CPUs that kBuild recognizes.
|
---|
149 | #
|
---|
150 | # When kBuild is ported to a new OS or architecture a unique keyword needs
|
---|
151 | # to be assigned to it and added here. This strictness is required because
|
---|
152 | # this keyword namespace is shared between OSes, architectures, cpus and
|
---|
153 | # build types. (PORTME)
|
---|
154 | #
|
---|
155 | KBUILD_OSES := darwin freebsd l4 linux netbsd nt openbsd os2 solaris win
|
---|
156 | KBUILD_ARCHES := x86 amd64 sparc32 sparc64 s390 s390x ppc32 ppc64 mips32 mips64 ia64 hppa32 hppa64 arm alpha
|
---|
157 |
|
---|
158 |
|
---|
159 | #
|
---|
160 | # Set default build type.
|
---|
161 | #
|
---|
162 | ifndef BUILD_TYPE
|
---|
163 | BUILD_TYPE := release
|
---|
164 | else
|
---|
165 | if1of ($(BUILD_TYPE), $(KBUILD_OSES) $(KBUILD_ARCHES))
|
---|
166 | $(error kBuild: The BUILD_TYPE value '$(BUILD_TYPE)' is an OS or architecture!)
|
---|
167 | endif
|
---|
168 | ifneq (.$(words $(BUILD_TYPE)).$(BUILD_TYPE).,.1.$(strip $(BUILD_TYPE)).)
|
---|
169 | $(error kBuild: The BUILD_TYPE value '$(BUILD_TYPE)' contains spaces/tabs!)
|
---|
170 | endif
|
---|
171 | endif
|
---|
172 |
|
---|
173 |
|
---|
174 | #
|
---|
175 | # Assert valid build platform variables.
|
---|
176 | #
|
---|
177 | # All these are set by kmk so they shouldn't be any trouble
|
---|
178 | # unless the user starts messing about with environment variables.
|
---|
179 | #
|
---|
180 | ifneq (.$(words $(BUILD_PLATFORM)).$(BUILD_PLATFORM).,.1.$(strip $(BUILD_PLATFORM)).)
|
---|
181 | $(error kBuild: The BUILD_PLATFORM value '$(BUILD_PLATFORM)' contains spaces/tabs!)
|
---|
182 | endif
|
---|
183 | ifneq ($(words $(filter $(BUILD_PLATFORM),$(KBUILD_OSES))),1)
|
---|
184 | $(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' is not recognized (valid: $(KBUILD_OSES)))
|
---|
185 | endif
|
---|
186 |
|
---|
187 | ifneq (.$(words $(BUILD_PLATFORM_ARCH)).$(BUILD_PLATFORM_ARCH).,.1.$(strip $(BUILD_PLATFORM_ARCH)).)
|
---|
188 | $(error kBuild: The BUILD_PLATFORM_ARCH value '$(BUILD_PLATFORM_ARCH)' contains spaces/tabs!)
|
---|
189 | endif
|
---|
190 | ifneq ($(words $(filter $(BUILD_PLATFORM_ARCH),$(KBUILD_ARCHES))),1)
|
---|
191 | $(error kBuild: BUILD_PLATFORM_ARCH value '$(BUILD_PLATFORM_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
|
---|
192 | endif
|
---|
193 |
|
---|
194 | ifeq ($(strip $(BUILD_PLATFORM_CPU)),)
|
---|
195 | BUILD_PLATFORM_CPU := blend
|
---|
196 | else
|
---|
197 | ifneq (.$(words $(BUILD_PLATFORM_CPU)).$(BUILD_PLATFORM_CPU).,.1.$(strip $(BUILD_PLATFORM_CPU)).)
|
---|
198 | $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' contains spaces/tabs!)
|
---|
199 | endif
|
---|
200 | if1of ($(BUILD_PLATFORM_CPU), $(KBUILD_OSES) $(BUILD_ARCHES))
|
---|
201 | $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' was found in the OS or architecture keywords!)
|
---|
202 | endif
|
---|
203 | ifeq ($(BUILD_PLATFORM_CPU),$(BUILD_TYPE))
|
---|
204 | $(error kBuild: The BUILD_PLATFORM_CPU value '$(BUILD_PLATFORM_CPU)' is the same as the BUILD_TYPE!)
|
---|
205 | endif
|
---|
206 | endif
|
---|
207 |
|
---|
208 |
|
---|
209 | #
|
---|
210 | # Assert or set default target platform.
|
---|
211 | # When not defined use the corresponding BUILD_PLATFORM value.
|
---|
212 | #
|
---|
213 | ifndef BUILD_TARGET
|
---|
214 | BUILD_TARGET := $(BUILD_PLATFORM)
|
---|
215 | else
|
---|
216 | ifneq (.$(words $(BUILD_TARGET)).$(BUILD_TARGET).,.1.$(strip $(BUILD_TARGET)).)
|
---|
217 | $(error kBuild: The BUILD_TARGET value '$(BUILD_TARGET)' contains spaces/tabs!)
|
---|
218 | endif
|
---|
219 | ifneq ($(words $(filter $(BUILD_TARGET),$(KBUILD_OSES))),1)
|
---|
220 | $(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' is not recognized (valid: $(KBUILD_OSES)))
|
---|
221 | endif
|
---|
222 | endif
|
---|
223 |
|
---|
224 | ifndef BUILD_TARGET_ARCH
|
---|
225 | BUILD_TARGET_ARCH := $(BUILD_PLATFORM_ARCH)
|
---|
226 | else
|
---|
227 | ifneq (.$(words $(BUILD_TARGET_ARCH)).$(BUILD_TARGET_ARCH).,.1.$(strip $(BUILD_TARGET_ARCH)).)
|
---|
228 | $(error kBuild: The BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)' contains spaces/tabs!)
|
---|
229 | endif
|
---|
230 | ifneq ($(words $(filter $(BUILD_TARGET_ARCH),$(KBUILD_ARCHES))),1)
|
---|
231 | $(error kBuild: BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)' is not recognized (valid: $(KBUILD_ARCHES)))
|
---|
232 | endif
|
---|
233 | endif
|
---|
234 |
|
---|
235 | ifndef BUILD_TARGET_CPU
|
---|
236 | BUILD_TARGET_CPU := $(BUILD_PLATFORM_CPU)
|
---|
237 | else ifeq ($(strip $(BUILD_TARGET_CPU)),)
|
---|
238 | ifeq ($(BUILD_TARGET_ARCH),$(BUILD_PLATFORM_ARCH))
|
---|
239 | BUILD_TARGET_CPU := $(BUILD_PLATFORM_CPU)
|
---|
240 | else
|
---|
241 | BUILD_TARGET_CPU := blend
|
---|
242 | endif
|
---|
243 | else
|
---|
244 | ifneq (.$(words $(BUILD_TARGET_CPU)).$(BUILD_TARGET_CPU).,.1.$(strip $(BUILD_TARGET_CPU)).)
|
---|
245 | $(error kBuild: The BUILD_TARGET_CPU value '$(BUILD_TARGET_CPU)' contains spaces/tabs!)
|
---|
246 | endif
|
---|
247 | if1of ($(BUILD_TARGET_CPU), $(KBUILD_OSES) $(BUILD_ARCHES))
|
---|
248 | $(error kBuild: The BUILD_TARGET_CPU value was found in the OS or architecture keywords!)
|
---|
249 | endif
|
---|
250 | ifeq ($(BUILD_TARGET_CPU),$(BUILD_TYPE))
|
---|
251 | $(error kBuild: The BUILD_TARGET_CPU value '$(BUILD_TARGET_CPU)' is the same as the BUILD_TYPE!)
|
---|
252 | endif
|
---|
253 | endif
|
---|
254 |
|
---|
255 |
|
---|
256 | #
|
---|
257 | # Paths and stuff.
|
---|
258 | #
|
---|
259 |
|
---|
260 | # Adjust DEPTH first.
|
---|
261 | DEPTH := $(strip $(DEPTH))
|
---|
262 | ifeq ($(DEPTH),)
|
---|
263 | DEPTH := .
|
---|
264 | endif
|
---|
265 |
|
---|
266 | ## PATH_CURRENT is the current directory (getcwd).
|
---|
267 | PATH_CURRENT := $(abspath $(CURDIR))
|
---|
268 | ## PATH_SUB_CURRENT points to current directory of the current makefile.
|
---|
269 | # Meaning that it will change value as we enter and exit sub-makefiles.
|
---|
270 | PATH_SUB_CURRENT := $(PATH_CURRENT)
|
---|
271 | ## PATH_ROOT points to the project root directory.
|
---|
272 | PATH_ROOT := $(abspath $(PATH_CURRENT)/$(DEPTH))
|
---|
273 | ## PATH_SUB_ROOT points to the directory of the top-level makefile.
|
---|
274 | ifneq ($(strip $(SUB_DEPTH)),)
|
---|
275 | SUB_DEPTH := $(strip $(SUB_DEPTH))
|
---|
276 | PATH_SUB_ROOT := $(abspath $(PATH_CURRENT)/$(SUB_DEPTH))
|
---|
277 | else
|
---|
278 | PATH_SUB_ROOT := $(PATH_CURRENT)
|
---|
279 | endif
|
---|
280 |
|
---|
281 | ## CURSUBDIR is PATH_SUB_ROOT described relative to PATH_ROOT.
|
---|
282 | # This variable is used to determin where the object files and other output goes.
|
---|
283 | ifneq ($(PATH_ROOT),$(PATH_SUB_ROOT))
|
---|
284 | CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(PATH_SUB_ROOT))
|
---|
285 | else
|
---|
286 | CURSUBDIR := .
|
---|
287 | endif
|
---|
288 |
|
---|
289 | # Output directories.
|
---|
290 | ifndef PATH_OUT_BASE
|
---|
291 | PATH_OUT_BASE := $(PATH_ROOT)/out
|
---|
292 | endif
|
---|
293 | ifndef PATH_OUT
|
---|
294 | ifdef BUILD_TARGET_SUB # (BUILD_TARGET_SUB is not currently recognized by kBuild in any other places.)
|
---|
295 | PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET).$(BUILD_TARGET_ARCH).$(BUILD_TARGET_SUB)/$(BUILD_TYPE)
|
---|
296 | else
|
---|
297 | PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET).$(BUILD_TARGET_ARCH)/$(BUILD_TYPE)
|
---|
298 | endif
|
---|
299 | endif # !define PATH_OUT
|
---|
300 | PATH_OBJCACHE = $(PATH_OUT_BASE)/kObjCache
|
---|
301 | PATH_OBJ = $(PATH_OUT)/obj
|
---|
302 | PATH_TARGET = $(PATH_OBJ)/$(CURSUBDIR)
|
---|
303 | PATH_INS = $(PATH_OUT)
|
---|
304 | PATH_BIN = $(PATH_INS)/bin
|
---|
305 | PATH_DLL = $(PATH_INS)/bin
|
---|
306 | PATH_SYS = $(PATH_INS)/bin
|
---|
307 | PATH_LIB = $(PATH_INS)/lib
|
---|
308 | PATH_DOC = $(PATH_INS)/doc
|
---|
309 |
|
---|
310 | # PATH_KBUILD is determined by kmk.
|
---|
311 | ifeq ($(strip $(PATH_KBUILD)),)
|
---|
312 | $(error kBuild: PATH_KBUILD is missing or empty! kmk is supposed to set it.)
|
---|
313 | endif
|
---|
314 | # PATH_KBUILD_BIN is determined by kmk.
|
---|
315 | ifeq ($(strip $(PATH_KBUILD_BIN)),)
|
---|
316 | $(error kBuild: PATH_KBUILD_BIN is missing or empty! kmk is supposed to set it.)
|
---|
317 | endif
|
---|
318 |
|
---|
319 | # kBuild files which might be of interest.
|
---|
320 | FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk
|
---|
321 | #FILE_KBUILD_CONFIG := $(PATH_KBUILD)/config.kmk
|
---|
322 | FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk
|
---|
323 |
|
---|
324 | ## MAKEFILE is the name of the main makefile.
|
---|
325 | MAKEFILE := $(firstword $(MAKEFILE_LIST))
|
---|
326 | ## MAKEFILE_CURRENT is the name of the current makefile.
|
---|
327 | # This is updated everything a sub-makefile is included.
|
---|
328 | MAKEFILE_CURRENT := $(MAKEFILE)
|
---|
329 |
|
---|
330 |
|
---|
331 | #
|
---|
332 | # Build platform setup.
|
---|
333 | # (PORTME)
|
---|
334 | #
|
---|
335 |
|
---|
336 | # OS/2
|
---|
337 | ifeq ($(BUILD_PLATFORM),os2)
|
---|
338 | EXEC_X86_WIN32 := innopec.exe
|
---|
339 | HOSTSUFF_EXE := .exe
|
---|
340 | endif
|
---|
341 |
|
---|
342 | # Linux
|
---|
343 | ifeq ($(BUILD_PLATFORM),linux)
|
---|
344 | EXEC_X86_WIN32 := wine
|
---|
345 | HOSTSUFF_EXE :=
|
---|
346 | endif
|
---|
347 |
|
---|
348 | # Win, Win32, Win64, NT.
|
---|
349 | if1of ($(BUILD_PLATFORM), win nt)
|
---|
350 | EXEC_X86_WIN32 :=
|
---|
351 | HOSTSUFF_EXE := .exe
|
---|
352 | endif
|
---|
353 |
|
---|
354 | # FreeBSD
|
---|
355 | ifeq ($(BUILD_PLATFORM),freebsd)
|
---|
356 | EXEC_X86_WIN32 := wine
|
---|
357 | HOSTSUFF_EXE :=
|
---|
358 | endif
|
---|
359 |
|
---|
360 | # Darwin / Mac OS X
|
---|
361 | ifeq ($(BUILD_PLATFORM),darwin)
|
---|
362 | EXEC_X86_WIN32 := false
|
---|
363 | HOSTSUFF_EXE :=
|
---|
364 | endif
|
---|
365 |
|
---|
366 | # Solaris
|
---|
367 | ifeq ($(BUILD_PLATFORM),solaris)
|
---|
368 | EXEC_X86_WIN32 := false
|
---|
369 | HOSTSUFF_EXE :=
|
---|
370 | endif
|
---|
371 |
|
---|
372 |
|
---|
373 | #
|
---|
374 | # Build target setup.
|
---|
375 | # (PORTME)
|
---|
376 | #
|
---|
377 | SUFF_DEP := .dep
|
---|
378 | if1of ($(BUILD_TARGET), win nt os2)
|
---|
379 | SUFF_OBJ := .obj
|
---|
380 | SUFF_LIB := .lib
|
---|
381 | SUFF_DLL := .dll
|
---|
382 | SUFF_EXE := .exe
|
---|
383 | SUFF_SYS := .sys
|
---|
384 | SUFF_RES := .res
|
---|
385 | else ifeq ($(BUILD_TARGET),l4)
|
---|
386 | SUFF_OBJ := .o
|
---|
387 | SUFF_LIB := .a
|
---|
388 | SUFF_DLL := .s.so
|
---|
389 | SUFF_EXE :=
|
---|
390 | SUFF_SYS := .a
|
---|
391 | SUFF_RES :=
|
---|
392 | else ifeq ($(BUILD_TARGET),darwin)
|
---|
393 | SUFF_OBJ := .o
|
---|
394 | SUFF_LIB := .a
|
---|
395 | SUFF_DLL := .dylib
|
---|
396 | SUFF_EXE :=
|
---|
397 | SUFF_SYS :=
|
---|
398 | SUFF_RES :=
|
---|
399 | else
|
---|
400 | SUFF_OBJ := .o
|
---|
401 | SUFF_LIB := .a
|
---|
402 | SUFF_DLL := .so
|
---|
403 | SUFF_EXE :=
|
---|
404 | if1of ($(BUILD_TARGET), freebsd linux netbsd openbsd) ## @todo check netbsd and openbsd.
|
---|
405 | SUFF_SYS := .ko
|
---|
406 | else
|
---|
407 | SUFF_SYS :=
|
---|
408 | endif
|
---|
409 | SUFF_RES :=
|
---|
410 | endif
|
---|
411 |
|
---|
412 | #
|
---|
413 | # Standard kBuild tools.
|
---|
414 | #
|
---|
415 | ifeq ($(KMK),kmk)
|
---|
416 | KMK := $(PATH_KBUILD_BIN)/kmk$(HOSTSUFF_EXE)
|
---|
417 | endif
|
---|
418 | MAKE := $(KMK)
|
---|
419 |
|
---|
420 | GMAKE := $(PATH_KBUILD_BIN)/kmk_gmake$(HOSTSUFF_EXE)
|
---|
421 |
|
---|
422 | DEP_EXT := $(PATH_KBUILD_BIN)/kDep$(HOSTSUFF_EXE)
|
---|
423 | if1of (kDep, $(KMK_BUILTIN))
|
---|
424 | DEP := kmk_builtin_kDep
|
---|
425 | else
|
---|
426 | DEP := $(DEP_EXT)
|
---|
427 | endif
|
---|
428 |
|
---|
429 | DEP_IDB_EXT := $(PATH_KBUILD_BIN)/kDepIDB$(HOSTSUFF_EXE)
|
---|
430 | if1of (kDepIDB, $(KMK_BUILTIN))
|
---|
431 | DEP_IDB := kmk_builtin_kDepIDB
|
---|
432 | else
|
---|
433 | DEP_IDB := $(DEP_IDB_EXT)
|
---|
434 | endif
|
---|
435 |
|
---|
436 | DEP_PRE_EXT := $(PATH_KBUILD_BIN)/kDepPre$(HOSTSUFF_EXE)
|
---|
437 | if1of (kDepPre, $(KMK_BUILTIN))
|
---|
438 | DEP_PRE := kmk_builtin_kDepPre
|
---|
439 | else
|
---|
440 | DEP_PRE := $(DEP_PRE_EXT)
|
---|
441 | endif
|
---|
442 |
|
---|
443 | KOBJCACHE_EXT := $(PATH_KBUILD_BIN)/kObjCache$(HOSTSUFF_EXE)
|
---|
444 | if1of (kObjCache, $(KMK_BUILTIN))
|
---|
445 | KOBJCACHE := kmk_builtin_kObjCache
|
---|
446 | else
|
---|
447 | KOBJCACHE := $(KOBJCACHE_EXT)
|
---|
448 | endif
|
---|
449 |
|
---|
450 | APPEND_EXT := $(PATH_KBUILD_BIN)/kmk_append$(HOSTSUFF_EXE)
|
---|
451 | APPEND := kmk_builtin_append
|
---|
452 |
|
---|
453 | CAT_EXT := $(PATH_KBUILD_BIN)/kmk_cat$(HOSTSUFF_EXE)
|
---|
454 | CAT := kmk_builtin_cat
|
---|
455 |
|
---|
456 | CMP_EXT := $(PATH_KBUILD_BIN)/kmk_cmp$(HOSTSUFF_EXE)
|
---|
457 | CMP := kmk_builtin_cmp
|
---|
458 |
|
---|
459 | CP_EXT := $(PATH_KBUILD_BIN)/kmk_cp$(HOSTSUFF_EXE)
|
---|
460 | CP := kmk_builtin_cp
|
---|
461 |
|
---|
462 | ECHO_EXT := $(PATH_KBUILD_BIN)/kmk_echo$(HOSTSUFF_EXE)
|
---|
463 | ECHO := kmk_builtin_echo
|
---|
464 |
|
---|
465 | INSTALL_EXT := $(PATH_KBUILD_BIN)/kmk_install$(HOSTSUFF_EXE)
|
---|
466 | INSTALL := kmk_builtin_install
|
---|
467 |
|
---|
468 | LN_EXT := $(PATH_KBUILD_BIN)/kmk_ln$(HOSTSUFF_EXE)
|
---|
469 | LN := kmk_builtin_ln
|
---|
470 |
|
---|
471 | MD5SUM_EXT := $(PATH_KBUILD_BIN)/kmk_md5sum$(HOSTSUFF_EXE)
|
---|
472 | MD5SUM := kmk_builtin_md5sum
|
---|
473 |
|
---|
474 | MKDIR_EXT := $(PATH_KBUILD_BIN)/kmk_mkdir$(HOSTSUFF_EXE)
|
---|
475 | MKDIR := kmk_builtin_mkdir
|
---|
476 |
|
---|
477 | MV_EXT := $(PATH_KBUILD_BIN)/kmk_mv$(HOSTSUFF_EXE)
|
---|
478 | MV := kmk_builtin_mv
|
---|
479 |
|
---|
480 | PRINTF_EXT := $(PATH_KBUILD_BIN)/kmk_printf$(HOSTSUFF_EXE)
|
---|
481 | PRINTF := kmk_builtin_printf
|
---|
482 |
|
---|
483 | REDIRECT_EXT:= $(PATH_KBUILD_BIN)/kmk_redirect$(HOSTSUFF_EXE)
|
---|
484 | if1of (redirect, $(KMK_BUILTIN))
|
---|
485 | REDIRECT := kmk_builtin_redirect
|
---|
486 | else
|
---|
487 | REDIRECT := $(REDIRECT_EXT)
|
---|
488 | endif
|
---|
489 |
|
---|
490 | RM_EXT := $(PATH_KBUILD_BIN)/kmk_rm$(HOSTSUFF_EXE)
|
---|
491 | RM := kmk_builtin_rm
|
---|
492 |
|
---|
493 | RMDIR_EXT := $(PATH_KBUILD_BIN)/kmk_rmdir$(HOSTSUFF_EXE)
|
---|
494 | RMDIR := kmk_builtin_rmdir
|
---|
495 |
|
---|
496 | SED_EXT := $(PATH_KBUILD_BIN)/kmk_sed$(HOSTSUFF_EXE)
|
---|
497 | if1of (sed, $(KMK_BUILTIN))
|
---|
498 | SED_INT := kmk_builtin_sed
|
---|
499 | else
|
---|
500 | SED_INT := $(SED_EXT)
|
---|
501 | endif
|
---|
502 | SED := $(SED_EXT)
|
---|
503 |
|
---|
504 | TEST_EXT := $(PATH_KBUILD_BIN)/kmk_test$(HOSTSUFF_EXE)
|
---|
505 | TEST := kmk_builtin_test
|
---|
506 |
|
---|
507 | # Our default shell is the Almquist shell from *BSD.
|
---|
508 | ASH := $(PATH_KBUILD_BIN)/kmk_ash$(HOSTSUFF_EXE)
|
---|
509 | MAKESHELL := $(ASH)
|
---|
510 | SHELL := $(ASH)
|
---|
511 | export SHELL MAKESHELL
|
---|
512 |
|
---|
513 | # Symlinking is problematic on some platforms...
|
---|
514 | LN_SYMLINK := $(LN) -s
|
---|
515 |
|
---|
516 |
|
---|
517 | #
|
---|
518 | # Some Functions.
|
---|
519 | # The lower cased ones are either fallbacks or candidates for functions.c.
|
---|
520 | #
|
---|
521 |
|
---|
522 | ## ABSPATH - make paths absolute.
|
---|
523 | # This implementation is clumsy and doesn't resolve '..' and '.' components.
|
---|
524 | #
|
---|
525 | # @param $1 The paths to make absolute.
|
---|
526 | # @obsolete Use the GNU make function $(abspath) directly now.
|
---|
527 | ABSPATH = $(abspath $(1))$(warning ABSPATH is deprecated, use abspath directly!)
|
---|
528 |
|
---|
529 | ## DIRDEP - make create directory dependencies.
|
---|
530 | #
|
---|
531 | # @param $1 The paths to the directories which must be created.
|
---|
532 | DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
|
---|
533 |
|
---|
534 | ## Cygwin kludge.
|
---|
535 | # This converts /cygdrive/x/% to x:%.
|
---|
536 | #
|
---|
537 | # @param $1 The paths to make native.
|
---|
538 | # @remark This macro is pretty much obsolete since we don't use cygwin base make.
|
---|
539 | ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
|
---|
540 | CYGPATHMIXED = $(foreach path,$(1)\
|
---|
541 | ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
|
---|
542 | else
|
---|
543 | CYGPATHMIXED = $(1)
|
---|
544 | endif
|
---|
545 |
|
---|
546 | ## Removes the drive letter from a path (if it has one)
|
---|
547 | # @param $1 the path
|
---|
548 | no-drive = $(word $(words $(subst :, ,$(1))),$(subst :, ,$(1)))
|
---|
549 |
|
---|
550 | ## Removes the root slash from a path (if it has one)
|
---|
551 | # @param $1 the path
|
---|
552 | no-root-slash = $(patsubst /%,%,$(1))
|
---|
553 |
|
---|
554 | ## Figure out where to put object files.
|
---|
555 | # @param $1 real target name.
|
---|
556 | # @param $2 normalized main target
|
---|
557 | TARGET_BASE = $(PATH_TARGET)/$(2)/$(call no-root-slash,$(call no-drive,$(1)))
|
---|
558 |
|
---|
559 | ## Figure out where to put object files.
|
---|
560 | # @param $1 normalized main target
|
---|
561 | TARGET_PATH = $(PATH_TARGET)/$(1)
|
---|
562 |
|
---|
563 |
|
---|
564 | #
|
---|
565 | # Initialize some of the globals which the Config.kmk and
|
---|
566 | # others can add stuff to if they like for processing in the footer.
|
---|
567 | #
|
---|
568 |
|
---|
569 | ## KBUILD_TEMPLATE_PATHS
|
---|
570 | # List a paths (separated by space) where templates can be found.
|
---|
571 | KBUILD_TEMPLATE_PATHS :=
|
---|
572 |
|
---|
573 | ## KBUILD_TOOL_PATHS
|
---|
574 | # List of paths (separated by space) where tools can be found.
|
---|
575 | KBUILD_TOOL_PATHS :=
|
---|
576 |
|
---|
577 | ## KBUILD_SDK_PATHS
|
---|
578 | # List of paths (separated by space) where SDKs can be found.
|
---|
579 | KBUILD_SDK_PATHS :=
|
---|
580 |
|
---|
581 | ## KBUILD_DEFAULT_PATHS
|
---|
582 | # List of paths (separated by space) to search for stuff as a last resort.
|
---|
583 | KBUILD_DEFAULT_PATHS :=
|
---|
584 |
|
---|
585 | ## Proritized list of the default makefile when walking subdirectories.
|
---|
586 | # The user can overload this list.
|
---|
587 | DEFAULT_MAKEFILE := Makefile.kmk makefile.kmk Makefile makefile
|
---|
588 |
|
---|
589 | ## KBUILD_SRC_HANDLERS
|
---|
590 | # The list of source handlers, pair of extension and handler.
|
---|
591 | # The user can overload this list to provide additional or custom
|
---|
592 | # handlers. On a per-target/template see SRC_HANDLERS.
|
---|
593 | KBUILD_SRC_HANDLERS := \
|
---|
594 | .c:def_src_handler_c \
|
---|
595 | .C:def_src_handler_c \
|
---|
596 | .cxx:def_src_handler_cxx \
|
---|
597 | .CXX:def_src_handler_cxx \
|
---|
598 | .cpp:def_src_handler_cxx \
|
---|
599 | .CPP:def_src_handler_cxx \
|
---|
600 | .cc:def_src_handler_cxx \
|
---|
601 | .CC:def_src_handler_cxx \
|
---|
602 | .m:def_src_handler_objc \
|
---|
603 | .asm:def_src_handler_asm \
|
---|
604 | .ASM:def_src_handler_asm \
|
---|
605 | .s:def_src_handler_asm \
|
---|
606 | .S:def_src_handler_asm \
|
---|
607 | .rc:def_src_handler_rc \
|
---|
608 | .obj:def_src_handler_obj \
|
---|
609 | .o:def_src_handler_obj \
|
---|
610 | .res:def_src_handler_obj
|
---|
611 |
|
---|
612 | ## PROPS_TOOLS
|
---|
613 | # This is a subset of PROPS_SINGLE.
|
---|
614 | PROPS_TOOLS := TOOL CTOOL CXXTOOL OBJCTOOL ASTOOL RCTOOL ARTOOL LDTOOL FETCHTOOL UNPACKTOOL PATCHTOOL
|
---|
615 |
|
---|
616 | ## PROPS_SINGLE
|
---|
617 | # The list of non-accumulative target properties.
|
---|
618 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
619 | # will do the necessary inheritance for templates, sdks, tools and targets.
|
---|
620 | PROPS_SINGLE := $(PROPS_TOOLS) TEMPLATE INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU FETCHDIR \
|
---|
621 | OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF ASOBJSUFF RCOBJSUFF SYSSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF
|
---|
622 | ## PROPS_SINGLE_LNK
|
---|
623 | # Subset of PROPS_SINGLE which applies to all linkable targets.
|
---|
624 | PROPS_SINGLE_LNK := TOOL TEMPLATE CTOOL CXXTOOL OBJCTOOL ASTOOL RCTOOL \
|
---|
625 | INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU \
|
---|
626 | OBJSUFF COBJSUFF CXXOBJSUFF OBJCOBJSUFF ASOBJSUFF RCOBJSUFF
|
---|
627 |
|
---|
628 | ## PROPS_DEFERRED
|
---|
629 | # This list of non-accumulative target properties which are or may be
|
---|
630 | # functions, and thus should not be expanded until the very last moment.
|
---|
631 | PROPS_DEFERRED := INSTFUN INSTALLER PRE_CMDS POST_CMDS NAME SONAME
|
---|
632 |
|
---|
633 | ## PROPS_ACCUMULATE_R
|
---|
634 | # The list of accumulative target properties where the right most value/flag
|
---|
635 | # is the 'most significant'.
|
---|
636 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
637 | # will do the necessary inheritance from templates to targets.
|
---|
638 | PROPS_ACCUMULATE_R := \
|
---|
639 | DEPS ORDERDEPS DEFS \
|
---|
640 | ARFLAGS \
|
---|
641 | CFLAGS CDEFS \
|
---|
642 | CXXFLAGS CXXDEFS \
|
---|
643 | OBJCFLAGS OBJCDEFS \
|
---|
644 | ASFLAGS ASDEFS \
|
---|
645 | RCFLAGS RCDEFS \
|
---|
646 | LDFLAGS \
|
---|
647 | IDFLAGS IFDLAGS ISFLAGS \
|
---|
648 | FETCHFLAGS UNPACKFLAGS PATCHFLAGS
|
---|
649 | ## PROPS_ACCUMULATE_R_LNK
|
---|
650 | # Subset of PROPS_ACCUMULATE_R which applies to all linkable targets.
|
---|
651 | PROPS_ACCUMULATE_R_LNK := \
|
---|
652 | DEPS ORDERDEPS DEFS \
|
---|
653 | CFLAGS CDEFS \
|
---|
654 | CXXFLAGS CXXDEFS \
|
---|
655 | OBJCFLAGS OBJCDEFS \
|
---|
656 | ASFLAGS ASDEFS \
|
---|
657 | RCFLAGS RCDEFS \
|
---|
658 | IDFLAGS IFDLAGS ISFLAGS
|
---|
659 |
|
---|
660 | ## PROPS_ACCUMULATE
|
---|
661 | # The list of accumulative target properties where the left most value/flag
|
---|
662 | # is the 'most significant'.
|
---|
663 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
664 | # will do the necessary inheritance from templates to targets.
|
---|
665 | PROPS_ACCUMULATE_L := \
|
---|
666 | SDKS SOURCES SRC_HANDLERS INTERMEDIATES \
|
---|
667 | INCS CINCS CXXINCS OBJCINCS ASINCS RCINCS \
|
---|
668 | LIBS LIBPATH \
|
---|
669 | DIRS BLDDIRS CLEAN
|
---|
670 | ## PROPS_ACCUMULATE_L_LNK
|
---|
671 | # Subset of PROPS_ACCUMULATE_L which applies to all linkable targets.
|
---|
672 | PROPS_ACCUMULATE_L_LNK := \
|
---|
673 | SDKS SOURCES SRC_HANDLERS \
|
---|
674 | INCS CINCS CXXINCS OBJCINCS ASINCS RCINCS \
|
---|
675 | BLDDIRS CLEAN
|
---|
676 |
|
---|
677 | ## PROPS_ALL
|
---|
678 | # List of all the properties.
|
---|
679 | PROPS_ALL = $(PROPS_SINGLE) $(PROPS_DEFERRED) $(PROPS_ACCUMULATE_L) $(PROPS_ACCUMULATE_R)
|
---|
680 |
|
---|
681 |
|
---|
682 | ## @name Properties valid on programs (BLDPROGS and PROGRAMS)
|
---|
683 | ## @{
|
---|
684 | PROPS_PROGRAMS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL EXESUFF
|
---|
685 | PROPS_PROGRAMS_DEFERRED := $(PROPS_DEFERRED)
|
---|
686 | PROPS_PROGRAMS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
|
---|
687 | PROPS_PROGRAMS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
|
---|
688 | ## @}
|
---|
689 |
|
---|
690 | ## @name Properties valid on libraries (LIBRARIES and IMPORT_LIBS)
|
---|
691 | ## @{
|
---|
692 | PROPS_LIBRARIES_SINGLE := $(PROPS_SINGLE_LNK) ARTOOL LIBSUFF ARLIBSUFF LIBSUFF
|
---|
693 | PROPS_LIBRARIES_DEFERRED := $(filter-out SONAME,$(PROPS_DEFERRED))
|
---|
694 | PROPS_LIBRARIES_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) ARFLAGS
|
---|
695 | PROPS_LIBRARIES_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK)
|
---|
696 | ## @}
|
---|
697 |
|
---|
698 | ## @name Properties valid on dlls (DLLS)
|
---|
699 | ## @{
|
---|
700 | PROPS_DLLS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL DLLSUFF LIBSUFF
|
---|
701 | PROPS_DLLS_DEFERRED := $(PROPS_DEFERRED)
|
---|
702 | PROPS_DLLS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
|
---|
703 | PROPS_DLLS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
|
---|
704 | ## @}
|
---|
705 |
|
---|
706 | ## @name Properties valid on system modules (SYSMODS)
|
---|
707 | ## @{
|
---|
708 | PROPS_SYSMODS_SINGLE := $(PROPS_SINGLE_LNK) LDTOOL SYSSUFF
|
---|
709 | PROPS_SYSMODS_DEFERRED := $(PROPS_DEFERRED)
|
---|
710 | PROPS_SYSMODS_ACCUMULATE_R := $(PROPS_ACCUMULATE_R_LNK) LDFLAGS
|
---|
711 | PROPS_SYSMODS_ACCUMULATE_L := $(PROPS_ACCUMULATE_L_LNK) LIBS LIBPATH
|
---|
712 | ## @}
|
---|
713 |
|
---|
714 | ## @name Properties valid on installs (INSTALLS)
|
---|
715 | ## @{
|
---|
716 | PROPS_INSTALLS_SINGLE := TOOL TEMPLATE INST NOINST
|
---|
717 | PROPS_INSTALLS_DEFERRED := INSTFUN INSTALLER
|
---|
718 | PROPS_INSTALLS_ACCUMULATE_R := DEPS ORDERDEPS
|
---|
719 | PROPS_INSTALLS_ACCUMULATE_L := SOURCES DIRS CLEAN
|
---|
720 | ## @}
|
---|
721 |
|
---|
722 | ## @name Properties valid on fetches (INSTALLS)
|
---|
723 | ## @{
|
---|
724 | PROPS_FETCHES_SINGLE := TOOL TEMPLATE FETCHTOOL UNPACKTOOL PATCHTOOL INST FETCHDIR
|
---|
725 | PROPS_FETCHES_DEFERRED :=
|
---|
726 | PROPS_FETCHES_ACCUMULATE_R := FETCHFLAGS UNPACKFLAGS PATCHFLAGS
|
---|
727 | PROPS_FETCHES_ACCUMULATE_L := SOURCES
|
---|
728 | ## @}
|
---|
729 |
|
---|
730 |
|
---|
731 | #
|
---|
732 | # Here is a special 'hack' to prevent innocent environment variables being
|
---|
733 | # picked up and treated as properties. (The most annoying example of why
|
---|
734 | # this is necessary is the Visual C++ commandline with it's LIBPATH.)
|
---|
735 | #
|
---|
736 | # Define KBUILD_DONT_KILL_ENV_PROPS in the env. or on the commandline to
|
---|
737 | # disable this 'hack'.
|
---|
738 | #
|
---|
739 | ifndef KBUILD_DONT_KILL_ENV_PROPS
|
---|
740 |
|
---|
741 | define def_nuke_environment_prop
|
---|
742 | ifeq ($(origin $(prop)),environment)
|
---|
743 | $(prop) =
|
---|
744 | endif
|
---|
745 | endef
|
---|
746 | $(foreach prop, $(PROPS_ALL) \
|
---|
747 | FETCHES PATCHES BLDPROGS LIBRARIES IMPORT_LIBS DLLS PROGRAMS SYSMODS INSTALLS OTHERS \
|
---|
748 | SUBDIRS MAKEFILES BLDDIRS \
|
---|
749 | ,$(eval $(value def_nuke_environment_prop)))
|
---|
750 |
|
---|
751 | endif # KBUILD_DONT_KILL_ENV_PROPS
|
---|
752 |
|
---|
753 |
|
---|
754 | #
|
---|
755 | # Pass configuration.
|
---|
756 | #
|
---|
757 | # The PASS_<passname>_trgs variable is listing the targets.
|
---|
758 | # The PASS_<passname>_vars variable is listing the target variables.
|
---|
759 | # The PASS_<passname>_pass variable is the lowercased passname.
|
---|
760 | #
|
---|
761 |
|
---|
762 | ## PASS: fetches
|
---|
763 | # This pass fetches and unpacks things needed to complete the build.
|
---|
764 | PASS_FETCHES := Fetches
|
---|
765 | PASS_FETCHES_trgs :=
|
---|
766 | PASS_FETCHES_vars := _FETCHES
|
---|
767 | PASS_FETCHES_pass := fetches
|
---|
768 |
|
---|
769 | ## PASS: patches
|
---|
770 | # This pass applies patches.
|
---|
771 | PASS_PATCHES := Patches
|
---|
772 | PASS_PATCHES_trgs :=
|
---|
773 | PASS_PATCHES_vars := _PATCHES
|
---|
774 | PASS_PATCHES_pass := patches
|
---|
775 |
|
---|
776 | ## PASS: bldprogs
|
---|
777 | # This pass builds targets which are required for building the rest.
|
---|
778 | PASS_BLDPROGS := Build Programs
|
---|
779 | PASS_BLDPROGS_trgs :=
|
---|
780 | PASS_BLDPROGS_vars := _BLDPROGS
|
---|
781 | PASS_BLDPROGS_pass := bldprogs
|
---|
782 |
|
---|
783 | ## PASS: libraries
|
---|
784 | # This pass builds library targets.
|
---|
785 | PASS_LIBRARIES := Libraries
|
---|
786 | PASS_LIBRARIES_trgs :=
|
---|
787 | PASS_LIBRARIES_vars := _LIBS _IMPORT_LIBS _OTHER_LIBRARIES
|
---|
788 | PASS_LIBRARIES_pass := libraries
|
---|
789 |
|
---|
790 | ## PASS: binaries
|
---|
791 | # This pass builds dll targets.
|
---|
792 | PASS_DLLS := DLLs
|
---|
793 | PASS_DLLS_trgs :=
|
---|
794 | PASS_DLLS_vars := _DLLS _OTHER_DLLS
|
---|
795 | PASS_DLLS_pass := dlls
|
---|
796 |
|
---|
797 | ## PASS: binaries
|
---|
798 | # This pass builds binary targets, i.e. programs, system modules and stuff.
|
---|
799 | PASS_BINARIES := Programs
|
---|
800 | PASS_BINARIES_trgs :=
|
---|
801 | PASS_BINARIES_vars := _PROGRAMS _SYSMODS _OTHER_BINARIES
|
---|
802 | PASS_BINARIES_pass := binaries
|
---|
803 |
|
---|
804 | ## PASS: others
|
---|
805 | # This pass builds other targets.
|
---|
806 | PASS_OTHERS := Other Stuff
|
---|
807 | PASS_OTHERS_trgs :=
|
---|
808 | PASS_OTHERS_vars := _OTHERS
|
---|
809 | PASS_OTHERS_pass := others
|
---|
810 |
|
---|
811 | ## PASS: install
|
---|
812 | # This pass installs the built entities to a sandbox area.
|
---|
813 | PASS_INSTALLS := Install
|
---|
814 | PASS_INSTALLS_trgs :=
|
---|
815 | PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS _INSTALLS_FILES
|
---|
816 | PASS_INSTALLS_pass := installs
|
---|
817 |
|
---|
818 | ## PASS: packing
|
---|
819 | # This pass processes custom packing rules.
|
---|
820 | PASS_PACKING := Packing
|
---|
821 | PASS_PACKING_trgs :=
|
---|
822 | PASS_PACKING_vars := _PACKING
|
---|
823 | PASS_PACKING_pass := packing
|
---|
824 | #alias
|
---|
825 | packing: pass_packing
|
---|
826 |
|
---|
827 | ## PASS: clean
|
---|
828 | # This pass removes all generated files.
|
---|
829 | PASS_CLEAN := Clean
|
---|
830 | PASS_CLEAN_trgs := do-clean
|
---|
831 | PASS_CLEAN_vars :=
|
---|
832 | PASS_CLEAN_pass := clean
|
---|
833 | # alias
|
---|
834 | clean: pass_clean
|
---|
835 |
|
---|
836 | ## PASS: nothing
|
---|
837 | # This pass just walks the tree.
|
---|
838 | PASS_NOTHING := Nothing
|
---|
839 | PASS_NOTHING_trgs := do-nothing
|
---|
840 | PASS_NOTHING_vars :=
|
---|
841 | PASS_NOTHING_pass := nothing
|
---|
842 | # alias
|
---|
843 | nothing: pass_nothing
|
---|
844 |
|
---|
845 | ## DEFAULT_PASSES
|
---|
846 | # The default passes and their order.
|
---|
847 | DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES OTHERS INSTALLS
|
---|
848 |
|
---|
849 | ## PASSES
|
---|
850 | # The passes that should be defined. This must include
|
---|
851 | # all passes mentioned by DEFAULT_PASSES.
|
---|
852 | PASSES := FETCHES PATCHES $(DEFAULT_PASSES) NOTHING CLEAN
|
---|
853 |
|
---|
854 |
|
---|
855 | #
|
---|
856 | # Check for --pretty-command-printing before including the Config.kmk
|
---|
857 | # so that anyone overriding the message macros can take the implied
|
---|
858 | # verbosity level change into account.
|
---|
859 | #
|
---|
860 | ifndef KBUILD_VERBOSE
|
---|
861 | ifndef KBUILD_QUIET
|
---|
862 | ifneq ($(filter --pretty-command-printing,$(MAKEFLAGS)),)
|
---|
863 | export KBUILD_VERBOSE := 2
|
---|
864 | endif
|
---|
865 | endif
|
---|
866 | endif
|
---|
867 |
|
---|
868 |
|
---|
869 | #
|
---|
870 | # Legacy variable translation.
|
---|
871 | # These will be eliminated when switching to the next version.
|
---|
872 | #
|
---|
873 | ifdef USE_KOBJCACHE
|
---|
874 | ifndef KBUILD_USE_KOBJCACHE
|
---|
875 | export KBUILD_USE_KOBJCACHE := $(USE_KOBJCACHE)
|
---|
876 | endif
|
---|
877 | endif
|
---|
878 |
|
---|
879 |
|
---|
880 | #
|
---|
881 | # This is how we find the closest config.kmk.
|
---|
882 | # It's a little hacky but I think it works fine.
|
---|
883 | #
|
---|
884 | _CFGDIR := .
|
---|
885 | _CFGFILES := ./Config.kmk ./config.kmk
|
---|
886 | define def_include_config
|
---|
887 | $(eval _CFGDIR := $(_CFGDIR)/$(dir))
|
---|
888 | _CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
|
---|
889 | endef
|
---|
890 | # walk down the _RELATIVE_ path specified by DEPTH.
|
---|
891 | $(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
|
---|
892 | # add the default config file.
|
---|
893 | _CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
|
---|
894 | _CFGFILES :=
|
---|
895 | _CFGDIR :=
|
---|
896 | ifeq ($(_CFGFILE),)
|
---|
897 | $(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
|
---|
898 | endif
|
---|
899 |
|
---|
900 | # Include the config.kmk we found file (or the default one).
|
---|
901 | ifdef KBUILD_PROFILE_SELF
|
---|
902 | _KBUILD_TS_NOW := $(nanots )
|
---|
903 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - including $(_CFGFILE))
|
---|
904 | $(info stat: $(make-stats ))
|
---|
905 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
906 |
|
---|
907 | include $(_CFGFILE)
|
---|
908 |
|
---|
909 | _KBUILD_TS_NOW := $(nanots )
|
---|
910 | $(info prof: $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_NOW), $(_KBUILD_TS_PREV)) - included $(_CFGFILE))
|
---|
911 | $(info stat: $(make-stats ))
|
---|
912 | _KBUILD_TS_PREV := $(_KBUILD_TS_NOW)
|
---|
913 | else
|
---|
914 | include $(_CFGFILE)
|
---|
915 | endif
|
---|
916 |
|
---|
917 |
|
---|
918 |
|
---|
919 | #
|
---|
920 | # Finalize a the central path variables now that we've included the Config.kmk file.
|
---|
921 | #
|
---|
922 | # This prevents some trouble when users override the defaults for these
|
---|
923 | # variables and uses relative paths or paths with incorrect case.
|
---|
924 | #
|
---|
925 | PATH_OUT := $(abspath $(PATH_OUT))
|
---|
926 | PATH_OBJ := $(abspath $(PATH_OBJ))
|
---|
927 | PATH_TARGET := $(abspath $(PATH_TARGET))
|
---|
928 | PATH_INS := $(abspath $(PATH_INS))
|
---|
929 | PATH_BIN := $(abspath $(PATH_BIN))
|
---|
930 | PATH_DLL := $(abspath $(PATH_DLL))
|
---|
931 | PATH_SYS := $(abspath $(PATH_SYS))
|
---|
932 | PATH_LIB := $(abspath $(PATH_LIB))
|
---|
933 | PATH_DOC := $(abspath $(PATH_DOC))
|
---|
934 |
|
---|
935 |
|
---|
936 | #
|
---|
937 | # Setup the message style. The default one is inlined.
|
---|
938 | #
|
---|
939 | # See kBuild/msgstyles for more styles or use KBUILD_MSG_STYLE_PATHS
|
---|
940 | # to create your own message style.
|
---|
941 | #
|
---|
942 | KBUILD_MSG_STYLE ?= default
|
---|
943 | ifeq ($(KBUILD_MSG_STYLE),default)
|
---|
944 | #
|
---|
945 | # The 'default' style.
|
---|
946 | #
|
---|
947 |
|
---|
948 | ## Fetch starting.
|
---|
949 | # @param 1 Target name.
|
---|
950 | MSG_FETCH ?= $(call MSG_L1,Fetching $1...)
|
---|
951 | ## Re-fetch starting.
|
---|
952 | # @param 1 Target name.
|
---|
953 | MSG_REFETCH ?= $(call MSG_L1,Re-fetching $1...)
|
---|
954 | ## Downloading a fetch component.
|
---|
955 | # @param 1 Target name.
|
---|
956 | # @param 2 The source URL.
|
---|
957 | # @param 3 The destination file name.
|
---|
958 | MSG_FETCH_DL ?= $(call MSG_L1,Downloading $1 - $2,=> $3)
|
---|
959 | ## Checking a fetch component.
|
---|
960 | # @param 1 Target name.
|
---|
961 | # @param 2 The source URL.
|
---|
962 | # @param 3 The destination file name.
|
---|
963 | MSG_FETCH_CHK?= $(call MSG_L1,Checking $1 - $3, ($2))
|
---|
964 | ## Unpacking a fetch component.
|
---|
965 | # @param 1 Target name.
|
---|
966 | # @param 2 The archive file name.
|
---|
967 | # @param 3 The target directory.
|
---|
968 | MSG_FETCH_UP ?= $(call MSG_L1,Unpacking $1 - $2 => $3)
|
---|
969 | ## Fetch completed.
|
---|
970 | # @param 1 Target name.
|
---|
971 | MSG_FETCH_OK ?= $(call MSG_L1,Successfully fetched $1)
|
---|
972 | ## Unfetch a fetch target.
|
---|
973 | # @param 1 Target name.
|
---|
974 | MSG_UNFETCH ?= $(call MSG_L1,Unfetching $1...)
|
---|
975 | ## Compiling a source file.
|
---|
976 | # @param 1 Target name.
|
---|
977 | # @param 2 The source filename.
|
---|
978 | # @param 3 The primary link output file name.
|
---|
979 | # @param 4 The source type (C,CXX,OBJC,AS,RC,++).
|
---|
980 | MSG_COMPILE ?= $(call MSG_L1,Compiling $1 - $2,=> $3)
|
---|
981 | ## Tool
|
---|
982 | # @param 1 The tool name (bin2c,...)
|
---|
983 | # @param 2 Target name.
|
---|
984 | # @param 3 The source filename.
|
---|
985 | # @param 4 The primary output file name.
|
---|
986 | MSG_TOOL ?= $(call MSG_L1,$1 $2 - $3,=> $4)
|
---|
987 | ## Generate a file, typically a source file.
|
---|
988 | # @param 1 Target name if applicable.
|
---|
989 | # @param 2 Output file name.
|
---|
990 | # @param 3 What it's generated from
|
---|
991 | MSG_GENERATE ?= $(call MSG_L1,Generating $(if $1,$1 - )$2,$(if $3,from $3))
|
---|
992 | ## Linking a bldprog/dll/program/sysmod target.
|
---|
993 | # @param 1 Target name.
|
---|
994 | # @param 2 The primary link output file name.
|
---|
995 | # @param 3 The link tool operation (LINK_LIBRARY,LINK_PROGRAM,LINK_DLL,LINK_SYSMOD,++).
|
---|
996 | MSG_LINK ?= $(call MSG_L1,Linking $1,=> $2)
|
---|
997 | ## Merging a library into the target (during library linking).
|
---|
998 | # @param 1 Target name.
|
---|
999 | # @param 2 The output library name.
|
---|
1000 | # @param 3 The input library name.
|
---|
1001 | MSG_AR_MERGE ?= $(call MSG_L1,Merging $3 into $1, ($2))
|
---|
1002 | ## Creating a directory (build).
|
---|
1003 | # @param 1 Directory name.
|
---|
1004 | MSG_MKDIR ?= $(call MSG_L2,Creating directory $1)
|
---|
1005 | ## Cleaning.
|
---|
1006 | MSG_CLEAN ?= $(call MSG_L1,Cleaning...)
|
---|
1007 | ## Nothing.
|
---|
1008 | MSG_NOTHING ?= $(call MSG_L1,Did nothing in $(CURDIR))
|
---|
1009 | ## Pass
|
---|
1010 | # @param 1 The pass name.
|
---|
1011 | MSG_PASS ?= $(call MSG_L1,Pass - $1)
|
---|
1012 | ## Installing a bldprog/lib/dll/program/sysmod target.
|
---|
1013 | # @param 1 Target name.
|
---|
1014 | # @param 2 The source filename.
|
---|
1015 | # @param 3 The destination file name.
|
---|
1016 | MSG_INST_TRG ?= $(call MSG_L1,Installing $1 => $3)
|
---|
1017 | ## Installing a file (install target).
|
---|
1018 | # @param 1 The source filename.
|
---|
1019 | # @param 2 The destination filename.
|
---|
1020 | MSG_INST_FILE?= $(call MSG_L1,Installing $2,(<= $1))
|
---|
1021 | ## Installing a symlink.
|
---|
1022 | # @param 1 Symlink
|
---|
1023 | # @param 2 Link target
|
---|
1024 | MSG_INST_SYM ?= $(call MSG_L1,Installing symlink $1,=> $2)
|
---|
1025 | ## Installing a directory.
|
---|
1026 | # @param 1 Directory name.
|
---|
1027 | MSG_INST_DIR ?= $(call MSG_L1,Installing directory $1)
|
---|
1028 |
|
---|
1029 | else
|
---|
1030 | _KBUILD_MSG_STYLE_FILE := $(firstword $(foreach path, $(KBUILD_MSG_STYLE_PATHS) $(PATH_KBUILD)/msgstyles, $(wildcard $(path)/$(KBUILD_MSG_STYLE).kmk)))
|
---|
1031 | ifneq ($(_KBUILD_MSG_STYLE_FILE),)
|
---|
1032 | include $(_KBUILD_MSG_STYLE_FILE)
|
---|
1033 | else
|
---|
1034 | $(error kBuild: Can't find the style setup file for KBUILD_MSG_STYLE '$(KBUILD_MSG_STYLE)')
|
---|
1035 | endif
|
---|
1036 | endif
|
---|
1037 |
|
---|
1038 |
|
---|
1039 | #
|
---|
1040 | # Message macros.
|
---|
1041 | #
|
---|
1042 | # This is done after including Config.kmk as to allow for
|
---|
1043 | # KBUILD_QUIET and KBUILD_VERBOSE to be configurable.
|
---|
1044 | #
|
---|
1045 | ifdef KBUILD_QUIET
|
---|
1046 | # No output
|
---|
1047 | QUIET := @
|
---|
1048 | QUIET2:= @
|
---|
1049 | MSG_L1 =
|
---|
1050 | MSG_L2 =
|
---|
1051 | else
|
---|
1052 | ifndef KBUILD_VERBOSE
|
---|
1053 | # Default output level.
|
---|
1054 | QUIET := @
|
---|
1055 | QUIET2 := @
|
---|
1056 | MSG_L1 ?= %@$(ECHO) "kBuild: $1"
|
---|
1057 | MSG_L2 =
|
---|
1058 | else ifeq ($(KBUILD_VERBOSE),1)
|
---|
1059 | # A bit more output
|
---|
1060 | QUIET := @
|
---|
1061 | QUIET2 := @
|
---|
1062 | MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
|
---|
1063 | MSG_L2 =
|
---|
1064 | else ifeq ($(KBUILD_VERBOSE),2)
|
---|
1065 | # Lot more output
|
---|
1066 | QUIET :=
|
---|
1067 | QUIET2 := @
|
---|
1068 | MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
|
---|
1069 | MSG_L2 ?= %@$(ECHO) "kBuild: $1"
|
---|
1070 | else
|
---|
1071 | # maximal output.
|
---|
1072 | QUIET :=
|
---|
1073 | QUIET2 :=
|
---|
1074 | MSG_L1 ?= %@$(ECHO) "kBuild: $1 $2"
|
---|
1075 | MSG_L2 ?= %@$(ECHO) "kBuild: $1"
|
---|
1076 | endif
|
---|
1077 | endif
|
---|
1078 |
|
---|
1079 |
|
---|
1080 | #
|
---|
1081 | # Validate any KBUILD_BLD_TYPES additions and finally the BUILD_TYPE.
|
---|
1082 | #
|
---|
1083 | if1of ($(KBUILD_BLD_TYPES), $(KBUILD_OSES))
|
---|
1084 | $(error kBuild: found KBUILD_BLD_TYPES in KBUILD_OSES!)
|
---|
1085 | endif
|
---|
1086 | if1of ($(KBUILD_BLD_TYPES), $(KBUILD_ARCHES))
|
---|
1087 | $(error kBuild: found KBUILD_BLD_TYPES in KBUILD_ARCHES!)
|
---|
1088 | endif
|
---|
1089 | if1of ($(KBUILD_OSES), $(KBUILD_ARCHES))
|
---|
1090 | $(error kBuild: found KBUILD_OSES in KBUILD_ARCHES!)
|
---|
1091 | endif
|
---|
1092 | ifn1of ($(BUILD_TYPE), $(KBUILD_BLD_TYPES))
|
---|
1093 | $(error kBuild: BUILD_TYPE(=$(BUILD_TYPE)) is not found in KBUILD_BLD_TYPES(=$(KBUILD_BLD_TYPES))!)
|
---|
1094 | endif
|
---|
1095 |
|
---|
1096 |
|
---|
1097 |
|
---|
1098 | ifdef KBUILD_PROFILE_SELF
|
---|
1099 | _KBUILD_TS_HEADER_END := $(nanots )
|
---|
1100 | $(info prof: $(int-sub $(_KBUILD_TS_HEADER_END), $(_KBUILD_TS_HEADER_START)) - $(int-sub $(_KBUILD_TS_HEADER_END), $(_KBUILD_TS_PREV)) - end of header.kmk)
|
---|
1101 | $(info stat: $(make-stats ))
|
---|
1102 | _KBUILD_TS_PREV := $(_KBUILD_TS_HEADER_END)
|
---|
1103 | endif
|
---|
1104 |
|
---|
1105 | # end-of-file-content
|
---|
1106 | __header_kmk__ := 1
|
---|
1107 | endif # __header_kmk__
|
---|
1108 |
|
---|