1 | # $Id: Makefile.kmk 66823 2017-05-08 16:51:09Z 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-2016 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 | DEPTH = ..
|
---|
20 | include $(KBUILD_PATH)/header.kmk
|
---|
21 |
|
---|
22 | LIBRARIES = SyntaxVBoxIncludeR3 SyntaxVBoxIncludeR0 SyntaxVBoxIncludeRC
|
---|
23 |
|
---|
24 | # Omit headers that are using C++ features and upsets gcc.
|
---|
25 | cpp_features_hdrs := \
|
---|
26 | VBox/vmm/hm.h \
|
---|
27 | VBox/vmm/hm_vmx.h \
|
---|
28 | VBox/HostServices/GuestControlSvc.h \
|
---|
29 | VBox/VBoxCrHgsmi.h \
|
---|
30 | VBox/VBoxUhgsmi.h
|
---|
31 |
|
---|
32 | # Omit headers that are C++ and ring-3.
|
---|
33 | r3_cpp_hdrs := \
|
---|
34 | VBox/dbggui.h \
|
---|
35 | VBox/settings.h \
|
---|
36 | VBox/com/Guid.h \
|
---|
37 | VBox/HostServices/GuestPropertySvc.h \
|
---|
38 | $(wildcard iprt/*_cpp.h iprt/cpp/*.h VBox/com/*.h )
|
---|
39 |
|
---|
40 | # Ring-3 only headers.
|
---|
41 | r3_only_hdrs := \
|
---|
42 | VBox/vrdpapi.h \
|
---|
43 | VBox/vrdpusb.h \
|
---|
44 | VBox/VBoxHDD.h \
|
---|
45 | VBox/VBoxHDD-Plugin.h \
|
---|
46 | VBox/VBoxCrHgsmi.h \
|
---|
47 | VBox/VBoxUhgsmi.h \
|
---|
48 | VBox/dbus.h \
|
---|
49 | VBox/vd.h \
|
---|
50 | VBox/vd-plugin.h \
|
---|
51 | VBox/vd-cache-plugin.h \
|
---|
52 | VBox/vmm/uvm.h \
|
---|
53 | VBox/vscsi.h \
|
---|
54 | $(wildcard VBox/ExtPack/*.h ) \
|
---|
55 | $(wildcard iprt/win/*.h ) \
|
---|
56 | iprt/alloca.h \
|
---|
57 | iprt/tcp.h \
|
---|
58 | iprt/localipc.h \
|
---|
59 | iprt/linux/sysfs.h \
|
---|
60 | iprt/socket.h
|
---|
61 |
|
---|
62 | # We omit a few headers which have platform specific issues or are templates.
|
---|
63 | hdrs := $(filter-out \
|
---|
64 | VBox/HostServices/glext.h \
|
---|
65 | VBox/HostServices/glxext.h \
|
---|
66 | VBox/HostServices/wglext.h \
|
---|
67 | VBox/VBoxGuest16.h \
|
---|
68 | VBox/VBoxGL2D.h \
|
---|
69 | VBox/WinNetConfig.h \
|
---|
70 | VBox/usblib-win.h \
|
---|
71 | VBox/usblib-solaris.h \
|
---|
72 | VBox/VDEPlug.h \
|
---|
73 | $(if-expr "$(KBUILD_TARGET)" != "win", \
|
---|
74 | VBox/VBoxDrvCfg-win.h \
|
---|
75 | VBox/VBoxNetCfg-win.h \
|
---|
76 | ,) \
|
---|
77 | \
|
---|
78 | VBox/dbus-calls.h \
|
---|
79 | VBox/VDEPlugSymDefs.h \
|
---|
80 | VBox/VBoxKeyboard.h \
|
---|
81 | VBox/vmm/pdmpcidevint.h \
|
---|
82 | iprt/runtime-loader.h \
|
---|
83 | iprt/mangling.h \
|
---|
84 | \
|
---|
85 | $(foreach os,$(filter-out $(KBUILD_TARGET),$(KBUILD_OSES)),iprt/$(os)/% VBox/$(os)/%) \
|
---|
86 | $(xforeach arch,$(KBUILD_ARCHES),iprt/nocrt/$(arch)/%) \
|
---|
87 | , $(wildcard VBox/*.h VBox/*/*.h iprt/*.h iprt/*/*.h))
|
---|
88 |
|
---|
89 | # ring-3, ring-0 and raw-mode context specific exclusions.
|
---|
90 | hdrs.r3 := $(filter-out , $(hdrs))
|
---|
91 | hdrs-c.r3 := $(filter-out $(cpp_features_hdrs) $(r3_cpp_hdrs), $(hdrs.r3))
|
---|
92 | hdrs.r0 := $(filter-out $(r3_cpp_hdrs) $(r3_only_hdrs), $(hdrs))
|
---|
93 | hdrs-c.r0 := $(filter-out $(cpp_features_hdrs), $(hdrs.r0))
|
---|
94 | hdrs.rc := $(filter-out \
|
---|
95 | VBox/VBoxGuestLib.h \
|
---|
96 | VBox/vmm/gvm.h \
|
---|
97 | iprt/thread.h \
|
---|
98 | iprt/mem.h \
|
---|
99 | iprt/memsafer.h \
|
---|
100 | iprt/alloc.h \
|
---|
101 | $(r3_cpp_hdrs) \
|
---|
102 | $(r3_only_hdrs) \
|
---|
103 | , $(hdrs))
|
---|
104 | hdrs-c.rc := $(filter-out $(cpp_features_hdrs), $(hdrs.rc))
|
---|
105 |
|
---|
106 | SyntaxVBoxIncludeR3_TEMPLATE = VBOXMAINEXE
|
---|
107 | SyntaxVBoxIncludeR3_DEFS = VBOX_WITH_HGCM
|
---|
108 | SyntaxVBoxIncludeR3_CDEFS = VBOX_WITHOUT_UNNAMED_UNIONS
|
---|
109 | SyntaxVBoxIncludeR3_SOURCES := \
|
---|
110 | $(addprefix $(PATH_TARGET)/,$(subst .h,-c.c, $(subst /,_,$(hdrs-c.r3)))) \
|
---|
111 | $(addprefix $(PATH_TARGET)/,$(subst .h,-cpp.cpp, $(subst /,_,$(hdrs.r3))))
|
---|
112 |
|
---|
113 | SyntaxVBoxIncludeR0_TEMPLATE = VBoxR0
|
---|
114 | SyntaxVBoxIncludeR0_DEFS = VBOX_WITH_HGCM
|
---|
115 | SyntaxVBoxIncludeR0_CDEFS = VBOX_WITHOUT_UNNAMED_UNIONS
|
---|
116 | SyntaxVBoxIncludeR0_SOURCES := \
|
---|
117 | $(addprefix $(PATH_TARGET)/,$(subst .h,-c.c, $(subst /,_,$(hdrs-c.r0)))) \
|
---|
118 | $(addprefix $(PATH_TARGET)/,$(subst .h,-cpp.cpp, $(subst /,_,$(hdrs.r0))))
|
---|
119 |
|
---|
120 | SyntaxVBoxIncludeRC_TEMPLATE = VBoxRc
|
---|
121 | SyntaxVBoxIncludeRC_DEFS = VBOX_WITH_HGCM
|
---|
122 | SyntaxVBoxIncludeRC_CDEFS = VBOX_WITHOUT_UNNAMED_UNIONS
|
---|
123 | SyntaxVBoxIncludeRC_SOURCES := \
|
---|
124 | $(addprefix $(PATH_TARGET)/,$(subst .h,-c.c, $(subst /,_,$(hdrs-c.rc)))) \
|
---|
125 | $(addprefix $(PATH_TARGET)/,$(subst .h,-cpp.cpp, $(subst /,_,$(hdrs.rc))))
|
---|
126 |
|
---|
127 |
|
---|
128 | # Comment out the next line to simplify header correction.
|
---|
129 | VBOX_ROOT_INCLUDE_MAKEFILE = $(PATH_ROOT)/include/Makefile.kmk
|
---|
130 |
|
---|
131 | include $(FILE_KBUILD_FOOTER)
|
---|
132 |
|
---|
133 |
|
---|
134 | define def_hdr
|
---|
135 | $(eval flatname := $(subst /,_,$(basename $(hdr))))
|
---|
136 | $$(PATH_TARGET)/$(flatname)-cpp.cpp: $(VBOX_ROOT_INCLUDE_MAKEFILE) | $$(PATH_TARGET)/
|
---|
137 | $(QUIET)$$(APPEND) -t -n $$@ '#include <$(hdr)>' 'int main(int argc, char **argv) {(void)argc; (void)argv; return 0;}'
|
---|
138 |
|
---|
139 | $$(PATH_TARGET)/$(flatname)-c.c: $(VBOX_ROOT_INCLUDE_MAKEFILE) | $$(PATH_TARGET)/
|
---|
140 | $(QUIET)$$(APPEND) -t -n $$@ '#include <$(hdr)>' 'int main(int argc, char **argv) {(void)argc; (void)argv; return 0;}'
|
---|
141 |
|
---|
142 | $(subst .h,.o,$(notdir $(hdr)))::
|
---|
143 | if1of ($(hdr), $(r3_cpp_hdrs) $(cpp_features_hdrs))
|
---|
144 | $$(MAKE) -f $(MAKEFILE) $(flatname)-cpp.o
|
---|
145 | else
|
---|
146 | $$(MAKE) -f $(MAKEFILE) $(flatname)-c.o $(flatname)-cpp.o
|
---|
147 | endif
|
---|
148 |
|
---|
149 | endef
|
---|
150 |
|
---|
151 | $(foreach hdr,$(hdrs), $(eval $(def_hdr)))
|
---|
152 |
|
---|