Skip to content
Snippets Groups Projects
configure 173 KiB
Newer Older
if [ -z "$optflags" ]; then
    if enabled small; then
        optflags=$cflags_size
    elif enabled optimizations; then
        optflags=$cflags_speed
    else
        optflags=$cflags_noopt
    fi

check_optflags(){
    check_cflags "$@"
    enabled lto && check_ldflags "$@"
}


if enabled lto; then
    test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
    check_cflags  -flto
    check_ldflags -flto $cpuflags
    disable inline_asm_direct_symbol_refs

check_optflags $optflags
check_optflags -fno-math-errno
check_optflags -fno-signed-zeros
enabled ftrapv && check_cflags -ftrapv

check_cc -mno-red-zone <<EOF && noredzone_flags="-mno-red-zone"
int x;
EOF

Måns Rullgård's avatar
Måns Rullgård committed
    # Just warnings, no remarks
    check_cflags -w1
    # -wd: Disable following warnings
    # 144, 167, 556: -Wno-pointer-sign
    # 188: enumerated type mixed with another type
    # 1292: attribute "foo" ignored
    # 1419: external declaration in primary source file
Måns Rullgård's avatar
Måns Rullgård committed
    # 10006: ignoring unknown option -fno-signed-zeros
    # 10148: ignoring unknown option -Wno-parentheses
Måns Rullgård's avatar
Måns Rullgård committed
    # 10156: ignoring option '-W'; no argument required
    check_cflags -wd144,167,188,556,1292,1419,10006,10148,10156
Måns Rullgård's avatar
Måns Rullgård committed
    # 11030: Warning unknown option --as-needed
    # 10156: ignoring option '-export'; no argument required
    check_ldflags -wd10156,11030
    # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
    enable ebp_available
    # The test above does not test linking
    enabled lto && disable symver_asm_label
    if enabled x86_32; then
        icc_version=$($cc -dumpversion)
        test ${icc_version%%.*} -ge 11 &&
            check_cflags -falign-stack=maintain-16-byte ||
elif enabled ccc; then
    # disable some annoying warnings
    add_cflags -msg_disable bitnotint
    add_cflags -msg_disable mixfuncvoid
    add_cflags -msg_disable nonstandcast
    add_cflags -msg_disable unsupieee
elif enabled gcc; then
    check_optflags -fno-tree-vectorize
    check_cflags -Werror=format-security
    check_cflags -Werror=implicit-function-declaration
    check_cflags -Werror=missing-prototypes
    check_cflags -Werror=return-type
    check_cflags -Werror=vla
    enabled extra_warnings || check_disable_warning -Wno-maybe-uninitialized
elif enabled llvm_gcc; then
    check_cflags -mllvm -stack-alignment=16
elif enabled clang; then
    check_cflags -mllvm -stack-alignment=16
    check_cflags -Qunused-arguments
    check_cflags -Werror=implicit-function-declaration
    check_cflags -Werror=missing-prototypes
    check_cflags -Werror=return-type
Luca Barbato's avatar
Luca Barbato committed
elif enabled cparser; then
    add_cflags -Wno-missing-variable-declarations
    add_cflags -Wno-empty-statement
elif enabled armcc; then
    add_cflags -W${armcc_opt},--diag_suppress=4343 # hardfp compat
    add_cflags -W${armcc_opt},--diag_suppress=3036 # using . as system include dir
    # 2523: use of inline assembly is deprecated
    add_cflags -W${armcc_opt},--diag_suppress=2523
    add_cflags -W${armcc_opt},--diag_suppress=1207
    add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
    add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
    add_cflags -W${armcc_opt},--diag_suppress=167  # pointer sign
    add_cflags -W${armcc_opt},--diag_suppress=513  # pointer sign
elif enabled tms470; then
    add_cflags -pds=824 -pds=837
elif enabled pathscale; then
    add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
elif enabled_any msvc icl; then
    enabled x86_32 && disable aligned_stack
    enabled_all x86_32 debug && add_cflags -Oy-
    enabled debug && add_ldflags -debug
    enable pragma_deprecated
    if enabled icl; then
        # -Qansi-alias is basically -fstrict-aliasing, but does not work
        # (correctly) on icl 13.x.
        check_cpp_condition "windows.h" "__ICL < 1300 || __ICL >= 1400" &&
            add_cflags -Qansi-alias
        # Some inline asm is not compilable in debug
        if enabled debug; then
            disable ebp_available
            disable ebx_available
        fi
    # msvcrt10 x64 incorrectly enables log2, only msvcrt12 onwards actually has log2.
    check_cpp_condition crtversion.h "_VC_CRT_MAJOR_VERSION >= 12" || disable log2
case $as_type in
    clang)
        add_asflags -Qunused-arguments
    ;;
esac

case $ld_type in
    clang)
        check_ldflags -Qunused-arguments
    ;;
esac

Mans Rullgard's avatar
Mans Rullgard committed
case $target_os in
    osf1)
        enabled ccc && add_ldflags '-Wl,-expect_unresolved,*'
    ;;
Mans Rullgard's avatar
Mans Rullgard committed
    plan9)
        add_cppflags -Dmain=plan9_main
    ;;
esac

enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }

enabled threads && ! enabled pthreads && ! enabled atomics_native && die "non pthread threading without atomics not supported, try adding --enable-pthreads or --cpu=i486 or higher if you are on x86"

if test $target_os = "haiku"; then
enabled_all dxva2 dxva2api_cobj CoTaskMemFree &&
    prepend ffmpeg_libs $($ldflags_filter "-lole32") &&
! enabled_any memalign posix_memalign aligned_malloc &&
    enabled_any $need_memalign && enable memalign_hack

# add_dep lib dep
# -> enable ${lib}_deps_${dep}
# -> add $dep to ${lib}_deps only once
add_dep() {
    lib=$1
    dep=$2
    enabled "${lib}_deps_${dep}" && return 0
    enable  "${lib}_deps_${dep}"
    prepend "${lib}_deps" $dep
}

# merge deps lib components
# merge all ${component}_deps into ${lib}_deps and ${lib}_deps_*
merge_deps() {
    lib=$1
    shift
    for comp in $*; do
        enabled $comp || continue
        eval "dep=\"\$${comp}_deps\""
        for d in $dep; do
            add_dep $lib $d
        done
    done
}

merge_deps libavfilter $FILTER_LIST

for thread in $THREADS_LIST; do
    if enabled $thread; then
        test -n "$thread_type" &&
            die "ERROR: Only one thread type must be selected." ||
            thread_type="$thread"
    fi
done

# conditional library dependencies, in linking order
enabled aconvert_filter     && prepend avfilter_deps "swresample"
enabled amovie_filter       && prepend avfilter_deps "avformat avcodec"
enabled aresample_filter    && prepend avfilter_deps "swresample"
enabled asyncts_filter      && prepend avfilter_deps "avresample"
enabled atempo_filter       && prepend avfilter_deps "avcodec"
enabled decimate_filter     && prepend avfilter_deps "avcodec"
enabled deshake_filter      && prepend avfilter_deps "avcodec"
enabled ebur128_filter && enabled swresample && prepend avfilter_deps "swresample"
enabled elbg_filter         && prepend avfilter_deps "avcodec"
enabled mcdeint_filter      && prepend avfilter_deps "avcodec"
enabled movie_filter    && prepend avfilter_deps "avformat avcodec"
enabled mp_filter           && prepend avfilter_deps "avcodec"
enabled pan_filter          && prepend avfilter_deps "swresample"
enabled pp_filter           && prepend avfilter_deps "postproc"
enabled removelogo_filter   && prepend avfilter_deps "avformat avcodec swscale"
enabled resample_filter && prepend avfilter_deps "avresample"
enabled sab_filter          && prepend avfilter_deps "swscale"
enabled scale_filter    && prepend avfilter_deps "swscale"
enabled showspectrum_filter && prepend avfilter_deps "avcodec"
enabled smartblur_filter    && prepend avfilter_deps "swscale"
enabled subtitles_filter    && prepend avfilter_deps "avformat avcodec"

enabled lavfi_indev         && prepend avdevice_deps "avfilter"
enabled opus_decoder    && prepend avcodec_deps "swresample"
expand_deps(){
    lib_deps=${1}_deps
    eval "deps=\$$lib_deps"
    append $lib_deps $(map 'eval echo \$${v}_deps' $deps)
    unique $lib_deps
}

#we have to remove gpl from the deps here as some code assumes all lib deps are libs
postproc_deps="$(filter_out 'gpl' $postproc_deps)"

map 'expand_deps $v' $LIBRARY_LIST

echo "install prefix            $prefix"
Diego Biurrun's avatar
Diego Biurrun committed
echo "source path               $source_path"
echo "C compiler                $cc"
echo "C library                 $libc_type"
if test "$host_cc" != "$cc"; then
    echo "host C compiler           $host_cc"
    echo "host C library            $host_libc_type"
Diego Biurrun's avatar
Diego Biurrun committed
echo "ARCH                      $arch ($cpu)"
if test "$build_suffix" != ""; then
    echo "build suffix              $build_suffix"
if test "$progs_suffix" != ""; then
    echo "progs suffix              $progs_suffix"
fi
if test "$extra_version" != ""; then
    echo "version string suffix     $extra_version"
fi
echo "big-endian                ${bigendian-no}"
echo "runtime cpu detection     ${runtime_cpudetect-no}"
    echo "${yasmexe}                      ${yasm-no}"
    echo "MMX enabled               ${mmx-no}"
    echo "MMXEXT enabled            ${mmxext-no}"
    echo "3DNow! extended enabled   ${amd3dnowext-no}"
    echo "SSE enabled               ${sse-no}"
    echo "SSSE3 enabled             ${ssse3-no}"
    echo "AVX enabled               ${avx-no}"
    echo "XOP enabled               ${xop-no}"
    echo "FMA3 enabled              ${fma3-no}"
    echo "i686 features enabled     ${i686-no}"
    echo "CMOV is fast              ${fast_cmov-no}"
    echo "EBX available             ${ebx_available-no}"
    echo "EBP available             ${ebp_available-no}"
if enabled aarch64; then
    echo "NEON enabled              ${neon-no}"
    echo "VFP enabled               ${vfp-no}"
fi
    echo "ARMv5TE enabled           ${armv5te-no}"
    echo "ARMv6 enabled             ${armv6-no}"
    echo "ARMv6T2 enabled           ${armv6t2-no}"
    echo "VFP enabled               ${vfp-no}"
    echo "NEON enabled              ${neon-no}"
    echo "THUMB enabled             ${thumb-no}"
    echo "MIPS FPU enabled          ${mipsfpu-no}"
    echo "MIPS32R2 enabled          ${mips32r2-no}"
    echo "MIPS DSP R1 enabled       ${mipsdspr1-no}"
    echo "MIPS DSP R2 enabled       ${mipsdspr2-no}"
    echo "AltiVec enabled           ${altivec-no}"
    echo "PPC 4xx optimizations     ${ppc4xx-no}"
    echo "PPC VSX optimizations     ${vsx-no}"
    echo "dcbzl available           ${dcbzl-no}"
echo "debug symbols             ${debug-no}"
echo "strip symbols             ${stripping-no}"
echo "optimize for size         ${small-no}"
echo "optimizations             ${optimizations-no}"
echo "static                    ${static-no}"
echo "shared                    ${shared-no}"
echo "postprocessing support    ${postproc-no}"
echo "network support           ${network-no}"
echo "threading support         ${thread_type-no}"
echo "safe bitstream reader     ${safe_bitstream_reader-no}"
echo "SDL support               ${sdl-no}"
echo "opencl enabled            ${opencl-no}"
echo "texi2html enabled         ${texi2html-no}"
echo "perl enabled              ${perl-no}"
echo "pod2man enabled           ${pod2man-no}"
echo "makeinfo enabled          ${makeinfo-no}"
test -n "$random_seed" &&
    echo "random seed               ${random_seed}"
Fabrice Bellard's avatar
Fabrice Bellard committed

echo "External libraries:"
print_enabled '' $EXTERNAL_LIBRARY_LIST | print_3_columns
echo

for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
    echo "Enabled ${type}s:"
    eval list=\$$(toupper $type)_LIST
    print_enabled '_*' $list | print_3_columns
license="LGPL version 2.1 or later"
if enabled nonfree; then
    license="nonfree and unredistributable"
elif enabled gplv3; then
    license="GPL version 3 or later"
elif enabled lgplv3; then
    license="LGPL version 3 or later"
elif enabled gpl; then
    license="GPL version 2 or later"
echo "Creating config.mak, config.h, and doc/config.texi..."
test -e Makefile || echo "include $source_path/Makefile" > Makefile
enabled stripping || strip="echo skipping strip"

config_files="$TMPH config.mak doc/config.texi"
cat > config.mak <<EOF
# Automatically generated by configure - do not modify!
ifndef FFMPEG_CONFIG_MAK
FFMPEG_CONFIG_MAK=1
FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
prefix=$prefix
LIBDIR=\$(DESTDIR)$libdir
SHLIBDIR=\$(DESTDIR)$shlibdir
INCDIR=\$(DESTDIR)$incdir
BINDIR=\$(DESTDIR)$bindir
DATADIR=\$(DESTDIR)$datadir
DOCDIR=\$(DESTDIR)$docdir
SRC_PATH=$source_path
ifndef MAIN_MAKEFILE
SRC_PATH:=\$(SRC_PATH:.%=..%)
endif
Mohamed Naufal's avatar
Mohamed Naufal committed
CXX=$cxx
DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS)
DEPAS=$as
DEPASFLAGS=$DEPASFLAGS \$(CPPFLAGS)
ARFLAGS=$arflags
AR_O=$ar_o
STRIP=$strip
LN_S=$ln_s
CPPFLAGS=$CPPFLAGS
CFLAGS=$CFLAGS
Mohamed Naufal's avatar
Mohamed Naufal committed
CXXFLAGS=$CXXFLAGS
CXX_C=$CXX_C
Mohamed Naufal's avatar
Mohamed Naufal committed
CXX_O=$CXX_O
LD_LIB=$LD_LIB
LD_PATH=$LD_PATH
DOXYGEN=$doxygen
SHFLAGS=$(echo $($ldflags_filter $SHFLAGS))
ASMSTRIPFLAGS=$ASMSTRIPFLAGS
YASMFLAGS=$YASMFLAGS
BUILDSUF=$build_suffix
PROGSSUF=$progs_suffix
FULLNAME=$FULLNAME
LIBPREF=$LIBPREF
LIBSUF=$LIBSUF
LIBNAME=$LIBNAME
SLIBPREF=$SLIBPREF
SLIBSUF=$SLIBSUF
EXESUF=$EXESUF
EXTRA_VERSION=$extra_version
CCDEP=$CCDEP
Mohamed Naufal's avatar
Mohamed Naufal committed
CXXDEP=$CXXDEP
CC_DEPFLAGS=$CC_DEPFLAGS
AS_DEPFLAGS=$AS_DEPFLAGS
HOSTCC=$host_cc
HOSTEXESUF=$HOSTEXESUF
HOSTLDFLAGS=$host_ldflags
HOSTLIBS=$host_libs
DEPHOSTCC=$host_cc
DEPHOSTCCFLAGS=$DEPHOSTCCFLAGS \$(HOSTCCFLAGS)
HOSTCCDEP=$HOSTCCDEP
HOSTCCDEP_FLAGS=$HOSTCCDEP_FLAGS
HOSTCC_DEPFLAGS=$HOSTCC_DEPFLAGS
HOSTLD_O=$HOSTLD_O
TARGET_EXEC=$target_exec $target_exec_args
TARGET_SAMPLES=${target_samples:-\$(SAMPLES)}
CFLAGS-ffplay=$sdl_cflags
ZLIB=$($ldflags_filter -lz)
LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
EXTRALIBS=$extralibs
COMPAT_OBJS=$compat_objs
LIBTARGET=${LIBTARGET}
SLIBNAME=${SLIBNAME}
SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
SAMPLES:=${samples:-\$(FATE_SAMPLES)}
NOREDZONE_FLAGS=$noredzone_flags
    name=$(toupper $lcname)
    file=$source_path/$lcname/version.h
    eval $(awk "/#define ${name}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file")
    enabled raise_major && eval ${name}_VERSION_MAJOR=$((${name}_VERSION_MAJOR+100))
    eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
    eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
    eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
    eval echo "${lcname}_VERSION_MINOR=\$${name}_VERSION_MINOR" >> config.mak
map 'get_version $v' $LIBRARY_LIST
map 'eval echo "${v}_FFLIBS=\$${v}_deps" >> config.mak' $LIBRARY_LIST
print_program_libs(){
    eval "program_libs=\$${1}_libs"
    eval echo "LIBS-${1}=${program_libs}" >> config.mak
}

map 'print_program_libs $v' $PROGRAM_LIST

cat > $TMPH <<EOF
/* Automatically generated by configure - do not modify! */
#ifndef FFMPEG_CONFIG_H
#define FFMPEG_CONFIG_H
#define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
#define FFMPEG_LICENSE "$(c_escape $license)"
#define CONFIG_THIS_YEAR 2014
#define FFMPEG_DATADIR "$(eval c_escape $datadir)"
#define AVCONV_DATADIR "$(eval c_escape $datadir)"
#define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
#define av_restrict $_restrict
#define EXTERN_PREFIX "${extern_prefix}"
#define EXTERN_ASM ${extern_prefix}
#define BUILDSUF "$build_suffix"
#define HAVE_MMX2 HAVE_MMXEXT
#define SWS_MAX_FILTER_SIZE $sws_max_filter_size
test -n "$assert_level" &&
    echo "#define ASSERT_LEVEL $assert_level" >>$TMPH

test -n "$malloc_prefix" &&
    echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH

if enabled yasm; then
    append config_files $TMPASM
    printf '' >$TMPASM
fi

enabled getenv || echo "#define getenv(x) NULL" >> $TMPH

mkdir -p doc
echo "@c auto-generated by configure" > doc/config.texi

print_config ARCH_   "$config_files" $ARCH_LIST
print_config HAVE_   "$config_files" $HAVE_LIST
print_config CONFIG_ "$config_files" $CONFIG_LIST       \
Måns Rullgård's avatar
Måns Rullgård committed
                                     $CONFIG_EXTRA      \
echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
Diego Biurrun's avatar
Diego Biurrun committed
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
cp_if_changed $TMPH config.h
enabled yasm && cp_if_changed $TMPASM config.asm

cat > $TMPH <<EOF
/* Generated by ffconf */
#ifndef AVUTIL_AVCONFIG_H
#define AVUTIL_AVCONFIG_H
EOF

print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB

echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH

cp_if_changed $TMPH libavutil/avconfig.h

if test -n "$WARNINGS"; then
    printf "\n$WARNINGS"
    enabled fatal_warnings && exit 1
fi
# build pkg-config files
    eval printf "\"lib${1}${build_suffix} >= \$LIB$(toupper ${1})_VERSION, \""
pkgconfig_generate(){
    name=$1
    shortname=${name#lib}${build_suffix}
    comment=$2
    version=$3
    libs=$4
    requires=$(map 'lib_version $v' $(eval echo \$${name#lib}_deps))
    requires=${requires%, }
    enabled ${name#lib} || return 0
    mkdir -p $name
    cat <<EOF > $name/$name${build_suffix}.pc
exec_prefix=\${prefix}
Name: $name
Description: $comment
Version: $version
Requires: $(enabled shared || echo $requires)
Requires.private: $(enabled shared && echo $requires)
Libs: -L\${libdir} $(enabled rpath && echo "-Wl,-rpath,\${libdir}") -l${shortname} $(enabled shared || echo $libs)
Libs.private: $(enabled shared && echo $libs)
Cflags: -I\${includedir}

mkdir -p doc/examples/pc-uninstalled
includedir=${source_path}
[ "$includedir" = . ] && includedir="\${pcfiledir}/../../.."
    cat <<EOF > doc/examples/pc-uninstalled/$name.pc
libdir=\${pcfiledir}/../../../$name
includedir=${includedir}
Name: $name
Description: $comment
Version: $version
Requires: $requires
Libs: -L\${libdir} -Wl,-rpath,\${libdir} -l${shortname} $(enabled shared || echo $libs)
pkgconfig_generate libavutil     "FFmpeg utility library"               "$LIBAVUTIL_VERSION"     "$LIBM"
pkgconfig_generate libavcodec    "FFmpeg codec library"                 "$LIBAVCODEC_VERSION"    "$extralibs"
pkgconfig_generate libavformat   "FFmpeg container format library"      "$LIBAVFORMAT_VERSION"   "$extralibs"
pkgconfig_generate libavdevice   "FFmpeg device handling library"       "$LIBAVDEVICE_VERSION"   "$extralibs"
pkgconfig_generate libavfilter   "FFmpeg audio/video filtering library" "$LIBAVFILTER_VERSION"   "$extralibs"
pkgconfig_generate libpostproc   "FFmpeg postprocessing library"        "$LIBPOSTPROC_VERSION"   ""
pkgconfig_generate libavresample "Libav audio resampling library"       "$LIBAVRESAMPLE_VERSION" "$extralibs"
pkgconfig_generate libswscale    "FFmpeg image rescaling library"       "$LIBSWSCALE_VERSION"    "$LIBM"
pkgconfig_generate libswresample "FFmpeg audio resampling library"      "$LIBSWRESAMPLE_VERSION" "$LIBM"