3 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
5 Usage: ./configure [options]
9 --help print this message
10 --disable-avs disables avisynth support (windows only)
11 --disable-lavf disables libavformat support
12 --disable-ffms disables ffmpegsource support
13 --disable-gpac disables gpac support
14 --disable-gpl disables GPL-only features
15 --disable-thread disables multithreaded encoding
16 --enable-win32thread use win32threads (windows only)
17 --disable-swscale disables swscale support
18 --disable-asm disables platform-specific assembly optimizations
19 --enable-debug adds -g, doesn't strip
20 --enable-gprof adds -pg, doesn't strip
21 --enable-visualize enables visualization (X11 only)
22 --enable-pic build position-independent code
23 --enable-shared build shared library
24 --bit-depth=BIT_DEPTH sets output bit depth (8-10), default 8
25 --extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS
26 --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS
27 --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS
28 --host=HOST build programs to run on HOST
29 --cross-prefix=PREFIX use PREFIX for compilation tools
30 --sysroot=SYSROOT root of cross-build tree
37 echo -n "checking $1... " >> config.log
41 echo "yes" >> config.log
45 echo "no" >> config.log
49 echo "$1" >> config.log
53 # Intel Compiler issues an incredibly large number of warnings on any warning level,
54 # suppress them by disabling all warnings rather than having to use #pragmas to disable most of them
56 [ $arg = -ffast-math ] && arg=
57 [[ "$arg" = -falign-loops* ]] && arg=
58 [ "$arg" = -fno-tree-vectorize ] && arg=
59 [ "$arg" = -Wshadow ] && arg=
60 if [ $compiler = ICL ]; then
61 [ "$arg" = -Wall ] && arg=-W0
62 [ "$arg" = -g ] && arg=-Z7
63 [ "$arg" = -fomit-frame-pointer ] && arg=
64 [ "$arg" = -s ] && arg=
65 [ "$arg" = -fPIC ] && arg=
67 [ "$arg" = -Wall ] && arg=-w0
70 [ -n "$arg" ] && echo -n "$arg "
76 arg=${arg/LIBPATH/libpath}
77 [ ${arg#-libpath:} == $arg -a ${arg#-l} != $arg ] && arg=${arg#-l}.lib
78 [ ${arg#-L} != $arg ] && arg=-libpath:${arg#-L}
79 [ $arg = -Wl,--large-address-aware ] && arg=-largeaddressaware
81 [ "$arg" = -Wl,-Bsymbolic ] && arg=
83 arg=${arg/pthreadGC/pthreadVC}
84 [ "$arg" = avifil32.lib ] && arg=vfw32.lib
85 [ "$arg" = gpac_static.lib ] && arg=libgpac_static.lib
87 [ -n "$arg" ] && echo -n "$arg "
93 if [ -z "$1$2" ]; then
94 log_check "whether $CC works"
95 elif [ -z "$1" ]; then
100 elif [ -z "$1" ]; then
102 log_check "whether $CC supports $3"
104 log_check "whether $CC supports $3 with $2"
107 log_check "for $3 in $1";
110 [ -n "$1" ] && echo "#include <$1>" > conftest.c
111 echo "int main () { $3 return 0; }" >> conftest.c
112 if [ $compiler = ICL ]; then
113 cc_cmd="$CC conftest.c $CFLAGS $2 -link $(icl_ldflags $2 $LDFLAGSCLI $LDFLAGS)"
115 cc_cmd="$CC conftest.c $CFLAGS $2 $LDFLAGSCLI $LDFLAGS -o conftest"
117 if $cc_cmd >conftest.log 2>&1; then
123 log_msg "Failed commandline was:"
124 log_msg "--------------------------------------------------"
126 cat conftest.log >> config.log
127 log_msg "--------------------------------------------------"
128 log_msg "Failed program was:"
129 log_msg "--------------------------------------------------"
130 cat conftest.c >> config.log
131 log_msg "--------------------------------------------------"
137 log_check "whether $3 is true"
139 [ -n "$1" ] && echo "#include <$1>" > conftest.c
140 echo -e "#if !($3) \n#error $4 \n#endif " >> conftest.c
142 if $CC conftest.c $CFLAGS $2 -E -o conftest >conftest.log 2>&1; then
148 log_msg "--------------------------------------------------"
149 cat conftest.log >> config.log
150 log_msg "--------------------------------------------------"
151 log_msg "Failed program was:"
152 log_msg "--------------------------------------------------"
153 cat conftest.c >> config.log
154 log_msg "--------------------------------------------------"
160 log_check "whether $AS supports $1"
161 echo "$1" > conftest.asm
162 if $AS conftest.asm $ASFLAGS $2 -o conftest.o >conftest.log 2>&1; then
168 log_msg "Failed commandline was:"
169 log_msg "--------------------------------------------------"
170 log_msg "$AS conftest.asm $ASFLAGS $2 -o conftest.o"
171 cat conftest.log >> config.log
172 log_msg "--------------------------------------------------"
173 log_msg "Failed program was:"
174 log_msg "--------------------------------------------------"
175 cat conftest.asm >> config.log
176 log_msg "--------------------------------------------------"
182 echo "#define $1$([ -n "$2" ] && echo " $2" || echo " 1")" >> config.h
191 rm -f x264_config.h config.h config.mak config.log x264.pc x264.def conftest*
194 exec_prefix='${prefix}'
195 bindir='${exec_prefix}/bin'
196 libdir='${exec_prefix}/lib'
197 includedir='${prefix}/include'
216 CFLAGS="$CFLAGS -Wall -I."
218 LDFLAGSCLI="$LDFLAGSCLI"
225 # list of all preprocessor HAVE values we can define
226 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"
237 exec_prefix="$optarg"
267 ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
270 CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
273 LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
278 --enable-win32thread)
289 LDFLAGS="$LDFLAGS -pg"
302 host="${opt#--host=}"
305 cross_prefix="${opt#--cross-prefix=}"
308 CFLAGS="$CFLAGS --sysroot=${opt#--sysroot=}"
309 LDFLAGS="$LDFLAGS --sysroot=${opt#--sysroot=}"
312 bit_depth="${opt#--bit-depth=}"
313 if [ "$bit_depth" -lt "8" -o "$bit_depth" -gt "10" ]; then
314 echo "Supplied bit depth must be in range [8,10]."
317 bit_depth=`expr $bit_depth + 0`
320 echo "Unknown option $opt, ignored"
325 CC="${CC-${cross_prefix}gcc}"
326 AR="${AR-${cross_prefix}ar}"
327 RANLIB="${RANLIB-${cross_prefix}ranlib}"
328 STRIP="${STRIP-${cross_prefix}strip}"
330 if [ "x$host" = x ]; then
331 host=`./config.guess`
333 # normalize a triplet into a quadruplet
334 host=`./config.sub $host`
337 host_cpu="${host%%-*}"
339 host_vendor="${host%%-*}"
342 # test for use of Intel Compiler
343 if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
344 if [[ `basename "$CC"` = icl* ]]; then
345 # Windows Intel Compiler creates dependency generation with absolute Windows paths, Cygwin's make does not support Windows paths.
346 [[ $host_os = cygwin* ]] && die "Windows Intel Compiler support requires MSYS"
348 CFLAGS="$CFLAGS -Qstd=c99 -nologo -Qms0 -DHAVE_STRING_H -Iextras"
350 `$CC 2>&1 | grep -q IA-32` && host_cpu=i486
351 `$CC 2>&1 | grep -q "Intel(R) 64"` && host_cpu=x86_64
352 cpp_check "" "" "_MSC_VER >= 1400" || die "Windows Intel Compiler support requires Visual Studio 2005 or newer"
355 if [[ `basename "$CC"` = icc* ]]; then
369 CFLAGS="$CFLAGS -falign-loops=16"
370 LDFLAGS="$LDFLAGS -lm"
371 if [ "$pic" = "no" ]; then
372 cc_check "" -mdynamic-no-pic && CFLAGS="$CFLAGS -mdynamic-no-pic"
377 LDFLAGS="$LDFLAGS -lm"
382 LDFLAGS="$LDFLAGS -lm"
386 LDFLAGS="$LDFLAGS -lm"
390 LDFLAGS="$LDFLAGS -lm"
395 LDFLAGS="$LDFLAGS -lm"
399 if cc_check "" -mno-cygwin; then
400 CFLAGS="$CFLAGS -mno-cygwin"
401 LDFLAGS="$LDFLAGS -mno-cygwin"
403 if cpp_check "" "" "defined(__CYGWIN32__)" ; then
419 LDFLAGS="$LDFLAGS -lm"
423 die "Unknown system $host, edit the configure"
431 ASFLAGS="$ASFLAGS -O2"
432 if [ $compiler = GNU ]; then
433 if [[ "$asm" == auto && "$CFLAGS" != *-march* ]]; then
434 CFLAGS="$CFLAGS -march=i686"
436 if [[ "$asm" == auto && "$CFLAGS" != *-mfpmath* ]]; then
437 CFLAGS="$CFLAGS -mfpmath=sse -msse"
440 # icc on linux has various degrees of mod16 stack support
441 if [ $SYS = LINUX ]; then
442 # < 11 is completely incapable of keeping a mod16 stack
443 if cpp_check "" "" "__INTEL_COMPILER < 1100" ; then
444 define BROKEN_STACK_ALIGNMENT
445 # 11 <= x < 12 is capable of keeping a mod16 stack, but defaults to not doing so.
446 elif cpp_check "" "" "__INTEL_COMPILER < 1200" ; then
447 CFLAGS="$CFLAGS -falign-stack=assume-16-byte"
449 # >= 12 defaults to a mod16 stack
451 # icl on windows has no mod16 stack support
452 [ $SYS = WINDOWS ] && define BROKEN_STACK_ALIGNMENT
454 if [ "$SYS" = MACOSX ]; then
455 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
456 elif [ "$SYS" = WINDOWS -o "$SYS" = CYGWIN ]; then
457 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
458 LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
460 ASFLAGS="$ASFLAGS -f elf"
466 if [ "$SYS" = MACOSX ]; then
467 ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
468 if cc_check '' "-arch x86_64"; then
469 CFLAGS="$CFLAGS -arch x86_64"
470 LDFLAGS="$LDFLAGS -arch x86_64"
472 elif [ "$SYS" = WINDOWS ]; then
473 ASFLAGS="$ASFLAGS -f win32 -m amd64"
474 # only the GNU toolchain is inconsistent in prefixing function names with _
475 [ $compiler = GNU ] && cc_check "" "-S" && grep -q "_main:" conftest && ASFLAGS="$ASFLAGS -DPREFIX"
477 ASFLAGS="$ASFLAGS -f elf -m amd64"
482 if [ $asm = auto ] ; then
484 AS="${AS-${cross_prefix}gcc}"
485 if [ $SYS = MACOSX ] ; then
486 CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4"
488 CFLAGS="$CFLAGS -maltivec -mabi=altivec"
489 define HAVE_ALTIVEC_H
497 if [ $asm = auto ]; then
499 if ! echo $CFLAGS | grep -Eq '\-mcpu' ; then
500 CFLAGS="$CFLAGS -mcpu=ultrasparc"
501 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
503 AS="${AS-${cross_prefix}as}"
504 ASFLAGS="$ASFLAGS -xarch=v8plusa"
509 mips|mipsel|mips64|mips64el)
514 if [ "$SYS" = MACOSX ] ; then
515 AS="${AS-extras/gas-preprocessor.pl $CC}"
516 ASFLAGS="$ASFLAGS -DPREFIX -DPIC" # apple's ld doesn't support movw/movt relocations at all
517 # build for armv7 by default
518 if ! echo $CFLAGS | grep -Eq '\-arch' ; then
519 CFLAGS="$CFLAGS -arch armv7"
520 LDFLAGS="$LDFLAGS -arch armv7"
523 AS="${AS-${cross_prefix}gcc}"
536 ARCH="$(echo $host_cpu | tr a-z A-Z)"
540 log_msg "x264 configure script"
542 msg="Command line options:"
552 cc_check || die "No working C compiler found."
554 if [ $compiler != ICL ]; then
555 if cc_check '' -std=gnu99 'for( int i = 0; i < 9; i++ );' ; then
556 CFLAGS="$CFLAGS -std=gnu99"
557 elif cc_check '' -std=c99 'for( int i = 0; i < 9; i++ );' ; then
558 CFLAGS="$CFLAGS -std=c99 -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE"
559 elif ! cc_check '' '' 'for( int i = 0; i < 9; i++ );' ; then
560 die "C99 compiler is needed for compilation."
564 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" -o $ARCH = "IA64" \) ] ; then
568 if [ $asm = auto -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
569 if ! as_check "vpaddw xmm0, xmm0, xmm0" ; then
570 VER=`($AS --version || echo no assembler) 2>/dev/null | head -n 1`
572 echo "Minimum version is yasm-0.7.0"
573 echo "If you really want to compile without asm, configure with --disable-asm."
576 if ! cc_check '' '' '__asm__("pabsw %xmm0, %xmm0");' ; then
577 VER=`(${cross_prefix}as --version || echo no gnu as) 2>/dev/null | head -n 1`
579 echo "Minimum version is binutils-2.17"
580 echo "Your compiler can't handle inline SSSE3 asm."
581 echo "If you really want to compile without asm, configure with --disable-asm."
587 if [ $asm = auto -a $ARCH = ARM ] ; then
588 # set flags so neon is built by default
589 echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu|-mfloat-abi)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp"
591 if cc_check '' '' '__asm__("rev ip, ip");' ; then define HAVE_ARMV6
592 cc_check '' '' '__asm__("movt r0, #0");' && define HAVE_ARMV6T2
593 cc_check '' '' '__asm__("vadd.i16 q0, q0, q0");' && define HAVE_NEON
594 ASFLAGS="$ASFLAGS $CFLAGS -c"
596 echo "You specified a pre-ARMv6 or Thumb-1 CPU in your CFLAGS."
597 echo "If you really want to run on such a CPU, configure with --disable-asm."
602 [ $asm = no ] && AS=""
603 [ "x$AS" = x ] && asm="no" || asm="yes"
608 # skip endianness check for Intel Compiler, as all supported platforms are little. the -ipo flag will also cause the check to fail
609 if [ $compiler = GNU ]; then
610 echo "int i[2] = {0x42494745,0}; double f[2] = {0x1.0656e6469616ep+102,0};" > conftest.c
611 $CC $CFLAGS conftest.c -c -o conftest.o 2>/dev/null || die "endian test failed"
612 if (${cross_prefix}strings -a conftest.o | grep -q BIGE) && (${cross_prefix}strings -a conftest.o | grep -q FPendian) ; then
613 define WORDS_BIGENDIAN
614 elif !(${cross_prefix}strings -a conftest.o | grep -q EGIB && ${cross_prefix}strings -a conftest.o | grep -q naidnePF) ; then
615 die "endian test failed"
619 # autodetect options that weren't forced nor disabled
621 # pthread-win32 is lgpl, prevent its use if --disable-gpl is specified and targeting windows
622 [ "$SYS" = "WINDOWS" -a "$gpl" = "no" -a "$thread" = "auto" ] && thread="win32"
625 if [ "$thread" = "auto" ]; then
630 define HAVE_BEOSTHREAD
633 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
635 libpthread="-lpthread"
636 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
638 libpthread="-lpthreadGC2"
639 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
641 libpthread="-lpthreadGC2 -lwsock32"
642 define PTW32_STATIC_LIB
643 elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
645 libpthread="-lpthreadGC2 -lws2_32"
646 define PTW32_STATIC_LIB
648 # default to native threading if pthread-win32 is unavailable
653 cc_check pthread.h -pthread && thread="posix" && libpthread="-pthread"
656 cc_check pthread.h -lpthread && thread="posix" && libpthread="-lpthread"
660 if [ "$thread" = "posix" ]; then
661 LDFLAGS="$LDFLAGS $libpthread"
662 define HAVE_POSIXTHREAD
664 if [ "$thread" = "win32" ]; then
665 # cygwin does not support win32 threads
666 if [ "$SYS" = "WINDOWS" ]; then
667 define HAVE_WIN32THREAD
672 [ "$thread" != "no" ] && define HAVE_THREAD
674 if cc_check "math.h" "-Werror" "return log2f(2);" ; then
678 if [ "$vis" = "yes" ] ; then
679 save_CFLAGS="$CFLAGS"
680 CFLAGS="$CFLAGS -I/usr/X11R6/include"
681 if cc_check "X11/Xlib.h" "-L/usr/X11R6/lib -lX11" "XOpenDisplay(0);" ; then
682 LDFLAGS="-L/usr/X11R6/lib -lX11 $LDFLAGS"
683 define HAVE_VISUALIZE
686 CFLAGS="$save_CFLAGS"
690 if [ "$swscale" = "auto" ] ; then
692 if ${cross_prefix}pkg-config --exists libswscale 2>/dev/null; then
693 SWSCALE_LIBS="$SWSCALE_LIBS $(${cross_prefix}pkg-config --libs libswscale)"
694 SWSCALE_CFLAGS="$SWSCALE_CFLAGS $(${cross_prefix}pkg-config --cflags libswscale)"
696 [ -z "$SWSCALE_LIBS" ] && SWSCALE_LIBS="-lswscale -lavutil"
698 error="swscale must be at least version 0.9.0"
699 if cc_check "libswscale/swscale.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "sws_getContext(0,0,0,0,0,0,0,0,0,0);" ; then
700 if cpp_check "libswscale/swscale.h" "$SWSCALE_CFLAGS" "LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(0,9,0)" "$error"; then
701 # we use colorspaces that were defined in libavutil r19775
702 if cc_check "libavutil/pixfmt.h" "$SWSCALE_CFLAGS" "enum PixelFormat pixfmt = PIX_FMT_YUV422P16LE;" ; then
705 echo "Warning: libavutil is too old, update to ffmpeg r19775+"
708 echo "Warning: ${error}"
713 if [ "$lavf" = "auto" ] ; then
715 if ${cross_prefix}pkg-config --exists libavformat libavcodec libswscale 2>/dev/null; then
716 LAVF_LIBS="$LAVF_LIBS $(${cross_prefix}pkg-config --libs libavformat libavcodec libavutil libswscale)"
717 LAVF_CFLAGS="$LAVF_CFLAGS $(${cross_prefix}pkg-config --cflags libavformat libavcodec libavutil libswscale)"
719 if [ -z "$LAVF_LIBS" -a -z "$LAVF_CFLAGS" ]; then
720 LAVF_LIBS="-lavformat"
721 for lib in -lpostproc -lavcodec -lavcore -lswscale -lavutil -lm -lz -lbz2 $libpthread -lavifil32; do
722 cc_check "" $lib && LAVF_LIBS="$LAVF_LIBS $lib"
725 LAVF_LIBS="-L. $LAVF_LIBS"
726 if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "avcodec_decode_video2(0,0,0,0);" ; then
727 if cpp_check libavcodec/avcodec.h "$LAVF_CFLAGS $LAVF_LIBS" "LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,64,0)" ; then
728 if [ "$swscale" = "yes" ]; then
731 echo "Warning: libavformat is not supported without swscale support"
734 echo "Warning: libavcodec is too old, update to ffmpeg r22735+"
739 if [ "$ffms" = "auto" ] ; then
740 ffms_major="2"; ffms_minor="14"; ffms_micro="0"; ffms_bump="0"
743 if ${cross_prefix}pkg-config --exists ffms2 2>/dev/null; then
744 FFMS2_LIBS="$FFMS2_LIBS $(${cross_prefix}pkg-config --libs ffms2)"
745 FFMS2_CFLAGS="$FFMS2_CFLAGS $(${cross_prefix}pkg-config --cflags ffms2)"
747 [ -z "$FFMS2_LIBS" ] && FFMS2_LIBS="-lffms2"
749 if cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS" "FFMS_DestroyVideoSource(0);" ; then
751 elif cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS -lstdc++ $LAVF_LIBS" "FFMS_DestroyVideoSource(0);" ; then
753 FFMS2_LIBS="$FFMS2_LIBS -lstdc++ $LAVF_LIBS"
756 error="ffms must be at least version $ffms_major.$ffms_minor.$ffms_micro.$ffms_bump"
757 if [ $ffms = "yes" ] && ! cpp_check "ffms.h" "$FFMS2_CFLAGS" "FFMS_VERSION >= (($ffms_major << 24) | ($ffms_minor << 16) | ($ffms_micro << 8) | $ffms_bump)" "$error"; then
759 echo "Warning: $error"
761 if [ "$ffms" = "yes" -a "$swscale" = "no" ]; then
762 echo "Warning: ffms is not supported without swscale support"
767 if [ "$swscale" = "yes" ]; then
768 LDFLAGSCLI="$SWSCALE_LIBS $LDFLAGSCLI"
769 CFLAGS="$CFLAGS $SWSCALE_CFLAGS"
771 if [ "$lavf" = "yes" ]; then
772 LDFLAGSCLI="$LAVF_LIBS $LDFLAGSCLI"
773 CFLAGS="$CFLAGS $LAVF_CFLAGS"
776 if [ "$ffms" = "yes" ]; then
777 LDFLAGSCLI="$FFMS2_LIBS $LDFLAGSCLI"
778 CFLAGS="$CFLAGS $FFMS2_CFLAGS"
783 GPAC_LIBS="-lgpac_static"
784 if [ $SYS = WINDOWS ]; then
785 GPAC_LIBS="$GPAC_LIBS -lwinmm"
787 if [ "$gpac" = "auto" ] ; then
789 if cc_check gpac/isomedia.h "$GPAC_LIBS" ; then
790 if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0);" ; then
793 echo "Warning: gpac is too old, update to 2007-06-21 UTC or later"
797 if [ "$gpac" = "yes" ] ; then
799 if cc_check gpac/isomedia.h "-Werror $GPAC_LIBS" "gf_malloc(1); gf_free(NULL);" ; then
800 define HAVE_GF_MALLOC
802 LDFLAGSCLI="$GPAC_LIBS $LDFLAGSCLI"
805 if [ "$avs" = "auto" ] ; then
807 # cygwin can use avisynth if it can use LoadLibrary
808 if [ $SYS = WINDOWS ] || ([ $SYS = CYGWIN ] && cc_check windows.h "" "LoadLibrary(0);") ; then
814 cc_check "stdint.h" "" "uint32_t test_vec __attribute__ ((vector_size (16))) = {0,1,2,3};" && define HAVE_VECTOREXT
816 if [ "$pic" = "yes" ] ; then
817 CFLAGS="$CFLAGS -fPIC"
818 ASFLAGS="$ASFLAGS -DPIC"
819 # resolve textrels in the x86 asm
820 cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
823 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
824 CFLAGS="$CFLAGS -s -fomit-frame-pointer"
825 LDFLAGS="$LDFLAGS -s"
828 if [ "$debug" = "yes" ]; then
829 CFLAGS="-O1 -g $CFLAGS"
830 elif [ $ARCH = ARM ]; then
831 # arm-gcc-4.2 produces incorrect output with -ffast-math
832 # and it doesn't save any speed anyway on 4.4, so disable it
833 CFLAGS="-O3 -fno-fast-math $CFLAGS"
835 CFLAGS="-O3 -ffast-math $CFLAGS"
838 if cc_check '' -fno-tree-vectorize ; then
839 CFLAGS="$CFLAGS -fno-tree-vectorize"
842 if [ $SYS = WINDOWS -a $ARCH = X86 -a $compiler = GNU ] ; then
843 # workaround gcc/ld bug with alignment of static variables/arrays that are initialized to zero
844 cc_check '' -fno-zero-initialized-in-bss && CFLAGS="$CFLAGS -fno-zero-initialized-in-bss"
847 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
850 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
851 define fseek fseeko64
852 define ftell ftello64
853 elif cc_check "stdio.h" "" "_fseeki64(stdin,0,0);" ; then
854 define fseek _fseeki64
855 define ftell _ftelli64
858 if cc_check '' -Wshadow ; then
859 CFLAGS="-Wshadow $CFLAGS"
862 if [ "$bit_depth" -gt "8" ]; then
863 define HIGH_BIT_DEPTH
864 ASFLAGS="$ASFLAGS -DHIGH_BIT_DEPTH"
867 ASFLAGS="$ASFLAGS -DBIT_DEPTH=$bit_depth"
869 [ $gpl = yes ] && define HAVE_GPL && x264_gpl=1 || x264_gpl=0
871 #define undefined vars as 0
872 for var in $CONFIG_HAVE; do
873 grep -q "HAVE_$var 1" config.h || define HAVE_$var 0
876 if [ $compiler = ICL ]; then
877 AR="xilib -nologo -out:"
882 LDFLAGS="-nologo -incremental:no $(icl_ldflags $LDFLAGS)"
883 LDFLAGSCLI="$(icl_ldflags $LDFLAGSCLI)"
887 if [ $debug = yes ]; then
888 LDFLAGS="-debug $LDFLAGS"
889 CFLAGS="-D_DEBUG $CFLAGS"
891 CFLAGS="-DNDEBUG $CFLAGS"
900 if [ $compiler = GNU ]; then
901 PROF_GEN_CC="-fprofile-generate"
902 PROF_GEN_LD="-fprofile-generate"
903 PROF_USE_CC="-fprofile-use"
904 PROF_USE_LD="-fprofile-use"
906 CFLAGS="$(intel_cflags $CFLAGS)"
907 # icc does not define __SSE__ until SSE2 optimization and icl never defines it or _M_IX86_FP
908 [ \( $ARCH = X86_64 -o $ARCH = X86 \) -a $asm = yes ] && ! cpp_check "" "" "defined(__SSE__)" && define __SSE__
909 PROF_GEN_CC="${QPRE}prof-gen ${QPRE}prof-dir."
911 PROF_USE_CC="${QPRE}prof-use ${QPRE}prof-dir."
917 # generate exported config file
919 cat > x264_config.h << EOF
920 #define X264_BIT_DEPTH $bit_depth
921 #define X264_GPL $x264_gpl
924 # generate config files
926 cat > config.mak << EOF
928 exec_prefix=$exec_prefix
931 includedir=$includedir
940 LDFLAGSCLI=$LDFLAGSCLI
948 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
950 PROF_GEN_CC=$PROF_GEN_CC
951 PROF_GEN_LD=$PROF_GEN_LD
952 PROF_USE_CC=$PROF_USE_CC
953 PROF_USE_LD=$PROF_USE_LD
956 if [ $compiler = ICL ]; then
957 echo '%.o: %.c' >> config.mak
958 echo ' $(CC) $(CFLAGS) -c -Fo$@ $<' >> config.mak
961 if [ "$shared" = "yes" ]; then
962 API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
963 if [ "$SYS" = "WINDOWS" -o "$SYS" = "CYGWIN" ]; then
964 echo "SONAME=libx264-$API.dll" >> config.mak
965 if [ $compiler = ICL ]; then
966 echo 'IMPLIBNAME=libx264.dll.lib' >> config.mak
967 # GNU ld on windows defaults to exporting all global functions if there are no explicit __declspec(dllexport) declarations
968 # MSVC link does not act similarly, so it is required to make an export definition out of x264.h and use it at link time
969 echo 'SOFLAGS=-dll -def:x264.def -implib:$(IMPLIBNAME)' >> config.mak
970 echo "EXPORTS" > x264.def
971 grep "^\(int\|void\|x264_t\|extern\).*x264.*[\[(;]" x264.h | sed -e "s/.*\(x264.*\)[\[(].*/\1/;s/.*\(x264.*\);/\1/;s/open/open_$API/g" >> x264.def
973 echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
974 echo 'SOFLAGS=-shared -Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
976 elif [ "$SYS" = "MACOSX" ]; then
977 echo "SOSUFFIX=dylib" >> config.mak
978 echo "SONAME=libx264.$API.dylib" >> config.mak
979 echo 'SOFLAGS=-shared -dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak
980 elif [ "$SYS" = "SunOS" ]; then
981 echo "SOSUFFIX=so" >> config.mak
982 echo "SONAME=libx264.so.$API" >> config.mak
983 echo 'SOFLAGS=-shared -Wl,-h,$(SONAME)' >> config.mak
985 echo "SOSUFFIX=so" >> config.mak
986 echo "SONAME=libx264.so.$API" >> config.mak
987 echo 'SOFLAGS=-shared -Wl,-soname,$(SONAME)' >> config.mak
989 echo 'default: $(SONAME)' >> config.mak
992 ./version.sh >> config.h
994 pclibs="-L$libdir -lx264 $libpthread"
998 exec_prefix=$exec_prefix
1000 includedir=$includedir
1003 Description: H.264 (MPEG4 AVC) encoder library
1004 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
1006 Cflags: -I$includedir
1009 filters="crop select_every"
1011 [ $swscale = yes ] && filters="resize $filters"
1012 [ $gpl = yes ] && filters="$filters $gpl_filters"
1014 cat > conftest.log <<EOF
1030 bit depth: $bit_depth
1034 cat conftest.log >> config.log
1039 echo "You can run 'make' or 'make fprofiled' now."