VirtualBox

source: kBuild/trunk/Config.kmk@ 3360

Last change on this file since 3360 was 3175, checked in by bird, 7 years ago

Config.kmk: svn override hack.

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