build_bc_lib.mk revision 1b0b0baa2e094de111f05e959f23cc9f589a99b6
1#
2# Copyright (C) 2012 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
17# Set these values always by default
18LOCAL_MODULE_TAGS := optional
19LOCAL_MODULE_CLASS := SHARED_LIBRARIES
20
21include $(BUILD_SYSTEM)/base_rules.mk
22
23BCC_STRIP_ATTR := $(BUILD_OUT_EXECUTABLES)/bcc_strip_attr$(BUILD_EXECUTABLE_SUFFIX)
24
25bc_clang_cc1_cflags :=
26ifeq ($(BCC_RS_TRIPLE),armv7-none-linux-gnueabi)
27# We need to pass the +long64 flag to the underlying version of Clang, since
28# we are generating a library for use with Renderscript (64-bit long type,
29# not 32-bit).
30bc_clang_cc1_cflags += -target-feature +long64
31endif
32bc_translated_clang_cc1_cflags := $(addprefix -Xclang , $(bc_clang_cc1_cflags))
33
34bc_cflags := -MD \
35             -DRS_VERSION=$(RS_VERSION) \
36             -std=c99 \
37             -c \
38             -O3 \
39             -fno-builtin \
40             -emit-llvm \
41             -target $(BCC_RS_TRIPLE) \
42             -fsigned-char \
43             $(LOCAL_CFLAGS) \
44             $(bc_translated_clang_cc1_cflags)
45
46ifeq ($(rs_debug_runtime),1)
47    bc_cflags += -DRS_DEBUG_RUNTIME
48endif
49rs_debug_runtime:=
50
51c_sources := $(filter %.c,$(LOCAL_SRC_FILES))
52ll_sources := $(filter %.ll,$(LOCAL_SRC_FILES))
53
54c_bc_files := $(patsubst %.c,%.bc, \
55    $(addprefix $(intermediates)/, $(c_sources)))
56
57ll_bc_files := $(patsubst %.ll,%.bc, \
58    $(addprefix $(intermediates)/, $(ll_sources)))
59
60$(c_bc_files): PRIVATE_INCLUDES := \
61    frameworks/rs/scriptc \
62    external/clang/lib/Headers
63$(c_bc_files): PRIVATE_CFLAGS := $(bc_cflags)
64
65$(c_bc_files): $(intermediates)/%.bc: $(LOCAL_PATH)/%.c  $(CLANG)
66	@mkdir -p $(dir $@)
67	$(hide) $(CLANG) $(addprefix -I, $(PRIVATE_INCLUDES)) $(PRIVATE_CFLAGS) $< -o $@
68
69$(ll_bc_files): $(intermediates)/%.bc: $(LOCAL_PATH)/%.ll $(LLVM_AS)
70	@mkdir -p $(dir $@)
71	$(hide) $(LLVM_AS) $< -o $@
72
73-include $(c_bc_files:%.bc=%.d)
74-include $(ll_bc_files:%.bc=%.d)
75
76$(LOCAL_BUILT_MODULE): PRIVATE_BC_FILES := $(c_bc_files) $(ll_bc_files)
77$(LOCAL_BUILT_MODULE): $(c_bc_files) $(ll_bc_files)
78$(LOCAL_BUILT_MODULE): $(LLVM_LINK) $(clcore_LLVM_LD)
79$(LOCAL_BUILT_MODULE): $(LLVM_AS) $(BCC_STRIP_ATTR)
80	@mkdir -p $(dir $@)
81	$(hide) $(LLVM_LINK) $(PRIVATE_BC_FILES) -o $@.unstripped
82	$(hide) $(BCC_STRIP_ATTR) -o $@ $@.unstripped
83