1LOCAL_PATH := $(call my-dir) 2include $(CLEAR_VARS) 3 4ifeq ($(ARCH_ARM_HAVE_NEON),true) 5 libvpx_target := armv7a-neon 6 libvpx_asm := .asm.s 7else ifeq ($(ARCH_ARM_HAVE_ARMV7A),true) 8 libvpx_target := armv7a 9 libvpx_asm := .asm.s 10endif 11 12ifeq ($(TARGET_ARCH),x86) 13 libvpx_target := x86 14 libvpx_asm := .asm 15endif 16 17ifeq ($(TARGET_ARCH),mips) 18 ifneq ($(ARCH_HAS_BIGENDIAN),true) 19 ifeq ($(ARCH_MIPS_DSP_REV),2) 20 libvpx_target := mips-dspr2 21 LOCAL_CFLAGS += -DMIPS_DSP_REV=$(ARCH_MIPS_DSP_REV) 22 else 23 libvpx_target := mips 24 ifeq ($(ARCH_MIPS_DSP_REV),1) 25 LOCAL_CFLAGS += -DMIPS_DSP_REV=$(ARCH_MIPS_DSP_REV) 26 else 27 LOCAL_CFLAGS += -DMIPS_DSP_REV=0 28 endif #mips_dsp_rev1 29 endif #mips_dsp_rev2 30 endif #bigendian 31endif #mips 32 33# Un-optimized targets 34libvpx_target ?= generic 35libvpx_asm ?= .asm 36 37libvpx_config_dir := $(LOCAL_PATH)/$(libvpx_target) 38libvpx_source_dir := $(LOCAL_PATH)/libvpx 39 40libvpx_codec_srcs := $(shell cat $(libvpx_config_dir)/libvpx_srcs.txt) 41 42LOCAL_SHARED_LIBRARIES += liblog 43LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog 44LOCAL_CFLAGS := -DHAVE_CONFIG_H=vpx_config.h 45LOCAL_CFLAGS += -Werror 46LOCAL_MODULE := libvpx_internal 47 48LOCAL_MODULE_CLASS := STATIC_LIBRARIES 49libvpx_intermediates := $(call local-intermediates-dir) 50 51# Extract the C files from the list and add them to LOCAL_SRC_FILES. 52libvpx_codec_srcs_unique := $(sort $(libvpx_codec_srcs)) 53libvpx_codec_srcs_c := $(filter %.c, $(libvpx_codec_srcs_unique)) 54ifeq ($(libvpx_target),x86) 55x86_asm_src_files := $(filter %.asm, $(libvpx_codec_srcs_unique)) 56X86_ASM_SRCS := $(addprefix $(LOCAL_PATH)/libvpx/, $(x86_asm_src_files)) 57X86_ASM_OBJS := $(addprefix $(libvpx_intermediates)/, $(x86_asm_src_files:%.asm=%.asm.o)) 58endif 59# vpx_config.c is an auto-generated file in $(config_dir) 60libvpx_codec_srcs_c_static := $(filter-out vpx_config.c, $(libvpx_codec_srcs_c)) 61LOCAL_SRC_FILES += $(addprefix libvpx/, $(libvpx_codec_srcs_c_static)) 62LOCAL_SRC_FILES += $(libvpx_target)/vpx_config.c 63 64# ARM and x86 use an 'offsets' file in the assembly. It is generated by 65# tricking the compiler and generating non-functional output which is then 66# processed with grep. For ARM, this must be additionally converted from 67# RVCT (ARM's in-house compiler) format to GNU Assembler Format for gcc. 68 69# Offset files are currently used in vpx_scale for NEON and some encoder 70# functions used in both ARM and x86. These files can not be compiled and need 71# to be named accordingly to avoid auto-build rules. The encoder files are not 72# used yet but are included in the comments for future reference. 73 74ifneq ($(libvpx_target),x86) 75libvpx_asm_offsets_intermediates := \ 76 vp8/encoder/vp8_asm_enc_offsets.intermediate \ 77 vpx_scale/vpx_scale_asm_offsets.intermediate \ 78 79libvpx_asm_offsets_files := \ 80 vp8/encoder/vp8_asm_enc_offsets.asm \ 81 vpx_scale/vpx_scale_asm_offsets.asm \ 82 83endif 84# Build the S files with inline assembly. 85COMPILE_TO_S := $(addprefix $(libvpx_intermediates)/, $(libvpx_asm_offsets_intermediates)) 86$(COMPILE_TO_S) : PRIVATE_INTERMEDIATES := $(libvpx_intermediates) 87$(COMPILE_TO_S) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir) 88$(COMPILE_TO_S) : PRIVATE_CONFIG_DIR := $(libvpx_config_dir) 89$(COMPILE_TO_S) : PRIVATE_CUSTOM_TOOL = $(TARGET_CC) -S $(addprefix -I, $(TARGET_C_INCLUDES)) -I $(PRIVATE_INTERMEDIATES) -I $(PRIVATE_SOURCE_DIR) -I $(PRIVATE_CONFIG_DIR) -DINLINE_ASM -o $@ $< 90$(COMPILE_TO_S) : $(libvpx_intermediates)/%.intermediate : $(libvpx_source_dir)/%.c 91 $(transform-generated-source) 92 93# Extract the offsets from the inline assembly. 94OFFSETS_GEN := $(addprefix $(libvpx_intermediates)/, $(libvpx_asm_offsets_files)) 95$(OFFSETS_GEN) : PRIVATE_OFFSET_PATTERN := '^[a-zA-Z0-9_]* EQU' 96$(OFFSETS_GEN) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir) 97$(OFFSETS_GEN) : PRIVATE_CUSTOM_TOOL = grep $(PRIVATE_OFFSET_PATTERN) $< | tr -d '$$\#' | perl $(PRIVATE_SOURCE_DIR)/build/make/ads2gas.pl > $@ 98$(OFFSETS_GEN) : %.asm : %.intermediate 99 $(transform-generated-source) 100 101LOCAL_GENERATED_SOURCES += $(OFFSETS_GEN) 102 103# This step is only required for ARM. MIPS uses intrinsics and x86 requires an 104# assembler to pre-process its assembly files. 105libvpx_asm_srcs := $(filter %.asm.s, $(libvpx_codec_srcs_unique)) 106 107# The ARM assembly sources must be converted from ADS to GAS compatible format. 108VPX_GEN := $(addprefix $(libvpx_intermediates)/, $(libvpx_asm_srcs)) 109$(VPX_GEN) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir) 110$(VPX_GEN) : PRIVATE_CUSTOM_TOOL = cat $< | perl $(PRIVATE_SOURCE_DIR)/build/make/ads2gas.pl > $@ 111$(VPX_GEN) : $(libvpx_intermediates)/%.s : $(libvpx_source_dir)/% 112 $(transform-generated-source) 113 114LOCAL_GENERATED_SOURCES += $(VPX_GEN) 115 116ifeq ($(libvpx_target),x86) 117libvpx_x86_asm_src_files := $(filter %.asm, $(libvpx_codec_srcs_unique)) 118libvpx_x86_yasm_dir := prebuilts/misc/$(HOST_OS)-$(HOST_PREBUILT_ARCH)/yasm 119 120X86_ASM_GEN := $(addprefix $(libvpx_intermediates)/, $(libvpx_x86_asm_src_files:%.asm=%.asm.o)) 121 122# Adding dependency on yasm generation 123$(X86_ASM_GEN) : $(libvpx_x86_yasm_dir)/yasm 124 125$(X86_ASM_GEN) : PRIVATE_YASM := $(libvpx_x86_yasm_dir)/yasm 126$(X86_ASM_GEN) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir) 127$(X86_ASM_GEN) : PRIVATE_CONFIG_DIR := $(libvpx_config_dir) 128$(X86_ASM_GEN) : PRIVATE_CUSTOM_TOOL = $(PRIVATE_YASM) -f elf32 -I $(PRIVATE_SOURCE_DIR) -I $(PRIVATE_CONFIG_DIR) -o $@ $< 129$(X86_ASM_GEN) : $(libvpx_intermediates)/%.o : $(libvpx_source_dir)/% 130 $(transform-generated-source) 131 132LOCAL_GENERATED_SOURCES += $(X86_ASM_GEN) 133 134libvpx_x86_yasm_dir := 135x86_asm_src_files := 136endif 137 138LOCAL_C_INCLUDES := \ 139 $(libvpx_source_dir) \ 140 $(libvpx_config_dir) \ 141 $(libvpx_intermediates)/vp8/common \ 142 $(libvpx_intermediates)/vp8/decoder \ 143 $(libvpx_intermediates)/vp8/encoder \ 144 $(libvpx_intermediates)/vpx_scale \ 145 146libvpx_target := 147libvpx_asm := 148libvpx_config_dir := 149libvpx_source_dir := 150libvpx_codec_srcs := 151libvpx_intermediates := 152libvpx_codec_srcs_unique := 153libvpx_codec_srcs_c := 154libvpx_codec_srcs_c_static := 155libvpx_asm_offsets_intermediates := 156libvpx_asm_offsets_files := 157libvpx_asm_srcs := 158 159include $(BUILD_STATIC_LIBRARY) 160