1 | # $Id: header.kmk 464 2006-07-10 01: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 | PATH_CURRENT := $(abspath $(CURDIR))
|
---|
251 | PATH_ROOT := $(abspath $(PATH_CURRENT)/$(DEPTH))
|
---|
252 |
|
---|
253 | else
|
---|
254 |
|
---|
255 | PATH_CURRENT := $(CURDIR)
|
---|
256 | # Get the real root path.
|
---|
257 | PATH_ROOT := $(PATH_CURRENT)
|
---|
258 | ifneq ($(DEPTH),.)
|
---|
259 | $(foreach d,$(subst /, ,$(DEPTH)), $(eval PATH_ROOT := $(patsubst %/,%,$(dir $(PATH_ROOT)))) )
|
---|
260 | endif
|
---|
261 |
|
---|
262 | endif
|
---|
263 | # Subdirectory relative to the root.
|
---|
264 | ifneq ($(PATH_ROOT),$(PATH_CURRENT))
|
---|
265 | CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(PATH_CURRENT))
|
---|
266 | else
|
---|
267 | CURSUBDIR := .
|
---|
268 | endif
|
---|
269 |
|
---|
270 | # Output directories.
|
---|
271 | ifndef PATH_OUT_BASE
|
---|
272 | PATH_OUT_BASE := $(PATH_ROOT)/out
|
---|
273 | endif
|
---|
274 | ifndef PATH_OUT
|
---|
275 | ifdef BUILD_TARGET_SUB # (BUILD_TARGET_SUB is not currently recognized by kBuild in any other places.)
|
---|
276 | PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET).$(BUILD_TARGET_ARCH).$(BUILD_TARGET_SUB)/$(BUILD_TYPE)
|
---|
277 | else
|
---|
278 | PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET).$(BUILD_TARGET_ARCH)/$(BUILD_TYPE)
|
---|
279 | endif
|
---|
280 | endif # !define PATH_OUT
|
---|
281 | PATH_OBJ = $(PATH_OUT)/obj
|
---|
282 | PATH_TARGET = $(PATH_OBJ)/$(CURSUBDIR)
|
---|
283 | PATH_INS = $(PATH_OUT)
|
---|
284 | PATH_BIN = $(PATH_INS)/bin
|
---|
285 | PATH_DLL = $(PATH_INS)/bin
|
---|
286 | PATH_SYS = $(PATH_INS)/bin
|
---|
287 | PATH_LIB = $(PATH_INS)/lib
|
---|
288 | PATH_DOC = $(PATH_INS)/doc
|
---|
289 |
|
---|
290 | # Usually kBuild is external to the source tree.
|
---|
291 | ifndef PATH_KBUILD
|
---|
292 | PATH_KBUILD := $(PATH_ROOT)/kBuild
|
---|
293 | endif
|
---|
294 | ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
|
---|
295 | PATH_KBUILD := $(abspath $(PATH_KBUILD))
|
---|
296 | endif
|
---|
297 | # kBuild files which might be of interest.
|
---|
298 | FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk
|
---|
299 | FILE_KBUILD_CONFIG := $(PATH_KBUILD)/config.kmk
|
---|
300 | FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk
|
---|
301 |
|
---|
302 | SUFF_DEP := .dep
|
---|
303 | MAKEFILE := $(firstword $(MAKEFILE_LIST))
|
---|
304 |
|
---|
305 |
|
---|
306 | #
|
---|
307 | # Get rid of the GNU Make default stuff
|
---|
308 | #
|
---|
309 | ifndef KMK_VERSION
|
---|
310 | include $(PATH_KBUILD)/StampOutPredefines.kmk
|
---|
311 | endif
|
---|
312 |
|
---|
313 | #
|
---|
314 | # Build platform setup.
|
---|
315 | #
|
---|
316 | PATH_TOOLS := $(PATH_KBUILD)/bin/$(BUILD_PLATFORM_ARCH).$(BUILD_PLATFORM)
|
---|
317 |
|
---|
318 | # OS/2
|
---|
319 | ifeq ($(BUILD_PLATFORM),os2)
|
---|
320 | EXEC_X86_WIN32 := innopec.exe
|
---|
321 | HOSTSUFF_EXE := .exe
|
---|
322 | endif
|
---|
323 |
|
---|
324 | # Linux
|
---|
325 | ifeq ($(BUILD_PLATFORM),linux)
|
---|
326 | EXEC_X86_WIN32 := wine
|
---|
327 | HOSTSUFF_EXE :=
|
---|
328 | endif
|
---|
329 |
|
---|
330 | # Win32 & Win64
|
---|
331 | ifeq ($(filter-out win32 win64,$(BUILD_TARGET)),)
|
---|
332 | EXEC_X86_WIN32 :=
|
---|
333 | HOSTSUFF_EXE := .exe
|
---|
334 | endif
|
---|
335 |
|
---|
336 | # FreeBSD
|
---|
337 | ifeq ($(BUILD_PLATFORM),freebsd)
|
---|
338 | EXEC_X86_WIN32 := wine
|
---|
339 | HOSTSUFF_EXE :=
|
---|
340 | endif
|
---|
341 |
|
---|
342 |
|
---|
343 | #
|
---|
344 | # Build target setup.
|
---|
345 | #
|
---|
346 | ifeq ($(BUILD_TARGET),os2)
|
---|
347 | SUFF_OBJ := .obj
|
---|
348 | SUFF_LIB := .lib
|
---|
349 | SUFF_DLL := .dll
|
---|
350 | SUFF_EXE := .exe
|
---|
351 | SUFF_SYS := .sys
|
---|
352 | SUFF_RES := .res
|
---|
353 | endif
|
---|
354 | ifeq ($(filter-out win32 win64,$(BUILD_TARGET)),)
|
---|
355 | SUFF_OBJ := .obj
|
---|
356 | SUFF_LIB := .lib
|
---|
357 | SUFF_DLL := .dll
|
---|
358 | SUFF_EXE := .exe
|
---|
359 | SUFF_SYS := .sys
|
---|
360 | SUFF_RES := .res
|
---|
361 | endif
|
---|
362 | ifeq ($(BUILD_TARGET),linux)
|
---|
363 | SUFF_OBJ := .o
|
---|
364 | SUFF_LIB := .a
|
---|
365 | SUFF_DLL := .so
|
---|
366 | SUFF_EXE :=
|
---|
367 | SUFF_SYS := .a
|
---|
368 | SUFF_RES :=
|
---|
369 | endif
|
---|
370 | ifeq ($(BUILD_TARGET),l4)
|
---|
371 | SUFF_OBJ := .o
|
---|
372 | SUFF_LIB := .a
|
---|
373 | SUFF_DLL := .s.so
|
---|
374 | SUFF_EXE :=
|
---|
375 | SUFF_SYS := .a
|
---|
376 | SUFF_RES :=
|
---|
377 | endif
|
---|
378 |
|
---|
379 | #
|
---|
380 | # Standard kBuild tools.
|
---|
381 | #
|
---|
382 | ifeq ($(MAKE),kmk)
|
---|
383 | MAKE := $(PATH_TOOLS)/kmk$(HOSTSUFF_EXE)
|
---|
384 | endif
|
---|
385 |
|
---|
386 | DEP_EXT := $(PATH_TOOLS)/kDep$(HOSTSUFF_EXE)
|
---|
387 | ifeq ($(filter kDep,$(KMK_BUILTIN)),kDep)
|
---|
388 | DEP := kmk_builtin_kDep
|
---|
389 | else
|
---|
390 | DEP := $(DEP_EXT)
|
---|
391 | endif
|
---|
392 |
|
---|
393 | DEP_IDB_EXT := $(PATH_TOOLS)/kDepIDB$(HOSTSUFF_EXE)
|
---|
394 | ifeq ($(filter kDepPre,$(KMK_BUILTIN)),kDepIDB)
|
---|
395 | DEP_IDB := $(if kmk_builtin_kDepIDB
|
---|
396 | else
|
---|
397 | DEP_IDB := $(DEP_IDB_EXT)
|
---|
398 | endif
|
---|
399 |
|
---|
400 | DEP_PRE_EXT := $(PATH_TOOLS)/kDepPre$(HOSTSUFF_EXE)
|
---|
401 | ifeq ($(filter kDepPre,$(KMK_BUILTIN)),kDepPre)
|
---|
402 | DEP_PRE := $(if kmk_builtin_kDepPre
|
---|
403 | else
|
---|
404 | DEP_PRE := $(DEP_PRE_EXT)
|
---|
405 | endif
|
---|
406 |
|
---|
407 | APPEND_EXT := $(PATH_TOOLS)/kmk_append$(HOSTSUFF_EXE)
|
---|
408 | ifeq ($(filter append,$(KMK_BUILTIN)),append)
|
---|
409 | APPEND := kmk_builtin_append
|
---|
410 | else
|
---|
411 | APPEND := $(APPEND_EXT)
|
---|
412 | endif
|
---|
413 |
|
---|
414 | CAT_EXT := $(PATH_TOOLS)/kmk_cat$(HOSTSUFF_EXE)
|
---|
415 | ifeq ($(filter cat,$(KMK_BUILTIN)),cat)
|
---|
416 | CAT := kmk_builtin_cat
|
---|
417 | else
|
---|
418 | CAT := $(CAT_EXT)
|
---|
419 | endif
|
---|
420 |
|
---|
421 | CP_EXT := $(PATH_TOOLS)/kmk_cp$(HOSTSUFF_EXE)
|
---|
422 | ifeq ($(filter cp,$(KMK_BUILTIN)),cp)
|
---|
423 | CP := kmk_builtin_cp
|
---|
424 | else
|
---|
425 | CP := $(CP_EXT)
|
---|
426 | endif
|
---|
427 |
|
---|
428 | ECHO_EXT := $(PATH_TOOLS)/kmk_echo$(HOSTSUFF_EXE)
|
---|
429 | ifeq ($(filter echo,$(KMK_BUILTIN)),echo)
|
---|
430 | ECHO := kmk_builtin_echo
|
---|
431 | else
|
---|
432 | ECHO := $(ECHO_EXT)
|
---|
433 | endif
|
---|
434 |
|
---|
435 | INSTALL_EXT := $(PATH_TOOLS)/kmk_install$(HOSTSUFF_EXE)
|
---|
436 | ifeq ($(filter install,$(KMK_BUILTIN)),install)
|
---|
437 | INSTALL := kmk_builtin_install
|
---|
438 | else
|
---|
439 | INSTALL := $(INSTALL_EXT)
|
---|
440 | endif
|
---|
441 |
|
---|
442 | LN_EXT := $(PATH_TOOLS)/kmk_ln$(HOSTSUFF_EXE)
|
---|
443 | ifeq ($(filter ln,$(KMK_BUILTIN)),ln)
|
---|
444 | LN := kmk_builtin_ln
|
---|
445 | else
|
---|
446 | LN := $(LN_EXT)
|
---|
447 | endif
|
---|
448 |
|
---|
449 | MKDIR_EXT := $(PATH_TOOLS)/kmk_mkdir$(HOSTSUFF_EXE)
|
---|
450 | ifeq ($(filter mkdir,$(KMK_BUILTIN)),mkdir)
|
---|
451 | MKDIR := kmk_builtin_mkdir
|
---|
452 | else
|
---|
453 | MKDIR := $(MKDIR_EXT)
|
---|
454 | endif
|
---|
455 |
|
---|
456 | MV_EXT := $(PATH_TOOLS)/kmk_mv$(HOSTSUFF_EXE)
|
---|
457 | ifeq ($(filter mv,$(KMK_BUILTIN)),mv)
|
---|
458 | MV := kmk_builtin_mv
|
---|
459 | else
|
---|
460 | MV := $(MV_EXT)
|
---|
461 | endif
|
---|
462 |
|
---|
463 | RM_EXT := $(PATH_TOOLS)/kmk_rm$(HOSTSUFF_EXE)
|
---|
464 | ifeq ($(filter rm,$(KMK_BUILTIN)),rm)
|
---|
465 | RM := kmk_builtin_rm
|
---|
466 | else
|
---|
467 | RM := $(RM_EXT)
|
---|
468 | endif
|
---|
469 |
|
---|
470 | SED_EXT := $(PATH_TOOLS)/kmk_sed$(HOSTSUFF_EXE)
|
---|
471 | ifeq ($(filter sed,$(KMK_BUILTIN)),sed)
|
---|
472 | SED := kmk_builtin_sed
|
---|
473 | else
|
---|
474 | SED := $(SED_EXT)
|
---|
475 | endif
|
---|
476 |
|
---|
477 | # Our default shell is the Almquist shell from *BSD.
|
---|
478 | ASH := $(PATH_TOOLS)/kmk_ash$(HOSTSUFF_EXE)
|
---|
479 | MAKESHELL := $(ASH)
|
---|
480 | SHELL := $(ASH)
|
---|
481 | export SHELL MAKESHELL
|
---|
482 |
|
---|
483 | # Symlinking is problematic on some platforms...
|
---|
484 | LN_SYMLINK := $(LN) -s
|
---|
485 |
|
---|
486 |
|
---|
487 |
|
---|
488 | #
|
---|
489 | # Message macros.
|
---|
490 | #
|
---|
491 |
|
---|
492 | ifndef BUILD_QUIET
|
---|
493 | ifdef BUILD_DEBUG
|
---|
494 | BUILD_VERBOSE := 9
|
---|
495 | endif
|
---|
496 | MSG_L1 = @$(ECHO) "kBuild: $1"
|
---|
497 | ifdef BUILD_VERBOSE
|
---|
498 | MSG_L2 = @$(ECHO) "kBuild: $1"
|
---|
499 | QUIET :=
|
---|
500 | else
|
---|
501 | QUIET := @
|
---|
502 | MSG_L2 =
|
---|
503 | endif
|
---|
504 | ifdef BUILD_DEBUG
|
---|
505 | MSG_L3 = @$(ECHO) "kBuild: $1"
|
---|
506 | else
|
---|
507 | MSG_L3 =
|
---|
508 | endif
|
---|
509 | else
|
---|
510 | QUIET :=
|
---|
511 | MSG_L1 =
|
---|
512 | MSG_L2 =
|
---|
513 | MSG_L3 =
|
---|
514 | endif
|
---|
515 |
|
---|
516 | ## ABSPATH - make paths absolute.
|
---|
517 | # This implementation is clumsy and doesn't resolve '..' and '.' components.
|
---|
518 | #
|
---|
519 | # @param $1 The paths to make absolute.
|
---|
520 | ifeq ($(filter abspath,$(KMK_FEATURES)),abspath)
|
---|
521 | ABSPATH = $(abspath $(1))
|
---|
522 | else
|
---|
523 | ABSPATH = $(foreach path,$(1)\
|
---|
524 | ,$(strip $(if $(subst <,,$(firstword $(subst /, ,<$(path)))),\
|
---|
525 | $(if $(patsubst %:,,$(firstword $(subst :,: ,$(path)))),$(PATH_CURRENT)/$(path),$(path)),\
|
---|
526 | $(path))))
|
---|
527 | endif
|
---|
528 |
|
---|
529 | ## DIRDEP - make create directory dependencies.
|
---|
530 | #
|
---|
531 | # @param $1 The paths to the directories which must be created.
|
---|
532 | ifeq ($(filter-out win32 win64,$(BUILD_PLATFORM)),)
|
---|
533 | DIRDEP = $(patsubst %/,%,$(1))
|
---|
534 | else
|
---|
535 | DIRDEP = $(foreach path,$(patsubst %/,%,$(1)),$(path)/)
|
---|
536 | endif
|
---|
537 |
|
---|
538 |
|
---|
539 | ## Cygwin kludge.
|
---|
540 | # This converts /cygdrive/x/% to x:%.
|
---|
541 | #
|
---|
542 | # @param $1 The paths to make native.
|
---|
543 | # @remark This macro is pretty much obsolete since we don't use cygwin base make.
|
---|
544 | ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
|
---|
545 | CYGPATHMIXED = $(foreach path,$(1)\
|
---|
546 | ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
|
---|
547 | else
|
---|
548 | CYGPATHMIXED = $(1)
|
---|
549 | endif
|
---|
550 |
|
---|
551 | #
|
---|
552 | # Initialize some of the globals which the Config.kmk and
|
---|
553 | # others can add stuff to if they like for processing in the footer.
|
---|
554 | #
|
---|
555 |
|
---|
556 | ## ALL_TARGET
|
---|
557 | # This is the list of all targets.
|
---|
558 | ALL_TARGETS :=
|
---|
559 |
|
---|
560 | ## TEMPLATE_PATHS
|
---|
561 | # List a paths (separated by space) where templates can be found.
|
---|
562 | TEMPLATE_PATHS :=
|
---|
563 |
|
---|
564 | ## TOOL_PATHS
|
---|
565 | # List of paths (separated by space) where tools can be found.
|
---|
566 | TOOL_PATHS :=
|
---|
567 |
|
---|
568 | ## SDK_PATHS
|
---|
569 | # List of paths (separated by space) where SDKs can be found.
|
---|
570 | SDK_PATHS :=
|
---|
571 |
|
---|
572 | ## Proritized list of the default makefile when walking subdirectories.
|
---|
573 | # The user can overload this list.
|
---|
574 | DEFAULT_MAKEFILE := Makefile.kmk makefile.kmk Makefile makefile
|
---|
575 |
|
---|
576 | ## PROPS_SINGLE
|
---|
577 | # The list of non-accumulative target properties.
|
---|
578 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
579 | # will do the necessary inheritance from templates to targets.
|
---|
580 | PROPS_SINGLE := TOOL ARTOOL CTOOL CXXTOOL ASTOOL LDTOOL INST NOINST
|
---|
581 |
|
---|
582 | ## PROPS_DEFERRED
|
---|
583 | # This list of non-accumulative target properties which are functions,
|
---|
584 | # and thus should not be expanded until the very last moment.
|
---|
585 | PROPS_DEFERRED := INSTFUN INSTALLER
|
---|
586 |
|
---|
587 | ## PROPS_ACCUMULATE
|
---|
588 | # The list of accumulative target properties.
|
---|
589 | # A Config.kmk file can add it's own properties to this list and kBuild
|
---|
590 | # will do the necessary inheritance from templates to targets.
|
---|
591 | PROPS_ACCUMULATE := \
|
---|
592 | SDKS DEFS DEPS INCS SOURCES \
|
---|
593 | COPTS CFLAGS CDEFS CINCS CXXOPTS CXXFLAGS CXXDEFS CXXINCS \
|
---|
594 | ASOPTS ASFLAGS ASDEFS ASINCS \
|
---|
595 | LDFLAGS LIBS LIBPATH \
|
---|
596 | BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU \
|
---|
597 | SYSSUFF EXESUFF DLLSUFF LIBSUFF ARLIBSUFF \
|
---|
598 |
|
---|
599 |
|
---|
600 | ## PROPS_TOOLS
|
---|
601 | # This is a subset of the other PROPS
|
---|
602 | PROPS_TOOLS := TOOL CTOOL CXXTOOL ASTOOL ARTOOL LDTOOL
|
---|
603 |
|
---|
604 |
|
---|
605 | #
|
---|
606 | # Pass configuration.
|
---|
607 | #
|
---|
608 | # The PASS_<passname>_trgs variable is listing the targets.
|
---|
609 | # The PASS_<passname>_vars variable is listing the target variables.
|
---|
610 | # The PASS_<passname>_pass variable is the lowercased passname.
|
---|
611 | #
|
---|
612 |
|
---|
613 | ## PASS: bldprogs
|
---|
614 | # This pass builds targets which are required for building the rest.
|
---|
615 | PASS_BLDPROGS := Build Programs
|
---|
616 | PASS_BLDPROGS_trgs :=
|
---|
617 | PASS_BLDPROGS_vars := _BLDPROGS
|
---|
618 | PASS_BLDPROGS_pass := bldprogs
|
---|
619 |
|
---|
620 | ## PASS: libraries
|
---|
621 | # This pass builds library targets.
|
---|
622 | PASS_LIBRARIES := Libraries
|
---|
623 | PASS_LIBRARIES_trgs :=
|
---|
624 | PASS_LIBRARIES_vars := _LIBS _IMPORT_LIBS _OTHER_LIBRARIES
|
---|
625 | PASS_LIBRARIES_pass := libraries
|
---|
626 |
|
---|
627 | ## PASS: binaries
|
---|
628 | # This pass builds dll targets.
|
---|
629 | PASS_DLLS := DLLs
|
---|
630 | PASS_DLLS_trgs :=
|
---|
631 | PASS_DLLS_vars := _DLLS _OTHER_DLLS
|
---|
632 | PASS_DLLS_pass := dlls
|
---|
633 |
|
---|
634 | ## PASS: binaries
|
---|
635 | # This pass builds binary targets, i.e. programs, system modules and stuff.
|
---|
636 | PASS_BINARIES := Programs
|
---|
637 | PASS_BINARIES_trgs :=
|
---|
638 | PASS_BINARIES_vars := _PROGRAMS _SYSMODS _OTHER_BINARIES
|
---|
639 | PASS_BINARIES_pass := binaries
|
---|
640 |
|
---|
641 | ## PASS: others
|
---|
642 | # This pass builds other targets.
|
---|
643 | PASS_OTHERS := Other Stuff
|
---|
644 | PASS_OTHERS_trgs :=
|
---|
645 | PASS_OTHERS_vars := _OTHERS
|
---|
646 | PASS_OTHERS_pass := others
|
---|
647 |
|
---|
648 | ## PASS: install
|
---|
649 | # This pass installs the built entities to a sandbox area.
|
---|
650 | PASS_INSTALLS := Install
|
---|
651 | PASS_INSTALLS_trgs :=
|
---|
652 | PASS_INSTALLS_vars := _INSTALLS_DIRS _INSTALLS
|
---|
653 | PASS_INSTALLS_pass := installs
|
---|
654 |
|
---|
655 | ## PASS: packing
|
---|
656 | # This pass processes custom packing rules.
|
---|
657 | PASS_PACKING := Packing
|
---|
658 | PASS_PACKING_trgs :=
|
---|
659 | PASS_PACKING_vars := _PACKING
|
---|
660 | PASS_PACKING_pass := packing
|
---|
661 | #alias
|
---|
662 | packing: pass_packing
|
---|
663 |
|
---|
664 | ## PASS: clean
|
---|
665 | # This pass removes all generated files.
|
---|
666 | PASS_CLEAN := Clean
|
---|
667 | PASS_CLEAN_trgs := do-clean
|
---|
668 | PASS_CLEAN_vars :=
|
---|
669 | PASS_CLEAN_pass := clean
|
---|
670 | # alias
|
---|
671 | clean: pass_clean
|
---|
672 |
|
---|
673 | ## PASS: nothing
|
---|
674 | # This pass just walks the tree.
|
---|
675 | PASS_NOTHING := Nothing
|
---|
676 | PASS_NOTHING_trgs := do-nothing
|
---|
677 | PASS_NOTHING_vars :=
|
---|
678 | PASS_NOTHING_pass := nothing
|
---|
679 | # alias
|
---|
680 | nothing: pass_nothing
|
---|
681 |
|
---|
682 | ## DEFAULT_PASSES
|
---|
683 | # The default passes and their order.
|
---|
684 | DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES OTHERS INSTALLS
|
---|
685 |
|
---|
686 | ## PASSES
|
---|
687 | # The passes that should be defined. This must include
|
---|
688 | # all passes mentioned by DEFAULT_PASSES.
|
---|
689 | PASSES := $(DEFAULT_PASSES) NOTHING CLEAN
|
---|
690 |
|
---|
691 |
|
---|
692 | #
|
---|
693 | # This is how we find the closest config.kmk.
|
---|
694 | # It's a little hacky but I think it works fine.
|
---|
695 | #
|
---|
696 | _CFGDIR := .
|
---|
697 | _CFGFILES := ./Config.kmk ./config.kmk
|
---|
698 | define def_include_config
|
---|
699 | $(eval _CFGDIR := $(_CFGDIR)/$(dir))
|
---|
700 | _CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
|
---|
701 | endef
|
---|
702 | # walk down the _RELATIVE_ path specified by DEPTH.
|
---|
703 | $(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
|
---|
704 | # add the default config file.
|
---|
705 | _CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
|
---|
706 | _CFGFILES :=
|
---|
707 | _CFGDIR :=
|
---|
708 | ifeq ($(_CFGFILE),)
|
---|
709 | $(error kBuild: no Config.kmk file found! Check the DEPTH: DEPTH='$(DEPTH)' PATH_CURRENT='$(PATH_CURRENT)')
|
---|
710 | endif
|
---|
711 |
|
---|
712 | # Include the config.kmk we found file (or the default one).
|
---|
713 | include $(_CFGFILE)
|
---|
714 |
|
---|
715 |
|
---|
716 | # end-of-file-content
|
---|
717 | __header_kmk__ := 1
|
---|
718 | endif # __header_kmk__
|
---|