VirtualBox

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

Last change on this file since 11878 was 11878, checked in by vboxsync, 16 years ago

Support/Makefile: Reformat linux/Makefile when VBOX_WITH_HARDENING changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.7 KB
Line 
1# $Id: Makefile.kmk 11878 2008-08-31 11:38:34Z vboxsync $
2## @file
3# Sub-Makefile for the support library and the drivers/modules/kexts it uses.
4#
5
6#
7# Copyright (C) 2006-2007 Sun Microsystems, Inc.
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# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27# Clara, CA 95054 USA or visit http://www.sun.com if you need
28# additional information or have any questions.
29#
30
31ifdef VBOX_KBUILD_HACKING
32SUB_DEPTH = ../../../..
33else
34SUB_DEPTH = ..
35DEPTH ?= ../../../..
36endif
37include $(KBUILD_PATH)/subheader.kmk
38
39#
40# Targets
41#
42LIBRARIES += SUPR3 SUPR3HardenedStatic
43ifndef VBOX_ONLY_DOCS
44 ifeq ($(filter-out pe lx,$(VBOX_LDR_FMT)),)
45 LIBRARIES += SUPR0
46 endif
47 ifdef VBOX_WITH_SUPSVC
48 PROGRAMS += VBoxSupSvc
49 endif
50 ifdef VBOX_WITH_VBOXDRV
51 LIBRARIES += SUPR0IdcClient
52 SYSMODS.darwin += VBoxDrv
53 SYSMODS.freebsd += vboxdrv
54 SYSMODS.linux += vboxdrv
55 SYSMODS.win += VBoxDrv
56 SYSMODS.os2 += VBoxDrv
57 SYSMODS.solaris += vboxdrv
58 OTHERS.linux += \
59 $(PATH_BIN)/src/build_in_tmp \
60 $(PATH_BIN)/src/Makefile \
61 $(if $(VBOX_OSE),,$(PATH_BIN)/src/dkms.conf)
62 endif
63 INSTALLS.linux += vboxmod-bin vboxmod-sh
64
65 #
66 # Include sub-makefile(s).
67 #
68 include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk
69
70 #
71 # Populate FILES_VBOXDRV_NOBIN and FILES_VBOXDRV_BIN
72 #
73 include $(PATH_SUB_CURRENT)/linux/files_vboxdrv
74endif # !VBOX_ONLY_DOCS
75
76vboxmod-bin_INST = bin/src/
77vboxmod-bin_MODE = a+r,u+w
78vboxmod-bin_SOURCES = $(subst ",,$(FILES_VBOXDRV_NOBIN)) #"
79
80vboxmod-sh_INST = bin/src/
81vboxmod-sh_MODE = a+rx,u+w
82vboxmod-sh_SOURCES = $(subst ",,$(FILES_VBOXDRV_BIN)) #"
83vboxmod-sh_CLEAN = $(PATH_TARGET)/vboxmod-sh-1.dep
84
85# Scripts needed for building the kernel modules
86## @todo generate these else where and move them from OTHERS to vboxmod-bin (which btw installs NOBIN files contrary to its name).
87
88$(PATH_BIN)/src/build_in_tmp: \
89 $(PATH_SUB_CURRENT)/linux/build_in_tmp \
90 $(VBOX_VERSION_STAMP)
91 $(call MSG_TOOL,Creating,,$@)
92 $(QUIET)$(SED) -e "s;_VERSION_;${VBOX_VERSION_STRING};g; s;_MODULE_;vboxdrv;g" --output $@ $<
93 $(QUIET)chmod 0755 $@
94
95$(PATH_BIN)/src/dkms.conf: \
96 $(PATH_SUB_CURRENT)/linux/dkms.conf \
97 $(VBOX_VERSION_STAMP)
98 $(call MSG_TOOL,Creating,,$@)
99 $(QUIET)$(SED) -e "s;_VERSION_;${VBOX_VERSION_STRING};g" --output $@ $<
100
101-include $(PATH_TARGET)/vboxmod-1.dep
102$(PATH_BIN)/src/Makefile: \
103 $(PATH_SUB_CURRENT)/linux/Makefile \
104 $$(if $$(eq $$(Support/linux/Makefile_HARDENED),$$(VBOX_WITH_HARDENING)),,FORCE) \
105 | $(call DIRDEP,$(PATH_TARGET))
106 $(call MSG_TOOL,Creating,,$@)
107ifdef VBOX_WITH_HARDENING
108 $(QUIET)$(SED) -e "s;-DVBOX_WITH_HARDENING;;g" --output $@ $<
109else
110 $(QUIET)$(CP) -f $< $@
111endif
112 %$(QUIET2)$(RM) -f -- $(PATH_TARGET)/vboxmod-1.dep
113 %$(QUIET2)$(APPEND) '$(PATH_TARGET)/vboxmod-1.dep' 'Support/linux/Makefile_HARDENED=$(VBOX_WITH_HARDENING)'
114
115
116#
117# The Ring-3 Support Library (this is linked into the IPRT dll, VBoxRT).
118#
119ifneq ($(filter l4%,$(KBUILD_TARGET) $(BUILD_TARGET_SUB)),)
120 # L4 has trouble with -pedantic. It also make trouble when inlining is not enabled.
121 SUPR3_TEMPLATE = VBOXR3NP
122else
123 SUPR3_TEMPLATE = VBOXR3
124endif
125SUPR3_DEFS = IN_SUP_R3 IN_RT_R3
126ifdef VBOX_WITH_IDT_PATCHING
127 SUPR3_DEFS += VBOX_WITH_IDT_PATCHING
128endif
129ifdef VBOX_WITH_SUPSVC
130 SUPR3_DEFS += VBOX_WITH_SUPSVC
131endif
132SUPR3_INCS := $(PATH_SUB_CURRENT)
133SUPR3_INCS.l4 = $(L4_INCDIR)
134SUPR3_SOURCES = \
135 SUPLib.cpp \
136 SUPR3HardenedIPRT.cpp \
137 SUPR3HardenedVerify.cpp \
138 $(KBUILD_TARGET)/SUPLib-$(KBUILD_TARGET).cpp
139
140
141#
142# The static part of the hardened support library (ring-3).
143#
144SUPR3HardenedStatic_TEMPLATE = VBOXR3HARDENEDLIB
145SUPR3HardenedStatic_DEFS = IN_SUP_HARDENED_R3
146ifdef VBOX_WITH_SUPSVC
147 SUPR3HardenedStatic_DEFS += VBOX_WITH_SUPSVC
148endif
149SUPR3HardenedStatic_INCS = .
150SUPR3HardenedStatic_SOURCES = \
151 SUPR3HardenedMain.cpp \
152 SUPR3HardenedVerify.cpp \
153 $(KBUILD_TARGET)/SUPLib-$(KBUILD_TARGET).cpp
154
155
156#
157# VBoxSupSvc - The system wide service/daemon.
158#
159VBoxSupSvc_TEMPLATE = VBOXR3EXE
160VBoxSupSvc_SOURCES = \
161 SUPSvc.cpp \
162 SUPSvcGlobal.cpp \
163 $(KBUILD_TARGET)/SUPSvc-$(KBUILD_TARGET).cpp
164if1of ($(KBUILD_TARGET), win)
165 VBoxSupSvc_SOURCES += \
166 SUPSvcGrant.cpp
167endif
168ifn1of ($(KBUILD_TARGET), win)
169 VBoxSupSvc_SOURCES += \
170 SUPSvcMain-posix.cpp
171endif
172VBoxSupSvc_LIBS = \
173 $(LIB_RUNTIME)
174
175
176#
177# SUPR0 - The Ring-0 Import / Thunk library.
178#
179SUPR0_TEMPLATE = VBOXR0
180ifeq ($(VBOX_LDR_FMT),pe)
181 SUPR0_SOURCES += SUPR0.def
182endif
183ifeq ($(VBOX_LDR_FMT),lx)
184SUPR0_SOURCES += $(PATH_TARGET)/SUPR0.def
185$(PATH_TARGET)/SUPR0.def: $(PATH_SUB_CURRENT)/SUPR0.def | $(call DIRDEP,$(PATH_TARGET))
186 $(SED) -e 's/^[ \t][ \t]*\([gA-Z]\)/ _\1/' -e 's/[ \t]DATA[ \t]*/ /' $< > [email protected]
187 $(MV) -f [email protected] $@
188endif
189
190
191#
192# SUPR0IdcClient - The Ring-0 IDC client driver library.
193#
194SUPR0IdcClient_TEMPLATE = VBOXR0DRV
195SUPR0IdcClient_DEFS = IN_RT_R0 IN_SUP_R0 IN_SUP_STATIC
196SUPR0IdcClient_SDKS.win = W2K3DDK WINPSDKINCS
197SUPR0IdcClient_SOURCES.$(KBUILD_TARGET) = \
198 $(KBUILD_TARGET)/SUPR0IdcClient-$(KBUILD_TARGET).c
199SUPR0IdcClient_SOURCES = \
200 SUPR0IdcClient.c \
201 SUPR0IdcClientComponent.c \
202 SUPR0IdcClientStubs.c
203
204
205#
206# VBoxDrv.sys - The Windows driver.
207#
208## @todo consoliate all the targets into a single mess.
209ifeq ($(KBUILD_TARGET),win)
210VBoxDrv_TEMPLATE = VBOXR0DRV
211ifdef VBOX_SIGNING_MODE
212 VBoxDrv_NOINST = true
213endif
214VBoxDrv_DEFS = IN_RT_R0 IN_SUP_R0 SUPDRV_WITH_RELEASE_LOGGER
215ifdef VBOX_WITH_IDT_PATCHING
216 VBoxDrv_DEFS += VBOX_WITH_IDT_PATCHING
217endif
218VBoxDrv_SDKS = W2K3DDK WINPSDKINCS
219VBoxDrv_INCS := $(PATH_SUB_CURRENT)
220VBoxDrv_SOURCES = \
221 win/SUPDrv-win.cpp \
222 win/SUPDrvA-win.asm \
223 SUPDrv.c
224VBoxDrv_LDFLAGS.x86 = -Entry:DriverEntry@8
225VBoxDrv_LDFLAGS.amd64 = -Entry:DriverEntry
226VBoxDrv_LIBS = \
227 $(PATH_SDK_W2K3DDK_LIB)/ntoskrnl.lib \
228 $(PATH_SDK_W2K3DDK_LIB)/hal.lib \
229 $(PATH_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB)
230
231
232INSTALLS += VBoxDrv-inf
233VBoxDrv-inf_INST = $(INST_BIN)
234VBoxDrv-inf_MODE = a+r,u+w
235VBoxDrv-inf_SOURCES = \
236 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.inf
237VBoxDrv-inf_CLEAN = $(VBoxDrv-inf_SOURCES)
238VBoxDrv-inf_BLDDIRS = $(PATH_TARGET)/VBoxDrvCat.dir
239
240$(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.inf: $(PATH_SUB_CURRENT)/win/VBoxDrv.inf $(MAKEFILE_CURRENT) | $$(call DIRDEP,$$(@D))
241 $(call MSG_GENERATE,VBoxDrv-inf,$@,$<)
242 $(call VBOX_EDIT_INF_FN,$<,$@)
243
244 ifdef VBOX_SIGNING_MODE
245VBoxDrv-inf_SOURCES += \
246 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.sys \
247 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.cat
248
249$(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.sys: $$(TARGET_VBoxDrv) | $$(call DIRDEP,$$(@D))
250 $(INSTALL) -m 644 $< $(@D)
251
252$(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.cat: \
253 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.inf \
254 $(PATH_TARGET)/VBoxDrvCat.dir/VBoxDrv.cat
255 $(call MSG_TOOL,Inf2Cat,VBoxDrv-inf,$@,$<)
256 $(call VBOX_MAKE_CAT_FN, $(@D),$@)
257 endif # signing
258endif # win
259
260
261#
262# vboxdrv.ko - The Linux Kernel Module (syntax only).
263#
264ifeq ($(KBUILD_TARGET),linux)
265vboxdrv_TEMPLATE = VBOXR0DRV
266vboxdrv_DEFS = KBUILD_MODNAME=KBUILD_STR\(vboxdrv\) KBUILD_BASENAME=KBUILD_STR\(vboxdrv\) MODULE IN_RT_R0 IN_SUP_R0 CONFIG_VBOXDRV_AS_MISC
267ifdef VBOX_WITH_IDT_PATCHING
268vboxdrv_DEFS += VBOX_WITH_IDT_PATCHING
269endif
270ifdef VBOX_LINUX_VERSION_2_4
271vboxdrv_DEFS += EXPORT_SYMTAB
272endif
273vboxdrv_INCS := \
274 $(PATH_SUB_CURRENT) \
275 $(PATH_ROOT)/src/VBox/Runtime/r0drv/linux
276vboxdrv_LIBS = $(PATH_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB)
277vboxdrv_LIBS.debug = $(vboxdrv_LIBS) $(VBOX_GCC_LIBGCC)
278vboxdrv_SOURCES = \
279 $(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).c \
280 SUPDrv.c
281ifndef VBOX_LINUX_VERSION_2_4
282vboxdrv_SOURCES += \
283 $(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).mod.c
284endif
285endif # real linux
286
287
288#
289# VBoxDrv.kext - The Darwin Kernel Extension.
290#
291ifeq ($(KBUILD_TARGET),darwin)
292VBoxDrv_TEMPLATE = VBOXR0DRV
293VBoxDrv_DEFS = IN_RT_R0 IN_SUP_R0 SUPDRV_WITH_RELEASE_LOGGER VBOX_SVN_REV=$(VBOX_SVN_REV)
294ifdef VBOX_WITH_IDT_PATCHING
295VBoxDrv_DEFS += VBOX_WITH_IDT_PATCHING
296endif
297VBoxDrv_DEFS += DEBUG_DARWIN_GIP
298VBoxDrv_INCS := $(PATH_SUB_CURRENT)
299VBoxDrv_LIBS = $(PATH_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB)
300VBoxDrv_LDFLAGS = -v -Wl,-whyload -Wl,-v -Wl,-whatsloaded
301VBoxDrv_INST = $(INST_VBOXDRV)Contents/MacOS/
302VBoxDrv_SOURCES = \
303 SUPDrv.c \
304 $(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).cpp
305
306INSTALLS += VBoxDrv.kext
307VBoxDrv.kext_INST = $(INST_VBOXDRV)Contents/
308VBoxDrv.kext_SOURCES = \
309 $(PATH_TARGET)/VBoxDrv/Info.plist
310VBoxDrv.kext_CLEAN = \
311 $(PATH_TARGET)/VBoxDrv/Info.plist
312
313$(PATH_TARGET)/VBoxDrv/Info.plist: $(PATH_SUB_CURRENT)/darwin/Info.plist $(VBOX_VERSION_MK) | $(call DIRDEP,$(PATH_TARGET)/VBoxDrv)
314 $(call MSG_GENERATE,VBoxDrv,$@,$<)
315 $(xQUIET)$(RM) -f $@
316 $(xQUIET)$(SED) \
317 -e 's/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g' \
318 -e 's/@VBOX_VERSION_MAJOR@/$(VBOX_VERSION_MAJOR)/g' \
319 -e 's/@VBOX_VERSION_MINOR@/$(VBOX_VERSION_MINOR)/g' \
320 -e 's/@VBOX_VERSION_BUILD@/$(VBOX_VERSION_BUILD)/g' \
321 $< > $@
322
323INSTALLS += Scripts
324Scripts_INST = $(INST_DIST)
325Scripts_SOURCES = \
326 darwin/load.sh
327
328endif # darwin
329
330
331#
332# VBoxDrv.sys - The OS/2 driver.
333#
334ifeq ($(KBUILD_TARGET),os2)
335VBoxDrv_TEMPLATE = VBOXR0DRV
336VBoxDrv_DEFS = IN_RT_R0 IN_SUP_R0
337VBoxDrv_INCS := $(PATH_SUB_CURRENT)
338#VBoxDrv_LDFLAGS = -s -t -v
339VBoxDrv_SOURCES = \
340 os2/SUPDrvA-os2.asm \
341 os2/SUPDrv-os2.def
342VBoxDrv_LIBS = \
343 $(TARGET_VBoxDrvLib) \
344 $(PATH_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB) \
345 $(VBOX_GCC_LIBGCC) \
346 end
347
348# temp hack to ensure that SUPDrvA-os2.asm is first in the link.
349LIBRARIES += VBoxDrvLib
350VBoxDrvLib_TEMPLATE = VBOXR0DRV
351VBoxDrvLib_NOINST = 1
352VBoxDrvLib_DEFS = IN_RT_R0 IN_SUP_R0
353VBoxDrvLib_INCS := \
354 $(PATH_SUB_CURRENT) \
355 $(PATH_TARGET) \
356 $(PATH_ROOT)/src/VBox/Runtime/include
357VBoxDrvLib_SOURCES = \
358 os2/SUPDrv-os2.cpp \
359 SUPDrv.c
360endif
361
362
363#
364# vboxdrv.ko - The FreeBSD Kernel Module.
365#
366ifeq ($(KBUILD_TARGET),freebsd)
367vboxdrv_TEMPLATE = VBOXR0DRV
368vboxdrv_DEFS = IN_RT_R0 IN_SUP_R0 SUPDRV_WITH_RELEASE_LOGGER VBOX_SVN_REV=$(VBOX_SVN_REV)
369ifdef VBOX_WITH_IDT_PATCHING
370vboxdrv_DEFS += VBOX_WITH_IDT_PATCHING
371endif
372vboxdrv_INCS := $(PATH_SUB_CURRENT)
373vboxdrv_LIBS = $(PATH_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB)
374vboxdrv_SOURCES := \
375 $(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).c \
376 $(PATH_SUB_CURRENT)/$(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).def \
377 SUPDrv.c
378## @todo the SUPDrv-freebsd.def is most probably gonna break it and require build system hacking...
379endif # freebsd
380
381
382#
383# vboxdrv.o - The Solaris Kernel Module.
384#
385ifeq ($(KBUILD_TARGET),solaris)
386vboxdrv_TEMPLATE = VBOXR0DRV
387vboxdrv_DEFS = IN_RT_R0 IN_SUP_R0
388ifdef VBOX_WITH_IDT_PATCHING
389vboxdrv_DEFS += VBOX_WITH_IDT_PATCHING
390endif
391vboxdrv_INCS := $(PATH_SUB_CURRENT)
392vboxdrv_LIBS = $(PATH_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB)
393vboxdrv_SOURCES = \
394 $(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).c \
395 SUPDrv.c
396endif # solaris
397
398
399#
400# SUPDrv.c needs the VBOX_SVN_REV.
401#
402SUPDrv.c_DEFS += VBOX_SVN_REV=$(VBOX_SVN_REV)
403
404
405include $(KBUILD_PATH)/subfooter.kmk
406
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