VirtualBox

source: kBuild/trunk/Config.kmk@ 2844

Last change on this file since 2844 was 2838, checked in by bird, 8 years ago

kWorker: A little more hacking.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.0 KB
Line 
1# $Id: Config.kmk 2838 2016-08-25 21:46:25Z bird $
2## @file
3# Build Configuration.
4#
5
6#
7# Copyright (c) 2005-2012 knut st. osmundsen <[email protected]>
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 3 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, see <http://www.gnu.org/licenses/>
23#
24#
25
26# Enable automatic installation of what's built.
27KBUILD_DO_AUTO_INSTALL := 1
28
29
30#
31# The kBuild version.
32#
33KBUILD_VERSION_MAJOR = 0
34KBUILD_VERSION_MINOR = 1
35KBUILD_VERSION_PATCH = 9998
36KBUILD_VERSION = 0.1.9998
37DEFS += \
38 KBUILD_VERSION_MAJOR=$(KBUILD_VERSION_MAJOR) \
39 KBUILD_VERSION_MINOR=$(KBUILD_VERSION_MINOR) \
40 KBUILD_VERSION_PATCH=$(KBUILD_VERSION_PATCH)
41
42#
43# Get the svn version.
44# This is shipped with the tarballs in a SvnInfo.kmk in the root.
45#
46ifneq ($(wildcard $(PATH_ROOT)/SvnInfo.kmk),)
47# Shipped
48KBUILD_SVN_INFO_KMK := $(PATH_ROOT)/SvnInfo.kmk
49KBUILD_SVN_INFO_DEP := $(KBUILD_SVN_INFO_KMK)
50
51else ifneq ($(wildcard $(PATH_ROOT)/.svn/ $(PATH_ROOT)/../.svn/),)
52# Generate from svn info
53KBUILD_SVN_INFO_KMK := $(PATH_OBJ)/SvnInfo.kmk
54KBUILD_SVN_INFO_DEP := $(KBUILD_SVN_INFO_KMK)
55
56$(PATH_OBJ)/SvnInfo.ts +| $(KBUILD_SVN_INFO_KMK): $(wildcard $(addprefix $(PATH_ROOT)/.svn/ $(PATH_ROOT)/../.svn/,\
57 . \
58 pristine \
59 wc.db \
60 tmp \
61 entries \
62 all-wcprops \
63 format \
64 props \
65 prop-base ) )
66 $(call MSG_GENERATE,,$(KBUILD_SVN_INFO_KMK))
67 @$(RM) -f $@ [email protected]
68 @$(MKDIR) -p $(@D)
69 @$(REDIRECT) -o [email protected] -E 'LC_ALL=C' -- svn info $(DEPTH)
70 @$(SED) \
71 -e 's/^URL: */KBUILD_SVN_URL := /' \
72 -e 's/Revision: */KBUILD_SVN_REV := /' \
73 -e '/KBUILD_SVN_/!d' \
74 --append $@ \
75 [email protected]
76 @$(RM) -f [email protected]
77 @$(CP) --changed -fv $@ $(KBUILD_SVN_INFO_KMK)
78
79 ifeq ($(DEPTH),.)
80OTHER_CLEAN += $(KBUILD_SVN_INFO_KMK) $(PATH_OBJ)/SvnInfo.ts
81 endif
82
83else
84# Some incomplete source export...
85KBUILD_SVN_INFO_KMK := $(PATH_OBJ)/SvnInfo.kmk
86KBUILD_SVN_INFO_DEP := $(KBUILD_SVN_INFO_KMK)
87$(warning Neither SvnInfo nor .svn/* was found in the root. Will have to cook up something too keep the build happy.)
88$(KBUILD_SVN_INFO_KMK):
89 $(RM) -f $@
90 $(MKDIR) -p $(@D)
91 $(APPEND) $@ 'KBUILD_SVN_REV := 0'
92 $(APPEND) $@ 'KBUILD_SVN_URL := /dev/null'
93
94 ifeq ($(DEPTH),.)
95OTHER_CLEAN += $(KBUILD_SVN_INFO_KMK)
96 endif
97
98endif
99include $(KBUILD_SVN_INFO_KMK)
100
101
102#
103# Local config, optional.
104#
105ifneq ($(wildcard $(PATH_ROOT)/LocalConfig.kmk),)
106 include $(PATH_ROOT)/LocalConfig.kmk
107endif
108
109
110#
111# Where to fine the GNU Make stuff (for FreeBSD and Windows).
112#
113PATH_GNUMAKE_SRC ?= $(PATH_ROOT)/src/kmk
114
115
116#
117# Various platform specific hacks.
118#
119ifn1of ($(KBUILD_TARGET), haiku openbsd)
120 GCC_Wextra = -Wextra
121endif
122if1of ($(KBUILD_TARGET), openbsd)
123 TOOL_FLEX_LEX = gflex
124endif
125
126#
127# The OS and Architecture indicators.
128#
129DEFS.darwin += KBUILD_OS_DARWIN
130DEFS.freebsd += KBUILD_OS_FREEBSD
131DEFS.linux += KBUILD_OS_LINUX
132DEFS.netbsd += KBUILD_OS_NETBSD
133DEFS.openbsd += KBUILD_OS_OPENBSD
134DEFS.os2 += KBUILD_OS_OS2
135DEFS.solaris += KBUILD_OS_SOLARIS
136DEFS.win += KBUILD_OS_WINDOWS
137
138DEFS.x86 += KBUILD_ARCH_X86
139DEFS.amd64 += KBUILD_ARCH_AMD64
140
141
142#
143# Check if we're building a *nix installation.
144#
145# There are a few optional overrides here for customizing the install location
146# and how it is installed:
147# MY_INST_BIN - the bin/ directory (the trailing slash is mandatory).
148# MY_INST_DATA - the share/kBuild/ directory (the trailing slash is mandatory).
149# MY_INST_DOC - the share/doc/kBuild-x.y.z/ directory (the trailing slash is mandatory).
150# MY_INST_UID - the default install UID or user name.
151# MY_INST_GID - the default install GID or group name.
152# MY_INST_MODE - the default install mode mask, ",a+x" is added for executables and files.
153# MY_INST_DATA_UID - data specialization.
154# MY_INST_DATA_GID - data specialization.
155# MY_INST_DATA_MODE - data specialization.
156# MY_INST_DOC_UID - doc specialization.
157# MY_INST_DOC_GID - doc specialization.
158# MY_INST_DOC_MODE - doc specialization.
159# MY_INST_BIN_UID - binary (executable) specialization.
160# MY_INST_BIN_GID - binary (executable) specialization.
161# MY_INST_BIN_MODE - binary (executable) specialization.
162#
163# When running kmk install, you can use PATH_INS like you use DESTDIR in other makefile
164# systems. (These things will be improved in 0.2.x btw, so will be possible to enable a
165# mode where PREFIX and DESTDIR will.)
166#
167#
168ifdef NIX_INSTALL_DIR
169 MY_INST_ROOT := $(patsubst /%,%,$(NIX_INSTALL_DIR))/
170 ifndef MY_INST_BIN
171 MY_INST_BIN := $(MY_INST_ROOT)bin/
172 endif
173 ifndef MY_INST_DATA
174 MY_INST_DATA := $(MY_INST_ROOT)share/kBuild/
175 endif
176 ifndef MY_INST_DOC
177 MY_INST_DOC := $(MY_INST_ROOT)share/doc/kBuild-$(KBUILD_VERSION)/
178 endif
179 if !defined(MY_INST_BIN_MODE) && defined(MY_INST_MODE)
180 MY_INST_BIN_MODE := $(MY_INST_MODE),a+x
181 endif
182
183DEFS += \
184 KBUILD_PATH=\"/$(patsubst %/,%,$(MY_INST_DATA))\" \
185 KBUILD_BIN_PATH=\"/$(patsubst %/,%,$(MY_INST_BIN))\"
186endif
187
188
189#
190# Templates for installing docs and make scripts.
191#
192TEMPLATE_DATA = Data installation template.
193TEMPLATE_DATA_INST = $(MY_INST_DATA)
194TEMPLATE_DATA_MODE ?= $(firstword $(MY_INST_DATA_MODE) $(MY_INST_MODE) a+r)
195TEMPLATE_DATA_UID ?= $(firstword $(MY_INST_DATA_UID) $(MY_INST_UID))
196TEMPLATE_DATA_GID ?= $(firstword $(MY_INST_DATA_GID) $(MY_INST_GID))
197
198TEMPLATE_DOC = Documentation installation template.
199TEMPLATE_DOC_INST = $(MY_INST_DOC)
200TEMPLATE_DOC_MODE ?= $(firstword $(MY_INST_DOC_MODE) $(MY_INST_MODE) a+r)
201TEMPLATE_DOC_UID ?= $(firstword $(MY_INST_DOC_UID) $(MY_INST_UID))
202TEMPLATE_DOC_GID ?= $(firstword $(MY_INST_DOC_GID) $(MY_INST_GID))
203
204
205#
206# Template for building commandline tools.
207#
208TEMPLATE_BIN = Command line binary
209
210TEMPLATE_BIN_INCS = $(PATH_ROOT)/src/lib
211TEMPLATE_BIN_DEFS.profile = NDEBUG
212TEMPLATE_BIN_DEFS.release = NDEBUG
213if defined(NIX_INSTALL_DIR) && !defined(KBUILD_BOOTSTRAP)
214 TEMPLATE_BIN_INST = $(MY_INST_BIN)
215 TEMPLATE_BIN_MODE ?= $(firstword $(MY_INST_BIN_MODE) a+rx)
216 TEMPLATE_BIN_UID ?= $(firstword $(MY_INST_BIN_UID) $(MY_INST_UID))
217 TEMPLATE_BIN_GID ?= $(firstword $(MY_INST_BIN_GID) $(MY_INST_GID))
218else
219 TEMPLATE_BIN_INST = kBuild/bin/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
220endif
221
222
223ifeq ($(KBUILD_TARGET),os2)
224TEMPLATE_BIN_TOOL = GCC3OMF
225TEMPLATE_BIN_CFLAGS = -g
226TEMPLATE_BIN_CFLAGS.profile = -pg
227TEMPLATE_BIN_CFLAGS.release = -O3
228TEMPLATE_BIN_LDFLAGS = -Zhigh-mem -Zstack=1024 -g
229endif
230
231ifeq ($(KBUILD_TARGET),darwin)
232 ifndef KBUILD_MACOSX_VERSION
233 export KBUILD_MACOSX_VERSION := $(expr $(firstword $(subst ., ,$(shell uname -r))) - 4)
234 endif
235 #ifndef KBUILD_XCODE_VERSION
236 # export KBUILD_XCODE_VERSION := $(shell xcodebuild -version | kmk_sed -e '/Xcode/!d' -e 's/Xcode *//')
237 #endif
238 ifndef KBUILD_MACOSX_TARGET_VERSION
239 if $(KBUILD_TARGET_ARCH) == amd64
240 KBUILD_MACOSX_TARGET_VERSION = 6
241 else
242 KBUILD_MACOSX_TARGET_VERSION = 4
243 endif
244 endif
245 ifndef KBUILD_MACOSX_WHATEVER_MODE
246 if $(KBUILD_MACOSX_TARGET_VERSION) == 4
247 TOOL_GCC4MACHO_SUFFIX = -4.0
248 TOOL_GXX4MACHO_SUFFIX = -4.0
249 else if $(KBUILD_MACOSX_TARGET_VERSION) >= 5
250 TOOL_GCC4MACHO_SUFFIX = -4.2
251 TOOL_GXX4MACHO_SUFFIX = -4.2
252 endif
253 ifndef KBUILD_MACOSX_SDK
254 KBUILD_MACOSX_SDK := /Developer/SDKs/MacOSX10.$(KBUILD_MACOSX_TARGET_VERSION)$(if-expr $(KBUILD_MACOSX_TARGET_VERSION)==4,u,).sdk
255 ifeq ($(wildcard $(KBUILD_MACOSX_SDK)),)
256 KBUILD_MACOSX_SDK := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform$(KBUILD_MACOSX_SDK)
257 endif
258 endif
259 ifeq ($(wildcard $(KBUILD_MACOSX_SDK)),)
260 $(error SDK not found ($(KBUILD_MACOSX_SDK)), please adjust KBUILD_MACOSX_TARGET_VERSION or/and KBUILD_MACOSX_SDK in LocalConfig.kmk or simply use KBUILD_MACOSX_WHATEVER_MODE=1.)
261 endif
262 endif # !KBUILD_MACOSX_WHATEVER_MODE
263 TEMPLATE_BIN_TOOL = GCC4MACHO
264 TEMPLATE_BIN_CFLAGS = -g -mmacosx-version-min=10.$(KBUILD_MACOSX_TARGET_VERSION) $(if $(KBUILD_MACOSX_WHATEVER_MODE),,-isysroot $(KBUILD_MACOSX_SDK))
265 ifeq ($(USER),bird)
266 TEMPLATE_BIN_CFLAGS += -Wall $(GCC_Wextra) -pedantic -Wno-unused-parameter -Wno-long-long -Wshadow
267 TEMPLATE_BIN_DEFS += NO_ENUM_BITFIELDS
268 endif
269 TEMPLATE_BIN_CFLAGS.profile = -O3 -pg
270 TEMPLATE_BIN_CFLAGS.release = -O3
271 TEMPLATE_BIN_LDFLAGS = -g -mmacosx-version-min=10.$(KBUILD_MACOSX_TARGET_VERSION) $(if $(KBUILD_MACOSX_WHATEVER_MODE),,-Wl,-syslibroot,$(KBUILD_MACOSX_SDK))
272 if $(KBUILD_MACOSX_TARGET_VERSION) == 4 && $(KBUILD_MACOSX_VERSION) >= 5
273 TEMPLATE_BIN_LDFLAGS += -classic_ld
274 endif
275 TEMPLATE_BIN_LDFLAGS.profile = -pg
276endif
277
278ifeq ($(filter-out win nt,$(KBUILD_TARGET)),)
279 TEMPLATE_BIN_TOOL = VCC100
280 TEMPLATE_BIN_TOOL.x86 = VCC100X86
281 TEMPLATE_BIN_TOOL.amd64 = VCC100AMD64
282 TEMPLATE_BIN_DEFS = WINDOWS32 _CONSOLE __WIN__ _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_WARNINGS
283 TEMPLATE_BIN_DEFS.x86 = WIN32 __WIN32__
284 TEMPLATE_BIN_DEFS.amd64 = WIN32 __WIN32__ __WIN64__ WIN64
285 TEMPLATE_BIN_CFLAGS = -W3 -Zi -Zl
286 TEMPLATE_BIN_CFLAGS.release = -O2
287 TEMPLATE_BIN_CFLAGS.profile = -O2 -GH -Gh
288 TEMPLATE_BIN_INCS += \
289 . \
290 $(PATH_GNUMAKE_SRC)/w32/include \
291 $(PATH_GNUMAKE_SRC)/glob
292 TEMPLATE_BIN_LDFLAGS = /SUBSYSTEM:console /INCREMENTAL:no /NOD /DEBUG /OPT:REF /OPT:ICF
293 ifeq ($(KBUILD_TYPE),profile)
294 TEMPLATE_BIN_SDKS = WINPSDKINCS
295 TEMPLATE_BIN_CFLAGS += -MT
296 TEMPLATE_BIN_LIBS = \
297 D:/coding/kStuff/svn/trunk/out/win.$(KBUILD_TARGET_ARCH)/release/kStuff/lib/kPrf2.lib \
298 D:/coding/kStuff/svn/trunk/out/win.$(KBUILD_TARGET_ARCH)/release/kStuff/lib/kPrf2WinApiWrappersImp.lib \
299 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/oldnames.lib \
300 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcmt.lib \
301 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcpmt.lib \
302 D:/coding/kStuff/svn/trunk/out/win.$(KBUILD_TARGET_ARCH)/release/kStuff/lib/kPrf2WinApiWrappersImp.lib \
303 $(PATH_SDK_WINPSDKINCS_LIB)/AdvAPI32.lib \
304 $(PATH_SDK_WINPSDKINCS_LIB)/User32.lib
305 else
306 TEMPLATE_BIN_SDKS = WINPSDK71
307 ifdef KBUILD_WITH_STATIC_MSVCRT
308 TEMPLATE_BIN_CFLAGS += -MT
309 TEMPLATE_BIN_LIBS = \
310 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/oldnames.lib \
311 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcmt.lib \
312 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcpmt.lib
313 else
314 TEMPLATE_BIN_CFLAGS += -MD
315 TEMPLATE_BIN_LIBS = \
316 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/oldnames.lib \
317 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/msvcrt.lib
318 endif
319 endif
320endif
321
322ifndef TEMPLATE_BIN_TOOL
323 # Use GCC3 when we're certain that the system is using GNU ld and ar.
324 ifeq ($(filter-out linux freebsd openbsd netbsd,$(KBUILD_TARGET)),)
325 TEMPLATE_BIN_TOOL = GCC3
326 else
327 TEMPLATE_BIN_TOOL = GCC3PLAIN
328 endif
329 TEMPLATE_BIN_CFLAGS = -g
330 ifeq ($(USER),bird)
331 TEMPLATE_BIN_CFLAGS += -Wall $(GCC_Wextra) -pedantic -Wno-unused-parameter -Wshadow
332 TEMPLATE_BIN_DEFS += NO_ENUM_BITFIELDS
333 endif
334 TEMPLATE_BIN_LDFLAGS = -g
335 TEMPLATE_BIN_LDFLAGS.profile = -pg -p
336 TEMPLATE_BIN_CFLAGS.release = -O3
337 TEMPLATE_BIN_CFLAGS.profile = -O3 -pg -p
338 ifeq ($(KBUILD_TARGET),freebsd)
339 TEMPLATE_BIN_INCS += $(PATH_GNUMAKE_SRC)/glob /usr/local/include
340 endif
341 ifeq ($(KBUILD_TARGET),linux)
342 TEMPLATE_BIN_LIBS += rt
343 endif
344 TEMPLATE_BIN_CFLAGS.x86 += -m32
345 TEMPLATE_BIN_CFLAGS.sparc32 += -m32
346 TEMPLATE_BIN_CFLAGS.amd64 += -m64
347 TEMPLATE_BIN_CFLAGS.sparc64 += -m64
348 TEMPLATE_BIN_CXXFLAGS.x86 += -m32
349 TEMPLATE_BIN_CXXFLAGS.sparc32+= -m32
350 TEMPLATE_BIN_CXXFLAGS.amd64 += -m64
351 TEMPLATE_BIN_CXXFLAGS.sparc64+= -m64
352 TEMPLATE_BIN_LDFLAGS.x86 += -m32
353 TEMPLATE_BIN_LDFLAGS.sparc32 += -m32
354 TEMPLATE_BIN_LDFLAGS.amd64 += -m64
355 TEMPLATE_BIN_LDFLAGS.sparc64 += -m64
356 ifeq ($(KBUILD_TARGET),solaris)
357 TEMPLATE_BIN_LIBS += rt dl
358 TEMPLATE_BIN_LDFLAGS += -Wl,-i
359 TEMPLATE_BIN_DEFS.x86 += _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE
360 TEMPLATE_BIN_DEFS.sparc32 += _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE
361 endif
362endif
363if1of ($(KBUILD_TARGET), darwin win)
364 TEMPLATE_BIN_LD_DEBUG = split
365endif
366
367#
368# Template for building threaded binaries.
369#
370TEMPLATE_BIN-THREADED = Threaded command line binary
371TEMPLATE_BIN-THREADED_EXTENDS = BIN
372TEMPLATE_BIN-THREADED_EXTENDS_BY = appending
373if1of ($(KBUILD_TARGET), dragonfly freebsd linux openbsd)
374 TEMPLATE_BIN-THREADED_LIBS = pthread
375endif
376
377#
378# Template for building libraries for the tools.
379#
380TEMPLATE_LIB = Library for Commandline binary
381TEMPLATE_LIB_EXTENDS = BIN
382TEMPLATE_LIB_INST = lib/
383# for LIB_KDEP
384TEMPLATE_LIB_TOOL = $(TEMPLATE_BIN_TOOL)
385
386
387#
388# Template for static threaded binaries (windows).
389#
390TEMPLATE_BIN-STATIC-THREADED = Threaded command line binary
391TEMPLATE_BIN-STATIC-THREADED_EXTENDS = BIN-THREADED
392ifeq ($(filter-out win nt,$(KBUILD_TARGET)),)
393 TEMPLATE_BIN-STATIC-THREADED_CFLAGS = $(filter-out -MD,$(TEMPLATE_BIN-THREADED_CFLAGS)) -MT
394 TEMPLATE_BIN-STATIC-THREADED_LIBS = $(filter-out %/msvcrt.lib,$(TEMPLATE_BIN-THREADED_LIBS)) \
395 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcmt.lib \
396 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcpmt.lib
397else
398 TEMPLATE_BIN-STATIC-THREADED_CFLAGS = $(TEMPLATE_BIN-THREADED_CFLAGS) -static
399 TEMPLATE_BIN-STATIC-THREADED_LDFLAGS = $(TEMPLATE_BIN-THREADED_LDFLAGS) -static
400endif
401
402#
403# Template for static threaded libraries.
404#
405TEMPLATE_LIB-STATIC-THREADED = Threaded command line library
406TEMPLATE_LIB-STATIC-THREADED_EXTENDS = BIN-STATIC-THREADED
407TEMPLATE_LIB-STATIC-THREADED_INST = lib/
408
409
410#
411# Library macros.
412#
413LIB_KDEP = $(PATH_OBJ)/kDep/$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBPREF)kDep$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBSUFF)
414LIB_KUTIL = $(PATH_OBJ)/kUtil/$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBPREF)kUtil$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBSUFF)
415
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette