3 # Some hacks to allow syntax and prerequisite include checking of headers.
4 # This makefile doesn't and shouldn't build successfully.
8 # Copyright (C) 2006-2024 Oracle and/or its affiliates.
10 # This file is part of VirtualBox base platform packages, as
11 # available from https://www.virtualbox.org.
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License
15 # as published by the Free Software Foundation, in version 3 of the
18 # This program is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, see <https://www.gnu.org/licenses>.
26 # SPDX-License-Identifier: GPL-3.0-only
30 include $(KBUILD_PATH
)/subheader.kmk
32 LIBRARIES
+= SyntaxVBoxIncludeR3 SyntaxVBoxIncludeR0
34 # Omit headers that are using C++ features and upsets gcc.
35 VBOX_HDRS_CPP_FEATURES
:= \
38 VBox
/vmm
/pdmaudioinline.h \
39 VBox
/vmm
/pdmaudiohostenuminline.h \
40 VBox
/HostServices
/GuestControlSvc.h \
41 VBox
/HostServices
/DragAndDropSvc.h \
42 VBox
/HostServices
/Service.h \
43 VBox
/GuestHost
/GuestControl.h \
44 VBox
/GuestHost
/DragAndDrop.h \
45 VBox
/GuestHost
/SharedClipboard-transfers.h \
49 VBox
/VBoxGuestLibSharedFoldersInline.h \
54 # Omit headers that are C++ and ring-3.
59 VBox
/vmm
/vmmr3vtable.h \
62 $(subst $(PATH_SUB_CURRENT
)/,,$(wildcard $(PATH_SUB_CURRENT
)/iprt
/*_cpp.h
))
64 # Ring-3 only headers.
65 VBOX_HDRS_R3_ONLY
:= \
69 VBox
/VBoxHDD-Plugin.h \
72 VBox
/VBoxNetCfg-win.h \
73 VBox
/VBoxDrvCfg-win.h \
76 $(if-expr
"$(KBUILD_TARGET)" == "win",VBox
/usblib.h
,) \
79 VBox
/vd-cache-backend.h \
81 VBox
/vd-ifs-internal.h \
82 VBox
/vd-image-backend.h \
84 VBox
/vd-filter-backend.h \
87 VBox
/vmm
/dbgfflowtrace.h \
90 VBox
/GuestHost
/SharedClipboard-transfers.h \
91 VBox
/GuestHost
/SharedClipboard-win.h \
92 VBox
/GuestHost
/SharedClipboard-x11.h \
93 VBox
/GuestHost
/DragAndDrop.h \
94 VBox
/HostServices
/Service.h \
95 VBox
/HostServices
/TstHGCMMock.h \
96 VBox
/HostServices
/TstHGCMMockUtils.h \
107 # Ring-0 driver only headers.
108 VBOX_HDRS_R0DRV_ONLY
:= \
109 VBox
/VBoxGuestLibSharedFolders.h \
110 VBox
/VBoxGuestLibSharedFoldersInline.h \
114 VBOX_HDRS_GCC_ONLY
:= \
118 # Headers to omit all together.
120 VBox
/HostServices
/glext.h \
121 VBox
/HostServices
/glxext.h \
122 VBox
/HostServices
/wglext.h \
123 $(if-expr
"$(KBUILD_TARGET)" != "linux", \
124 VBox
/GuestHost
/SharedClipboard-x11.h \
126 $(if-expr
"$(KBUILD_TARGET)" != "solaris", \
127 VBox
/usblib-solaris.h \
130 VBox
/VDEPlugSymDefs.h \
131 VBox
/VBoxNetCmn-win.h \
132 $(if-expr
"$(KBUILD_TARGET)" != "win", \
133 VBox
/com
/microatl.h \
134 VBox
/GuestHost
/SharedClipboard-win.h \
136 VBox
/VBoxDrvCfg-win.h \
137 VBox
/VBoxNetCfg-win.h \
138 iprt
/sanitized
/intrin.h \
139 ,$(VBOX_HDRS_GCC_ONLY
)) \
142 VBox
/xrandr-calls.h \
143 VBox
/VBoxKeyboard.h \
144 VBox
/VBoxLnxModInline.h \
145 VBox
/vmm
/pdmpcidevint.h \
146 VBox
/vmm
/vmmr3vtable-def.h \
147 VBox
/vmm
/cpumctx-x86-amd64.h \
148 VBox
/vmm
/cpumctx-armv8.h \
149 VBox
/vmm
/cpum-x86-amd64.h \
150 VBox
/vmm
/cpum-armv8.h \
151 VBox
/vmm
/iem-x86-amd64.h \
152 VBox
/vmm
/iem-armv8.h \
154 iprt
/runtime-loader.h \
156 $(subst $(PATH_SUB_CURRENT
)/,,$(wildcard $(PATH_SUB_CURRENT
)/iprt
/asm
*watcom
*.h
)) \
157 iprt
/asn1-generator
% \
161 $(foreach os
,$(filter-out $(KBUILD_TARGET
),$(KBUILD_OSES
)),iprt
/$(os
)/% VBox
/$(os
)/%) \
162 $(foreach arch
,$(KBUILD_ARCHES
),iprt
/nocrt
/$(arch
)/%)
164 # x86 / AMD64 only headers.
165 ifn1of
($(KBUILD_TARGET_ARCH
), x86 amd64
)
169 # AMD64 only headers.
170 ifneq ($(KBUILD_TARGET_ARCH
),amd64
)
173 VBox
/vmm
/cpumctx-v1_6.h \
174 VBox
/vmm
/dbgfcorefmt.h
177 ifn1of
($(KBUILD_TARGET_ARCH
), arm32 arm64
)
184 # We omit a few headers which have platform specific issues or are templates.
185 VBOX_HDRS_ALL
:= $(filter-out $(VBOX_HDRS_OMIT
), \
186 $(subst $(PATH_SUB_CURRENT
)/,,$(wildcard \
187 $(PATH_SUB_CURRENT
)/VBox
/*.h \
188 $(PATH_SUB_CURRENT
)/VBox
/*/*.h \
189 $(PATH_SUB_CURRENT
)/iprt
/*.h \
190 $(PATH_SUB_CURRENT
)/iprt
/*/*.h \
193 # ring-3, ring-0 and raw-mode context specific exclusions.
194 VBOX_HDRS_ALL_R3
:= $(filter-out $(VBOX_HDRS_R0DRV_ONLY
), $(VBOX_HDRS_ALL
))
195 if
"$(intersects $(KBUILD_TARGET_ARCH),$(VBOX_SUPPORTED_HOST_ARCHS))" == ""
196 ifeq ($(KBUILD_TARGET
),win
)
197 VBOX_HDRS_ALL_R3
:= $(filter-out VBox
/com
/VirtualBox.h VBox
/com
/listeners.h VBox
/settings.h
,$(VBOX_HDRS_ALL_R3
))
199 VBOX_HDRS_ALL_R3
:= $(filter-out VBox
/com
/% VBox
/settings.h
,$(VBOX_HDRS_ALL_R3
))
202 VBOX_HDRS_ALL_R3_C
:= $(filter-out $(VBOX_HDRS_CPP_FEATURES
) $(VBOX_HDRS_R3_CPP
), $(VBOX_HDRS_ALL_R3
))
203 VBOX_HDRS_ALL_R0
:= $(filter-out $(VBOX_HDRS_R3_CPP
) $(VBOX_HDRS_R3_ONLY
) $(VBOX_HDRS_R0DRV_ONLY
), $(VBOX_HDRS_ALL
))
204 VBOX_HDRS_ALL_R0_C
:= $(filter-out $(VBOX_HDRS_CPP_FEATURES
), $(VBOX_HDRS_ALL_R0
))
205 VBOX_HDRS_ALL_R0DRV
:= $(filter-out $(VBOX_HDRS_R3_CPP
) $(VBOX_HDRS_R3_ONLY
), $(VBOX_HDRS_ALL
))
206 VBOX_HDRS_ALL_R0DRV_C
:= $(filter-out $(VBOX_HDRS_CPP_FEATURES
), $(VBOX_HDRS_ALL_R0DRV
))
207 VBOX_HDRS_ALL_RC
:= $(filter-out \
208 VBox
/VBoxGuestLib.h \
215 $(VBOX_HDRS_R3_CPP
) \
216 $(VBOX_HDRS_R3_ONLY
) \
217 $(VBOX_HDRS_R0DRV_ONLY
) \
219 VBOX_HDRS_ALL_RC_C
:= $(filter-out $(VBOX_HDRS_CPP_FEATURES
), $(VBOX_HDRS_ALL_RC
))
220 #$(error $(subst $(SP),$(NLTAB),$(strip $(sort $(VBOX_HDRS_ALL_RC_C)))))
222 if1of
($(KBUILD_TARGET_ARCH
), $(VBOX_SUPPORTED_HOST_ARCHS
))
223 SyntaxVBoxIncludeR3_TEMPLATE
= VBoxMainExe
224 SyntaxVBoxIncludeR3_DEFS
= VBOX_WITH_HGCM
226 SyntaxVBoxIncludeR3_TEMPLATE
= VBoxR3Exe
227 SyntaxVBoxIncludeR3_SDKS.win
= ReorderCompilerIncs
$(VBOX_WINPSDK
) $(VBOX_WINDDK
)
229 SyntaxVBoxIncludeR3_DEFS
+= USING_VMM_COMMON_DEFS
230 SyntaxVBoxIncludeR3_CDEFS
= IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
231 SyntaxVBoxIncludeR3_SOURCES
:= \
232 $(addprefix $(PATH_OBJ
)/include/c
/, $(addsuffix .c
, $(basename $(VBOX_HDRS_ALL_R3_C
)))) \
233 $(addprefix $(PATH_OBJ
)/include/cpp/,$(addsuffix .
cpp,$(basename $(VBOX_HDRS_ALL_R3
))))
234 SyntaxVBoxIncludeR3_CLEAN
= $(SyntaxVBoxIncludeR3_SOURCES
)
235 #$(error $(subst $(SP),$(NLTAB),$(strip $(sort $(SyntaxVBoxIncludeR3_SOURCES)))))
237 SyntaxVBoxIncludeR0_TEMPLATE
= VBoxR0
238 SyntaxVBoxIncludeR0_DEFS
= VBOX_WITH_HGCM USING_VMM_COMMON_DEFS
239 SyntaxVBoxIncludeR0_CDEFS
= IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
240 SyntaxVBoxIncludeR0_SOURCES
:= \
241 $(addprefix $(PATH_OBJ
)/include/c
/, $(addsuffix .c
, $(basename $(VBOX_HDRS_ALL_R0_C
)))) \
242 $(addprefix $(PATH_OBJ
)/include/cpp/,$(addsuffix .
cpp,$(basename $(VBOX_HDRS_ALL_R0
))))
243 SyntaxVBoxIncludeR0_CLEAN
= $(SyntaxVBoxIncludeR0_SOURCES
)
245 if1of
($(KBUILD_TARGET
), darwin os2 solaris win
)
246 LIBRARIES
+= SyntaxVBoxIncludeR0Drv
247 SyntaxVBoxIncludeR0Drv_TEMPLATE
= VBoxR0DrvLib
248 SyntaxVBoxIncludeR0Drv_SDKS.win
= ReorderCompilerIncs
$(VBOX_WINDDK
) $(VBOX_WINPSDK_INCS
)
249 SyntaxVBoxIncludeR0Drv_DEFS
= VBOX_WITH_HGCM USING_VMM_COMMON_DEFS
250 SyntaxVBoxIncludeR0Drv_CDEFS
= IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
251 SyntaxVBoxIncludeR0Drv_SOURCES
:= \
252 $(addprefix $(PATH_OBJ
)/include/c
/, $(addsuffix .c
, $(basename $(VBOX_HDRS_ALL_R0DRV_C
)))) \
253 $(addprefix $(PATH_OBJ
)/include/cpp/,$(addsuffix .
cpp,$(basename $(VBOX_HDRS_ALL_R0DRV
))))
254 SyntaxVBoxIncludeR0Drv_CLEAN
= $(SyntaxVBoxIncludeR0Drv_SOURCES
)
257 ifdef VBOX_WITH_RAW_MODE
258 LIBRARIES
+= SyntaxVBoxIncludeRC
259 SyntaxVBoxIncludeRC_TEMPLATE
= VBoxRc
260 SyntaxVBoxIncludeRC_DEFS
= VBOX_WITH_HGCM USING_VMM_COMMON_DEFS
261 SyntaxVBoxIncludeRC_CDEFS
= IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
262 SyntaxVBoxIncludeRC_SOURCES
:= \
263 $(addprefix $(PATH_OBJ
)/include/c
/, $(addsuffix .c
, $(basename $(VBOX_HDRS_ALL_RC_C
)))) \
264 $(addprefix $(PATH_OBJ
)/include/cpp/,$(addsuffix .
cpp,$(basename $(VBOX_HDRS_ALL_RC
))))
265 SyntaxVBoxIncludeRC_CLEAN
= $(SyntaxVBoxIncludeRC_SOURCES
)
269 # Headers that must only be included once.
270 VBOX_HDRS_ONLY_ONCE
:= \
271 iprt
/bldprog-strtab-template.
cpp.h
274 # Generate the files we compile.
276 $(eval functioname
:= $(translate
$(basename $(hdr
)),-.
/,___
))
278 $$(PATH_OBJ
)/include/c
/$(basename $(hdr
)).c
: |
$$$$(dir $$$$@
)
279 $(QUIET
)$$(APPEND
) -t
-n
$$@ \
280 '#include <$(hdr)>' \
281 $(if-expr
$(intersects
$(hdr
),$(VBOX_HDRS_ONLY_ONCE
)),, '#include <$(hdr)>') \
282 'extern int $(functioname)_c(void);' \
283 'int $(functioname)_c(void) { return 0;}'
285 $$(PATH_OBJ
)/include/cpp/$(basename $(hdr
)).
cpp: |
$$$$(dir $$$$@
)
286 $(QUIET
)$$(APPEND
) -t
-n
$$@ \
287 '#include <$(hdr)>' \
288 $(if-expr
$(intersects
$(hdr
),$(VBOX_HDRS_ONLY_ONCE
)),, '#include <$(hdr)>') \
289 'extern int $(functioname)_cpp(void);' \
290 'int $(functioname)_cpp(void) { return 0;}'
294 $(foreach hdr
,$(VBOX_HDRS_ALL
), $(eval
$(def_hdr
)))
296 # Tell kBuild to generate rules for making the directories for the generated files.
297 VBOX_HDR_DIRS
:= $(sort $(dir $(VBOX_HDRS_ALL
)))
298 BLDDIRS
+= $(addprefix $(PATH_OBJ
)/include/c
/,$(VBOX_HDR_DIRS
)) $(addprefix $(PATH_OBJ
)/include/cpp/,$(VBOX_HDR_DIRS
))
301 include $(FILE_KBUILD_SUB_FOOTER
)