Colin Cross | b1657a5 | 2014-02-11 16:52:27 -0800 | [diff] [blame] | 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_TAGS := optional |
| 23 | LOCAL_MODULE_CLASS := SHARED_LIBRARIES |
| 24 | |
| 25 | include $(BUILD_SYSTEM)/base_rules.mk |
| 26 | |
| 27 | BCC_STRIP_ATTR := $(BUILD_OUT_EXECUTABLES)/bcc_strip_attr$(BUILD_EXECUTABLE_SUFFIX) |
| 28 | |
| 29 | bc_clang_cc1_cflags := |
| 30 | ifeq ($(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). |
| 34 | bc_clang_cc1_cflags += -target-feature +long64 |
| 35 | endif |
| 36 | bc_translated_clang_cc1_cflags := $(addprefix -Xclang , $(bc_clang_cc1_cflags)) |
| 37 | |
| 38 | bc_cflags := -MD \ |
Stephen Hines | c17fa06 | 2014-05-13 18:57:38 -0700 | [diff] [blame] | 39 | $(RS_VERSION_DEFINE) \ |
Colin Cross | b1657a5 | 2014-02-11 16:52:27 -0800 | [diff] [blame] | 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 | |
| 50 | ifeq ($(rs_debug_runtime),1) |
| 51 | bc_cflags += -DRS_DEBUG_RUNTIME |
| 52 | endif |
Colin Cross | b1657a5 | 2014-02-11 16:52:27 -0800 | [diff] [blame] | 53 | |
Tim Murray | 1efb819 | 2014-05-19 17:24:58 -0700 | [diff] [blame] | 54 | bc_src_files := $(LOCAL_SRC_FILES) |
| 55 | bc_src_files += $(LOCAL_SRC_FILES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) |
| 56 | |
| 57 | c_sources := $(filter %.c,$(bc_src_files)) |
| 58 | ll_sources := $(filter %.ll,$(bc_src_files)) |
Colin Cross | b1657a5 | 2014-02-11 16:52:27 -0800 | [diff] [blame] | 59 | |
| 60 | c_bc_files := $(patsubst %.c,%.bc, \ |
| 61 | $(addprefix $(intermediates)/, $(c_sources))) |
| 62 | |
| 63 | ll_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 | |
| 92 | BCC_RS_TRIPLE := |