1# Copyright © 2016 Red Hat.
2# Copyright © 2016 Mauro Rossi <issor.oruam@gmail.com>
3#
4# Permission is hereby granted, free of charge, to any person obtaining a
5# copy of this software and associated documentation files (the "Software"),
6# to deal in the Software without restriction, including without limitation
7# the rights to use, copy, modify, merge, publish, distribute, sublicense,
8# and/or sell copies of the Software, and to permit persons to whom the
9# Software is furnished to do so, subject to the following conditions:
10#
11# The above copyright notice and this permission notice (including the next
12# paragraph) shall be included in all copies or substantial portions of the
13# Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21# IN THE SOFTWARE.
22
23ifeq ($(MESA_ENABLE_LLVM),true)
24
25# ---------------------------------------
26# Build libmesa_amd_common
27# ---------------------------------------
28
29include $(CLEAR_VARS)
30
31LOCAL_MODULE := libmesa_amd_common
32
33LOCAL_SRC_FILES := \
34	$(AMD_COMMON_FILES) \
35	$(AMD_COMPILER_FILES) \
36	$(AMD_DEBUG_FILES) \
37	$(AMD_NIR_FILES)
38
39LOCAL_CFLAGS += -DFORCE_BUILD_AMDGPU   # instructs LLVM to declare LLVMInitializeAMDGPU* functions
40
41# generate sources
42LOCAL_MODULE_CLASS := STATIC_LIBRARIES
43intermediates := $(call local-generated-sources-dir)
44LOCAL_GENERATED_SOURCES := $(addprefix $(intermediates)/, $(AMD_GENERATED_FILES))
45
46$(LOCAL_GENERATED_SOURCES): PRIVATE_PYTHON := $(MESA_PYTHON2)
47$(LOCAL_GENERATED_SOURCES): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PYTHON) $^ > $@
48
49$(intermediates)/common/sid_tables.h: $(LOCAL_PATH)/common/sid_tables.py $(LOCAL_PATH)/common/sid.h $(LOCAL_PATH)/common/gfx9d.h
50	$(transform-generated-source)
51
52LOCAL_C_INCLUDES := \
53	$(MESA_TOP)/include \
54	$(MESA_TOP)/src \
55	$(MESA_TOP)/src/amd/common \
56	$(MESA_TOP)/src/compiler \
57	$(call generated-sources-dir-for,STATIC_LIBRARIES,libmesa_nir,,)/nir \
58	$(MESA_TOP)/src/gallium/include \
59	$(MESA_TOP)/src/gallium/auxiliary \
60	$(intermediates)/common
61
62LOCAL_EXPORT_C_INCLUDE_DIRS := \
63	$(LOCAL_PATH)/common
64
65LOCAL_SHARED_LIBRARIES := \
66	libdrm_amdgpu
67
68LOCAL_STATIC_LIBRARIES := \
69	libmesa_nir
70
71LOCAL_WHOLE_STATIC_LIBRARIES := \
72	libelf
73
74$(call mesa-build-with-llvm)
75
76include $(MESA_COMMON_MK)
77include $(BUILD_STATIC_LIBRARY)
78
79endif # MESA_ENABLE_LLVM == true
80