source: trunk/kBuild/header.kmk@ 91

Last change on this file since 91 was 88, checked in by bird, 21 years ago

..

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 KB
Line 
1# $Id: header.kmk 88 2004-06-04 16:14:30Z bird $
2## @file
3#
4# kBuild - File included at top of makefile.
5#
6# Copyright (c) 2004 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
27ifndef __header_kmk__
28# start-of-file-content
29
30#
31# default rule
32#
33all: all_recursive
34
35#
36# Try avoid inference rules.
37#
38.SUFFIXES:
39SUFFIXES :=
40
41
42#
43# Assert build type.
44#
45ifndef BUILD_TYPE
46ifndef BUILD_MODE
47$(error kBuild: You must define BUILD_TYPE!)
48endif
49BUILD_TYPE := $(BUILD_MODE)
50endif
51ifeq ($(BUILD_TYPE),DEBUG)
52BUILD_TYPE := debug
53endif
54ifeq ($(BUILD_TYPE),RELEASE)
55BUILD_TYPE := release
56endif
57ifeq ($(BUILD_TYPE),PROFILE)
58BUILD_TYPE := profile
59endif
60
61
62#
63# Assert build platform.
64#
65_BUILD_PLATFORM_OK := 0
66# OS/2
67ifeq ($(BUILD_PLATFORM),OS2)
68$(error kBuild: BUILD_PLATFORM must be all lowercase!)
69endif
70ifeq ($(BUILD_PLATFORM),os2)
71_BUILD_PLATFORM_OK := 1
72endif
73
74# Linux
75ifeq ($(BUILD_PLATFORM),LINUX)
76$(error kBuild: BUILD_PLATFORM must be all lowercase!)
77endif
78ifeq ($(BUILD_PLATFORM),linux)
79_BUILD_PLATFORM_OK := 1
80endif
81
82# Win32
83ifeq ($(BUILD_PLATFORM),WIN32)
84$(error kBuild: BUILD_PLATFORM must be all lowercase!)
85endif
86ifeq ($(BUILD_PLATFORM),win32)
87_BUILD_PLATFORM_OK := 1
88endif
89
90ifeq ($(_BUILD_PLATFORM_OK),0)
91$(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' was not recongized!)
92endif
93
94
95#
96# Assert target platform.
97#
98ifndef BUILD_TARGET
99# not defined, set to the same as build platform
100BUILD_TARGET := $(BUILD_PLATFORM)
101else
102_BUILD_TARGET_OK := 0
103# OS/2
104ifeq ($(BUILD_TARGET),OS2)
105$(error kBuild: BUILD_TARGET must be all lowercase!)
106endif
107ifeq ($(BUILD_TARGET),os2)
108_BUILD_TARGET_OK := 1
109endif
110
111# Linux
112ifeq ($(BUILD_TARGET),LINUX)
113$(error kBuild: BUILD_TARGET must be all lowercase!)
114endif
115ifeq ($(BUILD_TARGET),linux)
116_BUILD_TARGET_OK := 1
117endif
118
119# Win32
120ifeq ($(BUILD_TARGET),WIN32)
121$(error kBuild: BUILD_TARGET must be all lowercase!)
122endif
123ifeq ($(BUILD_TARGET),win32)
124_BUILD_TARGET_OK := 1
125endif
126
127ifeq ($(_BUILD_TARGET_OK),0)
128$(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' was not recongized!)
129endif
130endif
131BUILD_TARGET_ARCH := x86
132BUILD_TARGET_CPU := i586
133
134#
135# Cygwin kludge.
136#
137ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
138CYGPATHMIXED = $(foreach path,$(1)\
139 ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
140else
141CYGPATHMIXED = $(1)
142endif
143
144#
145# Common definitions.
146#
147PATH_CURRENT := $(CURDIR)
148# Get the real root path.
149PATH_ROOT := $(PATH_CURRENT)
150ifneq ($(DEPTH),.)
151$(foreach d,$(subst /, ,$(DEPTH)), $(eval PATH_ROOT := $(patsubst %/,%,$(dir $(PATH_ROOT)))) )
152endif
153# Subdirectory relative to the root.
154CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(CURDIR))
155# Output directories.
156PATH_OUT := $(PATH_ROOT)/out/$(BUILD_TARGET)/$(BUILD_TYPE)
157PATH_OBJ := $(PATH_OUT)/obj
158PATH_BIN := $(PATH_OUT)/bin
159PATH_LIB := $(PATH_OUT)/lib
160PATH_DOC := $(PATH_ROOT)/out/doc
161PATH_TARGET := $(PATH_OBJ)/$(CURSUBDIR)
162
163# Usually kBuild is external to the source tree.
164ifndef PATH_KBUILD
165PATH_KBUILD := $(PATH_ROOT)/kBuild
166endif
167# kBuild tools
168PATH_TOOLS_W32 := $(PATH_KBUILD)/bin/x86.win32
169PATH_TOOLS_LNX := $(PATH_KBUILD)/bin/x86.linux
170PATH_TOOLS_OS2 := $(PATH_KBUILD)/bin/x86.os2
171# kBuild files which might be of interest.
172FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk
173FILE_KBUILD_CONFIG := $(PATH_KBUILD)/config.kmk
174FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk
175
176SUFF_DEP := .dep
177
178
179#
180# Get rid of the GNU Make default stuff
181#
182include $(PATH_KBUILD)/StampOutPredefines.kmk
183
184
185#
186# Build platform setup.
187#
188# OS/2
189ifeq ($(BUILD_PLATFORM),os2)
190PATH_TOOLS := $(PATH_TOOLS_OS2)
191EXEC_X86_WIN32 := innopec.exe
192HOSTSUFF_EXE := .exe
193endif
194
195# Linux
196ifeq ($(BUILD_PLATFORM),linux)
197PATH_TOOLS := $(PATH_TOOLS_LNX)
198EXEC_X86_WIN32 := wine
199HOSTSUFF_EXE :=
200endif
201
202# Win32
203ifeq ($(BUILD_PLATFORM),win32)
204PATH_TOOLS := $(PATH_TOOLS_W32)
205EXEC_X86_WIN32 :=
206HOSTSUFF_EXE := .exe
207endif
208
209#
210# Build target setup.
211#
212ifeq ($(BUILD_TARGET),os2)
213SUFF_OBJ := .obj
214SUFF_LIB := .lib
215SUFF_DLL := .dll
216SUFF_EXE := .exe
217SUFF_SYS := .sys
218SUFF_RES := .res
219endif
220ifeq ($(BUILD_TARGET),win32)
221SUFF_OBJ := .obj
222SUFF_LIB := .lib
223SUFF_DLL := .dll
224SUFF_EXE := .exe
225SUFF_SYS := .sys
226SUFF_RES := .res
227endif
228ifeq ($(BUILD_TARGET),linux)
229SUFF_OBJ := .o
230SUFF_LIB := .a
231SUFF_DLL := .so
232SUFF_EXE :=
233SUFF_SYS := .a
234SUFF_RES :=
235endif
236
237
238#
239# Standard kBuild tools.
240#
241DEP := $(PATH_TOOLS)/kDep$(HOSTSUFF_EXE)
242# Standard Unix shell utils.
243MKDIR := $(PATH_TOOLS)/mkdir$(HOSTSUFF_EXE)
244RM := $(PATH_TOOLS)/rm$(HOSTSUFF_EXE)
245CP := $(PATH_TOOLS)/cp$(HOSTSUFF_EXE)
246MV := $(PATH_TOOLS)/mv$(HOSTSUFF_EXE)
247SED := $(PATH_TOOLS)/sed$(HOSTSUFF_EXE)
248CAT := $(PATH_TOOLS)/cat$(HOSTSUFF_EXE)
249# Bourn shell clone.
250MAKESHELL := $(PATH_TOOLS)/ash$(HOSTSUFF_EXE)
251SHELL := $(MAKESHELL)
252export SHELL MAKESHELL
253
254
255#
256# Message macros.
257#
258
259ifndef BUILD_QUIET
260ifdef BUILD_DEBUG
261BUILD_VERBOSE := 9
262endif
263MSG_L1 = @echo "kBuild: $1"
264ifdef BUILD_VERBOSE
265MSG_L2 = @echo "kBuild: $1"
266QUIET :=
267else
268QUIET := @
269MSG_L2 =
270endif
271ifdef BUILD_DEBUG
272MSG_L3 = @echo "kBuild: $1"
273else
274MSG_L3 =
275endif
276else
277QUIET :=
278MSG_L1 =
279MSG_L2 =
280MSG_L3 =
281endif
282
283#
284# This is how we find the closest config.kmk.
285# It's a little hacky but I think it works fine.
286#
287_CFGDIR := .
288_CFGFILES := ./Config.kmk ./config.kmk
289define def_include_config
290$(eval _CFGDIR := $(_CFGDIR)/$(dir))
291_CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
292endef
293# walk down the _RELATIVE_ path specified by DEPTH.
294$(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
295# add the default config file.
296_CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
297_CFGFILES :=
298_CFGDIR :=
299
300# Include the config.kmk we found file (or the default one).
301include $(_CFGFILE)
302
303
304# end-of-file-content
305__header_kmk__ := 1
306endif # __header_kmk__
Note: See TracBrowser for help on using the repository browser.