2 ## Copyright (c) 2012 The WebM project authors. All Rights Reserved.
4 ## Use of this source code is governed by a BSD-style license
5 ## that can be found in the LICENSE file in the root of the source
6 ## tree. An additional intellectual property rights grant can be found
7 ## in the file PATENTS. All contributing project authors may
8 ## be found in the AUTHORS file in the root of the source tree.
12 # This file is to be used for compiling libvpx for Android using the NDK.
13 # In an Android project place a libvpx checkout in the jni directory.
14 # Run the configure script from the jni directory. Base libvpx
15 # encoder/decoder configuration will look similar to:
16 # ./libvpx/configure --target=armv7-android-gcc --disable-examples \
17 # --sdk-path=/opt/android-ndk-r6b/
19 # When targeting Android, realtime-only is enabled by default. This can
20 # be overridden by adding the command line flag:
21 # --disable-realtime-only
23 # This will create .mk files that contain variables that contain the
24 # source files to compile.
26 # Place an Android.mk file in the jni directory that references the
27 # Android.mk file in the libvpx directory:
28 # LOCAL_PATH := $(call my-dir)
29 # include $(CLEAR_VARS)
30 # include jni/libvpx/build/make/Android.mk
32 # There are currently two TARGET_ARCH_ABI targets for ARM.
33 # armeabi and armeabi-v7a. armeabi-v7a is selected by creating an
34 # Application.mk in the jni directory that contains:
35 # APP_ABI := armeabi-v7a
37 # By default libvpx will detect at runtime the existance of NEON extension.
38 # For this we import the 'cpufeatures' module from the NDK sources.
39 # libvpx can also be configured without this runtime detection method.
40 # Configuring with --disable-runtime-cpu-detect will assume presence of NEON.
41 # Configuring with --disable-runtime-cpu-detect --disable-neon will remove any
44 # To change to building armeabi, run ./libvpx/configure again, but with
45 # --target=arm5te-android-gcc and modify the Application.mk file to
46 # set APP_ABI := armeabi
48 # Running ndk-build will build libvpx and include it in your project.
51 CONFIG_DIR := $(LOCAL_PATH)/
52 LIBVPX_PATH := $(LOCAL_PATH)/libvpx
53 ASM_CNV_PATH_LOCAL := $(TARGET_ARCH_ABI)/ads2gas
54 ASM_CNV_PATH := $(LOCAL_PATH)/$(ASM_CNV_PATH_LOCAL)
56 # Makefiles created by the libvpx configure process
57 # This will need to be fixed to handle x86.
58 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
59 include $(CONFIG_DIR)libs-armv7-android-gcc.mk
61 include $(CONFIG_DIR)libs-armv5te-android-gcc.mk
64 # Rule that is normally in Makefile created by libvpx
65 # configure. Used to filter out source files based on configuration.
66 enabled=$(filter-out $($(1)-no),$($(1)-yes))
68 # Override the relative path that is defined by the libvpx
70 SRC_PATH_BARE := $(LIBVPX_PATH)
72 # Include the list of files to be built
73 include $(LIBVPX_PATH)/libs.mk
75 # Want arm, not thumb, optimized
79 # -----------------------------------------------------------------------------
80 # Template : asm_offsets_template
81 # Arguments : 1: assembly offsets file to be created
82 # 2: c file to base assembly offsets on
84 # Usage : $(eval $(call asm_offsets_template,<asmfile>, <srcfile>
85 # Rationale : Create offsets at compile time using for structures that are
86 # defined in c, but used in assembly functions.
87 # -----------------------------------------------------------------------------
88 define asm_offsets_template
91 _OBJ:=$(ASM_CNV_PATH)/$$(notdir $(2)).S
93 _FLAGS = $$($$(my)CFLAGS) \
94 $$(call get-src-file-target-cflags,$(2)) \
95 $$(call host-c-includes,$$(LOCAL_C_INCLUDES) $$(CONFIG_DIR)) \
98 $$(call host-c-includes,$$($(my)C_INCLUDES)) \
102 _TEXT = "Compile $$(call get-src-file-text,$(2))"
105 $$(eval $$(call ev-build-file))
108 @mkdir -p $$(dir $$@)
109 @grep $(OFFSET_PATTERN) $$< | tr -d '\#' | $(CONFIG_DIR)$(ASM_CONVERSION) > $$@
112 # Use ads2gas script to convert from RVCT format to GAS format. This passes
113 # puts the processed file under $(ASM_CNV_PATH). Local clean rule
114 # to handle removing these
115 ifeq ($(CONFIG_VP8_ENCODER), yes)
116 ASM_CNV_OFFSETS_DEPEND += $(ASM_CNV_PATH)/vp8_asm_enc_offsets.asm
118 ifeq ($(HAVE_NEON), yes)
119 ASM_CNV_OFFSETS_DEPEND += $(ASM_CNV_PATH)/vpx_scale_asm_offsets.asm
123 $(ASM_CNV_PATH)/libvpx/%.asm.s: $(LIBVPX_PATH)/%.asm $(ASM_CNV_OFFSETS_DEPEND)
125 @$(CONFIG_DIR)$(ASM_CONVERSION) <$< > $@
127 # For building *_rtcd.h, which have rules in libs.mk
128 TGT_ISA:=$(word 1, $(subst -, ,$(TOOLCHAIN)))
131 LOCAL_SRC_FILES += vpx_config.c
133 # Remove duplicate entries
134 CODEC_SRCS_UNIQUE = $(sort $(CODEC_SRCS))
136 # Pull out C files. vpx_config.c is in the immediate directory and
137 # so it does not need libvpx/ prefixed like the rest of the source files.
138 # The neon files with intrinsics need to have .neon appended so the proper
140 CODEC_SRCS_C = $(filter %.c, $(CODEC_SRCS_UNIQUE))
141 LOCAL_NEON_SRCS_C = $(filter %_neon.c, $(CODEC_SRCS_C))
142 LOCAL_CODEC_SRCS_C = $(filter-out vpx_config.c %_neon.c, $(CODEC_SRCS_C))
144 LOCAL_SRC_FILES += $(foreach file, $(LOCAL_CODEC_SRCS_C), libvpx/$(file))
145 LOCAL_SRC_FILES += $(foreach file, $(LOCAL_NEON_SRCS_C), libvpx/$(file).neon)
147 # Pull out assembly files, splitting NEON from the rest. This is
148 # done to specify that the NEON assembly files use NEON assembler flags.
149 CODEC_SRCS_ASM_ALL = $(filter %.asm.s, $(CODEC_SRCS_UNIQUE))
150 CODEC_SRCS_ASM = $(foreach v, \
151 $(CODEC_SRCS_ASM_ALL), \
152 $(if $(findstring neon,$(v)),,$(v)))
153 CODEC_SRCS_ASM_ADS2GAS = $(patsubst %.s, \
154 $(ASM_CNV_PATH_LOCAL)/libvpx/%.s, \
156 LOCAL_SRC_FILES += $(CODEC_SRCS_ASM_ADS2GAS)
158 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
159 CODEC_SRCS_ASM_NEON = $(foreach v, \
160 $(CODEC_SRCS_ASM_ALL),\
161 $(if $(findstring neon,$(v)),$(v),))
162 CODEC_SRCS_ASM_NEON_ADS2GAS = $(patsubst %.s, \
163 $(ASM_CNV_PATH_LOCAL)/libvpx/%.s, \
164 $(CODEC_SRCS_ASM_NEON))
165 LOCAL_SRC_FILES += $(patsubst %.s, \
167 $(CODEC_SRCS_ASM_NEON_ADS2GAS))
171 -DHAVE_CONFIG_H=vpx_config.h \
175 LOCAL_MODULE := libvpx
177 LOCAL_LDLIBS := -llog
179 ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes)
180 LOCAL_STATIC_LIBRARIES := cpufeatures
183 # Add a dependency to force generation of the RTCD files.
184 ifeq ($(CONFIG_VP8), yes)
185 $(foreach file, $(LOCAL_SRC_FILES), $(LOCAL_PATH)/$(file)): vp8_rtcd.h
187 ifeq ($(CONFIG_VP9), yes)
188 $(foreach file, $(LOCAL_SRC_FILES), $(LOCAL_PATH)/$(file)): vp9_rtcd.h
190 $(foreach file, $(LOCAL_SRC_FILES), $(LOCAL_PATH)/$(file)): vpx_scale_rtcd.h
194 @echo "Clean: ads2gas files [$(TARGET_ARCH_ABI)]"
195 @$(RM) $(CODEC_SRCS_ASM_ADS2GAS) $(CODEC_SRCS_ASM_NEON_ADS2GAS)
196 @$(RM) $(patsubst %.asm, %.*, $(ASM_CNV_OFFSETS_DEPEND))
197 @$(RM) -r $(ASM_CNV_PATH)
200 include $(BUILD_SHARED_LIBRARY)
202 ifeq ($(HAVE_NEON), yes)
203 $(eval $(call asm_offsets_template,\
204 $(ASM_CNV_PATH)/vpx_scale_asm_offsets.asm, \
205 $(LIBVPX_PATH)/vpx_scale/vpx_scale_asm_offsets.c))
208 ifeq ($(CONFIG_VP8_ENCODER), yes)
209 $(eval $(call asm_offsets_template,\
210 $(ASM_CNV_PATH)/vp8_asm_enc_offsets.asm, \
211 $(LIBVPX_PATH)/vp8/encoder/vp8_asm_enc_offsets.c))
214 ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes)
215 $(call import-module,cpufeatures)