VirtualBox

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

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

Support/Makefile.kmk: Merged the win VBoxDrv with the generic one to fix build problem.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette