VirtualBox

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

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

drop verbose VBoxTpG

  • 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 40861 2012-04-10 23:46:27Z 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 library.
136#
137SUPR0_TEMPLATE = VBoxR0
138if1of ($(VBOX_LDR_FMT), pe lx)
139 SUPR0_SOURCES = $(SUPR0_0_OUTDIR)/SUPR0.def
140 SUPR0_CLEAN = $(SUPR0_0_OUTDIR)/SUPR0.def
141$$(SUPR0_0_OUTDIR)/SUPR0.def: \
142 $(PATH_SUB_CURRENT)/SUPDrv.c \
143 $(PATH_SUB_CURRENT)/SUPR0-def-$(VBOX_LDR_FMT).sed \
144 | $$(dir $$@)
145 $(SED) \
146 -f $(dir $<)/SUPR0-def-$(VBOX_LDR_FMT).sed \
147 --output $@ \
148 $<
149endif
150
151
152#
153# SUPR0IdcClient - The Ring-0 IDC client driver library.
154#
155SUPR0IdcClient_TEMPLATE = VBoxR0DrvLib
156SUPR0IdcClient_DEFS = IN_RT_R0 IN_SUP_R0 IN_SUP_STATIC
157SUPR0IdcClient_SDKS.win = W2K3DDK WINPSDKINCS
158SUPR0IdcClient_SOURCES.$(KBUILD_TARGET) = \
159 $(KBUILD_TARGET)/SUPR0IdcClient-$(KBUILD_TARGET).c
160SUPR0IdcClient_SOURCES = \
161 SUPR0IdcClient.c \
162 SUPR0IdcClientComponent.c \
163 SUPR0IdcClientStubs.c
164
165
166
167if !defined(VBOX_ONLY_DOCS) \
168 && !defined(VBOX_ONLY_EXTPACKS) \
169 && !defined(VBOX_ONLY_TESTSUITE)
170
171ifeq ($(KBUILD_TARGET),os2)
172
173#
174# VBoxDrv.sys - The OS/2 driver.
175#
176VBoxDrv_TEMPLATE = VBOXR0DRV
177VBoxDrv_DEFS = IN_RT_R0 IN_SUP_R0
178VBoxDrv_INCS := $(PATH_SUB_CURRENT)
179#VBoxDrv_LDFLAGS = -s -t -v
180VBoxDrv_SOURCES = \
181 os2/SUPDrvA-os2.asm \
182 os2/SUPDrv-os2.def
183VBoxDrv_LIBS = \
184 $(VBoxDrvLib_1_TARGET) \
185 $(PATH_STAGE_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB) \
186 $(VBOX_GCC_LIBGCC) \
187 end
188
189# temp hack to ensure that SUPDrvA-os2.asm is first in the link.
190LIBRARIES += VBoxDrvLib
191VBoxDrvLib_TEMPLATE = VBOXR0DRV
192VBoxDrvLib_INSTTYPE = none
193VBoxDrvLib_DEFS = IN_RT_R0 IN_SUP_R0
194VBoxDrvLib_INCS := \
195 . \
196 $(PATH_ROOT)/src/VBox/Runtime/include
197VBoxDrvLib_SOURCES = \
198 os2/SUPDrv-os2.cpp \
199 SUPDrv.c \
200 SUPDrvSem.c
201
202endif # os2
203ifeq ($(KBUILD_TARGET),freebsd)
204
205#
206# vboxdrv.ko - The FreeBSD Kernel Module.
207#
208vboxdrv_TEMPLATE = VBOXR0DRV
209vboxdrv_DEFS = IN_RT_R0 IN_SUP_R0 SUPDRV_WITH_RELEASE_LOGGER VBOX_SVN_REV=$(VBOX_SVN_REV)
210vboxdrv_INCS := $(PATH_SUB_CURRENT)
211vboxdrv_LIBS = $(PATH_STAGE_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB)
212vboxdrv_SOURCES := \
213 $(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).c \
214 $(PATH_SUB_CURRENT)/$(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).def \
215 SUPDrv.c \
216 SUPDrvSem.c
217## @todo the SUPDrv-freebsd.def is most probably gonna break it and require build system hacking...
218
219#
220# Targets for installing the freebsd sources.
221#
222vboxdrv-mod_INST = bin/src/vboxdrv/
223vboxdrv-mod_SOURCES = \
224 $(subst $(DQUOTE),,$(FILES_VBOXDRV_NOBIN)) \
225 $(vboxdrv-mod_0_OUTDIR)/Makefile
226vboxdrv-mod_CLEAN = \
227 $(vboxdrv-mod_0_OUTDIR)/Makefile
228
229$$(vboxdrv-mod_0_OUTDIR)/Makefile: \
230 $(PATH_SUB_CURRENT)/freebsd/Makefile \
231 $$(if $$(eq $$(Support/freebsd/Makefile_VBOX_HARDENED),$$(VBOX_WITH_HARDENING)),,FORCE) \
232 | $$(dir $$@)
233 $(call MSG_TOOL,Creating,,$@)
234 $(QUIET)$(RM) -f -- $@
235 ifndef VBOX_WITH_HARDENING
236 $(QUIET)$(SED) -e "s;-DVBOX_WITH_HARDENING;;g" --output $@ $<
237 else
238 $(QUIET)$(CP) -f $< $@
239 endif
240
241endif # freebsd
242
243
244#
245# New VBoxDrv target. TODO: Convert all the above to use this!
246#
247if1of ($(KBUILD_TARGET), darwin linux solaris win)
248 ifdef VBOX_WITH_VBOXDRV
249 SYSMODS += VBoxDrv
250 endif
251 VBoxDrv_TEMPLATE = VBOXR0DRV
252 VBoxDrv_NAME.freebsd = vboxdrv
253 VBoxDrv_NAME.linux = vboxdrv
254 VBoxDrv_NAME.solaris = vboxdrv
255 ifdef VBOX_SIGNING_MODE
256 VBoxDrv_INSTTYPE = none
257 VBoxDrv_DEBUG_INSTTYPE = both
258 endif
259 VBoxDrv_INST.darwin = $(INST_VBOXDRV)Contents/MacOS/
260 VBoxDrv_SDKS.win = W2K3DDK WINPSDKINCS
261
262 VBoxDrv_DEFS := IN_RT_R0 IN_SUP_R0 SUPDRV_WITH_RELEASE_LOGGER VBOX_SVN_REV=$(VBOX_SVN_REV)
263 ifdef VBOX_WITH_DTRACE_R0DRV
264 VBoxDrv_DEFS += VBOX_WITH_DTRACE VBOX_WITH_DTRACE_R0DRV
265 endif
266 #VBoxDrv_DEFS.debug += DEBUG_DARWIN_GIP
267 VBoxDrv_DEFS.darwin := VBOX_WITH_HOST_VMX
268 VBoxDrv_DEFS.linux := \
269 KBUILD_MODNAME=KBUILD_STR\(vboxdrv\) KBUILD_BASENAME=KBUILD_STR\(vboxdrv\) MODULE CONFIG_VBOXDRV_AS_MISC
270 ifdef VBOX_LINUX_VERSION_2_4
271 VBoxDrv_DEFS.linux += EXPORT_SYMTAB
272 endif
273 ifdef VBOX_WITH_NETFLT
274 VBoxDrv_DEFS.solaris += VBOX_WITH_NETFLT
275 endif
276 ifdef VBOX_WITH_NATIVE_SOLARIS_LOADING
277 VBoxDrv_DEFS.solaris += VBOX_WITH_NATIVE_SOLARIS_LOADING
278 endif
279 ifdef VBOX_WITHOUT_NATIVE_R0_LOADER
280 VBoxDrv_DEFS.win += VBOX_WITHOUT_NATIVE_R0_LOADER
281 endif
282 ifdef VBOX_WITH_VMMR0_DISABLE_PREEMPTION
283 VBoxDrv_DEFS.win += VBOX_WITH_VMMR0_DISABLE_PREEMPTION
284 endif
285
286 VBoxDrv_INCS = . $(VBoxDrv_0_OUTDIR)
287 VBoxDrv_INCS.darwin = ./darwin
288 VBoxDrv_INCS.linux = $(PATH_ROOT)/src/VBox/Runtime/r0drv/linux
289
290 VBoxDrv_LIBS = $(PATH_STAGE_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB)
291 VBoxDrv_LIBS.linux.debug = $(VBoxDrv_LIBS) $(VBOX_GCC_LIBGCC)
292 VBoxDrv_LIBS.win = \
293 $(PATH_SDK_W2K3DDK_LIB)/ntoskrnl.lib \
294 $(PATH_SDK_W2K3DDK_LIB)/hal.lib \
295 $(PATH_STAGE_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB)
296
297 #VBoxDrv_LDFLAGS.darwin = -v -Wl,-whyload -Wl,-v -Wl,-whatsloaded
298 VBoxDrv_LDFLAGS.solaris += -N misc/ctf
299 VBoxDrv_LDFLAGS.solaris += -N misc/dtrace
300 VBoxDrv_LDFLAGS.win.x86 = -Entry:DriverEntry@8
301 VBoxDrv_LDFLAGS.win.amd64= -Entry:DriverEntry
302
303 VBoxDrv_SOURCES.darwin = darwin/SUPDrv-darwin.cpp
304 VBoxDrv_SOURCES.solaris = \
305 solaris/SUPDrv-solaris.c
306 VBoxDrv_SOURCES.win = \
307 win/SUPDrv-win.cpp \
308 win/SUPDrvA-win.asm \
309 win/VBoxDrv.rc
310 VBoxDrv_SOURCES = \
311 SUPDrv.c \
312 SUPDrvSem.c \
313 SUPDrvTracer.cpp \
314 SUPDrv.d
315 ifdef VBOX_WITH_NATIVE_DTRACE_R0DRV
316 VBoxDrv_SOURCES += \
317 SUPDrv-dtrace.cpp
318 SUPDrv-dtrace.cpp_DEFS.darwin += VBOX_PATH_MACOSX_DTRACE_H=\"$(VBOX_PATH_MACOSX_SDK)/usr/include/sys/dtrace.h\"
319 endif
320 ifn1of ($(KBUILD_TARGET), linux freebsd)
321 VBoxDrv_SOURCES += \
322 SUPDrvTracerA.asm
323 endif
324 ifndef VBOX_LINUX_VERSION_2_4
325 VBoxDrv_SOURCES.linux += \
326 linux/SUPDrv-linux.mod.c
327 endif
328
329endif
330
331
332
333if1of ($(KBUILD_TARGET), darwin)
334 # Files necessary to make a darwin kernel extension bundle.
335 INSTALLS.darwin += VBoxDrv.kext
336 VBoxDrv.kext_INST = $(INST_VBOXDRV)Contents/
337 VBoxDrv.kext_SOURCES = $(VBoxDrv.kext_0_OUTDIR)/Info.plist
338 VBoxDrv.kext_CLEAN = $(VBoxDrv.kext_0_OUTDIR)/Info.plist
339
340$$(VBoxDrv.kext_0_OUTDIR)/Info.plist: \
341 $(PATH_SUB_CURRENT)/darwin/Info.plist \
342 $(VBOX_VERSION_MK) | $$(dir $$@)
343 $(call MSG_GENERATE,VBoxDrv,$@,$<)
344 $(QUIET)$(RM) -f $@
345 $(QUIET)$(SED) \
346 -e 's/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g' \
347 -e 's/@VBOX_VERSION_MAJOR@/$(VBOX_VERSION_MAJOR)/g' \
348 -e 's/@VBOX_VERSION_MINOR@/$(VBOX_VERSION_MINOR)/g' \
349 -e 's/@VBOX_VERSION_BUILD@/$(VBOX_VERSION_BUILD)/g' \
350 -e 's/@VBOX_VENDOR@/$(VBOX_VENDOR)/g' \
351 -e 's/@VBOX_PRODUCT@/$(VBOX_PRODUCT)/g' \
352 -e 's/@VBOX_C_YEAR@/$(VBOX_C_YEAR)/g' \
353 --output $@ \
354 $<
355endif
356
357
358if1of ($(KBUILD_TARGET), darwin solaris)
359 # Common manual loader script.
360 INSTALLS += SUPDrvScripts
361 SUPDrvScripts_INST = $(INST_DIST)
362 SUPDrvScripts_EXEC_SOURCES = \
363 $(KBUILD_TARGET)/load.sh
364endif
365
366
367if1of ($(KBUILD_TARGET), linux)
368 #
369 # Targets for installing the linux sources.
370 #
371 vboxdrv-mod_INST = bin/src/vboxdrv/
372 vboxdrv-mod_SOURCES = \
373 $(subst $(DQUOTE),,$(FILES_VBOXDRV_NOBIN)) \
374 $(vboxdrv-mod_0_OUTDIR)/Makefile
375 vboxdrv-mod_EXEC_SOURCES = \
376 $(subst $(DQUOTE),,$(FILES_VBOXDRV_BIN)) \
377 $(PATH_ROOT)/src/VBox/HostDrivers/linux/do_Module.symvers
378 vboxdrv-mod_CLEAN = \
379 $(vboxdrv-mod_0_OUTDIR)/Makefile \
380 $(PATH_TARGET)/vboxdrv-mod-1.dep \
381
382 # Scripts needed for building the kernel modules
383 includedep $(PATH_TARGET)/vboxdrv-mod-1.dep
384 $$(vboxdrv-mod_0_OUTDIR)/Makefile: \
385 $(PATH_SUB_CURRENT)/linux/Makefile \
386 $$(if $$(eq $$(Support/linux/Makefile_VBOX_HARDENED),$$(VBOX_WITH_HARDENING)),,FORCE) \
387 | $$(dir $$@)
388 $(call MSG_TOOL,Creating,,$@)
389 ifndef VBOX_WITH_HARDENING
390 $(QUIET)$(SED) -e "s;-DVBOX_WITH_HARDENING;;g" --output $@ $<
391 else
392 $(QUIET)$(CP) -f $< $@
393 endif
394 %$(QUIET2)$(APPEND) -t '$(PATH_TARGET)/vboxdrv-mod-1.dep' 'Support/linux/Makefile_VBOX_HARDENED=$(VBOX_WITH_HARDENING)'
395endif # real linux
396
397
398ifeq ($(KBUILD_TARGET), win)
399 INSTALLS.win += VBoxDrv-inf
400 VBoxDrv-inf_INST = $(INST_BIN)
401 VBoxDrv-inf_MODE = a+r,u+w
402 VBoxDrv-inf_SOURCES = \
403 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.inf
404 VBoxDrv-inf_CLEAN = $(VBoxDrv-inf_SOURCES)
405 VBoxDrv-inf_BLDDIRS = $(PATH_TARGET)/VBoxDrvCat.dir
406
407 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.inf: $(PATH_SUB_CURRENT)/win/VBoxDrv.inf $(MAKEFILE_CURRENT) | $$(dir $$@)
408 $(call MSG_GENERATE,VBoxDrv-inf,$@,$<)
409 $(call VBOX_EDIT_INF_FN,$<,$@)
410
411 ifdef VBOX_SIGNING_MODE
412 VBoxDrv-inf_SOURCES += \
413 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.sys \
414 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.cat
415
416 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.sys: $$(VBoxDrv_1_TARGET) | $$(dir $$@)
417 $(INSTALL) -m 644 $< $(@D)
418
419 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.cat: \
420 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.inf \
421 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.sys
422 $(call MSG_TOOL,Inf2Cat,VBoxDrv-inf,$@,$<)
423 $(call VBOX_MAKE_CAT_FN, $(@D),$@)
424 endif # signing
425endif # win
426
427
428endif # !VBOX_ONLY_DOCS && !VBOX_ONLY_EXTPACKS && !VBOX_ONLY_TESTSUITE
429include $(KBUILD_PATH)/subfooter.kmk
430
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