1 | # $Id: header.kmk 472 2006-07-15 04:33:50Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # kBuild - File included at top of makefile.
|
---|
5 | #
|
---|
6 | # Copyright (c) 2004-2005 knut st. osmundsen <bird-srcspam@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 |
|
---|
30 | #
|
---|
31 | # default rule
|
---|
32 | #
|
---|
33 | all: all_recursive
|
---|
34 |
|
---|
35 | #
|
---|
36 | # The FORCE rule.
|
---|
37 | #
|
---|
38 | FORCE:
|
---|
39 |
|
---|
40 | #
|
---|
41 | # Try avoid inference rules.
|
---|
42 | #
|
---|
43 | .SUFFIXES:
|
---|
44 | SUFFIXES :=
|
---|
45 |
|
---|
46 |
|
---|
47 | #
|
---|
48 | # General purpose macros.
|
---|
49 | #
|
---|
50 |
|
---|
51 | ## get last word in a list.
|
---|
52 | # @returns last word in $1.
|
---|
53 | # @param $1 Word list.
|
---|
54 | lastword = $(word $(words $(1)), $(1))
|
---|
55 |
|
---|
56 | ##
|
---|
57 | # Newline character(s).
|
---|
58 | define NL
|
---|
59 |
|
---|
60 |
|
---|
61 | endef
|
---|
62 |
|
---|
63 | ##
|
---|
64 | # Tab character.
|
---|
65 | TAB := $(subst ., ,.)
|
---|
66 |
|
---|
67 | ##
|
---|
68 | # Space character.
|
---|
69 | SP := $(subst ., ,.)
|
---|
70 |
|
---|
71 | ##
|
---|
72 | # Checks if two strings are equal.
|
---|
73 | # @returns blank if equal
|
---|
74 | # @returns non-blank if not equal.
|
---|
75 | # @param $1 String 1.
|
---|
76 | # @param $2 String 2
|
---|
77 | STRCMP = $(
|
---|
78 |
|
---|
79 | #
|
---|
80 | # Assert build type.
|
---|
81 | #
|
---|
82 | ifndef BUILD_TYPE
|
---|
83 | ifndef BUILD_MODE
|
---|
84 | $(error kBuild: You must define BUILD_TYPE!)
|
---|
85 | endif
|
---|
86 | BUILD_TYPE := $(BUILD_MODE)
|
---|
87 | endif
|
---|
88 | ifeq ($(BUILD_TYPE),DEBUG)
|
---|
89 | BUILD_TYPE := debug
|
---|
90 | endif
|
---|
91 | ifeq ($(BUILD_TYPE),RELEASE)
|
---|
92 | BUILD_TYPE := release
|
---|
93 | endif
|
---|
94 | ifeq ($(BUILD_TYPE),PROFILE)
|
---|
95 | BUILD_TYPE := profile
|
---|
96 | endif
|
---|
97 |
|
---|
98 |
|
---|
99 | #
|
---|
100 | # Assert build platform.
|
---|
101 | #
|
---|
102 | _BUILD_PLATFORM_OK := 0
|
---|
103 | # OS/2 (have uppercase legacy)
|
---|
104 | ifeq ($(BUILD_PLATFORM),OS2)
|
---|
105 | override BUILD_PLATFORM := os2
|
---|
106 | endif
|
---|
107 | ifeq ($(BUILD_PLATFORM),os2)
|
---|
108 | _BUILD_PLATFORM_OK := 1
|
---|
109 | endif
|
---|
110 |
|
---|
111 | # Linux
|
---|
112 | ifeq ($(BUILD_PLATFORM),LINUX)
|
---|
113 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
---|
114 | endif
|
---|
115 | ifeq ($(BUILD_PLATFORM),linux)
|
---|
116 | _BUILD_PLATFORM_OK := 1
|
---|
117 | endif
|
---|
118 |
|
---|
119 | # Win32
|
---|
120 | ifeq ($(BUILD_PLATFORM),WIN32)
|
---|
121 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
---|
122 | endif
|
---|
123 | ifeq ($(BUILD_PLATFORM),win32)
|
---|
124 | _BUILD_PLATFORM_OK := 1
|
---|
125 | endif
|
---|
126 |
|
---|
127 | # Win64
|
---|
128 | ifeq ($(BUILD_PLATFORM),WIN64)
|
---|
129 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
---|
130 | endif
|
---|
131 | ifeq ($(BUILD_PLATFORM),win64)
|
---|
132 | _BUILD_PLATFORM_OK := 1
|
---|
133 | endif
|
---|
134 |
|
---|
135 | # L4
|
---|
136 | ifeq ($(BUILD_PLATFORM),L4)
|
---|
137 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
---|
138 | endif
|
---|
139 | ifeq ($(BUILD_PLATFORM),l4)
|
---|
140 | _BUILD_PLATFORM_OK := 1
|
---|
141 | endif
|
---|
142 |
|
---|
143 | # FreeBSD
|
---|
144 | ifeq ($(BUILD_PLATFORM),FreeBSD)
|
---|
145 | $(error kBuild: BUILD_PLATFORM must be all lowercase!)
|
---|
146 | endif
|
---|
147 | ifeq ($(BUILD_PLATFORM),freebsd)
|
---|
148 | _BUILD_PLATFORM_OK := 1
|
---|
149 | endif
|
---|
150 |
|
---|
151 | ifeq ($(_BUILD_PLATFORM_OK),0)
|
---|
152 | $(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' was not recongized!)
|
---|
153 | endif
|
---|
154 |
|
---|
155 | # Fill in defaults if needed.
|
---|
156 | ifndef BUILD_PLATFORM_ARCH
|
---|
157 | ifeq ($(filter-out win64,$(BUILD_PLATFORM)),)
|
---|
158 | BUILD_PLATFORM_ARCH := amd64
|
---|
159 | else
|
---|
160 | BUILD_PLATFORM_ARCH := x86
|
---|
161 | endif
|
---|
162 | endif
|
---|
163 | ifndef BUILD_PLATFORM_CPU
|
---|
164 | ifeq ($(filter-out amd64,$(BUILD_PLATFORM_ARCH)),)
|
---|
165 | BUILD_PLATFORM_CPU := k8
|
---|
166 | else
|
---|
167 | BUILD_PLATFORM_CPU := i586
|
---|
168 | endif
|
---|
169 | endif
|
---|
170 |
|
---|
171 |
|
---|
172 | #
|
---|
173 | # Assert target platform.
|
---|
174 | #
|
---|
175 | ifndef BUILD_TARGET
|
---|
176 | # not defined, set to the same as build platform
|
---|
177 | BUILD_TARGET := $(BUILD_PLATFORM)
|
---|
178 | else
|
---|
179 | _BUILD_TARGET_OK := 0
|
---|
180 | # OS/2
|
---|
181 | ifeq ($(BUILD_TARGET),OS2)
|
---|
182 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
183 | endif
|
---|
184 | ifeq ($(BUILD_TARGET),os2)
|
---|
185 | _BUILD_TARGET_OK := 1
|
---|
186 | endif
|
---|
187 |
|
---|
188 | # Linux
|
---|
189 | ifeq ($(BUILD_TARGET),LINUX)
|
---|
190 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
191 | endif
|
---|
192 | ifeq ($(BUILD_TARGET),linux)
|
---|
193 | _BUILD_TARGET_OK := 1
|
---|
194 | endif
|
---|
195 |
|
---|
196 | # Win32
|
---|
197 | ifeq ($(BUILD_TARGET),WIN32)
|
---|
198 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
199 | endif
|
---|
200 | ifeq ($(BUILD_TARGET),win32)
|
---|
201 | _BUILD_TARGET_OK := 1
|
---|
202 | endif
|
---|
203 |
|
---|
204 | # Win64
|
---|
205 | ifeq ($(BUILD_TARGET),WIN64)
|
---|
206 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
207 | endif
|
---|
208 | ifeq ($(BUILD_TARGET),win64)
|
---|
209 | _BUILD_TARGET_OK := 1
|
---|
210 | endif
|
---|
211 |
|
---|
212 | # L4
|
---|
213 | ifeq ($(BUILD_TARGET),L4)
|
---|
214 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
215 | endif
|
---|
216 | ifeq ($(BUILD_TARGET),l4)
|
---|
217 | _BUILD_TARGET_OK := 1
|
---|
218 | endif
|
---|
219 |
|
---|
220 | # FreeBSD
|
---|
221 | ifeq ($(BUILD_TARGET),FreeBSD)
|
---|
222 | $(error kBuild: BUILD_TARGET must be all lowercase!)
|
---|
223 | endif
|
---|
224 | ifeq ($(BUILD_TARGET),freebsd)
|
---|
225 | _BUILD_TARGET_OK := 1
|
---|
226 | endif
|
---|
227 |
|
---|
228 | ifeq ($(_BUILD_TARGET_OK),0)
|
---|
229 | $(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' was not recongized!)
|
---|
230 | endif
|
---|
231 | endif
|
---|
232 |
|
---|
233 | # Fill in defaults if needed.
|
---|
234 | ifndef BUILD_TARGET_ARCH
|
---|
235 | BUILD_TARGET_ARCH := x86
|
---|
236 | endif
|
---|
237 | ifndef BUILD_TARGET_CPU
|
---|
238 | BUILD_TARGET_CPU := i586
|
---|
239 | endif
|
---|
240 |
|
---|
241 | # Adjust the DEPTH definition first
|
---|
242 | ifeq ($(strip $(DEPTH)),)
|
---|
243 | DEPTH := .
|
---|
244 | endif
|
---|
245 |
|
---|
246 | #
|
---|
247 | # Common definitions.
|
---|
248 | #
|
---|
249 | ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
|
---|
250 |
|
---|
251 | PATH_CURRENT := $(abspath $(CURDIR))
|
---|
252 | ifneq ($(strip $(SUB_DEPTH)),)
|
---|
253 | PATH_SUB_CURRENT := $(abspath $(PATH_CURRENT)/$(SUB_DEPTH))
|
---|
254 | else
|
---|
255 | PATH_SUB_CURRENT := $(PATH_CURRENT)
|
---|
256 | endif
|
---|
257 | PATH_ROOT := $(abspath $(PATH_CURRENT)/$(DEPTH))
|
---|
258 |
|
---|
259 | else
|
---|
260 |
|
---|
261 | PATH_CURRENT := $(CURDIR)
|
---|
262 | PATH_SUB_CURRENT := $(PATH_CURRENT)
|
---|
263 | ifneq ($(strip $(SUB_DEPTH)),)
|
---|
264 | ifneq ($(SUB_DEPTH),.)
|
---|
265 | $(foreach d,$(subst /, ,$(SUB_DEPTH)), $(eval PATH_SUB_CURRENT := $(patsubst %/,%,$(dir $(PATH_SUB_CURRENT)))) )
|
---|
266 | endif
|
---|
267 | endif
|
---|
268 | PATH_ROOT := $(PATH_CURRENT)
|
---|
269 | ifneq ($(DEPTH),.)
|
---|
270 | $(foreach d,$(subst /, ,$(DEPTH)), $(eval PATH_ROOT := $(patsubst %/,%,$(dir $(PATH_ROOT)))) )
|
---|
271 | endif
|
---|
272 |
|
---|
273 | endif
|
---|
274 |
|
---|
275 | # Subdirectory relative to the root.
|
---|
276 | ifneq ($(PATH_ROOT),$(PATH_CURRENT))
|
---|
277 | CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(PATH_SUB_CURRENT))
|
---|
278 | else
|
---|
279 | CURSUBDIR := .
|
---|
280 | endif
|
---|
281 |
|
---|
282 | # Output directories.
|
---|
283 | ifndef PATH_OUT_BASE
|
---|
284 | PATH_OUT_BASE := $(PATH_ROOT)/out
|
---|
285 | endif
|
---|
286 | ifndef PATH_OUT
|
---|
287 | ifdef BUILD_TARGET_SUB # (BUILD_TARGET_SUB is not currently recognized by kBuild in any other places.)
|
---|
288 | PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET).$(BUILD_TARGET_ARCH).$(BUILD_TARGET_SUB)/$(BUILD_TYPE)
|
---|
289 | else
|
---|
290 | PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET).$(BUILD_TARGET_ARCH)/$(BUILD_TYPE)
|
---|
291 | endif
|
---|
292 | endif # !define PATH_OUT
|
---|
293 | PATH_OBJ = $(PATH_OUT)/obj
|
---|
294 | PATH_TARGET = $(PATH_OBJ)/$(CURSUBDIR)
|
---|
295 | PATH_INS = $(PATH_OUT)
|
---|
296 | PATH_BIN = $(PATH_INS)/bin
|
---|
297 | PATH_DLL = $(PATH_INS)/bin
|
---|
298 | PATH_SYS = $(PATH_INS)/bin
|
---|
299 | PATH_LIB = $(PATH_INS)/lib
|
---|
300 | PATH_DOC = $(PATH_INS)/doc
|
---|
301 |
|
---|
302 | # Usually kBuild is external to the source tree.
|
---|
303 | ifndef PATH_KBUILD
|
---|
304 | PATH_KBUILD := $(PATH_ROOT)/kBuild
|
---|
305 | endif
|
---|
306 | ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
|
---|
307 | PATH_KBUILD := $(abspath $(PATH_KBUILD))
|
---|
308 | endif
|
---|
309 | # kBuild files which might be of interest.
|
---|
310 | FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk
|
---|
311 | FILE_KBUILD_CONFIG := $(PATH_KBUILD)/config.kmk
|
---|
312 | FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk
|
---|
313 |
|
---|
314 | SUFF_DEP := .dep
|
---|
315 | MAKEFILE := $(firstword $(MAKEFILE_LIST))
|
---|
316 |
|
---|
317 |
|
---|
318 | #
|
---|
319 | # Get rid of the GNU Make default stuff
|
---|
320 | #
|
---|
321 | ifndef KMK_VERSION
|
---|
322 | include $(PATH_KBUILD)/StampOutPredefines.kmk
|
---|
323 | endif
|
---|
324 |
|
---|
325 | #
|
---|
326 | # Build platform setup.
|
---|
327 | #
|
---|
328 | PATH_TOOLS := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)
|
---|
329 |
|
---|
330 | # OS/2
|
---|
331 | ifeq ($(BUILD_PLATFORM),os2)
|
---|
332 | EXEC_X86_WIN32 := innopec.exe
|
---|
333 | HOSTSUFF_EXE := .exe
|
---|
334 | endif
|
---|
335 |
|
---|
336 | # Linux
|
---|
337 | ifeq ($(BUILD_PLATFORM),linux)
|
---|
338 | EXEC_X86_WIN32 := wine
|
---|
339 | HOSTSUFF_EXE :=
|
---|
340 | endif
|
---|
341 |
|
---|
342 | # Win32 & Win64
|
---|
343 | ifeq ($(filter-out win32 win64,$(BUILD_TARGET)),)
|
---|
344 | EXEC_X86_WIN32 :=
|
---|
345 | HOSTSUFF_EXE := .exe
|
---|
346 | endif
|
---|
347 |
|
---|
348 | # FreeBSD
|
---|
349 | ifeq ($(BUILD_PLATFORM),freebsd)
|
---|
350 | EXEC_X86_WIN32 := wine
|
---|
351 | HOSTSUFF_EXE :=
|
---|
352 | endif
|
---|
353 |
|
---|
354 |
|
---|
355 | #
|
---|
356 | # Build target setup.
|
---|
357 | #
|
---|
358 | ifeq ($(BUILD_TARGET),os2)
|
---|
359 | SUFF_OBJ := .obj
|
---|
360 | SUFF_LIB := .lib
|
---|
361 | SUFF_DLL := .dll
|
---|
362 | SUFF_EXE := .exe
|
---|
363 | SUFF_SYS := .sys
|
---|
364 | SUFF_RES := .res
|
---|
365 | endif
|
---|
366 | ifeq ($(filter-out win32 win64,$(BUILD_TARGET)),)
|
---|
367 | SUFF_OBJ := .obj
|
---|
368 | SUFF_LIB := .lib
|
---|
369 | SUFF_DLL := .dll
|
---|
370 | SUFF_EXE := .exe
|
---|
371 | SUFF_SYS := .sys
|
---|
372 | SUFF_RES := .res
|
---|
373 | endif
|
---|
374 | ifeq ($(BUILD_TARGET),linux)
|
---|
375 | SUFF_OBJ := .o
|
---|
376 | SUFF_LIB := .a
|
---|
377 | SUFF_DLL := .so
|
---|
378 | SUFF_EXE :=
|
---|
379 | SUFF_SYS := .a
|
---|
380 | SUFF_RES :=
|
---|
381 | endif
|
---|
382 | ifeq ($(BUILD_TARGET),l4)
|
---|
383 | SUFF_OBJ := .o
|
---|
384 | SUFF_LIB := .a
|
---|
385 | SUFF_DLL := .s.so
|
---|
386 | SUFF_EXE :=
|
---|
387 | SUFF_SYS := .a
|
---|
388 | SUFF_RES :=
|
---|
389 | endif
|
---|
390 |
|
---|
391 | #
|
---|
392 | # Standard kBuild tools.
|
---|
393 | #
|
---|
394 | ifeq ($(MAKE),kmk)
|
---|
395 | MAKE := $(PATH_TOOLS)/kmk$(HOSTSUFF_EXE)
|
---|
396 | endif
|
---|
397 |
|
---|
398 | DEP_EXT := $(PATH_TOOLS)/kDep$(HOSTSUFF_EXE)
|
---|
399 | ifeq ($(filter kDep,$(KMK_BUILTIN)),kDep)
|
---|
400 | DEP := kmk_builtin_kDep
|
---|
401 | else
|
---|
402 | DEP := $(DEP_EXT)
|
---|
403 | endif
|
---|
404 |
|
---|
405 | DEP_IDB_EXT := $(PATH_TOOLS)/kDepIDB$(HOSTSUFF_EXE)
|
---|
406 | ifeq ($(filter kDepPre,$(KMK_BUILTIN)),kDepIDB)
|
---|
407 | DEP_IDB := $(if kmk_builtin_kDepIDB
|
---|
408 | else
|
---|
409 | DEP_IDB := $(DEP_IDB_EXT)
|
---|
410 | endif
|
---|
411 |
|
---|
412 | DEP_PRE_EXT := $(PATH_TOOLS)/kDepPre$(HOSTSUFF_EXE)
|
---|
413 | ifeq ($(filter kDepPre,$(KMK_BUILTIN)),kDepPre)
|
---|
414 | DEP_PRE := $(if kmk_builtin_kDepPre
|
---|
415 | else
|
---|
416 | DEP_PRE := $(DEP_PRE_EXT)
|
---|
417 | endif
|
---|
418 |
|
---|
419 | APPEND_EXT := $(PATH_TOOLS)/kmk_append$(HOSTSUFF_EXE)
|
---|
420 | ifeq ($(filter append,$(KMK_BUILTIN)),append)
|
---|
421 | APPEND := kmk_builtin_append
|
---|
422 | else
|
---|
423 | APPEND := $(APPEND_EXT)
|
---|
424 | endif
|
---|
425 |
|
---|
426 | CAT_EXT := $(PATH_TOOLS)/kmk_cat$(HOSTSUFF_EXE)
|
---|
427 | ifeq ($(filter cat,$(KMK_BUILTIN)),cat)
|
---|
428 | CAT := kmk_builtin_cat
|
---|
429 | else
|
---|
430 | CAT := $(CAT_EXT)
|
---|
431 | endif
|
---|
432 |
|
---|
433 | CP_EXT := $(PATH_TOOLS)/kmk_cp$(HOSTSUFF_EXE)
|
---|
434 | ifeq ($(filter cp,$(KMK_BUILTIN)),cp)
|
---|
435 | CP := kmk_builtin_cp
|
---|
436 | else
|
---|
437 | CP := $(CP_EXT)
|
---|
438 | endif
|
---|
439 |
|
---|
440 | ECHO_EXT := $(PATH_TOOLS)/kmk_echo$(HOSTSUFF_EXE)
|
---|
441 | ifeq ($(filter echo,$(KMK_BUILTIN)),echo)
|
---|
442 | ECHO := kmk_builtin_echo
|
---|
443 | else
|
---|
444 | ECHO := $(ECHO_EXT)
|
---|
445 | endif
|
---|
446 |
|
---|
447 | INSTALL_EXT := $(PATH_TOOLS)/kmk_install$(HOSTSUFF_EXE)
|
---|
448 | ifeq ($(filter install,$(KMK_BUILTIN)),install)
|
---|
449 | INSTALL := kmk_builtin_install
|
---|
450 | else
|
---|
451 | INSTALL := $(INSTALL_EXT)
|
---|
452 | endif
|
---|
453 |
|
---|
454 | LN_EXT := $(PATH_TOOLS)/kmk_ln$(HOSTSUFF_EXE)
|
---|
455 | ifeq ($(filter ln,$(KMK_BUILTIN)),ln)
|
---|
456 | LN := kmk_builtin_ln
|
---|
457 | else
|
---|
458 | LN := $(LN_EXT)
|
---|
459 | endif
|
---|
460 |
|
---|
461 | MKDIR_EXT := $(PATH_TOOLS)/kmk_mkdir$(HOSTSUFF_EXE)
|
---|
462 | ifeq ($(filter mkdir,$(KMK_BUILTIN)),mkdir)
|
---|
463 | MKDIR := kmk_builtin_mkdir
|
---|
464 | else
|
---|
465 | MKDIR := $(MKDIR_EXT)
|
---|
466 | endif
|
---|
467 |
|
---|
468 | MV_EXT := $(PATH_TOOLS)/kmk_mv$(HOSTSUFF_EXE)
|
---|
469 | ifeq ($(filter mv,$(KMK_BUILTIN)),mv)
|
---|
470 | MV := kmk_builtin_mv
|
---|
471 | else
|
---|
472 | MV := $(MV_EXT)
|
---|
473 | endif
|
---|
474 |
|
---|
475 | RM_EXT := $(PATH_TOOLS)/kmk_rm$(HOSTSUFF_EXE)
|
---|
476 | ifeq ($(filter rm,$(KMK_BUILTIN)),rm)
|
---|
477 | RM := kmk_builtin_rm
|
---|
478 | else
|
---|
479 | RM := $(RM_EXT)
|
---|
480 | endif
|
---|
481 |
|
---|
482 | SED_EXT := $(PATH_TOOLS)/kmk_sed$(HOSTSUFF_EXE)
|
---|
483 | ifeq ($(filter sed,$(KMK_BUILTIN)),sed)
|
---|
484 | SED := kmk_builtin_sed
|
---|
485 | else
|
---|
486 | SED := $(SED_EXT)
|
---|
487 | endif
|
---|
488 |
|
---|
489 | # Our default shell is the Almquist shell from *BSD.
|
---|
490 | ASH := $(PATH_TOOLS)/kmk_ash$(HOSTSUFF_EXE)
|
---|
491 | MAKESHELL := $(ASH)
|
---|
492 | SHELL := $(ASH)
|
---|
493 | export SHELL MAKESHELL
|
---|
494 |
|
---|
495 | # Symlinking is problematic on some platforms...
|
---|
496 | LN_SYMLINK := $(LN) -s
|
---|
497 |
|
---|
498 |
|
---|
499 |
|
---|
500 | #
|
---|
501 | # Message macros.
|
---|
502 | #
|
---|
503 |
|
---|
504 | ifndef BUILD_QUIET
|
---|
505 | ifdef BUILD_DEBUG
|
---|
506 | BUILD_VERBOSE := 9
|
---|
507 | endif
|
---|
508 | MSG_L1 = @$(ECHO) "kBuild: $1"
|
---|
509 | ifdef BUILD_VERBOSE
|
---|
510 | MSG_L2 = @$(ECHO) "kBuild: $1"
|
---|
511 | QUIET :=
|
---|
512 | else
|
---|
513 | QUIET := @
|
---|
514 | MSG_L2 =
|
---|
515 | endif
|
---|
516 | ifdef BUILD_DEBUG
|
---|
517 | MSG_L3 = @$(ECHO) "kBuild: $1"
|
---|
518 | else
|
---|
519 | MSG_L3 =
|
---|
520 | endif
|
---|
521 | else
|
---|
522 | QUIET :=
|
---|
523 | MSG_L1 =
|
---|
524 | MSG_L2 =
|
---|
525 | MSG_L3 =
|
---|
526 | endif
|
---|
527 |
|
---|
528 | ## ABSPATH - make paths absolute.
|
---|
529 | # This implementation is clumsy and doesn't resolve '..' and '.' components.
|
---|
530 | #
|
---|
531 | # @param $1 The paths to make absolute.
|
---|
532 | ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
|
---|
533 | ABSPATH = $(abspath $(1))
|
---|
534 | else
|
---|
535 | ABSPATH = $(foreach path,$(1)\
|
---|
536 | ,$(strip $(if $(subst <,,$(firstword $(subst /, ,<$(path)))),\
|
---|
537 | $(if $(patsubst %:,,$(firstword $(subst :,: ,$(path)))),$(PATH_CURRENT)/$(path),$(path)),\
|
---|
538 | $(path))))
|
---|
539 | endif
|
---|
540 |
|
---|
541 | ## DIRDEP - make create directory dependencies.
|
---|
542 | #
|
---|
543 | # @param $1 The paths to the directories which must be created.
|
---|
544 | ifeq ($(filter-out win32 win64,$(BUILD_PLATFORM)),)
|
---|
545 | DIRDEP = $(patsubst %/,%,$(1))
|
---|
546 | else
|
---|
547 | DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
|
---|
548 | endif
|
---|
549 |
|
---|
550 |
|
---|
551 | ## Cygwin kludge.
|
---|
552 | # This converts /cygdrive/x/% to x:%.
|
---|
553 | #
|
---|
554 | # @param $1 The paths to make native.
|
---|
555 | # @remark This macro is pretty much obsolete since we don't use cygwin base make.
|
---|
556 | ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
|
---|
557 | CYGPATHMIXED = $(foreach path,$(1)\
|
---|
558 | ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
|
---|
559 | else
|
---|
560 | CYGPATHMIXED = $(1)
|
---|
561 | endif
|
---|
562 |
|
---|
563 | #
|
---|
564 | # Initialize some of the globals which the Config.kmk and
|
---|
565 | # others can add stuff to if they like for processing in the footer.
|
---|
566 | #
|
---|
567 |
|
---|
568 | ## ALL_TARGET
|
---|
569 | # This is the list of all targets.
|
---|
570 | ALL_TARGETS :=
|
---|
571 |
|
---|
572 | ## TEMPLATE_PATHS
|
---|
573 | # List a paths (separated by space) where templates can be found.
|
---|
574 | TEMPLATE_PATHS :=
|
---|
575 |
|
---|
576 | ## TOOL_PATHS
|
---|
577 | # List of paths (separated by space) where tools can be found.
|
---|
578 | TOOL_PATHS :=
|
---|
579 |
|
---|
580 | ## SDK_PATHS
|
---|
581 | # List of paths (separated by space) where SDKs can be found.
|
---|
582 | SDK_PATHS :=
|
---|
583 |
|
---|
584 | ## Proritized list of the default makefile when walking subdirectories.
|
---|
585 | # The user can overload this list.
|
---|
586 | DEFAULT_MAKEFILE := Makefile.kmk makefile.kmk Makefile makefile
|
---|
587 |
|
---|
588 | ## PROPS_SINGLE
|
---|
589 | # The list of non-accumulative target properties.
|
---|
590 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
591 | # will do the necessary inheritance from templates to targets.
|
---|
592 | PROPS_SINGLE := TOOL ARTOOL CTOOL CXXTOOL ASTOOL LDTOOL INST NOINST
|
---|
593 |
|
---|
594 | ## PROPS_DEFERRED
|
---|
595 | # This list of non-accumulative target properties which are functions,
|
---|
596 | # and thus should not be expanded until the very last moment.
|
---|
597 | PROPS_DEFERRED := INSTFUN INSTALLER
|
---|
598 |
|
---|
599 | ## PROPS_ACCUMULATE
|
---|
600 | # The list of accumulative target properties.
|
---|
601 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
602 | # will do the necessary inheritance from templates to targets.
|
---|
603 | PROPS_ACCUMULATE := \
|
---|
604 | SDKS DEFS DEPS INCS SOURCES \
|
---|
605 | COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS \
|
---|
606 | ASOPTS ASFLAGS ASDEFS ASINCS \
|
---|
607 | LDFLAGS LIBS LIBPATH \
|
---|
608 | BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU \
|
---|
609 | SYSSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \
|
---|
610 |
|
---|
611 |
|
---|
612 | ## PROPS_TOOLS
|
---|
613 | # This is a subset of the other PROPS
|
---|
614 | PROPS_TOOLS := TOOL CTOOL CXXTOOL ASTOOL ARTOOL LDTOOL
|
---|
615 |
|
---|
616 |
|
---|
617 | #
|
---|
618 | # Pass configuration.
|
---|
619 | #
|
---|
620 | # The PASS_<passname>_trgs variable is listing the targets.
|
---|
621 | # The PASS_<passname>_vars variable is listing the target variables.
|
---|
622 | # The PASS_<passname>_pass variable is the lowercased passname.
|
---|
623 | #
|
---|
624 |
|
---|
625 | ## PASS: bldprogs
|
---|
626 | # This pass builds targets which are required for building the rest.
|
---|
627 | PASS_BLDPROGS := Build Programs
|
---|
628 | PASS_BLDPROGS_trgs :=
|
---|
629 | PASS_BLDPROGS_vars := _BLDPROGS
|
---|
630 | PASS_BLDPROGS_pass := bldprogs
|
---|
631 |
|
---|
632 | ## PASS: libraries
|
---|
633 | # This pass builds library targets.
|
---|
634 | PASS_LIBRARIES := Libraries
|
---|
635 | PASS_LIBRARIES_trgs :=
|
---|
636 | PASS_LIBRARIES_vars := _LIBS _IMPORT_LIBS _OTHER_LIBRARIES
|
---|
637 | PASS_LIBRARIES_pass := libraries
|
---|
638 |
|
---|
639 | ## PASS: binaries
|
---|
640 | # This pass builds dll targets.
|
---|
641 | PASS_DLLS := DLLs
|
---|
642 | PASS_DLLS_trgs :=
|
---|
643 | PASS_DLLS_vars := _DLLS _OTHER_DLLS
|
---|
644 | PASS_DLLS_pass := dlls
|
---|
645 |
|
---|
646 | ## PASS: binaries
|
---|
647 | # This pass builds binary targets, i.e. programs, system modules and stuff.
|
---|
648 | PASS_BINARIES := Programs
|
---|
649 | PASS_BINARIES_trgs :=
|
---|
650 | PASS_BINARIES_vars := _PROGRAMS _SYSMODS _OTHER_BINARIES
|
---|
651 | PASS_BINARIES_pass := binaries
|
---|
652 |
|
---|
653 | ## PASS: others
|
---|
654 | # This pass builds other targets.
|
---|
655 | PASS_OTHERS := Other Stuff
|
---|
656 | PASS_OTHERS_trgs :=
|
---|
657 | PASS_OTHERS_vars := _OTHERS
|
---|
658 | PASS_OTHERS_pass := others
|
---|
659 |
|
---|
660 | ## PASS: install
|
---|
661 | # This pass installs the built entities to a sandbox area.
|
---|
662 | PASS_INSTALLS := Install
|
---|
663 | PASS_INSTALLS_trgs :=
|
---|
664 | PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS
|
---|
665 | PASS_INSTALLS_pass := installs
|
---|
666 |
|
---|
667 | ## PASS: packing
|
---|
668 | # This pass processes custom packing rules.
|
---|
669 | PASS_PACKING := Packing
|
---|
670 | PASS_PACKING_trgs :=
|
---|
671 | PASS_PACKING_vars := _PACKING
|
---|
672 | PASS_PACKING_pass := packing
|
---|
673 | #alias
|
---|
674 | packing: pass_packing
|
---|
675 |
|
---|
676 | ## PASS: clean
|
---|
677 | # This pass removes all generated files.
|
---|
678 | PASS_CLEAN := Clean
|
---|
679 | PASS_CLEAN_trgs := do-clean
|
---|
680 | PASS_CLEAN_vars :=
|
---|
681 | PASS_CLEAN_pass := clean
|
---|
682 | # alias
|
---|
683 | clean: pass_clean
|
---|
684 |
|
---|
685 | ## PASS: nothing
|
---|
686 | # This pass just walks the tree.
|
---|
687 | PASS_NOTHING := Nothing
|
---|
688 | PASS_NOTHING_trgs := do-nothing
|
---|
689 | PASS_NOTHING_vars :=
|
---|
690 | PASS_NOTHING_pass := nothing
|
---|
691 | # alias
|
---|
692 | nothing: pass_nothing
|
---|
693 |
|
---|
694 | ## DEFAULT_PASSES
|
---|
695 | # The default passes and their order.
|
---|
696 | DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES OTHERS INSTALLS
|
---|
697 |
|
---|
698 | ## PASSES
|
---|
699 | # The passes that should be defined. This must include
|
---|
700 | # all passes mentioned by DEFAULT_PASSES.
|
---|
701 | PASSES := $(DEFAULT_PASSES) NOTHING CLEAN
|
---|
702 |
|
---|
703 |
|
---|
704 | #
|
---|
705 | # This is how we find the closest config.kmk.
|
---|
706 | # It's a little hacky but I think it works fine.
|
---|
707 | #
|
---|
708 | _CFGDIR := .
|
---|
709 | _CFGFILES := ./Config.kmk ./config.kmk
|
---|
710 | define def_include_config
|
---|
711 | $(eval _CFGDIR := $(_CFGDIR)/$(dir))
|
---|
712 | _CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
|
---|
713 | endef
|
---|
714 | # walk down the _RELATIVE_ path specified by DEPTH.
|
---|
715 | $(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
|
---|
716 | # add the default config file.
|
---|
717 | _CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
|
---|
718 | _CFGFILES :=
|
---|
719 | _CFGDIR :=
|
---|
720 | ifeq ($(_CFGFILE),)
|
---|
721 | $(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
|
---|
722 | endif
|
---|
723 |
|
---|
724 | # Include the config.kmk we found file (or the default one).
|
---|
725 | include $(_CFGFILE)
|
---|
726 |
|
---|
727 |
|
---|
728 | # end-of-file-content
|
---|
729 | __header_kmk__ := 1
|
---|
730 | endif # __header_kmk__
|
---|