available options:
--help print this message
+ --disable-cli disables cli
+ --system-libx264 use system libx264 instead of internal
+ --enable-shared build shared library
+ --enable-static build static library
--disable-avs disables avisynth support (windows only)
--disable-lavf disables libavformat support
--disable-ffms disables ffmpegsource support
--enable-win32thread use win32threads (windows only)
--disable-swscale disables swscale support
--disable-asm disables platform-specific assembly optimizations
- --enable-debug adds -g, doesn't strip
- --enable-gprof adds -pg, doesn't strip
+ --disable-interlaced disables interlaced encoding support
+ --enable-debug adds -g
+ --enable-gprof adds -pg
+ --enable-strip adds -s
--enable-visualize enables visualization (X11 only)
--enable-pic build position-independent code
- --enable-shared build shared library
--bit-depth=BIT_DEPTH sets output bit depth (8-10), default 8
--extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS
--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS
[ "$arg" = -Wall ] && arg=-w0
fi
- # Intel Compiler on Mac OS X does not allow pre -msse3
- [ $SYS = MACOSX -a \( "$arg" = -mia32 -o "$arg" = -msse -o "$arg" = -msse2 \) ] && arg=
[ -n "$arg" ] && echo -n "$arg "
done
}
log_check "for $1"
fi
elif [ -z "$1" ]; then
- log_check "whether $CC supports $3"
+ if [ -z "$2" ]; then
+ log_check "whether $CC supports $3"
+ else
+ log_check "whether $CC supports $3 with $2"
+ fi
else
log_check "for $3 in $1";
fi
includedir='${prefix}/include'
DEVNULL='/dev/null'
+cli="yes"
+cli_libx264="internal"
+shared="no"
+static="no"
avs="auto"
lavf="auto"
ffms="auto"
thread="auto"
swscale="auto"
asm="auto"
+interlaced="yes"
debug="no"
gprof="no"
+strip="no"
pic="no"
vis="no"
-shared="no"
bit_depth="8"
compiler="GNU"
EXE=""
# list of all preprocessor HAVE values we can define
-CONFIG_HAVE="MALLOC_H ALTIVEC ALTIVEC_H MMX ARMV6 ARMV6T2 NEON BEOSTHREAD POSIXTHREAD WIN32THREAD THREAD LOG2F VISUALIZE SWSCALE LAVF FFMS GPAC GF_MALLOC AVS GPL"
+CONFIG_HAVE="MALLOC_H ALTIVEC ALTIVEC_H MMX ARMV6 ARMV6T2 NEON BEOSTHREAD POSIXTHREAD WIN32THREAD THREAD LOG2F VISUALIZE SWSCALE LAVF FFMS GPAC GF_MALLOC AVS GPL VECTOREXT INTERLACED"
# parse options
--includedir=*)
includedir="$optarg"
;;
+ --disable-cli)
+ cli="no"
+ ;;
+ --system-libx264)
+ cli_libx264="system"
+ ;;
+ --enable-shared)
+ shared="yes"
+ ;;
+ --enable-static)
+ static="yes"
+ ;;
--disable-asm)
asm="no"
;;
+ --disable-interlaced)
+ interlaced="no"
+ ;;
--disable-avs)
avs="no"
;;
LDFLAGS="$LDFLAGS -pg"
gprof="yes"
;;
+ --enable-strip)
+ strip="yes"
+ ;;
--enable-pic)
pic="yes"
;;
- --enable-shared)
- shared="yes"
- ;;
--enable-visualize)
vis="yes"
;;
esac
done
+[ "$cli" = "no" -a "$shared" = "no" -a "$static" = "no" ] && die "Nothing to build. Enable cli, shared or static."
+
CC="${CC-${cross_prefix}gcc}"
AR="${AR-${cross_prefix}ar}"
RANLIB="${RANLIB-${cross_prefix}ranlib}"
if [[ `basename "$CC"` = icl* ]]; then
# Windows Intel Compiler creates dependency generation with absolute Windows paths, Cygwin's make does not support Windows paths.
[[ $host_os = cygwin* ]] && die "Windows Intel Compiler support requires MSYS"
- ARCHPRE="-arch:"
compiler=ICL
CFLAGS="$CFLAGS -Qstd=c99 -nologo -Qms0 -DHAVE_STRING_H -Iextras"
QPRE="-Q"
else
if [[ `basename "$CC"` = icc* ]]; then
AR="xiar"
- ARCHPRE="-m"
compiler=ICC
QPRE="-"
fi
LDFLAGS="$LDFLAGS -lm"
;;
cygwin*)
- SYS="WINDOWS"
EXE=".exe"
- DEVNULL="NUL"
if cc_check "" -mno-cygwin; then
CFLAGS="$CFLAGS -mno-cygwin"
LDFLAGS="$LDFLAGS -mno-cygwin"
fi
+ if cpp_check "" "" "defined(__CYGWIN32__)" ; then
+ define HAVE_MALLOC_H
+ SYS="CYGWIN"
+ else
+ SYS="WINDOWS"
+ DEVNULL="NUL"
+ fi
;;
mingw*)
SYS="WINDOWS"
CFLAGS="$CFLAGS -mfpmath=sse -msse"
fi
else
- # Intel Compiler >= 11 generally defaults to SSE2 optimization. -msse is also deprecated for -mia32
- if cpp_check "" "" "__INTEL_COMPILER >= 1100" \
- && ! (echo $CFLAGS | grep -Eiq "(${ARCHPRE}ia32|${ARCHPRE}sse|${ARCHPRE}ssse3|${ARCHPRE}avx)") \
- && [[ "$CFLAGS" != *${QPRE}x* ]]; then
- CFLAGS="$CFLAGS ${ARCHPRE}ia32"
- fi
# icc on linux has various degrees of mod16 stack support
if [ $SYS = LINUX ]; then
# < 11 is completely incapable of keeping a mod16 stack
fi
if [ "$SYS" = MACOSX ]; then
ASFLAGS="$ASFLAGS -f macho -DPREFIX"
- elif [ "$SYS" = WINDOWS ]; then
+ elif [ "$SYS" = WINDOWS -o "$SYS" = CYGWIN ]; then
ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
else
cc_check || die "No working C compiler found."
if [ $compiler != ICL ]; then
- if cc_check '' -std=gnu99 ; then
+ if cc_check '' -std=gnu99 'for( int i = 0; i < 9; i++ );' ; then
CFLAGS="$CFLAGS -std=gnu99"
- elif cc_check '' -std=c99 ; then
+ elif cc_check '' -std=c99 'for( int i = 0; i < 9; i++ );' ; then
CFLAGS="$CFLAGS -std=c99 -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE"
+ elif ! cc_check '' '' 'for( int i = 0; i < 9; i++ );' ; then
+ die "C99 compiler is needed for compilation."
fi
fi
if [ $asm = auto -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
if ! as_check "vpaddw xmm0, xmm0, xmm0" ; then
- VER=`($AS --version || echo no assembler) 2>$DEVNULL | head -n 1`
+ VER=`($AS --version || echo no assembler) 2>/dev/null | head -n 1`
echo "Found $VER"
echo "Minimum version is yasm-0.7.0"
echo "If you really want to compile without asm, configure with --disable-asm."
exit 1
fi
if ! cc_check '' '' '__asm__("pabsw %xmm0, %xmm0");' ; then
- VER=`(${cross_prefix}as --version || echo no gnu as) 2>$DEVNULL | head -n 1`
+ VER=`(${cross_prefix}as --version || echo no gnu as) 2>/dev/null | head -n 1`
echo "Found $VER"
echo "Minimum version is binutils-2.17"
echo "Your compiler can't handle inline SSSE3 asm."
# skip endianness check for Intel Compiler, as all supported platforms are little. the -ipo flag will also cause the check to fail
if [ $compiler = GNU ]; then
echo "int i[2] = {0x42494745,0}; double f[2] = {0x1.0656e6469616ep+102,0};" > conftest.c
- $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed"
+ $CC $CFLAGS conftest.c -c -o conftest.o 2>/dev/null || die "endian test failed"
if (${cross_prefix}strings -a conftest.o | grep -q BIGE) && (${cross_prefix}strings -a conftest.o | grep -q FPendian) ; then
define WORDS_BIGENDIAN
elif !(${cross_prefix}strings -a conftest.o | grep -q EGIB && ${cross_prefix}strings -a conftest.o | grep -q naidnePF) ; then
define HAVE_POSIXTHREAD
fi
if [ "$thread" = "win32" ]; then
+ # cygwin does not support win32 threads
if [ "$SYS" = "WINDOWS" ]; then
define HAVE_WIN32THREAD
else
if [ "$swscale" = "auto" ] ; then
swscale="no"
- if ${cross_prefix}pkg-config --exists libswscale 2>$DEVNULL; then
+ if ${cross_prefix}pkg-config --exists libswscale 2>/dev/null; then
SWSCALE_LIBS="$SWSCALE_LIBS $(${cross_prefix}pkg-config --libs libswscale)"
SWSCALE_CFLAGS="$SWSCALE_CFLAGS $(${cross_prefix}pkg-config --cflags libswscale)"
fi
if [ "$lavf" = "auto" ] ; then
lavf="no"
- if ${cross_prefix}pkg-config --exists libavformat libavcodec libswscale 2>$DEVNULL; then
+ if ${cross_prefix}pkg-config --exists libavformat libavcodec libswscale 2>/dev/null; then
LAVF_LIBS="$LAVF_LIBS $(${cross_prefix}pkg-config --libs libavformat libavcodec libavutil libswscale)"
LAVF_CFLAGS="$LAVF_CFLAGS $(${cross_prefix}pkg-config --cflags libavformat libavcodec libavutil libswscale)"
fi
fi
LAVF_LIBS="-L. $LAVF_LIBS"
if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "avcodec_decode_video2(0,0,0,0);" ; then
- # libvautil/pixdesc.h included the private header intreadwrite.h until r21854
- if cc_check libavutil/pixdesc.h "$LAVF_CFLAGS $LAVF_LIBS" ; then
+ if cpp_check libavcodec/avcodec.h "$LAVF_CFLAGS $LAVF_LIBS" "LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,64,0)" ; then
if [ "$swscale" = "yes" ]; then
lavf="yes"
else
echo "Warning: libavformat is not supported without swscale support"
fi
else
- echo "Warning: libavutil is too old, update to ffmpeg r21854+"
+ echo "Warning: libavcodec is too old, update to ffmpeg r22735+"
fi
fi
fi
ffms_major="2"; ffms_minor="14"; ffms_micro="0"; ffms_bump="0"
ffms="no"
- if ${cross_prefix}pkg-config --exists ffms2 2>$DEVNULL; then
+ if ${cross_prefix}pkg-config --exists ffms2 2>/dev/null; then
FFMS2_LIBS="$FFMS2_LIBS $(${cross_prefix}pkg-config --libs ffms2)"
FFMS2_CFLAGS="$FFMS2_CFLAGS $(${cross_prefix}pkg-config --cflags ffms2)"
fi
fi
fi
-GPAC_LIBS="-lgpac_static"
-if [ $SYS = WINDOWS ]; then
- GPAC_LIBS="$GPAC_LIBS -lwinmm"
-fi
if [ "$gpac" = "auto" ] ; then
gpac="no"
+ cc_check "" -lz && GPAC_LIBS="-lgpac_static -lz" || GPAC_LIBS="-lgpac_static"
+ if [ "$SYS" = "WINDOWS" ] ; then
+ GPAC_LIBS="$GPAC_LIBS -lwinmm"
+ fi
if cc_check gpac/isomedia.h "$GPAC_LIBS" ; then
if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0);" ; then
gpac="yes"
if [ "$avs" = "auto" ] ; then
avs="no"
- if [ $SYS = WINDOWS ] && cc_check extras/avisynth_c.h ; then
+ # cygwin can use avisynth if it can use LoadLibrary
+ if [ $SYS = WINDOWS ] || ([ $SYS = CYGWIN ] && cc_check windows.h "" "LoadLibrary(0);") ; then
avs="yes"
define HAVE_AVS
fi
fi
+cc_check "stdint.h" "" "uint32_t test_vec __attribute__ ((vector_size (16))) = {0,1,2,3};" && define HAVE_VECTOREXT
+
if [ "$pic" = "yes" ] ; then
CFLAGS="$CFLAGS -fPIC"
ASFLAGS="$ASFLAGS -DPIC"
fi
if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
- CFLAGS="$CFLAGS -s -fomit-frame-pointer"
+ CFLAGS="$CFLAGS -fomit-frame-pointer"
+fi
+
+if [ "$strip" = "yes" ]; then
+ CFLAGS="$CFLAGS -s"
LDFLAGS="$LDFLAGS -s"
fi
[ $gpl = yes ] && define HAVE_GPL && x264_gpl=1 || x264_gpl=0
+[ $interlaced = yes ] && define HAVE_INTERLACED && x264_interlaced=1 || x264_interlaced=0
+
#define undefined vars as 0
for var in $CONFIG_HAVE; do
grep -q "HAVE_$var 1" config.h || define HAVE_$var 0
# generate exported config file
cat > x264_config.h << EOF
-#define X264_BIT_DEPTH $bit_depth
-#define X264_GPL $x264_gpl
+#define X264_BIT_DEPTH $bit_depth
+#define X264_GPL $x264_gpl
+#define X264_INTERLACED $x264_interlaced
EOF
# generate config files
DEPMT=$DEPMT
LD=$LD
LDFLAGS=$LDFLAGS
-LDFLAGSCLI=$LDFLAGSCLI
LIBX264=$LIBX264
AR=$AR
RANLIB=$RANLIB
echo ' $(CC) $(CFLAGS) -c -Fo$@ $<' >> config.mak
fi
+if [ "$cli" = "yes" ]; then
+ echo 'default: cli' >> config.mak
+ echo 'install: install-cli' >> config.mak
+fi
+
if [ "$shared" = "yes" ]; then
API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
- if [ "$SYS" = "WINDOWS" ]; then
+ if [ "$SYS" = "WINDOWS" -o "$SYS" = "CYGWIN" ]; then
echo "SONAME=libx264-$API.dll" >> config.mak
if [ $compiler = ICL ]; then
echo 'IMPLIBNAME=libx264.dll.lib' >> config.mak
echo "SONAME=libx264.so.$API" >> config.mak
echo 'SOFLAGS=-shared -Wl,-soname,$(SONAME)' >> config.mak
fi
- echo 'default: $(SONAME)' >> config.mak
+ echo 'default: lib-shared' >> config.mak
+ echo 'install: install-lib-shared' >> config.mak
+fi
+
+if [ "$static" = "yes" ]; then
+ echo 'default: lib-static' >> config.mak
+ echo 'install: install-lib-static' >> config.mak
+fi
+
+if [ "$cli_libx264" = "system" ] ; then
+ if [ "$shared" = "yes" ]; then
+ CLI_LIBX264='$(SONAME)'
+ elif ${cross_prefix}pkg-config --exists x264 2>/dev/null; then
+ LDFLAGSCLI="$LDFLAGSCLI $(${cross_prefix}pkg-config --libs x264)"
+ CLI_LIBX264=
+ else
+ die "Can not find system libx264"
+ fi
+else
+ CLI_LIBX264='$(LIBX264)'
fi
+echo "LDFLAGSCLI = $LDFLAGSCLI" >> config.mak
+echo "CLI_LIBX264 = $CLI_LIBX264" >> config.mak
./version.sh >> config.h
cat > conftest.log <<EOF
Platform: $ARCH
System: $SYS
+cli: $cli
+libx264: $cli_libx264
+shared: $shared
+static: $static
asm: $asm
+interlaced: $interlaced
avs: $avs
lavf: $lavf
ffms: $ffms
filters: $filters
debug: $debug
gprof: $gprof
+strip: $strip
PIC: $pic
-shared: $shared
visualize: $vis
bit depth: $bit_depth
EOF