source: trunk/kBuild/header.kmk@ 78

Last change on this file since 78 was 78, 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: 6.5 KB
Line 
1# $Id: header.kmk 78 2004-06-01 01:07:24Z 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)
68BUILD_PLATFORM := os2
69endif
70ifeq ($(BUILD_PLATFORM),os2)
71_BUILD_PLATFORM_OK := 1
72endif
73
74# Linux
75ifeq ($(BUILD_PLATFORM),LINUX)
76BUILD_PLATFORM := linux
77endif
78ifeq ($(BUILD_PLATFORM),linux)
79_BUILD_PLATFORM_OK := 1
80endif
81
82# Win32
83ifeq ($(BUILD_PLATFORM),WIN32)
84BUILD_PLATFORM := win32
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)
105BUILD_TARGET := os2
106endif
107ifeq ($(BUILD_TARGET),os2)
108_BUILD_TARGET_OK := 1
109endif
110
111# Linux
112ifeq ($(BUILD_TARGET),LINUX)
113BUILD_TARGET := linux
114endif
115ifeq ($(BUILD_TARGET),linux)
116_BUILD_TARGET_OK := 1
117endif
118
119# Win32
120ifeq ($(BUILD_TARGET),WIN32)
121BUILD_TARGET := win32
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#
136# Common definitions.
137#
138PATH_CURRENT := $(CURDIR)
139# Get the real root path.
140PATH_ROOT := $(CURDIR)
141ifneq ($(DEPTH),.)
142$(foreach d,$(subst /, ,$(DEPTH)), $(eval PATH_ROOT := $(patsubst %/,%,$(dir $(PATH_ROOT)))) )
143endif
144# Subdirectory relative to the root.
145CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(CURDIR))
146# Output directories.
147PATH_OUT := $(PATH_ROOT)/out/$(BUILD_TARGET)/$(BUILD_TYPE)
148PATH_OBJ := $(PATH_OUT)/obj
149PATH_BIN := $(PATH_OUT)/bin
150PATH_LIB := $(PATH_OUT)/lib
151PATH_DOC := $(PATH_ROOT)/out/doc
152PATH_TARGET := $(PATH_OBJ)/$(CURSUBDIR)
153
154# Usually kBuild is external to the source tree.
155ifndef PATH_KBUILD
156PATH_KBUILD := $(PATH_ROOT)/kBuild
157endif
158# kBuild tools
159PATH_TOOLS_W32 := $(PATH_KBUILD)/bin/x86.win32
160PATH_TOOLS_LNX := $(PATH_KBUILD)/bin/x86.linux
161PATH_TOOLS_OS2 := $(PATH_KBUILD)/bin/x86.os2
162# kBuild files which might be of interest.
163FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk
164FILE_KBUILD_CONFIG := $(PATH_KBUILD)/config.kmk
165FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk
166
167SUFF_DEP := .dep
168
169
170#
171# Get rid of the GNU Make default stuff
172#
173include $(PATH_KBUILD)/StampOutPredefines.kmk
174
175
176#
177# Build platform setup.
178#
179# OS/2
180ifeq ($(BUILD_PLATFORM),os2)
181PATH_TOOLS := $(PATH_TOOLS_OS2)
182EXEC_X86_WIN32 := $(PATH_TOOLS)/bin/innopec.exe
183HOSTSUFF_EXE := .exe
184endif
185
186# Linux
187ifeq ($(BUILD_PLATFORM),linux)
188PATH_TOOLS := $(PATH_TOOLS_LNX)
189EXEC_X86_WIN32 := wine
190HOSTSUFF_EXE :=
191endif
192
193# Win32
194ifeq ($(BUILD_PLATFORM),win32)
195PATH_TOOLS := $(PATH_TOOLS_W32)
196EXEC_X86_WIN32 :=
197HOSTSUFF_EXE := .exe
198endif
199
200#
201# Build target setup.
202#
203ifeq ($(BUILD_TARGET),os2)
204SUFF_OBJ := .obj
205SUFF_LIB := .lib
206SUFF_DLL := .dll
207SUFF_EXE := .exe
208SUFF_DRV := .sys
209SUFF_RES := .res
210endif
211ifeq ($(BUILD_TARGET),win32)
212SUFF_OBJ := .obj
213SUFF_LIB := .lib
214SUFF_DLL := .dll
215SUFF_EXE := .exe
216SUFF_DRV := .sys
217SUFF_RES := .res
218endif
219ifeq ($(BUILD_TARGET),linux)
220SUFF_OBJ := .o
221SUFF_LIB := .a
222SUFF_DLL := .so
223SUFF_EXE :=
224SUFF_DRV := .a
225SUFF_RES :=
226endif
227
228
229#
230# Standard kBuild tools.
231#
232DEP := $(PATH_TOOLS)/kDep$(HOSTSUFF_EXE)
233# Standard Unix shell utils.
234MKDIR := $(PATH_TOOLS)/mkdir$(HOSTSUFF_EXE)
235RM := $(PATH_TOOLS)/rm$(HOSTSUFF_EXE)
236CP := $(PATH_TOOLS)/mv$(HOSTSUFF_EXE)
237MV := $(PATH_TOOLS)/cp$(HOSTSUFF_EXE)
238SED := $(PATH_TOOLS)/sed$(HOSTSUFF_EXE)
239CAT := $(PATH_TOOLS)/cat$(HOSTSUFF_EXE)
240# Bourn shell clone.
241MAKESHELL := $(PATH_TOOLS)/ash$(HOSTSUFF_EXE)
242SHELL := $(MAKESHELL)
243export SHELL MAKESHELL
244
245
246#
247# Message macros.
248#
249
250ifndef BUILD_QUIET
251ifdef BUILD_DEBUG
252BUILD_VERBOSE := 9
253endif
254MSG_L1 = @echo "kBuild: $1"
255ifdef BUILD_VERBOSE
256MSG_L2 = @echo "kBuild: $1"
257QUIET :=
258else
259QUIET := @
260MSG_L2 =
261endif
262ifdef BUILD_DEBUG
263MSG_L3 = @echo "kBuild: $1"
264else
265MSG_L3 =
266endif
267else
268QUIET :=
269MSG_L1 =
270MSG_L2 =
271MSG_L3 =
272endif
273
274#
275# This is how we find the closest config.kmk.
276# It's a little hacky but I think it works fine.
277#
278_CFGDIR := .
279_CFGFILES := ./Config.kmk ./config.kmk
280define def_include_config
281$(eval _CFGDIR := $(_CFGDIR)/$(dir))
282_CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
283endef
284# walk down the _RELATIVE_ path specified by DEPTH.
285$(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
286# add the default config file.
287_CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
288_CFGFILES :=
289_CFGDIR :=
290
291# Include the config.kmk we found file (or the default one).
292include $(_CFGFILE)
293
294
295# end-of-file-content
296__header_kmk__ := 1
297endif # __header_kmk__
Note: See TracBrowser for help on using the repository browser.