build: merge with master

Change-Id: I8ea836ce92c1c96f1e2bdf45e704d36ec9dbc401
This commit is contained in:
John Koleszar
2012-11-02 15:17:36 -07:00
parent 06f3e51da6
commit 1d0dc7c9f5
7 changed files with 555 additions and 99 deletions

210
build/make/Android.mk Normal file
View File

@@ -0,0 +1,210 @@
##
## 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)
# include libvpx/build/make/Android.mk
#
# There are currently two TARGET_ARCH_ABI targets for ARM.
# armeabi and armeabi-v7a. armeabi-v7a is selected by creating an
# Application.mk in the jni directory that contains:
# APP_ABI := armeabi-v7a
#
# 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.
# Configuring with --disable-runtime-cpu-detect --disable-neon will remove any
# NEON dependency.
# To change to building armeabi, run ./libvpx/configure again, but with
# --target=arm5te-android-gcc and modify the Application.mk file to
# set APP_ABI := armeabi
#
# Running ndk-build will build libvpx and include it in your project.
#
CONFIG_DIR := $(LOCAL_PATH)
LIBVPX_PATH := $(LOCAL_PATH)/libvpx
ASM_CNV_PATH_LOCAL := $(TARGET_ARCH_ABI)/ads2gas
ASM_CNV_PATH := $(LOCAL_PATH)/$(ASM_CNV_PATH_LOCAL)
# Makefiles created by the libvpx configure process
# This will need to be fixed to handle x86.
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
include $(CONFIG_DIR)/libs-armv7-android-gcc.mk
else
include $(CONFIG_DIR)/libs-armv5te-android-gcc.mk
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
# Want arm, not thumb, optimized
LOCAL_ARM_MODE := arm
LOCAL_CFLAGS := -O3
# -----------------------------------------------------------------------------
# Template : asm_offsets_template
# Arguments : 1: assembly offsets file to be created
# 2: c file to base assembly offsets on
# Returns : None
# Usage : $(eval $(call asm_offsets_template,<asmfile>, <srcfile>
# Rationale : Create offsets at compile time using for structures that are
# defined in c, but used in assembly functions.
# -----------------------------------------------------------------------------
define asm_offsets_template
_SRC:=$(2)
_OBJ:=$(ASM_CNV_PATH)/$$(notdir $(2)).S
_FLAGS = $$($$(my)CFLAGS) \
$$(call get-src-file-target-cflags,$(2)) \
$$(call host-c-includes,$$(LOCAL_C_INCLUDES) $$(CONFIG_DIR)) \
$$(LOCAL_CFLAGS) \
$$(NDK_APP_CFLAGS) \
$$(call host-c-includes,$$($(my)C_INCLUDES)) \
-DINLINE_ASM \
-S \
_TEXT = "Compile $$(call get-src-file-text,$(2))"
_CC = $$(TARGET_CC)
$$(eval $$(call ev-build-file))
$(1) : $$(_OBJ) $(2)
@mkdir -p $$(dir $$@)
@grep $(OFFSET_PATTERN) $$< | tr -d '\#' | $(CONFIG_DIR)/$(ASM_CONVERSION) > $$@
endef
# Use ads2gas script to convert from RVCT format to GAS format. This passes
# puts the processed file under $(ASM_CNV_PATH). Local clean rule
# to handle removing these
ASM_CNV_OFFSETS_DEPEND = $(ASM_CNV_PATH)/asm_com_offsets.asm
ifeq ($(CONFIG_VP8_DECODER), yes)
ASM_CNV_OFFSETS_DEPEND += $(ASM_CNV_PATH)/asm_dec_offsets.asm
endif
ifeq ($(CONFIG_VP8_ENCODER), yes)
ASM_CNV_OFFSETS_DEPEND += $(ASM_CNV_PATH)/asm_enc_offsets.asm
endif
.PRECIOUS: %.asm.s
$(ASM_CNV_PATH)/libvpx/%.asm.s: $(LIBVPX_PATH)/%.asm $(ASM_CNV_OFFSETS_DEPEND)
@mkdir -p $(dir $@)
@$(CONFIG_DIR)/$(ASM_CONVERSION) <$< > $@
# For building vpx_rtcd.h, which has a rule in libs.mk
TGT_ISA:=$(word 1, $(subst -, ,$(TOOLCHAIN)))
target := libs
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.
CODEC_SRCS_C = $(filter %.c, $(CODEC_SRCS_UNIQUE))
LOCAL_CODEC_SRCS_C = $(filter-out vpx_config.c, $(CODEC_SRCS_C))
LOCAL_SRC_FILES += $(foreach file, $(LOCAL_CODEC_SRCS_C), libvpx/$(file))
# Pull out assembly files, splitting NEON from the rest. This is
# done to specify that the NEON assembly files use NEON assembler flags.
CODEC_SRCS_ASM_ALL = $(filter %.asm.s, $(CODEC_SRCS_UNIQUE))
CODEC_SRCS_ASM = $(foreach v, \
$(CODEC_SRCS_ASM_ALL), \
$(if $(findstring neon,$(v)),,$(v)))
CODEC_SRCS_ASM_ADS2GAS = $(patsubst %.s, \
$(ASM_CNV_PATH_LOCAL)/libvpx/%.s, \
$(CODEC_SRCS_ASM))
LOCAL_SRC_FILES += $(CODEC_SRCS_ASM_ADS2GAS)
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
CODEC_SRCS_ASM_NEON = $(foreach v, \
$(CODEC_SRCS_ASM_ALL),\
$(if $(findstring neon,$(v)),$(v),))
CODEC_SRCS_ASM_NEON_ADS2GAS = $(patsubst %.s, \
$(ASM_CNV_PATH_LOCAL)/libvpx/%.s, \
$(CODEC_SRCS_ASM_NEON))
LOCAL_SRC_FILES += $(patsubst %.s, \
%.s.neon, \
$(CODEC_SRCS_ASM_NEON_ADS2GAS))
endif
LOCAL_CFLAGS += \
-DHAVE_CONFIG_H=vpx_config.h \
-I$(LIBVPX_PATH) \
-I$(ASM_CNV_PATH)
LOCAL_MODULE := libvpx
LOCAL_LDLIBS := -llog
ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes)
LOCAL_STATIC_LIBRARIES := cpufeatures
endif
$(foreach file, $(LOCAL_SRC_FILES), $(LOCAL_PATH)/$(file)): vpx_rtcd.h
.PHONY: clean
clean:
@echo "Clean: ads2gas files [$(TARGET_ARCH_ABI)]"
@$(RM) $(CODEC_SRCS_ASM_ADS2GAS) $(CODEC_SRCS_ASM_NEON_ADS2GAS)
@$(RM) $(patsubst %.asm, %.*, $(ASM_CNV_OFFSETS_DEPEND))
@$(RM) -r $(ASM_CNV_PATH)
@$(RM) $(CLEAN-OBJS)
include $(BUILD_SHARED_LIBRARY)
$(eval $(call asm_offsets_template,\
$(ASM_CNV_PATH)/asm_com_offsets.asm, \
$(LIBVPX_PATH)/vp8/common/asm_com_offsets.c))
ifeq ($(CONFIG_VP8_DECODER), yes)
$(eval $(call asm_offsets_template,\
$(ASM_CNV_PATH)/asm_dec_offsets.asm, \
$(LIBVPX_PATH)/vp8/decoder/asm_dec_offsets.c))
endif
ifeq ($(CONFIG_VP8_ENCODER), yes)
$(eval $(call asm_offsets_template,\
$(ASM_CNV_PATH)/asm_enc_offsets.asm, \
$(LIBVPX_PATH)/vp8/encoder/asm_enc_offsets.c))
endif
ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes)
$(call import-module,cpufeatures)
endif

View File

@@ -21,6 +21,7 @@ all: .DEFAULT
clean:: .DEFAULT clean:: .DEFAULT
install:: .DEFAULT install:: .DEFAULT
test:: .DEFAULT test:: .DEFAULT
testdata:: .DEFAULT
# Note: md5sum is not installed on OS X, but openssl is. Openssl may not be # Note: md5sum is not installed on OS X, but openssl is. Openssl may not be
@@ -66,6 +67,7 @@ endif
BUILD_ROOT?=. BUILD_ROOT?=.
VPATH=$(SRC_PATH_BARE) VPATH=$(SRC_PATH_BARE)
CFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT) -I$(SRC_PATH) CFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT) -I$(SRC_PATH)
CXXFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT) -I$(SRC_PATH)
ASFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT)/ -I$(SRC_PATH)/ ASFLAGS+=-I$(BUILD_PFX)$(BUILD_ROOT)/ -I$(SRC_PATH)/
DIST_DIR?=dist DIST_DIR?=dist
HOSTCC?=gcc HOSTCC?=gcc
@@ -98,6 +100,8 @@ dist:
install:: install::
.PHONY: test .PHONY: test
test:: test::
.PHONY: testdata
testdata::
$(BUILD_PFX)%.c.d: %.c $(BUILD_PFX)%.c.d: %.c
$(if $(quiet),@echo " [DEP] $@") $(if $(quiet),@echo " [DEP] $@")
@@ -111,11 +115,11 @@ $(BUILD_PFX)%.c.o: %.c
$(BUILD_PFX)%.cc.d: %.cc $(BUILD_PFX)%.cc.d: %.cc
$(if $(quiet),@echo " [DEP] $@") $(if $(quiet),@echo " [DEP] $@")
$(qexec)mkdir -p $(dir $@) $(qexec)mkdir -p $(dir $@)
$(qexec)g++ $(INTERNAL_CFLAGS) $(CFLAGS) -M $< | $(fmt_deps) > $@ $(qexec)$(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -M $< | $(fmt_deps) > $@
$(BUILD_PFX)%.cc.o: %.cc $(BUILD_PFX)%.cc.o: %.cc
$(if $(quiet),@echo " [CXX] $@") $(if $(quiet),@echo " [CXX] $@")
$(qexec)g++ $(INTERNAL_CFLAGS) $(CFLAGS) -c -o $@ $< $(qexec)$(CXX) $(INTERNAL_CFLAGS) $(CXXFLAGS) -c -o $@ $<
$(BUILD_PFX)%.asm.d: %.asm $(BUILD_PFX)%.asm.d: %.asm
$(if $(quiet),@echo " [DEP] $@") $(if $(quiet),@echo " [DEP] $@")
@@ -213,7 +217,7 @@ define linkerxx_template
$(1): $(filter-out -%,$(2)) $(1): $(filter-out -%,$(2))
$(1): $(1):
$(if $(quiet),@echo " [LD] $$@") $(if $(quiet),@echo " [LD] $$@")
$(qexec)g++ $$(strip $$(INTERNAL_LDFLAGS) $$(LDFLAGS) -o $$@ $(2) $(3) $$(extralibs)) $(qexec)$$(CXX) $$(strip $$(INTERNAL_LDFLAGS) $$(LDFLAGS) -o $$@ $(2) $(3) $$(extralibs))
endef endef
# make-3.80 has a bug with expanding large input strings to the eval function, # make-3.80 has a bug with expanding large input strings to the eval function,
# which was triggered in some cases by the following component of # which was triggered in some cases by the following component of

View File

@@ -26,12 +26,22 @@ print "\t.equ DO1STROUNDING, 0\n";
while (<STDIN>) while (<STDIN>)
{ {
undef $comment;
undef $line;
$comment_char = ";";
$comment_sub = "@";
# Handle comments.
if (/$comment_char/)
{
$comment = "";
($line, $comment) = /(.*?)$comment_char(.*)/;
$_ = $line;
}
# Load and store alignment # Load and store alignment
s/@/,:/g; s/@/,:/g;
# Comment character
s/;/@/g;
# Hexadecimal constants prefaced by 0x # Hexadecimal constants prefaced by 0x
s/#&/#0x/g; s/#&/#0x/g;
@@ -62,6 +72,17 @@ while (<STDIN>)
# Convert LTORG to .ltorg # Convert LTORG to .ltorg
s/LTORG/.ltorg/g; s/LTORG/.ltorg/g;
# Convert endfunc to nothing.
s/endfunc//ig;
# Convert FUNCTION to nothing.
s/FUNCTION//g;
s/function//g;
s/ENTRY//g;
s/MSARMASM/0/g;
s/^\s+end\s+$//g;
# Convert IF :DEF:to .if # Convert IF :DEF:to .if
# gcc doesn't have the ability to do a conditional # gcc doesn't have the ability to do a conditional
# if defined variable that is set by IF :DEF: on # if defined variable that is set by IF :DEF: on
@@ -106,6 +127,7 @@ while (<STDIN>)
if (s/RN\s+([Rr]\d+|lr)/.req $1/) if (s/RN\s+([Rr]\d+|lr)/.req $1/)
{ {
print; print;
print "$comment_sub$comment\n" if defined $comment;
next; next;
} }
@@ -114,6 +136,9 @@ while (<STDIN>)
s/EXPORT\s+\|([\$\w]*)\|/.global $1 \n\t.type $1, function/; s/EXPORT\s+\|([\$\w]*)\|/.global $1 \n\t.type $1, function/;
s/IMPORT\s+\|([\$\w]*)\|/.global $1/; s/IMPORT\s+\|([\$\w]*)\|/.global $1/;
s/EXPORT\s+([\$\w]*)/.global $1/;
s/export\s+([\$\w]*)/.global $1/;
# No vertical bars required; make additional symbol with prepended # No vertical bars required; make additional symbol with prepended
# underscore # underscore
s/^\|(\$?\w+)\|/_$1\n\t$1:/g; s/^\|(\$?\w+)\|/_$1\n\t$1:/g;
@@ -126,15 +151,21 @@ while (<STDIN>)
# ALIGN directive # ALIGN directive
s/ALIGN/.balign/g; s/ALIGN/.balign/g;
# Strip ARM # ARM code
s/\sARM/@ ARM/g; s/\sARM/.arm/g;
# Strip REQUIRE8 # NEON code
#s/\sREQUIRE8/@ REQUIRE8/g; s/(vld1.\d+\s+)(q\d+)/$1\{$2\}/g;
s/\sREQUIRE8/@ /g; #EQU cause problem s/(vtbl.\d+\s+[^,]+),([^,]+)/$1,\{$2\}/g;
# Strip PRESERVE8 # eabi_attributes numerical equivalents can be found in the
s/\sPRESERVE8/@ PRESERVE8/g; # "ARM IHI 0045C" document.
# REQUIRE8 Stack is required to be 8-byte aligned
s/\sREQUIRE8/.eabi_attribute 24, 1 \@Tag_ABI_align_needed/g;
# PRESERVE8 Stack 8-byte align is preserved
s/\sPRESERVE8/.eabi_attribute 25, 1 \@Tag_ABI_align_preserved/g;
# Use PROC and ENDP to give the symbols a .size directive. # Use PROC and ENDP to give the symbols a .size directive.
# This makes them show up properly in debugging tools like gdb and valgrind. # This makes them show up properly in debugging tools like gdb and valgrind.
@@ -155,7 +186,7 @@ while (<STDIN>)
} }
# EQU directive # EQU directive
s/(.*)EQU(.*)/.equ $1, $2/; s/(\S+\s+)EQU(\s+\S+)/.equ $1, $2/;
# Begin macro definition # Begin macro definition
if (/MACRO/) { if (/MACRO/) {
@@ -170,6 +201,7 @@ while (<STDIN>)
s/MEND/.endm/; # No need to tell it where to stop assembling s/MEND/.endm/; # No need to tell it where to stop assembling
next if /^\s*END\s*$/; next if /^\s*END\s*$/;
print; print;
print "$comment_sub$comment\n" if defined $comment;
} }
# Mark that this object doesn't need an executable stack. # Mark that this object doesn't need an executable stack.

View File

@@ -30,6 +30,8 @@ my @mapping_list = ("\$0", "\$1", "\$2", "\$3", "\$4", "\$5", "\$6", "\$7", "\$8
my @incoming_array; my @incoming_array;
my @imported_functions;
# Perl trim function to remove whitespace from the start and end of the string # Perl trim function to remove whitespace from the start and end of the string
sub trim($) sub trim($)
{ {
@@ -132,7 +134,18 @@ while (<STDIN>)
# Make function visible to linker, and make additional symbol with # Make function visible to linker, and make additional symbol with
# prepended underscore # prepended underscore
s/EXPORT\s+\|([\$\w]*)\|/.globl _$1\n\t.globl $1/; s/EXPORT\s+\|([\$\w]*)\|/.globl _$1\n\t.globl $1/;
s/IMPORT\s+\|([\$\w]*)\|/.globl $1/;
# Prepend imported functions with _
if (s/IMPORT\s+\|([\$\w]*)\|/.globl $1/)
{
$function = trim($1);
push(@imported_functions, $function);
}
foreach $function (@imported_functions)
{
s/$function/_$function/;
}
# No vertical bars required; make additional symbol with prepended # No vertical bars required; make additional symbol with prepended
# underscore # underscore
@@ -157,8 +170,8 @@ while (<STDIN>)
s/\sPRESERVE8/@ PRESERVE8/g; s/\sPRESERVE8/@ PRESERVE8/g;
# Strip PROC and ENDPROC # Strip PROC and ENDPROC
s/PROC/@/g; s/\bPROC\b/@/g;
s/ENDP/@/g; s/\bENDP\b/@/g;
# EQU directive # EQU directive
s/(.*)EQU(.*)/.set $1, $2/; s/(.*)EQU(.*)/.set $1, $2/;

View File

@@ -166,6 +166,17 @@ is_in(){
add_cflags() { add_cflags() {
CFLAGS="${CFLAGS} $@" CFLAGS="${CFLAGS} $@"
CXXFLAGS="${CXXFLAGS} $@"
}
add_cflags_only() {
CFLAGS="${CFLAGS} $@"
}
add_cxxflags_only() {
CXXFLAGS="${CXXFLAGS} $@"
} }
@@ -277,6 +288,13 @@ check_cc() {
check_cmd ${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C} check_cmd ${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C}
} }
check_cxx() {
log check_cxx "$@"
cat >${TMP_C}
log_file ${TMP_C}
check_cmd ${CXX} ${CXXFLAGS} "$@" -c -o ${TMP_O} ${TMP_C}
}
check_cpp() { check_cpp() {
log check_cpp "$@" log check_cpp "$@"
cat > ${TMP_C} cat > ${TMP_C}
@@ -310,8 +328,25 @@ int x;
EOF EOF
} }
check_cxxflags() {
log check_cxxflags "$@"
# Catch CFLAGS that trigger CXX warnings
case "$CXX" in
*g++*) check_cxx -Werror "$@" <<EOF
int x;
EOF
;;
*) check_cxx "$@" <<EOF
int x;
EOF
;;
esac
}
check_add_cflags() { check_add_cflags() {
check_cflags "$@" && add_cflags "$@" check_cxxflags "$@" && add_cxxflags_only "$@"
check_cflags "$@" && add_cflags_only "$@"
} }
check_add_asflags() { check_add_asflags() {
@@ -340,7 +375,8 @@ EOF
} }
write_common_config_banner() { write_common_config_banner() {
echo '# This file automatically generated by configure. Do not edit!' > config.mk print_webm_license config.mk "##" ""
echo '# This file automatically generated by configure. Do not edit!' >> config.mk
echo "TOOLCHAIN := ${toolchain}" >> config.mk echo "TOOLCHAIN := ${toolchain}" >> config.mk
case ${toolchain} in case ${toolchain} in
@@ -366,9 +402,12 @@ true
write_common_target_config_mk() { write_common_target_config_mk() {
local CC=${CC} local CC=${CC}
local CXX=${CXX}
enabled ccache && CC="ccache ${CC}" enabled ccache && CC="ccache ${CC}"
enabled ccache && CXX="ccache ${CXX}"
print_webm_license $1 "##" ""
cat > $1 << EOF cat >> $1 << EOF
# This file automatically generated by configure. Do not edit! # This file automatically generated by configure. Do not edit!
SRC_PATH="$source_path" SRC_PATH="$source_path"
SRC_PATH_BARE=$source_path SRC_PATH_BARE=$source_path
@@ -377,6 +416,7 @@ TOOLCHAIN=${toolchain}
ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl} ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl}
CC=${CC} CC=${CC}
CXX=${CXX}
AR=${AR} AR=${AR}
LD=${LD} LD=${LD}
AS=${AS} AS=${AS}
@@ -384,11 +424,13 @@ STRIP=${STRIP}
NM=${NM} NM=${NM}
CFLAGS = ${CFLAGS} CFLAGS = ${CFLAGS}
CXXFLAGS = ${CXXFLAGS}
ARFLAGS = -rus\$(if \$(quiet),c,v) ARFLAGS = -rus\$(if \$(quiet),c,v)
LDFLAGS = ${LDFLAGS} LDFLAGS = ${LDFLAGS}
ASFLAGS = ${ASFLAGS} ASFLAGS = ${ASFLAGS}
extralibs = ${extralibs} extralibs = ${extralibs}
AS_SFX = ${AS_SFX:-.asm} AS_SFX = ${AS_SFX:-.asm}
EXE_SFX = ${EXE_SFX}
RTCD_OPTIONS = ${RTCD_OPTIONS} RTCD_OPTIONS = ${RTCD_OPTIONS}
EOF EOF
@@ -411,7 +453,8 @@ EOF
write_common_target_config_h() { write_common_target_config_h() {
cat > ${TMP_H} << EOF print_webm_license ${TMP_H} "/*" " */"
cat >> ${TMP_H} << EOF
/* This file automatically generated by configure. Do not edit! */ /* This file automatically generated by configure. Do not edit! */
#ifndef VPX_CONFIG_H #ifndef VPX_CONFIG_H
#define VPX_CONFIG_H #define VPX_CONFIG_H
@@ -454,7 +497,10 @@ process_common_cmdline() {
eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'` eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
if echo "${ARCH_EXT_LIST}" | grep "^ *$option\$" >/dev/null; then if echo "${ARCH_EXT_LIST}" | grep "^ *$option\$" >/dev/null; then
[ $action = "disable" ] && RTCD_OPTIONS="${RTCD_OPTIONS}${opt} " [ $action = "disable" ] && RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
else elif [ $action = "disable" ] && ! disabled $option ; then
echo "${CMDLINE_SELECT}" | grep "^ *$option\$" >/dev/null ||
die_unknown $opt
elif [ $action = "enable" ] && ! enabled $option ; then
echo "${CMDLINE_SELECT}" | grep "^ *$option\$" >/dev/null || echo "${CMDLINE_SELECT}" | grep "^ *$option\$" >/dev/null ||
die_unknown $opt die_unknown $opt
fi fi
@@ -488,7 +534,11 @@ process_common_cmdline() {
--libdir=*) --libdir=*)
libdir="${optval}" libdir="${optval}"
;; ;;
--libc|--as|--prefix|--libdir) --sdk-path=*)
[ -d "${optval}" ] || die "Not a directory: ${optval}"
sdk_path="${optval}"
;;
--libc|--as|--prefix|--libdir|--sdk-path)
die "Option ${opt} requires argument" die "Option ${opt} requires argument"
;; ;;
--help|-h) show_help --help|-h) show_help
@@ -527,20 +577,31 @@ post_process_cmdline() {
setup_gnu_toolchain() { setup_gnu_toolchain() {
CC=${CC:-${CROSS}gcc} CC=${CC:-${CROSS}gcc}
CXX=${CXX:-${CROSS}g++}
AR=${AR:-${CROSS}ar} AR=${AR:-${CROSS}ar}
LD=${LD:-${CROSS}${link_with_cc:-ld}} LD=${LD:-${CROSS}${link_with_cc:-ld}}
AS=${AS:-${CROSS}as} AS=${AS:-${CROSS}as}
STRIP=${STRIP:-${CROSS}strip} STRIP=${STRIP:-${CROSS}strip}
NM=${NM:-${CROSS}nm} NM=${NM:-${CROSS}nm}
AS_SFX=.s AS_SFX=.s
EXE_SFX=
} }
process_common_toolchain() { process_common_toolchain() {
if [ -z "$toolchain" ]; then if [ -z "$toolchain" ]; then
gcctarget="$(gcc -dumpmachine 2> /dev/null)" gcctarget="${CHOST:-$(gcc -dumpmachine 2> /dev/null)}"
# detect tgt_isa # detect tgt_isa
case "$gcctarget" in case "$gcctarget" in
armv6*)
tgt_isa=armv6
;;
armv7*)
tgt_isa=armv7
;;
armv5te*)
tgt_isa=armv5te
;;
*x86_64*|*amd64*) *x86_64*|*amd64*)
tgt_isa=x86_64 tgt_isa=x86_64
;; ;;
@@ -572,6 +633,14 @@ process_common_toolchain() {
tgt_isa=x86_64 tgt_isa=x86_64
tgt_os=darwin10 tgt_os=darwin10
;; ;;
*darwin11*)
tgt_isa=x86_64
tgt_os=darwin11
;;
*darwin12*)
tgt_isa=x86_64
tgt_os=darwin12
;;
*mingw32*|*cygwin*) *mingw32*|*cygwin*)
[ -z "$tgt_isa" ] && tgt_isa=x86 [ -z "$tgt_isa" ] && tgt_isa=x86
tgt_os=win32 tgt_os=win32
@@ -582,6 +651,9 @@ process_common_toolchain() {
*solaris2.10) *solaris2.10)
tgt_os=solaris tgt_os=solaris
;; ;;
*os2*)
tgt_os=os2
;;
esac esac
if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then
@@ -610,39 +682,60 @@ process_common_toolchain() {
# Enable the architecture family # Enable the architecture family
case ${tgt_isa} in case ${tgt_isa} in
arm*|iwmmxt*) enable arm;; arm*) enable arm;;
mips*) enable mips;; mips*) enable mips;;
esac esac
# PIC is probably what we want when building shared libs # PIC is probably what we want when building shared libs
enabled shared && soft_enable pic enabled shared && soft_enable pic
# Handle darwin variants # Handle darwin variants. Newer SDKs allow targeting older
# platforms, so find the newest SDK available.
case ${toolchain} in
*-darwin*)
if [ -z "${DEVELOPER_DIR}" ]; then
DEVELOPER_DIR=`xcode-select -print-path 2> /dev/null`
[ $? -ne 0 ] && OSX_SKIP_DIR_CHECK=1
fi
if [ -z "${OSX_SKIP_DIR_CHECK}" ]; then
OSX_SDK_ROOTS="${DEVELOPER_DIR}/SDKs"
OSX_SDK_VERSIONS="MacOSX10.4u.sdk MacOSX10.5.sdk MacOSX10.6.sdk"
OSX_SDK_VERSIONS="${OSX_SDK_VERSIONS} MacOSX10.7.sdk"
for v in ${OSX_SDK_VERSIONS}; do
if [ -d "${OSX_SDK_ROOTS}/${v}" ]; then
osx_sdk_dir="${OSX_SDK_ROOTS}/${v}"
fi
done
fi
;;
esac
if [ -d "${osx_sdk_dir}" ]; then
add_cflags "-isysroot ${osx_sdk_dir}"
add_ldflags "-isysroot ${osx_sdk_dir}"
fi
case ${toolchain} in case ${toolchain} in
*-darwin8-*) *-darwin8-*)
add_cflags "-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
add_cflags "-mmacosx-version-min=10.4" add_cflags "-mmacosx-version-min=10.4"
add_ldflags "-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
add_ldflags "-mmacosx-version-min=10.4" add_ldflags "-mmacosx-version-min=10.4"
;; ;;
*-darwin9-*) *-darwin9-*)
add_cflags "-isysroot /Developer/SDKs/MacOSX10.5.sdk"
add_cflags "-mmacosx-version-min=10.5" add_cflags "-mmacosx-version-min=10.5"
add_ldflags "-isysroot /Developer/SDKs/MacOSX10.5.sdk"
add_ldflags "-mmacosx-version-min=10.5" add_ldflags "-mmacosx-version-min=10.5"
;; ;;
*-darwin10-*) *-darwin10-*)
add_cflags "-isysroot /Developer/SDKs/MacOSX10.6.sdk"
add_cflags "-mmacosx-version-min=10.6" add_cflags "-mmacosx-version-min=10.6"
add_ldflags "-isysroot /Developer/SDKs/MacOSX10.6.sdk"
add_ldflags "-mmacosx-version-min=10.6" add_ldflags "-mmacosx-version-min=10.6"
;; ;;
*-darwin11-*) *-darwin11-*)
add_cflags "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk"
add_cflags "-mmacosx-version-min=10.7" add_cflags "-mmacosx-version-min=10.7"
add_ldflags "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk"
add_ldflags "-mmacosx-version-min=10.7" add_ldflags "-mmacosx-version-min=10.7"
;; ;;
*-darwin12-*)
add_cflags "-mmacosx-version-min=10.8"
add_ldflags "-mmacosx-version-min=10.8"
;;
esac esac
# Handle Solaris variants. Solaris 10 needs -lposix4 # Handle Solaris variants. Solaris 10 needs -lposix4
@@ -658,44 +751,54 @@ process_common_toolchain() {
# Process ARM architecture variants # Process ARM architecture variants
case ${toolchain} in case ${toolchain} in
arm*|iwmmxt*) arm*)
# on arm, isa versions are supersets # on arm, isa versions are supersets
enabled armv7a && soft_enable armv7 ### DEBUG case ${tgt_isa} in
enabled armv7 && soft_enable armv6 armv7)
enabled armv7 || enabled armv6 && soft_enable armv5te soft_enable neon
enabled armv7 || enabled armv6 && soft_enable fast_unaligned soft_enable media
enabled iwmmxt2 && soft_enable iwmmxt soft_enable edsp
enabled iwmmxt && soft_enable armv5te soft_enable fast_unaligned
;;
armv6)
soft_enable media
soft_enable edsp
soft_enable fast_unaligned
;;
armv5te)
soft_enable edsp
;;
esac
asm_conversion_cmd="cat" asm_conversion_cmd="cat"
case ${tgt_cc} in case ${tgt_cc} in
gcc) gcc)
if enabled iwmmxt || enabled iwmmxt2
then
CROSS=${CROSS:-arm-iwmmxt-linux-gnueabi-}
elif enabled symbian; then
CROSS=${CROSS:-arm-none-symbianelf-}
else
CROSS=${CROSS:-arm-none-linux-gnueabi-} CROSS=${CROSS:-arm-none-linux-gnueabi-}
fi
link_with_cc=gcc link_with_cc=gcc
setup_gnu_toolchain setup_gnu_toolchain
arch_int=${tgt_isa##armv} arch_int=${tgt_isa##armv}
arch_int=${arch_int%%te} arch_int=${arch_int%%te}
check_add_asflags --defsym ARCHITECTURE=${arch_int} check_add_asflags --defsym ARCHITECTURE=${arch_int}
tune_cflags="-mtune=" tune_cflags="-mtune="
if enabled iwmmxt || enabled iwmmxt2 if [ ${tgt_isa} == "armv7" ]; then
check_add_cflags -march=armv7-a -mfloat-abi=softfp
check_add_asflags -march=armv7-a -mfloat-abi=softfp
if enabled neon
then then
check_add_asflags -mcpu=${tgt_isa} check_add_cflags -mfpu=neon #-ftree-vectorize
elif enabled armv7 check_add_asflags -mfpu=neon
then fi
check_add_cflags -march=armv7-a -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp #-ftree-vectorize
check_add_asflags -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp #-march=armv7-a if [ -z "${tune_cpu}" ]; then
tune_cpu=cortex-a8
fi
else else
check_add_cflags -march=${tgt_isa} check_add_cflags -march=${tgt_isa}
check_add_asflags -march=${tgt_isa} check_add_asflags -march=${tgt_isa}
fi fi
enabled debug && add_asflags -g enabled debug && add_asflags -g
asm_conversion_cmd="${source_path}/build/make/ads2gas.pl" asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
;; ;;
@@ -709,10 +812,14 @@ process_common_toolchain() {
tune_cflags="--cpu=" tune_cflags="--cpu="
tune_asflags="--cpu=" tune_asflags="--cpu="
if [ -z "${tune_cpu}" ]; then if [ -z "${tune_cpu}" ]; then
if enabled armv7 if [ ${tgt_isa} == "armv7" ]; then
if enabled neon
then then
check_add_cflags --cpu=Cortex-A8 --fpu=softvfp+vfpv3 check_add_cflags --fpu=softvfp+vfpv3
check_add_asflags --cpu=Cortex-A8 --fpu=softvfp+vfpv3 check_add_asflags --fpu=softvfp+vfpv3
fi
check_add_cflags --cpu=Cortex-A8
check_add_asflags --cpu=Cortex-A8
else else
check_add_cflags --cpu=${tgt_isa##armv} check_add_cflags --cpu=${tgt_isa##armv}
check_add_asflags --cpu=${tgt_isa##armv} check_add_asflags --cpu=${tgt_isa##armv}
@@ -733,12 +840,58 @@ process_common_toolchain() {
disable multithread disable multithread
disable os_support disable os_support
;; ;;
android*)
SDK_PATH=${sdk_path}
COMPILER_LOCATION=`find "${SDK_PATH}" \
-name "arm-linux-androideabi-gcc*" -print -quit`
TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi-
CC=${TOOLCHAIN_PATH}gcc
CXX=${TOOLCHAIN_PATH}g++
AR=${TOOLCHAIN_PATH}ar
LD=${TOOLCHAIN_PATH}gcc
AS=${TOOLCHAIN_PATH}as
STRIP=${TOOLCHAIN_PATH}strip
NM=${TOOLCHAIN_PATH}nm
if [ -z "${alt_libc}" ]; then
alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \
awk '{n = split($0,a,"/"); \
split(a[n-1],b,"-"); \
print $0 " " b[2]}' | \
sort -g -k 2 | \
awk '{ print $1 }' | tail -1`
fi
add_cflags "--sysroot=${alt_libc}"
add_ldflags "--sysroot=${alt_libc}"
# linker flag that routes around a CPU bug in some
# Cortex-A8 implementations (NDK Dev Guide)
add_ldflags "-Wl,--fix-cortex-a8"
enable pic
soft_enable realtime_only
if [ ${tgt_isa} == "armv7" ]; then
soft_enable runtime_cpu_detect
fi
if enabled runtime_cpu_detect; then
add_cflags "-I${SDK_PATH}/sources/android/cpufeatures"
fi
;;
darwin*) darwin*)
SDK_PATH=/Developer/Platforms/iPhoneOS.platform/Developer if [ -z "${sdk_path}" ]; then
SDK_PATH=`xcode-select -print-path 2> /dev/null`
SDK_PATH=${SDK_PATH}/Platforms/iPhoneOS.platform/Developer
else
SDK_PATH=${sdk_path}
fi
TOOLCHAIN_PATH=${SDK_PATH}/usr/bin TOOLCHAIN_PATH=${SDK_PATH}/usr/bin
CXX=${TOOLCHAIN_PATH}/g++
CC=${TOOLCHAIN_PATH}/gcc CC=${TOOLCHAIN_PATH}/gcc
AR=${TOOLCHAIN_PATH}/ar AR=${TOOLCHAIN_PATH}/ar
LD=${TOOLCHAIN_PATH}/arm-apple-darwin10-gcc-4.2.1 LD=${TOOLCHAIN_PATH}/arm-apple-darwin10-llvm-gcc-4.2
AS=${TOOLCHAIN_PATH}/as AS=${TOOLCHAIN_PATH}/as
STRIP=${TOOLCHAIN_PATH}/strip STRIP=${TOOLCHAIN_PATH}/strip
NM=${TOOLCHAIN_PATH}/nm NM=${TOOLCHAIN_PATH}/nm
@@ -752,13 +905,14 @@ process_common_toolchain() {
add_cflags -arch ${tgt_isa} add_cflags -arch ${tgt_isa}
add_ldflags -arch_only ${tgt_isa} add_ldflags -arch_only ${tgt_isa}
add_cflags "-isysroot ${SDK_PATH}/SDKs/iPhoneOS4.3.sdk" if [ -z "${alt_libc}" ]; then
alt_libc=${SDK_PATH}/SDKs/iPhoneOS5.1.sdk
fi
# This should be overridable add_cflags "-isysroot ${alt_libc}"
alt_libc=${SDK_PATH}/SDKs/iPhoneOS4.3.sdk
# Add the paths for the alternate libc # Add the paths for the alternate libc
for d in usr/include usr/include/gcc/darwin/4.2/ usr/lib/gcc/arm-apple-darwin10/4.2.1/include/; do for d in usr/include; do
try_dir="${alt_libc}/${d}" try_dir="${alt_libc}/${d}"
[ -d "${try_dir}" ] && add_cflags -I"${try_dir}" [ -d "${try_dir}" ] && add_cflags -I"${try_dir}"
done done
@@ -795,26 +949,16 @@ process_common_toolchain() {
fi fi
;; ;;
symbian*)
enable symbian
# Add the paths for the alternate libc
for d in include/libc; do
try_dir="${alt_libc}/${d}"
[ -d "${try_dir}" ] && add_cflags -I"${try_dir}"
done
for d in release/armv5/urel; do
try_dir="${alt_libc}/${d}"
[ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
done
add_cflags -DIMPORT_C=
esac esac
;; ;;
mips*) mips*)
CROSS=${CROSS:-mipsel-linux-uclibc-}
link_with_cc=gcc link_with_cc=gcc
setup_gnu_toolchain setup_gnu_toolchain
tune_cflags="-mtune=" tune_cflags="-mtune="
if enabled dspr2; then
check_add_cflags -mips32r2 -mdspr2
disable fast_unaligned
fi
check_add_cflags -march=${tgt_isa} check_add_cflags -march=${tgt_isa}
check_add_asflags -march=${tgt_isa} check_add_asflags -march=${tgt_isa}
check_add_asflags -KPIC check_add_asflags -KPIC
@@ -845,6 +989,11 @@ process_common_toolchain() {
x86*) x86*)
bits=32 bits=32
enabled x86_64 && bits=64 enabled x86_64 && bits=64
check_cpp <<EOF && bits=x32
#ifndef __ILP32__
#error "not x32"
#endif
EOF
soft_enable runtime_cpu_detect soft_enable runtime_cpu_detect
soft_enable mmx soft_enable mmx
soft_enable sse soft_enable sse
@@ -859,9 +1008,13 @@ process_common_toolchain() {
;; ;;
solaris*) solaris*)
CC=${CC:-${CROSS}gcc} CC=${CC:-${CROSS}gcc}
CXX=${CXX:-${CROSS}g++}
LD=${LD:-${CROSS}gcc} LD=${LD:-${CROSS}gcc}
CROSS=${CROSS:-g} CROSS=${CROSS:-g}
;; ;;
os2)
AS=${AS:-nasm}
;;
esac esac
AS="${alt_as:-${AS:-auto}}" AS="${alt_as:-${AS:-auto}}"
@@ -893,6 +1046,12 @@ process_common_toolchain() {
#for 32 bit x86 builds, -O3 did not turn on this flag #for 32 bit x86 builds, -O3 did not turn on this flag
enabled optimizations && check_add_cflags -fomit-frame-pointer enabled optimizations && check_add_cflags -fomit-frame-pointer
;; ;;
vs*)
# When building with Microsoft Visual Studio the assembler is
# invoked directly. Checking at configure time is unnecessary.
# Skip the check by setting AS arbitrarily
AS=msvs
;;
esac esac
case "${AS}" in case "${AS}" in
@@ -907,8 +1066,12 @@ process_common_toolchain() {
[ "${AS##*/}" = nasm ] && add_asflags -Ox [ "${AS##*/}" = nasm ] && add_asflags -Ox
AS_SFX=.asm AS_SFX=.asm
case ${tgt_os} in case ${tgt_os} in
win*) win32)
add_asflags -f win${bits} add_asflags -f win32
enabled debug && add_asflags -g cv8
;;
win64)
add_asflags -f x64
enabled debug && add_asflags -g cv8 enabled debug && add_asflags -g cv8
;; ;;
linux*|solaris*) linux*|solaris*)
@@ -928,6 +1091,11 @@ process_common_toolchain() {
# enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
enabled icc && ! enabled pic && add_cflags -fno-pic enabled icc && ! enabled pic && add_cflags -fno-pic
;; ;;
os2)
add_asflags -f aout
enabled debug && add_asflags -g
EXE_SFX=.exe
;;
*) log "Warning: Unknown os $tgt_os while setting up $AS flags" *) log "Warning: Unknown os $tgt_os while setting up $AS flags"
;; ;;
esac esac
@@ -989,11 +1157,24 @@ EOF
# Almost every platform uses pthreads. # Almost every platform uses pthreads.
if enabled multithread; then if enabled multithread; then
case ${toolchain} in case ${toolchain} in
*-win*);; *-win*-vs*);;
*-android-gcc);;
*) check_header pthread.h && add_extralibs -lpthread *) check_header pthread.h && add_extralibs -lpthread
esac esac
fi fi
# only for MIPS platforms
case ${toolchain} in
mips*)
if enabled dspr2; then
if enabled big_endian; then
echo "dspr2 optimizations are available only for little endian platforms"
disable dspr2
fi
fi
;;
esac
# for sysconf(3) and friends. # for sysconf(3) and friends.
check_header unistd.h check_header unistd.h
@@ -1040,6 +1221,22 @@ print_config_h() {
done done
} }
print_webm_license() {
local destination=$1
local prefix=$2
local suffix=$3
shift 3
cat <<EOF > ${destination}
${prefix} Copyright (c) 2011 The WebM project authors. All Rights Reserved.${suffix}
${prefix} ${suffix}
${prefix} Use of this source code is governed by a BSD-style license${suffix}
${prefix} that can be found in the LICENSE file in the root of the source${suffix}
${prefix} tree. An additional intellectual property rights grant can be found${suffix}
${prefix} in the file PATENTS. All contributing project authors may${suffix}
${prefix} be found in the AUTHORS file in the root of the source tree.${suffix}
EOF
}
process_targets() { process_targets() {
true; true;
} }

View File

@@ -42,7 +42,7 @@ done
[ -n "$srcfile" ] || show_help [ -n "$srcfile" ] || show_help
sfx=${sfx:-asm} sfx=${sfx:-asm}
includes=$(egrep -i "include +\"?[a-z0-9_/]+\.${sfx}" $srcfile | includes=$(LC_ALL=C egrep -i "include +\"?[a-z0-9_/]+\.${sfx}" $srcfile |
perl -p -e "s;.*?([a-z0-9_/]+.${sfx}).*;\1;") perl -p -e "s;.*?([a-z0-9_/]+.${sfx}).*;\1;")
#" restore editor state #" restore editor state
for inc in ${includes}; do for inc in ${includes}; do

View File

@@ -602,7 +602,7 @@ int parse_coff(uint8_t *buf, size_t sz) {
uint32_t symoffset; uint32_t symoffset;
char **sectionlist; // this array holds all section names in their correct order. char **sectionlist; // this array holds all section names in their correct order.
// it is used to check if the symbol is in .bss or .data section. // it is used to check if the symbol is in .bss or .rdata section.
nsections = get_le16(buf + 2); nsections = get_le16(buf + 2);
symtab_ptr = get_le32(buf + 8); symtab_ptr = get_le32(buf + 8);
@@ -643,15 +643,15 @@ int parse_coff(uint8_t *buf, size_t sz) {
} }
strcpy(sectionlist[i], sectionname); strcpy(sectionlist[i], sectionname);
if (!strcmp(sectionname, ".data")) sectionrawdata_ptr = get_le32(ptr + 20); if (!strcmp(sectionname, ".rdata")) sectionrawdata_ptr = get_le32(ptr + 20);
ptr += 40; ptr += 40;
} }
// log_msg("COFF: Symbol table at offset %u\n", symtab_ptr); // log_msg("COFF: Symbol table at offset %u\n", symtab_ptr);
// log_msg("COFF: raw data pointer ofset for section .data is %u\n", sectionrawdata_ptr); // log_msg("COFF: raw data pointer ofset for section .rdata is %u\n", sectionrawdata_ptr);
/* The compiler puts the data with non-zero offset in .data section, but puts the data with /* The compiler puts the data with non-zero offset in .rdata section, but puts the data with
zero offset in .bss section. So, if the data in in .bss section, set offset=0. zero offset in .bss section. So, if the data in in .bss section, set offset=0.
Note from Wiki: In an object module compiled from C, the bss section contains Note from Wiki: In an object module compiled from C, the bss section contains
the local variables (but not functions) that were declared with the static keyword, the local variables (but not functions) that were declared with the static keyword,