1 # This top-level build file is included by all modules that implement
2 # the hardware OpenGL ES emulation for Android.
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
9 # The following macros are used to start a new GLES emulation module.
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...)
14 # NOTE: You still need to define LOCAL_PATH before this
18 # $(call emugl-begin-static-library,<name>)
19 # LOCAL_SRC_FILES := ....
20 # LOCAL_C_INCLUDES += ....
21 # $(call emugl-end-module)
23 emugl-begin-static-library = $(call emugl-begin-module,$1,STATIC_LIBRARY)
24 emugl-begin-shared-library = $(call emugl-begin-module,$1,SHARED_LIBRARY)
26 # Internal list of all declared modules (used for sanity checking)
28 _emugl_HOST_modules :=
30 # do not use directly, see functions above instead
31 emugl-begin-module = \
32 $(eval include $(CLEAR_VARS)) \
33 $(eval LOCAL_MODULE := $1) \
34 $(eval LOCAL_MODULE_CLASS := $(patsubst HOST_%,%,$(patsubst %EXECUTABLE,%EXECUTABLES,$(patsubst %LIBRARY,%LIBRARIES,$2)))) \
35 $(eval LOCAL_IS_HOST_MODULE := $(if $3,true,))\
36 $(eval LOCAL_C_INCLUDES := $(EMUGL_COMMON_INCLUDES)) \
37 $(eval LOCAL_CFLAGS := $(EMUGL_COMMON_CFLAGS)) \
38 $(eval _EMUGL_INCLUDE_TYPE := $(BUILD_$2)) \
39 $(call _emugl-init-module,$1,$2,$3)
41 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26 && echo TREBLE),TREBLE)
42 emugl-begin-module += $(eval LOCAL_VENDOR_MODULE := true)
45 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23 && echo PreMarshmallow),PreMarshmallow)
46 emugl-begin-module += $(eval include external/stlport/libstlport.mk)
48 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 21 && echo PreLollipop),PreLollipop)
49 emugl-begin-module += $(eval LOCAL_PRELINK_MODULE := false)
51 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 19 && echo PreKitkat),PreKitkat)
52 emugl-begin-module += $(eval LOCAL_MODULE_TAGS := debug)
53 emugl-begin-module += $(eval LOCAL_SHARED_LIBRARIES += libstlport)
56 # Used to end a module definition, see function definitions above
58 $(eval include $(_EMUGL_INCLUDE_TYPE))\
59 $(eval _EMUGL_INCLUDE_TYPE :=) \
60 $(eval _emugl_$(_emugl_HOST)modules += $(_emugl_MODULE))\
61 $(if $(EMUGL_DEBUG),$(call emugl-dump-module))
63 # Managing module exports and imports.
65 # A module can 'import' another module, by calling emugl-import. This will
66 # make the current LOCAL_MODULE inherit various definitions exported from
67 # the imported module.
69 # Module exports are defined by calling emugl-export. Here is an example:
71 # $(call emugl-begin-static-library,foo)
72 # LOCAL_SRC_FILES := foo.c
73 # $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
74 # $(call emugl-export,SHARED_LIBRARIES,libcutils)
75 # $(call emugl-end-module)
77 # $(call emugl-begin-shared-library,bar)
78 # LOCAL_SRC_FILES := bar.cpp
79 # $(call emugl-import,foo)
80 # $(call emugl-end-module)
82 # Here, we define a static library named 'foo' which exports an include
83 # path and a shared library requirement, and a shared library 'bar' which
86 # What this means is that:
88 # - 'bar' will automatically inherit foo's LOCAL_PATH in its LOCAL_C_INCLUDES
89 # - 'bar' will automatically inherit libcutils in its own LOCAL_SHARED_LIBRARIES
91 # Note that order of declaration matters. If 'foo' is defined after 'bar' in
92 # the example above, nothing will work correctly because dependencies are
93 # computed at import time.
96 # IMPORTANT: Imports are transitive, i.e. when module A imports B,
97 # it automatically imports anything imported by B too.
99 # This is the list of recognized export types we support for now.
100 EMUGL_EXPORT_TYPES := \
107 ADDITIONAL_DEPENDENCIES
109 ifdef IS_AT_LEAST_PPD1
110 EMUGL_EXPORT_TYPES += HEADER_LIBRARIES
113 # Initialize a module in our database
116 # $3: "HOST" for a host module, empty for a target one.
117 _emugl-init-module = \
118 $(eval _emugl_HOST := $(if $3,HOST_,))\
119 $(eval _emugl_MODULE := $(_emugl_HOST)$1)\
120 $(if $(filter $(_emugl_$(_emugl_HOST)modules),$(_emugl_MODULE)),\
121 $(error There is already a $(if $3,host,) module named $1!)\
123 $(eval _mod = $(_emugl_MODULE)) \
124 $(eval _emugl.$(_mod).type := $(patsubst HOST_%,%,$2))\
125 $(eval _emugl.$(_mod).imports :=) \
126 $(eval _emugl,$(_mod).moved :=) \
127 $(foreach _type,$(EMUGL_EXPORT_TYPES),\
128 $(eval _emugl.$(_mod).export.$(_type) :=)\
131 # Called to indicate that a module exports a given local variable for its
132 # users. This also adds this to LOCAL_$1
133 # $1: Local variable type (e.g. CFLAGS, LDLIBS, etc...)
134 # $2: Value(s) to append to the export
136 $(eval _emugl.$(_emugl_MODULE).export.$1 += $2)\
137 $(eval LOCAL_$1 := $2 $(LOCAL_$1))
139 emugl-export-outer = \
140 $(eval _emugl.$(_emugl_MODULE).export.$1 += $2)
142 # Called to indicate that a module imports the exports of another module
143 # $1: list of modules to import
147 $(call _emugl-module-import,$(_emugl_HOST)$(_imod))\
150 _emugl-module-import = \
151 $(eval _mod := $(_emugl_MODULE))\
152 $(if $(filter-out $(_emugl_$(_emugl_HOST)modules),$1),\
153 $(info Unknown imported emugles module: $1)\
154 $(if $(_emugl_HOST),\
155 $(eval _names := $(patsubst HOST_%,%,$(_emugl_HOST_modules))),\
156 $(eval _names := $(_emugl_modules))\
158 $(info Please one of the following names: $(_names))\
161 $(if $(filter-out $(_emugl.$(_mod).imports),$1),\
162 $(eval _emugl.$(_mod).imports += $1)\
163 $(foreach _sub,$(_emugl.$1.imports),\
164 $(call _emugl-module-import,$(_sub))\
166 $(foreach _type,$(EMUGL_EXPORT_TYPES),\
167 $(eval LOCAL_$(_type) := $(_emugl.$1.export.$(_type)) $(LOCAL_$(_type)))\
169 $(if $(filter EXECUTABLE SHARED_LIBRARY,$(_emugl.$(_emugl_MODULE).type)),\
170 $(if $(filter STATIC_LIBRARY,$(_emugl.$1.type)),\
171 $(eval LOCAL_STATIC_LIBRARIES := $(1:HOST_%=%) $(LOCAL_STATIC_LIBRARIES))\
173 $(if $(filter SHARED_LIBRARY,$(_emugl.$1.type)),\
174 $(if $(_emugl.$1.moved),,\
175 $(eval LOCAL_SHARED_LIBRARIES := $(1:HOST_%=%) $(LOCAL_SHARED_LIBRARIES))\
182 $(foreach _list_item,$(strip $1),$(info . $(_list_item)))
184 emugl-dump-module = \
185 $(info MODULE=$(_emugl_MODULE))\
186 $(info . HOST=$(_emugl_HOST))\
187 $(info . TYPE=$(_emugl.$(_emugl_MODULE).type))\
188 $(info . IMPORTS=$(_emugl.$(_emugl_MODULE).imports))\
189 $(foreach _type,$(EMUGL_EXPORT_TYPES),\
190 $(if $(filter C_INCLUDES ADDITIONAL_DEPENDENCIES,$(_type)),\
191 $(info . EXPORT.$(_type) :=)\
192 $(call _emugl-dump-list,$(_emugl.$(_emugl_MODULE).export.$(_type)))\
193 $(info . LOCAL_$(_type) :=)\
194 $(call _emugl-dump-list,$(LOCAL_$(_type)))\
196 $(info . EXPORT.$(_type) := $(strip $(_emugl.$(_emugl_MODULE).export.$(_type))))\
197 $(info . LOCAL_$(_type) := $(strip $(LOCAL_$(_type))))\
200 $(info . LOCAL_SRC_FILES := $(LOCAL_SRC_FILES))\
202 # This function can be called to generate the wrapper source files.
203 # LOCAL_MODULE and LOCAL_MODULE_CLASS must be defined or the build will abort.
204 # Source files will be stored in the local intermediates directory that will
205 # be automatically added to your LOCAL_C_INCLUDES.
207 # $(call emugl-gen-wrapper,<input-dir>,<basename>)
209 emugl-gen-wrapper = \
210 $(eval _emugl_out := $(call local-intermediates-dir)) \
211 $(call emugl-gen-wrapper-generic,$(_emugl_out),$1,$2) \
212 $(call emugl-export,C_INCLUDES,$(_emugl_out))
214 # DO NOT CALL DIRECTLY, USE emugl-gen-wrapper instead.
216 # The following function can be called to generate GL library wrapper
219 # $(call emugl-gen-wrapper-generic,<dst-dir>,<src-dir>,<basename>)
221 # <dst-dir> is the destination directory where the generated sources are stored
222 # <src-dir> is the source directory where to find <basename>.attrib, etc..
223 # <basename> is the emugen basename (see host/tools/emugen/README)
225 emugl-gen-wrapper-generic = $(eval $(emugl-gen-wrapper-generic-ev))
227 define emugl-gen-wrapper-generic-ev
228 _emugl_wrap := $$1/$$3
229 _emugl_src := $$2/$$3
230 GEN := $$(_emugl_wrap)_wrapper_entry.cpp \
231 $$(_emugl_wrap)_wrapper_context.cpp \
232 $$(_emugl_wrap)_wrapper_context.h \
233 $$(_emugl_wrap)_wrapper_proc.h
235 $$(GEN): PRIVATE_PATH := $$(LOCAL_PATH)
236 $$(GEN): PRIVATE_CUSTOM_TOOL := $$(EMUGL_EMUGEN) -W $$1 -i $$2 $$3
237 $$(GEN): $$(EMUGL_EMUGEN) $$(_emugl_src).attrib $$(_emugl_src).in $$(_emugl_src).types
238 $$(transform-generated-source)
240 $$(call emugl-export,ADDITIONAL_DEPENDENCIES,$$(GEN))
241 LOCAL_GENERATED_SOURCES += $$(GEN)
242 LOCAL_C_INCLUDES += $$1
244 #ifneq ($$(HOST_OS),windows)
245 $$(call emugl-export,LDFLAGS,-ldl)
250 # Call this function when your shared library must be placed in a non-standard
251 # library path (i.e. not under /system/lib
252 # $1: library sub-path,relative to /system/lib
253 # For example: $(call emugl-set-shared-library-subpath,egl)
255 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 21 && echo PreLollipop),PreLollipop)
256 emugl-set-shared-library-subpath = \
257 $(eval LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/$1)\
258 $(eval LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/$1)\
259 $(eval _emugl.$(LOCAL_MODULE).moved := true)\
260 $(call emugl-export-outer,ADDITIONAL_DEPENDENCIES,$(LOCAL_MODULE_PATH)/$(LOCAL_MODULE)$(TARGET_SHLIB_SUFFIX))
262 emugl-set-shared-library-subpath = \
263 $(eval LOCAL_MODULE_RELATIVE_PATH := $1)\
264 $(eval _emugl.$(LOCAL_MODULE).moved := true)