17ec681f3Smrg# Mesa 3-D graphics library
27ec681f3Smrg#
37ec681f3Smrg# Copyright (C) 2021 GlobalLogic Ukraine
47ec681f3Smrg# Copyright (C) 2021 Roman Stratiienko (r.stratiienko@gmail.com)
57ec681f3Smrg#
67ec681f3Smrg# Permission is hereby granted, free of charge, to any person obtaining a
77ec681f3Smrg# copy of this software and associated documentation files (the "Software"),
87ec681f3Smrg# to deal in the Software without restriction, including without limitation
97ec681f3Smrg# the rights to use, copy, modify, merge, publish, distribute, sublicense,
107ec681f3Smrg# and/or sell copies of the Software, and to permit persons to whom the
117ec681f3Smrg# Software is furnished to do so, subject to the following conditions:
127ec681f3Smrg#
137ec681f3Smrg# The above copyright notice and this permission notice shall be included
147ec681f3Smrg# in all copies or substantial portions of the Software.
157ec681f3Smrg#
167ec681f3Smrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
177ec681f3Smrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
187ec681f3Smrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
197ec681f3Smrg# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
207ec681f3Smrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
217ec681f3Smrg# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
227ec681f3Smrg# DEALINGS IN THE SOFTWARE.
237ec681f3Smrg
247ec681f3Smrg# Turn "dir1/dir2/dir3/dir4" into "../../../../"
257ec681f3Smrgdefine relative_top_path
267ec681f3Smrg$(eval __s:=) \
277ec681f3Smrg$(foreach tmp,$(subst /,$(space),$1),$(eval __s:=$(__s)../)) \
287ec681f3Smrg$(__s)
297ec681f3Smrgendef
307ec681f3Smrg
317ec681f3SmrgMY_PATH := $(call my-dir)
327ec681f3Smrg
337ec681f3SmrgAOSP_ABSOLUTE_PATH := $(realpath .)
347ec681f3Smrg
357ec681f3Smrgm_dummy_$(LOCAL_MULTILIB) := $(TARGET_OUT_INTERMEDIATES)/MESON_DUMMY_$(LOCAL_MULTILIB)/dummy.c
367ec681f3Smrg
377ec681f3Smrg$(m_dummy_$(LOCAL_MULTILIB)):
387ec681f3Smrg	mkdir -p $(dir $@)
397ec681f3Smrg	touch $@
407ec681f3Smrg
417ec681f3SmrgLOCAL_SRC_FILES := $(call relative_top_path,$(MY_PATH))$(m_dummy_$(LOCAL_MULTILIB))
427ec681f3SmrgLOCAL_VENDOR_MODULE := true
437ec681f3SmrgLOCAL_MODULE := meson.dummy.$(LOCAL_MULTILIB)
447ec681f3Smrg
457ec681f3Smrg# Prepare intermediate variables by AOSP make/core internals
467ec681f3Smrginclude $(BUILD_SHARED_LIBRARY)
477ec681f3Smrg
487ec681f3SmrgLOCAL_PATH := $(MY_PATH)
497ec681f3Smrg
507ec681f3Smrglink_deps := \
517ec681f3Smrg	$(built_static_libraries) \
527ec681f3Smrg	$(built_shared_libraries) \
537ec681f3Smrg	$(built_whole_libraries) \
547ec681f3Smrg	$(strip $(all_objects)) \
557ec681f3Smrg	$(my_target_libatomic) \
567ec681f3Smrg	$(my_target_libcrt_builtins) \
577ec681f3Smrg	$(my_target_crtbegin_so_o) \
587ec681f3Smrg	$(my_target_crtend_so_o)
597ec681f3Smrg
607ec681f3Smrg# Build mesa3d using intermediate variables provided by AOSP make/core internals
617ec681f3SmrgM_TARGET_PREFIX := $(my_2nd_arch_prefix)
627ec681f3Smrg
637ec681f3SmrgMESA3D_LIB_DIR := lib$(subst 32,,$(LOCAL_MULTILIB))
647ec681f3Smrg
657ec681f3SmrgMESON_OUT_DIR                            := $($(M_TARGET_PREFIX)TARGET_OUT_INTERMEDIATES)/MESON_MESA3D
667ec681f3SmrgMESON_GEN_DIR                            := $(MESON_OUT_DIR)_GEN
677ec681f3SmrgMESON_GEN_FILES_TARGET                   := $(MESON_GEN_DIR)/.timestamp
687ec681f3Smrg
697ec681f3SmrgMESA3D_GALLIUM_DRI_DIR                   := $(MESON_OUT_DIR)/install/usr/local/lib/dri
707ec681f3Smrg$(M_TARGET_PREFIX)MESA3D_GALLIUM_DRI_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libgallium_dri.so
717ec681f3Smrg$(M_TARGET_PREFIX)MESA3D_LIBEGL_BIN      := $(MESON_OUT_DIR)/install/usr/local/lib/libEGL.so.1.0.0
727ec681f3Smrg$(M_TARGET_PREFIX)MESA3D_LIBGLESV1_BIN   := $(MESON_OUT_DIR)/install/usr/local/lib/libGLESv1_CM.so.1.1.0
737ec681f3Smrg$(M_TARGET_PREFIX)MESA3D_LIBGLESV2_BIN   := $(MESON_OUT_DIR)/install/usr/local/lib/libGLESv2.so.2.0.0
747ec681f3Smrg$(M_TARGET_PREFIX)MESA3D_LIBGLAPI_BIN    := $(MESON_OUT_DIR)/install/usr/local/lib/libglapi.so.0.0.0
757ec681f3Smrg$(M_TARGET_PREFIX)MESA3D_LIBGBM_BIN      := $(MESON_OUT_DIR)/install/usr/local/lib/libgbm.so.1.0.0
767ec681f3Smrg
777ec681f3Smrg
787ec681f3SmrgMESA3D_GLES_BINS := \
797ec681f3Smrg    $($(M_TARGET_PREFIX)MESA3D_LIBEGL_BIN)    \
807ec681f3Smrg    $($(M_TARGET_PREFIX)MESA3D_LIBGLESV1_BIN) \
817ec681f3Smrg    $($(M_TARGET_PREFIX)MESA3D_LIBGLESV2_BIN) \
827ec681f3Smrg    $($(M_TARGET_PREFIX)MESA3D_LIBGLAPI_BIN)  \
837ec681f3Smrg
847ec681f3SmrgMESON_GEN_NINJA := \
857ec681f3Smrg	cd $(MESON_OUT_DIR) && PATH=/usr/bin:/usr/local/bin:$$PATH meson ./build     \
867ec681f3Smrg	--cross-file $(AOSP_ABSOLUTE_PATH)/$(MESON_GEN_DIR)/aosp_cross               \
877ec681f3Smrg	--buildtype=release                                                          \
887ec681f3Smrg	-Ddri-search-path=/vendor/$(MESA3D_LIB_DIR)/dri                              \
897ec681f3Smrg	-Dplatforms=android                                                          \
907ec681f3Smrg	-Dplatform-sdk-version=$(PLATFORM_SDK_VERSION)                               \
917ec681f3Smrg	-Ddri-drivers=$(subst $(space),$(comma),$(BOARD_MESA3D_CLASSIC_DRIVERS))     \
927ec681f3Smrg	-Dgallium-drivers=$(subst $(space),$(comma),$(BOARD_MESA3D_GALLIUM_DRIVERS)) \
937ec681f3Smrg	-Dvulkan-drivers=$(subst $(space),$(comma),$(subst radeon,amd,$(BOARD_MESA3D_VULKAN_DRIVERS)))   \
947ec681f3Smrg	-Dgbm=enabled                                                                \
957ec681f3Smrg	-Degl=enabled                                                                \
967ec681f3Smrg	-Dcpp_rtti=false                                                             \
977ec681f3Smrg
987ec681f3SmrgMESON_BUILD := PATH=/usr/bin:/bin:/sbin:$$PATH ninja -C $(MESON_OUT_DIR)/build
997ec681f3Smrg
1007ec681f3Smrg$(MESON_GEN_FILES_TARGET): MESON_CPU_FAMILY := $(subst arm64,aarch64,$(TARGET_$(M_TARGET_PREFIX)ARCH))
1017ec681f3Smrg
1027ec681f3Smrgdefine create-pkgconfig
1037ec681f3Smrgecho -e "Name: $2" \
1047ec681f3Smrg	"\nDescription: $2" \
1057ec681f3Smrg	"\nVersion: $3" > $1/$2.pc
1067ec681f3Smrg
1077ec681f3Smrgendef
1087ec681f3Smrg
1097ec681f3Smrg# Taken from build/make/core/binary.mk. We need this
1107ec681f3Smrg# to use definitions from build/make/core/definitions.mk
1117ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_GLOBAL_C_INCLUDES := $(my_target_global_c_includes)
1127ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_target_global_c_system_includes)
1137ec681f3Smrg
1147ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_2ND_ARCH_VAR_PREFIX := $(M_TARGET_PREFIX)
1157ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_CC := $(my_cc)
1167ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_LINKER := $(my_linker)
1177ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_CXX := $(my_cxx)
1187ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_CXX_LINK := $(my_cxx_link)
1197ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
1207ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_ASFLAGS := $(my_asflags)
1217ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_CONLYFLAGS := $(my_conlyflags)
1227ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_CFLAGS := $(my_cflags)
1237ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_CPPFLAGS := $(my_cppflags)
1247ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override)
1257ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override)
1267ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
1277ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
1287ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_C_INCLUDES := $(my_c_includes)
1297ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_IMPORTED_INCLUDES := $(imported_includes)
1307ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_LDFLAGS := $(my_ldflags)
1317ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_LDLIBS := $(my_ldlibs)
1327ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_TIDY_CHECKS := $(my_tidy_checks)
1337ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_TIDY_FLAGS := $(my_tidy_flags)
1347ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_ARFLAGS := $(my_arflags)
1357ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
1367ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
1377ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
1387ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_OBJECTS := $(strip $(all_objects))
1397ec681f3Smrg
1407ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
1417ec681f3Smrg
1427ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
1437ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags)
1447ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
1457ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
1467ec681f3Smrg
1477ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins)
1487ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic)
1497ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o)
1507ec681f3Smrg$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o)
1517ec681f3Smrg##
1527ec681f3Smrg
1537ec681f3Smrgdefine m-lld-flags
1547ec681f3Smrg  -nostdlib -Wl,--gc-sections \
1557ec681f3Smrg  $(PRIVATE_TARGET_CRTBEGIN_SO_O) \
1567ec681f3Smrg  $(PRIVATE_ALL_OBJECTS) \
1577ec681f3Smrg  -Wl,--whole-archive \
1587ec681f3Smrg  $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
1597ec681f3Smrg  -Wl,--no-whole-archive \
1607ec681f3Smrg  $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
1617ec681f3Smrg  $(PRIVATE_ALL_STATIC_LIBRARIES) \
1627ec681f3Smrg  $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
1637ec681f3Smrg  $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
1647ec681f3Smrg  $(PRIVATE_TARGET_LIBCRT_BUILTINS) \
1657ec681f3Smrg  $(PRIVATE_TARGET_LIBATOMIC) \
1667ec681f3Smrg  $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
1677ec681f3Smrg  $(PRIVATE_LDFLAGS) \
1687ec681f3Smrg  $(PRIVATE_ALL_SHARED_LIBRARIES) \
1697ec681f3Smrg  $(PRIVATE_TARGET_CRTEND_SO_O) \
1707ec681f3Smrg  $(PRIVATE_LDLIBS)
1717ec681f3Smrgendef
1727ec681f3Smrg
1737ec681f3Smrgdefine m-lld-flags-cleaned
1747ec681f3Smrg  $(subst prebuilts/,$(AOSP_ABSOLUTE_PATH)/prebuilts/, \
1757ec681f3Smrg  $(subst out/,$(AOSP_ABSOLUTE_PATH)/out/,             \
1767ec681f3Smrg  $(subst -Wl$(comma)--fatal-warnings,,                \
1777ec681f3Smrg  $(subst -Wl$(comma)--no-undefined-version,,          \
1787ec681f3Smrg  $(subst -Wl$(comma)--gc-sections,,                   \
1797ec681f3Smrg  $(patsubst %dummy.o,,                                \
1807ec681f3Smrg    $(m-lld-flags)))))))
1817ec681f3Smrgendef
1827ec681f3Smrg
1837ec681f3Smrgdefine m-cpp-flags
1847ec681f3Smrg  $(PRIVATE_TARGET_GLOBAL_CFLAGS) \
1857ec681f3Smrg  $(PRIVATE_TARGET_GLOBAL_CPPFLAGS) \
1867ec681f3Smrg  $(PRIVATE_ARM_CFLAGS) \
1877ec681f3Smrg  $(PRIVATE_RTTI_FLAG) \
1887ec681f3Smrg  $(PRIVATE_CFLAGS) \
1897ec681f3Smrg  $(PRIVATE_CPPFLAGS) \
1907ec681f3Smrg  $(PRIVATE_DEBUG_CFLAGS) \
1917ec681f3Smrg  $(PRIVATE_CFLAGS_NO_OVERRIDE) \
1927ec681f3Smrg  $(PRIVATE_CPPFLAGS_NO_OVERRIDE)
1937ec681f3Smrgendef
1947ec681f3Smrg
1957ec681f3Smrgdefine m-c-flags
1967ec681f3Smrg  $(PRIVATE_TARGET_GLOBAL_CFLAGS) \
1977ec681f3Smrg  $(PRIVATE_TARGET_GLOBAL_CONLYFLAGS) \
1987ec681f3Smrg  $(PRIVATE_ARM_CFLAGS) \
1997ec681f3Smrg  $(PRIVATE_CFLAGS) \
2007ec681f3Smrg  $(PRIVATE_CONLYFLAGS) \
2017ec681f3Smrg  $(PRIVATE_DEBUG_CFLAGS) \
2027ec681f3Smrg  $(PRIVATE_CFLAGS_NO_OVERRIDE)
2037ec681f3Smrgendef
2047ec681f3Smrg
2057ec681f3Smrgdefine filter-c-flags
2067ec681f3Smrg  $(subst -std=gnu++17,, \
2077ec681f3Smrg  $(subst -fno-rtti,, \
2087ec681f3Smrg  $(patsubst  -W%,, \
2097ec681f3Smrg    $1)))
2107ec681f3Smrgendef
2117ec681f3Smrg
2127ec681f3Smrgdefine m-c-abs-includes
2137ec681f3Smrg  $(subst  -isystem , -isystem $(AOSP_ABSOLUTE_PATH)/, \
2147ec681f3Smrg  $(subst  -I, -I$(AOSP_ABSOLUTE_PATH)/, \
2157ec681f3Smrg  $(subst  -I , -I, \
2167ec681f3Smrg    $(c-includes))))
2177ec681f3Smrgendef
2187ec681f3Smrg
2197ec681f3Smrg$(MESON_GEN_FILES_TARGET): PREPROCESS_MESON_CONFIGS:=$(PREPROCESS_MESON_CONFIGS)
2207ec681f3Smrg$(MESON_GEN_FILES_TARGET): MESON_GEN_DIR:=$(MESON_GEN_DIR)
2217ec681f3Smrg$(MESON_GEN_FILES_TARGET): $(sort $(shell find -L $(MESA3D_TOP) -not -path '*/\.*'))
2227ec681f3Smrg	mkdir -p $(dir $@)
2237ec681f3Smrg	echo -e "[properties]\n"                                                                                                  \
2247ec681f3Smrg		"c_args = [$(foreach flag, $(call filter-c-flags,$(m-c-flags) $(m-c-abs-includes)),'$(flag)', )'']\n"             \
2257ec681f3Smrg		"cpp_args = [$(foreach flag, $(call filter-c-flags,$(m-cpp-flags) $(m-c-abs-includes)),'$(flag)', )'']\n"         \
2267ec681f3Smrg		"c_link_args = [$(foreach flag, $(m-lld-flags-cleaned),'$(flag)',)'']\n"                                          \
2277ec681f3Smrg		"cpp_link_args = [$(foreach flag, $(m-lld-flags-cleaned),'$(flag)',)'']\n"                                        \
2287ec681f3Smrg		"needs_exe_wrapper = true\n"                                                                                      \
2297ec681f3Smrg		"[binaries]\n"                                                                                                    \
2307ec681f3Smrg		"ar = '$(AOSP_ABSOLUTE_PATH)/$($($(M_TARGET_PREFIX))TARGET_AR)'\n"                                                \
2317ec681f3Smrg		"c = [$(foreach arg,$(PRIVATE_CC),'$(subst prebuilts/,$(AOSP_ABSOLUTE_PATH)/prebuilts/,$(arg))',)'']\n"           \
2327ec681f3Smrg		"cpp = [$(foreach arg,$(PRIVATE_CXX),'$(subst prebuilts/,$(AOSP_ABSOLUTE_PATH)/prebuilts/,$(arg))',)'']\n"        \
2337ec681f3Smrg		"c_ld = 'lld'\n"                                                                                                  \
2347ec681f3Smrg		"cpp_ld = 'lld'\n\n"                                                                                              \
2357ec681f3Smrg		"pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=' + '$(AOSP_ABSOLUTE_PATH)/$(MESON_GEN_DIR)', '/usr/bin/pkg-config']\n\n" \
2367ec681f3Smrg		"llvm-config = '/dev/null'\n"                                                                                     \
2377ec681f3Smrg		"[host_machine]\n"                                                                                                \
2387ec681f3Smrg		"system = 'linux'\n"                                                                                              \
2397ec681f3Smrg		"cpu_family = '$(MESON_CPU_FAMILY)'\n"                                                                            \
2407ec681f3Smrg		"cpu = '$(MESON_CPU_FAMILY)'\n"                                                                                   \
2417ec681f3Smrg		"endian = 'little'" > $(dir $@)/aosp_cross
2427ec681f3Smrg
2437ec681f3Smrg	#
2447ec681f3Smrg	$(foreach pkg, $(MESON_GEN_PKGCONFIGS), $(call create-pkgconfig,$(dir $@),$(word 1, $(subst :, ,$(pkg))),$(word 2, $(subst :, ,$(pkg)))))
2457ec681f3Smrg	touch $@
2467ec681f3Smrg
2477ec681f3Smrg$(MESON_OUT_DIR)/.build.timestamp: MESON_GEN_NINJA:=$(MESON_GEN_NINJA)
2487ec681f3Smrg$(MESON_OUT_DIR)/.build.timestamp: MESON_BUILD:=$(MESON_BUILD)
2497ec681f3Smrg$(MESON_OUT_DIR)/.build.timestamp: $(MESON_GEN_FILES_TARGET) $(link_deps)
2507ec681f3Smrg	rm -rf $(dir $@)
2517ec681f3Smrg	mkdir -p $(dir $@)
2527ec681f3Smrg	mkdir -p $(dir $@)/build
2537ec681f3Smrg	# Meson will update timestamps in sources directory, continuously retriggering the build
2547ec681f3Smrg	# even if nothing changed. Copy sources into intermediate dir to avoid this effect.
2557ec681f3Smrg	cp -r $(MESA3D_TOP)/* $(dir $@)
2567ec681f3Smrgifneq ($(MESON_GEN_LLVM_STUB),)
2577ec681f3Smrg	mkdir -p $(dir $@)/subprojects/llvm/
2587ec681f3Smrg	echo -e "project('llvm', 'cpp', version : '$(MESON_LLVM_VERSION)')\n" \
2597ec681f3Smrg		"dep_llvm = declare_dependency()\n"                           \
2607ec681f3Smrg		"has_rtti = false\n"                                          \
2617ec681f3Smrg		"irbuilder_h = files('$(AOSP_ABSOLUTE_PATH)/$(MESON_LLVM_IRBUILDER_PATH)')" > $(dir $@)/subprojects/llvm/meson.build
2627ec681f3Smrgendif
2637ec681f3Smrg	$(MESON_GEN_NINJA)
2647ec681f3Smrg	$(MESON_BUILD)
2657ec681f3Smrg	touch $@
2667ec681f3Smrg
2677ec681f3SmrgMESON_COPY_LIBGALLIUM := \
2687ec681f3Smrg	cp `ls -1 $(MESA3D_GALLIUM_DRI_DIR)/* | head -1` $($(M_TARGET_PREFIX)MESA3D_GALLIUM_DRI_BIN)
2697ec681f3Smrg
2707ec681f3Smrg$(MESON_OUT_DIR)/install/.install.timestamp: MESON_COPY_LIBGALLIUM:=$(MESON_COPY_LIBGALLIUM)
2717ec681f3Smrg$(MESON_OUT_DIR)/install/.install.timestamp: MESON_BUILD:=$(MESON_BUILD)
2727ec681f3Smrg$(MESON_OUT_DIR)/install/.install.timestamp: $(MESON_OUT_DIR)/.build.timestamp
2737ec681f3Smrg	rm -rf $(dir $@)
2747ec681f3Smrg	mkdir -p $(dir $@)
2757ec681f3Smrg	DESTDIR=$(AOSP_ABSOLUTE_PATH)/$(dir $@) $(MESON_BUILD) install
2767ec681f3Smrg	$(MESON_COPY_LIBGALLIUM)
2777ec681f3Smrg	touch $@
2787ec681f3Smrg
2797ec681f3Smrg$($(M_TARGET_PREFIX)MESA3D_LIBGBM_BIN) $(MESA3D_GLES_BINS): $(MESON_OUT_DIR)/install/.install.timestamp
2807ec681f3Smrg	echo "Build $@"
2817ec681f3Smrg	touch $@
2827ec681f3Smrg
2837ec681f3Smrgdefine vulkan_target
2847ec681f3Smrg$(M_TARGET_PREFIX)MESA3D_VULKAN_$1_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libvulkan_$(MESA_VK_LIB_SUFFIX_$1).so
2857ec681f3Smrg$(MESON_OUT_DIR)/install/usr/local/lib/libvulkan_$(MESA_VK_LIB_SUFFIX_$1).so: $(MESON_OUT_DIR)/install/.install.timestamp
2867ec681f3Smrg	touch $(MESON_OUT_DIR)/install/usr/local/lib/libvulkan_$(MESA_VK_LIB_SUFFIX_$1).so
2877ec681f3Smrg
2887ec681f3Smrgendef
2897ec681f3Smrg
2907ec681f3Smrg$(foreach driver,$(BOARD_MESA3D_VULKAN_DRIVERS), $(eval $(call vulkan_target,$(driver))))
2917ec681f3Smrg
2927ec681f3Smrg$($(M_TARGET_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES)/dri/.targets.timestamp: MESA3D_GALLIUM_DRI_DIR:=$(MESA3D_GALLIUM_DRI_DIR)
2937ec681f3Smrg$($(M_TARGET_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES)/dri/.targets.timestamp: $(MESON_OUT_DIR)/install/.install.timestamp
2947ec681f3Smrg	mkdir -p $(dir $@)
2957ec681f3Smrg	# Create Symlinks for gallium and kmsro drivers
2967ec681f3Smrg	ls -1 $(MESA3D_GALLIUM_DRI_DIR)/ | PATH=/usr/bin:$$PATH xargs -I{} ln -s -f libgallium_dri.so $(dir $@)/{}
2977ec681f3Smrg	# Remove unwanted Symlinks created for classic dri drivers
2987ec681f3Smrg	$(foreach d,$(BOARD_MESA3D_CLASSIC_DRIVERS), rm $(dir $@)/$(d)_dri.so;)
2997ec681f3Smrg	# Copy classic dri drivers
3007ec681f3Smrg	$(foreach d,$(BOARD_MESA3D_CLASSIC_DRIVERS), cp $(MESA3D_GALLIUM_DRI_DIR)/$(d)_dri.so $(dir $@)/$(d)_dri.so;)
3017ec681f3Smrg	touch $@
3027ec681f3Smrg
3037ec681f3Smrg$($(M_TARGET_PREFIX)MESA3D_GALLIUM_DRI_BIN): $(TARGET_OUT_VENDOR)/$(MESA3D_LIB_DIR)/dri/.targets.timestamp
3047ec681f3Smrg	echo "Build $@"
3057ec681f3Smrg	touch $@
306