VirtualBox

source: kBuild/trunk/Config.kmk@ 2817

Last change on this file since 2817 was 2814, checked in by bird, 9 years ago

Config.kmk: Re-enable linker optimizations disabled by /DEBUG (windows).

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