libvpx.mk revision ca15b5fc158a9df465aaf1acfe38d8cb5042c81b
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/common/asm_com_offsets.intermediate \
64    vp8/decoder/asm_dec_offsets.intermediate \
65    vp8/encoder/asm_enc_offsets.intermediate \
66
67libvpx_asm_offsets_files := \
68    vp8/common/asm_com_offsets.asm \
69    vp8/decoder/asm_dec_offsets.asm \
70    vp8/encoder/asm_enc_offsets.asm \
71
72# Build the S files with inline assembly.
73COMPILE_TO_S := $(addprefix $(libvpx_intermediates)/, $(libvpx_asm_offsets_intermediates))
74$(COMPILE_TO_S) : PRIVATE_INTERMEDIATES := $(libvpx_intermediates)
75$(COMPILE_TO_S) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir)
76$(COMPILE_TO_S) : PRIVATE_CONFIG_DIR := $(libvpx_config_dir)
77$(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 $@ $<
78$(COMPILE_TO_S) : $(libvpx_intermediates)/%.intermediate : $(libvpx_source_dir)/%.c
79	$(transform-generated-source)
80
81# Extract the offsets from the inline assembly.
82OFFSETS_GEN := $(addprefix $(libvpx_intermediates)/, $(libvpx_asm_offsets_files))
83$(OFFSETS_GEN) : PRIVATE_OFFSET_PATTERN := '^[a-zA-Z0-9_]* EQU'
84$(OFFSETS_GEN) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir)
85$(OFFSETS_GEN) : PRIVATE_CUSTOM_TOOL = grep $(PRIVATE_OFFSET_PATTERN) $< | tr -d '$$\#' | perl $(PRIVATE_SOURCE_DIR)/build/make/ads2gas.pl > $@
86$(OFFSETS_GEN) : %.asm : %.intermediate
87	$(transform-generated-source)
88
89LOCAL_GENERATED_SOURCES += $(OFFSETS_GEN)
90
91# This step is only required for ARM. MIPS uses intrinsics and x86 requires an
92# assembler to pre-process its assembly files.
93libvpx_asm_srcs := $(filter %.asm.s, $(libvpx_codec_srcs_unique))
94
95# The ARM assembly sources must be converted from ADS to GAS compatible format.
96VPX_GEN := $(addprefix $(libvpx_intermediates)/, $(libvpx_asm_srcs))
97$(VPX_GEN) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir)
98$(VPX_GEN) : PRIVATE_CUSTOM_TOOL = cat $< | perl $(PRIVATE_SOURCE_DIR)/build/make/ads2gas.pl > $@
99$(VPX_GEN) : $(libvpx_intermediates)/%.s : $(libvpx_source_dir)/%
100	$(transform-generated-source)
101
102LOCAL_GENERATED_SOURCES += $(VPX_GEN)
103
104LOCAL_C_INCLUDES := \
105    $(libvpx_source_dir) \
106    $(libvpx_config_dir) \
107    $(libvpx_intermediates)/vp8/common \
108    $(libvpx_intermediates)/vp8/decoder \
109    $(libvpx_intermediates)/vp8/encoder \
110
111libvpx_target :=
112libvpx_asm :=
113libvpx_config_dir :=
114libvpx_source_dir :=
115libvpx_codec_srcs :=
116libvpx_intermediates :=
117libvpx_codec_srcs_unique :=
118libvpx_codec_srcs_c :=
119libvpx_codec_srcs_c_static :=
120libvpx_asm_offsets_intermediates :=
121libvpx_asm_offsets_files :=
122libvpx_asm_srcs :=
123
124include $(BUILD_STATIC_LIBRARY)
125