Newer
Older
log check_inline_asm_flags "$@"
name="$1"
code="$2"
flags=''
shift 2
while [ "$1" != "" ]; do
append flags $1
shift
done;
disable $name
cat > $TMPC <<EOF
void foo(void){ __asm__ volatile($code); }
EOF
log_file $TMPC
test_cmd $cc $CPPFLAGS $CFLAGS $flags "$@" $CC_C $(cc_o $TMPO) $TMPC &&
enable $name && add_cflags $flags && add_asflags $flags && add_ldflags $flags
}
check_insn(){
log check_insn "$@"
Diego Biurrun
committed
check_inline_asm ${1}_inline "$2"
check_as ${1}_external "$2"
test_x86asm(){
log test_x86asm "$@"
test_cmd $x86asmexe $X86ASMFLAGS -Werror "$@" -o $TMPO $TMPS
ld_o(){
eval printf '%s\\n' $LD_O
}
test_ld(){
log test_ld "$@"
flags=$(filter_out '-l*|*.so' $@)
libs=$(filter '-l*|*.so' $@)
test_$type $($cflags_filter $flags) || return
flags=$($ldflags_filter $flags)
libs=$($ldflags_filter $libs)
test_cmd $ld $LDFLAGS $LDEXEFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
check_ld(){
log check_ld "$@"
type=$1
name=$2
shift 2
disable $name
test_ld $type $@ && enable $name
}
print_include(){
hdr=$1
test "${hdr%.h}" = "${hdr}" &&
echo "#include $hdr" ||
echo "#include <$hdr>"
}
test_code(){
log test_code "$@"
check=$1
headers=$2
code=$3
shift 3
{
for hdr in $headers; do
print_include $hdr
done
echo "int main(void) { $code; return 0; }"
} | test_$check "$@"
check_cppflags(){
log check_cppflags "$@"
test_cpp "$@" <<EOF && append CPPFLAGS "$@"
#include <stdlib.h>
test_cflags(){
log test_cflags "$@"
set -- $($cflags_filter "$@")
test_cc "$@" <<EOF
check_cflags(){
log check_cflags "$@"
test_cflags "$@" && add_cflags "$@"
}
set -- $($cflags_filter "$@")
test_cxx "$@" <<EOF && append CXXFLAGS "$@"
Diego Biurrun
committed
log test_objcflags "$@"
set -- $($objcflags_filter "$@")
test_objcc "$@" <<EOF
int x;
EOF
}
check_objcflags(){
Diego Biurrun
committed
log check_objcflags "$@"
test_objcflags "$@" && add_objcflags "$@"
}
test_ldflags(){
log test_ldflags "$@"
set -- $($ldflags_filter "$@")
test_ld "cc" "$@" <<EOF
int main(void){ return 0; }
check_ldflags(){
log check_ldflags "$@"
test_ldflags "$@" && add_ldflags "$@"
}
test_stripflags(){
log test_stripflags "$@"
# call test_cc to get a fresh TMPO
test_cc <<EOF
int main(void) { return 0; }
EOF
test_cmd $strip $ASMSTRIPFLAGS "$@" $TMPO
}
check_stripflags(){
log check_stripflags "$@"
test_stripflags "$@" && add_stripflags "$@"
}
log check_header "$@"
headers=$1
disable_sanitized $headers
{
for hdr in $headers; do
print_include $hdr
done
echo "int x;"
} | test_cpp "$@" && enable_sanitized $headers
check_header_objcc(){
log check_header_objcc "$@"
rm -f -- "$TMPO"
header=$1
shift
disable_sanitized $header
{
echo "#include <$header>"
echo "int main(void) { return 0; }"
} | test_objcc && test_stat "$TMPO" && enable_sanitized $header
check_apple_framework(){
log check_apple_framework "$@"
framework="$1"
name="$(tolower $framework)"
header="${framework}/${framework}.h"
disable $name
check_header_objcc $header &&
enable $name && eval ${name}_extralibs='"-framework $framework"'
log check_func "$@"
test_ld "cc" "$@" <<EOF && enable $func
int main(void){ $func(); }
check_complexfunc(){
log check_complexfunc "$@"
func=$1
narg=$2
shift 2
test $narg = 2 && args="f, g" || args="f * I"
disable $func
test_ld "cc" "$@" <<EOF && enable $func
#include <complex.h>
#include <math.h>
float foo(complex float f, complex float g) { return $func($args); }
int main(void){ return (int) foo; }
EOF
}
narg=$2
shift 2
test $narg = 2 && args="f, g" || args="f"
disable $func
test_ld "cc" "$@" <<EOF && enable $func
#include <math.h>
float foo(float f, float g) { return $func($args); }
int main(void){ return (int) foo; }
EOF
}
check_func_headers(){
log check_func_headers "$@"
funcs=$2
{
for hdr in $headers; do
print_include $hdr
done
echo "#include <stdint.h>"
for func in $funcs; do
echo "long check_$func(void) { return (long) $func; }"
done
echo "int main(void) { int ret = 0;"
# LTO could optimize out the test functions without this
for func in $funcs; do
echo " ret |= ((intptr_t)check_$func) & 0xFFFF;"
done
echo "return ret; }"
} | test_ld "cc" "$@" && enable $funcs && enable_sanitized $headers
}
check_class_headers_cpp(){
log check_class_headers_cpp "$@"
headers=$1
classes=$2
shift 2
{
for hdr in $headers; do
echo "#include <$hdr>"
done
echo "int main(void) { "
i=1
for class in $classes; do
echo "$class obj$i;"
i=$(expr $i + 1)
done
echo "return 0; }"
} | test_ld "cxx" "$@" && enable $funcs && enable_sanitized $headers
test_cpp_condition(){
log test_cpp_condition "$@"
header=$1
condition=$2
shift 2
test_cpp "$@" <<EOF
#include <$header>
#if !($condition)
#error "unsatisfied condition: $condition"
#endif
EOF
}
Diego Biurrun
committed
check_cpp_condition(){
log check_cpp_condition "$@"
name=$1
shift 1
disable $name
test_cpp_condition "$@" && enable $name
}
Michael Niedermayer
committed
test_cflags_cc(){
log test_cflags_cc "$@"
Michael Niedermayer
committed
header=$2
condition=$3
shift 3
test_cc "$@" <<EOF
Michael Niedermayer
committed
#include <$header>
#if !($condition)
#error "unsatisfied condition: $condition"
#endif
EOF
}
check_lib(){
log check_lib "$@"
name="$1"
headers="$2"
funcs="$3"
shift 3
disable $name
check_func_headers "$headers" "$funcs" "$@" &&
enable $name && eval ${name}_extralibs="\$@"
name="$1"
headers="$2"
classes="$3"
shift 3
disable $name
check_class_headers_cpp "$headers" "$classes" "$@" &&
enable $name && eval ${name}_extralibs="\$@"
test_pkg_config(){
log test_pkg_config "$@"
name="$1"
pkg_version="$2"
pkg="${2%% *}"
headers="$3"
funcs="$4"
shift 4
disable $name
test_cmd $pkg_config --exists --print-errors $pkg_version || return
pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
enable $name &&
set_sanitized "${name}_cflags" $pkg_cflags &&
set_sanitized "${name}_extralibs" $pkg_libs
check_pkg_config(){
log check_pkg_config "$@"
name="$1"
test_pkg_config "$@" &&
eval add_cflags \$${name}_cflags
test_exec(){
test_ld "cc" "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
}
Diego Biurrun
committed
log check_exec_crash "$@"
code=$(cat)
# exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
# are safe but may not be available everywhere. Thus we use
# raise(SIGTERM) instead. The check is run in a subshell so we
# can redirect the "Terminated" message from the shell. SIGBUS
# is not defined by standard C so it is used conditionally.
(test_exec "$@") >> $logfile 2>&1 <<EOF
#include <signal.h>
static void sighandler(int sig){
raise(SIGTERM);
}
$code
}
signal(SIGILL, sighandler);
signal(SIGFPE, sighandler);
signal(SIGSEGV, sighandler);
#ifdef SIGBUS
signal(SIGBUS, sighandler);
#endif
check_type(){
log check_type "$@"
headers=$1
type=$2
shift 2
disable_sanitized "$type"
test_code cc "$headers" "$type v" "$@" && enable_sanitized "$type"
log check_struct "$@"
headers=$1
struct=$2
member=$3
shift 3
disable_sanitized "${struct}_${member}"
test_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
enable_sanitized "${struct}_${member}"
check_builtin(){
log check_builtin "$@"
name=$1
headers=$2
builtin=$3
shift 3
disable "$name"
test_code ld "$headers" "$builtin" "cc" "$@" && enable "$name"
check_compile_assert(){
log check_compile_assert "$@"
name=$1
headers=$2
condition=$3
shift 3
disable "$name"
test_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name"
Diego Biurrun
committed
check_cc(){
log check_cc "$@"
name=$1
shift
disable "$name"
test_code cc "$@" && enable "$name"
}
require(){
Diego Biurrun
committed
log require "$@"
Diego Biurrun
committed
name_version="$1"
name="${1%% *}"
Diego Biurrun
committed
shift
check_lib $name "$@" || die "ERROR: $name_version not found"
Diego Biurrun
committed
require_cc(){
log require_cc "$@"
name="$1"
shift
test_code cc "$@" || die "ERROR: $name failed"
}
require_cpp(){
name="$1"
headers="$2"
classes="$3"
shift 3
check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found"
}
log require_header "$@"
headers="$1"
Diego Biurrun
committed
check_header "$@" || die "ERROR: $headers not found"
require_cpp_condition(){
log require_cpp_condition "$@"
condition="$2"
test_cpp_condition "$@" || die "ERROR: $condition not satisfied"
require_pkg_config(){
Diego Biurrun
committed
log require_pkg_config "$@"
pkg_version="$2"
check_pkg_config "$@" || die "ERROR: $pkg_version not found using pkg-config$pkg_config_fail_message"
hostcc_e(){
eval printf '%s\\n' $HOSTCC_E
}
hostcc_o(){
eval printf '%s\\n' $HOSTCC_O
}
test_host_cc(){
log test_host_cc "$@"
test_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
test_host_cpp(){
log test_host_cpp "$@"
cat > $TMPC
log_file $TMPC
test_cmd $host_cc $host_cppflags $host_cflags "$@" $(hostcc_e $TMPO) $TMPC
check_host_cppflags(){
log check_host_cppflags "$@"
test_host_cpp "$@" <<EOF && append host_cppflags "$@"
#include <stdlib.h>
EOF
}
check_host_cflags(){
log check_host_cflags "$@"
set -- $($host_cflags_filter "$@")
test_host_cc "$@" <<EOF && append host_cflags "$@"
test_host_cpp_condition(){
log test_host_cpp_condition "$@"
header=$1
condition=$2
shift 2
test_host_cpp "$@" <<EOF
#include <$header>
#if !($condition)
#error "unsatisfied condition: $condition"
#endif
EOF
}
Diego Biurrun
committed
check_host_cpp_condition(){
log check_host_cpp_condition "$@"
name=$1
shift 1
disable $name
test_host_cpp_condition "$@" && enable $name
}
cp_if_changed(){
Diego Biurrun
committed
cmp -s "$1" "$2" && { test "$quiet" != "yes" && echo "$2 is unchanged"; } && return
Diego Biurrun
committed
# CONFIG_LIST contains configurable options, while HAVE_LIST is for
# system-dependent things.
AVCODEC_COMPONENTS="
bsfs
decoders
encoders
hwaccels
parsers
"
AVDEVICE_COMPONENTS="
indevs
outdevs
"
AVFILTER_COMPONENTS="
filters
"
AVFORMAT_COMPONENTS="
demuxers
muxers
protocols
"
COMPONENT_LIST="
$AVCODEC_COMPONENTS
$AVDEVICE_COMPONENTS
$AVFILTER_COMPONENTS
$AVFORMAT_COMPONENTS
"
EXAMPLE_LIST="
avio_dir_cmd_example
decode_audio_example
decode_video_example
encode_audio_example
encode_video_example
extract_mvs_example
filtering_audio_example
filtering_video_example
muxing_example
resampling_audio_example
scaling_video_example
EXTERNAL_AUTODETECT_LIBRARY_LIST="
bzlib
iconv
libxcb
libxcb_shm
libxcb_shape
libxcb_xfixes
lzma
schannel
sdl2
securetransport
xlib
zlib
"
EXTERNAL_LIBRARY_GPL_LIST="
librubberband
libvidstab
libx264
libx265
libxavs
libxvid
"
EXTERNAL_LIBRARY_NONFREE_LIST="
libndi_newtek
libfdk_aac
openssl
"
EXTERNAL_LIBRARY_VERSION3_LIST="
libopencore_amrnb
libopencore_amrwb
EXTERNAL_LIBRARY_GPLV3_LIST="
libsmbclient
"
EXTERNAL_LIBRARY_LIST="
$EXTERNAL_LIBRARY_GPL_LIST
$EXTERNAL_LIBRARY_NONFREE_LIST
$EXTERNAL_LIBRARY_VERSION3_LIST
$EXTERNAL_LIBRARY_GPLV3_LIST
gcrypt
libass
libbluray
libcaca
libcelt
libfreetype
libiec61883
libmodplug
libmp3lame
libopenjpeg
libopus
libpulse
libtwolame
libv4l2
libvorbis
libvpx
HWACCEL_AUTODETECT_LIBRARY_LIST="
cuda
cuvid
d3d11va
dxva2
nvenc
vaapi
vdpau
xvmc
"
# catchall list of things that require external libs to link
EXTRALIBS_LIST="
cpu_init
cws2fws
"
HWACCEL_LIBRARY_NONFREE_LIST="
cuda_sdk
libnpp
"
HWACCEL_LIBRARY_LIST="
$HWACCEL_LIBRARY_NONFREE_LIST
libmfx
mmal
omx
"
doc
htmlpages
manpages
podpages
txtpages
"
FEATURE_LIST="
gray
hardcoded_tables
runtime_cpudetect
safe_bitstream_reader
shared
small
static
swscale_alpha
"
LIBRARY_LIST="
avcodec
avdevice
avfilter
avformat
avresample
avutil
swresample
swscale
"
LICENSE_LIST="
gpl
nonfree
version3
"
ffmpeg
"
SUBSYSTEM_LIST="
error_resilience
fast_unaligned
lsp
network
rdft
"
# COMPONENT_LIST needs to come last to ensure correct dependency checking
$EXAMPLE_LIST
$EXTERNAL_LIBRARY_LIST
$EXTERNAL_AUTODETECT_LIBRARY_LIST
$HWACCEL_LIBRARY_LIST
$HWACCEL_AUTODETECT_LIBRARY_LIST
$FEATURE_LIST
$LICENSE_LIST
$LIBRARY_LIST
$SUBSYSTEM_LIST
fontconfig
neon_clobber_test
ossfuzz
valgrind_backtrace
$COMPONENT_LIST
pthreads
w32threads
AUTODETECT_LIBS="
$EXTERNAL_AUTODETECT_LIBRARY_LIST
$HWACCEL_AUTODETECT_LIBRARY_LIST
$THREADS_LIST
"
alpha
avr32
avr32_ap
avr32_uc
bfin
ia64
m68k
mips
parisc
s390
sh4
sparc
sparc64
x86
x86_32
x86_64
armv5te
armv6
armv6t2
ARCH_EXT_LIST_MIPS="
mipsfpu
mips32r2
"
ARCH_EXT_LIST_LOONGSON="
amd3dnow
amd3dnowext
avx2
fma4
mmx
mmxext
sse
sse2
sse3
sse4
sse42
ssse3
ARCH_EXT_LIST_PPC="
altivec
dcbzl
ldbrx
vsx
ARCH_EXT_LIST_X86="
$ARCH_EXT_LIST_X86_SIMD
cpunop
i686
"
ARCH_EXT_LIST="
$ARCH_EXT_LIST_ARM
$ARCH_EXT_LIST_PPC
$ARCH_EXT_LIST_X86
$ARCH_EXT_LIST_MIPS
$ARCH_EXT_LIST_LOONGSON
ARCH_FEATURES="
aligned_stack
fast_64bit
fast_clz
fast_cmov
simd_align_16
BUILTIN_LIST="
atomic_cas_ptr
machine_rw_barrier
MemoryBarrier
mm_empty
rdtsc
sem_timedwait
sync_val_compare_and_swap
"
inline_asm
symver
HEADERS_LIST="
arpa_inet_h
asm_types_h
cdio_paranoia_h
cdio_paranoia_paranoia_h
dispatch_dispatch_h
dev_bktr_ioctl_bt848_h
dev_bktr_ioctl_meteor_h
dev_ic_bt8xx_h
dev_video_bktr_ioctl_bt848_h
dev_video_meteor_ioctl_meteor_h
direct_h
io_h
machine_ioctl_bt848_h
machine_ioctl_meteor_h