1#
2# Copyright (C) 2013 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH := $(call my-dir)
18
19# C/LLVM-IR source files for the library
20clcore_base_files := \
21    rs_allocation.c \
22    rs_cl.c \
23    rs_core.c \
24    rs_element.c \
25    rs_f16_math.c \
26    rs_mesh.c \
27    rs_matrix.c \
28    rs_program.c \
29    rs_sample.c \
30    rs_sampler.c \
31    rs_convert.c \
32    rs_quaternion.c
33
34clcore_cflags := -Werror -Wall -Wextra \
35	         -Iframeworks/rs/cpu_ref -DRS_DECLARE_EXPIRED_APIS
36
37clcore_base_files_32 := \
38    ll32/allocation.ll
39
40clcore_base_files_64 := \
41    ll64/allocation.ll
42
43clcore_files := \
44    $(clcore_base_files) \
45    arch/generic.c
46
47clcore_g_files := \
48    rs_abi_debuginfo.c \
49    arch/generic.c
50
51clcore_files_32 := \
52    $(clcore_base_files_32) \
53    ll32/math.ll
54
55clcore_files_64 := \
56    $(clcore_base_files_64) \
57    ll64/math.ll
58
59clcore_neon_files := \
60    $(clcore_base_files) \
61    $(clcore_files_32) \
62    arch/neon.ll \
63    arch/clamp.c
64
65clcore_arm64_files := \
66    $(clcore_files_64) \
67    arch/asimd.ll \
68    arch/clamp.c
69
70clcore_x86_files := \
71    $(clcore_base_files) \
72    arch/generic.c \
73    arch/x86_sse2.ll \
74    arch/x86_sse3.ll
75
76# Grab the current value for $(RS_VERSION_DEFINE)
77include frameworks/compile/slang/rs_version.mk
78
79# Build the base version of the library
80include $(CLEAR_VARS)
81
82LOCAL_MODULE := libclcore.bc
83LOCAL_CFLAGS += $(clcore_cflags)
84LOCAL_SRC_FILES := $(clcore_base_files)
85LOCAL_SRC_FILES_32 := $(clcore_files_32)
86LOCAL_SRC_FILES_32 += arch/generic.c
87
88ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm64))
89LOCAL_SRC_FILES_64 := $(clcore_arm64_files)
90LOCAL_CFLAGS_64 += -DARCH_ARM64_HAVE_NEON
91else
92LOCAL_SRC_FILES_64 := $(clcore_files_64)
93LOCAL_SRC_FILES_64 += arch/generic.c
94endif
95
96include $(LOCAL_PATH)/build_bc_lib.mk
97
98# Build a debug version of the library
99include $(CLEAR_VARS)
100
101LOCAL_MODULE := libclcore_debug.bc
102rs_debug_runtime := 1
103LOCAL_CFLAGS += $(clcore_cflags)
104LOCAL_SRC_FILES := $(clcore_base_files)
105LOCAL_SRC_FILES_32 := $(clcore_files_32)
106LOCAL_SRC_FILES_32 += arch/generic.c
107
108ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm64))
109LOCAL_SRC_FILES_64 := $(clcore_arm64_files)
110LOCAL_CFLAGS_64 += -DARCH_ARM64_HAVE_NEON
111else
112LOCAL_SRC_FILES_64 := $(clcore_files_64)
113LOCAL_SRC_FILES_64 += arch/generic.c
114endif
115
116include $(LOCAL_PATH)/build_bc_lib.mk
117rs_debug_runtime :=
118
119# Build an optimized version of the library for x86 platforms (all have SSE2/3).
120ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
121include $(CLEAR_VARS)
122
123LOCAL_MODULE := libclcore_x86.bc
124LOCAL_CFLAGS += $(clcore_cflags) -DARCH_X86_HAVE_SSSE3
125LOCAL_SRC_FILES := $(clcore_x86_files)
126LOCAL_SRC_FILES_32 := $(clcore_base_files_32)
127LOCAL_SRC_FILES_64 := $(clcore_base_files_64)
128
129include $(LOCAL_PATH)/build_bc_lib.mk
130endif
131
132# Build a NEON-enabled version of the library (if possible)
133# Only build on 32-bit, because we don't need a 64-bit NEON lib
134ifeq ($(ARCH_ARM_HAVE_NEON),true)
135  include $(CLEAR_VARS)
136
137  LOCAL_32_BIT_ONLY := true
138
139  LOCAL_MODULE := libclcore_neon.bc
140  LOCAL_CFLAGS += $(clcore_cflags)
141  LOCAL_SRC_FILES := $(clcore_neon_files)
142  LOCAL_CFLAGS += -DARCH_ARM_HAVE_NEON
143
144  include $(LOCAL_PATH)/build_bc_lib.mk
145endif
146
147# Build a version of the library with debug info
148include $(CLEAR_VARS)
149
150LOCAL_MODULE := libclcore_g.bc
151rs_g_runtime := 1
152LOCAL_CFLAGS += $(clcore_cflags)
153LOCAL_CFLAGS += -g -O0
154LOCAL_SRC_FILES := $(clcore_base_files) $(clcore_g_files)
155LOCAL_SRC_FILES_32 := $(clcore_base_files_32)
156LOCAL_SRC_FILES_64 := $(clcore_base_files_64)
157
158ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm64))
159LOCAL_CFLAGS_64 += -DARCH_ARM64_HAVE_NEON
160endif
161
162include $(LOCAL_PATH)/build_bc_lib.mk
163
164# Build a debug version of the library with debug info
165include $(CLEAR_VARS)
166
167LOCAL_MODULE := libclcore_debug_g.bc
168rs_debug_runtime := 1
169rs_g_runtime := 1
170LOCAL_CFLAGS += $(clcore_cflags)
171LOCAL_CFLAGS += -g -O0
172LOCAL_SRC_FILES := $(clcore_base_files)
173LOCAL_SRC_FILES += rs_abi_debuginfo.c
174LOCAL_SRC_FILES_32 := $(clcore_base_files_32)
175LOCAL_SRC_FILES_64 := $(clcore_base_files_64)
176
177ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm64))
178LOCAL_SRC_FILES_64 += arch/asimd.ll arch/clamp.c
179LOCAL_CFLAGS_64 += -DARCH_ARM64_HAVE_NEON
180else
181LOCAL_SRC_FILES_64 += arch/generic.c
182endif
183
184include $(LOCAL_PATH)/build_bc_lib.mk
185rs_debug_runtime :=
186rs_g_runtime :=
187
188### Build new versions (librsrt_<ARCH>.bc) as host shared libraries.
189### These will be used with bcc_compat and the support library.
190
191# Build the ARM version of the library
192include $(CLEAR_VARS)
193
194# FIXME for 64-bit
195LOCAL_32_BIT_ONLY := true
196
197BCC_RS_TRIPLE := renderscript32-linux-androideabi
198RS_TRIPLE_CFLAGS :=
199LOCAL_MODULE := librsrt_arm.bc
200LOCAL_IS_HOST_MODULE := true
201LOCAL_CFLAGS += $(clcore_cflags)
202LOCAL_SRC_FILES := $(clcore_files) $(clcore_files_32)
203include $(LOCAL_PATH)/build_bc_lib.mk
204
205# Build the MIPS version of the library
206include $(CLEAR_VARS)
207
208# FIXME for 64-bit
209LOCAL_32_BIT_ONLY := true
210
211BCC_RS_TRIPLE := renderscript32-linux-androideabi
212RS_TRIPLE_CFLAGS :=
213LOCAL_MODULE := librsrt_mips.bc
214LOCAL_IS_HOST_MODULE := true
215LOCAL_CFLAGS += $(clcore_cflags)
216LOCAL_SRC_FILES := $(clcore_files) $(clcore_files_32)
217include $(LOCAL_PATH)/build_bc_lib.mk
218
219# Build the x86 version of the library
220include $(CLEAR_VARS)
221
222# FIXME for 64-bit
223LOCAL_32_BIT_ONLY := true
224
225BCC_RS_TRIPLE := renderscript32-linux-androideabi
226RS_TRIPLE_CFLAGS := -D__i386__
227LOCAL_MODULE := librsrt_x86.bc
228LOCAL_IS_HOST_MODULE := true
229LOCAL_CFLAGS += $(clcore_cflags) -DARCH_X86_HAVE_SSSE3
230LOCAL_SRC_FILES := $(clcore_x86_files) $(clcore_base_files_32)
231include $(LOCAL_PATH)/build_bc_lib.mk
232
233include $(CLEAR_VARS)
234
235BCC_RS_TRIPLE := renderscript64-linux-android
236RS_TRIPLE_CFLAGS :=
237LOCAL_MODULE := librsrt_arm64.bc
238LOCAL_IS_HOST_MODULE := true
239LOCAL_CFLAGS += $(clcore_cflags)
240LOCAL_SRC_FILES := $(clcore_files) $(clcore_files_64)
241include $(LOCAL_PATH)/build_bc_lib.mk
242
243# Build the x86_64 version of the library
244include $(CLEAR_VARS)
245
246BCC_RS_TRIPLE := renderscript64-linux-android
247RS_TRIPLE_CFLAGS := -D__x86_64__
248LOCAL_MODULE := librsrt_x86_64.bc
249LOCAL_IS_HOST_MODULE := true
250LOCAL_CFLAGS += $(clcore_cflags) -DARCH_X86_HAVE_SSSE3
251LOCAL_SRC_FILES := $(clcore_x86_files) $(clcore_base_files_64)
252include $(LOCAL_PATH)/build_bc_lib.mk
253