Newer
Older
echo "#include $hdr" ||
echo "#include <$hdr>"
}
check_code(){
log check_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; }"
} | check_$check "$@"
}
check_cppflags(){
log check_cppflags "$@"
check_cc "$@" <<EOF && append CPPFLAGS "$@"
int x;
EOF
}
test_cflags(){
log test_cflags "$@"
set -- $($cflags_filter "$@")
check_cc "$@" <<EOF
check_cflags(){
log check_cflags "$@"
test_cflags "$@" && add_cflags "$@"
}
set -- $($cflags_filter "$@")
check_cxx "$@" <<EOF && append CXXFLAGS "$@"
int x;
EOF
}
test_objcflags(){
log test_cflags "$@"
set -- $($cflags_filter "$@")
check_objcc "$@" <<EOF
int x;
EOF
}
check_objcflags(){
log check_cflags "$@"
test_objcflags "$@" && add_objcflags "$@"
}
test_ldflags(){
log test_ldflags "$@"
int main(void){ return 0; }
check_ldflags(){
log check_ldflags "$@"
test_ldflags "$@" && add_ldflags "$@"
}
test_stripflags(){
log test_stripflags "$@"
# call check_cc to get a fresh TMPO
check_cc <<EOF
int main(void) { return 0; }
EOF
check_cmd $strip $ASMSTRIPFLAGS "$@" $TMPO
}
check_stripflags(){
log check_stripflags "$@"
test_stripflags "$@" && add_stripflags "$@"
}
log check_header "$@"
disable_safe $header
check_cpp "$@" <<EOF && enable_safe $header
#include <$header>
int x;
EOF
}
check_header_objcc(){
log check_header_objcc "$@"
rm -f -- "$TMPO"
header=$1
shift
disable_safe $header
{
echo "#include <$header>"
echo "int main(void) { return 0; }"
} | check_objcc && check_stat "$TMPO" && enable_safe $headers
log check_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
check_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
check_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; }"
} | check_ld "cc" "$@" && enable $funcs && enable_safe $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; }"
} | check_ld "cxx" "$@" && enable $funcs && enable_safe $headers
check_cpp_condition(){
log check_cpp_condition "$@"
header=$1
condition=$2
shift 2
#include <$header>
#if !($condition)
#error "unsatisfied condition: $condition"
#endif
EOF
}
Michael Niedermayer
committed
test_cflags_cc(){
log test_cflags_cc "$@"
Michael Niedermayer
committed
header=$2
condition=$3
shift 3
Michael Niedermayer
committed
check_cc "$@" <<EOF
#include <$header>
#if !($condition)
#error "unsatisfied condition: $condition"
#endif
EOF
}
check_lib(){
log check_lib "$@"
funcs="$2"
check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
check_lib_cpp(){
log check_lib_cpp "$@"
headers="$1"
classes="$2"
shift 2
check_class_headers_cpp "$headers" "$classes" "$@" && add_extralibs "$@"
}
check_pkg_config(){
log check_pkg_config "$@"
pkgandversion="$1"
pkg="${1%% *}"
headers="$2"
funcs="$3"
shift 3
check_cmd $pkg_config --exists --print-errors $pkgandversion || 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 "$@" &&
set_safe "${pkg}_cflags" $pkg_cflags &&
set_safe "${pkg}_libs" $pkg_libs
check_ld "cc" "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
}
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.
(check_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_safe "$type"
check_code cc "$headers" "$type v" "$@" && enable_safe "$type"
log check_struct "$@"
headers=$1
struct=$2
member=$3
shift 3
disable_safe "${struct}_${member}"
check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
enable_safe "${struct}_${member}"
check_builtin(){
log check_builtin "$@"
name=$1
headers=$2
builtin=$3
shift 3
disable "$name"
check_code ld "$headers" "$builtin" "cc" "$@" && enable "$name"
check_compile_assert(){
log check_compile_assert "$@"
name=$1
headers=$2
condition=$3
shift 3
disable "$name"
check_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name"
}
require(){
name="$1"
headers="$2"
func="$3"
shift 3
check_lib "$headers" $func "$@" || die "ERROR: $name not found"
require_cpp(){
name="$1"
headers="$2"
classes="$3"
shift 3
check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found"
}
use_pkg_config(){
check_pkg_config "$@" || return 1
add_cflags $(get_safe "${pkg}_cflags")
add_extralibs $(get_safe "${pkg}_libs")
require_pkg_config(){
use_pkg_config "$@" || die "ERROR: $pkg not found using pkg-config$pkg_config_fail_message"
require_libfreetype(){
log require_libfreetype "$@"
pkg="freetype2"
check_cmd $pkg_config --exists --print-errors $pkg \
|| die "ERROR: $pkg not found"
pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
{
echo "#include <ft2build.h>"
echo "#include FT_FREETYPE_H"
echo "long check_func(void) { return (long) FT_Init_FreeType; }"
echo "int main(void) { return 0; }"
} | check_ld "cc" $pkg_cflags $pkg_libs \
&& set_safe "${pkg}_cflags" $pkg_cflags \
&& set_safe "${pkg}_libs" $pkg_libs \
|| die "ERROR: $pkg not found"
add_cflags $(get_safe "${pkg}_cflags")
add_extralibs $(get_safe "${pkg}_libs")
hostcc_e(){
eval printf '%s\\n' $HOSTCC_E
}
hostcc_o(){
eval printf '%s\\n' $HOSTCC_O
}
check_host_cc(){
log check_host_cc "$@"
cat > $TMPC
log_file $TMPC
check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
check_host_cpp(){
log check_host_cpp "$@"
cat > $TMPC
log_file $TMPC
check_cmd $host_cc $host_cppflags $host_cflags "$@" $(hostcc_e $TMPO) $TMPC
check_host_cppflags(){
log check_host_cppflags "$@"
check_host_cc "$@" <<EOF && append host_cppflags "$@"
int x;
EOF
}
check_host_cflags(){
log check_host_cflags "$@"
set -- $($host_cflags_filter "$@")
check_host_cc "$@" <<EOF && append host_cflags "$@"
int x;
EOF
}
check_host_cpp_condition(){
log check_host_cpp_condition "$@"
header=$1
condition=$2
shift 2
check_host_cpp "$@" <<EOF
#include <$header>
#if !($condition)
#error "unsatisfied condition: $condition"
#endif
EOF
}
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
"
AVRESAMPLE_COMPONENTS=""
AVUTIL_COMPONENTS=""
COMPONENT_LIST="
$AVCODEC_COMPONENTS
$AVDEVICE_COMPONENTS
$AVFILTER_COMPONENTS
$AVFORMAT_COMPONENTS
$AVRESAMPLE_COMPONENTS
$AVUTIL_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
sdl
sdl2
securetransport
xlib
zlib
"
EXTERNAL_LIBRARY_GPL_LIST="
librubberband
libvidstab
libx264
libx265
libxavs
libxvid
"
EXTERNAL_LIBRARY_NONFREE_LIST="
libfdk_aac
openssl
"
EXTERNAL_LIBRARY_VERSION3_LIST="
libopencore_amrnb
libopencore_amrwb
libvo_amrwbenc
"
EXTERNAL_LIBRARY_GPLV3_LIST="
libsmbclient
"
EXTERNAL_LIBRARY_LIST="
$EXTERNAL_AUTODETECT_LIBRARY_LIST
$EXTERNAL_LIBRARY_GPL_LIST
$EXTERNAL_LIBRARY_NONFREE_LIST
$EXTERNAL_LIBRARY_VERSION3_LIST
$EXTERNAL_LIBRARY_GPLV3_LIST
crystalhd
gcrypt
libass
libbluray
libcaca
libcelt
libfreetype
libiec61883
libmodplug
libmp3lame
libopenjpeg
libopus
libpulse
librtmp
libschroedinger
libtwolame
libv4l2
libvorbis
libvpx
HWACCEL_AUTODETECT_LIBRARY_LIST="
audiotoolbox
cuda
cuvid
d3d11va
dxva2
nvenc
vaapi
vda
vdpau
videotoolbox_hwaccel
xvmc
"
HWACCEL_LIBRARY_NONFREE_LIST="
libnpp
"
HWACCEL_LIBRARY_LIST="
$HWACCEL_AUTODETECT_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
"
ffplay
ffprobe
ffserver
ffmpeg
"
SUBSYSTEM_LIST="
error_resilience
fast_unaligned
lsp
network
rdft
"
CONFIG_LIST="
$COMPONENT_LIST
$EXAMPLE_LIST
$EXTERNAL_LIBRARY_LIST
$HWACCEL_LIBRARY_LIST
$FEATURE_LIST
$LICENSE_LIST
$LIBRARY_LIST
$SUBSYSTEM_LIST
fontconfig
neon_clobber_test
valgrind_backtrace
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
local_aligned_8
local_aligned_16
simd_align_16
BUILTIN_LIST="
atomic_cas_ptr
machine_rw_barrier
MemoryBarrier
mm_empty
rdtsc
sarestart
sem_timedwait
sync_val_compare_and_swap
"
inline_asm
symver
yasm
HEADERS_LIST="
alsa_asoundlib_h
altivec_h
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
gsm_h
io_h
mach_mach_time_h
machine_ioctl_bt848_h
machine_ioctl_meteor_h
malloc_h
openjpeg_2_1_openjpeg_h
openjpeg_2_0_openjpeg_h
openjpeg_1_5_openjpeg_h
OpenGL_gl3_h
poll_h
sndio_h
soundcard_h
sys_mman_h
sys_param_h
sys_resource_h
sys_select_h
sys_soundcard_h
sys_time_h
sys_un_h
sys_videoio_h
termios_h
valgrind_valgrind_h
windows_h
winsock2_h
"
INTRINSICS_LIST="
intrinsics_neon
"
COMPLEX_FUNCS="
cabs
cexp
"
atanf
atan2f
exp2
exp2f
isinf
isnan
llrint
llrintf
log2
log2f
lrint
lrintf
rint
round
roundf
trunc
truncf
"
aligned_malloc
CommandLineToArgvW
Martin Storsjö
committed
getaddrinfo
getopt
GetProcessMemoryInfo
GetProcessTimes
jack_port_get_latency_range
localtime_r
Diego Biurrun
committed
lzo1x_999_compress
mach_absolute_time
SetConsoleTextAttribute
SetConsoleCtrlHandler
setmode
sysconf
sysctl
usleep
wglGetProcAddress
"
TOOLCHAIN_FEATURES="