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
45
46# Static functions declared in headers. b/18632512
47LOCAL_CFLAGS += -Wno-unused-function
48
49# Clang complains about every partial initialized structure,
50# in vp[89]_[cd]x_iface.c
51LOCAL_CLANG_CFLAGS += -Wno-missing-field-initializers
52
53LOCAL_CFLAGS += -Werror
54LOCAL_MODULE := libvpx_internal
55
56LOCAL_MODULE_CLASS := STATIC_LIBRARIES
57libvpx_intermediates := $(call local-intermediates-dir)
58
59# Extract the C files from the list and add them to LOCAL_SRC_FILES.
60libvpx_codec_srcs_unique := $(sort $(libvpx_codec_srcs))
61libvpx_codec_srcs_c := $(filter %.c, $(libvpx_codec_srcs_unique))
62ifeq ($(libvpx_target),x86)
63x86_asm_src_files := $(filter %.asm, $(libvpx_codec_srcs_unique))
64X86_ASM_SRCS := $(addprefix $(LOCAL_PATH)/libvpx/, $(x86_asm_src_files))
65X86_ASM_OBJS := $(addprefix $(libvpx_intermediates)/, $(x86_asm_src_files:%.asm=%.asm.o))
66endif
67# vpx_config.c is an auto-generated file in $(config_dir)
68libvpx_codec_srcs_c_static := $(filter-out vpx_config.c, $(libvpx_codec_srcs_c))
69LOCAL_SRC_FILES += $(addprefix libvpx/, $(libvpx_codec_srcs_c_static))
70LOCAL_SRC_FILES += $(libvpx_target)/vpx_config.c
71
72# ARM and x86 use an 'offsets' file in the assembly. It is generated by
73# tricking the compiler and generating non-functional output which is then
74# processed with grep. For ARM, this must be additionally converted from
75# RVCT (ARM's in-house compiler) format to GNU Assembler Format for gcc.
76
77# Offset files are currently used in vpx_scale for NEON and some encoder
78# functions used in both ARM and x86. These files can not be compiled and need
79# to be named accordingly to avoid auto-build rules. The encoder files are not
80# used yet but are included in the comments for future reference.
81
82ifneq ($(libvpx_target),x86)
83libvpx_asm_offsets_intermediates := \
84    vp8/encoder/vp8_asm_enc_offsets.intermediate \
85    vpx_scale/vpx_scale_asm_offsets.intermediate \
86
87libvpx_asm_offsets_files := \
88    vp8/encoder/vp8_asm_enc_offsets.asm \
89    vpx_scale/vpx_scale_asm_offsets.asm \
90
91endif
92# Build the S files with inline assembly.
93COMPILE_TO_S := $(addprefix $(libvpx_intermediates)/, $(libvpx_asm_offsets_intermediates))
94$(COMPILE_TO_S) : PRIVATE_INTERMEDIATES := $(libvpx_intermediates)
95$(COMPILE_TO_S) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir)
96$(COMPILE_TO_S) : PRIVATE_CONFIG_DIR := $(libvpx_config_dir)
97$(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 $@ $<
98$(COMPILE_TO_S) : $(libvpx_intermediates)/%.intermediate : $(libvpx_source_dir)/%.c
99	$(transform-generated-source)
100
101# Extract the offsets from the inline assembly.
102OFFSETS_GEN := $(addprefix $(libvpx_intermediates)/, $(libvpx_asm_offsets_files))
103$(OFFSETS_GEN) : PRIVATE_OFFSET_PATTERN := '^[a-zA-Z0-9_]* EQU'
104$(OFFSETS_GEN) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir)
105$(OFFSETS_GEN) : PRIVATE_CUSTOM_TOOL = grep $(PRIVATE_OFFSET_PATTERN) $< | tr -d '$$\#' | perl $(PRIVATE_SOURCE_DIR)/build/make/ads2gas.pl > $@
106$(OFFSETS_GEN) : %.asm : %.intermediate
107	$(transform-generated-source)
108
109LOCAL_GENERATED_SOURCES += $(OFFSETS_GEN)
110
111# This step is only required for ARM. MIPS uses intrinsics and x86 requires an
112# assembler to pre-process its assembly files.
113libvpx_asm_srcs := $(filter %.asm.s, $(libvpx_codec_srcs_unique))
114
115# The ARM assembly sources must be converted from ADS to GAS compatible format.
116VPX_GEN := $(addprefix $(libvpx_intermediates)/, $(libvpx_asm_srcs))
117$(VPX_GEN) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir)
118$(VPX_GEN) : PRIVATE_CUSTOM_TOOL = cat $< | perl $(PRIVATE_SOURCE_DIR)/build/make/ads2gas.pl > $@
119$(VPX_GEN) : $(libvpx_intermediates)/%.s : $(libvpx_source_dir)/%
120	$(transform-generated-source)
121
122LOCAL_GENERATED_SOURCES += $(VPX_GEN)
123
124ifeq ($(libvpx_target),x86)
125libvpx_x86_asm_src_files := $(filter %.asm, $(libvpx_codec_srcs_unique))
126libvpx_x86_yasm_dir := prebuilts/misc/$(HOST_OS)-$(HOST_PREBUILT_ARCH)/yasm
127
128X86_ASM_GEN := $(addprefix $(libvpx_intermediates)/, $(libvpx_x86_asm_src_files:%.asm=%.asm.o))
129
130# Adding dependency on yasm generation
131$(X86_ASM_GEN) : $(libvpx_x86_yasm_dir)/yasm
132
133$(X86_ASM_GEN) : PRIVATE_YASM := $(libvpx_x86_yasm_dir)/yasm
134$(X86_ASM_GEN) : PRIVATE_SOURCE_DIR := $(libvpx_source_dir)
135$(X86_ASM_GEN) : PRIVATE_CONFIG_DIR := $(libvpx_config_dir)
136$(X86_ASM_GEN) : PRIVATE_CUSTOM_TOOL = $(PRIVATE_YASM) -f elf32 -I $(PRIVATE_SOURCE_DIR) -I $(PRIVATE_CONFIG_DIR) -o $@ $<
137$(X86_ASM_GEN) : $(libvpx_intermediates)/%.o : $(libvpx_source_dir)/%
138	$(transform-generated-source)
139
140LOCAL_GENERATED_SOURCES += $(X86_ASM_GEN)
141
142libvpx_x86_yasm_dir :=
143x86_asm_src_files :=
144endif
145
146LOCAL_C_INCLUDES := \
147    $(libvpx_source_dir) \
148    $(libvpx_config_dir) \
149    $(libvpx_intermediates)/vp8/common \
150    $(libvpx_intermediates)/vp8/decoder \
151    $(libvpx_intermediates)/vp8/encoder \
152    $(libvpx_intermediates)/vpx_scale \
153
154libvpx_target :=
155libvpx_asm :=
156libvpx_config_dir :=
157libvpx_source_dir :=
158libvpx_codec_srcs :=
159libvpx_intermediates :=
160libvpx_codec_srcs_unique :=
161libvpx_codec_srcs_c :=
162libvpx_codec_srcs_c_static :=
163libvpx_asm_offsets_intermediates :=
164libvpx_asm_offsets_files :=
165libvpx_asm_srcs :=
166
167include $(BUILD_STATIC_LIBRARY)
168