[2478] | 1 | # $Id: Makefile.kmk 100254 2023-06-23 08:49:13Z vboxsync $
|
---|
| 2 | ## @file
|
---|
[1] | 3 | # Some hacks to allow syntax and prerequisite include checking of headers.
|
---|
| 4 | # This makefile doesn't and shouldn't build successfully.
|
---|
| 5 | #
|
---|
| 6 |
|
---|
| 7 | #
|
---|
[98103] | 8 | # Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[5999] | 9 | #
|
---|
[96407] | 10 | # This file is part of VirtualBox base platform packages, as
|
---|
| 11 | # available from https://www.virtualbox.org.
|
---|
[5999] | 12 | #
|
---|
[96407] | 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
|
---|
| 16 | # License.
|
---|
| 17 | #
|
---|
| 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.
|
---|
| 22 | #
|
---|
| 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>.
|
---|
| 25 | #
|
---|
| 26 | # SPDX-License-Identifier: GPL-3.0-only
|
---|
| 27 | #
|
---|
[1] | 28 |
|
---|
[68676] | 29 | SUB_DEPTH = ..
|
---|
| 30 | include $(KBUILD_PATH)/subheader.kmk
|
---|
[1] | 31 |
|
---|
[69686] | 32 | LIBRARIES += SyntaxVBoxIncludeR3 SyntaxVBoxIncludeR0
|
---|
[1] | 33 |
|
---|
[30788] | 34 | # Omit headers that are using C++ features and upsets gcc.
|
---|
[68676] | 35 | VBOX_HDRS_CPP_FEATURES := \
|
---|
[43387] | 36 | VBox/vmm/hm.h \
|
---|
| 37 | VBox/vmm/hm_vmx.h \
|
---|
[88058] | 38 | VBox/vmm/pdmaudioinline.h \
|
---|
| 39 | VBox/vmm/pdmaudiohostenuminline.h \
|
---|
[36536] | 40 | VBox/HostServices/GuestControlSvc.h \
|
---|
[68658] | 41 | VBox/HostServices/DragAndDropSvc.h \
|
---|
[68675] | 42 | VBox/HostServices/Service.h \
|
---|
| 43 | VBox/GuestHost/GuestControl.h \
|
---|
| 44 | VBox/GuestHost/DragAndDrop.h \
|
---|
[80862] | 45 | VBox/GuestHost/SharedClipboard-transfers.h \
|
---|
[78155] | 46 | VBox/dbus.h \
|
---|
[92990] | 47 | VBox/xrandr.h \
|
---|
[36536] | 48 | VBox/VBoxCrHgsmi.h \
|
---|
[76718] | 49 | VBox/VBoxGuestLibSharedFoldersInline.h \
|
---|
[78155] | 50 | VBox/VBoxPktDmp.h \
|
---|
[68658] | 51 | VBox/VBoxUhgsmi.h \
|
---|
[78155] | 52 | iprt/cpp/%
|
---|
[30788] | 53 |
|
---|
| 54 | # Omit headers that are C++ and ring-3.
|
---|
[68676] | 55 | VBOX_HDRS_R3_CPP := \
|
---|
[7133] | 56 | VBox/dbggui.h \
|
---|
| 57 | VBox/settings.h \
|
---|
[34071] | 58 | VBox/com/Guid.h \
|
---|
[93445] | 59 | VBox/vmm/vmmr3vtable.h \
|
---|
[68676] | 60 | iprt/cpp/% \
|
---|
| 61 | VBox/com/% \
|
---|
| 62 | $(subst $(PATH_SUB_CURRENT)/,,$(wildcard $(PATH_SUB_CURRENT)/iprt/*_cpp.h))
|
---|
[1] | 63 |
|
---|
[30788] | 64 | # Ring-3 only headers.
|
---|
[68676] | 65 | VBOX_HDRS_R3_ONLY := \
|
---|
[7133] | 66 | VBox/vrdpapi.h \
|
---|
[68670] | 67 | VBox/vrdpusb.h \
|
---|
[7133] | 68 | VBox/VBoxHDD.h \
|
---|
[25477] | 69 | VBox/VBoxHDD-Plugin.h \
|
---|
[36536] | 70 | VBox/VBoxCrHgsmi.h \
|
---|
| 71 | VBox/VBoxUhgsmi.h \
|
---|
[68670] | 72 | VBox/VBoxNetCfg-win.h \
|
---|
[68675] | 73 | VBox/VBoxDrvCfg-win.h \
|
---|
[25477] | 74 | VBox/dbus.h \
|
---|
[92990] | 75 | VBox/xrandr.h \
|
---|
[68675] | 76 | $(if-expr "$(KBUILD_TARGET)" == "win",VBox/usblib.h,) \
|
---|
[68670] | 77 | VBox/usblib-win.h \
|
---|
[36536] | 78 | VBox/vd.h \
|
---|
[68670] | 79 | VBox/vd-cache-backend.h \
|
---|
| 80 | VBox/vd-ifs.h \
|
---|
| 81 | VBox/vd-ifs-internal.h \
|
---|
| 82 | VBox/vd-image-backend.h \
|
---|
[36536] | 83 | VBox/vd-plugin.h \
|
---|
[68670] | 84 | VBox/vd-filter-backend.h \
|
---|
| 85 | VBox/vddbg.h \
|
---|
[35346] | 86 | VBox/vmm/uvm.h \
|
---|
[87136] | 87 | VBox/vmm/dbgfflowtrace.h \
|
---|
[30788] | 88 | VBox/vscsi.h \
|
---|
[68675] | 89 | VBox/ExtPack/% \
|
---|
[82158] | 90 | VBox/GuestHost/SharedClipboard-transfers.h \
|
---|
[78155] | 91 | VBox/GuestHost/SharedClipboard-win.h \
|
---|
[82158] | 92 | VBox/GuestHost/SharedClipboard-x11.h \
|
---|
[68675] | 93 | VBox/GuestHost/DragAndDrop.h \
|
---|
| 94 | VBox/HostServices/Service.h \
|
---|
[98578] | 95 | VBox/HostServices/TstHGCMMock.h \
|
---|
| 96 | VBox/HostServices/TstHGCMMockUtils.h \
|
---|
[68675] | 97 | iprt/win/% \
|
---|
[32336] | 98 | iprt/alloca.h \
|
---|
[7133] | 99 | iprt/tcp.h \
|
---|
[25477] | 100 | iprt/localipc.h \
|
---|
| 101 | iprt/linux/sysfs.h \
|
---|
[68675] | 102 | iprt/socket.h \
|
---|
[76372] | 103 | iprt/udp.h \
|
---|
[77759] | 104 | iprt/fuzz.h \
|
---|
[82158] | 105 | iprt/linux/symvers.h
|
---|
[7133] | 106 |
|
---|
[76719] | 107 | # Ring-0 driver only headers.
|
---|
| 108 | VBOX_HDRS_R0DRV_ONLY := \
|
---|
| 109 | VBox/VBoxGuestLibSharedFolders.h \
|
---|
[85700] | 110 | VBox/VBoxGuestLibSharedFoldersInline.h \
|
---|
[98444] | 111 | iprt/linux/version.h
|
---|
[68670] | 112 |
|
---|
[68675] | 113 | # GCC only headers.
|
---|
[68676] | 114 | VBOX_HDRS_GCC_ONLY := \
|
---|
[68675] | 115 | iprt/nocrt/fenv.h \
|
---|
| 116 | iprt/nocrt/math.h
|
---|
| 117 |
|
---|
| 118 | # Headers to omit all together.
|
---|
[68676] | 119 | VBOX_HDRS_OMIT := \
|
---|
[36536] | 120 | VBox/HostServices/glext.h \
|
---|
| 121 | VBox/HostServices/glxext.h \
|
---|
| 122 | VBox/HostServices/wglext.h \
|
---|
[82158] | 123 | $(if-expr "$(KBUILD_TARGET)" != "linux", \
|
---|
[99040] | 124 | VBox/GuestHost/SharedClipboard-x11.h \
|
---|
| 125 | ,) \
|
---|
[68676] | 126 | $(if-expr "$(KBUILD_TARGET)" != "solaris", \
|
---|
[99040] | 127 | VBox/usblib-solaris.h \
|
---|
| 128 | ,) \
|
---|
[30788] | 129 | VBox/VDEPlug.h \
|
---|
[68670] | 130 | VBox/VDEPlugSymDefs.h \
|
---|
| 131 | VBox/VBoxNetCmn-win.h \
|
---|
[36536] | 132 | $(if-expr "$(KBUILD_TARGET)" != "win", \
|
---|
[99040] | 133 | VBox/com/microatl.h \
|
---|
| 134 | VBox/GuestHost/SharedClipboard-win.h \
|
---|
| 135 | VBox/usblib-win.h \
|
---|
| 136 | VBox/VBoxDrvCfg-win.h \
|
---|
| 137 | VBox/VBoxNetCfg-win.h \
|
---|
| 138 | iprt/sanitized/intrin.h \
|
---|
| 139 | ,$(VBOX_HDRS_GCC_ONLY)) \
|
---|
[30788] | 140 | \
|
---|
| 141 | VBox/dbus-calls.h \
|
---|
[92990] | 142 | VBox/xrandr-calls.h \
|
---|
[30788] | 143 | VBox/VBoxKeyboard.h \
|
---|
[64373] | 144 | VBox/vmm/pdmpcidevint.h \
|
---|
[93445] | 145 | VBox/vmm/vmmr3vtable-def.h \
|
---|
[98960] | 146 | VBox/vmm/cpumctx-x86-amd64.h \
|
---|
| 147 | VBox/vmm/cpumctx-armv8.h \
|
---|
[98971] | 148 | VBox/vmm/cpum-x86-amd64.h \
|
---|
| 149 | VBox/vmm/cpum-armv8.h \
|
---|
[98981] | 150 | VBox/vmm/iem-x86-amd64.h \
|
---|
| 151 | VBox/vmm/iem-armv8.h \
|
---|
[30788] | 152 | iprt/runtime-loader.h \
|
---|
[36536] | 153 | iprt/mangling.h \
|
---|
[98444] | 154 | $(subst $(PATH_SUB_CURRENT)/,,$(wildcard $(PATH_SUB_CURRENT)/iprt/asm*watcom*.h)) \
|
---|
| 155 | iprt/asn1-generator% \
|
---|
| 156 | iprt/win/% \
|
---|
| 157 | iprt/nt/% \
|
---|
| 158 | \
|
---|
[25477] | 159 | $(foreach os,$(filter-out $(KBUILD_TARGET),$(KBUILD_OSES)),iprt/$(os)/% VBox/$(os)/%) \
|
---|
[68675] | 160 | $(foreach arch,$(KBUILD_ARCHES),iprt/nocrt/$(arch)/%)
|
---|
[7133] | 161 |
|
---|
[80069] | 162 | # AMD64 only headers.
|
---|
| 163 | ifneq ($(KBUILD_TARGET_ARCH),amd64)
|
---|
[98444] | 164 | VBOX_HDRS_OMIT += \
|
---|
| 165 | VBox/vmm/cpumctx.h \
|
---|
| 166 | VBox/vmm/cpumctx-v1_6.h \
|
---|
| 167 | VBox/vmm/dbgfcorefmt.h
|
---|
[80069] | 168 | endif
|
---|
[87200] | 169 | # ARM only headers.
|
---|
| 170 | ifn1of ($(KBUILD_TARGET_ARCH), arm32 arm64)
|
---|
[98444] | 171 | VBOX_HDRS_OMIT += \
|
---|
[100254] | 172 | iprt/asm-arm.h \
|
---|
| 173 | iprt/asmdefs-arm.h
|
---|
[87200] | 174 | endif
|
---|
[80069] | 175 |
|
---|
[87200] | 176 |
|
---|
[68675] | 177 | # We omit a few headers which have platform specific issues or are templates.
|
---|
[68676] | 178 | VBOX_HDRS_ALL := $(filter-out $(VBOX_HDRS_OMIT), \
|
---|
[99040] | 179 | $(subst $(PATH_SUB_CURRENT)/,,$(wildcard \
|
---|
| 180 | $(PATH_SUB_CURRENT)/VBox/*.h \
|
---|
| 181 | $(PATH_SUB_CURRENT)/VBox/*/*.h \
|
---|
| 182 | $(PATH_SUB_CURRENT)/iprt/*.h \
|
---|
| 183 | $(PATH_SUB_CURRENT)/iprt/*/*.h \
|
---|
| 184 | )))
|
---|
[68675] | 185 |
|
---|
[30788] | 186 | # ring-3, ring-0 and raw-mode context specific exclusions.
|
---|
[76719] | 187 | VBOX_HDRS_ALL_R3 := $(filter-out $(VBOX_HDRS_R0DRV_ONLY), $(VBOX_HDRS_ALL))
|
---|
[79903] | 188 | if "$(intersects $(KBUILD_TARGET_ARCH),$(VBOX_SUPPORTED_HOST_ARCHS))" == ""
|
---|
| 189 | ifeq ($(KBUILD_TARGET),win)
|
---|
[98444] | 190 | VBOX_HDRS_ALL_R3 := $(filter-out VBox/com/VirtualBox.h VBox/com/listeners.h VBox/settings.h,$(VBOX_HDRS_ALL_R3))
|
---|
[79903] | 191 | else
|
---|
[98444] | 192 | VBOX_HDRS_ALL_R3 := $(filter-out VBox/com/% VBox/settings.h,$(VBOX_HDRS_ALL_R3))
|
---|
[79903] | 193 | endif
|
---|
| 194 | endif
|
---|
[76719] | 195 | VBOX_HDRS_ALL_R3_C := $(filter-out $(VBOX_HDRS_CPP_FEATURES) $(VBOX_HDRS_R3_CPP), $(VBOX_HDRS_ALL_R3))
|
---|
| 196 | VBOX_HDRS_ALL_R0 := $(filter-out $(VBOX_HDRS_R3_CPP) $(VBOX_HDRS_R3_ONLY) $(VBOX_HDRS_R0DRV_ONLY), $(VBOX_HDRS_ALL))
|
---|
| 197 | VBOX_HDRS_ALL_R0_C := $(filter-out $(VBOX_HDRS_CPP_FEATURES), $(VBOX_HDRS_ALL_R0))
|
---|
| 198 | VBOX_HDRS_ALL_R0DRV := $(filter-out $(VBOX_HDRS_R3_CPP) $(VBOX_HDRS_R3_ONLY), $(VBOX_HDRS_ALL))
|
---|
| 199 | VBOX_HDRS_ALL_R0DRV_C := $(filter-out $(VBOX_HDRS_CPP_FEATURES), $(VBOX_HDRS_ALL_R0DRV))
|
---|
| 200 | VBOX_HDRS_ALL_RC := $(filter-out \
|
---|
[99040] | 201 | VBox/VBoxGuestLib.h \
|
---|
| 202 | VBox/vmm/gvm.h \
|
---|
| 203 | iprt/thread.h \
|
---|
| 204 | iprt/mem.h \
|
---|
| 205 | iprt/memsafer.h \
|
---|
| 206 | iprt/alloc.h \
|
---|
| 207 | iprt/vector.h \
|
---|
| 208 | $(VBOX_HDRS_R3_CPP) \
|
---|
| 209 | $(VBOX_HDRS_R3_ONLY) \
|
---|
| 210 | $(VBOX_HDRS_R0DRV_ONLY) \
|
---|
| 211 | , $(VBOX_HDRS_ALL))
|
---|
[68676] | 212 | VBOX_HDRS_ALL_RC_C := $(filter-out $(VBOX_HDRS_CPP_FEATURES), $(VBOX_HDRS_ALL_RC))
|
---|
| 213 | #$(error $(subst $(SP),$(NLTAB),$(strip $(sort $(VBOX_HDRS_ALL_RC_C)))))
|
---|
[7133] | 214 |
|
---|
[79903] | 215 | if1of ($(KBUILD_TARGET_ARCH), $(VBOX_SUPPORTED_HOST_ARCHS))
|
---|
[98444] | 216 | SyntaxVBoxIncludeR3_TEMPLATE = VBoxMainExe
|
---|
| 217 | SyntaxVBoxIncludeR3_DEFS = VBOX_WITH_HGCM
|
---|
[79903] | 218 | else
|
---|
[98444] | 219 | SyntaxVBoxIncludeR3_TEMPLATE = VBoxR3Exe
|
---|
| 220 | SyntaxVBoxIncludeR3_SDKS.win = ReorderCompilerIncs $(VBOX_WINPSDK) $(VBOX_WINDDK)
|
---|
[79903] | 221 | endif
|
---|
[80310] | 222 | SyntaxVBoxIncludeR3_DEFS += USING_VMM_COMMON_DEFS
|
---|
[69686] | 223 | SyntaxVBoxIncludeR3_CDEFS = IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
|
---|
[1] | 224 | SyntaxVBoxIncludeR3_SOURCES := \
|
---|
[68689] | 225 | $(addprefix $(PATH_OBJ)/include/c/, $(addsuffix .c, $(basename $(VBOX_HDRS_ALL_R3_C)))) \
|
---|
| 226 | $(addprefix $(PATH_OBJ)/include/cpp/,$(addsuffix .cpp,$(basename $(VBOX_HDRS_ALL_R3))))
|
---|
[68676] | 227 | SyntaxVBoxIncludeR3_CLEAN = $(SyntaxVBoxIncludeR3_SOURCES)
|
---|
[68689] | 228 | #$(error $(subst $(SP),$(NLTAB),$(strip $(sort $(SyntaxVBoxIncludeR3_SOURCES)))))
|
---|
[1] | 229 |
|
---|
[26222] | 230 | SyntaxVBoxIncludeR0_TEMPLATE = VBoxR0
|
---|
[80310] | 231 | SyntaxVBoxIncludeR0_DEFS = VBOX_WITH_HGCM USING_VMM_COMMON_DEFS
|
---|
[69686] | 232 | SyntaxVBoxIncludeR0_CDEFS = IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
|
---|
[7133] | 233 | SyntaxVBoxIncludeR0_SOURCES := \
|
---|
[68689] | 234 | $(addprefix $(PATH_OBJ)/include/c/, $(addsuffix .c, $(basename $(VBOX_HDRS_ALL_R0_C)))) \
|
---|
| 235 | $(addprefix $(PATH_OBJ)/include/cpp/,$(addsuffix .cpp,$(basename $(VBOX_HDRS_ALL_R0))))
|
---|
[68676] | 236 | SyntaxVBoxIncludeR0_CLEAN = $(SyntaxVBoxIncludeR0_SOURCES)
|
---|
[1] | 237 |
|
---|
[76719] | 238 | if1of ($(KBUILD_TARGET), darwin os2 solaris win)
|
---|
[98444] | 239 | LIBRARIES += SyntaxVBoxIncludeR0Drv
|
---|
| 240 | SyntaxVBoxIncludeR0Drv_TEMPLATE = VBoxR0DrvLib
|
---|
| 241 | SyntaxVBoxIncludeR0Drv_SDKS.win = ReorderCompilerIncs $(VBOX_WINDDK) $(VBOX_WINPSDK_INCS)
|
---|
| 242 | SyntaxVBoxIncludeR0Drv_DEFS = VBOX_WITH_HGCM USING_VMM_COMMON_DEFS
|
---|
| 243 | SyntaxVBoxIncludeR0Drv_CDEFS = IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
|
---|
| 244 | SyntaxVBoxIncludeR0Drv_SOURCES := \
|
---|
| 245 | $(addprefix $(PATH_OBJ)/include/c/, $(addsuffix .c, $(basename $(VBOX_HDRS_ALL_R0DRV_C)))) \
|
---|
| 246 | $(addprefix $(PATH_OBJ)/include/cpp/,$(addsuffix .cpp,$(basename $(VBOX_HDRS_ALL_R0DRV))))
|
---|
| 247 | SyntaxVBoxIncludeR0Drv_CLEAN = $(SyntaxVBoxIncludeR0Drv_SOURCES)
|
---|
[76719] | 248 | endif
|
---|
| 249 |
|
---|
[69686] | 250 | ifdef VBOX_WITH_RAW_MODE
|
---|
[98444] | 251 | LIBRARIES += SyntaxVBoxIncludeRC
|
---|
| 252 | SyntaxVBoxIncludeRC_TEMPLATE = VBoxRc
|
---|
| 253 | SyntaxVBoxIncludeRC_DEFS = VBOX_WITH_HGCM USING_VMM_COMMON_DEFS
|
---|
| 254 | SyntaxVBoxIncludeRC_CDEFS = IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
|
---|
| 255 | SyntaxVBoxIncludeRC_SOURCES := \
|
---|
| 256 | $(addprefix $(PATH_OBJ)/include/c/, $(addsuffix .c, $(basename $(VBOX_HDRS_ALL_RC_C)))) \
|
---|
| 257 | $(addprefix $(PATH_OBJ)/include/cpp/,$(addsuffix .cpp,$(basename $(VBOX_HDRS_ALL_RC))))
|
---|
| 258 | SyntaxVBoxIncludeRC_CLEAN = $(SyntaxVBoxIncludeRC_SOURCES)
|
---|
[69686] | 259 | endif
|
---|
[1] | 260 |
|
---|
| 261 |
|
---|
[68675] | 262 | # Headers that must only be included once.
|
---|
[68676] | 263 | VBOX_HDRS_ONLY_ONCE := \
|
---|
[68675] | 264 | iprt/bldprog-strtab-template.cpp.h
|
---|
| 265 |
|
---|
[68676] | 266 |
|
---|
| 267 | # Generate the files we compile.
|
---|
[1] | 268 | define def_hdr
|
---|
[68689] | 269 | $(eval functioname := $(translate $(basename $(hdr)),-./,___))
|
---|
| 270 |
|
---|
| 271 | $$(PATH_OBJ)/include/c/$(basename $(hdr)).c: | $$$$(dir $$$$@)
|
---|
[68675] | 272 | $(QUIET)$$(APPEND) -t -n $$@ \
|
---|
| 273 | '#include <$(hdr)>' \
|
---|
[68676] | 274 | $(if-expr $(intersects $(hdr),$(VBOX_HDRS_ONLY_ONCE)),, '#include <$(hdr)>') \
|
---|
[68689] | 275 | 'extern int $(functioname)_c(void);' \
|
---|
| 276 | 'int $(functioname)_c(void) { return 0;}'
|
---|
[1] | 277 |
|
---|
[68689] | 278 | $$(PATH_OBJ)/include/cpp/$(basename $(hdr)).cpp: | $$$$(dir $$$$@)
|
---|
[68675] | 279 | $(QUIET)$$(APPEND) -t -n $$@ \
|
---|
| 280 | '#include <$(hdr)>' \
|
---|
[68676] | 281 | $(if-expr $(intersects $(hdr),$(VBOX_HDRS_ONLY_ONCE)),, '#include <$(hdr)>') \
|
---|
[68689] | 282 | 'extern int $(functioname)_cpp(void);' \
|
---|
| 283 | 'int $(functioname)_cpp(void) { return 0;}'
|
---|
[36536] | 284 |
|
---|
[1] | 285 | endef
|
---|
| 286 |
|
---|
[68676] | 287 | $(foreach hdr,$(VBOX_HDRS_ALL), $(eval $(def_hdr)))
|
---|
[1] | 288 |
|
---|
[68689] | 289 | # Tell kBuild to generate rules for making the directories for the generated files.
|
---|
| 290 | VBOX_HDR_DIRS := $(sort $(dir $(VBOX_HDRS_ALL)))
|
---|
| 291 | BLDDIRS += $(addprefix $(PATH_OBJ)/include/c/,$(VBOX_HDR_DIRS)) $(addprefix $(PATH_OBJ)/include/cpp/,$(VBOX_HDR_DIRS))
|
---|
[68676] | 292 |
|
---|
| 293 |
|
---|
| 294 | include $(FILE_KBUILD_SUB_FOOTER)
|
---|