VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/Makefile.kmk@ 40602

Last change on this file since 40602 was 40602, checked in by vboxsync, 13 years ago

SUPDrv-dtrace.cpp: More code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.6 KB
Line 
1# $Id: Makefile.kmk 40602 2012-03-24 13:38:46Z vboxsync $
2## @file
3# Sub-Makefile for the support library and the drivers/modules/kexts it uses.
4#
5
6#
7# Copyright (C) 2006-2011 Oracle Corporation
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17# The contents of this file may alternatively be used under the terms
18# of the Common Development and Distribution License Version 1.0
19# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20# VirtualBox OSE distribution, in which case the provisions of the
21# CDDL are applicable instead of those of the GPL.
22#
23# You may elect to license modified versions of this file under the
24# terms and conditions of either the GPL or the CDDL or both.
25#
26
27SUB_DEPTH = ../../../..
28include $(KBUILD_PATH)/subheader.kmk
29
30#
31# Targets
32#
33LIBRARIES += SUPR3 SUPR3Static SUPR3HardenedStatic
34ifndef VBOX_ONLY_DOCS
35 if1of ($(VBOX_LDR_FMT), pe lx)
36 LIBRARIES += SUPR0
37 endif
38endif
39if !defined(VBOX_ONLY_DOCS) \
40 && !defined(VBOX_ONLY_EXTPACKS) \
41 && !defined(VBOX_ONLY_TESTSUITE)
42 ifdef VBOX_WITH_SUPSVC
43 PROGRAMS += VBoxSupSvc
44 endif
45 ifdef VBOX_WITH_VBOXDRV
46 LIBRARIES += SUPR0IdcClient
47 SYSMODS.freebsd += vboxdrv
48 SYSMODS.linux += vboxdrv
49 SYSMODS.win += VBoxDrv
50 SYSMODS.os2 += VBoxDrv
51 SYSMODS.solaris += vboxdrv
52 endif
53 INSTALLS.linux += vboxdrv-mod
54 INSTALLS.freebsd += vboxdrv-mod
55
56 #
57 # Include sub-makefile(s).
58 #
59 include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk
60
61 #
62 # Populate FILES_VBOXDRV_NOBIN and FILES_VBOXDRV_BIN
63 #
64 ifeq ($(KBUILD_TARGET),linux)
65 include $(PATH_SUB_CURRENT)/linux/files_vboxdrv
66 endif
67 ifeq ($(KBUILD_TARGET),freebsd)
68 include $(PATH_SUB_CURRENT)/freebsd/files_vboxdrv
69 endif
70endif # !VBOX_ONLY_DOCS && !VBOX_ONLY_EXTPACKS && !VBOX_ONLY_TESTSUITE
71
72
73#
74# The Ring-3 Support Library (this is linked into the IPRT dll, VBoxRT).
75#
76ifneq ($(filter l4%,$(KBUILD_TARGET) $(BUILD_TARGET_SUB)),)
77 # L4 has trouble with -pedantic. It also make trouble when inlining is not enabled.
78 SUPR3_TEMPLATE = VBOXR3NP
79else
80 SUPR3_TEMPLATE = VBOXR3
81endif
82SUPR3_DEFS = \
83 IN_SUP_R3 IN_RT_R3 \
84 $(if $(VBOX_WITH_SUPSVC),VBOX_WITH_SUPSVC) \
85 $(if $(VBOX_WITH_MAIN),VBOX_WITH_MAIN,) \
86 $(if $(VBOX_WITH_RAW_MODE),VBOX_WITH_RAW_MODE,)
87SUPR3_INCS := $(PATH_SUB_CURRENT)
88SUPR3_INCS.l4 = $(L4_INCDIR)
89SUPR3_SOURCES = \
90 SUPLib.cpp \
91 SUPLibSem.cpp \
92 SUPR3HardenedIPRT.cpp \
93 SUPR3HardenedVerify.cpp \
94 $(KBUILD_TARGET)/SUPLib-$(KBUILD_TARGET).cpp
95
96#
97# Static version of SUPR3.
98#
99SUPR3Static_TEMPLATE = VBOXR3STATIC
100SUPR3Static_EXTENDS = SUPR3
101
102#
103# The static part of the hardened support library (ring-3).
104#
105SUPR3HardenedStatic_TEMPLATE = VBOXR3HARDENEDLIB
106SUPR3HardenedStatic_DEFS = IN_SUP_HARDENED_R3
107SUPR3HardenedStatic_DEFS += \
108 $(if $(VBOX_WITH_SUPSVC),VBOX_WITH_SUPSVC,) \
109 $(if $(VBOX_WITH_MAIN),VBOX_WITH_MAIN,) \
110 $(if $(VBOX_WITH_RAW_MODE),VBOX_WITH_RAW_MODE,)
111SUPR3HardenedStatic_INCS = .
112SUPR3HardenedStatic_SOURCES = \
113 SUPR3HardenedMain.cpp \
114 SUPR3HardenedVerify.cpp \
115 $(KBUILD_TARGET)/SUPLib-$(KBUILD_TARGET).cpp
116
117#
118# VBoxSupSvc - The system wide service/daemon.
119#
120VBoxSupSvc_TEMPLATE = VBOXR3EXE
121VBoxSupSvc_SOURCES = \
122 SUPSvc.cpp \
123 SUPSvcGlobal.cpp \
124 $(KBUILD_TARGET)/SUPSvc-$(KBUILD_TARGET).cpp
125if1of ($(KBUILD_TARGET), win)
126 VBoxSupSvc_SOURCES += \
127 SUPSvcGrant.cpp
128endif
129ifn1of ($(KBUILD_TARGET), win)
130 VBoxSupSvc_SOURCES += \
131 SUPSvcMain-posix.cpp
132endif
133VBoxSupSvc_LIBS = \
134 $(LIB_RUNTIME)
135
136
137#
138# SUPR0 - The Ring-0 Import / Thunk library.
139#
140SUPR0_TEMPLATE = VBoxR0
141ifeq ($(VBOX_LDR_FMT),pe)
142 SUPR0_SOURCES += SUPR0.def
143endif
144ifeq ($(VBOX_LDR_FMT),lx)
145SUPR0_SOURCES += $$(SUPR0_0_OUTDIR)/SUPR0.def
146$$(SUPR0_0_OUTDIR)/SUPR0.def: $(PATH_SUB_CURRENT)/SUPR0.def | $$(dir $$@)
147 $(SED) \
148 -e 's/^[ \t][ \t]*\([gA-Z]\)/ _\1/' \
149 -e 's/[ \t]DATA[ \t]*/ /' \
150 -e 's/g_pSUPGlobalInfoPage/g_SUPGlobalInfoPage/' \
151 --output [email protected]\
152 $<
153 $(MV) -f [email protected] $@
154endif
155
156
157#
158# SUPR0IdcClient - The Ring-0 IDC client driver library.
159#
160SUPR0IdcClient_TEMPLATE = VBoxR0DrvLib
161SUPR0IdcClient_DEFS = IN_RT_R0 IN_SUP_R0 IN_SUP_STATIC
162SUPR0IdcClient_SDKS.win = W2K3DDK WINPSDKINCS
163SUPR0IdcClient_SOURCES.$(KBUILD_TARGET) = \
164 $(KBUILD_TARGET)/SUPR0IdcClient-$(KBUILD_TARGET).c
165SUPR0IdcClient_SOURCES = \
166 SUPR0IdcClient.c \
167 SUPR0IdcClientComponent.c \
168 SUPR0IdcClientStubs.c
169
170
171if !defined(VBOX_ONLY_DOCS) \
172 && !defined(VBOX_ONLY_EXTPACKS) \
173 && !defined(VBOX_ONLY_TESTSUITE)
174
175#
176# VBoxDrv.sys - The Windows driver.
177#
178## @todo consolidate all the targets into a single mess.
179ifeq ($(KBUILD_TARGET),win)
180VBoxDrv_TEMPLATE = VBOXR0DRV
181ifdef VBOX_SIGNING_MODE
182 VBoxDrv_INSTTYPE = none
183 VBoxDrv_DEBUG_INSTTYPE = both
184endif
185VBoxDrv_DEFS = IN_RT_R0 IN_SUP_R0 SUPDRV_WITH_RELEASE_LOGGER
186ifdef VBOX_WITHOUT_NATIVE_R0_LOADER
187 VBoxDrv_DEFS += VBOX_WITHOUT_NATIVE_R0_LOADER
188endif
189ifdef VBOX_WITH_VMMR0_DISABLE_PREEMPTION
190 VBoxDrv_DEFS += VBOX_WITH_VMMR0_DISABLE_PREEMPTION
191endif
192VBoxDrv_SDKS = W2K3DDK WINPSDKINCS
193VBoxDrv_INCS := $(PATH_SUB_CURRENT)
194VBoxDrv_SOURCES = \
195 win/SUPDrv-win.cpp \
196 win/SUPDrvA-win.asm \
197 SUPDrv.c \
198 SUPDrvSem.c \
199 win/VBoxDrv.rc
200VBoxDrv_LDFLAGS.x86 = -Entry:DriverEntry@8
201VBoxDrv_LDFLAGS.amd64 = -Entry:DriverEntry
202VBoxDrv_LIBS = \
203 $(PATH_SDK_W2K3DDK_LIB)/ntoskrnl.lib \
204 $(PATH_SDK_W2K3DDK_LIB)/hal.lib \
205 $(PATH_STAGE_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB)
206
207
208INSTALLS += VBoxDrv-inf
209VBoxDrv-inf_INST = $(INST_BIN)
210VBoxDrv-inf_MODE = a+r,u+w
211VBoxDrv-inf_SOURCES = \
212 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.inf
213VBoxDrv-inf_CLEAN = $(VBoxDrv-inf_SOURCES)
214VBoxDrv-inf_BLDDIRS = $(PATH_TARGET)/VBoxDrvCat.dir
215
216$(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.inf: $(PATH_SUB_CURRENT)/win/VBoxDrv.inf $(MAKEFILE_CURRENT) | $$(dir $$@)
217 $(call MSG_GENERATE,VBoxDrv-inf,$@,$<)
218 $(call VBOX_EDIT_INF_FN,$<,$@)
219
220 ifdef VBOX_SIGNING_MODE
221VBoxDrv-inf_SOURCES += \
222 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.sys \
223 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.cat
224
225$(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.sys: $$(VBoxDrv_1_TARGET) | $$(dir $$@)
226 $(INSTALL) -m 644 $< $(@D)
227
228$(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.cat: \
229 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.inf \
230 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.sys
231 $(call MSG_TOOL,Inf2Cat,VBoxDrv-inf,$@,$<)
232 $(call VBOX_MAKE_CAT_FN, $(@D),$@)
233 endif # signing
234endif # win
235
236
237#
238# vboxdrv.ko - The Linux Kernel Module (syntax check only).
239#
240ifeq ($(KBUILD_TARGET),linux)
241vboxdrv_TEMPLATE = VBOXR0DRV
242vboxdrv_DEFS = KBUILD_MODNAME=KBUILD_STR\(vboxdrv\) KBUILD_BASENAME=KBUILD_STR\(vboxdrv\) MODULE IN_RT_R0 IN_SUP_R0 CONFIG_VBOXDRV_AS_MISC
243ifdef VBOX_LINUX_VERSION_2_4
244 vboxdrv_DEFS += EXPORT_SYMTAB
245endif
246vboxdrv_INCS := \
247 $(PATH_SUB_CURRENT) \
248 $(PATH_ROOT)/src/VBox/Runtime/r0drv/linux
249vboxdrv_LIBS = $(PATH_STAGE_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB)
250vboxdrv_LIBS.debug = $(vboxdrv_LIBS) $(VBOX_GCC_LIBGCC)
251vboxdrv_SOURCES = \
252 $(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).c \
253 SUPDrv.c \
254 SUPDrvSem.c
255ifndef VBOX_LINUX_VERSION_2_4
256 vboxdrv_SOURCES += \
257 $(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).mod.c
258endif
259
260
261#
262# Targets for installing the linux sources.
263#
264vboxdrv-mod_INST = bin/src/vboxdrv/
265vboxdrv-mod_SOURCES = \
266 $(subst $(DQUOTE),,$(FILES_VBOXDRV_NOBIN)) \
267 $(vboxdrv-mod_0_OUTDIR)/Makefile
268vboxdrv-mod_EXEC_SOURCES = \
269 $(subst $(DQUOTE),,$(FILES_VBOXDRV_BIN)) \
270 $(PATH_ROOT)/src/VBox/HostDrivers/linux/do_Module.symvers
271vboxdrv-mod_CLEAN = \
272 $(vboxdrv-mod_0_OUTDIR)/Makefile \
273 $(PATH_TARGET)/vboxdrv-mod-1.dep \
274
275# Scripts needed for building the kernel modules
276
277includedep $(PATH_TARGET)/vboxdrv-mod-1.dep
278$$(vboxdrv-mod_0_OUTDIR)/Makefile: \
279 $(PATH_SUB_CURRENT)/linux/Makefile \
280 $$(if $$(eq $$(Support/linux/Makefile_VBOX_HARDENED),$$(VBOX_WITH_HARDENING)),,FORCE) \
281 | $$(dir $$@)
282 $(call MSG_TOOL,Creating,,$@)
283 ifndef VBOX_WITH_HARDENING
284 $(QUIET)$(SED) -e "s;-DVBOX_WITH_HARDENING;;g" --output $@ $<
285 else
286 $(QUIET)$(CP) -f $< $@
287 endif
288 %$(QUIET2)$(APPEND) -t '$(PATH_TARGET)/vboxdrv-mod-1.dep' 'Support/linux/Makefile_VBOX_HARDENED=$(VBOX_WITH_HARDENING)'
289
290endif # real linux
291
292
293ifeq ($(KBUILD_TARGET),os2)
294
295#
296# VBoxDrv.sys - The OS/2 driver.
297#
298VBoxDrv_TEMPLATE = VBOXR0DRV
299VBoxDrv_DEFS = IN_RT_R0 IN_SUP_R0
300VBoxDrv_INCS := $(PATH_SUB_CURRENT)
301#VBoxDrv_LDFLAGS = -s -t -v
302VBoxDrv_SOURCES = \
303 os2/SUPDrvA-os2.asm \
304 os2/SUPDrv-os2.def
305VBoxDrv_LIBS = \
306 $(VBoxDrvLib_1_TARGET) \
307 $(PATH_STAGE_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB) \
308 $(VBOX_GCC_LIBGCC) \
309 end
310
311# temp hack to ensure that SUPDrvA-os2.asm is first in the link.
312LIBRARIES += VBoxDrvLib
313VBoxDrvLib_TEMPLATE = VBOXR0DRV
314VBoxDrvLib_INSTTYPE = none
315VBoxDrvLib_DEFS = IN_RT_R0 IN_SUP_R0
316VBoxDrvLib_INCS := \
317 . \
318 $(PATH_ROOT)/src/VBox/Runtime/include
319VBoxDrvLib_SOURCES = \
320 os2/SUPDrv-os2.cpp \
321 SUPDrv.c \
322 SUPDrvSem.c
323
324endif # os2
325ifeq ($(KBUILD_TARGET),freebsd)
326
327#
328# vboxdrv.ko - The FreeBSD Kernel Module.
329#
330vboxdrv_TEMPLATE = VBOXR0DRV
331vboxdrv_DEFS = IN_RT_R0 IN_SUP_R0 SUPDRV_WITH_RELEASE_LOGGER VBOX_SVN_REV=$(VBOX_SVN_REV)
332vboxdrv_INCS := $(PATH_SUB_CURRENT)
333vboxdrv_LIBS = $(PATH_STAGE_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB)
334vboxdrv_SOURCES := \
335 $(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).c \
336 $(PATH_SUB_CURRENT)/$(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).def \
337 SUPDrv.c \
338 SUPDrvSem.c
339## @todo the SUPDrv-freebsd.def is most probably gonna break it and require build system hacking...
340
341#
342# Targets for installing the freebsd sources.
343#
344vboxdrv-mod_INST = bin/src/vboxdrv/
345vboxdrv-mod_SOURCES = \
346 $(subst $(DQUOTE),,$(FILES_VBOXDRV_NOBIN)) \
347 $(vboxdrv-mod_0_OUTDIR)/Makefile
348vboxdrv-mod_CLEAN = \
349 $(vboxdrv-mod_0_OUTDIR)/Makefile
350
351$$(vboxdrv-mod_0_OUTDIR)/Makefile: \
352 $(PATH_SUB_CURRENT)/freebsd/Makefile \
353 $$(if $$(eq $$(Support/freebsd/Makefile_VBOX_HARDENED),$$(VBOX_WITH_HARDENING)),,FORCE) \
354 | $$(dir $$@)
355 $(call MSG_TOOL,Creating,,$@)
356 $(QUIET)$(RM) -f -- $@
357 ifndef VBOX_WITH_HARDENING
358 $(QUIET)$(SED) -e "s;-DVBOX_WITH_HARDENING;;g" --output $@ $<
359 else
360 $(QUIET)$(CP) -f $< $@
361 endif
362
363endif # freebsd
364
365
366#
367# New VBoxDrv target. TODO: Convert all the above to use this!
368#
369if1of ($(KBUILD_TARGET), darwin solaris)
370# Leopard (x86) and Snow Leopard (x86/amd64)
371SYSMODS += VBoxDrv
372VBoxDrv_TEMPLATE = VBOXR0DRV
373VBoxDrv_NAME.solaris = vboxdrv
374VBoxDrv_NAME.freebsd = vboxdrv
375VBoxDrv_INST.darwin = $(INST_VBOXDRV)Contents/MacOS/
376VBoxDrv_DEFS := IN_RT_R0 IN_SUP_R0 SUPDRV_WITH_RELEASE_LOGGER VBOX_SVN_REV=$(VBOX_SVN_REV)
377ifdef VBOX_WITH_DTRACE_R0DRV
378 VBoxDrv_DEFS += VBOX_WITH_DTRACE VBOX_WITH_DTRACE_R0DRV
379endif
380ifdef VBOX_WITH_NETFLT
381 vboxdrv_DEFS.solaris += VBOX_WITH_NETFLT
382endif
383ifdef VBOX_WITH_NATIVE_SOLARIS_LOADING
384 vboxdrv_DEFS.solaris += VBOX_WITH_NATIVE_SOLARIS_LOADING
385endif
386VBoxDrv_DEFS.darwin:= VBOX_WITH_HOST_VMX
387#VBoxDrv_DEFS.debug += DEBUG_DARWIN_GIP
388VBoxDrv_INCS = . $(VBoxDrv_0_OUTDIR)
389VBoxDrv_INCS.darwin = ./darwin
390VBoxDrv_LIBS = $(PATH_STAGE_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB)
391#VBoxDrv_LDFLAGS = -v -Wl,-whyload -Wl,-v -Wl,-whatsloaded
392VBoxDrv_SOURCES = \
393 SUPDrv.c \
394 SUPDrvSem.c \
395 $(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).cpp
396ifdef VBOX_WITH_DTRACE_R0DRV
397 VBoxDrv_SOURCES += \
398 SUPDrv-dtrace.cpp
399endif
400VBoxDRV_LDFLAGS.solaris += -N misc/ctf
401endif
402
403
404if1of ($(KBUILD_TARGET), darwin)
405 # Files necessary to make a darwin kernel extension bundle.
406 INSTALLS.darwin += VBoxDrv.kext
407 VBoxDrv.kext_INST = $(INST_VBOXDRV)Contents/
408 VBoxDrv.kext_SOURCES = $(VBoxDrv.kext_0_OUTDIR)/Info.plist
409 VBoxDrv.kext_CLEAN = $(VBoxDrv.kext_0_OUTDIR)/Info.plist
410
411$$(VBoxDrv.kext_0_OUTDIR)/Info.plist: \
412 $(PATH_SUB_CURRENT)/darwin/Info.plist \
413 $(VBOX_VERSION_MK) | $$(dir $$@)
414 $(call MSG_GENERATE,VBoxDrv,$@,$<)
415 $(QUIET)$(RM) -f $@
416 $(QUIET)$(SED) \
417 -e 's/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g' \
418 -e 's/@VBOX_VERSION_MAJOR@/$(VBOX_VERSION_MAJOR)/g' \
419 -e 's/@VBOX_VERSION_MINOR@/$(VBOX_VERSION_MINOR)/g' \
420 -e 's/@VBOX_VERSION_BUILD@/$(VBOX_VERSION_BUILD)/g' \
421 -e 's/@VBOX_VENDOR@/$(VBOX_VENDOR)/g' \
422 -e 's/@VBOX_PRODUCT@/$(VBOX_PRODUCT)/g' \
423 -e 's/@VBOX_C_YEAR@/$(VBOX_C_YEAR)/g' \
424 --output $@ \
425 $<
426endif
427
428if1of ($(KBUILD_TARGET), darwin)
429 # Common manual loader script.
430 INSTALLS += Scripts
431 Scripts_INST = $(INST_DIST)
432 Scripts_EXEC_SOURCES = \
433 $(KBUILD_TARGET)/load.sh
434endif
435
436
437endif # !VBOX_ONLY_DOCS && !VBOX_ONLY_EXTPACKS && !VBOX_ONLY_TESTSUITE
438include $(KBUILD_PATH)/subfooter.kmk
439
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