1 # Mesa 3-D graphics library
3 # Copyright (C) 2021 GlobalLogic Ukraine
4 # Copyright (C) 2021 Roman Stratiienko (r.stratiienko@gmail.com)
6 # Permission is hereby granted, free of charge, to any person obtaining a
7 # copy of this software and associated documentation files (the "Software"),
8 # to deal in the Software without restriction, including without limitation
9 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 # and/or sell copies of the Software, and to permit persons to whom the
11 # Software is furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 # DEALINGS IN THE SOFTWARE.
24 ifneq ($(filter true, $(BOARD_MESA3D_USES_MESON_BUILD)),)
26 LOCAL_PATH := $(call my-dir)
27 MESA3D_TOP := $(dir $(LOCAL_PATH))
29 LIBDRM_VERSION = $(shell cat external/libdrm/meson.build | grep -o "\<version\>\s*:\s*'\w*\.\w*\.\w*'" | grep -o "\w*\.\w*\.\w*" | head -1)
31 MESA_VK_LIB_SUFFIX_amd := radeon
32 MESA_VK_LIB_SUFFIX_intel := intel
33 MESA_VK_LIB_SUFFIX_intel_hasvk := intel_hasvk
34 MESA_VK_LIB_SUFFIX_freedreno := freedreno
35 MESA_VK_LIB_SUFFIX_broadcom := broadcom
36 MESA_VK_LIB_SUFFIX_panfrost := panfrost
37 MESA_VK_LIB_SUFFIX_virtio-experimental := virtio
38 MESA_VK_LIB_SUFFIX_swrast := lvp
42 LOCAL_SHARED_LIBRARIES := libc libdl libdrm libm liblog libcutils libz libc++ libnativewindow libsync libhardware
43 LOCAL_STATIC_LIBRARIES := libexpat libarect libelf
44 LOCAL_HEADER_LIBRARIES := libnativebase_headers hwvulkan_headers libbacktrace_headers
45 MESON_GEN_PKGCONFIGS := backtrace cutils expat hardware libdrm:$(LIBDRM_VERSION) nativewindow sync zlib:1.2.11 libelf
46 LOCAL_CFLAGS += $(BOARD_MESA3D_CFLAGS)
48 ifneq ($(filter swrast,$(BOARD_MESA3D_GALLIUM_DRIVERS) $(BOARD_MESA3D_VULKAN_DRIVERS)),)
49 ifeq ($(BOARD_MESA3D_FORCE_SOFTPIPE),)
50 MESON_GEN_LLVM_STUB := true
54 ifneq ($(filter zink,$(BOARD_MESA3D_GALLIUM_DRIVERS)),)
55 LOCAL_SHARED_LIBRARIES += libvulkan
56 MESON_GEN_PKGCONFIGS += vulkan
59 ifneq ($(filter iris,$(BOARD_MESA3D_GALLIUM_DRIVERS)),)
60 LOCAL_SHARED_LIBRARIES += libdrm_intel
61 MESON_GEN_PKGCONFIGS += libdrm_intel:$(LIBDRM_VERSION)
64 ifneq ($(filter radeonsi amd,$(BOARD_MESA3D_GALLIUM_DRIVERS) $(BOARD_MESA3D_VULKAN_DRIVERS)),)
65 MESON_GEN_LLVM_STUB := true
66 LOCAL_CFLAGS += -DFORCE_BUILD_AMDGPU # instructs LLVM to declare LLVMInitializeAMDGPU* functions
67 LOCAL_SHARED_LIBRARIES += libdrm_amdgpu
68 MESON_GEN_PKGCONFIGS += libdrm_amdgpu:$(LIBDRM_VERSION)
71 ifneq ($(filter radeonsi r300 r600,$(BOARD_MESA3D_GALLIUM_DRIVERS)),)
72 LOCAL_SHARED_LIBRARIES += libdrm_radeon
73 MESON_GEN_PKGCONFIGS += libdrm_radeon:$(LIBDRM_VERSION)
76 ifneq ($(filter nouveau,$(BOARD_MESA3D_GALLIUM_DRIVERS)),)
77 LOCAL_SHARED_LIBRARIES += libdrm_nouveau
78 MESON_GEN_PKGCONFIGS += libdrm_nouveau:$(LIBDRM_VERSION)
81 ifneq ($(filter d3d12,$(BOARD_MESA3D_GALLIUM_DRIVERS)),)
82 LOCAL_HEADER_LIBRARIES += DirectX-Headers
83 LOCAL_STATIC_LIBRARIES += DirectX-Guids
84 MESON_GEN_PKGCONFIGS += DirectX-Headers
87 ifneq ($(MESON_GEN_LLVM_STUB),)
88 MESON_LLVM_VERSION := 12.0.0
89 LOCAL_SHARED_LIBRARIES += libLLVM12
92 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 30; echo $$?), 0)
93 LOCAL_SHARED_LIBRARIES += \
94 android.hardware.graphics.mapper@4.0 \
99 MESON_GEN_PKGCONFIGS += android.hardware.graphics.mapper:4.0
102 __MY_SHARED_LIBRARIES := $(LOCAL_SHARED_LIBRARIES)
104 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 30; echo $$?), 0)
105 MESA_LIBGBM_NAME := libgbm_mesa
107 MESA_LIBGBM_NAME := libgbm
110 ifeq ($(TARGET_IS_64_BIT),true)
115 include $(LOCAL_PATH)/mesa3d_cross.mk
117 ifdef TARGET_2ND_ARCH
119 include $(LOCAL_PATH)/mesa3d_cross.mk
122 #-------------------------------------------------------------------------------
127 # $4: source prebuilt
130 include $(CLEAR_VARS)
131 LOCAL_MODULE_CLASS := SHARED_LIBRARIES
133 LOCAL_VENDOR_MODULE := true
134 LOCAL_MODULE_RELATIVE_PATH := $3
135 LOCAL_PREBUILT_MODULE_FILE := $($4)
136 LOCAL_MULTILIB := first
137 LOCAL_CHECK_ELF_FILES := false
138 LOCAL_MODULE_SUFFIX := .so
139 LOCAL_MODULE_SYMLINKS := $1$2
140 LOCAL_SHARED_LIBRARIES := $(__MY_SHARED_LIBRARIES)
141 LOCAL_EXPORT_C_INCLUDE_DIRS := $5
142 include $(BUILD_PREBUILT)
144 ifdef TARGET_2ND_ARCH
145 include $(CLEAR_VARS)
146 LOCAL_MODULE_CLASS := SHARED_LIBRARIES
148 LOCAL_VENDOR_MODULE := true
149 LOCAL_MODULE_RELATIVE_PATH := $3
150 LOCAL_PREBUILT_MODULE_FILE := $(2ND_$4)
152 LOCAL_CHECK_ELF_FILES := false
153 LOCAL_MODULE_SUFFIX := .so
154 LOCAL_MODULE_SYMLINKS := $1$2
155 LOCAL_SHARED_LIBRARIES := $(__MY_SHARED_LIBRARIES)
156 LOCAL_EXPORT_C_INCLUDE_DIRS := $5
157 include $(BUILD_PREBUILT)
161 # Module 'libgallium_dri', produces '/vendor/lib{64}/dri/libgallium_dri.so'
162 # This module also trigger DRI symlinks creation process
163 $(eval $(call mesa3d-lib,libgallium_dri,.so.0,dri,MESA3D_GALLIUM_DRI_BIN))
164 # Module 'libglapi', produces '/vendor/lib{64}/libglapi.so'
165 $(eval $(call mesa3d-lib,libglapi,.so.0,,MESA3D_LIBGLAPI_BIN))
167 # Module 'libEGL_mesa', produces '/vendor/lib{64}/egl/libEGL_mesa.so'
168 $(eval $(call mesa3d-lib,libEGL_mesa,.so.1,egl,MESA3D_LIBEGL_BIN))
169 # Module 'libGLESv1_CM_mesa', produces '/vendor/lib{64}/egl/libGLESv1_CM_mesa.so'
170 $(eval $(call mesa3d-lib,libGLESv1_CM_mesa,.so.1,egl,MESA3D_LIBGLESV1_BIN))
171 # Module 'libGLESv2_mesa', produces '/vendor/lib{64}/egl/libGLESv2_mesa.so'
172 $(eval $(call mesa3d-lib,libGLESv2_mesa,.so.2,egl,MESA3D_LIBGLESV2_BIN))
174 # Modules 'vulkan.{driver_name}', produces '/vendor/lib{64}/hw/vulkan.{driver_name}.so' HAL
175 $(foreach driver,$(BOARD_MESA3D_VULKAN_DRIVERS), \
176 $(eval $(call mesa3d-lib,vulkan.$(MESA_VK_LIB_SUFFIX_$(driver)),.so.0,hw,MESA3D_VULKAN_$(driver)_BIN)))
178 ifneq ($(filter true, $(BOARD_MESA3D_BUILD_LIBGBM)),)
179 # Modules 'libgbm', produces '/vendor/lib{64}/libgbm.so'
180 $(eval $(call mesa3d-lib,$(MESA_LIBGBM_NAME),.so.1,,MESA3D_LIBGBM_BIN,$(MESA3D_TOP)/src/gbm/main))
183 #-------------------------------------------------------------------------------