libvpx.mk revision 91037db265ecdd914a26e056cf69207b4f50924e
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),mips) 13 ifneq ($(ARCH_HAS_BIGENDIAN),true) 14 ifeq ($(ARCH_MIPS_DSP_REV),2) 15 libvpx_target := mips-dspr2 16 LOCAL_CFLAGS += -DMIPS_DSP_REV=$(ARCH_MIPS_DSP_REV) 17 else 18 libvpx_target := mips 19 ifeq ($(ARCH_MIPS_DSP_REV),1) 20 LOCAL_CFLAGS += -DMIPS_DSP_REV=$(ARCH_MIPS_DSP_REV) 21 else 22 LOCAL_CFLAGS += -DMIPS_DSP_REV=0 23 endif #mips_dsp_rev1 24 endif #mips_dsp_rev2 25 endif #bigendian 26endif #mips 27 28# Un-optimized targets 29libvpx_target ?= generic 30libvpx_asm ?= .asm 31 32libvpx_config_dir := $(LOCAL_PATH)/$(libvpx_target) 33libvpx_source_dir := $(LOCAL_PATH)/libvpx 34 35libvpx_codec_srcs := $(shell cat $(libvpx_config_dir)/libvpx_srcs.txt) 36 37LOCAL_CFLAGS := -DHAVE_CONFIG_H=vpx_config.h 38 39LOCAL_MODULE := libvpx 40 41LOCAL_MODULE_CLASS := STATIC_LIBRARIES 42libvpx_intermediates := $(call local-intermediates-dir) 43 44# Extract the C files from the list and add them to LOCAL_SRC_FILES. 45libvpx_codec_srcs_unique := $(sort $(libvpx_codec_srcs)) 46libvpx_codec_srcs_c := $(filter %.c, $(libvpx_codec_srcs_unique)) 47# vpx_config.c is an auto-generated file in $(config_dir) 48libvpx_codec_srcs_c_static := $(filter-out vpx_config.c, $(libvpx_codec_srcs_c)) 49LOCAL_SRC_FILES += $(addprefix libvpx/, $(libvpx_codec_srcs_c_static)) 50LOCAL_SRC_FILES += $(libvpx_target)/vpx_config.c 51 52# ARM and x86 use an 'offsets' file in the assembly. It is generated by 53# tricking the compiler and generating non-functional output which is then 54# processed with grep. For ARM, this must be additionally converted from 55# RVCT (ARM's in-house compiler) format to GNU Assembler Format for gcc. 56 57# Offset files are currently used in vpx_scale for NEON and some encoder 58# functions used in both ARM and x86. These files can not be compiled and need 59# to be named accordingly to avoid auto-build rules. The encoder files are not 60# used yet but are included in the comments for future reference. 61 62libvpx_asm_offsets_intermediates := \ 63 vp8/encoder/vp8_asm_enc_offsets.intermediate \ 64 vpx_scale/vpx_scale_asm_offsets.intermediate \ 65 66libvpx_asm_offsets_files := \ 67 vp8/encoder/vp8_asm_enc_offsets.asm \ 68 vpx_scale/vpx_scale_asm_offsets.asm \ 69 70# Build the S files with inline assembly. 71COMPILE_TO_S := $(addprefix $(libvpx_intermediates)/, $(libvpx_asm_offsets_intermediates)) 72$(COMPILE_TO_S) : PRIVATE_INTERMEDIATES := $(libvpx_intermediates) 73$(COMPILE_TO_S) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir) 74$(COMPILE_TO_S) : PRIVATE_CONFIG_DIR := $(libvpx_config_dir) 75$(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 $@ $< 76$(COMPILE_TO_S) : $(libvpx_intermediates)/%.intermediate : $(libvpx_source_dir)/%.c 77 $(transform-generated-source) 78 79# Extract the offsets from the inline assembly. 80OFFSETS_GEN := $(addprefix $(libvpx_intermediates)/, $(libvpx_asm_offsets_files)) 81$(OFFSETS_GEN) : PRIVATE_OFFSET_PATTERN := '^[a-zA-Z0-9_]* EQU' 82$(OFFSETS_GEN) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir) 83$(OFFSETS_GEN) : PRIVATE_CUSTOM_TOOL = grep $(PRIVATE_OFFSET_PATTERN) $< | tr -d '$$\#' | perl $(PRIVATE_SOURCE_DIR)/build/make/ads2gas.pl > $@ 84$(OFFSETS_GEN) : %.asm : %.intermediate 85 $(transform-generated-source) 86 87LOCAL_GENERATED_SOURCES += $(OFFSETS_GEN) 88 89# This step is only required for ARM. MIPS uses intrinsics and x86 requires an 90# assembler to pre-process its assembly files. 91libvpx_asm_srcs := $(filter %.asm.s, $(libvpx_codec_srcs_unique)) 92 93# The ARM assembly sources must be converted from ADS to GAS compatible format. 94VPX_GEN := $(addprefix $(libvpx_intermediates)/, $(libvpx_asm_srcs)) 95$(VPX_GEN) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir) 96$(VPX_GEN) : PRIVATE_CUSTOM_TOOL = cat $< | perl $(PRIVATE_SOURCE_DIR)/build/make/ads2gas.pl > $@ 97$(VPX_GEN) : $(libvpx_intermediates)/%.s : $(libvpx_source_dir)/% 98 $(transform-generated-source) 99 100LOCAL_GENERATED_SOURCES += $(VPX_GEN) 101 102LOCAL_C_INCLUDES := \ 103 $(libvpx_source_dir) \ 104 $(libvpx_config_dir) \ 105 $(libvpx_intermediates)/vp8/common \ 106 $(libvpx_intermediates)/vp8/decoder \ 107 $(libvpx_intermediates)/vp8/encoder \ 108 $(libvpx_intermediates)/vpx_scale \ 109 110libvpx_target := 111libvpx_asm := 112libvpx_config_dir := 113libvpx_source_dir := 114libvpx_codec_srcs := 115libvpx_intermediates := 116libvpx_codec_srcs_unique := 117libvpx_codec_srcs_c := 118libvpx_codec_srcs_c_static := 119libvpx_asm_offsets_intermediates := 120libvpx_asm_offsets_files := 121libvpx_asm_srcs := 122 123include $(BUILD_STATIC_LIBRARY) 124