append CXXFLAGS $($cflags_filter "$@")
}
-add_asflags(){
- append ASFLAGS $($asflags_filter "$@")
-}
-
add_objcflags(){
append OBJCFLAGS $($objcflags_filter "$@")
}
+add_asflags(){
+ append ASFLAGS $($asflags_filter "$@")
+}
+
add_ldflags(){
append LDFLAGS $($ldflags_filter "$@")
}
append LDSOFLAGS $($ldflags_filter "$@")
}
-add_stripflags(){
- append ASMSTRIPFLAGS "$@"
-}
-
add_extralibs(){
prepend extralibs $($ldflags_filter "$@")
}
+add_stripflags(){
+ append ASMSTRIPFLAGS "$@"
+}
+
add_host_cppflags(){
append host_cppflags "$@"
}
stat "$1" >> $logfile 2>&1
}
+cc_e(){
+ eval printf '%s\\n' $CC_E
+}
+
cc_o(){
eval printf '%s\\n' $CC_O
}
-cc_e(){
- eval printf '%s\\n' $CC_E
+as_o(){
+ eval printf '%s\\n' $AS_O
+}
+
+x86asm_o(){
+ eval printf '%s\\n' $X86ASM_O
+}
+
+ld_o(){
+ eval printf '%s\\n' $LD_O
+}
+
+hostcc_e(){
+ eval printf '%s\\n' $HOSTCC_E
+}
+
+hostcc_o(){
+ eval printf '%s\\n' $HOSTCC_O
}
test_cc(){
test_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
}
-as_o(){
- eval printf '%s\\n' $AS_O
-}
-
test_as(){
log test_as "$@"
cat > $TMPS
test_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
}
-x86asm_o(){
- eval printf '%s\\n' $X86ASM_O
-}
-
test_x86asm(){
log test_x86asm "$@"
echo "$1" > $TMPASM
test_x86asm "$@" && enable $name
}
-ld_o(){
- eval printf '%s\\n' $LD_O
-}
-
test_ld(){
log test_ld "$@"
type=$1
test_stripflags "$@" && add_stripflags "$@"
}
-check_header(){
- log check_header "$@"
+check_headers(){
+ log check_headers "$@"
headers=$1
shift
disable_sanitized $headers
require_cc(){
log require_cc "$@"
name="$1"
- shift
- test_code cc "$@" || die "ERROR: $name failed"
+ check_cc "$@" || die "ERROR: $name failed"
}
require_cpp(){
check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found"
}
-require_header(){
- log require_header "$@"
+require_headers(){
+ log require_headers "$@"
headers="$1"
- check_header "$@" || die "ERROR: $headers not found"
+ check_headers "$@" || die "ERROR: $headers not found"
}
require_cpp_condition(){
log require_cpp_condition "$@"
- condition="$2"
- test_cpp_condition "$@" || die "ERROR: $condition not satisfied"
+ condition="$3"
+ check_cpp_condition "$@" || die "ERROR: $condition not satisfied"
}
require_pkg_config(){
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 "$@"
cat > $TMPC
swscale_alpha
"
+# this list should be kept in linking order
LIBRARY_LIST="
- avcodec
avdevice
avfilter
+ swscale
+ postproc
avformat
+ avcodec
+ swresample
avresample
avutil
- postproc
- swresample
- swscale
"
LICENSE_LIST="
ra_144_decoder_select="audiodsp"
ra_144_encoder_select="audio_frame_queue lpc audiodsp"
ralf_decoder_select="golomb"
+rasc_decoder_deps="zlib"
rawvideo_decoder_select="bswapdsp"
rscc_decoder_deps="zlib"
rtjpeg_decoder_select="me_cmp"
https_protocol_select="tls_protocol"
https_protocol_suggest="zlib"
icecast_protocol_select="http_protocol"
-librtmp_protocol_deps="librtmp"
-librtmpe_protocol_deps="librtmp"
-librtmps_protocol_deps="librtmp"
-librtmpt_protocol_deps="librtmp"
-librtmpte_protocol_deps="librtmp"
-libsmbclient_protocol_deps="libsmbclient gplv3"
-libssh_protocol_deps="libssh"
-libtls_conflict="openssl gnutls mbedtls"
mmsh_protocol_select="http_protocol"
mmst_protocol_select="network"
-libsrt_protocol_deps="libsrt"
-libsrt_protocol_select="network"
rtmp_protocol_conflict="librtmp_protocol"
rtmp_protocol_select="tcp_protocol"
rtmp_protocol_suggest="zlib"
unix_protocol_deps="sys_un_h"
unix_protocol_select="network"
+# external library protocols
+librtmp_protocol_deps="librtmp"
+librtmpe_protocol_deps="librtmp"
+librtmps_protocol_deps="librtmp"
+librtmpt_protocol_deps="librtmp"
+librtmpte_protocol_deps="librtmp"
+libsmbclient_protocol_deps="libsmbclient gplv3"
+libsrt_protocol_deps="libsrt"
+libsrt_protocol_select="network"
+libssh_protocol_deps="libssh"
+libtls_conflict="openssl gnutls mbedtls"
+
# filters
afftfilt_filter_deps="avcodec"
afftfilt_filter_select="fft"
cpu_init_extralibs="pthreads_extralibs"
cws2fws_extralibs="zlib_extralibs"
-# libraries, in linking order
+# libraries, in any order
avcodec_deps="avutil"
avcodec_suggest="libm"
avcodec_select="null_bsf"
disable mipsfpu
disable mipsdsp
disable mipsdspr2
+ # When gcc version less than 5.3.0, add -fno-expensive-optimizations flag.
+ if [ $cc == gcc ]; then
+ gcc_version=$(gcc -dumpversion)
+ if [ "$(echo "$gcc_version 5.3.0" | tr " " "\n" | sort -rV | head -n 1)" == "$gcc_version" ]; then
+ expensive_optimization_flag=""
+ else
+ expensive_optimization_flag="-fno-expensive-optimizations"
+ fi
+ fi
case $cpu in
loongson3*)
- cpuflags="-march=loongson3a -mhard-float -fno-expensive-optimizations"
+ cpuflags="-march=loongson3a -mhard-float $expensive_optimization_flag"
;;
loongson2e)
- cpuflags="-march=loongson2e -mhard-float -fno-expensive-optimizations"
+ cpuflags="-march=loongson2e -mhard-float $expensive_optimization_flag"
;;
loongson2f)
- cpuflags="-march=loongson2f -mhard-float -fno-expensive-optimizations"
+ cpuflags="-march=loongson2f -mhard-float $expensive_optimization_flag"
;;
esac
;;
enabled x86_64 && objformat="macho64" || objformat="macho32"
enabled_any pic shared x86_64 ||
{ check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
- check_header dispatch/dispatch.h &&
+ check_headers dispatch/dispatch.h &&
add_cppflags '-I\$(SRC_PATH)/compat/dispatch_semaphore'
if test -n "$sysroot"; then
is_in -isysroot $cc $CPPFLAGS $CFLAGS || check_cppflags -isysroot $sysroot
enabled mipsfpu && check_inline_asm_flags mipsfpu '"cvt.d.l $f0, $f2"' '-mhard-float'
enabled mipsfpu && (enabled mips32r5 || enabled mips32r6 || enabled mips64r6) && check_inline_asm_flags mipsfpu '"cvt.d.l $f0, $f1"' '-mfp64'
- enabled mipsfpu && enabled msa && check_inline_asm_flags msa '"addvi.b $w0, $w1, 1"' '-mmsa' && check_header msa.h || disable msa
+ enabled mipsfpu && enabled msa && check_inline_asm_flags msa '"addvi.b $w0, $w1, 1"' '-mmsa' && check_headers msa.h || disable msa
enabled mipsdsp && check_inline_asm_flags mipsdsp '"addu.qb $t0, $t1, $t2"' '-mdsp'
enabled mipsdspr2 && check_inline_asm_flags mipsdspr2 '"absq_s.qb $t0, $t1"' '-mdspr2'
check_type "sys/types.h sys/socket.h" socklen_t
# Prefer arpa/inet.h over winsock2
- if check_header arpa/inet.h ; then
+ if check_headers arpa/inet.h ; then
check_func closesocket
- elif check_header winsock2.h ; then
+ elif check_headers winsock2.h ; then
check_func_headers winsock2.h closesocket -lws2 &&
network_extralibs="-lws2" ||
{ check_func_headers winsock2.h closesocket -lws2_32 &&
enabled xlib &&
check_lib xlib "X11/Xlib.h X11/extensions/Xvlib.h" XvGetPortAttribute -lXv -lX11 -lXext
-check_header direct.h
-check_header dirent.h
-check_header dxgidebug.h
-check_header dxva.h
-check_header dxva2api.h -D_WIN32_WINNT=0x0600
-check_header io.h
-check_header linux/perf_event.h
-check_header libcrystalhd/libcrystalhd_if.h
-check_header malloc.h
-check_header net/udplite.h
-check_header poll.h
-check_header sys/param.h
-check_header sys/resource.h
-check_header sys/select.h
-check_header sys/time.h
-check_header sys/un.h
-check_header termios.h
-check_header unistd.h
-check_header valgrind/valgrind.h
+check_headers direct.h
+check_headers dirent.h
+check_headers dxgidebug.h
+check_headers dxva.h
+check_headers dxva2api.h -D_WIN32_WINNT=0x0600
+check_headers io.h
+check_headers linux/perf_event.h
+check_headers libcrystalhd/libcrystalhd_if.h
+check_headers malloc.h
+check_headers net/udplite.h
+check_headers poll.h
+check_headers sys/param.h
+check_headers sys/resource.h
+check_headers sys/select.h
+check_headers sys/time.h
+check_headers sys/un.h
+check_headers termios.h
+check_headers unistd.h
+check_headers valgrind/valgrind.h
check_func_headers VideoToolbox/VTCompressionSession.h VTCompressionSessionPrepareToEncodeFrames -framework VideoToolbox
-check_header windows.h
-check_header X11/extensions/XvMClib.h
-check_header asm/types.h
+check_headers windows.h
+check_headers X11/extensions/XvMClib.h
+check_headers asm/types.h
# it seems there are versions of clang in some distros that try to use the
# gcc headers, which explodes for stdatomic
# these are off by default, so fail if requested and not available
enabled cuda_sdk && require cuda_sdk cuda.h cuCtxCreate -lcuda
enabled chromaprint && require chromaprint chromaprint.h chromaprint_get_version -lchromaprint
-enabled decklink && { require_header DeckLinkAPI.h &&
+enabled decklink && { require_headers DeckLinkAPI.h &&
{ test_cpp_condition DeckLinkAPIVersion.h "BLACKMAGIC_DECKLINK_API_VERSION >= 0x0a060100" || die "ERROR: Decklink API version must be >= 10.6.1."; } }
-enabled libndi_newtek && require_header Processing.NDI.Lib.h
-enabled frei0r && require_header frei0r.h
+enabled libndi_newtek && require_headers Processing.NDI.Lib.h
+enabled frei0r && require_headers frei0r.h
enabled gmp && require gmp gmp.h mpz_export -lgmp
enabled gnutls && require_pkg_config gnutls gnutls gnutls/gnutls.h gnutls_global_init
-enabled jni && { [ $target_os = "android" ] && check_header jni.h && enabled pthreads || die "ERROR: jni not found"; }
-enabled ladspa && require_header ladspa.h
+enabled jni && { [ $target_os = "android" ] && check_headers jni.h && enabled pthreads || die "ERROR: jni not found"; }
+enabled ladspa && require_headers ladspa.h
enabled libaom && require_pkg_config libaom "aom >= 1.0.0" aom/aom_codec.h aom_codec_version
enabled lv2 && require_pkg_config lv2 lilv-0 "lilv/lilv.h" lilv_world_new
enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883
die "ERROR: libnpp not found"; }
enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
-enabled libopencv && { check_header opencv2/core/core_c.h &&
+enabled libopencv && { check_headers opencv2/core/core_c.h &&
{ check_pkg_config libopencv opencv opencv2/core/core_c.h cvCreateImageHeader ||
require libopencv opencv2/core/core_c.h cvCreateImageHeader -lopencv_core -lopencv_imgproc; } ||
require_pkg_config libopencv opencv opencv/cxcore.h cvCreateImageHeader; }
enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr
enabled libssh && require_pkg_config libssh libssh libssh/sftp.h sftp_init
enabled libspeex && require_pkg_config libspeex speex speex/speex.h speex_decoder_init
-enabled libsrt && require_pkg_config libsrt "srt >= 1.2.0" srt/srt.h srt_socket
+enabled libsrt && require_pkg_config libsrt "srt >= 1.3.0" srt/srt.h srt_socket
enabled libtensorflow && require libtensorflow tensorflow/c/c_api.h TF_Version -ltensorflow
enabled libtesseract && require_pkg_config libtesseract tesseract tesseract/capi.h TessBaseAPICreate
enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
enabled libx264 && { check_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode ||
{ require libx264 "stdint.h x264.h" x264_encoder_encode "-lx264 $pthreads_extralibs $libm_extralibs" &&
warn "using libx264 without pkg-config"; } } &&
- require_cpp_condition x264.h "X264_BUILD >= 118" &&
+ require_cpp_condition libx264 x264.h "X264_BUILD >= 118" &&
check_cpp_condition libx262 x264.h "X264_MPEG2"
enabled libx265 && require_pkg_config libx265 x265 x265.h x265_api_get &&
- require_cpp_condition x265.h "X265_BUILD >= 68"
+ require_cpp_condition libx265 x265.h "X265_BUILD >= 68"
enabled libxavs && require libxavs "stdint.h xavs.h" xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
enabled libzimg && require_pkg_config libzimg "zimg >= 2.7.0" zimg.h zimg_get_api_version
check_lib opengl ES2/gl.h glGetError "-isysroot=${sysroot} -Wl,-framework,OpenGLES" ||
die "ERROR: opengl not found."
}
-enabled omx && require_header OMX_Core.h
-enabled omx_rpi && { check_header OMX_Core.h ||
- { ! enabled cross_compile && add_cflags -isystem/opt/vc/include/IL && check_header OMX_Core.h ; } ||
+enabled omx && require_headers OMX_Core.h
+enabled omx_rpi && { check_headers OMX_Core.h ||
+ { ! enabled cross_compile && add_cflags -isystem/opt/vc/include/IL && check_headers OMX_Core.h ; } ||
die "ERROR: OpenMAX IL headers not found"; } && enable omx
enabled openssl && { check_pkg_config openssl openssl openssl/ssl.h OPENSSL_init_ssl ||
check_pkg_config openssl openssl openssl/ssl.h SSL_library_init ||
rsync --help 2> /dev/null | grep -q 'contimeout' && enable rsync_contimeout || disable rsync_contimeout
# check V4L2 codecs available in the API
-check_header linux/fb.h
-check_header linux/videodev2.h
+check_headers linux/fb.h
+check_headers linux/videodev2.h
test_code cc linux/videodev2.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
check_cc v4l2_m2m linux/videodev2.h "int i = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_BUF_FLAG_LAST;"
check_cc vc1_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VC1_ANNEX_G;"
check_cc vp8_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP8;"
check_cc vp9_v4l2_m2m linux/videodev2.h "int i = V4L2_PIX_FMT_VP9;"
-check_header sys/videoio.h
+check_headers sys/videoio.h
test_code cc sys/videoio.h "struct v4l2_frmsizeenum vfse; vfse.discrete.width = 0;" && enable_sanitized struct_v4l2_frmivalenum_discrete
check_lib user32 "windows.h winuser.h" GetShellWindow -luser32
check_type "dshow.h" IBaseFilter
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
-check_header "dev/bktr/ioctl_meteor.h dev/bktr/ioctl_bt848.h" ||
- check_header "machine/ioctl_meteor.h machine/ioctl_bt848.h" ||
- check_header "dev/video/meteor/ioctl_meteor.h dev/video/bktr/ioctl_bt848.h" ||
- check_header "dev/ic/bt8xx.h"
+check_headers "dev/bktr/ioctl_meteor.h dev/bktr/ioctl_bt848.h" ||
+ check_headers "machine/ioctl_meteor.h machine/ioctl_bt848.h" ||
+ check_headers "dev/video/meteor/ioctl_meteor.h dev/video/bktr/ioctl_bt848.h" ||
+ check_headers "dev/ic/bt8xx.h"
if check_struct sys/soundcard.h audio_buf_info bytes; then
enable_sanitized sys/soundcard.h
enabled zlib && add_cppflags -DZLIB_CONST
-# conditional library dependencies, in linking order
+# conditional library dependencies, in any order
enabled afftfilt_filter && prepend avfilter_deps "avcodec"
enabled afir_filter && prepend avfilter_deps "avcodec"
enabled amovie_filter && prepend avfilter_deps "avformat avcodec"
enabled opus_decoder && prepend avcodec_deps "swresample"
+# reorder the items at var $1 to align with the items order at var $2 .
+# die if an item at $1 is not at $2 .
+reorder_by(){
+ eval rb_in=\$$1
+ eval rb_ordered=\$$2
+
+ for rb in $rb_in; do
+ is_in $rb $rb_ordered || die "$rb at \$$1 is not at \$$2"
+ done
+
+ rb_out=
+ for rb in $rb_ordered; do
+ is_in $rb $rb_in && rb_out="$rb_out$rb "
+ done
+ eval $1=\$rb_out
+}
+
+# deps-expand fflib $1: N x {append all expanded deps; unique}
+# within a set of N items, N expansions are enough to expose a cycle.
expand_deps(){
- lib_deps=${1}_deps
- eval "deps=\$$lib_deps"
- append $lib_deps $(map 'eval echo \$${v}_deps' $deps)
- unique $lib_deps
+ unique ${1}_deps # required for the early break test.
+ for dummy in $LIBRARY_LIST; do # N iteratios
+ eval deps=\$${1}_deps
+ append ${1}_deps $(map 'eval echo \$${v}_deps' $deps)
+ unique ${1}_deps
+ eval '[ ${#deps} = ${#'${1}_deps'} ]' && break # doesn't expand anymore
+ done
+
+ eval is_in $1 \$${1}_deps && die "Dependency cycle at ${1}_deps"
+ reorder_by ${1}_deps LIBRARY_LIST # linking order is expected later
}
#we have to remove gpl from the deps here as some code assumes all lib deps are libs