1#
2# Copyright (C) 2010 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#
16LOCAL_PATH := $(call my-dir)
17
18FORCE_BUILD_LLVM_DISABLE_NDEBUG ?= false
19# Legality check: FORCE_BUILD_LLVM_DISABLE_NDEBUG should consist of one word -- either "true" or "false".
20ifneq "$(words $(FORCE_BUILD_LLVM_DISABLE_NDEBUG))$(words $(filter-out true false,$(FORCE_BUILD_LLVM_DISABLE_NDEBUG)))" "10"
21  $(error FORCE_BUILD_LLVM_DISABLE_NDEBUG may only be true, false, or unset)
22endif
23
24FORCE_BUILD_LLVM_DEBUG ?= false
25# Legality check: FORCE_BUILD_LLVM_DEBUG should consist of one word -- either "true" or "false".
26ifneq "$(words $(FORCE_BUILD_LLVM_DEBUG))$(words $(filter-out true false,$(FORCE_BUILD_LLVM_DEBUG)))" "10"
27  $(error FORCE_BUILD_LLVM_DEBUG may only be true, false, or unset)
28endif
29
30# The prebuilt tools should be used when we are doing app-only build.
31ifeq ($(TARGET_BUILD_APPS),)
32
33
34local_cflags_for_slang := -Wall -Werror -std=c++11
35ifeq ($(TARGET_BUILD_VARIANT),eng)
36local_cflags_for_slang += -O0 -D__ENABLE_INTERNAL_OPTIONS
37else
38ifeq ($(TARGET_BUILD_VARIANT),userdebug)
39else
40local_cflags_for_slang += -D__DISABLE_ASSERTS
41endif
42endif
43local_cflags_for_slang += -DTARGET_BUILD_VARIANT=$(TARGET_BUILD_VARIANT)
44
45include $(LOCAL_PATH)/rs_version.mk
46local_cflags_for_slang += $(RS_VERSION_DEFINE)
47
48static_libraries_needed_by_slang := \
49	libLLVMBitWriter_2_9 \
50	libLLVMBitWriter_2_9_func \
51	libLLVMBitWriter_3_2
52
53# Static library libslang for host
54# ========================================================
55include $(CLEAR_VARS)
56include $(CLEAR_TBLGEN_VARS)
57
58LLVM_ROOT_PATH := external/llvm
59CLANG_ROOT_PATH := external/clang
60
61include $(CLANG_ROOT_PATH)/clang.mk
62
63LOCAL_MODULE := libslang
64LOCAL_MODULE_TAGS := optional
65
66LOCAL_CFLAGS += $(local_cflags_for_slang)
67
68# Skip missing-field-initializer warnings for mingw.
69LOCAL_CFLAGS_windows += -Wno-error=missing-field-initializers
70
71TBLGEN_TABLES :=    \
72	AttrList.inc	\
73	Attrs.inc	\
74	CommentCommandList.inc \
75	CommentNodes.inc \
76	DeclNodes.inc	\
77	DiagnosticCommonKinds.inc	\
78	DiagnosticFrontendKinds.inc	\
79	DiagnosticSemaKinds.inc	\
80	StmtNodes.inc
81
82LOCAL_SRC_FILES :=	\
83	slang.cpp	\
84	slang_bitcode_gen.cpp	\
85	slang_backend.cpp	\
86	slang_diagnostic_buffer.cpp
87
88LOCAL_C_INCLUDES += frameworks/compile/libbcc/include
89
90LOCAL_LDLIBS := -ldl -lpthread
91
92include $(CLANG_HOST_BUILD_MK)
93include $(CLANG_TBLGEN_RULES_MK)
94include $(LLVM_GEN_INTRINSICS_MK)
95include $(LLVM_GEN_ATTRIBUTES_MK)
96include $(BUILD_HOST_STATIC_LIBRARY)
97
98# ========================================================
99include $(CLEAR_VARS)
100
101LLVM_ROOT_PATH := external/llvm
102
103LOCAL_MODULE := llvm-rs-as
104LOCAL_MODULE_TAGS := optional
105
106LOCAL_MODULE_CLASS := EXECUTABLES
107
108LOCAL_SRC_FILES :=	\
109	llvm-rs-as.cpp
110
111LOCAL_CFLAGS += $(local_cflags_for_slang)
112LOCAL_STATIC_LIBRARIES :=	\
113	libslang \
114	$(static_libraries_needed_by_slang)
115LOCAL_SHARED_LIBRARIES := \
116	libLLVM
117
118include $(CLANG_HOST_BUILD_MK)
119include $(LLVM_HOST_BUILD_MK)
120include $(LLVM_GEN_ATTRIBUTES_MK)
121include $(BUILD_HOST_EXECUTABLE)
122
123# Executable llvm-rs-cc for host
124# ========================================================
125include $(CLEAR_VARS)
126include $(CLEAR_TBLGEN_VARS)
127
128LOCAL_IS_HOST_MODULE := true
129LOCAL_MODULE := llvm-rs-cc
130
131LOCAL_CFLAGS += $(local_cflags_for_slang)
132
133# Skip missing-field-initializer warnings for mingw.
134LOCAL_CFLAGS += -Wno-error=missing-field-initializers
135LOCAL_MODULE_TAGS := optional
136
137LOCAL_MODULE_CLASS := EXECUTABLES
138
139TBLGEN_TABLES :=    \
140	AttrList.inc    \
141	Attrs.inc    \
142	CommentCommandList.inc \
143	CommentNodes.inc \
144	DeclNodes.inc    \
145	DiagnosticCommonKinds.inc   \
146	DiagnosticDriverKinds.inc	\
147	DiagnosticFrontendKinds.inc	\
148	DiagnosticSemaKinds.inc	\
149	StmtNodes.inc	\
150	RSCCOptions.inc
151
152LOCAL_SRC_FILES :=	\
153	llvm-rs-cc.cpp	\
154	rs_cc_options.cpp \
155	slang_rs_foreach_lowering.cpp \
156	slang_rs_ast_replace.cpp	\
157	slang_rs_check_ast.cpp	\
158	slang_rs_context.cpp	\
159	slang_rs_pragma_handler.cpp	\
160	slang_rs_exportable.cpp	\
161	slang_rs_export_type.cpp	\
162	slang_rs_export_element.cpp	\
163	slang_rs_export_var.cpp	\
164	slang_rs_export_func.cpp	\
165	slang_rs_export_foreach.cpp	\
166	slang_rs_export_reduce.cpp	\
167	slang_rs_object_ref_count.cpp	\
168	slang_rs_reflection.cpp \
169	slang_rs_reflection_cpp.cpp \
170	slang_rs_reflect_utils.cpp \
171	slang_rs_special_func.cpp	\
172	slang_rs_special_kernel_param.cpp \
173	strip_unknown_attributes.cpp
174
175LOCAL_C_INCLUDES += frameworks/compile/libbcc/include
176
177LOCAL_STATIC_LIBRARIES :=	\
178	libslang \
179	$(static_libraries_needed_by_slang)
180
181LOCAL_SHARED_LIBRARIES := \
182	libclang \
183	libLLVM
184
185LOCAL_LDLIBS_windows := -limagehlp -lpsapi
186LOCAL_LDLIBS_linux := -ldl -lpthread
187LOCAL_LDLIBS_darwin := -ldl -lpthread
188
189# For build RSCCOptions.inc from RSCCOptions.td
190intermediates := $(call local-generated-sources-dir)
191LOCAL_GENERATED_SOURCES += $(intermediates)/RSCCOptions.inc
192$(intermediates)/RSCCOptions.inc: $(LOCAL_PATH)/RSCCOptions.td $(LLVM_ROOT_PATH)/include/llvm/Option/OptParser.td $(LLVM_TBLGEN)
193	@echo "Building Renderscript compiler (llvm-rs-cc) Option tables with tblgen"
194	$(call transform-host-td-to-out,opt-parser-defs)
195
196include $(CLANG_HOST_BUILD_MK)
197include $(CLANG_TBLGEN_RULES_MK)
198include $(LLVM_GEN_ATTRIBUTES_MK)
199include $(BUILD_HOST_EXECUTABLE)
200
201endif  # TARGET_BUILD_APPS
202
203#=====================================================================
204# Include Subdirectories
205#=====================================================================
206include $(call all-makefiles-under,$(LOCAL_PATH))
207