1# Mesa 3-D graphics library
2#
3# Copyright (C) 2015 Chih-Wei Huang <cwhuang@linux.org.tw>
4# Copyright (C) 2015 Android-x86 Open Source Project
5#
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:
12#
13# The above copyright notice and this permission notice shall be included
14# in all copies or substantial portions of the Software.
15#
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.
23
24LOCAL_PATH := $(call my-dir)
25
26include $(CLEAR_VARS)
27
28LOCAL_MODULE := gallium_dri
29LOCAL_LICENSE_KINDS := SPDX-license-identifier-MIT
30LOCAL_LICENSE_CONDITIONS := notice
31LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../../../../LICENSE
32
33LOCAL_MODULE_RELATIVE_PATH := $(MESA_DRI_MODULE_REL_PATH)
34LOCAL_SRC_FILES := target.c
35
36LOCAL_CFLAGS :=
37
38# We need --undefined-version as some functions in dri.sym may be missing
39# depending on which drivers are enabled or not. Otherwise, we get the error:
40# "version script assignment of  to symbol FOO failed: symbol not defined"
41LOCAL_LDFLAGS := \
42	-Wl,--version-script=$(LOCAL_PATH)/dri.sym \
43	-Wl,--undefined-version
44
45LOCAL_SHARED_LIBRARIES := \
46	libdl \
47	libglapi \
48	libz \
49	liblog \
50	libsync
51
52# If Android version >=8 MESA should static link libexpat else should dynamic link
53ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 27; echo $$?), 0)
54LOCAL_STATIC_LIBRARIES := \
55	libexpat
56else
57LOCAL_SHARED_LIBRARIES += \
58	libexpat
59endif
60
61LOCAL_STATIC_LIBRARIES += \
62	libetnaviv_drm \
63	libfreedreno_common \
64	libfreedreno_drm \
65	libfreedreno_ir2 \
66	libfreedreno_ir3 \
67	libfreedreno_perfcntrs \
68	libmesa_gallium \
69	libpanfrost_bifrost \
70	libpanfrost_bifrost_disasm \
71	libpanfrost_lib \
72	libpanfrost_midgard \
73	libpanfrost_midgard_disasm \
74	libpanfrost_shared \
75	libpanfrost_util \
76
77ifeq ($(USE_LIBBACKTRACE),true)
78	LOCAL_SHARED_LIBRARIES += libbacktrace
79endif
80
81$(foreach d, $(MESA_BUILD_GALLIUM), $(eval LOCAL_CFLAGS += $(patsubst HAVE_%,-D%,$(d))))
82
83# sort GALLIUM_LIBS to remove any duplicates
84LOCAL_WHOLE_STATIC_LIBRARIES := \
85	$(sort $(GALLIUM_LIBS)) \
86	libmesa_st_dri \
87	libmesa_st_mesa \
88	libmesa_glsl \
89	libmesa_compiler \
90	libmesa_nir \
91	libmesa_dri_common \
92	libmesa_megadriver_stub \
93	libmesa_pipe_loader \
94	libmesa_util \
95	libmesa_loader
96
97# sort GALLIUM_SHARED_LIBS to remove any duplicates
98LOCAL_SHARED_LIBRARIES += $(sort $(GALLIUM_SHARED_LIBS))
99
100ifneq ($(filter 5 6 7, $(MESA_ANDROID_MAJOR_VERSION)),)
101LOCAL_POST_INSTALL_CMD := \
102	$(foreach l, lib $(if $(filter true,$(TARGET_IS_64_BIT)),lib64), \
103	  $(eval MESA_DRI_MODULE_PATH := $(TARGET_OUT_VENDOR)/$(l)/$(MESA_DRI_MODULE_REL_PATH)) \
104	  mkdir -p $(MESA_DRI_MODULE_PATH); \
105	  $(foreach d, $(GALLIUM_TARGET_DRIVERS), ln -sf gallium_dri.so $(MESA_DRI_MODULE_PATH)/$(d)_dri.so;) \
106	)
107else
108LOCAL_MODULE_SYMLINKS := $(foreach d, $(GALLIUM_TARGET_DRIVERS), $(d)_dri.so)
109endif
110
111include $(GALLIUM_COMMON_MK)
112include $(BUILD_SHARED_LIBRARY)
113