source: trunk/kBuild/header.kmk@ 71

Last change on this file since 71 was 70, checked in by bird, 21 years ago

Full PATH_ROOT and correct PATH_TARGET.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1# $Id: header.kmk 70 2004-05-29 08:53:13Z 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# Environment unifications
43#
44ifndef BUILD_TYPE
45ifndef BUILD_MODE
46$(error "define BUILD_TYPE you moron!")
47endif
48BUILD_TYPE := $(BUILD_MODE)
49endif
50
51
52#
53# .
54#
55PATH_ROOT := $(CURDIR)
56define def_root_dir
57PATH_ROOT := $(dir $(PATH_ROOT))
58endef
59PATH_ROOT
60
61#
62# Common definitions.
63#
64PATH_CURRENT := $(CURDIR)
65# Get the real root path.
66PATH_ROOT := $(CURDIR)
67ifneq ($(DEPTH),.)
68$(foreach d,$(subst /, ,$(DEPTH)), $(eval PATH_ROOT := $(patsubst %/,%,$(dir $(PATH_ROOT)))) )
69endif
70# Subdirectory relative to the root.
71DIR_DEPTH := $(patsubst $(PATH_ROOT)/%,%,$(CURDIR))
72# Output directories.
73PATH_OUT := $(PATH_ROOT)/out/$(BUILD_TARGET)/$(BUILD_TYPE)
74PATH_OBJ := $(PATH_OUT)/obj
75PATH_BIN := $(PATH_OUT)/bin
76PATH_LIB := $(PATH_OUT)/lib
77PATH_DOC := $(PATH_ROOT)/out/doc
78PATH_TARGET = $(PATH_OUT)/$(DIR_DEPTH)
79
80# Usually kBuild is external to the source tree.
81ifndef PATH_KBUILD
82PATH_KBUILD := $(PATH_ROOT)/kBuild
83endif
84# kBuild tools
85PATH_TOOLS_W32 := $(PATH_KBUILD)/bin/x86.win32
86PATH_TOOLS_LNX := $(PATH_KBUILD)/bin/x86.linux
87PATH_TOOLS_OS2 := $(PATH_KBUILD)/bin/x86.os2
88# kBuild files which might be of interest.
89FILE_KBUILD_HEADER := $(PATH_KBUILD)/header.kmk
90FILE_KBUILD_CONFIG := $(PATH_KBUILD)/config.kmk
91FILE_KBUILD_FOOTER := $(PATH_KBUILD)/footer.kmk
92
93
94#
95# Get rid of the GNU Make default stuff
96#
97include $(PATH_KBUILD)/StampOutPredefines.kmk
98
99
100#
101# PLATFORMS (host)
102#
103_BUILD_PLATFORM_OK := 0
104# OS/2
105ifeq ($(BUILD_PLATFORM),OS2)
106_BUILD_PLATFORM_OK := 1
107ifndef BUILD_TARGET
108BUILD_TARGET := OS2
109endif
110PATH_TOOLS := $(PATH_TOOLS_OS2)
111EXEC_X86_WIN32 := $(PATH_TOOLS)/bin/innopec.exe
112HOSTSUFF_EXE := .exe
113endif
114
115# Linux
116ifeq ($(BUILD_PLATFORM),LINUX)
117_BUILD_PLATFORM_OK := 1
118ifndef BUILD_TARGET
119BUILD_TARGET := LINUX
120endif
121PATH_TOOLS := $(PATH_TOOLS_LNX)
122EXEC_X86_WIN32 := wine
123HOSTSUFF_EXE :=
124endif
125
126# Win32
127ifeq ($(BUILD_PLATFORM),WIN32)
128ifndef BUILD_TARGET
129BUILD_TARGET := WIN32
130endif
131_BUILD_PLATFORM_OK := 1
132PATH_TOOLS := $(PATH_TOOLS_W32)
133EXEC_X86_WIN32 :=
134HOSTSUFF_EXE := .exe
135endif
136
137# assert build platform
138ifeq ($(_BUILD_PLATFORM_OK),0)
139$(error "BUILD_PLATFORM value '$(BUILD_PLATFORM)' was not recongized")
140endif
141
142
143#
144# Standard kBuild tools.
145#
146DEP := $(PATH_TOOLS)/kDep$(HOSTSUFF_EXE)
147# Standard Unix shell utils.
148MKDIR := $(PATH_TOOLS)/mkdir$(HOSTSUFF_EXE)
149RM := $(PATH_TOOLS)/rm$(HOSTSUFF_EXE)
150CP := $(PATH_TOOLS)/mv$(HOSTSUFF_EXE)
151MV := $(PATH_TOOLS)/cp$(HOSTSUFF_EXE)
152SED := $(PATH_TOOLS)/sed$(HOSTSUFF_EXE)
153CAT := $(PATH_TOOLS)/cat$(HOSTSUFF_EXE)
154# Bourn shell clone.
155MAKESHELL := $(PATH_TOOLS)/ash$(HOSTSUFF_EXE)
156SHELL := $(MAKESHELL)
157export SHELL MAKESHELL
158
159
160#
161# This is how we find the closest config.kmk.
162# It's a little hacky but I think it works fine.
163#
164_CFGDIR := .
165_CFGFILES :=
166define def_include_config
167_CFGDIR := $(_CFGDIR)/$(1)
168_CFGFILES += $(wildcard $(_CFGDIR)/config.kmk $(_CFGDIR)/config.kMk)
169endef
170# walk down the _RELATIVE_ path specified by DEPTH.
171$(foreach d,$(subst /, ,$(DEPTH)), $(eval $(call def_include_config,$(d))) )
172# add the default config file.
173_CFGFILE := $(firstword $(_CFGFILES) $(FILE_KBUILD_CONFIG))
174_CFGFILES :=
175_CFGDIR :=
176
177# Include the config.kmk we found file (or the default one).
178include $(_CFGFILE)
179
180
181# end-of-file-content
182__header_kmk__ := 1
183endif # __header_kmk__
Note: See TracBrowser for help on using the repository browser.