Home | History | Annotate | Download | only in libvpx_internal
      1 LOCAL_PATH := $(call my-dir)
      2 include $(CLEAR_VARS)
      3 
      4 ifeq ($(ARCH_ARM_HAVE_NEON),true)
      5   libvpx_target := armv7a-neon
      6   libvpx_asm := .asm.s
      7 else ifeq ($(ARCH_ARM_HAVE_ARMV7A),true)
      8   libvpx_target := armv7a
      9   libvpx_asm := .asm.s
     10 endif
     11 
     12 ifeq ($(TARGET_ARCH),x86)
     13   libvpx_target := x86
     14   libvpx_asm := .asm
     15 endif
     16 
     17 ifeq ($(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
     31 endif #mips
     32 
     33 # Un-optimized targets
     34 libvpx_target ?= generic
     35 libvpx_asm ?= .asm
     36 
     37 libvpx_config_dir := $(LOCAL_PATH)/$(libvpx_target)
     38 libvpx_source_dir := $(LOCAL_PATH)/libvpx
     39 
     40 libvpx_codec_srcs := $(shell cat $(libvpx_config_dir)/libvpx_srcs.txt)
     41 
     42 LOCAL_SHARED_LIBRARIES += liblog
     43 LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
     44 LOCAL_CFLAGS := -DHAVE_CONFIG_H=vpx_config.h
     45 LOCAL_CFLAGS += -Werror
     46 LOCAL_MODULE := libvpx_internal
     47 
     48 LOCAL_MODULE_CLASS := STATIC_LIBRARIES
     49 libvpx_intermediates := $(call local-intermediates-dir)
     50 
     51 # Extract the C files from the list and add them to LOCAL_SRC_FILES.
     52 libvpx_codec_srcs_unique := $(sort $(libvpx_codec_srcs))
     53 libvpx_codec_srcs_c := $(filter %.c, $(libvpx_codec_srcs_unique))
     54 ifeq ($(libvpx_target),x86)
     55 x86_asm_src_files := $(filter %.asm, $(libvpx_codec_srcs_unique))
     56 X86_ASM_SRCS := $(addprefix $(LOCAL_PATH)/libvpx/, $(x86_asm_src_files))
     57 X86_ASM_OBJS := $(addprefix $(libvpx_intermediates)/, $(x86_asm_src_files:%.asm=%.asm.o))
     58 endif
     59 # vpx_config.c is an auto-generated file in $(config_dir)
     60 libvpx_codec_srcs_c_static := $(filter-out vpx_config.c, $(libvpx_codec_srcs_c))
     61 LOCAL_SRC_FILES += $(addprefix libvpx/, $(libvpx_codec_srcs_c_static))
     62 LOCAL_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 
     74 ifneq ($(libvpx_target),x86)
     75 libvpx_asm_offsets_intermediates := \
     76     vp8/encoder/vp8_asm_enc_offsets.intermediate \
     77     vpx_scale/vpx_scale_asm_offsets.intermediate \
     78 
     79 libvpx_asm_offsets_files := \
     80     vp8/encoder/vp8_asm_enc_offsets.asm \
     81     vpx_scale/vpx_scale_asm_offsets.asm \
     82 
     83 endif
     84 # Build the S files with inline assembly.
     85 COMPILE_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.
     94 OFFSETS_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 
    101 LOCAL_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.
    105 libvpx_asm_srcs := $(filter %.asm.s, $(libvpx_codec_srcs_unique))
    106 
    107 # The ARM assembly sources must be converted from ADS to GAS compatible format.
    108 VPX_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 
    114 LOCAL_GENERATED_SOURCES += $(VPX_GEN)
    115 
    116 ifeq ($(libvpx_target),x86)
    117 libvpx_x86_asm_src_files := $(filter %.asm, $(libvpx_codec_srcs_unique))
    118 libvpx_x86_yasm_dir := prebuilts/misc/$(HOST_OS)-$(HOST_PREBUILT_ARCH)/yasm
    119 
    120 X86_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 
    132 LOCAL_GENERATED_SOURCES += $(X86_ASM_GEN)
    133 
    134 libvpx_x86_yasm_dir :=
    135 x86_asm_src_files :=
    136 endif
    137 
    138 LOCAL_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 
    146 libvpx_target :=
    147 libvpx_asm :=
    148 libvpx_config_dir :=
    149 libvpx_source_dir :=
    150 libvpx_codec_srcs :=
    151 libvpx_intermediates :=
    152 libvpx_codec_srcs_unique :=
    153 libvpx_codec_srcs_c :=
    154 libvpx_codec_srcs_c_static :=
    155 libvpx_asm_offsets_intermediates :=
    156 libvpx_asm_offsets_files :=
    157 libvpx_asm_srcs :=
    158 
    159 include $(BUILD_STATIC_LIBRARY)
    160