VirtualBox

source: vbox/trunk/Config.kmk@ 11410

Last change on this file since 11410 was 11392, checked in by vboxsync, 16 years ago
  • moved xpidl binary out of SDK to
  • improved Python example with easily extendable commands interpreter
  • more work on Python bindings
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 116.6 KB
Line 
1# $Id: Config.kmk 11392 2008-08-13 14:54:17Z 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-2007 Sun Microsystems, Inc.
11#
12# This file is part of VirtualBox Open Source Edition (OSE), as
13# available from http://www.virtualbox.org. This file is free software;
14# you can redistribute it and/or modify it under the terms of the GNU
15# General Public License as published by the Free Software Foundation,
16# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
17# distribution. VirtualBox OSE is distributed in the hope that it will
18# be useful, but WITHOUT ANY WARRANTY of any kind.
19#
20
21# Marker.
22VBOX_ROOT_CONFIG_KMK_INCLUDED = 1
23
24#
25# kBuild stuff
26#
27
28# Enable automatic installation of what's built.
29KBUILD_DO_AUTO_INSTALL := 1
30PASSES := $(filter-out PACKING,$(PASSES)) PACKING # temporary hack
31# Modify the order of the INSTALLS and OTHERS passes.
32DEFAULT_PASSES := BLDPROGS LIBRARIES DLLS BINARIES INSTALLS OTHERS
33# Modify the build types.
34## @todo checked and dbgopt
35KBUILD_BLD_TYPES = release profile debug kprofile
36
37# Install paths.
38PATH_INS := $(PATH_OUT)
39ifeq ($(KBUILD_TARGET),darwin)
40 INST_DIST = dist/
41 INST_SDK = $(INST_DIST)sdk/
42 INST_SDK_SAMPLES = $(INST_SDK)samples
43
44 # the bundles
45 INST_VIRTUALBOX = $(INST_DIST)VirtualBox.app/
46 INST_VBOXDRV = $(INST_DIST)VBoxDrv.kext/
47 INST_VBOXNETFLT = $(INST_DIST)VBoxNetFlt.kext/
48 INST_VBOXNETTAP = $(INST_DIST)VBoxNetTap.kext/
49 INST_VBOXUSB = $(INST_DIST)VBoxUSB.kext/
50
51 # put everything in the VirtualBox app bundle.
52 INST_BIN = $(INST_VIRTUALBOX)Contents/MacOS/
53 INST_DLL = $(INST_BIN)
54 INST_SYS = $(INST_BIN)
55 INST_TESTCASE = $(INST_BIN)testcase/
56 INST_ADDITIONS = $(INST_BIN)additions/
57
58 # other paths
59 INST_TESTSUITE = testsuite/
60 INST_LIB = lib/
61 INST_ADDITIONS_LIB = $(PATH_LIB)/additions/
62
63else
64
65 INST_BIN = bin/
66 INST_DIST = $(INST_BIN)
67 INST_DLL = $(INST_BIN)
68 INST_SDK = $(INST_BIN)sdk/
69 INST_SDK_SAMPLES = $(INST_SDK)samples
70 INST_DLL = $(INST_BIN)
71 INST_SYS = $(INST_BIN)
72 INST_TESTCASE = $(INST_BIN)testcase/
73 INST_ADDITIONS = $(INST_BIN)additions/
74
75 INST_TESTSUITE = testsuite/
76 INST_LIB = lib/
77 INST_ADDITIONS_LIB = $(INST_LIB)additions/
78endif
79
80PATH_BIN = $(patsubst %/,%,$(PATH_INS)/$(INST_BIN))
81PATH_DLL = $(patsubst %/,%,$(PATH_INS)/$(INST_DLL))
82PATH_SYS = $(patsubst %/,%,$(PATH_INS)/$(INST_SYS))
83PATH_LIB = $(patsubst %/,%,$(PATH_INS)/$(INST_LIB))
84PATH_DOC = $(PATH_OUT)/doc
85VBOX_PATH_SDK = $(patsubst %/,%,$(PATH_INS)/$(INST_SDK))
86VBOX_PATH_DIST = $(patsubst %/,%,$(PATH_INS)/$(INST_DIST))
87VBOX_PATH_TESTSUITE = $(patsubst %/,%,$(PATH_INS)/$(INST_TESTSUITE))
88VBOX_PATH_ADDITIONS = $(patsubst %/,%,$(PATH_INS)/$(INST_ADDITIONS))
89VBOX_PATH_ADDITIONS_LIB = $(patsubst %/,%,$(PATH_INS)/$(INST_ADDITIONS_LIB))
90
91
92# Delete targets on failure.
93.DELETE_ON_ERROR:
94
95# Notify about important kBuild updates.
96ifneq ($(call int-ge,$(KMK_REVISION),1650),1)
97 $(error You must update kBuild! KMK_REVISION=$(KMK_REVISION) KBUILD_PATH=$(KBUILD_PATH))
98endif
99
100#
101# Define USERNAME early on.
102#
103ifndef USERNAME
104 ifdef USER
105 USERNAME = $(USER)
106 else
107 $(warning Warning: You must have USERNAME or USER in your environment.)
108 endif
109endif
110
111#
112# The VirtualBox version.
113#
114
115# Major version.
116VBOX_VERSION_MAJOR = 1
117# Minor version.
118VBOX_VERSION_MINOR = 6
119# This is the current build number. It should be increased every time we publish a
120# new build. The define is available in every source file. Only even build numbers
121# will be published, odd numbers are set during development.
122VBOX_VERSION_BUILD = 51
123# Full version string (may include more than just x.y.z, but no spaces or other problematic chars).
124VBOX_VERSION_STRING = $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD)
125# Force the additions.sh script to get an exact additions build when we're doing the release.
126ifeq ($(int-mod $(VBOX_VERSION_BUILD),2),0)
127 export VBOX_ADDITIONS_SH_MODE = release
128endif
129
130
131#
132# The VirtualBox package type.
133#
134ifeq ($(KBUILD_TARGET),win)
135 VBOX_PACKAGE_OS = WINDOWS
136else ifeq ($(KBUILD_TARGET),linux)
137 VBOX_PACKAGE_OS = LINUX
138else ifeq ($(KBUILD_TARGET),darwin)
139 VBOX_PACKAGE_OS = DARWIN
140else ifeq ($(KBUILD_TARGET),solaris)
141 VBOX_PACKAGE_OS = SOLARIS
142else if1of ($(KBUILD_TARGET), dragonfly freebsd netbsd openbsd)
143 VBOX_PACKAGE_OS = BSD
144else
145 $(error Cannot determine VBOX_PACKAGE_OS)
146endif
147ifeq ($(KBUILD_TARGET_ARCH),x86)
148 VBOX_PACKAGE_ARCH = 32BITS
149else
150 VBOX_PACKAGE_ARCH = 64BITS
151endif
152# distribution, mostly for Linux/Solaris where we support different distributions
153# this strip will be overridden by the Linux packaging scripts
154VBOX_PACKAGE_DIST ?= GENERIC
155# Full string
156VBOX_PACKAGE_STRING = $(VBOX_PACKAGE_OS)_$(VBOX_PACKAGE_ARCH)_$(VBOX_PACKAGE_DIST)
157
158
159#
160# The VirtualBox Configuration Defaults.
161#
162# We try to document all the build configuration options here, thing which
163# aren't enabled by default is left commented out just to show that they
164# exist and which value they should have (usually 1, but anyway).
165#
166
167# This indicates that additions (of some kind or another) is being _built_.
168# VBOX_WITHOUT_ADDITIONS overrides it.
169#if1of ($(KBUILD_TARGET), freebsd linux os2 solaris win)
170if1of ($(KBUILD_TARGET), linux solaris win)
171 VBOX_WITH_ADDITIONS = 1
172endif
173# Build the optional ring-0 part of the additions for syntax checking.
174# (Except when cross-building on linux since we're using /usr/src/...)
175ifn1of ($(KBUILD_TARGET).$(KBUILD_HOST_ARCH).$(KBUILD_TARGET_ARCH), linux.x86.amd64 linux.amd64.x86)
176 VBOX_WITH_ADDITION_DRIVERS = 1
177endif
178# Build X11 additions. Can be disabled separately.
179if1of ($(KBUILD_TARGET), dragonfly freebsd linux netbsd openbsd solaris)
180 VBOX_WITH_X11_ADDITIONS = 1
181endif
182# Enable the building of shared folders in the windows additions.
183VBOX_WITH_WIN32_ADDITIONS_SHAREDFOLDERS = 1
184# Take the binaries of the OS/2 Additions.
185VBOX_WITH_OS2_ADDITIONS_BIN = 1
186# Use additions from the build server.
187#VBOX_WITH_ADDITIONS_FROM_BUILD_SERVER = 1
188# Don't bother with additions, overrides VBOX_WITH_ADDITIONS.
189# This is not used by makefiles, only Config.kmk, see below.
190#VBOX_WITHOUT_ADDITIONS = 1
191# Only build the additions (for the additions build server).
192#VBOX_ONLY_ADDITIONS = 1
193ifdef VBOX_ADDITIONS_ONLY # typical mistake.
194 $(error It is VBOX_ONLY_ADDITIONS=1 not VBOX_ADDITIONS_ONLY!)
195endif
196# Don't create the additions ISO.
197# (Used by the additions build server, don't invert it.)
198#VBOX_WITHOUT_ADDITIONS_ISO = 1
199
200# build the installer
201VBOX_WITH_INSTALLER = 1
202# enable VRDP server
203VBOX_WITH_VRDP = 1
204# build VRDP authentication modules
205VBOX_WITH_VRDP_AUTHMOD = 1
206# build enhanced version of rdesktop
207VBOX_WITH_VRDP_RDESKTOP = 1
208if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), win.x86 l4.x86 l4.amd64)
209# build the support driver & library with IDT patching.
210VBOX_WITH_IDT_PATCHING = 1
211endif
212# Activate this to force the VM to pre-allocate the guest RAM before startup
213VBOX_WITH_PREALLOC_RAM_BY_DEFAULT =
214# The kernel driver/module and related runtime libraries.
215VBOX_WITH_VBOXDRV = 1
216# build with secure label support
217ifeq ($(filter win.amd64,$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),) # too much work with freetype and all that.
218VBOX_WITH_SECURELABEL = 1
219endif
220
221# The main api.
222VBOX_WITH_MAIN = 1
223# The webservices api.
224VBOX_WITH_WEBSERVICES = 1
225# The SDL based GUI.
226VBOX_WITH_VBOXSDL = 1
227# The basic frontend (w/o Main).
228VBOX_WITH_VBOXBFE = 1
229# The Qt GUI.
230VBOX_WITH_QTGUI = 1
231# The Qt 4 GUI (experimental).
232VBOX_WITH_QT4GUI = 1
233# The headless frontend.
234VBOX_WITH_HEADLESS = 1
235## the Direct Framebuffer GUI
236#VBOX_WITH_VBOXFB = 1
237# Enable the debugger.
238ifneq ($(KBUILD_TYPE),release)
239 VBOX_WITH_DEBUGGER = 1
240 # Enable the debugger GUI.
241 VBOX_WITH_DEBUGGER_GUI = 1
242endif
243# the documentation
244VBOX_WITH_DOCS = 1
245# build the Host Guest Communication Manager component
246VBOX_WITH_HGCM = 1
247# Enable the USB feature.
248VBOX_WITH_USB = 1
249# Enable the USB 2.0 controller
250VBOX_WITH_EHCI = 1
251# Enable the ISCSI feature.
252VBOX_WITH_ISCSI = 1
253# Enable the E1000 feature
254VBOX_WITH_E1000 = 1
255# Enable ALSA support for Linux
256VBOX_WITH_ALSA = 1
257# Enable Pulse support for Linux
258VBOX_WITH_PULSE = 1
259# Disable WINMM support for Windows (not implemented)
260VBOX_WITH_WINMM =
261# Enable the kchmviewer
262VBOX_WITH_KCHMVIEWER = 1
263# Build the testsuite.
264VBOX_WITH_TESTSUITE = 1
265# Build the testcases.
266VBOX_WITH_TESTCASES = 1
267# Set this to not use COM or XPCOM in places where it can be avoided.
268#VBOX_WITHOUT_COM = 1
269# Set this to skip installing the redistributable compiler runtime.
270#VBOX_WITHOUT_COMPILER_REDIST = 1
271# Enabled internal networking.
272VBOX_WITH_INTERNAL_NETWORKING = 1
273# Enables the ffmpeg module for recording test runs.
274# Enable this for non-Linux builds later.
275ifeq ($(KBUILD_TARGET),linux)
276# VBOX_WITH_FFMPEG = 1
277endif
278# Enable OpenGL service
279VBOX_WITH_OGL = 1
280# Enable shared folders
281VBOX_WITH_SHARED_FOLDERS = 1
282# Enable shared clipboard
283VBOX_WITH_SHARED_CLIPBOARD = 1
284# Enable the Intel PXE ROM (replaces Etherboot).
285VBOX_WITH_INTEL_PXE = 1
286# Strip binaries of release and profile builds
287VBOX_DO_STRIP = $(if $(filter release profile,$(KBUILD_TYPE)),1,)
288# Strip R0/GC modules (current requirement for our loader)
289VBOX_DO_STRIP_MODULES = 1
290# Use kStuff for MACH-O and LX binary loading.
291if1of ($(KBUILD_TARGET),darwin os2)
292IPRT_WITH_KSTUFF = 1
293endif
294# Enable Crossbow support for Solaris.
295VBOX_WITH_CROSSBOW = 1
296# Enable setuid wrapper for Solaris.
297#VBOX_WITH_SUID_WRAPPER = 1
298# Enable the PDM Lock and let I/O threads call into the PICs.
299VBOX_WITH_PDM_LOCK = 1
300# Enable Seamless mode
301VBOX_X11_SEAMLESS_GUEST = 1
302# Enable the virtual SATA/AHCI controller
303VBOX_WITH_AHCI = 1
304# Enable the new async completion manager
305VBOX_WITH_PDM_ASYNC_COMPLETION = 1
306# Enable use of the $ORIGIN rpath feature. This is the default on
307# Solaris, but not else where for various reasons (ld.so, dist builds).
308ifeq ($(KBUILD_TARGET),solaris)
309 VBOX_WITH_ORIGIN = 1
310endif
311# Temporary switch for enabling / disabling the new USB code on Darwin.
312VBOX_WITH_NEW_USB_CODE_ON_DARWIN=1
313# Use the new VBI module on Solaris.
314VBOX_WITH_SOLARIS_VBI = 1
315# Enable 64 bits guest pointers.
316if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), linux.amd64 solaris.amd64 win.amd64)
317VBOX_WITH_64_BITS_GUESTS = 1
318else
319# VBOX_WITH_64_BITS_GUESTS = 1
320endif
321# Enable the host/guest information service (aka guest properties).
322VBOX_WITH_GUEST_PROPS = 1
323# Enable performance API.
324VBOX_WITH_RESOURCE_USAGE_API = 1
325# Enables all the doxgen bits.
326VBOX_WITH_ALL_DOXYGEN_TARGETS = 1
327
328
329#
330# Skip stuff.
331#
332
333# VBOX_QUICK can be used by core developers to speed to the build
334ifdef VBOX_QUICK
335 # undefine variables by assigning blank.
336 VBOX_WITH_TESTSUITE=
337 VBOX_WITH_TESTCASES=
338 VBOX_WITH_MAIN =
339 VBOX_WITH_VBOXSDL =
340 VBOX_WITH_VBOXBFE =
341 VBOX_WITH_QTGUI =
342 VBOX_WITH_QT4GUI =
343 VBOX_WITH_DEBUGGER_GUI =
344 VBOX_WITH_DOCS =
345endif # VBOX_QUICK
346
347ifeq ($(KBUILD_TARGET),darwin)
348 # Don't bother with SDL ttf for now.
349 VBOX_WITH_SECURELABEL=
350 # We'll use the native html/help viewer.
351 VBOX_WITH_KCHMVIEWER=
352 # Later:
353 VBOX_WITH_VRDP_AUTHMOD=
354 VBOX_WITH_VRDP_RDESKTOP=
355 VBOX_WITH_PDM_ASYNC_COMPLETION=
356endif
357
358ifeq ($(KBUILD_TARGET),freebsd)
359 VBOX_WITH_INSTALLER=
360 VBOX_WITH_SECURELABEL=
361 VBOX_WITH_VRDP_AUTHMOD=
362 VBOX_WITH_VRDP_RDESKTOP=
363 VBOX_WITH_TESTSUITE=
364 VBOX_WITH_USB=
365 VBOX_WITH_EHCI=
366 VBOX_WITH_DOCS=
367 VBOX_WITH_KCHMVIEWER=
368endif
369
370ifeq ($(KBUILD_TARGET),l4)
371 VBOX_WITH_VBOXDRV=
372 VBOX_WITH_ADDITION_DRIVERS=
373 VBOX_WITH_VRDP=
374 VBOX_WITH_HEADLESS=
375 VBOX_WITH_VBOXSDL=
376 VBOX_WITH_QTGUI=
377 VBOX_WITH_QT4GUI=
378 VBOX_WITH_MAIN=
379 VBOX_WITH_DOCS=
380 VBOX_WITH_ISCSI=
381 VBOX_WITH_INTERNAL_NETWORKING=
382 VBOX_WITH_PDM_ASYNC_COMPLETION=
383 VBOX_WITH_KCHMVIEWER=
384endif
385
386ifeq ($(KBUILD_TARGET),os2)
387 VBOX_WITH_INSTALLER=
388 VBOX_WITH_SECURELABEL=
389 VBOX_WITH_VRDP_AUTHMOD=
390 VBOX_WITH_VRDP_RDESKTOP=
391 VBOX_WITH_TESTSUITE=
392 VBOX_WITH_QT4GUI=
393 VBOX_WITH_USB=
394 VBOX_WITH_EHCI=
395 VBOX_WITH_DOCS=
396 VBOX_WITH_PDM_ASYNC_COMPLETION=
397 VBOX_WITH_KCHMVIEWER=
398endif
399
400ifeq ($(KBUILD_TARGET),solaris)
401 VBOX_WITH_SECURELABEL=
402 VBOX_WITH_VRDP_AUTHMOD=
403 VBOX_WITH_VRDP_RDESKTOP=
404 VBOX_WITH_USB=
405 VBOX_WITH_OGL=
406endif
407
408ifeq ($(KBUILD_TARGET),win)
409 VBOX_WITH_VRDP_RDESKTOP=
410 VBOX_WITH_KCHMVIEWER=
411endif
412
413
414#
415# Include automatic and local config file to override the above settings
416# and to provide defaults for the settings below this point.
417#
418AUTOCFG := $(wildcard $(PATH_ROOT)/AutoConfig.kmk)
419ifeq ($(AUTOCFG),)
420 # deprecated name. to be removed.
421 AUTOCFG := $(wildcard $(PATH_ROOT)/Config.kmkconf)
422 ifneq ($(AUTOCFG),)
423 $(warning Config.kmkconf has been renamed. Please re-run configure.)
424 endif
425endif
426ifneq ($(AUTOCFG),)
427 include $(AUTOCFG)
428endif
429
430LOCALCFG := $(wildcard $(PATH_ROOT)/LocalConfig.kmk)
431ifeq ($(LOCALCFG),)
432 # deprecated name. to be removed.
433 LOCALCFG := $(wildcard $(PATH_ROOT)/Config.kmklocal)
434 ifneq ($(LOCALCFG),)
435 $(warning Please rename your Config.kmklocal to LocalConfig.kmk.)
436 endif
437endif
438ifneq ($(LOCALCFG),)
439 include $(LOCALCFG)
440endif
441
442
443#
444# Disable components that are not open sourced.
445#
446ifdef VBOX_OSE
447 VBOX_WITH_WEBSERVICES=
448 VBOX_WITH_VRDP=
449 VBOX_WITH_USB=
450 VBOX_WITH_EHCI=
451 VBOX_WITH_ISCSI=
452 VBOX_WITH_E1000=
453 VBOX_WITH_DEBUGGER_GUI=
454 VBOX_WITH_WIN32_ADDITIONS_SHAREDFOLDERS=
455 VBOX_WITHOUT_ADDITIONS_ISO=1
456 VBOX_WITH_OS2_ADDITIONS_BIN=
457 VBOX_WITH_SECURELABEL=
458 VBOX_WITH_KCHMVIEWER=
459 VBOX_WITH_DOCS=
460 VBOX_WITH_TESTSUITE=
461 VBOX_WITH_INTEL_PXE=
462 ifeq ($(KBUILD_TARGET),darwin)
463 # Qt/Mac v3.3.x requires patching to work for us.
464 VBOX_WITH_QTGUI=
465 endif
466 ifn1of ($(KBUILD_TARGET),linux solaris)
467 # Only the Linux, Solaris installers are public
468 VBOX_WITH_INSTALLER=
469 endif
470 VBOX_WITH_AHCI=
471 VBOX_WITH_PDM_ASYNC_COMPLETION=
472endif
473
474#
475# Sanitize the additions build config variables.
476#
477ifdef VBOX_WITH_ADDITIONS_FROM_BUILD_SERVER
478 VBOX_WITHOUT_ADDITIONS := 1
479 ifdef VBOX_ONLY_ADDITIONS
480 $(error VBOX_ONLY_ADDITIONS + VBOX_WITH_ADDITIONS_FROM_BUILD_SERVER does not add up!)
481 endif
482endif
483
484ifdef VBOX_ONLY_ADDITIONS
485 ifdef VBOX_WITHOUT_ADDITIONS
486 $(error VBOX_ONLY_ADDITIONS + VBOX_WITHOUT_ADDITIONS does not add up!)
487 endif
488endif
489
490ifdef VBOX_WITHOUT_ADDITIONS
491 # Zap anything that could be contradicting this.
492 VBOX_WITH_ADDITIONS :=
493endif
494
495#
496# Disable components for headless
497#
498ifdef VBOX_HEADLESS
499 VBOX_WITH_QTGUI=
500 VBOX_WITH_VBOXSDL=
501 VBOX_WITH_VBOXBFE=
502 VBOX_WITH_OGL=
503 VBOX_WITH_KCHMVIEWER=
504endif
505
506#
507# Undefined VBOX_WITH_MAIN implies exclusion of a few more items.
508#
509ifndef VBOX_WITH_MAIN
510 VBOX_WITH_VRDP=
511 VBOX_WITH_VBOXSDL=
512 VBOX_WITH_QTGUI=
513 VBOX_WITH_DEBUGGER_GUI=
514 VBOX_WITH_HEADLESS=
515endif
516
517#
518# Mark OSE builds clearly, helps figuring out limitations more easily.
519#
520ifdef VBOX_OSE
521VBOX_VERSION_STRING = $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD)_OSE
522endif
523
524
525#
526# Image and object format config.
527#
528if1of ($(KBUILD_TARGET), linux l4 freebsd netbsd openbsd solaris)
529 VBOX_LDR_FMT = elf
530endif
531ifeq ($(KBUILD_TARGET),darwin)
532 VBOX_LDR_FMT = macho
533endif
534ifeq ($(KBUILD_TARGET),os2)
535 VBOX_LDR_FMT = lx
536 VBOX_LDR_FMT32 = lx
537 VBOX_LDR_FMT64 = elf
538 DONT_USE_YASM = 1 # yasm doesn't implement omf yet.
539endif
540ifeq ($(KBUILD_TARGET),win)
541 VBOX_LDR_FMT = pe
542endif
543VBOX_LDR_FMT32 ?= $(VBOX_LDR_FMT)
544VBOX_LDR_FMT64 ?= $(VBOX_LDR_FMT)
545
546#
547# Assembler setup.
548#
549# This is a bit complicated since we have to support two different assmblers
550# (yasm/nasm) and possibly two different formats (32-bit/64-bit).
551#
552ifeq ($(VBOX_LDR_FMT),elf)
553 ifeq ($(KBUILD_TARGET_ARCH),x86)
554VBOX_ASFLAGS_FMT = -f elf32 -DASM_FORMAT_ELF
555 else
556VBOX_ASFLAGS_FMT = -f elf64 -DASM_FORMAT_ELF
557 endif
558 VBOX_ASFLAGS_DBFINFO = -g dwarf2
559endif
560ifeq ($(VBOX_LDR_FMT),lx)
561 VBOX_ASFLAGS_FMT = -f obj -DASM_FORMAT_OMF
562 VBOX_ASFLAGS_DBFINFO = -g stabs
563endif
564ifeq ($(VBOX_LDR_FMT),macho)
565 VBOX_ASFLAGS_FMT = -f macho -DASM_FORMAT_MACHO
566 VBOX_ASFLAGS_DBFINFO = -g dwarf2
567endif
568ifeq ($(VBOX_LDR_FMT),pe)
569 ifeq ($(KBUILD_TARGET_ARCH),x86)
570VBOX_ASFLAGS_FMT = -f win32 -DASM_FORMAT_PE
571 else
572VBOX_ASFLAGS_FMT = -f win64 -DASM_FORMAT_PE
573 endif
574VBOX_ASFLAGS_DBFINFO = -g cv8
575endif
576ifndef VBOX_ASFLAGS_FMT
577 $(error VBOX_ASFLAGS_FMT is not defined. VBOX_LDR_FMT=$(VBOX_LDR_FMT))
578endif
579
580ifeq ($(VBOX_LDR_FMT32),elf)
581 VBOX_ASFLAGS_FMT32 = -f elf32 -DASM_FORMAT_ELF
582 VBOX_ASFLAGS_DBFINFO32 = -g dwarf2
583endif
584ifeq ($(VBOX_LDR_FMT32),lx)
585 VBOX_ASFLAGS_FMT32 = -f obj -DASM_FORMAT_OMF
586 VBOX_ASFLAGS_DBFINFO32 = -g stabs
587endif
588ifeq ($(VBOX_LDR_FMT32),macho)
589 VBOX_ASFLAGS_FMT32 = -f macho -DASM_FORMAT_MACHO
590 VBOX_ASFLAGS_DBFINFO32 = -g dwarf2
591endif
592ifeq ($(VBOX_LDR_FMT32),pe)
593 VBOX_ASFLAGS_FMT32 = -f win32 -DASM_FORMAT_PE
594 VBOX_ASFLAGS_DBFINFO32 = -g cv8
595endif
596ifndef VBOX_ASFLAGS_FMT32
597 $(error VBOX_ASFLAGS_FMT32 is not defined. VBOX_LDR_FMT32=$(VBOX_LDR_FMT32))
598endif
599
600ifeq ($(VBOX_LDR_FMT64),elf)
601 VBOX_ASFLAGS_FMT64 = -f elf64 -DASM_FORMAT_ELF
602 VBOX_ASFLAGS_DBFINFO64 = -g dwarf2
603endif
604ifeq ($(VBOX_LDR_FMT64),macho)
605 VBOX_ASFLAGS_FMT64 = -f macho64 -DASM_FORMAT_MACHO
606 VBOX_ASFLAGS_DBFINFO64 = -g dwarf2
607endif
608ifeq ($(VBOX_LDR_FMT64),pe)
609 VBOX_ASFLAGS_FMT64 = -f win64 -DASM_FORMAT_PE
610 VBOX_ASFLAGS_DBFINFO64 = -g cv8
611endif
612ifndef VBOX_ASFLAGS_FMT64
613 $(error VBOX_ASFLAGS_FMT64 is not defined. VBOX_LDR_FMT64=$(VBOX_LDR_FMT64))
614endif
615
616ifndef DONT_USE_YASM
617 VBOX_ASTOOL = YASM
618 VBOX_LDR_FMT_2_YASM_DBGINFO.elf = -g dwarf2
619 VBOX_LDR_FMT_2_YASM_DBGINFO.lx = -g stabs
620 VBOX_LDR_FMT_2_YASM_DBGINFO.macho =
621 VBOX_LDR_FMT_2_YASM_DBGINFO.pe = -g cv8
622 VBOX_ASFLAGS = $(VBOX_ASFLAGS_FMT) -D__YASM__ -Worphan-labels $(VBOX_LDR_FMT_2_YASM_DBGINFO.$(VBOX_LDR_FMT))
623 VBOX_ASFLAGS32 = $(VBOX_ASFLAGS_FMT32) -D__YASM__ -Worphan-labels $(VBOX_LDR_FMT_2_YASM_DBGINFO.$(VBOX_LDR_FMT32))
624 VBOX_ASFLAGS64 = $(VBOX_ASFLAGS_FMT64) -D__YASM__ -Worphan-labels $(VBOX_LDR_FMT_2_YASM_DBGINFO.$(VBOX_LDR_FMT64))
625else
626 VBOX_ASTOOL = NASM
627 VBOX_ASFLAGS = $(subst elf32,elf,$(VBOX_ASFLAGS_FMT)) -D__NASM__ -w+orphan-labels -g
628 VBOX_ASFLAGS32 = $(subst elf32,elf,$(VBOX_ASFLAGS_FMT32)) -D__NASM__ -w+orphan-labels -g
629 VBOX_ASFLAGS64 = $(VBOX_ASFLAGS_FMT64) -D__NASM__ -w+orphan-labels -g
630endif
631
632#
633# Windows only has mingw handy. On *nix we have to deal with cross compiling
634# 32-bit targets on 64-bit platforms, meaning we'll be using gcc32/g++32.
635# In the latter case we'll also have to disable all the all the R0 driver related stuff.
636#
637ifndef VBOX_GCC_TOOL
638 ifeq ($(KBUILD_TARGET),win)
639 VBOX_GCC_TOOL := MINGW32
640 TOOL_MINGW32_CFLAGS := $(UNDEFINED) # override -g
641 else ifeq ($(KBUILD_TARGET),os2)
642 VBOX_GCC_TOOL := GXX3OMF
643 else ifeq ($(KBUILD_TARGET),darwin)
644 VBOX_GCC_TOOL := GXX4MACHO
645 else ifeq ($(KBUILD_TARGET),solaris)
646 VBOX_GCC_TOOL := GXX3PLAIN
647 VBOX_GCC32_TOOL := GXX3PLAIN
648 else
649 VBOX_GCC_TOOL := GXX3
650 ifeq ($(KBUILD_TARGET_ARCH).$(KBUILD_HOST_ARCH),x86.amd64) ## @todo mixing target/host here!
651 VBOX_GCC_TOOL := GXX32
652 VBOX_WITH_VBOXDRV=
653 else ifeq ($(KBUILD_TARGET_ARCH).$(KBUILD_HOST_ARCH),amd64.x86)
654 VBOX_GCC_TOOL := GXX64
655 VBOX_WITH_VBOXDRV=
656 endif
657 endif
658endif
659ifndef VBOX_GCC32_TOOL
660 ifeq ($(KBUILD_TARGET_ARCH),x86)
661 VBOX_GCC32_TOOL := $(VBOX_GCC_TOOL)
662 else ifeq ($(KBUILD_TARGET),win)
663 VBOX_GCC32_TOOL := MINGW32
664 else
665 VBOX_GCC32_TOOL := GXX32
666 endif
667endif
668
669#
670# Decide which Visual C++ compiler version we're using by default.
671#
672ifndef VBOX_VCC_TOOL
673 ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),win.amd64)
674 VBOX_USE_VCC80 ?= 1 # Enforce VCC80 when targetting AMD64.
675 endif
676 ifdef VBOX_USE_VCC80
677 ifeq ($(KBUILD_TARGET_ARCH),x86)
678 VBOX_VCC_TOOL := VCC80X86
679 else
680 VBOX_VCC_TOOL := VCC80AMD64
681 endif
682 else
683 VBOX_VCC_TOOL := VCC70
684 endif
685endif
686
687#
688# The kBuild tools and SDKs are using PATH_DEVTOOLS, PATH_DEVTOOLS_BLD
689# and PATH_DEVTOOLS_TRG to find things if we give them specific locations.
690#
691PATH_DEVTOOLS ?= $(PATH_ROOT)/tools
692PATH_DEVTOOLS := $(abspath $(PATH_DEVTOOLS))
693PATH_DEVTOOLS_BLD ?= $(PATH_DEVTOOLS)/$(KBUILD_HOST).$(KBUILD_HOST_ARCH)
694PATH_DEVTOOLS_TRG ?= $(PATH_DEVTOOLS)/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)
695
696## @todo Remove the default tool crap here!
697TOOL = $(VBOX_GCC_TOOL)
698ifdef VBOX_USE_VCC80
699 TOOL.win.x86 = VCC80X86
700 TOOL.win.amd64 = VCC80AMD64
701else
702 TOOL.win = VCC70
703endif
704ASTOOL = $(VBOX_ASTOOL)
705
706#
707# L4-specific settings.
708#
709ifdef L4_DIR
710 ifeq ($(KBUILD_TARGET),l4)
711 L4_API ?= l4v2
712 L4_ARCH ?= $(KBUILD_TARGET_ARCH)
713 ifeq ($(L4_ARCH),x86)
714 L4_CPU ?= 586
715 L4LINUX26_INCDIR := $(L4LINUX26_DIR)/include \
716 $(L4LINUX26_DIR)/include/asm-l4/i386-arch
717 else ifeq ($(L4_ARCH),amd64)
718 L4_CPU ?= k8
719 L4LINUX26_INCDIR := $(L4LINUX26_DIR)/include
720 # no red zone for L4 because of IPC bindings
721 CFLAGS.l4 = -mno-red-zone
722 CXXFLAGS.l4 = -mno-red-zone
723 else
724 $(error L4_ARCH=$(L4_ARCH))
725 endif
726 L4_OBJ := $(L4_DIR)/build-$(L4_ARCH)-$(L4_CPU)-$(L4_API)
727 # support splitted Linux kernels (make O=<build directory>)
728 kernelsrc := $(shell $(SED_EXT) -ne 's+^KERNELSRC.*= *\(.*\)+\1+p' $(L4LINUX26_DIR)/Makefile)
729 ifneq ($(kernelsrc),)
730 kernelpath := $(realpath $(kernelsrc))
731 L4LINUX26_INCDIR += $(L4LINUX26_DIR)/include2 $(kernelpath)/include
732 endif
733 L4_INCDIR := \
734 $(L4_OBJ)/include/uclibc++ \
735 $(L4_OBJ)/include/$(L4_ARCH)/uclibc \
736 $(L4_OBJ)/include/uclibc \
737 $(L4LINUX26_INCDIR) \
738 $(L4_OBJ)/include/$(L4_ARCH)/$(L4_API) \
739 $(L4_OBJ)/include/$(L4_API) \
740 $(L4_OBJ)/include/$(L4_ARCH) \
741 $(L4_OBJ)/include \
742 $(L4_DIR)/tool/dice/include
743 L4_LIBDIR := \
744 $(L4_DIR)/build-$(L4_ARCH)-$(L4_CPU)-$(L4_API)/lib/$(L4_ARCH)_$(L4_CPU)/$(L4_API)
745 endif # KBUILD_TARGET == l4
746endif # L4_DIR
747
748# Produce debugging information that the Fiasco kernel debugger can read.
749ifeq ($(KBUILD_TARGET).$(KBUILD_TYPE),l4.debug)
750 DEBUG_L4 = -gstabs+
751endif
752
753#
754# Setup the global defines and includes.
755#
756# Note! The __SOMETHING__ #defines are deprecated as they violate the C/C++ specs.
757#
758INCS += $(PATH_ROOT)/include $(PATH_OUT)
759DEFS += VBOX
760DEFS.debug := DEBUG DEBUG_$(subst $(subst _, ,_),_,$(USERNAME)) DEBUG_USERNAME=$(subst $(subst _, ,_),_,$(USERNAME))
761DEFS.profile = VBOX_WITH_STATISTICS
762DEFS.x86 = RT_ARCH_X86 __X86__
763DEFS.amd64 = RT_ARCH_AMD64 __AMD64__
764DEFS.darwin = RT_OS_DARWIN __DARWIN__
765DEFS.darwin.x86 = VBOX_WITH_HYBIRD_32BIT_KERNEL
766DEFS.freebsd = RT_OS_FREEBSD __FREEBSD__
767DEFS.l4 = RT_OS_L4 __L4__ __L4ENV__ L4API_l4v2 ARCH_$(KBUILD_TARGET_ARCH) __NO_CTYPE _FILE_OFFSET_BITS=64
768DEFS.linux = RT_OS_LINUX _FILE_OFFSET_BITS=64
769DEFS.netbsd = RT_OS_NETBSD
770DEFS.openbsd = RT_OS_OPENBSD
771DEFS.os2 = RT_OS_OS2 __OS2__
772DEFS.solaris = RT_OS_SOLARIS _FILE_OFFSET_BITS=64
773DEFS.win = RT_OS_WINDOWS __WIN__
774DEFS.win.x86 = __WIN32__
775DEFS.win.amd64 = __WIN64__
776# optional defines (use environment or make commandline)
777ifdef VBOX_WITH_DEBUGGER
778 DEFS += VBOX_WITH_DEBUGGER
779endif
780ifdef VBOX_WITH_DEBUGGER_GUI
781 DEFS += VBOX_WITH_DEBUGGER_GUI
782endif
783ifdef VBOX_WITH_STATISTICS
784 DEFS += VBOX_WITH_STATISTICS
785endif
786ifdef VBOX_STRICT
787 DEFS += VBOX_STRICT
788endif
789ifdef LOG_ENABLED
790 DEFS += LOG_ENABLED
791endif
792ifdef VBOX_OSE
793 DEFS += VBOX_OSE
794endif
795ifdef VBOX_WITH_NEW_PHYS_CODE
796 DEFS += VBOX_WITH_NEW_PHYS_CODE
797endif
798ifdef VBOX_WITH_64_BITS_GUESTS
799 DEFS += VBOX_WITH_64_BITS_GUESTS
800endif
801## @todo eliminate these guys.
802ifdef VBOX_WITH_INTERNAL_NETWORKING
803DEFS += VBOX_WITH_INTERNAL_NETWORKING
804endif
805
806#
807# Compiler optimization flags.
808#
809ifeq ($(KBUILD_TYPE),debug)
810 VBOX_GCC_FP ?= -fno-omit-frame-pointer
811 VBOX_GCC_OPT ?= -O0
812 VBOX_VCC_FP ?= -Oy-
813 VBOX_VCC_OPT ?=
814 VBOX_GCC_GC_FP ?= -fno-omit-frame-pointer
815 VBOX_GCC_GC_OPT ?= -O0
816 VBOX_VCC_GC_FP ?= -Oy-
817 VBOX_VCC_GC_OPT ?=
818else
819 # We should use -fomit-frame-pointer for GCC / -Oy for VCC.
820 # -funwind-tables provides support for backtraces in gdb then.
821 VBOX_GCC_FP ?= -fno-omit-frame-pointer
822 VBOX_GCC_OPT ?= -O2 $(VBOX_GCC_mtune-generic)
823 VBOX_VCC_FP ?= -Oy-
824 ifdef VBOX_USE_VCC80
825 VBOX_VCC_OPT ?= -O2 -GS-
826 else
827 VBOX_VCC_OPT ?= -Ogitb2
828 endif
829 VBOX_GCC_GC_FP ?= -fno-omit-frame-pointer
830 VBOX_GCC_GC_OPT ?= -O2 $(VBOX_GCC_mtune-generic)
831 VBOX_VCC_GC_FP ?= -Oy-
832 ifdef VBOX_USE_VCC80
833 VBOX_VCC_GC_OPT ?= -O2
834 else
835 VBOX_VCC_GC_OPT ?= -Ogitb2
836 endif
837endif
838
839#
840# ARCH_BITS_DEFS.
841#
842ifeq ($(KBUILD_TARGET_ARCH),amd64)
843 ARCH_BITS_DEFS := HC_ARCH_BITS=64
844else ifeq ($(KBUILD_TARGET_ARCH),x86)
845 ARCH_BITS_DEFS := HC_ARCH_BITS=32
846else
847 error KBUILD_TARGET_ARCH=$(KBUILD_TARGET_ARCH)
848endif
849
850ifdef VBOX_WITH_64_BITS_GUESTS
851 VBOX_GC_ARCH_BITS_DEFS := GC_ARCH_BITS=64
852else
853 VBOX_GC_ARCH_BITS_DEFS := GC_ARCH_BITS=32
854endif
855ARCH_BITS_DEFS += $(VBOX_GC_ARCH_BITS_DEFS)
856
857#
858# Add the output dir(s) to the dynamic loader search path.
859#
860if1of ($(KBUILD_TARGET), linux l4 freebsd netbsd openbsd solaris)
861 export LD_LIBRARY_PATH:=$(PATH_BIN):$(PATH_LIB):$(LD_LIBRARY_PATH)
862endif
863ifeq ($(KBUILD_TARGET),os2)
864 #fixme! export BEGINLIBPATH:=$(PATH_BIN);$(PATH_LIB);$(BEGINLIBPATH)
865endif
866ifeq ($(KBUILD_TARGET),win)
867 export PATH:=$(PATH_BIN);$(PATH_LIB);$(PATH)
868endif
869
870#
871# Common libraries and tools.
872#
873ifeq ($(KBUILD_TARGET),darwin)
874 LIB_RUNTIME = $(PATH_BIN)/VBoxRT.dylib
875 LIB_RUNTIME_EF = #$(PATH_LIB)/RuntimeEFCPP.a
876 LIB_KPROFILE = $(PATH_BIN)/kPrf2.dylib
877 LIB_VMM = $(PATH_BIN)/VBoxVMM.dylib
878 LIB_VMMGC = $(PATH_BIN)/VMMGC.gc
879 LIB_REM = $(PATH_LIB)/VBoxREMImp.dylib
880 LIB_XPCOM = $(PATH_BIN)/VBoxXPCOM.dylib
881 LIB_DDU = $(PATH_BIN)/VBoxDDU.dylib
882 LIB_SETTINGS = $(PATH_BIN)/VBoxSettings.dylib
883endif
884ifeq ($(KBUILD_TARGET),l4)
885 LIB_RUNTIME = $(PATH_BIN)/VBoxRT.s.so
886 LIB_RUNTIME_EF = #$(PATH_LIB)/RuntimeEFCPP.a
887 LIB_KPROFILE = $(PATH_BIN)/kPrf2.s.so
888 LIB_VMM = $(PATH_BIN)/VBoxVMM.s.so
889 LIB_VMMGC = $(PATH_BIN)/VMMGC.gc
890 LIB_REM = $(PATH_BIN)/VBoxREMImp.s.so
891 LIB_XPCOM = $(PATH_BIN)/VBoxXPCOM.s.so
892 LIB_DDU = $(PATH_BIN)/VBoxDDU.s.so
893 LIB_SETTINGS = $(PATH_BIN)/VBoxSettings.s.so
894endif
895if1of ($(KBUILD_TARGET), linux freebsd netbsd openbsd solaris)
896 LIB_RUNTIME = $(PATH_BIN)/VBoxRT.so
897 LIB_RUNTIME_EF = $(PATH_LIB)/RuntimeEFCPP.a
898 LIB_KPROFILE = $(PATH_BIN)/kPrf2.so
899 LIB_VMM = $(PATH_BIN)/VBoxVMM.so
900 LIB_VMMGC = $(PATH_BIN)/VMMGC.gc
901 LIB_REM = $(PATH_BIN)/VBoxREMImp.so
902 LIB_XPCOM = $(PATH_BIN)/VBoxXPCOM.so
903 LIB_DDU = $(PATH_BIN)/VBoxDDU.so
904 LIB_SETTINGS = $(PATH_BIN)/VBoxSettings.so
905endif
906ifeq ($(KBUILD_TARGET),os2)
907 LIB_RUNTIME = $(PATH_BIN)/VBoxRT.dll
908 LIB_RUNTIME_EF = #$(PATH_LIB)/RuntimeEFCPP.a
909 LIB_KPROFILE = $(PATH_BIN)/kPrf2.dll
910 LIB_VMM = $(PATH_BIN)/VBoxVMM.dll
911 LIB_VMMGC = $(PATH_LIB)/VMMGCImp.lib
912 LIB_REM = $(PATH_LIB)/VBoxREMImp.lib
913 LIB_XPCOM = $(PATH_BIN)/VBoxXCOM.dll
914 LIB_DDU = $(PATH_BIN)/VBoxDDU.dll
915 LIB_SETTINGS = $(PATH_BIN)/VBoxSett.dll
916 OBJ_SYS0 = $(PATH_OBJ)/src/VBox/Runtime/RuntimeR0/os2/sys0.obj
917endif
918ifeq ($(KBUILD_TARGET),win)
919 LIB_RUNTIME = $(PATH_LIB)/VBoxRT.lib
920 LIB_RUNTIME_EF = #$(PATH_LIB)/RuntimeEFCPP.lib
921 LIB_KPROFILE = $(PATH_LIB)/kPrf2.lib
922 LIB_VMM = $(PATH_LIB)/VBoxVMM.lib
923 ifdef VBOX_SINGLE_MAKEFILE
924 LIB_VMMGC = $(PATH_OBJ)/VMMGC/VMMGC.lib
925 else
926 LIB_VMMGC = $(PATH_OBJ)/src/VBox/VMM/VMMGC/VMMGC.lib
927 endif
928 LIB_REM = $(PATH_LIB)/VBoxREMImp.lib
929 LIB_XPCOM = $(PATH_BIN)/VBoxXPCOM.dll
930 LIB_DDU = $(PATH_LIB)/VBoxDDU.lib
931 LIB_SETTINGS = $(PATH_LIB)/VBoxSettings.lib
932endif
933
934# The kprofile build automagically links with kProfile.
935ifeq ($(KBUILD_TYPE),kprofile)
936 LIB_RUNTIME += $(LIB_KPROFILE)
937endif
938
939## Enable C++ electric fence heap. (Warning: will easily run out of virtual memory / kernel stuff on Linux/Windows.)
940#LIB_RUNTIME += $(LIB_RUNTIME_EF) $(LIB_RUNTIME)
941
942# Overridable libraries (unix).
943LIB_PTHREAD ?= pthread
944
945# Xcursor (consider an SDK for this).
946# (LIB_XCURSOR is legacy, remove in a month or two.)
947ifndef VBOX_XCURSOR_LIBS
948 VBOX_XCURSOR_LIBS := $(LIB_XCURSOR)
949endif
950ifeq ($(VBOX_XCURSOR_LIBS),)
951 ifeq ($(KBUILD_TARGET),solaris)
952 VBOX_XCURSOR_LIBS := $(lastword $(wildcard $(PATH_DEVTOOLS_TRG)/libXcursor/*/lib/libXcursor.a))
953 ifneq ($(VBOX_XCURSOR_LIBS),)
954 VBOX_XCURSOR_INCS := $(patsubst %/lib/libXcursor.a,%/include, $(VBOX_XCURSOR_LIBS))
955 VBOX_XCURSOR_LIBS += X11 Xrender Xfixes
956 endif
957 endif
958 ifeq ($(VBOX_XCURSOR_LIBS),)
959 VBOX_XCURSOR_LIBS := Xcursor
960 endif
961endif
962
963
964# Intel ASL compiler for ACPI
965VBOX_IASLCMD ?= $(firstword $(wildcard $(PATH_DEVTOOLS_BLD)/bin/iasl$(HOSTSUFF_EXE)) iasl$(HOSTSUFF_EXE))
966
967# Bruce's C compile is a C-compiler for BIOS-related 8086 code
968VBOX_BCC ?= $(PATH_DEVTOOLS_BLD)/bin/bcc$(HOSTSUFF_EXE) -B $(PATH_DEVTOOLS_BLD)/bin/
969
970# Assembler for BIOS-related 8086 code
971VBOX_AS86 ?= $(PATH_DEVTOOLS_BLD)/bin/as86$(HOSTSUFF_EXE)
972
973# libxslt XSLT processor. (see PATH_TOOL_YASM for explanation why it's temporarily located in bin.)
974ifeq ($(KBUILD_HOST),win)
975# VBOX_XSLTPROC ?= $(PATH_DEVTOOLS)/win.x86/libxslt/10114/xsltproc.exe
976 VBOX_XSLTPROC ?= $(PATH_DEVTOOLS)/win.x86/bin/xsltproc.exe
977else ifeq ($(KBUILD_HOST),os2)
978 VBOX_XSLTPROC ?= BEGINLIBPATH="$(PATH_DEVTOOLS_BLD)/bin;$$BEGINLIBPATH" $(PATH_DEVTOOLS_BLD)/bin/xsltproc.exe
979else
980 VBOX_XSLTPROC ?= xsltproc$(HOSTSUFF_EXE)
981endif
982
983# bin2c (convert binary files into C arrays)
984VBOX_BIN2C ?= $(PATH_OBJ)/bin2c/bin2c$(HOSTSUFF_EXE)
985
986# mkisofs
987ifeq ($(KBUILD_HOST),win)
988 VBOX_MKISOFS ?= $(PATH_DEVTOOLS_BLD)/bin/mkisofs.exe
989else
990 VBOX_MKISOFS ?= mkisofs
991endif
992
993# Makeself for the linux installers.
994VBOX_MAKESELF ?= $(PATH_DEVTOOLS)/common/makeself/v2.1.4_1/makeself.sh
995
996# Microsoft HTML Help Workshop.
997VBOX_PATH_HTML_HELP_WORKSHOP ?= $(PATH_DEVTOOLS)/win.x86/HTML_Help_Workshop/v1.3/
998
999# Path to the null soft installer.
1000VBOX_PATH_NSIS ?= $(PATH_DEVTOOLS)/win.x86/nsis/v2.33-log-nsscm-r1
1001
1002# Path to AutoIt3.
1003VBOX_PATH_AUTOIT3 ?= $(PATH_DEVTOOLS)/win.x86/autoit/v3.2.10.0
1004
1005# Windows install tools...
1006VBOX_PATH_WIX ?= $(PATH_DEVTOOLS)/win.x86/wix/v2.0.4611.0
1007VBOX_PATH_DIFX ?= $(PATH_DEVTOOLS)/win.$(KBUILD_TARGET_ARCH)/DIFx/v2.1
1008
1009# We need to export YASM for OSE, but since it was converted to .zip we need to
1010# allow for the location used by the zip to be properly cleaned up first.
1011if1of ($(KBUILD_HOST).$(KBUILD_HOST_ARCH), win.x86 linux.x86 solaris.x86)
1012 PATH_TOOL_YASM ?= $(PATH_DEVTOOLS_BLD)/bin
1013endif
1014
1015# XPCOM setup for all but win32.
1016ifneq ($(KBUILD_TARGET),win)
1017 VBOX_WITH_XPCOM = 1
1018 # if updating, also update xpidl_INST var in src/libs/xpcom18a4/Makefile.kmk
1019 VBOX_XPIDL ?= $(PATH_BIN)/xpidl$(HOSTSUFF_EXE)
1020 VBOX_PATH_XPCOM_IDL ?= $(VBOX_PATH_SDK)/idl
1021 VBOX_XPCOM_INCS ?= \
1022 $(VBOX_PATH_SDK)/include \
1023 $(VBOX_PATH_SDK)/include/xpcom \
1024 $(VBOX_PATH_SDK)/include/xpcom/nsprpub \
1025 $(VBOX_PATH_SDK)/include/xpcom/string \
1026 $(VBOX_PATH_SDK)/include/xpcom/xpcom \
1027 $(VBOX_PATH_SDK)/include/xpcom/ipcd
1028 ifneq ($(KBUILD_TARGET),os2)
1029 # libIDL-config (for xpcom18a4)
1030 ifeq ($(origin VBOX_LIBIDL_CONFIG),undefined)
1031 export VBOX_LIBIDL_CONFIG := $(firstword $(shell which libIDL-config-2 libIDL-config 2> /dev/null))
1032 endif
1033 endif
1034endif
1035
1036ifeq ($(KBUILD_TARGET),os2)
1037 # search DLLs in the EXE directory first
1038 VBOX_XPIDL := BEGINLIBPATH="$(dir $(VBOX_XPIDL));$$BEGINLIBPATH" $(VBOX_XPIDL)
1039endif
1040#$(error $(VBOX_XPIDL))
1041
1042# The X11 LIBPATH. (The amd64 hack is for RHEL4.)
1043ifeq ($(KBUILD_TARGET_ARCH),amd64)
1044 VBOX_LIBPATH_X11 ?= /usr/X11R6/lib64 /usr/X11R6/lib
1045else
1046 VBOX_LIBPATH_X11 ?= /usr/X11R6/lib
1047endif
1048
1049# 32bit X11 LIBPATH for building 32bit guest additions
1050VBOX_LIBPATH32_X11 ?= /usr/X11R6/lib32 /usr/X11R6/lib
1051
1052#
1053# Macros dealing with the darwin version we're targeting.
1054#
1055ifeq ($(KBUILD_TARGET),darwin)
1056 VBOX_DEF_MACOSX_VERSION_MIN ?= 10.4
1057 ifeq ($(VBOX_DEF_MACOSX_VERSION_MIN),10.4)
1058 ifeq ($(origin VBOX_DARWIN_CLASSIC_LINKER),undefined)
1059 VBOX_DARWIN_CLASSIC_LINKER := $(shell ld -v 2>&1 )
1060 ifneq ($(filter ld64%, $(subst :, , $(VBOX_DARWIN_CLASSIC_LINKER))),)
1061 export VBOX_DARWIN_CLASSIC_LINKER := -Wl,-classic_linker
1062 else
1063 export VBOX_DARWIN_CLASSIC_LINKER :=
1064 endif
1065 endif
1066 VBOX_PATH_MACOSX_SDK ?= /Developer/SDKs/MacOSX$(VBOX_DEF_MACOSX_VERSION_MIN)u.sdk
1067 else
1068 VBOX_PATH_MACOSX_SDK ?= /Developer/SDKs/MacOSX$(VBOX_DEF_MACOSX_VERSION_MIN).sdk
1069 endif
1070 VBOX_DARWIN_DEF_SDK_DEFS := MAC_OS_X_VERSION_MIN_REQUIRED=$(subst .,,$(VBOX_DEF_MACOSX_VERSION_MIN))0 \
1071 MAC_OS_X_VERSION_MAX_ALLOWED=$(subst .,,$(VBOX_DEF_MACOSX_VERSION_MIN))0
1072 VBOX_DARWIN_DEF_SDK_CFLAGS := -mmacosx-version-min=$(VBOX_DEF_MACOSX_VERSION_MIN) -isysroot $(VBOX_PATH_MACOSX_SDK)
1073 VBOX_DARWIN_DEF_SDK_CXXFLAGS := -mmacosx-version-min=$(VBOX_DEF_MACOSX_VERSION_MIN) -isysroot $(VBOX_PATH_MACOSX_SDK)
1074 VBOX_DARWIN_DEF_SDK_OBJCFLAGS := -mmacosx-version-min=$(VBOX_DEF_MACOSX_VERSION_MIN) -isysroot $(VBOX_PATH_MACOSX_SDK)
1075 VBOX_DARWIN_DEF_SDK_LDFLAGS := -mmacosx-version-min=$(VBOX_DEF_MACOSX_VERSION_MIN) -Wl,-syslibroot,$(VBOX_PATH_MACOSX_SDK) $(VBOX_DARWIN_CLASSIC_LINKER)
1076endif # target=darwin
1077
1078#
1079# The X11 headers.
1080#
1081VBOX_PATH_X11_ROOT = $(PATH_ROOT)/src/VBox/Additions/x11/x11include
1082VBOX_PATH_X11_XFREE_4_2 = $(VBOX_PATH_X11_ROOT)/4.2
1083VBOX_PATH_X11_XFREE_4_3 = $(VBOX_PATH_X11_ROOT)/4.3
1084VBOX_PATH_X11_XORG_7_0 = $(VBOX_PATH_X11_ROOT)/7.0
1085VBOX_PATH_X11_XORG_7_1 = $(VBOX_PATH_X11_ROOT)/7.1
1086VBOX_PATH_X11_XORG_1_3 = $(VBOX_PATH_X11_ROOT)/1.3
1087VBOX_PATH_X11_XORG_1_4 = $(VBOX_PATH_X11_ROOT)/1.4
1088VBOX_PATH_X11_XORG_1_5 = $(VBOX_PATH_X11_ROOT)/1.5
1089
1090#
1091# Various other variables.
1092#
1093
1094# Two helper variables for the VBOX_WITH_ORIGIN stuff:
1095# VBOX_ORIGIN - Indirect expansion trick.
1096# VBOX_GCC_RPATH_OPT - Different GCC/LD combinations needs different options.
1097VBOX_ORIGIN = $$ORIGIN
1098ifeq ($(KBUILD_TARGET),solaris)
1099 VBOX_GCC_RPATH_OPT = -R
1100else
1101 VBOX_GCC_RPATH_OPT = -Wl,-rpath,
1102endif
1103
1104# The icons to use.
1105ifdef VBOX_OSE
1106 VBOX_WINDOWS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_win.ico
1107 VBOX_NSIS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_win.ico
1108 VBOX_MACOSX_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox.icns
1109else
1110 ifeq ($(KBUILD_HOST),win)
1111 VBOX_WINDOWS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/VirtualBox-vista.ico
1112 VBOX_NSIS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/VirtualBox-nsis.ico
1113 TOOL_VCC80X86_RC := $(PATH_DEVTOOLS)/win.x86/ddk/6000/bin/x86/rc.exe
1114 TOOL_VCC80AMD64_RC := $(PATH_DEVTOOLS)/win.x86/ddk/6000/bin/x86/rc.exe
1115 TOOL_VCC70_RC := $(PATH_DEVTOOLS)/win.x86/ddk/6000/bin/x86/rc.exe
1116 else
1117 VBOX_WINDOWS_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/VirtualBox-winxp.ico
1118 endif
1119 VBOX_MACOSX_ICON_FILE ?= $(PATH_ROOT)/src/VBox/Artwork/VirtualBox.icns
1120endif
1121
1122
1123#
1124# GCC stuff properties.
1125# Most of this is resolved on first kmk invocation and cached in PATH_OUT.
1126#
1127# Note! That a harmless warning is printed if the file doesn't exist.
1128# Note! Changes in GCC are not detected automatically (yet).
1129#
1130include $(KBUILD_PATH)/tools/$(VBOX_GCC_TOOL).kmk
1131ifneq ($(VBOX_GCC_TOOL),$(VBOX_GCC32_TOOL))
1132 include $(KBUILD_PATH)/tools/$(VBOX_GCC32_TOOL).kmk
1133endif
1134
1135# These tests never worked on Windows because of /dev/null, so, there
1136# can be no harm in just dropping them until cygwin is mp safe.
1137ifeq ($(KBUILD_HOST),win)
1138VBOX_GCC_CHECK_CC = $(2)
1139VBOX_GCC_CHECK_CXX = $(2)
1140VBOX_GCC_CHECK_LD = $(2)
1141VBOX_GCC32_CHECK_CXX = $(2)
1142else
1143VBOX_GCC_CHECK_CC = $(shell \
1144 if $(TOOL_$(VBOX_GCC_TOOL)_CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
1145 then echo "$(1)"; \
1146 else echo "$(2)"; fi; )
1147
1148VBOX_GCC_CHECK_CXX = $(shell \
1149 if $(TOOL_$(VBOX_GCC_TOOL)_CXX) $(1) -S -o /dev/null -xc++ /dev/null > /dev/null 2>&1; \
1150 then echo "$(1)"; \
1151 else echo "$(2)"; fi; )
1152
1153VBOX_GCC_CHECK_LD = $(shell \
1154 if $(TOOL_$(VBOX_GCC_TOOL)_LD) -Wl,$(1) -nostdlib -o /dev/null -xc /dev/null > /dev/null 2>&1 ;\
1155 then echo "-Wl,$(1)"; \
1156 else echo "$(2)"; fi; )
1157
1158VBOX_GCC32_CHECK_CXX = $(shell \
1159 if $(TOOL_$(VBOX_GCC32_TOOL)_CXX) $(1) -S -o /dev/null -xc++ /dev/null > /dev/null 2>&1; \
1160 then echo "$(1)"; \
1161 else echo "$(2)"; fi; )
1162endif
1163
1164ifeq ($(KBUILD_HOST),win)
1165# This isn't important (yet) on windows, so cook the result until
1166# cygwin is feeling better.
1167VBOX_GCC_VERSION := $(int-add $(int-mul 10000, 3), $(int-mul 100, 3), 3)
1168else
1169# This is kind of bad, the returned string needs to be re-evaluated before use.
1170# The reason for this hack is that the windows kmk_ash cannot deal with $((1+1)).
1171# Some versions of gcc (e.g. openSUSE11) return only major.minor on `gcc -dumpversion`.
1172VBOX_GCC_VERSION = $(shell \
1173 $(1) -dumpversion | $(SED_EXT) 's|\([0-9]\)\.\([0-9]\)\.\{0,1\}\([0-9]\{0,1\}\)|$$(int-add $$(int-mul 10000, \1), $$(int-mul 100, \2), $$(firstword \3 0))|' )
1174endif
1175
1176# No $(QUIET) here as it's interesting to see what goes into the file.
1177$(PATH_OUT)/GCCConfig.kmk: $(PATH_ROOT)/Config.kmk $(LOCALCFG) $(AUTOCFG)
1178 $(call MSG_GENERATE,,$@,)
1179 $(QUIET)$(RM) -f '$@'
1180 $(QUIET)$(MKDIR) -p $(@D)
1181
1182# HC compiler switch detection.
1183 $(APPEND) '$@' 'VBOX_GCC_VERSION_CC ?= $(call VBOX_GCC_VERSION,$(TOOL_$(VBOX_GCC_TOOL)_CC))'
1184 $(APPEND) '$@' 'VBOX_GCC_VERSION_CXX ?= $(call VBOX_GCC_VERSION,$(TOOL_$(VBOX_GCC_TOOL)_CXX))'
1185 $(APPEND) '$@' 'VBOX_GCC_LIBGCC ?= $(shell $(TOOL_$(VBOX_GCC_TOOL)_CC) -print-libgcc-file-name)'
1186 $(APPEND) '$@' 'VBOX_GCC_Wno-pointer-sign ?= $(call VBOX_GCC_CHECK_CC,-Wno-pointer-sign,)'
1187 $(APPEND) '$@' 'VBOX_GCC_Wno-variadic-macros ?= $(call VBOX_GCC_CHECK_CXX,-Wno-variadic-macros,)'
1188 $(APPEND) '$@' 'VBOX_GCC_Wno-invalid-offsetof ?= $(call VBOX_GCC_CHECK_CXX,-Wno-invalid-offsetof,)'
1189 $(APPEND) '$@' 'VBOX_GCC_Wno-extra ?= $(call VBOX_GCC_CHECK_CXX,-Wno-extra)'
1190 $(APPEND) '$@' 'VBOX_GCC_fno-stack-protector ?= $(call VBOX_GCC_CHECK_CC,-fno-stack-protector,)'
1191# Produce code optimized for the most common IA32/AMD64/EM64T processors. Introduced with gcc version 4.2.
1192 $(APPEND) '$@' 'VBOX_GCC_mtune-generic ?= $(call VBOX_GCC_CHECK_CC,-mtune=generic,)'
1193 $(APPEND) '$@' 'VBOX_LD_as_needed ?= $(call VBOX_GCC_CHECK_LD,--as-needed,)'
1194ifneq ($(KBUILD_TARGET),l4)
1195# Set default attribute for ELF and MACH-O symbols to ``hidden'' to reduce the number
1196# of relocation entries and PLT indirections in shared libraries. Don't allow for gcc version < 4.
1197 $(APPEND) '$@' 'ifneq ($$(VBOX_GCC_VERSION_CC),)'
1198 $(APPEND) '$@' ' ifneq ($$(int-ge $$(VBOX_GCC_VERSION_CC),40000),)'
1199 $(APPEND) '$@' ' VBOX_GCC_fvisibility-hidden ?= $(call VBOX_GCC_CHECK_CC,-fvisibility=hidden -DVBOX_HAVE_VISIBILITY_HIDDEN -DRT_USE_VISIBILITY_DEFAULT,)'
1200 $(APPEND) '$@' ' endif'
1201 $(APPEND) '$@' 'endif'
1202endif
1203ifneq ($(KBUILD_TARGET),l4)
1204# Set default attribute for inline functions to ``hidden'' to reduce the number
1205# of relocation entries and PLT indirections in shared libraries. Don't allow for gcc version < 4.
1206 $(APPEND) '$@' 'ifneq ($$(VBOX_GCC_VERSION_CXX),)'
1207 $(APPEND) '$@' ' ifneq ($$(int-ge $$(VBOX_GCC_VERSION_CXX),40000),)'
1208 $(APPEND) '$@' ' VBOX_GCC_fvisibility-inlines-hidden ?= $(call VBOX_GCC_CHECK_CXX,-fvisibility-inlines-hidden,)'
1209 $(APPEND) '$@' ' endif'
1210 $(APPEND) '$@' 'endif'
1211endif
1212# Find the compiler includes for IPRT no-crt.
1213# Note that `$(dir $(gcc -print-libgcc-file-name))/include does not work for a 64-bit cross build on a 32-bit build host.
1214ifeq ($(KBUILD_HOST),win)
1215# With the cygwin issues and gcc on windows returning a useless path, just skip this on windows.
1216 $(APPEND) '$@' 'VBOX_PATH_GCC_INCS ?= '
1217else
1218 $(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'
1219endif
1220# 32-bit (GC) compiler switch detection.
1221 $(APPEND) '$@' 'VBOX_GCC32_VERSION_CC ?= $(call VBOX_GCC_VERSION,$(TOOL_$(VBOX_GCC32_TOOL)_CC))'
1222 $(APPEND) '$@' 'VBOX_GCC32_VERSION_CXX ?= $(call VBOX_GCC_VERSION,$(TOOL_$(VBOX_GCC32_TOOL)_CXX))'
1223 $(APPEND) '$@' 'VBOX_GCC32_LIBGCC ?= $(shell $(TOOL_$(VBOX_GCC32_TOOL)_CC) -print-libgcc-file-name)'
1224 $(APPEND) '$@' 'VBOX_GCC32_Wno-variadic-macros ?= $(call VBOX_GCC32_CHECK_CXX,-Wno-variadic-macros,)'
1225
1226include $(PATH_OUT)/GCCConfig.kmk
1227
1228
1229#
1230# Code Signing.
1231#
1232ifdef VBOX_SIGNING_MODE
1233 ifeq ($(KBUILD_HOST),win)
1234 # VBOX_PATH_SELFSIGN points to the Vista WDK bin/SelfSign directory.
1235 ifndef VBOX_PATH_SELFSIGN
1236 VBOX_PATH_SELFSIGN := $(lastword $(sort $(wildcard $(PATH_DEVTOOLS)/win.x86/selfsign/*)))
1237 ifeq ($(VBOX_PATH_SELFSIGN),)
1238 VBOX_PATH_SELFSIGN := $(PATH_DEVTOOLS)/win.x86/selfsign/r1
1239 endif
1240 endif
1241 VBOX_SIGNTOOL ?= $(VBOX_PATH_SELFSIGN)/SignTool.exe
1242 VBOX_INF2CAT ?= $(VBOX_PATH_SELFSIGN)/Inf2Cat.exe
1243
1244 # There are three signing modes; 'test', 'development' and 'release'.
1245 ifeq ($(strip $(VBOX_SIGNING_MODE)),test)
1246 VBOX_CERTIFICATE_SUBJECT_NAME ?= MyTestCertificate
1247 VBOX_CERTIFICATE_SUBJECT_NAME_ARGS ?= /n "$(VBOX_CERTIFICATE_SUBJECT_NAME)"
1248 else if1of ($(VBOX_SIGNING_MODE),release development)
1249 VBOX_CERTIFICATE_SUBJECT_NAME ?= Sun Microsystems, Inc.
1250 VBOX_CERTIFICATE_SUBJECT_NAME_ARGS ?= /n "$(VBOX_CERTIFICATE_SUBJECT_NAME)"
1251 VBOX_CROSS_CERTIFICATE_FILE ?= $(VBOX_PATH_SELFSIGN)/MSCV-VSClass3.cer
1252 VBOX_CROSS_CERTIFICATE_FILE_ARGS ?= /ac "$(VBOX_CROSS_CERTIFICATE_FILE)"
1253 VBOX_TSA_URL ?= http://timestamp.verisign.com/scripts/timestamp.dll
1254 VBOX_TSA_URL_ARGS ?= /t "$(VBOX_TSA_URL)"
1255 else
1256 $(error Unknown VBOX_SIGNING_MODE: $(VBOX_SIGNING_MODE))
1257 endif
1258 VBOX_CERTIFICATE_STORE ?= my
1259 VBOX_CERTIFICATE_STORE_ARGS ?= /s "$(VBOX_CERTIFICATE_STORE)"
1260
1261 ## Commands for signing a driver image after link.
1262 VBOX_SIGN_DRIVER_CMDS ?= $(if $(eq $(tool_do),LINK_LIBRARY),,$(call VBOX_SIGN_FILE_FN,$(out)))
1263 ## Sign a file.
1264 # @param 1 The file to sign.
1265 VBOX_SIGN_FILE_FN ?= $(VBOX_SIGNTOOL) sign \
1266 $(VBOX_CROSS_CERTIFICATE_FILE_ARGS) \
1267 $(VBOX_CERTIFICATE_STORE_ARGS) \
1268 $(VBOX_CERTIFICATE_SUBJECT_NAME_ARGS) \
1269 $(VBOX_TSA_URL_ARGS) \
1270 $(1)
1271 ## Create a security catalog file.
1272 # @param 1 The directory containing the stuff to sign.
1273 # @param 2 The expected .cat name. (Inf2Cat lowercases it)
1274 # @param 3 The list of OSes, separated by ';'.
1275 VBOX_MAKE_CAT_HLP_FN ?= \
1276 $(RM) -f $(2)\
1277 $(NL)$(TAB)$(VBOX_INF2CAT) /driver:$(strip $(1)) /os:$(strip $(subst ;,$(COMMA),$(3))) /verbose \
1278 $(NL)$(TAB)$(MV) $(2) $(2) \
1279 $(NL)$(TAB)$(call VBOX_SIGN_FILE_FN,$(2))
1280 VBOX_MAKE_CAT64_FN ?= $(call VBOX_MAKE_CAT_HLP_FN,$(1),$(2),XP_X64;Server2003_X64;Vista_X64)
1281 VBOX_MAKE_CAT32_FN ?= $(call VBOX_MAKE_CAT_HLP_FN,$(1),$(2),2000;XP_X86;Server2003_X86;Vista_X86)
1282 ifeq ($(KBUILD_TARGET_ARCH),x86)
1283 VBOX_MAKE_CAT_FN ?= $(call VBOX_MAKE_CAT32_FN,$(1),$(2))
1284 else
1285 VBOX_MAKE_CAT_FN ?= $(call VBOX_MAKE_CAT64_FN,$(1),$(2))
1286 endif
1287
1288 # Go nuts, sign everything.
1289 ifeq ($(strip $(VBOX_SIGNING_MODE)),release)
1290 ## Commands for signing an executable or a dll image after link.
1291 VBOX_SIGN_IMAGE_CMDS ?= $(if $(eq $(tool_do),LINK_LIBRARY),,$(call VBOX_SIGN_FILE_FN,$(out)))
1292 ## Enable signing of the additions.
1293 VBOX_SIGN_ADDITIONS ?= 1
1294 endif
1295 else
1296 # Not windows build platform, ignore.
1297 VBOX_SIGNING_MODE :=
1298 endif
1299endif
1300
1301#
1302# Windows .inf editing.
1303#
1304ifeq ($(KBUILD_TARGET_ARCH),x86)
1305 VBOX_EDIT_INF_FN = $(call VBOX_EDIT_INF32_FN,$(1),$(2))
1306else
1307 VBOX_EDIT_INF_FN = $(call VBOX_EDIT_INF64_FN,$(1),$(2))
1308endif
1309## Edit an inf file an x86 target.
1310# @param 1 The inf file to edit.
1311# @param 2 The output file.
1312VBOX_EDIT_INF32_FN = $(SED) $(if $(VBOX_SIGNING_MODE),-e 's/^;cat *//', -e '/^;cat /d') -e 's/^;x86 *//' -e '/^;amd64 /d' --output $(2) $(1)
1313## Edit an inf file an x86 target.
1314# @param 1 The inf file to edit.
1315# @param 2 The output file.
1316VBOX_EDIT_INF64_FN = $(SED) $(if $(VBOX_SIGNING_MODE),-e 's/^;cat *//', -e '/^;cat /d') -e 's/^;amd64 *//' -e '/^;x86 /d' --output $(2) $(1)
1317
1318#
1319# Default prefixes and suffixes.
1320#
1321VBOX_PREF_LIB =
1322if1of ($(KBUILD_TARGET),win os2)
1323VBOX_SUFF_LIB = .lib
1324else
1325VBOX_SUFF_LIB = .a
1326endif
1327VBOX_SUFF_DLL = $(SUFF_DLL)
1328ifeq ($(KBUILD_TARGET),os2) # GXX3OMF produces out .o at the moment.
1329VBOX_SUFF_OBJ = .o
1330else
1331VBOX_SUFF_OBJ = $(SUFF_OBJ)
1332endif
1333VBOXW32GUEST_SUFF_LIB = .lib
1334VBOXLNX32GUEST_SUFF_LIB = .a
1335
1336#
1337# SDKs for external libraries.
1338#
1339SDK_VBOX_LIBXML2 = .
1340#if1of ($(KBUILD_TARGET),win os2 solaris)
1341 SDK_VBOX_LIBXML2_INCS ?= $(PATH_ROOT)/src/libs/libxml2-2.6.30/include
1342 SDK_VBOX_LIBXML2_LIBS ?= $(PATH_LIB)/VBox-libxml2$(VBOX_SUFF_LIB)
1343 SDK_VBOX_LIBXML2_DEFS ?= LIBXML_STATIC
1344 SDK_VBOX_LIBXML2_DEFS.win += WIN32 _WINDOWS _MBCS
1345#else if1of ($(KBUILD_TARGET),linux)
1346# SDK_VBOX_LIBXML2_INCS ?=
1347# SDK_VBOX_LIBXML2_LIBS ?=
1348# SDK_VBOX_LIBXML2_CFLAGS ?= $(shell pkg-config libxml-2.0 --cflags)
1349# SDK_VBOX_LIBXML2_CXXFLAGS ?= $(SDK_VBOX_LIBXML2_CFLAGS)
1350# SDK_VBOX_LIBXML2_LDFLAGS ?= $(shell pkg-config libxml-2.0 --libs)
1351#else
1352# SDK_VBOX_LIBXML2_INCS ?=
1353# SDK_VBOX_LIBXML2_LIBS ?= xml2
1354#endif
1355
1356SDK_VBOX_LIBXSLT = .
1357#if1of ($(KBUILD_TARGET),win os2 solaris)
1358 SDK_VBOX_LIBXSLT_INCS ?= $(PATH_ROOT)/src/libs/libxslt-1.1.22
1359 SDK_VBOX_LIBXSLT_LIBS ?= $(PATH_LIB)/VBox-libxslt$(VBOX_SUFF_LIB)
1360 SDK_VBOX_LIBXSLT_DEFS ?=
1361 SDK_VBOX_LIBXSLT_DEFS.win += WIN32 _WINDOWS _MBCS _REENTRANT
1362#else if1of ($(KBUILD_TARGET),linux)
1363# SDK_VBOX_LIBXSLT_INCS ?=
1364# SDK_VBOX_LIBXSLT_LIBS ?=
1365# SDK_VBOX_LIBXSLT_CFLAGS ?= $(shell pkg-config libxslt-1.0 --cflags)
1366# SDK_VBOX_LIBXSLT_CXXFLAGS ?= $(SDK_VBOX_LIBXSLT_CFLAGS)
1367# SDK_VBOX_LIBXSLT_LDFLAGS ?= $(shell pkg-config libxslt-1.0 --libs)
1368#else
1369# SDK_VBOX_LIBXSLT_INCS ?=
1370# SDK_VBOX_LIBXSLT_LIBS ?= xslt
1371#endif
1372
1373SDK_VBOX_LIBPNG = .
1374SDK_VBOX_LIBPNG_INCS ?= $(PATH_ROOT)/src/libs/libpng-1.2.8
1375SDK_VBOX_LIBPNG_LIBS ?= $(PATH_LIB)/VBox-libpng$(VBOX_SUFF_LIB)
1376
1377SDK_VBOX_ZLIB = .
1378if1of ($(KBUILD_TARGET), win os2)
1379 SDK_VBOX_ZLIB_INCS ?= $(PATH_ROOT)/src/libs/zlib-1.2.1
1380 SDK_VBOX_ZLIB_LIBS ?= $(PATH_LIB)/VBox-zlib$(VBOX_SUFF_LIB)
1381else
1382 SDK_VBOX_ZLIB_INCS ?=
1383 SDK_VBOX_ZLIB_LIBS ?= z
1384endif
1385
1386SDK_VBOX_OPENSSL = .
1387if1of ($(KBUILD_TARGET), darwin linux solaris win)
1388 ifdef VBOX_SINGLE_MAKEFILE
1389 SDK_VBOX_OPENSSL_DEFAULT_INCS := $(PATH_OUT)/obj/crypto-headers/include
1390 else
1391 SDK_VBOX_OPENSSL_DEFAULT_INCS := $(PATH_OUT)/obj/src/libs/openssl-0.9.8h/crypto-headers/include
1392 endif
1393 SDK_VBOX_OPENSSL_INCS ?= $(SDK_VBOX_OPENSSL_DEFAULT_INCS)
1394else
1395 SDK_VBOX_OPENSSL_INCS ?= $(PATH_ROOT)/src/libs/openssl-0.9.7e/include
1396endif
1397SDK_VBOX_OPENSSL_LIBS?= $(PATH_LIB)/VBox-libcrypto$(VBOX_SUFF_LIB)
1398
1399SDK_VBOX_FFMPEG = .
1400if1of ($(KBUILD_TARGET), win os2 darwin)
1401 SDK_VBOX_FFMPEG_INCS ?= \
1402 $(PATH_ROOT)/src/libs/ffmpeg-20060710/libavutil \
1403 $(PATH_ROOT)/src/libs/ffmpeg-20060710/libavcodec \
1404 $(PATH_ROOT)/src/libs/ffmpeg-20060710/libavformat
1405 ifeq ($(KBUILD_TARGET),win)
1406 ## @todo Michael! Where is $(PATH_LIB)/VBoxFFmpegImp$(VBOX_SUFF_LIB) supposed to come from?
1407 #SDK_VBOX_FFMPEG_LIBS ?= $(PATH_LIB)/VBoxFFmpeg.a
1408 SDK_VBOX_FFMPEG_LIBS ?= $(PATH_LIB)/VBoxFFmpegImp.lib
1409 else
1410 SDK_VBOX_FFMPEG_LIBS ?= $(PATH_BIN)/VBoxFFmpeg$(SUFF_DLL)
1411 endif
1412else
1413 SDK_VBOX_FFMPEG_INCS ?= /usr/include/ffmpeg /usr/include/libpng
1414 SDK_VBOX_FFMPEG_LIBS ?= avutil avcodec avformat
1415endif
1416
1417#
1418# Special SDK for the problematic NTDLL.LIB.
1419#
1420SDK_VBOX_NTDLL = Requires W2K3DDK
1421SDK_VBOX_NTDLL_LIBS ?= $(PATH_SDK_W2K3DDK_LIB)/ntdll.lib
1422
1423
1424#
1425# Qt build tools and libraries.
1426# For *NIX we require it to be present on the system.
1427#
1428## @todo convert this into SDK and integrate the Qt stuff into kBuild.
1429ifeq ($(KBUILD_TARGET),win)
1430 VBOX_PATH_QT ?= $(lastword $(sort $(wildcard $(PATH_DEVTOOLS_TRG)/qt/v3.*)))
1431 VBOX_DLL_QT ?= $(firstword $(wildcard $(VBOX_PATH_QT)/bin/VBoxQt3*.dll) \
1432 $(wildcard $(VBOX_PATH_QT)/bin/qtmt3*.dll) \
1433 $(wildcard $(VBOX_PATH_QT)/bin/qt-mt3*.dll) \
1434 $(wildcard $(VBOX_PATH_QT)/lib/qt-mt3*.dll))
1435 ifneq ($(wildcard $(VBOX_PATH_QT)/bin/accessible/VBoxQtWidgets100.dll),)
1436 VBOX_QT_BINARIES += \
1437 $(VBOX_PATH_QT)/bin/accessible/VBoxQtWidgets100.dll=>accessible/VBoxQtWidgets100.dll
1438 endif
1439 LIB_QT ?= $(firstword $(wildcard $(VBOX_PATH_QT)/lib/VBoxQt3*.lib) \
1440 $(wildcard $(VBOX_PATH_QT)/lib/qt-mt3*.lib) \
1441 $(wildcard $(VBOX_PATH_QT)/lib/dynamic/qt-mt3*.lib))
1442 LIB_QT_PRL ?= $(firstword $(wildcard $(VBOX_PATH_QT)/lib/VBoxQt.prl) \
1443 $(wildcard $(VBOX_PATH_QT)/lib/qt-mt.prl) \
1444 $(wildcard $(VBOX_PATH_QT)/lib/dynamic/qt-mt.prl))
1445 LIB_QTMAIN ?= $(firstword $(wildcard $(VBOX_PATH_QT)/lib/qtmain.lib) \
1446 $(wildcard $(VBOX_PATH_QT)/lib/dynamic/qtmain.lib))
1447 QTDIR ?= $(lastword $(sort $(wildcard $(PATH_DEVTOOLS_BLD)/qt/v3.*)))
1448else ifeq ($(KBUILD_TARGET),os2)
1449 QTDIR ?= $(PATH_DEVTOOLS_TRG)/qt/v3.3.1
1450 VBOX_PATH_QT ?= $(QTDIR)
1451 VBOX_DLL_QT ?= $(lastword $(sort $(wildcard $(VBOX_PATH_QT)/bin/*qt*.dll)))
1452 LIB_QT ?= $(lastword $(sort $(wildcard $(VBOX_PATH_QT)/lib/*qt*.lib)))
1453 LIB_QT_PRL ?= $(lastword $(sort $(wildcard $(VBOX_PATH_QT)/lib/*qt*.prl)))
1454 QTDIR := $(VBOX_PATH_QT)
1455else ifeq ($(KBUILD_TARGET),darwin)
1456 ifndef VBOX_PATH_QT
1457 VBOX_PATH_QT := $(lastword $(sort $(wildcard $(PATH_DEVTOOLS_TRG)/qt/v3.*)))
1458 VBOX_PATH_QT ?= $(PATH_DEVTOOLS_TRG)/qt/v3.3.8-r1
1459 endif
1460 VBOX_MUST_INSTALL_LIB_QT ?= 1
1461 LIB_QT ?= $(VBOX_PATH_QT)/lib/libqt-mt.3.dylib
1462 LIB_QTMAIN ?= $(NO_SUCH_VARIABLE)
1463 ifndef QTDIR
1464 QTDIR := $(sort $(wildcard $(PATH_DEVTOOLS_BLD)/v*))
1465 QTDIR := $(call lastword,$(QTDIR))
1466 endif
1467else
1468 ifndef QTDIR
1469 ifndef VBOX_PATH_QT
1470 # If QTDIR and VBOX_WITH_QTGUI aren't defined, we'll first
1471 # look in the tools tree and then on the system. If in the
1472 # tools, we'll have to install it.
1473 # Results are exported to avoid having to do this for every make file.
1474 VBOX_PATH_QT := $(lastword $(sort $(wildcard $(PATH_DEVTOOLS_TRG)/qt/v3.*)))
1475 ifneq ($(VBOX_PATH_QT),)
1476 export VBOX_PATH_QT
1477 export VBOX_MUST_INSTALL_LIB_QT := 1
1478 export LIB_QT := $(VBOX_PATH_QT)/lib/libqt-mt.so.3
1479 export LD_LIBRARY_PATH := $(VBOX_PATH_QT)/lib:$(LD_LIBRARY_PATH)
1480 else
1481 QTDIR := $(wildcard /usr/share/qt3)
1482 ifeq ($(QTDIR),)
1483 QTDIR := $(patsubst %/bin/moc,%,$(firstword $(wildcard /usr/bin/moc /usr/local/bin/moc /usr/X11R6/bin/moc)))
1484 endif
1485 ifneq ($(QTDIR),)
1486 export QTDIR
1487 endif
1488 endif
1489 else
1490 QTDIR := $(VBOX_PATH_QT)
1491 export QTDIR
1492 endif
1493 endif
1494endif
1495ifndef VBOX_PATH_QT
1496 VBOX_PATH_QT ?= $(QTDIR)
1497 LIB_QT ?= qt-mt
1498endif
1499ifeq ($(KBUILD_HOST),$(KBUILD_TARGET))
1500 VBOX_PATH_QT_HOST ?= $(VBOX_PATH_QT)
1501else
1502 VBOX_PATH_QT_HOST ?= $(QTDIR)
1503endif
1504VBOX_UIC ?= $(VBOX_PATH_QT_HOST)/bin/uic$(HOSTSUFF_EXE)
1505VBOX_MOC ?= $(VBOX_PATH_QT_HOST)/bin/moc$(HOSTSUFF_EXE)
1506VBOX_LUPDATE ?= $(VBOX_PATH_QT_HOST)/bin/lupdate$(HOSTSUFF_EXE)
1507VBOX_LRELEASE ?= $(VBOX_PATH_QT_HOST)/bin/lrelease$(HOSTSUFF_EXE)
1508
1509ifeq ($(KBUILD_TARGET),os2)
1510 # search DLLs in the EXE directory first (unless VBOX_DLL_QT is set)
1511 VBOX_DLL_QT_PATH := $(dir $(VBOX_DLL_QT))
1512 VBOX_DLL_QT_PATH := $(if $(VBOX_DLL_QT_PATH),$(VBOX_DLL_QT_PATH);,)
1513 VBOX_UIC := BEGINLIBPATH="$(VBOX_DLL_QT_PATH)$(dir $(VBOX_UIC));$$BEGINLIBPATH" $(VBOX_UIC)
1514 VBOX_MOC := BEGINLIBPATH="$(VBOX_DLL_QT_PATH)$(dir $(VBOX_MOC));$$BEGINLIBPATH" $(VBOX_MOC)
1515 VBOX_LUPDATE := BEGINLIBPATH="$(VBOX_DLL_QT_PATH)$(dir $(VBOX_LUPDATE));$$BEGINLIBPATH" $(VBOX_LUPDATE)
1516 VBOX_LRELEASE := BEGINLIBPATH="$(VBOX_DLL_QT_PATH)$(dir $(VBOX_LRELEASE));$$BEGINLIBPATH" $(VBOX_LRELEASE)
1517endif
1518
1519#
1520# The linux kernel headers(/sources).
1521#
1522if1of ($(KBUILD_TARGET), linux)
1523 ifeq ($(origin VBOX_LINUX_SRC),undefined)
1524 ifneq ($(wildcard /lib/modules/$(shell uname -r)/build/include/linux/autoconf.h),)
1525 export VBOX_LINUX_SRC := /lib/modules/$(shell uname -r)/build
1526 else
1527 export VBOX_LINUX_SRC := /usr/src/linux
1528 endif
1529 endif
1530 ifneq ($(VBOX_LINUX_SRC),)
1531 ifeq ($(origin VBOX_LINUX_INCS),undefined)
1532 export VBOX_LINUX_INCS := $(VBOX_LINUX_SRC)/include
1533 # support splitted Linux kernels (make O=<build directory>)
1534 # XXX hack alert!
1535 kernelsrc := $(shell $(SED_EXT) -ne 's+^KERNELSRC.*= *\(.*\)+\1+p' $(VBOX_LINUX_SRC)/Makefile)
1536 ifneq ($(kernelsrc),)
1537 kernelpath := $(realpath $(VBOX_LINUX_SRC)/$(kernelsrc))
1538 else
1539 # Linux >= 2.6.25
1540 kernelpath := $(shell $(SED_EXT) -ne 's+^MAKEARGS *:= *-C *\(.*\)+\1+p' $(VBOX_LINUX_SRC)/Makefile)
1541 endif
1542 ifneq ($(kernelpath),)
1543 VBOX_LINUX_INCS += $(VBOX_LINUX_SRC)/include2 $(kernelpath)/include
1544 else
1545 kernelpath := $(VBOX_LINUX_SRC)
1546 endif
1547 ifeq ($(KBUILD_TARGET_ARCH),x86)
1548 VBOX_LINUX_INCS += $(kernelpath)/include/asm-i386/mach-default \
1549 $(kernelpath)/include/asm-x86/mach-default
1550 endif
1551 endif
1552 endif
1553endif
1554
1555#
1556# Determine Solaris version.
1557#
1558ifeq ($(KBUILD_TARGET),solaris)
1559 ifeq ($(origin VBOX_SOLARIS_VERSION),undefined)
1560 $(eval export VBOX_SOLARIS_VERSION := $(shell uname -r | $(SED_EXT) 's|\([0-9]*\)\.\([0-9]*\)|$$(int-add $$(int-mul 100, \1), \2)|' ))
1561 endif
1562 ifeq ($(VBOX_SOLARIS_VERSION),510)
1563 DEFS.solaris += RT_OS_SOLARIS_10
1564 # Solaris 10 does not include crossbow.
1565 VBOX_WITH_CROSSBOW =
1566 VBOX_SOLARIS_10 = 1
1567 endif
1568endif
1569
1570
1571#
1572# Template for building GC things.
1573#
1574TEMPLATE_VBOXGC = VBox GC
1575TEMPLATE_VBOXGC_ASTOOL = $(VBOX_ASTOOL)
1576TEMPLATE_VBOXGC_ASFLAGS = $(VBOX_ASFLAGS32)
1577TEMPLATE_VBOXGC_DEFS = IN_GC $(ARCH_BITS_DEFS)
1578TEMPLATE_VBOXGC_SYSSUFF = .gc
1579TEMPLATE_VBOXGC_BLD_TRG_ARCH = x86
1580
1581ifeq ($(VBOX_LDR_FMT32),pe)
1582ifdef VBOX_USE_VCC80
1583 TEMPLATE_VBOXGC_TOOL = VCC80X86
1584 TEMPLATE_VBOXGC_CXXFLAGS = -Zi -Zl -GR- -GS- -EHs-c- -GF- -W3 -wd4244 -wd4996 -Zc:wchar_t- -Gs8192 $(VBOX_VCC_GC_OPT) $(VBOX_VCC_GC_FP)
1585else
1586 TEMPLATE_VBOXGC_TOOL = VCC70
1587 TEMPLATE_VBOXGC_CXXFLAGS = -Zi -Zl -GR- -GX- -GF- -W3 -wd4244 $(VBOX_VCC_GC_OPT) $(VBOX_VCC_GC_FP)
1588endif
1589TEMPLATE_VBOXGC_CFLAGS = $(TEMPLATE_VBOXGC_CXXFLAGS)
1590TEMPLATE_VBOXGC_LDFLAGS = -Driver -Subsystem:NATIVE -Incremental:NO -Align:64 -MapInfo:Lines -MapInfo:Exports -NoD
1591ifdef VBOX_USE_VCC80
1592 include $(KBUILD_PATH)/sdks/W2K3DDKX86.kmk
1593 TEMPLATE_VBOXGC_LIBS = \
1594 $(PATH_SDK_W2K3DDKX86_LIB)/int64.lib
1595else
1596 TEMPLATE_VBOXGC_LIBS = \
1597 $(PATH_TOOL_VCC70_LIB)/libcmt.lib # for 64-bit int
1598endif
1599endif
1600
1601ifeq ($(VBOX_LDR_FMT32),elf)
1602TEMPLATE_VBOXGC_TOOL = $(VBOX_GCC32_TOOL)
1603TEMPLATE_VBOXGC_CXXFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC32_Wno-variadic-macros) -pipe -fno-exceptions -fno-rtti $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_fvisibility-inlines-hidden)
1604TEMPLATE_VBOXGC_CFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC32_Wno-variadic-macros) -pipe -Wmissing-prototypes -Wstrict-prototypes $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-hidden)
1605ifeq ($(KBUILD_TARGET),solaris)
1606 TEMPLATE_VBOXGC_LDFLAGS = -r
1607else
1608 TEMPLATE_VBOXGC_LDFLAGS = -nostdlib -Bsymbolic
1609 # temporarily, must fix the loader.
1610 TEMPLATE_VBOXGC_LDFLAGS += $(if $(VBOX_DO_STRIP_MODULES),-S,)
1611 TEMPLATE_VBOXGC_LDFLAGS.release = $(if $(VBOX_DO_STRIP_MODULES),-S,)
1612endif
1613ifn1of ($(KBUILD_TARGET), solaris freebsd)
1614 TEMPLATE_VBOXGC_LIBS = \
1615 $(VBOX_GCC32_LIBGCC) # instricts
1616endif
1617endif
1618
1619ifeq ($(VBOX_LDR_FMT32),macho)
1620TEMPLATE_VBOXGC_TOOL = GXX4MACHO
1621TEMPLATE_VBOXGC_DEFS += $(VBOX_DARWIN_DEF_SDK_DEFS)
1622TEMPLATE_VBOXGC_CXXFLAGS = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS) -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC32_Wno-variadic-macros) -pipe -fno-common -msoft-float -static -fno-exceptions -fno-rtti $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -fno-strict-aliasing
1623TEMPLATE_VBOXGC_CFLAGS = $(VBOX_DARWIN_DEF_SDK_CFLAGS) -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC32_Wno-variadic-macros) -pipe -fno-common -msoft-float -static -Wno-trigraphs -Wmissing-prototypes -Wstrict-prototypes $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -fno-strict-aliasing
1624TEMPLATE_VBOXGC_LDFLAGS = $(VBOX_DARWIN_DEF_SDK_LDFLAGS) -nostdlib
1625#TEMPLATE_VBOXGC_LDFLAGS.release = -Wl,-S ???
1626endif
1627
1628ifeq ($(VBOX_LDR_FMT32),lx)
1629TEMPLATE_VBOXGC_TOOL = GXX3OMF
1630TEMPLATE_VBOXGC_CXXFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC32_Wno-variadic-macros) -pipe -fno-exceptions -fno-rtti $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -fno-strict-aliasing
1631TEMPLATE_VBOXGC_CFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC32_Wno-variadic-macros) -pipe -Wmissing-prototypes -Wstrict-prototypes $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -fno-strict-aliasing
1632TEMPLATE_VBOXGC_LDFLAGS = -Zdll -nostdlib
1633TEMPLATE_VBOXGC_LIBS = \
1634 $(VBOX_GCC32_LIBGCC) \
1635 $(OBJ_SYS0) \
1636 end
1637endif
1638
1639
1640#
1641# Template for building a GC ring-3 testcase (tstVMStructGC, tstDevStructGC).
1642#
1643TEMPLATE_VBOXGCEXE = VBox GC as ring-3 testcase
1644TEMPLATE_VBOXGCEXE_EXTENDS = VBOXGC
1645
1646ifeq ($(VBOX_LDR_FMT32),pe)
1647 TEMPLATE_VBOXGCEXE_LDFLAGS = -Incremental:NO -MapInfo:Exports -NoD -Debug
1648 TEMPLATE_VBOXGCEXE_SDKS = WIN32SDK
1649 ifdef VBOX_USE_VCC80
1650 TEMPLATE_VBOXGCEXE_LIBS = \
1651 $(PATH_TOOL_VCC80X86_LIB)/libcmt.lib \
1652 $(PATH_TOOL_VCC80X86_LIB)/oldnames.lib
1653 else
1654 TEMPLATE_VBOXGCEXE_LIBS = \
1655 $(PATH_TOOL_VCC70_LIB)/libcmt.lib \
1656 $(PATH_TOOL_VCC70_LIB)/oldnames.lib
1657 endif
1658endif
1659
1660ifeq ($(VBOX_LDR_FMT32),elf)
1661 TEMPLATE_VBOXGCEXE_LDFLAGS = -g
1662 TEMPLATE_VBOXGCEXE_LDFLAGS.release = -g
1663endif
1664
1665ifeq ($(VBOX_LDR_FMT32),macho)
1666 TEMPLATE_VBOXGCEXE_CFLAGS = $(filter-out -static,$(TEMPLATE_VBOXGC_CFLAGS))
1667 TEMPLATE_VBOXGCEXE_CXXFLAGS = $(filter-out -static,$(TEMPLATE_VBOXGC_CXXFLAGS))
1668 TEMPLATE_VBOXGCEXE_LDFLAGS = -g
1669endif
1670
1671ifeq ($(VBOX_LDR_FMT32),lx)
1672 TEMPLATE_VBOXGCEXE_LDFLAGS = -g
1673 TEMPLATE_VBOXGCEXE_LIBS = $(NO_SUCH_VARIABLE)
1674endif
1675
1676
1677#
1678# Template for building R0 things.
1679#
1680TEMPLATE_VBOXR0 = VBox Ring 0
1681TEMPLATE_VBOXR0_ASTOOL = $(VBOX_ASTOOL)
1682TEMPLATE_VBOXR0_ASFLAGS = $(VBOX_ASFLAGS)
1683TEMPLATE_VBOXR0_DEFS = IN_RING0 $(ARCH_BITS_DEFS)
1684
1685ifeq ($(VBOX_LDR_FMT),pe)
1686TEMPLATE_VBOXR0_TOOL = $(VBOX_VCC_TOOL)
1687ifdef VBOX_USE_VCC80
1688 TEMPLATE_VBOXR0_CXXFLAGS = -Zi -Zl -GR- -GS- -EHs-c- -GF- -W3 -wd4244 -wd4996 -Zc:wchar_t- $(VBOX_VCC_OPT) $(VBOX_VCC_FP)
1689else
1690 TEMPLATE_VBOXR0_CXXFLAGS = -Zi -Zl -GR- -GX- -GF- -W3 -wd4244 $(VBOX_VCC_OPT) $(VBOX_VCC_FP)
1691endif
1692TEMPLATE_VBOXR0_CFLAGS = $(TEMPLATE_VBOXR0_CXXFLAGS)
1693TEMPLATE_VBOXR0_LDFLAGS = -Driver -Subsystem:NATIVE -Incremental:NO -Align:64 -MapInfo:Exports -NoD
1694ifdef VBOX_USE_VCC80
1695 TEMPLATE_VBOXR0_LIBS.x86 = \
1696 $(PATH_SDK_W2K3DDKX86_LIB)/int64.lib
1697else
1698 TEMPLATE_VBOXR0_LIBS.x86 = \
1699 $(PATH_TOOL_VCC70_LIB)/libcmt.lib # for 64-bit int
1700endif
1701endif # pe
1702
1703ifeq ($(VBOX_LDR_FMT),elf)
1704TEMPLATE_VBOXR0_TOOL = $(VBOX_GCC_TOOL)
1705TEMPLATE_VBOXR0_CFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC_Wno-variadic-macros) -pipe -Wmissing-prototypes -Wstrict-prototypes $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-hidden)
1706TEMPLATE_VBOXR0_CXXFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC_Wno-variadic-macros) -pipe -fno-rtti -fno-exceptions $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_fvisibility-hidden)
1707TEMPLATE_VBOXR0_CFLAGS.amd64 = -m64 -mno-red-zone -mcmodel=kernel -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-asynchronous-unwind-tables -ffreestanding
1708TEMPLATE_VBOXR0_CXXFLAGS.amd64 = -m64 -mno-red-zone -mcmodel=kernel -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-asynchronous-unwind-tables
1709ifeq ($(KBUILD_TARGET),solaris)
1710 TEMPLATE_VBOXR0_LDFLAGS = -r
1711else
1712 TEMPLATE_VBOXR0_LDFLAGS = -nostdlib -Bsymbolic
1713 # temporarily, must fix the loader.
1714 TEMPLATE_VBOXR0_LDFLAGS += $(if $(VBOX_DO_STRIP_MODULES),-S,)
1715 TEMPLATE_VBOXR0_LDFLAGS.release = $(if $(VBOX_DO_STRIP_MODULES),-S,)
1716endif
1717ifn1of ($(KBUILD_TARGET),solaris freebsd)
1718 TEMPLATE_VBOXR0_LIBS = \
1719 $(VBOX_GCC_LIBGCC) # instricts
1720endif
1721endif
1722
1723ifeq ($(VBOX_LDR_FMT),macho)
1724TEMPLATE_VBOXR0_TOOL = GXX4MACHO
1725TEMPLATE_VBOXR0_DEFS += $(VBOX_DARWIN_DEF_SDK_DEFS)
1726TEMPLATE_VBOXR0_CXXFLAGS = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS) -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC_Wno-variadic-macros) -pipe -fno-common -msoft-float -static -fno-rtti -fno-exceptions $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing
1727TEMPLATE_VBOXR0_CFLAGS = $(VBOX_DARWIN_DEF_SDK_CFLAGS) -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC_Wno-variadic-macros) -pipe -fno-common -msoft-float -static -Wmissing-prototypes -Wstrict-prototypes $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing
1728TEMPLATE_VBOXR0_LDFLAGS = $(VBOX_DARWIN_DEF_SDK_LDFLAGS) -nostdlib
1729#TEMPLATE_VBOXR0_LDFLAGS.release = -Wl,-S ???
1730endif
1731
1732ifeq ($(VBOX_LDR_FMT),lx)
1733TEMPLATE_VBOXR0_TOOL = GXX3OMF
1734TEMPLATE_VBOXR0_CFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC_Wno-variadic-macros) -pipe -Wmissing-prototypes -Wstrict-prototypes $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing
1735TEMPLATE_VBOXR0_CXXFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC_Wno-variadic-macros) -pipe -fno-rtti -fno-exceptions $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing
1736TEMPLATE_VBOXR0_LDFLAGS = -Zdll -nostdlib
1737TEMPLATE_VBOXR0_LIBS = \
1738 $(VBOX_GCC_LIBGCC) \
1739 $(OBJ_SYS0) \
1740 end
1741endif
1742
1743
1744#
1745# Template for building SUPDRV R0 things.
1746#
1747TEMPLATE_VBOXR0DRV = VBox SUPDRV Ring 0
1748TEMPLATE_VBOXR0DRV_ASTOOL = $(VBOX_ASTOOL)
1749TEMPLATE_VBOXR0DRV_ASFLAGS = $(VBOX_ASFLAGS)
1750TEMPLATE_VBOXR0DRV_DEFS = IN_RING0 IN_RT_R0 $(ARCH_BITS_DEFS)
1751
1752ifeq ($(KBUILD_TARGET),win)
1753 TEMPLATE_VBOXR0DRV_TOOL = $(VBOX_VCC_TOOL)
1754 TEMPLATE_VBOXR0DRV_RCDEFS = \
1755 VBOX_VERSION_MAJOR=\"$(VBOX_VERSION_MAJOR)\" \
1756 VBOX_VERSION_MINOR=\"$(VBOX_VERSION_MINOR)\" \
1757 VBOX_VERSION_BUILD=\"$(VBOX_VERSION_BUILD)\" \
1758 VBOX_SVN_REV=\"$(VBOX_SVN_REV)\" \
1759 VBOX_VERSION_MAJOR_NR=$(VBOX_VERSION_MAJOR) \
1760 VBOX_VERSION_MINOR_NR=$(VBOX_VERSION_MINOR) \
1761 VBOX_VERSION_BUILD_NR=$(VBOX_VERSION_BUILD) \
1762 VBOX_SVN_REV_NR=$(VBOX_SVN_REV)
1763 TEMPLATE_VBOXR0DRV_DEFS.x86 = _X86_
1764 TEMPLATE_VBOXR0DRV_DEFS.amd64 = _AMD64_
1765 ifdef VBOX_USE_VCC80
1766 TEMPLATE_VBOXR0DRV_CXXFLAGS = -Zi -Zl -GR- -GS- -EHs-c- -GF- -Gz -W3 -wd4996 -Zc:wchar_t- $(VBOX_VCC_OPT) $(VBOX_VCC_FP)
1767 else
1768 TEMPLATE_VBOXR0DRV_CXXFLAGS = -Zi -Zl -GR- -GX- -GF- -Gz -W3 $(VBOX_VCC_OPT) $(VBOX_VCC_FP)
1769 endif
1770 TEMPLATE_VBOXR0DRV_CFLAGS = $(TEMPLATE_VBOXR0DRV_CXXFLAGS)
1771 TEMPLATE_VBOXR0DRV_LDFLAGS = -Driver -Subsystem:NATIVE -Incremental:NO -Align:64 -MapInfo:Exports -NoD -Debug
1772 TEMPLATE_VBOXR0DRV_POST_CMDS = $(VBOX_SIGN_DRIVER_CMDS)
1773endif
1774
1775ifeq ($(KBUILD_TARGET),linux)
1776TEMPLATE_VBOXR0DRV_TOOL = $(VBOX_GCC_TOOL)
1777TEMPLATE_VBOXR0DRV_DEFS = __KERNEL__ MODULE IN_RING0 IN_RT_R0
1778TEMPLATE_VBOXR0DRV_INCS = $(VBOX_LINUX_INCS)
1779TEMPLATE_VBOXR0DRV_CFLAGS = -nostdinc -iwithprefix include \
1780 -Wall -Wstrict-prototypes -Wno-trigraphs $(VBOX_GCC_Wno-pointer-sign) \
1781 $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing -fno-common
1782TEMPLATE_VBOXR0DRV_CFLAGS.x86 = -mpreferred-stack-boundary=2 -msoft-float
1783TEMPLATE_VBOXR0DRV_CFLAGS.amd64 = -m64 -mno-red-zone -mcmodel=kernel -mno-sse -mno-mmx -mno-sse2 -mno-3dnow \
1784 -fno-reorder-blocks -ffreestanding -fno-asynchronous-unwind-tables -funit-at-a-time \
1785 -Wno-sign-compare -Wdeclaration-after-statement
1786TEMPLATE_VBOXR0DRV_CXXFLAGS = $(filter-out -Wstrict-prototypes -Wno-pointer-sign -ffreestanding -Wdeclaration-after-statement,$(TEMPLATE_VBOXR0DRV_CFLAGS) $(TEMPLATE_VBOXR0DRV_CFLAGS.$(KBUILD_TARGET_ARCH))) -fno-exceptions -fno-rtti
1787 ifndef VBOX_LINUX_VERSION_2_4
1788# 2.6
1789TEMPLATE_VBOXR0DRV_SYSSUFF = .ko
1790TEMPLATE_VBOXR0DRV_LDFLAGS.x86 = -m elf_i386 -r
1791TEMPLATE_VBOXR0DRV_LDFLAGS.amd64 = -m elf_x86_64 -r
1792 else
1793# 2.4
1794TEMPLATE_VBOXR0DRV_SYSSUFF = .o
1795TEMPLATE_VBOXR0DRV_LDFLAGS = -r -s
1796 endif
1797endif
1798
1799ifeq ($(KBUILD_TARGET),os2)
1800TEMPLATE_VBOXR0DRV_TOOL = GXX3OMF
1801TEMPLATE_VBOXR0DRV_CXXFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC_Wno-variadic-macros) -pipe $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing -fno-rtti -fno-exceptions
1802TEMPLATE_VBOXR0DRV_CFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC_Wno-variadic-macros) -pipe -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing
1803TEMPLATE_VBOXR0DRV_LIBS = $(VBOX_GCC_LIBGCC)
1804# wlink thinks physdevice doesn't need fixups and should have a stack - stupid!
1805TEMPLATE_VBOXR0DRV_LDFLAGS = -Zlinker Option -Zlinker internalrelocs, -Zlinker togglerelocs
1806endif
1807
1808ifeq ($(KBUILD_TARGET),darwin)
1809TEMPLATE_VBOXR0DRV_TOOL = GXX4MACHO
1810TEMPLATE_VBOXR0DRV_DEFS += $(VBOX_DARWIN_DEF_SDK_DEFS) KERNEL KERNEL_PRIVATE DRIVER_PRIVATE APPLE NeXT RT_USE_VISIBILITY_HIDDEN
1811# I didn't really know why we have to state explicitly the position of the
1812# sdk headers. Maybe it has something to do with the fact that the kernel.framework
1813# isn't a real framework according to http://developer.apple.com/qa/qa2001/qa1096.html.
1814TEMPLATE_VBOXR0DRV_INCS += $(VBOX_PATH_MACOSX_SDK)/System/Library/Frameworks/Kernel.framework/Headers
1815TEMPLATE_VBOXR0DRV_CXXFLAGS = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS) \
1816 -g -Wall -Wno-long-long -Wno-trigraphs -pipe -fno-common -nostdinc -fno-builtin -finline \
1817 -fno-keep-inline-functions -force_cpusubtype_ALL -fno-exceptions -msoft-float -static \
1818 -fapple-kext -fno-rtti -fcheck-new
1819TEMPLATE_VBOXR0DRV_CXXFLAGS.release = $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing -fasm-blocks
1820TEMPLATE_VBOXR0DRV_CXXFLAGS.profile = $(TEMPLATE_VBOXR0DRV_CXXFLAGS.release)
1821TEMPLATE_VBOXR0DRV_CXXFLAGS.kprofile = $(TEMPLATE_VBOXR0DRV_CXXFLAGS.release)
1822TEMPLATE_VBOXR0DRV_CFLAGS = $(VBOX_DARWIN_DEF_SDK_CFLAGS) \
1823 -g -Wall -Wno-long-long -Wno-trigraphs -pipe -fno-common -nostdinc -fno-builtin -finline \
1824 -fno-keep-inline-functions -force_cpusubtype_ALL -fno-exceptions -msoft-float -static \
1825 -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
1826TEMPLATE_VBOXR0DRV_CFLAGS.release = $(TEMPLATE_VBOXR0DRV_CXXFLAGS.release)
1827TEMPLATE_VBOXR0DRV_CFLAGS.profile = $(TEMPLATE_VBOXR0DRV_CXXFLAGS.profile)
1828TEMPLATE_VBOXR0DRV_CFLAGS.kprofile = $(TEMPLATE_VBOXR0DRV_CXXFLAGS.kprofile)
1829TEMPLATE_VBOXR0DRV_LDFLAGS = $(VBOX_DARWIN_DEF_SDK_LDFLAGS) -static -nostdlib -r -Wl,-Y,1455 -keep_private_extern
1830TEMPLATE_VBOXR0DRV_LIBS = kmodc++ kmod cc_kext cpp_kext $(VBOX_GCC_LIBGCC)
1831endif
1832
1833ifeq ($(KBUILD_TARGET),solaris)
1834## The Solaris /usr/platform/i86pc/include and /usr/include directories.
1835VBOX_SOLARIS_SYS_INCS ?= /usr/platform/i86pc/include /usr/include
1836
1837TEMPLATE_VBOXR0DRV_TOOL = $(VBOX_GCC_TOOL)
1838TEMPLATE_VBOXR0DRV_DEFS = _KERNEL _STRICT_STDC IN_RING0 IN_RT_R0
1839TEMPLATE_VBOXR0DRV_INCS = $(VBOX_SOLARIS_SYS_INCS)
1840TEMPLATE_VBOXR0DRV_LDFLAGS = -r -dy
1841ifdef VBOX_WITH_SOLARIS_VBI
1842 TEMPLATE_VBOXR0DRV_LDFLAGS += -N misc/vbi
1843endif
1844TEMPLATE_VBOXR0DRV_LDFLAGS.amd64 = -64
1845# Exclude -Wall because of solaris headers' pragma ident warnings that gcc refuses to supress.
1846TEMPLATE_VBOXR0DRV_CFLAGS = -Wno-trigraphs -Wpointer-arith -Winline $(VBOX_GCC_Wno-pointer-sign) \
1847 -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs \
1848 -O2 -ffreestanding -nodefaultlibs -fno-strict-aliasing -fno-common -std=c99
1849TEMPLATE_VBOXR0DRV_CFLAGS.x86 = -m32 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
1850TEMPLATE_VBOXR0DRV_CFLAGS.amd64 = -m64 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow $(if $(VBOX_SOLARIS_10),,-msave-args) -mno-red-zone -mcmodel=kernel \
1851 -fno-reorder-blocks -fno-asynchronous-unwind-tables -funit-at-a-time
1852TEMPLATE_VBOXR0DRV_CXXFLAGS = -Wno-trigraphs -Wpointer-arith -Winline $(VBOX_GCC_Wno-pointer-sign) \
1853 -O2 -nodefaultlibs -fno-strict-aliasing -fno-common -fno-exceptions -fno-rtti
1854TEMPLATE_VBOXR0DRV_CXXFLAGS.x86 = $(TEMPLATE_VBOXR0DRV_CFLAGS.x86)
1855TEMPLATE_VBOXR0DRV_CXXFLAGS.amd64 = $(TEMPLATE_VBOXR0DRV_CFLAGS.amd64)
1856endif # Solaris
1857
1858ifeq ($(KBUILD_TARGET),freebsd)
1859# x86 FreeBSD:
1860# cc -O2 -fno-strict-aliasing -pipe -Werror -D_KERNEL -DKLD_MODULE \
1861# -nostdinc -I- -I. -I@ -I@/contrib/altq -I@/../include -I/usr/include \
1862# -finline-limit=8000 -fno-common -mno-align-long-strings -mpreferred-stack-boundary=2 \
1863# -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -ffreestanding -Wall -Wredundant-decls -Wnested-externs \
1864# -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -fformat-extensions \
1865# -std=c99 -c ../my.c
1866# ld -d -warn-common -r -d -o my.kld my.o
1867# :> export_syms
1868# awk -f /usr/src/sys/modules/my/../../conf/kmod_syms.awk my.kld export_syms | xargs -J% objcopy % my.kld
1869# ld -Bsharable -d warn-commnon -o my.ko my.kld
1870#
1871# Note: @ -> /usr/src/sys and machine -> /usr/src/sys/i386/include
1872
1873## The location of the FreeBSD kernel source.
1874VBOX_FREEBSD_SRC ?= /usr/src/sys
1875## The FreeBSD /usr/include.
1876VBOX_FREEBSD_SYS_INCS ?= /usr/include
1877
1878TEMPLATE_VBOXR0DRV_TOOL = $(VBOX_GCC_TOOL)
1879TEMPLATE_VBOXR0DRV_LDTOOL = FREEBSDKMODLD
1880TEMPLATE_VBOXR0DRV_DEFS = _KERNEL KLD_MODULE IN_RING0 IN_RT_R0
1881TEMPLATE_VBOXR0DRV_INCS = \
1882 $(VBOX_FREEBSD_SRC) \
1883 $(VBOX_FREEBSD_SRC)/contrib/altq \
1884 $(VBOX_FREEBSD_SRC)/../include \
1885 $(VBOX_FREEBSD_SYS_INCS)
1886# omitting: -Wcast-qual, -Wredundant-decls
1887TEMPLATE_VBOXR0DRV_CFLAGS = \
1888 -Wall -Wno-trigraphs -Wpointer-arith -Winline $(VBOX_GCC_Wno-pointer-sign) \
1889 -Wstrict-prototypes -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs \
1890 -O2 -fformat-extensions -ffreestanding -fno-strict-aliasing -fno-common -finline-limit=8000 \
1891 $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_OPT) $(VBOX_GCC_FP) \
1892 -nostdinc -std=c99
1893TEMPLATE_VBOXR0DRV_CFLAGS.x86 = -m32 -mno-align-long-strings -mpreferred-stack-boundary=2 -mno-mmx -mno-3dnow -mno-sse -mno-sse2
1894TEMPLATE_VBOXR0DRV_CFLAGS.amd64 = -m64 "Port me to amd64 FreeBSD"
1895TEMPLATE_VBOXR0DRV_CXXFLAGS = -fno-exceptions -fno-rtti \
1896 -Wall -Wno-trigraphs -Wpointer-arith -Winline $(VBOX_GCC_Wno-pointer-sign) \
1897 -O2 -fno-format-extensions -fno-strict-aliasing -fno-common -finline-limit=8000 \
1898 $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_OPT) $(VBOX_GCC_FP) \
1899 -nostdinc
1900TEMPLATE_VBOXR0DRV_SYSSUFF = .ko
1901TEMPLATE_VBOXR0DRV_LDFLAGS = -d --warn-common
1902TEMPLATE_VBOXR0DRV_LDFLAGS.x86 = -m elf_i386_fbsd
1903TEMPLATE_VBOXR0DRV_LDFLAGS.amd64 = -m elf_x86_64 "Port me to amd64 FreeBSD"
1904
1905TOOL_FREEBSDKMODLD = FreeBSD kernel module linker.
1906# See kBuild/tools/GCC3.kmk for docs.
1907TOOL_FREEBSDKMODLD_LINK_SYSMOD_OUTPUT = $(outbase).kld
1908TOOL_FREEBSDKMODLD_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
1909TOOL_FREEBSDKMODLD_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
1910TOOL_FREEBSDKMODLD_LINK_SYSMOD_DEPORD =
1911define TOOL_FREEBSDKMODLD_LINK_SYSMOD_CMDS
1912 @# Link intermediate .kld (a relocatable object).
1913 ld $(flags) -r -o $(outbase).kld $(objs) \
1914 $(foreach p,$(libpath), -L$(p))\
1915 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
1916 @# Strip non-exported symbols private and localize the exported ones.
1917 awk -f $(VBOX_FREEBSD_SRC)/conf/kmod_syms.awk $(outbase).kld $(if $(othersrc), $(othersrc),/dev/null) \
1918 | xargs -J% objcopy % $(outbase).kld
1919 @# Link the final .ko (a shared object).
1920 ld $(flags) -Bshareable -o $(out) $(outbase).kld
1921endef
1922
1923endif # FreeBSD
1924
1925ifdef VBOX_WITH_VBOXDRV
1926 ifndef TEMPLATE_VBOXR0DRV_TOOL
1927 $(warning Warning: VBox Build: Target $(KBUILD_HOST) is not officially supported!)
1928 endif
1929endif
1930
1931
1932
1933#
1934# Template for building R3 executables and static libraries which are linked into executables.
1935# Note! This is the base template for a whole lot of other ones, so be careful when changing it.
1936#
1937TEMPLATE_VBOXR3EXE = VBox Ring 3 Exe
1938TEMPLATE_VBOXR3EXE_ASTOOL = $(VBOX_ASTOOL)
1939TEMPLATE_VBOXR3EXE_ASFLAGS = $(VBOX_ASFLAGS)
1940TEMPLATE_VBOXR3EXE_DEFS = IN_RING3 $(ARCH_BITS_DEFS)
1941TEMPLATE_VBOXR3EXE_LIBS.kprofile = $(LIB_KPROFILE)
1942ifeq ($(KBUILD_TARGET),win)
1943 TEMPLATE_VBOXR3EXE_TOOL = $(VBOX_VCC_TOOL)
1944 TEMPLATE_VBOXR3EXE_RCDEFS = \
1945 VBOX_VERSION_MAJOR=\"$(VBOX_VERSION_MAJOR)\" \
1946 VBOX_VERSION_MINOR=\"$(VBOX_VERSION_MINOR)\" \
1947 VBOX_VERSION_BUILD=\"$(VBOX_VERSION_BUILD)\" \
1948 VBOX_SVN_REV=\"$(VBOX_SVN_REV)\" \
1949 VBOX_VERSION_MAJOR_NR=$(VBOX_VERSION_MAJOR) \
1950 VBOX_VERSION_MINOR_NR=$(VBOX_VERSION_MINOR) \
1951 VBOX_VERSION_BUILD_NR=$(VBOX_VERSION_BUILD) \
1952 VBOX_SVN_REV_NR=$(VBOX_SVN_REV)
1953 TEMPLATE_VBOXR3EXE_SDKS = WINPSDK
1954 ifdef VBOX_USE_VCC80
1955 TEMPLATE_VBOXR3EXE_CXXFLAGS = -Zi -Zl -GR- -EHs-c- -GF- -MD -W3 -wd4065 -wd4244 -wd4996 -Zc:wchar_t- $(VBOX_VCC_OPT) $(VBOX_VCC_FP)
1956 TEMPLATE_VBOXR3EXE_CXXFLAGS.debug = -RTCsu
1957 else
1958 TEMPLATE_VBOXR3EXE_CXXFLAGS = -Zi -Zl -GR- -GX- -GF- -MD -W3 -wd4065 -wd4244 $(VBOX_VCC_OPT) $(VBOX_VCC_FP)
1959 TEMPLATE_VBOXR3EXE_CXXFLAGS.debug = -GZ
1960 endif
1961 TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile = -Gh -GH
1962 TEMPLATE_VBOXR3EXE_CFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS)
1963 TEMPLATE_VBOXR3EXE_CFLAGS.debug = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.debug)
1964 TEMPLATE_VBOXR3EXE_CFLAGS.kprofile = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile)
1965 TEMPLATE_VBOXR3EXE_LDFLAGS = \
1966 /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LARGEADDRESSAWARE /DEBUG \
1967 /DISALLOWLIB:libc.lib \
1968 /DISALLOWLIB:libcd.lib \
1969 /DISALLOWLIB:libcmt.lib \
1970 /DISALLOWLIB:libcmtd.lib \
1971 /DISALLOWLIB:msvcrtd.lib
1972 TEMPLATE_VBOXR3EXE_LIBS = \
1973 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/msvcrt.lib \
1974 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/msvcprt.lib \
1975 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/oldnames.lib
1976 TEMPLATE_VBOXR3EXE_POST_CMDS = $(VBOX_SIGN_IMAGE_CMDS)
1977
1978else # the gcc guys
1979TEMPLATE_VBOXR3EXE_TOOL = $(VBOX_GCC_TOOL)
1980TEMPLATE_VBOXR3EXE_CXXFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC_Wno-variadic-macros) -pipe $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_fvisibility-hidden)
1981TEMPLATE_VBOXR3EXE_CXXFLAGS.x86 = -m32
1982TEMPLATE_VBOXR3EXE_CXXFLAGS.amd64 = -m64
1983# L4 currently can't handle exception handling.
1984TEMPLATE_VBOXR3EXE_CXXFLAGS.l4 = -fno-exceptions -nostdinc \
1985 $(addprefix -I,$(VBOX_PATH_GCC_INCS) $(L4_INCDIR) $(FILE_TOOL_GPP3_INCDIR)) \
1986 $(DEBUG_L4)
1987TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile = -finstrument-functions
1988TEMPLATE_VBOXR3EXE_CFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC_Wno-variadic-macros) -pipe -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing $(VBOX_GCC_fvisibility-hidden)
1989TEMPLATE_VBOXR3EXE_CFLAGS.x86 = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.x86)
1990TEMPLATE_VBOXR3EXE_CFLAGS.amd64 = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.amd64)
1991TEMPLATE_VBOXR3EXE_CFLAGS.debug = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.debug)
1992TEMPLATE_VBOXR3EXE_CFLAGS.kprofile = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile)
1993TEMPLATE_VBOXR3EXE_CFLAGS.l4 = -nostdinc \
1994 $(addprefix -I,$(VBOX_PATH_GCC_INCS) $(L4_INCDIR)) $(DEBUG_L4)
1995TEMPLATE_VBOXR3EXE_DEFS.l4 = L4_THREAD_SAFE
1996TEMPLATE_VBOXR3EXE_LDFLAGS.x86 = -m32
1997TEMPLATE_VBOXR3EXE_LDFLAGS.amd64 = -m64
1998TEMPLATE_VBOXR3EXE_LDFLAGS.l4 = \
1999 $(L4_LIBDIR)/../crt0.o \
2000 -T$(L4_LIBDIR)/../main_dyn.ld -nostdlib \
2001 -Wl,--export-dynamic,--dynamic-linker=libld-l4.s.so \
2002 -Wl,--rpath-link,$(L4_LIBDIR)
2003TEMPLATE_VBOXR3EXE_LDFLAGS.linux = -Wl,-z,noexecstack $(VBOX_LD_as_needed)
2004 ifeq ($(KBUILD_TARGET),linux)
2005TEMPLATE_VBOXR3EXE_LIBS = pthread m rt dl
2006 else ifeq ($(KBUILD_TARGET),l4)
2007TEMPLATE_VBOXR3EXE_LIBS = \
2008 $(L4_LIBDIR)/libvboxserver.s.so \
2009 $(L4_LIBDIR)/libuc++.0.s.so \
2010 supc++ gcc_eh gcc \
2011 $(L4_LIBDIR)/libdl.s.so \
2012 $(L4_LIBDIR)/libuc.0.s.so
2013 else ifeq ($(KBUILD_TARGET),os2)
2014TEMPLATE_VBOXR3EXE_TOOL = GXX3OMF
2015TEMPLATE_VBOXR3EXE_LIBS = socket iconv
2016 else ifeq ($(KBUILD_TARGET),darwin)
2017TEMPLATE_VBOXR3EXE_TOOL = GXX4MACHO
2018TEMPLATE_VBOXR3EXE_LIBS =
2019TEMPLATE_VBOXR3EXE_DEFS.darwin = $(VBOX_DARWIN_DEF_SDK_DEFS)
2020TEMPLATE_VBOXR3EXE_CFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_CFLAGS) -fno-common
2021TEMPLATE_VBOXR3EXE_CXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS)
2022TEMPLATE_VBOXR3EXE_OBJCFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_OBJCFLAGS)
2023TEMPLATE_VBOXR3EXE_LDFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_LDFLAGS) -read_only_relocs suppress
2024 else if1of ($(KBUILD_TARGET),freebsd netbsd openbsd)
2025TEMPLATE_VBOXR3EXE_TOOL = GXX3
2026TEMPLATE_VBOXR3EXE_LIBS = pthread
2027TEMPLATE_VBOXR3EXE_INCS += \
2028 /usr/include \
2029 /usr/X11R6/include \
2030 /usr/local/include
2031 else ifeq ($(KBUILD_TARGET),solaris)
2032TEMPLATE_VBOXR3EXE_TOOL = GXX3PLAIN
2033TEMPLATE_VBOXR3EXE_DEFS += LIBICONV_PLUG _REENTRANT # Avoid the GNU libiconv, for now at least.
2034TEMPLATE_VBOXR3EXE_LIBS = rt socket
2035 else
2036$(warning Warning: VBOX Build: Target $(KBUILD_TARGET) is not officially supported!)
2037TEMPLATE_VBOXR3EXE_CXXFLAGS.profile = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.release)
2038TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.krelease)
2039 endif
2040 ifdef VBOX_WITH_ORIGIN
2041 TEMPLATE_VBOXR3EXE_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$$(VBOX_ORIGIN)'
2042 endif
2043endif
2044
2045#
2046# Template for building R3 shared objects / DLLs.
2047# This is mostly identical to the VBOXR3EXE template. (Avoid PIC if possible!)
2048#
2049TEMPLATE_VBOXR3 = VBox Ring 3 SO/DLLs
2050TEMPLATE_VBOXR3_EXTENDS = VBOXR3EXE
2051TEMPLATE_VBOXR3_LDFLAGS.l4 = $(L4_LIBDIR)/../crt0.s.o -T$(L4_LIBDIR)/../main_rel.ld -nostdlib
2052TEMPLATE_VBOXR3_DEFS.l4 = $(TEMPLATE_VBOXR3EXE_DEFS.l4) __PIC__
2053TEMPLATE_VBOXR3_DEFS.darwin = $(TEMPLATE_VBOXR3EXE_DEFS.darwin) PIC
2054ifeq ($(filter-out solaris.x86 %.amd64,$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),)
2055 ifneq ($(KBUILD_TARGET),win)
2056 TEMPLATE_VBOXR3_DEFS = $(TEMPLATE_VBOXR3EXE_DEFS) PIC
2057 TEMPLATE_VBOXR3_CFLAGS = $(TEMPLATE_VBOXR3EXE_CFLAGS) -fPIC
2058 TEMPLATE_VBOXR3_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) -fPIC
2059 TEMPLATE_VBOXR3_LDFLAGS = $(TEMPLATE_VBOXR3EXE_LDFLAGS) -fPIC
2060 endif
2061endif
2062
2063#
2064# Template for building static R3 executables and any static
2065# libraries they link with.
2066#
2067TEMPLATE_VBOXR3STATIC = VBox Static Ring 3 EXE
2068TEMPLATE_VBOXR3STATIC_EXTENDS = VBOXR3EXE
2069ifeq ($(KBUILD_TARGET),win)
2070 TEMPLATE_VBOXR3STATIC_CFLAGS = $(filter-out -MD, $(TEMPLATE_VBOXR3EXE_CFLAGS)) -MT
2071 TEMPLATE_VBOXR3STATIC_CXXFLAGS = $(filter-out -MD, $(TEMPLATE_VBOXR3EXE_CFLAGS)) -MT
2072 TEMPLATE_VBOXR3STATIC_LDFLAGS = $(filter-out /DISALLOWLIB:libcmt.lib, $(TEMPLATE_VBOXR3EXE_LDFLAGS)) \
2073 /DISALLOWLIB:msvcrt.lib \
2074 /DISALLOWLIB:msvcprt.lib
2075 TEMPLATE_VBOXR3STATIC_LIBS = \
2076 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL)_LIB)/oldnames.lib \
2077 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL)_LIB)/libcmt.lib \
2078 $(PATH_TOOL_$(TEMPLATE_VBOXR3STATIC_TOOL)_LIB)/libcpmt.lib
2079else # the gcc guys (untested!)
2080 TEMPLATE_VBOXR3STATIC_CFLAGS = $(TEMPLATE_VBOXR3EXE_CFLAGS) -static
2081 TEMPLATE_VBOXR3STATIC_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) -static
2082 TEMPLATE_VBOXR3STATIC_OBJCFLAGS= $(TEMPLATE_VBOXR3EXE_OBJCFLAGS) -static
2083 TEMPLATE_VBOXR3STATIC_LDFLAGS = $(TEMPLATE_VBOXR3EXE_LDFLAGS) -static
2084endif
2085
2086#
2087# Ring-3 testcase.
2088# This is the VBOXR3EXE template only with a different install dir.
2089#
2090TEMPLATE_VBOXR3TSTEXE = VBox Ring 3 Testcase Exe
2091TEMPLATE_VBOXR3TSTEXE_EXTENDS = VBOXR3EXE
2092TEMPLATE_VBOXR3TSTEXE_INST = $(INST_TESTCASE)
2093TEMPLATE_VBOXR3TSTEXE_LIBS = $(LIB_RUNTIME) $(TEMPLATE_VBOXR3EXE_LIBS)
2094ifdef VBOX_WITH_ORIGIN
2095 TEMPLATE_VBOXR3TSTEXE_LDFLAGS= '$(VBOX_GCC_RPATH_OPT)$$(VBOX_ORIGIN)/..' $(TEMPLATE_VBOXR3EXE_LDFLAGS)
2096endif
2097ifeq ($(KBUILD_TARGET),win)
2098 ifdef VBOX_SIGNING_MODE
2099 TEMPLATE_VBOXR3TSTEXE_POST_CMDS =
2100 endif
2101endif
2102
2103#
2104# Template for the CppUnit kind of testcases.
2105#
2106TEMPLATE_VBOXCPPUNITEXE = VBox CppUnit Testcase Exe
2107TEMPLATE_VBOXCPPUNITEXE_EXTENDS = VBOXR3TSTEXE
2108## @todo make a CPPUNIT SDK and add cppunit tools packages for windows, mac, solaris and OS/2.
2109#TEMPLATE_VBOXCPPUNITEXE_SDKS = CPPUNIT -
2110TEMPLATE_VBOXCPPUNITEXE_LIBS = \
2111 $(TEMPLATE_VBOXR3TSTEXE_LIBS) \
2112 cppunit
2113
2114#
2115# Template for building bad C/C++ style R3 executables (no -pedantic).
2116#
2117TEMPLATE_VBOXR3NPEXE = VBox Ring 3 Non-pedantic
2118TEMPLATE_VBOXR3NPEXE_EXTENDS = VBOXR3EXE
2119ifneq ($(KBUILD_TARGET),win) # (only gcc)
2120 TEMPLATE_VBOXR3NPEXE_TOOL = $(VBOX_GCC_TOOL)
2121 TEMPLATE_VBOXR3NPEXE_CXXFLAGS = $(filter-out -pedantic,$(TEMPLATE_VBOXR3EXE_CXXFLAGS))
2122 TEMPLATE_VBOXR3NPEXE_CFLAGS = $(filter-out -pedantic -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations,$(TEMPLATE_VBOXR3EXE_CFLAGS))
2123endif
2124
2125
2126#
2127# Template for building bad C/C++ style R3 shared libraries / Dlls (no -pedantic).
2128# This is mostly identical to the VBOXR3NPEXE template.
2129#
2130TEMPLATE_VBOXR3NP= VBox Ring 3 Non-pedantic
2131TEMPLATE_VBOXR3NP_EXTENDS = VBOXR3NPEXE
2132TEMPLATE_VBOXR3NP_LDFLAGS.l4 = \
2133 $(L4_LIBDIR)/../crt0.s.o \
2134 -T$(L4_LIBDIR)/../main_rel.ld \
2135 -nostdlib
2136TEMPLATE_VBOXR3NP_DEFS.l4 = $(TEMPLATE_VBOXR3NPEXE_DEFS.l4) __PIC__
2137ifeq ($(filter-out solaris.x86 %.amd64,$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),)
2138 ifneq ($(KBUILD_TARGET),win)
2139 TEMPLATE_VBOXR3NP_DEFS = $(TEMPLATE_VBOXR3NPEXE_DEFS) PIC
2140 TEMPLATE_VBOXR3NP_CFLAGS = $(TEMPLATE_VBOXR3NPEXE_CFLAGS) -fPIC
2141 TEMPLATE_VBOXR3NP_CXXFLAGS = $(TEMPLATE_VBOXR3NPEXE_CXXFLAGS) -fPIC
2142 TEMPLATE_VBOXR3NP_LDFLAGS = $(TEMPLATE_VBOXR3NPEXE_LDFLAGS) -fPIC
2143 endif
2144endif
2145
2146
2147#
2148# Template for building libraries, shared libraries / modules
2149# which only depends on IPRT for crt.
2150#
2151TEMPLATE_VBOXNOCRTGCC = VBox no-crt GCC libraries and modules, yasm/nasm.
2152TEMPLATE_VBOXNOCRTGCC_DEFS = IN_RING3 IPRT_NO_CRT $(ARCH_BITS_DEFS)
2153TEMPLATE_VBOXNOCRTGCC_ASDEFS = ASM_CALL64_GCC
2154TEMPLATE_VBOXNOCRTGCC_CFLAGS = -nostdinc -fno-strict-aliasing -fno-math-errno -Wall
2155TEMPLATE_VBOXNOCRTGCC_CFLAGS.x86 = -m32
2156TEMPLATE_VBOXNOCRTGCC_CFLAGS.amd64 = -m64 -mcmodel=medium -fno-common
2157TEMPLATE_VBOXNOCRTGCC_CFLAGS.release = -O2 -fno-strict-aliasing
2158TEMPLATE_VBOXNOCRTGCC_CFLAGS.profile = $(TEMPLATE_VBOXNOCRTGCC_CFLAGS.release)
2159TEMPLATE_VBOXNOCRTGCC_CFLAGS.kprofile = $(TEMPLATE_VBOXNOCRTGCC_CFLAGS.release)
2160ifdef VBOX_TARGET_MAC_OS_X_VERSION_10_5 ## @todo this probably works for 10.4 too, check.
2161 TEMPLATE_VBOXNOCRTGCC_CFLAGS.darwin = -static
2162else
2163 TEMPLATE_VBOXNOCRTGCC_CFLAGS.darwin = -mdynamic-no-pic
2164endif
2165TEMPLATE_VBOXNOCRTGCC_CXXFLAGS = $(TEMPLATE_VBOXNOCRTGCC_CFLAGS)
2166TEMPLATE_VBOXNOCRTGCC_CXXFLAGS.$(KBUILD_TARGET) = $(TEMPLATE_VBOXNOCRTGCC_CFLAGS.$(KBUILD_TARGET))
2167TEMPLATE_VBOXNOCRTGCC_CXXFLAGS.$(KBUILD_TARGET_ARCH) = $(TEMPLATE_VBOXNOCRTGCC_CFLAGS.$(KBUILD_TARGET_ARCH))
2168TEMPLATE_VBOXNOCRTGCC_INCS = $(PATH_ROOT)/include/iprt/nocrt
2169
2170ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),win.amd64)
2171 # cross compile to 64-bit ELF (linux).
2172 TEMPLATE_VBOXNOCRTGCC_TOOL = XGCCAMD64LINUX
2173 TEMPLATE_VBOXNOCRTGCC_ASTOOL = YASM
2174 TEMPLATE_VBOXNOCRTGCC_ASFLAGS = -f elf64 -DASM_FORMAT_ELF -D__YASM__ -w+orphan-labels -g dwarf2
2175 TEMPLATE_VBOXNOCRTGCC_LIBS = $(PATH_DEVTOOLS)/win.x86/x86_64-unknown-linux-gnu/20060701-r2/lib/gcc/x86_64-unknown-linux-gnu/3.4.6/libgcc.a
2176 TEMPLATE_VBOXNOCRTGCC_LDFLAGS = -nostdlib
2177
2178else ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),win.x86)
2179 # Use the default GCC (MinGW) with the Microsoft linker.
2180 # (Drop all '-g' options as we're unable to strip the debug info.)
2181 TEMPLATE_VBOXNOCRTGCC_TOOL = $(VBOX_GCC_TOOL)
2182 TEMPLATE_VBOXNOCRTGCC_ASTOOL = $(VBOX_ASTOOL)
2183 TEMPLATE_VBOXNOCRTGCC_ASFLAGS = $(VBOX_ASFLAGS)
2184 TEMPLATE_VBOXNOCRTGCC_LDTOOL = $(VBOX_VCC_TOOL)
2185 TEMPLATE_VBOXNOCRTGCC_LDFLAGS = -Incremental:NO -MapInfo:Exports -NoD
2186 TEMPLATE_VBOXNOCRTGCC_LIBS = $(VBOX_GCC_LIBGCC)
2187 TEMPLATE_VBOXNOCRTGCC_CFLAGS := $(filter-out -g,$(TEMPLATE_VBOXNOCRTGCC_CFLAGS)) -s
2188
2189else
2190 # Use the default GCC.
2191 # The use of --exclude-libs ALL is to avoid confusing the linux ld.so.
2192 TEMPLATE_VBOXNOCRTGCC_TOOL = $(VBOX_GCC_TOOL)
2193 TEMPLATE_VBOXNOCRTGCC_ASTOOL = $(VBOX_ASTOOL)
2194 TEMPLATE_VBOXNOCRTGCC_ASFLAGS = $(VBOX_ASFLAGS)
2195 TEMPLATE_VBOXNOCRTGCC_CFLAGS += $(VBOX_GCC_fno-stack-protector)
2196 TEMPLATE_VBOXNOCRTGCC_CXXFLAGS += $(VBOX_GCC_fno-stack-protector)
2197 ifeq ($(KBUILD_TARGET_ARCH),amd64)
2198 # in 64-bit mode we'll build a sys-module (VBoxREM2).
2199 if1of ($(KBUILD_TARGET),darwin solaris)
2200 TEMPLATE_VBOXNOCRTGCC_LDFLAGS.solaris= -64 -r
2201 else
2202 TEMPLATE_VBOXNOCRTGCC_LDFLAGS = -nostdlib
2203 endif
2204 else # x86:
2205 TEMPLATE_VBOXNOCRTGCC_LDFLAGS = -nostdlib
2206 ifn1of ($(KBUILD_TARGET), os2 darwin solaris)
2207 TEMPLATE_VBOXNOCRTGCC_LDFLAGS += -Wl,--no-undefined
2208 endif
2209 endif # x86
2210 TEMPLATE_VBOXNOCRTGCC_LDFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_LDFLAGS)
2211 TEMPLATE_VBOXNOCRTGCC_LIBS = # FIXME - has unwind mess.
2212endif
2213
2214
2215#
2216# Same as VBOXNOCRTGCC only it uses GAS as the assembler instead of yasm/nasm.
2217#
2218TEMPLATE_VBOXNOCRTGAS = VBox no-crt GCC libraries and modules, gas.
2219TEMPLATE_VBOXNOCRTGAS_EXTENDS = VBOXNOCRTGCC
2220TEMPLATE_VBOXNOCRTGAS_ASTOOL = $(TEMPLATE_VBOXNOCRTGCC_TOOL)
2221ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),win.x86)
2222 TEMPLATE_VBOXNOCRTGAS_ASFLAGS = -s
2223else
2224 TEMPLATE_VBOXNOCRTGAS_ASFLAGS = -g
2225endif
2226TEMPLATE_VBOXNOCRTGAS_ASFLAGS.x86 = -m32
2227TEMPLATE_VBOXNOCRTGAS_ASFLAGS.amd64 = -m64
2228
2229
2230#
2231# Template for building executables that are part of the VBox Main component
2232# (COM/XPCOM interface to VirtualBox).
2233#
2234TEMPLATE_VBOXMAINEXE = VBox Main Executable
2235TEMPLATE_VBOXMAINEXE_ASTOOL = $(VBOX_ASTOOL)
2236TEMPLATE_VBOXMAINEXE_ASFLAGS = $(VBOX_ASFLAGS)
2237TEMPLATE_VBOXMAINEXE_DEFS = IN_RING3 UNICODE NDEBUG=1
2238TEMPLATE_VBOXMAINEXE_DEFS.win = _UNICODE
2239TEMPLATE_VBOXMAINEXE_RCDEFS = $(TEMPLATE_VBOXR3EXE_RCDEFS)
2240TEMPLATE_VBOXMAINEXE_LIBS.kprofile = $(LIB_KPROFILE)
2241TEMPLATE_VBOXMAINEXE_INCS = \
2242 $(VBOX_PATH_SDK)/include
2243
2244ifeq ($(KBUILD_TARGET),win)
2245 TEMPLATE_VBOXMAINEXE_SDKS = WINPSDK W2K3DDK
2246 ifdef VBOX_USE_VCC80
2247 TEMPLATE_VBOXMAINEXE_TOOL = $(VBOX_VCC_TOOL)
2248 TEMPLATE_VBOXMAINEXE_CXXFLAGS = -Zi -Zl -GR -GF- -MD -EHsc -W3 -wd4065 -wd4996 -Zc:wchar_t- $(VBOX_VCC_OPT) $(VBOX_VCC_FP)
2249 TEMPLATE_VBOXMAINEXE_CXXFLAGS.debug = -RTCsu
2250 else
2251 TEMPLATE_VBOXMAINEXE_TOOL = VCC70
2252 TEMPLATE_VBOXMAINEXE_CXXFLAGS = -Zi -Zl -GR -GX- -GF- -MD -EHsc -W3 -wd4065 $(VBOX_VCC_OPT) $(VBOX_VCC_FP)
2253 TEMPLATE_VBOXMAINEXE_CXXFLAGS.debug = -GZ
2254 endif
2255 TEMPLATE_VBOXMAINEXE_CXXFLAGS.kprofile = -Gh -GH
2256 TEMPLATE_VBOXMAINEXE_CFLAGS = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS)
2257 TEMPLATE_VBOXMAINEXE_CFLAGS.debug = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.debug)
2258 TEMPLATE_VBOXMAINEXE_CFLAGS.kprofile = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.kprofile)
2259 TEMPLATE_VBOXMAINEXE_INCS += \
2260 $(PATH_TOOL_$(VBOX_VCC_TOOL)_ATLMFC_INC)
2261 TEMPLATE_VBOXMAINEXE_LDFLAGS = \
2262 /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LARGEADDRESSAWARE /DEBUG\
2263 /DISALLOWLIB:libc.lib \
2264 /DISALLOWLIB:libcd.lib \
2265 /DISALLOWLIB:msvcrt.lib \
2266 /DISALLOWLIB:msvcrtd.lib \
2267 /DISALLOWLIB:libcmtd.lib \
2268 /DISALLOWLIB:libcmt.lib
2269 TEMPLATE_VBOXMAINEXE_LIBS = \
2270 $(LIB_RUNTIME) \
2271 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/msvcrt.lib \
2272 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/msvcprt.lib \
2273 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/oldnames.lib \
2274 $(PATH_TOOL_$(VBOX_VCC_TOOL)_ATLMFC_LIB)/atls.lib
2275 TEMPLATE_VBOXMAINEXE_POST_CMDS = $(VBOX_SIGN_IMAGE_CMDS)
2276 TEMPLATE_VBOXMAINEXE_INTERMEDIATES = \
2277 $(VBOX_PATH_SDK)/include/VirtualBox.h
2278
2279else # the GCC guys:
2280
2281TEMPLATE_VBOXMAINEXE_TOOL = $(VBOX_GCC_TOOL)
2282TEMPLATE_VBOXMAINEXE_CXXFLAGS = -g -Wall -Wno-long-long -Wno-trigraphs -pipe -Wno-non-virtual-dtor -fshort-wchar -fpermissive -fexceptions -frtti $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_fvisibility-hidden)
2283TEMPLATE_VBOXMAINEXE_CXXFLAGS.x86 = -m32
2284TEMPLATE_VBOXMAINEXE_CXXFLAGS.amd64 = -m64
2285TEMPLATE_VBOXMAINEXE_CXXFLAGS.kprofile = -finstrument-functions
2286TEMPLATE_VBOXMAINEXE_CFLAGS = -g -Wall -Wno-long-long -Wno-trigraphs -pipe -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing $(VBOX_GCC_fvisibility-hidden)
2287TEMPLATE_VBOXMAINEXE_CFLAGS.x86 = -m32
2288TEMPLATE_VBOXMAINEXE_CFLAGS.amd64 = -m64
2289TEMPLATE_VBOXMAINEXE_CFLAGS.kprofile = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.kprofile)
2290TEMPLATE_VBOXMAINEXE_LDFLAGS.x86 = -m32
2291TEMPLATE_VBOXMAINEXE_LDFLAGS.amd64 = -m64
2292 ifeq ($(KBUILD_TARGET),linux)
2293TEMPLATE_VBOXMAINEXE_LIBS = pthread m rt $(LIB_RUNTIME)
2294TEMPLATE_VBOXMAINEXE_LDFLAGS.linux = $(VBOX_LD_as_needed)
2295 else ifeq ($(KBUILD_TARGET),l4)
2296TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME)
2297# no libs as yet in l4 target - must be added later
2298 else ifeq ($(KBUILD_TARGET),os2)
2299TEMPLATE_VBOXMAINEXE_TOOL = GXX3OMF
2300TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME)
2301 else ifeq ($(KBUILD_TARGET),darwin)
2302TEMPLATE_VBOXMAINEXE_TOOL = GXX4MACHO
2303TEMPLATE_VBOXMAINEXE_DEFS += $(VBOX_DARWIN_DEF_SDK_DEFS)
2304TEMPLATE_VBOXMAINEXE_CFLAGS += $(VBOX_DARWIN_DEF_SDK_CFLAGS)
2305TEMPLATE_VBOXMAINEXE_CXXFLAGS += $(VBOX_DARWIN_DEF_SDK_CXXFLAGS)
2306TEMPLATE_VBOXMAINEXE_OBJCFLAGS += $(VBOX_DARWIN_DEF_SDK_OBJCFLAGS)
2307TEMPLATE_VBOXMAINEXE_LDFLAGS += $(VBOX_DARWIN_DEF_SDK_LDFLAGS) -bind_at_load -framework Carbon
2308TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME)
2309 else if1of ($(KBUILD_TARGET), freebsd netbsd openbsd)
2310TEMPLATE_VBOXMAINEXE_TOOL = GXX3
2311TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME)
2312 else ifeq ($(KBUILD_TARGET),solaris)
2313TEMPLATE_VBOXMAINEXE_TOOL = GXX3PLAIN
2314TEMPLATE_VBOXMAINEXE_DEFS += _REENTRANT
2315TEMPLATE_VBOXMAINEXE_LIBS = $(LIB_RUNTIME) rt
2316 else
2317$(warning Warning: VBOX Build: Target $(KBUILD_TARGET) is not officially supported!)
2318TEMPLATE_VBOXMAINEXE_LIBS =
2319 endif
2320 ifdef VBOX_WITH_ORIGIN
2321TEMPLATE_VBOXMAINEXE_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$$(VBOX_ORIGIN)'
2322 endif
2323TEMPLATE_VBOXMAINEXE_INTERMEDIATES = \
2324 $(VBOX_PATH_SDK)/include/VirtualBox_XPCOM.h
2325
2326endif # !win
2327
2328# Add COM/XPCOM stuff
2329TEMPLATE_VBOXMAINEXE_LIBS += \
2330 $(PATH_LIB)/VBoxCOM$(VBOX_SUFF_LIB)
2331ifdef VBOX_WITH_XPCOM
2332 ## @todo may be worth creating the VBOX_XPCOM SDK def
2333 TEMPLATE_VBOXMAINEXE_DEFS += VBOX_WITH_XPCOM
2334 TEMPLATE_VBOXMAINEXE_INCS += \
2335 $(VBOX_XPCOM_INCS)
2336 TEMPLATE_VBOXMAINEXE_LIBS += \
2337 $(LIB_XPCOM)
2338endif
2339
2340#
2341# Template for building the Main DLL modules (such as in-process COM/XPCOM
2342# components for Main).
2343#
2344# This differs from VBOXMAINEXE only in PIC handling and similar DLL stuff.
2345#
2346
2347TEMPLATE_VBOXMAINDLL = VBox Main Component (shared library)
2348TEMPLATE_VBOXMAINDLL_EXTENDS = VBOXMAINEXE
2349ifeq ($(filter-out solaris.x86 %.amd64,$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),)
2350 ifneq ($(KBUILD_TARGET),win)
2351 TEMPLATE_VBOXMAINDLL_DEFS = PIC $(TEMPLATE_VBOXMAINEXE_DEFS)
2352 TEMPLATE_VBOXMAINDLL_CFLAGS = -fPIC $(TEMPLATE_VBOXMAINEXE_CFLAGS)
2353 TEMPLATE_VBOXMAINDLL_CXXFLAGS = -fPIC $(TEMPLATE_VBOXMAINEXE_CXXFLAGS)
2354 TEMPLATE_VBOXMAINDLL_LDFLAGS = -fPIC $(TEMPLATE_VBOXMAINEXE_LDFLAGS)
2355 endif
2356endif
2357ifeq ($(KBUILD_TARGET),darwin)
2358 TEMPLATE_VBOXMAINDLL_LDFLAGS = $(filter-out -bind_at_load,$(TEMPLATE_VBOXMAINEXE_LDFLAGS))
2359endif
2360
2361#
2362# Template for building the Main static libraries.
2363#
2364# This differs from VBOXMAINDLL only that it zeroes out the _LIBS definition.
2365#
2366TEMPLATE_VBOXMAINLIB = VBox Main Component (static library)
2367TEMPLATE_VBOXMAINLIB_EXTENDS = VBOXMAINDLL
2368TEMPLATE_VBOXMAINLIB_LIBS =
2369
2370#
2371# Template for building executables that use the VBox Main component.
2372#
2373TEMPLATE_VBOXMAINCLIENTEXE = VBox Main Client (executable)
2374TEMPLATE_VBOXMAINCLIENTEXE_EXTENDS = VBOXMAINEXE
2375ifeq ($(KBUILD_TARGET),win)
2376 TEMPLATE_VBOXMAINCLIENTEXE_LIBS.win = $(TEMPLATE_VBOXMAINEXE_LIBS.win) \
2377 $(PATH_SDK_WINPSDK_LIB)/User32.Lib \
2378 $(PATH_SDK_WINPSDK_LIB)/Shell32.Lib \
2379 $(PATH_SDK_WINPSDK_LIB)/ShLwApi.Lib \
2380 $(PATH_SDK_WINPSDK_LIB)/Ole32.Lib \
2381 $(PATH_SDK_WINPSDK_LIB)/OleAut32.Lib \
2382 $(PATH_SDK_WINPSDK_LIB)/Uuid.Lib
2383else
2384 TEMPLATE_VBOXMAINCLIENTEXE_DEFS = $(TEMPLATE_VBOXMAINEXE_DEFS) \
2385 NDEBUG TRIMMED
2386 TEMPLATE_VBOXMAINCLIENTEXE_CXXFLAGS.linux = $(TEMPLATE_VBOXMAINEXE_CXXFLAGS.linux) \
2387 -pthread
2388 ifeq ($(KBUILD_TARGET),darwin)
2389 TEMPLATE_VBOXMAINCLIENTEXE_LDFLAGS = $(TEMPLATE_VBOXMAINEXE_LDFLAGS) -bind_at_load -framework Carbon
2390 endif
2391endif
2392
2393#
2394# Template for building shared libraries / DLLs that use the VBox Main component.
2395#
2396# This differs from VBOXMAINCLIENTEXE only in PIC handling and similar DLL stuff.
2397#
2398TEMPLATE_VBOXMAINCLIENTDLL = VBox MAIN Client (shared library)
2399TEMPLATE_VBOXMAINCLIENTDLL_EXTENDS = VBOXMAINCLIENTEXE
2400ifeq ($(filter-out solaris.x86 %.amd64,$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),)
2401 ifneq ($(KBUILD_TARGET),win)
2402 TEMPLATE_VBOXMAINCLIENTDLL_DEFS = PIC $(TEMPLATE_VBOXMAINCLIENTEXE_DEFS)
2403 TEMPLATE_VBOXMAINCLIENTDLL_CFLAGS = -fPIC $(TEMPLATE_VBOXMAINCLIENTEXE_CFLAGS)
2404 TEMPLATE_VBOXMAINCLIENTDLL_CXXFLAGS = -fPIC $(TEMPLATE_VBOXMAINCLIENTEXE_CXXFLAGS)
2405 TEMPLATE_VBOXMAINCLIENTDLL_LDFLAGS = -fPIC $(TEMPLATE_VBOXMAINCLIENTEXE_LDFLAGS)
2406 endif
2407endif
2408ifeq ($(KBUILD_TARGET),darwin)
2409 TEMPLATE_VBOXMAINCLIENTDLL_LDFLAGS = $(filter-out -bind_at_load,$(TEMPLATE_VBOXMAINCLIENTEXE_LDFLAGS))
2410endif
2411
2412
2413#
2414# Template for building Qt GUI executables.
2415#
2416TEMPLATE_VBOXQTGUIEXE = VBox Qt GUI Executable
2417TEMPLATE_VBOXQTGUIEXE_DEFS = IN_RING3 QT_NO_DEBUG QT_THREAD_SUPPORT $(ARCH_BITS_DEFS)
2418TEMPLATE_VBOXQTGUIEXE_INCS = \
2419 $(VBOX_PATH_SDK)/include \
2420 $(VBOX_PATH_QT)/include
2421
2422ifeq ($(KBUILD_TARGET),win)
2423 # drag in library configuration (we need QMAKE_PRL_DEFINES)
2424 ifneq ($(LIB_QT_PRL),)
2425 include $(LIB_QT_PRL)
2426 endif
2427 TEMPLATE_VBOXQTGUIEXE_TOOL = $(VBOX_VCC_TOOL)
2428 TEMPLATE_VBOXQTGUIEXE_DEFS += \
2429 _WIN32_WINNT=0x0500 UNICODE _UNICODE \
2430 QT_DLL _CRT_SECURE_NO_DEPRECATE \
2431 $(QMAKE_PRL_DEFINES)
2432 ## @todo VCC70 flags?
2433 ifdef VBOX_USE_VCC80
2434 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS = \
2435 -nologo -Zm200 -W3 -MD -Zi -EHsc -Zc:wchar_t-
2436 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.debug = -RTCsu
2437 else
2438 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS = \
2439 -nologo -Zm200 -W3 -MD -Zi -GX
2440 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.debug = -GZ
2441 endif
2442 TEMPLATE_VBOXQTGUIEXE_INCS += \
2443 $(PATH_TOOL_$(VBOX_VCC_TOOL)_ATLMFC_INC)
2444 TEMPLATE_VBOXQTGUIEXE_LDFLAGS = \
2445 /NOD /NOLOGO /INCREMENTAL:NO /MAPINFO:EXPORTS /DEBUG \
2446 /DELAYLOAD:oleaut32.dll
2447 TEMPLATE_VBOXQTGUIEXE_SDKS = WINPSDK
2448 TEMPLATE_VBOXQTGUIEXE_LIBS = \
2449 $(LIB_QT) \
2450 $(LIB_QTMAIN) \
2451 $(LIB_RUNTIME) \
2452 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/msvcprt.lib \
2453 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/msvcrt.lib \
2454 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/oldnames.lib \
2455 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/delayimp.lib \
2456 $(PATH_TOOL_$(VBOX_VCC_TOOL)_ATLMFC_LIB)/atls.lib
2457 TEMPLATE_VBOXQTGUIEXE_POST_CMDS = $(VBOX_SIGN_IMAGE_CMDS)
2458
2459else # the gcc guys:
2460 TEMPLATE_VBOXQTGUIEXE_TOOL = $(VBOX_GCC_TOOL)
2461 TEMPLATE_VBOXQTGUIEXE_DEFS.linux = _REENTRANT
2462 TEMPLATE_VBOXQTGUIEXE_DEFS.solaris = _REENTRANT
2463
2464 TEMPLATE_VBOXQTGUIEXE_INCS += \
2465 $(LIB_SDL_INC)
2466 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS = \
2467 -pipe -Wall -W -frtti -fno-exceptions -Wno-non-virtual-dtor \
2468 -Wno-long-long -fshort-wchar -fno-strict-aliasing \
2469 $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_fvisibility-inlines-hidden)
2470 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.x86 = -m32
2471 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.amd64 = -m64
2472 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS.linux = -pthread
2473 TEMPLATE_VBOXQTGUIEXE_LDFLAGS.x86 = -m32
2474 TEMPLATE_VBOXQTGUIEXE_LDFLAGS.amd64 = -m64
2475 TEMPLATE_VBOXQTGUIEXE_LIBS = \
2476 $(LIB_QT) \
2477 $(LIB_SDL) \
2478 $(LIB_RUNTIME) \
2479 $(LIB_REM) \
2480 $(LIB_VMM)
2481
2482 ifeq ($(KBUILD_TARGET_ARCH),amd64)
2483 TEMPLATE_VBOXQTGUIEXE_LIBPATH = \
2484 $(VBOX_PATH_QT)/lib64 $(VBOX_PATH_QT)/lib
2485 else
2486 TEMPLATE_VBOXQTGUIEXE_LIBPATH = \
2487 $(VBOX_PATH_QT)/lib
2488 endif
2489
2490 ifeq ($(KBUILD_TARGET),linux)
2491 TEMPLATE_VBOXQTGUIEXE_LDFLAGS += $(VBOX_LD_as_needed)
2492 else ifeq ($(KBUILD_TARGET),darwin)
2493 TEMPLATE_VBOXQTGUIEXE_DEFS += $(VBOX_DARWIN_DEF_SDK_DEFS)
2494 TEMPLATE_VBOXQTGUIEXE_CFLAGS += $(VBOX_DARWIN_DEF_SDK_CFLAGS)
2495 TEMPLATE_VBOXQTGUIEXE_CXXFLAGS += $(VBOX_DARWIN_DEF_SDK_CXXFLAGS)
2496 TEMPLATE_VBOXQTGUIEXE_OBJCFLAGS += $(VBOX_DARWIN_DEF_SDK_OBJCFLAGS)
2497 TEMPLATE_VBOXQTGUIEXE_LDFLAGS += $(VBOX_DARWIN_DEF_SDK_LDFLAGS) -framework Carbon -framework QuickTime -bind_at_load
2498 TEMPLATE_VBOXQTGUIEXE_LIBS +=
2499 TEMPLATE_VBOXQTGUIEXE_LIBPATH +=
2500 else ifeq ($(KBUILD_TARGET),os2)
2501 # drag in library configuration (we need QMAKE_PRL_DEFINES)
2502 ifneq ($(LIB_QT_PRL),)
2503 include $(LIB_QT_PRL)
2504 endif
2505 TEMPLATE_VBOXQTGUIEXE_DEFS += $(QMAKE_PRL_DEFINES)
2506 TEMPLATE_VBOXQTGUIEXE_LIBS +=
2507 TEMPLATE_VBOXQTGUIEXE_LIBPATH +=
2508 else
2509 TEMPLATE_VBOXQTGUIEXE_INCS += \
2510 $(VBOX_XCURSOR_INCS)
2511 TEMPLATE_VBOXQTGUIEXE_LIBS += \
2512 $(VBOX_XCURSOR_LIBS) \
2513 Xext \
2514 X11 \
2515 m \
2516 $(LIB_PTHREAD)
2517 TEMPLATE_VBOXQTGUIEXE_LIBPATH += \
2518 $(VBOX_LIBPATH_X11)
2519 ifeq ($(KBUILD_TARGET),freebsd)
2520 TEMPLATE_VBOXQTGUIEXE_INCS += \
2521 /usr/include \
2522 /usr/X11R6/include \
2523 /usr/local/include
2524 endif
2525 ifeq ($(KBUILD_TARGET),solaris)
2526 TEMPLATE_VBOXQTGUIEXE_LIBS += \
2527 rt socket nsl
2528 endif
2529 endif
2530 ifdef VBOX_WITH_ORIGIN
2531 ifeq ($(KBUILD_TARGET),solaris)
2532 TEMPLATE_VBOXQTGUIEXE_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$$(VBOX_ORIGIN):$$(VBOX_ORIGIN)/qtgcc/lib'
2533 else
2534 TEMPLATE_VBOXQTGUIEXE_LDFLAGS += '$(VBOX_GCC_RPATH_OPT)$$(VBOX_ORIGIN)'
2535 endif
2536 endif
2537
2538endif # !win
2539
2540# Add COM/XPCOM stuff
2541TEMPLATE_VBOXQTGUIEXE_LIBS += \
2542 $(PATH_LIB)/VBoxCOM$(VBOX_SUFF_LIB)
2543ifdef VBOX_WITH_XPCOM
2544 ## @todo may be worth creating the VBOX_XPCOM SDK def
2545 TEMPLATE_VBOXQTGUIEXE_DEFS += VBOX_WITH_XPCOM
2546 TEMPLATE_VBOXQTGUIEXE_INCS += \
2547 $(VBOX_XPCOM_INCS)
2548 TEMPLATE_VBOXQTGUIEXE_LIBS += \
2549 $(LIB_XPCOM)
2550 TEMPLATE_VBOXQTGUIEXE_INTERMEDIATES += \
2551 $(VBOX_PATH_SDK)/include/VirtualBox_XPCOM.h
2552else
2553 TEMPLATE_VBOXQTGUIEXE_INTERMEDIATES += \
2554 $(VBOX_PATH_SDK)/include/VirtualBox.h
2555endif
2556
2557#
2558# Template for building Qt GUI components.
2559#
2560TEMPLATE_VBOXQTGUI = VBox Qt GUI Components
2561TEMPLATE_VBOXQTGUI_EXTENDS = VBOXQTGUIEXE
2562TEMPLATE_VBOXQTGUI_LIBS = $(filter-out $(QTMAIN),$(TEMPLATE_VBOXQTGUIEXE_LIBS))
2563ifeq ($(KBUILD_TARGET),darwin)
2564 TEMPLATE_VBOXQTGUI_LDFLAGS = $(filter-out -framework Carbon -framework QuickTime -bind_at_load,$(TEMPLATE_VBOXQTGUIEXE_LDFLAGS))
2565endif
2566ifeq ($(filter-out solaris.x86 %.amd64,$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),)
2567 ifneq ($(KBUILD_TARGET),win)
2568 TEMPLATE_VBOXQTGUI_DEFS = PIC $(TEMPLATE_VBOXQTGUIEXE_DEFS)
2569 TEMPLATE_VBOXQTGUI_CFLAGS = -fPIC $(TEMPLATE_VBOXQTGUIEXE_CFLAGS)
2570 TEMPLATE_VBOXQTGUI_CXXFLAGS = -fPIC $(TEMPLATE_VBOXQTGUIEXE_CXXFLAGS)
2571 TEMPLATE_VBOXQTGUI_LDFLAGS = -fPIC $(TEMPLATE_VBOXQTGUIEXE_LDFLAGS)
2572 endif
2573endif
2574
2575
2576#
2577# Template for building build bldprogs.
2578#
2579TEMPLATE_VBOXBLDPROG = VBox Build Program
2580TEMPLATE_VBOXBLDPROG_DEFS = IN_RING3
2581ifeq ($(KBUILD_HOST),win)
2582 ifeq ($(KBUILD_HOST_ARCH),x86)
2583 ifdef VBOX_USE_VCC80
2584 TEMPLATE_VBOXBLDPROG_TOOL = VCC80X86
2585 else
2586 TEMPLATE_VBOXBLDPROG_TOOL = VCC70
2587 endif
2588 TEMPLATE_VBOXBLDPROG_SDKS = WIN32SDK
2589 else
2590 TEMPLATE_VBOXBLDPROG_TOOL = VCC80AMD64
2591 TEMPLATE_VBOXBLDPROG_SDKS = WIN64SDK
2592 endif
2593 ifneq ($(TEMPLATE_VBOXBLDPROG_TOOL),VCC70)
2594 TEMPLATE_VBOXBLDPROG_CXXFLAGS = -Zi -Zl -GR- -EHs-c- -GF- -MT -W3 -wd4996 -Zc:wchar_t-
2595 TEMPLATE_VBOXBLDPROG_CXXFLAGS.debug = -RTCsu
2596 TEMPLATE_VBOXBLDPROG_CXXFLAGS.release = -O2 -Oy- -GS-
2597 else
2598 TEMPLATE_VBOXBLDPROG_CXXFLAGS = -Zi -Zl -GR- -GX- -GF- -MT -W3
2599 TEMPLATE_VBOXBLDPROG_CXXFLAGS.debug = -GZ
2600 TEMPLATE_VBOXBLDPROG_CXXFLAGS.release = -Ogitb2 -Oy-
2601 endif
2602 TEMPLATE_VBOXBLDPROG_CXXFLAGS.profile = $(TEMPLATE_VBOXBLDPROG_CXXFLAGS.release)
2603 TEMPLATE_VBOXBLDPROG_CXXFLAGS.kprofile = $(TEMPLATE_VBOXBLDPROG_CXXFLAGS.release)
2604 TEMPLATE_VBOXBLDPROG_CFLAGS = $(TEMPLATE_VBOXBLDPROG_CXXFLAGS)
2605 TEMPLATE_VBOXBLDPROG_CFLAGS.debug = $(TEMPLATE_VBOXBLDPROG_CXXFLAGS.debug)
2606 TEMPLATE_VBOXBLDPROG_CFLAGS.release = $(TEMPLATE_VBOXBLDPROG_CXXFLAGS.release)
2607 TEMPLATE_VBOXBLDPROG_CFLAGS.profile = $(TEMPLATE_VBOXBLDPROG_CXXFLAGS.profile)
2608 TEMPLATE_VBOXBLDPROG_CFLAGS.kprofile = $(TEMPLATE_VBOXBLDPROG_CXXFLAGS.kprofile)
2609 TEMPLATE_VBOXBLDPROG_LDFLAGS = \
2610 /NOD /INCREMENTAL:NO /MAPINFO:EXPORTS /LARGEADDRESSAWARE /DEBUG \
2611 /DISALLOWLIB:libcd.lib \
2612 /DISALLOWLIB:libcmtd.lib \
2613 /DISALLOWLIB:msvcrt.lib \
2614 /DISALLOWLIB:msvcrtd.lib \
2615 /DISALLOWLIB:msvcprt.lib \
2616 /DISALLOWLIB:msvcprtd.lib
2617 TEMPLATE_VBOXBLDPROG_LIBS = \
2618 $(PATH_TOOL_$(TEMPLATE_VBOXBLDPROG_TOOL)_LIB)/oldnames.lib \
2619 $(PATH_TOOL_$(TEMPLATE_VBOXBLDPROG_TOOL)_LIB)/libcmt.lib \
2620 $(PATH_TOOL_$(TEMPLATE_VBOXBLDPROG_TOOL)_LIB)/libcpmt.lib
2621
2622else
2623# (gcc of some kind )
2624TEMPLATE_VBOXBLDPROG_TOOL = GXX3
2625TEMPLATE_VBOXBLDPROG_CFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs $(VBOX_GCC_Wno-variadic-macros) -pipe -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
2626TEMPLATE_VBOXBLDPROG_CFLAGS.x86 = -m32
2627TEMPLATE_VBOXBLDPROG_CFLAGS.amd64 = -m64
2628TEMPLATE_VBOXBLDPROG_CFLAGS.release = -O2 -fno-omit-frame-pointer -fno-strict-aliasing
2629TEMPLATE_VBOXBLDPROG_CFLAGS.profile = $(TEMPLATE_VBOXBLDPROG_CXXFLAGS.profile)
2630TEMPLATE_VBOXBLDPROG_CFLAGS.kprofile = $(TEMPLATE_VBOXBLDPROG_CXXFLAGS.kprofile)
2631TEMPLATE_VBOXBLDPROG_CXXFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs -pipe
2632TEMPLATE_VBOXBLDPROG_CXXFLAGS.x86 = -m32
2633TEMPLATE_VBOXBLDPROG_CXXFLAGS.amd64 = -m64
2634TEMPLATE_VBOXBLDPROG_CXXFLAGS.release = -O2 -fno-omit-frame-pointer -fno-strict-aliasing
2635TEMPLATE_VBOXBLDPROG_CXXFLAGS.profile = $(TEMPLATE_VBOXBLDPROG_CXXFLAGS.release)
2636TEMPLATE_VBOXBLDPROG_CXXFLAGS.kprofile = $(TEMPLATE_VBOXBLDPROG_CXXFLAGS.release)
2637TEMPLATE_VBOXBLDPROG_LDFLAGS.x86 = -m32
2638TEMPLATE_VBOXBLDPROG_LDFLAGS.amd64 = -m64
2639 ifeq ($(KBUILD_HOST),linux)
2640TEMPLATE_VBOXBLDPROG_LIBS = pthread m rt dl
2641 else ifeq ($(KBUILD_HOST),os2)
2642TEMPLATE_VBOXBLDPROG_TOOL = GXX3OMF
2643TEMPLATE_VBOXBLDPROG_LIBS = socket iconv
2644 else ifeq ($(KBUILD_HOST),darwin)
2645TEMPLATE_VBOXBLDPROG_TOOL = GXX4MACHO
2646TEMPLATE_VBOXBLDPROG_CFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_CFLAGS) -fno-common
2647TEMPLATE_VBOXBLDPROG_CXXFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS)
2648TEMPLATE_VBOXBLDPROG_OBJCFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_OBJCFLAGS)
2649TEMPLATE_VBOXBLDPROG_LDFLAGS.darwin = $(VBOX_DARWIN_DEF_SDK_LDFLAGS)
2650TEMPLATE_VBOXBLDPROG_LIBS =
2651 else if1of ($(KBUILD_HOST), freebsd netbsd openbsd)
2652TEMPLATE_VBOXBLDPROG_TOOL = GXX3
2653TEMPLATE_VBOXBLDPROG_LIBS =
2654 else ifeq ($(KBUILD_HOST),solaris)
2655TEMPLATE_VBOXBLDPROG_TOOL = GXX3PLAIN
2656TEMPLATE_VBOXBLDPROG_LIBS = rt
2657 else
2658$(warning Warning: VBOX Build: Target $(KBUILD_HOST) is not officially supported!)
2659 endif
2660
2661endif # !win
2662
2663
2664#
2665# Windows rc workaround for crosscompiling.
2666# (Some (old) Wine versions fails loading msvcrt.dll from the VCC bin directory.)
2667#
2668ifneq ($(KBUILD_HOST),win)
2669 TOOL_VCC80X86_RC := $(EXEC_X86_WIN32) $(PATH_DEVTOOLS)/win.x86/bin/rc.exe
2670 TOOL_VCC80AMD64_RC := $(EXEC_X86_WIN32) $(PATH_DEVTOOLS)/win.x86/bin/rc.exe
2671 TOOL_VCC70_RC := $(EXEC_X86_WIN32) $(PATH_DEVTOOLS)/win.x86/bin/rc.exe
2672 WIN32_MC = $(EXEC_X86_WIN32) $(PATH_DEVTOOLS)/win.x86/bin/mc.exe
2673else
2674 WIN32_MC = $(EXEC_X86_WIN32) $(firstword $(wildcard \
2675 $(PATH_SDK_WINPSDK_BIN)/MC.Exe\
2676 $(PATH_SDK_WINPSDK)/Bin/MC.Exe\
2677 $(PATH_SDK_WIN32SDK_BIN)/MC.Exe\
2678 $(PATH_SDK_WIN64SDK_BIN)/MC.Exe\
2679 $(PATH_DEVTOOLS)/win.x86/bin/mc.exe\
2680 ) Sorry_Cannot_find_mc_in_the_PSDK)
2681endif
2682
2683
2684#
2685# Template for building Linux host tools (only for KBUILD_TARGET=l4).
2686#
2687TEMPLATE_VBOXLNXHOSTR3EXE = Template for building linux host programs when targeting L4.
2688TEMPLATE_VBOXLNXHOSTR3EXE_INST = $(INST_BIN)
2689TEMPLATE_VBOXLNXHOSTR3EXE_BLD_TRG = linux
2690TEMPLATE_VBOXLNXHOSTR3EXE_TOOL = $(VBOX_GCC_TOOL)
2691TEMPLATE_VBOXLNXHOSTR3EXE_ASTOOL = YASM
2692TEMPLATE_VBOXLNXHOSTR3EXE_DLLSUFF = .so
2693TEMPLATE_VBOXLNXHOSTR3EXE_ASFLAGS = $(VBOX_ASFLAGS)
2694TEMPLATE_VBOXLNXHOSTR3EXE_DEFS = IN_RING3 $(ARCH_BITS_DEFS)
2695TEMPLATE_VBOXLNXHOSTR3EXE_CXXFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs -pipe $(VBOX_GCC_fno-stack-protector)
2696TEMPLATE_VBOXLNXHOSTR3EXE_CXXFLAGS.debug = -fno-inline
2697TEMPLATE_VBOXLNXHOSTR3EXE_CXXFLAGS.release = -O2 -fno-omit-frame-pointer -fno-strict-aliasing
2698TEMPLATE_VBOXLNXHOSTR3EXE_CXXFLAGS.profile = $(TEMPLATE_VBOXLNXHOSTR3EXE_CXXFLAGS.release)
2699TEMPLATE_VBOXLNXHOSTR3EXE_CXXFLAGS.kprofile = $(TEMPLATE_VBOXLNXHOSTR3EXE_CXXFLAGS.release)
2700TEMPLATE_VBOXLNXHOSTR3EXE_CFLAGS.release = $(TEMPLATE_VBOXLNXHOSTR3EXE_CXXFLAGS.release)
2701TEMPLATE_VBOXLNXHOSTR3EXE_CFLAGS.debug = $(TEMPLATE_VBOXLNXHOSTR3EXE_CXXFLAGS.debug)
2702TEMPLATE_VBOXLNXHOSTR3EXE_CFLAGS.profile = $(TEMPLATE_VBOXLNXHOSTR3EXE_CXXFLAGS.profile)
2703TEMPLATE_VBOXLNXHOSTR3EXE_CFLAGS.kprofile = $(TEMPLATE_VBOXLNXHOSTR3EXE_CXXFLAGS.kprofile)
2704TEMPLATE_VBOXLNXHOSTR3EXE_CFLAGS = -g -Wall -pedantic -Wno-long-long -Wno-trigraphs -pipe -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations $(VBOX_GCC_fno-stack-protector)
2705TEMPLATE_VBOXLNXHOSTR3EXE_LIBS = pthread m rt dl
2706
2707TEMPLATE_VBOXLNXHOSTR3LIB = Template for linux host libraries.
2708TEMPLATE_VBOXLNXHOSTR3LIB_EXTENDS = VBOXLNXHOSTR3EXE
2709TEMPLATE_VBOXLNXHOSTR3LIB_INST = $(INST_LIB)
2710
2711
2712#
2713# Template for building R3 programs for the guest additions.
2714# Note: Make sure you don't break VBOXGUESTR3CPPEXE when changing this.
2715#
2716TEMPLATE_VBOXGUESTR3EXE = VBox Guest Program
2717ifeq ($(KBUILD_TARGET),win)
2718 TEMPLATE_VBOXGUESTR3EXE_EXTENDS = VBOXR3EXE
2719 TEMPLATE_VBOXGUESTR3EXE_CFLAGS = $(filter-out -MD, $(TEMPLATE_VBOXR3EXE_CFLAGS)) -MT
2720 TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS = $(filter-out -MD, $(TEMPLATE_VBOXR3EXE_CFLAGS)) -MT
2721 TEMPLATE_VBOXGUESTR3EXE_LDFLAGS = $(filter-out /DISALLOWLIB:libcmt.lib, $(TEMPLATE_VBOXR3EXE_LDFLAGS)) \
2722 /DISALLOWLIB:msvcrt.lib \
2723 /DISALLOWLIB:msvcprt.lib
2724 TEMPLATE_VBOXGUESTR3EXE_LIBS = \
2725 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL)_LIB)/oldnames.lib \
2726 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL)_LIB)/libcmt.lib \
2727 $(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL)_LIB)/libcpmt.lib
2728else # the gcc guys
2729 TEMPLATE_VBOXGUESTR3EXE_EXTENDS = VBOXR3EXE
2730 TEMPLATE_VBOXGUESTR3EXE_TOOL := $(subst GXX,GCC,$(TEMPLATE_VBOXR3EXE_TOOL))
2731 TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) -fno-exceptions
2732endif
2733TEMPLATE_VBOXGUESTR3EXE_INST = $(INST_ADDITIONS)
2734TEMPLATE_VBOXGUESTR3EXE_DEFS := $(TEMPLATE_VBOXR3EXE_DEFS) IN_GUEST IN_GUEST_R3 IN_RT_R3
2735ifeq ($(KBUILD_TARGET),linux) # As few libs as possible on linux.
2736 TEMPLATE_VBOXGUESTR3EXE_LIBS = pthread rt m
2737endif
2738
2739#
2740# Template for building R3 (dynamic) libraries for the guest additions.
2741#
2742TEMPLATE_VBOXGUESTR3DLL = VBox Guest User Dynamic Libraries
2743TEMPLATE_VBOXGUESTR3DLL_EXTENDS = VBOXGUESTR3EXE
2744## @todo add a INSTFUN that separates dlls and libs.
2745ifn1of ($(KBUILD_TARGET), os2 win)
2746 TEMPLATE_VBOXGUESTR3DLL_DEFS = $(TEMPLATE_VBOXGUESTR3EXE_DEFS) PIC
2747 TEMPLATE_VBOXGUESTR3DLL_CFLAGS = $(TEMPLATE_VBOXGUESTR3EXE_CFLAGS) -fPIC
2748 TEMPLATE_VBOXGUESTR3DLL_CXXFLAGS = $(TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS) -fPIC -fno-exceptions
2749 TEMPLATE_VBOXGUESTR3DLL_LDFLAGS = $(TEMPLATE_VBOXGUESTR3EXE_LDFLAGS) -fPIC
2750endif
2751
2752#
2753# Template for building R3 (static) libraries for the guest additions.
2754#
2755TEMPLATE_VBOXGUESTR3LIB = VBox Guest User Libraries
2756TEMPLATE_VBOXGUESTR3LIB_EXTENDS = VBOXGUESTR3EXE
2757TEMPLATE_VBOXGUESTR3LIB_INST = $(INST_ADDITIONS_LIB)
2758if1of ($(KBUILD_TARGET), solaris) ## @todo r=bird: Fix the *R3Mini template to VBOXGUESTR3DLL and remove this hack.
2759 TEMPLATE_VBOXGUESTR3LIB_DEFS = $(TEMPLATE_VBOXGUESTR3EXE_DEFS) PIC
2760 TEMPLATE_VBOXGUESTR3LIB_CFLAGS = $(TEMPLATE_VBOXGUESTR3EXE_CFLAGS) -fPIC
2761 TEMPLATE_VBOXGUESTR3LIB_CXXFLAGS = $(TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS) -fPIC -fno-exceptions
2762endif
2763
2764
2765#
2766# Template for XFree86 guest modules (relocatable module, i.e. sysmod).
2767# This mostly about zapping the VBOXR3EXE linker flags and libraries.
2768#
2769TEMPLATE_VBOXGUESTR3XF86MOD = VBox Guest Program with C++ library dependencies
2770TEMPLATE_VBOXGUESTR3XF86MOD_EXTENDS = VBOXGUESTR3EXE
2771TEMPLATE_VBOXGUESTR3XF86MOD_LIBS.$(KBUILD_TYPE) = $(NO_SUCH_VARIABLE)
2772TEMPLATE_VBOXGUESTR3XF86MOD_LIBS.$(KBUILD_TARGET) = $(NO_SUCH_VARIABLE)
2773TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.$(KBUILD_TARGET) = $(NO_SUCH_VARIABLE)
2774TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.$(KBUILD_TYPE) = $(NO_SUCH_VARIABLE)
2775TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS = -r
2776if1of ($(KBUILD_TARGET), dragonfly freebsd linux netbsd openbsd) # the gnu ld guys.
2777 TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.release = -S
2778 TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.x86 = -m elf_i386
2779 TEMPLATE_VBOXGUESTR3XF86MOD_LDFLAGS.amd64 = -m elf_x86_64
2780endif
2781TEMPLATE_VBOXGUESTR3XF86MOD_CFLAGS = $(TEMPLATE_VBOXGUESTR3EXE_CFLAGS) -fno-merge-constants -std=c99
2782TEMPLATE_VBOXGUESTR3XF86MOD_CXXFLAGS= $(TEMPLATE_VBOXGUESTR3EXE_CXXFLAGS) -fno-merge-constants
2783TEMPLATE_VBOXGUESTR3XF86MOD_SYSSUFF = .o
2784TEMPLATE_VBOXGUESTR3XF86MOD_LIBS = \
2785 $(VBOX_LIB_VBGL_R3_XFREE86)
2786TEMPLATE_VBOXGUESTR3XF86MOD_DEFS = $(TEMPLATE_VBOXGUESTR3DLL_DEFS) LOG_TO_BACKDOOR
2787
2788
2789#
2790# Template for X.org guest modules (shared libs).
2791# This mostly about zapping unnecessary LIBS from VBOXGUESTR3DLL and adding some flags.
2792#
2793TEMPLATE_VBOXGUESTR3XORGMOD = VBox Guest Program with C++ library dependencies
2794TEMPLATE_VBOXGUESTR3XORGMOD_EXTENDS = VBOXGUESTR3DLL
2795TEMPLATE_VBOXGUESTR3XORGMOD_LIBS.$(KBUILD_TYPE) = $(NO_SUCH_VARIABLE)
2796TEMPLATE_VBOXGUESTR3XORGMOD_LIBS.$(KBUILD_TARGET) = $(NO_SUCH_VARIABLE)
2797TEMPLATE_VBOXGUESTR3XORGMOD_CFLAGS = $(TEMPLATE_VBOXGUESTR3DLL_CFLAGS) -std=c99
2798TEMPLATE_VBOXGUESTR3XORGMOD_DEFS = $(TEMPLATE_VBOXGUESTR3DLL_DEFS) LOG_TO_BACKDOOR
2799if1of ($(KBUILD_TARGET), linux)
2800 TEMPLATE_VBOXGUESTR3XORGMOD_LDFLAGS = $(TEMPLATE_VBOXGUESTR3DLL_LDFLAGS) -s
2801endif
2802TEMPLATE_VBOXGUESTR3XORGMOD_LIBS = \
2803 $(VBOX_LIB_VBGL_R3_SHARED) \
2804 $(VBOX_LIB_IPRT_GUEST_R3_MINI) \
2805 $(VBOX_LIB_VBGL_R3_SHARED)
2806
2807
2808#
2809# Template for guest stuff that makes use of the C++ library and features.
2810# (This is mostly about undoing what was done to C++ for VBOXGUESTR3EXE.)
2811#
2812TEMPLATE_VBOXGUESTR3CPPEXE = VBox Guest Program with C++ library dependencies
2813TEMPLATE_VBOXGUESTR3CPPEXE_EXTENDS = VBOXGUESTR3EXE
2814ifeq ($(KBUILD_TARGET),win)
2815 # later if necessary
2816else
2817 TEMPLATE_VBOXGUESTR3CPPEXE_TOOL = $(TEMPLATE_VBOXR3EXE_TOOL)
2818 TEMPLATE_VBOXGUESTR3CPPEXE_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS)
2819endif
2820
2821
2822#
2823# Template for building R0 drivers for the guest additions.
2824#
2825TEMPLATE_VBOXGUESTR0 = VBox Guest Driver
2826TEMPLATE_VBOXGUESTR0_EXTENDS = VBOXR0DRV
2827TEMPLATE_VBOXGUESTR0_INST = $(INST_ADDITIONS)
2828TEMPLATE_VBOXGUESTR0_SDKS.win.x86 = WIN32SDK W2K3DDK
2829TEMPLATE_VBOXGUESTR0_SDKS.win.amd64 = W2K3DDK WINPSDKINCS
2830TEMPLATE_VBOXGUESTR0_LIBS.win.x86 = \
2831 $(PATH_SDK_W2K3DDK_LIB)/int64.lib
2832TEMPLATE_VBOXGUESTR0_DEFS = $(TEMPLATE_VBOXR0DRV_DEFS) IN_GUEST IN_GUEST_R0
2833ifeq ($(KBUILD_TARGET),solaris) # No VBI for the guest additions yet.
2834 TEMPLATE_VBOXGUESTR0_LDFLAGS = -r -dy
2835endif
2836
2837#
2838# Template for building R0 libraries for the guest additions.
2839#
2840TEMPLATE_VBOXGUESTR0LIB = VBox Guest Driver Libraries
2841TEMPLATE_VBOXGUESTR0LIB_EXTENDS = VBOXGUESTR0
2842TEMPLATE_VBOXGUESTR0LIB_INST = $(INST_ADDITIONS_LIB)
2843
2844
2845#
2846# Guest additions libraries (all static).
2847# The _MINI and _SHARED are both compiled as PIC and intended for linking into a .so/.dll/.dylib.
2848#
2849VBOX_LIB_IPRT_GUEST_R3 = $(VBOX_PATH_ADDITIONS_LIB)/RuntimeGuestR3$(VBOX_SUFF_LIB)
2850VBOX_LIB_IPRT_GUEST_R3_MINI = $(VBOX_PATH_ADDITIONS_LIB)/RuntimeGuestR3Mini$(VBOX_SUFF_LIB)
2851VBOX_LIB_IPRT_GUEST_R0 = $(VBOX_PATH_ADDITIONS_LIB)/RuntimeGuestR0$(VBOX_SUFF_LIB)
2852ifeq ($(KBUILD_TARGET_ARCH),x86)
2853 VBOX_LIB_IPRT_GUEST_R0_NT4 = $(VBOX_PATH_ADDITIONS_LIB)/RuntimeGuestR0NT4$(VBOX_SUFF_LIB)
2854else
2855 VBOX_LIB_IPRT_GUEST_R0_NT4 = $(VBOX_LIB_IPRT_GUEST_R0)
2856endif
2857VBOX_LIB_VBGL_R3 = $(VBOX_PATH_ADDITIONS_LIB)/VBoxGuestR3Lib$(VBOX_SUFF_LIB)
2858VBOX_LIB_VBGL_R3_XFREE86 = $(VBOX_PATH_ADDITIONS_LIB)/VBoxGuestR3LibXFree86$(VBOX_SUFF_LIB)
2859VBOX_LIB_VBGL_R3_SHARED = $(VBOX_PATH_ADDITIONS_LIB)/VBoxGuestR3LibShared$(VBOX_SUFF_LIB)
2860VBOX_LIB_VBGL_R0BASE = $(VBOX_PATH_ADDITIONS_LIB)/VBoxGuestR0LibBase$(VBOX_SUFF_LIB)
2861VBOX_LIB_VBGL_R0 = $(VBOX_PATH_ADDITIONS_LIB)/VBoxGuestR0Lib$(VBOX_SUFF_LIB)
2862
2863
2864
2865#
2866# Two targets to coordinate version number changes properly. Note that the
2867# only way to get a really consistent build is to run 'kmk' in the top-level
2868# directory. If you don't run it there, you get a consistent sub-tree only.
2869#
2870VBOX_VERSION_STAMP = $(PATH_OUT)/version-stamp-$(VBOX_VERSION_STRING)
2871VBOX_VERSION_HEADER = $(PATH_OUT)/version-generated.h
2872VBOX_VERSION_MK = $(PATH_OUT)/version-generated.mk
2873
2874$(VBOX_VERSION_STAMP): | $(PATH_ROOT)/Config.kmk
2875 $(call MSG_GENERATE,,$@)
2876 $(QUIET)$(MKDIR) -p $(@D)
2877 $(QUIET)$(RM) -f $(wildcard $(PATH_OUT)/version-stamp-*)
2878 $(QUIET)$(APPEND) $@ $(VBOX_VERSION_STRING)
2879
2880$(VBOX_VERSION_HEADER): $(VBOX_VERSION_STAMP)
2881 $(call MSG_GENERATE,,$@)
2882 $(QUIET)$(MKDIR) -p $(@D)
2883 $(QUIET)$(RM) -f $@ $@.tmp
2884 $(QUIET)$(APPEND) $@.tmp '#ifndef ___version_generated_h___'
2885 $(QUIET)$(APPEND) $@.tmp '#define ___version_generated_h___'
2886 $(QUIET)$(APPEND) $@.tmp ''
2887 $(QUIET)$(APPEND) $@.tmp '#define VBOX_VERSION_MAJOR $(VBOX_VERSION_MAJOR)'
2888 $(QUIET)$(APPEND) $@.tmp '#define VBOX_VERSION_MINOR $(VBOX_VERSION_MINOR)'
2889 $(QUIET)$(APPEND) $@.tmp '#define VBOX_VERSION_BUILD $(VBOX_VERSION_BUILD)'
2890 $(QUIET)$(APPEND) $@.tmp '#define VBOX_VERSION_STRING "$(VBOX_VERSION_STRING)"'
2891 $(QUIET)$(APPEND) $@.tmp ''
2892 $(QUIET)$(APPEND) $@.tmp '#endif'
2893 $(QUIET)$(MV) -f $@.tmp $@
2894
2895
2896VBOX_PACKAGE_HEADER = $(PATH_OUT)/package-generated.h
2897
2898$(VBOX_PACKAGE_HEADER):
2899 $(call MSG_GENERATE,,$@)
2900 $(QUIET)$(MKDIR) -p $(@D)
2901 $(QUIET)$(RM) -f $@ $@.tmp
2902 $(QUIET)$(APPEND) $@.tmp '#ifndef ___package_generated_h___'
2903 $(QUIET)$(APPEND) $@.tmp '#define ___package_generated_h___'
2904 $(QUIET)$(APPEND) $@.tmp ''
2905 $(QUIET)$(APPEND) $@.tmp '#define VBOX_PACKAGE_STRING "$(VBOX_PACKAGE_STRING)"'
2906 $(QUIET)$(APPEND) $@.tmp ''
2907 $(QUIET)$(APPEND) $@.tmp '#endif'
2908 $(QUIET)$(MV) -f $@.tmp $@
2909
2910#
2911# Used for external makefiles which cannot include Config.kmk
2912#
2913$(VBOX_VERSION_MK): $(VBOX_VERSION_STAMP)
2914 $(call MSG_GENERATE,,$@)
2915 $(QUIET)$(RM) -f $@ $@.tmp
2916 $(QUIET)$(MKDIR) -p $(@D)
2917 $(QUIET)$(APPEND) $@.tmp 'VBOX_VERSION_MAJOR = $(VBOX_VERSION_MAJOR)'
2918 $(QUIET)$(APPEND) $@.tmp 'VBOX_VERSION_MINOR = $(VBOX_VERSION_MINOR)'
2919 $(QUIET)$(APPEND) $@.tmp 'VBOX_VERSION_BUILD = $(VBOX_VERSION_BUILD)'
2920 $(QUIET)$(APPEND) $@.tmp 'VBOX_VERSION_STRING = $(VBOX_VERSION_STRING)'
2921 $(QUIET)$(MV) -f $@.tmp $@
2922
2923ifndef VBOX_OSE
2924if1of ($(KBUILD_TARGET),freebsd linux netbsd openbsd solaris)
2925# VBOX_LICENSE_VER is used in several Makefiles
2926VBOX_LICENSE_SRC := $(PATH_ROOT)/doc/License.html
2927VBOX_LICENSE_VER_KMK = $(PATH_OUT)/license-version.kmk
2928$(VBOX_LICENSE_VER_KMK): $(VBOX_LICENSE_SRC)
2929 $(call MSG_GENERATE,,$(VBOX_LICENSE_VER_KMK))
2930 $(QUIET)$(MKDIR) -p $(@D)
2931 $(QUIET)$(SED) -e "s/.*License version \([0-9.]*\),.*/VBOX_LICENSE_VER=\1/;t;d" --output $@ $(VBOX_LICENSE_SRC)
2932-include $(VBOX_LICENSE_VER_KMK)
2933VBOX_LICENSE_BIN = $(PATH_BIN)/License-$(VBOX_LICENSE_VER).html
2934endif
2935endif
2936
2937
2938# Force building of the version header file as the first thing anywhere in
2939# the tree. This eliminates the need for manual dependencies on it.
2940## @todo there gotta be a better way of doing this.
2941Makefile.kmk: | $(VBOX_VERSION_HEADER) $(VBOX_VERSION_MK) $(VBOX_PACKAGE_HEADER)
2942Makefile: | $(VBOX_VERSION_HEADER) $(VBOX_VERSION_MK) $(VBOX_PACKAGE_HEADER)
2943makefile: | $(VBOX_VERSION_HEADER) $(VBOX_VERSION_MK) $(VBOX_PACKAGE_HEADER)
2944
2945
2946#
2947# Subversion tree revision.
2948#
2949# The VBOX_SVN_REV contains our best guess. Use svn info on the
2950# root of the treeto determin this it if .svn/entries is found,
2951# otherwise fall back on the Config.kmk revision.
2952#
2953SVN ?= svn$(HOSTSUFF_EXE)
2954VBOX_SVN_REV_KMK = $(PATH_OUT)/revision.kmk
2955ifndef VBOX_SVN_REV
2956 VBOX_SVN_REV_FALLBACK := $(patsubst %:,, $Rev: 11392 $ )
2957 VBOX_SVN_DEP := $(wildcard $(PATH_ROOT)/.svn/entries)
2958 ifeq ($(which $(SVN)),)
2959 VBOX_SVN_DEP :=
2960 endif
2961
2962# Rule for generating a timestamp and updating the real thing on change.
2963$(VBOX_SVN_REV_KMK).ts +| $(VBOX_SVN_REV_KMK): $(if $(VBOX_SVN_DEP), $(VBOX_SVN_DEP), $(PATH_ROOT)/Config.kmk)
2964 $(call MSG_GENERATE,,$(VBOX_SVN_REV_KMK))
2965 $(QUIET)$(RM) -f $@ $@.tmp
2966 $(QUIET)$(MKDIR) -p $(@D)
2967 ifneq ($(VBOX_SVN_DEP),)
2968 $(REDIRECT) -E 'LC_ALL=C' -wo $@.tmp -- $(SVN) info $(PATH_ROOT)
2969 ifeq ($(int-mod $(VBOX_VERSION_BUILD), 2),0)
2970 $(SED) -e '/^Last Changed Rev/!d' -e 's/Last Changed Rev\: */export VBOX_SVN_REV=/' --output $@ $@.tmp
2971 else
2972 $(SED) -e '/^Revision/!d' -e 's/Revision\: */export VBOX_SVN_REV=/' --output $@ $@.tmp
2973 endif
2974 $(QUIET)$(RM) -f $@.tmp
2975 else
2976 $(QUIET)$(APPEND) $@ 'export VBOX_SVN_REV=$(VBOX_SVN_REV_FALLBACK)'
2977 endif
2978 $(QUIET)$(CP) --changed -fv $@ $(VBOX_SVN_REV_KMK)
2979
2980 include $(VBOX_SVN_REV_KMK)
2981else
2982# allow to overwrite VBOX_SVN_REV externally (mainly for building .debs/.rpms)
2983$(VBOX_SVN_REV_KMK):
2984 $(call MSG_GENERATE,,$(VBOX_SVN_REV_KMK))
2985 $(QUIET)$(RM) -f $@
2986 $(QUIET)$(MKDIR) -p $(@D)
2987 $(QUIET)$(APPEND) $@ 'export VBOX_SVN_REV=$(VBOX_SVN_REV)'
2988 $(QUIET)echo '* $(VBOX_SVN_REV_KMK) was externally overwritten:'
2989 $(QUIET)$(CAT) $(VBOX_SVN_REV_KMK)
2990endif
2991
2992
2993#
2994# Legacy.
2995#
2996ifneq ($(LOCALCFG),)
2997 include $(LOCALCFG)
2998endif
2999
3000
3001#
3002# Some extra goals.
3003#
3004.PHONY: up update st stat status
3005up update::
3006 $(SVN) up
3007
3008up2 update2::
3009 $(SVN) up --ignore-externals
3010
3011st stat status:
3012 $(SVN) status
3013
3014quick:
3015 $(MAKE) VBOX_QUICK=1
3016
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