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