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