76fd4e92ab97615092e1f665b34d82f62dc43fcc
[iec.git] / src / type3_AndroidCloud / anbox-master / external / android-emugl / common.mk
1 # This top-level build file is included by all modules that implement
2 # the hardware OpenGL ES emulation for Android.
3 #
4 # We use it to ensure that all sub-Makefiles are included in the right
5 # order for various variable definitions and usage to happen in the correct
6 # order.
7 #
8
9 # The following macros are used to start a new GLES emulation module.
10 #
11 # This will define LOCAL_MODULE as $1, plus a few other variables
12 # needed by the build system (e.g. LOCAL_MODULE_TAGS, LOCAL_MODULE_CLASS...)
13 #
14 # NOTE: You still need to define LOCAL_PATH before this
15 #
16 # Usage example:
17 #
18 #   $(call emugl-begin-static-library,<name>)
19 #       LOCAL_SRC_FILES := ....
20 #       LOCAL_C_INCLUDES += ....
21 #   $(call emugl-end-module)
22 #
23 emugl-begin-host-static-library = $(call emugl-begin-module,$1,HOST_STATIC_LIBRARY,HOST)
24 emugl-begin-host-shared-library = $(call emugl-begin-module,$1,HOST_SHARED_LIBRARY,HOST)
25 emugl-begin-host-executable = $(call emugl-begin-module,$1,HOST_EXECUTABLE,HOST)
26
27 # Internal list of all declared modules (used for sanity checking)
28 _emugl_modules :=
29 _emugl_HOST_modules :=
30
31 # do not use directly, see functions above instead
32 emugl-begin-module = \
33     $(eval include $(CLEAR_VARS)) \
34     $(eval LOCAL_MODULE := $1) \
35     $(eval LOCAL_MODULE_TAGS := $(if $3,,debug)) \
36     $(eval LOCAL_MODULE_CLASS := $(patsubst HOST_%,%,$(patsubst %EXECUTABLE,%EXECUTABLES,$(patsubst %LIBRARY,%LIBRARIES,$2)))) \
37     $(eval LOCAL_IS_HOST_MODULE := $(if $3,true,))\
38     $(eval LOCAL_C_INCLUDES += $(EMUGL_COMMON_INCLUDES)) \
39     $(eval LOCAL_CFLAGS += $(EMUGL_COMMON_CFLAGS)) \
40     $(eval LOCAL_LDLIBS += $(CXX_STD_LIB)) \
41     $(eval LOCAL_BUILD_FILE := $(BUILD_$2)) \
42     $(call _emugl-init-module,$1,$2,$3)
43
44 # Used to end a module definition, see function definitions above
45 emugl-end-module = \
46     $(eval $(end-emulator-module-ev)) \
47     $(eval LOCAL_BUILD_FILE :=) \
48     $(eval _emugl_$(_emugl_HOST)modules += $(_emugl_MODULE))\
49     $(if $(EMUGL_DEBUG),$(call emugl-dump-module))
50
51 # Managing module exports and imports.
52 #
53 # A module can 'import' another module, by calling emugl-import. This will
54 # make the current LOCAL_MODULE inherit various definitions exported from
55 # the imported module.
56 #
57 # Module exports are defined by calling emugl-export. Here is an example:
58 #
59 #      $(call emugl-begin-static-library,foo)
60 #      LOCAL_SRC_FILES := foo.c
61 #      $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
62 #      $(call emugl-export,SHARED_LIBRARIES,libcutils)
63 #      $(call emugl-end-module)
64 #
65 #      $(call emugl-begin-shared-library,bar)
66 #      LOCAL_SRC_FILES := bar.cpp
67 #      $(call emugl-import,foo)
68 #      $(call emugl-end-module)
69 #
70 # Here, we define a static library named 'foo' which exports an include
71 # path and a shared library requirement, and a shared library 'bar' which
72 # imports it.
73 #
74 # What this means is that:
75 #
76 #    - 'bar' will automatically inherit foo's LOCAL_PATH in its LOCAL_C_INCLUDES
77 #    - 'bar' will automatically inherit libcutils in its own LOCAL_SHARED_LIBRARIES
78 #
79 # Note that order of declaration matters. If 'foo' is defined after 'bar' in
80 # the example above, nothing will work correctly because dependencies are
81 # computed at import time.
82 #
83 #
84 # IMPORTANT: Imports are transitive, i.e. when module A imports B,
85 #            it automatically imports anything imported by B too.
86
87 # This is the list of recognized export types we support for now.
88 EMUGL_EXPORT_TYPES := \
89     CFLAGS \
90     CXXFLAGS \
91     LDLIBS \
92     LDFLAGS \
93     C_INCLUDES \
94     SHARED_LIBRARIES \
95     STATIC_LIBRARIES \
96     ADDITIONAL_DEPENDENCIES
97
98 # Initialize a module in our database
99 # $1: Module name
100 # $2: Module type
101 # $3: "HOST" for a host module, empty for a target one.
102 _emugl-init-module = \
103     $(eval _emugl_HOST := $(if $3,HOST_,))\
104     $(eval _emugl_MODULE := $(_emugl_HOST)$1)\
105     $(if $(filter $(_emugl_$(_emugl_HOST)modules),$(_emugl_MODULE)),\
106         $(error There is already a $(if $3,host,) module named $1!)\
107     )\
108     $(eval _mod = $(_emugl_MODULE)) \
109     $(eval _emugl.$(_mod).type := $(patsubst HOST_%,%,$2))\
110     $(eval _emugl.$(_mod).imports :=) \
111     $(eval _emugl,$(_mod).moved :=) \
112     $(foreach _type,$(EMUGL_EXPORT_TYPES),\
113         $(eval _emugl.$(_mod).export.$(_type) :=)\
114     )
115
116 # Called to indicate that a module exports a given local variable for its
117 # users. This also adds this to LOCAL_$1
118 # $1: Local variable type (e.g. CFLAGS, LDLIBS, etc...)
119 # $2: Value(s) to append to the export
120 emugl-export = \
121     $(eval _emugl.$(_emugl_MODULE).export.$1 += $2)\
122     $(eval LOCAL_$1 := $(LOCAL_$1) $2)
123
124 emugl-export-outer = \
125     $(eval _emugl.$(_emugl_MODULE).export.$1 += $2)
126
127 # Called to indicate that a module imports the exports of another module
128 # $1: list of modules to import
129 #
130 emugl-import = \
131     $(foreach _imod,$1,\
132         $(call _emugl-module-import,$(_emugl_HOST)$(_imod))\
133     )
134
135 _emugl-module-import = \
136     $(eval _mod := $(_emugl_MODULE))\
137     $(if $(filter-out $(_emugl_$(_emugl_HOST)modules),$1),\
138         $(info Unknown imported emugles module: $1)\
139         $(if $(_emugl_HOST),\
140             $(eval _names := $(patsubst HOST_%,%,$(_emugl_HOST_modules))),\
141             $(eval _names := $(_emugl_modules))\
142         )\
143         $(info Please one of the following names: $(_names))\
144         $(error Aborting)\
145     )\
146     $(if $(filter-out $(_emugl.$(_mod).imports),$1),\
147         $(eval _emugl.$(_mod).imports += $1)\
148         $(foreach _sub,$(_emugl.$1.imports),\
149             $(call _emugl-module-import,$(_sub))\
150         )\
151         $(foreach _type,$(EMUGL_EXPORT_TYPES),\
152             $(eval LOCAL_$(_type) := $(LOCAL_$(_type)) $(_emugl.$1.export.$(_type)))\
153         )\
154         $(if $(filter EXECUTABLE SHARED_LIBRARY,$(_emugl.$(_emugl_MODULE).type)),\
155             $(if $(filter STATIC_LIBRARY,$(_emugl.$1.type)),\
156                 $(eval LOCAL_STATIC_LIBRARIES := $(1:HOST_%=%) $(LOCAL_STATIC_LIBRARIES))\
157             )\
158             $(if $(filter SHARED_LIBRARY,$(_emugl.$1.type)),\
159                 $(if $(_emugl.$1.moved),,\
160                   $(eval LOCAL_SHARED_LIBRARIES := $(1:HOST_%=%) $(LOCAL_SHARED_LIBRARIES))\
161                 )\
162             )\
163         )\
164     )
165
166 _emugl-dump-list = \
167     $(foreach _list_item,$(strip $1),$(info .    $(_list_item)))
168
169 emugl-dump-module = \
170     $(info MODULE=$(_emugl_MODULE))\
171     $(info .  HOST=$(_emugl_HOST))\
172     $(info .  TYPE=$(_emugl.$(_emugl_MODULE).type))\
173     $(info .  IMPORTS=$(_emugl.$(_emugl_MODULE).imports))\
174     $(foreach _type,$(EMUGL_EXPORT_TYPES),\
175         $(if $(filter C_INCLUDES ADDITIONAL_DEPENDENCIES,$(_type)),\
176             $(info .  EXPORT.$(_type) :=)\
177             $(call _emugl-dump-list,$(_emugl.$(_emugl_MODULE).export.$(_type)))\
178             $(info .  LOCAL_$(_type)  :=)\
179             $(call _emugl-dump-list,$(LOCAL_$(_type)))\
180         ,\
181             $(info .  EXPORT.$(_type) := $(strip $(_emugl.$(_emugl_MODULE).export.$(_type))))\
182             $(info .  LOCAL_$(_type)  := $(strip $(LOCAL_$(_type))))\
183         )\
184     )\
185     $(info .  LOCAL_SRC_FILES := $(LOCAL_SRC_FILES))\
186
187 # This function can be called to generate the decoder source files.
188 # LOCAL_MODULE and LOCAL_MODULE_CLASS must be defined or the build will abort.
189 # Source files will be stored in the local intermediates directory that will
190 # be automatically added to your LOCAL_C_INCLUDES.
191 #
192 # Usage:
193 #    $(call emugl-gen-decoder,<input-dir>,<basename>)
194 #
195 emugl-gen-decoder = \
196     $(eval _emugl_out := $(call intermediates-dir-for,$(BUILD_TARGET_BITS),$2))\
197     $(call emugl-gen-decoder-generic,$(_emugl_out),$1,$2)\
198     $(call emugl-export,C_INCLUDES,$(_emugl_out))
199
200 # DO NOT CALL DIRECTLY, USE emugl-gen-decoder instead.
201 #
202 # The following function can be called to generate wire protocol decoder
203 # source files, Usage is:
204 #
205 #  $(call emugl-gen-decoder-generic,<dst-dir>,<src-dir>,<basename>)
206 #
207 #  <dst-dir> is the destination directory where the generated sources are stored
208 #  <src-dir> is the source directory where to find <basename>.attrib, etc..
209 #  <basename> is the emugen basename (see host/tools/emugen/README)
210 #
211 emugl-gen-decoder-generic = $(eval $(emugl-gen-decoder-generic-ev))
212
213 define emugl-gen-decoder-generic-ev
214 _emugl_dec := $$1/$$3
215 _emugl_src := $$2/$$3
216 GEN := $$(_emugl_dec)_dec.cpp \
217        $$(_emugl_dec)_dec.h \
218        $$(_emugl_dec)_opcodes.h \
219        $$(_emugl_dec)_server_context.h \
220        $$(_emugl_dec)_server_context.cpp
221
222 $$(GEN): PRIVATE_PATH := $$(LOCAL_PATH)
223 $$(GEN): PRIVATE_CUSTOM_TOOL := $$(EMUGL_EMUGEN) -D $$1 -i $$2 $$3
224 $$(GEN): $$(EMUGL_EMUGEN) $$(_emugl_src).attrib $$(_emugl_src).in $$(_emugl_src).types
225         $$(transform-generated-source)
226
227 $$(call emugl-export,ADDITIONAL_DEPENDENCIES,$$(GEN))
228 LOCAL_GENERATED_SOURCES += $$(GEN)
229 LOCAL_C_INCLUDES += $$1
230 endef
231
232 # Call this function when your shared library must be placed in a non-standard
233 # library path (i.e. not under /system/lib
234 # $1: library sub-path,relative to /system/lib
235 # For example: $(call emugl-set-shared-library-subpath,egl)
236 emugl-set-shared-library-subpath = \
237     $(eval LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/$1)\
238     $(eval LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/$1)\
239     $(eval _emugl.$(LOCAL_MODULE).moved := true)\
240     $(call emugl-export-outer,ADDITIONAL_DEPENDENCIES,$(LOCAL_MODULE_PATH)/$(LOCAL_MODULE)$(TARGET_SHLIB_SUFFIX))
241