]> git.sesse.net Git - x264/blobdiff - configure
Improve build system capabilities
[x264] / configure
index e4c7729945fcc746f5c8d83db88fa9fdbdf8c83e..d16441432f9a224619ee6b5c6100598147c24350 100755 (executable)
--- a/configure
+++ b/configure
@@ -7,6 +7,10 @@ Usage: ./configure [options]
 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
@@ -16,11 +20,12 @@ available options:
   --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
@@ -67,8 +72,6 @@ intel_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
 }
@@ -100,7 +103,11 @@ cc_check() {
             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
@@ -195,6 +202,10 @@ libdir='${exec_prefix}/lib'
 includedir='${prefix}/include'
 DEVNULL='/dev/null'
 
+cli="yes"
+cli_libx264="internal"
+shared="no"
+static="no"
 avs="auto"
 lavf="auto"
 ffms="auto"
@@ -203,11 +214,12 @@ gpl="yes"
 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"
 
@@ -221,7 +233,7 @@ cross_prefix=""
 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
 
@@ -243,9 +255,24 @@ for opt do
         --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"
             ;;
@@ -287,12 +314,12 @@ for opt do
             LDFLAGS="$LDFLAGS -pg"
             gprof="yes"
             ;;
+        --enable-strip)
+            strip="yes"
+            ;;
         --enable-pic)
             pic="yes"
             ;;
-        --enable-shared)
-            shared="yes"
-            ;;
         --enable-visualize)
             vis="yes"
             ;;
@@ -320,6 +347,8 @@ for opt do
     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}"
@@ -342,7 +371,6 @@ if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
     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"
@@ -353,7 +381,6 @@ if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
 else
     if [[ `basename "$CC"` = icc* ]]; then
         AR="xiar"
-        ARCHPRE="-m"
         compiler=ICC
         QPRE="-"
     fi
@@ -395,13 +422,18 @@ case $host_os in
         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"
@@ -432,12 +464,6 @@ case $host_cpu in
                 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
@@ -454,7 +480,7 @@ case $host_cpu in
         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
@@ -553,10 +579,12 @@ log_msg ""
 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
 
@@ -566,14 +594,14 @@ 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."
@@ -607,7 +635,7 @@ define SYS_$SYS
 # 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
@@ -661,6 +689,7 @@ if [ "$thread" = "posix" ]; then
     define HAVE_POSIXTHREAD
 fi
 if [ "$thread" = "win32" ]; then
+    # cygwin does not support win32 threads
     if [ "$SYS" = "WINDOWS" ]; then
         define HAVE_WIN32THREAD
     else
@@ -687,7 +716,7 @@ fi
 
 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
@@ -710,7 +739,7 @@ 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
@@ -722,15 +751,14 @@ if [ "$lavf" = "auto" ] ; then
     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
@@ -739,7 +767,7 @@ if [ "$ffms" = "auto" ] ; then
     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
@@ -779,12 +807,12 @@ if [ "$swscale" = "yes" ]; then
     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"
@@ -803,12 +831,15 @@ fi
 
 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"
@@ -817,7 +848,11 @@ if [ "$pic" = "yes" ] ; then
 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
 
@@ -864,6 +899,8 @@ ASFLAGS="$ASFLAGS -DBIT_DEPTH=$bit_depth"
 
 [ $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
@@ -913,8 +950,9 @@ rm -f conftest*
 # 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
@@ -933,7 +971,6 @@ DEPMM=$DEPMM
 DEPMT=$DEPMT
 LD=$LD
 LDFLAGS=$LDFLAGS
-LDFLAGSCLI=$LDFLAGSCLI
 LIBX264=$LIBX264
 AR=$AR
 RANLIB=$RANLIB
@@ -954,9 +991,14 @@ if [ $compiler = ICL ]; then
     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
@@ -982,8 +1024,29 @@ if [ "$shared" = "yes" ]; then
         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
 
@@ -1010,7 +1073,12 @@ gpl_filters=""
 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
@@ -1020,8 +1088,8 @@ thread:     $thread
 filters:    $filters
 debug:      $debug
 gprof:      $gprof
+strip:      $strip
 PIC:        $pic
-shared:     $shared
 visualize:  $vis
 bit depth:  $bit_depth
 EOF