3 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
5 Usage: ./configure [options]
8 -h, --help print this message
11 --prefix=PREFIX install architecture-independent files in PREFIX
13 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
15 --bindir=DIR install binaries in DIR [EPREFIX/bin]
16 --libdir=DIR install libs in DIR [EPREFIX/lib]
17 --includedir=DIR install includes in DIR [PREFIX/include]
18 --extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS
19 --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS
20 --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS
22 Configuration options:
23 --disable-cli disable cli
24 --system-libx264 use system libx264 instead of internal
25 --enable-shared build shared library
26 --enable-static build static library
27 --disable-gpl disable GPL-only features
28 --disable-thread disable multithreaded encoding
29 --enable-win32thread use win32threads (windows only)
30 --disable-interlaced disable interlaced encoding support
31 --enable-visualize enable visualization (X11 only)
32 --bit-depth=BIT_DEPTH set output bit depth (8-10) [8]
33 --chroma-format=FORMAT output chroma format (420, 422, 444, all) [all]
36 --disable-asm disable platform-specific assembly optimizations
38 --enable-gprof add -pg
40 --enable-pic build position-independent code
43 --host=HOST build programs to run on HOST
44 --cross-prefix=PREFIX use PREFIX for compilation tools
45 --sysroot=SYSROOT root of cross-build tree
47 External library support:
48 --disable-avs disable avisynth support (windows only)
49 --disable-swscale disable swscale support
50 --disable-lavf disable libavformat support
51 --disable-ffms disable ffmpegsource support
52 --disable-gpac disable gpac support
59 echo -n "checking $1... " >> config.log
63 echo "yes" >> config.log
67 echo "no" >> config.log
71 echo "$1" >> config.log
75 # Intel Compiler issues an incredibly large number of warnings on any warning level,
76 # suppress them by disabling all warnings rather than having to use #pragmas to disable most of them
78 [ $arg = -ffast-math ] && arg=
79 [[ "$arg" = -falign-loops* ]] && arg=
80 [ "$arg" = -fno-tree-vectorize ] && arg=
81 [ "$arg" = -Wshadow ] && arg=
82 if [ $compiler = ICL ]; then
83 [ "$arg" = -Wall ] && arg=-W0
84 [ "$arg" = -g ] && arg=-Z7
85 [ "$arg" = -fomit-frame-pointer ] && arg=
86 [ "$arg" = -s ] && arg=
87 [ "$arg" = -fPIC ] && arg=
89 [ "$arg" = -Wall ] && arg=-w0
92 [ -n "$arg" ] && echo -n "$arg "
98 arg=${arg/LIBPATH/libpath}
99 [ ${arg#-libpath:} == $arg -a ${arg#-l} != $arg ] && arg=${arg#-l}.lib
100 [ ${arg#-L} != $arg ] && arg=-libpath:${arg#-L}
101 [ $arg = -Wl,--large-address-aware ] && arg=-largeaddressaware
102 [ $arg = -s ] && arg=
103 [ "$arg" = -Wl,-Bsymbolic ] && arg=
105 arg=${arg/pthreadGC/pthreadVC}
106 [ "$arg" = avifil32.lib ] && arg=vfw32.lib
107 [ "$arg" = gpac_static.lib ] && arg=libgpac_static.lib
109 [ -n "$arg" ] && echo -n "$arg "
115 if [ -z "$1$2" ]; then
116 log_check "whether $CC works"
117 elif [ -z "$1" ]; then
122 elif [ -z "$1" ]; then
124 log_check "whether $CC supports $3"
126 log_check "whether $CC supports $3 with $2"
129 log_check "for $3 in $1";
132 [ -n "$1" ] && echo "#include <$1>" > conftest.c
133 echo "int main () { $3 return 0; }" >> conftest.c
134 if [ $compiler = ICL ]; then
135 cc_cmd="$CC conftest.c $CFLAGS $2 -link $(icl_ldflags $2 $LDFLAGSCLI $LDFLAGS)"
137 cc_cmd="$CC conftest.c $CFLAGS $2 $LDFLAGSCLI $LDFLAGS -o conftest"
139 if $cc_cmd >conftest.log 2>&1; then
145 log_msg "Failed commandline was:"
146 log_msg "--------------------------------------------------"
148 cat conftest.log >> config.log
149 log_msg "--------------------------------------------------"
150 log_msg "Failed program was:"
151 log_msg "--------------------------------------------------"
152 cat conftest.c >> config.log
153 log_msg "--------------------------------------------------"
159 log_check "whether $3 is true"
161 [ -n "$1" ] && echo "#include <$1>" > conftest.c
162 echo -e "#if !($3) \n#error $4 \n#endif " >> conftest.c
164 if $CC conftest.c $CFLAGS $2 -E -o conftest >conftest.log 2>&1; then
170 log_msg "--------------------------------------------------"
171 cat conftest.log >> config.log
172 log_msg "--------------------------------------------------"
173 log_msg "Failed program was:"
174 log_msg "--------------------------------------------------"
175 cat conftest.c >> config.log
176 log_msg "--------------------------------------------------"
182 log_check "whether $AS supports $1"
183 echo "$1" > conftest.asm
184 if $AS conftest.asm $ASFLAGS $2 -o conftest.o >conftest.log 2>&1; then
190 log_msg "Failed commandline was:"
191 log_msg "--------------------------------------------------"
192 log_msg "$AS conftest.asm $ASFLAGS $2 -o conftest.o"
193 cat conftest.log >> config.log
194 log_msg "--------------------------------------------------"
195 log_msg "Failed program was:"
196 log_msg "--------------------------------------------------"
197 cat conftest.asm >> config.log
198 log_msg "--------------------------------------------------"
204 log_check "whether $RC works"
205 echo "$1" > conftest.rc
206 if [ $compiler = ICL ]; then
207 rc_cmd="$RC -foconftest.o conftest.rc"
209 rc_cmd="$RC -o conftest.o conftest.rc"
211 if $rc_cmd >conftest.log 2>&1; then
217 log_msg "Failed commandline was:"
218 log_msg "--------------------------------------------------"
220 cat conftest.log >> config.log
221 log_msg "--------------------------------------------------"
222 log_msg "Failed program was:"
223 log_msg "--------------------------------------------------"
224 cat conftest.rc >> config.log
225 log_msg "--------------------------------------------------"
231 echo "#define $1$([ -n "$2" ] && echo " $2" || echo " 1")" >> config.h
240 rm -f x264_config.h config.h config.mak config.log x264.pc x264.def conftest*
242 SRCPATH="$(cd $(dirname $0); pwd)"
243 [ "$SRCPATH" = "$(pwd)" ] && SRCPATH=.
244 [ -n "$(echo $SRCPATH | grep ' ')" ] && die "Out of tree builds are impossible with whitespace in source path."
245 [ -e "$SRCPATH/config.h" -o -e "$SRCPATH/x264_config.h" ] && die "Out of tree builds are impossible with config.h/x264_config.h in source dir."
248 exec_prefix='${prefix}'
249 bindir='${exec_prefix}/bin'
250 libdir='${exec_prefix}/lib'
251 includedir='${prefix}/include'
255 cli_libx264="internal"
276 CFLAGS="$CFLAGS -Wall -I. -I\$(SRCPATH)"
278 LDFLAGSCLI="$LDFLAGSCLI"
285 # list of all preprocessor HAVE values we can define
286 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 CPU_COUNT"
297 exec_prefix="$optarg"
323 --disable-interlaced)
342 ASFLAGS="$ASFLAGS $optarg"
345 CFLAGS="$CFLAGS $optarg"
348 LDFLAGS="$LDFLAGS $optarg"
353 --enable-win32thread)
364 LDFLAGS="$LDFLAGS -pg"
380 cross_prefix="$optarg"
383 CFLAGS="$CFLAGS --sysroot=$optarg"
384 LDFLAGS="$LDFLAGS --sysroot=$optarg"
388 if [ "$bit_depth" -lt "8" -o "$bit_depth" -gt "10" ]; then
389 echo "Supplied bit depth must be in range [8,10]."
392 bit_depth=`expr $bit_depth + 0`
395 chroma_format="$optarg"
396 if [ $chroma_format != "420" -a $chroma_format != "422" -a $chroma_format != "444" -a $chroma_format != "all" ]; then
397 echo "Supplied chroma format must be 420, 422, 444 or all."
402 echo "Unknown option $opt, ignored"
407 [ "$cli" = "no" -a "$shared" = "no" -a "$static" = "no" ] && die "Nothing to build. Enable cli, shared or static."
409 CC="${CC-${cross_prefix}gcc}"
410 AR="${AR-${cross_prefix}ar}"
411 RANLIB="${RANLIB-${cross_prefix}ranlib}"
412 STRIP="${STRIP-${cross_prefix}strip}"
414 if [ "x$host" = x ]; then
415 host=`${SRCPATH}/config.guess`
417 # normalize a triplet into a quadruplet
418 host=`${SRCPATH}/config.sub $host`
421 host_cpu="${host%%-*}"
423 host_vendor="${host%%-*}"
426 # test for use of Intel Compiler
427 if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
428 if [[ `basename "$CC"` = icl* ]]; then
429 # Windows Intel Compiler creates dependency generation with absolute Windows paths, Cygwin's make does not support Windows paths.
430 [[ $host_os = cygwin* ]] && die "Windows Intel Compiler support requires MSYS"
432 CFLAGS="$CFLAGS -Qstd=c99 -nologo -Qms0 -DHAVE_STRING_H -I\$(SRCPATH)/extras"
434 `$CC 2>&1 | grep -q IA-32` && host_cpu=i486
435 `$CC 2>&1 | grep -q "Intel(R) 64"` && host_cpu=x86_64
436 cpp_check "" "" "_MSC_VER >= 1400" || die "Windows Intel Compiler support requires Visual Studio 2005 or newer"
439 if [[ `basename "$CC"` = icc* ]]; then
453 CFLAGS="$CFLAGS -falign-loops=16"
454 LDFLAGS="$LDFLAGS -lm"
455 if [ "$pic" = "no" ]; then
456 cc_check "" -mdynamic-no-pic && CFLAGS="$CFLAGS -mdynamic-no-pic"
461 LDFLAGS="$LDFLAGS -lm"
466 LDFLAGS="$LDFLAGS -lm"
470 LDFLAGS="$LDFLAGS -lm"
474 LDFLAGS="$LDFLAGS -lm"
479 LDFLAGS="$LDFLAGS -lm"
484 LDFLAGS="$LDFLAGS -lm"
488 if cc_check "" -mno-cygwin; then
489 CFLAGS="$CFLAGS -mno-cygwin"
490 LDFLAGS="$LDFLAGS -mno-cygwin"
492 if cpp_check "" "" "defined(__CYGWIN32__)" ; then
508 LDFLAGS="$LDFLAGS -lm"
509 if cc_check "" /usr/lib/64/values-xpg6.o; then
510 LDFLAGS="$LDFLAGS /usr/lib/64/values-xpg6.o"
512 LDFLAGS="$LDFLAGS /usr/lib/values-xpg6.o"
517 die "Unknown system $host, edit the configure"
525 ASFLAGS="$ASFLAGS -O2"
526 if [ $compiler = GNU ]; then
527 if [[ "$asm" == auto && "$CFLAGS" != *-march* ]]; then
528 CFLAGS="$CFLAGS -march=i686"
530 if [[ "$asm" == auto && "$CFLAGS" != *-mfpmath* ]]; then
531 CFLAGS="$CFLAGS -mfpmath=sse -msse"
534 # icc on linux has various degrees of mod16 stack support
535 if [ $SYS = LINUX ]; then
536 # < 11 is completely incapable of keeping a mod16 stack
537 if cpp_check "" "" "__INTEL_COMPILER < 1100" ; then
538 define BROKEN_STACK_ALIGNMENT
539 # 11 <= x < 12 is capable of keeping a mod16 stack, but defaults to not doing so.
540 elif cpp_check "" "" "__INTEL_COMPILER < 1200" ; then
541 CFLAGS="$CFLAGS -falign-stack=assume-16-byte"
543 # >= 12 defaults to a mod16 stack
545 # icl on windows has no mod16 stack support
546 [ $SYS = WINDOWS ] && define BROKEN_STACK_ALIGNMENT
548 if [ "$SYS" = MACOSX ]; then
549 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
550 elif [ "$SYS" = WINDOWS -o "$SYS" = CYGWIN ]; then
551 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
552 LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
554 ASFLAGS="$ASFLAGS -f elf"
560 if [ "$SYS" = MACOSX ]; then
561 ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
562 if cc_check '' "-arch x86_64"; then
563 CFLAGS="$CFLAGS -arch x86_64"
564 LDFLAGS="$LDFLAGS -arch x86_64"
566 elif [ "$SYS" = WINDOWS ]; then
567 ASFLAGS="$ASFLAGS -f win32 -m amd64"
568 # only the GNU toolchain is inconsistent in prefixing function names with _
569 [ $compiler = GNU ] && cc_check "" "-S" && grep -q "_main:" conftest && ASFLAGS="$ASFLAGS -DPREFIX"
571 ASFLAGS="$ASFLAGS -f elf -m amd64"
576 if [ $asm = auto ] ; then
578 AS="${AS-${cross_prefix}gcc}"
579 if [ $SYS = MACOSX ] ; then
580 CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4"
582 CFLAGS="$CFLAGS -maltivec -mabi=altivec"
583 define HAVE_ALTIVEC_H
591 if [ $asm = auto ]; then
593 if ! echo $CFLAGS | grep -Eq '\-mcpu' ; then
594 CFLAGS="$CFLAGS -mcpu=ultrasparc"
595 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
597 AS="${AS-${cross_prefix}as}"
598 ASFLAGS="$ASFLAGS -xarch=v8plusa"
603 mips|mipsel|mips64|mips64el)
608 if [ "$SYS" = MACOSX ] ; then
609 AS="${AS-extras/gas-preprocessor.pl $CC}"
610 ASFLAGS="$ASFLAGS -DPREFIX -DPIC" # apple's ld doesn't support movw/movt relocations at all
611 # build for armv7 by default
612 if ! echo $CFLAGS | grep -Eq '\-arch' ; then
613 CFLAGS="$CFLAGS -arch armv7"
614 LDFLAGS="$LDFLAGS -arch armv7"
617 AS="${AS-${cross_prefix}gcc}"
633 ARCH="$(echo $host_cpu | tr a-z A-Z)"
638 if [ $SYS = WINDOWS ]; then
639 [ $compiler = ICL ] && RC="rc" || RC="${cross_prefix}windres"
640 if ! rc_check "0 RCDATA {0}" ; then
645 log_msg "x264 configure script"
647 msg="Command line options:"
657 cc_check || die "No working C compiler found."
659 if [ $compiler != ICL ]; then
660 if cc_check '' -std=gnu99 'for( int i = 0; i < 9; i++ );' ; then
661 CFLAGS="$CFLAGS -std=gnu99"
662 elif cc_check '' -std=c99 'for( int i = 0; i < 9; i++ );' ; then
663 CFLAGS="$CFLAGS -std=c99 -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE"
664 elif ! cc_check '' '' 'for( int i = 0; i < 9; i++ );' ; then
665 die "C99 compiler is needed for compilation."
669 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" -o $ARCH = "IA64" -o $ARCH = "PARISC" -o $ARCH = "MIPS" \) ] ; then
673 if [ $asm = auto -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
674 if ! as_check "vpperm xmm0, xmm0, xmm0, xmm0" ; then
675 VER=`($AS --version || echo no assembler) 2>/dev/null | head -n 1`
677 echo "Minimum version is yasm-1.0.0"
678 echo "If you really want to compile without asm, configure with --disable-asm."
681 if ! cc_check '' '' '__asm__("pabsw %xmm0, %xmm0");' ; then
682 VER=`(${cross_prefix}as --version || echo no gnu as) 2>/dev/null | head -n 1`
684 echo "Minimum version is binutils-2.17"
685 echo "Your compiler can't handle inline SSSE3 asm."
686 echo "If you really want to compile without asm, configure with --disable-asm."
692 if [ $asm = auto -a $ARCH = ARM ] ; then
693 # set flags so neon is built by default
694 echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon"
696 if cc_check '' '' '__asm__("rev ip, ip");' ; then define HAVE_ARMV6
697 cc_check '' '' '__asm__("movt r0, #0");' && define HAVE_ARMV6T2
698 cc_check '' '' '__asm__("vadd.i16 q0, q0, q0");' && define HAVE_NEON
699 ASFLAGS="$ASFLAGS $CFLAGS -c"
701 echo "You specified a pre-ARMv6 or Thumb-1 CPU in your CFLAGS."
702 echo "If you really want to run on such a CPU, configure with --disable-asm."
707 [ $asm = no ] && AS=""
708 [ "x$AS" = x ] && asm="no" || asm="yes"
713 # skip endianness check for Intel Compiler, as all supported platforms are little. the -ipo flag will also cause the check to fail
714 if [ $compiler = GNU ]; then
715 echo "int i[2] = {0x42494745,0}; double f[2] = {0x1.0656e6469616ep+102,0};" > conftest.c
716 $CC $CFLAGS conftest.c -c -o conftest.o 2>/dev/null || die "endian test failed"
717 if (${cross_prefix}strings -a conftest.o | grep -q BIGE) && (${cross_prefix}strings -a conftest.o | grep -q FPendian) ; then
718 define WORDS_BIGENDIAN
719 elif !(${cross_prefix}strings -a conftest.o | grep -q EGIB && ${cross_prefix}strings -a conftest.o | grep -q naidnePF) ; then
720 die "endian test failed"
724 # autodetect options that weren't forced nor disabled
726 # pthread-win32 is lgpl, prevent its use if --disable-gpl is specified and targeting windows
727 [ "$SYS" = "WINDOWS" -a "$gpl" = "no" -a "$thread" = "auto" ] && thread="win32"
730 if [ "$thread" = "auto" ]; then
735 define HAVE_BEOSTHREAD
738 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
740 libpthread="-lpthread"
741 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
743 libpthread="-lpthreadGC2"
744 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
746 libpthread="-lpthreadGC2 -lwsock32"
747 define PTW32_STATIC_LIB
748 elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
750 libpthread="-lpthreadGC2 -lws2_32"
751 define PTW32_STATIC_LIB
753 # default to native threading if pthread-win32 is unavailable
758 cc_check pthread.h -pthread && thread="posix" && libpthread="-pthread"
761 cc_check pthread.h -lpthread && thread="posix" && libpthread="-lpthread"
765 if [ "$thread" = "posix" ]; then
766 LDFLAGS="$LDFLAGS $libpthread"
767 define HAVE_POSIXTHREAD
768 if [ "$SYS" = "LINUX" ] && cc_check sched.h "-D_GNU_SOURCE -Werror" "cpu_set_t p_aff; return CPU_COUNT(&p_aff);" ; then
769 define HAVE_CPU_COUNT
772 if [ "$thread" = "win32" ]; then
773 # cygwin does not support win32 threads
774 if [ "$SYS" = "WINDOWS" ]; then
775 define HAVE_WIN32THREAD
780 [ "$thread" != "no" ] && define HAVE_THREAD
782 if cc_check "math.h" "-Werror" "return log2f(2);" ; then
786 if [ "$vis" = "yes" ] ; then
787 save_CFLAGS="$CFLAGS"
788 CFLAGS="$CFLAGS -I/usr/X11R6/include"
789 if cc_check "X11/Xlib.h" "-L/usr/X11R6/lib -lX11" "XOpenDisplay(0);" ; then
790 LDFLAGS="-L/usr/X11R6/lib -lX11 $LDFLAGS"
791 define HAVE_VISUALIZE
794 CFLAGS="$save_CFLAGS"
798 if [ "$swscale" = "auto" ] ; then
800 if ${cross_prefix}pkg-config --exists libswscale 2>/dev/null; then
801 SWSCALE_LIBS="$SWSCALE_LIBS $(${cross_prefix}pkg-config --libs libswscale libavutil)"
802 SWSCALE_CFLAGS="$SWSCALE_CFLAGS $(${cross_prefix}pkg-config --cflags libswscale libavutil)"
804 [ -z "$SWSCALE_LIBS" ] && SWSCALE_LIBS="-lswscale -lavutil"
806 if cc_check "libswscale/swscale.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "sws_init_context(0,0,0);" ; then
807 if cpp_check "libavutil/pixdesc.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "defined(PIX_FMT_RGB)" ; then
810 echo "Warning: PIX_FMT_RGB is missing from libavutil, update for swscale support"
815 if [ "$lavf" = "auto" ] ; then
817 if ${cross_prefix}pkg-config --exists libavformat libavcodec libswscale 2>/dev/null; then
818 LAVF_LIBS="$LAVF_LIBS $(${cross_prefix}pkg-config --libs libavformat libavcodec libavutil libswscale)"
819 LAVF_CFLAGS="$LAVF_CFLAGS $(${cross_prefix}pkg-config --cflags libavformat libavcodec libavutil libswscale)"
821 if [ -z "$LAVF_LIBS" -a -z "$LAVF_CFLAGS" ]; then
822 LAVF_LIBS="-lavformat"
823 for lib in -lpostproc -lavcodec -lavcore -lswscale -lavutil -lm -lz -lbz2 $libpthread -lavifil32; do
824 cc_check "" $lib && LAVF_LIBS="$LAVF_LIBS $lib"
827 LAVF_LIBS="-L. $LAVF_LIBS"
828 if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "avformat_find_stream_info(0,0); avcodec_open2(0,0,0);" ; then
829 if [ "$swscale" = "yes" ]; then
832 echo "Warning: libavformat is not supported without swscale support"
837 if [ "$ffms" = "auto" ] ; then
838 ffms_major="2"; ffms_minor="16"; ffms_micro="2"; ffms_bump="0"
841 if ${cross_prefix}pkg-config --exists ffms2 2>/dev/null; then
842 FFMS2_LIBS="$FFMS2_LIBS $(${cross_prefix}pkg-config --libs ffms2)"
843 FFMS2_CFLAGS="$FFMS2_CFLAGS $(${cross_prefix}pkg-config --cflags ffms2)"
845 [ -z "$FFMS2_LIBS" ] && FFMS2_LIBS="-lffms2"
847 if cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS" "FFMS_DestroyVideoSource(0);" ; then
849 elif cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS -lstdc++ $LAVF_LIBS" "FFMS_DestroyVideoSource(0);" ; then
851 FFMS2_LIBS="$FFMS2_LIBS -lstdc++ $LAVF_LIBS"
854 error="ffms must be at least version $ffms_major.$ffms_minor.$ffms_micro.$ffms_bump"
855 if [ $ffms = "yes" ] && ! cpp_check "ffms.h" "$FFMS2_CFLAGS" "FFMS_VERSION >= (($ffms_major << 24) | ($ffms_minor << 16) | ($ffms_micro << 8) | $ffms_bump)" "$error"; then
857 echo "Warning: $error"
859 if [ "$ffms" = "yes" -a "$swscale" = "no" ]; then
860 echo "Warning: ffms is not supported without swscale support"
865 if [ "$swscale" = "yes" ]; then
866 LDFLAGSCLI="$SWSCALE_LIBS $LDFLAGSCLI"
867 CFLAGS="$CFLAGS $SWSCALE_CFLAGS"
869 if [ "$lavf" = "yes" ]; then
870 LDFLAGSCLI="$LAVF_LIBS $LDFLAGSCLI"
871 CFLAGS="$CFLAGS $LAVF_CFLAGS"
874 if [ "$ffms" = "yes" ]; then
875 LDFLAGSCLI="$FFMS2_LIBS $LDFLAGSCLI"
876 CFLAGS="$CFLAGS $FFMS2_CFLAGS"
881 if [ "$gpac" = "auto" ] ; then
883 cc_check "" -lz && GPAC_LIBS="-lgpac_static -lz" || GPAC_LIBS="-lgpac_static"
884 if [ "$SYS" = "WINDOWS" ] ; then
885 GPAC_LIBS="$GPAC_LIBS -lwinmm"
887 if cc_check gpac/isomedia.h "$GPAC_LIBS" ; then
888 if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0);" ; then
891 echo "Warning: gpac is too old, update to 2007-06-21 UTC or later"
895 if [ "$gpac" = "yes" ] ; then
897 if cc_check gpac/isomedia.h "-Werror $GPAC_LIBS" "gf_malloc(1); gf_free(NULL);" ; then
898 define HAVE_GF_MALLOC
900 LDFLAGSCLI="$GPAC_LIBS $LDFLAGSCLI"
903 if [ "$avs" = "auto" ] ; then
905 # cygwin can use avisynth if it can use LoadLibrary
906 if [ $SYS = WINDOWS ] || ([ $SYS = CYGWIN ] && cc_check windows.h "" "LoadLibrary(0);") ; then
912 cc_check "stdint.h" "" "uint32_t test_vec __attribute__ ((vector_size (16))) = {0,1,2,3};" && define HAVE_VECTOREXT
914 if [ "$pic" = "yes" ] ; then
915 CFLAGS="$CFLAGS -fPIC"
916 ASFLAGS="$ASFLAGS -DPIC"
917 # resolve textrels in the x86 asm
918 cc_check stdio.h "-shared -Wl,-Bsymbolic" && SOFLAGS="$SOFLAGS -Wl,-Bsymbolic"
919 [ $SYS = SunOS -a "$ARCH" = "X86" ] && SOFLAGS="$SOFLAGS -mimpure-text"
922 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
923 CFLAGS="$CFLAGS -fomit-frame-pointer"
926 if [ "$strip" = "yes" ]; then
928 LDFLAGS="$LDFLAGS -s"
931 if [ "$debug" = "yes" ]; then
932 CFLAGS="-O1 -g $CFLAGS"
933 elif [ $ARCH = ARM ]; then
934 # arm-gcc-4.2 produces incorrect output with -ffast-math
935 # and it doesn't save any speed anyway on 4.4, so disable it
936 CFLAGS="-O3 -fno-fast-math $CFLAGS"
938 CFLAGS="-O3 -ffast-math $CFLAGS"
941 if cc_check '' -fno-tree-vectorize ; then
942 CFLAGS="$CFLAGS -fno-tree-vectorize"
945 if [ $SYS = WINDOWS -a $ARCH = X86 -a $compiler = GNU ] ; then
946 # workaround gcc/ld bug with alignment of static variables/arrays that are initialized to zero
947 cc_check '' -fno-zero-initialized-in-bss && CFLAGS="$CFLAGS -fno-zero-initialized-in-bss"
950 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
953 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
954 define fseek fseeko64
955 define ftell ftello64
956 elif cc_check "stdio.h" "" "_fseeki64(stdin,0,0);" ; then
957 define fseek _fseeki64
958 define ftell _ftelli64
961 if cc_check '' -Wshadow ; then
962 CFLAGS="-Wshadow $CFLAGS"
965 if [ "$bit_depth" -gt "8" ]; then
966 define HIGH_BIT_DEPTH
967 ASFLAGS="$ASFLAGS -DHIGH_BIT_DEPTH=1"
969 ASFLAGS="$ASFLAGS -DHIGH_BIT_DEPTH=0"
972 if [ "$chroma_format" != "all" ]; then
973 define CHROMA_FORMAT CHROMA_$chroma_format
976 ASFLAGS="$ASFLAGS -DBIT_DEPTH=$bit_depth"
978 [ $gpl = yes ] && define HAVE_GPL && x264_gpl=1 || x264_gpl=0
980 [ $interlaced = yes ] && define HAVE_INTERLACED && x264_interlaced=1 || x264_interlaced=0
982 #define undefined vars as 0
983 for var in $CONFIG_HAVE; do
984 grep -q "HAVE_$var 1" config.h || define HAVE_$var 0
987 if [ $compiler = ICL ]; then
988 AR="xilib -nologo -out:"
993 LDFLAGS="-nologo -incremental:no $(icl_ldflags $LDFLAGS)"
994 LDFLAGSCLI="$(icl_ldflags $LDFLAGSCLI)"
997 [ -n "$RC" ] && RC="$RC -I. -I\$(SRCPATH)/extras -fo"
999 if [ $debug = yes ]; then
1000 LDFLAGS="-debug $LDFLAGS"
1001 CFLAGS="-D_DEBUG $CFLAGS"
1003 CFLAGS="-DNDEBUG $CFLAGS"
1011 [ -n "$RC" ] && RC="$RC -I. -o "
1013 if [ $compiler = GNU ]; then
1014 PROF_GEN_CC="-fprofile-generate"
1015 PROF_GEN_LD="-fprofile-generate"
1016 PROF_USE_CC="-fprofile-use"
1017 PROF_USE_LD="-fprofile-use"
1019 CFLAGS="$(intel_cflags $CFLAGS)"
1020 # icc does not define __SSE__ until SSE2 optimization and icl never defines it or _M_IX86_FP
1021 [ \( $ARCH = X86_64 -o $ARCH = X86 \) -a $asm = yes ] && ! cpp_check "" "" "defined(__SSE__)" && define __SSE__
1022 PROF_GEN_CC="${QPRE}prof-gen ${QPRE}prof-dir."
1024 PROF_USE_CC="${QPRE}prof-use ${QPRE}prof-dir."
1030 # generate exported config file
1032 config_chroma_format="X264_CSP_I$chroma_format"
1033 [ "$config_chroma_format" == "X264_CSP_Iall" ] && config_chroma_format="0"
1034 cat > x264_config.h << EOF
1035 #define X264_BIT_DEPTH $bit_depth
1036 #define X264_GPL $x264_gpl
1037 #define X264_INTERLACED $x264_interlaced
1038 #define X264_CHROMA_FORMAT $config_chroma_format
1041 # generate config files
1043 cat > config.mak << EOF
1046 exec_prefix=$exec_prefix
1049 includedir=$includedir
1066 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
1068 PROF_GEN_CC=$PROF_GEN_CC
1069 PROF_GEN_LD=$PROF_GEN_LD
1070 PROF_USE_CC=$PROF_USE_CC
1071 PROF_USE_LD=$PROF_USE_LD
1074 if [ $compiler = ICL ]; then
1075 echo '%.o: %.c' >> config.mak
1076 echo ' $(CC) $(CFLAGS) -c -Fo$@ $<' >> config.mak
1079 if [ "$cli" = "yes" ]; then
1080 echo 'default: cli' >> config.mak
1081 echo 'install: install-cli' >> config.mak
1084 if [ "$shared" = "yes" ]; then
1085 API=$(grep '#define X264_BUILD' < ${SRCPATH}/x264.h | cut -f 3 -d ' ')
1086 if [ "$SYS" = "WINDOWS" -o "$SYS" = "CYGWIN" ]; then
1087 echo "SONAME=libx264-$API.dll" >> config.mak
1088 if [ $compiler = ICL ]; then
1089 echo 'IMPLIBNAME=libx264.dll.lib' >> config.mak
1090 # GNU ld on windows defaults to exporting all global functions if there are no explicit __declspec(dllexport) declarations
1091 # 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
1092 echo "SOFLAGS=-dll -def:x264.def -implib:\$(IMPLIBNAME) $SOFLAGS" >> config.mak
1093 echo "EXPORTS" > x264.def
1094 grep "^\(int\|void\|x264_t\|extern\).*x264.*[\[(;]" ${SRCPATH}/x264.h | sed -e "s/.*\(x264.*\)[\[(].*/\1/;s/.*\(x264.*\);/\1/;s/open/open_$API/g" >> x264.def
1096 echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
1097 echo "SOFLAGS=-shared -Wl,--out-implib,\$(IMPLIBNAME) -Wl,--enable-auto-image-base $SOFLAGS" >> config.mak
1099 elif [ "$SYS" = "MACOSX" ]; then
1100 echo "SOSUFFIX=dylib" >> config.mak
1101 echo "SONAME=libx264.$API.dylib" >> config.mak
1102 echo "SOFLAGS=-shared -dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name \$(DESTDIR)\$(libdir)/\$(SONAME) $SOFLAGS" >> config.mak
1103 elif [ "$SYS" = "SunOS" ]; then
1104 echo "SOSUFFIX=so" >> config.mak
1105 echo "SONAME=libx264.so.$API" >> config.mak
1106 echo "SOFLAGS=-shared -Wl,-h,\$(SONAME) $SOFLAGS" >> config.mak
1108 echo "SOSUFFIX=so" >> config.mak
1109 echo "SONAME=libx264.so.$API" >> config.mak
1110 echo "SOFLAGS=-shared -Wl,-soname,\$(SONAME) $SOFLAGS" >> config.mak
1112 echo 'default: lib-shared' >> config.mak
1113 echo 'install: install-lib-shared' >> config.mak
1116 if [ "$static" = "yes" ]; then
1117 echo 'default: lib-static' >> config.mak
1118 echo 'install: install-lib-static' >> config.mak
1121 if [ "$cli_libx264" = "system" ] ; then
1122 if [ "$shared" = "yes" ]; then
1123 CLI_LIBX264='$(SONAME)'
1124 elif ${cross_prefix}pkg-config --exists x264 2>/dev/null; then
1125 LDFLAGSCLI="$LDFLAGSCLI $(${cross_prefix}pkg-config --libs x264)"
1128 die "Can not find system libx264"
1131 CLI_LIBX264='$(LIBX264)'
1133 echo "LDFLAGSCLI = $LDFLAGSCLI" >> config.mak
1134 echo "CLI_LIBX264 = $CLI_LIBX264" >> config.mak
1136 ${SRCPATH}/version.sh "${SRCPATH}" >> x264_config.h
1138 pclibs="-L$libdir -lx264 $libpthread"
1140 cat > x264.pc << EOF
1142 exec_prefix=$exec_prefix
1144 includedir=$includedir
1147 Description: H.264 (MPEG4 AVC) encoder library
1148 Version: $(grep POINTVER < x264_config.h | sed -e 's/.* "//; s/".*//')
1150 Cflags: -I$includedir
1153 filters="crop select_every"
1155 [ $swscale = yes ] && filters="resize $filters"
1156 [ $gpl = yes ] && filters="$filters $gpl_filters"
1158 cat > conftest.log <<EOF
1162 libx264: $cli_libx264
1166 interlaced: $interlaced
1179 bit depth: $bit_depth
1180 chroma format: $chroma_format
1184 cat conftest.log >> config.log
1188 [ "$SRCPATH" != "." ] && ln -sf ${SRCPATH}/Makefile ./Makefile
1189 mkdir -p common/{arm,ppc,sparc,x86} encoder extras filters/video input output tools
1192 echo "You can run 'make' or 'make fprofiled' now."