Newer
Older
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
}
test_cflags_cpp(){
log test_cflags_cpp "$@"
flags=$1
condition=$2
shift 2
set -- $($cflags_filter "$flags")
test_cpp "$@" <<EOF
#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="\$@"
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(){
log test_exec "$@"
test_ld "$@" && { 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);
}
int foo(void){
$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
Diego Biurrun
committed
shift
test_code ld "$@" && 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"
}
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"
Diego Biurrun
committed
log require_pkg_config "$@"
pkg_version="$2"
Diego Biurrun
committed
check_pkg_config "$@" || die "ERROR: $pkg_version not found"
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="
"
AVFILTER_COMPONENTS="
filters
"
AVFORMAT_COMPONENTS="
demuxers
muxers
protocols
"
COMPONENT_LIST="
$AVCODEC_COMPONENTS
$AVDEVICE_COMPONENTS
$AVFILTER_COMPONENTS
$AVFORMAT_COMPONENTS
"
EXAMPLE_LIST="
decode_audio_example
decode_video_example
encode_audio_example
encode_video_example
output_example
# catchall list of things that require external libs to link
EXTRALIBS_LIST="
cpu_init
cws2fws
"
HWACCEL_LIBRARY_NONFREE_LIST="
cuda
libnpp
"
HWACCEL_LIBRARY_LIST="
$HWACCEL_LIBRARY_NONFREE_LIST
Michael Wootton
committed
amf
d3d11va
dxva2
libmfx
mmal
nvenc
omx
vaapi
vda
vdpau
"
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
EXTERNAL_LIBRARY_GPL_LIST="
libcdio
libx264
libx265
libxavs
libxvid
"
EXTERNAL_LIBRARY_NONFREE_LIST="
libfaac
libfdk_aac
openssl
"
EXTERNAL_LIBRARY_VERSION3_LIST="
libopencore_amrnb
libopencore_amrwb
libvo_aacenc
libvo_amrwbenc
"
EXTERNAL_LIBRARY_LIST="
$EXTERNAL_LIBRARY_GPL_LIST
$EXTERNAL_LIBRARY_NONFREE_LIST
$EXTERNAL_LIBRARY_VERSION3_LIST
frei0r
gnutls
libfreetype
libgsm
libhdcd
libmp3lame
libopencv
libopenjpeg
libopus
libpulse
librtmp
libschroedinger
libspeex
libtheora
libvorbis
libvpx
libxcb
libxcb_shm
libxcb_xfixes
"
SYSTEM_LIBRARY_LIST="
bzlib
zlib
"
FEATURE_LIST="
gray
hardcoded_tables
runtime_cpudetect
safe_bitstream_reader
shared
small
sram
static
swscale_alpha
"
LIBRARY_LIST="
avcodec
avdevice
avfilter
avformat
avresample
avutil
swscale
"
LICENSE_LIST="
gpl
nonfree
version3
"
PROGRAM_LIST="
avconv
avplay
avprobe
"
SUBSYSTEM_LIST="
doc
error_resilience
lsp
network
rdft
"
# COMPONENT_LIST needs to come last to ensure correct dependency checking
CONFIG_LIST="
$EXAMPLE_LIST
$EXTERNAL_LIBRARY_LIST
$HWACCEL_LIBRARY_LIST
$FEATURE_LIST
$LICENSE_LIST
$LIBRARY_LIST
$PROGRAM_LIST
$SUBSYSTEM_LIST
$SYSTEM_LIBRARY_LIST
neon_clobber_test
texi2html
valgrind_backtrace
$COMPONENT_LIST
pthreads
w32threads
alpha
avr32
avr32_ap
avr32_uc
bfin
ia64
m68k
mips
parisc
s390
sh4
sparc
sparc64
x86
x86_32
x86_64
armv5te
armv6
armv6t2
amd3dnow
amd3dnowext
fma4
mmx
mmxext
sse
sse2
sse3
sse4
sse42
ssse3
ARCH_EXT_LIST_PPC="
altivec
dcbzl
ldbrx
ARCH_EXT_LIST_X86="
$ARCH_EXT_LIST_X86_SIMD
cpunop
i686
"
ARCH_EXT_LIST_MIPS="
loongson
mips32r1
mips64r1
mips32r2
mips64r2
mips32r6
mips64r6
"
ARCH_EXT_LIST="
$ARCH_EXT_LIST_ARM
$ARCH_EXT_LIST_PPC
$ARCH_EXT_LIST_X86
ARCH_FEATURES="
aligned_stack
fast_64bit
fast_clz
fast_cmov
local_aligned_8
local_aligned_16
simd_align_16
"
BUILTIN_LIST="
atomic_cas_ptr
machine_rw_barrier
MemoryBarrier
mm_empty
rdtsc
sync_val_compare_and_swap
"
inline_asm
symver
arpa_inet_h
cdio_paranoia_h
cdio_paranoia_paranoia_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
dxva_h
io_h
machine_ioctl_bt848_h
machine_ioctl_meteor_h
malloc_h
poll_h
sys_param_h
sys_resource_h
sys_select_h
sys_soundcard_h
sys_time_h
sys_un_h
sys_videoio_h
unistd_h
valgrind_valgrind_h
windows_h
winsock2_h
"
INTRINSICS_LIST="
intrinsics_neon
"
atanf
atan2f
exp2
exp2f
isinf
isnan
llrint
llrintf
log2
log2f
lrint
lrintf
rint
round
roundf
trunc
truncf
"
SYSTEM_FEATURES="
dos_paths
libc_msvcrt
MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS
section_data_rel_ro
threads
uwp
"
aligned_malloc
clock_gettime
CommandLineToArgvW
Martin Storsjö
committed
getaddrinfo
getopt
GetProcessMemoryInfo
GetProcessTimes
localtime_r
mach_absolute_time
SetConsoleTextAttribute
setmode
sysconf
sysctl
usleep
VirtualAlloc
"
SYSTEM_LIBRARIES="
sdl
vaapi_drm
vaapi_x11
vdpau_x11
wincrypt
"
TOOLCHAIN_FEATURES="
blocks_extension
ebp_available
ebx_available
gnu_as
ibm_asm
inline_asm_labels
pragma_deprecated
symver_asm_label
symver_gnu_asm
vfp_args
xform_asm
xmm_clobbers
"
TYPES_LIST="
CONDITION_VARIABLE_Ptr
struct_addrinfo
struct_group_source_req
struct_ip_mreq_source
struct_ipv6_mreq
struct_rusage_ru_maxrss
struct_sockaddr_in6
Ronald S. Bultje
committed
struct_sockaddr_sa_len
struct_sockaddr_storage
"
HAVE_LIST="
$ARCH_EXT_LIST
$(add_suffix _external $ARCH_EXT_LIST)
$(add_suffix _inline $ARCH_EXT_LIST)
$ARCH_FEATURES
$BUILTIN_LIST
$HAVE_LIST_CMDLINE
$HAVE_LIST_PUB
$HEADERS_LIST
$SYSTEM_FEATURES
$SYSTEM_LIBRARIES
$THREADS_LIST
$TOOLCHAIN_FEATURES
$TYPES_LIST
"
# options emitted with CONFIG_ prefix but not available on the command line
aandcttables
ac3dsp
adts_header
blockdsp
dirac_parse
faandct
faanidct
golomb
h264chroma
h264dsp
h264pred
hpeldsp
huffman
huffyuvdsp
huffyuvencdsp
jpegtables
libx262
libxcb_shape
lpc
me_cmp
mpegaudiodsp
mpegaudioheader
mpegvideo
mpegvideoenc
pixblockdsp
rangecoder
rtpdec
sinewin
startcode
$ARCH_EXT_LIST
$HAVE_LIST_CMDLINE
$THREADS_LIST
logging
optimizations
incdir
libdir
mandir
prefix
shlibdir
CMDLINE_SET="
$PATHS_LIST
cpu
cross_prefix
extra_version
host_extralibs
ignore_tests
malloc_prefix
sysinclude
sysroot
CMDLINE_APPEND="
extra_cflags
host_cppflags
armv5te_deps="arm"
armv6_deps="arm"
neon_deps_any="aarch64 arm"
vfp_deps_any="aarch64 arm"
map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
dcbzl_deps="ppc"
ldbrx_deps="ppc"
vsx_deps="altivec"
power8_deps="vsx"
loongson_deps="mips"
mips32r1_deps="mips32"
mips32r2_deps="mips32"
mips32r6_deps="mips32"
mips64r1_deps="mips64"
mips64r2_deps="mips64"
mips64r6_deps="mips64"
vis_deps="sparc"
cpunop_deps="i686"
x86_64_select="i686"
x86_64_suggest="fast_cmov"
amd3dnow_deps="mmx"
amd3dnowext_deps="amd3dnow"
sse_deps="mmxext"
sse2_deps="sse"
sse3_deps="sse2"
ssse3_deps="sse3"
sse4_deps="ssse3"
sse42_deps="sse4"
avx_deps="sse42"
fma4_deps="avx"
mmx_external_deps="x86asm"
mmx_inline_deps="inline_asm x86"
mmx_suggest="mmx_external mmx_inline"
for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD); do
eval dep=\$${ext}_deps
eval ${ext}_external_deps='"${dep}_external"'
eval ${ext}_inline_deps='"${dep}_inline"'
eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
done
aligned_stack_if_any="aarch64 ppc x86"
fast_64bit_if_any="aarch64 alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
fast_clz_if_any="aarch64 alpha avr32 mips ppc x86"
fast_unaligned_if_any="aarch64 ppc x86"
simd_align_16_if_any="altivec neon sse"
simd_align_32_if_any="avx"
# system capabilities
symver_if_any="symver_asm_label symver_gnu_asm"
valgrind_backtrace_conflict="optimizations"
valgrind_backtrace_deps="valgrind_valgrind_h"
# threading support
atomics_gcc_if="sync_val_compare_and_swap"
atomics_suncc_if="atomic_cas_ptr machine_rw_barrier"
atomics_win32_if="MemoryBarrier"
atomics_native_if_any="$ATOMICS_LIST"
w32threads_deps="atomics_native"
threads_if_any="$THREADS_LIST"
# subsystems
cbs_h264_select="cbs golomb"
cbs_h265_select="cbs golomb"
cbs_mpeg2_select="cbs"
dirac_parse_select="golomb"
error_resilience_select="me_cmp"
faandct_deps="faan"
faandct_select="fdctdsp"
faanidct_deps="faan"
faanidct_select="idctdsp"