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