VirtualBox

source: kBuild/trunk/Config.kmk@ 2948

Last change on this file since 2948 was 2870, checked in by bird, 8 years ago

updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.1 KB
Line 
1# $Id: Config.kmk 2870 2016-09-04 13:52:39Z 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 = \
211 $(PATH_ROOT)/src/lib \
212 $(PATH_ROOT)/src/lib/kStuff/include
213TEMPLATE_BIN_DEFS.profile = NDEBUG
214TEMPLATE_BIN_DEFS.release = NDEBUG
215if defined(NIX_INSTALL_DIR) && !defined(KBUILD_BOOTSTRAP)
216 TEMPLATE_BIN_INST = $(MY_INST_BIN)
217 TEMPLATE_BIN_MODE ?= $(firstword $(MY_INST_BIN_MODE) a+rx)
218 TEMPLATE_BIN_UID ?= $(firstword $(MY_INST_BIN_UID) $(MY_INST_UID))
219 TEMPLATE_BIN_GID ?= $(firstword $(MY_INST_BIN_GID) $(MY_INST_GID))
220else
221 TEMPLATE_BIN_INST = kBuild/bin/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
222endif
223
224
225ifeq ($(KBUILD_TARGET),os2)
226TEMPLATE_BIN_TOOL = GCC3OMF
227TEMPLATE_BIN_CFLAGS = -g
228TEMPLATE_BIN_CFLAGS.profile = -pg
229TEMPLATE_BIN_CFLAGS.release = -O3
230TEMPLATE_BIN_LDFLAGS = -Zhigh-mem -Zstack=1024 -g
231endif
232
233ifeq ($(KBUILD_TARGET),darwin)
234 ifndef KBUILD_MACOSX_VERSION
235 export KBUILD_MACOSX_VERSION := $(expr $(firstword $(subst ., ,$(shell uname -r))) - 4)
236 endif
237 #ifndef KBUILD_XCODE_VERSION
238 # export KBUILD_XCODE_VERSION := $(shell xcodebuild -version | kmk_sed -e '/Xcode/!d' -e 's/Xcode *//')
239 #endif
240 ifndef KBUILD_MACOSX_TARGET_VERSION
241 if $(KBUILD_TARGET_ARCH) == amd64
242 KBUILD_MACOSX_TARGET_VERSION = 6
243 else
244 KBUILD_MACOSX_TARGET_VERSION = 4
245 endif
246 endif
247 ifndef KBUILD_MACOSX_WHATEVER_MODE
248 if $(KBUILD_MACOSX_TARGET_VERSION) == 4
249 TOOL_GCC4MACHO_SUFFIX = -4.0
250 TOOL_GXX4MACHO_SUFFIX = -4.0
251 else if $(KBUILD_MACOSX_TARGET_VERSION) >= 5
252 TOOL_GCC4MACHO_SUFFIX = -4.2
253 TOOL_GXX4MACHO_SUFFIX = -4.2
254 endif
255 ifndef KBUILD_MACOSX_SDK
256 KBUILD_MACOSX_SDK := /Developer/SDKs/MacOSX10.$(KBUILD_MACOSX_TARGET_VERSION)$(if-expr $(KBUILD_MACOSX_TARGET_VERSION)==4,u,).sdk
257 ifeq ($(wildcard $(KBUILD_MACOSX_SDK)),)
258 KBUILD_MACOSX_SDK := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform$(KBUILD_MACOSX_SDK)
259 endif
260 endif
261 ifeq ($(wildcard $(KBUILD_MACOSX_SDK)),)
262 $(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.)
263 endif
264 endif # !KBUILD_MACOSX_WHATEVER_MODE
265 TEMPLATE_BIN_TOOL = GCC4MACHO
266 TEMPLATE_BIN_CFLAGS = -g -mmacosx-version-min=10.$(KBUILD_MACOSX_TARGET_VERSION) $(if $(KBUILD_MACOSX_WHATEVER_MODE),,-isysroot $(KBUILD_MACOSX_SDK))
267 ifeq ($(USER),bird)
268 TEMPLATE_BIN_CFLAGS += -Wall $(GCC_Wextra) -pedantic -Wno-unused-parameter -Wno-long-long -Wshadow
269 TEMPLATE_BIN_DEFS += NO_ENUM_BITFIELDS
270 endif
271 TEMPLATE_BIN_CFLAGS.profile = -O3 -pg
272 TEMPLATE_BIN_CFLAGS.release = -O3
273 TEMPLATE_BIN_LDFLAGS = -g -mmacosx-version-min=10.$(KBUILD_MACOSX_TARGET_VERSION) $(if $(KBUILD_MACOSX_WHATEVER_MODE),,-Wl,-syslibroot,$(KBUILD_MACOSX_SDK))
274 if $(KBUILD_MACOSX_TARGET_VERSION) == 4 && $(KBUILD_MACOSX_VERSION) >= 5
275 TEMPLATE_BIN_LDFLAGS += -classic_ld
276 endif
277 TEMPLATE_BIN_LDFLAGS.profile = -pg
278endif
279
280ifeq ($(filter-out win nt,$(KBUILD_TARGET)),)
281 TEMPLATE_BIN_TOOL = VCC100
282 TEMPLATE_BIN_TOOL.x86 = VCC100X86
283 TEMPLATE_BIN_TOOL.amd64 = VCC100AMD64
284 TEMPLATE_BIN_DEFS = WINDOWS32 _CONSOLE __WIN__ _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_WARNINGS
285 TEMPLATE_BIN_DEFS.x86 = WIN32 __WIN32__
286 TEMPLATE_BIN_DEFS.amd64 = WIN32 __WIN32__ __WIN64__ WIN64
287 TEMPLATE_BIN_CFLAGS = -W3 -Zi -Zl
288 TEMPLATE_BIN_CFLAGS.release = -O2
289 TEMPLATE_BIN_CFLAGS.profile = -O2 -GH -Gh
290 TEMPLATE_BIN_INCS += \
291 . \
292 $(PATH_GNUMAKE_SRC)/w32/include \
293 $(PATH_GNUMAKE_SRC)/glob
294 TEMPLATE_BIN_LDFLAGS = /SUBSYSTEM:console /INCREMENTAL:no /NOD /DEBUG /OPT:REF /OPT:ICF /LargeAddressAware
295 ifeq ($(KBUILD_TYPE),profile)
296 TEMPLATE_BIN_SDKS = WINPSDKINCS
297 TEMPLATE_BIN_CFLAGS += -MT
298 TEMPLATE_BIN_LIBS = \
299 D:/coding/kStuff/svn/trunk/out/win.$(KBUILD_TARGET_ARCH)/release/kStuff/lib/kPrf2.lib \
300 D:/coding/kStuff/svn/trunk/out/win.$(KBUILD_TARGET_ARCH)/release/kStuff/lib/kPrf2WinApiWrappersImp.lib \
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 D:/coding/kStuff/svn/trunk/out/win.$(KBUILD_TARGET_ARCH)/release/kStuff/lib/kPrf2WinApiWrappersImp.lib \
305 $(PATH_SDK_WINPSDKINCS_LIB)/AdvAPI32.lib \
306 $(PATH_SDK_WINPSDKINCS_LIB)/User32.lib
307 else
308 TEMPLATE_BIN_SDKS = WINPSDK71
309 ifdef KBUILD_WITH_STATIC_MSVCRT
310 TEMPLATE_BIN_CFLAGS += -MT
311 TEMPLATE_BIN_LIBS = \
312 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/oldnames.lib \
313 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcmt.lib \
314 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcpmt.lib
315 else
316 TEMPLATE_BIN_CFLAGS += -MD
317 TEMPLATE_BIN_LIBS = \
318 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/oldnames.lib \
319 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/msvcrt.lib
320 endif
321 endif
322endif
323
324ifndef TEMPLATE_BIN_TOOL
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 TEMPLATE_BIN_CFLAGS.x86 += -m32
347 TEMPLATE_BIN_CFLAGS.sparc32 += -m32
348 TEMPLATE_BIN_CFLAGS.amd64 += -m64
349 TEMPLATE_BIN_CFLAGS.sparc64 += -m64
350 TEMPLATE_BIN_CXXFLAGS.x86 += -m32
351 TEMPLATE_BIN_CXXFLAGS.sparc32+= -m32
352 TEMPLATE_BIN_CXXFLAGS.amd64 += -m64
353 TEMPLATE_BIN_CXXFLAGS.sparc64+= -m64
354 TEMPLATE_BIN_LDFLAGS.x86 += -m32
355 TEMPLATE_BIN_LDFLAGS.sparc32 += -m32
356 TEMPLATE_BIN_LDFLAGS.amd64 += -m64
357 TEMPLATE_BIN_LDFLAGS.sparc64 += -m64
358 ifeq ($(KBUILD_TARGET),solaris)
359 TEMPLATE_BIN_LIBS += rt dl
360 TEMPLATE_BIN_LDFLAGS += -Wl,-i
361 TEMPLATE_BIN_DEFS.x86 += _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE
362 TEMPLATE_BIN_DEFS.sparc32 += _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE
363 endif
364endif
365if1of ($(KBUILD_TARGET), darwin win)
366 TEMPLATE_BIN_LD_DEBUG = split
367endif
368
369#
370# Template for building threaded binaries.
371#
372TEMPLATE_BIN-THREADED = Threaded command line binary
373TEMPLATE_BIN-THREADED_EXTENDS = BIN
374TEMPLATE_BIN-THREADED_EXTENDS_BY = appending
375if1of ($(KBUILD_TARGET), dragonfly freebsd linux openbsd)
376 TEMPLATE_BIN-THREADED_LIBS = pthread
377endif
378
379#
380# Template for building libraries for the tools.
381#
382TEMPLATE_LIB = Library for Commandline binary
383TEMPLATE_LIB_EXTENDS = BIN
384TEMPLATE_LIB_INST = lib/
385# for LIB_KDEP
386TEMPLATE_LIB_TOOL = $(TEMPLATE_BIN_TOOL)
387
388
389#
390# Template for static threaded binaries (windows).
391#
392TEMPLATE_BIN-STATIC-THREADED = Threaded command line binary
393TEMPLATE_BIN-STATIC-THREADED_EXTENDS = BIN-THREADED
394ifeq ($(filter-out win nt,$(KBUILD_TARGET)),)
395 TEMPLATE_BIN-STATIC-THREADED_CFLAGS = $(filter-out -MD,$(TEMPLATE_BIN-THREADED_CFLAGS)) -MT
396 TEMPLATE_BIN-STATIC-THREADED_LIBS = $(filter-out %/msvcrt.lib,$(TEMPLATE_BIN-THREADED_LIBS)) \
397 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcmt.lib \
398 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcpmt.lib
399else
400 TEMPLATE_BIN-STATIC-THREADED_CFLAGS = $(TEMPLATE_BIN-THREADED_CFLAGS) -static
401 TEMPLATE_BIN-STATIC-THREADED_LDFLAGS = $(TEMPLATE_BIN-THREADED_LDFLAGS) -static
402endif
403
404#
405# Template for static threaded libraries.
406#
407TEMPLATE_LIB-STATIC-THREADED = Threaded command line library
408TEMPLATE_LIB-STATIC-THREADED_EXTENDS = BIN-STATIC-THREADED
409TEMPLATE_LIB-STATIC-THREADED_INST = lib/
410
411
412#
413# Library macros.
414#
415LIB_KDEP = $(PATH_OBJ)/kDep/$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBPREF)kDep$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBSUFF)
416LIB_KUTIL = $(PATH_OBJ)/kUtil/$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBPREF)kUtil$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBSUFF)
417
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