1 | # $Id: Makefile.kmk 77759 2019-03-18 13:26:27Z 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/DragAndDrop.h \
|
---|
74 | VBox/HostServices/Service.h \
|
---|
75 | iprt/win/% \
|
---|
76 | iprt/alloca.h \
|
---|
77 | iprt/tcp.h \
|
---|
78 | iprt/localipc.h \
|
---|
79 | iprt/linux/sysfs.h \
|
---|
80 | iprt/socket.h \
|
---|
81 | iprt/udp.h \
|
---|
82 | iprt/fuzz.h \
|
---|
83 | iprt/linux/symvers.h
|
---|
84 |
|
---|
85 | # Ring-0 driver only headers.
|
---|
86 | VBOX_HDRS_R0DRV_ONLY := \
|
---|
87 | VBox/VBoxGuestLibSharedFolders.h \
|
---|
88 | VBox/VBoxGuestLibSharedFoldersInline.h
|
---|
89 |
|
---|
90 | # GCC only headers.
|
---|
91 | VBOX_HDRS_GCC_ONLY := \
|
---|
92 | iprt/nocrt/fenv.h \
|
---|
93 | iprt/nocrt/math.h
|
---|
94 |
|
---|
95 | # Headers to omit all together.
|
---|
96 | VBOX_HDRS_OMIT := \
|
---|
97 | VBox/HostServices/glext.h \
|
---|
98 | VBox/HostServices/glxext.h \
|
---|
99 | VBox/HostServices/wglext.h \
|
---|
100 | VBox/VBoxGL2D.h \
|
---|
101 | $(if-expr "$(KBUILD_TARGET)" != "solaris", \
|
---|
102 | VBox/usblib-solaris.h \
|
---|
103 | ,)\
|
---|
104 | VBox/VDEPlug.h \
|
---|
105 | VBox/VDEPlugSymDefs.h \
|
---|
106 | VBox/VBoxNetCmn-win.h \
|
---|
107 | $(if-expr "$(KBUILD_TARGET)" != "win", \
|
---|
108 | VBox/VBoxDrvCfg-win.h \
|
---|
109 | VBox/VBoxNetCfg-win.h \
|
---|
110 | VBox/usblib-win.h \
|
---|
111 | VBox/com/microatl.h \
|
---|
112 | ,$(VBOX_HDRS_GCC_ONLY)) \
|
---|
113 | \
|
---|
114 | VBox/dbus-calls.h \
|
---|
115 | VBox/VBoxKeyboard.h \
|
---|
116 | VBox/vmm/pdmpcidevint.h \
|
---|
117 | iprt/runtime-loader.h \
|
---|
118 | iprt/mangling.h \
|
---|
119 | $(subst $(PATH_SUB_CURRENT)/,,$(wildcard $(PATH_SUB_CURRENT)/iprt/asm*watcom*.h)) \
|
---|
120 | iprt/asn1-generator% \
|
---|
121 | iprt/win/% \
|
---|
122 | iprt/nt/% \
|
---|
123 | \
|
---|
124 | $(foreach os,$(filter-out $(KBUILD_TARGET),$(KBUILD_OSES)),iprt/$(os)/% VBox/$(os)/%) \
|
---|
125 | $(foreach arch,$(KBUILD_ARCHES),iprt/nocrt/$(arch)/%)
|
---|
126 |
|
---|
127 | # We omit a few headers which have platform specific issues or are templates.
|
---|
128 | VBOX_HDRS_ALL := $(filter-out $(VBOX_HDRS_OMIT), \
|
---|
129 | $(subst $(PATH_SUB_CURRENT)/,,$(wildcard \
|
---|
130 | $(PATH_SUB_CURRENT)/VBox/*.h \
|
---|
131 | $(PATH_SUB_CURRENT)/VBox/*/*.h \
|
---|
132 | $(PATH_SUB_CURRENT)/iprt/*.h \
|
---|
133 | $(PATH_SUB_CURRENT)/iprt/*/*.h \
|
---|
134 | )))
|
---|
135 |
|
---|
136 | # ring-3, ring-0 and raw-mode context specific exclusions.
|
---|
137 | VBOX_HDRS_ALL_R3 := $(filter-out $(VBOX_HDRS_R0DRV_ONLY), $(VBOX_HDRS_ALL))
|
---|
138 | VBOX_HDRS_ALL_R3_C := $(filter-out $(VBOX_HDRS_CPP_FEATURES) $(VBOX_HDRS_R3_CPP), $(VBOX_HDRS_ALL_R3))
|
---|
139 | VBOX_HDRS_ALL_R0 := $(filter-out $(VBOX_HDRS_R3_CPP) $(VBOX_HDRS_R3_ONLY) $(VBOX_HDRS_R0DRV_ONLY), $(VBOX_HDRS_ALL))
|
---|
140 | VBOX_HDRS_ALL_R0_C := $(filter-out $(VBOX_HDRS_CPP_FEATURES), $(VBOX_HDRS_ALL_R0))
|
---|
141 | VBOX_HDRS_ALL_R0DRV := $(filter-out $(VBOX_HDRS_R3_CPP) $(VBOX_HDRS_R3_ONLY), $(VBOX_HDRS_ALL))
|
---|
142 | VBOX_HDRS_ALL_R0DRV_C := $(filter-out $(VBOX_HDRS_CPP_FEATURES), $(VBOX_HDRS_ALL_R0DRV))
|
---|
143 | VBOX_HDRS_ALL_RC := $(filter-out \
|
---|
144 | VBox/VBoxGuestLib.h \
|
---|
145 | VBox/vmm/gvm.h \
|
---|
146 | iprt/thread.h \
|
---|
147 | iprt/mem.h \
|
---|
148 | iprt/memsafer.h \
|
---|
149 | iprt/alloc.h \
|
---|
150 | iprt/vector.h \
|
---|
151 | $(VBOX_HDRS_R3_CPP) \
|
---|
152 | $(VBOX_HDRS_R3_ONLY) \
|
---|
153 | $(VBOX_HDRS_R0DRV_ONLY) \
|
---|
154 | , $(VBOX_HDRS_ALL))
|
---|
155 | VBOX_HDRS_ALL_RC_C := $(filter-out $(VBOX_HDRS_CPP_FEATURES), $(VBOX_HDRS_ALL_RC))
|
---|
156 | #$(error $(subst $(SP),$(NLTAB),$(strip $(sort $(VBOX_HDRS_ALL_RC_C)))))
|
---|
157 |
|
---|
158 | SyntaxVBoxIncludeR3_TEMPLATE = VBOXMAINEXE
|
---|
159 | SyntaxVBoxIncludeR3_DEFS = VBOX_WITH_HGCM
|
---|
160 | SyntaxVBoxIncludeR3_CDEFS = IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
|
---|
161 | SyntaxVBoxIncludeR3_SOURCES := \
|
---|
162 | $(addprefix $(PATH_OBJ)/include/c/, $(addsuffix .c, $(basename $(VBOX_HDRS_ALL_R3_C)))) \
|
---|
163 | $(addprefix $(PATH_OBJ)/include/cpp/,$(addsuffix .cpp,$(basename $(VBOX_HDRS_ALL_R3))))
|
---|
164 | SyntaxVBoxIncludeR3_CLEAN = $(SyntaxVBoxIncludeR3_SOURCES)
|
---|
165 | #$(error $(subst $(SP),$(NLTAB),$(strip $(sort $(SyntaxVBoxIncludeR3_SOURCES)))))
|
---|
166 |
|
---|
167 | SyntaxVBoxIncludeR0_TEMPLATE = VBoxR0
|
---|
168 | SyntaxVBoxIncludeR0_DEFS = VBOX_WITH_HGCM
|
---|
169 | SyntaxVBoxIncludeR0_CDEFS = IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
|
---|
170 | SyntaxVBoxIncludeR0_SOURCES := \
|
---|
171 | $(addprefix $(PATH_OBJ)/include/c/, $(addsuffix .c, $(basename $(VBOX_HDRS_ALL_R0_C)))) \
|
---|
172 | $(addprefix $(PATH_OBJ)/include/cpp/,$(addsuffix .cpp,$(basename $(VBOX_HDRS_ALL_R0))))
|
---|
173 | SyntaxVBoxIncludeR0_CLEAN = $(SyntaxVBoxIncludeR0_SOURCES)
|
---|
174 |
|
---|
175 | if1of ($(KBUILD_TARGET), darwin os2 solaris win)
|
---|
176 | LIBRARIES += SyntaxVBoxIncludeR0Drv
|
---|
177 | SyntaxVBoxIncludeR0Drv_TEMPLATE = VBoxR0DrvLib
|
---|
178 | SyntaxVBoxIncludeR0Drv_SDKS.win = ReorderCompilerIncs $(VBOX_WINDDK) $(VBOX_WINPSDK)INCS
|
---|
179 | SyntaxVBoxIncludeR0Drv_DEFS = VBOX_WITH_HGCM
|
---|
180 | SyntaxVBoxIncludeR0Drv_CDEFS = IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
|
---|
181 | SyntaxVBoxIncludeR0Drv_SOURCES := \
|
---|
182 | $(addprefix $(PATH_OBJ)/include/c/, $(addsuffix .c, $(basename $(VBOX_HDRS_ALL_R0DRV_C)))) \
|
---|
183 | $(addprefix $(PATH_OBJ)/include/cpp/,$(addsuffix .cpp,$(basename $(VBOX_HDRS_ALL_R0DRV))))
|
---|
184 | SyntaxVBoxIncludeR0Drv_CLEAN = $(SyntaxVBoxIncludeR0Drv_SOURCES)
|
---|
185 | endif
|
---|
186 |
|
---|
187 | ifdef VBOX_WITH_RAW_MODE
|
---|
188 | LIBRARIES += SyntaxVBoxIncludeRC
|
---|
189 | SyntaxVBoxIncludeRC_TEMPLATE = VBoxRc
|
---|
190 | SyntaxVBoxIncludeRC_DEFS = VBOX_WITH_HGCM
|
---|
191 | SyntaxVBoxIncludeRC_CDEFS = IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS
|
---|
192 | SyntaxVBoxIncludeRC_SOURCES := \
|
---|
193 | $(addprefix $(PATH_OBJ)/include/c/, $(addsuffix .c, $(basename $(VBOX_HDRS_ALL_RC_C)))) \
|
---|
194 | $(addprefix $(PATH_OBJ)/include/cpp/,$(addsuffix .cpp,$(basename $(VBOX_HDRS_ALL_RC))))
|
---|
195 | SyntaxVBoxIncludeRC_CLEAN = $(SyntaxVBoxIncludeRC_SOURCES)
|
---|
196 | endif
|
---|
197 |
|
---|
198 |
|
---|
199 | # Headers that must only be included once.
|
---|
200 | VBOX_HDRS_ONLY_ONCE := \
|
---|
201 | iprt/bldprog-strtab-template.cpp.h
|
---|
202 |
|
---|
203 |
|
---|
204 | # Generate the files we compile.
|
---|
205 | define def_hdr
|
---|
206 | $(eval functioname := $(translate $(basename $(hdr)),-./,___))
|
---|
207 |
|
---|
208 | $$(PATH_OBJ)/include/c/$(basename $(hdr)).c: | $$$$(dir $$$$@)
|
---|
209 | $(QUIET)$$(APPEND) -t -n $$@ \
|
---|
210 | '#include <$(hdr)>' \
|
---|
211 | $(if-expr $(intersects $(hdr),$(VBOX_HDRS_ONLY_ONCE)),, '#include <$(hdr)>') \
|
---|
212 | 'extern int $(functioname)_c(void);' \
|
---|
213 | 'int $(functioname)_c(void) { return 0;}'
|
---|
214 |
|
---|
215 | $$(PATH_OBJ)/include/cpp/$(basename $(hdr)).cpp: | $$$$(dir $$$$@)
|
---|
216 | $(QUIET)$$(APPEND) -t -n $$@ \
|
---|
217 | '#include <$(hdr)>' \
|
---|
218 | $(if-expr $(intersects $(hdr),$(VBOX_HDRS_ONLY_ONCE)),, '#include <$(hdr)>') \
|
---|
219 | 'extern int $(functioname)_cpp(void);' \
|
---|
220 | 'int $(functioname)_cpp(void) { return 0;}'
|
---|
221 |
|
---|
222 | endef
|
---|
223 |
|
---|
224 | $(foreach hdr,$(VBOX_HDRS_ALL), $(eval $(def_hdr)))
|
---|
225 |
|
---|
226 | # Tell kBuild to generate rules for making the directories for the generated files.
|
---|
227 | VBOX_HDR_DIRS := $(sort $(dir $(VBOX_HDRS_ALL)))
|
---|
228 | BLDDIRS += $(addprefix $(PATH_OBJ)/include/c/,$(VBOX_HDR_DIRS)) $(addprefix $(PATH_OBJ)/include/cpp/,$(VBOX_HDR_DIRS))
|
---|
229 |
|
---|
230 |
|
---|
231 | include $(FILE_KBUILD_SUB_FOOTER)
|
---|
232 |
|
---|