VirtualBox

source: vbox/trunk/Config.kmk@ 91511

Last change on this file since 91511 was 91466, checked in by vboxsync, 3 years ago

VMNet: bugref:9932 Fixed uninitialized max_packet_size, really enabled VBOX_WITH_VMNET, minor log improvements

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 380.7 KB
Line 
1# $Id: Config.kmk 91466 2021-09-29 16:57:26Z vboxsync $
2## @file
3# The global build configuration file for VBox.
4#
5# This file gets included by all makefiles through the
6# include $(KBUILD_PATH)/header.kmk statement.
7#
8
9#
10# Copyright (C) 2006-2020 Oracle Corporation
11#
12# This file is part of VirtualBox Open Source Edition (OSE), as
13# available from http://www.virtualbox.org. This file is free software;
14# you can redistribute it and/or modify it under the terms of the GNU
15# General Public License (GPL) as published by the Free Software
16# Foundation, in version 2 as it comes in the "COPYING" file of the
17# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19#
20
21# Marker.
22VBOX_ROOT_CONFIG_KMK_INCLUDED = 1
23
24#
25# kBuild stuff
26#
27
28# Build with umask 022 (requires kBuild r2556 to work, harmless on earlier).
29$(set-umask 022)
30
31# Add our own directories to the search paths.
32KBUILD_TOOL_PATHS = $(KBUILD_DEVTOOLS)/kBuildTools/
33KBUILD_UNIT_PATHS = $(KBUILD_DEVTOOLS)/kBuildUnits/
34
35# Modify the build types.
36KBUILD_BLD_TYPES = release profile debug kprofile
37
38## 'strict' builds
39# Same as release builds, except that RT_STRICT and VBOX_STRICT are defined,
40# meaning all assertions are in action. (Appending means '.strict' props take
41# precedence in argument lists.)
42KBUILD_BLD_TYPES += strict
43BLD_TYPE_strict_EXTENDS = release
44BLD_TYPE_strict_EXTENDS_BY = appending
45
46## 'asan' builds
47# Same as release builds, except that some form of address sanitizer (e.g.
48# VBOX_WITH_GCC_SANITIZER=1 or VBOX_WITH_EF_WRAPS) is enabled. In addition
49# RT_STRICT and VBOX_STRICT are defined so assertions and sanity checks will
50# also be enabled (mainly for not needing to build+test strict builds separately).
51KBUILD_BLD_TYPES += asan
52BLD_TYPE_asan_EXTENDS = release
53BLD_TYPE_asan_EXTENDS_BY = appending
54
55## 'dbgopt' builds
56# Same as debug builds, except that compiler optimizations are enabled. This
57# intended for cases where all the debug facitities (logging, assertions, ++)
58# is wanted but actual source level debugging as important as execution speed.
59KBUILD_BLD_TYPES += dbgopt
60BLD_TYPE_dbgopt_EXTENDS = debug
61BLD_TYPE_dbgopt_EXTENDS_BY = overriding
62
63# Temporary hack for kBuild ticket #83.
64## @todo kBuild: remove after closing ticket #83.
65PROPS_ACCUMULATE_L_LNK += INTERMEDIATES
66PROPS_PROGRAMS_ACCUMULATE_L += INTERMEDIATES
67PROPS_LIBRARIES_ACCUMULATE_L += INTERMEDIATES
68PROPS_DLLS_ACCUMULATE_L += INTERMEDIATES
69PROPS_SYSMODS_ACCUMULATE_L += INTERMEDIATES
70PROPS_MISCBINS_ACCUMULATE_L += INTERMEDIATES
71
72# Misc names used by the install paths below.
73VBOX_PUEL_MANGLED_NAME := Oracle_VM_VirtualBox_Extension_Pack
74
75# Install paths
76## @todo This will change after 4.1 is branched off!
77# What is now 'bin' and 'lib' will be moved down under 'staged/', except on
78# darwin where it's currently called 'dist' which will be renamed to 'staged'.
79# When running 'kmk install' files will be copied to 'dist/', on unix systems
80# this will be done in FHS fashion assuming /usr/local or /usr as 'prefix'.
81#
82# Changes related to this are marked VBOX_WITH_NEW_LAYOUT.
83ifndef VBOX_WITH_NEW_LAYOUT
84 PATH_INS = $(PATH_OUT)/dist
85 PATH_STAGE = $(PATH_OUT)
86 INST_DEBUG := stage/debug/
87endif
88
89ifeq ($(KBUILD_TARGET),darwin)
90 ifndef VBOX_WITH_NEW_LAYOUT
91 INST_DIST = dist/
92 else
93 INST_DIST :=
94 endif
95 INST_SDK = $(INST_DIST)sdk/
96
97 # the bundles
98 INST_VIRTUALBOX = $(INST_DIST)VirtualBox.app/
99 INST_VBOXDRV = $(INST_DIST)VBoxDrv.kext/
100 INST_VBOXNETFLT = $(INST_DIST)VBoxNetFlt.kext/
101 INST_VBOXNETADP = $(INST_DIST)VBoxNetAdp.kext/
102 INST_VBOXUSB = $(INST_DIST)VBoxUSB.kext/
103
104 # put everything in the VirtualBox app bundle.
105 INST_BIN = $(INST_VIRTUALBOX)Contents/MacOS/
106 INST_DLL = $(INST_BIN)
107 INST_SYS = $(INST_BIN)
108 INST_TESTCASE = $(INST_BIN)testcase/
109 INST_ADDITIONS = $(INST_DIST)additions/
110 INST_ADDITIONS_ISO = $(INST_BIN)
111 INST_UNATTENDED_TEMPLATES = $(INST_BIN)UnattendedTemplates/
112
113 INST_VBOXDBG_SYMS = $(INST_VIRTUALBOX)Contents/Resources/VBoxDbgSyms/
114
115 # other paths
116 INST_LIB = lib/
117 INST_ADDITIONS_LIB = $(INST_LIB)additions/
118 VBOX_INST_DTRACE_LIB = $(INST_BIN)dtrace/lib/
119 VBOX_INST_DTRACE_TST = $(INST_BIN)dtrace/testcase/
120 VBOX_INST_TOOLS = $(INST_BIN)tools/
121
122else
123
124 INST_BIN = bin/
125 INST_DIST = $(INST_BIN)
126 INST_SDK = $(INST_BIN)sdk/
127
128 INST_VIRTUALBOX = $(INST_BIN)
129 INST_VBOXDRV = $(INST_BIN)
130 INST_VBOXNETFLT = $(INST_BIN)
131 INST_VBOXNETADP = $(INST_BIN)
132 INST_VBOXUSB = $(INST_BIN)
133
134 INST_DLL = $(INST_BIN)
135 INST_SYS = $(INST_BIN)
136 INST_TESTCASE = $(INST_BIN)testcase/
137 INST_ADDITIONS = $(INST_BIN)additions/
138 INST_ADDITIONS_ISO = $(INST_ADDITIONS)
139 INST_UNATTENDED_TEMPLATES = $(INST_BIN)UnattendedTemplates/
140
141 INST_LIB = lib/
142 INST_ADDITIONS_LIB = $(INST_LIB)additions/
143 VBOX_INST_DTRACE_LIB = $(INST_BIN)dtrace/lib/
144 VBOX_INST_DTRACE_TST = $(INST_BIN)dtrace/testcase/
145
146 INST_VBOXDBG_SYMS = $(INST_BIN)VBoxDbgSyms/
147 VBOX_INST_TOOLS = $(INST_BIN)tools/
148endif
149
150
151INST_VALIDATIONKIT = validationkit/
152INST_TESTBOXSCRIPT = testboxscript/
153
154INST_DOC = doc/
155INST_EXTPACK = $(INST_BIN)ExtensionPacks/
156INST_EXTPACK_CERTS = $(INST_BIN)ExtPackCertificates/
157INST_EXTPACK_PUEL = $(INST_EXTPACK)$(VBOX_PUEL_MANGLED_NAME)/
158INST_PACKAGES = packages/
159
160VBOX_PATH_SDK = $(patsubst %/,%,$(PATH_STAGE)/$(INST_SDK))
161VBOX_PATH_DIST = $(patsubst %/,%,$(PATH_STAGE)/$(INST_DIST))
162VBOX_PATH_VALIDATIONKIT = $(patsubst %/,%,$(PATH_STAGE)/$(INST_VALIDATIONKIT))
163VBOX_PATH_ADDITIONS = $(patsubst %/,%,$(PATH_STAGE)/$(INST_ADDITIONS))
164VBOX_PATH_ADDITIONS_ISO = $(patsubst %/,%,$(PATH_STAGE)/$(INST_ADDITIONS_ISO))
165VBOX_PATH_ADDITIONS_LIB = $(patsubst %/,%,$(PATH_STAGE)/$(INST_ADDITIONS_LIB))
166VBOX_PATH_EXTPACK_PUEL= $(patsubst %/,%,$(PATH_STAGE)/$(INST_EXTPACK_PUEL))
167VBOX_PATH_PACKAGES = $(patsubst %/,%,$(PATH_STAGE)/$(INST_PACKAGES))
168VBOX_PATH_TOOLS = $(patsubst %/,%,$(PATH_STAGE)/$(VBOX_INST_TOOLS))
169
170
171# Delete targets on failure.
172.DELETE_ON_ERROR:
173
174# Notify about important kBuild updates.
175if $(KBUILD_VERSION_MAJOR) == 0 \
176 && ( $(KBUILD_VERSION_MINOR) >= 2 \
177 || ( $(KBUILD_VERSION_MINOR) == 1 \
178 && $(KBUILD_VERSION_PATCH) >= 999))
179 VBOX_MIN_KMK_REVISION := 3093
180 VBOX_MIN_KBUILD_KMK_REVISION := $(if-expr "$(KBUILD_HOST)" == "win",3097,$(if-expr "$(KBUILD_HOST).$(KBUILD_HOST_ARCH)" == "solaris.sparc64",2511,3074))
181 if $(KMK_REVISION) >= $(VBOX_MIN_KMK_REVISION)
182 if $(KBUILD_KMK_REVISION) >= $(VBOX_MIN_KBUILD_KMK_REVISION)
183 # OK.
184 else
185 $(error You must update kBuild! Requires kBuild binaries $(VBOX_MIN_KBUILD_KMK_REVISION) or later, kmk says $(KBUILD_KMK_REVISION) ($(KBUILD_VERSION)))
186 endif
187 else
188 $(error You must update kBuild! Requires kBuild revision $(VBOX_MIN_KMK_REVISION) or later, found $(KMK_REVISION) ($(KBUILD_VERSION)))
189 endif
190else
191 $(error You must update kBuild! Requires 0.1.999 or later, found $(KBUILD_VERSION))
192endif
193
194#
195# Define USERNAME early on.
196#
197ifndef USERNAME
198 ifdef USER
199 USERNAME = $(USER)
200 else
201 $(warning Warning: You must have USERNAME or USER in your environment.)
202 endif
203endif
204
205#
206# Detect the darwin host version number so we can disable stuff that doesn't
207# currently build on Lion.
208#
209ifeq ($(KBUILD_HOST),darwin)
210 VBOX_DARWIN_HOST_VERSION := $(subst ., ,$(shell uname -r))
211 # Keep counting _MAJOR past 19.x (macOS 10.15.x) to simplify dealing with macOS 11.x.
212 VBOX_DARWIN_HOST_VERSION_MAJOR := $(expr $(word 1, $(VBOX_DARWIN_HOST_VERSION)) - 4)
213 VBOX_DARWIN_HOST_VERSION_MINOR := $(word 2, $(VBOX_DARWIN_HOST_VERSION))
214 VBOX_DARWIN_HOST_VERSION_PATCH := $(word 3, $(VBOX_DARWIN_HOST_VERSION))
215 if $(VBOX_DARWIN_HOST_VERSION_MAJOR) <= 15
216 VBOX_DARWIN_HOST_VERSION := 10.$(VBOX_DARWIN_HOST_VERSION_MAJOR).$(VBOX_DARWIN_HOST_VERSION_MINOR)
217 else
218 VBOX_DARWIN_HOST_VERSION := 11.$(expr $(VBOX_DARWIN_HOST_VERSION_MAJOR) - 16).$(VBOX_DARWIN_HOST_VERSION_MINOR)
219 endif
220endif
221
222include $(PATH_ROOT)/Version.kmk
223
224# The raw version string. This *must not* contain any other information/fields than
225# major, minor and build revision (as it is now) -- also will be used for host/guest version
226# comparison.
227VBOX_VERSION_STRING_RAW = $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD)
228
229# VBOX_VERSION_STRING without the publisher.
230VBOX_VERSION_STRING_NO_PUB = $(VBOX_VERSION_STRING_RAW)$(addprefix _,$(VBOX_VERSION_PRERELEASE))
231
232# Full version string (may include more than just x.y.z, but no spaces or other problematic chars).
233# Note! The BETA[n],ALPHA[n],RC[n] indicators should be inserted before the
234# publisher so that RTStrVersionCompare have a chance of comparing
235# prerelease from different publishers correctly.
236VBOX_VERSION_STRING = $(VBOX_VERSION_STRING_NO_PUB)$(VBOX_BUILD_PUBLISHER)
237
238
239## Make a numeric value from the major, minor and build numbers (params)
240VBOX_FULL_VERSION_MAKE = $(expr ($1 << 24) | ($2 << 16) | $3)
241
242## Checks if the current VBox version is higher or equal to the major, minor and
243# build numbers given as parameters.
244# @returns 1 if true, 0 if false. For use with 'if'.
245VBOX_VERSION_PREREQ = $(expr $(call VBOX_FULL_VERSION_MAKE,$(VBOX_VERSION_MAJOR),$(VBOX_VERSION_MINOR),$(VBOX_VERSION_BUILD)) \
246 >= $(call VBOX_FULL_VERSION_MAKE,$1,$2,$3))
247
248
249# Force the additions.sh script to get an exact additions build when we're doing the release.
250if $(VBOX_VERSION_BUILD) % 2 == 0
251 ifeq ($(VBOX_VERSION_PRERELEASE),)
252 VBOX_RELEASE_EXACT_MATCH=1
253 endif
254endif
255ifneq ($(VBOX_RELEASE_EXACT_MATCH),)
256 export VBOX_ADDITIONS_SH_MODE = release
257 export VBOX_DOCUMENTATION_SH_MODE = release
258 export VBOX_EFI_SH_MODE = release
259 export VBOX_EXTPACKS_SH_MODE = release
260endif
261
262# Some info on the vendor
263VBOX_VENDOR = Oracle Corporation
264VBOX_VENDOR_SHORT = Oracle
265VBOX_PRODUCT = Oracle VM VirtualBox
266# Not all could be done automatically. Here is a list of known places which
267# have to be updated manually, please keep this up to date:
268# src/VBox/Devices/PC/PXE/client/uinit.asm
269# src/VBox/RDP/webclient/flash/com/sun/network/rdp/Version.as
270# src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
271# src/VBox/Frontends/VirtualBox/src/settings/global/VBoxGLSettingsLanguage.cpp
272# src/VBox/Frontends/VirtualBox/nls/*.ts
273# debian/control
274# src/VBox/Installer/linux/{debian,rpm}
275# src/VBox/Installer/linux/virtualbox.desktop
276# src/VBox/Additions/WINNT/Installer/ISO/ReadmeDrivers.txt
277# src/VBox/Main/nls/*.ts
278# src/VBox/ExtPacks/Puel/nls/*.ts
279# */*.inf, */*.rc
280
281# Maybe we want set this manually.
282VBOX_C_YEAR = $(date-utc %Y)
283
284#
285# The VirtualBox package type.
286#
287ifeq ($(KBUILD_TARGET),win)
288 VBOX_PACKAGE_OS = WINDOWS
289else ifeq ($(KBUILD_TARGET),linux)
290 VBOX_PACKAGE_OS = LINUX
291else ifeq ($(KBUILD_TARGET),darwin)
292 VBOX_PACKAGE_OS = DARWIN
293else ifeq ($(KBUILD_TARGET),solaris)
294 VBOX_PACKAGE_OS = SOLARIS
295else ifeq ($(KBUILD_TARGET),os2)
296 VBOX_PACKAGE_OS = OS2
297else ifeq ($(KBUILD_TARGET),haiku)
298 VBOX_PACKAGE_OS = HAIKU
299else if1of ($(KBUILD_TARGET), dragonfly freebsd netbsd openbsd)
300 VBOX_PACKAGE_OS = BSD
301else
302 $(error Cannot determine VBOX_PACKAGE_OS)
303endif
304ifeq ($(KBUILD_TARGET_ARCH),x86)
305 VBOX_PACKAGE_ARCH = 32BITS
306else
307 VBOX_PACKAGE_ARCH = 64BITS
308endif
309# distribution, mostly for Linux/Solaris where we support different distributions
310# this strip will be overridden by the Linux packaging scripts
311VBOX_PACKAGE_DIST ?= GENERIC
312# Full string
313VBOX_PACKAGE_STRING = $(VBOX_PACKAGE_OS)_$(VBOX_PACKAGE_ARCH)_$(VBOX_PACKAGE_DIST)
314
315# Supported VirtualBox host architectures.
316VBOX_SUPPORTED_HOST_ARCHS := amd64
317
318#
319# The VirtualBox Configuration Defaults.
320#
321# We try to document all the build configuration options here, things which
322# aren't enabled by default are left commented out just to show that they
323# exist and which value they should have (usually 1, but anyway).
324#
325
326# Select new Xcode based on host OS X version.
327ifeq ($(KBUILD_HOST),darwin)
328 if "$(KBUILD_TARGET_ARCH)" == "arm64"
329VBOX_WITH_EVEN_NEWER_XCODE := 1
330# else if !defined(VBOX_WITH_EVEN_NEWER_XCODE) && !defined(VBOX_WITHOUT_EVEN_NEWER_XCODE) && !defined(VBOX_WITH_NEW_XCODE) && $(KBUILD_HOST_VERSION_MAJOR) >= 16 # (OS X 10.12 Sierra)
331#VBOX_WITH_EVEN_NEWER_XCODE := 1
332 else if !defined(VBOX_WITH_NEW_XCODE) && !defined(VBOX_WITHOUT_NEW_XCODE) && $(KBUILD_HOST_VERSION_MAJOR) >= 13 # (OS X 10.9 Mavericks)
333VBOX_WITH_NEW_XCODE := 1
334 endif
335endif
336# Select new VC++ on Windows.
337VBOX_WITH_NEW_VCC = 1
338
339## @name Additions
340## @{
341# This indicates that additions (of some kind or another) is being _built_.
342# VBOX_WITHOUT_ADDITIONS overrides it.
343VBOX_WITH_ADDITIONS = 1
344# Build the optional ring-0 part of the additions for syntax checking.
345# On linux we build this as a test case instead.
346ifneq ($(KBUILD_TARGET), linux)
347 VBOX_WITH_ADDITION_DRIVERS = 1
348endif
349# Build X11 additions. Can be disabled separately.
350if1of ($(KBUILD_TARGET), dragonfly freebsd linux netbsd openbsd solaris)
351 VBOX_WITH_X11_ADDITIONS = 1
352endif
353# Enable the building of shared folders in the windows additions.
354VBOX_WITH_WIN32_ADDITIONS_SHAREDFOLDERS = 1
355# Take the binaries of the OS/2 Additions.
356VBOX_WITH_OS2_ADDITIONS_BIN = 1
357# Use additions from the build server.
358#VBOX_WITH_ADDITIONS_FROM_BUILD_SERVER = 1
359# Include additions in the package
360VBOX_WITH_ADDITIONS_PACKING = 1
361# Only build the additions (for the additions build server).
362#VBOX_ONLY_ADDITIONS = 1
363ifdef VBOX_ADDITIONS_ONLY # typical mistake.
364 $(error It is VBOX_ONLY_ADDITIONS=1 not VBOX_ADDITIONS_ONLY!)
365endif
366# Don't bother with additions, overrides VBOX_WITH_ADDITIONS.
367# This is not used by makefiles, only Config.kmk, see below.
368ifdef VBOX_ONLY_SDK
369 VBOX_WITHOUT_ADDITIONS = 1
370endif
371# Don't create the additions ISO.
372# (Used by the additions build server, don't invert it.)
373#VBOX_WITHOUT_ADDITIONS_ISO = 1
374## @}
375# Set build options right for building the Additions as an RPM package.
376# VBOX_ONLY_RPM_ADDITIONS = 1
377ifdef VBOX_ONLY_RPM_ADDITIONS
378 VBOX_ONLY_ADDITIONS=1
379 VBOX_ONLY_ADDITIONS_WITHOUT_RTISOMAKER=1
380 # We build the RPMs using public sources.
381 VBOX_OSE=1
382 # We want to re-use parts of the packing pass, but not all.
383 VBOX_WITHOUT_LINUX_GUEST_PACKAGE=1
384 VBOX_WITHOUT_ADDITIONS_ISO=1
385endif
386
387## @name Documentation
388## @{
389# The documentation
390VBOX_WITH_DOCS = 1
391# Use documentation from the build server.
392#VBOX_WITH_DOCS_FROM_BUILD_SERVER = 1
393# Include documentation in the package
394VBOX_WITH_DOCS_PACKING = 1
395# Include CHM when building docs (unset in LocalConfig.kmk to suppress CHM)
396## @todo CHM docs are on the way out...
397if1of ($(KBUILD_TARGET), win)
398 VBOX_WITH_DOCS_CHM =
399 VBOX_WITH_DOCS_CHM_PACKING =
400endif
401# Build QHelp documentation, needs qhelpgenerator
402VBOX_WITH_DOCS_QHELP = 1
403# Include QHelp documentation in the package
404VBOX_WITH_DOCS_QHELP_PACKING = 1
405# By default only include translations in documentation-only builds
406ifdef VBOX_ONLY_DOCS
407 ifndef VBOX_NO_DOCS_TRANSLATIONS
408 VBOX_WITH_DOCS_TRANSLATIONS = 1
409 endif
410endif
411# Default languages
412VBOX_MANUAL_LANGUAGES = en_US
413ifdef VBOX_WITH_DOCS_TRANSLATIONS
414 # The French translation is too outdated to be useful, needs a fresh start.
415 #VBOX_MANUAL_ADD_LANGUAGES = fr_FR
416endif
417# Don't bother with documentation, overrides VBOX_WITH_DOCS.
418# This is not used by makefiles, only Config.kmk, see below.
419#VBOX_WITHOUT_DOCS = 1
420# Only build the documentation (for the documentation build server).
421#VBOX_ONLY_DOCS = 1
422ifdef VBOX_DOCS_ONLY # typical mistake.
423 $(error It is VBOX_ONLY_DOCS=1 not VBOX_DOCS_ONLY!)
424endif
425## @}
426
427## @name VMM related settings.
428## @{
429# Enable safe STR (store task register) emulation for raw-mode.
430VBOX_WITH_SAFE_STR = 1
431# Enable support for 64-bit guests.
432VBOX_WITH_64_BITS_GUESTS = 1
433# Enable multi-core VCPUs.
434VBOX_WITH_MULTI_CORE = 1
435# Activate this to force the VM to pre-allocate the guest RAM before startup
436VBOX_WITH_PREALLOC_RAM_BY_DEFAULT =
437# Enable the debugger.
438VBOX_WITH_DEBUGGER = 1
439# Enable the debugger GUI.
440VBOX_WITH_DEBUGGER_GUI = 1
441# Nested hardware virtualization (64-bit hosts only).
442ifeq ($(KBUILD_TARGET_ARCH),amd64)
443 # Enables SVM nested hardware virtualization support.
444 VBOX_WITH_NESTED_HWVIRT_SVM = 1
445 # Enables VMX nested hardware virtualization support.
446 VBOX_WITH_NESTED_HWVIRT_VMX = 1
447 # Enables nested hardware virtualization support but only in IEM.
448 #VBOX_WITH_NESTED_HWVIRT_ONLY_IN_IEM = 1
449 ifdef VBOX_WITH_NESTED_HWVIRT_ONLY_IN_IEM
450 if !defined(VBOX_WITH_NESTED_HWVIRT_SVM) && !defined(VBOX_WITH_NESTED_HWVIRT_VMX)
451 $(error VBOX_WITH_NESTED_HWVIRT_ONLY_IN_IEM defined without enabling nested VMX or nested SVM support)
452 endif
453 endif
454 # Enables guest EPT support for VMX nested hardware virtualization.
455 VBOX_WITH_NESTED_HWVIRT_VMX_EPT = 1
456endif
457# Enable native NEM on windows.
458if1of ($(KBUILD_TARGET), win)
459 VBOX_WITH_NATIVE_NEM = 1
460endif
461# Enables the new breakpoint handling code, see @bugref{8650}
462VBOX_WITH_DBGF_FLOW_TRACING = 1
463## @}
464
465
466## @name Devices, Drivers, ...
467## @{
468# Build the Host Guest Communication Manager component.
469VBOX_WITH_HGCM = 1
470## Build the bugcheck detection code.
471#VBOX_WITH_GUEST_BUGCHECK_DETECTION =
472# Enable the USB feature. This includes VBOX_WITH_VUSB!
473VBOX_WITH_USB = 1
474# Enable the USB 1.1 controller plus virtual USB HID devices.
475VBOX_WITH_VUSB = 1
476# Enable the USB 2.0 controller.
477VBOX_WITH_EHCI = 1
478# Enable the ISCSI feature.
479VBOX_WITH_ISCSI = 1
480# Enable INIP support in the ISCSI feature.
481VBOX_WITH_INIP = 1
482# Enables lwip as a core of NAT service
483VBOX_WITH_LWIP_NAT = 1
484# Enables compilation of NAT service
485VBOX_WITH_NAT_SERVICE = 1
486# Enable the E1000 feature.
487VBOX_WITH_E1000 = 1
488# Enable the Virtio feature.
489VBOX_WITH_VIRTIO = 1
490# Enable the Virtio SCSI device.
491VBOX_WITH_VIRTIO_SCSI = 1
492# HDA emulation is Intel HDA by default.
493VBOX_WITH_INTEL_HDA = 1
494ifn1of ($(KBUILD_TARGET), win darwin)
495 # Enable OSS audio support.
496 VBOX_WITH_AUDIO_OSS = 1
497endif
498if1of ($(KBUILD_TARGET), linux)
499 # Enable ALSA audio support.
500 VBOX_WITH_AUDIO_ALSA = 1
501endif
502if1of ($(KBUILD_TARGET), linux)
503 # Enable PulseAudio audio support.
504 VBOX_WITH_AUDIO_PULSE = 1
505endif
506# Enable building debugging backend.
507# Only will be used at runtime when "VBoxInternal2/Audio/Debug/Enabled" (VM / global) is set.
508VBOX_WITH_AUDIO_DEBUG = 1
509# Enables the audio endpoint detection on Windows hosts.
510VBOX_WITH_AUDIO_MMNOTIFICATION_CLIENT = 1
511# Enable PCI passthrough support.
512# (disabled with 6.1, since it's not complete/useful enough)
513VBOX_WITH_PCI_PASSTHROUGH =
514# Enable statically linked dbus support.
515if1of ($(KBUILD_TARGET), linux solaris)
516 VBOX_WITH_DBUS = 1
517endif
518# Enable building PAM modules.
519if1of ($(KBUILD_TARGET), linux solaris)
520 VBOX_WITH_PAM = 1
521endif
522# Enable internal networking.
523VBOX_WITH_INTERNAL_NETWORKING = 1
524# Enable vmsvga (svga2) graphics device variant, 2D part
525VBOX_WITH_VMSVGA = 1
526# Enable vmsvga (svga2) graphics device variant, 3D part
527if1of ($(KBUILD_TARGET), darwin linux win)
528 VBOX_WITH_VMSVGA3D = 1
529endif
530# Enable the generic 3D settings support if at least one 3D capable solution is enabled
531ifdef VBOX_WITH_VMSVGA3D
532 VBOX_WITH_3D_ACCELERATION = 1
533endif
534# Enable Host Guest Shared Memory Interface.
535VBOX_WITH_HGSMI = 1
536# Enable Video 2D Acceleration.
537if1of ($(KBUILD_TARGET), darwin linux win freebsd)
538 VBOX_WITH_VIDEOHWACCEL = 1
539endif
540# Enable Wddm Video driver for Vista+ guests.
541VBOX_WITH_WDDM = 1
542# Lazy developer!!
543VBOXWDDM_WITH_VBVA = 1
544# Lazy developer!!
545ifdef VBOX_WITH_WDDM
546 VBOX_WITH_VDMA = 1
547else ifdef VBOX_WITH_VDMA
548 undef VBOX_WITH_VDMA
549endif
550# Gallium based WDDM driver
551if1of ($(KBUILD_TARGET), win)
552 VBOX_WITH_MESA3D = 1
553endif
554# Disable the Intel PXE ROM (uses Etherboot).
555VBOX_WITH_INTEL_PXE =
556# Enable EFI support
557VBOX_WITH_EFI = 1
558# Enable Secure Boot in the EFI firmware.
559VBOX_WITH_EFI_SECURE_BOOT = 1
560# Enable TPM support in the EFI firmware.
561VBOX_WITH_EFI_TPM = 1
562# Embed the EFI firmwares in VBoxDD2.dll/dylib/so.
563VBOX_WITH_EFI_IN_DD2 = 1
564# Fetch EFI firmware image from the build server
565#VBOX_WITH_EFIFW_FROM_BUILD_SERVER = 1
566# Include the EFI firmware into the package
567ifndef VBOX_WITH_EFI_IN_DD2
568 VBOX_WITH_EFIFW_PACKING = 1
569endif
570# Enable setuid wrapper for Solaris host DVD.
571#VBOX_WITH_SUID_WRAPPER = 1
572# Enable the virtual SATA/AHCI controller
573VBOX_WITH_AHCI = 1
574# Enable the new async completion manager
575VBOX_WITH_PDM_ASYNC_COMPLETION = 1
576ifdef VBOX_WITH_USB
577 VBOX_WITH_VUSB = 1
578 VBOX_WITH_XHCI_IMPL=1
579endif
580ifdef VBOX_WITH_EHCI
581 VBOX_WITH_EHCI_IMPL = 1
582endif
583ifdef VBOX_WITH_PCI_PASSTHROUGH
584 ## @bugref{9218}: Disabled awaiting conversion of the device to new PDM device style.
585 #VBOX_WITH_PCI_PASSTHROUGH_IMPL = 1
586endif
587ifndef VBOX_WITHOUT_HOSTWEBCAM
588 VBOX_WITH_USB_VIDEO_IMPL = 1
589endif
590# Enable the hal/sysfs USB code on Linux.
591ifeq ($(KBUILD_TARGET),linux)
592 VBOX_USB_WITH_SYSFS = 1
593 # Disabled for now
594 # VBOX_USB_WITH_DBUS = 1
595 VBOX_USB_WITH_INOTIFY = 1
596endif
597# Enable performance API.
598VBOX_WITH_RESOURCE_USAGE_API = 1
599# Use VBoxVolInfo for getting FS dependecies.
600if1of ($(KBUILD_TARGET), linux)
601 VBOX_WITH_DEVMAPPER = 1
602endif
603# Enable unattended installation API
604VBOX_WITH_UNATTENDED = 1
605# Enable BusLogic SCSI host adapter
606VBOX_WITH_BUSLOGIC = 1
607# Enable LsiLogic SCSI host adapter
608VBOX_WITH_LSILOGIC = 1
609# Enable SCSI drivers
610VBOX_WITH_SCSI = 1
611# Enable this setting to force a fallback to default DMI data on configuration errors
612VBOX_BIOS_DMI_FALLBACK =
613# Enable the builtin PXE ROM
614VBOX_WITH_PXE_ROM = 1
615# Enable MSI support in devices
616VBOX_WITH_MSI_DEVICES = 1
617# Enable host network interface API.
618if1of ($(KBUILD_TARGET), darwin freebsd linux solaris win)
619 VBOX_WITH_HOSTNETIF_API = 1
620endif
621# Emulated USB smart card reader
622VBOX_WITH_USB_CARDREADER = 1
623# Disk crypt plugin
624VBOX_WITH_PLUGIN_CRYPT = 1
625# VirtualKD stub/loader device, only relevant on Windows host
626VBOX_WITH_VIRTUALKD = 1
627# NVMe device emulation
628VBOX_WITH_NVME_IMPL = 1
629# Storage related debug drivers
630VBOX_WITH_DRV_DISK_INTEGRITY = 1
631# Enables the AMD IOMMU
632VBOX_WITH_IOMMU_AMD = 1
633# Enables the Intel IOMMU
634VBOX_WITH_IOMMU_INTEL = 1
635# Enables the new DBGF tracing framework
636VBOX_WITH_DBGF_TRACING = 1
637# Enable TPM device emulation support.
638VBOX_WITH_TPM = 1
639## @}
640
641# legacy
642ifdef VBOX_ONLY_TESTSUITE
643 $(warning VBOX_ONLY_TESTSUITE was renamed to VBOX_ONLY_VALIDATIONKIT)
644 VBOX_ONLY_VALIDATIONKIT = $(VBOX_ONLY_TESTSUITE)
645endif
646
647## @name Other Component
648## @{
649# Build the installer.
650VBOX_WITH_INSTALLER = 1
651VBOX_WITH_GUEST_INSTALLER_UNICODE = 1
652# The kernel driver/module and related runtime libraries.
653# On Linux we build this as a test case instead.
654ifneq ($(KBUILD_TARGET), linux)
655 VBOX_WITH_VBOXDRV = 1
656endif
657# The main api.
658VBOX_WITH_MAIN = 1
659# Enables proxy stub for MS COM (speeds up setting IPC for objects).
660# (The VBOX_MIDL_PROXY_CLSID and VBOX_MIDL_PROXY_CLSID_IS are just two
661# representations of the class ID for the proxy stub.)
662VBOX_WITH_MIDL_PROXY_STUB = 1
663VBOX_MIDL_PROXY_CLSID := {0bb3b78c-1807-4249-5ba5-ea42d66af0bf}
664VBOX_MIDL_PROXY_CLSID_IS := {0x0bb3b78c,0x1807,0x4249,{0x5b,0xa5,0xea,0x42,0xd6,0x6a,0xf0,0xbf}}
665# Whether to also ship 32-bit main API on 64-bit systems.
666if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), solaris.amd64 win.amd64)
667 if !defined(VBOX_ONLY_VALIDATIONKIT) && !defined(VBOX_ONLY_ADDITIONS) && !defined(VBOX_ONLY_DOCS) && !defined(VBOX_ONLY_EXTPACKS)
668 VBOX_WITH_32_ON_64_MAIN_API = 1
669 endif
670endif
671# Whether to generate a database of USB vendor IDs and device IDs into VBoxSVC.
672VBOX_WITH_MAIN_USB_ID_DATABASE = 1
673# Whether to enable error message translation in Main.
674VBOX_WITH_MAIN_NLS = 1
675# Whether to enable error message translation in Extension VM Pack.
676VBOX_WITH_PUEL_NLS = 1
677# Set this to prefix all C symbols in XPCOM, to avoid dynamic linking problems
678# caused by our XPCOM library polluting the symbol namespace for system libs.
679if1of ($(KBUILD_TARGET), linux solaris)
680 VBOX_WITH_XPCOM_NAMESPACE_CLEANUP = 1
681endif
682# The webservices api.
683VBOX_WITH_WEBSERVICES = 1
684VBOX_WITH_WEBSERVICES_SSL = 1
685# The Qt GUI.
686VBOX_WITH_QTGUI = 1
687# Indicates the Qt is Cocoa based on the Mac.
688ifeq ($(KBUILD_TARGET),darwin)
689 VBOX_WITH_COCOA_QT = 1
690endif
691# Enable the QHelp based help function in UI.
692if1of ($(KBUILD_TARGET), darwin linux solaris win)
693 VBOX_WITH_QHELP_VIEWER = 1
694endif
695# VBox Ballooning Control frontend.
696VBOX_WITH_FE_BALLOONCTRL = 1
697# VBox Autostart Service.
698VBOX_WITH_FE_AUTOSTART = 1
699# VBox Bug Report tool.
700VBOX_WITH_FE_BUGREPORT = 1
701# The SDL based GUI.
702VBOX_WITH_VBOXSDL = 1
703# Build VBoxSDL with secure label support.
704ifeq ($(filter win.amd64,$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),) # too much work with freetype and all that.
705VBOX_WITH_SECURELABEL = 1
706endif
707# The headless frontend.
708VBOX_WITH_HEADLESS = 1
709# Enable the build of VRDP server.
710VBOX_WITH_VRDP = 1
711# Build the VRDP authentication modules.
712VBOX_WITH_VRDP_AUTHMOD = 1
713# Build enhanced version of rdesktop.
714VBOX_WITH_VRDP_RDESKTOP = 1
715## The Direct Framebuffer GUI.
716#VBOX_WITH_VBOXFB = 1
717# Enables the Python<->XPCOM, Python<->COM and (WS enabled) Python<->WS bindings.
718VBOX_WITH_PYTHON ?= 1
719# Enables the PERL<->WS binding (if WS enabled).
720#VBOX_WITH_PERL ?= 1
721# Enables the PHP<->WS binding (if WS enabled).
722VBOX_WITH_PHP ?= 1
723if1of ($(KBUILD_TARGET), darwin linux solaris)
724 # Enable Java<->XPCOM bridge + glue code
725 VBOX_WITH_JXPCOM ?= 1
726endif
727if1of ($(KBUILD_TARGET), )
728 # Enable Java<->MSCOM glue, bridge is provided by an external lib (Jacob)
729 VBOX_WITH_JMSCOM ?= 1
730endif
731if1of ($(KBUILD_TARGET), darwin linux solaris)
732 # Enable Java<->JAX-WS bridge
733 VBOX_WITH_JWS ?= 1
734endif
735# Use XPIDL instead of XSLT stylesheet
736VBOX_WITH_JAVA_SUPPORT_IN_XPIDL ?=
737# Build against multiple Python versions present in the system (only up to 3.2,
738# unless VBOX_WITH_ONLY_PYTHON_LIMITED_API is overridden).
739VBOX_WITH_MULTIVERSION_PYTHON ?= 1
740# Only build the limited Python extension API version for 3.3 and later.
741VBOX_WITH_ONLY_PYTHON_LIMITED_API = 1
742# Enable the kchmviewer.
743## @todo CHM docs are on the way out...
744VBOX_WITH_KCHMVIEWER =
745# Build the Validation Kit.
746VBOX_WITH_VALIDATIONKIT = 1
747# Set if we should ship the audio test from the Validation Kit with the host installer.
748VBOX_WITH_HOST_SHIPPING_AUDIO_TEST = 1
749# Set if we should ship the audio test from the Validation Kit with the guest additions.
750VBOX_WITH_ADDITIONS_SHIPPING_AUDIO_TEST = 1
751# Build the testcases.
752VBOX_WITH_TESTCASES = 1
753# Enable this to build vbox-img even if VBOX_WITH_TESTCASES is disabled
754VBOX_WITH_VBOX_IMG =
755# Enables recording support.
756VBOX_WITH_RECORDING = 1
757# Enable VPX (VP8 / VP9 codec), required for video capturing.
758VBOX_WITH_LIBVPX = 1
759# Enables audio support for recording (depends on VBOX_WITH_RECORDING).
760VBOX_WITH_AUDIO_RECORDING = 1
761# Enables libopus (Opus), required for encoding audio into the recorded data.
762VBOX_WITH_LIBOPUS = 1
763# Enable SEE (+ AVX) optimizations for Opus.
764VBOX_WITH_OPUS_SSE = 1
765# Enable shared folders
766VBOX_WITH_SHARED_FOLDERS = 1
767# Enable shared clipboard
768VBOX_WITH_SHARED_CLIPBOARD = 1
769# Enable shared clipboard (file) transfers
770#if1of ($(KBUILD_TARGET), win linux)
771# VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS = 1
772# if1of ($(KBUILD_TARGET), linux)
773# VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP = 1
774# endif
775#endif
776# Enable the host/guest information service (aka guest properties).
777VBOX_WITH_GUEST_PROPS = 1
778# Enable this to prevent the guest from writing guest properties.
779VBOX_WITH_GUEST_PROPS_RDONLY_GUEST =
780# Compile the host channel
781VBOX_WITH_HOST_CHANNEL = 1
782# Enable the guest control service.
783if1of ($(KBUILD_TARGET), darwin freebsd linux solaris win)
784 VBOX_WITH_GUEST_CONTROL = 1
785endif
786# Enable ballooning
787VBOX_WITH_MEMBALLOON = 1
788# Enable cURL (required for the network part of the GUI)
789VBOX_WITH_LIBCURL = 1
790# Enable Host=>Guest Drag'n'Drop
791if1of ($(KBUILD_TARGET), darwin linux solaris win)
792 VBOX_WITH_DRAG_AND_DROP = 1
793 if1of ($(KBUILD_TARGET), darwin linux solaris win)
794 VBOX_WITH_DRAG_AND_DROP_GH = $(VBOX_WITH_DRAG_AND_DROP)
795 endif
796 ifdef VBOX_WITH_DRAG_AND_DROP_GH
797 ifeq ($(KBUILD_TARGET),darwin)
798 # On OS X (Darwin) this needs to be set in order to get proper
799 # guest->host support.
800 # Note: Setting this requires Qt also having this feature enabled!
801 VBOX_WITH_DRAG_AND_DROP_PROMISES = $(VBOX_WITH_DRAG_AND_DROP)
802 endif
803 endif
804endif
805# Enable audio support for VRDE.
806VBOX_WITH_AUDIO_VRDE = 1
807ifdef VBOX_WITH_VALIDATIONKIT
808 # Ship the Validation Kit audio driver for running tests (driver disabled by default).
809 VBOX_WITH_AUDIO_VALIDATIONKIT = 1
810endif
811# Use the VRDE external authentication library from VBoxSVC.
812if1of ($(KBUILD_TARGET), win)
813 VBOX_WITH_VRDEAUTH_IN_VBOXSVC = 1
814endif
815# Enables use of merge modules in the windows installer. This will increase
816# the overall installer size significantly because merge modules are not able
817# to use a common .cab file to reduce their size.
818#VBOX_WITH_MSM_INSTALL = 1
819## @}
820
821
822## @name Networking
823## @{
824# Use VBoxNetFlt for host interface networking.
825if1of ($(KBUILD_TARGET), darwin freebsd linux solaris win)
826 VBOX_WITH_NETFLT = 1
827 ifeq ($(KBUILD_TARGET),solaris)
828 # requires snv_159+.
829 VBOX_WITH_NETFLT_CROSSBOW = 1
830 endif
831 # Use VBoxNetAdp for host only networking.
832 if1of ($(KBUILD_TARGET), darwin freebsd linux solaris win)
833 VBOX_WITH_NETADP = 1
834 endif
835endif
836# Enables the UDP tunnel transport.
837VBOX_WITH_UDPTUNNEL = 1
838# Enable the netshaper support
839VBOX_WITH_NETSHAPER = 1
840# Enable Virtual Distributed Ethernet or not.
841if1of ($(KBUILD_TARGET), freebsd linux)
842 VBOX_WITH_VDE = 1
843endif
844# Use new VBoxNetDhcpd instead of old VBoxNetDHCP
845VBOX_WITH_DHCPD = 1
846# Experimental suport for cloud network integration
847VBOX_WITH_CLOUD_NET = 1
848# Use Mac OS X VMNET API instead of network kernel extensions
849VBOX_WITH_VMNET = 1
850## @}
851
852
853## @name Extension pack
854## @{
855# Enables the extension pack feature.
856VBOX_WITH_EXTPACK = 1
857# Enables separating code into the Oracle VM VirtualBox Extension Pack, dubbed PUEL.
858VBOX_WITH_EXTPACK_PUEL = 1
859# Enables building+packing the Oracle VM VirtualBox Extension Pack, includes VBOX_WITH_EXTPACK_PUEL
860VBOX_WITH_EXTPACK_PUEL_BUILD = 1
861# Enable the BusMouse sample extension pack.
862#VBOX_WITH_EXTPACK_BUSMOUSESAMPLE = 1
863# Enable the VNC server extension pack (GPL only).
864#VBOX_WITH_EXTPACK_VNC = 1
865# Enables the VBoxDTrace extension pack.
866VBOX_WITH_EXTPACK_VBOXDTRACE = 1
867## @}
868
869## @name Misc
870## @{
871# Enable to compile with OpenSSL 1.0 (only relevant for Windows, see src/VBox/Runtime/Makefile.kmk)
872#VBOX_WITH_OPENSSL_PRE_1_1 = 1
873# Enables all the doxgen bits.
874VBOX_WITH_ALL_DOXYGEN_TARGETS = 1
875# Set this to skip installing the redistributable compiler runtime.
876#VBOX_WITHOUT_COMPILER_REDIST = 1
877# Enables VMMR0.r0 (++) loading using the native loader on solaris.
878# Good for debugging and analysis. Experimental.
879#VBOX_WITH_NATIVE_SOLARIS_LOADING = 1
880# Set this to enable user mode dtrace probes.
881if1of ($(KBUILD_TARGET), darwin linux solaris)
882 if1of ($(KBUILD_TARGET_ARCH), x86 amd64) ## @todo bugref:9898
883VBOX_WITH_DTRACE_R3 := 1
884VBOX_WITH_DTRACE_R3_MAIN := 1
885 endif
886endif
887# Set this to enable kernel driver dtrace probes.
888if1of ($(KBUILD_TARGET), darwin solaris)
889 if1of ($(KBUILD_TARGET_ARCH), x86 amd64) ## @todo bugref:9898
890VBOX_WITH_DTRACE_R0DRV := 1
891 endif
892endif
893# Set this to enable dtrace probes in platform agnostic kernel code.
894ifn1of ($(KBUILD_TARGET), os2)
895 if1of ($(KBUILD_TARGET_ARCH), x86 amd64) ## @todo bugref:9898
896VBOX_WITH_DTRACE_R0 := 1
897 endif
898endif
899# Set this to enable dtrace probes raw-mode context code.
900if1of ($(KBUILD_TARGET), linux solaris)
901 if1of ($(KBUILD_TARGET_ARCH), x86 amd64) ## @todo bugref:9898
902VBOX_WITH_DTRACE_RC := 1
903 endif
904endif
905# Set this to enable support for dtrace probes in guest code.
906#VBOX_WITH_DTRACE_GST = 1
907# Set this to indicate that the host ships with DTrace.
908if1of ($(KBUILD_TARGET), darwin solaris)
909 if1of ($(KBUILD_TARGET_ARCH), x86 amd64) ## @todo bugref:9898
910VBOX_WITH_NATIVE_DTRACE := 1
911 endif
912endif
913# Makes it possible to run some of the testcases and tools on older
914# windows versions (only define when buildling win.x86).
915#VBOX_WITH_MORE_NT4_COMPAT_BINARIES = 1
916# Set this to enable building of the vboximg-mount FUSE mounting utility.
917if1of ($(KBUILD_TARGET), darwin linux)
918 VBOX_WITH_VBOXIMGMOUNT = 1
919endif
920# Set this to enable packaging the fuse related bits into our installer.
921if1of ($(KBUILD_TARGET), darwin)
922 VBOX_WITH_FUSE_PACKING = 1
923endif
924## @}
925
926
927## @name Compiler and linker config
928## @{
929# For treating compiler and linker warnings as errors where possible.
930if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), darwin.x86 darwin.amd64 linux.x86 linux.amd64 win.x86 win.amd64)
931 VBOX_WITH_WARNINGS_AS_ERRORS = 1
932endif
933# Whether we can use Open Watcom to build stuff.
934if1of ($(KBUILD_TARGET), darwin linux os2 win)
935 VBOX_WITH_OPEN_WATCOM = 1
936endif
937## @}
938
939
940## @name Hardening
941## @{
942# Enables hardening.
943# Most developers will want to disable this in their LocalConfig.kmk.
944VBOX_WITH_HARDENING = 1
945# Where the application files are (going to be) installed.
946#VBOX_PATH_APP_PRIVATE = /usr/lib/virtualbox
947ifdef VBOX_WITH_HARDENING
948 if1of ($(KBUILD_TARGET), linux solaris)
949 VBOX_PATH_APP_PRIVATE = /opt/VirtualBox
950 else ifeq ($(KBUILD_TARGET),darwin)
951 VBOX_PATH_APP_PRIVATE = /Applications/VirtualBox.app/Contents/MacOS
952 else ifeq ($(KBUILD_TARGET),freebsd)
953 VBOX_PATH_APP_PRIVATE = /usr/local/lib/virtualbox
954 else ifeq ($(KBUILD_TARGET),haiku)
955 VBOX_PATH_APP_PRIVATE = /boot/system/apps/VirtualBox
956 endif
957endif
958# Where the architecture specific application files are (going to be) installed.
959#VBOX_PATH_APP_PRIVATE_ARCH = /usr/lib/virtualbox
960ifdef VBOX_WITH_HARDENING
961 if1of ($(KBUILD_TARGET), solaris)
962 VBOX_PATH_APP_PRIVATE_ARCH_TOP = $(VBOX_PATH_APP_PRIVATE)
963 VBOX_PATH_APP_PRIVATE_ARCH = $(VBOX_PATH_APP_PRIVATE_ARCH_TOP)/$(if-expr $(KBUILD_TARGET_ARCH) == "amd64",amd64,i386)
964 else ifdef VBOX_PATH_APP_PRIVATE
965 VBOX_PATH_APP_PRIVATE_ARCH = $(VBOX_PATH_APP_PRIVATE)
966 endif
967endif
968# Where the shared libraries are (going to be) installed.
969#VBOX_PATH_SHARED_LIBS = /usr/lib
970ifdef VBOX_WITH_HARDENING
971 if1of ($(KBUILD_TARGET), solaris)
972 VBOX_PATH_SHARED_LIBS = $(VBOX_PATH_APP_PRIVATE)/$(if-expr $(KBUILD_TARGET_ARCH) == "amd64",amd64,i386)
973 else ifdef VBOX_PATH_APP_PRIVATE
974 VBOX_PATH_SHARED_LIBS = $(VBOX_PATH_APP_PRIVATE)
975 endif
976endif
977# Where the documentation is (going to be) installed.
978#VBOX_PATH_APP_DOCS = /usr/share/doc/virtualbox
979ifdef VBOX_WITH_HARDENING
980 ifdef VBOX_PATH_APP_PRIVATE
981 VBOX_PATH_APP_DOCS = $(VBOX_PATH_APP_PRIVATE)
982 endif
983endif
984# The DT_RPATH/DT_RUNPATH to embed into the binaries (ELF).
985# (This one is used for all binaries, there is no need to adjust this
986# depending on the location of the object.)
987#VBOX_WITH_RUNPATH = /usr/lib/virtualbox
988ifdef VBOX_WITH_HARDENING
989 if1of ($(KBUILD_TARGET), solaris)
990 VBOX_WITH_RUNPATH = $(VBOX_PATH_APP_PRIVATE)/$(if-expr $(KBUILD_TARGET_ARCH) == "amd64",amd64,i386)
991 else if1of ($(KBUILD_TARGET), freebsd linux)
992 VBOX_WITH_RUNPATH = $(VBOX_PATH_APP_PRIVATE)
993 endif
994endif
995# Enable use of the $ORIGIN DT_RPATH/DT_RUNPATH feature (ELF).
996# Because of the setuid usage on all ELF platforms when hardening the build
997# things gets a bit complicated since the $ORIGIN+setuid policy differs.
998#VBOX_WITH_ORIGIN = 1
999ifndef VBOX_WITH_HARDENING
1000 if1of ($(KBUILD_TARGET), freebsd linux netbsd openbsd solaris) # duplicated further down
1001 VBOX_WITH_ORIGIN = 1
1002 endif
1003endif
1004# Enable the system wide support service/daemon.
1005# Very sketchy work in progress.
1006#VBOX_WITH_SUPSVC = 1
1007
1008# Continue to support Vista w/o any service pack, at least for now.
1009VBOX_WITH_VISTA_NO_SP = 1
1010# Enable image verification on darwin @bugref{9232}.
1011VBOX_WITH_DARWIN_R0_DARWIN_IMAGE_VERIFICATION = 1
1012## @}
1013
1014
1015# Strip binaries of release and profile builds before packing them into the installer
1016# archive. When building .deb/.rpms, don't strip the symbols as they are required for
1017# the debug packages containing symbols for gdb located in /usr/lib/debug.
1018# In rpm Additions we also need to do part of packing without strip.
1019ifndef VBOX_ONLY_RPM_ADDITIONS
1020 VBOX_DO_STRIP := $(if $(filter release profile,$(KBUILD_TYPE)),1,)
1021endif
1022
1023
1024#
1025# Config items for enabling work in progress.
1026#
1027# It's good pratice to add stuff here even if it is currently disabled by
1028# default.
1029#
1030# Note! Please, do *not* add stuff to the global DEFS unless it is *really*
1031# necessary! The other guys will hate for it you when they have to
1032# recompile everything when the feature is enabled or disabled. Put
1033# the ifdefs in target or template definitions.
1034#
1035
1036# Mask all Local APIC interrupt vectors which are set up to NMI mode when switching
1037# to/from the guest in raw mode. Modern Linux kernels use the performance counter
1038# to raise an NMI from time to time.
1039if1of ($(KBUILD_TARGET), linux)
1040 VBOX_WITH_VMMR0_DISABLE_LAPIC_NMI = 1
1041endif
1042## For testing deadlock detection and lock order validation.
1043# If issues are found, create high priority defects and temporarily comment
1044# the next line.
1045VBOX_WITH_STRICT_LOCKS = 1
1046## VBoxSDS is the bridge windows service that sits between
1047# VirtualBox object client and VBoxSVC that fixes problem
1048# when multiple VBoxSVC starts for the same user
1049# it is enabled for windows build only
1050ifeq ($(KBUILD_TARGET),win)
1051 VBOX_WITH_SDS = 1
1052endif
1053
1054
1055#
1056# Branding
1057#
1058VBOX_BRAND_BIOS_LOGO := $(PATH_ROOT)/src/VBox/Devices/Graphics/BIOS/puel_logo.bmp
1059VBOX_BRAND_LICENSE_HTML := $(PATH_ROOT)/doc/License-gpl-2.0.html
1060VBOX_BRAND_LICENSE_RTF := $(PATH_ROOT)/doc/License-gpl-2.0.rtf
1061VBOX_BRAND_LICENSE_TXT := $(PATH_ROOT)/doc/License-gpl-2.0.txt
1062VBOX_BRAND_LICENSE_VER :=
1063VBOX_BRAND_GUI_ABOUT_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/about.png
1064VBOX_BRAND_GUI_ABOUT_X2_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/about_x2.png
1065VBOX_BRAND_GUI_ABOUT_X3_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/about_x3.png
1066VBOX_BRAND_GUI_ABOUT_X4_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/about_x4.png
1067VBOX_BRAND_GUI_ABOUT_16PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/about_16px.png
1068VBOX_BRAND_GUI_ABOUT_16PX_X2_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/about_16px_x2.png
1069VBOX_BRAND_GUI_ABOUT_16PX_X3_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/about_16px_x3.png
1070VBOX_BRAND_GUI_ABOUT_16PX_X4_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/about_16px_x4.png
1071VBOX_BRAND_GUI_VBOX_16PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/VirtualBox_16px.png
1072VBOX_BRAND_GUI_VBOX_20PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/VirtualBox_20px.png
1073VBOX_BRAND_GUI_VBOX_32PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/VirtualBox_32px.png
1074VBOX_BRAND_GUI_VBOX_40PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/VirtualBox_40px.png
1075VBOX_BRAND_GUI_VBOX_48PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/VirtualBox_48px.png
1076VBOX_BRAND_GUI_VBOX_64PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/NonOSE/VirtualBox_64px.png
1077VBOX_BRAND_GUI_VBOX_SVG := $(PATH_ROOT)/src/VBox/Artwork/NonOSE/virtualbox.svg
1078VBOX_BRAND_WIN_INST_DLGJPG := $(PATH_ROOT)/src/VBox/Installer/win/Binary/Dialog.jpg
1079VBOX_BRAND_WIN_INST_EXT :=
1080VBOX_BRAND_WIN_ADD_INST_DLGBMP := $(PATH_ROOT)/src/VBox/Additions/WINNT/Installer/welcome.bmp
1081VBOX_BRAND_DARWIN_DISKIMAGE_DS_STORE := $(PATH_ROOT)/src/VBox/Installer/darwin/DiskImage/DS_Store
1082VBOX_BRAND_DARWIN_DISKIMAGE_BG := $(PATH_ROOT)/src/VBox/Installer/darwin/DiskImage/vbox_folder.tiff
1083VBOX_BRAND_DARWIN_INSTALLER_BG := $(PATH_ROOT)/src/VBox/Installer/darwin/VirtualBox_mpkg/background.tif
1084
1085#
1086# Skip stuff.
1087#
1088
1089ifdef VBOX_ONLY_EXTPACKS
1090 # Clear some VBOX_WITH_XXX variables instead of adding ifdefs all over the place.
1091 VBOX_WITH_DEBUGGER =
1092 VBOX_WITH_ADDITIONS =
1093 VBOX_WITH_VBOXDRV =
1094 VBOX_WITH_TESTCASES =
1095endif
1096
1097# VBOX_QUICK can be used by core developers to speed to the build
1098ifdef VBOX_QUICK
1099 # undefine variables by assigning blank.
1100 VBOX_WITH_ADDITIONS=
1101 VBOX_WITH_VALIDATIONKIT=
1102 VBOX_WITH_TESTCASES=
1103 VBOX_WITH_VBOXSDL=
1104 VBOX_WITH_HEADLESS=
1105 VBOX_WITH_VRDP=
1106 VBOX_WITH_VRDP_RDESKTOP=
1107 VBOX_WITH_DOCS=
1108 VBOX_WITH_WEBSERVICES=
1109 VBOX_WITH_32_ON_64_MAIN_API=
1110endif # VBOX_QUICK
1111
1112# Only AMD64 is supported for the main product, so disable most of the other bits.
1113ifn1of ($(KBUILD_TARGET_ARCH), $(VBOX_SUPPORTED_HOST_ARCHS))
1114 VBOX_WITH_MAIN=
1115 VBOX_WITH_QTGUI=
1116 VBOX_WITH_VBOXSDL=
1117 VBOX_WITH_VBOXHEADLESS=
1118 VBOX_WITH_WEBSERVICES=
1119 VBOX_WITH_DEBUGGER_GUI=
1120endif
1121
1122ifeq ($(KBUILD_TARGET),darwin)
1123 # Don't bother with SDL ttf for now.
1124 VBOX_WITH_SECURELABEL=
1125 # We'll use the native html/help viewer.
1126 VBOX_WITH_KCHMVIEWER=
1127 VBOX_WITH_VRDP_RDESKTOP=
1128 # Permanent (no working SDL).
1129 VBOX_WITH_VBOXSDL=
1130endif
1131
1132ifeq ($(KBUILD_TARGET),freebsd)
1133 VBOX_WITH_DOCS=
1134endif
1135
1136ifeq ($(KBUILD_TARGET),haiku)
1137 # Don't bother with SDL ttf for now.
1138 VBOX_WITH_SECURELABEL=
1139 # We'll use the native html/help viewer.
1140 VBOX_WITH_KCHMVIEWER=
1141 VBOX_WITH_VRDP_RDESKTOP=
1142 # Permanent (no working SDL).
1143 VBOX_WITH_VBOXSDL=
1144 VBOX_WITH_DOCS=
1145 VBOX_WITH_VBOXDRV=
1146 VBOX_WITH_VRDP=
1147 VBOX_WITH_HEADLESS=
1148 VBOX_WITH_VBOXSDL=
1149 VBOX_WITH_QTGUI=
1150# VBOX_WITH_MAIN=
1151 VBOX_WITH_DOCS=
1152 VBOX_WITH_ISCSI=
1153 VBOX_WITH_INIP=
1154 VBOX_WITH_INTERNAL_NETWORKING=
1155 VBOX_WITH_PDM_ASYNC_COMPLETION=
1156 VBOX_WITH_KCHMVIEWER=
1157 VBOX_WITH_HARDENING=
1158endif
1159
1160
1161ifeq ($(KBUILD_TARGET),os2)
1162 VBOX_WITH_WEBSERVICES=
1163 VBOX_WITH_INSTALLER=
1164 VBOX_WITH_SECURELABEL=
1165 VBOX_WITH_VRDP_AUTHMOD=
1166 VBOX_WITH_VRDP_RDESKTOP=
1167 VBOX_WITH_VALIDATIONKIT=
1168 VBOX_WITH_QTGUI=
1169 VBOX_WITH_USB=
1170 VBOX_WITH_EHCI=
1171 VBOX_WITH_DOCS=
1172 VBOX_WITH_PDM_ASYNC_COMPLETION=
1173 VBOX_WITH_KCHMVIEWER=
1174 VBOX_WITH_HARDENING=
1175endif
1176
1177ifeq ($(KBUILD_TARGET),solaris)
1178 VBOX_WITH_SECURELABEL=
1179endif
1180
1181ifeq ($(KBUILD_TARGET),win)
1182 VBOX_WITH_VRDP_RDESKTOP=
1183 VBOX_WITH_KCHMVIEWER=
1184endif
1185
1186ifn1of ($(KBUILD_TARGET_ARCH), x86 amd64 arm64)
1187 VBOX_WITH_ADDITION_DRIVERS=
1188 VBOX_WITH_DEBUGGER=
1189 VBOX_WITH_DOCS=
1190 VBOX_WITH_EHCI=
1191 VBOX_WITH_HARDENING=
1192 VBOX_WITH_HEADLESS=
1193 VBOX_WITH_HGCM=
1194 VBOX_WITH_HGSMI=
1195 VBOX_WITH_INIP=
1196 VBOX_WITH_INSTALLER=
1197 VBOX_WITH_INTERNAL_NETWORKING=
1198 VBOX_WITH_ISCSI=
1199 VBOX_WITH_KCHMVIEWER=
1200 VBOX_WITH_MAIN=
1201 VBOX_WITH_PDM_ASYNC_COMPLETION=
1202 VBOX_WITH_QTGUI=
1203 VBOX_WITH_RAW_MODE=
1204 VBOX_WITH_SECURELABEL=
1205 VBOX_WITH_VALIDATIONKIT=
1206 VBOX_WITH_USB=
1207 VBOX_WITH_VBOXDRV=
1208 VBOX_WITH_VBOXSDL=
1209 VBOX_WITH_WEBSERVICES=
1210 VBOX_WITH_XPCOM=
1211 VBOX_WITHOUT_HARDENING=1
1212 # remove later:
1213 VBOX_WITH_VRDP=
1214 VBOX_WITH_VRDP_AUTHMOD=
1215 VBOX_WITH_VRDP_RDESKTOP=
1216endif
1217
1218
1219#
1220# Include automatic and local config file to override the above settings
1221# and to provide defaults for the settings below this point.
1222#
1223ifndef AUTOCFG
1224 AUTOCFG := $(wildcard $(PATH_ROOT)/AutoConfig.kmk)
1225endif
1226ifneq ($(AUTOCFG),)
1227 include $(AUTOCFG)
1228endif
1229
1230ifndef LOCALCFG
1231 LOCALCFG := $(wildcard $(PATH_ROOT)/LocalConfig.kmk)
1232 ifneq ($(LOCALCFG),)
1233 include $(LOCALCFG)
1234 endif
1235else
1236 # Ignore it if it doesn't exist.
1237 if exists "$(LOCALCFG)"
1238 include $(LOCALCFG)
1239 else
1240 $(warning LOCALCFG='$(LOCALCFG)' does not exist)
1241 override LOCALCFG :=
1242 endif
1243endif
1244
1245#
1246# Allow to overwrite the branding information from an external file
1247#
1248ifdef VBOX_BRANDING_CFG
1249 include $(VBOX_BRANDING_CFG)
1250endif
1251
1252#
1253# VBOX_WITH_NLS controls all NLS (except the GUI at the moment).
1254# We disable NLS for SDK-only builds.
1255#
1256if defined(VBOX_WITH_MAIN_NLS) || defined(VBOX_WITH_PUEL_NLS)
1257 VBOX_WITH_NLS := 1
1258endif
1259#
1260# Additions does not use NLS support yet
1261#
1262if defined(VBOX_ONLY_SDK) || defined(VBOX_ONLY_ADDITIONS)
1263 override VBOX_WITH_NLS :=
1264endif
1265ifndef VBOX_WITH_NLS # (We test again to account for 'override VBOX_WITH_NLS :=')
1266 VBOX_WITH_MAIN_NLS :=
1267 VBOX_WITH_PUEL_NLS :=
1268endif
1269
1270#
1271# Bitch about old settings.
1272#
1273ifdef VBOX_WITHOUT_LINUX_COMPILER_H
1274 $(warning VBOX_WITHOUT_LINUX_COMPILER_H was renamed to VBOX_WITH_LINUX_COMPILER_H, the meaning is inverted.)
1275endif
1276
1277#
1278# Indicate VBOX_ONLY build if any of the VBOX_ONLY_* variables are set.
1279#
1280VBOX_ONLY_BUILD := $(strip $(foreach x, ADDITIONS DOCS EXTPACKS SDK VALIDATIONKIT\
1281 , $(if-expr defined(VBOX_ONLY_$(x)),VBOX_ONLY_$(x))))
1282if $(words $(VBOX_ONLY_BUILD)) > 1
1283 $(error VBox: More than one VBOX_ONLY build enabled! $(VBOX_ONLY_BUILD))
1284endif
1285
1286#
1287# For the docs build box.
1288#
1289ifdef VBOX_ONLY_DOCS
1290 # Phase out the .chm docs
1291 VBOX_WITH_DOCS_CHM =
1292 # Always produce HTML docs (for publishing on website as part of release)
1293 VBOX_WITH_DOCS_HTML = 1
1294 # Always produce QHelp docs (for help in the UI, replacing CHM)
1295 VBOX_WITH_DOCS_QHELP = 1
1296 VBOX_WITH_TOOLS_QT_LINUX = 1
1297endif
1298
1299#
1300# Disable components that are not open sourced.
1301#
1302ifdef VBOX_OSE
1303 VBOX_WITH_VRDP=
1304 VBOX_WITH_EHCI_IMPL=
1305 VBOX_WITH_XHCI_IMPL=
1306 VBOX_WITH_USB_VIDEO_IMPL=
1307 VBOX_WITH_NVME_IMPL=
1308 VBOX_WITH_EXTPACK_PUEL=
1309 VBOX_WITH_EXTPACK_PUEL_BUILD=
1310 VBOX_WITH_PCI_PASSTHROUGH_IMPL=
1311 VBOX_WITH_OS2_ADDITIONS_BIN=
1312 ifeq ($(KBUILD_TARGET),win)
1313 VBOX_WITH_NATIVE_NEM=
1314 endif
1315 # not yet
1316 VBOX_WITH_SECURELABEL=
1317 VBOX_WITH_KCHMVIEWER=
1318 VBOX_WITH_PLUGIN_CRYPT=
1319 VBOX_WITH_DRAG_AND_DROP_PROMISES=
1320 ifn1of ($(KBUILD_TARGET), linux)
1321 VBOX_WITH_DOCS=
1322 VBOX_WITH_DOCS_PACKING=
1323 endif
1324 if1of ($(KBUILD_TARGET), solaris)
1325 VBOX_WITH_32_ON_64_MAIN_API=
1326 endif
1327 if1of ($(KBUILD_TARGET), win)
1328 # tar/gzip uncommon on Windows
1329 VBOX_WITH_EXTPACK_VBOXDTRACE=
1330 endif
1331 # Enable any translations in OSE, even partial ones.
1332 ifndef ($(VBOX_NO_DOCS_TRANSLATIONS))
1333 VBOX_WITH_DOCS_TRANSLATIONS = 1
1334 endif
1335 VBOX_WITH_INTEL_PXE=
1336 # Disable for OSE, requires snv_159+.
1337 VBOX_WITH_NETFLT_CROSSBOW=
1338 ifn1of ($(KBUILD_TARGET), darwin linux solaris win)
1339 VBOX_WITH_INSTALLER=
1340 endif
1341 if1of ($(KBUILD_TARGET), win)
1342 # Undefine codec libraries which are not needed.
1343 VBOX_WITH_LIBVPX=
1344 VBOX_WITH_LIBOPUS=
1345 # Disable recording (with audio support).
1346 VBOX_WITH_RECORDING=
1347 VBOX_WITH_AUDIO_RECORDING=
1348 endif
1349 # branding
1350 VBOX_BRAND_LICENSE_HTML := $(PATH_ROOT)/doc/License-gpl-2.0.html
1351 VBOX_BRAND_LICENSE_RTF := $(PATH_ROOT)/doc/License-gpl-2.0.rtf
1352 VBOX_BRAND_LICENSE_TXT := $(PATH_ROOT)/doc/License-gpl-2.0.txt
1353 VBOX_BRAND_BIOS_LOGO := $(PATH_ROOT)/src/VBox/Devices/Graphics/BIOS/ose_logo.bmp
1354 VBOX_BRAND_GUI_ABOUT_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/about.png
1355 VBOX_BRAND_GUI_ABOUT_X2_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/about_x2.png
1356 VBOX_BRAND_GUI_ABOUT_X3_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/about_x3.png
1357 VBOX_BRAND_GUI_ABOUT_X4_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/about_x4.png
1358 VBOX_BRAND_GUI_ABOUT_16PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/about_16px.png
1359 VBOX_BRAND_GUI_ABOUT_16PX_X2_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/about_16px_x2.png
1360 VBOX_BRAND_GUI_ABOUT_16PX_X3_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/about_16px_x3.png
1361 VBOX_BRAND_GUI_ABOUT_16PX_X4_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/about_16px_x4.png
1362 VBOX_BRAND_GUI_VBOX_16PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_16px.png
1363 VBOX_BRAND_GUI_VBOX_20PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_20px.png
1364 VBOX_BRAND_GUI_VBOX_32PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_32px.png
1365 VBOX_BRAND_GUI_VBOX_40PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_40px.png
1366 VBOX_BRAND_GUI_VBOX_48PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_48px.png
1367 VBOX_BRAND_GUI_VBOX_64PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_64px.png
1368 VBOX_BRAND_GUI_CUBE_42PX_PNG := $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_cube_42px.png
1369 VBOX_BRAND_GUI_VBOX_SVG := $(PATH_ROOT)/src/VBox/Artwork/OSE/virtualbox.svg
1370endif
1371
1372#
1373# VBOX_WITHOUT_HARDENING is for developers (put in LocalConfig.kmk).
1374# Note that this is a bit rough since hardening governs more than one
1375# variable... Also note that we allow VBOX_WITH_HARDENING=1 on the
1376# command line to overrule VBOX_WITHOUT_HARDENING (the check below).
1377#
1378ifdef VBOX_WITHOUT_HARDENING
1379 VBOX_WITH_HARDENING=
1380 ifeq ($(VBOX_WITH_HARDENING),)
1381 VBOX_PATH_APP_PRIVATE=
1382 VBOX_PATH_APP_PRIVATE_ARCH=
1383 VBOX_PATH_APP_PRIVATE_ARCH_TOP=
1384 VBOX_PATH_SHARED_LIBS=
1385 VBOX_PATH_APP_DOCS=
1386 VBOX_WITH_RUNPATH=
1387 if1of ($(KBUILD_TARGET), freebsd linux netbsd openbsd solaris) # duplicated up above
1388 VBOX_WITH_ORIGIN = 1
1389 endif
1390 endif
1391endif
1392
1393#
1394# Sanitize the additions build config variables.
1395#
1396ifdef VBOX_WITH_ADDITIONS_FROM_BUILD_SERVER
1397 VBOX_WITHOUT_ADDITIONS := 1
1398 ifdef VBOX_ONLY_ADDITIONS
1399 $(error VBOX_ONLY_ADDITIONS + VBOX_WITH_ADDITIONS_FROM_BUILD_SERVER does not add up!)
1400 endif
1401endif
1402
1403ifdef VBOX_ONLY_ADDITIONS
1404 ifdef VBOX_WITHOUT_ADDITIONS
1405 $(error VBOX_ONLY_ADDITIONS + VBOX_WITHOUT_ADDITIONS does not add up!)
1406 endif
1407 ifndef VBOX_WITH_ADDITIONS
1408 $(error VBOX_ONLY_ADDITIONS + unset VBOX_WITH_ADDITIONS does not add up!)
1409 endif
1410endif
1411
1412ifdef VBOX_WITHOUT_ADDITIONS
1413 # Zap anything that could be contradicting this.
1414 VBOX_WITH_ADDITIONS :=
1415endif
1416
1417#
1418# Sanitize the documentation build config variables.
1419#
1420ifdef VBOX_WITH_DOCS_FROM_BUILD_SERVER
1421 VBOX_WITHOUT_DOCS := 1
1422 ifdef VBOX_ONLY_DOCS
1423 $(error VBOX_ONLY_DOCS + VBOX_WITH_DOCS_FROM_BUILD_SERVER does not add up!)
1424 endif
1425endif
1426
1427ifdef VBOX_ONLY_DOCS
1428 ifdef VBOX_WITHOUT_DOCS
1429 $(error VBOX_ONLY_DOCS + VBOX_WITHOUT_DOCS does not add up!)
1430 endif
1431endif
1432
1433ifdef VBOX_WITHOUT_DOCS
1434 # Zap anything that could be contradicting this.
1435 VBOX_WITH_DOCS :=
1436 VBOX_WITH_DOCS_CHM :=
1437endif
1438
1439#
1440# Disable components for headless
1441#
1442ifdef VBOX_HEADLESS
1443 VBOX_WITH_QTGUI=
1444 VBOX_WITH_VBOXSDL=
1445 VBOX_WITH_KCHMVIEWER=
1446 VBOX_WITH_VRDP_RDESKTOP=
1447endif
1448
1449#
1450# Undefined VBOX_WITH_MAIN implies exclusion of a few more items.
1451#
1452ifndef VBOX_WITH_MAIN
1453 VBOX_WITH_VBOXSDL=
1454 VBOX_WITH_QTGUI=
1455 VBOX_WITH_DEBUGGER_GUI=
1456 VBOX_WITH_HEADLESS=
1457 ifdef VBOX_ONLY_DOCS
1458 $(error Oh, does VBOX_ONLY_DOCS actually end up here. sweet.)
1459 endif
1460 VBOX_WITH_DOCS=
1461endif
1462
1463ifndef VBOX_WITH_QTGUI
1464 VBOX_WITH_KCHMVIEWER=
1465endif
1466
1467ifdef VBOX_WITH_EXTPACK_PUEL_BUILD
1468 VBOX_WITH_EXTPACK_PUEL = 1
1469endif
1470
1471ifdef VBOX_WITH_TESTSUITE
1472 $(warning VBOX_WITH_TESTSUITE was renamed to VBOX_WITH_VALIDATIONKIT)
1473 VBOX_WITH_VALIDATIONKIT = $(VBOX_WITH_TESTSUITE)
1474endif
1475
1476
1477#
1478# Derived indicators.
1479#
1480
1481## Indicates that we need the extpack openssl libs.
1482if defined(VBOX_WITH_EXTPACK_PUEL_BUILD) \
1483 && ( !defined(VRDP_WITH_IPRT_CRYPTO) \
1484 || !defined(VRDP_WITH_IPRT_SSL) \
1485 || !defined(VD_WITH_IPRT_CRYPTO) )
1486 VBOX_NEED_EXTPACK_OPENSSL = 1
1487else
1488 VBOX_NEED_EXTPACK_OPENSSL =
1489endif
1490
1491
1492#
1493# Mark OSE builds clearly, helps figuring out limitations more easily.
1494#
1495ifdef VBOX_OSE
1496# This can be overridden (e.g. in LocalConfig.kmk) by whoever publishes a set
1497# of VirtualBox binaries. We request though that you always use something that
1498# clearly identifies your build and makes it clear that it is not one done by
1499# the VirtualBox team.
1500 VBOX_BUILD_PUBLISHER ?= _OSE
1501endif
1502
1503# Keep in sync with G_virtualBoxPackage in glue-jaxws.xsl and glue-java.xsl
1504# Changed with every new version, so beware!
1505if $(VBOX_VERSION_BUILD) < 51
1506 VBOX_API_VERSION = $(VBOX_VERSION_MAJOR)_$(VBOX_VERSION_MINOR)
1507else
1508 VBOX_API_VERSION = $(VBOX_VERSION_MAJOR)_$(expr $(VBOX_VERSION_MINOR) + 1)
1509endif
1510VBOX_API_SUFFIX = _$(VBOX_API_VERSION)
1511VBOX_JAVA_PACKAGE = org.virtualbox$(VBOX_API_SUFFIX)
1512
1513#
1514# Derived / helper config indicators. Not configurable.
1515#
1516
1517# Use the OpenGL module in qt when the video hardware acceleration feature
1518# is enabled.
1519if defined(VBOX_WITH_VIDEOHWACCEL) && defined(VBOX_WITH_QTGUI)
1520 VBOX_GUI_USE_QGL = 1
1521else
1522 VBOX_GUI_USE_QGL=
1523endif
1524
1525# Collection macro mainly for deciding whether VBoxDTrace needs shipping.
1526VBOX_WITH_DTRACE := $(if-expr defined(VBOX_WITH_DTRACE_R0) || defined(VBOX_WITH_DTRACE_R0DRV) \
1527 || defined(VBOX_WITH_DTRACE_R3) || defined(VBOX_WITH_DTRACE_RC),1,)
1528
1529# kSubmit / kWorker is only available on windows.
1530ifdef VBOX_USE_KSUBMIT
1531 ifeq ($(KBUILD_HOST),win)
1532 TOOL_VCC142AMD64_USE_KSUBMIT := 1
1533 TOOL_VCC142X86_USE_KSUBMIT := 1
1534# TOOL_VCC120AMD64_USE_KSUBMIT := 1
1535# TOOL_VCC120X86_USE_KSUBMIT := 1
1536 TOOL_VCC100AMD64_USE_KSUBMIT := 1
1537 TOOL_VCC100X86_USE_KSUBMIT := 1
1538 TOOL_QT5_USE_KSUBMIT := 1
1539 TOOL_OPENWATCOM_USE_KSUBMIT := 1
1540 TOOL_YASM_USE_KSUBMIT := 1
1541 TOOL_NASM_USE_KSUBMIT := 1
1542 TOOL_VBoxNasm_USE_KSUBMIT := 1
1543 else
1544 VBOX_USE_KSUBMIT :=
1545 endif
1546endif
1547
1548#
1549# Image and object format config.
1550#
1551if1of ($(KBUILD_TARGET), freebsd haiku linux netbsd openbsd solaris)
1552 VBOX_LDR_FMT = elf
1553endif
1554ifeq ($(KBUILD_TARGET),darwin)
1555 VBOX_LDR_FMT = macho
1556endif
1557ifeq ($(KBUILD_TARGET),os2)
1558 VBOX_LDR_FMT = lx
1559 VBOX_LDR_FMT32 = lx
1560 VBOX_LDR_FMT64 = elf
1561 DONT_USE_YASM = 1 # yasm doesn't implement omf yet.
1562endif
1563ifeq ($(KBUILD_TARGET),win)
1564 VBOX_LDR_FMT = pe
1565endif
1566VBOX_LDR_FMT32 ?= $(VBOX_LDR_FMT)
1567VBOX_LDR_FMT64 ?= $(VBOX_LDR_FMT)
1568
1569#
1570# Assembler setup.
1571#
1572# This is a bit complicated since we have to support two different assmblers
1573# (yasm/nasm) and possibly two different formats (32-bit/64-bit).
1574#
1575if1of ($(KBUILD_TARGET_ARCH), amd64 x86)
1576 ifeq ($(VBOX_LDR_FMT),elf)
1577 ifeq ($(KBUILD_TARGET_ARCH),x86)
1578VBOX_ASFLAGS_FMT = -f elf32 -DASM_FORMAT_ELF
1579 else
1580VBOX_ASFLAGS_FMT = -f elf64 -DASM_FORMAT_ELF
1581 endif
1582VBOX_ASFLAGS_DBFINFO = -g dwarf2
1583 endif
1584 ifeq ($(VBOX_LDR_FMT),lx)
1585VBOX_ASFLAGS_FMT = -f obj -DASM_FORMAT_OMF
1586VBOX_ASFLAGS_DBFINFO = -g stabs
1587 endif
1588 ifeq ($(VBOX_LDR_FMT),macho)
1589 ifeq ($(KBUILD_TARGET_ARCH),x86)
1590VBOX_ASFLAGS_FMT = -f macho32 -DASM_FORMAT_MACHO
1591 else
1592VBOX_ASFLAGS_FMT = -f macho64 -DASM_FORMAT_MACHO
1593 endif
1594VBOX_ASFLAGS_DBFINFO = -g dwarf2
1595 endif
1596 ifeq ($(VBOX_LDR_FMT),pe)
1597 ifeq ($(KBUILD_TARGET_ARCH),x86)
1598VBOX_ASFLAGS_FMT = -f win32 -DASM_FORMAT_PE
1599 else
1600VBOX_ASFLAGS_FMT = -f win64 -DASM_FORMAT_PE
1601 endif
1602VBOX_ASFLAGS_DBFINFO = -g cv8
1603 endif
1604 ifndef VBOX_ASFLAGS_FMT
1605 $(error VBOX_ASFLAGS_FMT is not defined. VBOX_LDR_FMT=$(VBOX_LDR_FMT))
1606 endif
1607
1608 ifeq ($(VBOX_LDR_FMT32),elf)
1609VBOX_ASFLAGS_FMT32 = -f elf32 -DASM_FORMAT_ELF
1610VBOX_ASFLAGS_DBFINFO32 = -g dwarf2
1611 endif
1612 ifeq ($(VBOX_LDR_FMT32),lx)
1613VBOX_ASFLAGS_FMT32 = -f obj -DASM_FORMAT_OMF
1614VBOX_ASFLAGS_DBFINFO32 = -g stabs
1615 endif
1616 ifeq ($(VBOX_LDR_FMT32),macho)
1617VBOX_ASFLAGS_FMT32 = -f macho32 -DASM_FORMAT_MACHO
1618VBOX_ASFLAGS_DBFINFO32 = -g dwarf2
1619 endif
1620 ifeq ($(VBOX_LDR_FMT32),pe)
1621VBOX_ASFLAGS_FMT32 = -f win32 -DASM_FORMAT_PE
1622VBOX_ASFLAGS_DBFINFO32 = -g cv8
1623 endif
1624 ifndef VBOX_ASFLAGS_FMT32
1625 $(error VBOX_ASFLAGS_FMT32 is not defined. VBOX_LDR_FMT32=$(VBOX_LDR_FMT32))
1626 endif
1627
1628 ifeq ($(VBOX_LDR_FMT64),elf)
1629VBOX_ASFLAGS_FMT64 = -f elf64 -DASM_FORMAT_ELF
1630VBOX_ASFLAGS_DBFINFO64 = -g dwarf2
1631 endif
1632 ifeq ($(VBOX_LDR_FMT64),macho)
1633VBOX_ASFLAGS_FMT64 = -f macho64 -DASM_FORMAT_MACHO
1634VBOX_ASFLAGS_DBFINFO64 = -g dwarf2
1635 endif
1636 ifeq ($(VBOX_LDR_FMT64),pe)
1637VBOX_ASFLAGS_FMT64 = -f win64 -DASM_FORMAT_PE
1638VBOX_ASFLAGS_DBFINFO64 = -g cv8
1639 endif
1640 ifndef VBOX_ASFLAGS_FMT64
1641 $(error VBOX_ASFLAGS_FMT64 is not defined. VBOX_LDR_FMT64=$(VBOX_LDR_FMT64))
1642 endif
1643
1644 ifndef DONT_USE_YASM
1645VBOX_ASTOOL = YASM
1646VBOX_LDR_FMT_2_YASM_DBGINFO.elf = -g dwarf2
1647VBOX_LDR_FMT_2_YASM_DBGINFO.lx = -g stabs
1648VBOX_LDR_FMT_2_YASM_DBGINFO.macho =
1649VBOX_LDR_FMT_2_YASM_DBGINFO.pe = -g cv8
1650VBOX_ASFLAGS = $(VBOX_ASFLAGS_FMT) -D__YASM__ -Worphan-labels $(VBOX_YASM_Wno-segreg-in-64bit) $(VBOX_LDR_FMT_2_YASM_DBGINFO.$(VBOX_LDR_FMT))
1651VBOX_ASFLAGS32 = $(VBOX_ASFLAGS_FMT32) -D__YASM__ -Worphan-labels $(VBOX_YASM_Wno-segreg-in-64bit) $(VBOX_LDR_FMT_2_YASM_DBGINFO.$(VBOX_LDR_FMT32))
1652VBOX_ASFLAGS64 = $(VBOX_ASFLAGS_FMT64) -D__YASM__ -Worphan-labels $(VBOX_YASM_Wno-segreg-in-64bit) $(VBOX_LDR_FMT_2_YASM_DBGINFO.$(VBOX_LDR_FMT64))
1653 else
1654VBOX_ASTOOL = NASM
1655VBOX_ASFLAGS = $(subst elf32,elf,$(VBOX_ASFLAGS_FMT)) -D__NASM__ -w+orphan-labels -g
1656VBOX_ASFLAGS32 = $(subst elf32,elf,$(VBOX_ASFLAGS_FMT32)) -D__NASM__ -w+orphan-labels -g
1657VBOX_ASFLAGS64 = $(VBOX_ASFLAGS_FMT64) -D__NASM__ -w+orphan-labels -g
1658 endif
1659else # ifn1of ($(KBUILD_TARGET_ARCH), amd64 x86)
1660VBOX_ASTOOL =# No tool, just use the compiler one.
1661VBOX_LDR_FMT_2_FLAGS.elf := -DASM_FORMAT_ELF
1662VBOX_LDR_FMT_2_FLAGS.macho := -DASM_FORMAT_MACHO
1663VBOX_LDR_FMT_2_FLAGS.pe := -DASM_FORMAT_PE
1664VBOX_ASFLAGS := -g $(VBOX_LDR_FMT_2_FLAGS.$(VBOX_LDR_FMT))
1665VBOX_ASFLAGS32 := -g $(VBOX_LDR_FMT_2_FLAGS.$(VBOX_LDR_FMT32))
1666VBOX_ASFLAGS64 := -g $(VBOX_LDR_FMT_2_FLAGS.$(VBOX_LDR_FMT64))
1667endif # ifn1of ($(KBUILD_TARGET_ARCH), amd64 x86)
1668
1669#
1670# Windows only has mingw handy. On *nix we have to deal with cross compiling
1671# 32-bit targets on 64-bit platforms, meaning we'll be using gcc32/g++32.
1672# In the latter case we'll also have to disable all the all the R0 driver related stuff.
1673#
1674ifndef VBOX_GCC_TOOL
1675 ifeq ($(KBUILD_TARGET),win)
1676 ifeq ($(KBUILD_TARGET_ARCH),x86)
1677 VBOX_GCC_TOOL := MINGW32
1678 TOOL_MINGW32_CFLAGS := $(UNDEFINED) # override -g
1679 else
1680 VBOX_GCC_TOOL := MINGWW64
1681 endif
1682 else ifeq ($(KBUILD_TARGET),os2)
1683 VBOX_GCC_TOOL := GXX3OMF
1684 else ifeq ($(KBUILD_TARGET),darwin)
1685 ifdef VBOX_WITH_EVEN_NEWER_XCODE
1686 VBOX_GCC_TOOL := CLANGXXMACHO
1687 DARWINCMN_TOOLCHAIN_DIRS_IGNORE_DEVTOOLS = 1# Use the system toolchains, not anything from tools/darwin.*.
1688 else ifdef VBOX_WITH_NEW_XCODE
1689 VBOX_GCC_TOOL := VBoxXcode62
1690 else
1691 VBOX_GCC_TOOL := GXX4MACHO
1692 endif
1693 else ifeq ($(KBUILD_TARGET),haiku)
1694 # Haiku shouldn't pass '-r' to the linker by default
1695 VBOX_GCC_TOOL := GXX3PLAIN
1696 else ifeq ($(KBUILD_TARGET),solaris)
1697 VBOX_GCC_TOOL := GXX3PLAIN
1698 VBOX_GCC32_TOOL := GCC3PLAIN
1699 ifeq ($(KBUILD_HOST),solaris)
1700 TOOL_GXX3PLAIN_LD_SYSMOD ?= /usr/ccs/bin/ld
1701 endif
1702 else
1703 VBOX_GCC_TOOL := GXX3
1704 ifeq ($(KBUILD_TARGET_ARCH).$(KBUILD_HOST_ARCH),x86.amd64) ## @todo mixing target/host here!
1705 VBOX_GCC_TOOL := GXX32
1706 VBOX_WITH_VBOXDRV=
1707 else ifeq ($(KBUILD_TARGET_ARCH).$(KBUILD_HOST_ARCH),amd64.x86)
1708 VBOX_GCC_TOOL := GXX64
1709 VBOX_WITH_VBOXDRV=
1710 endif
1711 endif
1712endif
1713ifndef VBOX_GCC32_TOOL
1714 ifeq ($(KBUILD_TARGET_ARCH),x86)
1715 VBOX_GCC32_TOOL := $(VBOX_GCC_TOOL)
1716 else ifeq ($(KBUILD_TARGET),win)
1717 VBOX_GCC32_TOOL := MINGW32
1718 else
1719 VBOX_GCC32_TOOL := GCC32
1720 endif
1721endif
1722
1723#
1724# Decide which Visual C++ compiler version we're using by default.
1725#
1726ifndef VBOX_VCC_TOOL_STEM
1727 ifdef VBOX_WITH_NEW_VCC
1728 VBOX_VCC_TOOL_STEM := VCC142
1729 else
1730 VBOX_VCC_TOOL_STEM := VCC100
1731 endif
1732else ifn1of ($(VBOX_VCC_TOOL_STEM), VCC100 VCC110 VCC120 VCC140 VCC141 VCC142)
1733 $(error VBox: VBOX_VCC_TOOL_STEM='$(VBOX_VCC_TOOL_STEM)' is not supported, only VCC100, VCC110, VCC120, VCC140, VCC141, VCC142 are)
1734endif
1735ifndef VBOX_VCC_TOOL
1736 VBOX_VCC_TOOL := $(VBOX_VCC_TOOL_STEM)$(toupper $(KBUILD_TARGET_ARCH))
1737endif
1738
1739#
1740# Decide which Visual C++ compiler version we're using for newer stuff.
1741#
1742ifndef VBOX_NEWER_VCC_TOOL_STEM
1743 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC120"
1744 VBOX_NEWER_VCC_TOOL_STEM := $(VBOX_VCC_TOOL_STEM)
1745 else
1746 VBOX_NEWER_VCC_TOOL_STEM := VCC120
1747 endif
1748else ifn1of ($(VBOX_NEWER_VCC_TOOL_STEM), VCC120 VCC140 VCC141 VCC142)
1749 $(error VBox: VBOX_NEWER_VCC_TOOL_STEM='$(VBOX_NEWER_VCC_TOOL_STEM)' is not supported)
1750endif
1751ifndef VBOX_NEWER_VCC_TOOL
1752 VBOX_NEWER_VCC_TOOL := $(VBOX_NEWER_VCC_TOOL_STEM)$(toupper $(KBUILD_TARGET_ARCH))
1753endif
1754
1755# Temporary measure while kBuild / tools updates their define quoting.
1756ifdef KMK_WITH_QUOTING
1757 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140" && "$(KBUILD_TARGET)" == "win"
1758 VBOX_WITH_AUTOMATIC_DEFS_QUOTING := 1
1759 endif
1760endif
1761
1762
1763#
1764# Default tool nonsense.
1765#
1766## @todo Remove the default tool crap here!
1767TOOL = $(VBOX_GCC_TOOL)
1768TOOL.win.x86 = $(VBOX_VCC_TOOL_STEM)X86
1769TOOL.win.amd64 = $(VBOX_VCC_TOOL_STEM)AMD64
1770ASTOOL := $(VBOX_ASTOOL)
1771
1772
1773#
1774# Setup the global defines and includes.
1775#
1776# Note! The __SOMETHING__ #defines are deprecated as they violate the C/C++ specs.
1777#
1778INCS += $(PATH_ROOT)/include $(PATH_OUT)
1779DEFS += VBOX
1780DEFS.debug := DEBUG DEBUG_$(subst $(subst _, ,_),_,$(USERNAME)) DEBUG_USERNAME=$(subst $(subst _, ,_),_,$(USERNAME))
1781DEFS.dbgopt = $(DEFS.debug)
1782DEFS.profile = VBOX_WITH_STATISTICS
1783DEFS.strict = RT_STRICT VBOX_STRICT
1784DEFS.asan = RT_STRICT VBOX_STRICT
1785DEFS.x86 = RT_ARCH_X86 __X86__
1786DEFS.amd64 = RT_ARCH_AMD64 __AMD64__
1787DEFS.sparc32 = RT_ARCH_SPARC
1788DEFS.sparc64 = RT_ARCH_SPARC64
1789DEFS.darwin = RT_OS_DARWIN __DARWIN__
1790DEFS.freebsd = RT_OS_FREEBSD __FREEBSD__
1791DEFS.haiku = RT_OS_HAIKU
1792DEFS.linux = RT_OS_LINUX _FILE_OFFSET_BITS=64
1793DEFS.netbsd = RT_OS_NETBSD
1794DEFS.openbsd = RT_OS_OPENBSD
1795DEFS.os2 = RT_OS_OS2 __OS2__
1796DEFS.os-agnostic = RT_OS_AGNOSTIC
1797DEFS.solaris = RT_OS_SOLARIS _FILE_OFFSET_BITS=64
1798DEFS.win = RT_OS_WINDOWS __WIN__
1799DEFS.win.x86 = __WIN32__
1800DEFS.win.amd64 = __WIN64__
1801# optional defines (use environment or make commandline)
1802ifdef VBOX_WITH_STATISTICS
1803 DEFS += VBOX_WITH_STATISTICS
1804endif
1805ifdef VBOX_STRICT
1806 DEFS += VBOX_STRICT
1807endif
1808ifdef LOG_ENABLED
1809 DEFS += LOG_ENABLED
1810endif
1811ifdef VBOX_OSE
1812 DEFS += VBOX_OSE
1813endif
1814ifdef VBOX_WITH_64_BITS_GUESTS
1815 DEFS += VBOX_WITH_64_BITS_GUESTS
1816endif
1817ifdef VBOX_WITH_REM
1818 DEFS += VBOX_WITH_REM
1819endif
1820ifdef VBOX_WITH_RAW_MODE
1821 DEFS += VBOX_WITH_RAW_MODE
1822endif
1823
1824# Don't flood CDEFS, old MASMs doesn't like too many defines.
1825ifdef VBOX_WITH_DEBUGGER
1826 CDEFS += VBOX_WITH_DEBUGGER
1827endif
1828ifdef VBOX_WITH_HARDENING
1829 CDEFS += VBOX_WITH_HARDENING
1830endif
1831if defined(VBOX_WITH_STRICT_LOCKS) && ($(KBUILD_TYPE) == "debug" || $(KBUILD_TYPE) == "strict" || $(KBUILD_TYPE) == "asan")
1832 CDEFS += RT_LOCK_STRICT RT_LOCK_STRICT_ORDER
1833endif
1834ifdef VBOX_WITH_EF_WRAPS
1835 CDEFS += RTMEM_WRAP_TO_EF_APIS RTMEM_WRAP_SOME_NEW_AND_DELETE_TO_EF
1836endif
1837
1838# Quoted strings should not be passed to the assemblers since they might not
1839# subscribe to C preprocessing semantics.
1840ifdef VBOX_PATH_APP_PRIVATE
1841 ifdef VBOX_WITH_AUTOMATIC_DEFS_QUOTING
1842 CDEFS += RTPATH_APP_PRIVATE="$(VBOX_PATH_APP_PRIVATE)"
1843 else
1844 CDEFS += RTPATH_APP_PRIVATE=\"$(VBOX_PATH_APP_PRIVATE)\"
1845 endif
1846endif
1847ifdef VBOX_PATH_APP_PRIVATE_ARCH
1848 ifdef VBOX_WITH_AUTOMATIC_DEFS_QUOTING
1849 CDEFS += RTPATH_APP_PRIVATE_ARCH="$(VBOX_PATH_APP_PRIVATE_ARCH)"
1850 else
1851 CDEFS += RTPATH_APP_PRIVATE_ARCH=\"$(VBOX_PATH_APP_PRIVATE_ARCH)\"
1852 endif
1853endif
1854ifdef VBOX_PATH_APP_PRIVATE_ARCH_TOP
1855 ifdef VBOX_WITH_AUTOMATIC_DEFS_QUOTING
1856 CDEFS += RTPATH_APP_PRIVATE_ARCH_TOP="$(VBOX_PATH_APP_PRIVATE_ARCH_TOP)"
1857 else
1858 CDEFS += RTPATH_APP_PRIVATE_ARCH_TOP=\"$(VBOX_PATH_APP_PRIVATE_ARCH_TOP)\"
1859 endif
1860endif
1861ifdef VBOX_PATH_SHARED_LIBS
1862 ifdef VBOX_WITH_AUTOMATIC_DEFS_QUOTING
1863 CDEFS += RTPATH_SHARED_LIBS="$(VBOX_PATH_SHARED_LIBS)"
1864 else
1865 CDEFS += RTPATH_SHARED_LIBS=\"$(VBOX_PATH_SHARED_LIBS)\"
1866 endif
1867endif
1868ifdef VBOX_PATH_APP_DOCS
1869 ifdef VBOX_WITH_AUTOMATIC_DEFS_QUOTING
1870 CDEFS += RTPATH_APP_DOCS="$(VBOX_PATH_APP_DOCS)"
1871 else
1872 CDEFS += RTPATH_APP_DOCS=\"$(VBOX_PATH_APP_DOCS)\"
1873 endif
1874endif
1875CXXDEFS += $(CDEFS)
1876PCHDEFS += $(CDEFS)
1877OBJCDEFS += $(CDEFS)
1878
1879USES += dtrace
1880USES.win += vboximportchecker
1881
1882
1883#
1884# Decide which Windows DDK to use by default.
1885#
1886if1of ($(VBOX_VCC_TOOL_STEM), VCC110)
1887 VBOX_WINDDK ?= WINDDK80
1888else
1889 VBOX_WINDDK ?= WINDDK71
1890endif
1891VBOX_WINDDK_WLH ?= $(VBOX_WINDDK)WLH
1892
1893VBOX_WINDDK_GST ?= $(VBOX_WINDDK)
1894VBOX_WINDDK_GST_W8 ?= WINDDK80W8
1895VBOX_WINDDK_GST_W7 ?= $(VBOX_WINDDK_GST)W7
1896VBOX_WINDDK_GST_WLH ?= $(VBOX_WINDDK_GST)WLH
1897VBOX_WINDDK_GST_W2K3 ?= WINDDK71WNET
1898ifeq ($(KBUILD_TARGET_ARCH),x86)
1899 VBOX_WINDDK_GST_WXP ?= WINDDK71WXP
1900 VBOX_WINDDK_GST_W2K ?= $(VBOX_WINDDK_GST_WXP)
1901 VBOX_WINDDK_GST_NT4 ?= $(VBOX_WINDDK_GST_WXP)
1902else
1903 VBOX_WINDDK_GST_WXP ?= $(VBOX_WINDDK_GST_W2K3)
1904 VBOX_WINDDK_GST_W2K ?= $(VBOX_WINDDK_GST_W2K3)
1905 VBOX_WINDDK_GST_NT4 ?= $(VBOX_WINDDK_GST_W2K3)
1906endif
1907
1908
1909#
1910# Decide which Windows SDK to use by default.
1911#
1912if1of ($(VBOX_VCC_TOOL_STEM), VCC110)
1913 VBOX_WINPSDK ?= WINPSDK80
1914else
1915 VBOX_WINPSDK ?= WINPSDK71
1916endif
1917VBOX_WINPSDK_GST ?= $(VBOX_WINPSDK)
1918VBOX_WINPSDK_GST_W8 ?= WINPSDK80
1919VBOX_WINPSDK_GST_W7 ?= $(VBOX_WINPSDK_GST)
1920VBOX_WINPSDK_GST_WLH ?= $(VBOX_WINPSDK_GST)
1921VBOX_WINPSDK_GST_WXP ?= $(VBOX_WINPSDK_GST)
1922ifeq ($(KBUILD_TARGET_ARCH),x86)
1923 VBOX_WINPSDK_GST_W2K ?= $(VBOX_WINPSDK_GST)
1924 VBOX_WINPSDK_GST_NT4 ?= $(VBOX_WINPSDK_GST)
1925else
1926 VBOX_WINPSDK_GST_W2K ?= $(VBOX_WINPSDK_GST_WXP)
1927 VBOX_WINPSDK_GST_NT4 ?= $(VBOX_WINPSDK_GST_WXP)
1928endif
1929
1930
1931#
1932# ARCH_BITS_DEFS.
1933#
1934if1of ($(KBUILD_TARGET_ARCH),amd64 sparc64 arm64)
1935 VBOX_HC_ARCH_BITS := 64
1936 ARCH_BITS_DEFS := HC_ARCH_BITS=64
1937else if1of ($(KBUILD_TARGET_ARCH),x86 sparc32)
1938 VBOX_HC_ARCH_BITS := 32
1939 ARCH_BITS_DEFS := HC_ARCH_BITS=32
1940else
1941 $(error VBox: KBUILD_TARGET_ARCH=$(KBUILD_TARGET_ARCH))
1942endif
1943
1944ifdef VBOX_WITH_64_BITS_GUESTS
1945 VBOX_GC_ARCH_BITS_DEFS := GC_ARCH_BITS=64
1946else
1947 VBOX_GC_ARCH_BITS_DEFS := GC_ARCH_BITS=32
1948endif
1949ARCH_BITS_DEFS += $(VBOX_GC_ARCH_BITS_DEFS)
1950
1951#
1952# Add the output dir(s) to the dynamic loader search path.
1953#
1954if1of ($(KBUILD_HOST), freebsd linux netbsd openbsd solaris)
1955 export LD_LIBRARY_PATH:=$(PATH_STAGE_BIN):$(PATH_STAGE_LIB):$(LD_LIBRARY_PATH)
1956endif
1957ifeq ($(KBUILD_HOST),haiku)
1958 export LIBRARY_PATH:=$(PATH_STAGE_BIN):$(PATH_STAGE_LIB):$(LIBRARY_PATH)
1959endif
1960ifeq ($(KBUILD_HOST),os2)
1961 #fixme! export BEGINLIBPATH:=$(PATH_STAGE_BIN);$(PATH_STAGE_LIB);$(BEGINLIBPATH)
1962endif
1963ifeq ($(KBUILD_HOST),win)
1964 # This check is a bit hacky, but avoids problems with PATH being changed
1965 # again when the makefiles are reread because some automatically generated
1966 # makefile has been modified.
1967 ifeq ($(findstring $(PATH_STAGE_BIN);$(PATH_STAGE_LIB);,$(PATH)),)
1968 export PATH:=$(PATH_STAGE_BIN);$(PATH_STAGE_LIB);$(PATH)
1969 endif
1970endif
1971
1972#
1973# Common libraries and tools.
1974#
1975ifeq ($(KBUILD_TARGET),darwin)
1976 LIB_RUNTIME = $(PATH_STAGE_BIN)/VBoxRT.dylib
1977 LIB_RUNTIME_EF = #$(PATH_STAGE_LIB)/RuntimeEFCPP.a
1978 VBOX_LIB_RUNTIME_X86 = $(PATH_STAGE_BIN)/VBoxRT-x86.dylib
1979 LIB_KPROFILE = $(PATH_STAGE_BIN)/kPrf2.dylib
1980 LIB_VMM = $(PATH_STAGE_BIN)/VBoxVMM.dylib
1981 LIB_VMMRC = $(PATH_STAGE_BIN)/VMMRC.rc
1982 LIB_REM = $(PATH_STAGE_LIB)/VBoxREM.dylib
1983 LIB_XPCOM = $(PATH_STAGE_BIN)/VBoxXPCOM.dylib
1984 LIB_XPCOM_IMP = $(PATH_STAGE_LIB)/VBoxXPCOMImp.dylib
1985 VBOX_LIB_XPCOM_X86 = $(PATH_STAGE_BIN)/VBoxXPCOM-x86.dylib
1986 LIB_DDU = $(PATH_STAGE_BIN)/VBoxDDU.dylib
1987endif
1988if1of ($(KBUILD_TARGET), freebsd haiku linux netbsd openbsd solaris)
1989 LIB_RUNTIME = $(PATH_STAGE_BIN)/VBoxRT.so
1990 LIB_RUNTIME_EF = $(PATH_STAGE_LIB)/RuntimeEFCPP.a
1991 VBOX_LIB_RUNTIME_X86 = $(PATH_STAGE_BIN)/VBoxRT-x86.so
1992 LIB_KPROFILE = $(PATH_STAGE_BIN)/kPrf2.so
1993 LIB_VMM = $(PATH_STAGE_BIN)/VBoxVMM.so
1994 LIB_VMMRC = $(PATH_STAGE_BIN)/VMMRC.rc
1995 LIB_REM = $(PATH_STAGE_LIB)/VBoxREM.so
1996 LIB_XPCOM = $(PATH_STAGE_BIN)/VBoxXPCOM.so
1997 LIB_XPCOM_IMP = $(PATH_STAGE_LIB)/VBoxXPCOMImp.so
1998 VBOX_LIB_XPCOM_X86 = $(PATH_STAGE_BIN)/VBoxXPCOM-x86.so
1999 LIB_DDU = $(PATH_STAGE_BIN)/VBoxDDU.so
2000endif
2001ifeq ($(KBUILD_TARGET),os2)
2002 LIB_RUNTIME = $(PATH_STAGE_BIN)/VBoxRT.dll
2003 LIB_RUNTIME_EF = #$(PATH_STAGE_LIB)/RuntimeEFCPP.a
2004 VBOX_LIB_RUNTIME_X86 = $(PATH_STAGE_BIN)/VBoxRT-x86.dll
2005 LIB_KPROFILE = $(PATH_STAGE_BIN)/kPrf2.dll
2006 LIB_VMM = $(PATH_STAGE_BIN)/VBoxVMM.dll
2007 LIB_VMMRC = $(PATH_STAGE_LIB)/VMMRCImp.lib
2008 LIB_REM = $(PATH_STAGE_LIB)/VBoxREMImp.lib
2009 LIB_XPCOM = $(PATH_STAGE_BIN)/VBoxXCOM.dll
2010 LIB_XPCOM_IMP = $(PATH_STAGE_LIB)/VBoxXPCOMImp.lib
2011 VBOX_LIB_XPCOM_X86 = $(PATH_STAGE_BIN)/VBoxXPCOM-x86.dll
2012 LIB_DDU = $(PATH_STAGE_BIN)/VBoxDDU.dll
2013 VBOX_OBJ_SYS0 = $(PATH_OBJ)/RuntimeR0/os2/sys0.obj
2014endif
2015ifeq ($(KBUILD_TARGET),win)
2016 LIB_RUNTIME = $(PATH_STAGE_LIB)/VBoxRT.lib
2017 LIB_RUNTIME_EF = #$(PATH_STAGE_LIB)/RuntimeEFCPP.lib
2018 VBOX_LIB_RUNTIME_X86 = $(PATH_STAGE_LIB)/VBoxRT-x86.lib
2019 LIB_KPROFILE = $(PATH_STAGE_LIB)/kPrf2.lib
2020 LIB_VMM = $(PATH_STAGE_LIB)/VBoxVMM.lib
2021 LIB_VMMRC = $(PATH_OBJ)/VMMRC/VMMRC.lib
2022 LIB_REM = $(PATH_STAGE_LIB)/VBoxREMImp.lib
2023 LIB_XPCOM =
2024 LIB_XPCOM_IMP =
2025 VBOX_LIB_XPCOM_X86 =
2026 LIB_DDU = $(PATH_STAGE_LIB)/VBoxDDU.lib
2027endif
2028if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), win.amd64 linux.amd64)
2029 VBOX_LIB_VMM_LAZY = $(PATH_STAGE_LIB)/VMMR3LazyImp$(VBOX_SUFF_LIB)
2030else if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), darwin.arm64)
2031 VBOX_LIB_VMM_LAZY = $(PATH_STAGE_LIB)/VMMR3Imp.dylib
2032else
2033 VBOX_LIB_VMM_LAZY = $(LIB_VMM)
2034endif
2035ifn1of ($(KBUILD_TARGET_ARCH), $(VBOX_SUPPORTED_HOST_ARCHS)) # Hack to build a couple of extpack things that thing they need the VMM lib.
2036 LIB_VMM :=
2037 LIB_VMMRC :=
2038 VBOX_LIB_VMM_LAZY :=
2039endif
2040VBOX_LIB_SUPHARDENED = $(PATH_STAGE_LIB)/SUPR3HardenedStatic$(VBOX_SUFF_LIB)
2041VBOX_LIB_RUNTIME_STATIC = $(PATH_STAGE_LIB)/RuntimeR3$(VBOX_SUFF_LIB)
2042
2043ifndef VBOX_WITH_REM
2044 LIB_REM :=
2045endif
2046
2047# Python
2048ifndef VBOX_BLD_PYTHON
2049 if1of ($(KBUILD_HOST), win)
2050 VBOX_BLD_PYTHON := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS)/win.x86/python/v*/python$(HOSTSUFF_EXE))) \
2051 python-not-found.exe)
2052 else ifndef VBOX_WITH_PYTHON2_PREFERENCE
2053 VBOX_BLD_PYTHON := $(firstword \
2054 $(which python3$(HOSTSUFF_EXE)) \
2055 $(which python3.10$(HOSTSUFF_EXE)) \
2056 $(which python3.9$(HOSTSUFF_EXE)) \
2057 $(which python3.8$(HOSTSUFF_EXE)) \
2058 $(which python3.7$(HOSTSUFF_EXE)) \
2059 $(which python3.6$(HOSTSUFF_EXE)) \
2060 $(which python3.5$(HOSTSUFF_EXE)) \
2061 $(which python3.4$(HOSTSUFF_EXE)) \
2062 $(which python2.7$(HOSTSUFF_EXE)) \
2063 $(which python$(HOSTSUFF_EXE)) \
2064 $(which python2.6$(HOSTSUFF_EXE)) \
2065 python-not-found$(HOSTSUFF_EXE) )
2066 else
2067 VBOX_BLD_PYTHON := $(firstword \
2068 $(which python2.7$(HOSTSUFF_EXE)) \
2069 $(which python2.6$(HOSTSUFF_EXE)) \
2070 $(which python$(HOSTSUFF_EXE)) \
2071 $(which python3$(HOSTSUFF_EXE)) \
2072 python-not-found$(HOSTSUFF_EXE) )
2073 endif
2074endif
2075## For running python unittests in the validation kit.
2076VBOX_UNITTEST_PYTHON ?= $(VBOX_BLD_PYTHON)
2077
2078#
2079# pylint setup, see https://www.pylint.org/.
2080#
2081# Disabled:
2082# W0301 - Unnecessary semicolon.
2083# W0511 - TODO/XXX/FIXME/+++.
2084# W0603 - Using the global statement.
2085# W0702 - No exception type(s) specified.
2086# W0703 - Catch "Exception".
2087# I0011 - Locally disabling XXXXX.
2088# C0321 - More than one statement on a single line.
2089# R0201 - Method could be a function.
2090# C0326 - ????
2091# W0123 - ????
2092# C0330:bad-continuation - Wrong continued indentation (add X spaces).
2093# * Triggering on perfectly legal comments in array initializers and stuff.
2094# C0413:wrong-import-position - Import "YYYYY XXXXX" should be placed at the top of the module.
2095# * False positives due to __copyright__, __version__, probably.
2096# E0012:bad-option-value - Bad option value XXXXX.
2097# * Newer pylint doesn't grok older warning disables in sources (e.g. W0142 in db.py). Wonderful!
2098# I0012:locally-enabled - Locally enabling XXXXX.
2099# * We temporarily disable stuff and then renabled it. Very tedious.
2100#
2101# Note! Yes, --max-branchs is a typo, but not by me.
2102#
2103# Note! Users of older pylint release (< 1.0) needs to define
2104# VBOX_WITH_PYLINT_PRE_V1_0 in LocalConfig because they changed the
2105# output arguments in an backwards incompatible way and added more
2106# attribute regex options.
2107#
2108ifndef VBOX_PYLINT
2109 VBOX_PYLINT := $(firstword $(which pylint-2.7) $(which pylint-2.6) $(which pylint2) $(which pylint))
2110 #ifdef VBOX_PYLINT # -- why was this needed. It messes up when using pylint w/ 3.x and building with 2.7.
2111 # VBOX_PYLINT := $(VBOX_BLD_PYTHON) $(VBOX_PYLINT)
2112 #endif
2113endif
2114if !defined(VBOX_WITH_PYLINT) && defined(VBOX_PYLINT)
2115 VBOX_WITH_PYLINT := 1
2116 ifndef VBOX_PYLINT_VERSION
2117 ifdef VBOX_WITH_PYLINT_PRE_V1_0
2118 VBOX_PYLINT_VERSION = 9999
2119 else ifdef VBOX_WITH_PYLINT_V1_2_1_PLUS
2120 VBOX_PYLINT_VERSION = 10201
2121 else ifdef VBOX_WITH_PYLINT_V1_1_PLUS
2122 VBOX_PYLINT_VERSION = 10100
2123 else
2124 VBOX_PYLINT_VERSION = 10000
2125 endif
2126 endif
2127endif
2128VBOX_PYLINT_FLAGS = $(if-expr $(VBOX_PYLINT_VERSION) >= 10500,--reports=n,--report=n) \
2129 $(if-expr $(VBOX_PYLINT_VERSION) >= 10000\
2130 ,--msg-template='{path}:{line}: <{msg_id}>({obj}:{symbol}): {msg}' \
2131 ,--output-format=msvs --include-ids=y) \
2132 --persistent=n \
2133 --rcfile=$(PATH_ROOT)/tools/pylintrc \
2134 --max-line-length=130 \
2135 --max-attributes=32 \
2136 --max-branch$(if-expr $(VBOX_PYLINT_VERSION) >= 10000,e,)s=50 \
2137 --max-statements=100 \
2138 --max-returns=100 \
2139 --max-public-methods=139 \
2140 --max-args=9 \
2141 --max-module-lines=4096 \
2142 --max-locals=32 \
2143 $(if-expr $(VBOX_PYLINT_VERSION) >= 10500,--max-bool-expr=99,) \
2144 --min-public-methods=0 \
2145 --function-rgx='[a-z_][a-zA-Z0-9_]{2,40}$(DOLLAR)' \
2146 --method-rgx='[a-z_][a-zA-Z0-9_]{2,40}$(DOLLAR)' \
2147 --argument-rgx='([a-z_][a-zA-Z0-9_]{2,30}|rc|hr|s|c|ch|cx|cy|cb|fn)$(DOLLAR)' \
2148 --variable-rgx='([a-z_][a-zA-Z0-9_]{2,30}|rc|hr|s|c|ch|cx|cy|cb|fn)$(DOLLAR)' \
2149 --attr-rgx='([a-z_][a-zA-Z0-9_]{2,30}|rc|hr|o)$(DOLLAR)' \
2150 --module-rgx='(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+)|(td[A-Z][a-zA-Z0-9]+)|(t(e|)st(-|)[a-zA-Z0-9]+))$(DOLLAR)' \
2151 --class-rgx='(td|)[A-Z_][a-zA-Z0-9_]+$(DOLLAR)' \
2152 --const-rgx='(g_(k|)[abcdefhmnpilorstu]+[A-Z][a-zA-Z0-9]+|[A-Z_][A-Z0-9_]+|__copyright__|__version__|__file__|__all__)$(DOLLAR)' \
2153 --good-names='i,j,k,t,o,c,e,ch,s,_' \
2154 $(if-expr $(VBOX_PYLINT_VERSION) >= 10000,--class-attribute-rgx='(k[abcdefhmnpilorstu]+[A-Z0-9][a-zA-Z0-9_]{0,32}|[A-Z_][A-Z0-9_]{2,32})',) \
2155 $(if-expr $(VBOX_PYLINT_VERSION) >= 10500,--max-nested-blocks=9,) \
2156 $(if-expr $(VBOX_PYLINT_VERSION) >= 10100,--disable=bad-whitespace,) \
2157 $(if-expr $(VBOX_PYLINT_VERSION) >= 10201,--disable=bad-continuation --disable=eval-used,) \
2158 $(if-expr $(VBOX_PYLINT_VERSION) >= 10201 && $(VBOX_PYLIN_VERSION) < 10500,--disable=bad-option-value,) \
2159 $(if-expr $(VBOX_PYLINT_VERSION) >= 10500,--disable=wrong-import-position --disable=E0012 --disable=locally-enabled,) \
2160 $(if-expr $(VBOX_PYLINT_VERSION) >= 10600,--disable=missing-docstring --disable=trailing-newlines --disable=ungrouped-imports,) \
2161 $(if-expr $(VBOX_PYLINT_VERSION) >= 10800,--disable=redundant-keyword-arg,) \
2162 $(if-expr $(VBOX_PYLINT_VERSION) >= 20000,--disable=useless-object-inheritance --disable=useless-return,) \
2163 $(if-expr $(VBOX_PYLINT_VERSION) >= 20400,--disable=import-outside-toplevel,) \
2164 --disable=unnecessary-semicolon,invalid-encoded-data,global-statement,bare-except,broad-except,multiple-statements,no-self-use,fixme \
2165 --disable=I0011 \
2166 --ignored-classes=testdriver.vboxcon \
2167
2168
2169# Define the macro for win path conversion.
2170ifndef VBOX_ONLY_SDK
2171 if1of (quote,$(KMK_FEATURES))
2172 VBOX_FN_MAKE_WIN_PATH = "$(quote-sh-dq $(subst /,\,$(requote unq, $(1))))"
2173 else
2174 VBOX_FN_MAKE_WIN_PATH = $(subst /,\\,$(1))
2175 endif
2176else
2177 # on Wine Z: is always FS root
2178 VBOX_FN_MAKE_WIN_PATH = $(subst /,\\,$(patsubst /%,Z:/%,$(1)))
2179endif #!VBOX_ONLY_SDK
2180
2181# The kprofile build automagically links with kProfile.
2182ifeq ($(KBUILD_TYPE),kprofile)
2183 LIB_RUNTIME += $(LIB_KPROFILE)
2184endif
2185
2186# Enable C++ electric fence heap. (Warning: will easily run out of virtual memory / kernel stuff on Linux/Windows.)
2187ifdef VBOX_WITH_CPP_EF
2188 LIB_RUNTIME <= $(LIB_RUNTIME_EF)
2189endif
2190
2191# Overridable libraries (unix).
2192LIB_PTHREAD ?= pthread
2193
2194# Xcursor (consider an SDK for this).
2195ifeq ($(VBOX_XCURSOR_LIBS),)
2196 ifeq ($(KBUILD_TARGET),solaris)
2197 VBOX_XCURSOR_LIBS := $(lastword $(wildcard $(KBUILD_DEVTOOLS_TRG)/libXcursor/*/lib/libXcursor.a))
2198 ifneq ($(VBOX_XCURSOR_LIBS),)
2199 VBOX_XCURSOR_INCS := $(patsubst %/lib/libXcursor.a,%/include, $(VBOX_XCURSOR_LIBS))
2200 VBOX_XCURSOR_LIBS += X11 Xrender Xfixes
2201 endif
2202 endif
2203 ifeq ($(VBOX_XCURSOR_LIBS),)
2204 VBOX_XCURSOR_LIBS := Xcursor
2205 endif
2206endif
2207
2208
2209# Intel ASL compiler for ACPI
2210VBOX_IASLCMD ?= $(firstword $(wildcard $(KBUILD_DEVTOOLS_HST)/bin/iasl$(HOSTSUFF_EXE)) iasl$(HOSTSUFF_EXE))
2211
2212# libxslt XSLT processor. (see PATH_TOOL_YASM for explanation why it's temporarily located in bin.)
2213ifeq ($(VBOX_XSLTPROC),)
2214 ifeq ($(KBUILD_HOST),win)
2215 VBOX_XSLTPROC := $(wildcard $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).$(KBUILD_HOST_ARCH)/libxslt/10128/bin/xsltproc.exe)
2216 ifeq ($(VBOX_XSLTPROC),)
2217 VBOX_XSLTPROC := $(KBUILD_DEVTOOLS)/win.x86/bin/xsltproc.exe
2218 endif
2219 else ifeq ($(KBUILD_HOST),os2)
2220 VBOX_XSLTPROC := BEGINLIBPATH="$(KBUILD_DEVTOOLS_HST)/bin;$$BEGINLIBPATH" $(KBUILD_DEVTOOLS_HST)/bin/xsltproc.exe
2221 else ifeq ($(KBUILD_HOST),haiku)
2222 VBOX_XSLTPROC := $(KBUILD_DEVTOOLS)/haiku.x86/bin/xsltproc
2223 else
2224 VBOX_XSLTPROC := xsltproc$(HOSTSUFF_EXE)
2225 endif
2226endif
2227
2228# bin2c (convert binary files into C arrays)
2229VBOX_BIN2C ?= $(PATH_OBJ)/bin2c/bin2c$(HOSTSUFF_EXE)
2230
2231# RTManifest (extension pack manifest utility)
2232VBOX_RTMANIFEST ?= $(PATH_OBJ)/bldRTManifest/bldRTManifest$(HOSTSUFF_EXE)
2233
2234# RTSignTool (certificate extraction tool)
2235VBOX_RTSIGNTOOL ?= $(PATH_OBJ)/bldRTSignTool/bldRTSignTool$(HOSTSUFF_EXE)
2236
2237# RTIsoMaker (our own ISO maker).
2238VBOX_RTISOMAKER ?= $(PATH_OBJ)/bldRTIsoMaker/bldRTIsoMaker$(HOSTSUFF_EXE)
2239
2240# RTLdrCheckImports (checks imports against oldest supported OS version (GAs typically))
2241VBOX_RTLDRCHECKIMPORTS ?= $(PATH_OBJ)/bldRTLdrCheckImports/bldRTLdrCheckImports$(HOSTSUFF_EXE)
2242
2243# VBoxCmp (simple /bin/cmp with more sensible output)
2244VBOX_VBOXCMP ?= $(PATH_OBJ)/VBoxCmp/VBoxCmp$(HOSTSUFF_EXE)
2245
2246# VBoxCPP (special purpose C preprocessor)
2247VBOX_VBOXCPP ?= $(PATH_OBJ)/VBoxCPP/VBoxCPP$(HOSTSUFF_EXE)
2248
2249# VBoxTpG (tracepoint generator)
2250VBOX_VBOXTPG ?= $(PATH_OBJ)/VBoxTpG/VBoxTpG$(HOSTSUFF_EXE)
2251
2252# VBoxPeSetVersion (changes the minimum OS version of an image)
2253VBOX_PE_SET_VERSION ?= $(PATH_OBJ)/VBoxPeSetVersion/VBoxPeSetVersion$(HOSTSUFF_EXE)
2254
2255# Visual C++ EditBin.exe.
2256VBOX_VCC_EDITBIN = $(if $(PATH_TOOL_$(VBOX_VCC_TOOL)_BIN_QSH),$(PATH_TOOL_$(VBOX_VCC_TOOL)_BIN_QSH)/,$(if $(PATH_TOOL_$(VBOX_VCC_TOOL)_BIN),$(PATH_TOOL_$(VBOX_VCC_TOOL)_BIN)/,))editbin.exe /NoLogo
2257
2258# filesplitter (splits java files)
2259VBOX_FILESPLIT ?= $(PATH_OBJ)/filesplitter/filesplitter$(HOSTSUFF_EXE)
2260
2261# biossums (set BIOS checksums)
2262VBOX_BIOSSUMS ?= $(PATH_OBJ)/biossums/biossums$(HOSTSUFF_EXE)
2263
2264# MakeAlternativeSource (for BIOSes)
2265VBOX_MAKE_ALTERNATIVE_SOURCE ?= $(PATH_OBJ)/MakeAlternativeSource/MakeAlternativeSource$(HOSTSUFF_EXE)
2266
2267# VBoxDef2LazyLoad (lazy dynamic library loader assembly generator)
2268VBOX_DEF_2_LAZY_LOAD ?= $(PATH_OBJ)/VBoxDef2LazyLoad/VBoxDef2LazyLoad$(HOSTSUFF_EXE)
2269
2270# VBoxCheckImports (checks what we imports from on windows)
2271VBOX_CHECK_IMPORTS ?= $(PATH_OBJ)/VBoxCheckImports/VBoxCheckImports$(HOSTSUFF_EXE)
2272
2273# VBoxEditCoffLib (symbol name tweaking for VBoxSF on windows)
2274VBOX_EDIT_COFF_LIB ?= $(PATH_OBJ)/VBoxEditCoffLib/VBoxEditCoffLib$(HOSTSUFF_EXE)
2275
2276# GNU tar if present.
2277if1of ($(KBUILD_TARGET), linux os2 win)
2278 VBOX_GTAR ?= tar
2279else if1of ($(KBUILD_TARGET), freebsd netbsd solaris)
2280 VBOX_GTAR ?= gtar
2281endif
2282
2283# zip
2284VBOX_ZIP ?= zip$(HOSTSUFF_EXE)
2285
2286ifeq ($(KBUILD_TARGET),win)
2287 ifeq ($(KBUILD_TARGET_ARCH),x86) # Normally we should test for KBUILD_HOST_ARCH but we only require MINGWW64 for 64-bit _targets_
2288 VBOX_NM ?= $(PATH_TOOL_MINGW32)/bin/nm.exe -p
2289 else
2290 VBOX_NM ?= $(PATH_TOOL_MINGWW64)/bin/nm.exe -p
2291 endif
2292else ifeq ($(KBUILD_HOST),darwin) # Xcode 7.3.1 nm doesn't like -t, and -x behaves very differently. Throwing in -B (bsd) to make sure.
2293 VBOX_NM ?= $(subst $(REDIRECT_INT),$(REDIRECT_EXT),$(TOOL_$(VBOX_GCC_TOOL)_ENV_SETUP) $(PATH_TOOL_$(VBOX_GCC_TOOL)_TOOLCHAIN_BIN_SLASH)nm) -p \
2294 $(if-expr $(VBOX_XCODE_VERSION_MAJOR) > 7 || ($(VBOX_XCODE_VERSION_MAJOR) == 7 && $(VBOX_XCODE_VERSION_MINOR) >= 3),-B,)
2295else
2296 VBOX_NM ?= nm -p -t x
2297endif
2298
2299# Makeself for the linux installers.
2300VBOX_MAKESELF ?= $(KBUILD_DEVTOOLS)/common/makeself/v2.1.5/makeself.sh
2301
2302# Microsoft HTML Help Workshop.
2303VBOX_PATH_HTML_HELP_WORKSHOP ?= $(KBUILD_DEVTOOLS)/win.x86/HTML_Help_Workshop/v1.3/
2304
2305# Path to the null soft installer.
2306VBOX_PATH_NSIS ?= $(KBUILD_DEVTOOLS)/win.x86/nsis/v3.04-log
2307
2308# Path to AutoIt3.
2309VBOX_PATH_AUTOIT3 ?= $(KBUILD_DEVTOOLS)/win.x86/autoit/v3.2.10.0
2310
2311# Windows install tools...
2312# Note! The scripts has been moved to Bin in v8.0.
2313VBOX_PATH_WIX ?= $(KBUILD_DEVTOOLS)/win.x86/wix/v3.8.1128.0
2314VBOX_PATH_MSITRAN ?= $(KBUILD_DEVTOOLS)/win.x86/sdk/v7.1/Bin/MsiTran.Exe
2315VBOX_PATH_MSIDB ?= $(KBUILD_DEVTOOLS)/win.x86/sdk/v7.1/Bin/MsiDb.Exe
2316VBOX_PATH_WISUBSTG ?= $(KBUILD_DEVTOOLS)/win.x86/sdk/v7.1/Samples/sysmgmt/msi/scripts/WiSubStg.vbs
2317VBOX_PATH_WISUMINFO ?= $(KBUILD_DEVTOOLS)/win.x86/sdk/v7.1/Samples/sysmgmt/msi/scripts/WiSumInf.vbs
2318VBOX_PATH_DIFX ?= $(KBUILD_DEVTOOLS)/win.$(KBUILD_TARGET_ARCH)/DIFx/v2.1-r3
2319
2320ifdef VBOX_OSE ## @todo try get rid of this crap! People can use the latest and greatest Yasm release, no need to check in the binary for OSE.
2321 # We need to export YASM for OSE, but since it was converted to .zip we need to
2322 # allow for the location used by the zip to be properly cleaned up first.
2323 if1of ($(KBUILD_HOST).$(KBUILD_HOST_ARCH), linux.x86 solaris.x86 win.x86)
2324 PATH_TOOL_YASM ?= $(KBUILD_DEVTOOLS_HST)/bin
2325 endif
2326endif
2327
2328# The Microsoft IDL compiler (the SDK build needs this on non-Windows).
2329VBOX_WIN_MIDL ?= $(EXEC_X86_WIN32) $(call VBOX_FN_MAKE_WIN_PATH,$(firstword $(wildcard $(addsuffix /[Mm][Ii][Dd][Ll].[Ee][Xx][Ee], \
2330 $(KBUILD_DEVTOOLS)/win.x86/sdk/v7.1/Bin$(if-expr "$(KBUILD_HOST).$(KBUILD_HOST_ARCH)" == "win.amd64",/x64,) \
2331 $(KBUILD_DEVTOOLS)/win.x86/ddk/7600.16385.1/bin/x86 \
2332 $(KBUILD_DEVTOOLS)/win.x86/bin \
2333 $(PATH_SDK_$(VBOX_WINPSDK)_BIN) \
2334 $(PATH_SDK_$(VBOX_WINPSDK)) \
2335 $(PATH_SDK_WINPSDK_BIN) \
2336 $(PATH_SDK_WINPSDK) \
2337 )) Sorry_Cannot_Find_The_Midl_Compiler_In_The_PSDK))
2338
2339# Tricks to work around midl.exe problems with spaces in the /cpp_cmd value, it
2340# forgets to quote it when creating the commandline and cl.exe gets very confused.
2341if1of (quote, $(KMK_FEATURES))
2342VBOX_MIDL_REDIRECT = $(REDIRECT) --prepend "$(quote-sh-dq PATH=$(PATH_TOOL_$(VBOX_VCC_TOOL)_BIN);$(qaddsuffix ,;,$(PATH_TOOL_$(VBOX_VCC_TOOL)_DLL_BIN)))" --
2343VBOX_MIDL_REDIRECT_X86 = $(REDIRECT) --prepend "$(quote-sh-dq PATH=$(PATH_TOOL_$(VBOX_VCC_TOOL_STEM)X86_BIN);$(qaddsuffix ,;,$(PATH_TOOL_$(VBOX_VCC_TOOL_STEM)X86_DLL_BIN)))" --
2344else
2345VBOX_MIDL_REDIRECT = $(REDIRECT) --prepend 'PATH=$(PATH_TOOL_$(VBOX_VCC_TOOL)_BIN);$(PATH)' --
2346VBOX_MIDL_REDIRECT_X86 = $(REDIRECT) --prepend 'PATH=$(PATH_TOOL_$(VBOX_VCC_TOOL_STEM)X86_BIN);$(PATH)' --
2347endif
2348VBOX_MIDL_CPP_CMD = $(lastword $(notdir ,$(subst $(EXEC_X86_WIN32),,$(TOOL_$(VBOX_VCC_TOOL)_CC))))
2349VBOX_MIDL_CPP_CMD_X86 = $(lastword $(notdir ,$(subst $(EXEC_X86_WIN32),,$(TOOL_$(VBOX_VCC_TOOL_STEM)X86_CC))))
2350
2351# XPCOM setup for all but win32.
2352ifneq ($(KBUILD_TARGET),win)
2353 VBOX_WITH_XPCOM = 1
2354 # if updating, also update xpidl_INST var in src/libs/xpcom18a4/Makefile.kmk
2355 VBOX_XPIDL ?= $(PATH_STAGE_BIN)/xpidl$(HOSTSUFF_EXE)
2356 ifeq ($(KBUILD_TARGET),os2)
2357 VBOX_XPIDL_ENV = BEGINLIBPATH="$(dir $(VBOX_XPIDL));$$BEGINLIBPATH"$(SP)
2358 endif
2359 VBOX_PATH_XPCOM_IDL ?= $(VBOX_PATH_SDK)/bindings/xpcom/idl
2360 VBOX_XPCOM_INCS ?= \
2361 $(VBOX_PATH_SDK)/bindings/xpcom/include \
2362 $(VBOX_PATH_SDK)/bindings/xpcom/include/xpcom \
2363 $(VBOX_PATH_SDK)/bindings/xpcom/include/string \
2364 $(VBOX_PATH_SDK)/bindings/xpcom/include/xpcom \
2365 $(VBOX_PATH_SDK)/bindings/xpcom/include/nsprpub \
2366 $(VBOX_PATH_SDK)/bindings/xpcom/include/ipcd
2367 ifneq ($(KBUILD_TARGET),os2)
2368 # libIDL-config (for xpcom18a4)
2369 ifeq ($(origin VBOX_LIBIDL_CONFIG),undefined)
2370 ifeq ($(KBUILD_HOST),solaris)
2371 VBOX_LIBIDL_CONFIG_FALLBACK = $(lastword $(wildcard $(KBUILD_DEVTOOLS)/solaris.amd64/libIDL/*/bin/libIDL-config-2))
2372 endif
2373 export VBOX_LIBIDL_CONFIG := $(firstword $(which libIDL-config-2 libIDL-config) $(VBOX_LIBIDL_CONFIG_FALLBACK) libIDL-config-2-not-found)
2374 endif
2375 endif
2376endif
2377
2378# The X11 LIBPATH. (The amd64 hack is for RHEL4.)
2379ifeq ($(KBUILD_TARGET_ARCH),amd64)
2380 VBOX_LIBPATH_X11 ?= /usr/X11R6/lib64 /usr/X11R6/lib
2381else
2382 VBOX_LIBPATH_X11 ?= /usr/X11R6/lib
2383endif
2384
2385# 32bit X11 LIBPATH for building 32bit guest additions
2386VBOX_LIBPATH32_X11 ?= /usr/X11R6/lib32 /usr/X11R6/lib
2387
2388# Good windows shell.
2389VBOX_GOOD_COMSPEC = $(subst \,/,$(SystemRoot))/System32/cmd.exe
2390VBOX_GOOD_COMSPEC_BS ?= $(subst /,\,$(VBOX_GOOD_COMSPEC))
2391
2392# Disable VMNET depending on platform / build / LocalConfig.kmk settings
2393ifneq ($(KBUILD_TARGET),darwin)
2394 VBOX_WITH_VMNET=
2395endif
2396# Disable VMNET for special builds
2397if defined(VBOX_ONLY_VALIDATIONKIT) || defined(VBOX_ONLY_ADDITIONS) || defined(VBOX_ONLY_DOCS) || defined(VBOX_ONLY_EXTPACKS)
2398 VBOX_WITH_VMNET=
2399endif
2400# VMNET can only be compiled with the newer Xcode
2401ifndef VBOX_WITH_EVEN_NEWER_XCODE
2402 VBOX_WITH_VMNET=
2403endif
2404# Force SDK 10.15 for VMNET
2405ifdef VBOX_WITH_VMNET
2406 VBOX_DEF_MACOSX_VERSION_MIN=10.15# Catalina
2407endif
2408
2409#
2410# Macros dealing with the darwin version we're targeting.
2411# The DEF in VBOX_DEF_MACOSX_VERSION_MIN mean default. The default min
2412# version is assumed to be the
2413#
2414ifeq ($(KBUILD_TARGET),darwin)
2415 # The minimum macOS version we're targetting.
2416 ifndef VBOX_DEF_MACOSX_VERSION_MIN
2417 if1of ($(VBOX_GCC_TOOL), GXX4MACHO GXX42MACHO) # For GAs.
2418 VBOX_DEF_MACOSX_VERSION_MIN := 10.6# Snow Leopard
2419 else if1of ($(VBOX_GCC_TOOL), VBoxXcode62)
2420 VBOX_DEF_MACOSX_VERSION_MIN := 10.9# Mavericks
2421 else ifeq ($(KBUILD_TARGET_ARCH),arm64)
2422 VBOX_DEF_MACOSX_VERSION_MIN := 11.0# The Jack Kerouac novel.
2423 else
2424 VBOX_DEF_MACOSX_VERSION_MIN := 10.13# High Sierra
2425 endif
2426 endif
2427 VBOX_DEF_MACOSX_VERSION_MIN_NO_DOT := $(subst .,,$(VBOX_DEF_MACOSX_VERSION_MIN))
2428
2429 if1of ($(VBOX_GCC_TOOL), GXX4MACHO GXX42MACHO) # For GAs.
2430 # Check for the Xcode 4.1 bits in tools/darwin.x86.
2431 if !defined(VBOX_WITH_MACOSX_COMPILERS_FROM_DEVEL) \
2432 && !defined(VBOX_XCODE_VERSION) \
2433 && exists "$(KBUILD_DEVTOOLS)/darwin.x86/xcode/v4.1"
2434 VBOX_WITH_MACOSX_COMPILERS_FROM_DEVEL := 1
2435 VBOX_PATH_MACOSX_DEVEL_ROOT := $(KBUILD_DEVTOOLS)/darwin.x86/xcode/v4.1
2436 VBOX_XCODE_VERSION := 4.1
2437 else
2438 # Fallback - system / LocalConfig.kmk.
2439 VBOX_PATH_MACOSX_DEVEL_ROOT ?= /Developer
2440 VBOX_PATH_MACOSX_SDK_ROOT ?= $(VBOX_PATH_MACOSX_DEVEL_ROOT)/SDKs
2441 VBOX_PATH_MACOSX_TOOLCHAIN_ROOT ?= $(VBOX_PATH_MACOSX_DEVEL_ROOT)
2442 endif
2443 else ifeq ($(VBOX_GCC_TOOL),VBoxXcode62)
2444 # Use the tool path of the compiler (it's clang, not gcc in this instance).
2445 include $(KBUILD_TOOL_PATHS)/$(VBOX_GCC_TOOL).kmk
2446 VBOX_PATH_MACOSX_DEVEL_ROOT := $(PATH_TOOL_$(VBOX_GCC_TOOL))
2447 # Fallback - system / LocalConfig.kmk.
2448 ifndef VBOX_PATH_MACOSX_DEVEL_ROOT
2449 VBOX_PATH_MACOSX_DEVEL_ROOT := $(firstword $(wildcard /Applications/Xcode.app/Contents/Developer /Developer /Library/Developer))
2450 endif
2451 ifndef VBOX_PATH_MACOSX_SDK_ROOT
2452 VBOX_PATH_MACOSX_SDK_ROOT := $(firstword $(wildcard \
2453 $(PATH_TOOL_$(VBOX_GCC_TOOL)_SDKS) \
2454 $(VBOX_PATH_MACOSX_DEVEL_ROOT)/SDKs/. \
2455 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/. \
2456 /Developer/SDKs/. \
2457 /Library/Developer/CommandLineTools/SDKs/. ))
2458 endif
2459 ifndef VBOX_PATH_MACOSX_TOOLCHAIN_ROOT
2460 VBOX_PATH_MACOSX_TOOLCHAIN_ROOT := $(firstword $(wildcard \
2461 $(PATH_TOOL_$(VBOX_GCC_TOOL)_TOOLCHAIN) \
2462 $(VBOX_PATH_MACOSX_DEVEL_ROOT)/Library/Developer/CommandLineTools/. \
2463 $(VBOX_PATH_MACOSX_DEVEL_ROOT)/Toolchains/XcodeDefault.xctoolchain/. \
2464 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/. \
2465 /Library/Developer/CommandLineTools/. \
2466 ) /. )
2467 endif
2468 else
2469 # VBOX_WITH_EVEN_NEWER_XCODE ends up here.
2470 include $(KBUILD_PATH)/tools/$(VBOX_GCC_TOOL).kmk
2471 include $(KBUILD_PATH)/sdks/MACOSX$(VBOX_DEF_MACOSX_VERSION_MIN_NO_DOT).kmk
2472 ifndef VBOX_PATH_MACOSX_SDK
2473 VBOX_PATH_MACOSX_SDK := $(PATH_SDK_MACOSX$(VBOX_DEF_MACOSX_VERSION_MIN_NO_DOT))
2474 endif
2475 VBOX_PATH_MACOSX_SDK_ROOT = $(dir $(VBOX_PATH_MACOSX_SDK))
2476 endif
2477
2478 # Figure the default SDK location and obsolete linker tricks.
2479 ifeq ($(VBOX_DEF_MACOSX_VERSION_MIN),10.4)
2480 ifeq ($(origin VBOX_DARWIN_CLASSIC_LINKER),undefined)
2481 VBOX_DARWIN_CLASSIC_LINKER := $(shell ld -v 2>&1 )
2482 ifneq ($(filter ld64%, $(subst :, , $(VBOX_DARWIN_CLASSIC_LINKER))),)
2483 export VBOX_DARWIN_CLASSIC_LINKER := -Wl,-classic_linker
2484 else
2485 export VBOX_DARWIN_CLASSIC_LINKER :=
2486 endif
2487 endif
2488 endif
2489 if !defined(VBOX_PATH_MACOSX_SDK) && !defined(VBOX_WITH_EVEN_NEWER_XCODE) # newer xcode handles this above
2490VBOX_PATH_MACOSX_SDK_ROOT_DIRS ?= \
2491 $(VBOX_PATH_MACOSX_SDK_ROOT) \
2492 $(KBUILD_DEVTOOLS)/darwin.x86/SDKs/ \
2493 $(KBUILD_DEVTOOLS)/darwin.amd64/SDKs/ \
2494 $(KBUILD_DEVTOOLS)/darwin.x86/xcode/v4.1/SDKs \
2495 $(KBUILD_DEVTOOLS)/darwin.x86/xcode/v3.2.6/SDKs
2496 ifeq ($(VBOX_DEF_MACOSX_VERSION_MIN),10.4)
2497VBOX_PATH_MACOSX_SDK := $(firstword $(wildcard $(addsuffix /MacOSX$(VBOX_DEF_MACOSX_VERSION_MIN)u.sdk, $(VBOX_PATH_MACOSX_SDK_ROOT_DIRS))) \
2498 $(VBOX_PATH_MACOSX_SDK_ROOT)/MacOSX$(VBOX_DEF_MACOSX_VERSION_MIN)u.sdk )
2499 else
2500VBOX_PATH_MACOSX_SDK := $(firstword $(wildcard $(addsuffix /MacOSX$(VBOX_DEF_MACOSX_VERSION_MIN).sdk, $(VBOX_PATH_MACOSX_SDK_ROOT_DIRS))) \
2501 $(VBOX_PATH_MACOSX_SDK_ROOT)/MacOSX$(VBOX_DEF_MACOSX_VERSION_MIN).sdk )
2502 endif
2503 endif
2504
2505 ## The Xcode version (not relevant for command line tools, so we skip this in VBOX_WITH_EVEN_NEWER_XCODE mode).
2506 ifdef VBOX_WITH_EVEN_NEWER_XCODE
2507 VBOX_XCODE_VERSION ?= 10.98## Just a high non-existing version number.
2508 else ifeq ($(KBUILD_HOST),darwin)
2509 ifndef VBOX_XCODE_VERSION
2510 if1of ($(VBOX_GCC_TOOL), VBoxXcode62)
2511 VBOX_XCODE_VERSION := $(shell exec $(VBOX_PATH_MACOSX_DEVEL_ROOT)/usr/bin/xcodebuild -version 2>&1)
2512 ifneq ($(pos Symbol not found,$(VBOX_XCODE_VERSION)),0) # Try detect unresolved symbol running Xcode 6.2 on Catalina.
2513 VBOX_XCODE_VERSION = 6.2
2514 else
2515 VBOX_XCODE_VERSION := $(word 2, $(VBOX_XCODE_VERSION))
2516 endif
2517 else if defined(VBOX_WITH_MACOSX_COMPILERS_FROM_DEVEL) || exists "$(VBOX_PATH_MACOSX_DEVEL_ROOT)/usr/bin/xcodebuild"
2518 VBOX_XCODE_VERSION := $(word 2, $(shell $(VBOX_PATH_MACOSX_DEVEL_ROOT)/usr/bin/xcodebuild -version))
2519 else
2520 VBOX_XCODE_VERSION := $(word 2, $(shell xcodebuild -version))
2521 endif
2522 ifeq ($(strip $(VBOX_XCODE_VERSION)),)
2523 if1of ($(VBOX_GCC_TOOL), GXX4MACHO GXX42MACHO)
2524 VBOX_XCODE_VERSION := 4.1
2525 else if1of ($(VBOX_GCC_TOOL), VBoxXcode62)
2526 VBOX_XCODE_VERSION := 6.2
2527 else
2528 VBOX_XCODE_VERSION := 9.4# whatever
2529 endif
2530 endif
2531 endif
2532 if1of ($(VBOX_GCC_TOOL), VBoxXcode62)
2533 ifdef KBUILD_USE_KOBJCACHE
2534 $(warning KBUILD_USE_KOBJCACHE does _not_ currently work with this version of Xcode)
2535 endif
2536 endif
2537 else
2538 VBOX_XCODE_VERSION ?= 4.1## @todo Anything special for GA, extpack and valkit tools fetching?
2539 endif
2540 VBOX_XCODE_VERSION_MAJOR := $(word 1, $(subst ., ,$(VBOX_XCODE_VERSION)))
2541 VBOX_XCODE_VERSION_MINOR := $(word 2, $(subst ., ,$(VBOX_XCODE_VERSION)))
2542 VBOX_XCODE_VERSION := $(VBOX_XCODE_VERSION_MAJOR).$(VBOX_XCODE_VERSION_MINOR)
2543
2544 ifeq ($(KBUILD_TARGET_ARCH),x86)
2545 if1of ($(VBOX_DEF_MACOSX_VERSION_MIN), 10.4 10.5)
2546 VBOX_DARWIN_NO_COMPACT_LINKEDIT ?= $(VBOX_LD_no_compact_linkedit)
2547 TOOL_GXX4MACHO_SUFFIX ?= -4.0
2548 endif
2549 else if $(VBOX_XCODE_VERSION_MAJOR) < 4 && "$(VBOX_XCODE_VERSION)" != "3.2"
2550 ifeq ($(PATH_CURRENT),$(PATH_ROOT)/tools)
2551 $(warning VBox: 64-bit darwin builds require Xcode 3.2 or later, you have $(VBOX_XCODE_VERSION))
2552 else
2553 $(error VBox: 64-bit darwin builds require Xcode 3.2 or later, you have $(VBOX_XCODE_VERSION))
2554 endif
2555 endif
2556 if1of ($(VBOX_GCC_TOOL), GXX4MACHO GXX42MACHO)
2557 if $(VBOX_XCODE_VERSION_MAJOR) > 4 || ($(VBOX_XCODE_VERSION_MAJOR) == 4 && $(VBOX_XCODE_VERSION_MINOR) >= 2)
2558 TOOL_GXX4MACHO_PREFIX ?= llvm-
2559 endif
2560 if $(VBOX_XCODE_VERSION_MAJOR) < 5
2561 TOOL_GXX4MACHO_SUFFIX ?= -4.2
2562 endif
2563 VBOX_DARWIN_NO_COMPACT_LINKEDIT ?=
2564
2565 TOOL_GCC4MACHO_SUFFIX ?= $(TOOL_GXX4MACHO_SUFFIX)$(HOSTSUFF_EXE)
2566 TOOL_GCC4MACHO_PREFIX ?= $(TOOL_GXX4MACHO_PREFIX)
2567 if defined(VBOX_WITH_MACOSX_COMPILERS_FROM_DEVEL)
2568 TOOL_GCC4MACHO_PREFIX := $(VBOX_PATH_MACOSX_TOOLCHAIN_ROOT)/usr/bin/$(TOOL_GCC4MACHO_PREFIX)
2569 TOOL_GXX4MACHO_PREFIX := $(VBOX_PATH_MACOSX_TOOLCHAIN_ROOT)/usr/bin/$(TOOL_GXX4MACHO_PREFIX)
2570 TOOL_GCC4MACHO_SUFFIX := $(TOOL_GCC4MACHO_SUFFIX) -isysroot "$(VBOX_PATH_MACOSX_SDK)"
2571 TOOL_GXX4MACHO_SUFFIX := $(TOOL_GXX4MACHO_SUFFIX) -isysroot "$(VBOX_PATH_MACOSX_SDK)"
2572 ifndef SVN # must expand first so we won't be using old svn.
2573 SVN := $(firstword $(which svn) svn)
2574 endif
2575 if $(VBOX_XCODE_VERSION_MAJOR) > 4 || ($(VBOX_XCODE_VERSION_MAJOR) == 4 && $(VBOX_XCODE_VERSION_MINOR) >= 2)
2576 export PATH:=$(VBOX_PATH_MACOSX_DEVEL_ROOT)/usr/bin/:$(VBOX_PATH_MACOSX_SDK)/usr/bin:$(VBOX_PATH_MACOSX_TOOLCHAIN_ROOT)/usr/bin:$(PATH)
2577 export DEVELOPER_DIR:=$(VBOX_PATH_MACOSX_DEVEL_ROOT)
2578 else
2579 export PATH:=$(VBOX_PATH_MACOSX_DEVEL_ROOT)/usr/bin/:$(PATH)
2580 endif
2581 TOOL_GXX32_CC = $(TOOL_GCC4MACHO_PREFIX)gcc$(TOOL_GCC4MACHO_SUFFIX) -m32
2582 TOOL_GXX32_CXX = $(TOOL_GCC4MACHO_PREFIX)g++$(TOOL_GCC4MACHO_SUFFIX) -m32
2583 TOOL_GXX32_LD = $(TOOL_GXX32_CXX)
2584 override TOOL_StandardDTrace_DTRACE := dtrace "-xcpppath=$(TOOL_GCC4MACHO_PREFIX)cpp-4.2"
2585 endif
2586 if $(VBOX_XCODE_VERSION_MAJOR) < 5
2587 ## @todo WTF do we do the -m32/64 stuff here for these compilers? Also the visibility should be elsewhere...
2588 TOOL_GXX4MACHO_OBJC = $(TOOL_GCC4MACHO_PREFIX)gcc$(TOOL_GCC4MACHO_SUFFIX) $(if-expr $(KBUILD_TARGET_ARCH) == "x86",-m32,-m64) -fvisibility=hidden
2589 TOOL_GXX4MACHO_OBJCXX = $(TOOL_GCC4MACHO_PREFIX)gcc$(TOOL_GCC4MACHO_SUFFIX) $(if-expr $(KBUILD_TARGET_ARCH) == "x86",-m32,-m64) -fvisibility=hidden -fvisibility-inlines-hidden
2590 endif
2591 else if1of ($(VBOX_GCC_TOOL), VBoxXcode62)
2592 if $(KBUILD_HOST_VERSION_MAJOR) >= 18 # HACK ALERT! dtrace doesn't work on Mojave if we specify our Xcode 6.2 environment.
2593 override TOOL_StandardDTrace_DTRACE := dtrace "-xcpppath=$(VBOX_PATH_MACOSX_DEVEL_ROOT)/usr/bin/gcc"
2594 else
2595 override TOOL_StandardDTrace_DTRACE := $(TOOL_$(VBOX_GCC_TOOL)_ENV_SETUP) dtrace "-xcpppath=$(VBOX_PATH_MACOSX_DEVEL_ROOT)/usr/bin/gcc"
2596 endif
2597 export PATH:=$(VBOX_PATH_MACOSX_SDK)/usr/bin:$(PATH)
2598 else # effectively VBOX_WITH_EVEN_NEWER_XCODE
2599 override TOOL_StandardDTrace_DTRACE := $(TOOL_$(VBOX_GCC_TOOL)_ENV_SETUP) dtrace "-xcpppath=$(filter-out -f%,$(TOOL_$(VBOX_GCC_TOOL)_CC))"
2600 endif
2601
2602 ifdef VBOX_WITH_EVEN_NEWER_XCODE
2603 VBOX_DARWIN_DEF_SDK_SDKS := MACOSX$(VBOX_DEF_MACOSX_VERSION_MIN_NO_DOT)
2604 VBOX_DARWIN_DEF_SDK_DEFS := MAC_OS_X_VERSION_MAX_ALLOWED=$(SDK_MACOSX$(VBOX_DEF_MACOSX_VERSION_MIN_NO_DOT)_VERSION_VALUE)
2605 VBOX_DARWIN_DEF_SDK_LDFLAGS = $(VBOX_DARWIN_CLASSIC_LINKER) $(VBOX_DARWIN_NO_COMPACT_LINKEDIT)
2606 else
2607 VBOX_DARWIN_DEF_SDK_DEFS := MAC_OS_X_VERSION_MIN_REQUIRED=$(VBOX_DEF_MACOSX_VERSION_MIN_NO_DOT)0 \
2608 MAC_OS_X_VERSION_MAX_ALLOWED=$(VBOX_DEF_MACOSX_VERSION_MIN_NO_DOT)0
2609 VBOX_DARWIN_DEF_SDK_CFLAGS := -mmacosx-version-min=$(VBOX_DEF_MACOSX_VERSION_MIN) -isysroot "$(VBOX_PATH_MACOSX_SDK)"
2610 VBOX_DARWIN_DEF_SDK_CXXFLAGS := -mmacosx-version-min=$(VBOX_DEF_MACOSX_VERSION_MIN) -isysroot "$(VBOX_PATH_MACOSX_SDK)"
2611 VBOX_DARWIN_DEF_SDK_OBJCFLAGS := -mmacosx-version-min=$(VBOX_DEF_MACOSX_VERSION_MIN) -isysroot "$(VBOX_PATH_MACOSX_SDK)"
2612 VBOX_DARWIN_DEF_SDK_OBJCXXFLAGS := -mmacosx-version-min=$(VBOX_DEF_MACOSX_VERSION_MIN) -isysroot "$(VBOX_PATH_MACOSX_SDK)"
2613 VBOX_DARWIN_DEF_SDK_LDFLAGS = -mmacosx-version-min=$(VBOX_DEF_MACOSX_VERSION_MIN) -Wl,-syslibroot,"$(VBOX_PATH_MACOSX_SDK)" \
2614 $(VBOX_DARWIN_CLASSIC_LINKER) $(VBOX_DARWIN_NO_COMPACT_LINKEDIT)
2615 endif
2616
2617 # specific versions - only used by xpcom18a4 (python) and 10.7 by UsbWebcam.
2618 ## @todo s/VBOX_DARWIN_DEF_SDK_10/VBOX_DARWIN_SDK_10/g
2619
2620 if1of ($(VBOX_DEF_MACOSX_VERSION_MIN), 10.4) # classic linker detection is bust otherwise
2621 VBOX_PATH_MACOSX_SDK_10_4 ?= $(VBOX_PATH_MACOSX_SDK_ROOT)/MacOSX10.4u.sdk
2622 VBOX_DARWIN_DEF_SDK_10_4_DEFS := MAC_OS_X_VERSION_MIN_REQUIRED=1040 MAC_OS_X_VERSION_MAX_ALLOWED=1040
2623 VBOX_DARWIN_DEF_SDK_10_4_CFLAGS := -mmacosx-version-min=10.4 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_4)"
2624 VBOX_DARWIN_DEF_SDK_10_4_CXXFLAGS := -mmacosx-version-min=10.4 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_4)"
2625 VBOX_DARWIN_DEF_SDK_10_4_OBJCFLAGS := -mmacosx-version-min=10.4 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_4)"
2626 VBOX_DARWIN_DEF_SDK_10_4_OBJCXXFLAGS := -mmacosx-version-min=10.4 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_4)"
2627 VBOX_DARWIN_DEF_SDK_10_4_LDFLAGS := -mmacosx-version-min=10.4 -Wl,-syslibroot,"$(VBOX_PATH_MACOSX_SDK_10_4)" $(VBOX_DARWIN_CLASSIC_LINKER)
2628 else
2629 VBOX_PATH_MACOSX_SDK_10_4 = $(error VBox: $(if $(target),$(target): ,)Using 10.4 SDK)
2630 VBOX_DARWIN_DEF_SDK_10_4_CXXFLAGS = $(error VBox: $(if $(target),$(target): ,)Using 10.4 SDK)
2631 VBOX_DARWIN_DEF_SDK_10_4_LDFLAGS = $(error VBox: $(if $(target),$(target): ,)Using 10.4 SDK)
2632 endif
2633
2634 if1of ($(VBOX_DEF_MACOSX_VERSION_MIN), 10.4 10.5)
2635 VBOX_PATH_MACOSX_SDK_10_5 ?= $(VBOX_PATH_MACOSX_SDK_ROOT)/MacOSX10.5.sdk
2636 VBOX_DARWIN_DEF_SDK_10_5_DEFS := MAC_OS_X_VERSION_MIN_REQUIRED=1050 MAC_OS_X_VERSION_MAX_ALLOWED=1050
2637 VBOX_DARWIN_DEF_SDK_10_5_CFLAGS := -mmacosx-version-min=10.5 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_5)"
2638 VBOX_DARWIN_DEF_SDK_10_5_CXXFLAGS := -mmacosx-version-min=10.5 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_5)"
2639 VBOX_DARWIN_DEF_SDK_10_5_OBJCFLAGS := -mmacosx-version-min=10.5 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_5)"
2640 VBOX_DARWIN_DEF_SDK_10_5_OBJCXXFLAGS := -mmacosx-version-min=10.5 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_5)"
2641 VBOX_DARWIN_DEF_SDK_10_5_LDFLAGS := -mmacosx-version-min=10.5 -Wl,-syslibroot,"$(VBOX_PATH_MACOSX_SDK_10_5)" $(VBOX_DARWIN_NO_COMPACT_LINKEDIT)
2642 else
2643 VBOX_PATH_MACOSX_SDK_10_5 = $(error VBox: $(if $(target),$(target): ,)Using 10.5 SDK)
2644 VBOX_DARWIN_DEF_SDK_10_5_CXXFLAGS = $(error VBox: $(if $(target),$(target): ,)Using 10.5 SDK)
2645 VBOX_DARWIN_DEF_SDK_10_5_LDFLAGS = $(error VBox: $(if $(target),$(target): ,)Using 10.5 SDK)
2646 endif
2647
2648 if1of ($(VBOX_DEF_MACOSX_VERSION_MIN), 10.4 10.5 10.6)
2649 VBOX_PATH_MACOSX_SDK_10_6 ?= $(VBOX_PATH_MACOSX_SDK_ROOT)/MacOSX10.6.sdk
2650 VBOX_DARWIN_DEF_SDK_10_6_DEFS := MAC_OS_X_VERSION_MIN_REQUIRED=1060 MAC_OS_X_VERSION_MAX_ALLOWED=1060
2651 VBOX_DARWIN_DEF_SDK_10_6_CFLAGS := -mmacosx-version-min=10.6 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_6)"
2652 VBOX_DARWIN_DEF_SDK_10_6_CXXFLAGS := -mmacosx-version-min=10.6 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_6)"
2653 VBOX_DARWIN_DEF_SDK_10_6_OBJCFLAGS := -mmacosx-version-min=10.6 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_6)"
2654 VBOX_DARWIN_DEF_SDK_10_6_OBJCXXFLAGS := -mmacosx-version-min=10.6 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_6)"
2655 VBOX_DARWIN_DEF_SDK_10_6_LDFLAGS := -mmacosx-version-min=10.6 -Wl,-syslibroot,"$(VBOX_PATH_MACOSX_SDK_10_6)"
2656 else
2657 VBOX_PATH_MACOSX_SDK_10_6 = $(error VBox: $(if $(target),$(target): ,)Using 10.6 SDK)
2658 VBOX_DARWIN_DEF_SDK_10_6_CXXFLAGS = $(error VBox: $(if $(target),$(target): ,)Using 10.6 SDK)
2659 VBOX_DARWIN_DEF_SDK_10_6_LDFLAGS = $(error VBox: $(if $(target),$(target): ,)Using 10.6 SDK)
2660 endif
2661
2662 if1of ($(VBOX_DEF_MACOSX_VERSION_MIN), 10.4 10.5 10.6 10.7)
2663 ifndef VBOX_PATH_MACOSX_SDK_10_7
2664 ifneq ($(wildcard $(VBOX_PATH_MACOSX_SDK_ROOT)/MacOSX10.7.sdk),)
2665 VBOX_PATH_MACOSX_SDK_10_7 = $(VBOX_PATH_MACOSX_SDK_ROOT)/MacOSX10.7.sdk
2666 else
2667 VBOX_PATH_MACOSX_SDK_10_7 = $(KBUILD_DEVTOOLS)/darwin.x86/SDKs/MacOSX10.7.sdk
2668 endif
2669 endif
2670 VBOX_DARWIN_DEF_SDK_10_7_DEFS := MAC_OS_X_VERSION_MIN_REQUIRED=1070 MAC_OS_X_VERSION_MAX_ALLOWED=1070
2671 VBOX_DARWIN_DEF_SDK_10_7_CFLAGS := -mmacosx-version-min=10.7 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_7)"
2672 VBOX_DARWIN_DEF_SDK_10_7_CXXFLAGS := -mmacosx-version-min=10.7 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_7)"
2673 VBOX_DARWIN_DEF_SDK_10_7_OBJCFLAGS := -mmacosx-version-min=10.7 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_7)"
2674 VBOX_DARWIN_DEF_SDK_10_7_OBJCXXFLAGS := -mmacosx-version-min=10.7 -isysroot "$(VBOX_PATH_MACOSX_SDK_10_7)"
2675 VBOX_DARWIN_DEF_SDK_10_7_LDFLAGS := -mmacosx-version-min=10.7 -Wl,-syslibroot,"$(VBOX_PATH_MACOSX_SDK_10_7)"
2676 else
2677 VBOX_PATH_MACOSX_SDK_10_7 = $(error VBox: $(if $(target),$(target): ,)Using 10.7 SDK)
2678 VBOX_DARWIN_DEF_SDK_10_7_CXXFLAGS = $(error VBox: $(if $(target),$(target): ,)Using 10.7 SDK)
2679 VBOX_DARWIN_DEF_SDK_10_7_LDFLAGS = $(error VBox: $(if $(target),$(target): ,)Using 10.7 SDK)
2680 endif
2681
2682 #
2683 # Use bison and flex from Xcode to avoid linking issues (bison).
2684 #
2685 TOOL_BISON_YACC ?= $(TOOL_$(VBOX_GCC_TOOL)_ENV_SETUP) $(PATH_TOOL_$(VBOX_GCC_TOOL)_TOOLCHAIN_BIN_SLASH)bison
2686 TOOL_FLEX_LEX ?= $(TOOL_$(VBOX_GCC_TOOL)_ENV_SETUP) $(PATH_TOOL_$(VBOX_GCC_TOOL)_TOOLCHAIN_BIN_SLASH)flex
2687
2688endif # target=darwin
2689
2690#
2691# Macro switching between @executable_path, @rpath and /Applications/VirtualBox.app
2692# depending on whether the build is hardened or not (dylib install_name).
2693#
2694ifeq ($(KBUILD_TARGET),darwin)
2695 ifndef VBOX_DYLD_EXECUTABLE_PATH
2696 ifdef VBOX_WITH_HARDENING
2697 VBOX_DYLD_EXECUTABLE_PATH = $(VBOX_PATH_APP_PRIVATE_ARCH)
2698 else if 0
2699 VBOX_DYLD_EXECUTABLE_PATH = @executable_path
2700 else
2701 VBOX_DYLD_EXECUTABLE_PATH = @rpath
2702 VBOX_WITH_RELATIVE_RUNPATH = @loader_path/
2703 endif
2704 endif
2705endif
2706
2707#
2708# Check for incompatible rpath combinations.
2709#
2710if defined(VBOX_WITH_RUNPATH) && defined(VBOX_WITH_ORIGIN)
2711 $(error VBox: VBOX_WITH_RUNPATH and VBOX_WITH_ORIGIN are mutually exclusive)
2712endif
2713if defined(VBOX_WITH_RELATIVE_RUNPATH) && defined(VBOX_WITH_ORIGIN)
2714 $(error VBox: VBOX_WITH_RELATIVE_RUNPATH and VBOX_WITH_ORIGIN are mutually exclusive)
2715endif
2716if defined(VBOX_WITH_RUNPATH) && defined(VBOX_WITH_RELATIVE_RUNPATH)
2717 $(error VBox: VBOX_WITH_RUNPATH and VBOX_WITH_RELATIVE_RUNPATH are mutually exclusive)
2718endif
2719if defined(VBOX_WITH_RELATIVE_RUNPATH) && defined(VBOX_WITH_HARDENING)
2720 $(error VBox: VBOX_WITH_RELATIVE_RUNPATH and VBOX_WITH_HARDENING are mutually exclusive)
2721endif
2722
2723#
2724# VBOX_WITH_ORIGIN translates into VBOX_WITH_RELATIVE_RUNPATH.
2725#
2726# We use two helper variables for the VBOX_WITH_ORIGIN stuff:
2727# VBOX_ORIGIN - Indirect expansion trick.
2728# VBOX_GCC_RPATH_OPT - Different GCC/LD combinations needs different options.
2729#
2730VBOX_ORIGIN = $$ORIGIN
2731ifeq ($(KBUILD_TARGET),solaris)
2732 VBOX_GCC_RPATH_OPT = -R
2733else
2734 VBOX_GCC_RPATH_OPT = -Wl,-rpath,
2735 VBOX_GCC_ORIGIN_OPT = -Wl,-z,origin
2736endif
2737ifdef VBOX_WITH_ORIGIN
2738 VBOX_WITH_RELATIVE_RUNPATH = $$(VBOX_ORIGIN)
2739endif
2740
2741
2742#
2743# Configure 'asan' type builds.
2744#
2745# We ASSUME that anyone doing this kind of build on linux has a compiler
2746# with sanitizer support (otherwise we'd end up with a circular dependency
2747# with DynamicConfig.kmk here to check the compiler version).
2748#
2749ifeq ($(KBUILD_TYPE),asan)
2750 if "$(KBUILD_TARGET)" == "linux"
2751VBOX_WITH_GCC_SANITIZER := 1
2752 else
2753VBOX_WITH_EF_WRAPS := 1
2754 endif
2755endif
2756
2757#
2758# The address sanitiser library intercepts dlopen() and breaks RPATH $ORIGIN,
2759# so we need to link it statically or set LD_LIBRARY_PATH. To link statically,
2760# set VBOX_WITH_GCC_SANITIZER_STATIC in addition.
2761#
2762ifdef VBOX_WITH_GCC_SANITIZER
2763 VBOX_GCC_SANITIZER_FLAGS := \
2764 -fsanitize=undefined \
2765 -fsanitize=address \
2766 -fsanitize=return \
2767 -fsanitize=bounds \
2768 -fsanitize=object-size \
2769 -fno-sanitize=alignment \
2770 -fno-sanitize=vptr \
2771 -fno-common \
2772 -DIPRT_WITH_GCC_SANITIZER \
2773 -DVBOX_WITH_GCC_SANITIZER
2774else ifdef VBOX_WITH_CLANG_SANITIZER ## @todo make work...
2775 VBOX_GCC_SANITIZER_FLAGS := \
2776 -DIPRT_WITH_GCC_SANITIZER \
2777 -DVBOX_WITH_GCC_SANITIZER \
2778 -fsanitize=object-size \
2779 -fsanitize-undefined-trap-on-error
2780else
2781 VBOX_GCC_SANITIZER_FLAGS =
2782endif
2783
2784# -libasan-static is currently not supported in combination with -no-undefined.
2785VBOX_GCC_NO_UNDEFINED :=
2786VBOX_GCC_NO_UNDEFINED_R0 :=
2787ifdef VBOX_WITH_GCC_SANITIZER
2788 ifdef VBOX_WITH_GCC_SANITIZER_STATIC
2789 VBOX_GCC_NO_UNDEFINED := -Wl,--no-undefined
2790 VBOX_GCC_NO_UNDEFINED_R0 := -no-undefined
2791 VBOX_GCC_SANITIZER_LDFLAGS += -static-libasan
2792 else
2793 VBOX_GCC_SANITIZER_LDFLAGS += -lasan
2794 endif
2795endif
2796
2797
2798#
2799# The X11 headers.
2800#
2801VBOX_PATH_X11_ROOT = $(PATH_ROOT)/src/VBox/Additions/x11/x11include
2802
2803
2804#
2805# Miscellaneous includes
2806#
2807VBOX_GRAPHICS_INCS = $(PATH_ROOT)/include/VBox/Graphics
2808VBOX_JPEG_INCS = $(PATH_ROOT)/src/libs/jpeg-9b
2809
2810
2811# The icons to use.
2812ifdef VBOX_OSE
2813 VBOX_WINDOWS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/win/OSE/VirtualBox_win.ico
2814 VBOX_WINDOWS_ADDITIONS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/win/OSE/VirtualBox_win.ico
2815 VBOX_NSIS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/win/OSE/VirtualBox_win.ico
2816 VBOX_MACOSX_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/darwin/OSE/VirtualBox.icns
2817else
2818 ifeq ($(KBUILD_HOST),win)
2819 VBOX_WINDOWS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/win/NonOSE/VirtualBox-vista.ico
2820 VBOX_WINDOWS_ADDITIONS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/win/NonOSE/VirtualBoxGA-vista.ico
2821 VBOX_NSIS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/win/NonOSE/VirtualBoxGA-nsis.ico
2822 TOOL_VCC80X86_RC := $(KBUILD_DEVTOOLS)/win.x86/ddk/6000/bin/x86/rc.exe
2823 TOOL_VCC80AMD64_RC := $(KBUILD_DEVTOOLS)/win.x86/ddk/6000/bin/x86/rc.exe
2824 TOOL_VCC70_RC := $(KBUILD_DEVTOOLS)/win.x86/ddk/6000/bin/x86/rc.exe
2825 else
2826 VBOX_WINDOWS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/win/NonOSE/VirtualBox-winxp.ico
2827 VBOX_WINDOWS_ADDITIONS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/win/NonOSE/VirtualBoxGA-winxp.ico
2828 VBOX_NSIS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/win/NonOSE/VirtualBox-nsis.ico
2829 endif
2830 VBOX_MACOSX_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/darwin/NonOSE/VirtualBox.icns
2831endif
2832
2833
2834ifndef VBOX_NOINC_DYNAMIC_CONFIG_KMK
2835#
2836# GCC and YASM dynamic properties.
2837# Most of this is resolved on first kmk invocation and cached in PATH_OUT.
2838#
2839# Note! That a harmless warning is printed if the file doesn't exist.
2840# Note! Changes in GCC are not detected automatically (yet).
2841#
2842if $(pos VBox,$(VBOX_GCC_TOOL)) > 0
2843 include $(KBUILD_TOOL_PATHS)/$(VBOX_GCC_TOOL).kmk
2844else
2845 include $(KBUILD_PATH)/tools/$(VBOX_GCC_TOOL).kmk
2846endif
2847ifneq ($(VBOX_GCC_TOOL),$(VBOX_GCC32_TOOL))
2848 if $(pos VBox,$(VBOX_GCC32_TOOL)) > 0
2849 include $(KBUILD_TOOL_PATHS)/$(VBOX_GCC32_TOOL).kmk
2850 else
2851 include $(KBUILD_PATH)/tools/$(VBOX_GCC32_TOOL).kmk
2852 endif
2853endif
2854
2855# These tests never worked on Windows because of /dev/null, so, there
2856# can be no harm in just dropping them until cygwin is mp safe.
2857ifeq ($(KBUILD_HOST),win)
2858 VBOX_GCC_CHECK_EX_CC = $(3)
2859 VBOX_GCC_CHECK_EX_CXX = $(3)
2860 VBOX_GCC_CHECK_EX_LD = $(3)
2861 VBOX_GCC_CHECK_CC = $(2)
2862 VBOX_GCC_CHECK_CXX = $(2)
2863 VBOX_GCC_CHECK_LD = $(2)
2864 VBOX_GCC32_CHECK_CXX = $(2)
2865else
2866 # Note! The chcking for 'error: unknown warning option' is for clang on darwin not giving us a
2867 # non-zero exit code when using an invalid option here, but it does later on.
2868 ifndef CLOSEPAR
2869 CLOSEPAR := )
2870 endif
2871 VBOX_GCC_CHECK_EX_CC_CXX = $(shell \
2872 if $(1) $(subst -Wno-,-W,$(2)) -Werror -c -o /dev/null $(4) > /dev/null 2>&1; then \
2873 case "`LC_ALL=C $(1) $(subst -Wno-,-W,$(2)) -Werror -c -o /dev/null $(4) 2>&1`" in \
2874 "error: unknown warning option"*$(CLOSEPAR) echo "$(3)";; \
2875 *$(CLOSEPAR) echo "$(2)";; \
2876 esac; \
2877 else echo "$(3)"; fi; )
2878 VBOX_GCC_CHECK_EX_CC = $(call VBOX_GCC_CHECK_EX_CC_CXX,$(1),$(2),$(3),-xc $(PATH_OUT)/DynamicConfig.c)
2879 VBOX_GCC_CHECK_EX_CXX = $(call VBOX_GCC_CHECK_EX_CC_CXX,$(1),$(2),$(3),-xc++ $(PATH_OUT)/DynamicConfig.cpp)
2880 VBOX_GCC_CHECK_EX_LD = $(shell \
2881 if $(1) -Wl,$(2) $(if $(eq $(KBUILD_HOST),darwin),-Wl$(COMMA)-u$(COMMA)start -Wl$(COMMA)-undefined$(COMMA)dynamic_lookup,) \
2882 -nostdlib -o /dev/null -xc /dev/null > /dev/null 2>&1; \
2883 then echo "-Wl,$(2)"; else echo "$(3)"; fi; )
2884
2885 VBOX_GCC_CHECK_CC = $(call VBOX_GCC_CHECK_EX_CC, $(TOOL_$(VBOX_GCC_TOOL)_ENV_SETUP) $(TOOL_$(VBOX_GCC_TOOL)_CC),$1,$2)
2886 VBOX_GCC_CHECK_CXX = $(call VBOX_GCC_CHECK_EX_CXX, $(TOOL_$(VBOX_GCC_TOOL)_ENV_SETUP) $(TOOL_$(VBOX_GCC_TOOL)_CXX),$1,$2)
2887 VBOX_GCC_CHECK_LD = $(call VBOX_GCC_CHECK_EX_LD, $(TOOL_$(VBOX_GCC_TOOL)_ENV_SETUP) $(TOOL_$(VBOX_GCC_TOOL)_LD),$1,$2)
2888 VBOX_GCC32_CHECK_CXX = $(call VBOX_GCC_CHECK_EX_CXX, $(TOOL_$(VBOX_GCC32_TOOL)_ENV_SETUP) $(TOOL_$(VBOX_GCC32_TOOL)_CXX),$1,$2)
2889endif
2890
2891ifeq ($(KBUILD_HOST),win)
2892 # We're not using gcc on windows anymore, just cook the result.
2893 VBOX_GCC_VERSION := $(expr 10000 * 3 + 100 * 3 + 3)
2894else
2895 # This is kind of bad, the returned string needs to be re-evaluated before use.
2896 # The reason for this hack is that the windows kmk_ash cannot deal with $((1+1)).
2897 # Some versions of gcc (e.g. openSUSE11) return only major.minor on `gcc -dumpversion`.
2898 # gcc-5 of openSUSE42.1 only returns the major version on `gcc -dumpversion`!
2899 VBOX_GCC_VERSION = $(shell ($(1) -dumpfullversion 2>/dev/null || $(1) -dumpversion) | \
2900 $(SED_EXT) 's|\([0-9][0-9]*\)\.\{0,1\}\([0-9]\{0,\}\)\.\{0,1\}\([0-9]\{0,\}\).*|$$(expr 10000 * \1 + 100 * $$(firstword \2 0) + $$(firstword \3 0))|' )
2901 ifeq ($(KBUILD_TARGET), darwin)
2902 VBOX_CLANG_VERSION = $(shell $(1) --version | \
2903 $(SED_EXT) -n 's|.*version \([0-9][0-9]*\)\.\{0,1\}\([0-9]\{0,\}\)\.\{0,1\}\([0-9]\{0,\}\).*|$$(expr 10000 * \1 + 100 * $$(firstword \2 0) + $$(firstword \3 0))|p' )
2904 endif
2905endif
2906
2907# YASM macros
2908ifndef DONT_USE_YASM
2909 include $(KBUILD_PATH)/tools/YASM.kmk
2910 if1of ($(KBUILD_HOST), win os2)
2911 VBOX_YASM_CHECK = $(if-expr "$(shell $(TOOL_YASM_AS) -e -o nul $1 - < /dev/null 2>&1)" == "",$(1),)
2912 else
2913 VBOX_YASM_CHECK = $(if-expr "$(shell $(TOOL_YASM_AS) -e -o /dev/null $1 - < /dev/null 2>&1)" == "",$(1),)
2914 endif
2915else
2916 VBOX_YASM_CHECK =
2917endif
2918
2919# NASM macros (input and output must differ with recent versions (strcmp)).
2920ifndef DONT_USE_NASM
2921 include $(KBUILD_PATH)/tools/NASM.kmk
2922 if1of ($(KBUILD_HOST), win os2)
2923 VBOX_NASM_CHECK = $(if-expr "$(shell $(TOOL_NASM_AS) -e -o nul $1 NUL 2>&1)" == "",$(1),$(2))
2924 else
2925 VBOX_NASM_CHECK = $(if-expr "$(shell $(TOOL_NASM_AS) -e -o /dev/./null $1 /dev/null 2>&1)" == "",$(1),$(2))
2926 endif
2927else
2928 VBOX_NASM_CHECK =
2929endif
2930
2931# Figures the pylint version.
2932VBOX_PYLINT_FIGURE_VERSION = $(shell $(1) --version 2> /dev/null \
2933 | $(SED_EXT) -n -e 's/pylint-[^[:blank:]]*/pylint/' \
2934 -e 's|^ *pylint *\([0-9][0-9]*\).\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$(DOLLAR)|$$(expr \1 * 10000 + \2 * 100 + \3)|p' )
2935
2936# Java stuff.
2937ifeq ($(KBUILD_TARGET), darwin)
2938 VBOX_JAVA_BIN_PATH = $(firstword $(wildcard \
2939 /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Commands \
2940 /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands \
2941 $(if-expr $(VBOX_XCODE_VERSION_MAJOR) >= 4,/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands,) \
2942 $(if-expr $(VBOX_XCODE_VERSION_MAJOR) >= 10,/Library/Java/JavaVirtualMachines/jdk1.8.*.jdk/Contents/Home/bin,) \
2943 ) /usr/bin)
2944 VBOX_JAVA = $(VBOX_JAVA_BIN_PATH)/java
2945 VBOX_JAVAC = $(VBOX_JAVA_BIN_PATH)/javac
2946 VBOX_JAVAH = $(VBOX_JAVA_BIN_PATH)/javah
2947 VBOX_JAR = $(VBOX_JAVA_BIN_PATH)/jar
2948 VBOX_JAVADOC = $(VBOX_JAVA_BIN_PATH)/javadoc
2949 VBOX_WSIMPORT = $(VBOX_JAVA_BIN_PATH)/wsimport
2950 if $(VBOX_XCODE_VERSION_MAJOR) >= 4 # Lion (4.1-preview 5) has a broken CurrentJDK link. Blindly applying it to 4.0.
2951 VBOX_JAVA_INC = $(firstword $(wildcard \
2952 $(VBOX_PATH_MACOSX_SDK)/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers \
2953 /Library/Java/JavaVirtualMachines/jdk1.8.*.jdk/Contents/Home/include \
2954 ) )
2955 else
2956 VBOX_JAVA_INC = $(VBOX_PATH_MACOSX_SDK)/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Headers
2957 endif
2958
2959else # !darwin
2960
2961 ifeq ($(KBUILD_TARGET),linux)
2962 ifeq ($(origin VBOX_JAVA_HOME),undefined)
2963 # Add correct detection for you distro after the /usr/../java-6-sun line.
2964 VBOX_JAVA_HOME := $(firstword $(wildcard \
2965 $(KBUILD_DEVTOOLS)/linux.x86/jdk1.6.0_27 \
2966 /usr/lib/jvm/java-6-sun \
2967 /usr/lib/jvm/java-6-openjdk \
2968 /usr/lib/jvm/java-6-openjdk-i386 \
2969 /usr/lib/jvm/java-6-openjdk-amd64 \
2970 /usr/lib/jvm/java-7-openjdk-i386 \
2971 /usr/lib/jvm/java-7-openjdk-amd64 \
2972 /usr/lib/jvm/default-java \
2973 /usr/lib/jvm/java \
2974 \
2975 /usr/lib/jvm/sun-jdk-1.6 \
2976 ) /usr/lib/jvm/java-6-sun)
2977 endif
2978 endif
2979
2980 ifeq ($(KBUILD_TARGET),solaris)
2981 # VBOX_JAVA_HOME ?= /usr/jdk/jdk1.6.0
2982 VBOX_JAVA_HOME ?= $(firstword $(abspath $(wildcard \
2983 /usr/jdk/latest/include/.. \
2984 /usr/jdk/instances/jdk1.8*/include/.. \
2985 /usr/jdk/instances/jdk1.7*/include/.. \
2986 /usr/jdk/instances/jdk1.6*/include/.. \
2987 )) /usr/java)
2988 endif
2989
2990 ifeq ($(KBUILD_TARGET),win)
2991 VBOX_JAVA_HOME ?= c:/jdk
2992 endif
2993
2994 VBOX_JAVA_BIN_PATH ?= $(VBOX_JAVA_HOME)/bin
2995 VBOX_JAVA ?= "$(VBOX_JAVA_BIN_PATH)/java$(HOSTSUFF_EXE)"
2996 VBOX_JAVAC = "$(VBOX_JAVA_BIN_PATH)/javac$(HOSTSUFF_EXE)"
2997 VBOX_JAVAH = "$(VBOX_JAVA_BIN_PATH)/javah$(HOSTSUFF_EXE)"
2998 VBOX_JAR = "$(VBOX_JAVA_BIN_PATH)/jar$(HOSTSUFF_EXE)"
2999 VBOX_JAVADOC = "$(VBOX_JAVA_BIN_PATH)/javadoc$(HOSTSUFF_EXE)"
3000 # With Java 11 wsimport was removed, usually part of a separate install now.
3001 VBOX_WSIMPORT = $(firstword $(wildcard $(VBOX_JAVA_BIN_PATH)/wsimport$(HOSTSUFF_EXE)) wsimport$(HOSTSUFF_EXE))
3002 # correct for targets we care about
3003 VBOX_MD_OS = $(KBUILD_TARGET)
3004 VBOX_JAVA_INC = \
3005 $(VBOX_JAVA_HOME)/include \
3006 $(VBOX_JAVA_HOME)/include/$(VBOX_MD_OS)
3007endif # !darwin
3008# The first transform the almost usless openjdk versions like "javac 9-Ubuntu" into something the 2nd expression groks.
3009VBOX_JAVA_FIGURE_VERSION = $(shell $(1) -version 2>&1 \
3010 | $(SED_EXT) -n \
3011 -e 's/ \([0-9][0-9]*\)\(-[[:alpha:]][[:alpha:]]\)/ \1.0.0\2/' \
3012 -e 's|^[^ ]* *\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$(DOLLAR)|$$(expr \1 * 10000 + \2 * 100 + \3)|p' )
3013
3014# Test C and C++ files.
3015$(PATH_OUT)/DynamicConfig.c $(PATH_OUT)/DynamicConfig.cpp:
3016 $(QUIET)$(MKDIR) -p $(@D)
3017 $(QUIET)$(APPEND) -tn "$@" "int foobar(void)" "{" " return 42;" "}" ""
3018
3019# No $(QUIET) here as it's interesting to see what goes into the file.
3020$(PATH_OUT)/DynamicConfig.kmk: \
3021 $(PATH_ROOT)/Config.kmk \
3022 $(LOCALCFG) \
3023 $(AUTOCFG) \
3024 $(VBOX_GCC_PATH_CC) \
3025 $(VBOX_GCC_PATH_CXX) \
3026 $(VBOX_GCC_LIBGCC) \
3027 $(VBOX_GCC32_PATH_CC) \
3028 $(VBOX_GCC32_PATH_CXX) \
3029 $(VBOX_GCC32_LIBGCC) \
3030 $(if-expr "$(KBUILD_HOST).$(KBUILD_HOST_ARCH)" == "solaris.amd64" && $(KBUILD_HOST_VERSION_MINOR) >= 11 \
3031 , /platform/i86pc/kernel/$(KBUILD_HOST_ARCH)/unix,) \
3032 | $(PATH_OUT)/DynamicConfig.c $(PATH_OUT)/DynamicConfig.cpp
3033 $(call MSG_GENERATE,,$@,)
3034 $(QUIET)$(RM) -f '$@'
3035 $(QUIET)$(MKDIR) -p $(@D)
3036 $(QUIET)$(APPEND) '$@' '# Host version: $(KBUILD_HOST_VERSION_MAJOR).$(KBUILD_HOST_VERSION_MINOR).$(KBUILD_HOST_VERSION_PATCH); full: $(KBUILD_HOST_VERSION)'
3037ifneq ($(KBUILD_TARGET),win)
3038 $(QUIET)$(APPEND) '$@' '# $(KBUILD_HOST_UNAME_SYSNAME) - $(KBUILD_HOST_UNAME_RELEASE) - $(KBUILD_HOST_UNAME_VERSION)'
3039endif
3040ifeq ($(KBUILD_TARGET),darwin)
3041 $(QUIET)$(APPEND) '$@' '# VBOX_XCODE_VERSION: $(VBOX_XCODE_VERSION)'
3042 $(QUIET)$(APPEND) '$@' '# VBOX_PATH_MACOSX_TOOLCHAIN_ROOT: $(VBOX_PATH_MACOSX_TOOLCHAIN_ROOT)'
3043 $(QUIET)$(APPEND) '$@' '# VBOX_PATH_MACOSX_SDK_ROOT: $(VBOX_PATH_MACOSX_SDK_ROOT)'
3044 $(QUIET)$(APPEND) '$@' '# VBOX_PATH_MACOSX_DEVEL_ROOT: $(VBOX_PATH_MACOSX_DEVEL_ROOT)'
3045 $(QUIET)$(APPEND) '$@' 'VBOX_CLANG_VERSION_CC ?= $(call VBOX_CLANG_VERSION,$(TOOL_$(VBOX_GCC_TOOL)_CC))'
3046 $(QUIET)$(APPEND) '$@' 'VBOX_CLANG_VERSION_CXX ?= $(call VBOX_CLANG_VERSION,$(TOOL_$(VBOX_GCC_TOOL)_CXX))'
3047endif
3048# HC compiler switch detection.
3049 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_VERSION_CC ?= $(call VBOX_GCC_VERSION,$(TOOL_$(VBOX_GCC_TOOL)_CC))'
3050 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_VERSION_CXX ?= $(call VBOX_GCC_VERSION,$(TOOL_$(VBOX_GCC_TOOL)_CXX))'
3051 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_PATH_CC ?= $(which $(TOOL_$(VBOX_GCC_TOOL)_CC))'
3052 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_PATH_CXX ?= $(which $(TOOL_$(VBOX_GCC_TOOL)_CXX))'
3053 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_LIBGCC ?= $(shell $(TOOL_$(VBOX_GCC_TOOL)_CC) -print-libgcc-file-name)'
3054 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-pointer-sign ?= $(call VBOX_GCC_CHECK_CC,-Wno-pointer-sign,)'
3055 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-array_bounds ?= $(call VBOX_GCC_CHECK_CC,-Wno-array-bounds,)'
3056# -Wextra produces additional useful warnings but includes -Wno-missing-field-initializers (too noisy)
3057 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wextra ?= $(call VBOX_GCC_CHECK_CC,-Wextra,)'
3058 $(QUIET)$(APPEND) '$@' 'ifneq ($$(VBOX_GCC_VERSION_CC),)'
3059 $(QUIET)$(APPEND) '$@' ' if $$(VBOX_GCC_VERSION_CC) >= 40500'
3060 $(QUIET)$(APPEND) '$@' ' VBOX_GCC_Wlogical-op ?= $(call VBOX_GCC_CHECK_CC,-Wlogical-op,)'
3061 $(QUIET)$(APPEND) '$@' ' VBOX_GCC_Wno-logical-op ?= $$(subst -Wlogical-op,-Wno-logical-op,$$(VBOX_GCC_Wlogical-op))
3062 $(QUIET)$(APPEND) '$@' ' endif'
3063 $(QUIET)$(APPEND) '$@' 'endif'
3064 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-address ?= $(call VBOX_GCC_CHECK_CXX,-Wno-address,)'
3065 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-delete-non-virtual-dtor ?= $(call VBOX_GCC_CHECK_CXX,-Wno-delete-non-virtual-dtor,)'
3066 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-non-virtual-dtor ?= $(call VBOX_GCC_CHECK_CXX,-Wno-non-virtual-dtor,)'
3067 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-int-in-bool-context ?= $(call VBOX_GCC_CHECK_CC,-Wno-int-in-bool-context,)'
3068 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-int-to-pointer-cast ?= $(call VBOX_GCC_CHECK_CC,-Wno-int-to-pointer-cast,)'
3069 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-invalid-offsetof ?= $(call VBOX_GCC_CHECK_CXX,-Wno-invalid-offsetof,)'
3070 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-literal-suffix ?= $(call VBOX_GCC_CHECK_CXX,-Wno-literal-suffix,)'
3071 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-misleading-indentation ?= $(call VBOX_GCC_CHECK_CC,-Wno-misleading-indentation,)'
3072 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-missing-field-initializers ?= $(call VBOX_GCC_CHECK_CC,-Wno-missing-field-initializers,)'
3073 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-pointer-to-int-cast ?= $(call VBOX_GCC_CHECK_CC,-Wno-pointer-to-int-cast,)'
3074 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-variadic-macros ?= $(call VBOX_GCC_CHECK_CXX,-Wno-variadic-macros,)'
3075 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-vla ?= $(call VBOX_GCC_CHECK_CXX,-Wno-vla,)'
3076 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-overlength-strings ?= $(call VBOX_GCC_CHECK_CC,-Wno-overlength-strings,)'
3077 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-overloaded-virtual ?= $(call VBOX_GCC_CHECK_CXX,-Wno-overloaded-virtual,)'
3078 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-ignored-qualifiers ?= $(call VBOX_GCC_CHECK_CXX,-Wno-ignored-qualifiers,)'
3079 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-multistatement-macros ?= $(call VBOX_GCC_CHECK_CXX,-Wno-multistatement-macros,)'
3080 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-class-memaccess ?= $(call VBOX_GCC_CHECK_CXX,-Wno-class-memaccess,)'
3081 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-stringop-overflow ?= $(call VBOX_GCC_CHECK_CXX,-Wno-stringop-overflow,)'
3082 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-stringop-truncation ?= $(call VBOX_GCC_CHECK_CXX,-Wno-stringop-truncation,)'
3083 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-cast-function-type ?= $(call VBOX_GCC_CHECK_CC,-Wno-cast-function-type,)'
3084 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-deprecated-declarations ?= $(call VBOX_GCC_CHECK_CC,-Wno-deprecated-declarations,)'
3085 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-implicit-fallthrough ?= $(call VBOX_GCC_CHECK_CC,-Wno-implicit-fallthrough,)'
3086 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_fno-stack-protector ?= $(call VBOX_GCC_CHECK_CC,-fno-stack-protector,)'
3087 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_fno-dwarf2-cfi-asm ?= $(call VBOX_GCC_CHECK_CC,-fno-dwarf2-cfi-asm,)'
3088 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_m64 ?= $(call VBOX_GCC_CHECK_CC,-m64,)'
3089 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_msse4.1 ?= $(call VBOX_GCC_CHECK_CC,-msse4.1,)'
3090 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_mavx ?= $(call VBOX_GCC_CHECK_CC,-mavx,)'
3091 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_mavx2 ?= $(call VBOX_GCC_CHECK_CC,-mavx2,)'
3092 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_no-pie ?= $(call VBOX_GCC_CHECK_CC,-no-pie,)'
3093 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_fdiagnostics-show-option ?= $(call VBOX_GCC_CHECK_CC,-fdiagnostics-show-option,)'
3094 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wa_cma_nocompress_debug_sections ?= $(call VBOX_GCC_CHECK_CC,-Wa$(COMMA)--nocompress-debug-sections,)'
3095# Produce code optimized for the most common IA32/AMD64/EM64T processors. Introduced with gcc version 4.2.
3096 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_mtune-generic ?= $(call VBOX_GCC_CHECK_CC,-mtune=generic,)'
3097 $(QUIET)$(APPEND) '$@' 'VBOX_LD_as_needed ?= $(call VBOX_GCC_CHECK_LD,--as-needed,)'
3098 $(QUIET)$(APPEND) '$@' 'VBOX_LD_hash_style_sysv ?= $(call VBOX_GCC_CHECK_LD,--hash-style=sysv,)'
3099# Set default attribute for ELF and MACH-O symbols to ``hidden'' to reduce the number
3100# of relocation entries and PLT indirections in shared libraries. Don't allow for gcc version < 4.
3101 $(QUIET)$(APPEND) '$@' 'ifneq ($$(VBOX_GCC_VERSION_CC),)'
3102 $(QUIET)$(APPEND) '$@' ' if $$(VBOX_GCC_VERSION_CC) >= 40000'
3103 $(QUIET)$(APPEND) '$@' ' VBOX_GCC_fvisibility-hidden ?= $(call VBOX_GCC_CHECK_CC,-fvisibility=hidden -DVBOX_HAVE_VISIBILITY_HIDDEN -DRT_USE_VISIBILITY_DEFAULT,)'
3104 $(QUIET)$(APPEND) '$@' ' endif'
3105 $(QUIET)$(APPEND) '$@' 'endif'
3106ifn1of ($(KBUILD_TARGET),haiku)
3107# Set default attribute for inline functions to ``hidden'' to reduce the number
3108# of relocation entries and PLT indirections in shared libraries. Don't allow for gcc version < 4.
3109 $(QUIET)$(APPEND) '$@' 'ifneq ($$(VBOX_GCC_VERSION_CXX),)'
3110 $(QUIET)$(APPEND) '$@' ' if $$(VBOX_GCC_VERSION_CXX) >= 40000'
3111 $(QUIET)$(APPEND) '$@' ' VBOX_GCC_fvisibility-inlines-hidden ?= $(call VBOX_GCC_CHECK_CXX,-fvisibility-inlines-hidden,)'
3112 $(QUIET)$(APPEND) '$@' ' endif'
3113 $(QUIET)$(APPEND) '$@' 'endif'
3114endif
3115# Prevent warnings about unused parameters as of gcc-4.8 / clang 6 as this warning is now very verbose
3116 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-unused-parameter ?= $(call VBOX_GCC_CHECK_CC,-Wno-unused-parameter,)'
3117# Clang 6.
3118 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-language-extension-token ?= $(call VBOX_GCC_CHECK_CC,-Wno-language-extension-token,)'
3119 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-extended-offsetof ?= $(call VBOX_GCC_CHECK_CC,-Wno-extended-offsetof,)'
3120 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-gnu-folding-constant ?= $(call VBOX_GCC_CHECK_CC,-Wno-gnu-folding-constant,)'
3121 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-return-type-c-linkage ?= $(call VBOX_GCC_CHECK_CXX,-Wno-return-type-c-linkage,)'
3122 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-string-plus-int ?= $(call VBOX_GCC_CHECK_CC,-Wno-string-plus-int,)'
3123 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-nested-anon-types ?= $(call VBOX_GCC_CHECK_CC,-Wno-nested-anon-types,)'
3124 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-gnu-anonymous-struct ?= $(call VBOX_GCC_CHECK_CXX,-Wno-gnu-anonymous-struct,)'
3125# Clang 11.
3126 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-c++17-compat-mangling ?= $(call VBOX_GCC_CHECK_CXX,-Wno-c++17-compat-mangling,)'
3127 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-nullability-extension ?= $(call VBOX_GCC_CHECK_CXX,-Wno-nullability-extension,)'
3128 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-gnu-statement-expression ?= $(call VBOX_GCC_CHECK_CXX,-Wno-gnu-statement-expression,)'
3129 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-import-preprocessor-directive-pedantic ?= $(call VBOX_GCC_CHECK_CXX,-Wno-import-preprocessor-directive-pedantic,)'
3130 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-undefined-var-template ?= $(call VBOX_GCC_CHECK_CXX,-Wno-undefined-var-template,)'
3131 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-c11-extensions ?= $(call VBOX_GCC_CHECK_CXX,-Wno-c11-extensions,)'
3132 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_Wno-tautological-pointer-compare ?= $(call VBOX_GCC_CHECK_CC,-Wno-tautological-pointer-compare,)'
3133ifeq ($(KBUILD_TARGET),solaris)
3134 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_msave-args ?= $(call VBOX_GCC_CHECK_CXX,-msave-args,)'
3135# Detect the solaris assembler. It is used by the the 4.x gcc compilers,
3136# apparently. It will not be able to handle IEMAll via a -pipe, only when
3137# passed a file. The solaris assmbler rulez ... not!
3138 $(QUIET)$(APPEND) '$@' 'VBOX_AS_VERSION ?= $(shell `gcc -print-prog-name=as` -V -o /dev/null < /dev/null 2>&1 | kmk_sed -e '1!d' -e 's/^as: *//' )'
3139 $(QUIET)$(APPEND) '$@' 'if $$(pos Sun Compiler Common,$$(VBOX_AS_VERSION)) > 0'
3140 $(QUIET)$(APPEND) '$@' ' VBOX_GCC_USING_SOLARIS_AS=1'
3141 $(QUIET)$(APPEND) '$@' 'endif'
3142 $(QUIET)$(APPEND) '$@' 'ifndef VBOX_GCC_USING_SOLARIS_AS'
3143 $(QUIET)$(APPEND) '$@' ' VBOX_GCC_pipe ?= -pipe'
3144 $(QUIET)$(APPEND) '$@' 'endif'
3145else
3146 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_pipe ?= -pipe'
3147endif
3148# Find the compiler includes for IPRT no-crt.
3149# Note that `$(dir $(gcc -print-libgcc-file-name))/include does not work for a 64-bit cross build on a 32-bit build host.
3150ifeq ($(KBUILD_HOST),win)
3151# With the cygwin issues and gcc on windows returning a useless path, just skip this on windows.
3152 $(QUIET)$(APPEND) '$@' 'VBOX_PATH_GCC_INCS ?= '
3153else
3154 $(QUIET)$(APPEND) '$@' 'VBOX_PATH_GCC_INCS ?= $(shell LC_ALL=C $(TOOL_$(VBOX_GCC_TOOL)_CC) -print-search-dirs|$(SED_EXT) -ne 's+^install: \(.*[^/][^/]*\)/+\1+p')/include'
3155endif
3156# 32-bit (GC) compiler switch detection.
3157 $(QUIET)$(APPEND) '$@' 'VBOX_GCC32_PATH_CC ?= $(which $(TOOL_$(VBOX_GCC32_TOOL)_CC))'
3158 $(QUIET)$(APPEND) '$@' 'VBOX_GCC32_PATH_CXX ?= $(which $(TOOL_$(VBOX_GCC32_TOOL)_CXX))'
3159 $(QUIET)$(APPEND) '$@' 'VBOX_GCC32_VERSION_CC ?= $(call VBOX_GCC_VERSION,$(TOOL_$(VBOX_GCC32_TOOL)_CC))'
3160 $(QUIET)$(APPEND) '$@' 'VBOX_GCC32_VERSION_CXX ?= $(call VBOX_GCC_VERSION,$(TOOL_$(VBOX_GCC32_TOOL)_CXX))'
3161 $(QUIET)$(APPEND) '$@' 'VBOX_GCC32_LIBGCC ?= $(shell $(TOOL_$(VBOX_GCC32_TOOL)_CC) -print-libgcc-file-name)'
3162 $(QUIET)$(APPEND) '$@' 'VBOX_GCC32_Wno-variadic-macros ?= $(call VBOX_GCC32_CHECK_CXX,-Wno-variadic-macros,)'
3163# darwin no_compact_linkedit starting at Xcode 3.2
3164ifeq ($(KBUILD_HOST),darwin)
3165 $(QUIET)$(APPEND) '$@' 'VBOX_LD_no_compact_linkedit ?= $(call VBOX_GCC_CHECK_LD,-no_compact_linkedit,)'
3166endif
3167# YASM
3168 $(QUIET)$(APPEND) '$@' '# debug: TOOL_YASM_AS="$(TOOL_YASM_AS)"'
3169 $(QUIET)$(APPEND) '$@' 'VBOX_YASM_Wno-segreg-in-64bit ?= $(call VBOX_YASM_CHECK,-Wno-segreg-in-64bit,)'
3170# NASM (--allow-64-bit: 2.12rc2)
3171 $(QUIET)$(APPEND) '$@' 'VBOX_NASM_allow_64_bit ?= $(call VBOX_NASM_CHECK,--allow-64-bit,)'
3172if1of ($(KBUILD_TARGET), linux)
3173 ifeq ($(KBUILD_TARGET),$(KBUILD_HOST))
3174 $(QUIET)$(RM) -f -- "[email protected]" "[email protected]" '[email protected]'
3175 $(APPEND) -t '[email protected]' 'int foo() { return 42; }'
3176 $(QUIET)$(APPEND) '$@' 'VBOX_GCC_SANITIZER_SO_FILES := \'
3177 $(TOOL_$(VBOX_GCC_TOOL)_ENV_SETUP) $(TOOL_$(VBOX_GCC_TOOL)_CC) -fPIC -shared \
3178 $(VBOX_GCC_SANITIZER_FLAGS) $(VBOX_GCC_SANITIZER_LDFLAGS) -o "[email protected]" "[email protected]"
3179 ldd "[email protected]" | $(SED_EXT) --append '$@' -re '/lib(a|ub)san\.so/!d' -e 's/.* => //' -e 's/ \(0x[0-9a-fA-F]*\) *$(DOLLAR)/ \\/'
3180 $(QUIET)$(APPEND) '$@' ''
3181# $(QUIET)$(APPEND) '$@' 'VBOX_GCC32_SANITIZER_SO_FILES := \'
3182# $(TOOL_$(VBOX_GCC32_TOOL)_ENV_SETUP) $(TOOL_$(VBOX_GCC32_TOOL)_CC) -fPIC -shared \
3183# $(VBOX_GCC_SANITIZER_FLAGS) $(VBOX_GCC_SANITIZER_LDFLAGS) -o "[email protected]" "[email protected]"
3184# ldd "[email protected]" | $(SED_EXT) --append '$@' -re '/lib(a|ub)san\.so/!d' -e 's/.* => //' -e 's/ \(0x[0-9a-fA-F]*\) *$(DOLLAR)/ \\/'
3185# $(QUIET)$(APPEND) '$@' ''
3186 $(QUIET)$(RM) -f -- "[email protected]" "[email protected]" '[email protected]'
3187 endif
3188endif
3189ifdef VBOX_PATH_PREFIX_MINGW32
3190 $(QUIET)$(APPEND) '$@' 'VBOX_MINGW32_VERSION_CC ?= $(call VBOX_GCC_VERSION,$(VBOX_PATH_PREFIX_MINGW32)gcc -m32)'
3191 $(QUIET)$(APPEND) '$@' 'VBOX_MINGW32_VERSION_CXX ?= $(call VBOX_GCC_VERSION,$(VBOX_PATH_PREFIX_MINGW32)g++ -m32)'
3192 $(QUIET)$(APPEND) '$@' 'VBOX_MINGW32_Wno-array-bounds ?= $(call VBOX_GCC_CHECK_EX_CXX,$(VBOX_PATH_PREFIX_MINGW32)g++ -m32,-Wno-array-bounds,)'
3193 $(QUIET)$(APPEND) '$@' 'VBOX_MINGW32_Wno-unused-but-set-variable ?= $(call VBOX_GCC_CHECK_EX_CXX,$(VBOX_PATH_PREFIX_MINGW32)g++ -m32,-Wno-unused-but-set-variable,)'
3194 $(QUIET)$(APPEND) '$@' 'VBOX_MINGW32_Wno-maybe-uninitialized ?= $(call VBOX_GCC_CHECK_EX_CXX,$(VBOX_PATH_PREFIX_MINGW32)g++ -m32,-Wno-maybe-uninitialized,)'
3195 $(QUIET)$(APPEND) '$@' 'VBOX_MINGW32_USER_LABEL_PREFIX ?= $(shell echo "__USER_LABEL_PREFIX__" | $(VBOX_PATH_PREFIX_MINGW32)g++ -m32 -E -xc++ - | $(SED) -e "/^$(HASH)/d")'
3196endif
3197ifdef VBOX_PATH_PREFIX_MINGW64
3198 $(QUIET)$(APPEND) '$@' 'VBOX_MINGW64_VERSION_CC ?= $(call VBOX_GCC_VERSION,$(VBOX_PATH_PREFIX_MINGW64)gcc -m64)'
3199 $(QUIET)$(APPEND) '$@' 'VBOX_MINGW64_VERSION_CXX ?= $(call VBOX_GCC_VERSION,$(VBOX_PATH_PREFIX_MINGW64)g++ -m64)'
3200 $(QUIET)$(APPEND) '$@' 'VBOX_MINGW64_Wno-array-bounds ?= $(call VBOX_GCC_CHECK_EX_CXX,$(VBOX_PATH_PREFIX_MINGW64)g++ -m64,-Wno-array-bounds,)'
3201 $(QUIET)$(APPEND) '$@' 'VBOX_MINGW64_Wno-unused-but-set-variable ?= $(call VBOX_GCC_CHECK_EX_CXX,$(VBOX_PATH_PREFIX_MINGW64)g++ -m64,-Wno-unused-but-set-variable,)'
3202 $(QUIET)$(APPEND) '$@' 'VBOX_MINGW64_Wno-maybe-uninitialized ?= $(call VBOX_GCC_CHECK_EX_CXX,$(VBOX_PATH_PREFIX_MINGW64)g++ -m64,-Wno-maybe-uninitialized,)'
3203 $(QUIET)$(APPEND) '$@' 'VBOX_MINGW64_USER_LABEL_PREFIX ?= $(shell echo "__USER_LABEL_PREFIX__" | $(VBOX_PATH_PREFIX_MINGW64)g++ -m64 -E -xc++ - | $(SED) -e "/^$(HASH)/d")'
3204endif
3205ifeq ($(KBUILD_HOST),darwin)
3206 $(QUIET)$(APPEND) '$@' 'VBOX_HAVE_FLEX ?= 1'
3207 $(QUIET)$(APPEND) '$@' 'VBOX_HAVE_BISON ?= 1'
3208else
3209 $(QUIET)$(APPEND) '$@' 'VBOX_HAVE_FLEX ?= $(if $(which flex),1,)'
3210 $(QUIET)$(APPEND) '$@' 'VBOX_HAVE_BISON ?= $(if $(which bison),1,)'
3211endif
3212 $(QUIET)$(APPEND) '$@' 'VBOX_HAVE_XMLLINT ?= $(which xmllint)'
3213if "$(KBUILD_HOST)" == "solaris" && $(KBUILD_HOST_VERSION_MAJOR) == 5 && $(KBUILD_HOST_VERSION_MINOR) == 11
3214# BRANCH_VERSION format on S11 - S11.3:
3215# <trunk_id>.<update>.<sru>.<reserved>.<buildid>.<nightly_id>
3216# e.g.: 0.175.3.32.0.4.0:20180427T232405Z - N.B. trunk_id = 0.175
3217# BRANCH_VERSION format on S11.4:
3218# <minor>.<update>.<sru>.<reserved>.<reserved>.<buildid>.<nightly_id>
3219# e.g.: 11.4.0.0.1.10.0:20180702T173343Z
3220# We're interested in <update> and <buildid>.
3221 $(QUIET)$(APPEND) '$@' "VBOX_SOLARIS_11_BRANCH_VERSION := $(shell pkg contents -H -t set -o pkg.fmri system/kernel | $(SED_EXT) -e '1!d' -e 's/^.*\-//;s/\:.*//;s/.*,//')"
3222 $(QUIET)$(APPEND) '$@' 'ifeq ($$(word 2, $$(subst ., ,$$(VBOX_SOLARIS_11_BRANCH_VERSION))),175)'
3223 $(QUIET)$(APPEND) '$@' ' VBOX_SOLARIS_11_UPDATE_VERSION := $$(word 3, $$(subst ., ,$$(VBOX_SOLARIS_11_BRANCH_VERSION)))'
3224 $(QUIET)$(APPEND) '$@' 'else'
3225 $(QUIET)$(APPEND) '$@' ' VBOX_SOLARIS_11_UPDATE_VERSION := $$(word 2, $$(subst ., ,$$(VBOX_SOLARIS_11_BRANCH_VERSION)))'
3226 $(QUIET)$(APPEND) '$@' 'endif'
3227 $(QUIET)$(APPEND) '$@' 'VBOX_SOLARIS_11_BUILD_VERSION := $$(word 6, $$(subst ., ,$$(VBOX_SOLARIS_11_BRANCH_VERSION)))'
3228endif
3229if1of ($(KBUILD_HOST), darwin freebsd solaris)
3230 $(QUIET)$(APPEND) '$@' 'VBOX_HOST_DTRACE_VERSION := $(shell dtrace -V)'
3231endif
3232if defined(VBOX_PYLINT) && !defined(VBOX_WITH_PYLINT_PRE_V1_0) && !defined(VBOX_WITH_PYLINT_V1_1_PLUS) && !defined(VBOX_WITH_PYLINT_V1_2_1_PLUS)
3233 $(QUIET)$(APPEND) '$@' "VBOX_PYLINT_VERSION := $(call VBOX_PYLINT_FIGURE_VERSION, $(VBOX_PYLINT))"
3234endif
3235if defined(VBOX_JAVAC)
3236 $(QUIET)$(APPEND) '$@' 'VBOX_JAVA_VERSION := $(call VBOX_JAVA_FIGURE_VERSION, $(VBOX_JAVAC))'
3237endif
3238
3239 $(QUIET)$(ECHO) '========= START OF $@ ========='
3240 $(QUIET)$(CAT) $@
3241 $(QUIET)$(ECHO) '=========== END OF $@ ========='
3242
3243include $(PATH_OUT)/DynamicConfig.kmk
3244endif # !VBOX_NOINC_DYNAMIC_CONFIG_KMK
3245
3246
3247#
3248# C++ language level.
3249## @todo consider maxing this.
3250#
3251ifndef VBOX_GCC_std
3252 ## @todo rewrite using "$(VBOX_CLANG_VERSION_CXX)" vge 50000 so we can skip the ifneq stuff here.
3253 ifneq ($(VBOX_CLANG_VERSION_CXX),)
3254 if $(VBOX_CLANG_VERSION_CXX) >= 50000 # darwin Xcode 5 allegedly knows what C++11 is
3255VBOX_GCC_std := -std=c++11
3256 endif
3257 endif
3258 if "$(VBOX_GCC_VERSION_CXX)" != "" && !defined(VBOX_GCC_std)
3259 if $(VBOX_GCC_VERSION_CXX) >= 40800
3260VBOX_GCC_std := -std=c++11
3261 else if $(VBOX_GCC_VERSION_CXX) >= 40600
3262VBOX_GCC_std := -std=c++0x
3263 endif
3264 endif
3265endif
3266
3267
3268#
3269# Compiler warning control.
3270#
3271VBOX_GCC_WARN ?= -Wall $(VBOX_GCC_Wextra) $(VBOX_GCC_Wno-missing-field-initializers) -Wno-unused -Wno-trigraphs \
3272 $(VBOX_GCC_fdiagnostics-show-option) $(VBOX_GCC_Wno-unused-parameter) $(VBOX_GCC_Wno-language-extension-token) \
3273 $(VBOX_GCC_Wno-extended-offsetof) $(VBOX_GCC_Wno-gnu-folding-constant) $(VBOX_GCC_Wno-gnu-anonymous-struct) \
3274 $(VBOX_GCC_Wlogical-op) $(VBOX_GCC_Wno-string-plus-int) $(VBOX_GCC_Wno-nested-anon-types) $(VBOX_GCC_Wno-variadic-macros) \
3275 $(VBOX_GCC_Wno-c++17-compat-mangling)
3276VBOX_GCC_WARN_PEDANTIC = -Wshadow $(VBOX_GCC_WARN) -Wno-long-long
3277if $(VBOX_GCC_VERSION_CXX) >= 40200 || defined(VBOX_WITH_MASOCHISTIC_WARNINGS) # gcc 4.2.x+ (4.1.2 is causing trouble with the extpack & add builds)
3278 VBOX_GCC_WARN_MASOCHISTIC ?= -Wunused-variable -Wunused-function -Wunused-label -Wunused-parameter
3279endif
3280if $(KBUILD_TARGET) == "linux" \
3281 || ($(KBUILD_TARGET) == "darwin" && "$(VBOX_GCC_TOOL)" != "GXX4MACHO" && "$(VBOX_GCC_TOOL)" != "GXX42MACHO") \
3282 || defined(VBOX_WITH_MASOCHISTIC_WARNINGS)
3283 VBOX_GCC_WARN_PEDANTIC += $(VBOX_GCC_WARN_MASOCHISTIC)
3284endif
3285
3286VBOX_GCC_PEDANTIC_CXX ?= -pedantic $(VBOX_GCC_WARN_PEDANTIC) $(VBOX_GCC_Wno-return-type-c-linkage) $(VBOX_GCC_Wno-overloaded-virtual) $(VBOX_GCC_Wno-undefined-var-template)
3287VBOX_GCC_PEDANTIC_C ?= -pedantic $(VBOX_GCC_WARN_PEDANTIC) -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Werror-implicit-function-declaration
3288
3289# Avoid freaking out when using flexible arrays in C++ code (ldrPE.cpp, ++).
3290if ($(VBOX_GCC_VERSION_CXX) < 60100 || $(VBOX_GCC_VERSION_CXX) >= 70000) && "$(VBOX_GCC_Wno-array_bounds)" != ""
3291 VBOX_GCC_PEDANTIC_CXX += $(VBOX_GCC_Wno-array_bounds)
3292endif
3293# Stupid problem with (__typeof__((*ppv)) casts in asm.h where volatile is involved and ignored.
3294if $(VBOX_GCC_VERSION_CXX) >= 80000 && "$(VBOX_GCC_Wno-ignored-qualifiers)"
3295 VBOX_GCC_PEDANTIC_CXX += $(VBOX_GCC_Wno-ignored-qualifiers)
3296endif
3297
3298
3299VBOX_GCC_NON_PEDANTIC_CXX ?= -Wno-sign-compare
3300VBOX_GCC_NON_PEDANTIC_C ?= -Wno-sign-compare -Werror-implicit-function-declaration
3301
3302if "$(KBUILD_TARGET)" == "darwin" && "$(VBOX_GCC_TOOL)" != "GXX4MACHO" && "$(VBOX_GCC_TOOL)" != "GXX42MACHO"
3303 VBOX_GCC_PEDANTIC_CXX += -Wno-c99-extensions
3304 VBOX_GCC_NON_PEDANTIC_CXX += -Wno-c99-extensions
3305endif
3306
3307
3308# Disabled Visual C++ warnings, W4:
3309# -wd4065: switch statement contains 'default' but no 'case' labels
3310# -wd4996: deprecated / insecure.
3311# -wd4127: conditional expression is constant [level 4]
3312# -wd4706: assignment within conditional expression [level 4]
3313# -wd4201: nonstandard extension used : nameless struct/union [level 4]
3314# -wd4214: nonstandard extension used : bit field types other than int [level 4]
3315# -wd4510: 'VM::<unnamed-tag>' : default constructor could not be generated
3316# -wd4512: 'VM' : assignment operator could not be generated
3317# -wd4610: union 'VM::<unnamed-tag>' can never be instantiated - user defined constructor required
3318# Disabled Visual C++ warnings, Wall:
3319# -wd4514: unreferenced inline function has been removed
3320# -wd4820: 'RTSTRSPACECORE' : '7' bytes padding added after data member 'RTSTRSPACECORE::uchHeight'
3321# -wd4365: '=' : conversion from 'unsigned char' to 'char', signed/unsigned mismatch
3322# -wd4987: nonstandard extension used: 'throw (...)' (setjmp.h + our stuff)
3323# -wd4710: 'std::string std::_Narrow_str(std::wstring)' : function not inlined
3324# -wd4061: enumerator 'RTASN1TYPE_END' in switch of enum 'RTASN1TYPE' is not explicitly handled by a case label
3325# Note! C4062 checks for the same but includes the 'default' case, just like gcc. So, no trouble disabling this.
3326# -wd4986: 'operator new[]': exception specification does not match previous declaration (crtdbg.h vs new, exception specification only)
3327# -wd4191: 'type cast' : unsafe conversion from 'int (__cdecl *)(gzFile)' to 'PFNRT'
3328# -wd4574: 'INCL_WINSOCK_API_TYPEDEFS' is defined to be '0': did you mean to use '#if INCL_WINSOCK_API_TYPEDEFS'?
3329# -wd4917: 'OLE_XPOS_HIMETRIC' : a GUID can only be associated with a class, interface or namespace
3330# -wd4711: function 'void __cdecl rtMemCacheFreeOne(struct RTMEMCACHEINT * __ptr64,void * __ptr64)' selected for automatic inline expansion
3331# -wd4571: Informational: catch(...) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught
3332# -wd4611: interaction between '_setjmp' and C++ object destruction is non-portable
3333# -wd4324: '_TDI_PNP_CONTEXT_XP' : structure was padded due to __declspec(align())
3334# -wd4505: VBoxNetFltNobj.h(45) : warning C4505: 'VBoxNetFltNobj::Release' : unreferenced local function has been removed
3335# Probably related to http://stackoverflow.com/questions/3051992/compiler-warning-at-c-template-base-class
3336# -wd4263: 'int VRDPChannelClipboard::SendPacket(const void *,uint32_t)' : member function does not override any base class virtual member function
3337# Probably useful, but impractical, just like the next one.
3338# -wd4264: 'int VRDPOutputCtx::SendPacket(void)' : no override available for virtual member function from base 'VRDPOutputCtx'; function is hidden
3339# -wd4738: storing 32-bit float result in memory, possible loss of performance
3340# -wd4371: UIActionPool.h(393) : warning C4371: 'UIActionPool::PointerToFunction' : layout of class may have changed from a previous version of the compiler due to better packing of member 'UIActionPool::PointerToFunction::ptfr'
3341# -wd4748: uiactionpoolmanager.cpp(2723) : warning C4748: /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function
3342# Want to enable these:
3343# -wd4242: '=' : conversion from 'uint32_t' to 'uint8_t', possible loss of data
3344# -wd4244: 'conversion' conversion from 'type1' to 'type2', possible loss of data
3345# -wd4200: nonstandard extension used : zero-sized array in struct/union
3346# Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array
3347VBOX_VCC_WARN_ALL := -W4 -Wall -wd4065 -wd4996 -wd4127 -wd4706 -wd4201 -wd4214 -wd4510 -wd4512 -wd4610 \
3348 -wd4514 -wd4820 -wd4365 -wd4987 -wd4710 -wd4061 -wd4986 -wd4191 -wd4574 -wd4917 -wd4711 -wd4611 -wd4571 -wd4324 -wd4505 \
3349 -wd4263 -wd4264 -wd4738 -wd4200 -wd4371 -wd4748
3350if1of ($(VBOX_VCC_TOOL_STEM), VCC120)
3351 # -wd4350: behavior change: 'std::_Wrap_alloc<std::allocator<char>>::_Wrap_alloc(const std::_Wrap_alloc<std::allocator<char>> &) throw()' called instead of 'std::_Wrap_alloc<std::allocator<char>>::_Wrap_alloc<std::_Wrap_alloc<std::allocator<char>>>(_Other &) throw()'
3352 # -wd4435: iprt/cpp/xml.h(185) : warning C4435: 'xml::Input' : Object layout under /vd2 will change due to virtual base 'xml::Stream'
3353 VBOX_VCC_WARN_ALL += -wd4350 -wd4435
3354 VBOX_VCC120_WARN_ALL := $(VBOX_VCC_WARN_ALL)
3355endif
3356if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
3357 # -wd5045: Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
3358 # -wd5039: 'RTStrSpaceDestroy': pointer or reference to potentially throwing function passed to extern C function under -EHc. Undefined behavior may occur if this function throws an exception.
3359 # -wd4464: relative include path contains '..' (iprt/nocrt/compiler.msc.h)
3360 # -wd4623: 'VM': default constructor was implicitly defined as deleted
3361 # -wd4625: 'SUPDRVTRACERDATA': copy constructor was implicitly defined as deleted
3362 # -wd4626: 'SUPDRVTRACERDATA': assignment operator was implicitly defined as deleted
3363 # -wd5026: 'SUPDRVTRACERDATA': move constructor was implicitly defined as deleted
3364 # -wd5027: 'SUPDRVTRACERDATA': move assignment operator was implicitly defined as deleted
3365 # -wd4435: 'xml::Input': Object layout under /vd2 will change due to virtual base 'xml::Stream'
3366 VBOX_VCC_WARN_ALL += -wd5045 -wd4464 -wd4623 -wd4625 -wd4626 -wd5026 -wd5027 -wd4435
3367endif
3368VBOX_VCC_WARN_ALL += -wd4242 -wd4244
3369ifndef VBOX_NEWER_VCC_WARN_ALL
3370 if "$(VBOX_VCC_TOOL_STEM)" < "VCC120"
3371 VBOX_NEWER_VCC_WARN_ALL := $(VBOX_VCC_WARN_ALL) -wd4350 -wd4435
3372 else
3373 VBOX_NEWER_VCC_WARN_ALL := $(VBOX_VCC_WARN_ALL)
3374 endif
3375endif
3376
3377
3378# Disable pedantic warnings for NP/NonPedantic templates.
3379# -wd4131: 'bi_flush' : uses old-style declarator
3380# -wd4255: 'tr_static_init' : no function prototype given: converting '()' to '(void)'
3381# -wd4668: '_WIN32_WCE' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'/
3382# -wd4100: 'cinfo' : unreferenced formal parameter
3383# -wd4189: 'sz' : local variable is initialized but not referenced
3384# -wd4132: 'xmlStringComment' : const object should be initialized
3385# -wd4152: nonstandard extension, function/data pointer conversion in expression
3386# -wd4702: unreachable code
3387# -wd4057: '=' : 'xmlChar *' differs in indirection to slightly different base types from 'char *'
3388# -wd4296: '>=' : expression is always true
3389# -wd4389: '==' : signed/unsigned mismatch
3390# -wd4018: '<=' : signed/unsigned mismatch
3391# -wd4245: '=' : conversion from 'int' to 'unsigned int', signed/unsigned mismatch
3392# -wd4267: '+=' : conversion from 'size_t' to 'long', possible loss of data
3393# -wd4295: 'vendor_string' : array is too small to include a terminating null character
3394VBOX_VCC_NON_PEDANTIC = -wd4131 -wd4255 -wd4668 -wd4100 -wd4189 -wd4132 -wd4152 -wd4702 -wd4057 -wd4296 -wd4389 -wd4018 -wd4245 \
3395 -wd4267 -wd4295
3396VBOX_NEWER_VCC_NON_PEDANTIC = $(VBOX_VCC_NON_PEDANTIC)
3397
3398ifeq ($(KBUILD_TARGET),win)
3399 VBOX_C_CXX_FLAGS_NO_UNUSED_PARAMETERS = -wd4100
3400else
3401 VBOX_C_CXX_FLAGS_NO_UNUSED_PARAMETERS = -Wno-unused-parameter
3402endif
3403
3404#
3405# Compiler optimization flags.
3406#
3407ifeq ($(KBUILD_TYPE),debug)
3408 VBOX_GCC_FP ?= -fno-omit-frame-pointer
3409 VBOX_GCC_OPT ?= -O0
3410 VBOX_VCC_FP ?= -Oy-
3411 VBOX_VCC_OPT ?=
3412 VBOX_GCC_R0_FP ?= -fno-omit-frame-pointer -fno-optimize-sibling-calls
3413 VBOX_GCC_R0_OPT ?= -O2
3414 VBOX_VCC_R0_FP ?= -Oy-
3415 VBOX_VCC_R0_OPT ?=
3416 VBOX_GCC_GC_FP ?= -fno-omit-frame-pointer -fno-optimize-sibling-calls
3417 VBOX_GCC_GC_OPT ?= -O2
3418 VBOX_VCC_GC_FP ?= -Oy-
3419 VBOX_VCC_GC_OPT ?=
3420else
3421 # We should use -fomit-frame-pointer for GCC / -Oy for VCC.
3422 # -funwind-tables provides support for backtraces in gdb then.
3423 VBOX_GCC_FP ?= -fno-omit-frame-pointer
3424 VBOX_GCC_OPT ?= -O2 $(VBOX_GCC_mtune-generic)
3425 VBOX_VCC_FP ?= -Oy-
3426 VBOX_VCC_OPT ?= -O2
3427 VBOX_GCC_R0_FP ?= -fno-omit-frame-pointer
3428 VBOX_GCC_R0_OPT ?= -O2 $(VBOX_GCC_mtune-generic)
3429 VBOX_VCC_R0_FP ?= -Oy-
3430 VBOX_VCC_R0_OPT ?= -O2
3431 VBOX_GCC_GC_FP ?= -fno-omit-frame-pointer
3432 VBOX_GCC_GC_OPT ?= -O2 $(VBOX_GCC_mtune-generic)
3433 VBOX_VCC_GC_FP ?= -Oy-
3434 VBOX_VCC_GC_OPT ?= -O2
3435endif
3436ifeq ($(KBUILD_TARGET_ARCH),x86)
3437 ifneq ($(KBUILD_TARGET),darwin)
3438 # (The '<=' operator is for prepending (kmk specific).)
3439 VBOX_GCC_OPT <= -march=i586
3440 endif
3441endif
3442
3443
3444#
3445# Select the CRT type we're using with Microsoft Visual C++.
3446#
3447if1of ($(KBUILD_TYPE), debug dbgopt strict)
3448#not yet# VBOX_WITH_DEBUG_VCC_CRT = 1
3449endif
3450ifdef VBOX_WITH_DEBUG_VCC_CRT
3451 VBOX_VCC_CRT_TYPE = d
3452 VBOX_VCC_CRT_TYPE_N =
3453else
3454 VBOX_VCC_CRT_TYPE =
3455 VBOX_VCC_CRT_TYPE_N = d
3456endif
3457
3458
3459#
3460# Warnings as errors.
3461#
3462# GCC: We disable warnings on non-X86 systems because of the variadic
3463# macro usage in the logger.
3464#
3465ifdef VBOX_WITH_WARNINGS_AS_ERRORS
3466 if $(VBOX_GCC_VERSION_CXX) >= 40000
3467 VBOX_GCC_WERR ?= -Werror
3468 endif
3469 VBOX_VCC_WERR ?= -WX
3470 VBOX_VCC_LD_WERR ?= ## @todo later also: -WX
3471endif
3472
3473#
3474# The general GCC/Clang no warning policy.
3475#
3476# Note! This doesn't control everything. Instead set VBOX_GCC_WERR=$(NO_SUCH_VARIABLE) to
3477# completely disable -Werror.
3478#
3479if !defined(VBOX_WITHOUT_NO_GCC_WARNING_POLICY) && !defined(VBOX_WITH_NO_GCC_WARNING_POLICY)
3480 if defined(VBOX_WITH_MASOCHISTIC_WARNINGS) # gcc 4.6.x+
3481 VBOX_WITH_NO_GCC_WARNING_POLICY = 1
3482 else if "$(KBUILD_TARGET)" == "darwin"
3483 ifn1of ($(VBOX_GCC_TOOL), GXX4MACHO GXX42MACHO)
3484 VBOX_WITH_NO_GCC_WARNING_POLICY = 1
3485 endif
3486 else if1of ($(KBUILD_TARGET), linux)
3487 if $(VBOX_GCC_VERSION_CXX) >= 40600 # gcc 4.6.x+
3488 VBOX_WITH_NO_GCC_WARNING_POLICY = 1
3489 endif
3490 endif
3491endif
3492ifdef VBOX_WITH_NO_GCC_WARNING_POLICY
3493 $(info build debug: VBOX_WITH_NO_GCC_WARNING_POLICY is enabled)
3494endif
3495
3496#
3497# Misc stuff that should be after including DynamicConfig.kmk.
3498#
3499
3500# libxml XML linter.
3501ifeq ($(VBOX_XMLLINT),)
3502 ifeq ($(KBUILD_HOST),win)
3503 VBOX_XMLLINT := $(wildcard $(KBUILD_DEVTOOLS)/$(KBUILD_HOST).$(KBUILD_HOST_ARCH)/libxslt/10128/bin/xmllint.exe)
3504 endif
3505 ifeq ($(VBOX_XMLLINT),)
3506 VBOX_XMLLINT := $(VBOX_HAVE_XMLLINT)
3507 endif
3508 ifneq ($(VBOX_XMLLINT),)
3509 VBOX_HAVE_XMLLINT := 1
3510 else
3511 VBOX_XMLLINT := xmllint
3512 VBOX_HAVE_XMLLINT :=
3513 endif
3514else
3515 VBOX_HAVE_XMLLINT := 1
3516endif
3517
3518
3519
3520#
3521# Misc macros.
3522#
3523
3524##
3525# Edits VirtualBox version, vendor and package strings in a text file.
3526#
3527# The rule using this must list $(VBOX_SVN_REV_KMK) as a prerequisite.
3528#
3529# @param 1 The input filename.
3530# @param 2 The output filename.
3531#
3532VBOX_EDIT_VERSION_CMD_FN = $(SED) \
3533 -e 's/@VBOX_VERSION_MAJOR@/$(VBOX_VERSION_MAJOR)/g' \
3534 -e 's/@VBOX_VERSION_MINOR@/$(VBOX_VERSION_MINOR)/g' \
3535 -e 's/@VBOX_VERSION_BUILD@/$(VBOX_VERSION_BUILD)/g' \
3536 -e 's/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g' \
3537 -e 's/@VBOX_SVN_REV@/$(VBOX_SVN_REV)/g' \
3538 -e 's/@VBOX_VENDOR@/$(VBOX_VENDOR)/g' \
3539 -e 's/@VBOX_VENDOR_SHORT@/$(VBOX_VENDOR_SHORT)/g' \
3540 -e 's/@VBOX_PRODUCT@/$(VBOX_PRODUCT)/g' \
3541 -e 's/@VBOX_C_YEAR@/$(VBOX_C_YEAR)/g' \
3542 -e 's/@VBOX_PACKAGE_STRING@/$(VBOX_PACKAGE_STRING)/g' \
3543 --output $(2) $(1)
3544
3545##
3546# Generates a rule for editing a file using VBOX_EDIT_VERSION_CMD_FN.
3547#
3548# @param 1 The target name.
3549# @param 2 The input filename relative to the current sub-makefile.
3550# @param 3 The output filename relative to the target output dir.
3551# Optional, defaults to 2.
3552#
3553VBOX_EDIT_VERSION_RULE_FN = $(eval $(value VBOX_EDIT_VERSION_RULE_DEF))
3554define VBOX_EDIT_VERSION_RULE_DEF
3555$$($(1)_0_OUTDIR)/$(if $(3),$(3),$(2)): $(PATH_SUB_CURRENT)/$(2) $(VBOX_SVN_REV_KMK) | $$(dir $$@)
3556 $(call MSG_GENERATE,$(1),$@,$<)
3557 $(QUIET)$(call VBOX_EDIT_VERSION_CMD_FN,$<,$@)
3558$(eval $(1)_CLEAN += $$($(1)_0_OUTDIR)/$(if $(3),$(3),$(2)))
3559endef
3560
3561
3562##
3563# Edits VirtualBox version, vendor, package, build target, build arch, and build type strings in a text file.
3564#
3565# Please use VBOX_EDIT_VERSION_AND_BUILD_RULE_FN to generate edit rule.
3566#
3567# @param 1 The input filename.
3568# @param 2 The output filename.
3569#
3570VBOX_EDIT_VERSION_AND_BUILD_CMD_FN = $(SED) \
3571 -e 's/@VBOX_VERSION_MAJOR@/$(VBOX_VERSION_MAJOR)/g' \
3572 -e 's/@VBOX_VERSION_MINOR@/$(VBOX_VERSION_MINOR)/g' \
3573 -e 's/@VBOX_VERSION_BUILD@/$(VBOX_VERSION_BUILD)/g' \
3574 -e 's/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g' \
3575 -e 's/@VBOX_SVN_REV@/$(VBOX_SVN_REV)/g' \
3576 -e 's/@VBOX_VENDOR@/$(VBOX_VENDOR)/g' \
3577 -e 's/@VBOX_VENDOR_SHORT@/$(VBOX_VENDOR_SHORT)/g' \
3578 -e 's/@VBOX_PRODUCT@/$(VBOX_PRODUCT)/g' \
3579 -e 's/@VBOX_C_YEAR@/$(VBOX_C_YEAR)/g' \
3580 -e 's/@VBOX_PACKAGE_STRING@/$(VBOX_PACKAGE_STRING)/g' \
3581 -e 's/@KBUILD_TYPE@/$(KBUILD_TYPE)/g' \
3582 -e 's/@KBUILD_TARGET@/$(KBUILD_TARGET)/g' \
3583 -e 's/@KBUILD_TARGET_ARCH@/$(KBUILD_TARGET_ARCH)/g' \
3584 --output $(2) $(1)
3585
3586##
3587# Generates a rule for editing a file using VBOX_EDIT_VERSION_CMD_FN.
3588#
3589# @param 1 The target name.
3590# @param 2 The input filename relative to the current sub-makefile.
3591# @param 3 The output filename relative to the target output dir.
3592# Optional, defaults to 2.
3593#
3594VBOX_EDIT_VERSION_AND_BUILD_RULE_FN = $(eval $(VBOX_EDIT_VERSION_AND_BUILD_RULE_DEF))
3595define VBOX_EDIT_VERSION_AND_BUILD_RULE_DEF
3596$$$$($(1)_0_OUTDIR)/$(if $(3),$(3),$(2)): $$(PATH_SUB_CURRENT)/$(2) $$(VBOX_SVN_REV_KMK) | $$$$(dir $$$$@)
3597 $$(call MSG_GENERATE,$(1),$$@,$$<)
3598 $$(QUIET)$$(call VBOX_EDIT_VERSION_AND_BUILD_CMD_FN,$$<,$$@)
3599$(1)_CLEAN += $$($(1)_0_OUTDIR)/$(if $(3),$(3),$(2))
3600endef
3601
3602
3603##
3604# Fill in am import library target based on a somewhat special windows .def file.
3605#
3606# @param 1 The target name of the import library.
3607# @param 2 The name of the real library.
3608# @param 3 The .def-file paths relative to the current makefile.
3609#
3610VBOX_GENERATE_IMPORT_TARGET_FN = $(eval $(VBOX_GENERATE_IMPORT_TARGET_DEF))
3611define VBOX_GENERATE_IMPORT_TARGET_DEF
3612$(1)_TEMPLATE = VBoxR3Dll
3613$(1)_INST = $(INST_LIB)
3614if $(KBUILD_TARGET) == "darwin"
3615 $(1)_LDFLAGS = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/$(2)$(SUFF_DLL)
3616else ifn1of ($(KBUILD_TARGET), os2 win)
3617 $(1)_SONAME = $(2)$(SUFF_DLL)
3618endif
3619if1of ($(KBUILD_TARGET), os2 win)
3620 $(1)_SOURCES = $$($(1)_0_OUTDIR)/$(1)Imp.def
3621 $(1)_CLEAN = $$($(1)_0_OUTDIR)/$(1)Imp.def
3622else
3623 $(1)_SOURCES = $$($(1)_0_OUTDIR)/$(1)Imp.c
3624 $(1)_CLEAN = $$($(1)_0_OUTDIR)/$(1)Imp.c
3625endif
3626
3627$$$$($(1)_SOURCES): $(addprefix $(PATH_SUB_CURRENT)/,$(3)) $(PATH_ROOT)/src/bldprogs/deftoimp.sed | $$$$(dir $$$$@)
3628 $$(call MSG_GENERATE,,$$@)
3629ifeq ($(KBUILD_TARGET),os2)
3630 $$(SED) \
3631 -e '/not-$(KBUILD_TARGET)/d' \
3632 -e '/not-$(KBUILD_TARGET_ARCH)/d' \
3633 -e 's/^LIBRARY[[:space:]][[:space:]]*\(.*\)\.dll/LIBRARY \1 INITINSTANCE TERMINSTANCE\nDATA MULTIPLE\n/' \
3634 -e 's/^[ \t][ \t]*\([_a-zA-Z]\)/ _\1/' \
3635 -e 's/[ \t]DATA[ \t]*/ /' \
3636 --output $$@ $(addprefix $(PATH_SUB_CURRENT)/,$(3))
3637else ifeq ($(KBUILD_TARGET),win)
3638 $$(SED) \
3639 -e '/not-$(KBUILD_TARGET)/d' \
3640 -e '/not-$(KBUILD_TARGET_ARCH)/d' \
3641 --output $$@ $(addprefix $(PATH_SUB_CURRENT)/,$(3))
3642else
3643 $$(QUIET)$$(APPEND) -tn $$@ \
3644 '#ifdef VBOX_HAVE_VISIBILITY_HIDDEN' \
3645 '# define EXPORT __attribute__((visibility("default")))' \
3646 '# define EXPORT_DATA __attribute__((visibility("default")))' \
3647 '#else' \
3648 '# define EXPORT' \
3649 '# define EXPORT_DATA' \
3650 '#endif' \
3651 ''
3652 $$(SED) \
3653 -e '/not-$(KBUILD_TARGET)/d' \
3654 -e '/not-$(KBUILD_TARGET_ARCH)/d' \
3655 -f $(PATH_ROOT)/src/bldprogs/deftoimp.sed \
3656 --append $$@ $(addprefix $(PATH_SUB_CURRENT)/,$(3))
3657endif
3658endef # VBOX_GENERATE_IMPORT_TARGET_DEF
3659
3660
3661#
3662# Code Signing.
3663#
3664# There are two signing modes; 'test' and 'release'.
3665# - The 'test' mode is tailored local development, where typically test
3666# certificates are involved. Only the bar minimum of files are signed and
3667# nothing is timestamped (if we can control timestamping) in order to reduce
3668# build time and to allow working offline.
3669# - The 'release' mode is tailored for creating builds that are give to other
3670# people, like the ones the build servers create. As much as possible is
3671# signed and timestamped.
3672#
3673ifdef VBOX_SIGNING_MODE
3674 VBOX_SIGNING_MODE := $(strip $(VBOX_SIGNING_MODE))
3675 ifn1of ($(VBOX_SIGNING_MODE), test release)
3676 $(error VBOX_SIGNING_MODE must be either 'test' or 'release'. The value '$(VBOX_SIGNING_MODE)' is not recognized.)
3677 endif
3678 VBOX_RETRY ?= $(ASH) $(KBUILD_DEVTOOLS)/bin/retry.sh
3679 # temporary solution for a $(dir ...) equivalent which assumes that it gets a single path, possibly with spaces.
3680 VBOX_DIRX = $(subst ?,$(SP),$(dir $(subst $(SP),?,$1)))
3681 # Corp code signing client.
3682 VBOX_CCS_CLIENT_JAR := $(firstword $(rsort \
3683 $(wildcard $(KBUILD_DEVTOOLS)/common/ccs/v*/Client.jar)) \
3684 $(KBUILD_DEVTOOLS)/common/ccs/notfound/Client.jar )
3685 VBOX_CCS_USER ?= virtualbox_grp
3686 VBOX_CCS_GLOBAL_UID ?= non-of-your-business
3687 VBOX_CCS_SERVER ?= UK
3688 ##
3689 # Corp Code Signing command line.
3690 # @param $1 Signing method: solaris_elf, solaris_pkg, driver (microsoft), ...
3691 # @param $2 The file to be submitted for signing.
3692 # @param $3 The directory to put the signed file in. Defaults to $(dir $2).
3693 # @param $4 Additional options.
3694 VBOX_CCS_SIGN_CMD = $(VBOX_RETRY) $(VBOX_JAVA) -jar "$(VBOX_CCS_CLIENT_JAR)" \
3695 sign -user "$(VBOX_CCS_USER)" -global_uid "$(VBOX_CCS_GLOBAL_UID)" \
3696 -job_timeout 90 -server_timeout 75 -server "$(VBOX_CCS_SERVER)" \
3697 -sign_method "$1" -file_to_sign "$2" -signed_location "$(if $3,$3,$(call VBOX_DIRX,$2))" $4
3698
3699 ifeq ($(KBUILD_HOST),win)
3700 #
3701 # Windows
3702 #
3703
3704 # VBOX_PATH_SELFSIGN points to the Vista WDK bin/SelfSign directory.
3705 ifndef VBOX_PATH_SELFSIGN
3706 VBOX_PATH_SELFSIGN := $(firstword $(rsort $(wildcard $(KBUILD_DEVTOOLS)/win.x86/selfsign/*)))
3707 ifeq ($(VBOX_PATH_SELFSIGN),)
3708 VBOX_PATH_SELFSIGN := $(KBUILD_DEVTOOLS)/win.x86/selfsign/r1
3709 endif
3710 endif
3711 ifndef VBOX_PATH_SIGN_TOOLS
3712 VBOX_PATH_SIGN_TOOLS := $(firstword $(rsort $(wildcard \
3713 $(addprefix $(KBUILD_DEVTOOLS)/win.x86/sdk/v8.1*/Bin/, x86 $(if-expr $(KBUILD_HOST_ARCH)=="amd64",x64,) ) )))
3714 ifeq ($(VBOX_PATH_SIGN_TOOLS),)
3715 VBOX_PATH_SIGN_TOOLS := $(firstword $(rsort $(wildcard \
3716 $(addprefix $(KBUILD_DEVTOOLS)/win.x86/sdk/v10*/Bin/, x86 $(if-expr $(KBUILD_HOST_ARCH)=="amd64",x64,) ) )))
3717 ifeq ($(VBOX_PATH_SIGN_TOOLS),)
3718 VBOX_PATH_SIGN_TOOLS := $(VBOX_PATH_SELFSIGN)
3719 endif
3720 endif
3721 endif
3722
3723 VBOX_SIGNTOOL ?= $(VBOX_RETRY) "$(VBOX_PATH_SIGN_TOOLS)/signtool.exe"
3724 VBOX_INF2CAT ?= $(VBOX_PATH_SELFSIGN)/inf2cat.exe
3725
3726 ifeq ($(VBOX_SIGNING_MODE),test)
3727 VBOX_CERTIFICATE_SUBJECT_NAME ?= MyTestCertificate
3728 VBOX_CERTIFICATE_SUBJECT_NAME_ARGS ?= /n "$(VBOX_CERTIFICATE_SUBJECT_NAME)"
3729 else # release
3730 VBOX_CERTIFICATE_SUBJECT_NAME ?= Oracle Corporation
3731 VBOX_CERTIFICATE_SUBJECT_NAME_ARGS ?= /n "$(VBOX_CERTIFICATE_SUBJECT_NAME)" /a
3732 #VBOX_CERTIFICATE_FINGERPRINT ?= 7e 92 b6 6b e5 1b 79 d8 ce 3f f2 5c 15 c2 df 6a b8 c7 f2 f2
3733 #VBOX_CERTIFICATE_FINGERPRINT ?= 5b de fe 58 0a 81 66 61 cd b5 7a 57 10 7b f4 18 74 86 ef cc
3734 VBOX_CERTIFICATE_FINGERPRINT ?= 6f 47 42 06 bc bb 39 1b b8 2b a9 e5 dc 03 02 de f3 7a eb be
3735 #VBOX_CROSS_CERTIFICATE_FILE ?= $(VBOX_PATH_SELFSIGN)/VeriSign Class 3 Public Primary Certification Authority - G5.cer
3736 VBOX_CROSS_CERTIFICATE_FILE ?= $(VBOX_PATH_SELFSIGN)/DigiCert Assured ID Root CA.crt
3737 #VBOX_TSA_URL ?= http://timestamp.verisign.com/scripts/timstamp.dll - Appears to be broken between 2020-12-25 and 2020-12-30 (bugref:9849).
3738 VBOX_TSA_URL ?= http://timestamp.digicert.com
3739 endif
3740 if !defined(VBOX_CROSS_CERTIFICATE_FILE_ARGS) && defined(VBOX_CROSS_CERTIFICATE_FILE)
3741 VBOX_CROSS_CERTIFICATE_FILE_ARGS = /ac "$(VBOX_CROSS_CERTIFICATE_FILE)"
3742 endif
3743 if !defined(VBOX_TSA_URL_ARGS) && defined(VBOX_TSA_URL)
3744 VBOX_TSA_URL_ARGS = /t "$(VBOX_TSA_URL)"
3745 endif
3746 VBOX_CERTIFICATE_STORE ?= my
3747 VBOX_CERTIFICATE_STORE_ARGS ?= /s "$(VBOX_CERTIFICATE_STORE)"
3748 VBOX_CERTIFICATE_FINGERPRINT_ARGS := $(if-expr "$(VBOX_CERTIFICATE_FINGERPRINT)" != "" \
3749 ,/sha1 "$(subst $(SP),,$(VBOX_CERTIFICATE_FINGERPRINT))",)
3750
3751 ifeq ($(VBOX_SIGNING_MODE),test)
3752 #VBOX_CERTIFICATE_SHA2_SUBJECT_NAME ?= MyTestCertificateSha2
3753 VBOX_CERTIFICATE_SHA2_SUBJECT_NAME_ARGS ?= /n "$(VBOX_CERTIFICATE_SHA2_SUBJECT_NAME)"
3754 else # release
3755 VBOX_CERTIFICATE_SHA2_SUBJECT_NAME ?= Oracle Corporation
3756 VBOX_CERTIFICATE_SHA2_SUBJECT_NAME_ARGS ?= /n "$(VBOX_CERTIFICATE_SHA2_SUBJECT_NAME)" /a
3757 #VBOX_CERTIFICATE_SHA2_FINGERPRINT ?= 31 31 bb 58 8b 19 9e 6e 85 0f d3 35 82 b0 c5 82 55 e1 6c 49
3758 #VBOX_CERTIFICATE_SHA2_FINGERPRINT ?= 22 05 6a 4d 46 2e 3d 2b b2 c3 2f bf b0 5b 84 c4 65 9c f7 fe
3759 #VBOX_CERTIFICATE_SHA2_FINGERPRINT ?= 17 3a 19 bf 8e 62 72 be 25 04 d3 08 aa 68 b1 b0 0e 03 33 2c
3760 VBOX_CERTIFICATE_SHA2_FINGERPRINT ?= 30 65 6f ca 8c 48 b1 d9 86 23 a9 4b 40 a6 bc 98 bd 87 bf ad
3761 VBOX_CROSS_CERTIFICATE_SHA2_FILE ?= $(VBOX_PATH_SELFSIGN)/DigiCert Assured ID Root CA.crt
3762 #VBOX_TSA_SHA2_URL ?= http://sha256timestamp.ws.symantec.com/sha256/timestamp - phase out for consistency reasons
3763 VBOX_TSA_SHA2_URL ?= http://timestamp.digicert.com
3764 endif
3765 if !defined(VBOX_CROSS_CERTIFICATE_SHA2_FILE_ARGS) && defined(VBOX_CROSS_CERTIFICATE_SHA2_FILE)
3766 VBOX_CROSS_CERTIFICATE_SHA2_FILE_ARGS = /ac "$(VBOX_CROSS_CERTIFICATE_SHA2_FILE)"
3767 endif
3768 if !defined(VBOX_TSA_SHA2_URL_ARGS) && defined(VBOX_TSA_SHA2_URL)
3769 VBOX_TSA_SHA2_URL_ARGS = /tr "$(VBOX_TSA_SHA2_URL)"
3770 endif
3771 VBOX_CERTIFICATE_SHA2_STORE ?= my
3772 VBOX_CERTIFICATE_SHA2_STORE_ARGS ?= /s "$(VBOX_CERTIFICATE_SHA2_STORE)"
3773 VBOX_CERTIFICATE_SHA2_FINGERPRINT_ARGS := $(if-expr "$(VBOX_CERTIFICATE_SHA2_FINGERPRINT)" != "" \
3774 ,/sha1 "$(subst $(SP),,$(VBOX_CERTIFICATE_SHA2_FINGERPRINT))",) # Still using SHA-1 for fingerprinting, it's good enough for that!
3775 #VBOX_CERTIFICATE_EV_SUBJECT_NAME ?= MyEvCertificate
3776 VBOX_CERTIFICATE_EV_SUBJECT_NAME_ARGS ?= /n "$(VBOX_CERTIFICATE_EV_SUBJECT_NAME)"
3777 VBOX_CERTIFICATE_EV_STORE ?= my
3778 VBOX_CERTIFICATE_EV_STORE_ARGS ?= /s "$(VBOX_CERTIFICATE_EV_STORE)"
3779 #VBOX_CERTIFICATE_EV_FINGERPRINT ?= my ev cert fingerprint
3780 VBOX_CERTIFICATE_EV_FINGERPRINT_ARGS := $(if-expr "$(VBOX_CERTIFICATE_EV_FINGERPRINT)" != "" \
3781 ,/sha1 "$(subst $(SP),,$(VBOX_CERTIFICATE_EV_FINGERPRINT))",) # Still using SHA-1 for fingerprinting, it's good enough for that!
3782
3783 ## Sign a file (generic).
3784 # @param 1 The file to sign.
3785 # @param 2 File description. Optional.
3786 # @param 3 Additional parameters. Optional.
3787 # @param 4 Set to 2 if the expression will be expanded twice before chopped into commands (for _CMDS).
3788 # @param 5 Disables dual signing if non-empty.
3789 # @param 6 non-zero for alternative command separator. This is used for generating repacking scripts.
3790 ifndef VBOX_SIGN_FILE_FN
3791 if $(intersects win all 1,$(VBOX_WITH_CORP_CODE_SIGNING))
3792 VBOX_SIGN_FILE_FN = $(call VBOX_CCS_SIGN_CMD,driver$(if-expr "$3" == "/ph",_pagehash,),$1,,-digest_algo SHA1) \
3793 $(if-expr "$5" == "",\
3794 $(if-expr "$6" == "",$(if-expr "$4" == "2",$$(NLTAB),$(NLTAB)),$6) \
3795 $(call VBOX_CCS_SIGN_CMD,driver$(if-expr "$3" == "/ph",_pagehash,),$1,,-dual_sign -digest_algo SHA2))
3796 else ifdef VBOX_CERTIFICATE_SHA2_SUBJECT_NAME
3797 VBOX_SIGN_FILE_FN = $(VBOX_SIGNTOOL) \
3798 sign /fd sha1\
3799 $(VBOX_CROSS_CERTIFICATE_FILE_ARGS) \
3800 $(VBOX_CERTIFICATE_STORE_ARGS) \
3801 $(VBOX_CERTIFICATE_SUBJECT_NAME_ARGS) \
3802 $(VBOX_CERTIFICATE_FINGERPRINT_ARGS) \
3803 $(VBOX_TSA_URL_ARGS) \
3804 $(if $(strip $(2)),/d "$(strip $(2))",) \
3805 $(3) \
3806 "$(1)" \
3807 $(if-expr "$5" == "",\
3808 $(if-expr "$6" == "",$(if-expr "$4" == "2",$$(NLTAB),$(NLTAB)),$6)$(VBOX_SIGNTOOL) \
3809 sign /as /fd sha256 \
3810 $(VBOX_CROSS_CERTIFICATE_SHA2_FILE_ARGS) \
3811 $(VBOX_CERTIFICATE_SHA2_STORE_ARGS) \
3812 $(VBOX_CERTIFICATE_SHA2_SUBJECT_NAME_ARGS) \
3813 $(VBOX_CERTIFICATE_SHA2_FINGERPRINT_ARGS) \
3814 $(VBOX_TSA_SHA2_URL_ARGS) \
3815 $(if $(strip $(2)),/d "$(strip $(2))",) \
3816 $(3) \
3817 "$(1)",)
3818 else
3819 VBOX_SIGN_FILE_FN = $(VBOX_SIGNTOOL) sign \
3820 $(VBOX_CROSS_CERTIFICATE_FILE_ARGS) \
3821 $(VBOX_CERTIFICATE_STORE_ARGS) \
3822 $(VBOX_CERTIFICATE_SUBJECT_NAME_ARGS) \
3823 $(VBOX_CERTIFICATE_FINGERPRINT_ARGS) \
3824 $(VBOX_TSA_URL_ARGS) \
3825 $(if $(strip $(2)),/d "$(strip $(2))",) \
3826 $(3) \
3827 "$(1)"
3828 endif
3829 endif
3830
3831 ## EV sign a file (generic).
3832 # @param 1 The file to sign.
3833 # @param 2 The directory to put the signed file in. Defaults to $(dir $1).
3834 ifndef VBOX_SIGN_EV_FILE_FN
3835 if $(intersects win_ev all 1,$(VBOX_WITH_CORP_CODE_SIGNING))
3836 VBOX_SIGN_EV_FILE_FN = $(call VBOX_CCS_SIGN_CMD,microsoftev,$1,$(if $2,$2,))
3837 else ifdef VBOX_CERTIFICATE_EV_SUBJECT_NAME
3838 VBOX_SIGN_EV_FILE_FN = $(VBOX_SIGNTOOL) \
3839 sign /as /fd sha256 \
3840 $(VBOX_CERTIFICATE_EV_STORE_ARGS) \
3841 $(VBOX_CERTIFICATE_EV_SUBJECT_NAME_ARGS) \
3842 $(VBOX_CERTIFICATE_EV_FINGERPRINT_ARGS) \
3843 $(VBOX_TSA_SHA2_URL_ARGS) \
3844 "$(1)"
3845 endif
3846 endif
3847
3848 ## Corp code signing for drivers and catalogs, plan B.
3849 #
3850 # Since the corp code signing cannot dual signing and doesn't even have a
3851 # SHA-1 cert, we have to get creative:
3852 # 1. Sign $1 using local SHA-1 certificate.
3853 # 2. Make temporary copy of $1 as $1.ccs
3854 # 3. Do SHA-256 corp code signing of $1.ccs
3855 # 4. Add the SHA-256 signature from $1.ccs to $1 using bldRTSignTool.
3856 # 5. Delete $1.ccs.
3857 #
3858 # @param 1 The file to sign.
3859 # @param 2 File description. Optional.
3860 # @param 3 Additional parameters. Optional.
3861 # @param 4 Set to 2 if the expression will be expanded twice before chopped into commands (for _CMDS).
3862 # @param 5 Disables dual signing if non-empty.
3863 #
3864 # @remarks The parameters are the same as VBOX_SIGN_FILE_FN.
3865 VBOX_SIGN_IMAGE_PLAN_B_FN = $(VBOX_SIGNTOOL) \
3866 sign /fd sha1\
3867 $(VBOX_CROSS_CERTIFICATE_FILE_ARGS) \
3868 $(VBOX_CERTIFICATE_STORE_ARGS) \
3869 $(VBOX_CERTIFICATE_SUBJECT_NAME_ARGS) \
3870 $(VBOX_CERTIFICATE_FINGERPRINT_ARGS) \
3871 $(VBOX_TSA_URL_ARGS) \
3872 $(if $(strip $(2)),/d "$(strip $(2))",) \
3873 $(3) \
3874 "$(1)" \
3875 $(if-expr "$5" == "",\
3876 $(if-expr "$4" == "2",$$(NLTAB),$(NLTAB))$(RM) -f -- "$1.ccs" \
3877 $(if-expr "$4" == "2",$$(NLTAB),$(NLTAB))$(CP) -- "$1" "$1.ccs" \
3878 $(if-expr "$4" == "2",$$(NLTAB),$(NLTAB))$(call VBOX_CCS_SIGN_CMD,driver$(if-expr "$3" == "/ph",_pagehash,),$1.ccs,,-digest_algo SHA2) \
3879 $(if-expr "$4" == "2",$$(NLTAB),$(NLTAB))$(VBOX_RTSIGNTOOL) add-nested-$(if-expr "$(suffix $1)" == ".cat",cat,exe)-signature -v "$1" "$1.ccs" \
3880 $(if-expr "$4" == "2",$$(NLTAB),$(NLTAB))$(RM) -f -- "$1.ccs" \
3881 ,)
3882
3883 ## Sign an executable image.
3884 # @param 1 The file to sign.
3885 # @param 2 File description. Optional.
3886 # @param 3 Set to 2 if the expression will be expanded twice before chopped into commands (for _CMDS).
3887 VBOX_SIGN_IMAGE_FN ?= $(call VBOX_SIGN_FILE_FN,$(1),$(2),/ph,$(3))
3888
3889 ## Commands for signing a driver image after link.
3890 if $(intersects win_planb,$(VBOX_WITH_CORP_CODE_SIGNING))
3891 VBOX_SIGN_DRIVER_CMDS ?= $(if $(eq $(tool_do),LINK_LIBRARY),,$(call VBOX_SIGN_IMAGE_PLAN_B_FN,$(out),,/ph,2))
3892 VBOX_SIGN_DRIVER_ORDERDEPS ?= $(VBOX_RTSIGNTOOL)
3893 else
3894 VBOX_SIGN_DRIVER_CMDS ?= $(if $(eq $(tool_do),LINK_LIBRARY),,$(call VBOX_SIGN_IMAGE_FN,$(out),,2))
3895 endif
3896
3897 ## Create a security catalog file.
3898 # @param 1 The directory containing the stuff to sign.
3899 # @param 2 The expected .cat name. (Inf2Cat lowercases it)
3900 # @param 3 The list of OSes, separated by ';'.
3901 ifndef VBOX_MAKE_CAT_HLP_FN
3902 VBOX_MAKE_CAT_HLP_FN = \
3903 $(RM) -f -- "$(2)"\
3904 $(NL)$(TAB)$(VBOX_INF2CAT) "/driver:$(strip $(1))" "/os:$(strip $(subst ;,$(COMMA),$(3)))" /verbose \
3905 $(NL)$(TAB)$(MV) -- "$(2)" "$(2)"
3906 if $(intersects win_planb,$(VBOX_WITH_CORP_CODE_SIGNING))
3907 VBOX_MAKE_CAT_HLP_FN += $(NL)$(TAB)$(call VBOX_SIGN_IMAGE_PLAN_B_FN,$(2),,,$(NL)$(TAB))
3908 else
3909 VBOX_MAKE_CAT_HLP_FN += $(NL)$(TAB)$(call VBOX_SIGN_FILE_FN,$(2),,,$(NL)$(TAB))
3910 endif
3911 endif
3912 VBOX_MAKE_CAT64_FN ?= $(call VBOX_MAKE_CAT_HLP_FN,$(1),$(2),XP_X64;Server2003_X64;Vista_X64)
3913 VBOX_MAKE_CAT32_FN ?= $(call VBOX_MAKE_CAT_HLP_FN,$(1),$(2),2000;XP_X86;Server2003_X86;Vista_X86)
3914 ifeq ($(KBUILD_TARGET_ARCH),x86)
3915 VBOX_MAKE_CAT_FN ?= $(call VBOX_MAKE_CAT32_FN,$(1),$(2))
3916 else
3917 VBOX_MAKE_CAT_FN ?= $(call VBOX_MAKE_CAT64_FN,$(1),$(2))
3918 endif
3919
3920 # Go nuts, sign everything.
3921 if "$(VBOX_SIGNING_MODE)" == "release" || defined(VBOX_WITH_HARDENING)
3922 ## Commands for signing an executable or a dll image after link.
3923 VBOX_SIGN_IMAGE_CMDS ?= $(if $(eq $(tool_do),LINK_LIBRARY),,$(call VBOX_SIGN_IMAGE_FN,$(out),,2))
3924 endif
3925 ## Enable signing of the additions.
3926 VBOX_SIGN_ADDITIONS ?= 1
3927
3928 else ifeq ($(KBUILD_HOST),darwin)
3929 #
3930 # Darwin code signing.
3931 #
3932 # Currently release signing is done when packing. This may change later.
3933 # (Installer package signing is done elsewhere (VBOX_MACOSX_INSTALLER_SIGN).)
3934 #
3935 if defined(VBOX_CERTIFICATE_FINGERPRINT) && !defined(VBOX_CERTIFICATE_SUBJECT_NAME)
3936 VBOX_CERTIFICATE_SUBJECT_NAME = $(subst $(SP),,$(VBOX_CERTIFICATE_FINGERPRINT))
3937 endif
3938 ifeq ($(VBOX_SIGNING_MODE),test)
3939 VBOX_CERTIFICATE_SUBJECT_NAME ?= $(error You need to set VBOX_CERTIFICATE_SUBJECT_NAME in LocalConfig.kmk.)
3940 VBOX_CERTIFICATE_SUBJECT_NAME_ARGS ?= --sign "$(VBOX_CERTIFICATE_SUBJECT_NAME)"
3941 VBOX_TSA_URL ?= none
3942 else
3943 VBOX_CERTIFICATE_SUBJECT_NAME ?= Developer ID Application: Oracle America, Inc.
3944 VBOX_CERTIFICATE_SUBJECT_NAME_ARGS ?= --sign "$(VBOX_CERTIFICATE_SUBJECT_NAME)"
3945 endif
3946
3947 VBOX_CODESIGN ?= codesign
3948 if 0
3949 VBOX_DARWIN_KEXT_SIGN_FILES = CodeDirectory CodeRequirement CodeResources CodeSignature
3950 else
3951 VBOX_DARWIN_KEXT_SIGN_FILES = CodeResources
3952 endif
3953
3954 # Always enable the hardened runtime when signing. Can be disabled if
3955 # trying to build on quite old macOS, which will likely need some effort.
3956 VBOX_WITH_MACOS_HARDENED_RUNTIME ?= 1
3957
3958 ##
3959 # Corp Code Notarization command line. Modifies the file because the tickets are stapled.
3960 # @param 1 The file to be submitted for signing.
3961 # @param 2 Identifier, mandatory.
3962 # @param 3 The directory to put the notarized file in. Defaults to $(dir $1).
3963 VBOX_CCS_NOTARIZE_CMD = $(VBOX_RETRY) $(VBOX_JAVA) -jar "$(VBOX_CCS_CLIENT_JAR)" \
3964 mac_notarize -user "$(VBOX_CCS_USER)" -global_uid "$(VBOX_CCS_GLOBAL_UID)" \
3965 -job_timeout 90 -server_timeout 75 -server "$(VBOX_CCS_SERVER)" \
3966 -file_to_notarize "$1" -bundle_id "$2" -download_location "$(if $3,$3,$(call VBOX_DIRX,$1))"
3967
3968 ## Sign an application bundle, framework or kernel extension.
3969 # @param 1 The bundle to sign.
3970 # @param 2 Identifier, optional.
3971 # @param 3 Additional codesign command line parameters, optional.
3972 if $(intersects darwin all 1,$(VBOX_WITH_CORP_CODE_SIGNING))
3973 ## @todo cannot handle $(2), the identifier.
3974 ## @todo $(3) is hopefully either empty, --deep or --entitlements=...
3975 VBOX_SIGN_BUNDLE_FN = $(call MSG_TOOL,SIGNTOOL,,$(1),$(2))$(NLTAB) \
3976 ditto -c -k --keepParent "$(1)" "$(1).zip"$(NLTAB) \
3977 $(call VBOX_CCS_SIGN_CMD,apple,$(1).zip,,$(subst --entitlements=,-entitlement_file_path ,$(subst --deep,-deep,$(3))) \
3978 $(if $(VBOX_WITH_MACOS_HARDENED_RUNTIME),-hardened_runtime))$(NLTAB) \
3979 ditto -x -k "$(1).zip" "$(1)/../"$(NLTAB) \
3980 $(RM) -f -- "$(1).zip"
3981 else
3982 VBOX_SIGN_BUNDLE_FN = $(call MSG_TOOL,SIGNTOOL,,$(1),$(2))$(NLTAB)$(VBOX_CODESIGN) \
3983 --verbose=9 \
3984 --force \
3985 $(if-expr $(KBUILD_HOST_VERSION_MAJOR) <= 14,--digest-algorithm sha256,) \
3986 $(if $(VBOX_WITH_MACOS_HARDENED_RUNTIME),$(if-expr $(KBUILD_HOST_VERSION_MAJOR) <= 16,--options 0x10000,--options runtime)) \
3987 --file-list - \
3988 $(if-expr defined(VBOX_TSA_URL),--timestamp="$(VBOX_TSA_URL)") \
3989 $(3) \
3990 $(VBOX_CERTIFICATE_SUBJECT_NAME_ARGS) \
3991 "$(1)" $(if $(2),--identifier "$(2)",)
3992 endif
3993
3994 ## Sign a Mach-O image.
3995 # @param 1 The file to sign.
3996 # @param 2 Identifier, optional.
3997 # @param 3 Additional codesign command line parameters, optional.
3998 if $(intersects darwin all 1,$(VBOX_WITH_CORP_CODE_SIGNING))
3999 ## @todo cannot handle $(2), the identifier.
4000 ## @todo $(3) is hopefully either empty or --entitlements=...
4001 VBOX_SIGN_MACHO_FN = $(call MSG_TOOL,SIGNTOOL,,$(1),$(2))$(NLTAB) \
4002 $(call VBOX_CCS_SIGN_CMD,binary,$(1),,$(subst --entitlements=,-entitlement_file_path ,$(3)) \
4003 $(if $(VBOX_WITH_MACOS_HARDENED_RUNTIME),-hardened_runtime))
4004 else
4005 VBOX_SIGN_MACHO_FN = $(call MSG_TOOL,SIGNTOOL,,$(1),$(2))$(NLTAB)$(VBOX_CODESIGN) \
4006 --verbose=9 \
4007 --force \
4008 $(if-expr $(KBUILD_HOST_VERSION_MAJOR) <= 14,--digest-algorithm sha256,) \
4009 $(if $(VBOX_WITH_MACOS_HARDENED_RUNTIME),$(if-expr $(KBUILD_HOST_VERSION_MAJOR) <= 16,--options 0x10000,--options runtime)) \
4010 --file-list - \
4011 $(if-expr defined(VBOX_TSA_URL),--timestamp="$(VBOX_TSA_URL)") \
4012 $(VBOX_CERTIFICATE_SUBJECT_NAME_ARGS) \
4013 $(3) \
4014 "$(1)" \
4015 $(if $(2),--identifier "$(2)",)
4016 endif
4017
4018 ## Commands for signing an extpack dylib file after link.
4019 if $(intersects darwin all 1,$(VBOX_WITH_CORP_CODE_SIGNING))
4020 VBOX_SIGN_EXTPACK_DYLIB_CMDS ?= $(if $(eq $(tool_do),LINK_LIBRARY),, \
4021 $(call VBOX_CCS_SIGN_CMD,binary,$(out),, \
4022 $(if $(VBOX_WITH_MACOS_HARDENED_RUNTIME),-hardened_runtime)) )
4023 else
4024 VBOX_SIGN_EXTPACK_DYLIB_CMDS ?= $(if $(eq $(tool_do),LINK_LIBRARY),, \
4025 $(VBOX_CODESIGN) \
4026 --verbose=9 \
4027 --force \
4028 $(if-expr $(KBUILD_HOST_VERSION_MAJOR) <= 14,--digest-algorithm sha256,) \
4029 $(if $(VBOX_WITH_MACOS_HARDENED_RUNTIME),$(if-expr $(KBUILD_HOST_VERSION_MAJOR) <= 16,--options 0x10000,--options runtime)) \
4030 --file-list - \
4031 $(if-expr defined(VBOX_TSA_URL),--timestamp="$(VBOX_TSA_URL)") \
4032 $(VBOX_CERTIFICATE_SUBJECT_NAME_ARGS) \
4033 $(out) )
4034 endif
4035
4036 ## Sign a VMM Mach-O image.
4037 # @param 1 The file to sign.
4038 # @param 2 Identifier, optional.
4039 VBOX_SIGN_VMM_MOD_FN = $(VBOX_SIGN_MACHO_FN)
4040
4041 ## Sign a non-executable file.
4042 # @param 1 The file to sign.
4043 # @param 2 Identifier, optional.
4044 if $(intersects darwin all 1,$(VBOX_WITH_CORP_CODE_SIGNING))
4045 ## @todo cannot handle $(2), the identifier.
4046 VBOX_SIGN_FILE_FN = $(call MSG_TOOL,SIGNTOOL,,$(1),$(2))$(NLTAB)$(call VBOX_CCS_SIGN_CMD,binary,$(1))
4047 else
4048 VBOX_SIGN_FILE_FN = $(call MSG_TOOL,SIGNTOOL,,$(1),$(2))$(NLTAB)$(VBOX_CODESIGN) \
4049 --verbose=9 \
4050 --force \
4051 $(if-expr $(KBUILD_HOST_VERSION_MAJOR) <= 14,--digest-algorithm sha256,) \
4052 --file-list=- \
4053 $(if-expr defined(VBOX_TSA_URL),--timestamp="$(VBOX_TSA_URL)") \
4054 $(if $(2),--identifier "$(2)",) \
4055 $(VBOX_CERTIFICATE_SUBJECT_NAME_ARGS) \
4056 "$(1)"
4057 endif
4058
4059 ## Sign a DMG image.
4060 # @param 1 The file to sign.
4061 # @param 2 Identifier, optional.
4062 # @note Will segfault if --file-list is used on 10.15.2 (kSecCodeInfoChangedFiles -> NULL, outputter doesn't check for NULL).
4063 VBOX_SIGN_DMG_FN = $(filter-out --file-list=-,$(VBOX_SIGN_FILE_FN))
4064
4065 ## Sign a PKG file. Used with corp code signing only.
4066 # @param 1 The file to sign.
4067 # @param 2 Identifier, optional.
4068 if $(intersects darwin all 1,$(VBOX_WITH_CORP_CODE_SIGNING))
4069 ## @todo cannot handle $(2), the identifier.
4070 VBOX_SIGN_PKG_FN = $(call MSG_TOOL,SIGNTOOL,,$(1),$(2))$(NLTAB)$(call VBOX_CCS_SIGN_CMD,mac_pkg,$(1))
4071 endif
4072
4073 ## Notarize a file (usually DMG, can also be PKG). Used with corp code signing only.
4074 # @param 1 The file to notarize.
4075 # @param 2 Identifier, mandatory.
4076 if $(intersects darwin all 1,$(VBOX_WITH_CORP_CODE_SIGNING))
4077 VBOX_NOTARIZE_FILE_FN = $(call MSG_TOOL,SIGNTOOL,,$(1),$(2))$(NLTAB)$(call VBOX_CCS_NOTARIZE_CMD,$(1),$(2))
4078 endif
4079
4080 ## @def VBOX_TEST_SIGN_KEXT
4081 # Adds test signing to a $1.kext target (the plist installer target).
4082 #
4083 # After both targets has been defined:
4084 # $(evalcall2 VBOX_TEST_SIGN_KEXT,VBoxDrv)
4085 #
4086 # @param 1 The kext name. Assumes there is a SYSMODS target of name $1
4087 # as well as an .plist installer by the name of '$1.kext'.
4088 # @remarks Currently assumes only binary + Info.plist in the bundle, no
4089 # other files. Should there be more, add them as a list in
4090 # a 2nd parameter.
4091 # @note This is only for the 'test' signing mode, we skip this in
4092 # 'release' signing mode as to not waste time on the build boxes.
4093 ifeq ($(VBOX_SIGNING_MODE),test) ## @todo when kBuild is updated to r2742+, this should be enabled for both modes.
4094 define VBOX_TEST_SIGN_KEXT
4095 $1_INSTTYPE.darwin = none
4096
4097 $1.kext_SOURCES += $$($1.kext_0_OUTDIR)/Contents/MacOS/$1=>MacOS/$1 \
4098 $(foreach extfile, $(VBOX_DARWIN_KEXT_SIGN_FILES) \
4099 , $$($1.kext_0_OUTDIR)/Contents/_CodeSignature/$(extfile)=>_CodeSignature/$(extfile))
4100 $1.kext_SYMLINKS += $(foreach symfile, $(VBOX_DARWIN_KEXT_SIGN_SYMLINKS), $(symfile)=>_CodeSignature/$(symfile))
4101 $1.kext_CLEAN += \
4102 $(foreach extfile, $(VBOX_DARWIN_KEXT_SIGN_FILES) , $$($1.kext_0_OUTDIR)/Contents/_CodeSignature/$(extfile)) \
4103 $(foreach symfile, $(VBOX_DARWIN_KEXT_SIGN_SYMLINKS), $$($1.kext_0_OUTDIR)/Contents/$(symfile)) \
4104 $$($1.kext_0_OUTDIR)/Contents/MacOS/$1 \
4105 $$($1.kext_0_OUTDIR)/$1.kext/Contents/_CodeSignature/
4106 $1.kext_BLDDIRS += $$($1.kext_0_OUTDIR)/Contents/MacOS/
4107
4108 $$$$($1.kext_0_OUTDIR)/Contents/MacOS/$1 \
4109 + $(foreach file,$(VBOX_DARWIN_KEXT_SIGN_FILES), $$$$($1.kext_0_OUTDIR)/Contents/_CodeSignature/$(file)): \
4110 $$$$($1.kext_0_OUTDIR)/Contents/Info.plist $$$$($1_1_TARGET) | $$$$($1.kext_0_OUTDIR)/
4111 $(RM) -Rf -- "$$($1.kext_0_OUTDIR)/Contents/_CodeSignature/" "$$($1.kext_0_OUTDIR)/Contents/MacOS/"
4112 $(MKDIR) -p -- "$$($1.kext_0_OUTDIR)/Contents/MacOS/"
4113 $(INSTALL) -m 644 $$($1_1_TARGET) $$($1.kext_0_OUTDIR)/Contents/MacOS/$1
4114 $(call VBOX_SIGN_BUNDLE_FN,$$($1.kext_0_OUTDIR),org.virtualbox.app.kext.$1,)
4115 endef
4116 else
4117 VBOX_TEST_SIGN_KEXT =
4118 endif
4119
4120
4121 else ifeq ($(KBUILD_HOST),solaris)
4122 #
4123 # Solaris code signing.
4124 #
4125 ifeq ($(VBOX_SIGNING_MODE),test)
4126 VBOX_CERTIFICATE_FILE ?= $(error You need to set VBOX_CERTIFICATE_FILE in LocalConfig.kmk.)
4127 VBOX_TOKEN_NAME ?= $(error You need to set VBOX_TOKEN_NAME in LocalConfig.kmk.)
4128 VBOX_PIN_FILE ?= $(error You need to set VBOX_PIN_FILE in LocalConfig.kmk.)
4129 else
4130 VBOX_CERTIFICATE_FILE ?= $(PATH_ROOT)/oracle.pem
4131 VBOX_TOKEN_NAME ?= "Sun Software PKCS\#11 softtoken"
4132 VBOX_PIN_FILE ?= $(PATH_ROOT)/oracle.pin
4133 endif
4134 VBOX_CERTIFICATE_FILE_ARGS ?= -c $(VBOX_CERTIFICATE_FILE)
4135 VBOX_TOKEN_NAME_ARGS ?= -T $(VBOX_TOKEN_NAME)
4136 VBOX_PIN_ARGS ?= -P $(VBOX_PIN_FILE)
4137
4138 VBOX_ELFSIGN ?= elfsign
4139
4140 # Sign an ELF image.
4141 # @param 1 The elf object file to sign.
4142 VBOX_SIGN_ELF_FN ?= $(VBOX_ELFSIGN) \
4143 sign \
4144 $(VBOX_CERTIFICATE_FILE_ARGS) \
4145 $(VBOX_TOKEN_NAME_ARGS) \
4146 $(VBOX_PIN_ARGS) \
4147 -e "$(1)"
4148
4149 ## Commands for signing a driver image after link.
4150 if $(intersects solaris all 1,$(VBOX_WITH_CORP_CODE_SIGNING))
4151 VBOX_SIGN_DRIVER_CMDS ?= $(if $(eq $(tool_do),LINK_LIBRARY),,$(call VBOX_CCS_SIGN_CMD,solaris_elf,$(out)))
4152 else
4153 VBOX_SIGN_DRIVER_CMDS ?= $(if $(eq $(tool_do),LINK_LIBRARY),,$(call VBOX_SIGN_ELF_FN,$(out)))
4154 endif
4155
4156 else
4157 # Not Windows, Mac OS X or Solaris build host, ignore.
4158 VBOX_SIGNING_MODE :=
4159 endif
4160
4161#
4162# Complain if windows hardening is enabled but not code signing.
4163#
4164else if "$(KBUILD_TARGET)" == "win" && defined(VBOX_WITH_HARDENING) && !defined(VBOX_ONLY_BUILD)
4165 $(error You need to enable code signing for a hardened windows build to work.)
4166endif
4167
4168#
4169# Windows .inf editing.
4170#
4171ifeq ($(KBUILD_TARGET_ARCH),x86)
4172 VBOX_EDIT_INF_FN = $(call VBOX_EDIT_INF32_FN,$(1),$(2))
4173else
4174 VBOX_EDIT_INF_FN = $(call VBOX_EDIT_INF64_FN,$(1),$(2))
4175endif
4176## Edit an inf file an x86 target.
4177# @param 1 The inf file to edit.
4178# @param 2 The output file.
4179VBOX_EDIT_INF32_FN = $(SED) $(if $(VBOX_SIGNING_MODE),-e 's/^;cat *//', -e '/^;cat /d') \
4180 -e 's/^;x86 *//' \
4181 -e '/^;amd64 /d' \
4182 -e 's/@DOT-NT-ARCH@//' \
4183 -e 's/@COMMA-NT-ARCH@//' \
4184 -e 's/^;edit-DriverVer.*/DriverVer = $(date-utc %m\/%d\/%Y),$(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD).$(expr $(VBOX_SVN_REV) % 50000) ; r$(VBOX_SVN_REV)/' \
4185 --output $(2) \
4186 $(1)
4187## Edit an inf file an x86 target.
4188# @param 1 The inf file to edit.
4189# @param 2 The output file.
4190VBOX_EDIT_INF64_FN = $(SED) \
4191 $(if $(VBOX_SIGNING_MODE),-e 's/^;cat *//', -e '/^;cat /d')\
4192 -e 's/^;amd64 *//' \
4193 -e '/^;x86 /d' \
4194 -e 's/@DOT-NT-ARCH@/.ntamd64/' \
4195 -e 's/@COMMA-NT-ARCH@/,ntamd64/' \
4196 -e 's/^;edit-DriverVer.*/DriverVer = $(date-utc %m\/%d\/%Y),$(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD).$(expr $(VBOX_SVN_REV) % 50000) ; r$(VBOX_SVN_REV)/' \
4197 --output $(2) \
4198 $(1)
4199
4200## @def VBOX_RE_SIGN_DLL_FN
4201# Helper macro for re-signing DLL images from tools that we ship so they won't
4202# cause trouble for the hardened build requirements.
4203#
4204# Invoke via $(call VBOX_RE_SIGN_DLL_FN) inside the SOURCES list. Necessary
4205# _CLEAN entry will be added to the target. If hardening is not enabled or
4206# we're not on windows, the source will be returned.
4207#
4208# @returns Name of the output file name. May have leading space, but no trailing.
4209# @param 1 Target name.
4210# @param 2 The source name.
4211# @param 3 Optional prefix to avoid name collisions.
4212#
4213if defined(VBOX_SIGNING_MODE) && "$(KBUILD_TARGET)" == "win"
4214 if1of (quote, $(KMK_FEATURES))
4215 VBOX_RE_SIGN_DLL_FN = $(if-expr !defined($(1)_VBOX_RE_SIGNED_$(3)$(qnotdir ,$(2))),\
4216 $(evalcall VBOX_RE_SIGN_DLL_INTERNAL_FN,$1,$2,$3)\
4217 ,)$($(1)_0_OUTDIR)/$(3)$(qnotdir ,$2)
4218
4219 define VBOX_RE_SIGN_DLL_INTERNAL_FN
4220 local n = $(3)$(qnotdir ,$2)
4221 ifndef $(1)_VBOX_RE_SIGNED_$(n)
4222 $(1)_VBOX_RE_SIGNED_$(n) := 1
4223 $(eval $(1)_CLEAN += $$($(1)_0_OUTDIR)/$(n))
4224
4225 $$($(1)_0_OUTDIR)/$(n): $(2) $(VBOX_VERSION_STAMP) | $$(dir $$@)
4226 $(call MSG_TOOL,SIGNTOOL,,$<,$@)
4227 $(RM) -f -- "$@"
4228 $(CP) -- "$(quote-sh-dq $<)" "$@"
4229 $(CHMOD) a+rw -- "$@"
4230 $(VBOX_VCC_EDITBIN) /LargeAddressAware /DynamicBase /NxCompat /Release /IntegrityCheck \
4231 /Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
4232 "$@"
4233 $(call VBOX_SIGN_IMAGE_FN,$@)
4234 endif
4235 endef # VBOX_RE_SIGN_DLL_INTERNAL_FN
4236
4237 else # old kmk: no quote feature
4238VBOX_RE_SIGN_DLL_FN = $(if-expr !defined($(1)_VBOX_RE_SIGNED_$(3)$(notdir $(2))),\
4239 $(evalcall VBOX_RE_SIGN_DLL_INTERNAL_FN,$1,$2,$3)\
4240 ,)$($(1)_0_OUTDIR)/$(3)$(notdir $2)
4241 define VBOX_RE_SIGN_DLL_INTERNAL_FN
4242local n = $(3)$(notdir $2)
4243ifndef $(1)_VBOX_RE_SIGNED_$(n)
4244 $(1)_VBOX_RE_SIGNED_$(n) := 1
4245 $(eval $(1)_CLEAN += $$($(1)_0_OUTDIR)/$(n))
4246
4247 $$($(1)_0_OUTDIR)/$(n): $(2) $(VBOX_VERSION_STAMP) | $$(dir $$@)
4248 $(call MSG_TOOL,SIGNTOOL,,$<,$@)
4249 $(RM) -f -- "$@"
4250 $(CP) -- "$<" "$@"
4251 $(CHMOD) a+rw -- "$@"
4252 $(VBOX_VCC_EDITBIN) /LargeAddressAware /DynamicBase /NxCompat /Release /IntegrityCheck \
4253 /Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
4254 "$@"
4255 $(call VBOX_SIGN_IMAGE_FN,$@)
4256endif
4257 endef # VBOX_RE_SIGN_DLL_INTERNAL_FN
4258 endif # old kmk: no quote feature
4259else
4260 VBOX_RE_SIGN_DLL_FN = $(2)
4261endif
4262
4263
4264#
4265# File version info and description macros (ignored on most OSes).
4266#
4267
4268##
4269# Internal macro.
4270#
4271# @param 1 The target name.
4272# @param 2 The description
4273# @param 3 Optional icon file.
4274# @param 4 The template base name.
4275# @param 5 Additional RC options.
4276#
4277# @remarks ASSUMES RCFLAGS isn't a simple variable (var := value).
4278define VBOX_SET_VER_INFO_INTERNAL
4279ifeq ($(KBUILD_TARGET),win)
4280$(1)_SOURCES.win += $(PATH_ROOT)/src/VBox/Artwork/win/$(4)
4281$(1)_RCFLAGS += /nologo /dIN_INTERNAL_NAME="\"$(1)\"" /dIN_FILE_DESCRIPTION="\"$(2)\"" \
4282 /dIN_ORIGINAL_NAME="\"$$(notdir $$($(1)_1_INST_TARGET))\"" \
4283 $(if $(3), /dIN_ICON_FILE="\"$(subst \\,/,$(strip $(3)))\"") $(5)
4284$$$$($(1)_0_OUTDIR)/src/VBox/Artwork/win/$(basename $(4)).res: \
4285 $(PATH_ROOT)/include/VBox/version.h $$$$(VBOX_VERSION_HEADER)
4286endif
4287endef
4288
4289##
4290# Macro for setting DLL/SO/DYLIB version information and description.
4291#
4292# The macro must be invoked using evalcall2 after the whole target has
4293# been declared.
4294#
4295# @param 1 The target name.
4296# @param 2 The description
4297# @param 3 Optional icon file.
4298VBOX_SET_VER_INFO_DLL = $(evalcall2 VBOX_SET_VER_INFO_INTERNAL,$1,$2,$3,TemplateDll.rc,)
4299
4300##
4301# Macro for setting EXE version information and description.
4302#
4303# The macro must be invoked using call after the whole target has been declared.
4304#
4305# @param 1 The target name.
4306# @param 2 The description
4307# @param 3 Optional icon file.
4308VBOX_SET_VER_INFO_EXE = $(evalcall2 VBOX_SET_VER_INFO_INTERNAL,$1,$2,$3,TemplateExe.rc,)
4309
4310##
4311# Macro for setting driver version information and description.
4312#
4313# The macro must be invoked using call after the whole target has been declared.
4314#
4315# @param 1 The target name.
4316# @param 2 The description
4317# @param 3 Optional icon file.
4318# @param 4 Optional VFT2_DRV_xxx define for windows. Uses VFT2_UNKNOWN by default.
4319VBOX_SET_VER_INFO_DRV = $(evalcall2 VBOX_SET_VER_INFO_INTERNAL,$1,$2,$3,TemplateDrv.rc,$(if $(4), /dIN_FILE_SUBTYPE=$(4)))
4320
4321##
4322# Macro for setting the version information and description for a ring-0 module.
4323#
4324# The macro must be invoked using call after the whole target has been declared.
4325#
4326# @param 1 The target name.
4327# @param 2 The description
4328# @param 3 Optional icon file.
4329VBOX_SET_VER_INFO_R0 = $(evalcall2 VBOX_SET_VER_INFO_INTERNAL,$1,$2,$3,TemplateR0.rc,)
4330
4331##
4332# Macro for setting the version information and description for a raw-mode context module.
4333#
4334# The macro must be invoked using call after the whole target has been declared.
4335#
4336# @param 1 The target name.
4337# @param 2 The description
4338# @param 3 Optional icon file.
4339VBOX_SET_VER_INFO_RC = $(evalcall2 VBOX_SET_VER_INFO_INTERNAL,$1,$2,$3,TemplateRc.rc,)
4340
4341
4342
4343#
4344# Adjust kBuild defaults.
4345#
4346kBuildGlobalDefaults_DEBUG_NOSTAGE.win = true
4347kBuildGlobalDefaults_DEBUG_NOSTAGE.os2 = true
4348if1of ($(KBUILD_TARGET), darwin win)
4349 kBuildGlobalDefaults_LD_DEBUG = split
4350endif
4351
4352
4353#
4354# Haiku resource and version generation.
4355#
4356ifeq ($(KBUILD_HOST),haiku)
4357 VBOX_HAIKU_RCTOOL := rc
4358 VBOX_HAIKU_XRESTOOL := xres
4359 VBOX_HAIKU_SETVERSIONTOOL := setversion
4360 # XXX: install won't preserve attributes...
4361 VBOX_HAIKU_MIMESETTOOL := mimeset
4362
4363 ## Add optional resources to the program, set its version info, and sniff its mime properties.
4364 # @param 1 The file to add resources to.
4365 # @param 2 The resource files.
4366 # @param 3 The target name.
4367define VBOX_HAIKU_XRES_SETVER_FN
4368 $(if $(2),$(call MSG_TOOL,HaikuAddResources,$(3),$(2))
4369 $(QUIET)$(VBOX_HAIKU_XRESTOOL) -o $(1) $(2),)
4370 $(call MSG_TOOL,HaikuSetVersion,$(3))
4371 $(QUIET)$(VBOX_HAIKU_SETVERSIONTOOL) $(1) \
4372 -app $(VBOX_VERSION_MAJOR) $(VBOX_VERSION_MINOR) $(VBOX_VERSION_BUILD) d $(VBOX_SVN_REV) \
4373 -short "$(VBOX_PRODUCT)" \
4374 -long "$(VBOX_PRODUCT) $(VBOX_VERSION_STRING) $(shell /bin/echo -e '\xC2\xA9')2009-$(VBOX_C_YEAR) $(VBOX_VENDOR)"
4375 $(call MSG_TOOL,HaikuMimeSet,$(3))
4376 $(QUIET)$(VBOX_HAIKU_MIMESETTOOL) -f $(1)
4377endef
4378
4379 VBOX_HAIKU_XRES_SETVER_CMDS ?= $(if $(eq $(tool_do),LINK_PROGRAM),$(call VBOX_HAIKU_XRES_SETVER_FN,$(out),$($(target)_RSRCS),$(target)),)
4380endif
4381
4382#
4383# Default prefixes and suffixes.
4384#
4385VBOX_PREF_LIB =
4386if1of ($(KBUILD_TARGET), os2 win)
4387VBOX_SUFF_LIB = .lib
4388else
4389VBOX_SUFF_LIB = .a
4390endif
4391if1of ($(KBUILD_HOST), os2 win)
4392VBOX_HOSTSUFF_LIB = .lib
4393else
4394VBOX_HOSTSUFF_LIB = .a
4395endif
4396VBOX_SUFF_DLL = $(SUFF_DLL)
4397ifeq ($(KBUILD_TARGET),os2) # GXX3OMF produces out .o at the moment.
4398VBOX_SUFF_OBJ = .o
4399else
4400VBOX_SUFF_OBJ = $(SUFF_OBJ)
4401endif
4402VBOXW32GUEST_SUFF_LIB = .lib
4403VBOXLNX32GUEST_SUFF_LIB = .a
4404
4405#
4406# SDKs for external libraries.
4407#
4408SDK_VBOX_LIBXML2 = .
4409SDK_VBOX_LIBXML2_INCS ?= $(PATH_ROOT)/src/libs/libxml2-2.9.4/include
4410SDK_VBOX_LIBXML2_DEFS ?= _REENTRANT LIBXML_STATIC LIBXML_STATIC_FOR_DLL
4411SDK_VBOX_LIBXML2_DEFS.win ?= WIN32 _WINDOWS _MBCS HAVE_WIN32_THREADS HAVE_COMPILER_TLS
4412# Note: no linking to LIB here, we do that explicitly in src/VBox/Runtime/Makefile.kmk to link
4413# libxml against VBoxRT
4414
4415SDK_VBOX_LIBPNG = .
4416SDK_VBOX_LIBPNG_INCS ?= $(PATH_ROOT)/src/libs/libpng-1.6.36
4417SDK_VBOX_LIBPNG_LIBS ?= $(PATH_STAGE_LIB)/VBox-libpng$(VBOX_SUFF_LIB)
4418
4419SDK_VBOX_ZLIB = .
4420if1of ($(KBUILD_TARGET), os2 solaris win)
4421 SDK_VBOX_ZLIB_INCS ?= $(PATH_ROOT)/src/libs/zlib-1.2.11
4422 SDK_VBOX_ZLIB_LIBS ?= $(PATH_STAGE_LIB)/VBox-zlib$(VBOX_SUFF_LIB)
4423else
4424 SDK_VBOX_ZLIB_INCS ?=
4425 SDK_VBOX_ZLIB_LIBS ?= z
4426 SDK_VBOX_ZLIB_DEFS.linux ?= _LARGEFILE64_SOURCE
4427endif
4428
4429SDK_VBOX_ZLIB-x86 = .
4430SDK_VBOX_ZLIB-x86_EXTENDS = VBOX_ZLIB
4431if1of ($(KBUILD_TARGET), os2 solaris win)
4432 SDK_VBOX_ZLIB_LIBS-x86 ?= $(PATH_STAGE_LIB)/VBox-zlib-x86$(VBOX_SUFF_LIB)
4433endif
4434
4435SDK_VBOX_ZLIB_STATIC = .
4436SDK_VBOX_ZLIB_STATIC_EXTENDS ?= VBOX_ZLIB
4437if1of ($(KBUILD_TARGET), os2 win) # Not required on solaris.
4438 SDK_VBOX_ZLIB_STATIC_LIBS ?= $(PATH_STAGE_LIB)/VBox-zlib-static$(VBOX_SUFF_LIB)
4439endif
4440
4441SDK_VBOX_LZF = .
4442SDK_VBOX_LZF_INCS ?= $(PATH_ROOT)/src/libs/liblzf-3.4
4443SDK_VBOX_LZF_LIBS ?= $(PATH_STAGE_LIB)/VBox-liblzf$(VBOX_SUFF_LIB)
4444
4445SDK_VBOX_LZF-x86 = .
4446SDK_VBOX_LZF-x86_EXTENDS = VBOX_LZF
4447SDK_VBOX_LZF_LIBS-x86 ?= $(PATH_STAGE_LIB)/VBox-liblzf-x86$(VBOX_SUFF_LIB)
4448
4449SDK_VBOX_LZF_STATIC = .
4450SDK_VBOX_LZF_STATIC_EXTENDS ?= VBOX_LZF
4451if1of ($(KBUILD_TARGET), os2 win)
4452 SDK_VBOX_LZF_STATIC_LIBS ?= $(PATH_STAGE_LIB)/VBox-liblzf-static$(VBOX_SUFF_LIB)
4453endif
4454
4455SDK_VBOX_OPENSSL = Only for VBoxRT and/or statically linked programs.
4456SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS := $(PATH_OUT)/obj/crypto-1.1.1-headers/include
4457SDK_VBOX_OPENSSL_INCS ?= $(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)
4458SDK_VBOX_OPENSSL_ORDERDEPS ?= $(crypto-headers_1_TARGET)
4459if !defined(VBOX_ONLY_SDK) \
4460 && (!defined(VBOX_ONLY_ADDITIONS) || !defined(VBOX_ONLY_ADDITIONS_WITHOUT_RTISOMAKER)) \
4461 && (!defined(VBOX_ONLY_EXTPACKS) || defined(VBOX_NEED_EXTPACK_OPENSSL) || !defined(VBOX_ONLY_EXTPACKS_USE_IMPLIBS)) \
4462 && ("$(SDK_VBOX_OPENSSL_INCS)" == "$(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)" || defined(VBOX_NEED_EXTPACK_OPENSSL))
4463 SDK_VBOX_OPENSSL_DEPS ?= $(SDK_VBOX_OPENSSL_INCS)/openssl/openssl-mangling.h
4464endif
4465SDK_VBOX_OPENSSL_LIBS ?= \
4466 $(PATH_STAGE_LIB)/VBox-libssl$(VBOX_SUFF_LIB) \
4467 $(PATH_STAGE_LIB)/VBox-libcrypto$(VBOX_SUFF_LIB)
4468
4469SDK_VBOX_OPENSSL-x86 = Only for VBoxRT and/or statically linked programs.
4470SDK_VBOX_OPENSSL-x86_VBOX_DEFAULT_INCS := $(PATH_OUT)/obj/crypto-1.1.1-headers/include
4471SDK_VBOX_OPENSSL-x86_INCS ?= $(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)
4472SDK_VBOX_OPENSSL-x86_ORDERDEPS ?= $(crypto-headers_1_TARGET)
4473if ("$(SDK_VBOX_OPENSSL_INCS)" == "$(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)" || defined(VBOX_NEED_EXTPACK_OPENSSL))
4474 SDK_VBOX_OPENSSL-x86_DEPS ?= $(SDK_VBOX_OPENSSL_INCS)/openssl/openssl-mangling.h
4475endif
4476SDK_VBOX_OPENSSL-x86_LIBS ?= \
4477 $(PATH_STAGE_LIB)/VBox-libssl-x86$(VBOX_SUFF_LIB) \
4478 $(PATH_STAGE_LIB)/VBox-libcrypto-x86$(VBOX_SUFF_LIB)
4479
4480SDK_VBOX_OPENSSL2 = What you should be using.
4481SDK_VBOX_OPENSSL2_EXTENDS = VBOX_OPENSSL
4482if "$(SDK_VBOX_OPENSSL_INCS)" == "$(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)"
4483 SDK_VBOX_OPENSSL2_LIBS = $(NO_SUCH_VARIABLE)
4484endif
4485
4486ifdef VBOX_WITH_LIBCURL
4487SDK_VBOX_LIBCURL = .
4488SDK_VBOX_LIBCURL_INCS ?= $(PATH_ROOT)/src/libs/curl-7.64.0/include
4489SDK_VBOX_LIBCURL_LIBS ?= $(PATH_STAGE_LIB)/VBox-libcurl$(VBOX_SUFF_LIB)
4490SDK_VBOX_LIBCURL_DEFS ?= BUILDING_LIBCURL
4491
4492SDK_VBOX_LIBCURL-x86 = .
4493SDK_VBOX_LIBCURL-x86_INCS ?= $(PATH_ROOT)/src/libs/curl-7.64.0/include
4494SDK_VBOX_LIBCURL-x86_LIBS.x86 ?= $(PATH_STAGE_LIB)/VBox-libcurl-x86$(VBOX_SUFF_LIB)
4495SDK_VBOX_LIBCURL-x86_DEFS ?= BUILDING_LIBCURL
4496endif
4497
4498ifdef VBOX_WITH_LIBVPX
4499 SDK_VBOX_VPX = .
4500 SDK_VBOX_VPX_DEFAULT_INCS := $(PATH_ROOT)/src/libs/libvpx-1.6.1
4501 SDK_VBOX_VPX_INCS ?= $(SDK_VBOX_VPX_DEFAULT_INCS)
4502 SDK_VBOX_VPX_LIBS ?= $(PATH_STAGE_LIB)/VBox-libvpx$(VBOX_SUFF_LIB)
4503endif
4504
4505ifdef VBOX_WITH_LIBOPUS
4506 SDK_VBOX_OPUS = .
4507 SDK_VBOX_OPUS_DEFAULT_INCS := $(PATH_ROOT)/src/libs/libopus-1.2.1/include
4508 SDK_VBOX_OPUS_INCS ?= $(SDK_VBOX_OPUS_DEFAULT_INCS)
4509 SDK_VBOX_OPUS_LIBS ?= $(PATH_STAGE_LIB)/VBox-libopus$(VBOX_SUFF_LIB)
4510endif
4511
4512ifdef VBOX_WITH_LIBFUSE
4513 SDK_VBOX_FUSE = .
4514 SDK_VBOX_FUSE_DEFAULT_INCS := $(PATH_ROOT)/src/libs/libfuse-2.9.8/include
4515 SDK_VBOX_FUSE_INCS ?= $(SDK_VBOX_FUSE_DEFAULT_INCS)
4516 SDK_VBOX_FUSE_LIBS ?= $(PATH_STAGE_LIB)/VBox-libfuse$(VBOX_SUFF_LIB)
4517endif
4518
4519#
4520# Special SDK for the problematic NTDLL.LIB.
4521#
4522SDK_VBOX_NTDLL = Mini NTDLL import library, required IPRT.
4523SDK_VBOX_NTDLL_LIBS.x86 ?= $(PATH_STAGE_LIB)/RuntimeR3NtDll-x86.lib
4524SDK_VBOX_NTDLL_LIBS.amd64 ?= $(PATH_STAGE_LIB)/RuntimeR3NtDll-amd64.lib
4525
4526#
4527# Determine Solaris version.
4528#
4529ifeq ($(KBUILD_TARGET),solaris)
4530 VBOX_SOLARIS_VERSION := $(expr $(KBUILD_HOST_VERSION_MAJOR) * 100 + $(KBUILD_HOST_VERSION_MINOR))
4531 ifeq ($(VBOX_SOLARIS_VERSION),510)
4532 DEFS.solaris += RT_OS_SOLARIS_10
4533 # Solaris 10 does not include crossbow.
4534 VBOX_SOLARIS_10 = 1
4535 # We cannot compile additions on Solaris 10, due kernel interface deps
4536 VBOX_WITHOUT_ADDITIONS := 1
4537 VBOX_WITH_ADDITIONS =
4538 else ifeq ($(VBOX_SOLARIS_VERSION),511)
4539 # OSS audio support for Solaris
4540 VBOX_WITH_AUDIO_OSS := 1
4541 endif
4542
4543 # XPCOM namespace cleanup issue with Solaris GCC 4.5.2 and newer, see @bugref{5838}.
4544 if $(VBOX_GCC_VERSION_CXX) >= 40502
4545 VBOX_WITH_XPCOM_NAMESPACE_CLEANUP =
4546 endif
4547endif
4548
4549#
4550# VBoxTpG tool.
4551#
4552TOOL_VBoxTpG = The VirtualBox Tracepoint Generator
4553TOOL_VBoxTpG_DTRACE_DEPORD = $(VBOX_VBOXTPG)
4554TOOL_VBoxTpG_DTRACE_HDR_FLAGS := \
4555 -h --host-$(VBOX_HC_ARCH_BITS)-bit #-vvv
4556define TOOL_VBoxTpG_DTRACE_HDR_CMDS
4557 $(QUIET)$(VBOX_VBOXTPG) $(if-expr $(intersects $(bld_trg_arch),$(KBUILD_ARCHES_64)),-64,-32) \
4558 $(flags) -o "$(out)" -s "$(source)"
4559endef
4560TOOL_VBoxTpG_DTRACE_OBJ_NOT_NEEDED :=
4561TOOL_VBoxTpG_DTRACE_OBJ_FLAGS := -G --host-$(VBOX_HC_ARCH_BITS)-bit #-vvv
4562define TOOL_VBoxTpG_DTRACE_OBJ_CMDS
4563 $(QUIET)$(VBOX_VBOXTPG) --assembler "$(TOOL_$(VBOX_ASTOOL)_AS)" \
4564 $(if-expr $(intersects $(bld_trg_arch),$(KBUILD_ARCHES_64)),-64,-32) \
4565 $(flags) \
4566 -o "$(out)" -s "$(source)"
4567endef
4568
4569
4570#
4571# VBoxTpG tool - Disabled, only generate the header.
4572#
4573TOOL_VBoxTpG-Disabled = The VirtualBox Tracepoint Generator, disabled.
4574TOOL_VBoxTpG-Disabled_DTRACE_DEPORD = $(VBOX_VBOXTPG)
4575TOOL_VBoxTpG-Disabled_DTRACE_HDR_FLAGS := -h
4576define TOOL_VBoxTpG-Disabled_DTRACE_HDR_CMDS
4577 $(QUIET)$(VBOX_VBOXTPG) $(flags) -o "$(out)" -s "$(source)"
4578endef
4579TOOL_VBoxTpG-Disabled_DTRACE_OBJ_NOT_NEEDED := $(KBUILD_OSES)
4580
4581
4582#
4583# dtrace+VBoxTpG tool for ring-3 to ring-0 pointer conversion.
4584#
4585TOOL_DTraceAndVBoxTpG = DTrace and the VirtualBox Tracepoint Generator working together on static ring-3 probes.
4586TOOL_DTraceAndVBoxTpG_EXTENDS = StandardDTrace
4587TOOL_DTraceAndVBoxTpG_DTRACE_DEPORD = $(VBOX_VBOXTPG)
4588TOOL_DTraceAndVBoxTpG_DTRACE_HDR_CMDS =
4589define TOOL_DTraceAndVBoxTpG_DTRACE_HDR_CMDS
4590 $(TOOL_StandardDTrace_DTRACE_HDR_CMDS)
4591 $(QUIET)$(VBOX_VBOXTPG) --generate-wrapper-header --host-$(VBOX_HC_ARCH_BITS)-bit --ring-3-context \
4592 $(filter-out -C, $(filter-out -h,$(flags))) \
4593 -o "$(out).tmp" -s "$(source)"
4594 $(APPEND) "$(out).tmp"
4595 $(SED) -e 's/\(#define.*\)(arg0/\1_ORIGINAL(arg0/' --append "$(out).tmp" "$(out)"
4596 $(MV) -f -- "$(out).tmp" "$(out)"
4597endef
4598TOOL_DTraceAndVBoxTpG_DTRACE_OBJ_NOT_NEEDED = $(TOOL_StandardDTrace_DTRACE_OBJ_NOT_NEEDED)
4599TOOL_DTraceAndVBoxTpG_DTRACE_OBJ_CMDS = $(TOOL_StandardDTrace_DTRACE_OBJ_CMDS)
4600
4601
4602ifdef VBOX_WITH_RAW_MODE
4603 #
4604 # Template for building RC things.
4605 #
4606 # Disabled Visual C++ warnings:
4607 # -wd4505: 'iemRaisePageFaultJmp' : unreferenced local function has been removed
4608 #
4609 TEMPLATE_VBoxRc = VBox Raw-Mode Context
4610 TEMPLATE_VBoxRc_ASTOOL := $(VBOX_ASTOOL)
4611 TEMPLATE_VBoxRc_ASFLAGS = $(VBOX_ASFLAGS32)
4612 TEMPLATE_VBoxRc_DEFS = IN_RC IPRT_NO_CRT RT_WITH_NOCRT_ALIASES $(ARCH_BITS_DEFS)
4613 TEMPLATE_VBoxRc_INCS = $(PATH_ROOT)/include/iprt/nocrt
4614 TEMPLATE_VBoxRc_SYSSUFF = .rc
4615 TEMPLATE_VBoxRc_BLD_TRG_ARCH = x86
4616 TEMPLATE_VBoxRc_MODE = a+r,u+w
4617
4618 TEMPLATE_VBoxRc_USES += dtrace
4619 TEMPLATE_VBoxRc_DTRACE_HDR_FLAGS = --raw-mode-context
4620 TEMPLATE_VBoxRc_DTRACE_OBJ_FLAGS = --raw-mode-context --probe-fn-name "VMMRCProbeFire"
4621 ifdef VBOX_WITH_DTRACE_RC
4622 TEMPLATE_VBoxRc_DTRACETOOL = VBoxTpG
4623 TEMPLATE_VBoxRc_DEFS += VBOX_WITH_DTRACE VBOX_WITH_DTRACE_RC
4624 else
4625 TEMPLATE_VBoxRc_DTRACETOOL = VBoxTpG-Disabled
4626 endif
4627
4628 ifeq ($(VBOX_LDR_FMT32),pe)
4629 TEMPLATE_VBoxRc_TOOL = $(VBOX_VCC_TOOL_STEM)X86
4630 TEMPLATE_VBoxRc_RCDEFS = VBOX_SVN_REV=$(VBOX_SVN_REV) VBOX_SVN_REV_MOD_5K=$(expr $(VBOX_SVN_REV) % 50000)
4631 TEMPLATE_VBoxRc_CXXFLAGS = -Zi -Zl -GR- -EHs- -GF -GS- -Zc:wchar_t- -Gs8192 $(VBOX_VCC_GC_OPT) $(VBOX_VCC_GC_FP) \
4632 $(VBOX_VCC_WARN_ALL) -wd4505 $(VBOX_VCC_WERR)
4633 ifdef VBOX_WITH_MSC_ANALYZE_THIS
4634 TEMPLATE_VBoxRc_CXXFLAGS += /analyze
4635 endif
4636 TEMPLATE_VBoxRc_CFLAGS = $(TEMPLATE_VBoxRc_CXXFLAGS)
4637 TEMPLATE_VBoxRc_LDFLAGS = -Ignore:4197 \
4638 -Driver -Subsystem:NATIVE -Incremental:NO -Align:64 -MapInfo:Exports -NoD $(VBOX_VCC_LD_WERR) -Release -Debug -Opt:Ref -Opt:Icf \
4639 -Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
4640 -Stub:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com
4641 ifdef VBOX_SIGNING_MODE
4642 TEMPLATE_VBoxRc_LDFLAGS += -IntegrityCheck
4643 endif
4644 TEMPLATE_VBoxRc_LIBS = \
4645 $(PATH_SDK_$(VBOX_WINDDK)_LIB.x86)/int64.lib
4646 TEMPLATE_VBoxRc_LIBS += \
4647 $(PATH_STAGE_LIB)/RuntimeRCStub$(VBOX_SUFF_LIB)
4648 TEMPLATE_VBoxRc_POST_CMDS = $(VBOX_SIGN_IMAGE_CMDS)
4649 endif # pe
4650
4651 ifeq ($(VBOX_LDR_FMT32),elf)
4652 TEMPLATE_VBoxRc_TOOL = $(VBOX_GCC32_TOOL)
4653 TEMPLATE_VBoxRc_CXXFLAGS = -fno-pie -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC32_Wno-variadic-macros) -fno-exceptions $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_fvisibility-inlines-hidden) -fno-rtti $(VBOX_GCC_IPRT_FMT_CHECK)
4654 TEMPLATE_VBoxRc_CFLAGS = -fno-pie -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_C) $(VBOX_GCC32_Wno-variadic-macros) -fno-exceptions $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_IPRT_FMT_CHECK)
4655 if $(VBOX_GCC32_VERSION_CC) < 30400
4656 TEMPLATE_VBoxRc_DEFS += RT_WITHOUT_PRAGMA_ONCE
4657 endif
4658 ifeq ($(KBUILD_TARGET),solaris)
4659 TEMPLATE_VBoxRc_LDFLAGS = -r
4660 else
4661 TEMPLATE_VBoxRc_LDFLAGS = -nostdlib -Bsymbolic -g
4662 ## @todo WTF doesn't the globals work? Debug info is supposed to be split everywhere. GRR
4663 TEMPLATE_VBoxRc_LD_DEBUG = split
4664 endif
4665 ifn1of ($(KBUILD_TARGET), solaris freebsd)
4666 TEMPLATE_VBoxRc_LIBS = \
4667 $(VBOX_GCC32_LIBGCC) # intrinsics
4668 endif
4669 if1of ($(KBUILD_TARGET),linux)
4670 TEMPLATE_VBoxRc_POST_CMDS = $(if $(eq $(tool_do),LINK_SYSMOD),if readelf -S $(out)|grep -q "[cd]tors"; then echo "Found ctors/dtors in $(out)!"; exit 1; fi)
4671 endif
4672 endif
4673
4674 ifeq ($(VBOX_LDR_FMT32),macho)
4675 TEMPLATE_VBoxRc_TOOL = $(VBOX_GCC_TOOL)
4676 TEMPLATE_VBoxRc_SDKS += $(VBOX_DARWIN_DEF_SDK_SDKS)
4677 TEMPLATE_VBoxRc_DEFS += $(VBOX_DARWIN_DEF_SDK_DEFS)
4678 TEMPLATE_VBoxRc_CXXFLAGS = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS) -m32 -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC32_Wno-variadic-macros) -fno-common -msoft-float -static $(VBOX_GCC_fno-stack-protector) -fno-exceptions $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -fno-strict-aliasing -fno-rtti $(VBOX_GCC_std)
4679 TEMPLATE_VBoxRc_CFLAGS = $(VBOX_DARWIN_DEF_SDK_CFLAGS) -m32 -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_C) $(VBOX_GCC32_Wno-variadic-macros) -fno-common -msoft-float -static $(VBOX_GCC_fno-stack-protector) -fno-exceptions $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -fno-strict-aliasing
4680 TEMPLATE_VBoxRc_LDFLAGS = $(VBOX_DARWIN_DEF_SDK_LDFLAGS) -m32 -nostdlib
4681 #TEMPLATE_VBoxRc_LDFLAGS.release = -Wl,-S ???
4682 endif
4683
4684 ifeq ($(VBOX_LDR_FMT32),lx)
4685 TEMPLATE_VBoxRc_TOOL = GXX3OMF
4686 if $(VBOX_GCC_VERSION_CC) < 30400
4687 TEMPLATE_VBoxRc_DEFS += RT_WITHOUT_PRAGMA_ONCE
4688 endif
4689 TEMPLATE_VBoxRc_CXXFLAGS = -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC32_Wno-variadic-macros) $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -fno-strict-aliasing -fno-exceptions -fno-rtti
4690 TEMPLATE_VBoxRc_CFLAGS = -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_C) $(VBOX_GCC32_Wno-variadic-macros) $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -fno-strict-aliasing -fno-exceptions
4691 TEMPLATE_VBoxRc_LDFLAGS = -Zdll -nostdlib
4692 TEMPLATE_VBoxRc_LIBS = \
4693 $(VBOX_GCC32_LIBGCC) \
4694 $(VBOX_OBJ_SYS0) \
4695 end
4696 endif
4697
4698
4699 #
4700 # Template for building a RC ring-3 testcase (tstVMStructGC, tstDevStructGC).
4701 #
4702 TEMPLATE_VBoxRcExe = VBox Raw-Mode as ring-3 testcase
4703 TEMPLATE_VBoxRcExe_EXTENDS = VBoxRc
4704 TEMPLATE_VBoxRcExe_DEFS = $(filter-out IPRT_NO_CRT RT_WITH_NOCRT_ALIASES,$(TEMPLATE_VBoxRc_DEFS))
4705 TEMPLATE_VBoxRcExe_INCS = $(NO_SUCH_VARIABLE)
4706 TEMPLATE_VBoxRcExe_MODE = $(NO_SUCH_VARIABLE)
4707
4708 ifeq ($(VBOX_LDR_FMT32),pe)
4709 TEMPLATE_VBoxRcExe_LDFLAGS = -Ignore:4197 \
4710 -Incremental:NO -MapInfo:Exports -NoD -Debug -Opt:Ref -Opt:Icf \
4711 -Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
4712 -Stub:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com
4713 TEMPLATE_VBoxRcExe_SDKS = ReorderCompilerIncs $(VBOX_WINPSDK)
4714 TEMPLATE_VBoxRcExe_LIBS = \
4715 $(PATH_TOOL_$(VBOX_VCC_TOOL_STEM)X86_LIB)/libcmt.lib \
4716 $(PATH_TOOL_$(VBOX_VCC_TOOL_STEM)X86_LIB)/oldnames.lib
4717 endif
4718
4719 ifeq ($(VBOX_LDR_FMT32),elf)
4720 TEMPLATE_VBoxRcExe_CFLAGS = $(filter-out -nostdinc,$(TEMPLATE_VBoxRc_CFLAGS)) -O0
4721 TEMPLATE_VBoxRcExe_CXXFLAGS = $(filter-out -nostdinc,$(TEMPLATE_VBoxRc_CXXFLAGS)) -O0
4722 TEMPLATE_VBoxRcExe_LDFLAGS = -g
4723 TEMPLATE_VBoxRcExe_LDFLAGS.dbgopt = -g
4724 TEMPLATE_VBoxRcExe_LDFLAGS.strict = -g
4725 TEMPLATE_VBoxRcExe_LDFLAGS.release = -g
4726 if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), freebsd.amd64)
4727 # The FreeBSD port of gcc isn't picking up -m32 where it should.
4728 TEMPLATE_VBoxRcExe_DEFS.$(KBUILD_TARGET) = $(TEMPLATE_VBoxRc_DEFS.$(KBUILD_TARGET)) IPRT_DONT_USE_SYSTEM_STDINT_H
4729 TEMPLATE_VBoxRcExe_LDFLAGS.$(KBUILD_TARGET) = /usr/lib32/crt1.o /usr/lib32/crti.o /usr/lib32/crtbegin.o $(TEMPLATE_VBoxRc_LDFLAGS.$(KBUILD_TARGET)) -nostdlib -v
4730 TEMPLATE_VBoxRcExe_LIBPATH.$(KBUILD_TARGET) = /usr/lib32
4731 TEMPLATE_VBoxRcExe_LIBS.$(KBUILD_TARGET) = /usr/lib32/crtend.o /usr/lib32/crtn.o /usr/lib32/libc.so
4732 endif
4733 endif
4734
4735 ifeq ($(VBOX_LDR_FMT32),macho)
4736 TEMPLATE_VBoxRcExe_CFLAGS = $(filter-out -static -nostdinc,$(TEMPLATE_VBoxRc_CFLAGS))
4737 TEMPLATE_VBoxRcExe_CXXFLAGS = $(filter-out -static -nostdinc,$(TEMPLATE_VBoxRc_CXXFLAGS))
4738 TEMPLATE_VBoxRcExe_LDFLAGS = -g -m32
4739 endif
4740
4741 ifeq ($(VBOX_LDR_FMT32),lx)
4742 TEMPLATE_VBoxRcExe_CFLAGS = $(filter-out -nostdinc,$(TEMPLATE_VBoxRc_CFLAGS))
4743 TEMPLATE_VBoxRcExe_CXXFLAGS = $(filter-out -nostdinc,$(TEMPLATE_VBoxRc_CXXFLAGS))
4744 TEMPLATE_VBoxRcExe_LDFLAGS = -g
4745 TEMPLATE_VBoxRcExe_LIBS = $(NO_SUCH_VARIABLE)
4746 endif
4747endif # VBOX_WITH_RAW_MODE
4748
4749
4750#
4751# Template for building R0 things.
4752#
4753# Disabled Visual C++ warnings:
4754# -wd4505: 'iemRaisePageFaultJmp' : unreferenced local function has been removed
4755#
4756TEMPLATE_VBoxR0 = VBox Ring 0
4757TEMPLATE_VBoxR0_ASTOOL := $(VBOX_ASTOOL)
4758TEMPLATE_VBoxR0_ASFLAGS = $(VBOX_ASFLAGS)
4759TEMPLATE_VBoxR0_DEFS = IN_RING0 IN_RING0_AGNOSTIC IPRT_NO_CRT RT_WITH_NOCRT_ALIASES $(ARCH_BITS_DEFS)
4760TEMPLATE_VBoxR0_INCS = $(PATH_ROOT)/include/iprt/nocrt
4761TEMPLATE_VBoxR0_SYSSUFF = .r0
4762TEMPLATE_VBoxR0_MODE = a+r,u+w
4763
4764TEMPLATE_VBoxR0_USES += dtrace
4765TEMPLATE_VBoxR0_DTRACE_HDR_FLAGS = --ring-0-context-agnostic
4766TEMPLATE_VBoxR0_DTRACE_OBJ_FLAGS = --ring-0-context-agnostic
4767ifdef VBOX_WITH_DTRACE_R0
4768 TEMPLATE_VBoxR0_DTRACETOOL = VBoxTpG
4769 TEMPLATE_VBoxR0_DEFS += VBOX_WITH_DTRACE VBOX_WITH_DTRACE_R0
4770else
4771 TEMPLATE_VBoxR0_DTRACETOOL = VBoxTpG-Disabled
4772endif
4773
4774ifeq ($(VBOX_LDR_FMT),pe)
4775TEMPLATE_VBoxR0_TOOL = $(VBOX_VCC_TOOL)
4776TEMPLATE_VBoxR0_RCDEFS = VBOX_SVN_REV=$(VBOX_SVN_REV) VBOX_SVN_REV_MOD_5K=$(expr $(VBOX_SVN_REV) % 50000)
4777TEMPLATE_VBoxR0_CXXFLAGS = -Zi -Zl -GR- -EHs- -GF -GS- -Zc:wchar_t- $(VBOX_VCC_OPT) $(VBOX_VCC_FP) \
4778 $(VBOX_VCC_WARN_ALL) -wd4505 $(VBOX_VCC_WERR)
4779 ifdef VBOX_WITH_MSC_ANALYZE_THIS
4780TEMPLATE_VBoxR0_CXXFLAGS += /analyze
4781 endif
4782TEMPLATE_VBoxR0_CFLAGS = $(TEMPLATE_VBoxR0_CXXFLAGS)
4783TEMPLATE_VBoxR0_LDFLAGS = -Ignore:4197 \
4784 -Driver -Subsystem:NATIVE -Incremental:NO -Align:4096 -MapInfo:Exports -NoD $(VBOX_VCC_LD_WERR) -Release -Debug -Opt:Ref -Opt:Icf \
4785 -Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
4786 -Stub:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com
4787 ifdef VBOX_WITH_DTRACE_R0
4788TEMPLATE_VBoxR0_LDFLAGS += -Merge:VTGPrLc.Data=VTGPrLc.Begin -Merge:VTGPrLc.End=VTGPrLc.Begin -Merge:VTGPrLc.Begin=VTGObj
4789 endif
4790 ifdef VBOX_SIGNING_MODE
4791 TEMPLATE_VBoxR0_LDFLAGS += -IntegrityCheck
4792 endif
4793TEMPLATE_VBoxR0_LIBS = \
4794 $(PATH_STAGE_LIB)/RuntimeR0Stub$(VBOX_SUFF_LIB)
4795 include $(KBUILD_PATH)/sdks/$(VBOX_WINDDK).kmk ## TODO: Add a kBuild feature for loading SDKs.
4796TEMPLATE_VBoxR0_LIBS.x86 = \
4797 $(PATH_SDK_$(VBOX_WINDDK)_LIB.x86)/int64.lib
4798TEMPLATE_VBoxR0_ORDERDEPS = $(VBOX_SIGN_DRIVER_ORDERDEPS)
4799TEMPLATE_VBoxR0_POST_CMDS = $(VBOX_SIGN_DRIVER_CMDS)
4800endif # pe
4801
4802ifeq ($(VBOX_LDR_FMT),elf)
4803TEMPLATE_VBoxR0_TOOL = $(VBOX_GCC_TOOL)
4804TEMPLATE_VBoxR0_CFLAGS = -fno-pie -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_C) \
4805 $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fno-exceptions \
4806 $(VBOX_GCC_fno-stack-protector) -fno-common $(VBOX_GCC_fvisibility-hidden) -std=gnu99 $(VBOX_GCC_IPRT_FMT_CHECK)
4807TEMPLATE_VBoxR0_CXXFLAGS = -fno-pie -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_CXX) \
4808 $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fno-exceptions \
4809 $(VBOX_GCC_fno-stack-protector) -fno-common $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_fvisibility-hidden) \
4810 -fno-rtti $(VBOX_GCC_std) $(VBOX_GCC_IPRT_FMT_CHECK)
4811TEMPLATE_VBoxR0_CFLAGS.amd64 = -m64 -mno-red-zone -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fasynchronous-unwind-tables -ffreestanding
4812TEMPLATE_VBoxR0_CXXFLAGS.amd64 = -m64 -mno-red-zone -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fasynchronous-unwind-tables
4813TEMPLATE_VBoxR0_CXXFLAGS.freebsd = -ffreestanding
4814 if $(VBOX_GCC_VERSION_CC) < 30400
4815TEMPLATE_VBoxR0_DEFS += RT_WITHOUT_PRAGMA_ONCE
4816 endif
4817 ifeq ($(KBUILD_TARGET),solaris)
4818TEMPLATE_VBoxR0_LDFLAGS = -r
4819TEMPLATE_VBoxR0_LDFLAGS.solaris = -u _init -u _info
4820TEMPLATE_VBoxR0_LDFLAGS.solaris.amd64 = -m64
4821TEMPLATE_VBoxR0_LDFLAGS.solaris.x86 = -m32
4822TEMPLATE_VBoxR0_LIBS.solaris = \
4823 $(PATH_STAGE_LIB)/RuntimeR0Stub$(VBOX_SUFF_LIB)
4824 ifdef VBOX_GCC_USING_SOLARIS_AS
4825TEMPLATE_VBoxR0_CFLAGS.amd64 += -Wa,-xmodel=kernel
4826TEMPLATE_VBoxR0_CXXFLAGS.amd64 += -Wa,-xmodel=kernel
4827 endif
4828 # Solaris driver signing.
4829TEMPLATE_VBoxR0_POST_CMDS = $(VBOX_SIGN_DRIVER_CMDS)
4830 else
4831TEMPLATE_VBoxR0_LDFLAGS = -nostdlib -Bsymbolic -g
4832 ## @todo WTF doesn't the globals work? Debug info is supposed to be split everywhere. GRR
4833TEMPLATE_VBoxR0_LD_DEBUG = split
4834 endif
4835 if "$(KBUILD_TARGET)" == "linux" && !defined(VBOX_WITH_KMOD_WRAPPED_R0_MODS)
4836VBOX_WITH_VBOXR0_AS_DLL = 1
4837TEMPLATE_VBoxR0_DLLSUFF = .r0
4838TEMPLATE_VBoxR0_CFLAGS += -fPIC
4839TEMPLATE_VBoxR0_CXXFLAGS += -fPIC
4840TEMPLATE_VBoxR0_LDFLAGS +=
4841TEMPLATE_VBoxR0_DTRACE_HDR_FLAGS += --pic
4842TEMPLATE_VBoxR0_DTRACE_OBJ_FLAGS += --pic
4843 else
4844TEMPLATE_VBoxR0_CFLAGS.amd64 += -mcmodel=kernel
4845TEMPLATE_VBoxR0_CXXFLAGS.amd64 += -mcmodel=kernel
4846 endif
4847 ifdef VBOX_WITH_KMOD_WRAPPED_R0_MODS # For BTF/pahold issue we use -g1
4848TEMPLATE_VBoxR0_DEFS += VBOX_WITH_KMOD_WRAPPED_R0_MODS
4849TEMPLATE_VBoxR0_LDFLAGS.linux += $(PATH_ROOT)/src/VBox/HostDrivers/Support/linux/VBoxR0-wrapped.lds
4850TEMPLATE_VBoxR0_LNK_DEPS.linux += $(PATH_ROOT)/src/VBox/HostDrivers/Support/linux/VBoxR0-wrapped.lds
4851TEMPLATE_VBoxR0_CFLAGS.linux += -g1
4852TEMPLATE_VBoxR0_CXXFLAGS.linux += -g1
4853 endif
4854 ifn1of ($(KBUILD_TARGET),solaris freebsd)
4855 TEMPLATE_VBoxR0_LIBS = \
4856 $(VBOX_GCC_LIBGCC) # intrinsics
4857 endif
4858 if1of ($(KBUILD_TARGET),linux)
4859 TEMPLATE_VBoxR0_POST_CMDS += $(NLTAB)\
4860 $(if $(eq $(tool_do),LINK_SYSMOD),if readelf -S $(out)|grep -q "[cd]tors"; then echo "Found ctors/dtors in $(out)!"; exit 1; fi)
4861 endif
4862endif # elf
4863
4864ifeq ($(VBOX_LDR_FMT),macho)
4865TEMPLATE_VBoxR0_TOOL = $(VBOX_GCC_TOOL)
4866TEMPLATE_VBoxR0_SDKS += $(VBOX_DARWIN_DEF_SDK_SDKS)
4867TEMPLATE_VBoxR0_DEFS += $(VBOX_DARWIN_DEF_SDK_DEFS)
4868TEMPLATE_VBoxR0_CXXFLAGS = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS) -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC_Wno-variadic-macros) \
4869 -fno-common -static -fno-rtti -fno-exceptions $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing \
4870 $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_std)
4871TEMPLATE_VBoxR0_CXXFLAGS.amd64 = -m64 -msoft-float -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-red-zone -mno-sse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-sse4a -fno-unwind-tables
4872TEMPLATE_VBoxR0_CXXFLAGS.x86 = -m32 -msoft-float -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
4873TEMPLATE_VBoxR0_CXXFLAGS.arm64 = -m64 -target arm64e-apple-macos11.0 # Assembly fixup issues w/o the -target bit. Why?
4874TEMPLATE_VBoxR0_CFLAGS = $(VBOX_DARWIN_DEF_SDK_CFLAGS) -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_C) $(VBOX_GCC_Wno-variadic-macros) \
4875 -fno-common -static -fno-exceptions $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing \
4876 $(VBOX_GCC_fno-stack-protector)
4877TEMPLATE_VBoxR0_CFLAGS.amd64 = -m64 -msoft-float -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-red-zone -mno-sse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-sse4a -fno-unwind-tables
4878TEMPLATE_VBoxR0_CFLAGS.x86 = -m32 -msoft-float -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
4879TEMPLATE_VBoxR0_CFLAGS.arm64 = -m64 -target arm64e-apple-macos11.0
4880TEMPLATE_VBoxR0_LDFLAGS = $(VBOX_DARWIN_DEF_SDK_LDFLAGS) -nostdlib
4881TEMPLATE_VBoxR0_LDFLAGS.amd64 = -m64 -static
4882TEMPLATE_VBoxR0_LDFLAGS.arm64 = -m64 -static
4883TEMPLATE_VBoxR0_LDFLAGS.x86 = -m32
4884TEMPLATE_VBoxR0_CXXFLAGS.amd64 += -mkernel
4885TEMPLATE_VBoxR0_CFLAGS.amd64 += -mkernel
4886TEMPLATE_VBoxR0_CXXFLAGS.arm64 += -mkernel
4887TEMPLATE_VBoxR0_CFLAGS.arm64 += -mkernel
4888TEMPLATE_VBoxR0_LDFLAGS += -Wl,-kext -mkernel
4889TEMPLATE_VBoxR0_POST_CMDS = $(if $(eq $(tool_do),LINK_LIBRARY),,$(call VBOX_SIGN_VMM_MOD_FN,$(out),org.virtualbox.app.r0.$(target)))
4890endif
4891
4892ifeq ($(VBOX_LDR_FMT),lx)
4893TEMPLATE_VBoxR0_TOOL = GXX3OMF
4894TEMPLATE_VBoxR0_CFLAGS = -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_C) $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fno-exceptions -fno-common
4895TEMPLATE_VBoxR0_CXXFLAGS = -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fno-exceptions -fno-common -fno-rtti
4896 if $(VBOX_GCC_VERSION_CC) < 30400
4897TEMPLATE_VBoxR0_DEFS += RT_WITHOUT_PRAGMA_ONCE
4898 endif
4899TEMPLATE_VBoxR0_LDFLAGS = -nostdlib -Zdll
4900TEMPLATE_VBoxR0_LIBS = \
4901 $(VBOX_GCC_LIBGCC) \
4902 $(VBOX_OBJ_SYS0) \
4903 end
4904endif
4905
4906
4907#
4908# Template for building SUPDRV R0 things.
4909#
4910# Disabled Visual C++ warnings:
4911# -wd4996: deprecated / insecure.
4912# -wd4127: conditional expression is constant [level 4]
4913# -wd4201: nonstandard extension used : nameless struct/union [level 4]
4914# -wd4214: nonstandard extension used : bit field types other than int [level 4]
4915# -wd4706: assignment within conditional expression [level 4]
4916# -wd4324: '_TDI_PNP_CONTEXT_XP' : structure was padded due to __declspec(align())
4917#
4918# -wd4100: 'identifier' : unreferenced formal parameter [level 4] --- TODO: Enable this one!
4919#
4920TEMPLATE_VBOXR0DRV = VBox SUPDRV Ring 0
4921TEMPLATE_VBOXR0DRV_ASTOOL := $(VBOX_ASTOOL)
4922TEMPLATE_VBOXR0DRV_ASFLAGS = $(VBOX_ASFLAGS)
4923TEMPLATE_VBOXR0DRV_DEFS = IN_RING0 IN_RT_R0 $(ARCH_BITS_DEFS)
4924TEMPLATE_VBOXR0DRV_USES += dtrace
4925ifdef VBOX_WITH_DTRACE_R0DRV
4926 TEMPLATE_VBOXR0DRV_DTRACETOOL = VBoxTpG
4927 TEMPLATE_VBOXR0DRV_DEFS += VBOX_WITH_DTRACE VBOX_WITH_DTRACE_R0DRV
4928 ifdef VBOX_WITH_NATIVE_DTRACE
4929 TEMPLATE_VBOXR0DRV_DEFS += VBOX_WITH_NATIVE_DTRACE
4930 endif
4931else
4932 TEMPLATE_VBOXR0DRV_DTRACETOOL = VBoxTpG-Disabled
4933endif
4934
4935ifeq ($(KBUILD_TARGET),win)
4936 TEMPLATE_VBOXR0DRV_TOOL = $(VBOX_VCC_TOOL)
4937 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140" # for stddef.h ## @todo 8489: check if still needed
4938 TEMPLATE_VBOXR0DRV_SDKS = WINSDK10-UCRT-INCS
4939 endif
4940 TEMPLATE_VBOXR0DRV_RCDEFS = VBOX_SVN_REV=$(VBOX_SVN_REV) VBOX_SVN_REV_MOD_5K=$(expr $(VBOX_SVN_REV) % 50000)
4941 TEMPLATE_VBOXR0DRV_DEFS.x86 = _X86_
4942 TEMPLATE_VBOXR0DRV_DEFS.x86 += NO_INTERLOCKED_INTRINSICS # Avoids intrisic VC/WDK trouble
4943 TEMPLATE_VBOXR0DRV_DEFS.x86 += WIN9X_COMPAT_SPINLOCK # Avoid multiply defined _KeInitializeSpinLock@4
4944 TEMPLATE_VBOXR0DRV_DEFS.amd64 = _AMD64_
4945 TEMPLATE_VBOXR0DRV_DEFS.win = IPRT_NT_MAP_TO_ZW
4946 TEMPLATE_VBOXR0DRV_CXXFLAGS = -Zi -Zl -GR- -EHs- -GF -Gz -GS- -Zc:wchar_t- $(VBOX_VCC_FP) -Gs4096 $(VBOX_VCC_OPT) \
4947 $(VBOX_VCC_WARN_ALL) $(VBOX_VCC_WERR)
4948 ifdef VBOX_WITH_MSC_ANALYZE_THIS
4949 TEMPLATE_VBOXR0DRV_CXXFLAGS += /analyze
4950 endif
4951 TEMPLATE_VBOXR0DRV_CFLAGS = $(TEMPLATE_VBOXR0DRV_CXXFLAGS)
4952 TEMPLATE_VBOXR0DRV_LDFLAGS = -Ignore:4197 \
4953 -Driver -Subsystem:NATIVE -Incremental:NO -Align:4096 -MapInfo:Exports -NoD -Release -Debug -Opt:Ref -Opt:Icf \
4954 -Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
4955 -Stub:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com
4956 ifdef VBOX_WITH_DTRACE_R0DRV
4957 TEMPLATE_VBOXR0DRV_LDFLAGS += -Merge:VTGPrLc.Data=VTGPrLc.Begin -Merge:VTGPrLc.End=VTGPrLc.Begin -Merge:VTGPrLc.Begin=VTGObj
4958 endif
4959 ifdef VBOX_SIGNING_MODE
4960 TEMPLATE_VBOXR0DRV_LDFLAGS += -IntegrityCheck
4961 endif
4962 TEMPLATE_VBOXR0DRV_ORDERDEPS = $(VBOX_SIGN_DRIVER_ORDERDEPS)
4963 TEMPLATE_VBOXR0DRV_POST_CMDS = $(VBOX_SIGN_DRIVER_CMDS)
4964endif
4965
4966ifeq ($(KBUILD_TARGET),linux)
4967 TEMPLATE_VBOXR0DRV_TOOL = $(NO_SUCH_VARIABLE)
4968
4969 ifndef KERN_DIR
4970 ifndef KERN_VER
4971 KERN_VER := $(patsubst /lib/modules/%/build/.config,%,$(firstword $(shell LC_ALL=C ls -t /lib/modules/*/build/.config 2>/dev/null)))
4972 endif
4973 ifeq ($(KERN_VER),)
4974 KERN_VER := $(shell uname -r)
4975 endif
4976 KERN_DIR := /lib/modules/$(KERN_VER)/build
4977 endif
4978
4979 ##
4980 ## Generates a rule for test-building a linux kernel module (use evalcall2 to invoke).
4981 ##
4982 ## Since Linux KBuild will not abort due to undefined symbols when building
4983 ## external modules we need to grep the error output ourselves. Since vboxdrv
4984 ## and vboxguest respectively provide symbols that other modules use, we use
4985 ## the rule target (tst*.run) to save those symbols so that KBuild can do its
4986 ## checking.
4987 ##
4988 ## @param 1 Module name.
4989 ## @param 2 The test build which symvers we need (empty if none)
4990 ## @param 3 Save symvers if non-empty.
4991 ##
4992 ## @note Using the extra expansion to replace $(1), $(2) and $(3) before eval,
4993 ## thus everything else needs escaped dollars.
4994 ##
4995 if defined(VBOX_WITH_TESTCASES) \
4996 && "$(KBUILD_HOST)" == "linux" \
4997 && "$(KBUILD_HOST_ARCH)" == "$(KBUILD_TARGET_ARCH)" \
4998 && !defined(VBOX_WITHOUT_LINUX_TEST_BUILDS) \
4999 && !defined(VBOX_ONLY_SDK) \
5000 && !defined(VBOX_ONLY_DOCS) \
5001 && !defined(VBOX_ONLY_VALIDATIONKIT)
5002 define VBOX_LINUX_KMOD_TEST_BUILD_RULE_FN
5003 ifneq ($(KERN_DIR),)
5004TESTING += $$(PATH_TARGET)/tst$(1)$(subst /,_,$(KERN_DIR))_mod.run
5005OTHERS += $$(PATH_TARGET)/tst$(1)$(subst /,_,$(KERN_DIR))_mod.run
5006OTHERS_CLEAN += $$(PATH_TARGET)/tst$(1)$(subst /,_,$(KERN_DIR))_mod.run
5007$$(PATH_TARGET)/tst$(1)$(subst /,_,$(KERN_DIR))_mod.run: \
5008 $$(if $(2),$$(PATH_TARGET)/tst$(2)$(subst /,_,$(KERN_DIR))_mod.run,) \
5009 $$$$($(1)_2_STAGE_TARGETS)
5010 $(QUIET)$$(call MSG_L1,Doing a test build of the $(1) kernel module)
5011 $(QUIET)$$(RM) -f -- "$$@"
5012 $(QUIET)$$(TEST) -n "$$($(1)_INST)"
5013 $(QUIET)$$(RM) -Rf -- "$$(PATH_TARGET)/tst$(1)_mod"
5014 $(QUIET)$$(MKDIR) -p -- "$$(PATH_TARGET)/tst$(1)_mod"
5015 $(QUIET)$$(CP) -R -- "$$(PATH_STAGE_BIN)/../$$($(1)_INST)" "$$(PATH_TARGET)/tst$(1)_mod/"
5016 + $(QUIET)make KBUILD_VERBOSE=$(KBUILD_VERBOSE) KERN_DIR=$(KERN_DIR) VBOX_KERN_QUIET=1 \
5017 VBOX_KBUILD_TYPE=$(KBUILD_TYPE) VBOX_KBUILD_TARGET_ARCH=$(KBUILD_TARGET_ARCH) \
5018 KBUILD_TYPE= KBUILD_TARGET= KBUILD_TARGET_ARCH= KBUILD_TARGET_CPU= KBUILD_HOST= KBUILD_HOST_ARCH= KBUILD_HOST_CPU= \
5019 BUILD_TYPE= BUILD_TARGET= BUILD_TARGET_ARCH= BUILD_TARGET_CPU= BUILD_PLATFORM= BUILD_PLATFORM_ARCH= BUILD_PLATFORM_CPU= \
5020 -C $$(PATH_TARGET)/tst$(1)_mod clean
5021 ifneq ($(2),)
5022 $(QUIET)$$(CP) -f -- "$$<" "$$(PATH_TARGET)/tst$(1)_mod/Module.symvers"
5023 endif
5024 + $(QUIET)$(REDIRECT_EXT) -d2=1 -w1 "$$(PATH_TARGET)/tst$(1)_mod/make.err" -- \
5025 make KBUILD_VERBOSE=$(KBUILD_VERBOSE) KERN_DIR=$(KERN_DIR) VBOX_KERN_QUIET=1 $(if $(2),KBUILD_EXTRA_SYMBOLS="$$(PATH_TARGET)/tst$(1)_mod/Module.symvers",) $(if-expr $(KMK_OPTS_JOBS) != 0,JOBS=$(KMK_OPTS_JOBS),) \
5026 VBOX_KBUILD_TYPE=$(KBUILD_TYPE) VBOX_KBUILD_TARGET_ARCH=$(KBUILD_TARGET_ARCH) \
5027 KBUILD_TYPE= KBUILD_TARGET= KBUILD_TARGET_ARCH= KBUILD_TARGET_CPU= KBUILD_HOST= KBUILD_HOST_ARCH= KBUILD_HOST_CPU= \
5028 BUILD_TYPE= BUILD_TARGET= BUILD_TARGET_ARCH= BUILD_TARGET_CPU= BUILD_PLATFORM= BUILD_PLATFORM_ARCH= BUILD_PLATFORM_CPU= \
5029 -C $$(PATH_TARGET)/tst$(1)_mod
5030 $(CAT) "$$(PATH_TARGET)/tst$(1)_mod/make.err"
5031 $(QUIET)! grep "^WARNING: .* undefined!$$$$" "$$(PATH_TARGET)/tst$(1)_mod/make.err"
5032 if1of ($(USERNAME), bird)
5033 - nm -u "$$(PATH_TARGET)/tst$(1)_mod/"*.ko | sort
5034 endif
5035 ifneq ($(3),)
5036 $(QUIET)$$(CP) -f -- "$$(PATH_TARGET)/tst$(1)_mod/Module.symvers" "$$@"
5037 else
5038 $(QUIET)$$(APPEND) -t "$$@" "done"
5039 endif
5040 $(QUIET)$$(RM) -Rf -- "$$(PATH_TARGET)/tst$(1)_mod"
5041vbox-linux-kmod-test-builds: $$(PATH_TARGET)/tst$(1)$(subst /,_,$(KERN_DIR))_mod.run
5042$$(foreach src,$$(notdir $$(filter %.c,$$(subst =>,/,$$($(1)_SOURCES)))),$$(patsubst %.c,%.o,$$(src))): $$(PATH_TARGET)/tst$(1)$(subst /,_,$(KERN_DIR))_mod.run
5043 endif
5044 endef # VBOX_LINUX_KMOD_TEST_BUILD_RULE_FN
5045 else
5046 VBOX_LINUX_KMOD_TEST_BUILD_RULE_FN =
5047 endif
5048else
5049 VBOX_LINUX_KMOD_TEST_BUILD_RULE_FN =
5050endif # linux target
5051
5052ifeq ($(KBUILD_TARGET),os2)
5053 ifndef VBOX_USE_WATCOM_FOR_OS2
5054TEMPLATE_VBOXR0DRV_TOOL = GXX3OMF
5055TEMPLATE_VBOXR0DRV_CXXFLAGS = -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fno-exceptions -fno-rtti
5056TEMPLATE_VBOXR0DRV_CFLAGS = -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_C) $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fno-exceptions
5057TEMPLATE_VBOXR0DRV_LIBS = $(VBOX_GCC_LIBGCC)
5058# wlink thinks physdevice doesn't need fixups and should have a stack - stupid!
5059TEMPLATE_VBOXR0DRV_LDFLAGS = -Zlinker Option -Zlinker internalrelocs, -Zlinker togglerelocs
5060 else
5061TEMPLATE_VBOXR0DRV_TOOL = OPENWATCOM
5062TEMPLATE_VBOXR0DRV_CTOOL = OPENWATCOM
5063TEMPLATE_VBOXR0DRV_CXXTOOL = OPENWATCOM
5064TEMPLATE_VBOXR0DRV_LDTOOL = OPENWATCOM-WL
5065TEMPLATE_VBOXR0DRV_ARTOOL = OPENWATCOM
5066TEMPLATE_VBOXR0DRV_ASTOOL = NASM
5067TEMPLATE_VBOXR0DRV_ASFLAGS = -fobj -DASM_FORMAT_OMF -D__NASM__ -w+orphan-labels #-g -F borland
5068TEMPLATE_VBOXR0DRV_DEFS.os2 = #_OS2EMX_H
5069TEMPLATE_VBOXR0DRV_INCS = \
5070 $(PATH_TOOL_OPENWATCOM)/h \
5071 $(PATH_TOOL_OPENWATCOM)/h/os2 \
5072 $(PATH_ROOT)/include \
5073 $(PATH_KLIBC_TRUNK)/libc/include # for os2ddk
5074TEMPLATE_VBOXR0DRV_CFLAGS = -s -ze -w4 -hd -d1+ -nt=TEXT32 -nc=CODE -4 -of+
5075TEMPLATE_VBOXR0DRV_CXXFLAGS = -s -ze -w4 -hd -d2t -nt=TEXT32 -nc=CODE -4 -of+
5076TEMPLATE_VBOXR0DRV_LDFLAGS = \
5077 form os2 lx physdevice \
5078 option NODefaultlibs, internalrelocs, togglerelocs \
5079 debug dwarf all #option symfile
5080# debug codeview all option symfile - wlink generates bad info, overwritten mod dir header.
5081 endif
5082endif
5083
5084ifeq ($(KBUILD_TARGET),darwin)
5085TEMPLATE_VBOXR0DRV_TOOL = $(VBOX_GCC_TOOL)
5086TEMPLATE_VBOXR0DRV_SDKS += $(VBOX_DARWIN_DEF_SDK_SDKS)
5087TEMPLATE_VBOXR0DRV_DEFS += $(VBOX_DARWIN_DEF_SDK_DEFS) KERNEL KERNEL_PRIVATE DRIVER_PRIVATE APPLE NeXT
5088 if1of ($(VBOX_GCC_TOOL), GXX4MACHO GXX42MACHO)
5089TEMPLATE_VBOXR0DRV_INCS += \
5090 $(VBOX_PATH_MACOSX_SDK)/System/Library/Frameworks/Kernel.framework/PrivateHeaders \
5091 $(VBOX_PATH_MACOSX_SDK)/System/Library/Frameworks/Kernel.framework/Headers
5092## @todo try use VBOX_GCC_PEDANTIC_CXX
5093TEMPLATE_VBOXR0DRV_CXXFLAGS = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS) \
5094 -g $(VBOX_GCC_pipe) $(VBOX_GCC_WARN) -Wno-long-long $(VBOX_GCC_fdiagnostics-show-option) \
5095 -fno-common -nostdinc -fno-builtin -finline $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_fvisibility-hidden) \
5096 -fno-keep-inline-functions -fno-exceptions -msoft-float \
5097 -fapple-kext -fno-rtti -fcheck-new -force_cpusubtype_ALL \
5098 $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fasm-blocks
5099TEMPLATE_VBOXR0DRV_CXXFLAGS.amd64 = -m64 -mkernel -mno-red-zone -gdwarf-2
5100TEMPLATE_VBOXR0DRV_CXXFLAGS.x86 = -m32 -static
5101TEMPLATE_VBOXR0DRV_CFLAGS = $(VBOX_DARWIN_DEF_SDK_CFLAGS) \
5102 -g $(VBOX_GCC_pipe) $(VBOX_GCC_WARN) -Wno-long-long -fno-common -nostdinc -fno-builtin -finline \
5103 -fno-keep-inline-functions -fno-exceptions $(VBOX_GCC_fvisibility-hidden) -msoft-float \
5104 -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations \
5105 -Werror-implicit-function-declaration -force_cpusubtype_ALL \
5106 $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fasm-blocks
5107TEMPLATE_VBOXR0DRV_CFLAGS.amd64 = -m64 -mkernel -mno-red-zone -gdwarf-2
5108TEMPLATE_VBOXR0DRV_CFLAGS.x86 = -m32 -static
5109TEMPLATE_VBOXR0DRV_LDFLAGS = $(filter-out $(VBOX_DARWIN_NO_COMPACT_LINKEDIT),$(VBOX_DARWIN_DEF_SDK_LDFLAGS)) \
5110 -nostdlib -Wl,-kext,-new_linker -Wl,-Y,1455 -keep_private_extern
5111TEMPLATE_VBOXR0DRV_LDFLAGS.amd64 = -m64
5112TEMPLATE_VBOXR0DRV_LDFLAGS.x86 = -m32
5113TEMPLATE_VBOXR0DRV_LIBS = kmodc++ kmod cc_kext cpp_kext $(VBOX_GCC_LIBGCC)
5114 else
5115 # Note xcode uses -fstrict-aliasing, we currently don't dare... We also add -mno-red-zone.
5116TEMPLATE_VBOXR0DRV_INCS += \
5117 $(VBOX_PATH_MACOSX_SDK)/System/Library/Frameworks/Kernel.framework/PrivateHeaders \
5118 $(VBOX_PATH_MACOSX_SDK)/System/Library/Frameworks/Kernel.framework/Headers
5119## @todo try use VBOX_GCC_PEDANTIC_CXX
5120# -Wno-c++11-extensions -Wno-c99-extensions -Wno-extra-semi -Wno-zero-length-array
5121TEMPLATE_VBOXR0DRV_CXXFLAGS = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS) -mkernel \
5122 -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_CXX) -Wno-long-long $(VBOX_GCC_fdiagnostics-show-option) \
5123 -Wno-c++11-extensions -Wno-c99-extensions -Wno-extra-semi -Wno-zero-length-array \
5124 -Wno-gnu-zero-variadic-macro-arguments -Wno-four-char-constants \
5125 -fno-common -nostdinc -fno-builtin $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_fvisibility-hidden) \
5126 -fno-exceptions -fapple-kext -fno-rtti -mkernel \
5127 -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -Wnon-modular-include-in-framework-module \
5128 -Werror=non-modular-include-in-framework-module \
5129 $(VBOX_GCC_Wno-nullability-extension) $(VBOX_GCC_Wno-gnu-statement-expression) \
5130 $(VBOX_GCC_Wno-import-preprocessor-directive-pedantic) $(VBOX_GCC_Wno-c11-extensions) \
5131 $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fasm-blocks -fno-strict-aliasing -stdlib=libc++
5132# if1of ($(VBOX_GCC_TOOL), CLANGXXMACHO) ## @todo check if we can safely use $(VBOX_GCC_std) @bugref{9790}, good for noexcept.
5133#TEMPLATE_VBOXR0DRV_CXXFLAGS += $(VBOX_GCC_std)
5134# endif
5135# also used by xcode 6.2: \
5136# -Werror=return-type \
5137# -Werror=deprecated-objc-isa-usage \
5138# -Werror=objc-root-class \
5139# -Wno-missing-field-initializers -Wno-missing-prototypes -Wunreachable-code \
5140# -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function \
5141# -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body \
5142# -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants \
5143# -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion \
5144# -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion
5145TEMPLATE_VBOXR0DRV_CXXFLAGS.amd64 = -m64 -msoft-float -mno-red-zone
5146TEMPLATE_VBOXR0DRV_CXXFLAGS.x86 = -m32 -msoft-float
5147TEMPLATE_VBOXR0DRV_CXXFLAGS.arm64 = -m64 -fno-sanitize=vptr -target arm64e-apple-macos11.0
5148TEMPLATE_VBOXR0DRV_CFLAGS = $(VBOX_DARWIN_DEF_SDK_CFLAGS) -mkernel \
5149 -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_C) -Wno-long-long $(VBOX_GCC_fdiagnostics-show-option) \
5150 -fno-common -nostdinc -fno-builtin $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_fvisibility-hidden) \
5151 -fno-exceptions -fapple-kext -fno-rtti \
5152 -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -Wnon-modular-include-in-framework-module \
5153 -Werror=non-modular-include-in-framework-module $(VBOX_GCC_Wno-c11-extensions) \
5154 $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fasm-blocks -fno-strict-aliasing
5155TEMPLATE_VBOXR0DRV_CFLAGS.amd64 = -m64 -msoft-float -mno-red-zone
5156TEMPLATE_VBOXR0DRV_CFLAGS.x86 = -m32 -msoft-float
5157TEMPLATE_VBOXR0DRV_CFLAGS.arm64 = -m64 -fno-sanitize=vptr -target arm64e-apple-macos11.0
5158 if 1
5159 TEMPLATE_VBOXR0DRV_CFLAGS += $(VBOX_GCC_WERR)
5160 TEMPLATE_VBOXR0DRV_CXXFLAGS += $(VBOX_GCC_WERR)
5161 endif
5162TEMPLATE_VBOXR0DRV_LDFLAGS = $(filter-out $(VBOX_DARWIN_NO_COMPACT_LINKEDIT),$(VBOX_DARWIN_DEF_SDK_LDFLAGS)) \
5163 -nostdlib -stdlib=libc++ -Wl,-kext -Wl,-keep_private_externs
5164TEMPLATE_VBOXR0DRV_LDFLAGS.amd64 = -m64
5165TEMPLATE_VBOXR0DRV_LDFLAGS.arm64 = -m64
5166TEMPLATE_VBOXR0DRV_LDFLAGS.x86 = -m32
5167TEMPLATE_VBOXR0DRV_LIBS = kmodc++ kmod cc_kext
5168 endif
5169endif
5170
5171ifeq ($(KBUILD_TARGET),solaris)
5172## The Solaris /usr/platform/i86pc/include and /usr/include directories.
5173VBOX_SOLARIS_SYS_INCS ?= /usr/platform/i86pc/include /usr/include
5174
5175TEMPLATE_VBOXR0DRV_TOOL = $(VBOX_GCC_TOOL)
5176TEMPLATE_VBOXR0DRV_DEFS += _MACHDEP _KERNEL _STRICT_STDC
5177 if $(VBOX_GCC_VERSION_CC) < 30400
5178TEMPLATE_VBOXR0DRV_DEFS += RT_WITHOUT_PRAGMA_ONCE
5179 endif
5180TEMPLATE_VBOXR0DRV_INCS = $(VBOX_SOLARIS_SYS_INCS)
5181TEMPLATE_VBOXR0DRV_LDFLAGS = -r -dy
5182TEMPLATE_VBOXR0DRV_LDFLAGS.amd64 = $(if $(eq $(KBUILD_HOST),solaris),-64,-m elf_x86_64)
5183# Exclude -Wall because of solaris headers' pragma ident warnings that gcc refuses to supress.
5184TEMPLATE_VBOXR0DRV_CFLAGS = -Wpointer-arith -Winline $(VBOX_GCC_Wno-pointer-sign) \
5185 -Wmissing-prototypes -Wstrict-prototypes $(VBOX_GCC_fdiagnostics-show-option) \
5186 -Wshadow -Wuninitialized -Wunused-function -Wunused-label -Wunused-value -Wunused-variable \
5187 -Wformat -Wimplicit-int -Wimplicit-function-declaration -Werror-implicit-function-declaration -Wparentheses \
5188 -O2 -fno-omit-frame-pointer -ffreestanding -nodefaultlibs -fno-strict-aliasing -fno-common -std=c99
5189TEMPLATE_VBOXR0DRV_CFLAGS.x86 = -m32 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
5190TEMPLATE_VBOXR0DRV_CFLAGS.amd64 = -m64 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow $(VBOX_GCC_msave-args) \
5191 -mno-red-zone -mcmodel=kernel $(if-expr defined(VBOX_GCC_USING_SOLARIS_AS),-Wa$(COMMA)-xmodel=kernel,) \
5192 -fno-reorder-blocks -fno-asynchronous-unwind-tables -funit-at-a-time
5193TEMPLATE_VBOXR0DRV_CXXFLAGS = -Wpointer-arith -Winline \
5194 -Wshadow -Wuninitialized -Wunused-function -Wunused-label -Wunused-value -Wunused-variable \
5195 -Wformat \
5196 -O2 -nodefaultlibs -fno-omit-frame-pointer -fno-strict-aliasing -fno-common -fno-exceptions -fno-rtti
5197TEMPLATE_VBOXR0DRV_CXXFLAGS.x86 = $(TEMPLATE_VBOXR0DRV_CFLAGS.x86)
5198TEMPLATE_VBOXR0DRV_CXXFLAGS.amd64 = $(TEMPLATE_VBOXR0DRV_CFLAGS.amd64)
5199TEMPLATE_VBOXR0DRV_POST_CMDS = $(VBOX_SIGN_DRIVER_CMDS)
5200endif # Solaris
5201
5202ifeq ($(KBUILD_TARGET),freebsd)
5203# x86 FreeBSD (6.2 or something):
5204# cc -O2 -fno-strict-aliasing -pipe -Werror -D_KERNEL -DKLD_MODULE \
5205# -nostdinc -I- -I. -I@ -I@/contrib/altq -I@/../include -I/usr/include \
5206# -finline-limit=8000 -fno-common -mno-align-long-strings -mpreferred-stack-boundary=2 \
5207# -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -ffreestanding -Wall -Wredundant-decls -Wnested-externs \
5208# -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -fformat-extensions \
5209# -std=c99 -c ../my.c
5210# ld -d -warn-common -r -d -o my.kld my.o
5211# :> export_syms
5212# awk -f /usr/src/sys/modules/my/../../conf/kmod_syms.awk my.kld export_syms | xargs -J% objcopy % my.kld
5213# ld -Bsharable -d warn-commnon -o my.ko my.kld
5214#
5215# AMD64 FreeBSD (7.1):
5216# cc -O2 -fno-strict-aliasing -pipe -D_KERNEL -DKLD_MODULE -std=c99 -nostdinc -I. -I@ -I@/contrib/altq \
5217# -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000 -fno-common \
5218# -fno-omit-frame-pointer -mcmodel=kernel -mno-red-zone -mfpmath=387 -mno-sse -mno-sse2 -mno-mmx \
5219# -mno-3dnow -msoft-float -fno-asynchronous-unwind-tables -ffreestanding \
5220# -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign \
5221# -fformat-extensions -c /usr/src/sys/modules/my/../../dev/my/if_my.c
5222# ld -d -warn-common -r -d -o if_my.ko if_my.o
5223# :> export_syms
5224# awk -f /usr/src/sys/modules/my/../../conf/kmod_syms.awk if_my.ko export_syms | xargs -J% objcopy % if_my.ko
5225
5226# Note: @ -> /usr/src/sys and machine -> /usr/src/sys/i386/include
5227
5228## The location of the FreeBSD kernel source.
5229VBOX_FREEBSD_SRC ?= /usr/src/sys
5230## The FreeBSD /usr/include.
5231VBOX_FREEBSD_SYS_INCS ?= /usr/include
5232
5233TEMPLATE_VBOXR0DRV_TOOL = $(VBOX_GCC_TOOL)
5234TEMPLATE_VBOXR0DRV_LDTOOL = FREEBSDKMODLD
5235TEMPLATE_VBOXR0DRV_DEFS += _KERNEL KLD_MODULE
5236 if $(VBOX_GCC_VERSION_CC) < 30400
5237TEMPLATE_VBOXR0DRV_DEFS += RT_WITHOUT_PRAGMA_ONCE
5238 endif
5239TEMPLATE_VBOXR0DRV_INCS = \
5240 $(VBOX_FREEBSD_SRC) \
5241 $(VBOX_FREEBSD_SRC)/contrib/altq \
5242 $(VBOX_FREEBSD_SRC)/contrib/ck/include \
5243 $(VBOX_FREEBSD_SRC)/../include \
5244 $(VBOX_FREEBSD_SYS_INCS)
5245# omitting: -Wcast-qual, -Wredundant-decls
5246TEMPLATE_VBOXR0DRV_CFLAGS = \
5247 $(VBOX_GCC_WARN) -Wpointer-arith -Winline $(VBOX_GCC_Wno-pointer-sign) $(VBOX_GCC_fdiagnostics-show-option) \
5248 -Wstrict-prototypes -Wmissing-prototypes -Wstrict-prototypes \
5249 -Wimplicit-function-declaration -Werror-implicit-function-declaration \
5250 -O2 -ffreestanding -fno-strict-aliasing -fno-common \
5251 $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) \
5252 -nostdinc -std=c99
5253TEMPLATE_VBOXR0DRV_CFLAGS.x86 = -m32 -mno-align-long-strings -mno-mmx -mno-3dnow -mno-sse -mno-sse2
5254TEMPLATE_VBOXR0DRV_CFLAGS.amd64 = -m64 -fno-omit-frame-pointer -mcmodel=kernel -mno-red-zone -mfpmath=387 \
5255 -mno-sse -mno-sse2 -mno-mmx -mno-3dnow -msoft-float -fno-asynchronous-unwind-tables -Wundef
5256TEMPLATE_VBOXR0DRV_CXXFLAGS = -fno-exceptions -fno-rtti \
5257 $(VBOX_GCC_WARN) -Wpointer-arith -Winline \
5258 -O2 -fno-strict-aliasing -fno-common \
5259 $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) \
5260 -nostdinc
5261TEMPLATE_VBOXR0DRV_CXXFLAGS.x86 = $(TEMPLATE_VBOXR0DRV_CFLAGS.x86)
5262TEMPLATE_VBOXR0DRV_CXXFLAGS.amd64 = $(TEMPLATE_VBOXR0DRV_CFLAGS.amd64)
5263TEMPLATE_VBOXR0DRV_SYSSUFF = .ko
5264TEMPLATE_VBOXR0DRV_LDFLAGS = -d --warn-common
5265TEMPLATE_VBOXR0DRV_LDFLAGS.x86 = -m elf_i386_fbsd
5266TEMPLATE_VBOXR0DRV_LDFLAGS.amd64 = -m elf_x86_64_fbsd
5267
5268TOOL_FREEBSDKMODLD = FreeBSD kernel module linker.
5269# See kBuild/tools/GCC3.kmk for docs.
5270TOOL_FREEBSDKMODLD_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
5271TOOL_FREEBSDKMODLD_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
5272TOOL_FREEBSDKMODLD_LINK_SYSMOD_DEPORD =
5273 ifeq ($(KBUILD_TARGET_ARCH),amd64)
5274TOOL_FREEBSDKMODLD_LINK_SYSMOD_OUTPUT =
5275define TOOL_FREEBSDKMODLD_LINK_SYSMOD_CMDS
5276# Link intermediate .kld (a relocatable object).
5277 ld $(flags) -r -o $(out) $(objs) \
5278 $(foreach p,$(libpath), -L$(p))\
5279 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
5280# Strip non-exported symbols private and localize the exported ones.
5281 awk -f $(VBOX_FREEBSD_SRC)/conf/kmod_syms.awk $(out) $(if $(othersrc), $(othersrc),/dev/null) \
5282 | xargs -J% objcopy % $(out)
5283
5284## Strip debug info (comment out if debugging or something).
5285 objcopy --strip-debug $(out)
5286endef
5287 else # x86
5288TOOL_FREEBSDKMODLD_LINK_SYSMOD_OUTPUT = $(outbase).kld
5289define TOOL_FREEBSDKMODLD_LINK_SYSMOD_CMDS
5290# Link intermediate .kld (a relocatable object).
5291 ld $(flags) -r -o $(outbase).kld $(objs) \
5292 $(foreach p,$(libpath), -L$(p))\
5293 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
5294# Strip non-exported symbols private and localize the exported ones.
5295 awk -f $(VBOX_FREEBSD_SRC)/conf/kmod_syms.awk $(outbase).kld $(if $(othersrc), $(othersrc),/dev/null) \
5296 | xargs -J% objcopy % $(outbase).kld
5297
5298# Link the final .ko (a shared object).
5299 ld $(flags) -Bshareable -o $(out) $(outbase).kld
5300endef
5301 endif # x86
5302
5303endif # FreeBSD
5304
5305ifeq ($(KBUILD_TARGET),netbsd)
5306
5307# The location of the NetBSD sources.
5308VBOX_NETBSD_SRC ?= /usr/src
5309
5310# NetBSD uses "i386" for 32-bit, "x86" for common 32- and 64-bit code.
5311ifeq ($(KBUILD_TARGET_ARCH),amd64)
5312VBOX_NETBSD_TARGET_ARCH=amd64
5313else
5314VBOX_NETBSD_TARGET_ARCH=i386
5315endif
5316
5317VBOX_NETBSD_TARGET_SRC=$(VBOX_NETBSD_SRC)/sys/arch/$(VBOX_NETBSD_TARGET_ARCH)
5318
5319TEMPLATE_VBOXR0DRV_TOOL = $(VBOX_GCC_TOOL)
5320TEMPLATE_VBOXR0DRV_DEFS += _KERNEL _MODULE
5321 if $(VBOX_GCC_VERSION_CC) < 30400
5322TEMPLATE_VBOXR0DRV_DEFS += RT_WITHOUT_PRAGMA_ONCE
5323 endif
5324TEMPLATE_VBOXR0DRV_INCS = \
5325 $(VBOX_NETBSD_SRC)/sys \
5326 $(VBOX_NETBSD_SRC)/common/include \
5327 $(PATH_OBJ)/netbsd/include
5328
5329TEMPLATE_VBOXR0DRV_CFLAGS = \
5330 $(VBOX_GCC_WARN) -Wpointer-arith -Winline $(VBOX_GCC_Wno-pointer-sign) \
5331 $(VBOX_GCC_fdiagnostics-show-option) \
5332 -Wstrict-prototypes -Wmissing-prototypes -Wstrict-prototypes \
5333 -Wimplicit-function-declaration -Werror-implicit-function-declaration \
5334 -O2 -ffreestanding -fno-strict-aliasing -fno-common -finline-limit=8000 \
5335 $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) \
5336 -nostdinc -std=c99 -msoft-float
5337TEMPLATE_VBOXR0DRV_CFLAGS.x86 = -m32 -mno-mmx -mno-sse -mno-avx \
5338 -mno-fp-ret-in-387
5339TEMPLATE_VBOXR0DRV_CFLAGS.amd64 = -m64 --param inline-unit-growth=100 \
5340 --param large-function-growth=1000 -fno-omit-frame-pointer \
5341 -mcmodel=kernel -mno-red-zone -mno-sse -mno-mmx -mno-avx \
5342 -fno-asynchronous-unwind-tables -mno-fp-ret-in-387
5343TEMPLATE_VBOXR0DRV_CXXFLAGS = -fno-exceptions -fno-rtti \
5344 $(VBOX_GCC_WARN) -Wpointer-arith -Winline \
5345 -O2 -fno-strict-aliasing -fno-common -finline-limit=8000 \
5346 $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) \
5347 -nostdinc -msoft-float
5348TEMPLATE_VBOXR0DRV_CXXFLAGS.x86 = $(TEMPLATE_VBOXR0DRV_CFLAGS.x86)
5349TEMPLATE_VBOXR0DRV_CXXFLAGS.amd64 = $(TEMPLATE_VBOXR0DRV_CFLAGS.amd64)
5350TEMPLATE_VBOXR0DRV_SYSSUFF = .kmod
5351TEMPLATE_VBOXR0DRV_LDFLAGS = -d --warn-common
5352TEMPLATE_VBOXR0DRV_LDFLAGS.x86 = -m elf_i386
5353TEMPLATE_VBOXR0DRV_LDFLAGS.amd64 = -m elf_x86_64
5354
5355# symlink kernel includes
5356TEMPLATE_VBOXR0DRV_ORDERDEPS += \
5357 $(PATH_OBJ)/netbsd/include/$(VBOX_NETBSD_TARGET_ARCH) \
5358 $(PATH_OBJ)/netbsd/include/x86 \
5359 $(PATH_OBJ)/netbsd/include/machine
5360
5361$$(PATH_OBJ)/netbsd/include/$(VBOX_NETBSD_TARGET_ARCH):
5362 $(QUIET)$(MKDIR) -p $(@D)
5363 $(QUIET)$(LN_SYMLINK) $(VBOX_NETBSD_TARGET_SRC)/include $@
5364
5365$$(PATH_OBJ)/netbsd/include/x86:
5366 $(QUIET)$(MKDIR) -p $(@D)
5367 $(QUIET)$(LN_SYMLINK) $(VBOX_NETBSD_SRC)/sys/arch/x86/include $@
5368
5369$$(PATH_OBJ)/netbsd/include/machine:
5370 $(QUIET)$(MKDIR) -p $(@D)
5371 $(QUIET)$(LN_SYMLINK) $(VBOX_NETBSD_TARGET_ARCH) $@
5372
5373endif # NetBSD
5374
5375ifeq ($(KBUILD_TARGET),haiku)
5376## The Haiku include directories
5377VBOX_HAIKU_SYS_INCS ?= /boot/develop/headers/os/kernel /boot/develop/headers/os/drivers
5378
5379TEMPLATE_VBOXR0DRV_TOOL = $(VBOX_GCC_TOOL)
5380TEMPLATE_VBOXR0DRV_LDTOOL = $(VBOX_GCC_TOOL)
5381TEMPLATE_VBOXR0DRV_DEFS = _KERNEL_MODE=1 _STRICT_STDC IN_RING0 IN_RT_R0
5382 if $(VBOX_GCC_VERSION_CC) < 30400
5383TEMPLATE_VBOXR0DRV_DEFS += RT_WITHOUT_PRAGMA_ONCE
5384 endif
5385TEMPLATE_VBOXR0DRV_INCS = $(VBOX_HAIKU_SYS_INCS)
5386#TODO: sort this out
5387TEMPLATE_VBOXR0DRV_LDFLAGS = -shared $(VBOX_GCC_NO_UNDEFINED_R0) -dc -dy -lroot -rpath-link /boot/system/develop/lib/x86 --no-add-needed /boot/system/develop/lib/_KERNEL_ --no-add-needed /boot/system/develop/lib/haiku_version_glue.o
5388TEMPLATE_VBOXR0DRV_CFLAGS = -fno-PIC \
5389 $(VBOX_GCC_WARN) -Wstrict-prototypes $(VBOX_GCC_Wno-pointer-sign) -Wno-sign-compare \
5390 $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
5391TEMPLATE_VBOXR0DRV_CFLAGS.x86 = -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
5392TEMPLATE_VBOXR0DRV_CFLAGS.x86 = -m32 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
5393TEMPLATE_VBOXR0DRV_CFLAGS.amd64 = -m64 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow \
5394 -fno-reorder-blocks -ffreestanding -fno-asynchronous-unwind-tables -funit-at-a-time \
5395 -Wno-sign-compare
5396TEMPLATE_VBOXR0DRV_CXXFLAGS = -fno-PIC -Wpointer-arith \
5397 -Wshadow -Wuninitialized -Wunused-function -Wunused-label -Wunused-value -Wunused-variable \
5398 -Wformat \
5399 -O2 -nodefaultlibs -fno-omit-frame-pointer -fno-strict-aliasing -fno-common -fno-exceptions -fno-rtti
5400TEMPLATE_VBOXR0DRV_CXXFLAGS.x86 = $(TEMPLATE_VBOXR0DRV_CFLAGS.x86) -fno-exceptions -fno-rtti
5401TEMPLATE_VBOXR0DRV_CXXFLAGS.amd64 = $(TEMPLATE_VBOXR0DRV_CFLAGS.amd64) -fno-exceptions -fno-rtti
5402endif # Haiku
5403
5404ifdef VBOX_WITH_VBOXDRV
5405 ifndef TEMPLATE_VBOXR0DRV_TOOL
5406 $(warning Warning: VBox Build: Target $(KBUILD_HOST) is not officially supported!)
5407 endif
5408endif
5409
5410ifn1of ($(KBUILD_TARGET), darwin os2 win solaris freebsd)
5411 # This doesn't work if supdrv is natively loading VMMR0.r0 et al, but
5412 # fortunately it isn't really necessary.
5413 TEMPLATE_VBOXR0DRV_CFLAGS += -include $(PATH_ROOT)/include/VBox/SUPDrvMangling.h
5414 TEMPLATE_VBOXR0DRV_CXXFLAGS += -include $(PATH_ROOT)/include/VBox/SUPDrvMangling.h
5415endif
5416
5417ifeq ($(KBUILD_TARGET),darwin)
5418#
5419# A variant of VBOXR0DRV that uses the 10.10 SDK.
5420#
5421TEMPLATE_VBoxR0DrvOSX10.10 = VBoxR0Drv variant using the 10.10 SDK
5422TEMPLATE_VBoxR0DrvOSX10.10_EXTENDS = VBOXR0DRV
5423TEMPLATE_VBoxR0DrvOSX10.10_SDKS = MACOSX1010
5424TEMPLATE_VBoxR0DrvOSX10.10_INCS = $(filter-out $(VBOX_PATH_MACOSX_SDK)/%,$(TEMPLATE_VBOXR0DRV_INCS)) \
5425 $(PATH_SDK_MACOSX1010)/System/Library/Frameworks/Kernel.framework/PrivateHeaders \
5426 $(PATH_SDK_MACOSX1010)/System/Library/Frameworks/Kernel.framework/Headers
5427TEMPLATE_VBoxR0DrvOSX10.10_DEFS = $(filter-out $(VBOX_DARWIN_DEF_SDK_DEFS),$(TEMPLATE_VBOXR0DRV_DEFS))
5428
5429endif
5430
5431#
5432# Template for building libraries used by ring-0 drivers.
5433#
5434TEMPLATE_VBoxR0DrvLib = VBox Ring 0 Driver Library
5435TEMPLATE_VBoxR0DrvLib_EXTENDS = VBOXR0DRV
5436TEMPLATE_VBoxR0DrvLib_INSTTYPE = stage
5437TEMPLATE_VBoxR0DrvLib_INSTTYPE.linux = stage
5438
5439#
5440# Template for installing INF and CAT files.
5441#
5442TEMPLATE_VBoxR0DrvInfCat = VBox SUPDRV Ring 0 - Install .sys, .cat, .inf
5443TEMPLATE_VBoxR0DrvInfCat_INST = $(INST_BIN)
5444TEMPLATE_VBoxR0DrvInfCat_MODE = a+r,u+w
5445TEMPLATE_VBoxR0DrvInfCat_IFFLAGS = --no-hard-link-files-when-possible
5446
5447
5448#
5449# Template for building R3 executables and static libraries which are linked into executables.
5450# Note! This is the base template for a whole lot of other ones, so be careful when changing it.
5451#
5452# Disabled Visual C++ warnings:
5453# -wd4065: switch statement contains 'default' but no 'case' labels
5454# -wd4244: 'conversion' conversion from 'type1' to 'type2', possible loss of data
5455# -wd4996: deprecated / insecure.
5456#
5457TEMPLATE_VBOXR3EXE = VBox Ring 3 Exe
5458TEMPLATE_VBOXR3EXE_ASTOOL := $(VBOX_ASTOOL)
5459TEMPLATE_VBOXR3EXE_ASFLAGS.x86 = $(VBOX_ASFLAGS32)
5460TEMPLATE_VBOXR3EXE_ASFLAGS.sparc32 = $(VBOX_ASFLAGS32)
5461TEMPLATE_VBOXR3EXE_ASFLAGS.amd64 = $(VBOX_ASFLAGS64)
5462TEMPLATE_VBOXR3EXE_ASFLAGS.arm64 = $(VBOX_ASFLAGS64)
5463TEMPLATE_VBOXR3EXE_ASFLAGS.sparc64 = $(VBOX_ASFLAGS64)
5464TEMPLATE_VBOXR3EXE_DEFS = IN_RING3 $(VBOX_GC_ARCH_BITS_DEFS)
5465TEMPLATE_VBOXR3EXE_DEFS.x86 = HC_ARCH_BITS=32
5466TEMPLATE_VBOXR3EXE_DEFS.arm32 = HC_ARCH_BITS=32
5467TEMPLATE_VBOXR3EXE_DEFS.sparc32 = HC_ARCH_BITS=32
5468TEMPLATE_VBOXR3EXE_DEFS.amd64 = HC_ARCH_BITS=64
5469TEMPLATE_VBOXR3EXE_DEFS.arm64 = HC_ARCH_BITS=64
5470TEMPLATE_VBOXR3EXE_DEFS.sparc64 = HC_ARCH_BITS=64
5471TEMPLATE_VBOXR3EXE_DEFS.win = _CRT_SECURE_NO_DEPRECATE
5472TEMPLATE_VBOXR3EXE_USES = dtrace
5473if defined(VBOX_WITH_DTRACE_R3) && defined(VBOX_WITH_NATIVE_DTRACE)
5474 TEMPLATE_VBOXR3EXE_DTRACETOOL = DTraceAndVBoxTpG
5475 TEMPLATE_VBOXR3EXE_DTRACE_OBJ_FLAGS = -C
5476 TEMPLATE_VBOXR3EXE_DTRACE_HDR_FLAGS = -C
5477 TEMPLATE_VBOXR3EXE_DEFS += VBOX_WITH_DTRACE VBOX_WITH_DTRACE_R3 VBOX_WITH_NATIVE_DTRACE
5478else
5479 TEMPLATE_VBOXR3EXE_DTRACE_HDR_FLAGS = --ring-3-context
5480 TEMPLATE_VBOXR3EXE_DTRACE_OBJ_FLAGS = --ring-3-context --pic --probe-fn-imported --probe-fn-name "SUPTracerFireProbe"
5481 if defined(VBOX_WITH_DTRACE_R3)
5482 TEMPLATE_VBOXR3EXE_DTRACETOOL = VBoxTpG
5483 TEMPLATE_VBOXR3EXE_DEFS += VBOX_WITH_DTRACE VBOX_WITH_DTRACE_R3
5484 else
5485 TEMPLATE_VBOXR3EXE_DTRACETOOL = VBoxTpG-Disabled
5486 endif
5487endif
5488TEMPLATE_VBOXR3EXE_LIBS.kprofile = $(LIB_KPROFILE)
5489ifeq ($(KBUILD_TARGET),win)
5490# TEMPLATE_VBOXR3EXE_TOOL = $(VBOX_VCC_TOOL)
5491 TEMPLATE_VBOXR3EXE_TOOL.win.x86 = $(VBOX_VCC_TOOL_STEM)X86
5492 TEMPLATE_VBOXR3EXE_TOOL.win.amd64 = $(VBOX_VCC_TOOL_STEM)AMD64
5493 TEMPLATE_VBOXR3EXE_RCDEFS = VBOX_SVN_REV=$(VBOX_SVN_REV) VBOX_SVN_REV_MOD_5K=$(expr $(VBOX_SVN_REV) % 50000)
5494 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
5495 TEMPLATE_VBOXR3EXE_SDKS = ReorderCompilerIncs WINSDK10-UCRT $(VBOX_WINPSDK)
5496 else
5497 TEMPLATE_VBOXR3EXE_SDKS = ReorderCompilerIncs $(VBOX_WINPSDK)
5498 endif
5499 TEMPLATE_VBOXR3EXE_CXXFLAGS = -Zi -Zl -GR- -EHsc -GF -MD$(VBOX_VCC_CRT_TYPE) -Zc:wchar_t- $(VBOX_VCC_OPT) $(VBOX_VCC_FP) \
5500 $(VBOX_VCC_WARN_ALL) $(VBOX_VCC_WERR)
5501 ifdef VBOX_WITH_MSC_ANALYZE_THIS
5502 TEMPLATE_VBOXR3EXE_CXXFLAGS += /analyze
5503 endif
5504 TEMPLATE_VBOXR3EXE_CXXFLAGS.debug = -RTCsu
5505 TEMPLATE_VBOXR3EXE_CXXFLAGS.dbgopt = $(NO_SUCH_VARIABLE)
5506 TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile = -Gh -GH
5507 TEMPLATE_VBOXR3EXE_CFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS)
5508 TEMPLATE_VBOXR3EXE_CFLAGS.debug = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.debug)
5509 TEMPLATE_VBOXR3EXE_CFLAGS.dbgopt = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.dbgopt)
5510 TEMPLATE_VBOXR3EXE_CFLAGS.kprofile = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile)
5511 TEMPLATE_VBOXR3EXE_PCHFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS)
5512 TEMPLATE_VBOXR3EXE_PCHFLAGS.debug = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.debug)
5513 TEMPLATE_VBOXR3EXE_PCHFLAGS.dbgopt = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.dbgopt)
5514 TEMPLATE_VBOXR3EXE_PCHFLAGS.kprofile = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile)
5515 TEMPLATE_VBOXR3EXE_LDFLAGS = -Ignore:4197 \
5516 /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LargeAddressAware /DynamicBase /NxCompat /Release /Debug /Opt:Ref /Opt:Icf \
5517 /Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
5518 /STUB:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com \
5519 /DISALLOWLIB:libc.lib \
5520 /DISALLOWLIB:libcd.lib \
5521 /DISALLOWLIB:libcmt.lib \
5522 /DISALLOWLIB:libcmtd.lib \
5523 /DISALLOWLIB:msvcrt$(VBOX_VCC_CRT_TYPE_N).lib \
5524 /DISALLOWLIB:msvcprt$(VBOX_VCC_CRT_TYPE_N).lib
5525 ifdef VBOX_WITH_DTRACE_R3
5526 TEMPLATE_VBOXR3EXE_LDFLAGS += -Merge:VTGPrLc.Data=VTGPrLc.Begin -Merge:VTGPrLc.End=VTGPrLc.Begin -Merge:VTGPrLc.Begin=VTGObj
5527 endif
5528 if defined(VBOX_SIGNING_MODE) && defined(VBOX_WITH_HARDENING)
5529 TEMPLATE_VBOXR3EXE_LDFLAGS += -IntegrityCheck
5530 endif
5531
5532 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
5533 TEMPLATE_VBOXR3EXE_LIBS.x86 = \
5534 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.x86)_LIB)/vcruntime$(VBOX_VCC_CRT_TYPE).lib \
5535 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.x86)_LIB)/msvcrt$(VBOX_VCC_CRT_TYPE).lib \
5536 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.x86)_LIB)/msvcprt$(VBOX_VCC_CRT_TYPE).lib \
5537 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.x86)_LIB)/oldnames.lib
5538 TEMPLATE_VBOXR3EXE_LIBS.amd64 = \
5539 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.amd64)_LIB)/vcruntime$(VBOX_VCC_CRT_TYPE).lib \
5540 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.amd64)_LIB)/msvcrt$(VBOX_VCC_CRT_TYPE).lib \
5541 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.amd64)_LIB)/msvcprt$(VBOX_VCC_CRT_TYPE).lib \
5542 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.amd64)_LIB)/oldnames.lib
5543 else
5544 TEMPLATE_VBOXR3EXE_LIBS.x86 = \
5545 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.x86)_LIB)/msvcrt$(VBOX_VCC_CRT_TYPE).lib \
5546 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.x86)_LIB)/msvcprt$(VBOX_VCC_CRT_TYPE).lib \
5547 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.x86)_LIB)/oldnames.lib
5548 TEMPLATE_VBOXR3EXE_LIBS.amd64 = \
5549 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.amd64)_LIB)/msvcrt$(VBOX_VCC_CRT_TYPE).lib \
5550 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.amd64)_LIB)/msvcprt$(VBOX_VCC_CRT_TYPE).lib \
5551 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.amd64)_LIB)/oldnames.lib
5552 endif
5553
5554 TEMPLATE_VBOXR3EXE_POST_CMDS = $(VBOX_SIGN_IMAGE_CMDS)
5555 if defined(VBOX_WITH_MORE_NT4_COMPAT_BINARIES) && "$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)" == "win.x86"
5556 TEMPLATE_VBOXR3EXE_POST_CMDS.win.x86 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION) $(out)$$(NLTAB)$(TEMPLATE_VBOXR3EXE_POST_CMDS))
5557 TEMPLATE_VBOXR3EXE_LNK_DEPS.win.x86 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION))
5558 TEMPLATE_VBOXR3EXE_LDFLAGS.win.x86 = \
5559 -Include:_vcc100_kernel32_fakes_cpp \
5560 -Include:_vcc100_kernel32_fakes_asm
5561 TEMPLATE_VBOXR3EXE_LIBS.win.x86 = \
5562 $(PATH_STAGE_LIB)/RuntimeR3VccTricks2$(VBOX_SUFF_LIB)
5563 TEMPLATE_VBOXR3EXE_LIBS.x86 = \
5564 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.x86)_LIB)/oldnames.lib \
5565 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.x86)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
5566 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.x86)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib
5567 endif
5568
5569else # the gcc guys
5570TEMPLATE_VBOXR3EXE_TOOL = $(VBOX_GCC_TOOL)
5571 if $(VBOX_GCC_VERSION_CC) < 30400
5572TEMPLATE_VBOXR3EXE_DEFS += RT_WITHOUT_PRAGMA_ONCE
5573 endif
5574TEMPLATE_VBOXR3EXE_CXXFLAGS = -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_OPT) \
5575 $(VBOX_GCC_FP) -fno-strict-aliasing $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_std) $(VBOX_GCC_fvisibility-inlines-hidden) \
5576 $(VBOX_GCC_IPRT_FMT_CHECK) $(VBOX_GCC_SANITIZER_FLAGS)
5577 ifdef VBOX_WITH_NO_GCC_WARNING_POLICY
5578 TEMPLATE_VBOXR3EXE_CXXFLAGS += $(VBOX_GCC_WERR)
5579 endif
5580TEMPLATE_VBOXR3EXE_CXXFLAGS.x86 = -m32
5581TEMPLATE_VBOXR3EXE_CXXFLAGS.amd64 = -m64
5582TEMPLATE_VBOXR3EXE_CXXFLAGS.sparc32 = -m32
5583TEMPLATE_VBOXR3EXE_CXXFLAGS.sparc64 = -m64
5584TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile = -finstrument-functions
5585TEMPLATE_VBOXR3EXE_CFLAGS = -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_C) $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_OPT) \
5586 $(VBOX_GCC_FP) -fno-strict-aliasing $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_IPRT_FMT_CHECK)
5587 ifdef VBOX_WITH_NO_GCC_WARNING_POLICY
5588 TEMPLATE_VBOXR3EXE_CFLAGS += $(VBOX_GCC_WERR)
5589 endif
5590TEMPLATE_VBOXR3EXE_CFLAGS.x86 = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.x86)
5591TEMPLATE_VBOXR3EXE_CFLAGS.amd64 = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.amd64)
5592TEMPLATE_VBOXR3EXE_CFLAGS.sparc32 = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.sparc32)
5593TEMPLATE_VBOXR3EXE_CFLAGS.sparc64 = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.sparc64)
5594TEMPLATE_VBOXR3EXE_CFLAGS.debug = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.debug)
5595TEMPLATE_VBOXR3EXE_CFLAGS.kprofile = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile)
5596TEMPLATE_VBOXR3EXE_OBJCFLAGS = $(TEMPLATE_VBOXR3EXE_CFLAGS)
5597TEMPLATE_VBOXR3EXE_OBJCFLAGS.x86 = $(TEMPLATE_VBOXR3EXE_CFLAGS.x86)
5598TEMPLATE_VBOXR3EXE_OBJCFLAGS.amd64 = $(TEMPLATE_VBOXR3EXE_CFLAGS.amd64)
5599TEMPLATE_VBOXR3EXE_OBJCFLAGS.debug = $(TEMPLATE_VBOXR3EXE_CFLAGS.debug)
5600TEMPLATE_VBOXR3EXE_OBJCFLAGS.kprofile = $(TEMPLATE_VBOXR3EXE_CFLAGS.kprofile)
5601TEMPLATE_VBOXR3EXE_OBJCXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS)
5602TEMPLATE_VBOXR3EXE_OBJCXXFLAGS.x86 = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.x86)
5603TEMPLATE_VBOXR3EXE_OBJCXXFLAGS.amd64 = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.amd64)
5604TEMPLATE_VBOXR3EXE_OBJCXXFLAGS.debug = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.debug)
5605TEMPLATE_VBOXR3EXE_OBJCXXFLAGS.kprofile= $(TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile)
5606TEMPLATE_VBOXR3EXE_PCHFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS)
5607TEMPLATE_VBOXR3EXE_PCHFLAGS.x86 = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.x86)
5608TEMPLATE_VBOXR3EXE_PCHFLAGS.amd64 = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.amd64)
5609TEMPLATE_VBOXR3EXE_PCHFLAGS.debug = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.debug)
5610TEMPLATE_VBOXR3EXE_PCHFLAGS.kprofile = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile)
5611TEMPLATE_VBOXR3EXE_LDFLAGS = $(VBOX_GCC_SANITIZER_FLAGS) $(VBOX_GCC_SANITIZER_LDFLAGS)
5612TEMPLATE_VBOXR3EXE_LDFLAGS.x86 = -m32
5613TEMPLATE_VBOXR3EXE_LDFLAGS.amd64 = -m64
5614TEMPLATE_VBOXR3EXE_LDFLAGS.sparc32 = -m32
5615TEMPLATE_VBOXR3EXE_LDFLAGS.sparc64 = -m64
5616TEMPLATE_VBOXR3EXE_LDFLAGS.linux = -Wl,-z,noexecstack,-z,relro $(VBOX_LD_as_needed)
5617TEMPLATE_VBOXR3EXE_LDFLAGS.solaris = -Wl,-z,ignore # same as VBOX_LD_as_needed
5618
5619 ifeq ($(KBUILD_TARGET),linux)
5620TEMPLATE_VBOXR3EXE_LIBS = pthread m rt dl
5621 else ifeq ($(KBUILD_TARGET),os2)
5622TEMPLATE_VBOXR3EXE_TOOL = GXX3OMF
5623TEMPLATE_VBOXR3EXE_LIBS = socket iconv
5624 else ifeq ($(KBUILD_TARGET),darwin)
5625TEMPLATE_VBOXR3EXE_TOOL = $(VBOX_GCC_TOOL)
5626TEMPLATE_VBOXR3EXE_LIBS =
5627TEMPLATE_VBOXR3EXE_DEFS += LIBICONV_PLUG # Avoid 3rd party libiconv (from macports).
5628TEMPLATE_VBOXR3EXE_SDKS.darwin = $(VBOX_DARWIN_DEF_SDK_SDKS)
5629TEMPLATE_VBOXR3EXE_DEFS.darwin = $(VBOX_DARWIN_DEF_SDK_DEFS)
5630TEMPLATE_VBOXR3EXE_CFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_CFLAGS) -fno-common
5631TEMPLATE_VBOXR3EXE_CXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS)
5632TEMPLATE_VBOXR3EXE_PCHFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS)
5633TEMPLATE_VBOXR3EXE_OBJCFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_OBJCFLAGS)
5634TEMPLATE_VBOXR3EXE_OBJCXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_OBJCXXFLAGS)
5635TEMPLATE_VBOXR3EXE_LDFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_LDFLAGS) -Wl,-headerpad_max_install_names
5636TEMPLATE_VBOXR3EXE_LDFLAGS.darwin.x86 = -read_only_relocs suppress
5637 ifdef VBOX_WITH_DTRACE_R3
5638 TEMPLATE_VBOXR3EXE_CXXFLAGS := $(filter-out -pedantic,$(TEMPLATE_VBOXR3EXE_CXXFLAGS)) -fdollars-in-identifiers # annoying gcc option precedence.
5639 endif
5640 else ifeq ($(KBUILD_TARGET),haiku)
5641TEMPLATE_VBOXR3EXE_TOOL = GXX3
5642TEMPLATE_VBOXR3EXE_POST_CMDS = $(VBOX_HAIKU_XRES_SETVER_CMDS)
5643TEMPLATE_VBOXR3EXE_LIBS = network iconv stdc++ supc++
5644TEMPLATE_VBOXR3EXE_LIBPATH += \
5645 /boot/common/lib
5646# Haiku uses PIC by default...
5647TEMPLATE_VBOXR3EXE_CFLAGS += -fno-pic
5648TEMPLATE_VBOXR3EXE_CXXFLAGS += -fno-pic
5649TEMPLATE_VBOXR3EXE_LDFLAGS += -fno-pic
5650 else if1of ($(KBUILD_TARGET), freebsd openbsd)
5651TEMPLATE_VBOXR3EXE_TOOL = GXX3
5652TEMPLATE_VBOXR3EXE_LIBS = pthread
5653TEMPLATE_VBOXR3EXE_INCS += \
5654 /usr/include \
5655 /usr/X11R6/include \
5656 /usr/local/include
5657TEMPLATE_VBOXR3EXE_LIBPATH += \
5658 /usr/lib \
5659 /usr/X11R6/lib \
5660 /usr/local/lib
5661 else ifeq ($(KBUILD_TARGET),netbsd)
5662TEMPLATE_VBOXR3EXE_TOOL = GXX3
5663TEMPLATE_VBOXR3EXE_LIBS = pthread
5664TEMPLATE_VBOXR3EXE_INCS += \
5665 /usr/include \
5666 /usr/X11R7/include
5667TEMPLATE_VBOXR3EXE_LIBPATH += \
5668 /usr/lib \
5669 /usr/X11R7/lib
5670 else ifeq ($(KBUILD_TARGET),solaris)
5671TEMPLATE_VBOXR3EXE_TOOL = GXX3PLAIN
5672TEMPLATE_VBOXR3EXE_DEFS += LIBICONV_PLUG _REENTRANT # Avoid the GNU libiconv, for now at least.
5673TEMPLATE_VBOXR3EXE_LIBS = rt socket
5674 else
5675$(warning Warning: VBOX Build: Target $(KBUILD_TARGET) is not officially supported!)
5676TEMPLATE_VBOXR3EXE_CXXFLAGS.profile = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.release)
5677TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.krelease)
5678 endif
5679 ifdef VBOX_WITH_RUNPATH
5680 TEMPLATE_VBOXR3EXE_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)'
5681 else ifdef VBOX_WITH_RELATIVE_RUNPATH
5682 TEMPLATE_VBOXR3EXE_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)'
5683 endif
5684 ifdef VBOX_WITH_ORIGIN
5685 TEMPLATE_VBOXR3EXE_LDFLAGS.linux += $(VBOX_GCC_ORIGIN_OPT)
5686 endif
5687endif
5688
5689#
5690# Template for building R3 shared objects / DLLs.
5691# This is mostly identical to the VBOXR3EXE template. (Avoid PIC if possible!)
5692# -
5693TEMPLATE_VBOXR3 = VBox Ring 3 SO/DLLs
5694TEMPLATE_VBOXR3_EXTENDS = VBOXR3EXE
5695TEMPLATE_VBOXR3_DEFS.darwin = $(TEMPLATE_VBOXR3EXE_DEFS.darwin) PIC
5696TEMPLATE_VBOXR3_LDFLAGS.darwin = $(TEMPLATE_VBOXR3EXE_LDFLAGS.darwin) \
5697 -current_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
5698 -compatibility_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD)
5699ifn1of ($(KBUILD_TARGET), darwin win os2)
5700 TEMPLATE_VBOXR3_DEFS = $(TEMPLATE_VBOXR3EXE_DEFS) PIC
5701 TEMPLATE_VBOXR3_CFLAGS = $(TEMPLATE_VBOXR3EXE_CFLAGS) -fPIC
5702 TEMPLATE_VBOXR3_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) -fPIC
5703 TEMPLATE_VBOXR3_PCHFLAGS = $(TEMPLATE_VBOXR3EXE_PCHFLAGS) -fPIC
5704 TEMPLATE_VBOXR3_LDFLAGS = $(TEMPLATE_VBOXR3EXE_LDFLAGS) -fPIC
5705endif
5706ifeq ($(KBUILD_TARGET),haiku)
5707 # Haiku uses PIC by default...
5708 TEMPLATE_VBOXR3_CFLAGS = $(TEMPLATE_VBOXR3EXE_CFLAGS) -fno-pic
5709 TEMPLATE_VBOXR3_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) -fno-pic
5710 TEMPLATE_VBOXR3_PCHFLAGS = $(TEMPLATE_VBOXR3EXE_PCHFLAGS) -fno-pic
5711 TEMPLATE_VBOXR3_LDFLAGS = $(TEMPLATE_VBOXR3EXE_LDFLAGS) -fno-pic
5712endif
5713
5714#
5715# Temporary: Renaming the template and warnings will be errors ("soon").
5716#
5717TEMPLATE_VBoxR3Dll += VBox ring-3 SO/DLLs, no warnings
5718TEMPLATE_VBoxR3Dll_EXTENDS += VBOXR3
5719TEMPLATE_VBoxR3Dll_EXTENDS_BY += appending
5720ifeq ($(KBUILD_TARGET),win)
5721 TEMPLATE_VBoxR3Dll_CFLAGS += $(VBOX_VCC_WERR)
5722 TEMPLATE_VBoxR3Dll_CXXFLAGS += $(VBOX_VCC_WERR)
5723 TEMPLATE_VBoxR3Dll_PCHFLAGS += $(VBOX_VCC_WERR)
5724 TEMPLATE_VBoxR3Dll_LDFLAGS += $(VBOX_VCC_LD_WERR)
5725else
5726 TEMPLATE_VBoxR3Dll_CFLAGS += $(VBOX_GCC_WERR)
5727 TEMPLATE_VBoxR3Dll_CXXFLAGS += $(VBOX_GCC_WERR)
5728 TEMPLATE_VBoxR3Dll_PCHFLAGS += $(VBOX_GCC_WERR)
5729endif
5730
5731# x86 edition of the above template for use on AMD64 targets.
5732TEMPLATE_VBoxR3Dll-x86 = 32-bit VBox ring-3 SO/DLLs, no warnings
5733TEMPLATE_VBoxR3Dll-x86_EXTENDS = VBoxR3Dll
5734TEMPLATE_VBoxR3Dll-x86_BLD_TRG_ARCH = x86
5735TEMPLATE_VBoxR3Dll-x86_DEFS = $(filter-out HC_ARCH_BITS%,$(TEMPLATE_VBoxR3Dll_DEFS)) \
5736 HC_ARCH_BITS=32 ARCH_BITS=32
5737ifeq ($(KBUILD_TARGET),solaris)
5738 ifdef VBOX_WITH_RUNPATH
5739 TEMPLATE_VBoxR3Dll-x86_LDFLAGS = \
5740 $(filter-out '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)',$(TEMPLATE_VBoxR3Dll_LDFLAGS)) \
5741 '$(VBOX_GCC_RPATH_OPT)$(VBOX_PATH_APP_PRIVATE)' \
5742 '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)'
5743 endif
5744endif
5745
5746
5747#
5748# Template for building performance critical stuff with warnings-as-errors.
5749#
5750TEMPLATE_VBoxR3DllNoPic = VBox ring-3 SO/DLLs without PIC, without warnings.
5751TEMPLATE_VBoxR3DllNoPic_EXTENDS = VBOXR3
5752if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), linux.x86 freebsd.x86)
5753 TEMPLATE_VBoxR3DllNoPic_DEFS = $(TEMPLATE_VBOXR3EXE_DEFS)
5754 TEMPLATE_VBoxR3DllNoPic_CFLAGS = $(TEMPLATE_VBOXR3EXE_CFLAGS) $(VBOX_GCC_WERR)
5755 TEMPLATE_VBoxR3DllNoPic_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) $(VBOX_GCC_WERR)
5756 TEMPLATE_VBoxR3DllNoPic_PCHFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) $(VBOX_GCC_WERR)
5757 TEMPLATE_VBoxR3DllNoPic_LDFLAGS = $(TEMPLATE_VBOXR3EXE_LDFLAGS)
5758else ifeq ($(KBUILD_TARGET),win)
5759 TEMPLATE_VBoxR3DllNoPic_CFLAGS = $(filter-out -W3 -wd%,$(TEMPLATE_VBOXR3_CFLAGS)) $(VBOX_VCC_WARN_ALL) $(VBOX_VCC_WERR)
5760 TEMPLATE_VBoxR3DllNoPic_CFLAGS.debug = $(filter-out -RTC%,$(TEMPLATE_VBOXR3_CFLAGS.debug))
5761 TEMPLATE_VBoxR3DllNoPic_CFLAGS.release = $(TEMPLATE_VBOXR3_CFLAGS.release) -GS-
5762 TEMPLATE_VBoxR3DllNoPic_CXXFLAGS = $(filter-out -W3 -wd%,$(TEMPLATE_VBOXR3_CXXFLAGS)) $(VBOX_VCC_WARN_ALL) $(VBOX_VCC_WERR)
5763 TEMPLATE_VBoxR3DllNoPic_CXXFLAGS.debug = $(filter-out -RTC%,$(TEMPLATE_VBOXR3_CXXFLAGS.debug)) # RTCsu Prevents IEM opt.
5764 TEMPLATE_VBoxR3DllNoPic_CXXFLAGS.release = $(TEMPLATE_VBOXR3_CXXFLAGS.release) -GS-
5765 TEMPLATE_VBoxR3DllNoPic_PCHFLAGS = $(filter-out -W3 -wd%,$(TEMPLATE_VBOXR3_PCHFLAGS)) $(VBOX_VCC_WARN_ALL) $(VBOX_VCC_WERR)
5766 TEMPLATE_VBoxR3DllNoPic_PCHFLAGS.debug = $(filter-out -RTC%,$(TEMPLATE_VBOXR3_PCHFLAGS.debug)) # RTCsu Prevents IEM opt.
5767 TEMPLATE_VBoxR3DllNoPic_PCHFLAGS.release = $(TEMPLATE_VBOXR3_PCHFLAGS.release) -GS-
5768 TEMPLATE_VBoxR3DllNoPic_LDFLAGS = $(TEMPLATE_VBOXR3_LDFLAGS) $(VBOX_VCC_LD_WERR)
5769else
5770 TEMPLATE_VBoxR3DllNoPic_CFLAGS = $(TEMPLATE_VBOXR3_CFLAGS) $(VBOX_GCC_WERR)
5771 TEMPLATE_VBoxR3DllNoPic_CXXFLAGS = $(TEMPLATE_VBOXR3_CXXFLAGS) $(VBOX_GCC_WERR)
5772 TEMPLATE_VBoxR3DllNoPic_PCHFLAGS = $(TEMPLATE_VBOXR3_PCHFLAGS) $(VBOX_GCC_WERR)
5773endif
5774
5775# x86 edition of the above template for use on AMD64 targets.
5776TEMPLATE_VBoxR3DllNoPic-x86 = 32-bit VBox ring-3 SO/DLLs without PIC, without warnings.
5777TEMPLATE_VBoxR3DllNoPic-x86_EXTENDS = VBoxR3DllNoPic
5778TEMPLATE_VBoxR3DllNoPic-x86_BLD_TRG_ARCH = x86
5779TEMPLATE_VBoxR3DllNoPic-x86_DEFS = $(filter-out HC_ARCH_BITS%,$(TEMPLATE_VBoxR3DllNoPic_DEFS)) \
5780 HC_ARCH_BITS=32 ARCH_BITS=32
5781
5782
5783#
5784# Template for building performance critical stuff without warnings-as-errors.
5785#
5786TEMPLATE_VBoxR3DllWarnNoPic = VBox ring-3 SO/DLLs without PIC, with warnings.
5787TEMPLATE_VBoxR3DllWarnNoPic_EXTENDS = VBOXR3
5788if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), linux.x86 freebsd.x86)
5789 TEMPLATE_VBoxR3DllWarnNoPic_DEFS = $(TEMPLATE_VBOXR3EXE_DEFS)
5790 TEMPLATE_VBoxR3DllWarnNoPic_CFLAGS = $(TEMPLATE_VBOXR3EXE_CFLAGS)
5791 TEMPLATE_VBoxR3DllWarnNoPic_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS)
5792 TEMPLATE_VBoxR3DllWarnNoPic_PCHFLAGS = $(TEMPLATE_VBOXR3EXE_PCHFLAGS)
5793 TEMPLATE_VBoxR3DllWarnNoPic_LDFLAGS = $(TEMPLATE_VBOXR3EXE_LDFLAGS)
5794else ifeq ($(KBUILD_TARGET),win)
5795 TEMPLATE_VBoxR3DllWarnNoPic_CFLAGS.release = $(TEMPLATE_VBOXR3_CFLAGS.release) -GS-
5796 TEMPLATE_VBoxR3DllWarnNoPic_CXXFLAGS.release = $(TEMPLATE_VBOXR3_CXXFLAGS.release) -GS-
5797 TEMPLATE_VBoxR3DllWarnNoPic_PCHFLAGS.release = $(TEMPLATE_VBOXR3_PCHFLAGS.release) -GS-
5798endif
5799
5800#
5801# Template for building static R3 executables and any static
5802# libraries they link with.
5803#
5804TEMPLATE_VBOXR3STATIC = VBox Static Ring 3 EXE
5805TEMPLATE_VBOXR3STATIC_EXTENDS = VBOXR3EXE
5806TEMPLATE_VBOXR3STATIC_DEFS = IN_RT_STATIC IN_RT_R3 IN_SUP_STATIC $(TEMPLATE_VBOXR3EXE_DEFS)
5807ifeq ($(KBUILD_TARGET),win)
5808 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
5809 TEMPLATE_VBOXR3STATIC_SDKS = $(subst WINSDK10-UCRT, WINSDK10-UCRT-STATIC,$(TEMPLATE_VBOXR3EXE_SDKS))
5810 endif
5811 TEMPLATE_VBOXR3STATIC_CFLAGS = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBOXR3EXE_CFLAGS)) -MT$(VBOX_VCC_CRT_TYPE) -Gy
5812 TEMPLATE_VBOXR3STATIC_CXXFLAGS = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBOXR3EXE_CXXFLAGS)) -MT$(VBOX_VCC_CRT_TYPE) -Gy
5813 TEMPLATE_VBOXR3STATIC_PCHFLAGS = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBOXR3EXE_PCHFLAGS)) -MT$(VBOX_VCC_CRT_TYPE) -Gy
5814 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC120" # Do not use SSE so valkit stuff can run on NT4 w/o needing a separate runtime library.
5815 TEMPLATE_VBOXR3STATIC_CFLAGS.win.x86 = $(TEMPLATE_VBOXR3EXE_CFLAGS.win.86) /arch:IA32 -Gw
5816 TEMPLATE_VBOXR3STATIC_CXXFLAGS.win.x86 = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.win.86) /arch:IA32 -Gw
5817 TEMPLATE_VBOXR3STATIC_PCHFLAGS.win.x86 = $(TEMPLATE_VBOXR3EXE_PCHFLAGS.win.86) /arch:IA32 -Gw
5818 endif
5819 TEMPLATE_VBOXR3STATIC_LDFLAGS = $(filter-out /DISALLOWLIB:libcmt$(VBOX_VCC_CRT_TYPE).lib /DISALLOWLIB:libcpmt$(VBOX_VCC_CRT_TYPE).lib, $(TEMPLATE_VBOXR3EXE_LDFLAGS)) \
5820 /DISALLOWLIB:msvcrt.lib \
5821 /DISALLOWLIB:msvcrtd.lib \
5822 /DISALLOWLIB:msvcprt.lib \
5823 /DISALLOWLIB:msvcprtd.lib \
5824 /DISALLOWLIB:vcruntime.lib \
5825 /DISALLOWLIB:vcruntimed.lib \
5826 /DISALLOWLIB:ucrt.lib \
5827 /DISALLOWLIB:ucrtd.lib
5828 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
5829 TEMPLATE_VBOXR3STATIC_LIBS.x86 = \
5830 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.x86)_LIB)/libvcruntime$(VBOX_VCC_CRT_TYPE).lib \
5831 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.x86)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
5832 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.x86)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib \
5833 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.x86)_LIB)/oldnames.lib
5834 TEMPLATE_VBOXR3STATIC_LIBS.amd64 = \
5835 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.amd64)_LIB)/libvcruntime$(VBOX_VCC_CRT_TYPE).lib \
5836 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.amd64)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
5837 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.amd64)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib \
5838 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.amd64)_LIB)/oldnames.lib
5839 else
5840 TEMPLATE_VBOXR3STATIC_LIBS.x86 = \
5841 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.x86)_LIB)/oldnames.lib \
5842 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.x86)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
5843 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.x86)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib
5844 TEMPLATE_VBOXR3STATIC_LIBS.amd64 = \
5845 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.amd64)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
5846 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.amd64)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib \
5847 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL.win.amd64)_LIB)/oldnames.lib
5848 endif
5849else ifn1of ($(KBUILD_TARGET), darwin linux solaris)
5850 # The gcc guys sans darwin, linux and solaris (don't depend on statically compiled system libs there)
5851 TEMPLATE_VBOXR3STATIC_CFLAGS = $(TEMPLATE_VBOXR3EXE_CFLAGS) -static
5852 TEMPLATE_VBOXR3STATIC_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) -static
5853 TEMPLATE_VBOXR3STATIC_PCHFLAGS = $(TEMPLATE_VBOXR3EXE_PCHFLAGS) -static
5854 TEMPLATE_VBOXR3STATIC_OBJCFLAGS = $(TEMPLATE_VBOXR3EXE_OBJCFLAGS) -static
5855 TEMPLATE_VBOXR3STATIC_OBJCXXFLAGS = $(TEMPLATE_VBOXR3EXE_OBJCXXFLAGS) -static
5856 TEMPLATE_VBOXR3STATIC_LDFLAGS = $(TEMPLATE_VBOXR3EXE_LDFLAGS) -static
5857else ifeq ($(KBUILD_TARGET),solaris)
5858 TEMPLATE_VBOXR3STATIC_LIBS = $(TEMPLATE_VBOXR3EXE_LIBS) nsl
5859 TEMPLATE_VBOXR3STATIC_LDFLAGS = $(filter-out '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)' '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)',$(TEMPLATE_VBOXR3EXE_LDFLAGS))
5860else
5861 TEMPLATE_VBOXR3STATIC_LDFLAGS = $(filter-out '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)' '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)',$(TEMPLATE_VBOXR3EXE_LDFLAGS))
5862endif
5863
5864#
5865# Temporary: Renaming the template and warnings will be errors (soon).
5866# Unlike VBOXR3STATIC, this is strict wrt warnings and includes IPRT.
5867#
5868TEMPLATE_VBoxR3Static = New name for VBOXR3STATIC
5869TEMPLATE_VBoxR3Static_EXTENDS = VBOXR3STATIC
5870TEMPLATE_VBoxR3Static_EXTENDS_BY = appending
5871TEMPLATE_VBoxR3Static_SDKS += VBOX_OPENSSL
5872TEMPLATE_VBoxR3Static_SDKS.win += VBOX_NTDLL
5873ifeq ($(KBUILD_TARGET),win)
5874 TEMPLATE_VBoxR3Static_CFLAGS += $(VBOX_VCC_WERR)
5875 TEMPLATE_VBoxR3Static_CXXFLAGS += $(VBOX_VCC_WERR)
5876 TEMPLATE_VBoxR3Static_PCHFLAGS += $(VBOX_VCC_WERR)
5877 TEMPLATE_VBoxR3Static_LDFLAGS += $(VBOX_VCC_LD_WERR)
5878else
5879 TEMPLATE_VBoxR3Static_CFLAGS += $(VBOX_GCC_WERR)
5880 TEMPLATE_VBoxR3Static_CXXFLAGS += $(VBOX_GCC_WERR)
5881 TEMPLATE_VBoxR3Static_PCHFLAGS += $(VBOX_GCC_WERR)
5882endif
5883TEMPLATE_VBoxR3Static_LIBS += \
5884 $(VBOX_LIB_RUNTIME_STATIC)
5885ifndef SDK_VBOX_LIBXML2_LIBS
5886 TEMPLATE_VBoxR3Static_LIBS += \
5887 $(PATH_STAGE_LIB)/VBox-libxml2-static$(VBOX_SUFF_LIB)
5888endif
5889if1of ($(KBUILD_TARGET),os2 win)
5890 TEMPLATE_VBoxR3Static_LIBS += \
5891 $(SDK_VBOX_LZF_STATIC_LIBS) \
5892 $(SDK_VBOX_ZLIB_STATIC_LIBS)
5893else
5894 TEMPLATE_VBoxR3Static_LIBS += \
5895 $(SDK_VBOX_LZF_LIBS) \
5896 $(SDK_VBOX_ZLIB_LIBS)
5897 if1of ($(KBUILD_TARGET),darwin freebsd)
5898 TEMPLATE_VBoxR3Static_LIBS += iconv
5899 else ifeq ($(KBUILD_TARGET),solaris)
5900 TEMPLATE_VBoxR3Static_LIBS += kstat
5901 endif
5902endif
5903
5904#
5905# Non-pedantic variation of VBoxR3Static
5906#
5907TEMPLATE_VBoxR3StaticNonPedantic = VBox Static Ring-3 EXE, non-pedantic.
5908TEMPLATE_VBoxR3StaticNonPedantic_EXTENDS = VBoxR3Static
5909ifeq ($(KBUILD_TARGET),win)
5910 TEMPLATE_VBoxR3StaticNonPedantic_CFLAGS = $(TEMPLATE_VBoxR3Static_CFLAGS) $(VBOX_VCC_NON_PEDANTIC)
5911 TEMPLATE_VBoxR3StaticNonPedantic_CXXFLAGS = $(TEMPLATE_VBoxR3Static_CXXFLAGS) $(VBOX_VCC_NON_PEDANTIC)
5912 TEMPLATE_VBoxR3StaticNonPedantic_PCHFLAGS = $(TEMPLATE_VBoxR3Static_PCHFLAGS) $(VBOX_VCC_NON_PEDANTIC)
5913else # gcc:
5914 TEMPLATE_VBoxR3StaticNonPedantic_TOOL = $(VBOX_GCC_TOOL)
5915 TEMPLATE_VBoxR3StaticNonPedantic_CFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_C) ,$(TEMPLATE_VBoxR3Static_CFLAGS)) \
5916 $(VBOX_GCC_NON_PEDANTIC_CXX)
5917 TEMPLATE_VBoxR3StaticNonPedantic_CXXFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_CXX),$(TEMPLATE_VBoxR3Static_CXXFLAGS)) \
5918 $(VBOX_GCC_NON_PEDANTIC_CXX)
5919 TEMPLATE_VBoxR3StaticNonPedantic_PCHFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_CXX),$(TEMPLATE_VBoxR3Static_PCHFLAGS)) \
5920 $(VBOX_GCC_NON_PEDANTIC_CXX)
5921endif
5922
5923#
5924# VBoxR3Static w/o any CRT (windows only atm, experimental).
5925# Implies no fancy C++, no exceptions, no static constructors or destructors, ++.
5926#
5927TEMPLATE_VBoxR3StaticNoCrt = Static
5928TEMPLATE_VBoxR3StaticNoCrt_EXTENDS = VBoxR3Static
5929TEMPLATE_VBoxR3StaticNoCrt_SDKS = $(subst WINSDK10-UCRT-STATIC,WINSDK10-UCRT-INCS, $(filter-out VBOX_OPENSSL,$(TEMPLATE_VBoxR3Static_SDKS)))
5930TEMPLATE_VBoxR3StaticNoCrt_DEFS = $(TEMPLATE_VBoxR3Static_DEFS) \
5931 RT_NO_CRT \
5932 IN_RT_STATIC
5933TEMPLATE_VBoxR3StaticNoCrt_DEFS.win = $(TEMPLATE_VBoxR3Static_DEFS.win) \
5934 RT_WITHOUT_NOCRT_WRAPPERS
5935TEMPLATE_VBoxR3StaticNoCrt_LIBS = \
5936 $(PATH_STAGE_LIB)/RuntimeR3NoCrt$(VBOX_SUFF_LIB)
5937ifeq ($(KBUILD_TARGET),win)
5938TEMPLATE_VBoxR3StaticNoCrt_LIBS.x86 = $(NO_SUCH_VARIABLE)
5939TEMPLATE_VBoxR3StaticNoCrt_LIBS.amd64 = $(NO_SUCH_VARIABLE)
5940TEMPLATE_VBoxR3StaticNoCrt_LIBS.win = $(NO_SUCH_VARIABLE)
5941TEMPLATE_VBoxR3StaticNoCrt_LIBS.win.x86 = \
5942 $(PATH_SDK_$(VBOX_WINDDK)_LIB.x86)/int64.lib \
5943 $(PATH_TOOL_$(TEMPLATE_VBoxR3StaticNoCrt_TOOL.win.x86)_LIB)/chkstk.obj
5944TEMPLATE_VBoxR3StaticNoCrt_LDFLAGS.win.x86 = $(filter-out -Include%, $(TEMPLATE_VBoxR3Static_LDFLAGS.win.x86))
5945TEMPLATE_VBoxR3StaticNoCrt_CFLAGS = $(filter-out -EH%,$(TEMPLATE_VBoxR3Static_CFLAGS)) /GS- -EHs-
5946TEMPLATE_VBoxR3StaticNoCrt_CXXFLAGS = $(filter-out -EH%,$(TEMPLATE_VBoxR3Static_CXXFLAGS)) /GS- -EHs-
5947TEMPLATE_VBoxR3StaticNoCrt_PCHFLAGS = $(filter-out -EH%,$(TEMPLATE_VBoxR3Static_PCHFLAGS)) /GS- -EHs-
5948TEMPLATE_VBoxR3StaticNoCrt_CXXFLAGS.debug = $(filter-out /RTC% -RTC%, $(TEMPLATE_VBoxR3Static_CXXFLAGS.debug))
5949else
5950TEMPLATE_VBoxR3StaticNoCrt_CXXFLAGS = $(TEMPLATE_VBoxR3Static_CXXFLAGS) -fno-exceptions
5951TEMPLATE_VBoxR3StaticNoCrt_PCHFLAGS = $(TEMPLATE_VBoxR3Static_PCHFLAGS) -fno-exceptions
5952endif
5953
5954
5955#
5956# Executable w/o CRT (windows only atm, experimental).
5957# Implies no fancy C++, no exceptions, no static constructors or destructors, ++.
5958#
5959TEMPLATE_VBoxR3StaticNoCrtExe := VBoxR3StaticNoCrt with EXE startup code calling a main() function
5960TEMPLATE_VBoxR3StaticNoCrtExe_EXTENDS := VBoxR3StaticNoCrt
5961TEMPLATE_VBoxR3StaticNoCrtExe_EXTENDS_BY := appending
5962TEMPLATE_VBoxR3StaticNoCrtExe_LDFLAGS.win := /entry:CustomMainEntrypoint /subsystem:console
5963
5964
5965#
5966# Same as VBOXR3EXE but without C++ exceptions.
5967#
5968# VBOXR3EXE does C++ exceptions and may assumes that extern "C" functions
5969# doesn't throw them. Use this template (and VBOXR3DLLNOXCPT) with care
5970# and only where the C++ overhead is really unwanted.
5971#
5972TEMPLATE_VBOXR3EXENOXCPT = VBox Ring 3 Exe without C++ exception
5973TEMPLATE_VBOXR3EXENOXCPT_EXTENDS = VBOXR3EXE
5974ifeq ($(KBUILD_TARGET),win)
5975 TEMPLATE_VBOXR3EXENOXCPT_CFLAGS = $(filter-out -EH%,$(TEMPLATE_VBOXR3EXE_CFLAGS) ) -EHs-
5976 TEMPLATE_VBOXR3EXENOXCPT_CXXFLAGS = $(filter-out -EH%,$(TEMPLATE_VBOXR3EXE_CXXFLAGS)) -EHs-
5977 TEMPLATE_VBOXR3EXENOXCPT_PCHFLAGS = $(filter-out -EH%,$(TEMPLATE_VBOXR3EXE_PCHFLAGS)) -EHs-
5978else
5979 TEMPLATE_VBOXR3EXENOXCPT_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) -fno-exceptions
5980 TEMPLATE_VBOXR3EXENOXCPT_PCHFLAGS = $(TEMPLATE_VBOXR3EXE_PCHFLAGS) -fno-exceptions
5981endif
5982
5983#
5984# Same as VBOXR3 but without C++ exceptions.
5985#
5986TEMPLATE_VBOXR3DLLNOXCPT = VBox Ring 3 SO/DLLs without C++ exception
5987TEMPLATE_VBOXR3DLLNOXCPT_EXTENDS = VBOXR3
5988ifeq ($(KBUILD_TARGET),win)
5989 TEMPLATE_VBOXR3DLLNOXCPT_CFLAGS = $(filter-out -EH%,$(TEMPLATE_VBOXR3_CFLAGS) ) -EHs-
5990 TEMPLATE_VBOXR3DLLNOXCPT_CXXFLAGS = $(filter-out -EH%,$(TEMPLATE_VBOXR3_CXXFLAGS)) -EHs-
5991 TEMPLATE_VBOXR3DLLNOXCPT_PCHFLAGS = $(filter-out -EH%,$(TEMPLATE_VBOXR3_PCHFLAGS)) -EHs-
5992else
5993 TEMPLATE_VBOXR3DLLNOXCPT_CXXFLAGS = $(TEMPLATE_VBOXR3_CXXFLAGS) -fno-exceptions
5994 TEMPLATE_VBOXR3DLLNOXCPT_PCHFLAGS = $(TEMPLATE_VBOXR3_PCHFLAGS) -fno-exceptions
5995endif
5996
5997#
5998# Template for building hardened Ring-3 executables.
5999# These shall have no extra runpaths, esp. not origin ones.
6000#
6001TEMPLATE_VBOXR3HARDENEDEXE = Hardened VBox Ring-3 EXE
6002TEMPLATE_VBOXR3HARDENEDEXE_EXTENDS = VBOXR3EXE
6003TEMPLATE_VBOXR3HARDENEDEXE_DEBUG_INST.win = $(INST_DEBUG)hardened-exes/
6004TEMPLATE_VBOXR3HARDENEDEXE_DEFS = $(TEMPLATE_VBOXR3EXE_DEFS) RTMEM_NO_WRAP_TO_EF_APIS
6005ifdef VBOX_WITH_HARDENING
6006 TEMPLATE_VBOXR3HARDENEDEXE_LIBS = $(VBOX_LIB_SUPHARDENED) $(TEMPLATE_VBOXR3EXE_LIBS)
6007else
6008 TEMPLATE_VBOXR3HARDENEDEXE_LIBS = $(TEMPLATE_VBOXR3EXE_LIBS)
6009endif
6010TEMPLATE_VBOXR3HARDENEDEXE_LDFLAGS.darwin = $(TEMPLATE_VBOXR3EXE_LDFLAGS.darwin) -framework IOKit
6011ifeq ($(KBUILD_TARGET),linux)
6012# not necessary except USE_LIB_PCAP is defined in SUPR3HardenedMain.cpp
6013# TEMPLATE_VBOXR3HARDENEDEXE_LIBS += cap
6014endif
6015ifeq ($(KBUILD_TARGET),win) # No CRT!
6016 TEMPLATE_VBOXR3HARDENEDEXE_SDKS = VBOX_NTDLL $(TEMPLATE_VBOXR3EXE_SDKS)
6017 TEMPLATE_VBOXR3HARDENEDEXE_LIBS.x86 = \
6018 $(PATH_SDK_$(VBOX_WINDDK)_LIB.x86)/int64.lib \
6019 $(PATH_TOOL_$(TEMPLATE_VBOXR3HARDENEDEXE_TOOL.win.x86)_LIB)/chkstk.obj
6020 TEMPLATE_VBOXR3HARDENEDEXE_CXXFLAGS = $(filter-out -RTC% -GZ -GS,$(TEMPLATE_VBOXR3EXE_CXXFLAGS)) -GS-
6021 TEMPLATE_VBOXR3HARDENEDEXE_CXXFLAGS.debug= $(filter-out -RTC% -GZ -GS,$(TEMPLATE_VBOXR3EXE_CXXFLAGS.debug)) -GS- #-O2 -Oy-
6022 TEMPLATE_VBOXR3HARDENEDEXE_PCHFLAGS = $(filter-out -RTC% -GZ -GS,$(TEMPLATE_VBOXR3EXE_PCHFLAGS)) -GS-
6023 TEMPLATE_VBOXR3HARDENEDEXE_PCHFLAGS.debug= $(filter-out -RTC% -GZ -GS,$(TEMPLATE_VBOXR3EXE_PCHFLAGS.debug)) -GS- #-O2 -Oy-
6024 TEMPLATE_VBOXR3HARDENEDEXE_CFLAGS = $(filter-out -RTC% -GZ -GS,$(TEMPLATE_VBOXR3EXE_CFLAGS)) -GS-
6025 TEMPLATE_VBOXR3HARDENEDEXE_CFLAGS.debug = $(filter-out -RTC% -GZ -GS,$(TEMPLATE_VBOXR3EXE_CFLAGS.debug)) -GS- -O2 -Oy-
6026 TEMPLATE_VBOXR3HARDENEDEXE_LDFLAGS = $(TEMPLATE_VBOXR3EXE_LDFLAGS) \
6027 /DISALLOWLIB:msvcrt$(VBOX_VCC_CRT_TYPE).lib \
6028 /DISALLOWLIB:msvcprt$(VBOX_VCC_CRT_TYPE).lib \
6029 /DISALLOWLIB:vcruntime$(VBOX_VCC_CRT_TYPE).lib \
6030 /DISALLOWLIB:ucrt$(VBOX_VCC_CRT_TYPE).lib
6031 TEMPLATE_VBOXR3HARDENEDEXE_LDFLAGS.win.x86 = $(TEMPLATE_VBOXR3EXE_LDFLAGS.win.x86) /entry:suplibHardenedWindowsMain
6032 TEMPLATE_VBOXR3HARDENEDEXE_LDFLAGS.win.amd64 = $(TEMPLATE_VBOXR3EXE_LDFLAGS.win.amd64) /entry:suplibHardenedWindowsMain
6033 TEMPLATE_VBOXR3HARDENEDEXE_LIBS.x86 = $(NOT_SUCH_VARIABLE)
6034 TEMPLATE_VBOXR3HARDENEDEXE_LIBS.amd64 = $(NOT_SUCH_VARIABLE)
6035else ifn1of ($(KBUILD_TARGET), os2 solaris) # Keep RPATH on Solaris so we can find libgcc_1/libstdc++ within $(VBOX_WITH_RUNPATH).
6036 ifneq ($(KBUILD_TYPE),asan) # Keep RPATH in asan builds so we can find libasan.so.X and libubsan.so.Y.
6037 TEMPLATE_VBOXR3HARDENEDEXE_LDFLAGS = $(filter-out '$(VBOX_GCC_RPATH_OPT)%,$(TEMPLATE_VBOXR3EXE_LDFLAGS))
6038 TEMPLATE_VBOXR3HARDENEDEXE_LDFLAGS.linux = $(filter-out $(VBOX_GCC_ORIGIN_OPT),$(TEMPLATE_VBOXR3EXE_LDFLAGS.linux))
6039 endif
6040endif
6041
6042#
6043# Template for building hardened Ring-3 libraries.
6044#
6045TEMPLATE_VBOXR3HARDENEDLIB = Hardened VBox Ring-3 LIB
6046TEMPLATE_VBOXR3HARDENEDLIB_EXTENDS = VBOXR3HARDENEDEXE
6047TEMPLATE_VBOXR3HARDENEDLIB_LIBS = $(NO_SUCH_VARIABLE)
6048
6049
6050#
6051# Template for building hardened Ring-3 testcase executables.
6052#
6053TEMPLATE_VBoxR3HardenedTstExe = VBox Ring-3 Hardened Testcase Exe (currently windows only!)
6054TEMPLATE_VBoxR3HardenedTstExe_EXTENDS = VBOXR3HARDENEDEXE
6055TEMPLATE_VBoxR3HardenedTstExe_INST = $(INST_TESTCASE)
6056
6057#
6058# Template for building hardened Ring-3 testcase DLLs (pairs with VBoxR3HardenedTstExe).
6059#
6060TEMPLATE_VBoxR3HardenedTstDll = VBox Ring-3 Hardened Testcase Dll (currently windows only!)
6061TEMPLATE_VBoxR3HardenedTstDll_EXTENDS = VBoxR3TstDll
6062TEMPLATE_VBoxR3HardenedTstDll_INST = $(INST_TESTCASE)
6063 TEMPLATE_VBoxR3HardenedTstDll_LDFLAGS.win = $(TEMPLATE_VBoxR3TstDll_LDFLAGS.win) -IntegrityCheck
6064ifn1of ($(KBUILD_TARGET), win os2)
6065 TEMPLATE_VBoxR3HardenedTstDll_LDFLAGS = $(filter-out '$(VBOX_GCC_RPATH_OPT)%,$(TEMPLATE_VBoxR3TstDll_LDFLAGS))
6066 TEMPLATE_VBoxR3HardenedTstDll_LDFLAGS.linux = $(filter-out $(VBOX_GCC_ORIGIN_OPT),$(TEMPLATE_VBoxR3TstDll_LDFLAGS.linux))
6067endif
6068
6069#
6070# Template for building set-uid-to-root helper programs.
6071# In hardened builds, these may only contain absolute runpaths!
6072#
6073TEMPLATE_VBoxR3SetUidToRoot = Set-uid-to-root helper program.
6074if1of ($(KBUILD_TARGET),win)
6075 TEMPLATE_VBoxR3SetUidToRoot_EXTENDS = VBOXR3EXE
6076else
6077 TEMPLATE_VBoxR3SetUidToRoot_EXTENDS = VBOXR3HARDENEDEXE
6078 TEMPLATE_VBoxR3SetUidToRoot_LDFLAGS = $(VBOX_GCC_SANITIZER_FLAGS) $(VBOX_GCC_SANITIZER_LDFLAGS)
6079endif
6080TEMPLATE_VBoxR3SetUidToRoot_LIBS = $(NO_SUCH_VARIABLE)
6081ifdef VBOX_WITH_RUNPATH
6082 TEMPLATE_VBoxR3SetUidToRoot_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)'
6083endif
6084ifndef VBOX_WITH_HARDENING
6085 ifdef VBOX_WITH_RELATIVE_RUNPATH
6086 TEMPLATE_VBoxR3SetUidToRoot_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)'
6087 endif
6088 ifdef VBOX_WITH_ORIGIN
6089 TEMPLATE_VBoxR3SetUidToRoot_LDFLAGS.linux += $(VBOX_GCC_ORIGIN_OPT)
6090 endif
6091endif
6092
6093#
6094# Template for building R3 tools.
6095#
6096TEMPLATE_VBoxR3Tool = VBox Ring 3 Tools
6097TEMPLATE_VBoxR3Tool_EXTENDS = VBOXR3EXE
6098TEMPLATE_VBoxR3Tool_INST = $(VBOX_INST_TOOLS)
6099ifeq ($(KBUILD_TARGET),win)
6100 TEMPLATE_VBoxR3Tool_CFLAGS = $(TEMPLATE_VBOXR3EXE_CFLAGS) $(VBOX_VCC_WERR)
6101 TEMPLATE_VBoxR3Tool_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) $(VBOX_VCC_WERR)
6102 TEMPLATE_VBoxR3Tool_PCHFLAGS = $(TEMPLATE_VBOXR3EXE_PCHFLAGS) $(VBOX_VCC_WERR)
6103 TEMPLATE_VBoxR3Tool_LDFLAGS = $(TEMPLATE_VBOXR3EXE_LDFLAGS) $(VBOX_VCC_LD_WERR)
6104else
6105 TEMPLATE_VBoxR3Tool_CFLAGS = $(TEMPLATE_VBOXR3EXE_CFLAGS) $(VBOX_GCC_WERR)
6106 TEMPLATE_VBoxR3Tool_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) $(VBOX_GCC_WERR)
6107 TEMPLATE_VBoxR3Tool_PCHFLAGS = $(TEMPLATE_VBOXR3EXE_PCHFLAGS) $(VBOX_GCC_WERR)
6108 ifdef VBOX_WITH_RUNPATH
6109 TEMPLATE_VBoxR3Tool_LDFLAGS = '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)' $(TEMPLATE_VBOXR3EXE_LDFLAGS)
6110 else ifdef VBOX_WITH_RELATIVE_RUNPATH
6111 TEMPLATE_VBoxR3Tool_LDFLAGS = '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)/..' $(TEMPLATE_VBOXR3EXE_LDFLAGS)
6112 endif
6113endif
6114TEMPLATE_VBoxR3Tool_LIBS = $(LIB_RUNTIME) $(TEMPLATE_VBOXR3EXE_LIBS)
6115if defined(VBOX_WITH_MORE_NT4_COMPAT_BINARIES) && "$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)" == "win.x86"
6116 TEMPLATE_VBoxR3Tool_LIBS.x86 = \
6117 $(PATH_STAGE_LIB)/RuntimeR3VccTricks2$(VBOX_SUFF_LIB) \
6118 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.x86)_LIB)/oldnames.lib
6119endif
6120
6121#
6122# Template for building R3 shared objects / DLLs with the 10.5 Mac OS X SDK.
6123# Identical to VBOXR3EXE, except for the DYLIB, the classic_linker and SDK bits.
6124#
6125TEMPLATE_VBOXR3OSX105 = VBox Ring 3 SO/DLLs for OS X 10.5
6126TEMPLATE_VBOXR3OSX105_EXTENDS = VBOXR3EXE
6127TEMPLATE_VBOXR3OSX105_DEFS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_DEFS) PIC
6128TEMPLATE_VBOXR3OSX105_CFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_CFLAGS) -fno-common
6129TEMPLATE_VBOXR3OSX105_CXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_CXXFLAGS)
6130TEMPLATE_VBOXR3OSX105_PCHFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_PCHFLAGS)
6131TEMPLATE_VBOXR3OSX105_OBJCFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_OBJCFLAGS)
6132TEMPLATE_VBOXR3OSX105_OBJCXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_OBJCFLAGS)
6133TEMPLATE_VBOXR3OSX105_LDFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_LDFLAGS) \
6134 -read_only_relocs suppress \
6135 -current_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
6136 -compatibility_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD)
6137
6138#
6139# Template for building R3 shared objects / DLLs with the 10.7 Mac OS X SDK.
6140# Identical to VBoxR3Dll, except for the DYLIB, the classic_linker and SDK bits.
6141#
6142TEMPLATE_VBoxR3DllOsX107 = VBox Ring 3 SO/DLLs for OS X 10.7
6143TEMPLATE_VBoxR3DllOsX107_EXTENDS = VBoxR3Dll
6144TEMPLATE_VBoxR3DllOsX107_TOOL = LLVMGXX42MACHO
6145TEMPLATE_VBoxR3DllOsX107_DEFS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_DEFS) PIC
6146TEMPLATE_VBoxR3DllOsX107_CFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_CFLAGS) -fno-common
6147TEMPLATE_VBoxR3DllOsX107_CXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_CXXFLAGS)
6148TEMPLATE_VBoxR3DllOsX107_PCHFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_PCHFLAGS)
6149TEMPLATE_VBoxR3DllOsX107_OBJCFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_OBJCFLAGS)
6150TEMPLATE_VBoxR3DllOsX107_OBJCXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_OBJCFLAGS)
6151TEMPLATE_VBoxR3DllOsX107_LDFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_LDFLAGS) \
6152 -current_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
6153 -compatibility_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD)
6154
6155
6156#
6157# Ring-3 testcase, running automatically during the build.
6158# This is the VBOXR3EXE template only with a different install dir.
6159#
6160TEMPLATE_VBOXR3AUTOTST = VBox Ring 3 Testcase Exe
6161ifeq ($(KBUILD_TARGET),win)
6162 TEMPLATE_VBOXR3AUTOTST_EXTENDS = VBoxR3Static
6163 TEMPLATE_VBOXR3AUTOTST_LIBS = $(NO_SUCH_VARIABLE)
6164 TEMPLATE_VBOXR3AUTOTST_SDKS = $(filter-out VBOX_OPENSSL,$(TEMPLATE_VBoxR3Static_SDKS))
6165else
6166 TEMPLATE_VBOXR3AUTOTST_EXTENDS = VBOXR3EXE
6167endif
6168TEMPLATE_VBOXR3AUTOTST_INST = $(INST_TESTCASE)
6169if "$(KBUILD_TARGET)" == "win" && defined(VBOX_SIGNING_MODE)
6170 TEMPLATE_VBOXR3AUTOTST_POST_CMDS = $(NO_SUCH_VARIABLE)
6171 TEMPLATE_VBOXR3AUTOTST_LDFLAGS = $(filter-out -IntegrityCheck, $(TEMPLATE_VBoxR3Static_LDFLAGS))
6172endif
6173
6174#
6175# Ring-3 testcase.
6176# This is the VBOXR3EXE template only with a different install dir.
6177#
6178TEMPLATE_VBOXR3TSTEXE = VBox Ring 3 Testcase Exe
6179TEMPLATE_VBOXR3TSTEXE_EXTENDS = VBOXR3EXE
6180TEMPLATE_VBOXR3TSTEXE_INST = $(INST_TESTCASE)
6181TEMPLATE_VBOXR3TSTEXE_LIBS = $(LIB_RUNTIME) $(TEMPLATE_VBOXR3EXE_LIBS)
6182ifdef VBOX_WITH_RUNPATH
6183 TEMPLATE_VBOXR3TSTEXE_LDFLAGS = '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)' $(TEMPLATE_VBOXR3EXE_LDFLAGS)
6184else ifdef VBOX_WITH_RELATIVE_RUNPATH
6185 TEMPLATE_VBOXR3TSTEXE_LDFLAGS = '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)/..' $(TEMPLATE_VBOXR3EXE_LDFLAGS)
6186endif
6187if "$(KBUILD_TARGET)" == "win" && defined(VBOX_SIGNING_MODE)
6188 TEMPLATE_VBOXR3TSTEXE_POST_CMDS =
6189 TEMPLATE_VBOXR3TSTEXE_LDFLAGS = $(filter-out -IntegrityCheck, $(TEMPLATE_VBOXR3EXE_LDFLAGS))
6190endif
6191if defined(VBOX_WITH_MORE_NT4_COMPAT_BINARIES) && "$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)" == "win.x86"
6192 TEMPLATE_VBOXR3TSTEXE_POST_CMDS.win.x86 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION) $(out))
6193 TEMPLATE_VBOXR3TSTEXE_LIBS.x86 = \
6194 $(PATH_STAGE_LIB)/RuntimeR3VccTricks2$(VBOX_SUFF_LIB) \
6195 $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.x86)_LIB)/oldnames.lib
6196endif
6197
6198#
6199# Ring-3 testcase (no -pedantic)
6200#
6201TEMPLATE_VBOXR3TSTNPEXE = VBox Ring 3 Testcase Exe Non-pedantic
6202TEMPLATE_VBOXR3TSTNPEXE_EXTENDS = VBOXR3TSTEXE
6203ifneq ($(KBUILD_TARGET),win) # (only gcc)
6204 TEMPLATE_VBOXR3TSTNPEXE_TOOL = $(VBOX_GCC_TOOL)
6205 TEMPLATE_VBOXR3TSTNPEXE_CFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_C) ,$(TEMPLATE_VBOXR3TSTEXE_CFLAGS)) \
6206 -Wno-sign-compare
6207 TEMPLATE_VBOXR3TSTNPEXE_CXXFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_CXX),$(TEMPLATE_VBOXR3TSTEXE_CXXFLAGS)) \
6208 -Wno-sign-compare
6209 TEMPLATE_VBOXR3TSTNPEXE_PCHFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_CXX),$(TEMPLATE_VBOXR3TSTEXE_PCHFLAGS)) \
6210 -Wno-sign-compare
6211endif
6212
6213
6214#
6215# Ring-3 testcase DLL.
6216#
6217TEMPLATE_VBoxR3TstDll = VBox Ring-3 Testcase Dll
6218TEMPLATE_VBoxR3TstDll_EXTENDS = VBOXR3TSTEXE
6219ifn1of ($(KBUILD_TARGET), darwin win os2)
6220 TEMPLATE_VBoxR3TstDll_DEFS = $(TEMPLATE_VBOXR3TSTEXE_DEFS) PIC
6221 TEMPLATE_VBoxR3TstDll_CFLAGS = $(TEMPLATE_VBOXR3TSTEXE_CFLAGS) -fPIC
6222 TEMPLATE_VBoxR3TstDll_CXXFLAGS = $(TEMPLATE_VBOXR3TSTEXE_CXXFLAGS) -fPIC
6223 TEMPLATE_VBoxR3TstDll_PCHFLAGS = $(TEMPLATE_VBOXR3TSTEXE_PCHFLAGS) -fPIC
6224 TEMPLATE_VBoxR3TstDll_LDFLAGS = $(TEMPLATE_VBOXR3TSTEXE_LDFLAGS) -fPIC
6225endif
6226
6227
6228#
6229# Template for the CppUnit kind of testcases.
6230#
6231TEMPLATE_VBOXCPPUNITEXE = VBox CppUnit Testcase Exe
6232TEMPLATE_VBOXCPPUNITEXE_EXTENDS = VBOXR3TSTEXE
6233## @todo make a CPPUNIT SDK and add cppunit tools packages for windows, mac, solaris and OS/2.
6234#TEMPLATE_VBOXCPPUNITEXE_SDKS = CPPUNIT -
6235TEMPLATE_VBOXCPPUNITEXE_LIBS = \
6236 $(TEMPLATE_VBOXR3TSTEXE_LIBS) \
6237 cppunit
6238
6239#
6240# Template for building bad C/C++ style R3 executables (no -pedantic).
6241#
6242TEMPLATE_VBOXR3NPEXE = VBox Ring 3 Non-pedantic
6243TEMPLATE_VBOXR3NPEXE_EXTENDS = VBOXR3EXE
6244ifneq ($(KBUILD_TARGET),win) # (only gcc)
6245 TEMPLATE_VBOXR3NPEXE_TOOL = $(VBOX_GCC_TOOL)
6246 TEMPLATE_VBOXR3NPEXE_CFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_C) ,$(TEMPLATE_VBOXR3EXE_CFLAGS)) \
6247 $(VBOX_GCC_NON_PEDANTIC_C)
6248 TEMPLATE_VBOXR3NPEXE_CXXFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_CXX),$(TEMPLATE_VBOXR3EXE_CXXFLAGS)) \
6249 $(VBOX_GCC_NON_PEDANTIC_CXX)
6250 TEMPLATE_VBOXR3NPEXE_PCHFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_CXX),$(TEMPLATE_VBOXR3EXE_PCHFLAGS)) \
6251 $(VBOX_GCC_NON_PEDANTIC_CXX)
6252endif
6253
6254
6255#
6256# Template for building bad C/C++ style R3 shared libraries / Dlls (no -pedantic).
6257# (Same transformation as for VBOXR3NPEXE.)
6258#
6259# @deprecated Use VBoxR3DllNonPedantic!
6260#
6261TEMPLATE_VBOXR3NP = VBox Ring 3 Non-pedantic
6262TEMPLATE_VBOXR3NP_EXTENDS = VBOXR3
6263ifneq ($(KBUILD_TARGET),win) # (only gcc)
6264 TEMPLATE_VBOXR3NP_TOOL = $(VBOX_GCC_TOOL)
6265 TEMPLATE_VBOXR3NP_CFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_C) ,$(TEMPLATE_VBOXR3_CFLAGS)) \
6266 $(VBOX_GCC_NON_PEDANTIC_C)
6267 TEMPLATE_VBOXR3NP_CXXFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_CXX),$(TEMPLATE_VBOXR3_CXXFLAGS)) \
6268 $(VBOX_GCC_NON_PEDANTIC_CXX)
6269 TEMPLATE_VBOXR3NP_PCHFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_CXX),$(TEMPLATE_VBOXR3_PCHFLAGS)) \
6270 $(VBOX_GCC_NON_PEDANTIC_CXX)
6271 TEMPLATE_VBOXR3NP_OBJCFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) -pedantic -Wstrict-prototypes,$(TEMPLATE_VBOXR3_OBJCFLAGS))
6272 TEMPLATE_VBOXR3NP_OBJCXXFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) -pedantic,$(TEMPLATE_VBOXR3_OBJCXXFLAGS))
6273endif
6274
6275
6276#
6277# Template for building bad C/C++ style R3 shared libraries / Dlls (no -pedantic).
6278# (Same transformation as for VBoxR3ExeNonPedantic.)
6279#
6280TEMPLATE_VBoxR3DllNonPedantic = VBox ring-3 Non-pedantic, with warnings.
6281TEMPLATE_VBoxR3DllNonPedantic_EXTENDS = VBOXR3
6282ifeq ($(KBUILD_TARGET),win)
6283 TEMPLATE_VBoxR3DllNonPedantic_CFLAGS = $(TEMPLATE_VBOXR3_CFLAGS) $(VBOX_VCC_NON_PEDANTIC)
6284 TEMPLATE_VBoxR3DllNonPedantic_CXXFLAGS = $(TEMPLATE_VBOXR3_CXXFLAGS) $(VBOX_VCC_NON_PEDANTIC)
6285 TEMPLATE_VBoxR3DllNonPedantic_PCHFLAGS = $(TEMPLATE_VBOXR3_PCHFLAGS) $(VBOX_VCC_NON_PEDANTIC)
6286else # gcc:
6287 TEMPLATE_VBoxR3DllNonPedantic_TOOL = $(VBOX_GCC_TOOL)
6288 TEMPLATE_VBoxR3DllNonPedantic_CFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_C) ,$(TEMPLATE_VBOXR3_CFLAGS)) \
6289 $(VBOX_GCC_NON_PEDANTIC_C)
6290 TEMPLATE_VBoxR3DllNonPedantic_CXXFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_CXX),$(TEMPLATE_VBOXR3_CXXFLAGS)) \
6291 $(VBOX_GCC_NON_PEDANTIC_CXX)
6292 TEMPLATE_VBoxR3DllNonPedantic_PCHFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_CXX),$(TEMPLATE_VBOXR3_PCHFLAGS)) \
6293 $(VBOX_GCC_NON_PEDANTIC_CXX)
6294endif
6295
6296# x86 edition of the above template for use on AMD64 targets.
6297TEMPLATE_VBoxR3DllNonPedantic-x86 = 32-bit VBox ring-3 SO/DLLs, no warnings
6298TEMPLATE_VBoxR3DllNonPedantic-x86_EXTENDS = VBoxR3DllNonPedantic
6299TEMPLATE_VBoxR3DllNonPedantic-x86_BLD_TRG_ARCH = x86
6300TEMPLATE_VBoxR3DllNonPedantic-x86_DEFS = $(filter-out HC_ARCH_BITS%,$(TEMPLATE_VBoxR3DllNonPedantic_DEFS)) \
6301 HC_ARCH_BITS=32 ARCH_BITS=32
6302
6303
6304
6305#
6306# Same as VBoxR3DllNonPedantic, only it optimizes debug builds.
6307#
6308TEMPLATE_VBoxR3DllNonPedanticFast = VBox ring-3 Non-pedantic, with warnings, optimized debug.
6309TEMPLATE_VBoxR3DllNonPedanticFast_EXTENDS = VBoxR3DllNonPedantic
6310ifeq ($(KBUILD_TYPE),debug)
6311 ifeq ($(KBUILD_TARGET),win)
6312 TEMPLATE_VBoxR3DllNonPedanticFast_CFLAGS = $(filter-out -O0, $(TEMPLATE_VBoxR3DllNonPedantic_CFLAGS)) -O2 -Oy-
6313 TEMPLATE_VBoxR3DllNonPedanticFast_CFLAGS.debug = $(filter-out -RTC%, $(TEMPLATE_VBoxR3DllNonPedantic_CFLAGS.debug))
6314 TEMPLATE_VBoxR3DllNonPedanticFast_CXXFLAGS = $(filter-out -O0, $(TEMPLATE_VBoxR3DllNonPedantic_CXXFLAGS)) -O2 -Oy-
6315 TEMPLATE_VBoxR3DllNonPedanticFast_CXXFLAGS.debug = $(filter-out -RTC%, $(TEMPLATE_VBoxR3DllNonPedantic_CXXFLAGS.debug))
6316 TEMPLATE_VBoxR3DllNonPedanticFast_PCHFLAGS = $(filter-out -O0, $(TEMPLATE_VBoxR3DllNonPedantic_PCHFLAGS)) -O2 -Oy-
6317 TEMPLATE_VBoxR3DllNonPedanticFast_PCHFLAGS.debug = $(filter-out -RTC%, $(TEMPLATE_VBoxR3DllNonPedantic_PCHFLAGS.debug))
6318 else
6319 TEMPLATE_VBoxR3DllNonPedanticFast_CFLAGS = $(TEMPLATE_VBoxR3DllNonPedantic_CFLAGS) -O2 -fno-omit-frame-pointer
6320 TEMPLATE_VBoxR3DllNonPedanticFast_CXXFLAGS = $(TEMPLATE_VBoxR3DllNonPedantic_CXXFLAGS) -O2 -fno-omit-frame-pointer
6321 TEMPLATE_VBoxR3DllNonPedanticFast_PCHFLAGS = $(TEMPLATE_VBoxR3DllNonPedantic_PCHFLAGS) -O2 -fno-omit-frame-pointer
6322 endif
6323endif
6324
6325
6326#
6327# Template for building libraries that are linked into VBoxRT.dll
6328# and it's variations, pedantic variation.
6329#
6330TEMPLATE_VBoxR3RuntimeDll = For libraries that are linked into VBoxRT.
6331TEMPLATE_VBoxR3RuntimeDll_EXTENDS = VBoxR3Dll
6332if defined(VBOX_WITH_MORE_NT4_COMPAT_BINARIES) && "$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)" == "win.x86"
6333 TEMPLATE_VBoxR3RuntimeDll_CFLAGS = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBoxR3Dll_CFLAGS)) -MT$(VBOX_VCC_CRT_TYPE)
6334 TEMPLATE_VBoxR3RuntimeDll_CXXFLAGS = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBoxR3Dll_CXXFLAGS)) -MT$(VBOX_VCC_CRT_TYPE)
6335 TEMPLATE_VBoxR3RuntimeDll_PCHFLAGS = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBoxR3Dll_PCHFLAGS)) -MT$(VBOX_VCC_CRT_TYPE)
6336 TEMPLATE_VBoxR3RuntimeDll_LIBS.x86 = $(filter-out $(PATH_TOOL_$(TEMPLATE_VBOXR3EXE_TOOL.win.x86)_LIB)/%, $(TEMPLATE_VBoxR3Dll_LIBS.x86)) \
6337 $(PATH_TOOL_$(TEMPLATE_VBoxR3RuntimeDll_TOOL.win.x86)_LIB)/oldnames.lib \
6338 $(PATH_TOOL_$(TEMPLATE_VBoxR3RuntimeDll_TOOL.win.x86)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
6339 $(PATH_TOOL_$(TEMPLATE_VBoxR3RuntimeDll_TOOL.win.x86)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib
6340endif
6341
6342#
6343# Template for building libraries that are linked into VBoxRT.dll
6344# and it's variations, non-pedantic variation.
6345#
6346TEMPLATE_VBoxR3RuntimeDllNonPedantic = For libraries that are linked into VBoxRT, but must be excluded from -pedantic warnings.
6347TEMPLATE_VBoxR3RuntimeDllNonPedantic_EXTENDS = VBoxR3DllNonPedantic
6348if defined(VBOX_WITH_MORE_NT4_COMPAT_BINARIES) && $(KBUILD_TARGET_ARCH) == "x86"
6349 TEMPLATE_VBoxR3RuntimeDllNonPedantic_CFLAGS = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBoxR3DllNonPedantic_CFLAGS)) -MT$(VBOX_VCC_CRT_TYPE)
6350 TEMPLATE_VBoxR3RuntimeDllNonPedantic_CXXFLAGS = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBoxR3DllNonPedantic_CXXFLAGS)) -MT$(VBOX_VCC_CRT_TYPE)
6351 TEMPLATE_VBoxR3RuntimeDllNonPedantic_PCHFLAGS = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBoxR3DllNonPedantic_PCHFLAGS)) -MT$(VBOX_VCC_CRT_TYPE)
6352endif
6353
6354#
6355# Same as VBoxR3RuntimeDllNonPedantic, only it optimized debug builds too.
6356#
6357TEMPLATE_VBoxR3RuntimeDllNonPedanticFast = For libraries that are linked into VBoxRT, but must be excluded from -pedantic warnings, optmized debug.
6358TEMPLATE_VBoxR3RuntimeDllNonPedanticFast_EXTENDS = VBoxR3RuntimeDllNonPedantic
6359ifeq ($(KBUILD_TYPE),debug)
6360 ifeq ($(KBUILD_TARGET),win)
6361 TEMPLATE_VBoxR3RuntimeDllNonPedanticFast_CFLAGS = $(filter-out -O0, $(TEMPLATE_VBoxR3RuntimeDllNonPedantic_CFLAGS)) -O2 -Oy-
6362 TEMPLATE_VBoxR3RuntimeDllNonPedanticFast_CFLAGS.debug = $(filter-out -RTC%, $(TEMPLATE_VBoxR3RuntimeDllNonPedantic_CFLAGS.debug))
6363 TEMPLATE_VBoxR3RuntimeDllNonPedanticFast_CXXFLAGS = $(filter-out -O0, $(TEMPLATE_VBoxR3RuntimeDllNonPedantic_CXXFLAGS)) -O2 -Oy-
6364 TEMPLATE_VBoxR3RuntimeDllNonPedanticFast_CXXFLAGS.debug = $(filter-out -RTC%, $(TEMPLATE_VBoxR3RuntimeDllNonPedantic_CXXFLAGS.debug))
6365 TEMPLATE_VBoxR3RuntimeDllNonPedanticFast_PCHFLAGS = $(filter-out -O0, $(TEMPLATE_VBoxR3RuntimeDllNonPedantic_PCHFLAGS)) -O2 -Oy-
6366 TEMPLATE_VBoxR3RuntimeDllNonPedanticFast_PCHFLAGS.debug = $(filter-out -RTC%, $(TEMPLATE_VBoxR3RuntimeDllNonPedantic_PCHFLAGS.debug))
6367 else
6368 TEMPLATE_VBoxR3RuntimeDllNonPedanticFast_CFLAGS = $(TEMPLATE_VBoxR3RuntimeDllNonPedantic_CFLAGS) -O2 -fno-omit-frame-pointer
6369 TEMPLATE_VBoxR3RuntimeDllNonPedanticFast_CXXFLAGS = $(TEMPLATE_VBoxR3RuntimeDllNonPedantic_CXXFLAGS) -O2 -fno-omit-frame-pointer
6370 TEMPLATE_VBoxR3RuntimeDllNonPedanticFast_PCHFLAGS = $(TEMPLATE_VBoxR3RuntimeDllNonPedantic_PCHFLAGS) -O2 -fno-omit-frame-pointer
6371 endif
6372endif
6373
6374
6375#
6376# Template for building libraries, shared libraries / modules
6377# which only depends on IPRT for crt.
6378#
6379TEMPLATE_VBoxNoCrtGccLib = VBox no-crt GCC libraries and modules, yasm/nasm.
6380TEMPLATE_VBoxNoCrtGccLib_DEFS = IN_RING3 IPRT_NO_CRT $(ARCH_BITS_DEFS)
6381TEMPLATE_VBoxNoCrtGccLib_ASDEFS = ASM_CALL64_GCC
6382TEMPLATE_VBoxNoCrtGccLib_CFLAGS = -nostdinc -fno-strict-aliasing -fno-math-errno $(VBOX_GCC_WARN) -Werror-implicit-function-declaration
6383TEMPLATE_VBoxNoCrtGccLib_CFLAGS.x86 = -m32
6384TEMPLATE_VBoxNoCrtGccLib_CFLAGS.amd64 = -m64 -mcmodel=medium -fno-common
6385TEMPLATE_VBoxNoCrtGccLib_CFLAGS.sparc32 = -m32
6386TEMPLATE_VBoxNoCrtGccLib_CFLAGS.sparc64 = -m64
6387TEMPLATE_VBoxNoCrtGccLib_CFLAGS.release = -O2 -fno-strict-aliasing
6388TEMPLATE_VBoxNoCrtGccLib_CFLAGS.profile = $(TEMPLATE_VBoxNoCrtGccLib_CFLAGS.release)
6389TEMPLATE_VBoxNoCrtGccLib_CFLAGS.kprofile = $(TEMPLATE_VBoxNoCrtGccLib_CFLAGS.release)
6390TEMPLATE_VBoxNoCrtGccLib_CFLAGS.darwin = -static
6391TEMPLATE_VBoxNoCrtGccLib_CXXFLAGS = $(filter-out -Werror-implicit-function-declaration,$(TEMPLATE_VBoxNoCrtGccLib_CFLAGS))
6392TEMPLATE_VBoxNoCrtGccLib_CXXFLAGS.$(KBUILD_TARGET) = $(TEMPLATE_VBoxNoCrtGccLib_CFLAGS.$(KBUILD_TARGET))
6393TEMPLATE_VBoxNoCrtGccLib_CXXFLAGS.$(KBUILD_TARGET_ARCH) = $(TEMPLATE_VBoxNoCrtGccLib_CFLAGS.$(KBUILD_TARGET_ARCH))
6394TEMPLATE_VBoxNoCrtGccLib_PCHFLAGS = $(TEMPLATE_VBoxNoCrtGccLib_CXXFLAGS)
6395TEMPLATE_VBoxNoCrtGccLib_PCHFLAGS.$(KBUILD_TARGET) = $(TEMPLATE_VBoxNoCrtGccLib_CXXFLAGS.$(KBUILD_TARGET))
6396TEMPLATE_VBoxNoCrtGccLib_PCHFLAGS.$(KBUILD_TARGET_ARCH) = $(TEMPLATE_VBoxNoCrtGccLib_CXXFLAGS.$(KBUILD_TARGET_ARCH))
6397TEMPLATE_VBoxNoCrtGccLib_INCS = $(PATH_ROOT)/include/iprt/nocrt
6398
6399ifeq (disabled-by-mingw-w64 $(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),win.amd64)
6400 # cross compile to 64-bit ELF (linux).
6401 TEMPLATE_VBoxNoCrtGccLib_TOOL = XGCCAMD64LINUX
6402 TEMPLATE_VBoxNoCrtGccLib_ASTOOL = YASM
6403 TEMPLATE_VBoxNoCrtGccLib_ASFLAGS = -f elf64 -DASM_FORMAT_ELF -D__YASM__ -g dwarf2 -w+orphan-labels $(VBOX_YASM_Wno-segreg-in-64bit)
6404 TEMPLATE_VBoxNoCrtGccLib_LIBS = $(KBUILD_DEVTOOLS)/win.x86/x86_64-unknown-linux-gnu/20060701-r2/lib/gcc/x86_64-unknown-linux-gnu/3.4.6/libgcc.a
6405 TEMPLATE_VBoxNoCrtGccLib_LDFLAGS = -nostdlib
6406
6407else if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), win.x86 win.amd64)
6408 # Use the default GCC (MinGW) with the Microsoft linker.
6409 # (Drop all '-g' options as we're unable to strip the debug info.)
6410 TEMPLATE_VBoxNoCrtGccLib_TOOL = $(VBOX_GCC_TOOL)
6411 if $(VBOX_GCC_VERSION_CC) < 30400
6412 TEMPLATE_VBoxNoCrtGccLib_DEFS += RT_WITHOUT_PRAGMA_ONCE
6413 endif
6414 TEMPLATE_VBoxNoCrtGccLib_ASTOOL := $(VBOX_ASTOOL)
6415 TEMPLATE_VBoxNoCrtGccLib_ASFLAGS = $(VBOX_ASFLAGS)
6416 TEMPLATE_VBoxNoCrtGccLib_LDTOOL = $(VBOX_VCC_TOOL)
6417 TEMPLATE_VBoxNoCrtGccLib_LDFLAGS = -Incremental:NO -MapInfo:Exports -NoD -Ignore:4197
6418 TEMPLATE_VBoxNoCrtGccLib_LIBS = $(VBOX_GCC_LIBGCC)
6419 TEMPLATE_VBoxNoCrtGccLib_CFLAGS := $(filter-out -g,$(TEMPLATE_VBoxNoCrtGccLib_CFLAGS)) -s
6420 TEMPLATE_VBoxNoCrtGccLib_CXXFLAGS := $(filter-out -g,$(TEMPLATE_VBoxNoCrtGccLib_CXXFLAGS)) -s
6421 TEMPLATE_VBoxNoCrtGccLib_PCHFLAGS := $(filter-out -g,$(TEMPLATE_VBoxNoCrtGccLib_PCHFLAGS)) -s
6422
6423else
6424 # Use the default GCC.
6425 # The use of --exclude-libs ALL is to avoid confusing the linux ld.so.
6426 TEMPLATE_VBoxNoCrtGccLib_TOOL = $(VBOX_GCC_TOOL)
6427 if $(VBOX_GCC_VERSION_CC) < 30400
6428 TEMPLATE_VBoxNoCrtGccLib_DEFS += RT_WITHOUT_PRAGMA_ONCE
6429 endif
6430 TEMPLATE_VBoxNoCrtGccLib_ASTOOL := $(VBOX_ASTOOL)
6431 TEMPLATE_VBoxNoCrtGccLib_ASFLAGS = $(VBOX_ASFLAGS)
6432 TEMPLATE_VBoxNoCrtGccLib_CFLAGS += $(VBOX_GCC_fno-stack-protector)
6433 TEMPLATE_VBoxNoCrtGccLib_CXXFLAGS += $(VBOX_GCC_fno-stack-protector)
6434 TEMPLATE_VBoxNoCrtGccLib_PCHFLAGS += $(VBOX_GCC_fno-stack-protector)
6435 ifeq ($(KBUILD_TARGET_ARCH),amd64)
6436 # in 64-bit mode we'll build a sys-module (VBoxREM2).
6437 if1of ($(KBUILD_TARGET), darwin solaris)
6438 TEMPLATE_VBoxNoCrtGccLib_LDFLAGS.solaris= -64 -r
6439 else
6440 TEMPLATE_VBoxNoCrtGccLib_LDFLAGS = -nostdlib
6441 endif
6442 else # x86:
6443 TEMPLATE_VBoxNoCrtGccLib_LDFLAGS = -nostdlib
6444 ifn1of ($(KBUILD_TARGET), os2 darwin solaris)
6445 TEMPLATE_VBoxNoCrtGccLib_LDFLAGS += $(VBOX_GCC_NO_UNDEFINED)
6446 endif
6447 endif # x86
6448 TEMPLATE_VBoxNoCrtGccLib_LDFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_LDFLAGS) -Wl,-headerpad_max_install_names
6449 TEMPLATE_VBoxNoCrtGccLib_LIBS = # FIXME - has unwind mess.
6450endif
6451
6452
6453#
6454# Same as VBoxNoCrtGccLib only it uses GAS as the assembler instead of yasm/nasm.
6455#
6456TEMPLATE_VBOXNOCRTGAS = VBox no-crt GCC libraries and modules, gas.
6457TEMPLATE_VBOXNOCRTGAS_EXTENDS = VBoxNoCrtGccLib
6458TEMPLATE_VBOXNOCRTGAS_ASTOOL = $(TEMPLATE_VBoxNoCrtGccLib_TOOL)
6459ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),win.x86)
6460 TEMPLATE_VBOXNOCRTGAS_ASFLAGS = -s
6461else
6462 TEMPLATE_VBOXNOCRTGAS_ASFLAGS = -g
6463endif
6464TEMPLATE_VBOXNOCRTGAS_ASFLAGS.x86 = -m32
6465TEMPLATE_VBOXNOCRTGAS_ASFLAGS.amd64 = -m64
6466
6467
6468#
6469# Template for building executables that are part of the VBox Main component
6470# (COM/XPCOM interface to VirtualBox).
6471#
6472TEMPLATE_VBOXMAINEXE = VBox Main Executable
6473TEMPLATE_VBOXMAINEXE_ASTOOL := $(VBOX_ASTOOL)
6474TEMPLATE_VBOXMAINEXE_ASFLAGS = $(VBOX_ASFLAGS)
6475TEMPLATE_VBOXMAINEXE_DEFS = IN_RING3 UNICODE NDEBUG=1
6476TEMPLATE_VBOXMAINEXE_DEFS.win = _UNICODE
6477TEMPLATE_VBOXMAINEXE_RCDEFS = $(TEMPLATE_VBOXR3EXE_RCDEFS)
6478TEMPLATE_VBOXMAINEXE_LIBS.kprofile = $(LIB_KPROFILE)
6479TEMPLATE_VBOXMAINEXE_USES = dtrace
6480if defined(VBOX_WITH_DTRACE_R3_MAIN) && defined(VBOX_WITH_NATIVE_DTRACE)
6481 TEMPLATE_VBOXMAINEXE_DTRACETOOL = DTraceAndVBoxTpG
6482 TEMPLATE_VBOXMAINEXE_DTRACE_OBJ_FLAGS = -C
6483 TEMPLATE_VBOXMAINEXE_DTRACE_HDR_FLAGS = -C
6484 TEMPLATE_VBOXMAINEXE_DEFS += VBOX_WITH_DTRACE VBOX_WITH_DTRACE_R3 VBOX_WITH_DTRACE_R3_MAIN VBOX_WITH_NATIVE_DTRACE
6485else
6486 TEMPLATE_VBOXMAINEXE_DTRACE_HDR_FLAGS = --ring-3-context
6487 TEMPLATE_VBOXMAINEXE_DTRACE_OBJ_FLAGS = --ring-3-context --pic --probe-fn-imported --probe-fn-name "SUPTracerFireProbe"
6488 if defined(VBOX_WITH_DTRACE_R3_MAIN)
6489 TEMPLATE_VBOXMAINEXE_DTRACETOOL = VBoxTpG
6490 TEMPLATE_VBOXMAINEXE_DEFS += VBOX_WITH_DTRACE VBOX_WITH_DTRACE_R3 VBOX_WITH_DTRACE_R3_MAIN
6491 else
6492 TEMPLATE_VBOXMAINEXE_DTRACETOOL = VBoxTpG-Disabled
6493 endif
6494endif
6495
6496ifeq ($(KBUILD_TARGET),win)
6497 #TEMPLATE_VBOXMAINEXE_TOOL = $(VBOX_VCC_TOOL)
6498 TEMPLATE_VBOXMAINEXE_TOOL.win.x86 = $(VBOX_VCC_TOOL_STEM)X86
6499 TEMPLATE_VBOXMAINEXE_TOOL.win.amd64 = $(VBOX_VCC_TOOL_STEM)AMD64
6500 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
6501 TEMPLATE_VBOXMAINEXE_SDKS = ReorderCompilerIncs WINSDK10-UCRT $(VBOX_WINPSDK) $(VBOX_WINDDK)
6502 else
6503 TEMPLATE_VBOXMAINEXE_SDKS = ReorderCompilerIncs $(VBOX_WINPSDK) $(VBOX_WINDDK)
6504 endif
6505 TEMPLATE_VBOXMAINEXE_CXXFLAGS = -Zi -Zl -GR -EHsc -GF -MD$(VBOX_VCC_CRT_TYPE) -Zc:wchar_t- $(VBOX_VCC_OPT) $(VBOX_VCC_FP)
6506 # -wd4625: 'DisplaySourceBitmap' : copy constructor could not be generated because a base class copy constructor is inaccessible
6507 # -wd4626: 'DisplaySourceBitmap' : assignment operator could not be generated because a base class assignment operator is inaccessible
6508 # The two above can be cured by adding private: DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(xxxx); but too much work.
6509 # -wd4355: 'this' : used in base member initializer list (e.g. VirtualBoxBase.cpp)
6510 TEMPLATE_VBOXMAINEXE_CXXFLAGS += $(VBOX_VCC_WARN_ALL) -wd4625 -wd4626 -wd4355 $(VBOX_VCC_WERR)
6511 ifdef VBOX_WITH_MSC_ANALYZE_THIS
6512 TEMPLATE_VBOXMAINEXE_CXXFLAGS += /analyze
6513 endif
6514 TEMPLATE_VBOXMAINEXE_CXXFLAGS.debug = -RTCsu
6515 TEMPLATE_VBOXMAINEXE_CXXFLAGS.dbgopt = $(NO_SUCH_VARIABLE)
6516 TEMPLATE_VBOXMAINEXE_CXXFLAGS.kprofile = -Gh -GH
6517 TEMPLATE_VBOXMAINEXE_CFLAGS = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS)
6518 TEMPLATE_VBOXMAINEXE_CFLAGS.debug = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.debug)
6519 TEMPLATE_VBOXMAINEXE_CFLAGS.dbgopt = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.dbgopt)
6520 TEMPLATE_VBOXMAINEXE_CFLAGS.kprofile = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.kprofile)
6521 TEMPLATE_VBOXMAINEXE_PCHFLAGS = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS)
6522 TEMPLATE_VBOXMAINEXE_PCHFLAGS.debug = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.debug)
6523 TEMPLATE_VBOXMAINEXE_PCHFLAGS.dbgopt = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.dbgopt)
6524 TEMPLATE_VBOXMAINEXE_PCHFLAGS.kprofile = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.kprofile)
6525 TEMPLATE_VBOXMAINEXE_LDFLAGS = -Ignore:4197 \
6526 /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LargeAddressAware /DynamicBase /NxCompat /Release /Debug /Opt:Ref /Opt:Icf \
6527 /Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
6528 /STUB:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com \
6529 /DISALLOWLIB:libc.lib \
6530 /DISALLOWLIB:libcd.lib \
6531 /DISALLOWLIB:libcmt.lib \
6532 /DISALLOWLIB:libcmtd.lib \
6533 /DISALLOWLIB:msvcrt$(VBOX_VCC_CRT_TYPE_N).lib \
6534 /DISALLOWLIB:msvcprt$(VBOX_VCC_CRT_TYPE_N).lib \
6535 /DISALLOWLIB:vcruntime$(VBOX_VCC_CRT_TYPE_N).lib \
6536 /DISALLOWLIB:ucrt$(VBOX_VCC_CRT_TYPE_N).lib \
6537 /DISALLOWLIB:libvcruntime.lib \
6538 /DISALLOWLIB:libvcruntimed.lib \
6539 /DISALLOWLIB:libucrt.lib \
6540 /DISALLOWLIB:libucrtd.lib
6541 if defined(VBOX_SIGNING_MODE) && defined(VBOX_WITH_HARDENING)
6542 TEMPLATE_VBOXMAINEXE_LDFLAGS += -IntegrityCheck
6543 endif
6544 ifdef VBOX_WITH_DTRACE_R3_MAIN
6545 TEMPLATE_VBOXMAINEXE_LDFLAGS += -Merge:VTGPrLc.Data=VTGPrLc.Begin -Merge:VTGPrLc.End=VTGPrLc.Begin -Merge:VTGPrLc.Begin=VTGObj
6546 endif
6547 TEMPLATE_VBOXMAINEXE_LIBS = \
6548 $(LIB_RUNTIME)
6549 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
6550 TEMPLATE_VBOXMAINEXE_LIBS.x86 = \
6551 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.x86)_LIB)/vcruntime$(VBOX_VCC_CRT_TYPE).lib \
6552 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.x86)_LIB)/msvcrt$(VBOX_VCC_CRT_TYPE).lib \
6553 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.x86)_LIB)/msvcprt$(VBOX_VCC_CRT_TYPE).lib \
6554 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.x86)_LIB)/oldnames.lib
6555 TEMPLATE_VBOXMAINEXE_LIBS.amd64 = \
6556 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.amd64)_LIB)/vcruntime$(VBOX_VCC_CRT_TYPE).lib \
6557 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.amd64)_LIB)/msvcrt$(VBOX_VCC_CRT_TYPE).lib \
6558 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.amd64)_LIB)/msvcprt$(VBOX_VCC_CRT_TYPE).lib \
6559 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.amd64)_LIB)/oldnames.lib
6560 else
6561 TEMPLATE_VBOXMAINEXE_LIBS.x86 = \
6562 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.x86)_LIB)/msvcrt$(VBOX_VCC_CRT_TYPE).lib \
6563 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.x86)_LIB)/msvcprt$(VBOX_VCC_CRT_TYPE).lib \
6564 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.x86)_LIB)/oldnames.lib
6565 TEMPLATE_VBOXMAINEXE_LIBS.amd64 = \
6566 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.amd64)_LIB)/msvcrt$(VBOX_VCC_CRT_TYPE).lib \
6567 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.amd64)_LIB)/msvcprt$(VBOX_VCC_CRT_TYPE).lib \
6568 $(PATH_TOOL_$(TEMPLATE_VBOXMAINEXE_TOOL.win.amd64)_LIB)/oldnames.lib
6569 endif
6570 TEMPLATE_VBOXMAINEXE_POST_CMDS = $(VBOX_SIGN_IMAGE_CMDS)
6571
6572else # the GCC guys:
6573
6574TEMPLATE_VBOXMAINEXE_TOOL = $(VBOX_GCC_TOOL)
6575 if $(VBOX_GCC_VERSION_CC) < 30400
6576 TEMPLATE_VBOXMAINEXE_DEFS += RT_WITHOUT_PRAGMA_ONCE
6577 endif
6578TEMPLATE_VBOXMAINEXE_CXXFLAGS = -g $(VBOX_GCC_pipe) \
6579 $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_Wno-multistatement-macros) $(VBOX_GCC_Wno-class-memaccess) -Wshadow \
6580 -fshort-wchar -fpermissive -fexceptions -frtti $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing \
6581 $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_std) $(VBOX_GCC_IPRT_FMT_CHECK) \
6582 $(VBOX_GCC_SANITIZER_FLAGS)
6583 if !defined("VBOX_GCC_Wno-delete-non-virtual-dtor") && defined("VBOX_GCC_Wno-non-virtual-dtor")
6584 TEMPLATE_VBOXMAINEXE_CXXFLAGS += $(VBOX_GCC_Wno-non-virtual-dtor)
6585 endif
6586 ifdef VBOX_WITH_NO_GCC_WARNING_POLICY
6587 TEMPLATE_VBOXMAINEXE_CXXFLAGS += $(VBOX_GCC_WERR)
6588 endif
6589 ifdef VBOX_WITH_DTRACE_R3_MAIN
6590 TEMPLATE_VBOXMAINEXE_CXXFLAGS := $(filter-out -pedantic,$(TEMPLATE_VBOXMAINEXE_CXXFLAGS)) -fdollars-in-identifiers # annoying gcc option precedence.
6591 endif
6592TEMPLATE_VBOXMAINEXE_CXXFLAGS.x86 = -m32
6593TEMPLATE_VBOXMAINEXE_CXXFLAGS.amd64 = -m64
6594TEMPLATE_VBOXMAINEXE_CXXFLAGS.kprofile = -finstrument-functions
6595TEMPLATE_VBOXMAINEXE_CFLAGS = -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_C) $(VBOX_GCC_Wno-variadic-macros) \
6596 $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_IPRT_FMT_CHECK) \
6597 $(VBOX_GCC_SANITIZER_FLAGS)
6598 ifdef VBOX_WITH_NO_GCC_WARNING_POLICY
6599 TEMPLATE_VBOXMAINEXE_CFLAGS += $(VBOX_GCC_WERR)
6600 endif
6601TEMPLATE_VBOXMAINEXE_CFLAGS.x86 = -m32
6602TEMPLATE_VBOXMAINEXE_CFLAGS.amd64 = -m64
6603TEMPLATE_VBOXMAINEXE_CFLAGS.kprofile = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.kprofile)
6604TEMPLATE_VBOXMAINEXE_CFLAGS.debug = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.debug)
6605TEMPLATE_VBOXMAINEXE_OBJCFLAGS = $(TEMPLATE_VBOXMAINEXE_CFLAGS)
6606TEMPLATE_VBOXMAINEXE_OBJCFLAGS.x86 = $(TEMPLATE_VBOXMAINEXE_CFLAGS.x86)
6607TEMPLATE_VBOXMAINEXE_OBJCFLAGS.amd64 = $(TEMPLATE_VBOXMAINEXE_CFLAGS.amd64)
6608TEMPLATE_VBOXMAINEXE_OBJCFLAGS.debug = $(TEMPLATE_VBOXMAINEXE_CFLAGS.debug)
6609TEMPLATE_VBOXMAINEXE_OBJCFLAGS.kprofile = $(TEMPLATE_VBOXMAINEXE_CFLAGS.kprofile)
6610TEMPLATE_VBOXMAINEXE_OBJCXXFLAGS = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS)
6611TEMPLATE_VBOXMAINEXE_OBJCXXFLAGS.x86 = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.x86)
6612TEMPLATE_VBOXMAINEXE_OBJCXXFLAGS.amd64 = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.amd64)
6613TEMPLATE_VBOXMAINEXE_OBJCXXFLAGS.debug = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.debug)
6614TEMPLATE_VBOXMAINEXE_OBJCXXFLAGS.kprofile= $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.kprofile)
6615TEMPLATE_VBOXMAINEXE_PCHFLAGS = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS)
6616TEMPLATE_VBOXMAINEXE_PCHFLAGS.x86 = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.x86)
6617TEMPLATE_VBOXMAINEXE_PCHFLAGS.amd64 = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.amd64)
6618TEMPLATE_VBOXMAINEXE_PCHFLAGS.debug = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.debug)
6619TEMPLATE_VBOXMAINEXE_PCHFLAGS.kprofile = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.kprofile)
6620TEMPLATE_VBOXMAINEXE_LDFLAGS = $(VBOX_GCC_SANITIZER_FLAGS) $(VBOX_GCC_SANITIZER_LDFLAGS)
6621TEMPLATE_VBOXMAINEXE_LDFLAGS.x86 = -m32
6622TEMPLATE_VBOXMAINEXE_LDFLAGS.amd64 = -m64
6623 ifeq ($(KBUILD_TARGET),linux)
6624TEMPLATE_VBOXMAINEXE_LIBS = pthread m rt $(LIB_RUNTIME) dl
6625TEMPLATE_VBOXMAINEXE_LDFLAGS.linux = -Wl,-z,noexecstack,-z,relro $(VBOX_LD_as_needed)
6626 else ifeq ($(KBUILD_TARGET),os2)
6627TEMPLATE_VBOXMAINEXE_TOOL = GXX3OMF
6628TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME)
6629 else ifeq ($(KBUILD_TARGET),darwin)
6630TEMPLATE_VBOXMAINEXE_TOOL = $(VBOX_GCC_TOOL)
6631TEMPLATE_VBOXMAINEXE_SDKS += $(VBOX_DARWIN_DEF_SDK_SDKS)
6632TEMPLATE_VBOXMAINEXE_DEFS += $(VBOX_DARWIN_DEF_SDK_DEFS)
6633TEMPLATE_VBOXMAINEXE_CFLAGS += $(VBOX_DARWIN_DEF_SDK_CFLAGS)
6634TEMPLATE_VBOXMAINEXE_CXXFLAGS += $(VBOX_DARWIN_DEF_SDK_CXXFLAGS)
6635TEMPLATE_VBOXMAINEXE_OBJCFLAGS += $(VBOX_DARWIN_DEF_SDK_OBJCFLAGS)
6636TEMPLATE_VBOXMAINEXE_OBJCXXFLAGS += $(VBOX_DARWIN_DEF_SDK_OBJCXXFLAGS)
6637TEMPLATE_VBOXMAINEXE_LDFLAGS.darwin += -bind_at_load
6638TEMPLATE_VBOXMAINEXE_LDFLAGS += $(VBOX_DARWIN_DEF_SDK_LDFLAGS) -framework Carbon -Wl,-headerpad_max_install_names
6639TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME)
6640 else ifeq ($(KBUILD_TARGET),haiku)
6641TEMPLATE_VBOXMAINEXE_TOOL = GXX3
6642TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME) network stdc++ supc++
6643 else if1of ($(KBUILD_TARGET), freebsd openbsd)
6644TEMPLATE_VBOXMAINEXE_TOOL = GXX3
6645TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME)
6646TEMPLATE_VBOXMAINEXE_INCS += \
6647 /usr/include \
6648 /usr/X11R6/include \
6649 /usr/local/include
6650TEMPLATE_VBOXMAINEXE_LIBPATH += \
6651 /usr/lib \
6652 /usr/X11R6/lib \
6653 /usr/local/lib
6654 else ifeq ($(KBUILD_TARGET),netbsd)
6655TEMPLATE_VBOXMAINEXE_TOOL = GXX3
6656TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME)
6657TEMPLATE_VBOXMAINEXE_INCS += \
6658 /usr/include \
6659 /usr/X11R7/include
6660TEMPLATE_VBOXMAINEXE_LIBPATH += \
6661 /usr/lib \
6662 /usr/X11R7/lib
6663else ifeq ($(KBUILD_TARGET),solaris)
6664TEMPLATE_VBOXMAINEXE_TOOL = GXX3PLAIN
6665TEMPLATE_VBOXMAINEXE_DEFS += _REENTRANT
6666TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME) rt thread
6667 else
6668$(warning Warning: VBOX Build: Target $(KBUILD_TARGET) is not officially supported!)
6669TEMPLATE_VBOXMAINEXE_LIBS =
6670 endif
6671TEMPLATE_VBOXMAINEXE_LDFLAGS.solaris = -Wl,-z,ignore # Same as VBOX_LD_as_needed.
6672 ifdef VBOX_WITH_RUNPATH
6673TEMPLATE_VBOXMAINEXE_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)'
6674 else ifdef VBOX_WITH_RELATIVE_RUNPATH
6675TEMPLATE_VBOXMAINEXE_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)'
6676 endif
6677 ifdef VBOX_WITH_ORIGIN
6678TEMPLATE_VBOXMAINEXE_LDFLAGS.linux += $(VBOX_GCC_ORIGIN_OPT)
6679 endif
6680
6681endif # !win
6682
6683# Add COM/XPCOM stuff
6684TEMPLATE_VBOXMAINEXE_LIBS += \
6685 $(PATH_STAGE_LIB)/VBoxCOM$(VBOX_SUFF_LIB)
6686ifdef VBOX_WITH_XPCOM
6687 ## @todo may be worth creating the VBOX_XPCOM SDK def
6688 TEMPLATE_VBOXMAINEXE_DEFS += VBOX_WITH_XPCOM
6689 ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
6690 TEMPLATE_VBOXMAINEXE_DEFS += VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
6691 endif
6692 TEMPLATE_VBOXMAINEXE_INCS += \
6693 $(VBOX_XPCOM_INCS)
6694 TEMPLATE_VBOXMAINEXE_LIBS += \
6695 $(LIB_XPCOM)
6696 TEMPLATE_VBOXMAINEXE_INTERMEDIATES += \
6697 $(VBOX_PATH_SDK)/bindings/xpcom/include/VirtualBox_XPCOM.h
6698
6699else # COM
6700 TEMPLATE_VBOXMAINEXE_INCS += \
6701 $(VBOX_PATH_SDK)/bindings/mscom/include
6702 TEMPLATE_VBOXMAINEXE_INTERMEDIATES += \
6703 $(VBOX_PATH_SDK)/bindings/mscom/include/VirtualBox.h
6704endif # COM
6705
6706#
6707# Template for building the Main DLL modules (such as in-process COM/XPCOM
6708# components for Main).
6709#
6710# This differs from VBOXMAINEXE only in PIC handling and similar DLL stuff.
6711#
6712TEMPLATE_VBOXMAINDLL = VBox Main Component (shared library)
6713TEMPLATE_VBOXMAINDLL_EXTENDS = VBOXMAINEXE
6714ifn1of ($(KBUILD_TARGET), darwin haiku os2 win)
6715 TEMPLATE_VBOXMAINDLL_DEFS = PIC $(TEMPLATE_VBOXMAINEXE_DEFS)
6716 TEMPLATE_VBOXMAINDLL_CFLAGS = -fPIC $(TEMPLATE_VBOXMAINEXE_CFLAGS)
6717 TEMPLATE_VBOXMAINDLL_CXXFLAGS = -fPIC $(TEMPLATE_VBOXMAINEXE_CXXFLAGS)
6718 TEMPLATE_VBOXMAINDLL_PCHFLAGS = -fPIC $(TEMPLATE_VBOXMAINEXE_PCHFLAGS)
6719 TEMPLATE_VBOXMAINDLL_LDFLAGS = -fPIC $(TEMPLATE_VBOXMAINEXE_LDFLAGS)
6720endif
6721TEMPLATE_VBOXMAINDLL_LDFLAGS.darwin = $(filter-out -bind_at_load,$(TEMPLATE_VBOXMAINEXE_LDFLAGS.darwin)) \
6722 -current_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
6723 -compatibility_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD)
6724
6725#
6726# Template identical to VBOXMAINDLL except for where the stuff is
6727# installed when using XPCOM (components/).
6728#
6729# Note! In the hardened build this gets a bit ugly since $ORIGIN/..
6730# doesn't work. So, we keep the $ORIGIN from VBOXMAINEXE and let
6731# the installers do the necessary .so symlinking.
6732#
6733# (No difference when building against COM on Windows.)
6734#
6735TEMPLATE_VBOXMAINCOMP = VBox Main COM/XPCOM Component (shared library)
6736TEMPLATE_VBOXMAINCOMP_EXTENDS = VBOXMAINEXE
6737ifn1of ($(KBUILD_TARGET), win)
6738 TEMPLATE_VBOXMAINCOMP_INST = $(INST_BIN)components/
6739endif
6740ifneq ($(KBUILD_TARGET),win)
6741 ifeq ($(filter-out solaris.x86 %.amd64 %.sparc32 %.sparc64,$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),) ## TODO: cleanup!
6742 TEMPLATE_VBOXMAINCOMP_DEFS = PIC $(TEMPLATE_VBOXMAINEXE_DEFS)
6743 TEMPLATE_VBOXMAINCOMP_CFLAGS = -fPIC $(TEMPLATE_VBOXMAINEXE_CFLAGS)
6744 TEMPLATE_VBOXMAINCOMP_CXXFLAGS = -fPIC $(TEMPLATE_VBOXMAINEXE_CXXFLAGS)
6745 TEMPLATE_VBOXMAINCOMP_PCHFLAGS = -fPIC $(TEMPLATE_VBOXMAINEXE_PCHFLAGS)
6746 if defined(VBOX_WITH_RELATIVE_RUNPATH) && !defined(VBOX_WITH_HARDENING)
6747 TEMPLATE_VBOXMAINCOMP_LDFLAGS = -fPIC $(filter-out '$(VBOX_GCC_RPATH_OPT)%',$(TEMPLATE_VBOXMAINEXE_LDFLAGS)) '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)/..'
6748 else
6749 TEMPLATE_VBOXMAINCOMP_LDFLAGS = -fPIC $(TEMPLATE_VBOXMAINEXE_LDFLAGS)
6750 endif
6751 else ifndef VBOX_WITH_HARDENING
6752 ifdef VBOX_WITH_RELATIVE_RUNPATH
6753 TEMPLATE_VBOXMAINCOMP_LDFLAGS = $(filter-out '$(VBOX_GCC_RPATH_OPT)%',$(TEMPLATE_VBOXMAINEXE_LDFLAGS)) '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)/..'
6754 endif
6755 endif
6756endif
6757TEMPLATE_VBOXMAINCOMP_LDFLAGS.darwin = $(filter-out -bind_at_load,$(TEMPLATE_VBOXMAINEXE_LDFLAGS.darwin)) \
6758 -current_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
6759 -compatibility_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD)
6760
6761TEMPLATE_VBoxMainComp-x86 = 32-bit VBox Main Component (shared library)
6762TEMPLATE_VBoxMainComp-x86_EXTENDS = VBOXMAINCOMP
6763TEMPLATE_VBoxMainComp-x86_BLD_TRG_ARCH = x86
6764TEMPLATE_VBoxMainComp-x86_INST.win = $(INST_DLL)x86/
6765TEMPLATE_VBoxMainComp-x86_DEFS = $(filter-out HC_ARCH_BITS%,$(TEMPLATE_VBOXMAINCOMP_DEFS)) HC_ARCH_BIT=32 ARCH_BITS=32 \
6766 VBOX_IN_32_ON_64_MAIN_API
6767TEMPLATE_VBoxMainComp-x86_LIBS = \
6768 $(subst $(PATH_STAGE_LIB)/VBoxCOM$(VBOX_SUFF_LIB),$(PATH_STAGE_LIB)/VBoxCOM-x86$(VBOX_SUFF_LIB),\
6769 $(subst $(LIB_RUNTIME),$(VBOX_LIB_RUNTIME_X86),\
6770 $(subst $(LIB_XPCOM),$(VBOX_LIB_XPCOM_X86),\
6771 $(TEMPLATE_VBOXMAINCOMP_LIBS))))
6772ifeq ($(KBUILD_TARGET),solaris)
6773 ifdef VBOX_WITH_RUNPATH
6774 TEMPLATE_VBoxMainComp-x86_LDFLAGS = \
6775 $(filter-out '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)',$(TEMPLATE_VBOXMAINCOMP_LDFLAGS)) \
6776 '$(VBOX_GCC_RPATH_OPT)$(VBOX_PATH_APP_PRIVATE)' \
6777 '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)'
6778 endif
6779endif
6780
6781
6782#
6783# Template for building the Main static libraries.
6784#
6785# This differs from VBOXMAINDLL only that it zeroes out the _LIBS definition.
6786#
6787TEMPLATE_VBoxMainLib = VBox Main Component (static library)
6788TEMPLATE_VBoxMainLib_EXTENDS = VBOXMAINDLL
6789TEMPLATE_VBoxMainLib_LIBS =
6790
6791TEMPLATE_VBoxMainLib-x86 = 32-bit VBox Main Component (static library)
6792TEMPLATE_VBoxMainLib-x86_EXTENDS = VBoxMainLib
6793TEMPLATE_VBoxMainLib-x86_BLD_TRG_ARCH = x86
6794TEMPLATE_VBoxMainLib-x86_DEFS = $(filter-out HC_ARCH_BITS%,$(TEMPLATE_VBoxMainLib_DEFS)) HC_ARCH_BIT=32 ARCH_BITS=32 \
6795 VBOX_IN_32_ON_64_MAIN_API
6796
6797#
6798# Main unit testing, for compiling API implementation files into a testcase.
6799# This is the VBOXMAINEXE template only with a different install dir.
6800#
6801TEMPLATE_VBOXMAINTSTEXE = VBox Main Testcase Exe
6802TEMPLATE_VBOXMAINTSTEXE_EXTENDS = VBOXMAINEXE
6803TEMPLATE_VBOXMAINTSTEXE_INST = $(INST_TESTCASE)
6804ifdef VBOX_WITH_RUNPATH
6805 TEMPLATE_VBOXMAINTSTEXE_LDFLAGS = '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)' $(TEMPLATE_VBOXMAINEXE_LDFLAGS)
6806else ifdef VBOX_WITH_RELATIVE_RUNPATH
6807 TEMPLATE_VBOXMAINTSTEXE_LDFLAGS = '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)/..' $(TEMPLATE_VBOXMAINEXE_LDFLAGS)
6808endif
6809if "$(KBUILD_TARGET)" == "win" && defined(VBOX_SIGNING_MODE)
6810 TEMPLATE_VBOXMAINTSTEXE_POST_CMDS =
6811endif
6812
6813#
6814# Template for building executables that use the VBox Main component.
6815#
6816TEMPLATE_VBOXMAINCLIENTEXE = VBox Main Client (executable)
6817TEMPLATE_VBOXMAINCLIENTEXE_EXTENDS = VBOXMAINEXE
6818ifeq ($(KBUILD_TARGET),win)
6819 TEMPLATE_VBOXMAINCLIENTEXE_DEPS = $(VBOX_PATH_SDK)/bindings/mscom/include/VirtualBox.h
6820 TEMPLATE_VBOXMAINCLIENTEXE_LIBS.win = $(TEMPLATE_VBOXMAINEXE_LIBS.win) \
6821 $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/User32.Lib \
6822 $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/Shell32.Lib \
6823 $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/ShLwApi.Lib \
6824 $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/Ole32.Lib \
6825 $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/OleAut32.Lib \
6826 $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/Uuid.Lib
6827else
6828 TEMPLATE_VBOXMAINCLIENTEXE_DEPS = $(VBOX_PATH_SDK)/bindings/xpcom/include/VirtualBox_XPCOM.h
6829 TEMPLATE_VBOXMAINCLIENTEXE_DEFS = $(TEMPLATE_VBOXMAINEXE_DEFS) \
6830 NDEBUG TRIMMED
6831 TEMPLATE_VBOXMAINCLIENTEXE_CXXFLAGS.linux = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.linux) -pthread
6832 TEMPLATE_VBOXMAINCLIENTEXE_PCHFLAGS.linux = $(TEMPLATE_VBOXMAINEXE_PCHFLAGS.linux) -pthread
6833endif
6834
6835#
6836# Template for building shared libraries / DLLs that use the VBox Main component.
6837#
6838# This differs from VBOXMAINCLIENTEXE only in PIC handling and similar DLL stuff.
6839#
6840TEMPLATE_VBOXMAINCLIENTDLL = VBox MAIN Client (shared library)
6841TEMPLATE_VBOXMAINCLIENTDLL_EXTENDS = VBOXMAINCLIENTEXE
6842ifn1of ($(KBUILD_TARGET), darwin os2 win)
6843 TEMPLATE_VBOXMAINCLIENTDLL_DEFS = PIC $(TEMPLATE_VBOXMAINCLIENTEXE_DEFS)
6844 TEMPLATE_VBOXMAINCLIENTDLL_CFLAGS = -fPIC $(TEMPLATE_VBOXMAINCLIENTEXE_CFLAGS)
6845 TEMPLATE_VBOXMAINCLIENTDLL_CXXFLAGS = -fPIC $(TEMPLATE_VBOXMAINCLIENTEXE_CXXFLAGS)
6846 TEMPLATE_VBOXMAINCLIENTDLL_PCHFLAGS = -fPIC $(TEMPLATE_VBOXMAINCLIENTEXE_PCHFLAGS)
6847 TEMPLATE_VBOXMAINCLIENTDLL_LDFLAGS = -fPIC $(TEMPLATE_VBOXMAINCLIENTEXE_LDFLAGS)
6848endif
6849TEMPLATE_VBOXMAINCLIENTDLL_LDFLAGS.darwin = $(filter-out -bind_at_load,$(TEMPLATE_VBOXMAINCLIENTEXE_LDFLAGS.darwin))
6850
6851#
6852# Template for building testcases which are API clients.
6853#
6854TEMPLATE_VBOXMAINCLIENTTSTEXE = VBox Main Client Testcase (executable)
6855TEMPLATE_VBOXMAINCLIENTTSTEXE_EXTENDS = VBOXMAINCLIENTEXE
6856TEMPLATE_VBOXMAINCLIENTTSTEXE_INST = $(INST_TESTCASE)
6857ifdef VBOX_WITH_RUNPATH
6858 TEMPLATE_VBOXMAINCLIENTTSTEXE_LDFLAGS = '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)' $(TEMPLATE_VBOXMAINCLIENTEXE_LDFLAGS)
6859else ifdef VBOX_WITH_RELATIVE_RUNPATH
6860 TEMPLATE_VBOXMAINCLIENTTSTEXE_LDFLAGS = '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)/..' $(TEMPLATE_VBOXMAINCLIENTEXE_LDFLAGS)
6861endif
6862if "$(KBUILD_TARGET)" == "win" && defined(VBOX_SIGNING_MODE)
6863 TEMPLATE_VBOXMAINCLIENTTSTEXE_POST_CMDS =
6864endif
6865
6866
6867
6868#
6869# Templates used for building the extension packs.
6870#
6871ifdef VBOX_WITH_EXTPACK
6872 # Base templates (native or portable).
6873 TEMPLATE_VBoxR3ExtPack = For the ring-3 context extension pack modules.
6874 if 1 # Native for now.
6875 TEMPLATE_VBoxR3ExtPack_EXTENDS = VBOXR3DLLNOXCPT
6876 TEMPLATE_VBoxR3ExtPack_DEFS = $(TEMPLATE_VBOXR3DLLNOXCPT_DEFS) VBOX_IN_EXTPACK VBOX_IN_EXTPACK_R3
6877 else
6878 TEMPLATE_VBoxR3ExtPack_EXTENDS = VBoxNoCrtGccLib
6879 TEMPLATE_VBoxR3ExtPack_DEFS = $(TEMPLATE_VBoxNoCrtGccLib_DEFS) VBOX_IN_EXTPACK VBOX_IN_EXTPACK_R3 IPRT_NO_CRT IN_RING3
6880 TEMPLATE_VBoxR3ExtPack_INCS = $(PATH_ROOT)/include/iprt/nocrt $(TEMPLATE_VBOXR3DLLNOXCPT_INCS)
6881 endif
6882 ifneq ($(KBUILD_TARGET),win)
6883 TEMPLATE_VBoxR3ExtPack_CXXFLAGS = $(TEMPLATE_VBOXR3DLLNOXCPT_CXXFLAGS) -fno-rtti
6884 TEMPLATE_VBoxR3ExtPack_PCHFLAGS = $(TEMPLATE_VBOXR3DLLNOXCPT_PCHFLAGS) -fno-rtti
6885 endif
6886 TEMPLATE_VBoxR3ExtPack_INST = $(INST_EXTPACK)YouShallOverrideThis/
6887 ifeq ($(KBUILD_TARGET),linux)
6888 TEMPLATE_VBoxR3ExtPack_LDFLAGS = $(filter-out '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)' '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)', $(TEMPLATE_VBOXR3DLLNOXCPT_LDFLAGS))
6889 else if !defined(VBOX_WITH_RUNPATH) && defined(VBOX_WITH_RELATIVE_RUNPATH)
6890 TEMPLATE_VBoxR3ExtPack_LDFLAGS = '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)/../../..' $(filter-out '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)', $(TEMPLATE_VBOXR3DLLNOXCPT_LDFLAGS))
6891 endif
6892 ifdef VBOX_ONLY_EXTPACKS_USE_IMPLIBS
6893 if1of ($(KBUILD_TARGET), win os2)
6894 TEMPLATE_VBoxR3ExtPack_LIBS = \
6895 $(TEMPLATE_LIBS_VBOXR3) \
6896 $(if-expr "$(VBOX_LIB_VMM_LAZY)" == "$(LIB_VMM)", $(PATH_STAGE_LIB)/VMMR3Imp$(VBOX_SUFF_LIB), $(VBOX_LIB_VMM_LAZY)) \
6897 $(PATH_STAGE_LIB)/VBoxRTImp$(VBOX_SUFF_LIB)
6898 else
6899 TEMPLATE_VBoxR3ExtPack_LIBS = \
6900 $(TEMPLATE_LIBS_VBOXR3) \
6901 $(if-expr "$(VBOX_LIB_VMM_LAZY)" == "$(LIB_VMM)", $(PATH_STAGE_LIB)/VMMR3Imp$(VBOX_SUFF_DLL), $(VBOX_LIB_VMM_LAZY)) \
6902 $(PATH_STAGE_LIB)/VBoxRTImp$(VBOX_SUFF_DLL)
6903 endif
6904 else
6905 TEMPLATE_VBoxR3ExtPack_LIBS = \
6906 $(TEMPLATE_LIBS_VBOXR3) \
6907 $(LIB_RUNTIME) \
6908 $(VBOX_LIB_VMM_LAZY)
6909 endif
6910 ifeq ($(KBUILD_TARGET),darwin)
6911 TEMPLATE_VBoxR3ExtPack_POST_CMDS = $(VBOX_SIGN_EXTPACK_DYLIB_CMDS)
6912 endif
6913
6914 TEMPLATE_VBoxR3ExtPackApi = For the ring-3 context extension pack modules using the Main API.
6915 TEMPLATE_VBoxR3ExtPackApi_EXTENDS = VBOXMAINDLL
6916 TEMPLATE_VBoxR3ExtPackApi_DEFS = $(TEMPLATE_VBOXMAINDLL_DEFS) VBOX_IN_EXTPACK VBOX_IN_EXTPACK_R3
6917 TEMPLATE_VBoxR3ExtPackApi_INST = $(INST_EXTPACK)YouShallOverrideThis/
6918 ifeq ($(KBUILD_TARGET),linux)
6919 TEMPLATE_VBoxR3ExtPackApi_LDFLAGS = $(filter-out '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)' '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)', $(TEMPLATE_VBOXMAINDLL_LDFLAGS))
6920 else if !defined(VBOX_WITH_RUNPATH) && defined(VBOX_WITH_RELATIVE_RUNPATH)
6921 TEMPLATE_VBoxR3ExtPackApi_LDFLAGS = '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)/../../..' $(filter-out '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)', $(TEMPLATE_VBOXMAINDLL_LDFLAGS))
6922 endif
6923 ifdef VBOX_ONLY_EXTPACKS_USE_IMPLIBS
6924 if1of ($(KBUILD_TARGET), win os2)
6925 TEMPLATE_VBoxR3ExtPackApi_LIBS = \
6926 $(TEMPLATE_LIBS_VBOXR3) \
6927 $(if-expr "$(VBOX_LIB_VMM_LAZY)" == "$(LIB_VMM)", $(PATH_STAGE_LIB)/VMMR3Imp$(VBOX_SUFF_LIB), $(VBOX_LIB_VMM_LAZY)) \
6928 $(PATH_STAGE_LIB)/VBoxRTImp$(VBOX_SUFF_LIB)
6929 else
6930 TEMPLATE_VBoxR3ExtPackApi_LIBS = \
6931 $(TEMPLATE_LIBS_VBOXR3) \
6932 $(if-expr "$(VBOX_LIB_VMM_LAZY)" == "$(LIB_VMM)", $(PATH_STAGE_LIB)/VMMR3Imp$(VBOX_SUFF_DLL), $(VBOX_LIB_VMM_LAZY)) \
6933 $(PATH_STAGE_LIB)/VBoxRTImp$(VBOX_SUFF_DLL)
6934 endif
6935 else
6936 TEMPLATE_VBoxR3ExtPackApi_LIBS = \
6937 $(TEMPLATE_LIBS_VBOXR3) \
6938 $(LIB_RUNTIME) \
6939 $(VBOX_LIB_VMM_LAZY)
6940 endif
6941 ifeq ($(KBUILD_TARGET),darwin)
6942 TEMPLATE_VBoxR3ExtPackApi_POST_CMDS = $(VBOX_SIGN_EXTPACK_DYLIB_CMDS)
6943 endif
6944
6945 TEMPLATE_VBoxR0ExtPack = For the ring-0 context extension pack modules.
6946 TEMPLATE_VBoxR0ExtPack_EXTENDS = VBoxR0
6947 TEMPLATE_VBoxR0ExtPack_EXTENDS_BY = appending
6948 TEMPLATE_VBoxR0ExtPack_INST = $(INST_EXTPACK)YouShallOverrideThis/
6949 TEMPLATE_VBoxR0ExtPack_DEFS = VBOX_IN_EXTPACK VBOX_IN_EXTPACK_R0
6950 if1of ($(VBOX_LDR_FMT), pe lx)
6951 TEMPLATE_VBoxR0ExtPack_LIBS = \
6952 $(PATH_STAGE_LIB)/VMMR0Imp$(VBOX_SUFF_LIB) \
6953 $(PATH_STAGE_LIB)/SUPR0$(VBOX_SUFF_LIB)
6954 endif
6955
6956 TEMPLATE_VBoxRcExtPack = For the raw-mode context extension pack modules.
6957 TEMPLATE_VBoxRcExtPack_EXTENDS = VBoxRc
6958 TEMPLATE_VBoxRcExtPack_EXTENDS_BY = appending
6959 TEMPLATE_VBoxRcExtPack_SYSSUFF = .rc
6960 TEMPLATE_VBoxRcExtPack_INST = $(INST_EXTPACK)YouShallOverrideThis/
6961 TEMPLATE_VBoxRcExtPack_DEFS = VBOX_IN_EXTPACK VBOX_IN_EXTPACK_RC
6962 if1of ($(VBOX_LDR_FMT32), pe lx)
6963 TEMPLATE_VBoxRcExtPack_LIBS = \
6964 $(PATH_STAGE_LIB)/VMMRCBuiltin$(VBOX_SUFF_LIB) \
6965 $(PATH_STAGE_LIB)/VMMRCImp$(VBOX_SUFF_LIB)
6966 endif
6967
6968 TEMPLATE_VBoxInsExtPack = For the install targets of an extension pack.
6969 TEMPLATE_VBoxInsExtPack_MODE = 0644
6970 TEMPLATE_VBoxInsExtPack_INST = $(INST_EXTPACK)YouShallOverrideThis/
6971
6972 # For each individual extension pack
6973 ifdef VBOX_WITH_EXTPACK_PUEL
6974 TEMPLATE_VBoxR3ExtPackPuel = For the ring-3 context modules in the PUEL extension pack.
6975 TEMPLATE_VBoxR3ExtPackPuel_EXTENDS = VBoxR3ExtPack
6976 TEMPLATE_VBoxR3ExtPackPuel_INST = $(INST_EXTPACK_PUEL)$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
6977 TEMPLATE_VBoxR3ExtPackPuel_DEFS = $(TEMPLATE_VBoxR3ExtPack_DEFS) VBOX_IN_PUEL_EXTPACK
6978 TEMPLATE_VBoxR3ExtPackPuel_LD_DEBUG = split
6979
6980 TEMPLATE_VBoxR3ExtPackApiPuel = For the ring-3 context modules in the PUEL extension pack.
6981 TEMPLATE_VBoxR3ExtPackApiPuel_EXTENDS = VBoxR3ExtPackApi
6982 TEMPLATE_VBoxR3ExtPackApiPuel_INST = $(INST_EXTPACK_PUEL)$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
6983 TEMPLATE_VBoxR3ExtPackApiPuel_DEFS = $(TEMPLATE_VBoxR3ExtPackApi_DEFS) VBOX_IN_PUEL_EXTPACK
6984 TEMPLATE_VBoxR3ExtPackApiPuel_LD_DEBUG = split
6985
6986 TEMPLATE_VBoxR3ExtPackPuelWithOpenSsl = For the ring-3 context modules in the PUEL extension pack using ExtPack OpenSSL.
6987 TEMPLATE_VBoxR3ExtPackPuelWithOpenSsl_EXTENDS = VBoxR3ExtPackPuel
6988 ifdef VBOX_NEED_EXTPACK_OPENSSL
6989 TEMPLATE_VBoxR3ExtPackPuelWithOpenSsl_INCS = \
6990 $(TEMPLATE_VBoxR3ExtPack_INCS) \
6991 $(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)
6992 TEMPLATE_VBoxR3ExtPackPuelWithOpenSsl_LIBS = \
6993 $(PATH_STAGE_LIB)/VBoxExtPack-libssl$(VBOX_SUFF_LIB) \
6994 $(PATH_STAGE_LIB)/VBoxExtPack-libcrypto$(VBOX_SUFF_LIB) \
6995 $(TEMPLATE_VBoxR3ExtPack_LIBS) # Must come after the two libraries or we'll pick up SSL from VBoxRT!
6996 endif
6997
6998 TEMPLATE_VBoxR0ExtPackPuel = For the ring-0 context modules in the PUEL extension pack.
6999 TEMPLATE_VBoxR0ExtPackPuel_EXTENDS = VBoxR0ExtPack
7000 TEMPLATE_VBoxR0ExtPackPuel_INST = $(INST_EXTPACK_PUEL)$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
7001 TEMPLATE_VBoxR0ExtPackPuel_DEFS = $(TEMPLATE_VBoxR0ExtPack_DEFS) VBOX_IN_PUEL_EXTPACK
7002
7003 TEMPLATE_VBoxRcExtPackPuel = For the raw-mode context modules in the PUEL extension pack.
7004 TEMPLATE_VBoxRcExtPackPuel_EXTENDS = VBoxRcExtPack
7005 TEMPLATE_VBoxRcExtPackPuel_INST = $(INST_EXTPACK_PUEL)$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/
7006 TEMPLATE_VBoxRcExtPackPuel_DEFS = $(TEMPLATE_VBoxRcExtPack_DEFS) VBOX_IN_PUEL_EXTPACK
7007
7008 TEMPLATE_VBoxInsExtPackPuel = For the install targets of an extension pack.
7009 TEMPLATE_VBoxInsExtPackPuel_EXTENDS = VBoxR0ExtPack
7010 TEMPLATE_VBoxInsExtPackPuel_INST = $(INST_EXTPACK_PUEL)
7011 endif
7012
7013endif # VBOX_WITH_EXTPACK
7014
7015
7016#
7017# Qt
7018# Qt
7019# Qt
7020#
7021if defined(VBOX_WITH_QTGUI) || defined(VBOX_WITH_NLS)
7022
7023 # Guess VBOX_WITH_ORACLE_QT
7024 ifndef VBOX_WITH_ORACLE_QT
7025 ifndef VBOX_OSE
7026 if1of ($(KBUILD_TARGET), darwin solaris win)
7027 VBOX_WITH_ORACLE_QT := 1
7028 endif
7029 endif
7030 endif
7031
7032 #
7033 # Handmade configuration of Qt - very annoying, this needs to
7034 # be cleaned up properly later some time (not important now).
7035 #
7036 ifeq ($(VBOX_PATH_QT),)
7037 ifeq ($(KBUILD_TARGET),darwin)
7038 VBOX_PATH_QT := $(lastword $(sort $(wildcard $(KBUILD_DEVTOOLS_TRG)/qt/v5*)))
7039 ifeq ($(VBOX_PATH_QT),)
7040 ifneq ($(wildcard /Library/Frameworks/QtCore.framework),)
7041 # Using the global installation (for OSE).
7042 VBOX_PATH_QT ?= /usr
7043 VBOX_PATH_QT_FRAMEWORKS ?= /Library/Frameworks
7044 endif
7045 endif
7046 else if1of ($(KBUILD_TARGET), win)
7047 VBOX_PATH_QT := $(rsort $(wildcard $(KBUILD_DEVTOOLS_TRG)/qt/v5*))
7048 VBOX_PATH_QT := $(firstword $(filter %-$(tolower $(VBOX_VCC_TOOL_STEM)),$(VBOX_PATH_QT)) \
7049 $(filter-out %-vcc100 %-vcc110 %-vcc120 %-vcc140 %-vcc141 %-vcc142 %-vcc143 %-vcc150, $(VBOX_PATH_QT)))
7050 ifdef VBOX_PATH_QT
7051 PATH_SDK_QT5 := $(VBOX_PATH_QT)
7052 PATH_TOOL_QT5 := $(VBOX_PATH_QT)
7053 endif
7054 else if1of ($(KBUILD_TARGET), linux solaris)
7055 VBOX_PATH_QT ?= $(lastword $(sort $(wildcard $(KBUILD_DEVTOOLS_TRG)/qt/v5*)))
7056 ifneq ($(VBOX_PATH_QT),)
7057 VBOX_WITH_ORACLE_QT = 1
7058 endif
7059 endif
7060 endif
7061 ifeq ($(VBOX_PATH_QT),)
7062 if1of ($(USERNAME), bird)
7063 # gentoo (64-bit)
7064 VBOX_PATH_QT ?= /usr
7065 VBOX_PATH_QT_LIB ?= /usr/lib/qt5
7066 endif
7067 endif
7068 VBOX_PATH_QT ?= /usr
7069 VBOX_PATH_QT_LIB ?= $(VBOX_PATH_QT)/lib
7070
7071 ifdef VBOX_WITH_ORACLE_QT
7072 VBOX_QT_INFIX=VBox
7073 endif
7074
7075 ifeq ($(KBUILD_TARGET), darwin)
7076 VBOX_QT_MOD = QtCore QtGui QtWidgets QtPrintSupport QtMacExtras $(if $(VBOX_GUI_USE_QGL),QtOpenGL,)
7077 else if1of ($(KBUILD_TARGET), linux freebsd netbsd openbsd solaris win)
7078 VBOX_QT_MOD += Qt5Core Qt5Gui Qt5Widgets Qt5PrintSupport $(if $(VBOX_GUI_USE_QGL),Qt5OpenGL,)
7079 if1of ($(KBUILD_TARGET), linux freebsd netbsd openbsd solaris)
7080 VBOX_QT_MOD += Qt5DBus Qt5Xml Qt5XcbQpa Qt5X11Extras
7081 VBOX_QT_PLUGINS = \
7082 plugins/platforms/libqxcb.so \
7083 plugins/platformthemes/libqgtk2.so \
7084 plugins/platformthemes/libqgtk3.so \
7085 plugins/sqldrivers/libqsqlite.so \
7086 plugins/styles/libqgtk2style.so \
7087 plugins/xcbglintegrations/libqxcb-glx-integration.so
7088 else ifeq ($(KBUILD_TARGET), win)
7089 VBOX_QT_MOD += Qt5WinExtras
7090 endif # win
7091 endif # linux freebsd netbsd openbsd solaris win
7092
7093 ifdef VBOX_WITH_QHELP_VIEWER
7094 ifeq ($(KBUILD_TARGET), darwin)
7095 VBOX_QT_MOD += QtHelp QtNetwork QtSql
7096 else if1of ($(KBUILD_TARGET), linux freebsd netbsd openbsd solaris win)
7097 VBOX_QT_MOD += Qt5Help Qt5Network Qt5Sql
7098 endif
7099 endif
7100
7101 VBOX_QT_MOD_NAMES = $(foreach qtmod,$(VBOX_QT_MOD),$(qtmod)$(VBOX_QT_INFIX))
7102
7103 # Hack LD_LIBRARY_PATH for stuff in tools.
7104 ifdef VBOX_WITH_ORACLE_QT
7105 if1of ($(KBUILD_TARGET), linux solaris)
7106 export LD_LIBRARY_PATH := $(VBOX_PATH_QT_LIB):$(LD_LIBRARY_PATH)
7107 endif
7108 endif
7109
7110 # WORKAROUND:
7111 # Both files included automatically, 1st include is included from 2nd one,
7112 # but moc can't include it due to problem with parsing framework structure,
7113 # as a result QT_VERSION can't be calculated and it's not only used in our
7114 # GUI but by the moc itself to parse modern signal/slot definitions.
7115 # We were hardcoding QT_VERSION for TEMPLATE_VBOXQTGUIEXE below for quite
7116 # a long, but this have to end. Instead we can pass both includes manually.
7117 TOOL_QT5_MOCFLAGS.darwin += --include qconfig.h --include qglobal.h
7118endif # defined(VBOX_WITH_QTGUI) || defined(VBOX_WITH_NLS)
7119
7120ifdef VBOX_WITH_QTGUI
7121 #
7122 # Template for building Qt GUI executables.
7123 #
7124 TEMPLATE_VBOXQTGUIEXE = VBox Qt GUI Executable
7125 TEMPLATE_VBOXQTGUIEXE_USES = qt5
7126 TEMPLATE_VBOXQTGUIEXE_QTTOOL = QT5
7127 TEMPLATE_VBOXQTGUIEXE_MOCTOOL = QT5
7128 TEMPLATE_VBOXQTGUIEXE_UICTOOL = QT5
7129 TEMPLATE_VBOXQTGUIEXE_RCCTOOL = QT5
7130 TEMPLATE_VBOXQTGUIEXE_LRCTOOL = QT5
7131 TEMPLATE_VBOXQTGUIEXE_SDKS = QT5
7132 TEMPLATE_VBOXQTGUIEXE_QT_INFIX = $(VBOX_QT_INFIX)
7133 TEMPLATE_VBOXQTGUIEXE_DEFS = IN_RING3 QT_NO_DEBUG QT_THREAD_SUPPORT QT_SHARED HAVE_CONFIG_H $(ARCH_BITS_DEFS)
7134 TEMPLATE_VBOXQTGUIEXE_RCDEFS = $(TEMPLATE_VBOXR3EXE_RCDEFS)
7135
7136 ifeq ($(KBUILD_TARGET),win)
7137 # Note! No use of VBOX_VCC_CRT_TYPE here yet as it requires a /MDd build of Qt as well.
7138 TEMPLATE_VBOXQTGUIEXE_TOOL = $(VBOX_VCC_TOOL)
7139 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
7140 TEMPLATE_VBOXQTGUIEXE_SDKS = WINSDK10-UCRT
7141 endif
7142 TEMPLATE_VBOXQTGUIEXE_DEFS += \
7143 _WIN32_WINNT=0x0500 UNICODE _UNICODE \
7144 QT_DLL _CRT_SECURE_NO_DEPRECATE \
7145 $(QMAKE_PRL_DEFINES)
7146 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS = -nologo -Zm200 -MD -Zi -EHsc -Zc:wchar_t-
7147 # -wd4481: nonstandard extension used: override specifier 'override'
7148 # -wd4625: 'QRubberBand' : copy constructor could not be generated because a base class copy constructor is inaccessible
7149 # -wd4626: 'QRubberBand' : assignment operator could not be generated because a base class assignment operator is inaccessible
7150 # -wd4640: qmetatype.h(2210): warning C4640: 'f' : construction of local static object is not thread-safe [too bad]
7151 # -wd4350: behavior change: 'int QStringList::indexOf(const QRegExp &,int) const' called instead of 'int QStringList::indexOf(QRegExp &,int) const'
7152 # -wd4121: UIActionPool.h(393) : warning C4121: 'UIActionPool::PointerToFunction' : alignment of a member was sensitive to packing
7153 # -wd4718: qmap.h(222) : warning C4718: 'QMapNode<enum DetailsElementType,bool>::destroySubTree' : recursive call has no side effects, deleting
7154 # -wd5204: pplwin.h(78): warning C5204: 'Concurrency::details::_DefaultPPLTaskScheduler': class has virtual functions
7155 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS += $(VBOX_VCC_WARN_ALL) -wd4481 -wd4625 -wd4626 -wd4640 -wd4350 -wd4371 -wd4121 -wd4718 -wd5204 $(VBOX_VCC_WERR)
7156 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC120"
7157 # -wd4619: qvectro.h(305 : warning C4619: #pragma warning : there is no warning number '4345'
7158 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS += -wd4619
7159 endif
7160 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
7161 # -wd4774: string(530): warning C4774: '_scprintf' : format string expected in argument 1 is not a string literal
7162 # -wd4456: UICommon.cpp(1471): warning C4456: declaration of '_container_' hides previous local declaration [nested foreach]
7163 # -wd4458: UISettingsDialogSpecific.cpp(416): warning C4458: declaration of 'data' hides class member
7164 # qwidget.h(730): note: see declaration of 'QWidget::data'
7165 # -wd4946: qmap.h(213): warning C4946: reinterpret_cast used between related classes: 'QMapNodeBase' and 'QMapNode<Key,T>'
7166 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS += -wd4774 -wd4456 -wd4458 -wd4946
7167 endif
7168 ifdef VBOX_WITH_MSC_ANALYZE_THIS
7169 TEMPLATE_VBOXR0DRV_CXXFLAGS += /analyze
7170 endif
7171
7172 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.debug = -RTCsu
7173 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.debug = -RTCsu
7174 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.dbgopt = $(NO_SUCH_VARIABLE)
7175 TEMPLATE_VBOXQTGUIEXE_PCHFLAGS = $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS)
7176 TEMPLATE_VBOXQTGUIEXE_PCHFLAGS.debug = $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.debug)
7177 TEMPLATE_VBOXQTGUIEXE_PCHFLAGS.dbgopt = $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.dbgopt)
7178 TEMPLATE_VBOXQTGUIEXE_LDFLAGS = -Ignore:4197 \
7179 /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LargeAddressAware /DynamicBase /NxCompat /Release /Debug /Opt:Ref /Opt:Icf \
7180 /Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
7181 /STUB:$(PATH_ROOT)/src/VBox/HostDrivers/Support/win/winstub.com
7182 if defined(VBOX_SIGNING_MODE) && defined(VBOX_WITH_HARDENING)
7183 TEMPLATE_VBOXQTGUIEXE_LDFLAGS += -IntegrityCheck
7184 endif
7185
7186 TEMPLATE_VBOXQTGUIEXE_SDKS += $(VBOX_WINPSDK)
7187 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
7188 TEMPLATE_VBOXQTGUIEXE_LIBS = \
7189 $(VBOX_LIBS_QT) \
7190 $(LIB_RUNTIME) \
7191 $(VBOX_LIB_VMM_LAZY) \
7192 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/vcruntime.lib \
7193 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/msvcrt.lib \
7194 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/msvcprt.lib \
7195 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/oldnames.lib \
7196 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/delayimp.lib
7197 else
7198 TEMPLATE_VBOXQTGUIEXE_LIBS = \
7199 $(VBOX_LIBS_QT) \
7200 $(LIB_RUNTIME) \
7201 $(VBOX_LIB_VMM_LAZY) \
7202 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/msvcprt.lib \
7203 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/msvcrt.lib \
7204 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/oldnames.lib \
7205 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/delayimp.lib
7206 endif
7207 TEMPLATE_VBOXQTGUIEXE_POST_CMDS = $(VBOX_SIGN_IMAGE_CMDS)
7208
7209 else # the gcc guys:
7210 TEMPLATE_VBOXQTGUIEXE_TOOL = $(VBOX_GCC_TOOL)
7211 if $(VBOX_GCC_VERSION_CC) < 30400
7212 TEMPLATE_VBOXQTGUIEXE_DEFS += RT_WITHOUT_PRAGMA_ONCE
7213 endif
7214 TEMPLATE_VBOXQTGUIEXE_DEFS.linux = _REENTRANT
7215 TEMPLATE_VBOXQTGUIEXE_DEFS.solaris = _REENTRANT
7216
7217 ## @todo Use VBOX_GCC_PEDANTIC_CXX?
7218 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS = \
7219 -g $(VBOX_GCC_pipe) $(filter-out -Wno-unused $(VBOX_GCC_Wno-unused-parameter),$(VBOX_GCC_WARN)) -frtti -fno-exceptions \
7220 -Wno-long-long -fshort-wchar -fno-strict-aliasing \
7221 $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_Wno-multistatement-macros) $(VBOX_GCC_Wno-ignored-qualifiers) \
7222 $(VBOX_GCC_Wno-return-type-c-linkage) $(VBOX_GCC_std) $(VBOX_GCC_IPRT_FMT_CHECK) $(VBOX_GCC_SANITIZER_FLAGS)
7223 ifdef VBOX_WITH_NO_GCC_WARNING_POLICY
7224 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS += $(VBOX_GCC_WERR)
7225 endif
7226 ifn1of ($(USERNAME),dsen serkan) # Bunch of stuff deprecated after 5.6.*. These guys knows how to deal with it. :)
7227 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS += $(VBOX_GCC_Wno-deprecated-declarations)
7228 endif
7229 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.x86 = -m32
7230 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.amd64 = -m64
7231 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.linux = -pthread
7232 TEMPLATE_VBOXQTGUIEXE_PCHFLAGS = $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS)
7233 TEMPLATE_VBOXQTGUIEXE_PCHFLAGS.x86 = $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.x86)
7234 TEMPLATE_VBOXQTGUIEXE_PCHFLAGS.amd64 = $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.amd64)
7235 TEMPLATE_VBOXQTGUIEXE_PCHFLAGS.linux = $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.linux)
7236 TEMPLATE_VBOXQTGUIEXE_PCHFLAGS.debug = $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.debug)
7237 TEMPLATE_VBOXQTGUIEXE_PCHFLAGS.dbgopt = $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.dbgopt)
7238 TEMPLATE_VBOXQTGUIEXE_OBJCFLAGS = -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_C) -fno-exceptions $(VBOX_GCC_IPRT_FMT_CHECK)
7239 TEMPLATE_VBOXQTGUIEXE_OBJCFLAGS.x86 = $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.x86)
7240 TEMPLATE_VBOXQTGUIEXE_OBJCFLAGS.amd64 = $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.amd64)
7241 TEMPLATE_VBOXQTGUIEXE_OBJCXXFLAGS = \
7242 -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_CXX) \
7243 -frtti -fno-exceptions $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_IPRT_FMT_CHECK)
7244 ifdef VBOX_WITH_NO_GCC_WARNING_POLICY
7245 TEMPLATE_VBOXQTGUIEXE_OBJCXXFLAGS += $(VBOX_GCC_WERR)
7246 endif
7247 TEMPLATE_VBOXQTGUIEXE_OBJCXXFLAGS.x86 = $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.x86)
7248 TEMPLATE_VBOXQTGUIEXE_OBJCXXFLAGS.amd64 = $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.amd64)
7249 TEMPLATE_VBOXQTGUIEXE_LDFLAGS = $(VBOX_GCC_SANITIZER_FLAGS) $(VBOX_GCC_SANITIZER_LDFLAGS)
7250 TEMPLATE_VBOXQTGUIEXE_LDFLAGS.x86 = -m32
7251 TEMPLATE_VBOXQTGUIEXE_LDFLAGS.amd64 = -m64
7252 TEMPLATE_VBOXQTGUIEXE_LIBS = \
7253 $(VBOX_LIBS_QT) \
7254 $(LIB_RUNTIME) \
7255 $(if-expr "$(LIB_VMM)" == "$(VBOX_LIB_VMM_LAZY)",$(LIB_REM),) \
7256 $(VBOX_LIB_VMM_LAZY)
7257
7258 ifeq ($(KBUILD_TARGET),linux)
7259 TEMPLATE_VBOXQTGUIEXE_LDFLAGS += -Wl,-z,noexecstack,-z,relro $(VBOX_LD_as_needed)
7260 TEMPLATE_VBOXQTGUIEXE_LIBS += \
7261 $(VBOX_XCURSOR_LIBS) \
7262 Xext \
7263 X11
7264 TEMPLATE_VBOXQTGUIEXE_LIBPATH += \
7265 $(VBOX_LIBPATH_X11)
7266 else ifeq ($(KBUILD_TARGET),darwin)
7267 TEMPLATE_VBOXQTGUIEXE_SDKS.darwin += $(VBOX_DARWIN_DEF_SDK_SDKS)
7268 TEMPLATE_VBOXQTGUIEXE_DEFS.darwin += $(VBOX_DARWIN_DEF_SDK_DEFS)
7269 TEMPLATE_VBOXQTGUIEXE_CFLAGS.darwin += $(VBOX_DARWIN_DEF_SDK_CFLAGS)
7270 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.darwin += $(VBOX_DARWIN_DEF_SDK_CXXFLAGS)
7271 TEMPLATE_VBOXQTGUIEXE_PCHFLAGS.darwin += $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.darwin)
7272 TEMPLATE_VBOXQTGUIEXE_OBJCFLAGS.darwin += $(VBOX_DARWIN_DEF_SDK_OBJCFLAGS)
7273 TEMPLATE_VBOXQTGUIEXE_OBJCXXFLAGS.darwin += $(VBOX_DARWIN_DEF_SDK_OBJCXXFLAGS) $(VBOX_GCC_std)
7274 TEMPLATE_VBOXQTGUIEXE_LDFLAGS.darwin += $(VBOX_DARWIN_DEF_SDK_LDFLAGS) -bind_at_load -Wl,-headerpad_max_install_names
7275 TEMPLATE_VBOXQTGUIEXE_LIBS +=
7276 TEMPLATE_VBOXQTGUIEXE_LIBPATH +=
7277 else
7278 TEMPLATE_VBOXQTGUIEXE_INCS += \
7279 $(VBOX_XCURSOR_INCS)
7280 TEMPLATE_VBOXQTGUIEXE_LIBS += \
7281 $(VBOX_XCURSOR_LIBS) \
7282 Xext \
7283 X11 \
7284 m \
7285 $(LIB_PTHREAD)
7286 TEMPLATE_VBOXQTGUIEXE_LIBPATH += \
7287 $(VBOX_LIBPATH_X11)
7288 ifeq ($(KBUILD_TARGET),freebsd)
7289 TEMPLATE_VBOXQTGUIEXE_INCS += \
7290 /usr/include \
7291 /usr/X11R6/include \
7292 /usr/local/include
7293 TEMPLATE_VBOXQTGUIEXE_LIBPATH += \
7294 /usr/lib \
7295 /usr/X11R6/lib \
7296 /usr/local/lib
7297 endif
7298 ifeq ($(KBUILD_TARGET),solaris)
7299 TEMPLATE_VBOXQTGUIEXE_LDFLAGS.solaris = -Wl,-z,ignore # Same as VBOX_LD_as_needed.
7300 TEMPLATE_VBOXQTGUIEXE_LIBS += \
7301 rt socket nsl
7302 endif
7303 endif
7304 # Assume the Qt shared objects are in the same directory as the executable, on Solaris too.
7305 ifdef VBOX_WITH_RUNPATH
7306 TEMPLATE_VBOXQTGUIEXE_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RUNPATH)'
7307 else ifdef VBOX_WITH_RELATIVE_RUNPATH
7308 TEMPLATE_VBOXQTGUIEXE_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)'
7309 endif
7310
7311 endif
7312
7313 # Add COM/XPCOM stuff
7314 TEMPLATE_VBOXQTGUIEXE_LIBS += \
7315 $(PATH_STAGE_LIB)/VBoxCOM$(if-expr defined(VBOX_WITH_DEBUG_VCC_CRT) && $(KBUILD_TARGET) == win,-GUI,)$(VBOX_SUFF_LIB)
7316 ifdef VBOX_WITH_XPCOM
7317 ## @todo may be worth creating the VBOX_XPCOM SDK def, or just a SDK_VBOXXPCOM.
7318 TEMPLATE_VBOXQTGUIEXE_DEFS += VBOX_WITH_XPCOM
7319 ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
7320 TEMPLATE_VBOXQTGUIEXE_DEFS += VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
7321 endif
7322 TEMPLATE_VBOXQTGUIEXE_INCS += \
7323 $(VBOX_XPCOM_INCS)
7324 TEMPLATE_VBOXQTGUIEXE_LIBS += \
7325 $(LIB_XPCOM)
7326 TEMPLATE_VBOXQTGUIEXE_INTERMEDIATES += \
7327 $(VBOX_PATH_SDK)/bindings/xpcom/include/VirtualBox_XPCOM.h
7328 else # COM
7329 TEMPLATE_VBOXQTGUIEXE_INCS += \
7330 $(VBOX_PATH_SDK)/bindings/mscom/include
7331 TEMPLATE_VBOXQTGUIEXE_INTERMEDIATES += \
7332 $(VBOX_PATH_SDK)/bindings/mscom/include/VirtualBox.h
7333 endif # COM
7334
7335 ifn1of ($(KBUILD_TARGET), darwin os2 win)
7336 TEMPLATE_VBOXQTGUIEXE_DEFS += PIC
7337 TEMPLATE_VBOXQTGUIEXE_CFLAGS += -fPIC
7338 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS += -fPIC
7339 # Needed for GCC 9. Even system's Qt 5.12.4 (on Ubuntu 19.10) did not have this fixed yet.
7340 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.linux = -Wno-deprecated-copy $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS)
7341 TEMPLATE_VBOXQTGUIEXE_LDFLAGS += -fPIC
7342 endif # not darwin, os2 or win
7343
7344 ifeq ($(KBUILD_TARGET),darwin)
7345 TEMPLATE_VBOXQTGUIEXE_POST_CMDS = $(QUIET)install_name_tool $(foreach qtmod, $(VBOX_QT_MOD_NAMES), \
7346 $(foreach prefix, @executable_path/../Frameworks/ $(VBOX_PATH_QT)/Frameworks/ $(PATH_SDK_QT5)/, \
7347 -change "$(prefix)$(qtmod).framework/Versions/5/$(qtmod)" \
7348 "$(if $(VBOX_WITH_HARDENING),/Applications/VirtualBox.app/Contents/Frameworks,@rpath)/$(qtmod).framework/Versions/5/$(qtmod)" ) ) "$(out)"
7349 endif
7350
7351 #
7352 # Template for building Qt GUI components.
7353 #
7354 TEMPLATE_VBOXQTGUI = VBox Qt GUI Components
7355 TEMPLATE_VBOXQTGUI_EXTENDS = VBOXQTGUIEXE
7356 TEMPLATE_VBOXQTGUI_LIBS = $(filter-out $(QTMAIN),$(TEMPLATE_VBOXQTGUIEXE_LIBS))
7357 ifeq ($(KBUILD_TARGET),darwin)
7358 TEMPLATE_VBOXQTGUI_LDFLAGS.darwin += $(filter-out -bind_at_load,$(TEMPLATE_VBOXQTGUIEXE_LDFLAGS.darwin)) \
7359 -current_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
7360 -compatibility_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD)
7361 endif
7362 ifn1of ($(KBUILD_TARGET), darwin os2 win)
7363 TEMPLATE_VBOXQTGUI_DEFS = PIC $(TEMPLATE_VBOXQTGUIEXE_DEFS)
7364 TEMPLATE_VBOXQTGUI_CFLAGS = -fPIC $(TEMPLATE_VBOXQTGUIEXE_CFLAGS)
7365 TEMPLATE_VBOXQTGUI_CXXFLAGS = -fPIC $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS)
7366 TEMPLATE_VBOXQTGUI_PCHFLAGS = $(TEMPLATE_VBOXQTGUI_CXXFLAGS)
7367 TEMPLATE_VBOXQTGUI_LDFLAGS = -fPIC $(TEMPLATE_VBOXQTGUIEXE_LDFLAGS)
7368 endif
7369endif # VBOX_WITH_QTGUI
7370
7371ifdef VBOX_WITH_NLS
7372 #
7373 # Template for translation compilation.
7374 # Made as simple program without installing itself.
7375 # To archive it, the dummy code without runtime is used,
7376 # i.e. only compiler and system standard libs are linked.
7377 #
7378 TEMPLATE_VBoxNLS = VBox NLS template for installing translation files
7379 TEMPLATE_VBoxNLS_EXTENDS = VBoxR3Static
7380 TEMPLATE_VBoxNLS_USES = qt5
7381 TEMPLATE_VBoxNLS_QTTOOL = QT5
7382 TEMPLATE_VBoxNLS_QT_INFIX = $(VBOX_QT_INFIX)
7383 TEMPLATE_VBoxNLS_INSTTYPE = none
7384 TEMPLATE_VBoxNLS_LRCFLAGS += -silent
7385 TEMPLATE_VBoxNLS_QT_TRANSLATIONS_INST = $(INST_BIN)nls/
7386 TEMPLATE_VBoxNLS_SOURCES = \
7387 $(PATH_ROOT)/src/VBox/Main/nls/dummy.c
7388 TEMPLATE_VBoxNLS_LIBS = $(filter-out \
7389 $(VBOX_LIB_RUNTIME_STATIC) \
7390 $(PATH_STAGE_LIB)/VBox-libxml2-static$(VBOX_SUFF_LIB), \
7391 $(TEMPLATE_VBoxR3Static_LIBS))
7392endif # !VBOX_WITH_NLS
7393
7394
7395#
7396# Template for installing symbol files that we wish to ship.
7397#
7398TEMPLATE_VBoxDbgSyms = Symbol files for VBoxDbg and gurus.
7399TEMPLATE_VBoxDbgSyms_INST = $(INST_VBOXDBG_SYMS)
7400
7401
7402#
7403# Template for building build bldprogs.
7404# HACK ALERT! The BLD_TRG_* is a hack to allow building libraries as well.
7405#
7406TEMPLATE_VBoxBldProg = VBox Build Program
7407TEMPLATE_VBoxBldProg_BLD_TRG := $(KBUILD_HOST)
7408TEMPLATE_VBoxBldProg_BLD_TRG_ARCH := $(KBUILD_HOST_ARCH)
7409TEMPLATE_VBoxBldProg_BLD_TRG_CPU := $(KBUILD_HOST_CPU)
7410TEMPLATE_VBoxBldProg_DEFS := IN_RING3 LOG_DISABLED IN_BLD_PROG
7411TEMPLATE_VBoxBldProg_DEFS.win := _CRT_SECURE_NO_DEPRECATE
7412ifeq ($(KBUILD_TARGET),$(KBUILD_HOST))
7413TEMPLATE_VBoxBldProg_ASTOOL := $(VBOX_ASTOOL)
7414TEMPLATE_VBoxBldProg_ASFLAGS.x86 := $(VBOX_ASFLAGS32)
7415TEMPLATE_VBoxBldProg_ASFLAGS.arm32 := $(VBOX_ASFLAGS32)
7416TEMPLATE_VBoxBldProg_ASFLAGS.sparc32 := $(VBOX_ASFLAGS32)
7417TEMPLATE_VBoxBldProg_ASFLAGS.amd64 := $(VBOX_ASFLAGS64)
7418TEMPLATE_VBoxBldProg_ASFLAGS.arm64 := $(VBOX_ASFLAGS64)
7419TEMPLATE_VBoxBldProg_ASFLAGS.sparc64 := $(VBOX_ASFLAGS64)
7420else if1of ($(KBUILD_TARGET_ARCH), amd64 x86)
7421TEMPLATE_VBoxBldProg_ASTOOL := YASM
7422TEMPLATE_VBoxBldProg_ASFLAGS := -D__YASM__ -Worphan-labels $(VBOX_YASM_Wno-segreg-in-64bit)
7423 if1of ($(KBUILD_HOST),win)
7424TEMPLATE_VBoxBldProg_ASFLAGS += -g cv8 -DASM_FORMAT_ELF
7425TEMPLATE_VBoxBldProg_ASFLAGS.x86 := -f win32
7426TEMPLATE_VBoxBldProg_ASFLAGS.amd64 := -f win64
7427 else if1of ($(KBUILD_HOST),darwin)
7428TEMPLATE_VBoxBldProg_ASFLAGS += -DASM_FORMAT_MACHO
7429TEMPLATE_VBoxBldProg_ASFLAGS.x86 := -f macho32
7430TEMPLATE_VBoxBldProg_ASFLAGS.amd64 := -f macho64
7431 else
7432TEMPLATE_VBoxBldProg_ASFLAGS += -g dwarf2 -DASM_FORMAT_ELF
7433TEMPLATE_VBoxBldProg_ASFLAGS.x86 := -f elf32
7434TEMPLATE_VBoxBldProg_ASFLAGS.amd64 := -f elf64
7435 endif
7436endif
7437ifeq ($(KBUILD_HOST),win)
7438 TEMPLATE_VBoxBldProg_TOOL := $(VBOX_VCC_TOOL_STEM)$(toupper $(KBUILD_HOST_ARCH))
7439 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
7440 TEMPLATE_VBoxBldProg_SDKS := ReorderCompilerIncs WINSDK10-UCRT-STATIC $(VBOX_WINPSDK)
7441 else
7442 TEMPLATE_VBoxBldProg_SDKS := ReorderCompilerIncs $(VBOX_WINPSDK)
7443 endif
7444 TEMPLATE_VBoxBldProg_CXXFLAGS := -Zi -Zl -GR- -EHsc -GF -Zc:wchar_t- $(VBOX_VCC_OPT) $(VBOX_VCC_FP) -MT$(VBOX_VCC_CRT_TYPE) \
7445 $(VBOX_VCC_WARN_ALL) $(VBOX_VCC_WERR)
7446 ifdef VBOX_WITH_MSC_ANALYZE_THIS
7447 TEMPLATE_VBoxBldProg_CXXFLAGS += /analyze
7448 endif
7449 TEMPLATE_VBoxBldProg_CXXFLAGS.debug := -RTCsu
7450 TEMPLATE_VBoxBldProg_CXXFLAGS.dbgopt = $(NO_SUCH_VARIABLE)
7451 TEMPLATE_VBoxBldProg_CXXFLAGS.profile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.release)
7452 TEMPLATE_VBoxBldProg_CXXFLAGS.kprofile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.release)
7453 TEMPLATE_VBoxBldProg_CFLAGS = $(TEMPLATE_VBoxBldProg_CXXFLAGS)
7454 TEMPLATE_VBoxBldProg_CFLAGS.debug = $(TEMPLATE_VBoxBldProg_CXXFLAGS.debug)
7455 TEMPLATE_VBoxBldProg_CFLAGS.dbgopt = $(TEMPLATE_VBoxBldProg_CXXFLAGS.dbgopt)
7456 TEMPLATE_VBoxBldProg_CFLAGS.release = $(TEMPLATE_VBoxBldProg_CXXFLAGS.release)
7457 TEMPLATE_VBoxBldProg_CFLAGS.profile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.profile)
7458 TEMPLATE_VBoxBldProg_CFLAGS.kprofile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.kprofile)
7459 TEMPLATE_VBoxBldProg_PCHFLAGS = $(TEMPLATE_VBoxBldProg_CXXFLAGS)
7460 TEMPLATE_VBoxBldProg_PCHFLAGS.debug = $(TEMPLATE_VBoxBldProg_CXXFLAGS.debug)
7461 TEMPLATE_VBoxBldProg_PCHFLAGS.dbgopt = $(TEMPLATE_VBoxBldProg_CXXFLAGS.dbgopt)
7462 TEMPLATE_VBoxBldProg_PCHFLAGS.release = $(TEMPLATE_VBoxBldProg_CXXFLAGS.release)
7463 TEMPLATE_VBoxBldProg_PCHFLAGS.profile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.profile)
7464 TEMPLATE_VBoxBldProg_PCHFLAGS.kprofile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.kprofile)
7465 TEMPLATE_VBoxBldProg_LDFLAGS = -Ignore:4197 \
7466 /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LargeAddressAware /DynamicBase /NxCompat /Release /Debug /Opt:Ref /Opt:Icf \
7467 /Version:$(VBOX_VERSION_MAJOR)0$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
7468 /DISALLOWLIB:libc$(VBOX_VCC_CRT_TYPE_N).lib \
7469 /DISALLOWLIB:libcmt$(VBOX_VCC_CRT_TYPE_N).lib \
7470 /DISALLOWLIB:msvcrt.lib \
7471 /DISALLOWLIB:msvcrtd.lib \
7472 /DISALLOWLIB:msvcprt.lib \
7473 /DISALLOWLIB:msvcprtd.lib \
7474 /DISALLOWLIB:libvcruntime$(VBOX_VCC_CRT_TYPE_N).lib \
7475 /DISALLOWLIB:libucrt$(VBOX_VCC_CRT_TYPE_N).lib \
7476 /DISALLOWLIB:vcruntime.lib \
7477 /DISALLOWLIB:vcruntimed.lib \
7478 /DISALLOWLIB:ucrt.lib \
7479 /DISALLOWLIB:ucrtd.lib
7480 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
7481 TEMPLATE_VBoxBldProg_LIBS = \
7482 $(PATH_TOOL_$(TEMPLATE_VBoxBldProg_TOOL)_LIB)/libvcruntime$(VBOX_VCC_CRT_TYPE).lib \
7483 $(PATH_TOOL_$(TEMPLATE_VBoxBldProg_TOOL)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
7484 $(PATH_TOOL_$(TEMPLATE_VBoxBldProg_TOOL)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib \
7485 $(PATH_TOOL_$(TEMPLATE_VBoxBldProg_TOOL)_LIB)/oldnames.lib
7486 else
7487 TEMPLATE_VBoxBldProg_LIBS = \
7488 $(PATH_TOOL_$(TEMPLATE_VBoxBldProg_TOOL)_LIB)/oldnames.lib \
7489 $(PATH_TOOL_$(TEMPLATE_VBoxBldProg_TOOL)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
7490 $(PATH_TOOL_$(TEMPLATE_VBoxBldProg_TOOL)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib
7491 endif
7492
7493else
7494# (gcc of some kind )
7495TEMPLATE_VBoxBldProg_TOOL = GXX3
7496 if $(VBOX_GCC_VERSION_CC) < 30400
7497TEMPLATE_VBoxBldProg_DEFS += RT_WITHOUT_PRAGMA_ONCE
7498 endif
7499TEMPLATE_VBoxBldProg_CFLAGS = -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_C) $(VBOX_GCC_Wno-variadic-macros)
7500 ifdef VBOX_WITH_NO_GCC_WARNING_POLICY
7501 TEMPLATE_VBoxBldProg_CFLAGS += $(VBOX_GCC_WERR)
7502 endif
7503TEMPLATE_VBoxBldProg_CFLAGS.x86 = -m32
7504TEMPLATE_VBoxBldProg_CFLAGS.sparc32 = -m32
7505TEMPLATE_VBoxBldProg_CFLAGS.amd64 = -m64
7506TEMPLATE_VBoxBldProg_CFLAGS.sparc64 = -m64
7507TEMPLATE_VBoxBldProg_CFLAGS.release = -O2 -fno-omit-frame-pointer -fno-strict-aliasing
7508TEMPLATE_VBoxBldProg_CFLAGS.profile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.profile)
7509TEMPLATE_VBoxBldProg_CFLAGS.kprofile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.kprofile)
7510TEMPLATE_VBoxBldProg_CXXFLAGS = -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_std)
7511 ifdef VBOX_WITH_NO_GCC_WARNING_POLICY
7512 TEMPLATE_VBoxBldProg_CXXFLAGS += $(VBOX_GCC_WERR)
7513 endif
7514TEMPLATE_VBoxBldProg_CXXFLAGS.x86 = -m32
7515TEMPLATE_VBoxBldProg_CXXFLAGS.sparc32 = -m32
7516TEMPLATE_VBoxBldProg_CXXFLAGS.amd64 = -m64
7517TEMPLATE_VBoxBldProg_CXXFLAGS.sparc64 = -m64
7518TEMPLATE_VBoxBldProg_CXXFLAGS.release = -O2 -fno-omit-frame-pointer -fno-strict-aliasing
7519TEMPLATE_VBoxBldProg_CXXFLAGS.profile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.release)
7520TEMPLATE_VBoxBldProg_CXXFLAGS.kprofile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.release)
7521TEMPLATE_VBoxBldProg_OBJCFLAGS = $(TEMPLATE_VBoxBldProg_CFLAGS)
7522TEMPLATE_VBoxBldProg_OBJCFLAGS.x86 = $(TEMPLATE_VBoxBldProg_CFLAGS.x86)
7523TEMPLATE_VBoxBldProg_OBJCFLAGS.amd64 = $(TEMPLATE_VBoxBldProg_CFLAGS.amd64)
7524TEMPLATE_VBoxBldProg_OBJCFLAGS.release = $(TEMPLATE_VBoxBldProg_CFLAGS.release)
7525TEMPLATE_VBoxBldProg_OBJCFLAGS.profile = $(TEMPLATE_VBoxBldProg_CFLAGS.profile)
7526TEMPLATE_VBoxBldProg_OBJCFLAGS.kprofile = $(TEMPLATE_VBoxBldProg_CFLAGS.kprofile)
7527TEMPLATE_VBoxBldProg_OBJCXXFLAGS = $(TEMPLATE_VBoxBldProg_CXXFLAGS)
7528TEMPLATE_VBoxBldProg_OBJCXXFLAGS.x86 = $(TEMPLATE_VBoxBldProg_CXXFLAGS.x86)
7529TEMPLATE_VBoxBldProg_OBJCXXFLAGS.amd64 = $(TEMPLATE_VBoxBldProg_CXXFLAGS.amd64)
7530TEMPLATE_VBoxBldProg_OBJCXXFLAGS.release = $(TEMPLATE_VBoxBldProg_CXXFLAGS.release)
7531TEMPLATE_VBoxBldProg_OBJCXXFLAGS.profile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.profile)
7532TEMPLATE_VBoxBldProg_OBJCXXFLAGS.kprofile= $(TEMPLATE_VBoxBldProg_CXXFLAGS.kprofile)
7533TEMPLATE_VBoxBldProg_PCHFLAGS = $(TEMPLATE_VBoxBldProg_CXXFLAGS)
7534TEMPLATE_VBoxBldProg_PCHFLAGS.x86 = $(TEMPLATE_VBoxBldProg_CXXFLAGS.x86)
7535TEMPLATE_VBoxBldProg_PCHFLAGS.amd64 = $(TEMPLATE_VBoxBldProg_CXXFLAGS.amd64)
7536TEMPLATE_VBoxBldProg_PCHFLAGS.release = $(TEMPLATE_VBoxBldProg_CXXFLAGS.release)
7537TEMPLATE_VBoxBldProg_PCHFLAGS.profile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.profile)
7538TEMPLATE_VBoxBldProg_PCHFLAGS.kprofile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.kprofile)
7539TEMPLATE_VBoxBldProg_LDFLAGS.x86 = -m32
7540TEMPLATE_VBoxBldProg_LDFLAGS.sparc32 = -m32
7541TEMPLATE_VBoxBldProg_LDFLAGS.amd64 = -m64
7542TEMPLATE_VBoxBldProg_LDFLAGS.sparc64 = -m64
7543 ifeq ($(KBUILD_HOST),linux)
7544TEMPLATE_VBoxBldProg_LIBS = pthread m rt dl
7545 else ifeq ($(KBUILD_HOST),os2)
7546TEMPLATE_VBoxBldProg_TOOL = GXX3OMF
7547TEMPLATE_VBoxBldProg_LIBS = socket iconv
7548 else ifeq ($(KBUILD_HOST),darwin)
7549TEMPLATE_VBoxBldProg_TOOL = $(VBOX_GCC_TOOL)
7550 if "$(VBOX_DEF_MACOSX_VERSION_MIN)" == "10.7" || "$(VBOX_DARWIN_HOST_VERSION_MAJOR)" == "7"
7551TEMPLATE_VBoxBldProg_DEFS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_DEFS)
7552TEMPLATE_VBoxBldProg_CFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_CFLAGS) -fno-common
7553TEMPLATE_VBoxBldProg_CXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_CXXFLAGS)
7554TEMPLATE_VBoxBldProg_PCHFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_CXXFLAGS)
7555TEMPLATE_VBoxBldProg_OBJCFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_OBJCFLAGS) $(VBOX_GCC_PEDANTIC_C)
7556TEMPLATE_VBoxBldProg_OBJCXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_OBJCXXFLAGS) $(VBOX_GCC_PEDANTIC_CXX)
7557TEMPLATE_VBoxBldProg_LDFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_7_LDFLAGS)
7558 else if "$(VBOX_DEF_MACOSX_VERSION_MIN)" == "10.6" || "$(VBOX_DARWIN_HOST_VERSION_MAJOR)" == "6"
7559TEMPLATE_VBoxBldProg_DEFS.darwin = $(VBOX_DARWIN_DEF_SDK_10_6_DEFS)
7560TEMPLATE_VBoxBldProg_CFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_6_CFLAGS) -fno-common
7561TEMPLATE_VBoxBldProg_CXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_6_CXXFLAGS)
7562TEMPLATE_VBoxBldProg_PCHFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_6_CXXFLAGS)
7563TEMPLATE_VBoxBldProg_OBJCFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_6_OBJCFLAGS) $(VBOX_GCC_PEDANTIC_C)
7564TEMPLATE_VBoxBldProg_OBJCXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_6_OBJCXXFLAGS) $(VBOX_GCC_PEDANTIC_CXX)
7565TEMPLATE_VBoxBldProg_LDFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_6_LDFLAGS)
7566 else if "$(VBOX_DEF_MACOSX_VERSION_MIN)" == "10.5" || "$(VBOX_DARWIN_HOST_VERSION_MAJOR)" == "5" || defined(VBOX_MACOS_10_5_WORKAROUND)
7567TEMPLATE_VBoxBldProg_DEFS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_DEFS)
7568TEMPLATE_VBoxBldProg_CFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_CFLAGS) -fno-common
7569TEMPLATE_VBoxBldProg_CXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_CXXFLAGS)
7570TEMPLATE_VBoxBldProg_PCHFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_CXXFLAGS)
7571TEMPLATE_VBoxBldProg_OBJCFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_OBJCFLAGS) $(VBOX_GCC_PEDANTIC_C)
7572TEMPLATE_VBoxBldProg_OBJCXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_OBJCXXFLAGS) $(VBOX_GCC_PEDANTIC_CXX)
7573TEMPLATE_VBoxBldProg_LDFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_10_5_LDFLAGS)
7574 else
7575TEMPLATE_VBoxBldProg_SDKS.darwin = $(VBOX_DARWIN_DEF_SDK_SDKS)
7576TEMPLATE_VBoxBldProg_DEFS.darwin = $(VBOX_DARWIN_DEF_SDK_DEFS)
7577TEMPLATE_VBoxBldProg_CFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_CFLAGS) -fno-common
7578TEMPLATE_VBoxBldProg_CXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS)
7579TEMPLATE_VBoxBldProg_PCHFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS)
7580TEMPLATE_VBoxBldProg_OBJCFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_OBJCFLAGS) $(VBOX_GCC_PEDANTIC_C)
7581TEMPLATE_VBoxBldProg_OBJCXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_OBJCXXFLAGS) $(VBOX_GCC_PEDANTIC_CXX)
7582TEMPLATE_VBoxBldProg_LDFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_LDFLAGS)
7583 endif
7584TEMPLATE_VBoxBldProg_LIBS =
7585 else ifeq ($(KBUILD_HOST),haiku)
7586TEMPLATE_VBoxBldProg_TOOL = GXX3
7587TEMPLATE_VBoxBldProg_LIBS = network iconv
7588TEMPLATE_VBoxBldProg_LIBPATH += \
7589 /boot/common/lib
7590 else if1of ($(KBUILD_HOST), freebsd openbsd)
7591TEMPLATE_VBoxBldProg_TOOL = GXX3
7592TEMPLATE_VBoxBldProg_LIBS = pthread
7593TEMPLATE_VBoxBldProg_INCS += \
7594 /usr/include \
7595 /usr/X11R6/include \
7596 /usr/local/include
7597TEMPLATE_VBoxBldProg_LIBPATH += \
7598 /usr/lib \
7599 /usr/X11R6/lib \
7600 /usr/local/lib
7601 else ifeq ($(KBUILD_HOST),netbsd)
7602TEMPLATE_VBoxBldProg_TOOL = GXX3
7603TEMPLATE_VBoxBldProg_LIBS = pthread
7604TEMPLATE_VBoxBldProg_INCS += \
7605 /usr/include \
7606 /usr/X11R7/include
7607TEMPLATE_VBoxBldProg_LIBPATH += \
7608 /usr/lib \
7609 /usr/X11R7/lib
7610 else ifeq ($(KBUILD_HOST),solaris)
7611TEMPLATE_VBoxBldProg_TOOL = GXX3PLAIN
7612TEMPLATE_VBoxBldProg_LIBS = rt
7613 else
7614$(warning Warning: VBOX Build: Target $(KBUILD_HOST) is not officially supported!)
7615 endif
7616
7617endif # !win
7618
7619
7620#
7621# Advanced build programs using IPRT and stuff.
7622#
7623TEMPLATE_VBoxAdvBldProg = Advanced VBox Build Program
7624TEMPLATE_VBoxAdvBldProg_EXTENDS = VBoxBldProg
7625TEMPLATE_VBoxAdvBldProg_SDKS = $(TEMPLATE_VBoxBldProg_SDKS)
7626TEMPLATE_VBoxAdvBldProg_SDKS.win= $(TEMPLATE_VBoxBldProg_SDKS.win) VBOX_NTDLL
7627TEMPLATE_VBoxAdvBldProg_DEFS = $(TEMPLATE_VBoxBldProg_DEFS) IN_RT_R3 IN_ADV_BLD_PROG
7628ifeq ($(KBUILD_HOST),win)
7629 TEMPLATE_VBoxAdvBldProg_CFLAGS = $(TEMPLATE_VBoxBldProg_CFLAGS) $(VBOX_VCC_WERR)
7630 TEMPLATE_VBoxAdvBldProg_CXXFLAGS = $(TEMPLATE_VBoxBldProg_CXXFLAGS) $(VBOX_VCC_WERR)
7631 TEMPLATE_VBoxAdvBldProg_PCHFLAGS = $(TEMPLATE_VBoxAdvBldProg_CXXFLAGS)
7632endif
7633TEMPLATE_VBoxAdvBldProg_LIBS = \
7634 $(PATH_STAGE_LIB)/RuntimeBldProg$(VBOX_HOSTSUFF_LIB) \
7635 $(TEMPLATE_VBoxBldProg_LIBS)
7636TEMPLATE_VBoxAdvBldProg_LIBS.darwin = \
7637 $(TEMPLATE_VBoxAdvBldProg_LIBS) \
7638 iconv \
7639 $(TEMPLATE_VBoxBldProg_LIBS.darwin)
7640TEMPLATE_VBoxAdvBldProg_LIBS.freebsd = \
7641 $(TEMPLATE_VBoxAdvBldProg_LIBS) \
7642 iconv \
7643 rt \
7644 $(TEMPLATE_VBoxBldProg_LIBS.freebsd)
7645TEMPLATE_VBoxAdvBldProg_LIBS.linux = \
7646 $(TEMPLATE_VBoxAdvBldProg_LIBS) \
7647 $(TEMPLATE_VBoxBldProg_LIBS.linux)
7648TEMPLATE_VBoxAdvBldProg_LIBS.solaris = \
7649 $(TEMPLATE_VBoxAdvBldProg_LIBS) \
7650 contract \
7651 kstat \
7652 rt \
7653 socket \
7654 nsl \
7655 $(TEMPLATE_VBoxBldProg_LIBS.solaris)
7656
7657
7658#
7659# Windows rc workaround for crosscompiling.
7660# (Some (old) Wine versions fails loading msvcrt.dll from the VCC bin directory.)
7661#
7662ifneq ($(KBUILD_HOST),win)
7663 TOOL_VCC80X86_RC := $(EXEC_X86_WIN32) $(KBUILD_DEVTOOLS)/win.x86/bin/rc.exe
7664 TOOL_VCC80AMD64_RC := $(EXEC_X86_WIN32) $(KBUILD_DEVTOOLS)/win.x86/bin/rc.exe
7665 TOOL_VCC70_RC := $(EXEC_X86_WIN32) $(KBUILD_DEVTOOLS)/win.x86/bin/rc.exe
7666 WIN32_MC = $(EXEC_X86_WIN32) $(KBUILD_DEVTOOLS)/win.x86/bin/mc.exe
7667else
7668 WIN32_MC = $(EXEC_X86_WIN32) $(firstword $(wildcard \
7669 $(PATH_SDK_$(VBOX_WINPSDK)_BIN)/MC.Exe\
7670 $(PATH_SDK_WINPSDK_BIN)/MC.Exe\
7671 $(PATH_SDK_WINPSDK)/Bin/MC.Exe\
7672 $(PATH_SDK_WIN32SDK_BIN)/MC.Exe\
7673 $(PATH_SDK_WIN64SDK_BIN)/MC.Exe\
7674 $(KBUILD_DEVTOOLS)/win.x86/bin/mc.exe\
7675 ) Sorry_Cannot_find_mc_in_the_PSDK)
7676endif
7677
7678
7679#
7680# Template for building R3 programs for the guest additions.
7681#
7682TEMPLATE_VBOXGUESTR3EXE = VBox Guest Program
7683ifeq ($(KBUILD_TARGET),win)
7684 TEMPLATE_VBOXGUESTR3EXE_EXTENDS = VBOXR3EXE
7685 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
7686 TEMPLATE_VBOXGUESTR3EXE_SDKS = ReorderCompilerIncs WINSDK10-UCRT-STATIC $(VBOX_WINPSDK_GST) VBOX_NTDLL
7687 else
7688 TEMPLATE_VBOXGUESTR3EXE_SDKS = ReorderCompilerIncs $(VBOX_WINPSDK_GST) VBOX_NTDLL
7689 endif
7690 TEMPLATE_VBOXGUESTR3EXE_CFLAGS = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBOXR3EXE_CFLAGS)) -MT$(VBOX_VCC_CRT_TYPE) -Gy
7691 TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS = $(filter-out -MD$(VBOX_VCC_CRT_TYPE), $(TEMPLATE_VBOXR3EXE_CFLAGS)) -MT$(VBOX_VCC_CRT_TYPE) -Gy
7692 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC120" # Do not use SSE so the binaries might works on NT4 and earlier.
7693 TEMPLATE_VBOXGUESTR3EXE_CFLAGS.win.x86 = $(TEMPLATE_VBOXR3EXE_CFLAGS.win.86) /arch:IA32 -Gw
7694 TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS.win.x86 = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.win.86) /arch:IA32 -Gw
7695 TEMPLATE_VBOXGUESTR3EXE_PCHFLAGS.win.x86 = $(TEMPLATE_VBOXR3EXE_PCHFLAGS.win.86) /arch:IA32 -Gw
7696 endif
7697 TEMPLATE_VBOXGUESTR3EXE_LDFLAGS = $(filter-out /DISALLOWLIB:libcmt$(VBOX_VCC_CRT_TYPE).lib /DISALLOWLIB:libcpmt$(VBOX_VCC_CRT_TYPE).lib, $(TEMPLATE_VBOXR3EXE_LDFLAGS)) \
7698 /DISALLOWLIB:msvcrt$(VBOX_VCC_CRT_TYPE).lib \
7699 /DISALLOWLIB:msvcprt$(VBOX_VCC_CRT_TYPE).lib \
7700 /DISALLOWLIB:vcruntime$(VBOX_VCC_CRT_TYPE).lib \
7701 /DISALLOWLIB:ucrt$(VBOX_VCC_CRT_TYPE).lib
7702 if "$(VBOX_VCC_TOOL_STEM)" >= "VCC140"
7703 TEMPLATE_VBOXGUESTR3EXE_LIBS.x86 = \
7704 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.x86)_LIB)/libvcruntime$(VBOX_VCC_CRT_TYPE).lib \
7705 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.x86)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
7706 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.x86)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib \
7707 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.x86)_LIB)/oldnames.lib
7708 TEMPLATE_VBOXGUESTR3EXE_LIBS.amd64 = \
7709 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.amd64)_LIB)/libvcruntime$(VBOX_VCC_CRT_TYPE).lib \
7710 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.amd64)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
7711 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.amd64)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib \
7712 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.amd64)_LIB)/oldnames.lib
7713 else
7714 TEMPLATE_VBOXGUESTR3EXE_LIBS.x86 = \
7715 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.x86)_LIB)/oldnames.lib \
7716 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.x86)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
7717 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.x86)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib
7718 TEMPLATE_VBOXGUESTR3EXE_LIBS.amd64 = \
7719 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.amd64)_LIB)/oldnames.lib \
7720 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.amd64)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
7721 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.amd64)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib
7722 endif
7723 # Hack for running on NT3x, NT4, W2K and XP w/o SP: Change OS and subsystem version in the image.
7724 # The .bss section trick is for NT 3.1 which doesn't support merging initialized and uninitialized
7725 # section because it doesn't recognize Misc.VirtualSize. VBOX_PE_SET_VERSION will unset the !K flag.
7726 # HACK ALERT! Double expansion of $$(NLTAB).
7727 TEMPLATE_VBOXGUESTR3EXE_POST_CMDS.win.x86 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION) $(out)$$(NLTAB)$(TEMPLATE_VBOXR3EXE_POST_CMDS))
7728 TEMPLATE_VBOXGUESTR3EXE_LNK_DEPS.win.x86 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION))
7729 TEMPLATE_VBOXGUESTR3EXE_LDFLAGS.win.x86 = -Section:.bss,RW!K $(TEMPLATE_VBOXR3EXE_LDFLAGS.win.x86)
7730
7731 if defined(VBOX_WITH_MORE_NT4_COMPAT_BINARIES) && "$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)" == "win.x86"
7732 TEMPLATE_VBOXGUESTR3EXE_LIBS.win.x86 = $(NO_SUCH_VARIABLE)# Ditch RuntimeR3VccTricks2
7733 endif
7734else # the gcc guys
7735 TEMPLATE_VBOXGUESTR3EXE_EXTENDS = VBOXR3EXE
7736 ifn1of ($(KBUILD_TARGET), darwin)
7737 TEMPLATE_VBOXGUESTR3EXE_TOOL := $(subst GXX,GCC,$(TEMPLATE_VBOXR3EXE_TOOL))
7738 endif
7739 TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) -fno-exceptions -fno-rtti
7740 # Do not inherit sanitizer flags from VBOXR3EXE in guest executables. Deal with them separately.
7741 TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS.debug = $(NO_SUCH_VARIABLE)
7742 TEMPLATE_VBOXGUESTR3EXE_CFLAGS.debug = $(NO_SUCH_VARIABLE)
7743 TEMPLATE_VBOXGUESTR3EXE_LDFLAGS.linux = $(filter-out $(VBOX_GCC_ORIGIN_OPT),$(TEMPLATE_VBOXR3EXE_LDFLAGS.linux))
7744 TEMPLATE_VBOXGUESTR3EXE_LDFLAGS.debug = $(NO_SUCH_VARIABLE)
7745 TEMPLATE_VBOXGUESTR3EXE_LDFLAGS = $(filter-out '$(VBOX_GCC_RPATH_OPT)%,$(TEMPLATE_VBOXR3EXE_LDFLAGS))
7746endif
7747TEMPLATE_VBOXGUESTR3EXE_INST = $(INST_ADDITIONS)
7748TEMPLATE_VBOXGUESTR3EXE_DEFS := $(filter-out $(ARCH_BITS_DEFS) VBOX_WITH_DTRACE VBOX_WITH_DTRACE_R3, $(TEMPLATE_VBOXR3EXE_DEFS)) IN_GUEST IN_GUEST_R3 IN_RT_R3 $(VBOX_GC_ARCH_BITS_DEFS) RT_NEED_NEW_AND_DELETE
7749TEMPLATE_VBOXGUESTR3EXE_DEFS.linux := $(TEMPLATE_VBOXR3EXE_DEFS.linux) LOG_USE_C99 RT_WITHOUT_EXEC_ALLOC
7750ifeq ($(KBUILD_TARGET),linux) # As few libs as possible on linux.
7751 TEMPLATE_VBOXGUESTR3EXE_LIBS = pthread rt m dl
7752else if1of ($(KBUILD_TARGET), darwin freebsd openbsd)
7753 TEMPLATE_VBOXGUESTR3EXE_LIBS = $(TEMPLATE_VBOXR3EXE_LIBS) iconv
7754else ifeq ($(KBUILD_TARGET), solaris)
7755 TEMPLATE_VBOXGUESTR3EXE_LIBS = $(TEMPLATE_VBOXR3EXE_LIBS) nsl
7756endif
7757
7758# Use older versions of APIs which were improved in versions of glibc later
7759# than what we are targetting, and do not use the stack protector, which
7760# needs glibc 2.4 or later.
7761TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS.linux = \
7762 -include $(PATH_ROOT)/include/iprt/linux/symvers.h \
7763 $(VBOX_GCC_fno-stack-protector)
7764TEMPLATE_VBOXGUESTR3EXE_CFLAGS.linux = $(TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS.linux)
7765# The GNU_HASH ELF tag is not supported by older systems.
7766TEMPLATE_VBOXGUESTR3EXE_LDFLAGS.linux += $(VBOX_LD_hash_style_sysv)
7767
7768#
7769# Template for building normal R3 programs for the guest additions.
7770#
7771TEMPLATE_NewVBoxGuestR3Exe = VBox Guest Program w/ IPRT and VBGL.
7772TEMPLATE_NewVBoxGuestR3Exe_EXTENDS = VBOXGUESTR3EXE
7773TEMPLATE_NewVBoxGuestR3Exe_LIBS = \
7774 $(VBOX_LIB_IPRT_GUEST_R3) \
7775 $(VBOX_LIB_VBGL_R3) \
7776 $(VBOX_LIB_IPRT_GUEST_R3) \
7777 $(TEMPLATE_VBOXGUESTR3EXE_LIBS)
7778ifeq ($(KBUILD_TARGET),solaris)
7779TEMPLATE_NewVBoxGuestR3Exe_LIBS += contract
7780endif
7781
7782#
7783# Template for building normal R3 programs for the guest additions, strict.
7784#
7785TEMPLATE_VBoxGuestR3Exe = VBox Guest Program w/ IPRT and VBGL.
7786TEMPLATE_VBoxGuestR3Exe_EXTENDS = NewVBoxGuestR3Exe
7787TEMPLATE_VBoxGuestR3Exe_EXTENDS_BY = appending
7788ifeq ($(KBUILD_TARGET),win)
7789 TEMPLATE_VBoxGuestR3Exe_CFLAGS += $(VBOX_VCC_WERR)
7790 TEMPLATE_VBoxGuestR3Exe_CXXFLAGS += $(VBOX_VCC_WERR)
7791 if1of ($(VBOX_VCC_TOOL_STEM), VCC120)
7792 # VBoxDrvInst.cpp(520) : warning C4313: 'wprintf' : '%d' in format string conflicts with argument 1 of type 'const TCHAR *' [false positive - buggy compiler?]
7793 TEMPLATE_VBoxGuestR3Exe_CXXFLAGS += -wd4313
7794 endif
7795 TEMPLATE_VBoxGuestR3Exe_LDFLAGS += $(VBOX_VCC_LD_WERR)
7796else
7797 TEMPLATE_VBoxGuestR3Exe_CFLAGS += $(VBOX_GCC_WERR)
7798 TEMPLATE_VBoxGuestR3Exe_CXXFLAGS += $(VBOX_GCC_WERR)
7799endif
7800
7801#
7802# Template for building R3 (dynamic) libraries for the guest additions.
7803#
7804TEMPLATE_VBOXGUESTR3DLL = VBox Guest User Dynamic Libraries
7805TEMPLATE_VBOXGUESTR3DLL_EXTENDS = VBOXGUESTR3EXE
7806## @todo add a INSTFUN that separates dlls and libs.
7807ifn1of ($(KBUILD_TARGET), darwin os2 win)
7808 TEMPLATE_VBOXGUESTR3DLL_DEFS = $(TEMPLATE_VBOXGUESTR3EXE_DEFS) PIC
7809 TEMPLATE_VBOXGUESTR3DLL_CFLAGS = $(TEMPLATE_VBOXGUESTR3EXE_CFLAGS) -fPIC
7810 TEMPLATE_VBOXGUESTR3DLL_CXXFLAGS = $(TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS) -fPIC -fno-exceptions
7811 TEMPLATE_VBOXGUESTR3DLL_LDFLAGS = $(TEMPLATE_VBOXGUESTR3EXE_LDFLAGS) -fPIC
7812endif
7813
7814#
7815# Template for building normal R3 (dynamic) libraries for the guest additions, allows warnings.
7816#
7817## @todo rename to VBoxGuestR3DllWarn
7818TEMPLATE_NewVBoxGuestR3Dll = VBox Guest User Dynamic Libraries w/ IPRT and VBGL.
7819TEMPLATE_NewVBoxGuestR3Dll_EXTENDS = VBOXGUESTR3DLL
7820TEMPLATE_NewVBoxGuestR3Dll_LIBS = \
7821 $(VBOX_LIB_IPRT_GUEST_R3_SHARED) \
7822 $(VBOX_LIB_VBGL_R3_SHARED) \
7823 $(VBOX_LIB_IPRT_GUEST_R3_SHARED) \
7824 $(TEMPLATE_VBOXGUESTR3DLL_LIBS)
7825
7826#
7827# Template for building normal R3 (dynamic) libraries for the guest additions, strict.
7828#
7829TEMPLATE_VBoxGuestR3Dll = VBox Guest User Dynamic Libraries w/ IPRT and VBGL.
7830TEMPLATE_VBoxGuestR3Dll_EXTENDS = NewVBoxGuestR3Dll
7831TEMPLATE_VBoxGuestR3Dll_EXTENDS_BY = appending
7832ifeq ($(KBUILD_TARGET),win)
7833 TEMPLATE_VBoxGuestR3Dll_CFLAGS += $(VBOX_VCC_WERR)
7834 TEMPLATE_VBoxGuestR3Dll_CXXFLAGS += $(VBOX_VCC_WERR)
7835 TEMPLATE_VBoxGuestR3Dll_LDFLAGS += $(VBOX_VCC_LD_WERR)
7836else
7837 TEMPLATE_VBoxGuestR3Dll_CFLAGS += $(VBOX_GCC_WERR)
7838 TEMPLATE_VBoxGuestR3Dll_CXXFLAGS += $(VBOX_GCC_WERR)
7839endif
7840
7841#
7842# Variant of VBoxGuestR3Dll that requires Windows 2000 or later for x86, and W2K3 for AMD64.
7843#
7844TEMPLATE_VBoxGuestR3DllMinW2K = VBox Guest User Dynamic Libraries w/ IPRT and VBGL.
7845TEMPLATE_VBoxGuestR3DllMinW2K_EXTENDS = VBoxGuestR3Dll
7846ifeq ($(KBUILD_TARGET),win)
7847 TEMPLATE_VBoxGuestR3DllMinW2K_LDFLAGS.win.x86 = $(filter-out -Section:.bss$(COMMA)RW!K,$(TEMPLATE_VBoxGuestR3Dll_LDFLAGS.win.x86))
7848 TEMPLATE_VBoxGuestR3DllMinW2K_POST_CMDS.win.x86 = $(subst $(VBOX_PE_SET_VERSION), $(VBOX_PE_SET_VERSION) --w2k,$(TEMPLATE_VBoxGuestR3Dll_POST_CMDS.win.x86))
7849 TEMPLATE_VBoxGuestR3DllMinW2K_POST_CMDS.win.amd64 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION) --w2k3 $(out)$$(NLTAB)$(TEMPLATE_VBoxGuestR3Dll_POST_CMDS.win.amd64))
7850 TEMPLATE_VBoxGuestR3DllMinW2K_LNK_DEPS.win.amd64 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION)) $(TEMPLATE_VBoxGuestR3Dll_LNK_DEPS.win.amd64)
7851endif
7852
7853#
7854# Variant of VBoxGuestR3Dll that requires Windows Vista or later.
7855#
7856TEMPLATE_VBoxGuestR3DllMinVista = VBox Guest User Dynamic Libraries w/ IPRT and VBGL.
7857TEMPLATE_VBoxGuestR3DllMinVista_EXTENDS = VBoxGuestR3Dll
7858ifeq ($(KBUILD_TARGET),win)
7859 TEMPLATE_VBoxGuestR3DllMinVista_LDFLAGS.win.x86 = $(filter-out -Section:.bss$(COMMA)RW!K,$(TEMPLATE_VBoxGuestR3Dll_LDFLAGS.win.x86))
7860 TEMPLATE_VBoxGuestR3DllMinVista_POST_CMDS.win.x86 = $(subst $(VBOX_PE_SET_VERSION), $(VBOX_PE_SET_VERSION) --vista,$(TEMPLATE_VBoxGuestR3Dll_POST_CMDS.win.x86))
7861 TEMPLATE_VBoxGuestR3DllMinVista_POST_CMDS.win.amd64 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION) --vista $(out)$$(NLTAB)$(TEMPLATE_VBoxGuestR3Dll_POST_CMDS.win.amd64))
7862 TEMPLATE_VBoxGuestR3DllMinVista_LNK_DEPS.win.amd64 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION)) $(TEMPLATE_VBoxGuestR3Dll_LNK_DEPS.win.amd64)
7863endif
7864
7865#
7866# Template for building normal R3 (dynamic) libraries for the guest additions with Visual C++ 2013 or later, strict.
7867#
7868TEMPLATE_NewerVccVBoxGuestR3Dll = VBOXGUESTR3DLL with the newer Visual C++ version (2013 or later).
7869TEMPLATE_NewerVccVBoxGuestR3Dll_EXTENDS = VBOXGUESTR3DLL
7870if "$(KBUILD_TARGET)" == "win" && "$(VBOX_NEWER_VCC_TOOL_STEM)" != "$(VBOX_VCC_TOOL_STEM)"
7871 TEMPLATE_NewerVccVBoxGuestR3Dll_TOOL.win.x86 = $(VBOX_NEWER_VCC_TOOL_STEM)X86
7872 TEMPLATE_NewerVccVBoxGuestR3Dll_TOOL.win.amd64 = $(VBOX_NEWER_VCC_TOOL_STEM)AMD64
7873 TEMPLATE_NewerVccVBoxGuestR3Dll_CXXFLAGS = \
7874 $(filter-out $(VBOX_VCC_WARN_ALL) $(VBOX_VCC_WERR), $(TEMPLATE_VBOXGUESTR3DLL_CXXFLAGS)) \
7875 $(VBOX_NEWER_VCC_WARN_ALL) $(VBOX_VCC_WERR)
7876 TEMPLATE_NewerVccVBoxGuestR3Dll_CFLAGS = $(TEMPLATE_NewerVccVBOXGUESTR3DLL_CXXFLAGS)
7877# Hack begin
7878# Does not work when building x86 for amd64 build (No rule to make target /oldnames.lib).
7879# TEMPLATE_NewerVccVBoxGuestR3Dll_LIBS.x86 = \
7880# $(subst $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3DLL_TOOL.win.x86)_LIB),$(PATH_TOOL_$(TEMPLATE_NewerVccVBoxGuestR3Dll_TOOL.win.x86)_LIB), $(TEMPLATE_VBOXGUESTR3DLL_LIBS.x86))
7881# TEMPLATE_NewerVccVBoxGuestR3Dll_LIBS.amd64 = \
7882# $(subst $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3DLL_TOOL.win.amd64)_LIB),$(PATH_TOOL_$(TEMPLATE_NewerVccVBoxGuestR3Dll_TOOL.win.amd64)_LIB), $(TEMPLATE_VBOXGUESTR3DLL_LIBS.amd64))
7883# Directly assign TEMPLATE_NewerVccVBoxGuestR3Dll_LIBS.
7884 TEMPLATE_NewerVccVBoxGuestR3Dll_LIBS.x86 = \
7885 $(PATH_TOOL_$(TEMPLATE_NewerVccVBoxGuestR3Dll_TOOL.win.x86)_LIB)/oldnames.lib \
7886 $(PATH_TOOL_$(TEMPLATE_NewerVccVBoxGuestR3Dll_TOOL.win.x86)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
7887 $(PATH_TOOL_$(TEMPLATE_NewerVccVBoxGuestR3Dll_TOOL.win.x86)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib
7888 TEMPLATE_NewerVccVBoxGuestR3Dll_LIBS.amd64 = \
7889 $(PATH_TOOL_$(TEMPLATE_NewerVccVBoxGuestR3Dll_TOOL.win.amd64)_LIB)/oldnames.lib \
7890 $(PATH_TOOL_$(TEMPLATE_NewerVccVBoxGuestR3Dll_TOOL.win.amd64)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
7891 $(PATH_TOOL_$(TEMPLATE_NewerVccVBoxGuestR3Dll_TOOL.win.amd64)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib
7892# Hack end
7893endif
7894
7895#
7896# Variant of NewerVccVBoxGuestR3Dll that requires Windows Vista or later.
7897#
7898TEMPLATE_NewerVccVBoxGuestR3DllMinVista = NewerVccVBoxGuestR3Dll with the newer Visual C++ version (2013 or later).
7899TEMPLATE_NewerVccVBoxGuestR3DllMinVista_EXTENDS = NewerVccVBoxGuestR3Dll
7900ifeq ($(KBUILD_TARGET),win)
7901 TEMPLATE_NewerVccVBoxGuestR3DllMinVista_LDFLAGS.win.x86 = $(filter-out -Section:.bss$(COMMA)RW!K,$(TEMPLATE_NewerVccVBoxGuestR3Dll_LDFLAGS.win.x86))
7902 TEMPLATE_NewerVccVBoxGuestR3DllMinVista_POST_CMDS.win.x86 = $(subst $(VBOX_PE_SET_VERSION), $(VBOX_PE_SET_VERSION) --vista,$(TEMPLATE_NewerVccVBoxGuestR3Dll_POST_CMDS.win.x86))
7903 TEMPLATE_NewerVccVBoxGuestR3DllMinVista_POST_CMDS.win.amd64 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION) --vista $(out)$$(NLTAB)$(TEMPLATE_NewerVccVBoxGuestR3Dll_POST_CMDS.win.amd64))
7904 TEMPLATE_NewerVccVBoxGuestR3DllMinVista_LNK_DEPS.win.amd64 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION)) $(TEMPLATE_NewerVccVBoxGuestR3Dll_LNK_DEPS.win.amd64)
7905endif
7906
7907#
7908# Template for building R3 (static) libraries for the guest additions, allows warnings.
7909#
7910## @todo rename to VBoxGuestR3LibWarn.
7911TEMPLATE_VBOXGUESTR3LIB = VBox Guest User Libraries
7912TEMPLATE_VBOXGUESTR3LIB_EXTENDS = VBOXGUESTR3EXE
7913TEMPLATE_VBOXGUESTR3LIB_INST = $(INST_ADDITIONS_LIB)
7914
7915#
7916# Template for building R3 (static) libraries for the guest additions, strict.
7917#
7918TEMPLATE_VBoxGuestR3Lib = VBox Guest User Dynamic Libraries w/ IPRT and VBGL.
7919TEMPLATE_VBoxGuestR3Lib_EXTENDS = VBOXGUESTR3LIB
7920TEMPLATE_VBoxGuestR3Lib_EXTENDS_BY = appending
7921ifeq ($(KBUILD_TARGET),win)
7922 TEMPLATE_VBoxGuestR3Lib_CFLAGS += $(VBOX_VCC_WERR)
7923 TEMPLATE_VBoxGuestR3Lib_CXXFLAGS += $(VBOX_VCC_WERR)
7924 TEMPLATE_VBoxGuestR3Lib_LDFLAGS += $(VBOX_VCC_LD_WERR)
7925else
7926 TEMPLATE_VBoxGuestR3Lib_CFLAGS += $(VBOX_GCC_WERR)
7927 TEMPLATE_VBoxGuestR3Lib_CXXFLAGS += $(VBOX_GCC_WERR)
7928endif
7929
7930
7931#
7932# Guest version of VBoxR3StaticNoCrtExe.
7933#
7934TEMPLATE_VBoxGuestR3NoCrtExe := ...
7935TEMPLATE_VBoxGuestR3NoCrtExe_EXTENDS := VBoxGuestR3Exe
7936TEMPLATE_VBoxGuestR3NoCrtExe_SDKS = $(subst WINSDK10-UCRT-STATIC,WINSDK10-UCRT-INCS, $(filter-out VBOX_OPENSSL,$(TEMPLATE_VBoxGuestR3Exe_SDKS)))
7937TEMPLATE_VBoxGuestR3NoCrtExe_DEFS = $(TEMPLATE_VBoxGuestR3Exe_DEFS) \
7938 RT_NO_CRT \
7939 IN_RT_STATIC
7940TEMPLATE_VBoxGuestR3NoCrtExe_DEFS.win = $(TEMPLATE_VBoxGuestR3Exe_DEFS.win) \
7941 RT_WITHOUT_NOCRT_WRAPPERS
7942TEMPLATE_VBoxGuestR3NoCrtExe_LIBS = \
7943 $(PATH_STAGE_LIB)/RuntimeR3NoCrt$(VBOX_SUFF_LIB)
7944ifeq ($(KBUILD_TARGET),win)
7945TEMPLATE_VBoxGuestR3NoCrtExe_LIBS.x86 = $(NO_SUCH_VARIABLE)
7946TEMPLATE_VBoxGuestR3NoCrtExe_LIBS.amd64 = $(NO_SUCH_VARIABLE)
7947TEMPLATE_VBoxGuestR3NoCrtExe_LIBS.win = $(NO_SUCH_VARIABLE)
7948TEMPLATE_VBoxGuestR3NoCrtExe_LIBS.win.x86 = \
7949 $(PATH_SDK_$(VBOX_WINDDK)_LIB.x86)/int64.lib \
7950 $(PATH_TOOL_$(TEMPLATE_VBoxGuestR3NoCrtExe_TOOL.win.x86)_LIB)/chkstk.obj
7951TEMPLATE_VBoxGuestR3NoCrtExe_LDFLAGS.win.x86 = $(filter-out -Include%, $(TEMPLATE_VBoxGuestR3Exe_LDFLAGS.win.x86))
7952TEMPLATE_VBoxGuestR3NoCrtExe_LDFLAGS.win = $(TEMPLATE_VBoxGuestR3Exe_LDFLAGS.win) /entry:CustomMainEntrypoint /subsystem:console
7953TEMPLATE_VBoxGuestR3NoCrtExe_CFLAGS = $(filter-out -EH%,$(TEMPLATE_VBoxGuestR3Exe_CFLAGS)) /GS- -EHs-
7954TEMPLATE_VBoxGuestR3NoCrtExe_CXXFLAGS = $(filter-out -EH%,$(TEMPLATE_VBoxGuestR3Exe_CXXFLAGS)) /GS- -EHs-
7955TEMPLATE_VBoxGuestR3NoCrtExe_PCHFLAGS = $(filter-out -EH%,$(TEMPLATE_VBoxGuestR3Exe_PCHFLAGS)) /GS- -EHs-
7956TEMPLATE_VBoxGuestR3NoCrtExe_CXXFLAGS.debug = $(filter-out /RTC% -RTC%, $(TEMPLATE_VBoxGuestR3Exe_CXXFLAGS.debug))
7957else
7958TEMPLATE_VBoxGuestR3NoCrtExe_CXXFLAGS = $(TEMPLATE_VBoxGuestR3Exe_CXXFLAGS) -fno-exceptions
7959TEMPLATE_VBoxGuestR3NoCrtExe_PCHFLAGS = $(TEMPLATE_VBoxGuestR3Exe_PCHFLAGS) -fno-exceptions
7960endif
7961
7962
7963#
7964# Template for building R3 programs for the guest additions (no -pedantic)
7965#
7966TEMPLATE_VBOXGUESTR3NPEXE = VBox Guest Program Non-pedantic
7967TEMPLATE_VBOXGUESTR3NPEXE_EXTENDS = VBOXGUESTR3EXE
7968ifneq ($(KBUILD_TARGET),win) # gcc only
7969 TEMPLATE_VBOXGUESTR3NPEXE_CXXFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_CXX),$(TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS)) \
7970 -Wno-sign-compare
7971 TEMPLATE_VBOXGUESTR3NPEXE_CFLAGS = $(filter-out $(VBOX_GCC_WERR) $(VBOX_GCC_WARN_MASOCHISTIC) $(VBOX_GCC_PEDANTIC_C) ,$(TEMPLATE_VBOXGUESTR3EXE_CFLAGS)) \
7972 -Wno-sign-compare
7973endif
7974
7975#
7976# Template for building R3 (dynamic) libraries for the guest additions (no -pedantic)
7977#
7978TEMPLATE_VBOXGUESTR3NPDLL = VBox Guest User Dynamic Libraries Non-pedantic
7979TEMPLATE_VBOXGUESTR3NPDLL_EXTENDS = VBOXGUESTR3NPEXE
7980## @todo add a INSTFUN that separates dlls and libs.
7981ifn1of ($(KBUILD_TARGET), darwin os2 win)
7982 TEMPLATE_VBOXGUESTR3NPDLL_DEFS = $(TEMPLATE_VBOXGUESTR3NPEXE_DEFS) PIC
7983 TEMPLATE_VBOXGUESTR3NPDLL_CFLAGS = $(TEMPLATE_VBOXGUESTR3NPEXE_CFLAGS) -fPIC
7984 TEMPLATE_VBOXGUESTR3NPDLL_CXXFLAGS = $(TEMPLATE_VBOXGUESTR3NPEXE_CXXFLAGS) -fPIC -fno-exceptions
7985 TEMPLATE_VBOXGUESTR3NPDLL_LDFLAGS = $(TEMPLATE_VBOXGUESTR3NPEXE_LDFLAGS) -fPIC
7986endif
7987
7988#
7989# Template for building R3 (static) libraries for the guest additions (no -pedantic)
7990#
7991TEMPLATE_VBOXGUESTR3NPLIB = VBox Guest User Libraries Non-pedantic
7992TEMPLATE_VBOXGUESTR3NPLIB_EXTENDS = VBOXGUESTR3NPEXE
7993TEMPLATE_VBOXGUESTR3NPLIB_INST = $(INST_ADDITIONS_LIB)
7994
7995
7996#
7997# Template for XFree86 guest modules (relocatable module, i.e. sysmod).
7998# This mostly about zapping the VBOXR3EXE linker flags and libraries.
7999#
8000TEMPLATE_VBOXGUESTR3XF86MOD = VBox XFree86 Guest Module
8001TEMPLATE_VBOXGUESTR3XF86MOD_EXTENDS = VBOXGUESTR3EXE
8002TEMPLATE_VBOXGUESTR3XF86MOD_LIBS.$(KBUILD_TYPE) = $(NO_SUCH_VARIABLE)
8003TEMPLATE_VBOXGUESTR3XF86MOD_LIBS.$(KBUILD_TARGET) = $(NO_SUCH_VARIABLE)
8004TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.$(KBUILD_TARGET) = $(NO_SUCH_VARIABLE)
8005# The GNU_HASH ELF tag is not supported by older glibc dynamic linkers.
8006TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.linux = $(subst -Wl$(COMMA),,$(VBOX_LD_hash_style_sysv))
8007TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.$(KBUILD_TYPE) = $(NO_SUCH_VARIABLE)
8008TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS = -r
8009if1of ($(KBUILD_TARGET), dragonfly freebsd linux netbsd openbsd) # the gnu ld guys.
8010 TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.release = -S
8011 TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.x86 = -m elf_i386
8012 TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.amd64 = -m elf_x86_64
8013endif
8014TEMPLATE_VBOXGUESTR3XF86MOD_CFLAGS = $(filter-out $(VBOX_GCC_SANITIZER_FLAGS),$(TEMPLATE_VBOXGUESTR3EXE_CFLAGS)) \
8015 -fno-pie -fno-merge-constants -std=c99 -ffreestanding
8016TEMPLATE_VBOXGUESTR3XF86MOD_CXXFLAGS= $(filter-out $(VBOX_GCC_SANITIZER_FLAGS),$(TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS)) \
8017 -fno-pie -fno-merge-constants -ffreestanding
8018TEMPLATE_VBOXGUESTR3XF86MOD_CFLAGS.linux = $(VBOX_GCC_fno-stack-protector) # Remove symvers.h
8019TEMPLATE_VBOXGUESTR3XF86MOD_CXXFLAGS.linux = $(VBOX_GCC_fno-stack-protector) # Remove symvers.h
8020TEMPLATE_VBOXGUESTR3XF86MOD_SYSSUFF = .o
8021TEMPLATE_VBOXGUESTR3XF86MOD_LIBS = \
8022 $(VBOX_LIB_VBGL_R3_XFREE86)
8023TEMPLATE_VBOXGUESTR3XF86MOD_DEFS = $(TEMPLATE_VBOXGUESTR3DLL_DEFS) VBOX_GUESTR3XF86MOD RTMEM_NO_WRAP_TO_EF_APIS
8024
8025
8026#
8027# Template for XFree86 guest libraries.
8028#
8029TEMPLATE_VBOXGUESTR3XF86LIB = VBox XFree86 Guest Library
8030TEMPLATE_VBOXGUESTR3XF86LIB_EXTENDS = VBOXGUESTR3XF86MOD
8031TEMPLATE_VBOXGUESTR3XF86LIB_INST = $(INST_ADDITIONS_LIB)
8032
8033
8034#
8035# Template for X.org guest modules (shared libs).
8036# This mostly about zapping unnecessary LIBS from VBOXGUESTR3DLL and adding some flags.
8037#
8038TEMPLATE_VBOXGUESTR3XORGMOD = VBox X.org Guest Module
8039TEMPLATE_VBOXGUESTR3XORGMOD_EXTENDS = VBOXGUESTR3DLL
8040TEMPLATE_VBOXGUESTR3XORGMOD_LIBS.$(KBUILD_TYPE) = $(NO_SUCH_VARIABLE)
8041TEMPLATE_VBOXGUESTR3XORGMOD_LIBS.$(KBUILD_TARGET) = $(NO_SUCH_VARIABLE)
8042TEMPLATE_VBOXGUESTR3XORGMOD_CFLAGS = $(filter-out $(VBOX_GCC_SANITIZER_FLAGS),$(TEMPLATE_VBOXGUESTR3DLL_CFLAGS)) -std=c99
8043TEMPLATE_VBOXGUESTR3XORGMOD_CXXFLAGS = $(filter-out $(VBOX_GCC_SANITIZER_FLAGS),$(TEMPLATE_VBOXGUESTR3DLL_CXXFLAGS))
8044if1of ($(KBUILD_TARGET), linux)
8045 TEMPLATE_VBOXGUESTR3XORGMOD_CFLAGS += -Wno-conversion -Wno-unused-parameter
8046endif
8047TEMPLATE_VBOXGUESTR3XORGMOD_DEFS = $(TEMPLATE_VBOXGUESTR3DLL_DEFS) VBOX_GUESTR3XORGMOD RTMEM_NO_WRAP_TO_EF_APIS
8048ifeq ($(KBUILD_TARGET_ARCH),amd64)
8049 TEMPLATE_VBOXGUESTR3XORGMOD_DEFS += _XSERVER64
8050endif
8051TEMPLATE_VBOXGUESTR3XORGMOD_LDFLAGS = $(filter-out $(VBOX_GCC_SANITIZER_FLAGS) $(VBOX_GCC_SANITIZER_LDFLAGS),$(TEMPLATE_VBOXGUESTR3DLL_LDFLAGS))
8052TEMPLATE_VBOXGUESTR3XORGMOD_LIBS = \
8053 $(VBOX_LIB_VBGL_R3_XORG)
8054TEMPLATE_VBOXGUESTR3XORGMOD_LIBS.freebsd += \
8055 iconv
8056
8057
8058#
8059# Template for X.Org guest libraries.
8060#
8061TEMPLATE_VBOXGUESTR3XORGLIB = VBox X.Org Guest Library
8062TEMPLATE_VBOXGUESTR3XORGLIB_EXTENDS = VBOXGUESTR3XORGMOD
8063TEMPLATE_VBOXGUESTR3XORGLIB_INST = $(INST_ADDITIONS_LIB)
8064
8065
8066#
8067# Template for building R0 drivers for the guest additions.
8068#
8069TEMPLATE_VBOXGUESTR0 = VBox Guest Driver
8070TEMPLATE_VBOXGUESTR0_EXTENDS = VBOXR0DRV
8071TEMPLATE_VBOXGUESTR0_INST = $(INST_ADDITIONS)
8072TEMPLATE_VBOXGUESTR0_SDKS.win.x86 = ReorderCompilerIncs $(VBOX_WINDDK_GST) $(VBOX_WINPSDK_GST)INCS
8073TEMPLATE_VBOXGUESTR0_SDKS.win.amd64 = ReorderCompilerIncs $(VBOX_WINDDK_GST) $(VBOX_WINPSDK_GST)INCS
8074TEMPLATE_VBOXGUESTR0_LIBS.win.x86 = \
8075 $(PATH_SDK_$(VBOX_WINDDK)_LIB)/int64.lib
8076TEMPLATE_VBOXGUESTR0_DEFS = $(TEMPLATE_VBOXR0DRV_DEFS) IN_GUEST IN_GUEST_R0
8077TEMPLATE_VBOXGUESTR0_DEFS.linux = RT_NO_EXPORT_SYMBOL
8078ifeq ($(KBUILD_TARGET),solaris)
8079 TEMPLATE_VBOXGUESTR0_LDFLAGS = -r -dy
8080endif
8081ifn1of (darwin os2 win, $(KBUILD_TARGET))
8082 TEMPLATE_VBOXGUESTR0_CFLAGS = $(patsubst %/VBox/SUPDrvMangling.h,%/VBox/VBoxGuestMangling.h,$(TEMPLATE_VBOXR0DRV_CFLAGS))
8083 TEMPLATE_VBOXGUESTR0_CXXFLAGS = $(patsubst %/VBox/SUPDrvMangling.h,%/VBox/VBoxGuestMangling.h,$(TEMPLATE_VBOXR0DRV_CXXFLAGS))
8084endif
8085if "$(VBOX_VCC_TOOL_STEM)" >= "VCC120" # Do not use SSE so the binaries might works on NT4 and earlier.
8086 TEMPLATE_VBOXGUESTR0_CFLAGS.win.x86 = $(TEMPLATE_VBOXR0DRV_CFLAGS.win.x86) /arch:IA32
8087 TEMPLATE_VBOXGUESTR0_CXXFLAGS.win.x86 = $(TEMPLATE_VBOXR0DRV_CXXFLAGS.win.x86) /arch:IA32
8088endif
8089
8090
8091#
8092# Template for building R0 libraries for the guest additions.
8093#
8094TEMPLATE_VBOXGUESTR0LIB = VBox Guest Driver Libraries
8095TEMPLATE_VBOXGUESTR0LIB_EXTENDS = VBOXGUESTR0
8096TEMPLATE_VBOXGUESTR0LIB_INSTTYPE = stage
8097TEMPLATE_VBOXGUESTR0LIB_INSTTYPE.linux = stage
8098TEMPLATE_VBOXGUESTR0LIB_INST = $(INST_ADDITIONS_LIB)
8099ifeq ($(KBUILD_TARGET),haiku)
8100 TEMPLATE_VBOXGUESTR0LIB_LDFLAGS = -r -dy
8101endif
8102
8103
8104#
8105# Guest additions libraries (all static).
8106# The _MINI and _SHARED are both compiled as PIC and intended for linking into a .so/.dll/.dylib.
8107#
8108VBOX_LIB_IPRT_GUEST_R3 = $(VBOX_PATH_ADDITIONS_LIB)/RuntimeGuestR3$(VBOX_SUFF_LIB)
8109VBOX_LIB_IPRT_GUEST_R3_SHARED = $(VBOX_PATH_ADDITIONS_LIB)/RuntimeGuestR3Shared$(VBOX_SUFF_LIB)
8110VBOX_LIB_IPRT_GUEST_R0 = $(VBOX_PATH_ADDITIONS_LIB)/RuntimeGuestR0$(VBOX_SUFF_LIB)
8111#ifeq ($(KBUILD_TARGET_ARCH),x86)
8112# VBOX_LIB_IPRT_GUEST_R0_NT4 = $(VBOX_PATH_ADDITIONS_LIB)/RuntimeGuestR0NT4$(VBOX_SUFF_LIB)
8113#else
8114 VBOX_LIB_IPRT_GUEST_R0_NT4 = $(VBOX_LIB_IPRT_GUEST_R0)
8115#endif
8116VBOX_LIB_VBGL_R3 = $(VBOX_PATH_ADDITIONS_LIB)/VBoxGuestR3Lib$(VBOX_SUFF_LIB)
8117VBOX_LIB_VBGL_R3_XFREE86 = $(VBOX_PATH_ADDITIONS_LIB)/VBoxGuestR3LibXFree86$(VBOX_SUFF_LIB)
8118VBOX_LIB_VBGL_R3_XORG = $(VBOX_PATH_ADDITIONS_LIB)/VBoxGuestR3LibXOrg$(VBOX_SUFF_LIB)
8119VBOX_LIB_VBGL_R3_SHARED = $(VBOX_PATH_ADDITIONS_LIB)/VBoxGuestR3LibShared$(VBOX_SUFF_LIB)
8120VBOX_LIB_VBGL_R0BASE = $(VBOX_PATH_ADDITIONS_LIB)/VBoxGuestR0LibBase$(VBOX_SUFF_LIB)
8121VBOX_LIB_VBGL_R0 = $(VBOX_PATH_ADDITIONS_LIB)/VBoxGuestR0Lib$(VBOX_SUFF_LIB)
8122ifeq ($(KBUILD_TARGET),x86)
8123 VBOX_LIB_IPRT_GUEST_R3_X86 = $(VBOX_LIB_IPRT_GUEST_R3)
8124 VBOX_LIB_IPRT_GUEST_R3_SHARED_X86 = $(VBOX_LIB_IPRT_GUEST_R3_SHARED)
8125 VBOX_LIB_VBGL_R3_X86 = $(VBOX_LIB_VBGL_R3)
8126 VBOX_LIB_VBGL_R3_SHARED_X86 = $(VBOX_LIB_VBGL_R3_SHARED)
8127else
8128 VBOX_LIB_IPRT_GUEST_R3_X86 = $(VBOX_PATH_ADDITIONS_LIB)/RuntimeGuestR3-x86$(VBOX_SUFF_LIB)
8129 VBOX_LIB_IPRT_GUEST_R3_SHARED_X86 = $(VBOX_PATH_ADDITIONS_LIB)/RuntimeGuestR3Shared-x86$(VBOX_SUFF_LIB)
8130 VBOX_LIB_VBGL_R3_X86 = $(VBOX_PATH_ADDITIONS_LIB)/VBoxGuestR3Lib-x86$(VBOX_SUFF_LIB)
8131 VBOX_LIB_VBGL_R3_SHARED_X86 = $(VBOX_PATH_ADDITIONS_LIB)/VBoxGuestR3LibShared-x86$(VBOX_SUFF_LIB)
8132endif
8133
8134
8135#
8136# Check the publisher and version string.
8137#
8138# We are being very strict because the version string is visible in various
8139# APIs and logs and must be machine readable.
8140#
8141VBOX_VERSION_COMP_VALID_CHAR_SET = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz()[]{}+-.,
8142ifneq ($(VBOX_BUILD_PUBLISHER),)
8143 if !defined(VBOX_BUILD_TAG) && $(length $(VBOX_BUILD_PUBLISHER)) > 10
8144 $(error VBox: VBOX_BUILD_PUBLISHER must not be longer than 10 characters!)
8145 else if defined(VBOX_BUILD_TAG) && $(length $(VBOX_BUILD_PUBLISHER)) > 48
8146 $(error VBox: VBOX_BUILD_PUBLISHER must not be longer than 48 characters!)
8147 endif
8148 if "$(substr $(VBOX_BUILD_PUBLISHER), 1, 1)" != "_"
8149 $(error VBox: VBOX_BUILD_PUBLISHER must start with an underscore!)
8150 endif
8151 if "$(translate $(substr $(VBOX_BUILD_PUBLISHER),2),$(VBOX_VERSION_COMP_VALID_CHAR_SET),)" != ""
8152 $(error VBox: VBOX_BUILD_PUBLISHER='$(VBOX_BUILD_PUBLISHER)' contains bad characters! Valid set is:$(NLTAB)$(VBOX_VERSION_COMP_VALID_CHAR_SET))
8153 endif
8154endif
8155
8156if $(words $(VBOX_VERSION_STRING)) != 1
8157 $(error VBox: VBOX_VERSION_STRING='$(VBOX_VERSION_STRING)' contains spaces or is empty.)
8158endif
8159if "$(subst __,-,$(VBOX_VERSION_STRING))" != "$(VBOX_VERSION_STRING)"
8160 $(error VBox: VBOX_VERSION_STRING='$(VBOX_VERSION_STRING)' contains double underscores.)
8161endif
8162
8163VBOX_VER_TMP1 := $(subst _,$(SP),$(VBOX_VERSION_STRING))
8164
8165if $(words $(VBOX_VER_TMP1)) > 3
8166 $(error VBox: VBOX_VERSION_STRING='$(VBOX_VERSION_STRING)' contains too many parts (underscores), max 3!)
8167endif
8168if "$(translate $(word 1,$(VBOX_VER_TMP1)),0123456789,)" != ".."
8169 $(error VBox: The x.y.z part of VBOX_VERSION_STRING='$(VBOX_VERSION_STRING)' is malformed: '$(word 1,$(VBOX_VER_TMP1))')
8170endif
8171if "$(word 1,$(VBOX_VER_TMP1))" != "$(VBOX_VERSION_STRING_RAW)"
8172 $(error VBox: VBOX_VERSION_STRING='$(VBOX_VERSION_STRING)' does not start with VBOX_VERSION_STRING_RAW='$(VBOX_VERSION_STRING_RAW)')
8173endif
8174
8175if $(words $(VBOX_VER_TMP1)) == 3 || ($(words $(VBOX_VER_TMP1)) == 2 && "$(VBOX_BUILD_PUBLISHER)" == "")
8176 if "$(substr $(word 2,$(VBOX_VER_TMP1)),1,4)" == "BETA"
8177 VBOX_VER_TMP2 = 5
8178 else if "$(substr $(word 2,$(VBOX_VER_TMP1)),1,5)" == "ALPHA"
8179 VBOX_VER_TMP2 = 6
8180 else if "$(substr $(word 2,$(VBOX_VER_TMP1)),1,2)" == "RC"
8181 VBOX_VER_TMP2 = 3
8182 else
8183 $(error VBox: VBOX_VERSION_STRING='$(VBOX_VERSION_STRING)' uses an unknown build type: '$(word 2,$(VBOX_VER_TMP1))')
8184 endif
8185 if "$(translate $(substr $(word 2,$(VBOX_VER_TMP1)),$(VBOX_VER_TMP2)),0123456789)" != ""
8186 $(error VBox: VBOX_VERSION_STRING='$(VBOX_VERSION_STRING)' uses an unknown build type: '$(word 2,$(VBOX_VER_TMP1))')
8187 endif
8188endif
8189
8190VBOX_VER_TMP1 :=
8191VBOX_VER_TMP2 :=
8192
8193
8194#
8195# Two targets to coordinate version number changes properly. Note that the
8196# only way to get a really consistent build is to run 'kmk' in the top-level
8197# directory. If you don't run it there, you get a consistent sub-tree only.
8198#
8199VBOX_BAD_CHAR_SET = ,;:/\$(SP)$(TAB)$(HASH)=![]@%&''()*""<>?^{}|~
8200VBOX_VERSION_STAMP = $(PATH_OUT)/version-stamp-raw-api-$(translate $(VBOX_VERSION_STRING)-$(VBOX_C_YEAR)-$(VBOX_VENDOR)-$(VBOX_PRODUCT)-$(VBOX_API_VERSION)-$(VBOX_BUILD_PUBLISHER)-$(USERNAME),$(VBOX_BAD_CHAR_SET),,_)
8201VBOX_VERSION_HEADER = $(PATH_OUT)/version-generated.h
8202VBOX_VERSION_MK = $(PATH_OUT)/version-generated.mk
8203
8204$(VBOX_VERSION_STAMP): | $(PATH_ROOT)/Config.kmk
8205 $(call MSG_GENERATE,,$@)
8206 $(QUIET)$(MKDIR) -p $(@D)
8207 $(QUIET)$(RM) -f $(wildcard $(PATH_OUT)/version-stamp-*)
8208 $(QUIET)$(APPEND) $@ $(VBOX_VERSION_STRING)
8209
8210$(VBOX_VERSION_HEADER): $(VBOX_VERSION_STAMP)
8211 $(call MSG_GENERATE,,$@)
8212 $(QUIET)$(MKDIR) -p $(@D)
8213 $(QUIET)$(RM) -f $@ [email protected]
8214 $(QUIET)$(APPEND) [email protected] '#ifndef ___version_generated_h___'
8215 $(QUIET)$(APPEND) [email protected] '#define ___version_generated_h___'
8216 $(QUIET)$(APPEND) [email protected] ''
8217 $(QUIET)$(APPEND) [email protected] '#define VBOX_VERSION_MAJOR $(VBOX_VERSION_MAJOR)'
8218 $(QUIET)$(APPEND) [email protected] '#define VBOX_VERSION_MINOR $(VBOX_VERSION_MINOR)'
8219 $(QUIET)$(APPEND) [email protected] '#define VBOX_VERSION_BUILD $(VBOX_VERSION_BUILD)'
8220ifneq ($(VBOX_VERSION_PRERELEASE),)
8221 $(QUIET)$(APPEND) [email protected] '#define VBOX_VERSION_PRERELEASE "$(strip $(VBOX_VERSION_PRERELEASE))"'
8222endif
8223 $(QUIET)$(APPEND) [email protected] '#define VBOX_VERSION_STRING_RAW "$(VBOX_VERSION_STRING_RAW)"'
8224 $(QUIET)$(APPEND) [email protected] '#define VBOX_VERSION_STRING "$(VBOX_VERSION_STRING)"'
8225 $(QUIET)$(APPEND) [email protected] '#define VBOX_API_VERSION_STRING "$(VBOX_API_VERSION)"'
8226 $(QUIET)$(APPEND) [email protected] ''
8227ifdef VBOX_BUILD_SERVER_BUILD
8228 $(QUIET)$(APPEND) [email protected] '#define VBOX_BUILD_SERVER_BUILD 1'
8229else
8230 $(QUIET)$(APPEND) [email protected] '#define VBOX_PRIVATE_BUILD_DESC "Private build by $(USERNAME)"'
8231endif
8232 $(QUIET)$(APPEND) [email protected] ''
8233 $(QUIET)$(APPEND) [email protected] '#endif'
8234 $(QUIET)$(MV) -f [email protected] $@
8235
8236
8237VBOX_PACKAGE_HEADER = $(PATH_OUT)/package-generated.h
8238
8239$(VBOX_PACKAGE_HEADER):
8240 $(call MSG_GENERATE,,$@)
8241 $(QUIET)$(MKDIR) -p $(@D)
8242 $(QUIET)$(RM) -f $@ [email protected]
8243 $(QUIET)$(APPEND) [email protected] '#ifndef ___package_generated_h___'
8244 $(QUIET)$(APPEND) [email protected] '#define ___package_generated_h___'
8245 $(QUIET)$(APPEND) [email protected] ''
8246 $(QUIET)$(APPEND) [email protected] '#define VBOX_PACKAGE_STRING "$(VBOX_PACKAGE_STRING)"'
8247 $(QUIET)$(APPEND) [email protected] ''
8248 $(QUIET)$(APPEND) [email protected] '#endif'
8249 $(QUIET)$(MV) -f [email protected] $@
8250
8251VBOX_PRODUCT_HEADER = $(PATH_OUT)/product-generated.h
8252
8253$(VBOX_PRODUCT_HEADER): $(VBOX_VERSION_STAMP)
8254 $(call MSG_GENERATE,,$@)
8255 $(QUIET)$(MKDIR) -p $(@D)
8256 $(QUIET)$(RM) -f $@ [email protected]
8257 $(QUIET)$(APPEND) [email protected] '#ifndef ___product_generated_h___'
8258 $(QUIET)$(APPEND) [email protected] '#define ___product_generated_h___'
8259 $(QUIET)$(APPEND) [email protected] ''
8260 $(QUIET)$(APPEND) [email protected] '#define VBOX_VENDOR "$(VBOX_VENDOR)"'
8261 $(QUIET)$(APPEND) [email protected] '#define VBOX_VENDOR_SHORT "$(VBOX_VENDOR_SHORT)"'
8262 $(QUIET)$(APPEND) [email protected] '#define VBOX_PRODUCT "$(VBOX_PRODUCT)"'
8263 $(QUIET)$(APPEND) [email protected] '#define VBOX_BUILD_PUBLISHER "$(VBOX_BUILD_PUBLISHER)"'
8264 $(QUIET)$(APPEND) [email protected] '#define VBOX_C_YEAR "$(VBOX_C_YEAR)"'
8265 $(QUIET)$(APPEND) [email protected] ''
8266 $(QUIET)$(APPEND) [email protected] '#endif'
8267 $(QUIET)$(MV) -f [email protected] $@
8268
8269#
8270# Used for external makefiles which cannot include Config.kmk
8271#
8272$(VBOX_VERSION_MK): $(VBOX_VERSION_STAMP)
8273 $(call MSG_GENERATE,,$@)
8274 $(QUIET)$(RM) -f $@ [email protected]
8275 $(QUIET)$(MKDIR) -p $(@D)
8276 $(QUIET)$(APPEND) [email protected] 'VBOX_VERSION_MAJOR = $(VBOX_VERSION_MAJOR)'
8277 $(QUIET)$(APPEND) [email protected] 'VBOX_VERSION_MINOR = $(VBOX_VERSION_MINOR)'
8278 $(QUIET)$(APPEND) [email protected] 'VBOX_VERSION_BUILD = $(VBOX_VERSION_BUILD)'
8279 $(QUIET)$(APPEND) [email protected] 'VBOX_VERSION_STRING = $(VBOX_VERSION_STRING)'
8280ifneq ($(VBOX_VERSION_PRERELEASE),)
8281 $(QUIET)$(APPEND) [email protected] 'VBOX_VERSION_PRERELEASE = $(strip $(VBOX_VERSION_PRERELEASE))'
8282endif
8283 $(QUIET)$(APPEND) [email protected] 'VBOX_VENDOR = $(VBOX_VENDOR)'
8284 $(QUIET)$(APPEND) [email protected] 'VBOX_VENDOR_SHORT = $(VBOX_VENDOR_SHORT)'
8285 $(QUIET)$(APPEND) [email protected] 'VBOX_PRODUCT = $(VBOX_PRODUCT)'
8286 $(QUIET)$(APPEND) [email protected] 'VBOX_C_YEAR = $(VBOX_C_YEAR)'
8287ifdef VBOX_BUILD_SERVER_BUILD
8288 $(QUIET)$(APPEND) [email protected] 'VBOX_BUILD_SERVER_BUILD = 1'
8289else
8290 $(QUIET)$(APPEND) [email protected] 'VBOX_PRIVATE_BUILD_DESC = Private build by $(USERNAME)'
8291endif
8292 $(QUIET)$(MV) -f [email protected] $@
8293
8294if !defined(VBOX_OSE) && !defined(VBOX_NOINC_LICENSE_VER_KMK)
8295 if1of ($(KBUILD_TARGET), freebsd linux netbsd openbsd solaris)
8296 # VBOX_LICENSE_VER is used in several Makefiles
8297 VBOX_LICENSE_VER_KMK = $(PATH_OUT)/license-version.kmk
8298$(VBOX_LICENSE_VER_KMK): $(VBOX_BRAND_LICENSE_HTML)
8299 $(call MSG_GENERATE,,$(VBOX_LICENSE_VER_KMK))
8300 $(QUIET)$(MKDIR) -p $(@D)
8301 ifdef VBOX_BRAND_LICENSE_VER
8302 $(QUIET)$(RM) -f '$@'
8303 $(APPEND) '$@' 'VBOX_LICENSE_VER=$(VBOX_BRAND_LICENSE_VER)'
8304 else
8305 $(QUIET)$(SED) -e "s/.*License version \([0-9.]*\) *[,&].*/VBOX_LICENSE_VER=\1/;t;d" --output $@ $(VBOX_BRAND_LICENSE_HTML)
8306 endif
8307 -include $(VBOX_LICENSE_VER_KMK)
8308 ifdef VBOX_LICENSE_VER
8309 VBOX_LICENSE_FILES = \
8310 License-$(VBOX_LICENSE_VER).html \
8311 $(foreach f,$(VBOX_INSTALLER_ADD_LANGUAGES),License-$(VBOX_LICENSE_VER)-$(f).html)
8312 VBOX_LICENSE_BINS = $(addprefix $(PATH_STAGE_BIN)/,$(VBOX_LICENSE_FILES))
8313 endif
8314 endif
8315endif
8316
8317
8318ifndef VBOX_NOINC_MISC
8319# Force building of the version header file as the first thing anywhere in
8320# the tree. This eliminates the need for manual dependencies on it.
8321## @todo there gotta be a better way of doing this.
8322Makefile.kmk: | $(VBOX_VERSION_HEADER) $(VBOX_VERSION_MK) $(VBOX_PRODUCT_HEADER) $(VBOX_PACKAGE_HEADER)
8323endif
8324
8325
8326#
8327# Subversion tree revision.
8328#
8329# The VBOX_SVN_REV contains our best guess. Use svn info on the root of the
8330# tree to determine this it if .svn/wc.db or .svn/entries is found (the former
8331# also up to two directory levels higher to allow for checkouts of the entire
8332# repository), otherwise fall back on maximum value of Config.kmk and
8333# Version.kmk revision.
8334#
8335# Makefile rules using this information shall list $(VBOX_SVN_REV_KMK) as a
8336# prerequisite.
8337#
8338SVN ?= svn$(HOSTSUFF_EXE)
8339VBOX_SVN_REV_KMK = $(PATH_OUT)/revision.kmk
8340ifndef VBOX_SVN_REV
8341 VBOX_SVN_REV_CONFIG_FALLBACK := $(patsubst %:,, $Rev: 91466 $ )
8342 VBOX_SVN_REV_FALLBACK := $(if-expr $(VBOX_SVN_REV_CONFIG_FALLBACK) > $(VBOX_SVN_REV_VERSION_FALLBACK),$(VBOX_SVN_REV_CONFIG_FALLBACK),$(VBOX_SVN_REV_VERSION_FALLBACK))
8343 VBOX_SVN_DEP := $(firstword $(wildcard $(PATH_ROOT)/.svn/wc.db $(abspath $(PATH_ROOT)/../.svn/wc.db) $(abspath $(PATH_ROOT)/../../.svn/wc.db) $(PATH_ROOT)/.svn/entries))
8344 ifeq ($(which $(SVN)),)
8345 VBOX_SVN_DEP :=
8346 endif
8347
8348# Rule for generating a timestamp and updating the real thing on change.
8349$(VBOX_SVN_REV_KMK).ts +| $(VBOX_SVN_REV_KMK): $(if $(VBOX_SVN_DEP), $(VBOX_SVN_DEP), $(PATH_ROOT)/Config.kmk)
8350 $(call MSG_GENERATE,,$(VBOX_SVN_REV_KMK))
8351 $(QUIET)$(RM) -f $@ [email protected]
8352 $(QUIET)$(MKDIR) -p $(@D)
8353 ifneq ($(VBOX_SVN_DEP),)
8354 -$(REDIRECT) -E 'LC_ALL=C' -wo [email protected] -- $(SVN) info $(PATH_ROOT)
8355 # Append fallback. Will be ignored if "svn info" provides meaningful data.
8356 $(QUIET)$(APPEND) [email protected] 'Last Changed Rev: $(VBOX_SVN_REV_FALLBACK)'
8357 $(SED) -e '/^Last Changed Rev/!d' -e 's/Last Changed Rev\: */export VBOX_SVN_REV=/; t a; :a q' --output $@ [email protected]
8358 $(QUIET)$(RM) -f [email protected]
8359 else
8360 $(QUIET)$(APPEND) $@ 'export VBOX_SVN_REV=$(VBOX_SVN_REV_FALLBACK)'
8361 endif
8362 $(QUIET)$(CP) --changed -fv $@ $(VBOX_SVN_REV_KMK)
8363
8364 ifndef VBOX_NOINC_SVN_REV_KMK
8365 include $(VBOX_SVN_REV_KMK)
8366 endif
8367else
8368# allow to overwrite VBOX_SVN_REV externally (mainly for building .debs/.rpms)
8369$(VBOX_SVN_REV_KMK):
8370 $(call MSG_GENERATE,,$(VBOX_SVN_REV_KMK))
8371 $(QUIET)$(RM) -f $@
8372 $(QUIET)$(MKDIR) -p $(@D)
8373 $(QUIET)$(APPEND) $@ 'export VBOX_SVN_REV=$(VBOX_SVN_REV)'
8374 $(QUIET)echo '* $(VBOX_SVN_REV_KMK) was externally overwritten:'
8375 $(QUIET)$(CAT) $(VBOX_SVN_REV_KMK)
8376endif
8377
8378# only needed for VBoxGuest for Linux/FreeBSD guests
8379VBOX_SVN_REV_HEADER = $(PATH_OUT)/revision-generated.h
8380$(VBOX_SVN_REV_HEADER): $(VBOX_SVN_REV_KMK)
8381 $(call MSG_GENERATE,,$@)
8382 $(QUIET)$(RM) -f $@ [email protected]
8383 $(QUIET)$(MKDIR) -p $(@D)
8384 $(QUIET)$(APPEND) [email protected] '#define VBOX_SVN_REV $(VBOX_SVN_REV)'
8385 $(QUIET)$(MV) -f [email protected] $@
8386
8387#
8388# Shared definitions of the XIDL file to use as a source for
8389# generating various other files (VBoxSVC, webservice, docs, front-ends, ...)
8390#
8391
8392# Real XIDL source file; from this we strip the <desc> elements to generate
8393# a second XIDL file, from which the COM/XPCOM IDL files are then generated:
8394VBOX_XIDL_FILE_SRC = $(PATH_ROOT)/src/VBox/Main/idl/VirtualBox.xidl
8395# second XIDL file to use as source for COM/XPCOM IDL (with stripped docs):
8396VBOX_XIDL_FILE = $(PATH_OUT)/obj/VirtualBox_stripped.xidl
8397
8398
8399#
8400# VBOX_SEP needs to be quoted when used on the shell command line.
8401#
8402if1of ($(KBUILD_TARGET), os2 win)
8403 VBOX_SEP = $(SEMICOLON)
8404else
8405 VBOX_SEP = $(COLON)
8406endif
8407
8408# Java compiler options, needs some version checking.
8409if defined(VBOX_JAVA_VERSION) && $(VBOX_JAVA_VERSION) >= 110000
8410 VBOX_JAVA_WS_PATH ?= /usr/share/java
8411 VBOX_JAVA_WS_EXTRA_JARS ?= $(VBOX_JAVA_WS_PATH)/jws-api.jar$(VBOX_SEP)$(VBOX_JAVA_WS_PATH)/jaxb-api.jar$(VBOX_SEP)$(VBOX_JAVA_WS_PATH)/jaxws-api.jar
8412else if defined(VBOX_JAVA_VERSION) && $(VBOX_JAVA_VERSION) >= 10900
8413 VBOX_JAVA_WS_OPTS ?= --add-modules java.xml.ws
8414endif
8415if defined(VBOX_JAVA_VERSION) && $(VBOX_JAVA_VERSION) >= 110000
8416 VBOX_JAVAC_OPTS = -encoding UTF-8 -source 9 -target 9 -Xlint:unchecked
8417else if defined(VBOX_JAVA_VERSION) && $(VBOX_JAVA_VERSION) >= 90000
8418 VBOX_JAVAC_OPTS = -encoding UTF-8 -source 6 -target 6 -Xlint:unchecked
8419else
8420 VBOX_JAVAC_OPTS = -encoding UTF-8 -source 1.5 -target 1.5 -Xlint:unchecked
8421endif
8422VBOX_JAVADOC_OPTS = -encoding UTF-8
8423
8424
8425#
8426# Legacy.
8427#
8428## @todo try remove this.
8429ifneq ($(LOCALCFG),)
8430 include $(LOCALCFG)
8431endif
8432
8433
8434#
8435# For efficiently build serveral build types / archs.
8436#
8437both-debug-release both-release-debug: \
8438 build-release-$(KBUILD_TARGET_ARCH) \
8439 build-debug-$(KBUILD_TARGET_ARCH)
8440both-x86-amd64 both-amd64-x86: \
8441 build-$(KBUILD_TYPE)-x86 \
8442 build-$(KBUILD_TYPE)-x86
8443both-types-archs both-archs-types: \
8444 build-debug-x86 \
8445 build-release-x86 \
8446 build-debug-amd64 \
8447 build-release-amd64
8448
8449build-release-x86:
8450 +$(MAKE) KBUILD_TYPE=release KBUILD_TARGET_ARCH=x86
8451
8452build-debug-x86:
8453 +$(MAKE) KBUILD_TYPE=debug KBUILD_TARGET_ARCH=x86
8454
8455build-release-amd64:
8456 +$(MAKE) KBUILD_TYPE=release KBUILD_TARGET_ARCH=amd64
8457
8458build-debug-amd64:
8459 +$(MAKE) KBUILD_TYPE=debug KBUILD_TARGET_ARCH=amd64
8460
8461
8462#
8463# Some extra goals.
8464#
8465.PHONY: up update st stat status
8466up update::
8467 $(SVN) up
8468
8469up2 update2::
8470 $(SVN) up --ignore-externals
8471
8472st stat status:
8473 $(SVN) status
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