VirtualBox

source: vbox/trunk/Config.kmk@ 98374

Last change on this file since 98374 was 98332, checked in by vboxsync, 22 months ago

curl-7.87.0: switching to 7.87.0. bugref:10356

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