1# USE_LLVM_EXECUTIONENGINE is not fully implemented. We use libbcc instead.
2USE_LLVM_EXECUTIONENGINE := false
3# If using libLLVMExecutionEngine,
4# need to add files to several Android.mk in external/llvm, and comment out some stuff in
5# llvm DynamicLibrary.cpp and Intercept.cpp
6
7DEBUG_BUILD := false
8
9LOCAL_PATH := $(call my-dir)
10LIBBCC_ROOT_PATH := frameworks/compile/libbcc
11include $(LIBBCC_ROOT_PATH)/libbcc.mk
12
13# These are for using llvm::ExecutionEngine, also remove libbcc
14# libLLVMX86CodeGen;libLLVMX86Info;libLLVMBitReader;libLLVMSelectionDAG;libLLVMAsmPrinter;libLLVMJIT;libLLVMCodeGen;libLLVMTarget;libLLVMMC;libLLVMScalarOpts;libLLVMipo;libLLVMTransformUtils;libLLVMCore;libLLVMSupport;libLLVMSystem;libLLVMAnalysis;libLLVMInstCombine;libLLVMipa;libLLVMMCParser;libLLVMExecutionEngine;
15libMesa_STATIC_LIBS :=  \
16    libLLVMBitReader    \
17    libLLVMSelectionDAG \
18    libLLVMAsmPrinter   \
19    libLLVMJIT          \
20    libLLVMCodeGen      \
21    libLLVMTarget       \
22    libLLVMMC           \
23    libLLVMScalarOpts   \
24    libLLVMipo          \
25    libLLVMTransformUtils \
26    libLLVMCore         \
27    libLLVMSupport      \
28    libLLVMSystem       \
29    libLLVMAnalysis     \
30    libLLVMInstCombine  \
31    libLLVMipa          \
32    libLLVMMCParser     \
33    libLLVMExecutionEngine
34
35libMesa_SRC_FILES := \
36    src/glsl/glcpp/pp.c \
37    src/glsl/glcpp/glcpp-lex.c \
38    src/glsl/glcpp/glcpp-parse.c \
39    src/glsl/ast_expr.cpp \
40    src/glsl/ast_function.cpp \
41    src/glsl/ast_to_hir.cpp \
42    src/glsl/ast_type.cpp \
43    src/glsl/builtin_function.cpp \
44    src/glsl/glsl_lexer.cpp \
45    src/glsl/glsl_parser.cpp \
46    src/glsl/glsl_parser_extras.cpp \
47    src/glsl/glsl_symbol_table.cpp \
48    src/glsl/glsl_types.cpp \
49    src/glsl/hir_field_selection.cpp \
50    src/glsl/ir.cpp \
51    src/glsl/ir_basic_block.cpp \
52    src/glsl/ir_clone.cpp \
53    src/glsl/ir_constant_expression.cpp \
54    src/glsl/ir_expression_flattening.cpp \
55    src/glsl/ir_function.cpp \
56    src/glsl/ir_function_can_inline.cpp \
57    src/glsl/ir_hierarchical_visitor.cpp \
58    src/glsl/ir_hv_accept.cpp \
59    src/glsl/ir_import_prototypes.cpp \
60    src/glsl/ir_print_visitor.cpp \
61    src/glsl/ir_reader.cpp \
62    src/glsl/ir_rvalue_visitor.cpp \
63    src/glsl/ir_set_program_inouts.cpp \
64    src/glsl/ir_validate.cpp \
65    src/glsl/ir_variable.cpp \
66    src/glsl/ir_variable_refcount.cpp \
67    src/glsl/link_functions.cpp \
68    src/glsl/linker.cpp \
69    src/glsl/loop_analysis.cpp \
70    src/glsl/loop_controls.cpp \
71    src/glsl/loop_unroll.cpp \
72    src/glsl/lower_discard.cpp \
73    src/glsl/lower_if_to_cond_assign.cpp \
74    src/glsl/lower_instructions.cpp \
75    src/glsl/lower_jumps.cpp \
76    src/glsl/lower_mat_op_to_vec.cpp \
77    src/glsl/lower_noise.cpp \
78    src/glsl/lower_texture_projection.cpp \
79    src/glsl/lower_variable_index_to_cond_assign.cpp \
80    src/glsl/lower_vec_index_to_cond_assign.cpp \
81    src/glsl/lower_vec_index_to_swizzle.cpp \
82    src/glsl/lower_vector.cpp \
83    src/glsl/main.cpp \
84    src/glsl/opt_algebraic.cpp \
85    src/glsl/opt_constant_folding.cpp \
86    src/glsl/opt_constant_propagation.cpp \
87    src/glsl/opt_constant_variable.cpp \
88    src/glsl/opt_copy_propagation.cpp \
89    src/glsl/opt_dead_code.cpp \
90    src/glsl/opt_dead_code_local.cpp \
91    src/glsl/opt_dead_functions.cpp \
92    src/glsl/opt_discard_simplification.cpp \
93    src/glsl/opt_function_inlining.cpp \
94    src/glsl/opt_if_simplification.cpp \
95    src/glsl/opt_noop_swizzle.cpp \
96    src/glsl/opt_redundant_jumps.cpp \
97    src/glsl/opt_structure_splitting.cpp \
98    src/glsl/opt_swizzle_swizzle.cpp \
99    src/glsl/opt_tree_grafting.cpp \
100    src/glsl/s_expression.cpp \
101    src/glsl/strtod.c \
102    src/glsl/ir_to_llvm.cpp \
103    src/mesa/main/shaderobj.c \
104    src/mesa/program/hash_table.c \
105    src/mesa/program/prog_parameter.cpp \
106    src/mesa/program/symbol_table.c \
107    src/pixelflinger2/buffer.cpp \
108    src/pixelflinger2/format.cpp \
109    src/pixelflinger2/llvm_scanline.cpp \
110    src/pixelflinger2/llvm_texture.cpp \
111    src/pixelflinger2/pixelflinger2.cpp \
112    src/pixelflinger2/raster.cpp \
113    src/pixelflinger2/scanline.cpp \
114    src/pixelflinger2/shader.cpp \
115    src/pixelflinger2/texture.cpp \
116    src/talloc/hieralloc.c
117
118libMesa_C_INCLUDES := \
119    $(LOCAL_PATH) \
120    $(LOCAL_PATH)/src/glsl   \
121    $(LOCAL_PATH)/src/mesa   \
122    $(LOCAL_PATH)/src/talloc \
123    $(LOCAL_PATH)/src/mapi   \
124    $(LOCAL_PATH)/include    \
125    $(LIBBCC_ROOT_PATH)/include
126
127# Static library for host
128# ========================================================
129include $(CLEAR_VARS)
130
131LOCAL_MODULE_TAGS := optional
132
133ifeq ($(DEBUG_BUILD),true)
134LOCAL_CFLAGS += -DDEBUG -UNDEBUG -O0 -g
135else
136LOCAL_CFLAGS += -O3
137endif
138
139LOCAL_MODULE := libMesa
140LOCAL_MODULE_CLASS := STATIC_LIBRARIES
141LOCAL_IS_HOST_MODULE := true
142LOCAL_SRC_FILES := $(libMesa_SRC_FILES)
143
144ifeq ($(USE_LLVM_EXECUTIONENGINE),true)
145LOCAL_CFLAGS += -DUSE_LLVM_EXECUTIONENGINE=1
146LOCAL_STATIC_LIBRARIES := libLLVMX86CodeGen libLLVMX86Info $(libMesa_STATIC_LIBS)
147else
148LOCAL_CFLAGS += -DUSE_LLVM_EXECUTIONENGINE=0
149LOCAL_SHARED_LIBRARIES := libbcc libbcinfo
150endif
151
152LOCAL_C_INCLUDES := $(libMesa_C_INCLUDES)
153
154include $(LIBBCC_GEN_CONFIG_MK)
155include $(LLVM_HOST_BUILD_MK)
156include $(BUILD_HOST_STATIC_LIBRARY)
157
158
159# Static library for target
160# ========================================================
161include $(CLEAR_VARS)
162
163LOCAL_MODULE_TAGS := optional
164
165ifeq ($(DEBUG_BUILD),true)
166LOCAL_CFLAGS += -DDEBUG -UNDEBUG -O0 -g
167else
168LOCAL_CFLAGS += -O3
169endif
170
171LOCAL_MODULE := libMesa
172LOCAL_MODULE_CLASS := STATIC_LIBRARIES
173LOCAL_SRC_FILES := $(libMesa_SRC_FILES)
174LOCAL_SHARED_LIBRARIES := libstlport libcutils libdl libutils
175
176ifeq ($(USE_LLVM_EXECUTIONENGINE),true)
177LOCAL_CFLAGS += -DUSE_LLVM_EXECUTIONENGINE=1
178LOCAL_STATIC_LIBRARIES :=  libLLVMARMCodeGen libLLVMARMInfo libLLVMARMDisassembler \
179    libLLVMARMAsmPrinter $(libMesa_STATIC_LIBS)
180else
181LOCAL_CFLAGS += -DUSE_LLVM_EXECUTIONENGINE=0
182LOCAL_SHARED_LIBRARIES += libbcc libbcinfo
183endif
184
185LOCAL_C_INCLUDES := $(libMesa_C_INCLUDES)
186
187include $(LIBBCC_GEN_CONFIG_MK)
188include $(LLVM_DEVICE_BUILD_MK)
189include $(BUILD_STATIC_LIBRARY)
190
191# glsl_compiler for host
192# ========================================================
193include $(CLEAR_VARS)
194
195LOCAL_MODULE_TAGS := optional
196
197ifeq ($(DEBUG_BUILD),true)
198LOCAL_CFLAGS += -DDEBUG -UNDEBUG -O0 -g
199endif
200
201LOCAL_MODULE := glsl_compiler
202LOCAL_MODULE_CLASS := EXECUTABLES
203LOCAL_SRC_FILES := src/glsl/glsl_compiler.cpp
204LOCAL_C_INCLUDES := $(libMesa_C_INCLUDES)
205LOCAL_STATIC_LIBRARIES := libMesa
206
207include $(BUILD_HOST_EXECUTABLE)
208
209# Build children
210# ========================================================
211include $(call all-makefiles-under,$(LOCAL_PATH))
212