build_bc_lib_internal.mk revision 16cfba29a921308efad37855c487d4278de5f571
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_CFLAGS) \ 48 $(bc_translated_clang_cc1_cflags) 49 50ifeq ($(rs_debug_runtime),1) 51 bc_cflags += -DRS_DEBUG_RUNTIME 52endif 53 54bc_src_files := $(LOCAL_SRC_FILES) 55bc_src_files += $(LOCAL_SRC_FILES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) 56 57c_sources := $(filter %.c,$(bc_src_files)) 58ll_sources := $(filter %.ll,$(bc_src_files)) 59 60c_bc_files := $(patsubst %.c,%.bc, \ 61 $(addprefix $(intermediates)/, $(c_sources))) 62 63ll_bc_files := $(patsubst %.ll,%.bc, \ 64 $(addprefix $(intermediates)/, $(ll_sources))) 65 66$(c_bc_files): PRIVATE_INCLUDES := \ 67 frameworks/rs/scriptc \ 68 external/clang/lib/Headers 69$(c_bc_files): PRIVATE_CFLAGS := $(bc_cflags) 70 71$(c_bc_files): $(intermediates)/%.bc: $(LOCAL_PATH)/%.c $(CLANG) 72 @echo "bc: $(PRIVATE_MODULE) <= $<" 73 @mkdir -p $(dir $@) 74 $(hide) $(CLANG) $(addprefix -I, $(PRIVATE_INCLUDES)) $(PRIVATE_CFLAGS) $< -o $@ 75 76$(ll_bc_files): $(intermediates)/%.bc: $(LOCAL_PATH)/%.ll $(LLVM_AS) 77 @mkdir -p $(dir $@) 78 $(hide) $(LLVM_AS) $< -o $@ 79 80-include $(c_bc_files:%.bc=%.d) 81-include $(ll_bc_files:%.bc=%.d) 82 83$(LOCAL_BUILT_MODULE): PRIVATE_BC_FILES := $(c_bc_files) $(ll_bc_files) 84$(LOCAL_BUILT_MODULE): $(c_bc_files) $(ll_bc_files) 85$(LOCAL_BUILT_MODULE): $(LLVM_LINK) $(clcore_LLVM_LD) 86$(LOCAL_BUILT_MODULE): $(LLVM_AS) $(BCC_STRIP_ATTR) 87 @echo "bc lib: $(PRIVATE_MODULE) ($@)" 88 @mkdir -p $(dir $@) 89 $(hide) $(LLVM_LINK) $(PRIVATE_BC_FILES) -o $@.unstripped 90 $(hide) $(BCC_STRIP_ATTR) -o $@ $@.unstripped 91 92BCC_RS_TRIPLE := 93