VirtualBox

source: kBuild/trunk/Config.kmk@ 3110

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

More GNU hurd adjustments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.4 KB
Line 
1# $Id: Config.kmk 3110 2017-10-20 19:14:56Z 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)
226 TEMPLATE_BIN_TOOL = GCC3OMF
227 TEMPLATE_BIN_CFLAGS = -g
228 TEMPLATE_BIN_CFLAGS.profile = -pg
229 TEMPLATE_BIN_CFLAGS.release = -O3
230 TEMPLATE_BIN_LDFLAGS = -Zhigh-mem -Zstack=1024 -g
231
232else if1of ($(KBUILD_TARGET), win nt)
233 TEMPLATE_BIN_TOOL = VCC100
234 TEMPLATE_BIN_TOOL.x86 = VCC100X86
235 TEMPLATE_BIN_TOOL.amd64 = VCC100AMD64
236 TEMPLATE_BIN_DEFS = WINDOWS32 _CONSOLE __WIN__ _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_WARNINGS
237 TEMPLATE_BIN_DEFS.x86 = WIN32 __WIN32__
238 TEMPLATE_BIN_DEFS.amd64 = WIN32 __WIN32__ __WIN64__ WIN64
239 TEMPLATE_BIN_CFLAGS = -W3 -Zi -Zl
240 TEMPLATE_BIN_CFLAGS.release = -O2
241 TEMPLATE_BIN_CFLAGS.profile = -O2 -GH -Gh
242 TEMPLATE_BIN_INCS += \
243 . \
244 $(PATH_GNUMAKE_SRC)/w32/include \
245 $(PATH_GNUMAKE_SRC)/glob
246 TEMPLATE_BIN_LDFLAGS = /SUBSYSTEM:console /INCREMENTAL:no /NOD /DEBUG /OPT:REF /OPT:ICF /LargeAddressAware
247 ifeq ($(KBUILD_TYPE),profile)
248 TEMPLATE_BIN_SDKS = WINPSDKINCS
249 TEMPLATE_BIN_CFLAGS += -MT
250 TEMPLATE_BIN_LIBS = \
251 D:/coding/kStuff/svn/trunk/out/win.$(KBUILD_TARGET_ARCH)/release/kStuff/lib/kPrf2.lib \
252 D:/coding/kStuff/svn/trunk/out/win.$(KBUILD_TARGET_ARCH)/release/kStuff/lib/kPrf2WinApiWrappersImp.lib \
253 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/oldnames.lib \
254 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcmt.lib \
255 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcpmt.lib \
256 D:/coding/kStuff/svn/trunk/out/win.$(KBUILD_TARGET_ARCH)/release/kStuff/lib/kPrf2WinApiWrappersImp.lib \
257 $(PATH_SDK_WINPSDKINCS_LIB)/AdvAPI32.lib \
258 $(PATH_SDK_WINPSDKINCS_LIB)/User32.lib
259 else
260 TEMPLATE_BIN_SDKS = WINPSDK71
261 ifdef KBUILD_WITH_STATIC_MSVCRT
262 TEMPLATE_BIN_CFLAGS += -MT
263 TEMPLATE_BIN_LIBS = \
264 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/oldnames.lib \
265 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcmt.lib \
266 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcpmt.lib
267 else
268 TEMPLATE_BIN_CFLAGS += -MD
269 TEMPLATE_BIN_LIBS = \
270 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/oldnames.lib \
271 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/msvcrt.lib
272 endif
273 endif
274
275else # !os2, !win, !nt
276
277 ifeq ($(KBUILD_TARGET),darwin)
278 ifndef KBUILD_MACOSX_VERSION
279 export KBUILD_MACOSX_VERSION := $(expr $(firstword $(subst ., ,$(shell uname -r))) - 4)
280 endif
281 #ifndef KBUILD_XCODE_VERSION
282 # export KBUILD_XCODE_VERSION := $(shell xcodebuild -version | kmk_sed -e '/Xcode/!d' -e 's/Xcode *//')
283 #endif
284 ifndef KBUILD_MACOSX_TARGET_VERSION
285 if $(KBUILD_TARGET_ARCH) == amd64
286 KBUILD_MACOSX_TARGET_VERSION = 6
287 else
288 KBUILD_MACOSX_TARGET_VERSION = 5
289 endif
290 endif
291 ifndef KBUILD_MACOSX_WHATEVER_MODE
292 if $(KBUILD_MACOSX_TARGET_VERSION) == 4
293 TOOL_GCC4MACHO_SUFFIX = -4.0
294 TOOL_GXX4MACHO_SUFFIX = -4.0
295 else if $(KBUILD_MACOSX_TARGET_VERSION) >= 5
296 TOOL_GCC4MACHO_SUFFIX = -4.2
297 TOOL_GXX4MACHO_SUFFIX = -4.2
298 endif
299 ifndef KBUILD_MACOSX_SDK
300 KBUILD_MACOSX_SDK := /Developer/SDKs/MacOSX10.$(KBUILD_MACOSX_TARGET_VERSION)$(if-expr $(KBUILD_MACOSX_TARGET_VERSION)==4,u,).sdk
301 ifeq ($(wildcard $(KBUILD_MACOSX_SDK)),)
302 KBUILD_MACOSX_SDK := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform$(KBUILD_MACOSX_SDK)
303 endif
304 endif
305 ifeq ($(wildcard $(KBUILD_MACOSX_SDK)),)
306 $(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.)
307 endif
308 endif # !KBUILD_MACOSX_WHATEVER_MODE
309 TEMPLATE_BIN_TOOL = GCC4MACHO
310 TEMPLATE_BIN_CFLAGS = -g -mmacosx-version-min=10.$(KBUILD_MACOSX_TARGET_VERSION) $(if $(KBUILD_MACOSX_WHATEVER_MODE),,-isysroot $(KBUILD_MACOSX_SDK))
311 ifeq ($(USER),bird)
312 TEMPLATE_BIN_CFLAGS += -Wall $(GCC_Wextra) -pedantic -Wno-unused-parameter -Wno-long-long -Wshadow
313 TEMPLATE_BIN_DEFS += NO_ENUM_BITFIELDS
314 endif
315 TEMPLATE_BIN_CFLAGS.profile = -O3 -pg
316 TEMPLATE_BIN_CFLAGS.release = -O3
317 TEMPLATE_BIN_LDFLAGS = -g -mmacosx-version-min=10.$(KBUILD_MACOSX_TARGET_VERSION) $(if $(KBUILD_MACOSX_WHATEVER_MODE),,-Wl,-syslibroot,$(KBUILD_MACOSX_SDK))
318 if $(KBUILD_MACOSX_TARGET_VERSION) == 4 && $(KBUILD_MACOSX_VERSION) >= 5
319 TEMPLATE_BIN_LDFLAGS += -classic_ld
320 endif
321 TEMPLATE_BIN_LDFLAGS.profile = -pg
322
323 else # !darwin
324 # Use GCC3 when we're certain that the system is using GNU ld and ar.
325 ifeq ($(filter-out linux freebsd openbsd netbsd,$(KBUILD_TARGET)),)
326 TEMPLATE_BIN_TOOL = GCC3
327 else
328 TEMPLATE_BIN_TOOL = GCC3PLAIN
329 endif
330 TEMPLATE_BIN_CFLAGS = -g
331 ifeq ($(USER),bird)
332 TEMPLATE_BIN_CFLAGS += -Wall $(GCC_Wextra) -pedantic -Wno-unused-parameter -Wshadow
333 TEMPLATE_BIN_DEFS += NO_ENUM_BITFIELDS
334 endif
335 TEMPLATE_BIN_LDFLAGS = -g
336 TEMPLATE_BIN_LDFLAGS.profile = -pg -p
337 TEMPLATE_BIN_CFLAGS.release = -O3
338 TEMPLATE_BIN_CFLAGS.profile = -O3 -pg -p
339 ifeq ($(KBUILD_TARGET),freebsd)
340 TEMPLATE_BIN_INCS += $(PATH_GNUMAKE_SRC)/glob /usr/local/include
341 endif
342 ifeq ($(KBUILD_TARGET),linux)
343 TEMPLATE_BIN_LIBS += rt
344 endif
345 endif
346
347 # Make sure we get the right bit count in the output.
348 TEMPLATE_BIN_CFLAGS.x86 += -m32
349 TEMPLATE_BIN_CFLAGS.sparc32 += -m32
350 TEMPLATE_BIN_CFLAGS.amd64 += -m64
351 TEMPLATE_BIN_CFLAGS.sparc64 += -m64
352 TEMPLATE_BIN_CXXFLAGS.x86 += -m32
353 TEMPLATE_BIN_CXXFLAGS.sparc32 += -m32
354 TEMPLATE_BIN_CXXFLAGS.amd64 += -m64
355 TEMPLATE_BIN_CXXFLAGS.sparc64 += -m64
356 TEMPLATE_BIN_LDFLAGS.x86 += -m32
357 TEMPLATE_BIN_LDFLAGS.sparc32 += -m32
358 TEMPLATE_BIN_LDFLAGS.amd64 += -m64
359 TEMPLATE_BIN_LDFLAGS.sparc64 += -m64
360 ifeq ($(KBUILD_TARGET),solaris)
361 TEMPLATE_BIN_LIBS += rt dl
362 TEMPLATE_BIN_LDFLAGS += -Wl,-i
363 TEMPLATE_BIN_DEFS.x86 += _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE
364 TEMPLATE_BIN_DEFS.sparc32 += _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE
365 endif
366 ifeq ($(KBUILD_TARGET),netbsd)
367 TEMPLATE_BIN_LIBS += util
368 endif
369endif
370
371# On systems where it's possible, do split out the debug info from the binaries.
372if1of ($(KBUILD_TARGET), darwin win)
373 TEMPLATE_BIN_LD_DEBUG = split
374endif
375
376#
377# Template for building threaded binaries.
378#
379TEMPLATE_BIN-THREADED = Threaded command line binary
380TEMPLATE_BIN-THREADED_EXTENDS = BIN
381TEMPLATE_BIN-THREADED_EXTENDS_BY = appending
382if1of ($(KBUILD_TARGET), dragonfly freebsd gnuhurd gnukfbsd gnuknbsd linux netbsd openbsd)
383 TEMPLATE_BIN-THREADED_LIBS = pthread
384endif
385
386#
387# Template for building libraries for the tools.
388#
389TEMPLATE_LIB = Library for Commandline binary
390TEMPLATE_LIB_EXTENDS = BIN
391TEMPLATE_LIB_INST = lib/
392# for LIB_KDEP
393TEMPLATE_LIB_TOOL = $(TEMPLATE_BIN_TOOL)
394
395
396#
397# Template for static threaded binaries (windows).
398#
399TEMPLATE_BIN-STATIC-THREADED = Threaded command line binary
400TEMPLATE_BIN-STATIC-THREADED_EXTENDS = BIN-THREADED
401ifeq ($(filter-out win nt,$(KBUILD_TARGET)),)
402 TEMPLATE_BIN-STATIC-THREADED_CFLAGS = $(filter-out -MD,$(TEMPLATE_BIN-THREADED_CFLAGS)) -MT
403 TEMPLATE_BIN-STATIC-THREADED_LIBS = $(filter-out %/msvcrt.lib,$(TEMPLATE_BIN-THREADED_LIBS)) \
404 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcmt.lib \
405 $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/libcpmt.lib
406else
407 TEMPLATE_BIN-STATIC-THREADED_CFLAGS = $(TEMPLATE_BIN-THREADED_CFLAGS) -static
408 TEMPLATE_BIN-STATIC-THREADED_LDFLAGS = $(TEMPLATE_BIN-THREADED_LDFLAGS) -static
409endif
410
411#
412# Template for static threaded libraries.
413#
414TEMPLATE_LIB-STATIC-THREADED = Threaded command line library
415TEMPLATE_LIB-STATIC-THREADED_EXTENDS = BIN-STATIC-THREADED
416TEMPLATE_LIB-STATIC-THREADED_INST = lib/
417
418
419#
420# Library macros.
421#
422LIB_KDEP = $(PATH_OBJ)/kDep/$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBPREF)kDep$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBSUFF)
423LIB_KUTIL = $(PATH_OBJ)/kUtil/$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBPREF)kUtil$(TOOL_$(TEMPLATE_LIB_TOOL)_ARLIBSUFF)
424
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