source: trunk/kBuild/header.kmk@ 292

Last change on this file since 292 was 292, checked in by bird, 20 years ago

Added L4.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.3 KB
RevLine 
[69]1# $Id: header.kmk 292 2005-06-01 15:06:11Z 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#
[204]45
[95]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
[271]76# OS/2 (have uppercase legacy)
[72]77ifeq ($(BUILD_PLATFORM),OS2)
[271]78override BUILD_PLATFORM := os2
[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
[292]100# L4
101ifeq ($(BUILD_PLATFORM),L4)
102$(error kBuild: BUILD_PLATFORM must be all lowercase!)
103endif
104ifeq ($(BUILD_PLATFORM),l4)
105_BUILD_PLATFORM_OK := 1
106endif
107
[72]108ifeq ($(_BUILD_PLATFORM_OK),0)
109$(error kBuild: BUILD_PLATFORM value '$(BUILD_PLATFORM)' was not recongized!)
110endif
[95]111BUILD_PLATFORM_ARCH := x86
112BUILD_PLATFORM_CPU := i586
[72]113
114
[70]115#
[72]116# Assert target platform.
117#
118ifndef BUILD_TARGET
119# not defined, set to the same as build platform
120BUILD_TARGET := $(BUILD_PLATFORM)
121else
122_BUILD_TARGET_OK := 0
123# OS/2
124ifeq ($(BUILD_TARGET),OS2)
[88]125$(error kBuild: BUILD_TARGET must be all lowercase!)
[72]126endif
127ifeq ($(BUILD_TARGET),os2)
128_BUILD_TARGET_OK := 1
129endif
130
131# Linux
132ifeq ($(BUILD_TARGET),LINUX)
[88]133$(error kBuild: BUILD_TARGET must be all lowercase!)
[72]134endif
135ifeq ($(BUILD_TARGET),linux)
136_BUILD_TARGET_OK := 1
137endif
138
139# Win32
140ifeq ($(BUILD_TARGET),WIN32)
[88]141$(error kBuild: BUILD_TARGET must be all lowercase!)
[72]142endif
[77]143ifeq ($(BUILD_TARGET),win32)
[72]144_BUILD_TARGET_OK := 1
145endif
146
[292]147# L4
148ifeq ($(BUILD_TARGET),L4)
149$(error kBuild: BUILD_TARGET must be all lowercase!)
150endif
151ifeq ($(BUILD_TARGET),l4)
152_BUILD_TARGET_OK := 1
153endif
154
[72]155ifeq ($(_BUILD_TARGET_OK),0)
156$(error kBuild: BUILD_TARGET value '$(BUILD_TARGET)' was not recongized!)
157endif
158endif
[78]159BUILD_TARGET_ARCH := x86
160BUILD_TARGET_CPU := i586
[72]161
[266]162# Adjust the DEPTH definition first
163ifeq ($(strip $(DEPTH)),)
164DEPTH := .
165endif
[72]166
167#
[69]168# Common definitions.
169#
170PATH_CURRENT := $(CURDIR)
[70]171# Get the real root path.
[85]172PATH_ROOT := $(PATH_CURRENT)
[70]173ifneq ($(DEPTH),.)
174$(foreach d,$(subst /, ,$(DEPTH)), $(eval PATH_ROOT := $(patsubst %/,%,$(dir $(PATH_ROOT)))) )
[69]175endif
[70]176# Subdirectory relative to the root.
[266]177ifneq ($(DEPTH),.)
[72]178CURSUBDIR := $(patsubst $(PATH_ROOT)/%,%,$(CURDIR))
[266]179else
180CURSUBDIR := .
181endif
[70]182# Output directories.
[242]183ifndef PATH_OUT_BASE
184PATH_OUT_BASE := $(PATH_ROOT)/out
185endif
[240]186ifndef PATH_OUT
[245]187ifdef BUILD_TARGET_SUB # (BUILD_TARGET_SUB is not currently recognized by kBuild in any other places.)
188PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET)/$(BUILD_TARGET_SUB)/$(BUILD_TYPE)
189else
[242]190PATH_OUT := $(PATH_OUT_BASE)/$(BUILD_TARGET)/$(BUILD_TYPE)
[240]191endif
[245]192endif
[69]193PATH_OBJ := $(PATH_OUT)/obj
[271]194PATH_TARGET := $(PATH_OBJ)/$(CURSUBDIR)
195ifndef KBUILD_NEW_STUFF
[69]196PATH_BIN := $(PATH_OUT)/bin
197PATH_LIB := $(PATH_OUT)/lib
198PATH_DOC := $(PATH_ROOT)/out/doc
[271]199else
200PATH_INS := $(PATH_OUT)
201PATH_BIN := $(PATH_INS)/bin
202PATH_DLL := $(PATH_INS)/bin
203PATH_LIB := $(PATH_INS)/lib
204PATH_DOC := $(PATH_INS)/doc
205endif
[70]206
207# Usually kBuild is external to the source tree.
208ifndef PATH_KBUILD
209PATH_KBUILD := $(PATH_ROOT)/kBuild
210endif
211# kBuild tools
[69]212PATH_TOOLS_W32 := $(PATH_KBUILD)/bin/x86.win32
213PATH_TOOLS_LNX := $(PATH_KBUILD)/bin/x86.linux
214PATH_TOOLS_OS2 := $(PATH_KBUILD)/bin/x86.os2
215# kBuild files which might be of interest.
216FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk
217FILE_KBUILD_CONFIG := $(PATH_KBUILD)/config.kmk
218FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk
219
[72]220SUFF_DEP := .dep
[204]221MAKEFILE := $(firstword $(MAKEFILE_LIST))
[69]222
[72]223
[69]224#
225# Get rid of the GNU Make default stuff
226#
[230]227ifndef KMK_VERSION
[69]228include $(PATH_KBUILD)/StampOutPredefines.kmk
[216]229endif
[69]230
231#
[72]232# Build platform setup.
[69]233#
234# OS/2
[72]235ifeq ($(BUILD_PLATFORM),os2)
[69]236PATH_TOOLS := $(PATH_TOOLS_OS2)
[83]237EXEC_X86_WIN32 := innopec.exe
[69]238HOSTSUFF_EXE := .exe
239endif
240
241# Linux
[72]242ifeq ($(BUILD_PLATFORM),linux)
[69]243PATH_TOOLS := $(PATH_TOOLS_LNX)
[135]244EXEC_X86_WIN32 := wine
[69]245HOSTSUFF_EXE :=
246endif
[70]247
[69]248# Win32
[72]249ifeq ($(BUILD_PLATFORM),win32)
[69]250PATH_TOOLS := $(PATH_TOOLS_W32)
251EXEC_X86_WIN32 :=
252HOSTSUFF_EXE := .exe
253endif
254
[125]255
[73]256#
257# Build target setup.
258#
259ifeq ($(BUILD_TARGET),os2)
260SUFF_OBJ := .obj
261SUFF_LIB := .lib
262SUFF_DLL := .dll
263SUFF_EXE := .exe
[86]264SUFF_SYS := .sys
[73]265SUFF_RES := .res
266endif
267ifeq ($(BUILD_TARGET),win32)
268SUFF_OBJ := .obj
269SUFF_LIB := .lib
270SUFF_DLL := .dll
271SUFF_EXE := .exe
[86]272SUFF_SYS := .sys
[73]273SUFF_RES := .res
274endif
275ifeq ($(BUILD_TARGET),linux)
276SUFF_OBJ := .o
277SUFF_LIB := .a
278SUFF_DLL := .so
279SUFF_EXE :=
[86]280SUFF_SYS := .a
[73]281SUFF_RES :=
282endif
[69]283
[73]284
[69]285#
286# Standard kBuild tools.
287#
288DEP := $(PATH_TOOLS)/kDep$(HOSTSUFF_EXE)
[262]289DEP_PRE := $(PATH_TOOLS)/kDepPre$(HOSTSUFF_EXE)
[233]290ifeq ($(MAKE),kmk)
291MAKE := $(PATH_TOOLS)/kmk$(HOSTSUFF_EXE)
292endif
293
[69]294# Standard Unix shell utils.
[230]295ifdef KMK_BUILTIN
296ECHO := kmk_builtin_echo
297MKDIR := kmk_builtin_mkdir
298RM := kmk_builtin_rm
299CP := kmk_builtin_cp
300else
301ECHO := echo
[69]302MKDIR := $(PATH_TOOLS)/mkdir$(HOSTSUFF_EXE)
303RM := $(PATH_TOOLS)/rm$(HOSTSUFF_EXE)
[87]304CP := $(PATH_TOOLS)/cp$(HOSTSUFF_EXE)
[230]305endif
[237]306CP_EXT := $(PATH_TOOLS)/cp$(HOSTSUFF_EXE)
[87]307MV := $(PATH_TOOLS)/mv$(HOSTSUFF_EXE)
[69]308SED := $(PATH_TOOLS)/sed$(HOSTSUFF_EXE)
309CAT := $(PATH_TOOLS)/cat$(HOSTSUFF_EXE)
310# Bourn shell clone.
311MAKESHELL := $(PATH_TOOLS)/ash$(HOSTSUFF_EXE)
312SHELL := $(MAKESHELL)
313export SHELL MAKESHELL
314
315
316#
[73]317# Message macros.
[204]318#
319
[73]320ifndef BUILD_QUIET
[75]321ifdef BUILD_DEBUG
322BUILD_VERBOSE := 9
323endif
[230]324MSG_L1 = @$(ECHO) "kBuild: $1"
[73]325ifdef BUILD_VERBOSE
[230]326MSG_L2 = @$(ECHO) "kBuild: $1"
[75]327QUIET :=
[73]328else
[75]329QUIET := @
[73]330MSG_L2 =
331endif
332ifdef BUILD_DEBUG
[230]333MSG_L3 = @$(ECHO) "kBuild: $1"
[73]334else
335MSG_L3 =
336endif
337else
[75]338QUIET :=
[73]339MSG_L1 =
340MSG_L2 =
341MSG_L3 =
342endif
343
[130]344## ABSPATH - make paths absolute.
[129]345# This implementation is clumsy and doesn't resolve '..' and '.' components.
[73]346#
[129]347# @param $1 The paths to make absolute.
348ABSPATH = $(foreach path,$(1)\
349 ,$(strip $(if $(subst <,,$(firstword $(subst /, ,<$(path)))),\
350 $(if $(patsubst %:,,$(firstword $(subst :,: ,$(path)))),$(PATH_CURRENT)/$(path),$(path)),\
351 $(path))))
[130]352## DIRDEP - make create directory dependencies.
353#
354# @param $1 The paths to the directories which must be created.
355DIRDEP = $(foreach path,$(1),$(path)/.dir_created)
[129]356
[204]357
[129]358## Cygwin kludge.
359# This converts /cygdrive/x/% to x:%.
360#
361# @param $1 The paths to make native.
362# @remark This macro is pretty much obsolete since we don't use cygwin base make.
363ifneq ($(patsubst /cygdrive/%,%,$(CURDIR)),$(CURDIR))
364CYGPATHMIXED = $(foreach path,$(1)\
365 ,$(if $(patsubst /cygdrive/%,,$(path)),$(path),$(patsubst $(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path)))))/%,$(strip $(firstword $(subst /, ,$(patsubst /cygdrive/%,%,$(path))))):/%,$(patsubst /cygdrive/%,%,$(path)))))
366else
367CYGPATHMIXED = $(1)
368endif
369
370#
[69]371# This is how we find the closest config.kmk.
372# It's a little hacky but I think it works fine.
[70]373#
374_CFGDIR := .
[78]375_CFGFILES := ./Config.kmk ./config.kmk
[69]376define def_include_config
[78]377$(eval _CFGDIR := $(_CFGDIR)/$(dir))
378_CFGFILES += $(_CFGDIR)/Config.kmk $(_CFGDIR)/config.kmk
[69]379endef
380# walk down the _RELATIVE_ path specified by DEPTH.
[78]381$(foreach dir,$(subst /, ,$(DEPTH)), $(eval $(def_include_config)) )
[69]382# add the default config file.
[78]383_CFGFILE := $(firstword $(wildcard $(_CFGFILES) $(FILE_KBUILD_CONFIG)))
[69]384_CFGFILES :=
385_CFGDIR :=
386
387# Include the config.kmk we found file (or the default one).
388include $(_CFGFILE)
389
390
391# end-of-file-content
[72]392__header_kmk__ := 1
[69]393endif # __header_kmk__
Note: See TracBrowser for help on using the repository browser.