2012-01-06 20:50:05 +01:00
|
|
|
##
|
|
|
|
## Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
|
|
|
##
|
|
|
|
## Use of this source code is governed by a BSD-style license
|
|
|
|
## that can be found in the LICENSE file in the root of the source
|
|
|
|
## tree. An additional intellectual property rights grant can be found
|
|
|
|
## in the file PATENTS. All contributing project authors may
|
|
|
|
## be found in the AUTHORS file in the root of the source tree.
|
|
|
|
##
|
|
|
|
|
|
|
|
#
|
|
|
|
# This file is to be used for compiling libvpx for Android using the NDK.
|
|
|
|
# In an Android project place a libvpx checkout in the jni directory.
|
|
|
|
# Run the configure script from the jni directory. Base libvpx
|
|
|
|
# encoder/decoder configuration will look similar to:
|
|
|
|
# ./libvpx/configure --target=armv7-android-gcc --disable-examples \
|
|
|
|
# --sdk-path=/opt/android-ndk-r6b/
|
|
|
|
#
|
|
|
|
# When targeting Android, realtime-only is enabled by default. This can
|
|
|
|
# be overridden by adding the command line flag:
|
|
|
|
# --disable-realtime-only
|
|
|
|
#
|
|
|
|
# This will create .mk files that contain variables that contain the
|
|
|
|
# source files to compile.
|
|
|
|
#
|
|
|
|
# Place an Android.mk file in the jni directory that references the
|
|
|
|
# Android.mk file in the libvpx directory:
|
|
|
|
# LOCAL_PATH := $(call my-dir)
|
|
|
|
# include $(CLEAR_VARS)
|
2012-12-19 01:30:47 +01:00
|
|
|
# include jni/libvpx/build/make/Android.mk
|
2012-01-06 20:50:05 +01:00
|
|
|
#
|
2012-04-12 11:50:19 +02:00
|
|
|
# By default libvpx will detect at runtime the existance of NEON extension.
|
|
|
|
# For this we import the 'cpufeatures' module from the NDK sources.
|
|
|
|
# libvpx can also be configured without this runtime detection method.
|
|
|
|
# Configuring with --disable-runtime-cpu-detect will assume presence of NEON.
|
2014-05-14 20:33:47 +02:00
|
|
|
# Configuring with --disable-runtime-cpu-detect --disable-neon \
|
|
|
|
# --disable-neon-asm
|
|
|
|
# will remove any NEON dependency.
|
2012-04-12 11:50:19 +02:00
|
|
|
|
2012-01-06 20:50:05 +01:00
|
|
|
#
|
|
|
|
# Running ndk-build will build libvpx and include it in your project.
|
|
|
|
#
|
|
|
|
|
2016-09-08 00:18:40 +02:00
|
|
|
# Alternatively, building the examples and unit tests can be accomplished in the
|
|
|
|
# following way:
|
|
|
|
#
|
|
|
|
# Create a standalone toolchain from the NDK:
|
|
|
|
# https://developer.android.com/ndk/guides/standalone_toolchain.html
|
|
|
|
#
|
|
|
|
# For example - to test on arm64 devices with clang:
|
|
|
|
# $NDK/build/tools/make_standalone_toolchain.py \
|
|
|
|
# --arch arm64 --install-dir=/tmp/my-android-toolchain
|
|
|
|
# export PATH=/tmp/my-android-toolchain/bin:$PATH
|
|
|
|
# CROSS=aarch64-linux-android- CC=clang CXX=clang++ /path/to/libvpx/configure \
|
|
|
|
# --target=arm64-android-gcc
|
|
|
|
#
|
|
|
|
# Push the resulting binaries to a device and run them:
|
|
|
|
# adb push test_libvpx /data/tmp/test_libvpx
|
|
|
|
# adb shell /data/tmp/test_libvpx --gtest_filter=\*Sixtap\*
|
|
|
|
#
|
|
|
|
# Make sure to push the test data as well and set LIBVPX_TEST_DATA
|
|
|
|
|
2013-04-17 19:52:50 +02:00
|
|
|
CONFIG_DIR := $(LOCAL_PATH)/
|
2012-01-06 20:50:05 +01:00
|
|
|
LIBVPX_PATH := $(LOCAL_PATH)/libvpx
|
|
|
|
ASM_CNV_PATH_LOCAL := $(TARGET_ARCH_ABI)/ads2gas
|
|
|
|
ASM_CNV_PATH := $(LOCAL_PATH)/$(ASM_CNV_PATH_LOCAL)
|
2016-11-24 01:46:50 +01:00
|
|
|
ifneq ($(V),1)
|
|
|
|
qexec := @
|
|
|
|
endif
|
2012-01-06 20:50:05 +01:00
|
|
|
|
2014-05-02 16:18:00 +02:00
|
|
|
# Use the makefiles generated by upstream configure to determine which files to
|
|
|
|
# build. Also set any architecture-specific flags.
|
2012-01-06 20:50:05 +01:00
|
|
|
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
2013-04-17 19:52:50 +02:00
|
|
|
include $(CONFIG_DIR)libs-armv7-android-gcc.mk
|
2014-05-02 16:18:00 +02:00
|
|
|
LOCAL_ARM_MODE := arm
|
2014-05-07 20:01:31 +02:00
|
|
|
else ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
|
2016-11-01 02:35:23 +01:00
|
|
|
include $(CONFIG_DIR)libs-arm64-android-gcc.mk
|
2014-05-07 20:01:31 +02:00
|
|
|
LOCAL_ARM_MODE := arm
|
2014-05-02 16:18:00 +02:00
|
|
|
else ifeq ($(TARGET_ARCH_ABI),x86)
|
|
|
|
include $(CONFIG_DIR)libs-x86-android-gcc.mk
|
2015-07-24 23:24:20 +02:00
|
|
|
else ifeq ($(TARGET_ARCH_ABI),x86_64)
|
|
|
|
include $(CONFIG_DIR)libs-x86_64-android-gcc.mk
|
2014-05-02 16:18:00 +02:00
|
|
|
else ifeq ($(TARGET_ARCH_ABI),mips)
|
|
|
|
include $(CONFIG_DIR)libs-mips-android-gcc.mk
|
|
|
|
else
|
|
|
|
$(error Not a supported TARGET_ARCH_ABI: $(TARGET_ARCH_ABI))
|
2012-01-06 20:50:05 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Rule that is normally in Makefile created by libvpx
|
|
|
|
# configure. Used to filter out source files based on configuration.
|
|
|
|
enabled=$(filter-out $($(1)-no),$($(1)-yes))
|
|
|
|
|
|
|
|
# Override the relative path that is defined by the libvpx
|
|
|
|
# configure process
|
|
|
|
SRC_PATH_BARE := $(LIBVPX_PATH)
|
|
|
|
|
|
|
|
# Include the list of files to be built
|
|
|
|
include $(LIBVPX_PATH)/libs.mk
|
|
|
|
|
2014-05-02 16:18:00 +02:00
|
|
|
# Optimise the code. May want to revisit this setting in the future.
|
2012-01-06 20:50:05 +01:00
|
|
|
LOCAL_CFLAGS := -O3
|
|
|
|
|
2014-05-02 16:18:00 +02:00
|
|
|
# For x86, include the source code in the search path so it will find files
|
|
|
|
# like x86inc.asm and x86_abi_support.asm
|
|
|
|
LOCAL_ASMFLAGS := -I$(LIBVPX_PATH)
|
|
|
|
|
2016-11-01 00:18:51 +01:00
|
|
|
.PRECIOUS: %.asm.S
|
|
|
|
$(ASM_CNV_PATH)/libvpx/%.asm.S: $(LIBVPX_PATH)/%.asm
|
2016-11-24 01:46:50 +01:00
|
|
|
$(qexec)mkdir -p $(dir $@)
|
|
|
|
$(qexec)$(CONFIG_DIR)$(ASM_CONVERSION) <$< > $@
|
2012-01-06 20:50:05 +01:00
|
|
|
|
2013-04-17 19:52:50 +02:00
|
|
|
# For building *_rtcd.h, which have rules in libs.mk
|
2012-02-16 00:23:04 +01:00
|
|
|
TGT_ISA:=$(word 1, $(subst -, ,$(TOOLCHAIN)))
|
|
|
|
target := libs
|
2012-01-06 20:50:05 +01:00
|
|
|
|
|
|
|
LOCAL_SRC_FILES += vpx_config.c
|
|
|
|
|
|
|
|
# Remove duplicate entries
|
|
|
|
CODEC_SRCS_UNIQUE = $(sort $(CODEC_SRCS))
|
|
|
|
|
|
|
|
# Pull out C files. vpx_config.c is in the immediate directory and
|
|
|
|
# so it does not need libvpx/ prefixed like the rest of the source files.
|
2014-01-10 21:16:59 +01:00
|
|
|
# The neon files with intrinsics need to have .neon appended so the proper
|
|
|
|
# flags are applied.
|
2012-01-06 20:50:05 +01:00
|
|
|
CODEC_SRCS_C = $(filter %.c, $(CODEC_SRCS_UNIQUE))
|
2014-01-10 21:16:59 +01:00
|
|
|
LOCAL_NEON_SRCS_C = $(filter %_neon.c, $(CODEC_SRCS_C))
|
|
|
|
LOCAL_CODEC_SRCS_C = $(filter-out vpx_config.c %_neon.c, $(CODEC_SRCS_C))
|
2012-01-06 20:50:05 +01:00
|
|
|
|
|
|
|
LOCAL_SRC_FILES += $(foreach file, $(LOCAL_CODEC_SRCS_C), libvpx/$(file))
|
2014-05-07 20:01:31 +02:00
|
|
|
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
|
|
|
LOCAL_SRC_FILES += $(foreach file, $(LOCAL_NEON_SRCS_C), libvpx/$(file).neon)
|
|
|
|
else # If there are neon sources then we are building for arm64 and do not need to specify .neon
|
|
|
|
LOCAL_SRC_FILES += $(foreach file, $(LOCAL_NEON_SRCS_C), libvpx/$(file))
|
|
|
|
endif
|
2012-01-06 20:50:05 +01:00
|
|
|
|
|
|
|
# Pull out assembly files, splitting NEON from the rest. This is
|
|
|
|
# done to specify that the NEON assembly files use NEON assembler flags.
|
2016-11-01 00:18:51 +01:00
|
|
|
# x86 assembly matches %.asm, arm matches %.asm.S
|
2014-05-02 16:18:00 +02:00
|
|
|
|
|
|
|
# x86:
|
|
|
|
|
|
|
|
CODEC_SRCS_ASM_X86 = $(filter %.asm, $(CODEC_SRCS_UNIQUE))
|
|
|
|
LOCAL_SRC_FILES += $(foreach file, $(CODEC_SRCS_ASM_X86), libvpx/$(file))
|
|
|
|
|
|
|
|
# arm:
|
2016-11-01 00:18:51 +01:00
|
|
|
CODEC_SRCS_ASM_ARM_ALL = $(filter %.asm.S, $(CODEC_SRCS_UNIQUE))
|
2014-05-02 16:18:00 +02:00
|
|
|
CODEC_SRCS_ASM_ARM = $(foreach v, \
|
|
|
|
$(CODEC_SRCS_ASM_ARM_ALL), \
|
|
|
|
$(if $(findstring neon,$(v)),,$(v)))
|
2016-11-01 00:18:51 +01:00
|
|
|
CODEC_SRCS_ASM_ADS2GAS = $(patsubst %.S, \
|
|
|
|
$(ASM_CNV_PATH_LOCAL)/libvpx/%.S, \
|
2014-05-02 16:18:00 +02:00
|
|
|
$(CODEC_SRCS_ASM_ARM))
|
2012-01-06 20:50:05 +01:00
|
|
|
LOCAL_SRC_FILES += $(CODEC_SRCS_ASM_ADS2GAS)
|
|
|
|
|
|
|
|
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
2016-11-24 01:49:19 +01:00
|
|
|
ASM_INCLUDES := vpx_dsp/arm/idct_neon.asm.S
|
2012-01-06 20:50:05 +01:00
|
|
|
CODEC_SRCS_ASM_NEON = $(foreach v, \
|
2014-05-02 16:18:00 +02:00
|
|
|
$(CODEC_SRCS_ASM_ARM_ALL),\
|
2012-01-06 20:50:05 +01:00
|
|
|
$(if $(findstring neon,$(v)),$(v),))
|
2016-11-24 01:49:19 +01:00
|
|
|
CODEC_SRCS_ASM_NEON := $(filter-out $(addprefix %, $(ASM_INCLUDES)), \
|
|
|
|
$(CODEC_SRCS_ASM_NEON))
|
2016-11-01 00:18:51 +01:00
|
|
|
CODEC_SRCS_ASM_NEON_ADS2GAS = $(patsubst %.S, \
|
|
|
|
$(ASM_CNV_PATH_LOCAL)/libvpx/%.S, \
|
2012-01-06 20:50:05 +01:00
|
|
|
$(CODEC_SRCS_ASM_NEON))
|
2016-11-01 00:18:51 +01:00
|
|
|
LOCAL_SRC_FILES += $(patsubst %.S, \
|
|
|
|
%.S.neon, \
|
2012-01-06 20:50:05 +01:00
|
|
|
$(CODEC_SRCS_ASM_NEON_ADS2GAS))
|
2016-11-24 01:49:19 +01:00
|
|
|
|
|
|
|
NEON_ASM_TARGETS = $(patsubst %.S, \
|
|
|
|
$(ASM_CNV_PATH)/libvpx/%.S, \
|
|
|
|
$(CODEC_SRCS_ASM_NEON))
|
|
|
|
# add a dependency to the full path to the ads2gas output to ensure the
|
|
|
|
# includes are converted first.
|
|
|
|
ifneq ($(strip $(NEON_ASM_TARGETS)),)
|
|
|
|
$(NEON_ASM_TARGETS): $(addprefix $(ASM_CNV_PATH)/libvpx/, $(ASM_INCLUDES))
|
|
|
|
endif
|
2012-01-06 20:50:05 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
LOCAL_CFLAGS += \
|
|
|
|
-DHAVE_CONFIG_H=vpx_config.h \
|
|
|
|
-I$(LIBVPX_PATH) \
|
2016-11-01 02:34:16 +01:00
|
|
|
-I$(ASM_CNV_PATH) \
|
|
|
|
-I$(ASM_CNV_PATH)/libvpx
|
2012-01-06 20:50:05 +01:00
|
|
|
|
|
|
|
LOCAL_MODULE := libvpx
|
|
|
|
|
2012-04-12 11:50:19 +02:00
|
|
|
ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes)
|
|
|
|
LOCAL_STATIC_LIBRARIES := cpufeatures
|
|
|
|
endif
|
2012-01-06 20:50:05 +01:00
|
|
|
|
2013-04-17 19:52:50 +02:00
|
|
|
# Add a dependency to force generation of the RTCD files.
|
2015-06-10 04:27:20 +02:00
|
|
|
define rtcd_dep_template
|
2015-07-30 01:07:05 +02:00
|
|
|
rtcd_dep_template_SRCS := $(addprefix $(LOCAL_PATH)/, $(LOCAL_SRC_FILES))
|
|
|
|
rtcd_dep_template_SRCS := $$(rtcd_dep_template_SRCS:.neon=)
|
2013-04-17 19:52:50 +02:00
|
|
|
ifeq ($(CONFIG_VP8), yes)
|
2015-07-30 01:07:05 +02:00
|
|
|
$$(rtcd_dep_template_SRCS): vp8_rtcd.h
|
2013-04-17 19:52:50 +02:00
|
|
|
endif
|
|
|
|
ifeq ($(CONFIG_VP9), yes)
|
2015-07-30 01:07:05 +02:00
|
|
|
$$(rtcd_dep_template_SRCS): vp9_rtcd.h
|
2013-04-17 19:52:50 +02:00
|
|
|
endif
|
2015-07-30 01:07:05 +02:00
|
|
|
$$(rtcd_dep_template_SRCS): vpx_scale_rtcd.h
|
|
|
|
$$(rtcd_dep_template_SRCS): vpx_dsp_rtcd.h
|
2012-04-11 14:20:13 +02:00
|
|
|
|
2016-11-01 02:34:16 +01:00
|
|
|
rtcd_dep_template_CONFIG_ASM_ABIS := x86 x86_64 armeabi-v7a
|
2016-11-25 02:51:10 +01:00
|
|
|
ifneq ($$(findstring $(TARGET_ARCH_ABI),$$(rtcd_dep_template_CONFIG_ASM_ABIS)),)
|
2015-07-30 01:07:05 +02:00
|
|
|
$$(rtcd_dep_template_SRCS): vpx_config.asm
|
2014-05-02 16:18:00 +02:00
|
|
|
endif
|
2015-06-10 04:27:20 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
$(eval $(call rtcd_dep_template))
|
2014-05-02 16:18:00 +02:00
|
|
|
|
2012-01-06 20:50:05 +01:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
@echo "Clean: ads2gas files [$(TARGET_ARCH_ABI)]"
|
2016-11-24 01:46:50 +01:00
|
|
|
$(qexec)$(RM) $(CODEC_SRCS_ASM_ADS2GAS) $(CODEC_SRCS_ASM_NEON_ADS2GAS)
|
|
|
|
$(qexec)$(RM) -r $(ASM_CNV_PATH)
|
|
|
|
$(qexec)$(RM) $(CLEAN-OBJS)
|
2012-01-06 20:50:05 +01:00
|
|
|
|
2015-04-09 06:03:36 +02:00
|
|
|
ifeq ($(ENABLE_SHARED),1)
|
2016-11-19 03:53:22 +01:00
|
|
|
LOCAL_CFLAGS += -fPIC
|
2015-04-09 06:03:36 +02:00
|
|
|
include $(BUILD_SHARED_LIBRARY)
|
|
|
|
else
|
|
|
|
include $(BUILD_STATIC_LIBRARY)
|
|
|
|
endif
|
2012-01-06 20:50:05 +01:00
|
|
|
|
2012-04-12 11:50:19 +02:00
|
|
|
ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes)
|
2016-11-14 22:21:27 +01:00
|
|
|
$(call import-module,android/cpufeatures)
|
2012-04-12 11:50:19 +02:00
|
|
|
endif
|