VirtualBox

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

Last change on this file since 49634 was 49634, checked in by vboxsync, 11 years ago

SUPDrv: Added an interface for probing MSRs.

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