1bf215546Sopenharmony_ci# Mesa 3-D graphics library
2bf215546Sopenharmony_ci#
3bf215546Sopenharmony_ci# Copyright (C) 2021 GlobalLogic Ukraine
4bf215546Sopenharmony_ci# Copyright (C) 2021 Roman Stratiienko (r.stratiienko@gmail.com)
5bf215546Sopenharmony_ci#
6bf215546Sopenharmony_ci# Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci# copy of this software and associated documentation files (the "Software"),
8bf215546Sopenharmony_ci# to deal in the Software without restriction, including without limitation
9bf215546Sopenharmony_ci# the rights to use, copy, modify, merge, publish, distribute, sublicense,
10bf215546Sopenharmony_ci# and/or sell copies of the Software, and to permit persons to whom the
11bf215546Sopenharmony_ci# Software is furnished to do so, subject to the following conditions:
12bf215546Sopenharmony_ci#
13bf215546Sopenharmony_ci# The above copyright notice and this permission notice shall be included
14bf215546Sopenharmony_ci# in all copies or substantial portions of the Software.
15bf215546Sopenharmony_ci#
16bf215546Sopenharmony_ci# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17bf215546Sopenharmony_ci# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18bf215546Sopenharmony_ci# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19bf215546Sopenharmony_ci# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20bf215546Sopenharmony_ci# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21bf215546Sopenharmony_ci# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22bf215546Sopenharmony_ci# DEALINGS IN THE SOFTWARE.
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ciMY_PATH := $(call my-dir)
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ciAOSP_ABSOLUTE_PATH := $(realpath .)
27bf215546Sopenharmony_cidefine relative-to-absolute
28bf215546Sopenharmony_ci$(if $(patsubst /%,,$1),$(AOSP_ABSOLUTE_PATH)/$1,$1)
29bf215546Sopenharmony_ciendef
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ciLOCAL_MODULE_CLASS := SHARED_LIBRARIES
32bf215546Sopenharmony_ciLOCAL_MODULE := meson.dummy.$(LOCAL_MULTILIB)
33bf215546Sopenharmony_ci
34bf215546Sopenharmony_cim_dummy := $(local-generated-sources-dir)/dummy.c
35bf215546Sopenharmony_ci$(m_dummy):
36bf215546Sopenharmony_ci	mkdir -p $(dir $@)
37bf215546Sopenharmony_ci	touch $@
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_ciLOCAL_GENERATED_SOURCES := $(m_dummy)
40bf215546Sopenharmony_ciLOCAL_VENDOR_MODULE := true
41bf215546Sopenharmony_ci
42bf215546Sopenharmony_ci# Prepare intermediate variables by AOSP make/core internals
43bf215546Sopenharmony_ciinclude $(BUILD_SHARED_LIBRARY)
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_ciLOCAL_PATH := $(MY_PATH)
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_cilink_deps := \
48bf215546Sopenharmony_ci	$(built_static_libraries) \
49bf215546Sopenharmony_ci	$(built_shared_libraries) \
50bf215546Sopenharmony_ci	$(built_whole_libraries) \
51bf215546Sopenharmony_ci	$(strip $(all_objects)) \
52bf215546Sopenharmony_ci	$(my_target_libatomic) \
53bf215546Sopenharmony_ci	$(my_target_libcrt_builtins) \
54bf215546Sopenharmony_ci	$(my_target_crtbegin_so_o) \
55bf215546Sopenharmony_ci	$(my_target_crtend_so_o)
56bf215546Sopenharmony_ci
57bf215546Sopenharmony_ci# Build mesa3d using intermediate variables provided by AOSP make/core internals
58bf215546Sopenharmony_ciM_TARGET_PREFIX := $(my_2nd_arch_prefix)
59bf215546Sopenharmony_ci
60bf215546Sopenharmony_ciMESA3D_LIB_DIR := lib$(subst 32,,$(LOCAL_MULTILIB))
61bf215546Sopenharmony_ci
62bf215546Sopenharmony_ciMESON_OUT_DIR                            := $($(M_TARGET_PREFIX)TARGET_OUT_INTERMEDIATES)/MESON_MESA3D
63bf215546Sopenharmony_ciMESON_GEN_DIR                            := $(MESON_OUT_DIR)_GEN
64bf215546Sopenharmony_ciMESON_GEN_FILES_TARGET                   := $(MESON_GEN_DIR)/.timestamp
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_ciMESA3D_GALLIUM_DRI_DIR                   := $(MESON_OUT_DIR)/install/usr/local/lib/dri
67bf215546Sopenharmony_ci$(M_TARGET_PREFIX)MESA3D_GALLIUM_DRI_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libgallium_dri.so
68bf215546Sopenharmony_ci$(M_TARGET_PREFIX)MESA3D_LIBEGL_BIN      := $(MESON_OUT_DIR)/install/usr/local/lib/libEGL.so.1.0.0
69bf215546Sopenharmony_ci$(M_TARGET_PREFIX)MESA3D_LIBGLESV1_BIN   := $(MESON_OUT_DIR)/install/usr/local/lib/libGLESv1_CM.so.1.1.0
70bf215546Sopenharmony_ci$(M_TARGET_PREFIX)MESA3D_LIBGLESV2_BIN   := $(MESON_OUT_DIR)/install/usr/local/lib/libGLESv2.so.2.0.0
71bf215546Sopenharmony_ci$(M_TARGET_PREFIX)MESA3D_LIBGLAPI_BIN    := $(MESON_OUT_DIR)/install/usr/local/lib/libglapi.so.0.0.0
72bf215546Sopenharmony_ci$(M_TARGET_PREFIX)MESA3D_LIBGBM_BIN      := $(MESON_OUT_DIR)/install/usr/local/lib/libgbm.so.1.0.0
73bf215546Sopenharmony_ci
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ciMESA3D_GLES_BINS := \
76bf215546Sopenharmony_ci    $($(M_TARGET_PREFIX)MESA3D_LIBEGL_BIN)    \
77bf215546Sopenharmony_ci    $($(M_TARGET_PREFIX)MESA3D_LIBGLESV1_BIN) \
78bf215546Sopenharmony_ci    $($(M_TARGET_PREFIX)MESA3D_LIBGLESV2_BIN) \
79bf215546Sopenharmony_ci    $($(M_TARGET_PREFIX)MESA3D_LIBGLAPI_BIN)  \
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_ciMESON_GEN_NINJA := \
82bf215546Sopenharmony_ci	cd $(MESON_OUT_DIR) && PATH=/usr/bin:/usr/local/bin:$$PATH meson ./build     \
83bf215546Sopenharmony_ci	--cross-file $(call relative-to-absolute,$(MESON_GEN_DIR))/aosp_cross        \
84bf215546Sopenharmony_ci	--buildtype=release                                                          \
85bf215546Sopenharmony_ci	-Ddri-search-path=/vendor/$(MESA3D_LIB_DIR)/dri                              \
86bf215546Sopenharmony_ci	-Dplatforms=android                                                          \
87bf215546Sopenharmony_ci	-Dplatform-sdk-version=$(PLATFORM_SDK_VERSION)                               \
88bf215546Sopenharmony_ci	-Ddri-drivers=$(subst $(space),$(comma),$(BOARD_MESA3D_CLASSIC_DRIVERS))     \
89bf215546Sopenharmony_ci	-Dgallium-drivers=$(subst $(space),$(comma),$(BOARD_MESA3D_GALLIUM_DRIVERS)) \
90bf215546Sopenharmony_ci	-Dvulkan-drivers=$(subst $(space),$(comma),$(subst radeon,amd,$(BOARD_MESA3D_VULKAN_DRIVERS)))   \
91bf215546Sopenharmony_ci	-Dgbm=enabled                                                                \
92bf215546Sopenharmony_ci	-Degl=enabled                                                                \
93bf215546Sopenharmony_ci	-Dcpp_rtti=false                                                             \
94bf215546Sopenharmony_ci
95bf215546Sopenharmony_ciMESON_BUILD := PATH=/usr/bin:/bin:/sbin:$$PATH ninja -C $(MESON_OUT_DIR)/build
96bf215546Sopenharmony_ci
97bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): MESON_CPU_FAMILY := $(subst arm64,aarch64,$(TARGET_$(M_TARGET_PREFIX)ARCH))
98bf215546Sopenharmony_ci
99bf215546Sopenharmony_cidefine create-pkgconfig
100bf215546Sopenharmony_ciecho -e "Name: $2" \
101bf215546Sopenharmony_ci	"\nDescription: $2" \
102bf215546Sopenharmony_ci	"\nVersion: $3" > $1/$2.pc
103bf215546Sopenharmony_ci
104bf215546Sopenharmony_ciendef
105bf215546Sopenharmony_ci
106bf215546Sopenharmony_ci# Taken from build/make/core/binary.mk. We need this
107bf215546Sopenharmony_ci# to use definitions from build/make/core/definitions.mk
108bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_GLOBAL_C_INCLUDES := $(my_target_global_c_includes)
109bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_target_global_c_system_includes)
110bf215546Sopenharmony_ci
111bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_2ND_ARCH_VAR_PREFIX := $(M_TARGET_PREFIX)
112bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_CC := $(my_cc)
113bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_LINKER := $(my_linker)
114bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_CXX := $(my_cxx)
115bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_CXX_LINK := $(my_cxx_link)
116bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
117bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_ASFLAGS := $(my_asflags)
118bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_CONLYFLAGS := $(my_conlyflags)
119bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_CFLAGS := $(my_cflags)
120bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_CPPFLAGS := $(my_cppflags)
121bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override)
122bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override)
123bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
124bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
125bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_C_INCLUDES := $(my_c_includes)
126bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_IMPORTED_INCLUDES := $(imported_includes)
127bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_LDFLAGS := $(my_ldflags)
128bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_LDLIBS := $(my_ldlibs)
129bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_TIDY_CHECKS := $(my_tidy_checks)
130bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_TIDY_FLAGS := $(my_tidy_flags)
131bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_ARFLAGS := $(my_arflags)
132bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
133bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
134bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
135bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_OBJECTS := $(strip $(all_objects))
136bf215546Sopenharmony_ci
137bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
138bf215546Sopenharmony_ci
139bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
140bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags)
141bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
142bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
143bf215546Sopenharmony_ci
144bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins)
145bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic)
146bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o)
147bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o)
148bf215546Sopenharmony_ci##
149bf215546Sopenharmony_ci
150bf215546Sopenharmony_cidefine m-lld-flags
151bf215546Sopenharmony_ci  -nostdlib -Wl,--gc-sections \
152bf215546Sopenharmony_ci  $(PRIVATE_TARGET_CRTBEGIN_SO_O) \
153bf215546Sopenharmony_ci  $(PRIVATE_ALL_OBJECTS) \
154bf215546Sopenharmony_ci  -Wl,--whole-archive \
155bf215546Sopenharmony_ci  $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
156bf215546Sopenharmony_ci  -Wl,--no-whole-archive \
157bf215546Sopenharmony_ci  $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
158bf215546Sopenharmony_ci  $(PRIVATE_ALL_STATIC_LIBRARIES) \
159bf215546Sopenharmony_ci  $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
160bf215546Sopenharmony_ci  $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
161bf215546Sopenharmony_ci  $(PRIVATE_TARGET_LIBCRT_BUILTINS) \
162bf215546Sopenharmony_ci  $(PRIVATE_TARGET_LIBATOMIC) \
163bf215546Sopenharmony_ci  $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
164bf215546Sopenharmony_ci  $(PRIVATE_LDFLAGS) \
165bf215546Sopenharmony_ci  $(PRIVATE_ALL_SHARED_LIBRARIES) \
166bf215546Sopenharmony_ci  $(PRIVATE_TARGET_CRTEND_SO_O) \
167bf215546Sopenharmony_ci  $(PRIVATE_LDLIBS)
168bf215546Sopenharmony_ciendef
169bf215546Sopenharmony_ci
170bf215546Sopenharmony_cidefine m-lld-flags-cleaned
171bf215546Sopenharmony_ci  $(subst prebuilts/,$(AOSP_ABSOLUTE_PATH)/prebuilts/, \
172bf215546Sopenharmony_ci  $(subst $(OUT_DIR)/,$(call relative-to-absolute,$(OUT_DIR))/, \
173bf215546Sopenharmony_ci  $(subst -Wl$(comma)--fatal-warnings,,                \
174bf215546Sopenharmony_ci  $(subst -Wl$(comma)--no-undefined-version,,          \
175bf215546Sopenharmony_ci  $(subst -Wl$(comma)--gc-sections,,                   \
176bf215546Sopenharmony_ci  $(patsubst %dummy.o,,                                \
177bf215546Sopenharmony_ci    $(m-lld-flags)))))))
178bf215546Sopenharmony_ciendef
179bf215546Sopenharmony_ci
180bf215546Sopenharmony_cidefine m-cpp-flags
181bf215546Sopenharmony_ci  $(PRIVATE_TARGET_GLOBAL_CFLAGS) \
182bf215546Sopenharmony_ci  $(PRIVATE_TARGET_GLOBAL_CPPFLAGS) \
183bf215546Sopenharmony_ci  $(PRIVATE_ARM_CFLAGS) \
184bf215546Sopenharmony_ci  $(PRIVATE_RTTI_FLAG) \
185bf215546Sopenharmony_ci  $(PRIVATE_CFLAGS) \
186bf215546Sopenharmony_ci  $(PRIVATE_CPPFLAGS) \
187bf215546Sopenharmony_ci  $(PRIVATE_DEBUG_CFLAGS) \
188bf215546Sopenharmony_ci  $(PRIVATE_CFLAGS_NO_OVERRIDE) \
189bf215546Sopenharmony_ci  $(PRIVATE_CPPFLAGS_NO_OVERRIDE)
190bf215546Sopenharmony_ciendef
191bf215546Sopenharmony_ci
192bf215546Sopenharmony_cidefine m-c-flags
193bf215546Sopenharmony_ci  $(PRIVATE_TARGET_GLOBAL_CFLAGS) \
194bf215546Sopenharmony_ci  $(PRIVATE_TARGET_GLOBAL_CONLYFLAGS) \
195bf215546Sopenharmony_ci  $(PRIVATE_ARM_CFLAGS) \
196bf215546Sopenharmony_ci  $(PRIVATE_CFLAGS) \
197bf215546Sopenharmony_ci  $(PRIVATE_CONLYFLAGS) \
198bf215546Sopenharmony_ci  $(PRIVATE_DEBUG_CFLAGS) \
199bf215546Sopenharmony_ci  $(PRIVATE_CFLAGS_NO_OVERRIDE)
200bf215546Sopenharmony_ciendef
201bf215546Sopenharmony_ci
202bf215546Sopenharmony_cidefine filter-c-flags
203bf215546Sopenharmony_ci  $(filter-out -std=gnu++17 -std=gnu++14 -std=gnu99 -fno-rtti, \
204bf215546Sopenharmony_ci    $(patsubst  -W%,, $1))
205bf215546Sopenharmony_ciendef
206bf215546Sopenharmony_ci
207bf215546Sopenharmony_cidefine nospace-includes
208bf215546Sopenharmony_ci  $(subst $(space)-isystem$(space),$(space)-isystem, \
209bf215546Sopenharmony_ci  $(subst $(space)-I$(space),$(space)-I, \
210bf215546Sopenharmony_ci  $(strip $(c-includes))))
211bf215546Sopenharmony_ciendef
212bf215546Sopenharmony_ci
213bf215546Sopenharmony_ci# Ensure include paths are always absolute
214bf215546Sopenharmony_ci# When OUT_DIR_COMMON_BASE env variable is set the AOSP/KATI will use absolute paths
215bf215546Sopenharmony_ci# for headers in intermediate output directories, but relative for all others.
216bf215546Sopenharmony_cidefine abs-include
217bf215546Sopenharmony_ci$(strip \
218bf215546Sopenharmony_ci  $(if $(patsubst -I%,,$1),\
219bf215546Sopenharmony_ci    $(if $(patsubst -isystem/%,,$1),\
220bf215546Sopenharmony_ci      $(subst -isystem,-isystem$(AOSP_ABSOLUTE_PATH)/,$1),\
221bf215546Sopenharmony_ci      $1\
222bf215546Sopenharmony_ci    ),\
223bf215546Sopenharmony_ci    $(if $(patsubst -I/%,,$1),\
224bf215546Sopenharmony_ci      $(subst -I,-I$(AOSP_ABSOLUTE_PATH)/,$1),\
225bf215546Sopenharmony_ci      $1\
226bf215546Sopenharmony_ci    )\
227bf215546Sopenharmony_ci  )
228bf215546Sopenharmony_ci)
229bf215546Sopenharmony_ciendef
230bf215546Sopenharmony_ci
231bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): PREPROCESS_MESON_CONFIGS:=$(PREPROCESS_MESON_CONFIGS)
232bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): MESON_GEN_DIR:=$(MESON_GEN_DIR)
233bf215546Sopenharmony_ci$(MESON_GEN_FILES_TARGET): $(sort $(shell find -L $(MESA3D_TOP) -not -path '*/\.*'))
234bf215546Sopenharmony_ci	mkdir -p $(dir $@)
235bf215546Sopenharmony_ci	echo -e "[properties]\n"                                                                                                  \
236bf215546Sopenharmony_ci		"c_args = [$(foreach flag,$(call filter-c-flags,$(m-c-flags)),'$(flag)', ) \
237bf215546Sopenharmony_ci                           $(foreach inc,$(nospace-includes),'$(call abs-include,$(inc))', )'']\n" \
238bf215546Sopenharmony_ci		"cpp_args = [$(foreach flag,$(call filter-c-flags,$(m-cpp-flags)),'$(flag)', ) \
239bf215546Sopenharmony_ci                             $(foreach inc,$(nospace-includes),'$(call abs-include,$(inc))', )'']\n" \
240bf215546Sopenharmony_ci		"c_link_args = [$(foreach flag, $(m-lld-flags-cleaned),'$(flag)',)'']\n"                                          \
241bf215546Sopenharmony_ci		"cpp_link_args = [$(foreach flag, $(m-lld-flags-cleaned),'$(flag)',)'']\n"                                        \
242bf215546Sopenharmony_ci		"needs_exe_wrapper = true\n"                                                                                      \
243bf215546Sopenharmony_ci		"[binaries]\n"                                                                                                    \
244bf215546Sopenharmony_ci		"ar = '$(AOSP_ABSOLUTE_PATH)/$($($(M_TARGET_PREFIX))TARGET_AR)'\n"                                                \
245bf215546Sopenharmony_ci		"c = [$(foreach arg,$(PRIVATE_CC),'$(subst prebuilts/,$(AOSP_ABSOLUTE_PATH)/prebuilts/,$(arg))',)'']\n"           \
246bf215546Sopenharmony_ci		"cpp = [$(foreach arg,$(PRIVATE_CXX),'$(subst prebuilts/,$(AOSP_ABSOLUTE_PATH)/prebuilts/,$(arg))',)'']\n"        \
247bf215546Sopenharmony_ci		"c_ld = 'lld'\n"                                                                                                  \
248bf215546Sopenharmony_ci		"cpp_ld = 'lld'\n\n"                                                                                              \
249bf215546Sopenharmony_ci		"pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=' + '$(call relative-to-absolute,$(MESON_GEN_DIR))', '/usr/bin/pkg-config']\n\n" \
250bf215546Sopenharmony_ci		"llvm-config = '/dev/null'\n"                                                                                     \
251bf215546Sopenharmony_ci		"[host_machine]\n"                                                                                                \
252bf215546Sopenharmony_ci		"system = 'linux'\n"                                                                                              \
253bf215546Sopenharmony_ci		"cpu_family = '$(MESON_CPU_FAMILY)'\n"                                                                            \
254bf215546Sopenharmony_ci		"cpu = '$(MESON_CPU_FAMILY)'\n"                                                                                   \
255bf215546Sopenharmony_ci		"endian = 'little'" > $(dir $@)/aosp_cross
256bf215546Sopenharmony_ci
257bf215546Sopenharmony_ci	#
258bf215546Sopenharmony_ci	$(foreach pkg, $(MESON_GEN_PKGCONFIGS), $(call create-pkgconfig,$(dir $@),$(word 1, $(subst :, ,$(pkg))),$(word 2, $(subst :, ,$(pkg)))))
259bf215546Sopenharmony_ci	touch $@
260bf215546Sopenharmony_ci
261bf215546Sopenharmony_ci$(MESON_OUT_DIR)/.build.timestamp: MESON_GEN_NINJA:=$(MESON_GEN_NINJA)
262bf215546Sopenharmony_ci$(MESON_OUT_DIR)/.build.timestamp: MESON_BUILD:=$(MESON_BUILD)
263bf215546Sopenharmony_ci$(MESON_OUT_DIR)/.build.timestamp: $(MESON_GEN_FILES_TARGET) $(link_deps)
264bf215546Sopenharmony_ci	rm -rf $(dir $@)
265bf215546Sopenharmony_ci	mkdir -p $(dir $@)
266bf215546Sopenharmony_ci	mkdir -p $(dir $@)/build
267bf215546Sopenharmony_ci	# Meson will update timestamps in sources directory, continuously retriggering the build
268bf215546Sopenharmony_ci	# even if nothing changed. Copy sources into intermediate dir to avoid this effect.
269bf215546Sopenharmony_ci	cp -r $(MESA3D_TOP)/* $(dir $@)
270bf215546Sopenharmony_ciifneq ($(MESON_GEN_LLVM_STUB),)
271bf215546Sopenharmony_ci	mkdir -p $(dir $@)/subprojects/llvm/
272bf215546Sopenharmony_ci	echo -e "project('llvm', 'cpp', version : '$(MESON_LLVM_VERSION)')\n" \
273bf215546Sopenharmony_ci		"dep_llvm = declare_dependency()\n"                           \
274bf215546Sopenharmony_ci		"has_rtti = false\n" > $(dir $@)/subprojects/llvm/meson.build
275bf215546Sopenharmony_ciendif
276bf215546Sopenharmony_ci	$(MESON_GEN_NINJA)
277bf215546Sopenharmony_ci	$(MESON_BUILD)
278bf215546Sopenharmony_ci	touch $@
279bf215546Sopenharmony_ci
280bf215546Sopenharmony_ciMESON_COPY_LIBGALLIUM := \
281bf215546Sopenharmony_ci	cp `ls -1 $(MESA3D_GALLIUM_DRI_DIR)/* | head -1` $($(M_TARGET_PREFIX)MESA3D_GALLIUM_DRI_BIN)
282bf215546Sopenharmony_ci
283bf215546Sopenharmony_ci$(MESON_OUT_DIR)/install/.install.timestamp: MESON_COPY_LIBGALLIUM:=$(MESON_COPY_LIBGALLIUM)
284bf215546Sopenharmony_ci$(MESON_OUT_DIR)/install/.install.timestamp: MESON_BUILD:=$(MESON_BUILD)
285bf215546Sopenharmony_ci$(MESON_OUT_DIR)/install/.install.timestamp: $(MESON_OUT_DIR)/.build.timestamp
286bf215546Sopenharmony_ci	rm -rf $(dir $@)
287bf215546Sopenharmony_ci	mkdir -p $(dir $@)
288bf215546Sopenharmony_ci	DESTDIR=$(call relative-to-absolute,$(dir $@)) $(MESON_BUILD) install
289bf215546Sopenharmony_ci	$(MESON_COPY_LIBGALLIUM)
290bf215546Sopenharmony_ci	touch $@
291bf215546Sopenharmony_ci
292bf215546Sopenharmony_ci$($(M_TARGET_PREFIX)MESA3D_LIBGBM_BIN) $(MESA3D_GLES_BINS): $(MESON_OUT_DIR)/install/.install.timestamp
293bf215546Sopenharmony_ci	echo "Build $@"
294bf215546Sopenharmony_ci	touch $@
295bf215546Sopenharmony_ci
296bf215546Sopenharmony_cidefine vulkan_target
297bf215546Sopenharmony_ci$(M_TARGET_PREFIX)MESA3D_VULKAN_$1_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libvulkan_$(MESA_VK_LIB_SUFFIX_$1).so
298bf215546Sopenharmony_ci$(MESON_OUT_DIR)/install/usr/local/lib/libvulkan_$(MESA_VK_LIB_SUFFIX_$1).so: $(MESON_OUT_DIR)/install/.install.timestamp
299bf215546Sopenharmony_ci	touch $(MESON_OUT_DIR)/install/usr/local/lib/libvulkan_$(MESA_VK_LIB_SUFFIX_$1).so
300bf215546Sopenharmony_ci
301bf215546Sopenharmony_ciendef
302bf215546Sopenharmony_ci
303bf215546Sopenharmony_ci$(foreach driver,$(BOARD_MESA3D_VULKAN_DRIVERS), $(eval $(call vulkan_target,$(driver))))
304bf215546Sopenharmony_ci
305bf215546Sopenharmony_ci$($(M_TARGET_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES)/dri/.targets.timestamp: MESA3D_GALLIUM_DRI_DIR:=$(MESA3D_GALLIUM_DRI_DIR)
306bf215546Sopenharmony_ci$($(M_TARGET_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES)/dri/.targets.timestamp: $(MESON_OUT_DIR)/install/.install.timestamp
307bf215546Sopenharmony_ci	mkdir -p $(dir $@)
308bf215546Sopenharmony_ci	# Create Symlinks for gallium and kmsro drivers
309bf215546Sopenharmony_ci	ls -1 $(MESA3D_GALLIUM_DRI_DIR)/ | PATH=/usr/bin:$$PATH xargs -I{} ln -s -f libgallium_dri.so $(dir $@)/{}
310bf215546Sopenharmony_ci	# Remove unwanted Symlinks created for classic dri drivers
311bf215546Sopenharmony_ci	$(foreach d,$(BOARD_MESA3D_CLASSIC_DRIVERS), rm $(dir $@)/$(d)_dri.so;)
312bf215546Sopenharmony_ci	# Copy classic dri drivers
313bf215546Sopenharmony_ci	$(foreach d,$(BOARD_MESA3D_CLASSIC_DRIVERS), cp $(MESA3D_GALLIUM_DRI_DIR)/$(d)_dri.so $(dir $@)/$(d)_dri.so;)
314bf215546Sopenharmony_ci	touch $@
315bf215546Sopenharmony_ci
316bf215546Sopenharmony_ci$($(M_TARGET_PREFIX)MESA3D_GALLIUM_DRI_BIN): $(TARGET_OUT_VENDOR)/$(MESA3D_LIB_DIR)/dri/.targets.timestamp
317bf215546Sopenharmony_ci	echo "Build $@"
318bf215546Sopenharmony_ci	touch $@
319