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 ifndef BCC_RS_TRIPLE 18 BCC_RS_TRIPLE := $($(LOCAL_2ND_ARCH_VAR_PREFIX)RS_TRIPLE) 19 endif 20 21 # Set these values always by default 22 LOCAL_MODULE_CLASS := RENDERSCRIPT_BITCODE 23 24 include $(BUILD_SYSTEM)/base_rules.mk 25 26 BCC_STRIP_ATTR := $(BUILD_OUT_EXECUTABLES)/bcc_strip_attr$(BUILD_EXECUTABLE_SUFFIX) 27 28 bc_clang := $(RS_CLANG) 29 ifdef RS_DRIVER_CLANG_EXE 30 bc_clang := $(RS_DRIVER_CLANG_EXE) 31 endif 32 33 # Disable deprecated warnings, because we have to support even legacy APIs. 34 bc_warning_flags := -Wno-deprecated -Werror 35 36 bc_cflags := -MD \ 37 $(RS_VERSION_DEFINE) \ 38 -std=c99 \ 39 -c \ 40 -O3 \ 41 -fno-builtin \ 42 -emit-llvm \ 43 -target $(BCC_RS_TRIPLE) \ 44 -fsigned-char \ 45 $($(LOCAL_2ND_ARCH_VAR_PREFIX)RS_TRIPLE_CFLAGS) \ 46 $(bc_warning_flags) \ 47 $(LOCAL_CFLAGS) \ 48 $(LOCAL_CFLAGS_$(my_32_64_bit_suffix)) \ 49 -x renderscript 50 51 ifeq ($(rs_debug_runtime),1) 52 bc_cflags += -DRS_DEBUG_RUNTIME 53 endif 54 55 ifeq ($(rs_g_runtime),1) 56 bc_cflags += -DRS_G_RUNTIME 57 endif 58 59 bc_src_files := $(LOCAL_SRC_FILES) 60 bc_src_files += $(LOCAL_SRC_FILES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) 61 62 c_sources := $(filter %.c,$(bc_src_files)) 63 ll_sources := $(filter %.ll,$(bc_src_files)) 64 65 c_bc_files := $(patsubst %.c,%.bc, \ 66 $(addprefix $(intermediates)/, $(c_sources))) 67 68 ll_bc_files := $(patsubst %.ll,%.bc, \ 69 $(addprefix $(intermediates)/, $(ll_sources))) 70 71 $(c_bc_files): PRIVATE_INCLUDES := \ 72 frameworks/rs/script_api/include \ 73 external/clang/lib/Headers 74 $(c_bc_files): PRIVATE_CFLAGS := $(bc_cflags) 75 76 $(c_bc_files): $(intermediates)/%.bc: $(LOCAL_PATH)/%.c $(bc_clang) 77 @echo "bc: $(PRIVATE_MODULE) <= $<" 78 @mkdir -p $(dir $@) 79 $(hide) $(RELATIVE_PWD) $(bc_clang) $(addprefix -I, $(PRIVATE_INCLUDES)) $(PRIVATE_CFLAGS) $< -o $@ 80 81 $(ll_bc_files): $(intermediates)/%.bc: $(LOCAL_PATH)/%.ll $(RS_LLVM_AS) 82 @mkdir -p $(dir $@) 83 $(hide) $(RELATIVE_PWD) $(RS_LLVM_AS) $< -o $@ 84 85 $(foreach f,$(c_bc_files),$(call include-depfile,$(f:%.bc=%.d),$(f))) 86 87 $(LOCAL_BUILT_MODULE): PRIVATE_BC_FILES := $(c_bc_files) $(ll_bc_files) 88 $(LOCAL_BUILT_MODULE): $(c_bc_files) $(ll_bc_files) 89 $(LOCAL_BUILT_MODULE): $(RS_LLVM_LINK) 90 $(LOCAL_BUILT_MODULE): $(RS_LLVM_AS) $(BCC_STRIP_ATTR) 91 @echo "bc lib: $(PRIVATE_MODULE) ($@)" 92 @mkdir -p $(dir $@) 93 # Strip useless known warning about combining mismatched modules, as well as 94 # any blank lines that llvm-link inserts. 95 $(hide) $(RELATIVE_PWD) $(RS_LLVM_LINK) $(PRIVATE_BC_FILES) -o $@.unstripped 2> >(grep -v "\(modules of different\)\|^$$" >&2) 96 $(hide) $(RELATIVE_PWD) $(BCC_STRIP_ATTR) -o $@ $@.unstripped 97 98 BCC_RS_TRIPLE := 99