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