source: trunk/kBuild/header.kmk@ 75

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