summaryrefslogtreecommitdiffstats
path: root/src/VBox/HostDrivers/VBoxUSB/win/Makefile.kmk
blob: 4f408276f490842fecea51cbd4896a2d0271afe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# $Id: Makefile.kmk $
## @file
# Sub-Makefile for the Windows USB drivers.
#

#
# Copyright (C) 2006-2022 Oracle and/or its affiliates.
#
# This file is part of VirtualBox base platform packages, as
# available from https://www.virtualbox.org.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, in version 3 of the
# License.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <https://www.gnu.org/licenses>.
#
# The contents of this file may alternatively be used under the terms
# of the Common Development and Distribution License Version 1.0
# (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
# in the VirtualBox distribution, in which case the provisions of the
# CDDL are applicable instead of those of the GPL.
#
# You may elect to license modified versions of this file under the
# terms and conditions of either the GPL or the CDDL or both.
#
# SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
#

SUB_DEPTH = ../../../../..
include $(KBUILD_PATH)/subheader.kmk

LIBRARIES.win += usbd
SYSMODS.win   += VBoxUSB VBoxUSBMon
PROGRAMS.win  += USBInstall USBUninstall USBTest
INSTALLS.win  += install-infs

#
# usbd
#
usbd_TEMPLATE       = VBOXR0DRV
usbd_SOURCES        = usbd/usbd.def

#
# VBoxUSB
#
VBoxUSB_TEMPLATE    = VBOXR0DRV
ifdef VBOX_SIGNING_MODE
 VBoxUSB_INSTTYPE   = none
 VBoxUSB_DEBUG_INSTTYPE = both
endif
VBoxUSB_SDKS        = ReorderCompilerIncs $(VBOX_WINDDK) $(VBOX_WINPSDK_INCS)
ifdef VBOX_WITH_AUTOMATIC_DEFS_QUOTING
 VBoxUSB_DEFS      := IN_RT_R0 IN_SUP_R0 VBOX_DBG_LOG_NAME="USBDev"
else
 VBoxUSB_DEFS      := IN_RT_R0 IN_SUP_R0 VBOX_DBG_LOG_NAME=\"USBDev\"
endif
VBoxUSB_LDFLAGS.x86 = -Entry:DriverEntry@8
VBoxUSB_LDFLAGS.amd64 = -Entry:DriverEntry
VBoxUSB_SOURCES     = \
	dev/VBoxUsbDev.cpp \
	dev/VBoxUsbRt.cpp \
	dev/VBoxUsbPnP.cpp \
	dev/VBoxUsbPwr.cpp \
	cmn/VBoxUsbTool.cpp \
	cmn/VBoxDrvTool.cpp \
	dev/VBoxUsbDev.rc
VBoxUSB_LIBS        = \
	$(PATH_SDK_$(VBOX_WINDDK)_LIB)/ntoskrnl.lib \
	$(PATH_SDK_$(VBOX_WINDDK)_LIB)/hal.lib \
	$(PATH_STAGE_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB) \
	$(usbd_1_TARGET)

#
# VBoxUSBMon
#
VBoxUSBMon_TEMPLATE    = VBOXR0DRV
ifdef VBOX_SIGNING_MODE
 VBoxUSBMon_INSTTYPE = none
 VBoxUSBMon_DEBUG_INSTTYPE = both
endif
VBoxUSBMon_INCS       := $(PATH_SUB_CURRENT)/..
VBoxUSBMon_SDKS        = ReorderCompilerIncs $(VBOX_WINDDK) $(VBOX_WINPSDK_INCS)
VBoxUSBMon_DEFS        = IN_RT_R0 IN_SUP_R0 NTDDI_WINNT=_NTDDI_VISTA VBOXUSBFILTERMGR_USB_SPINLOCK
ifdef VBOX_WITH_AUTOMATIC_DEFS_QUOTING
 VBoxUSBMon_DEFS      += VBOX_DBG_LOG_NAME="USBMon"
else
 VBoxUSBMon_DEFS      += VBOX_DBG_LOG_NAME=\"USBMon\"
endif
VBoxUSBMon_LDFLAGS.x86 = -Entry:DriverEntry@8
VBoxUSBMon_LDFLAGS.amd64 = -Entry:DriverEntry
ifdef VBOX_USBMON_WITH_FILTER_AUTOAPPLY
 VBoxUSBMon_DEFS      += VBOX_USBMON_WITH_FILTER_AUTOAPPLY
endif
VBoxUSBMon_SOURCES     = \
	mon/VBoxUsbMon.cpp  \
	mon/VBoxUsbFlt.cpp  \
	mon/VBoxUsbHook.cpp \
	cmn/VBoxUsbTool.cpp \
	cmn/VBoxDrvTool.cpp \
	../USBFilter.cpp \
	../VBoxUSBFilterMgr.cpp \
	mon/VBoxUsbMon.rc
VBoxUSBMon_LIBS        = \
	$(PATH_SDK_$(VBOX_WINDDK)_LIB)/ntoskrnl.lib \
	$(PATH_SDK_$(VBOX_WINDDK)_LIB)/hal.lib \
	$(PATH_STAGE_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB) \
	$(usbd_1_TARGET)
if1of ($(KBUILD_TYPE), debug)
VBoxUSBMon_DEFS      += LOG_ENABLED VBOX_USB_WITH_VERBOSE_LOGGING
endif

#
# Template for USBInstalls and friends.
#
TEMPLATE_VBoxUsbR3 = Template for USBInstalls, USBUninstall and USBTest
TEMPLATE_VBoxUsbR3_EXTENDS  = VBOXR3EXE
TEMPLATE_VBoxUsbR3_SDKS     = $(TEMPLATE_VBOXR3EXE_SDKS) ReorderCompilerIncs $(VBOX_WINPSDK) $(VBOX_WINDDK) VBOX_WIN_NEWDEV
TEMPLATE_VBoxUsbR3_CXXFLAGS = $(TEMPLATE_VBOXR3EXE_CXXFLAGS) -Gz
TEMPLATE_VBoxUsbR3_CFLAGS   = $(TEMPLATE_VBOXR3EXE_CFLAGS) -Gz
TEMPLATE_VBoxUsbR3_LIBS     = $(TEMPLATE_VBOXR3EXE_LIBS) \
	$(PATH_STAGE_LIB)/VBoxDrvCfgExe$(VBOX_SUFF_LIB) \
       $(LIB_RUNTIME)

#
# USBInstall
#
USBInstall_TEMPLATE = VBoxUsbR3
USBInstall_SOURCES  = Install/USBInstall.cpp

#
# USBUninstall
#
USBUninstall_TEMPLATE = VBoxUsbR3
USBUninstall_SOURCES  = Install/USBUninstall.cpp

#
# USBTest
#
USBTest_TEMPLATE = VBoxUsbR3
USBTest_DEFS     = IN_USBLIB
USBTest_SOURCES  = \
	testcase/USBTest.cpp \
	../USBFilter.cpp

#
# Install the INF files.
#
install-infs_TEMPLATE = VBoxR0DrvInfCat
install-infs_SOURCES = \
	$(PATH_TARGET)/VBoxUSBCat.dir/VBoxUSB.inf \
	$(PATH_TARGET)/VBoxUSBMonCat.dir/VBoxUSBMon.inf
install-infs_CLEAN = $(install-infs_SOURCES)
install-infs_BLDDIRS = \
	$(PATH_TARGET)/VBoxUSBCat.dir \
	$(PATH_TARGET)/VBoxUSBMonCat.dir

$(PATH_TARGET)/VBoxUSBCat.dir/VBoxUSB.inf: $(PATH_SUB_CURRENT)/dev/VBoxUSB.inf $(MAKEFILE_CURRENT) | $$(dir $$@)
	$(call MSG_GENERATE,install-infs,$@,$<)
	$(call VBOX_EDIT_INF_FN,$<,$@)

$(PATH_TARGET)/VBoxUSBMonCat.dir/VBoxUSBMon.inf: $(PATH_SUB_CURRENT)/mon/VBoxUSBMon.inf $(MAKEFILE_CURRENT) | $$(dir $$@)
	$(call MSG_GENERATE,install-infs,$@,$<)
	$(call VBOX_EDIT_INF_FN,$<,$@)

ifdef VBOX_SIGNING_MODE
install-infs_SOURCES += \
	$(PATH_TARGET)/VBoxUSBCat.dir/VBoxUSB.cat \
	$(PATH_TARGET)/VBoxUSBCat.dir/VBoxUSB.cat=>VBoxUSB-PreW10.cat \
	$(PATH_TARGET)/VBoxUSBCat.dir/VBoxUSB.sys \
	$(PATH_TARGET)/VBoxUSBMonCat.dir/VBoxUSBMon.cat \
	$(PATH_TARGET)/VBoxUSBMonCat.dir/VBoxUSBMon.cat=>VBoxUSBMon-PreW10.cat \
	$(PATH_TARGET)/VBoxUSBMonCat.dir/VBoxUSBMon.sys

$(PATH_TARGET)/VBoxUSBCat.dir/VBoxUSB.sys: $$(VBoxUSB_1_TARGET) | $$(dir $$@)
	$(INSTALL) -m 644 $< $(@D)

$(PATH_TARGET)/VBoxUSBCat.dir/VBoxUSB.cat: \
		$(PATH_TARGET)/VBoxUSBCat.dir/VBoxUSB.inf \
		$(PATH_TARGET)/VBoxUSBCat.dir/VBoxUSB.sys
	$(call MSG_TOOL,Inf2Cat,VBoxUSB-inf,$@,$<)
	$(call VBOX_MAKE_CAT_FN, $(@D),$@)

$(PATH_TARGET)/VBoxUSBMonCat.dir/VBoxUSBMon.sys: $$(VBoxUSBMon_1_TARGET) | $$(dir $$@)
	$(INSTALL) -m 644 $< $(@D)

$(PATH_TARGET)/VBoxUSBMonCat.dir/VBoxUSBMon.cat: \
		$(PATH_TARGET)/VBoxUSBMonCat.dir/VBoxUSBMon.inf \
		$(PATH_TARGET)/VBoxUSBMonCat.dir/VBoxUSBMon.sys
	$(call MSG_TOOL,Inf2Cat,VBoxUSBMon-inf,$@,$<)
	$(call VBOX_MAKE_CAT_FN, $(@D),$@)

endif # signing

# generate rules
include $(FILE_KBUILD_SUB_FOOTER)