source: trunk/kBuild/header.kmk@ 121

Last change on this file since 121 was 103, checked in by bird, 21 years ago

MSC confuses '/' in files with '/' in options, naturally..

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