1 | # $Id: Makefile.kmk 78176 2019-04-17 16:28:47Z vboxsync $
|
---|
2 | ## @file
|
---|
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 | #
|
---|
8 | # Copyright (C) 2006-2019 Oracle Corporation
|
---|
9 | #
|
---|
10 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | # available from http://www.virtualbox.org. This file is free software;
|
---|
12 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | # General Public License (GPL) as published by the Free Software
|
---|
14 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | #
|
---|
18 |
|
---|
19 | SUB_DEPTH = ..
|
---|
20 | include $(KBUILD_PATH)/subheader.kmk
|
---|
21 |
|
---|
22 | LIBRARIES += SyntaxVBoxIncludeR3 SyntaxVBoxIncludeR0
|
---|
23 |
|
---|
24 | # Omit headers that are using C++ features and upsets gcc.
|
---|
25 | VBOX_HDRS_CPP_FEATURES := \
|
---|
26 | VBox/vmm/hm.h \
|
---|
27 | VBox/vmm/hm_vmx.h \
|
---|
28 | VBox/HostServices/GuestControlSvc.h \
|
---|
29 | VBox/HostServices/DragAndDropSvc.h \
|
---|
30 | VBox/HostServices/Service.h \
|
---|
31 | VBox/GuestHost/GuestControl.h \
|
---|
32 | VBox/GuestHost/DragAndDrop.h \
|
---|
33 | VBox/dbus.h \
|
---|
34 | VBox/VBoxCrHgsmi.h \
|
---|
35 | VBox/VBoxGuestLibSharedFoldersInline.h \
|
---|
36 | VBox/VBoxPktDmp.h \
|
---|
37 | VBox/VBoxUhgsmi.h \
|
---|
38 | iprt/cpp/%
|
---|
39 |
|
---|
40 | # Omit headers that are C++ and ring-3.
|
---|
41 | VBOX_HDRS_R3_CPP := \
|
---|
42 | VBox/dbggui.h \
|
---|
43 | VBox/settings.h \
|
---|
44 | VBox/com/Guid.h \
|
---|
45 | iprt/cpp/% \
|
---|
46 | VBox/com/% \
|
---|
47 | $(subst $(PATH_SUB_CURRENT)/,,$(wildcard $(PATH_SUB_CURRENT)/iprt/*_cpp.h))
|
---|
48 |
|
---|
49 | # Ring-3 only headers.
|
---|
50 | VBOX_HDRS_R3_ONLY := \
|
---|
51 | VBox/vrdpapi.h \
|
---|
52 | VBox/vrdpusb.h \
|
---|
53 | VBox/VBoxHDD.h \
|
---|
54 | VBox/VBoxHDD-Plugin.h \
|
---|
55 | VBox/VBoxCrHgsmi.h \
|
---|
56 | VBox/VBoxUhgsmi.h \
|
---|
57 | VBox/VBoxNetCfg-win.h \
|
---|
58 | VBox/VBoxDrvCfg-win.h \
|
---|
59 | VBox/dbus.h \
|
---|
60 | $(if-expr "$(KBUILD_TARGET)" == "win",VBox/usblib.h,) \
|
---|
61 | VBox/usblib-win.h \
|
---|
62 | VBox/vd.h \
|
---|
63 | VBox/vd-cache-backend.h \
|
---|
64 | VBox/vd-ifs.h \
|
---|
65 | VBox/vd-ifs-internal.h \
|
---|
66 | VBox/vd-image-backend.h \
|
---|
67 | VBox/vd-plugin.h \
|
---|
68 | VBox/vd-filter-backend.h \
|
---|
69 | VBox/vddbg.h \
|
---|
70 | VBox/vmm/uvm.h \
|
---|
71 | VBox/vscsi.h \
|
---|
72 | VBox/ExtPack/% \
|
---|
73 | VBox/GuestHost/SharedClipboard-win.h \
|
---|
74 | VBox/GuestHost/DragAndDrop.h \
|
---|
75 | VBox/HostServices/Service.h \
|
---|
76 | iprt/win/% \
|
---|
77 | iprt/alloca.h \
|
---|
78 | iprt/tcp.h \
|
---|
79 | iprt/localipc.h \
|
---|
80 | iprt/linux/sysfs.h \
|
---|
81 | iprt/socket.h \
|
---|
82 | iprt/udp.h \
|
---|
83 | iprt/fuzz.h \
|
---|
84 | iprt/linux/symvers.h
|
---|
85 |
|
---|
86 | # Ring-0 driver only headers.
|
---|
87 | VBOX_HDRS_R0DRV_ONLY := \
|
---|
88 | VBox/VBoxGuestLibSharedFolders.h \
|
---|
89 | VBox/VBoxGuestLibSharedFoldersInline.h
|
---|
90 |
|
---|
91 | # GCC only headers.
|
---|
92 | VBOX_HDRS_GCC_ONLY := \
|
---|
93 | iprt/nocrt/fenv.h \
|
---|
94 | iprt/nocrt/math.h
|
---|
95 |
|
---|
96 | # Headers to omit all together.
|
---|
97 | VBOX_HDRS_OMIT := \
|
---|
98 | VBox/HostServices/glext.h \
|
---|
99 | VBox/HostServices/glxext.h \
|
---|
100 | VBox/HostServices/wglext.h \
|
---|
101 | VBox/VBoxGL2D.h \
|
---|
102 | $(if-expr "$(KBUILD_TARGET)" != "solaris", \
|
---|
103 | VBox/usblib-solaris.h \
|
---|
104 | ,)\
|
---|
105 | VBox/VDEPlug.h \
|
---|
106 | VBox/VDEPlugSymDefs.h \
|
---|
107 | VBox/VBoxNetCmn-win.h \
|
---|
108 | $(if-expr "$(KBUILD_TARGET)" != "win", \
|
---|
109 | VBox/com/microatl.h \
|
---|
110 | VBox/GuestHost/SharedClipboard-win.h \
|
---|
111 | VBox/usblib-win.h \
|
---|
112 | VBox/VBoxDrvCfg-win.h \
|
---|
113 | VBox/VBoxNetCfg-win.h \
|
---|
114 | ,$(VBOX_HDRS_GCC_ONLY)) \
|
---|
115 | \
|
---|
116 | VBox/dbus-calls.h \
|
---|
117 | VBox/VBoxKeyboard.h \
|
---|
118 | VBox/vmm/pdmpcidevint.h \
|
---|
119 | iprt/runtime-loader.h \
|
---|
120 | iprt/mangling.h \
|
---|
121 | $(subst $(PATH_SUB_CURRENT)/,,$(wildcard $(PATH_SUB_CURRENT)/iprt/asm*watcom*.h)) \
|
---|
122 | iprt/asn1-generator% \
|
---|
123 | iprt/win/% \
|
---|
124 | iprt/nt/% \
|
---|
125 | \
|
---|
126 | $(foreach os,$(filter-out $(KBUILD_TARGET),$(KBUILD_OSES)),iprt/$(os)/% VBox/$(os)/%) \
|
---|
127 | $(foreach arch,$(KBUILD_ARCHES),iprt/nocrt/$(arch)/%)
|
---|
128 |
|
---|
129 | # We omit a few headers which have platform specific issues or are templates.
|
---|
130 | VBOX_HDRS_ALL := $(filter-out $(VBOX_HDRS_OMIT), \
|
---|
131 | $(subst $(PATH_SUB_CURRENT)/,,$(wildcard \
|
---|
132 | $(PATH_SUB_CURRENT)/VBox/*.h \
|
---|
133 | $(PATH_SUB_CURRENT)/VBox/*/*.h \
|
---|
134 | $(PATH_SUB_CURRENT)/iprt/*.h \
|
---|
135 | $(PATH_SUB_CURRENT)/iprt/*/*.h \
|
---|
136 | )))
|
---|
137 |
|
---|
138 | # ring-3, ring-0 and raw-mode context specific exclusions.
|
---|
139 | VBOX_HDRS_ALL_R3 := $(filter-out $(VBOX_HDRS_R0DRV_ONLY), $(VBOX_HDRS_ALL))
|
---|
140 | VBOX_HDRS_ALL_R3_C := $(filter-out $(VBOX_HDRS_CPP_FEATURES) $(VBOX_HDRS_R3_CPP), $(VBOX_HDRS_ALL_R3))
|
---|
141 | VBOX_HDRS_ALL_R0 := $(filter-out $(VBOX_HDRS_R3_CPP) $(VBOX_HDRS_R3_ONLY) $(VBOX_HDRS_R0DRV_ONLY), $(VBOX_HDRS_ALL))
|
---|
142 | VBOX_HDRS_ALL_R0_C := $(filter-out $(VBOX_HDRS_CPP_FEATURES), $(VBOX_HDRS_ALL_R0))
|
---|
143 | VBOX_HDRS_ALL_R0DRV := $(filter-out $(VBOX_HDRS_R3_CPP) $(VBOX_HDRS_R3_ONLY), $(VBOX_HDRS_ALL))
|
---|
144 | VBOX_HDRS_ALL_R0DRV_C := $(filter-out $(VBOX_HDRS_CPP_FEATURES), $(VBOX_HDRS_ALL_R0DRV))
|
---|
145 | VBOX_HDRS_ALL_RC := $(filter-out \
|
---|
146 | VBox/VBoxGuestLib.h \
|
---|
147 | VBox/vmm/gvm.h \
|
---|
148 | iprt/thread.h \
|
---|
149 | iprt/mem.h \
|
---|
150 | iprt/memsafer.h \
|
---|
151 | iprt/alloc.h \
|
---|
152 | iprt/vector.h \
|
---|
153 | $(VBOX_HDRS_R3_CPP) \
|
---|
154 | $(VBOX_HDRS_R3_ONLY) \
|
---|
155 | $(VBOX_HDRS_R0DRV_ONLY) \
|
---|
156 | , $(VBOX_HDRS_ALL))
|
---|
157 | VBOX_HDRS_ALL_RC_C := $(filter-out $(VBOX_HDRS_CPP_FEATURES), $(VBOX_HDRS_ALL_RC))
|
---|
158 | #$(error $(subst $(SP),$(NLTAB),$(strip $(sort $(VBOX_HDRS_ALL_RC_C)))))
|
---|
159 |
|
---|
160 | SyntaxVBoxIncludeR3_TEMPLATE = VBOXMAINEXE
|
---|
161 | SyntaxVBoxIncludeR3_DEFS = VBOX_WITH_HGCM
|
---|
162 | SyntaxVBoxIncludeR3_CDEFS = IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
|
---|
163 | SyntaxVBoxIncludeR3_SOURCES := \
|
---|
164 | $(addprefix $(PATH_OBJ)/include/c/, $(addsuffix .c, $(basename $(VBOX_HDRS_ALL_R3_C)))) \
|
---|
165 | $(addprefix $(PATH_OBJ)/include/cpp/,$(addsuffix .cpp,$(basename $(VBOX_HDRS_ALL_R3))))
|
---|
166 | SyntaxVBoxIncludeR3_CLEAN = $(SyntaxVBoxIncludeR3_SOURCES)
|
---|
167 | #$(error $(subst $(SP),$(NLTAB),$(strip $(sort $(SyntaxVBoxIncludeR3_SOURCES)))))
|
---|
168 |
|
---|
169 | SyntaxVBoxIncludeR0_TEMPLATE = VBoxR0
|
---|
170 | SyntaxVBoxIncludeR0_DEFS = VBOX_WITH_HGCM
|
---|
171 | SyntaxVBoxIncludeR0_CDEFS = IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
|
---|
172 | SyntaxVBoxIncludeR0_SOURCES := \
|
---|
173 | $(addprefix $(PATH_OBJ)/include/c/, $(addsuffix .c, $(basename $(VBOX_HDRS_ALL_R0_C)))) \
|
---|
174 | $(addprefix $(PATH_OBJ)/include/cpp/,$(addsuffix .cpp,$(basename $(VBOX_HDRS_ALL_R0))))
|
---|
175 | SyntaxVBoxIncludeR0_CLEAN = $(SyntaxVBoxIncludeR0_SOURCES)
|
---|
176 |
|
---|
177 | if1of ($(KBUILD_TARGET), darwin os2 solaris win)
|
---|
178 | LIBRARIES += SyntaxVBoxIncludeR0Drv
|
---|
179 | SyntaxVBoxIncludeR0Drv_TEMPLATE = VBoxR0DrvLib
|
---|
180 | SyntaxVBoxIncludeR0Drv_SDKS.win = ReorderCompilerIncs $(VBOX_WINDDK) $(VBOX_WINPSDK)INCS
|
---|
181 | SyntaxVBoxIncludeR0Drv_DEFS = VBOX_WITH_HGCM
|
---|
182 | SyntaxVBoxIncludeR0Drv_CDEFS = IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
|
---|
183 | SyntaxVBoxIncludeR0Drv_SOURCES := \
|
---|
184 | $(addprefix $(PATH_OBJ)/include/c/, $(addsuffix .c, $(basename $(VBOX_HDRS_ALL_R0DRV_C)))) \
|
---|
185 | $(addprefix $(PATH_OBJ)/include/cpp/,$(addsuffix .cpp,$(basename $(VBOX_HDRS_ALL_R0DRV))))
|
---|
186 | SyntaxVBoxIncludeR0Drv_CLEAN = $(SyntaxVBoxIncludeR0Drv_SOURCES)
|
---|
187 | endif
|
---|
188 |
|
---|
189 | ifdef VBOX_WITH_RAW_MODE
|
---|
190 | LIBRARIES += SyntaxVBoxIncludeRC
|
---|
191 | SyntaxVBoxIncludeRC_TEMPLATE = VBoxRc
|
---|
192 | SyntaxVBoxIncludeRC_DEFS = VBOX_WITH_HGCM
|
---|
193 | SyntaxVBoxIncludeRC_CDEFS = IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
|
---|
194 | SyntaxVBoxIncludeRC_SOURCES := \
|
---|
195 | $(addprefix $(PATH_OBJ)/include/c/, $(addsuffix .c, $(basename $(VBOX_HDRS_ALL_RC_C)))) \
|
---|
196 | $(addprefix $(PATH_OBJ)/include/cpp/,$(addsuffix .cpp,$(basename $(VBOX_HDRS_ALL_RC))))
|
---|
197 | SyntaxVBoxIncludeRC_CLEAN = $(SyntaxVBoxIncludeRC_SOURCES)
|
---|
198 | endif
|
---|
199 |
|
---|
200 |
|
---|
201 | # Headers that must only be included once.
|
---|
202 | VBOX_HDRS_ONLY_ONCE := \
|
---|
203 | iprt/bldprog-strtab-template.cpp.h
|
---|
204 |
|
---|
205 |
|
---|
206 | # Generate the files we compile.
|
---|
207 | define def_hdr
|
---|
208 | $(eval functioname := $(translate $(basename $(hdr)),-./,___))
|
---|
209 |
|
---|
210 | $$(PATH_OBJ)/include/c/$(basename $(hdr)).c: | $$$$(dir $$$$@)
|
---|
211 | $(QUIET)$$(APPEND) -t -n $$@ \
|
---|
212 | '#include <$(hdr)>' \
|
---|
213 | $(if-expr $(intersects $(hdr),$(VBOX_HDRS_ONLY_ONCE)),, '#include <$(hdr)>') \
|
---|
214 | 'extern int $(functioname)_c(void);' \
|
---|
215 | 'int $(functioname)_c(void) { return 0;}'
|
---|
216 |
|
---|
217 | $$(PATH_OBJ)/include/cpp/$(basename $(hdr)).cpp: | $$$$(dir $$$$@)
|
---|
218 | $(QUIET)$$(APPEND) -t -n $$@ \
|
---|
219 | '#include <$(hdr)>' \
|
---|
220 | $(if-expr $(intersects $(hdr),$(VBOX_HDRS_ONLY_ONCE)),, '#include <$(hdr)>') \
|
---|
221 | 'extern int $(functioname)_cpp(void);' \
|
---|
222 | 'int $(functioname)_cpp(void) { return 0;}'
|
---|
223 |
|
---|
224 | endef
|
---|
225 |
|
---|
226 | $(foreach hdr,$(VBOX_HDRS_ALL), $(eval $(def_hdr)))
|
---|
227 |
|
---|
228 | # Tell kBuild to generate rules for making the directories for the generated files.
|
---|
229 | VBOX_HDR_DIRS := $(sort $(dir $(VBOX_HDRS_ALL)))
|
---|
230 | BLDDIRS += $(addprefix $(PATH_OBJ)/include/c/,$(VBOX_HDR_DIRS)) $(addprefix $(PATH_OBJ)/include/cpp/,$(VBOX_HDR_DIRS))
|
---|
231 |
|
---|
232 |
|
---|
233 | include $(FILE_KBUILD_SUB_FOOTER)
|
---|
234 |
|
---|