VirtualBox

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

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

Partly reverted r89244 and r89245.

  • 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 48677 2013-09-25 11:05: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-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 SUPLibSem.cpp \
86 SUPLibTracerA.asm \
87 SUPR3HardenedIPRT.cpp \
88 SUPR3HardenedVerify.cpp \
89 $(KBUILD_TARGET)/SUPLib-$(KBUILD_TARGET).cpp
90
91SUPR3-x86_TEMPLATE = VBoxR3Dll-x86
92SUPR3-x86_EXTENDS = SUPR3
93
94
95#
96# Static version of SUPR3.
97#
98SUPR3Static_TEMPLATE = VBOXR3STATIC
99SUPR3Static_EXTENDS = SUPR3
100
101#
102# The static part of the hardened support library (ring-3).
103#
104SUPR3HardenedStatic_TEMPLATE = VBOXR3HARDENEDLIB
105SUPR3HardenedStatic_DEFS = IN_SUP_HARDENED_R3
106SUPR3HardenedStatic_DEFS += \
107 $(if $(VBOX_WITH_SUPSVC),VBOX_WITH_SUPSVC,) \
108 $(if $(VBOX_WITH_MAIN),VBOX_WITH_MAIN,) \
109 $(if $(VBOX_WITH_RAW_MODE),VBOX_WITH_RAW_MODE,)
110SUPR3HardenedStatic_INCS = .
111SUPR3HardenedStatic_SOURCES = \
112 SUPR3HardenedMain.cpp \
113 SUPR3HardenedVerify.cpp \
114 $(KBUILD_TARGET)/SUPLib-$(KBUILD_TARGET).cpp
115
116#
117# VBoxSupSvc - The system wide service/daemon.
118#
119VBoxSupSvc_TEMPLATE = VBOXR3EXE
120VBoxSupSvc_SOURCES = \
121 SUPSvc.cpp \
122 SUPSvcGlobal.cpp \
123 $(KBUILD_TARGET)/SUPSvc-$(KBUILD_TARGET).cpp
124if1of ($(KBUILD_TARGET), win)
125 VBoxSupSvc_SOURCES += \
126 SUPSvcGrant.cpp
127endif
128ifn1of ($(KBUILD_TARGET), win)
129 VBoxSupSvc_SOURCES += \
130 SUPSvcMain-posix.cpp
131endif
132VBoxSupSvc_LIBS = \
133 $(LIB_RUNTIME)
134
135
136#
137# SUPR0 - The Ring-0 Import library.
138#
139SUPR0_TEMPLATE = VBoxR0
140if1of ($(VBOX_LDR_FMT), pe lx)
141 SUPR0_SOURCES = $(SUPR0_0_OUTDIR)/SUPR0.def
142 SUPR0_CLEAN = $(SUPR0_0_OUTDIR)/SUPR0.def
143$$(SUPR0_0_OUTDIR)/SUPR0.def: \
144 $(PATH_SUB_CURRENT)/SUPDrv.c \
145 $(PATH_SUB_CURRENT)/SUPR0-def-$(VBOX_LDR_FMT).sed \
146 | $$(dir $$@)
147 $(SED) \
148 -f $(dir $<)/SUPR0-def-$(VBOX_LDR_FMT).sed \
149 --output $@ \
150 $<
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 = ReorderCompilerIncs $(VBOX_WINDDK) $(VBOX_WINPSDK)INCS
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 win)
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.win = none
259 VBoxDrv_DEBUG_INSTTYPE.win = both
260 endif
261 VBoxDrv_INST.darwin = $(INST_VBOXDRV)Contents/MacOS/
262 VBoxDrv_DEBUG_INST.darwin= $(patsubst %/,%,$(INST_VBOXDRV))
263 VBoxDrv_SDKS.win = ReorderCompilerIncs $(VBOX_WINDDK) $(VBOX_WINPSDK)INCS
264
265 VBoxDrv_DEFS := IN_RT_R0 IN_SUP_R0 SUPDRV_WITH_RELEASE_LOGGER VBOX_SVN_REV=$(VBOX_SVN_REV)
266 ifdef VBOX_WITH_DTRACE_R0DRV
267 VBoxDrv_DEFS += VBOX_WITH_DTRACE VBOX_WITH_DTRACE_R0DRV
268 endif
269 #VBoxDrv_DEFS.debug += DEBUG_DARWIN_GIP
270 VBoxDrv_DEFS.darwin := VBOX_WITH_HOST_VMX
271 VBoxDrv_DEFS.linux := \
272 KBUILD_MODNAME=KBUILD_STR\(vboxdrv\) KBUILD_BASENAME=KBUILD_STR\(vboxdrv\) MODULE CONFIG_VBOXDRV_AS_MISC
273 ifdef VBOX_LINUX_VERSION_2_4
274 VBoxDrv_DEFS.linux += EXPORT_SYMTAB
275 endif
276 ifdef VBOX_WITH_NETFLT
277 VBoxDrv_DEFS.solaris += VBOX_WITH_NETFLT
278 endif
279 ifdef VBOX_WITH_NATIVE_SOLARIS_LOADING
280 VBoxDrv_DEFS.solaris += VBOX_WITH_NATIVE_SOLARIS_LOADING
281 endif
282 ifdef VBOX_WITHOUT_NATIVE_R0_LOADER
283 VBoxDrv_DEFS.win += VBOX_WITHOUT_NATIVE_R0_LOADER
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_$(VBOX_WINDDK)_LIB)/ntoskrnl.lib \
294 $(PATH_SDK_$(VBOX_WINDDK)_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 ifdef VBOX_WITH_NATIVE_DTRACE
300 VBoxDrv_LDFLAGS.solaris += -N drv/dtrace
301 endif
302 VBoxDrv_LDFLAGS.win.x86 = -Entry:DriverEntry@8
303 VBoxDrv_LDFLAGS.win.amd64= -Entry:DriverEntry
304
305 VBoxDrv_SOURCES.darwin = \
306 darwin/SUPDrv-darwin.cpp
307 VBoxDrv_SOURCES.linux = \
308 linux/SUPDrv-linux.c
309 VBoxDrv_SOURCES.solaris = \
310 solaris/SUPDrv-solaris.c
311 VBoxDrv_SOURCES.win = \
312 win/SUPDrv-win.cpp \
313 win/SUPDrvA-win.asm \
314 win/VBoxDrv.rc
315 VBoxDrv_SOURCES = \
316 SUPDrv.d \
317 SUPDrv.c \
318 SUPDrvSem.c \
319 SUPDrvTracer.cpp
320 ifdef VBOX_WITH_NATIVE_DTRACE
321 VBoxDrv_SOURCES += \
322 SUPDrv-dtrace.cpp
323 SUPDrv-dtrace.cpp_DEFS.darwin += VBOX_PATH_MACOSX_DTRACE_H=\"$(VBOX_PATH_MACOSX_SDK)/usr/include/sys/dtrace.h\"
324 endif
325 ifn1of ($(KBUILD_TARGET), linux freebsd)
326 VBoxDrv_SOURCES += \
327 SUPDrvTracerA.asm
328 endif
329 ifndef VBOX_LINUX_VERSION_2_4
330 VBoxDrv_SOURCES.linux += \
331 linux/SUPDrv-linux.mod.c
332 endif
333
334endif
335
336
337
338if1of ($(KBUILD_TARGET), darwin)
339 # Files necessary to make a darwin kernel extension bundle.
340 INSTALLS.darwin += VBoxDrv.kext
341 VBoxDrv.kext_INST = $(INST_VBOXDRV)Contents/
342 VBoxDrv.kext_SOURCES = $(VBoxDrv.kext_0_OUTDIR)/Info.plist
343 VBoxDrv.kext_CLEAN = $(VBoxDrv.kext_0_OUTDIR)/Info.plist
344
345$$(VBoxDrv.kext_0_OUTDIR)/Info.plist: \
346 $(PATH_SUB_CURRENT)/darwin/Info.plist \
347 $(VBOX_VERSION_MK) | $$(dir $$@)
348 $(call MSG_GENERATE,VBoxDrv,$@,$<)
349 $(QUIET)$(RM) -f $@
350 $(QUIET)$(SED) \
351 -e 's/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g' \
352 -e 's/@VBOX_VERSION_MAJOR@/$(VBOX_VERSION_MAJOR)/g' \
353 -e 's/@VBOX_VERSION_MINOR@/$(VBOX_VERSION_MINOR)/g' \
354 -e 's/@VBOX_VERSION_BUILD@/$(VBOX_VERSION_BUILD)/g' \
355 -e 's/@VBOX_VENDOR@/$(VBOX_VENDOR)/g' \
356 -e 's/@VBOX_PRODUCT@/$(VBOX_PRODUCT)/g' \
357 -e 's/@VBOX_C_YEAR@/$(VBOX_C_YEAR)/g' \
358 --output $@ \
359 $<
360endif
361
362
363if1of ($(KBUILD_TARGET), darwin solaris)
364 # Common manual loader script.
365 INSTALLS += SUPDrvScripts
366 SUPDrvScripts_INST = $(INST_DIST)
367 SUPDrvScripts_EXEC_SOURCES = \
368 $(KBUILD_TARGET)/load.sh
369endif
370
371
372if1of ($(KBUILD_TARGET), linux)
373 #
374 # Targets for installing the linux sources.
375 #
376 vboxdrv-mod_INST = bin/src/vboxdrv/
377 vboxdrv-mod_SOURCES = \
378 $(subst $(DQUOTE),,$(FILES_VBOXDRV_NOBIN)) \
379 $(vboxdrv-mod_0_OUTDIR)/Makefile
380 vboxdrv-mod_EXEC_SOURCES = \
381 $(subst $(DQUOTE),,$(FILES_VBOXDRV_BIN)) \
382 $(PATH_ROOT)/src/VBox/HostDrivers/linux/do_Module.symvers
383 vboxdrv-mod_CLEAN = \
384 $(vboxdrv-mod_0_OUTDIR)/Makefile \
385 $(PATH_TARGET)/vboxdrv-mod-1.dep \
386
387 # Scripts needed for building the kernel modules
388 includedep $(PATH_TARGET)/vboxdrv-mod-1.dep
389 $$(vboxdrv-mod_0_OUTDIR)/Makefile: \
390 $(PATH_SUB_CURRENT)/linux/Makefile \
391 $$(if $$(eq $$(Support/linux/Makefile_VBOX_HARDENED),$$(VBOX_WITH_HARDENING)),,FORCE) \
392 | $$(dir $$@)
393 $(call MSG_TOOL,Creating,,$@)
394 ifndef VBOX_WITH_HARDENING
395 $(QUIET)$(SED) -e "s;-DVBOX_WITH_HARDENING;;g" --output $@ $<
396 else
397 $(QUIET)$(CP) -f $< $@
398 endif
399 %$(QUIET2)$(APPEND) -t '$(PATH_TARGET)/vboxdrv-mod-1.dep' 'Support/linux/Makefile_VBOX_HARDENED=$(VBOX_WITH_HARDENING)'
400endif # real linux
401
402
403ifeq ($(KBUILD_TARGET), win)
404 INSTALLS.win += VBoxDrv-inf
405 VBoxDrv-inf_INST = $(INST_BIN)
406 VBoxDrv-inf_MODE = a+r,u+w
407 VBoxDrv-inf_SOURCES = \
408 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.inf
409 VBoxDrv-inf_CLEAN = $(VBoxDrv-inf_SOURCES)
410 VBoxDrv-inf_BLDDIRS = $(PATH_TARGET)/VBoxDrvCat.dir
411
412 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.inf: $(PATH_SUB_CURRENT)/win/VBoxDrv.inf $(MAKEFILE_CURRENT) | $$(dir $$@)
413 $(call MSG_GENERATE,VBoxDrv-inf,$@,$<)
414 $(call VBOX_EDIT_INF_FN,$<,$@)
415
416 ifdef VBOX_SIGNING_MODE
417 VBoxDrv-inf_SOURCES += \
418 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.sys \
419 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.cat
420
421 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.sys: $$(VBoxDrv_1_TARGET) | $$(dir $$@)
422 $(INSTALL) -m 644 $< $(@D)
423
424 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.cat: \
425 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.inf \
426 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.sys
427 $(call MSG_TOOL,Inf2Cat,VBoxDrv-inf,$@,$<)
428 $(call VBOX_MAKE_CAT_FN, $(@D),$@)
429 endif # signing
430endif # win
431
432
433endif # !VBOX_ONLY_DOCS && !VBOX_ONLY_EXTPACKS && !VBOX_ONLY_TESTSUITE
434include $(FILE_KBUILD_SUB_FOOTER)
435
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