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 --disable-interlaced disables interlaced encoding support
20 --enable-debug adds -g, doesn't strip
21 --enable-gprof adds -pg, doesn't strip
22 --enable-visualize enables visualization (X11 only)
23 --enable-pic build position-independent code
24 --enable-shared build shared library
25 --bit-depth=BIT_DEPTH sets output bit depth (8-10), default 8
26 --extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS
27 --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS
28 --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS
29 --host=HOST build programs to run on HOST
30 --cross-prefix=PREFIX use PREFIX for compilation tools
31 --sysroot=SYSROOT root of cross-build tree
38 echo -n "checking $1... " >> config.log
42 echo "yes" >> config.log
46 echo "no" >> config.log
50 echo "$1" >> config.log
54 # Intel Compiler issues an incredibly large number of warnings on any warning level,
55 # suppress them by disabling all warnings rather than having to use #pragmas to disable most of them
57 [ $arg = -ffast-math ] && arg=
58 [[ "$arg" = -falign-loops* ]] && arg=
59 [ "$arg" = -fno-tree-vectorize ] && arg=
60 [ "$arg" = -Wshadow ] && arg=
61 if [ $compiler = ICL ]; then
62 [ "$arg" = -Wall ] && arg=-W0
63 [ "$arg" = -g ] && arg=-Z7
64 [ "$arg" = -fomit-frame-pointer ] && arg=
65 [ "$arg" = -s ] && arg=
66 [ "$arg" = -fPIC ] && arg=
68 [ "$arg" = -Wall ] && arg=-w0
71 [ -n "$arg" ] && echo -n "$arg "
77 arg=${arg/LIBPATH/libpath}
78 [ ${arg#-libpath:} == $arg -a ${arg#-l} != $arg ] && arg=${arg#-l}.lib
79 [ ${arg#-L} != $arg ] && arg=-libpath:${arg#-L}
80 [ $arg = -Wl,--large-address-aware ] && arg=-largeaddressaware
82 [ "$arg" = -Wl,-Bsymbolic ] && arg=
84 arg=${arg/pthreadGC/pthreadVC}
85 [ "$arg" = avifil32.lib ] && arg=vfw32.lib
86 [ "$arg" = gpac_static.lib ] && arg=libgpac_static.lib
88 [ -n "$arg" ] && echo -n "$arg "
94 if [ -z "$1$2" ]; then
95 log_check "whether $CC works"
96 elif [ -z "$1" ]; then
101 elif [ -z "$1" ]; then
103 log_check "whether $CC supports $3"
105 log_check "whether $CC supports $3 with $2"
108 log_check "for $3 in $1";
111 [ -n "$1" ] && echo "#include <$1>" > conftest.c
112 echo "int main () { $3 return 0; }" >> conftest.c
113 if [ $compiler = ICL ]; then
114 cc_cmd="$CC conftest.c $CFLAGS $2 -link $(icl_ldflags $2 $LDFLAGSCLI $LDFLAGS)"
116 cc_cmd="$CC conftest.c $CFLAGS $2 $LDFLAGSCLI $LDFLAGS -o conftest"
118 if $cc_cmd >conftest.log 2>&1; then
124 log_msg "Failed commandline was:"
125 log_msg "--------------------------------------------------"
127 cat conftest.log >> config.log
128 log_msg "--------------------------------------------------"
129 log_msg "Failed program was:"
130 log_msg "--------------------------------------------------"
131 cat conftest.c >> config.log
132 log_msg "--------------------------------------------------"
138 log_check "whether $3 is true"
140 [ -n "$1" ] && echo "#include <$1>" > conftest.c
141 echo -e "#if !($3) \n#error $4 \n#endif " >> conftest.c
143 if $CC conftest.c $CFLAGS $2 -E -o conftest >conftest.log 2>&1; then
149 log_msg "--------------------------------------------------"
150 cat conftest.log >> config.log
151 log_msg "--------------------------------------------------"
152 log_msg "Failed program was:"
153 log_msg "--------------------------------------------------"
154 cat conftest.c >> config.log
155 log_msg "--------------------------------------------------"
161 log_check "whether $AS supports $1"
162 echo "$1" > conftest.asm
163 if $AS conftest.asm $ASFLAGS $2 -o conftest.o >conftest.log 2>&1; then
169 log_msg "Failed commandline was:"
170 log_msg "--------------------------------------------------"
171 log_msg "$AS conftest.asm $ASFLAGS $2 -o conftest.o"
172 cat conftest.log >> config.log
173 log_msg "--------------------------------------------------"
174 log_msg "Failed program was:"
175 log_msg "--------------------------------------------------"
176 cat conftest.asm >> config.log
177 log_msg "--------------------------------------------------"
183 echo "#define $1$([ -n "$2" ] && echo " $2" || echo " 1")" >> config.h
192 rm -f x264_config.h config.h config.mak config.log x264.pc x264.def conftest*
195 exec_prefix='${prefix}'
196 bindir='${exec_prefix}/bin'
197 libdir='${exec_prefix}/lib'
198 includedir='${prefix}/include'
218 CFLAGS="$CFLAGS -Wall -I."
220 LDFLAGSCLI="$LDFLAGSCLI"
227 # list of all preprocessor HAVE values we can define
228 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"
239 exec_prefix="$optarg"
253 --disable-interlaced)
272 ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
275 CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
278 LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
283 --enable-win32thread)
294 LDFLAGS="$LDFLAGS -pg"
307 host="${opt#--host=}"
310 cross_prefix="${opt#--cross-prefix=}"
313 CFLAGS="$CFLAGS --sysroot=${opt#--sysroot=}"
314 LDFLAGS="$LDFLAGS --sysroot=${opt#--sysroot=}"
317 bit_depth="${opt#--bit-depth=}"
318 if [ "$bit_depth" -lt "8" -o "$bit_depth" -gt "10" ]; then
319 echo "Supplied bit depth must be in range [8,10]."
322 bit_depth=`expr $bit_depth + 0`
325 echo "Unknown option $opt, ignored"
330 CC="${CC-${cross_prefix}gcc}"
331 AR="${AR-${cross_prefix}ar}"
332 RANLIB="${RANLIB-${cross_prefix}ranlib}"
333 STRIP="${STRIP-${cross_prefix}strip}"
335 if [ "x$host" = x ]; then
336 host=`./config.guess`
338 # normalize a triplet into a quadruplet
339 host=`./config.sub $host`
342 host_cpu="${host%%-*}"
344 host_vendor="${host%%-*}"
347 # test for use of Intel Compiler
348 if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
349 if [[ `basename "$CC"` = icl* ]]; then
350 # Windows Intel Compiler creates dependency generation with absolute Windows paths, Cygwin's make does not support Windows paths.
351 [[ $host_os = cygwin* ]] && die "Windows Intel Compiler support requires MSYS"
353 CFLAGS="$CFLAGS -Qstd=c99 -nologo -Qms0 -DHAVE_STRING_H -Iextras"
355 `$CC 2>&1 | grep -q IA-32` && host_cpu=i486
356 `$CC 2>&1 | grep -q "Intel(R) 64"` && host_cpu=x86_64
357 cpp_check "" "" "_MSC_VER >= 1400" || die "Windows Intel Compiler support requires Visual Studio 2005 or newer"
360 if [[ `basename "$CC"` = icc* ]]; then
374 CFLAGS="$CFLAGS -falign-loops=16"
375 LDFLAGS="$LDFLAGS -lm"
376 if [ "$pic" = "no" ]; then
377 cc_check "" -mdynamic-no-pic && CFLAGS="$CFLAGS -mdynamic-no-pic"
382 LDFLAGS="$LDFLAGS -lm"
387 LDFLAGS="$LDFLAGS -lm"
391 LDFLAGS="$LDFLAGS -lm"
395 LDFLAGS="$LDFLAGS -lm"
400 LDFLAGS="$LDFLAGS -lm"
404 if cc_check "" -mno-cygwin; then
405 CFLAGS="$CFLAGS -mno-cygwin"
406 LDFLAGS="$LDFLAGS -mno-cygwin"
408 if cpp_check "" "" "defined(__CYGWIN32__)" ; then
424 LDFLAGS="$LDFLAGS -lm"
428 die "Unknown system $host, edit the configure"
436 ASFLAGS="$ASFLAGS -O2"
437 if [ $compiler = GNU ]; then
438 if [[ "$asm" == auto && "$CFLAGS" != *-march* ]]; then
439 CFLAGS="$CFLAGS -march=i686"
441 if [[ "$asm" == auto && "$CFLAGS" != *-mfpmath* ]]; then
442 CFLAGS="$CFLAGS -mfpmath=sse -msse"
445 # icc on linux has various degrees of mod16 stack support
446 if [ $SYS = LINUX ]; then
447 # < 11 is completely incapable of keeping a mod16 stack
448 if cpp_check "" "" "__INTEL_COMPILER < 1100" ; then
449 define BROKEN_STACK_ALIGNMENT
450 # 11 <= x < 12 is capable of keeping a mod16 stack, but defaults to not doing so.
451 elif cpp_check "" "" "__INTEL_COMPILER < 1200" ; then
452 CFLAGS="$CFLAGS -falign-stack=assume-16-byte"
454 # >= 12 defaults to a mod16 stack
456 # icl on windows has no mod16 stack support
457 [ $SYS = WINDOWS ] && define BROKEN_STACK_ALIGNMENT
459 if [ "$SYS" = MACOSX ]; then
460 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
461 elif [ "$SYS" = WINDOWS -o "$SYS" = CYGWIN ]; then
462 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
463 LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
465 ASFLAGS="$ASFLAGS -f elf"
471 if [ "$SYS" = MACOSX ]; then
472 ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
473 if cc_check '' "-arch x86_64"; then
474 CFLAGS="$CFLAGS -arch x86_64"
475 LDFLAGS="$LDFLAGS -arch x86_64"
477 elif [ "$SYS" = WINDOWS ]; then
478 ASFLAGS="$ASFLAGS -f win32 -m amd64"
479 # only the GNU toolchain is inconsistent in prefixing function names with _
480 [ $compiler = GNU ] && cc_check "" "-S" && grep -q "_main:" conftest && ASFLAGS="$ASFLAGS -DPREFIX"
482 ASFLAGS="$ASFLAGS -f elf -m amd64"
487 if [ $asm = auto ] ; then
489 AS="${AS-${cross_prefix}gcc}"
490 if [ $SYS = MACOSX ] ; then
491 CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4"
493 CFLAGS="$CFLAGS -maltivec -mabi=altivec"
494 define HAVE_ALTIVEC_H
502 if [ $asm = auto ]; then
504 if ! echo $CFLAGS | grep -Eq '\-mcpu' ; then
505 CFLAGS="$CFLAGS -mcpu=ultrasparc"
506 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
508 AS="${AS-${cross_prefix}as}"
509 ASFLAGS="$ASFLAGS -xarch=v8plusa"
514 mips|mipsel|mips64|mips64el)
519 if [ "$SYS" = MACOSX ] ; then
520 AS="${AS-extras/gas-preprocessor.pl $CC}"
521 ASFLAGS="$ASFLAGS -DPREFIX -DPIC" # apple's ld doesn't support movw/movt relocations at all
522 # build for armv7 by default
523 if ! echo $CFLAGS | grep -Eq '\-arch' ; then
524 CFLAGS="$CFLAGS -arch armv7"
525 LDFLAGS="$LDFLAGS -arch armv7"
528 AS="${AS-${cross_prefix}gcc}"
541 ARCH="$(echo $host_cpu | tr a-z A-Z)"
545 log_msg "x264 configure script"
547 msg="Command line options:"
557 cc_check || die "No working C compiler found."
559 if [ $compiler != ICL ]; then
560 if cc_check '' -std=gnu99 'for( int i = 0; i < 9; i++ );' ; then
561 CFLAGS="$CFLAGS -std=gnu99"
562 elif cc_check '' -std=c99 'for( int i = 0; i < 9; i++ );' ; then
563 CFLAGS="$CFLAGS -std=c99 -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE"
564 elif ! cc_check '' '' 'for( int i = 0; i < 9; i++ );' ; then
565 die "C99 compiler is needed for compilation."
569 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" -o $ARCH = "IA64" \) ] ; then
573 if [ $asm = auto -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
574 if ! as_check "vpaddw xmm0, xmm0, xmm0" ; then
575 VER=`($AS --version || echo no assembler) 2>/dev/null | head -n 1`
577 echo "Minimum version is yasm-0.7.0"
578 echo "If you really want to compile without asm, configure with --disable-asm."
581 if ! cc_check '' '' '__asm__("pabsw %xmm0, %xmm0");' ; then
582 VER=`(${cross_prefix}as --version || echo no gnu as) 2>/dev/null | head -n 1`
584 echo "Minimum version is binutils-2.17"
585 echo "Your compiler can't handle inline SSSE3 asm."
586 echo "If you really want to compile without asm, configure with --disable-asm."
592 if [ $asm = auto -a $ARCH = ARM ] ; then
593 # set flags so neon is built by default
594 echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu|-mfloat-abi)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp"
596 if cc_check '' '' '__asm__("rev ip, ip");' ; then define HAVE_ARMV6
597 cc_check '' '' '__asm__("movt r0, #0");' && define HAVE_ARMV6T2
598 cc_check '' '' '__asm__("vadd.i16 q0, q0, q0");' && define HAVE_NEON
599 ASFLAGS="$ASFLAGS $CFLAGS -c"
601 echo "You specified a pre-ARMv6 or Thumb-1 CPU in your CFLAGS."
602 echo "If you really want to run on such a CPU, configure with --disable-asm."
607 [ $asm = no ] && AS=""
608 [ "x$AS" = x ] && asm="no" || asm="yes"
613 # skip endianness check for Intel Compiler, as all supported platforms are little. the -ipo flag will also cause the check to fail
614 if [ $compiler = GNU ]; then
615 echo "int i[2] = {0x42494745,0}; double f[2] = {0x1.0656e6469616ep+102,0};" > conftest.c
616 $CC $CFLAGS conftest.c -c -o conftest.o 2>/dev/null || die "endian test failed"
617 if (${cross_prefix}strings -a conftest.o | grep -q BIGE) && (${cross_prefix}strings -a conftest.o | grep -q FPendian) ; then
618 define WORDS_BIGENDIAN
619 elif !(${cross_prefix}strings -a conftest.o | grep -q EGIB && ${cross_prefix}strings -a conftest.o | grep -q naidnePF) ; then
620 die "endian test failed"
624 # autodetect options that weren't forced nor disabled
626 # pthread-win32 is lgpl, prevent its use if --disable-gpl is specified and targeting windows
627 [ "$SYS" = "WINDOWS" -a "$gpl" = "no" -a "$thread" = "auto" ] && thread="win32"
630 if [ "$thread" = "auto" ]; then
635 define HAVE_BEOSTHREAD
638 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
640 libpthread="-lpthread"
641 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
643 libpthread="-lpthreadGC2"
644 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
646 libpthread="-lpthreadGC2 -lwsock32"
647 define PTW32_STATIC_LIB
648 elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
650 libpthread="-lpthreadGC2 -lws2_32"
651 define PTW32_STATIC_LIB
653 # default to native threading if pthread-win32 is unavailable
658 cc_check pthread.h -pthread && thread="posix" && libpthread="-pthread"
661 cc_check pthread.h -lpthread && thread="posix" && libpthread="-lpthread"
665 if [ "$thread" = "posix" ]; then
666 LDFLAGS="$LDFLAGS $libpthread"
667 define HAVE_POSIXTHREAD
669 if [ "$thread" = "win32" ]; then
670 # cygwin does not support win32 threads
671 if [ "$SYS" = "WINDOWS" ]; then
672 define HAVE_WIN32THREAD
677 [ "$thread" != "no" ] && define HAVE_THREAD
679 if cc_check "math.h" "-Werror" "return log2f(2);" ; then
683 if [ "$vis" = "yes" ] ; then
684 save_CFLAGS="$CFLAGS"
685 CFLAGS="$CFLAGS -I/usr/X11R6/include"
686 if cc_check "X11/Xlib.h" "-L/usr/X11R6/lib -lX11" "XOpenDisplay(0);" ; then
687 LDFLAGS="-L/usr/X11R6/lib -lX11 $LDFLAGS"
688 define HAVE_VISUALIZE
691 CFLAGS="$save_CFLAGS"
695 if [ "$swscale" = "auto" ] ; then
697 if ${cross_prefix}pkg-config --exists libswscale 2>/dev/null; then
698 SWSCALE_LIBS="$SWSCALE_LIBS $(${cross_prefix}pkg-config --libs libswscale)"
699 SWSCALE_CFLAGS="$SWSCALE_CFLAGS $(${cross_prefix}pkg-config --cflags libswscale)"
701 [ -z "$SWSCALE_LIBS" ] && SWSCALE_LIBS="-lswscale -lavutil"
703 error="swscale must be at least version 0.9.0"
704 if cc_check "libswscale/swscale.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "sws_getContext(0,0,0,0,0,0,0,0,0,0);" ; then
705 if cpp_check "libswscale/swscale.h" "$SWSCALE_CFLAGS" "LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(0,9,0)" "$error"; then
706 # we use colorspaces that were defined in libavutil r19775
707 if cc_check "libavutil/pixfmt.h" "$SWSCALE_CFLAGS" "enum PixelFormat pixfmt = PIX_FMT_YUV422P16LE;" ; then
710 echo "Warning: libavutil is too old, update to ffmpeg r19775+"
713 echo "Warning: ${error}"
718 if [ "$lavf" = "auto" ] ; then
720 if ${cross_prefix}pkg-config --exists libavformat libavcodec libswscale 2>/dev/null; then
721 LAVF_LIBS="$LAVF_LIBS $(${cross_prefix}pkg-config --libs libavformat libavcodec libavutil libswscale)"
722 LAVF_CFLAGS="$LAVF_CFLAGS $(${cross_prefix}pkg-config --cflags libavformat libavcodec libavutil libswscale)"
724 if [ -z "$LAVF_LIBS" -a -z "$LAVF_CFLAGS" ]; then
725 LAVF_LIBS="-lavformat"
726 for lib in -lpostproc -lavcodec -lavcore -lswscale -lavutil -lm -lz -lbz2 $libpthread -lavifil32; do
727 cc_check "" $lib && LAVF_LIBS="$LAVF_LIBS $lib"
730 LAVF_LIBS="-L. $LAVF_LIBS"
731 if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "avcodec_decode_video2(0,0,0,0);" ; then
732 if cpp_check libavcodec/avcodec.h "$LAVF_CFLAGS $LAVF_LIBS" "LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,64,0)" ; then
733 if [ "$swscale" = "yes" ]; then
736 echo "Warning: libavformat is not supported without swscale support"
739 echo "Warning: libavcodec is too old, update to ffmpeg r22735+"
744 if [ "$ffms" = "auto" ] ; then
745 ffms_major="2"; ffms_minor="14"; ffms_micro="0"; ffms_bump="0"
748 if ${cross_prefix}pkg-config --exists ffms2 2>/dev/null; then
749 FFMS2_LIBS="$FFMS2_LIBS $(${cross_prefix}pkg-config --libs ffms2)"
750 FFMS2_CFLAGS="$FFMS2_CFLAGS $(${cross_prefix}pkg-config --cflags ffms2)"
752 [ -z "$FFMS2_LIBS" ] && FFMS2_LIBS="-lffms2"
754 if cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS" "FFMS_DestroyVideoSource(0);" ; then
756 elif cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS -lstdc++ $LAVF_LIBS" "FFMS_DestroyVideoSource(0);" ; then
758 FFMS2_LIBS="$FFMS2_LIBS -lstdc++ $LAVF_LIBS"
761 error="ffms must be at least version $ffms_major.$ffms_minor.$ffms_micro.$ffms_bump"
762 if [ $ffms = "yes" ] && ! cpp_check "ffms.h" "$FFMS2_CFLAGS" "FFMS_VERSION >= (($ffms_major << 24) | ($ffms_minor << 16) | ($ffms_micro << 8) | $ffms_bump)" "$error"; then
764 echo "Warning: $error"
766 if [ "$ffms" = "yes" -a "$swscale" = "no" ]; then
767 echo "Warning: ffms is not supported without swscale support"
772 if [ "$swscale" = "yes" ]; then
773 LDFLAGSCLI="$SWSCALE_LIBS $LDFLAGSCLI"
774 CFLAGS="$CFLAGS $SWSCALE_CFLAGS"
776 if [ "$lavf" = "yes" ]; then
777 LDFLAGSCLI="$LAVF_LIBS $LDFLAGSCLI"
778 CFLAGS="$CFLAGS $LAVF_CFLAGS"
781 if [ "$ffms" = "yes" ]; then
782 LDFLAGSCLI="$FFMS2_LIBS $LDFLAGSCLI"
783 CFLAGS="$CFLAGS $FFMS2_CFLAGS"
788 if [ "$gpac" = "auto" ] ; then
790 cc_check "" -lz && GPAC_LIBS="-lgpac_static -lz" || GPAC_LIBS="-lgpac_static"
791 if [ "$SYS" = "WINDOWS" ] ; then
792 GPAC_LIBS="$GPAC_LIBS -lwinmm"
794 if cc_check gpac/isomedia.h "$GPAC_LIBS" ; then
795 if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0);" ; then
798 echo "Warning: gpac is too old, update to 2007-06-21 UTC or later"
802 if [ "$gpac" = "yes" ] ; then
804 if cc_check gpac/isomedia.h "-Werror $GPAC_LIBS" "gf_malloc(1); gf_free(NULL);" ; then
805 define HAVE_GF_MALLOC
807 LDFLAGSCLI="$GPAC_LIBS $LDFLAGSCLI"
810 if [ "$avs" = "auto" ] ; then
812 # cygwin can use avisynth if it can use LoadLibrary
813 if [ $SYS = WINDOWS ] || ([ $SYS = CYGWIN ] && cc_check windows.h "" "LoadLibrary(0);") ; then
819 cc_check "stdint.h" "" "uint32_t test_vec __attribute__ ((vector_size (16))) = {0,1,2,3};" && define HAVE_VECTOREXT
821 if [ "$pic" = "yes" ] ; then
822 CFLAGS="$CFLAGS -fPIC"
823 ASFLAGS="$ASFLAGS -DPIC"
824 # resolve textrels in the x86 asm
825 cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
828 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
829 CFLAGS="$CFLAGS -s -fomit-frame-pointer"
830 LDFLAGS="$LDFLAGS -s"
833 if [ "$debug" = "yes" ]; then
834 CFLAGS="-O1 -g $CFLAGS"
835 elif [ $ARCH = ARM ]; then
836 # arm-gcc-4.2 produces incorrect output with -ffast-math
837 # and it doesn't save any speed anyway on 4.4, so disable it
838 CFLAGS="-O3 -fno-fast-math $CFLAGS"
840 CFLAGS="-O3 -ffast-math $CFLAGS"
843 if cc_check '' -fno-tree-vectorize ; then
844 CFLAGS="$CFLAGS -fno-tree-vectorize"
847 if [ $SYS = WINDOWS -a $ARCH = X86 -a $compiler = GNU ] ; then
848 # workaround gcc/ld bug with alignment of static variables/arrays that are initialized to zero
849 cc_check '' -fno-zero-initialized-in-bss && CFLAGS="$CFLAGS -fno-zero-initialized-in-bss"
852 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
855 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
856 define fseek fseeko64
857 define ftell ftello64
858 elif cc_check "stdio.h" "" "_fseeki64(stdin,0,0);" ; then
859 define fseek _fseeki64
860 define ftell _ftelli64
863 if cc_check '' -Wshadow ; then
864 CFLAGS="-Wshadow $CFLAGS"
867 if [ "$bit_depth" -gt "8" ]; then
868 define HIGH_BIT_DEPTH
869 ASFLAGS="$ASFLAGS -DHIGH_BIT_DEPTH"
872 ASFLAGS="$ASFLAGS -DBIT_DEPTH=$bit_depth"
874 [ $gpl = yes ] && define HAVE_GPL && x264_gpl=1 || x264_gpl=0
876 [ $interlaced = yes ] && define HAVE_INTERLACED && x264_interlaced=1 || x264_interlaced=0
878 #define undefined vars as 0
879 for var in $CONFIG_HAVE; do
880 grep -q "HAVE_$var 1" config.h || define HAVE_$var 0
883 if [ $compiler = ICL ]; then
884 AR="xilib -nologo -out:"
889 LDFLAGS="-nologo -incremental:no $(icl_ldflags $LDFLAGS)"
890 LDFLAGSCLI="$(icl_ldflags $LDFLAGSCLI)"
894 if [ $debug = yes ]; then
895 LDFLAGS="-debug $LDFLAGS"
896 CFLAGS="-D_DEBUG $CFLAGS"
898 CFLAGS="-DNDEBUG $CFLAGS"
907 if [ $compiler = GNU ]; then
908 PROF_GEN_CC="-fprofile-generate"
909 PROF_GEN_LD="-fprofile-generate"
910 PROF_USE_CC="-fprofile-use"
911 PROF_USE_LD="-fprofile-use"
913 CFLAGS="$(intel_cflags $CFLAGS)"
914 # icc does not define __SSE__ until SSE2 optimization and icl never defines it or _M_IX86_FP
915 [ \( $ARCH = X86_64 -o $ARCH = X86 \) -a $asm = yes ] && ! cpp_check "" "" "defined(__SSE__)" && define __SSE__
916 PROF_GEN_CC="${QPRE}prof-gen ${QPRE}prof-dir."
918 PROF_USE_CC="${QPRE}prof-use ${QPRE}prof-dir."
924 # generate exported config file
926 cat > x264_config.h << EOF
927 #define X264_BIT_DEPTH $bit_depth
928 #define X264_GPL $x264_gpl
929 #define X264_INTERLACED $x264_interlaced
932 # generate config files
934 cat > config.mak << EOF
936 exec_prefix=$exec_prefix
939 includedir=$includedir
948 LDFLAGSCLI=$LDFLAGSCLI
956 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
958 PROF_GEN_CC=$PROF_GEN_CC
959 PROF_GEN_LD=$PROF_GEN_LD
960 PROF_USE_CC=$PROF_USE_CC
961 PROF_USE_LD=$PROF_USE_LD
964 if [ $compiler = ICL ]; then
965 echo '%.o: %.c' >> config.mak
966 echo ' $(CC) $(CFLAGS) -c -Fo$@ $<' >> config.mak
969 if [ "$shared" = "yes" ]; then
970 API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
971 if [ "$SYS" = "WINDOWS" -o "$SYS" = "CYGWIN" ]; then
972 echo "SONAME=libx264-$API.dll" >> config.mak
973 if [ $compiler = ICL ]; then
974 echo 'IMPLIBNAME=libx264.dll.lib' >> config.mak
975 # GNU ld on windows defaults to exporting all global functions if there are no explicit __declspec(dllexport) declarations
976 # 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
977 echo 'SOFLAGS=-dll -def:x264.def -implib:$(IMPLIBNAME)' >> config.mak
978 echo "EXPORTS" > x264.def
979 grep "^\(int\|void\|x264_t\|extern\).*x264.*[\[(;]" x264.h | sed -e "s/.*\(x264.*\)[\[(].*/\1/;s/.*\(x264.*\);/\1/;s/open/open_$API/g" >> x264.def
981 echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
982 echo 'SOFLAGS=-shared -Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
984 elif [ "$SYS" = "MACOSX" ]; then
985 echo "SOSUFFIX=dylib" >> config.mak
986 echo "SONAME=libx264.$API.dylib" >> config.mak
987 echo 'SOFLAGS=-shared -dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak
988 elif [ "$SYS" = "SunOS" ]; then
989 echo "SOSUFFIX=so" >> config.mak
990 echo "SONAME=libx264.so.$API" >> config.mak
991 echo 'SOFLAGS=-shared -Wl,-h,$(SONAME)' >> config.mak
993 echo "SOSUFFIX=so" >> config.mak
994 echo "SONAME=libx264.so.$API" >> config.mak
995 echo 'SOFLAGS=-shared -Wl,-soname,$(SONAME)' >> config.mak
997 echo 'default: $(SONAME)' >> config.mak
1000 ./version.sh >> config.h
1002 pclibs="-L$libdir -lx264 $libpthread"
1004 cat > x264.pc << EOF
1006 exec_prefix=$exec_prefix
1008 includedir=$includedir
1011 Description: H.264 (MPEG4 AVC) encoder library
1012 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
1014 Cflags: -I$includedir
1017 filters="crop select_every"
1019 [ $swscale = yes ] && filters="resize $filters"
1020 [ $gpl = yes ] && filters="$filters $gpl_filters"
1022 cat > conftest.log <<EOF
1026 interlaced: $interlaced
1039 bit depth: $bit_depth
1043 cat conftest.log >> config.log
1048 echo "You can run 'make' or 'make fprofiled' now."