VirtualBox

root/trunk/Config.kmk

Revision 11140, 116.3 kB (checked in by vboxsync, 3 days ago)

Windows Guest Additions Installer: Fix for corrupted W2K installer icon. For 32-bit we now don't have a big (256x256) Vista icon anymore since the crappy NSIS uses the *same* icon for the application icon and the header icons in the installer. On 64-bit, the big icon is available.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
Line 
1 # $Id$
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.
22 VBOX_ROOT_CONFIG_KMK_INCLUDED = 1
23
24 #
25 # kBuild stuff
26 #
27
28 # Enable automatic installation of what's built.
29 KBUILD_DO_AUTO_INSTALL := 1
30 PASSES := $(filter-out PACKING,$(PASSES)) PACKING # temporary hack
31 # Modify the order of the INSTALLS and OTHERS passes.
32 DEFAULT_PASSES       := BLDPROGS LIBRARIES DLLS BINARIES INSTALLS OTHERS
33 # Modify the build types.
34 ## @todo checked and dbgopt
35 KBUILD_BLD_TYPES = release profile debug kprofile
36
37 # Install paths.
38 PATH_INS            := $(PATH_OUT)
39 ifeq ($(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
63 else
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/
78 endif
79
80 PATH_BIN              = $(patsubst %/,%,$(PATH_INS)/$(INST_BIN))
81 PATH_DLL              = $(patsubst %/,%,$(PATH_INS)/$(INST_DLL))
82 PATH_SYS              = $(patsubst %/,%,$(PATH_INS)/$(INST_SYS))
83 PATH_LIB              = $(patsubst %/,%,$(PATH_INS)/$(INST_LIB))
84 PATH_DOC              = $(PATH_OUT)/doc
85 VBOX_PATH_SDK         = $(patsubst %/,%,$(PATH_INS)/$(INST_SDK))
86 VBOX_PATH_DIST        = $(patsubst %/,%,$(PATH_INS)/$(INST_DIST))
87 VBOX_PATH_TESTSUITE   = $(patsubst %/,%,$(PATH_INS)/$(INST_TESTSUITE))
88 VBOX_PATH_ADDITIONS   = $(patsubst %/,%,$(PATH_INS)/$(INST_ADDITIONS))
89 VBOX_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.
96 ifneq ($(call int-ge,$(KMK_REVISION),1650),1)
97  $(error You must update kBuild! KMK_REVISION=$(KMK_REVISION) KBUILD_PATH=$(KBUILD_PATH))
98 endif
99
100 #
101 # Define USERNAME early on.
102 #
103 ifndef USERNAME
104  ifdef USER
105   USERNAME = $(USER)
106  else
107   $(warning Warning: You must have USERNAME or USER in your environment.)
108  endif
109 endif
110
111 #
112 # The VirtualBox version.
113 #
114
115 # Major version.
116 VBOX_VERSION_MAJOR = 1
117 # Minor version.
118 VBOX_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.
122 VBOX_VERSION_BUILD = 51
123 # Full version string (may include more than just x.y.z, but no spaces or other problematic chars).
124 VBOX_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.
126 ifeq ($(int-mod $(VBOX_VERSION_BUILD),2),0)
127  export VBOX_ADDITIONS_SH_MODE = release
128 endif
129
130
131 #
132 # The VirtualBox package type.
133 #
134 ifeq ($(KBUILD_TARGET),win)
135   VBOX_PACKAGE_OS = WINDOWS
136 else ifeq ($(KBUILD_TARGET),linux)
137   VBOX_PACKAGE_OS = LINUX
138 else ifeq ($(KBUILD_TARGET),darwin)
139   VBOX_PACKAGE_OS = DARWIN
140 else ifeq ($(KBUILD_TARGET),solaris)
141   VBOX_PACKAGE_OS = SOLARIS
142 else if1of ($(KBUILD_TARGET), dragonfly freebsd netbsd openbsd)
143   VBOX_PACKAGE_OS = BSD
144 else
145   $(error Cannot determine VBOX_PACKAGE_OS)
146 endif
147 ifeq ($(KBUILD_TARGET_ARCH),x86)
148   VBOX_PACKAGE_ARCH = 32BITS
149 else
150   VBOX_PACKAGE_ARCH = 64BITS
151 endif
152 # distribution, mostly for Linux/Solaris where we support different distributions
153 # this strip will be overridden by the Linux packaging scripts
154 VBOX_PACKAGE_DIST ?= GENERIC
155 # Full string
156 VBOX_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)
170 if1of ($(KBUILD_TARGET), linux solaris win)
171  VBOX_WITH_ADDITIONS = 1
172 endif
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/...)
175 ifn1of ($(KBUILD_TARGET).$(KBUILD_HOST_ARCH).$(KBUILD_TARGET_ARCH), linux.x86.amd64 linux.amd64.x86)
176  VBOX_WITH_ADDITION_DRIVERS = 1
177 endif
178 # Build X11 additions. Can be disabled separately.
179 if1of ($(KBUILD_TARGET), dragonfly freebsd linux netbsd openbsd solaris)
180  VBOX_WITH_X11_ADDITIONS = 1
181 endif
182 # Enable the building of shared folders in the windows additions.
183 VBOX_WITH_WIN32_ADDITIONS_SHAREDFOLDERS = 1
184 # Take the binaries of the OS/2 Additions.
185 VBOX_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
193 ifdef VBOX_ADDITIONS_ONLY # typical mistake.
194  $(error It is VBOX_ONLY_ADDITIONS=1 not VBOX_ADDITIONS_ONLY!)
195 endif
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
201 VBOX_WITH_INSTALLER = 1
202 # enable VRDP server
203 VBOX_WITH_VRDP = 1
204 # build VRDP authentication modules
205 VBOX_WITH_VRDP_AUTHMOD = 1
206 # build enhanced version of rdesktop
207 VBOX_WITH_VRDP_RDESKTOP = 1
208 if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), win.x86 l4.x86 l4.amd64)
209 # build the support driver & library with IDT patching.
210 VBOX_WITH_IDT_PATCHING = 1
211 endif
212 # Activate this to force the VM to pre-allocate the guest RAM before startup
213 VBOX_WITH_PREALLOC_RAM_BY_DEFAULT =
214 # The kernel driver/module and related runtime libraries.
215 VBOX_WITH_VBOXDRV = 1
216 # build with secure label support
217 ifeq ($(filter win.amd64,$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),) # too much work with freetype and all that.
218 VBOX_WITH_SECURELABEL = 1
219 endif
220
221 # The main api.
222 VBOX_WITH_MAIN = 1
223 # The webservices api.
224 VBOX_WITH_WEBSERVICES = 1
225 # The SDL based GUI.
226 VBOX_WITH_VBOXSDL = 1
227 # The basic frontend (w/o Main).
228 VBOX_WITH_VBOXBFE = 1
229 # The Qt GUI.
230 VBOX_WITH_QTGUI = 1
231 # The Qt 4 GUI (experimental).
232 VBOX_WITH_QT4GUI = 1
233 # The headless frontend.
234 VBOX_WITH_HEADLESS = 1
235 ## the Direct Framebuffer GUI
236 #VBOX_WITH_VBOXFB = 1
237 # Enable the debugger.
238 ifneq ($(KBUILD_TYPE),release)
239  VBOX_WITH_DEBUGGER = 1
240  # Enable the debugger GUI.
241  VBOX_WITH_DEBUGGER_GUI = 1
242 endif
243 # the documentation
244 VBOX_WITH_DOCS = 1
245 # build the Host Guest Communication Manager component
246 VBOX_WITH_HGCM = 1
247 # Enable the USB feature.
248 VBOX_WITH_USB = 1
249 # Enable the USB 2.0 controller
250 VBOX_WITH_EHCI = 1
251 # Enable the ISCSI feature.
252 VBOX_WITH_ISCSI = 1
253 # Enable the E1000 feature
254 VBOX_WITH_E1000 = 1
255 # Enable ALSA support for Linux
256 VBOX_WITH_ALSA = 1
257 # Enable Pulse support for Linux
258 VBOX_WITH_PULSE = 1
259 # Disable WINMM support for Windows (not implemented)
260 VBOX_WITH_WINMM =
261 # Enable the kchmviewer
262 VBOX_WITH_KCHMVIEWER = 1
263 # Build the testsuite.
264 VBOX_WITH_TESTSUITE = 1
265 # Build the testcases.
266 VBOX_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.
272 VBOX_WITH_INTERNAL_NETWORKING = 1
273 # Enables the ffmpeg module for recording test runs.
274 # Enable this for non-Linux builds later.
275 ifeq ($(KBUILD_TARGET),linux)
276 #  VBOX_WITH_FFMPEG = 1
277 endif
278 # Enable OpenGL service
279 VBOX_WITH_OGL = 1
280 # Enable shared folders
281 VBOX_WITH_SHARED_FOLDERS = 1
282 # Enable shared clipboard
283 VBOX_WITH_SHARED_CLIPBOARD = 1
284 # Enable the Intel PXE ROM (replaces Etherboot).
285 VBOX_WITH_INTEL_PXE = 1
286 # Strip binaries of release and profile builds
287 VBOX_DO_STRIP = $(if $(filter release profile,$(KBUILD_TYPE)),1,)
288 # Strip R0/GC modules (current requirement for our loader)
289 VBOX_DO_STRIP_MODULES = 1
290 # Use kStuff for MACH-O and LX binary loading.
291 if1of ($(KBUILD_TARGET),darwin os2)
292 IPRT_WITH_KSTUFF = 1
293 endif
294 # Enable Crossbow support for Solaris.
295 VBOX_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.
299 VBOX_WITH_PDM_LOCK = 1
300 # Enable Seamless mode
301 VBOX_X11_SEAMLESS_GUEST = 1
302 # Enable the virtual SATA/AHCI controller
303 VBOX_WITH_AHCI = 1
304 # Enable the new async completion manager
305 VBOX_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).
308 ifeq ($(KBUILD_TARGET),solaris)
309  VBOX_WITH_ORIGIN = 1
310 endif
311 # Temporary switch for enabling / disabling the new USB code on Darwin.
312 VBOX_WITH_NEW_USB_CODE_ON_DARWIN=1
313 # Use the new VBI module on Solaris.
314 VBOX_WITH_SOLARIS_VBI = 1
315 # Enable 64 bits guest pointers.
316 if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), linux.amd64 solaris.amd64 win.amd64)
317 VBOX_WITH_64_BITS_GUESTS = 1
318 else
319 # VBOX_WITH_64_BITS_GUESTS = 1
320 endif
321 # Enable the host/guest information service (aka guest properties).
322 VBOX_WITH_GUEST_PROPS = 1
323 # Enable performance API.
324 VBOX_WITH_RESOURCE_USAGE_API = 1
325 # Enables all the doxgen bits.
326 VBOX_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
334 ifdef 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 =
345 endif # VBOX_QUICK
346
347 ifeq ($(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=
356 endif
357
358 ifeq ($(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=
368 endif
369
370 ifeq ($(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=
384 endif
385
386 ifeq ($(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=
398 endif
399
400 ifeq ($(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=
406  VBOX_WITH_KCHMVIEWER=
407 endif
408
409 ifeq ($(KBUILD_TARGET),win)
410  VBOX_WITH_VRDP_RDESKTOP=
411  VBOX_WITH_KCHMVIEWER=
412 endif
413
414
415 #
416 # Include automatic and local config file to override the above settings
417 # and to provide defaults for the settings below this point.
418 #
419 AUTOCFG := $(wildcard $(PATH_ROOT)/AutoConfig.kmk)
420 ifeq ($(AUTOCFG),)
421  # deprecated name. to be removed.
422  AUTOCFG := $(wildcard $(PATH_ROOT)/Config.kmkconf)
423  ifneq ($(AUTOCFG),)
424   $(warning Config.kmkconf has been renamed. Please re-run configure.)
425  endif
426 endif
427 ifneq ($(AUTOCFG),)
428  include $(AUTOCFG)
429 endif
430
431 LOCALCFG := $(wildcard $(PATH_ROOT)/LocalConfig.kmk)
432 ifeq ($(LOCALCFG),)
433  # deprecated name. to be removed.
434  LOCALCFG := $(wildcard $(PATH_ROOT)/Config.kmklocal)
435  ifneq ($(LOCALCFG),)
436   $(warning Please rename your Config.kmklocal to LocalConfig.kmk.)
437  endif
438 endif
439 ifneq ($(LOCALCFG),)
440  include $(LOCALCFG)
441 endif
442
443
444 #
445 # Disable components that are not open sourced.
446 #
447 ifdef VBOX_OSE
448  VBOX_WITH_WEBSERVICES=
449  VBOX_WITH_VRDP=
450  VBOX_WITH_USB=
451  VBOX_WITH_EHCI=
452  VBOX_WITH_ISCSI=
453  VBOX_WITH_E1000=
454  VBOX_WITH_DEBUGGER_GUI=
455  VBOX_WITH_WIN32_ADDITIONS_SHAREDFOLDERS=
456  VBOX_WITHOUT_ADDITIONS_ISO=1
457  VBOX_WITH_OS2_ADDITIONS_BIN=
458  VBOX_WITH_SECURELABEL=
459  VBOX_WITH_KCHMVIEWER=
460  VBOX_WITH_DOCS=
461  VBOX_WITH_TESTSUITE=
462  VBOX_WITH_INTEL_PXE=
463  ifeq ($(KBUILD_TARGET),darwin)
464   # Qt/Mac v3.3.x requires patching to work for us.
465   VBOX_WITH_QTGUI=
466  endif
467  ifn1of ($(KBUILD_TARGET),linux solaris)
468   # Only the Linux, Solaris installers are public
469   VBOX_WITH_INSTALLER=
470  endif
471  VBOX_WITH_AHCI=
472  VBOX_WITH_PDM_ASYNC_COMPLETION=
473 endif
474
475 #
476 # Sanitize the additions build config variables.
477 #
478 ifdef VBOX_WITH_ADDITIONS_FROM_BUILD_SERVER
479  VBOX_WITHOUT_ADDITIONS := 1
480  ifdef VBOX_ONLY_ADDITIONS
481   $(error VBOX_ONLY_ADDITIONS + VBOX_WITH_ADDITIONS_FROM_BUILD_SERVER does not add up!)
482  endif
483 endif
484
485 ifdef VBOX_ONLY_ADDITIONS
486  ifdef VBOX_WITHOUT_ADDITIONS
487   $(error VBOX_ONLY_ADDITIONS + VBOX_WITHOUT_ADDITIONS does not add up!)
488  endif
489 endif
490
491 ifdef VBOX_WITHOUT_ADDITIONS
492  # Zap anything that could be contradicting this.
493  VBOX_WITH_ADDITIONS :=
494 endif
495
496 #
497 # Disable components for headless
498 #
499 ifdef VBOX_HEADLESS
500  VBOX_WITH_QTGUI=
501  VBOX_WITH_VBOXSDL=
502  VBOX_WITH_VBOXBFE=
503  VBOX_WITH_OGL=
504  VBOX_WITH_KCHMVIEWER=
505 endif
506
507 #
508 # Undefined VBOX_WITH_MAIN implies exclusion of a few more items.
509 #
510 ifndef VBOX_WITH_MAIN
511  VBOX_WITH_VRDP=
512  VBOX_WITH_VBOXSDL=
513  VBOX_WITH_QTGUI=
514  VBOX_WITH_DEBUGGER_GUI=
515  VBOX_WITH_HEADLESS=
516 endif
517
518 #
519 # Mark OSE builds clearly, helps figuring out limitations more easily.
520 #
521 ifdef VBOX_OSE
522 VBOX_VERSION_STRING = $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD)_OSE
523 endif
524
525
526 #
527 # Image and object format config.
528 #
529 if1of ($(KBUILD_TARGET), linux l4 freebsd netbsd openbsd solaris)
530  VBOX_LDR_FMT = elf
531 endif
532 ifeq ($(KBUILD_TARGET),darwin)
533  VBOX_LDR_FMT = macho
534 endif
535 ifeq ($(KBUILD_TARGET),os2)
536  VBOX_LDR_FMT = lx
537  VBOX_LDR_FMT32 = lx
538  VBOX_LDR_FMT64 = elf
539  DONT_USE_YASM = 1 # yasm doesn't implement omf yet.
540 endif
541 ifeq ($(KBUILD_TARGET),win)
542  VBOX_LDR_FMT = pe
543 endif
544 VBOX_LDR_FMT32 ?= $(VBOX_LDR_FMT)
545 VBOX_LDR_FMT64 ?= $(VBOX_LDR_FMT)
546
547 #
548 # Assembler setup.
549 #
550 # This is a bit complicated since we have to support two different assmblers
551 # (yasm/nasm) and possibly two different formats (32-bit/64-bit).
552 #
553 ifeq ($(VBOX_LDR_FMT),elf)
554  ifeq ($(KBUILD_TARGET_ARCH),x86)
555 VBOX_ASFLAGS_FMT = -f elf32 -DASM_FORMAT_ELF
556  else
557 VBOX_ASFLAGS_FMT = -f elf64 -DASM_FORMAT_ELF
558  endif
559  VBOX_ASFLAGS_DBFINFO = -g dwarf2
560 endif
561 ifeq ($(VBOX_LDR_FMT),lx)
562  VBOX_ASFLAGS_FMT = -f obj -DASM_FORMAT_OMF
563  VBOX_ASFLAGS_DBFINFO = -g stabs
564 endif
565 ifeq ($(VBOX_LDR_FMT),macho)
566  VBOX_ASFLAGS_FMT = -f macho -DASM_FORMAT_MACHO
567  VBOX_ASFLAGS_DBFINFO = -g dwarf2
568 endif
569 ifeq ($(VBOX_LDR_FMT),pe)
570  ifeq ($(KBUILD_TARGET_ARCH),x86)
571 VBOX_ASFLAGS_FMT = -f win32 -DASM_FORMAT_PE
572  else
573 VBOX_ASFLAGS_FMT = -f win64 -DASM_FORMAT_PE
574  endif
575 VBOX_ASFLAGS_DBFINFO = -g cv8
576 endif
577 ifndef VBOX_ASFLAGS_FMT
578  $(error VBOX_ASFLAGS_FMT is not defined. VBOX_LDR_FMT=$(VBOX_LDR_FMT))
579 endif
580
581 ifeq ($(VBOX_LDR_FMT32),elf)
582  VBOX_ASFLAGS_FMT32 = -f elf32 -DASM_FORMAT_ELF
583  VBOX_ASFLAGS_DBFINFO32 = -g dwarf2
584 endif
585 ifeq ($(VBOX_LDR_FMT32),lx)
586  VBOX_ASFLAGS_FMT32 = -f obj -DASM_FORMAT_OMF
587  VBOX_ASFLAGS_DBFINFO32 = -g stabs
588 endif
589 ifeq ($(VBOX_LDR_FMT32),macho)
590  VBOX_ASFLAGS_FMT32 = -f macho -DASM_FORMAT_MACHO
591  VBOX_ASFLAGS_DBFINFO32 = -g dwarf2
592 endif
593 ifeq ($(VBOX_LDR_FMT32),pe)
594  VBOX_ASFLAGS_FMT32 = -f win32 -DASM_FORMAT_PE
595  VBOX_ASFLAGS_DBFINFO32 = -g cv8
596 endif
597 ifndef VBOX_ASFLAGS_FMT32
598  $(error VBOX_ASFLAGS_FMT32 is not defined. VBOX_LDR_FMT32=$(VBOX_LDR_FMT32))
599 endif
600
601 ifeq ($(VBOX_LDR_FMT64),elf)
602  VBOX_ASFLAGS_FMT64 = -f elf64 -DASM_FORMAT_ELF
603  VBOX_ASFLAGS_DBFINFO64 = -g dwarf2
604 endif
605 ifeq ($(VBOX_LDR_FMT64),macho)
606  VBOX_ASFLAGS_FMT64 = -f macho64 -DASM_FORMAT_MACHO
607  VBOX_ASFLAGS_DBFINFO64 = -g dwarf2
608 endif
609 ifeq ($(VBOX_LDR_FMT64),pe)
610  VBOX_ASFLAGS_FMT64 = -f win64 -DASM_FORMAT_PE
611  VBOX_ASFLAGS_DBFINFO64 = -g cv8
612 endif
613 ifndef VBOX_ASFLAGS_FMT64
614  $(error VBOX_ASFLAGS_FMT64 is not defined. VBOX_LDR_FMT64=$(VBOX_LDR_FMT64))
615 endif
616
617 ifndef DONT_USE_YASM
618  VBOX_ASTOOL    = YASM
619  VBOX_LDR_FMT_2_YASM_DBGINFO.elf   = -g dwarf2
620  VBOX_LDR_FMT_2_YASM_DBGINFO.lx    = -g stabs
621  VBOX_LDR_FMT_2_YASM_DBGINFO.macho =
622  VBOX_LDR_FMT_2_YASM_DBGINFO.pe    = -g cv8
623  VBOX_ASFLAGS   = $(VBOX_ASFLAGS_FMT)   -D__YASM__ -Worphan-labels $(VBOX_LDR_FMT_2_YASM_DBGINFO.$(VBOX_LDR_FMT))
624  VBOX_ASFLAGS32 = $(VBOX_ASFLAGS_FMT32) -D__YASM__ -Worphan-labels $(VBOX_LDR_FMT_2_YASM_DBGINFO.$(VBOX_LDR_FMT32))
625  VBOX_ASFLAGS64 = $(VBOX_ASFLAGS_FMT64) -D__YASM__ -Worphan-labels $(VBOX_LDR_FMT_2_YASM_DBGINFO.$(VBOX_LDR_FMT64))
626 else
627  VBOX_ASTOOL    = NASM
628  VBOX_ASFLAGS   = $(subst elf32,elf,$(VBOX_ASFLAGS_FMT))   -D__NASM__ -w+orphan-labels -g
629  VBOX_ASFLAGS32 = $(subst elf32,elf,$(VBOX_ASFLAGS_FMT32)) -D__NASM__ -w+orphan-labels -g
630  VBOX_ASFLAGS64 = $(VBOX_ASFLAGS_FMT64) -D__NASM__ -w+orphan-labels -g
631 endif
632
633 #
634 # Windows only has mingw handy. On *nix we have to deal with cross compiling
635 # 32-bit targets on 64-bit platforms, meaning we'll be using gcc32/g++32.
636 # In the latter case we'll also have to disable all the all the R0 driver related stuff.
637 #
638 ifndef VBOX_GCC_TOOL
639  ifeq ($(KBUILD_TARGET),win)
640   VBOX_GCC_TOOL := MINGW32
641   TOOL_MINGW32_CFLAGS := $(UNDEFINED) # override -g
642  else ifeq ($(KBUILD_TARGET),os2)
643   VBOX_GCC_TOOL := GXX3OMF
644  else ifeq ($(KBUILD_TARGET),darwin)
645   VBOX_GCC_TOOL := GXX4MACHO
646  else ifeq ($(KBUILD_TARGET),solaris)
647   VBOX_GCC_TOOL := GXX3PLAIN
648   VBOX_GCC32_TOOL := GXX3PLAIN
649  else
650   VBOX_GCC_TOOL := GXX3
651   ifeq ($(KBUILD_TARGET_ARCH).$(KBUILD_HOST_ARCH),x86.amd64) ## @todo mixing target/host here!
652    VBOX_GCC_TOOL := GXX32
653    VBOX_WITH_VBOXDRV=
654   else ifeq ($(KBUILD_TARGET_ARCH).$(KBUILD_HOST_ARCH),amd64.x86)
655    VBOX_GCC_TOOL := GXX64
656    VBOX_WITH_VBOXDRV=
657   endif
658  endif
659 endif
660 ifndef VBOX_GCC32_TOOL
661  ifeq ($(KBUILD_TARGET_ARCH),x86)
662   VBOX_GCC32_TOOL := $(VBOX_GCC_TOOL)
663  else ifeq ($(KBUILD_TARGET),win)
664   VBOX_GCC32_TOOL := MINGW32
665  else
666   VBOX_GCC32_TOOL := GXX32
667  endif
668 endif
669
670 #
671 # Decide which Visual C++ compiler version we're using by default.
672 #
673 ifndef VBOX_VCC_TOOL
674  ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),win.amd64)
675   VBOX_USE_VCC80 ?= 1 # Enforce VCC80 when targetting AMD64.
676  endif
677  ifdef VBOX_USE_VCC80
678   ifeq ($(KBUILD_TARGET_ARCH),x86)
679    VBOX_VCC_TOOL := VCC80X86
680   else
681    VBOX_VCC_TOOL := VCC80AMD64
682   endif
683  else
684   VBOX_VCC_TOOL := VCC70
685  endif
686 endif
687
688 #
689 # The kBuild tools and SDKs are using PATH_DEVTOOLS, PATH_DEVTOOLS_BLD
690 # and PATH_DEVTOOLS_TRG to find things if we give them specific locations.
691 #
692 PATH_DEVTOOLS ?= $(PATH_ROOT)/tools
693 PATH_DEVTOOLS := $(abspath $(PATH_DEVTOOLS))
694 PATH_DEVTOOLS_BLD ?= $(PATH_DEVTOOLS)/$(KBUILD_HOST).$(KBUILD_HOST_ARCH)
695 PATH_DEVTOOLS_TRG ?= $(PATH_DEVTOOLS)/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)
696
697 ## @todo Remove the default tool crap here!
698 TOOL = $(VBOX_GCC_TOOL)
699 ifdef VBOX_USE_VCC80
700  TOOL.win.x86 = VCC80X86
701  TOOL.win.amd64 = VCC80AMD64
702 else
703  TOOL.win = VCC70
704 endif
705 ASTOOL = $(VBOX_ASTOOL)
706
707 #
708 # L4-specific settings.
709 #
710 ifdef L4_DIR
711  ifeq ($(KBUILD_TARGET),l4)
712   L4_API  ?= l4v2
713   L4_ARCH ?= $(KBUILD_TARGET_ARCH)
714   ifeq ($(L4_ARCH),x86)
715    L4_CPU ?= 586
716    L4LINUX26_INCDIR := $(L4LINUX26_DIR)/include \
717                        $(L4LINUX26_DIR)/include/asm-l4/i386-arch
718   else ifeq ($(L4_ARCH),amd64)
719    L4_CPU ?= k8
720    L4LINUX26_INCDIR := $(L4LINUX26_DIR)/include
721    # no red zone for L4 because of IPC bindings
722    CFLAGS.l4   = -mno-red-zone
723    CXXFLAGS.l4 = -mno-red-zone
724   else
725    $(error L4_ARCH=$(L4_ARCH))
726   endif
727   L4_OBJ := $(L4_DIR)/build-$(L4_ARCH)-$(L4_CPU)-$(L4_API)
728   # support splitted Linux kernels (make O=<build directory>)
729   kernelsrc := $(shell $(SED_EXT) -ne 's+^KERNELSRC.*= *\(.*\)+\1+p' $(L4LINUX26_DIR)/Makefile)
730   ifneq ($(kernelsrc),)
731    kernelpath := $(realpath $(kernelsrc))
732     L4LINUX26_INCDIR += $(L4LINUX26_DIR)/include2 $(kernelpath)/include
733   endif
734   L4_INCDIR := \
735     $(L4_OBJ)/include/uclibc++ \
736     $(L4_OBJ)/include/$(L4_ARCH)/uclibc \
737     $(L4_OBJ)/include/uclibc \
738     $(L4LINUX26_INCDIR) \
739     $(L4_OBJ)/include/$(L4_ARCH)/$(L4_API) \
740     $(L4_OBJ)/include/$(L4_API) \
741     $(L4_OBJ)/include/$(L4_ARCH) \
742     $(L4_OBJ)/include \
743     $(L4_DIR)/tool/dice/include
744   L4_LIBDIR := \
745    $(L4_DIR)/build-$(L4_ARCH)-$(L4_CPU)-$(L4_API)/lib/$(L4_ARCH)_$(L4_CPU)/$(L4_API)
746  endif # KBUILD_TARGET == l4
747 endif # L4_DIR
748
749 # Produce debugging information that the Fiasco kernel debugger can read.
750 ifeq ($(KBUILD_TARGET).$(KBUILD_TYPE),l4.debug)
751  DEBUG_L4 = -gstabs+
752 endif
753
754 #
755 # Setup the global defines and includes.
756 #
757 # Note! The __SOMETHING__ #defines are deprecated as they violate the C/C++ specs.
758 #
759 INCS += $(PATH_ROOT)/include $(PATH_OUT)
760 DEFS += VBOX
761 DEFS.debug := DEBUG DEBUG_$(subst $(subst _, ,_),_,$(USERNAME)) DEBUG_USERNAME=$(subst $(subst _, ,_),_,$(USERNAME))
762 DEFS.profile = VBOX_WITH_STATISTICS
763 DEFS.x86     = RT_ARCH_X86 __X86__
764 DEFS.amd64   = RT_ARCH_AMD64 __AMD64__
765 DEFS.darwin  = RT_OS_DARWIN __DARWIN__
766 DEFS.darwin.x86 = VBOX_WITH_HYBIRD_32BIT_KERNEL
767 DEFS.freebsd = RT_OS_FREEBSD __FREEBSD__
768 DEFS.l4      = RT_OS_L4 __L4__ __L4ENV__ L4API_l4v2 ARCH_$(KBUILD_TARGET_ARCH) __NO_CTYPE _FILE_OFFSET_BITS=64
769 DEFS.linux   = RT_OS_LINUX _FILE_OFFSET_BITS=64
770 DEFS.netbsd  = RT_OS_NETBSD
771 DEFS.openbsd = RT_OS_OPENBSD
772 DEFS.os2     = RT_OS_OS2 __OS2__
773 DEFS.solaris = RT_OS_SOLARIS _FILE_OFFSET_BITS=64
774 DEFS.win     = RT_OS_WINDOWS __WIN__
775 DEFS.win.x86 = __WIN32__
776 DEFS.win.amd64 = __WIN64__
777 # optional defines (use environment or make commandline)
778 ifdef VBOX_WITH_DEBUGGER
779  DEFS += VBOX_WITH_DEBUGGER
780 endif
781 ifdef VBOX_WITH_DEBUGGER_GUI
782  DEFS += VBOX_WITH_DEBUGGER_GUI
783 endif
784 ifdef VBOX_WITH_STATISTICS
785  DEFS += VBOX_WITH_STATISTICS
786 endif
787 ifdef VBOX_STRICT
788  DEFS += VBOX_STRICT
789 endif
790 ifdef LOG_ENABLED
791  DEFS += LOG_ENABLED
792 endif
793 ifdef VBOX_OSE
794  DEFS += VBOX_OSE
795 endif
796 ifdef VBOX_WITH_NEW_PHYS_CODE
797  DEFS += VBOX_WITH_NEW_PHYS_CODE
798 endif
799 ifdef VBOX_WITH_64_BITS_GUESTS
800  DEFS += VBOX_WITH_64_BITS_GUESTS
801 endif
802 ## @todo eliminate these guys.
803 ifdef VBOX_WITH_INTERNAL_NETWORKING
804 DEFS += VBOX_WITH_INTERNAL_NETWORKING
805 endif
806
807 #
808 # Compiler optimization flags.
809 #
810 ifeq ($(KBUILD_TYPE),debug)
811  VBOX_GCC_FP  ?= -fno-omit-frame-pointer
812  VBOX_GCC_OPT ?= -O0
813  VBOX_VCC_FP  ?= -Oy-
814  VBOX_VCC_OPT ?=
815  VBOX_GCC_GC_FP  ?= -fno-omit-frame-pointer
816  VBOX_GCC_GC_OPT ?= -O0
817  VBOX_VCC_GC_FP  ?= -Oy-
818  VBOX_VCC_GC_OPT ?=
819 else
820  # We should use -fomit-frame-pointer for GCC / -Oy for VCC.
821  # -funwind-tables provides support for backtraces in gdb then.
822  VBOX_GCC_FP  ?= -fno-omit-frame-pointer
823  VBOX_GCC_OPT ?= -O2 $(VBOX_GCC_mtune-generic)
824  VBOX_VCC_FP  ?= -Oy-
825  ifdef VBOX_USE_VCC80
826  VBOX_VCC_OPT ?= -O2 -GS-
827  else
828  VBOX_VCC_OPT ?= -Ogitb2
829  endif
830  VBOX_GCC_GC_FP  ?= -fno-omit-frame-pointer
831  VBOX_GCC_GC_OPT ?= -O2 $(VBOX_GCC_mtune-generic)
832  VBOX_VCC_GC_FP  ?= -Oy-
833  ifdef VBOX_USE_VCC80
834  VBOX_VCC_GC_OPT ?= -O2
835  else
836  VBOX_VCC_GC_OPT ?= -Ogitb2
837  endif
838 endif
839
840 #
841 # ARCH_BITS_DEFS.
842 #
843 ifeq ($(KBUILD_TARGET_ARCH),amd64)
844  ARCH_BITS_DEFS := HC_ARCH_BITS=64
845 else ifeq ($(KBUILD_TARGET_ARCH),x86)
846  ARCH_BITS_DEFS := HC_ARCH_BITS=32
847 else
848  error KBUILD_TARGET_ARCH=$(KBUILD_TARGET_ARCH)
849 endif
850
851 ifdef VBOX_WITH_64_BITS_GUESTS
852  VBOX_GC_ARCH_BITS_DEFS := GC_ARCH_BITS=64
853 else
854  VBOX_GC_ARCH_BITS_DEFS := GC_ARCH_BITS=32
855 endif
856 ARCH_BITS_DEFS += $(VBOX_GC_ARCH_BITS_DEFS)
857
858 #
859 # Add the output dir(s) to the dynamic loader search path.
860 #
861 if1of ($(KBUILD_TARGET), linux l4 freebsd netbsd openbsd solaris)
862  export LD_LIBRARY_PATH:=$(PATH_BIN):$(PATH_LIB):$(LD_LIBRARY_PATH)
863 endif
864 ifeq ($(KBUILD_TARGET),os2)
865  #fixme! export BEGINLIBPATH:=$(PATH_BIN);$(PATH_LIB);$(BEGINLIBPATH)
866 endif
867 ifeq ($(KBUILD_TARGET),win)
868  export PATH:=$(PATH_BIN);$(PATH_LIB);$(PATH)
869 endif
870
871 #
872 # Common libraries and tools.
873 #
874 ifeq ($(KBUILD_TARGET),darwin)
875  LIB_RUNTIME     = $(PATH_BIN)/VBoxRT.dylib
876  LIB_RUNTIME_EF  = #$(PATH_LIB)/RuntimeEFCPP.a
877  LIB_KPROFILE    = $(PATH_BIN)/kPrf2.dylib
878  LIB_VMM         = $(PATH_BIN)/VBoxVMM.dylib
879  LIB_VMMGC       = $(PATH_BIN)/VMMGC.gc
880  LIB_REM         = $(PATH_LIB)/VBoxREMImp.dylib
881  LIB_XPCOM       = $(PATH_BIN)/VBoxXPCOM.dylib
882  LIB_DDU         = $(PATH_BIN)/VBoxDDU.dylib
883  LIB_SETTINGS    = $(PATH_BIN)/VBoxSettings.dylib
884 endif
885 ifeq ($(KBUILD_TARGET),l4)
886  LIB_RUNTIME     = $(PATH_BIN)/VBoxRT.s.so
887  LIB_RUNTIME_EF  = #$(PATH_LIB)/RuntimeEFCPP.a
888  LIB_KPROFILE    = $(PATH_BIN)/kPrf2.s.so
889  LIB_VMM         = $(PATH_BIN)/VBoxVMM.s.so
890  LIB_VMMGC       = $(PATH_BIN)/VMMGC.gc
891  LIB_REM         = $(PATH_BIN)/VBoxREMImp.s.so
892  LIB_XPCOM       = $(PATH_BIN)/VBoxXPCOM.s.so
893  LIB_DDU         = $(PATH_BIN)/VBoxDDU.s.so
894  LIB_SETTINGS    = $(PATH_BIN)/VBoxSettings.s.so
895 endif
896 if1of ($(KBUILD_TARGET), linux freebsd netbsd openbsd solaris)
897  LIB_RUNTIME     = $(PATH_BIN)/VBoxRT.so
898  LIB_RUNTIME_EF  = $(PATH_LIB)/RuntimeEFCPP.a
899  LIB_KPROFILE    = $(PATH_BIN)/kPrf2.so
900  LIB_VMM         = $(PATH_BIN)/VBoxVMM.so
901  LIB_VMMGC       = $(PATH_BIN)/VMMGC.gc
902  LIB_REM         = $(PATH_BIN)/VBoxREMImp.so
903  LIB_XPCOM       = $(PATH_BIN)/VBoxXPCOM.so
904  LIB_DDU         = $(PATH_BIN)/VBoxDDU.so
905  LIB_SETTINGS    = $(PATH_BIN)/VBoxSettings.so
906 endif
907 ifeq ($(KBUILD_TARGET),os2)
908  LIB_RUNTIME     = $(PATH_BIN)/VBoxRT.dll
909  LIB_RUNTIME_EF  = #$(PATH_LIB)/RuntimeEFCPP.a
910  LIB_KPROFILE    = $(PATH_BIN)/kPrf2.dll
911  LIB_VMM         = $(PATH_BIN)/VBoxVMM.dll
912  LIB_VMMGC       = $(PATH_LIB)/VMMGCImp.lib
913  LIB_REM         = $(PATH_LIB)/VBoxREMImp.lib
914  LIB_XPCOM       = $(PATH_BIN)/VBoxXCOM.dll
915  LIB_DDU         = $(PATH_BIN)/VBoxDDU.dll
916  LIB_SETTINGS    = $(PATH_BIN)/VBoxSett.dll
917  OBJ_SYS0        = $(PATH_OBJ)/src/VBox/Runtime/RuntimeR0/os2/sys0.obj
918 endif
919 ifeq ($(KBUILD_TARGET),win)
920  LIB_RUNTIME     = $(PATH_LIB)/VBoxRT.lib
921  LIB_RUNTIME_EF  = #$(PATH_LIB)/RuntimeEFCPP.lib
922  LIB_KPROFILE    = $(PATH_LIB)/kPrf2.lib
923  LIB_VMM         = $(PATH_LIB)/VBoxVMM.lib
924  ifdef VBOX_SINGLE_MAKEFILE
925   LIB_VMMGC      = $(PATH_OBJ)/VMMGC/VMMGC.lib
926  else
927   LIB_VMMGC      = $(PATH_OBJ)/src/VBox/VMM/VMMGC/VMMGC.lib
928  endif
929  LIB_REM         = $(PATH_LIB)/VBoxREMImp.lib
930  LIB_XPCOM       = $(PATH_BIN)/VBoxXPCOM.dll
931  LIB_DDU         = $(PATH_LIB)/VBoxDDU.lib
932  LIB_SETTINGS    = $(PATH_LIB)/VBoxSettings.lib
933 endif
934
935 # The kprofile build automagically links with kProfile.
936 ifeq ($(KBUILD_TYPE),kprofile)
937  LIB_RUNTIME    += $(LIB_KPROFILE)
938 endif
939
940 ## Enable C++ electric fence heap. (Warning: will easily run out of virtual memory / kernel stuff on Linux/Windows.)
941 #LIB_RUNTIME += $(LIB_RUNTIME_EF) $(LIB_RUNTIME)
942
943 # Overridable libraries (unix).
944 LIB_PTHREAD      ?= pthread
945
946 # Xcursor (consider an SDK for this).
947 # (LIB_XCURSOR is legacy, remove in a month or two.)
948 ifndef VBOX_XCURSOR_LIBS
949  VBOX_XCURSOR_LIBS := $(LIB_XCURSOR)
950 endif
951 ifeq ($(VBOX_XCURSOR_LIBS),)
952  ifeq ($(KBUILD_TARGET),solaris)
953   VBOX_XCURSOR_LIBS := $(lastword $(wildcard $(PATH_DEVTOOLS_TRG)/libXcursor/*/lib/libXcursor.a))
954   ifneq ($(VBOX_XCURSOR_LIBS),)
955    VBOX_XCURSOR_INCS := $(patsubst %/lib/libXcursor.a,%/include, $(VBOX_XCURSOR_LIBS))
956    VBOX_XCURSOR_LIBS += X11 Xrender Xfixes
957   endif
958  endif
959  ifeq ($(VBOX_XCURSOR_LIBS),)
960   VBOX_XCURSOR_LIBS := Xcursor
961  endif
962 endif
963
964
965 # Intel ASL compiler for ACPI
966 VBOX_IASLCMD   ?= $(firstword $(wildcard $(PATH_DEVTOOLS_BLD)/bin/iasl$(HOSTSUFF_EXE)) iasl$(HOSTSUFF_EXE))
967
968 # Bruce's C compile is a C-compiler for BIOS-related 8086 code
969 VBOX_BCC       ?= $(PATH_DEVTOOLS_BLD)/bin/bcc$(HOSTSUFF_EXE) -B $(PATH_DEVTOOLS_BLD)/bin/
970
971 # Assembler for BIOS-related 8086 code
972 VBOX_AS86      ?= $(PATH_DEVTOOLS_BLD)/bin/as86$(HOSTSUFF_EXE)
973
974 # libxslt XSLT processor. (see PATH_TOOL_YASM for explanation why it's temporarily located in bin.)
975 ifeq ($(KBUILD_HOST),win)
976 # VBOX_XSLTPROC ?= $(PATH_DEVTOOLS)/win.x86/libxslt/10114/xsltproc.exe
977  VBOX_XSLTPROC ?= $(PATH_DEVTOOLS)/win.x86/bin/xsltproc.exe
978 else ifeq ($(KBUILD_HOST),os2)
979  VBOX_XSLTPROC ?= BEGINLIBPATH="$(PATH_DEVTOOLS_BLD)/bin;$$BEGINLIBPATH" $(PATH_DEVTOOLS_BLD)/bin/xsltproc.exe
980 else
981  VBOX_XSLTPROC ?= xsltproc$(HOSTSUFF_EXE)
982 endif
983
984 # bin2c (convert binary files into C arrays)
985 VBOX_BIN2C     ?= $(PATH_OBJ)/bin2c/bin2c$(HOSTSUFF_EXE)
986
987 # mkisofs
988 ifeq ($(KBUILD_HOST),win)
989  VBOX_MKISOFS  ?= $(PATH_DEVTOOLS_BLD)/bin/mkisofs.exe
990 else
991  VBOX_MKISOFS  ?= mkisofs
992 endif
993
994 # Makeself for the linux installers.
995 VBOX_MAKESELF  ?= $(PATH_DEVTOOLS)/common/makeself/v2.1.4_1/makeself.sh
996
997 # Microsoft HTML Help Workshop.
998 VBOX_PATH_HTML_HELP_WORKSHOP ?= $(PATH_DEVTOOLS)/win.x86/HTML_Help_Workshop/v1.3/
999
1000 # Path to the null soft installer.
1001 VBOX_PATH_NSIS ?= $(PATH_DEVTOOLS)/win.x86/nsis/v2.33-log-nsscm-r1
1002
1003 # Path to AutoIt3.
1004 VBOX_PATH_AUTOIT3 ?= $(PATH_DEVTOOLS)/win.x86/autoit/v3.2.10.0
1005
1006 # Windows install tools...
1007 VBOX_PATH_WIX  ?= $(PATH_DEVTOOLS)/win.x86/wix/v2.0.4611.0
1008 VBOX_PATH_DIFX ?= $(PATH_DEVTOOLS)/win.$(KBUILD_TARGET_ARCH)/DIFx/v2.1
1009
1010 # We need to export YASM for OSE, but since it was converted to .zip we need to
1011 # allow for the location used by the zip to be properly cleaned up first.
1012 if1of ($(KBUILD_HOST).$(KBUILD_HOST_ARCH),  win.x86 linux.x86 solaris.x86)
1013  PATH_TOOL_YASM ?= $(PATH_DEVTOOLS_BLD)/bin
1014 endif
1015
1016 # XPCOM setup for all but win32.
1017 ifneq ($(KBUILD_TARGET),win)
1018  VBOX_WITH_XPCOM      = 1
1019  VBOX_XPIDL          ?= $(VBOX_PATH_SDK)/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
1034 endif
1035
1036 ifeq ($(KBUILD_TARGET),os2)
1037  # search DLLs in the EXE directory first
1038  VBOX_XPIDL    := BEGINLIBPATH="$(dir $(VBOX_XPIDL));$$BEGINLIBPATH" $(VBOX_XPIDL)
1039 endif
1040 #$(error $(VBOX_XPIDL))
1041
1042 # The X11 LIBPATH. (The amd64 hack is for RHEL4.)
1043 ifeq ($(KBUILD_TARGET_ARCH),amd64)
1044  VBOX_LIBPATH_X11 ?= /usr/X11R6/lib64 /usr/X11R6/lib
1045 else
1046  VBOX_LIBPATH_X11 ?= /usr/X11R6/lib
1047 endif
1048
1049 # 32bit X11 LIBPATH for building 32bit guest additions
1050 VBOX_LIBPATH32_X11 ?= /usr/X11R6/lib32 /usr/X11R6/lib
1051
1052 #
1053 # Macros dealing with the darwin version we're targeting.
1054 #
1055 ifeq ($(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)
1076 endif # target=darwin
1077
1078 #
1079 # The X11 headers.
1080 #
1081 VBOX_PATH_X11_ROOT      = $(PATH_ROOT)/src/VBox/Additions/x11/x11include
1082 VBOX_PATH_X11_XFREE_4_2 = $(VBOX_PATH_X11_ROOT)/4.2
1083 VBOX_PATH_X11_XFREE_4_3 = $(VBOX_PATH_X11_ROOT)/4.3
1084 VBOX_PATH_X11_XORG_7_0  = $(VBOX_PATH_X11_ROOT)/7.0
1085 VBOX_PATH_X11_XORG_7_1  = $(VBOX_PATH_X11_ROOT)/7.1
1086 VBOX_PATH_X11_XORG_1_3  = $(VBOX_PATH_X11_ROOT)/1.3
1087 VBOX_PATH_X11_XORG_1_4  = $(VBOX_PATH_X11_ROOT)/1.4
1088 VBOX_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.
1097 VBOX_ORIGIN = $$ORIGIN
1098 ifeq ($(KBUILD_TARGET),solaris)
1099  VBOX_GCC_RPATH_OPT = -R
1100 else
1101  VBOX_GCC_RPATH_OPT = -Wl,-rpath,
1102 endif
1103
1104 # The icons to use.
1105 ifdef 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
1109 else
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
1120 endif
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 #
1130 include $(KBUILD_PATH)/tools/$(VBOX_GCC_TOOL).kmk
1131 ifneq ($(VBOX_GCC_TOOL),$(VBOX_GCC32_TOOL))
1132  include $(KBUILD_PATH)/tools/$(VBOX_GCC32_TOOL).kmk
1133 endif
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.
1137 ifeq ($(KBUILD_HOST),win)
1138 VBOX_GCC_CHECK_CC = $(2)
1139 VBOX_GCC_CHECK_CXX = $(2)
1140 VBOX_GCC_CHECK_LD = $(2)
1141 VBOX_GCC32_CHECK_CXX = $(2)
1142 else
1143 VBOX_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
1148 VBOX_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
1153 VBOX_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
1158 VBOX_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; )
1162 endif
1163
1164 ifeq ($(KBUILD_HOST),win)
1165 # This isn't important (yet) on windows, so cook the result until
1166 # cygwin is feeling better.
1167 VBOX_GCC_VERSION := $(int-add $(int-mul 10000, 3), $(int-mul 100, 3), 3)
1168 else
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 VBOX_GCC_VERSION = $(shell \
1172   $(1) -dumpversion | $(SED_EXT) 's|\([0-9]\)\.\([0-9]\)\.\([0-9]\)|$$(int-add $$(int-mul 10000, \1), $$(int-mul 100, \2), \3)|' )
1173 endif
1174
1175 # No $(QUIET) here as it's interesting to see what goes into the file.
1176 $(PATH_OUT)/GCCConfig.kmk: $(PATH_ROOT)/Config.kmk $(LOCALCFG) $(AUTOCFG)
1177         $(call MSG_GENERATE,,$@,)
1178         $(QUIET)$(RM) -f '$@'
1179         $(QUIET)$(MKDIR) -p $(@D)
1180
1181 # HC compiler switch detection.
1182         $(APPEND) '$@' 'VBOX_GCC_VERSION_CC            ?= $(call VBOX_GCC_VERSION,$(TOOL_$(VBOX_GCC_TOOL)_CC))'
1183         $(APPEND) '$@' 'VBOX_GCC_VERSION_CXX           ?= $(call VBOX_GCC_VERSION,$(TOOL_$(VBOX_GCC_TOOL)_CXX))'
1184         $(APPEND) '$@' 'VBOX_GCC_LIBGCC                ?= $(shell $(TOOL_$(VBOX_GCC_TOOL)_CC) -print-libgcc-file-name)'
1185         $(APPEND) '$@' 'VBOX_GCC_Wno-pointer-sign      ?= $(call VBOX_GCC_CHECK_CC,-Wno-pointer-sign,)'
1186         $(APPEND) '$@' 'VBOX_GCC_Wno-variadic-macros   ?= $(call VBOX_GCC_CHECK_CXX,-Wno-variadic-macros,)'
1187         $(APPEND) '$@' 'VBOX_GCC_Wno-invalid-offsetof  ?= $(call VBOX_GCC_CHECK_CXX,-Wno-invalid-offsetof,)'
1188         $(APPEND) '$@' 'VBOX_GCC_Wno-extra             ?= $(call VBOX_GCC_CHECK_CXX,-Wno-extra)'
1189         $(APPEND) '$@' 'VBOX_GCC_fno-stack-protector   ?= $(call VBOX_GCC_CHECK_CC,-fno-stack-protector,)'
1190 # Produce code optimized for the most common IA32/AMD64/EM64T processors. Introduced with gcc version 4.2.
1191         $(APPEND) '$@' 'VBOX_GCC_mtune-generic         ?= $(call VBOX_GCC_CHECK_CC,-mtune=generic,)'
1192         $(APPEND) '$@' 'VBOX_LD_as_needed              ?= $(call VBOX_GCC_CHECK_LD,--as-needed,)'
1193 ifneq ($(KBUILD_TARGET),l4)
1194 # Set default attribute for ELF and MACH-O symbols to ``hidden'' to reduce the number
1195 # of relocation entries and PLT indirections in shared libraries. Don't allow for gcc version < 4.
1196         $(APPEND) '$@' 'ifneq ($$(VBOX_GCC_VERSION_CC),)'
1197         $(APPEND) '$@' ' ifneq ($$(int-ge $$(VBOX_GCC_VERSION_CC),40000),)'
1198         $(APPEND) '$@' '  VBOX_GCC_fvisibility-hidden  ?= $(call VBOX_GCC_CHECK_CC,-fvisibility=hidden -DVBOX_HAVE_VISIBILITY_HIDDEN -DRT_USE_VISIBILITY_DEFAULT,)'
1199         $(APPEND) '$@' ' endif'
1200         $(APPEND) '$@' 'endif'
1201 endif
1202 ifneq ($(KBUILD_TARGET),l4)
1203 # Set default attribute for inline functions to ``hidden'' to reduce the number
1204 # of relocation entries and PLT indirections in shared libraries. Don't allow for gcc version < 4.
1205         $(APPEND) '$@' 'ifneq ($$(VBOX_GCC_VERSION_CXX),)'
1206         $(APPEND) '$@' ' ifneq ($$(int-ge $$(VBOX_GCC_VERSION_CXX),40000),)'
1207         $(APPEND) '$@' '  VBOX_GCC_fvisibility-inlines-hidden ?= $(call VBOX_GCC_CHECK_CXX,-fvisibility-inlines-hidden,)'
1208         $(APPEND) '$@' ' endif'
1209         $(APPEND) '$@' 'endif'
1210 endif
1211 # Find the compiler includes for IPRT no-crt.
1212 # Note that `$(dir $(gcc -print-libgcc-file-name))/include does not work for a 64-bit cross build on a 32-bit build host.
1213 ifeq ($(KBUILD_HOST),win)
1214 # With the cygwin issues and gcc on windows returning a useless path, just skip this on windows.
1215         $(APPEND) '$@' 'VBOX_PATH_GCC_INCS             ?= '
1216 else
1217         $(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'
1218 endif
1219 # 32-bit (GC) compiler switch detection.
1220         $(APPEND) '$@' 'VBOX_GCC32_VERSION_CC          ?= $(call VBOX_GCC_VERSION,$(TOOL_$(VBOX_GCC32_TOOL)_CC))'
1221         $(APPEND) '$@' 'VBOX_GCC32_VERSION_CXX         ?= $(call VBOX_GCC_VERSION,$(TOOL_$(VBOX_GCC32_TOOL)_CXX))'
1222         $(APPEND) '$@' 'VBOX_GCC32_LIBGCC              ?= $(shell $(TOOL_$(VBOX_GCC32_TOOL)_CC) -print-libgcc-file-name)'
1223         $(APPEND) '$@' 'VBOX_GCC32_Wno-variadic-macros ?= $(call VBOX_GCC32_CHECK_CXX,-Wno-variadic-macros,)'
1224
1225 include $(PATH_OUT)/GCCConfig.kmk
1226
1227
1228 #
1229 # Code Signing.
1230 #
1231 ifdef VBOX_SIGNING_MODE
1232  ifeq ($(KBUILD_HOST),win)
1233   # VBOX_PATH_SELFSIGN points to the Vista WDK bin/SelfSign directory.
1234   ifndef VBOX_PATH_SELFSIGN
1235    VBOX_PATH_SELFSIGN := $(lastword $(sort $(wildcard $(PATH_DEVTOOLS)/win.x86/selfsign/*)))
1236    ifeq ($(VBOX_PATH_SELFSIGN),)
1237     VBOX_PATH_SELFSIGN := $(PATH_DEVTOOLS)/win.x86/selfsign/r1
1238    endif
1239   endif
1240   VBOX_SIGNTOOL ?= $(VBOX_PATH_SELFSIGN)/SignTool.exe
1241   VBOX_INF2CAT  ?= $(VBOX_PATH_SELFSIGN)/Inf2Cat.exe
1242
1243   # There are three signing modes; 'test', 'development' and 'release'.
1244   ifeq ($(strip $(VBOX_SIGNING_MODE)),test)
1245    VBOX_CERTIFICATE_SUBJECT_NAME ?= MyTestCertificate
1246    VBOX_CERTIFICATE_SUBJECT_NAME_ARGS ?= /n "$(VBOX_CERTIFICATE_SUBJECT_NAME)"
1247   else if1of ($(VBOX_SIGNING_MODE),release development)
1248    VBOX_CERTIFICATE_SUBJECT_NAME ?= Sun Microsystems, Inc.
1249    VBOX_CERTIFICATE_SUBJECT_NAME_ARGS ?= /n "$(VBOX_CERTIFICATE_SUBJECT_NAME)"
1250    VBOX_CROSS_CERTIFICATE_FILE ?= $(VBOX_PATH_SELFSIGN)/MSCV-VSClass3.cer
1251    VBOX_CROSS_CERTIFICATE_FILE_ARGS ?= /ac "$(VBOX_CROSS_CERTIFICATE_FILE)"
1252    VBOX_TSA_URL ?= http://timestamp.verisign.com/scripts/timestamp.dll
1253    VBOX_TSA_URL_ARGS ?= /t "$(VBOX_TSA_URL)"
1254   else
1255    $(error Unknown VBOX_SIGNING_MODE: $(VBOX_SIGNING_MODE))
1256   endif
1257   VBOX_CERTIFICATE_STORE ?= my
1258   VBOX_CERTIFICATE