3 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
5 Usage: ./configure [options]
9 --help print this message
10 --disable-cli disables cli
11 --system-libx264 use system libx264 instead of internal
12 --enable-shared build shared library
13 --enable-static build static library
14 --disable-avs disables avisynth support (windows only)
15 --disable-lavf disables libavformat support
16 --disable-ffms disables ffmpegsource support
17 --disable-gpac disables gpac support
18 --disable-gpl disables GPL-only features
19 --disable-thread disables multithreaded encoding
20 --enable-win32thread use win32threads (windows only)
21 --disable-swscale disables swscale support
22 --disable-asm disables platform-specific assembly optimizations
23 --disable-interlaced disables interlaced encoding support
24 --enable-debug adds -g
25 --enable-gprof adds -pg
26 --enable-strip adds -s
27 --enable-visualize enables visualization (X11 only)
28 --enable-pic build position-independent code
29 --bit-depth=BIT_DEPTH sets output bit depth (8-10), default 8
30 --extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS
31 --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS
32 --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS
33 --host=HOST build programs to run on HOST
34 --cross-prefix=PREFIX use PREFIX for compilation tools
35 --sysroot=SYSROOT root of cross-build tree
42 echo -n "checking $1... " >> config.log
46 echo "yes" >> config.log
50 echo "no" >> config.log
54 echo "$1" >> config.log
58 # Intel Compiler issues an incredibly large number of warnings on any warning level,
59 # suppress them by disabling all warnings rather than having to use #pragmas to disable most of them
61 [ $arg = -ffast-math ] && arg=
62 [[ "$arg" = -falign-loops* ]] && arg=
63 [ "$arg" = -fno-tree-vectorize ] && arg=
64 [ "$arg" = -Wshadow ] && arg=
65 if [ $compiler = ICL ]; then
66 [ "$arg" = -Wall ] && arg=-W0
67 [ "$arg" = -g ] && arg=-Z7
68 [ "$arg" = -fomit-frame-pointer ] && arg=
69 [ "$arg" = -s ] && arg=
70 [ "$arg" = -fPIC ] && arg=
72 [ "$arg" = -Wall ] && arg=-w0
75 [ -n "$arg" ] && echo -n "$arg "
81 arg=${arg/LIBPATH/libpath}
82 [ ${arg#-libpath:} == $arg -a ${arg#-l} != $arg ] && arg=${arg#-l}.lib
83 [ ${arg#-L} != $arg ] && arg=-libpath:${arg#-L}
84 [ $arg = -Wl,--large-address-aware ] && arg=-largeaddressaware
86 [ "$arg" = -Wl,-Bsymbolic ] && arg=
88 arg=${arg/pthreadGC/pthreadVC}
89 [ "$arg" = avifil32.lib ] && arg=vfw32.lib
90 [ "$arg" = gpac_static.lib ] && arg=libgpac_static.lib
92 [ -n "$arg" ] && echo -n "$arg "
98 if [ -z "$1$2" ]; then
99 log_check "whether $CC works"
100 elif [ -z "$1" ]; then
105 elif [ -z "$1" ]; then
107 log_check "whether $CC supports $3"
109 log_check "whether $CC supports $3 with $2"
112 log_check "for $3 in $1";
115 [ -n "$1" ] && echo "#include <$1>" > conftest.c
116 echo "int main () { $3 return 0; }" >> conftest.c
117 if [ $compiler = ICL ]; then
118 cc_cmd="$CC conftest.c $CFLAGS $2 -link $(icl_ldflags $2 $LDFLAGSCLI $LDFLAGS)"
120 cc_cmd="$CC conftest.c $CFLAGS $2 $LDFLAGSCLI $LDFLAGS -o conftest"
122 if $cc_cmd >conftest.log 2>&1; then
128 log_msg "Failed commandline was:"
129 log_msg "--------------------------------------------------"
131 cat conftest.log >> config.log
132 log_msg "--------------------------------------------------"
133 log_msg "Failed program was:"
134 log_msg "--------------------------------------------------"
135 cat conftest.c >> config.log
136 log_msg "--------------------------------------------------"
142 log_check "whether $3 is true"
144 [ -n "$1" ] && echo "#include <$1>" > conftest.c
145 echo -e "#if !($3) \n#error $4 \n#endif " >> conftest.c
147 if $CC conftest.c $CFLAGS $2 -E -o conftest >conftest.log 2>&1; then
153 log_msg "--------------------------------------------------"
154 cat conftest.log >> config.log
155 log_msg "--------------------------------------------------"
156 log_msg "Failed program was:"
157 log_msg "--------------------------------------------------"
158 cat conftest.c >> config.log
159 log_msg "--------------------------------------------------"
165 log_check "whether $AS supports $1"
166 echo "$1" > conftest.asm
167 if $AS conftest.asm $ASFLAGS $2 -o conftest.o >conftest.log 2>&1; then
173 log_msg "Failed commandline was:"
174 log_msg "--------------------------------------------------"
175 log_msg "$AS conftest.asm $ASFLAGS $2 -o conftest.o"
176 cat conftest.log >> config.log
177 log_msg "--------------------------------------------------"
178 log_msg "Failed program was:"
179 log_msg "--------------------------------------------------"
180 cat conftest.asm >> config.log
181 log_msg "--------------------------------------------------"
187 echo "#define $1$([ -n "$2" ] && echo " $2" || echo " 1")" >> config.h
196 rm -f x264_config.h config.h config.mak config.log x264.pc x264.def conftest*
199 exec_prefix='${prefix}'
200 bindir='${exec_prefix}/bin'
201 libdir='${exec_prefix}/lib'
202 includedir='${prefix}/include'
206 cli_libx264="internal"
226 CFLAGS="$CFLAGS -Wall -I."
228 LDFLAGSCLI="$LDFLAGSCLI"
235 # list of all preprocessor HAVE values we can define
236 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"
247 exec_prefix="$optarg"
273 --disable-interlaced)
292 ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
295 CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
298 LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
303 --enable-win32thread)
314 LDFLAGS="$LDFLAGS -pg"
327 host="${opt#--host=}"
330 cross_prefix="${opt#--cross-prefix=}"
333 CFLAGS="$CFLAGS --sysroot=${opt#--sysroot=}"
334 LDFLAGS="$LDFLAGS --sysroot=${opt#--sysroot=}"
337 bit_depth="${opt#--bit-depth=}"
338 if [ "$bit_depth" -lt "8" -o "$bit_depth" -gt "10" ]; then
339 echo "Supplied bit depth must be in range [8,10]."
342 bit_depth=`expr $bit_depth + 0`
345 echo "Unknown option $opt, ignored"
350 [ "$cli" = "no" -a "$shared" = "no" -a "$static" = "no" ] && die "Nothing to build. Enable cli, shared or static."
352 CC="${CC-${cross_prefix}gcc}"
353 AR="${AR-${cross_prefix}ar}"
354 RANLIB="${RANLIB-${cross_prefix}ranlib}"
355 STRIP="${STRIP-${cross_prefix}strip}"
357 if [ "x$host" = x ]; then
358 host=`./config.guess`
360 # normalize a triplet into a quadruplet
361 host=`./config.sub $host`
364 host_cpu="${host%%-*}"
366 host_vendor="${host%%-*}"
369 # test for use of Intel Compiler
370 if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
371 if [[ `basename "$CC"` = icl* ]]; then
372 # Windows Intel Compiler creates dependency generation with absolute Windows paths, Cygwin's make does not support Windows paths.
373 [[ $host_os = cygwin* ]] && die "Windows Intel Compiler support requires MSYS"
375 CFLAGS="$CFLAGS -Qstd=c99 -nologo -Qms0 -DHAVE_STRING_H -Iextras"
377 `$CC 2>&1 | grep -q IA-32` && host_cpu=i486
378 `$CC 2>&1 | grep -q "Intel(R) 64"` && host_cpu=x86_64
379 cpp_check "" "" "_MSC_VER >= 1400" || die "Windows Intel Compiler support requires Visual Studio 2005 or newer"
382 if [[ `basename "$CC"` = icc* ]]; then
396 CFLAGS="$CFLAGS -falign-loops=16"
397 LDFLAGS="$LDFLAGS -lm"
398 if [ "$pic" = "no" ]; then
399 cc_check "" -mdynamic-no-pic && CFLAGS="$CFLAGS -mdynamic-no-pic"
404 LDFLAGS="$LDFLAGS -lm"
409 LDFLAGS="$LDFLAGS -lm"
413 LDFLAGS="$LDFLAGS -lm"
417 LDFLAGS="$LDFLAGS -lm"
422 LDFLAGS="$LDFLAGS -lm"
426 if cc_check "" -mno-cygwin; then
427 CFLAGS="$CFLAGS -mno-cygwin"
428 LDFLAGS="$LDFLAGS -mno-cygwin"
430 if cpp_check "" "" "defined(__CYGWIN32__)" ; then
446 LDFLAGS="$LDFLAGS -lm"
450 die "Unknown system $host, edit the configure"
458 ASFLAGS="$ASFLAGS -O2"
459 if [ $compiler = GNU ]; then
460 if [[ "$asm" == auto && "$CFLAGS" != *-march* ]]; then
461 CFLAGS="$CFLAGS -march=i686"
463 if [[ "$asm" == auto && "$CFLAGS" != *-mfpmath* ]]; then
464 CFLAGS="$CFLAGS -mfpmath=sse -msse"
467 # icc on linux has various degrees of mod16 stack support
468 if [ $SYS = LINUX ]; then
469 # < 11 is completely incapable of keeping a mod16 stack
470 if cpp_check "" "" "__INTEL_COMPILER < 1100" ; then
471 define BROKEN_STACK_ALIGNMENT
472 # 11 <= x < 12 is capable of keeping a mod16 stack, but defaults to not doing so.
473 elif cpp_check "" "" "__INTEL_COMPILER < 1200" ; then
474 CFLAGS="$CFLAGS -falign-stack=assume-16-byte"
476 # >= 12 defaults to a mod16 stack
478 # icl on windows has no mod16 stack support
479 [ $SYS = WINDOWS ] && define BROKEN_STACK_ALIGNMENT
481 if [ "$SYS" = MACOSX ]; then
482 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
483 elif [ "$SYS" = WINDOWS -o "$SYS" = CYGWIN ]; then
484 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
485 LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
487 ASFLAGS="$ASFLAGS -f elf"
493 if [ "$SYS" = MACOSX ]; then
494 ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
495 if cc_check '' "-arch x86_64"; then
496 CFLAGS="$CFLAGS -arch x86_64"
497 LDFLAGS="$LDFLAGS -arch x86_64"
499 elif [ "$SYS" = WINDOWS ]; then
500 ASFLAGS="$ASFLAGS -f win32 -m amd64"
501 # only the GNU toolchain is inconsistent in prefixing function names with _
502 [ $compiler = GNU ] && cc_check "" "-S" && grep -q "_main:" conftest && ASFLAGS="$ASFLAGS -DPREFIX"
504 ASFLAGS="$ASFLAGS -f elf -m amd64"
509 if [ $asm = auto ] ; then
511 AS="${AS-${cross_prefix}gcc}"
512 if [ $SYS = MACOSX ] ; then
513 CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4"
515 CFLAGS="$CFLAGS -maltivec -mabi=altivec"
516 define HAVE_ALTIVEC_H
524 if [ $asm = auto ]; then
526 if ! echo $CFLAGS | grep -Eq '\-mcpu' ; then
527 CFLAGS="$CFLAGS -mcpu=ultrasparc"
528 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
530 AS="${AS-${cross_prefix}as}"
531 ASFLAGS="$ASFLAGS -xarch=v8plusa"
536 mips|mipsel|mips64|mips64el)
541 if [ "$SYS" = MACOSX ] ; then
542 AS="${AS-extras/gas-preprocessor.pl $CC}"
543 ASFLAGS="$ASFLAGS -DPREFIX -DPIC" # apple's ld doesn't support movw/movt relocations at all
544 # build for armv7 by default
545 if ! echo $CFLAGS | grep -Eq '\-arch' ; then
546 CFLAGS="$CFLAGS -arch armv7"
547 LDFLAGS="$LDFLAGS -arch armv7"
550 AS="${AS-${cross_prefix}gcc}"
563 ARCH="$(echo $host_cpu | tr a-z A-Z)"
567 log_msg "x264 configure script"
569 msg="Command line options:"
579 cc_check || die "No working C compiler found."
581 if [ $compiler != ICL ]; then
582 if cc_check '' -std=gnu99 'for( int i = 0; i < 9; i++ );' ; then
583 CFLAGS="$CFLAGS -std=gnu99"
584 elif cc_check '' -std=c99 'for( int i = 0; i < 9; i++ );' ; then
585 CFLAGS="$CFLAGS -std=c99 -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE"
586 elif ! cc_check '' '' 'for( int i = 0; i < 9; i++ );' ; then
587 die "C99 compiler is needed for compilation."
591 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" -o $ARCH = "IA64" \) ] ; then
595 if [ $asm = auto -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
596 if ! as_check "vpaddw xmm0, xmm0, xmm0" ; then
597 VER=`($AS --version || echo no assembler) 2>/dev/null | head -n 1`
599 echo "Minimum version is yasm-0.7.0"
600 echo "If you really want to compile without asm, configure with --disable-asm."
603 if ! cc_check '' '' '__asm__("pabsw %xmm0, %xmm0");' ; then
604 VER=`(${cross_prefix}as --version || echo no gnu as) 2>/dev/null | head -n 1`
606 echo "Minimum version is binutils-2.17"
607 echo "Your compiler can't handle inline SSSE3 asm."
608 echo "If you really want to compile without asm, configure with --disable-asm."
614 if [ $asm = auto -a $ARCH = ARM ] ; then
615 # set flags so neon is built by default
616 echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu|-mfloat-abi)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp"
618 if cc_check '' '' '__asm__("rev ip, ip");' ; then define HAVE_ARMV6
619 cc_check '' '' '__asm__("movt r0, #0");' && define HAVE_ARMV6T2
620 cc_check '' '' '__asm__("vadd.i16 q0, q0, q0");' && define HAVE_NEON
621 ASFLAGS="$ASFLAGS $CFLAGS -c"
623 echo "You specified a pre-ARMv6 or Thumb-1 CPU in your CFLAGS."
624 echo "If you really want to run on such a CPU, configure with --disable-asm."
629 [ $asm = no ] && AS=""
630 [ "x$AS" = x ] && asm="no" || asm="yes"
635 # skip endianness check for Intel Compiler, as all supported platforms are little. the -ipo flag will also cause the check to fail
636 if [ $compiler = GNU ]; then
637 echo "int i[2] = {0x42494745,0}; double f[2] = {0x1.0656e6469616ep+102,0};" > conftest.c
638 $CC $CFLAGS conftest.c -c -o conftest.o 2>/dev/null || die "endian test failed"
639 if (${cross_prefix}strings -a conftest.o | grep -q BIGE) && (${cross_prefix}strings -a conftest.o | grep -q FPendian) ; then
640 define WORDS_BIGENDIAN
641 elif !(${cross_prefix}strings -a conftest.o | grep -q EGIB && ${cross_prefix}strings -a conftest.o | grep -q naidnePF) ; then
642 die "endian test failed"
646 # autodetect options that weren't forced nor disabled
648 # pthread-win32 is lgpl, prevent its use if --disable-gpl is specified and targeting windows
649 [ "$SYS" = "WINDOWS" -a "$gpl" = "no" -a "$thread" = "auto" ] && thread="win32"
652 if [ "$thread" = "auto" ]; then
657 define HAVE_BEOSTHREAD
660 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
662 libpthread="-lpthread"
663 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
665 libpthread="-lpthreadGC2"
666 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
668 libpthread="-lpthreadGC2 -lwsock32"
669 define PTW32_STATIC_LIB
670 elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
672 libpthread="-lpthreadGC2 -lws2_32"
673 define PTW32_STATIC_LIB
675 # default to native threading if pthread-win32 is unavailable
680 cc_check pthread.h -pthread && thread="posix" && libpthread="-pthread"
683 cc_check pthread.h -lpthread && thread="posix" && libpthread="-lpthread"
687 if [ "$thread" = "posix" ]; then
688 LDFLAGS="$LDFLAGS $libpthread"
689 define HAVE_POSIXTHREAD
691 if [ "$thread" = "win32" ]; then
692 # cygwin does not support win32 threads
693 if [ "$SYS" = "WINDOWS" ]; then
694 define HAVE_WIN32THREAD
699 [ "$thread" != "no" ] && define HAVE_THREAD
701 if cc_check "math.h" "-Werror" "return log2f(2);" ; then
705 if [ "$vis" = "yes" ] ; then
706 save_CFLAGS="$CFLAGS"
707 CFLAGS="$CFLAGS -I/usr/X11R6/include"
708 if cc_check "X11/Xlib.h" "-L/usr/X11R6/lib -lX11" "XOpenDisplay(0);" ; then
709 LDFLAGS="-L/usr/X11R6/lib -lX11 $LDFLAGS"
710 define HAVE_VISUALIZE
713 CFLAGS="$save_CFLAGS"
717 if [ "$swscale" = "auto" ] ; then
719 if ${cross_prefix}pkg-config --exists libswscale 2>/dev/null; then
720 SWSCALE_LIBS="$SWSCALE_LIBS $(${cross_prefix}pkg-config --libs libswscale libavutil)"
721 SWSCALE_CFLAGS="$SWSCALE_CFLAGS $(${cross_prefix}pkg-config --cflags libswscale libavutil)"
723 [ -z "$SWSCALE_LIBS" ] && SWSCALE_LIBS="-lswscale -lavutil"
725 if cc_check "libswscale/swscale.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "sws_init_context(0,0,0);" ; then
726 if cc_check "libavutil/pixdesc.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "av_get_pix_fmt_name(0);" ; then
729 echo "Warning: av_get_pix_fmt_name is missing from libavutil, update for swscale support"
734 if [ "$lavf" = "auto" ] ; then
736 if ${cross_prefix}pkg-config --exists libavformat libavcodec libswscale 2>/dev/null; then
737 LAVF_LIBS="$LAVF_LIBS $(${cross_prefix}pkg-config --libs libavformat libavcodec libavutil libswscale)"
738 LAVF_CFLAGS="$LAVF_CFLAGS $(${cross_prefix}pkg-config --cflags libavformat libavcodec libavutil libswscale)"
740 if [ -z "$LAVF_LIBS" -a -z "$LAVF_CFLAGS" ]; then
741 LAVF_LIBS="-lavformat"
742 for lib in -lpostproc -lavcodec -lavcore -lswscale -lavutil -lm -lz -lbz2 $libpthread -lavifil32; do
743 cc_check "" $lib && LAVF_LIBS="$LAVF_LIBS $lib"
746 LAVF_LIBS="-L. $LAVF_LIBS"
747 if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "avformat_open_input(0,0,0,0);" ; then
748 if [ "$swscale" = "yes" ]; then
751 echo "Warning: libavformat is not supported without swscale support"
756 if [ "$ffms" = "auto" ] ; then
757 ffms_major="2"; ffms_minor="14"; ffms_micro="0"; ffms_bump="0"
760 if ${cross_prefix}pkg-config --exists ffms2 2>/dev/null; then
761 FFMS2_LIBS="$FFMS2_LIBS $(${cross_prefix}pkg-config --libs ffms2)"
762 FFMS2_CFLAGS="$FFMS2_CFLAGS $(${cross_prefix}pkg-config --cflags ffms2)"
764 [ -z "$FFMS2_LIBS" ] && FFMS2_LIBS="-lffms2"
766 if cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS" "FFMS_DestroyVideoSource(0);" ; then
768 elif cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS -lstdc++ $LAVF_LIBS" "FFMS_DestroyVideoSource(0);" ; then
770 FFMS2_LIBS="$FFMS2_LIBS -lstdc++ $LAVF_LIBS"
773 error="ffms must be at least version $ffms_major.$ffms_minor.$ffms_micro.$ffms_bump"
774 if [ $ffms = "yes" ] && ! cpp_check "ffms.h" "$FFMS2_CFLAGS" "FFMS_VERSION >= (($ffms_major << 24) | ($ffms_minor << 16) | ($ffms_micro << 8) | $ffms_bump)" "$error"; then
776 echo "Warning: $error"
778 if [ "$ffms" = "yes" -a "$swscale" = "no" ]; then
779 echo "Warning: ffms is not supported without swscale support"
784 if [ "$swscale" = "yes" ]; then
785 LDFLAGSCLI="$SWSCALE_LIBS $LDFLAGSCLI"
786 CFLAGS="$CFLAGS $SWSCALE_CFLAGS"
788 if [ "$lavf" = "yes" ]; then
789 LDFLAGSCLI="$LAVF_LIBS $LDFLAGSCLI"
790 CFLAGS="$CFLAGS $LAVF_CFLAGS"
793 if [ "$ffms" = "yes" ]; then
794 LDFLAGSCLI="$FFMS2_LIBS $LDFLAGSCLI"
795 CFLAGS="$CFLAGS $FFMS2_CFLAGS"
800 if [ "$gpac" = "auto" ] ; then
802 cc_check "" -lz && GPAC_LIBS="-lgpac_static -lz" || GPAC_LIBS="-lgpac_static"
803 if [ "$SYS" = "WINDOWS" ] ; then
804 GPAC_LIBS="$GPAC_LIBS -lwinmm"
806 if cc_check gpac/isomedia.h "$GPAC_LIBS" ; then
807 if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0);" ; then
810 echo "Warning: gpac is too old, update to 2007-06-21 UTC or later"
814 if [ "$gpac" = "yes" ] ; then
816 if cc_check gpac/isomedia.h "-Werror $GPAC_LIBS" "gf_malloc(1); gf_free(NULL);" ; then
817 define HAVE_GF_MALLOC
819 LDFLAGSCLI="$GPAC_LIBS $LDFLAGSCLI"
822 if [ "$avs" = "auto" ] ; then
824 # cygwin can use avisynth if it can use LoadLibrary
825 if [ $SYS = WINDOWS ] || ([ $SYS = CYGWIN ] && cc_check windows.h "" "LoadLibrary(0);") ; then
831 cc_check "stdint.h" "" "uint32_t test_vec __attribute__ ((vector_size (16))) = {0,1,2,3};" && define HAVE_VECTOREXT
833 if [ "$pic" = "yes" ] ; then
834 CFLAGS="$CFLAGS -fPIC"
835 ASFLAGS="$ASFLAGS -DPIC"
836 # resolve textrels in the x86 asm
837 cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
840 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
841 CFLAGS="$CFLAGS -fomit-frame-pointer"
844 if [ "$strip" = "yes" ]; then
846 LDFLAGS="$LDFLAGS -s"
849 if [ "$debug" = "yes" ]; then
850 CFLAGS="-O1 -g $CFLAGS"
851 elif [ $ARCH = ARM ]; then
852 # arm-gcc-4.2 produces incorrect output with -ffast-math
853 # and it doesn't save any speed anyway on 4.4, so disable it
854 CFLAGS="-O3 -fno-fast-math $CFLAGS"
856 CFLAGS="-O3 -ffast-math $CFLAGS"
859 if cc_check '' -fno-tree-vectorize ; then
860 CFLAGS="$CFLAGS -fno-tree-vectorize"
863 if [ $SYS = WINDOWS -a $ARCH = X86 -a $compiler = GNU ] ; then
864 # workaround gcc/ld bug with alignment of static variables/arrays that are initialized to zero
865 cc_check '' -fno-zero-initialized-in-bss && CFLAGS="$CFLAGS -fno-zero-initialized-in-bss"
868 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
871 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
872 define fseek fseeko64
873 define ftell ftello64
874 elif cc_check "stdio.h" "" "_fseeki64(stdin,0,0);" ; then
875 define fseek _fseeki64
876 define ftell _ftelli64
879 if cc_check '' -Wshadow ; then
880 CFLAGS="-Wshadow $CFLAGS"
883 if [ "$bit_depth" -gt "8" ]; then
884 define HIGH_BIT_DEPTH
885 ASFLAGS="$ASFLAGS -DHIGH_BIT_DEPTH"
888 ASFLAGS="$ASFLAGS -DBIT_DEPTH=$bit_depth"
890 [ $gpl = yes ] && define HAVE_GPL && x264_gpl=1 || x264_gpl=0
892 [ $interlaced = yes ] && define HAVE_INTERLACED && x264_interlaced=1 || x264_interlaced=0
894 #define undefined vars as 0
895 for var in $CONFIG_HAVE; do
896 grep -q "HAVE_$var 1" config.h || define HAVE_$var 0
899 if [ $compiler = ICL ]; then
900 AR="xilib -nologo -out:"
905 LDFLAGS="-nologo -incremental:no $(icl_ldflags $LDFLAGS)"
906 LDFLAGSCLI="$(icl_ldflags $LDFLAGSCLI)"
910 if [ $debug = yes ]; then
911 LDFLAGS="-debug $LDFLAGS"
912 CFLAGS="-D_DEBUG $CFLAGS"
914 CFLAGS="-DNDEBUG $CFLAGS"
923 if [ $compiler = GNU ]; then
924 PROF_GEN_CC="-fprofile-generate"
925 PROF_GEN_LD="-fprofile-generate"
926 PROF_USE_CC="-fprofile-use"
927 PROF_USE_LD="-fprofile-use"
929 CFLAGS="$(intel_cflags $CFLAGS)"
930 # icc does not define __SSE__ until SSE2 optimization and icl never defines it or _M_IX86_FP
931 [ \( $ARCH = X86_64 -o $ARCH = X86 \) -a $asm = yes ] && ! cpp_check "" "" "defined(__SSE__)" && define __SSE__
932 PROF_GEN_CC="${QPRE}prof-gen ${QPRE}prof-dir."
934 PROF_USE_CC="${QPRE}prof-use ${QPRE}prof-dir."
940 # generate exported config file
942 cat > x264_config.h << EOF
943 #define X264_BIT_DEPTH $bit_depth
944 #define X264_GPL $x264_gpl
945 #define X264_INTERLACED $x264_interlaced
948 # generate config files
950 cat > config.mak << EOF
952 exec_prefix=$exec_prefix
955 includedir=$includedir
971 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
973 PROF_GEN_CC=$PROF_GEN_CC
974 PROF_GEN_LD=$PROF_GEN_LD
975 PROF_USE_CC=$PROF_USE_CC
976 PROF_USE_LD=$PROF_USE_LD
979 if [ $compiler = ICL ]; then
980 echo '%.o: %.c' >> config.mak
981 echo ' $(CC) $(CFLAGS) -c -Fo$@ $<' >> config.mak
984 if [ "$cli" = "yes" ]; then
985 echo 'default: cli' >> config.mak
986 echo 'install: install-cli' >> config.mak
989 if [ "$shared" = "yes" ]; then
990 API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
991 if [ "$SYS" = "WINDOWS" -o "$SYS" = "CYGWIN" ]; then
992 echo "SONAME=libx264-$API.dll" >> config.mak
993 if [ $compiler = ICL ]; then
994 echo 'IMPLIBNAME=libx264.dll.lib' >> config.mak
995 # GNU ld on windows defaults to exporting all global functions if there are no explicit __declspec(dllexport) declarations
996 # 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
997 echo 'SOFLAGS=-dll -def:x264.def -implib:$(IMPLIBNAME)' >> config.mak
998 echo "EXPORTS" > x264.def
999 grep "^\(int\|void\|x264_t\|extern\).*x264.*[\[(;]" x264.h | sed -e "s/.*\(x264.*\)[\[(].*/\1/;s/.*\(x264.*\);/\1/;s/open/open_$API/g" >> x264.def
1001 echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
1002 echo 'SOFLAGS=-shared -Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
1004 elif [ "$SYS" = "MACOSX" ]; then
1005 echo "SOSUFFIX=dylib" >> config.mak
1006 echo "SONAME=libx264.$API.dylib" >> config.mak
1007 echo 'SOFLAGS=-shared -dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak
1008 elif [ "$SYS" = "SunOS" ]; then
1009 echo "SOSUFFIX=so" >> config.mak
1010 echo "SONAME=libx264.so.$API" >> config.mak
1011 echo 'SOFLAGS=-shared -Wl,-h,$(SONAME)' >> config.mak
1013 echo "SOSUFFIX=so" >> config.mak
1014 echo "SONAME=libx264.so.$API" >> config.mak
1015 echo 'SOFLAGS=-shared -Wl,-soname,$(SONAME)' >> config.mak
1017 echo 'default: lib-shared' >> config.mak
1018 echo 'install: install-lib-shared' >> config.mak
1021 if [ "$static" = "yes" ]; then
1022 echo 'default: lib-static' >> config.mak
1023 echo 'install: install-lib-static' >> config.mak
1026 if [ "$cli_libx264" = "system" ] ; then
1027 if [ "$shared" = "yes" ]; then
1028 CLI_LIBX264='$(SONAME)'
1029 elif ${cross_prefix}pkg-config --exists x264 2>/dev/null; then
1030 LDFLAGSCLI="$LDFLAGSCLI $(${cross_prefix}pkg-config --libs x264)"
1033 die "Can not find system libx264"
1036 CLI_LIBX264='$(LIBX264)'
1038 echo "LDFLAGSCLI = $LDFLAGSCLI" >> config.mak
1039 echo "CLI_LIBX264 = $CLI_LIBX264" >> config.mak
1041 ./version.sh >> config.h
1043 pclibs="-L$libdir -lx264 $libpthread"
1045 cat > x264.pc << EOF
1047 exec_prefix=$exec_prefix
1049 includedir=$includedir
1052 Description: H.264 (MPEG4 AVC) encoder library
1053 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
1055 Cflags: -I$includedir
1058 filters="crop select_every"
1060 [ $swscale = yes ] && filters="resize $filters"
1061 [ $gpl = yes ] && filters="$filters $gpl_filters"
1063 cat > conftest.log <<EOF
1067 libx264: $cli_libx264
1071 interlaced: $interlaced
1084 bit depth: $bit_depth
1088 cat conftest.log >> config.log
1093 echo "You can run 'make' or 'make fprofiled' now."