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 # Intel Compiler on Mac OS X does not allow pre -msse3
71 [ $SYS = MACOSX -a \( "$arg" = -mia32 -o "$arg" = -msse -o "$arg" = -msse2 \) ] && arg=
72 [ -n "$arg" ] && echo -n "$arg "
78 arg=${arg/LIBPATH/libpath}
79 [ ${arg#-libpath:} == $arg -a ${arg#-l} != $arg ] && arg=${arg#-l}.lib
80 [ ${arg#-L} != $arg ] && arg=-libpath:${arg#-L}
81 [ $arg = -Wl,--large-address-aware ] && arg=-largeaddressaware
83 [ "$arg" = -Wl,-Bsymbolic ] && arg=
85 arg=${arg/pthreadGC/pthreadVC}
86 [ "$arg" = avifil32.lib ] && arg=vfw32.lib
87 [ "$arg" = gpac_static.lib ] && arg=libgpac_static.lib
89 [ -n "$arg" ] && echo -n "$arg "
95 if [ -z "$1$2" ]; then
96 log_check "whether $CC works"
97 elif [ -z "$1" ]; then
102 elif [ -z "$1" ]; then
103 log_check "whether $CC supports $3"
105 log_check "for $3 in $1";
108 [ -n "$1" ] && echo "#include <$1>" > conftest.c
109 echo "int main () { $3 return 0; }" >> conftest.c
110 if [ $compiler = ICL ]; then
111 cc_cmd="$CC conftest.c $CFLAGS $2 -link $(icl_ldflags $2 $LDFLAGSCLI $LDFLAGS)"
113 cc_cmd="$CC conftest.c $CFLAGS $2 $LDFLAGSCLI $LDFLAGS -o conftest"
115 if $cc_cmd >conftest.log 2>&1; then
121 log_msg "Failed commandline was:"
122 log_msg "--------------------------------------------------"
124 cat conftest.log >> config.log
125 log_msg "--------------------------------------------------"
126 log_msg "Failed program was:"
127 log_msg "--------------------------------------------------"
128 cat conftest.c >> config.log
129 log_msg "--------------------------------------------------"
135 log_check "whether $3 is true"
137 [ -n "$1" ] && echo "#include <$1>" > conftest.c
138 echo -e "#if !($3) \n#error $4 \n#endif " >> conftest.c
140 if $CC conftest.c $CFLAGS $2 -E -o conftest >conftest.log 2>&1; then
146 log_msg "--------------------------------------------------"
147 cat conftest.log >> config.log
148 log_msg "--------------------------------------------------"
149 log_msg "Failed program was:"
150 log_msg "--------------------------------------------------"
151 cat conftest.c >> config.log
152 log_msg "--------------------------------------------------"
158 log_check "whether $AS supports $1"
159 echo "$1" > conftest.asm
160 if $AS conftest.asm $ASFLAGS $2 -o conftest.o >conftest.log 2>&1; then
166 log_msg "Failed commandline was:"
167 log_msg "--------------------------------------------------"
168 log_msg "$AS conftest.asm $ASFLAGS $2 -o conftest.o"
169 cat conftest.log >> config.log
170 log_msg "--------------------------------------------------"
171 log_msg "Failed program was:"
172 log_msg "--------------------------------------------------"
173 cat conftest.asm >> config.log
174 log_msg "--------------------------------------------------"
180 echo "#define $1$([ -n "$2" ] && echo " $2" || echo " 1")" >> config.h
189 rm -f x264_config.h config.h config.mak config.log x264.pc x264.def conftest*
192 exec_prefix='${prefix}'
193 bindir='${exec_prefix}/bin'
194 libdir='${exec_prefix}/lib'
195 includedir='${prefix}/include'
214 CFLAGS="$CFLAGS -Wall -I."
216 LDFLAGSCLI="$LDFLAGSCLI"
223 # list of all preprocessor HAVE values we can define
224 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"
235 exec_prefix="$optarg"
265 ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
268 CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
271 LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
276 --enable-win32thread)
287 LDFLAGS="$LDFLAGS -pg"
300 host="${opt#--host=}"
303 cross_prefix="${opt#--cross-prefix=}"
306 CFLAGS="$CFLAGS --sysroot=${opt#--sysroot=}"
307 LDFLAGS="$LDFLAGS --sysroot=${opt#--sysroot=}"
310 bit_depth="${opt#--bit-depth=}"
311 if [ "$bit_depth" -lt "8" -o "$bit_depth" -gt "10" ]; then
312 echo "Supplied bit depth must be in range [8,10]."
315 bit_depth=`expr $bit_depth + 0`
318 echo "Unknown option $opt, ignored"
323 CC="${CC-${cross_prefix}gcc}"
324 AR="${AR-${cross_prefix}ar}"
325 RANLIB="${RANLIB-${cross_prefix}ranlib}"
326 STRIP="${STRIP-${cross_prefix}strip}"
328 if [ "x$host" = x ]; then
329 host=`./config.guess`
331 # normalize a triplet into a quadruplet
332 host=`./config.sub $host`
335 host_cpu="${host%%-*}"
337 host_vendor="${host%%-*}"
340 # test for use of Intel Compiler
341 if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
342 if [[ `basename "$CC"` = icl* ]]; then
343 # Windows Intel Compiler creates dependency generation with absolute Windows paths, Cygwin's make does not support Windows paths.
344 [[ $host_os = cygwin* ]] && die "Windows Intel Compiler support requires MSYS"
347 CFLAGS="$CFLAGS -Qstd=c99 -nologo -Qms0 -DHAVE_STRING_H -Iextras"
349 `$CC 2>&1 | grep -q IA-32` && host_cpu=i486
350 `$CC 2>&1 | grep -q "Intel(R) 64"` && host_cpu=x86_64
351 cpp_check "" "" "_MSC_VER >= 1400" || die "Windows Intel Compiler support requires Visual Studio 2005 or newer"
354 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"
401 if cc_check "" -mno-cygwin; then
402 CFLAGS="$CFLAGS -mno-cygwin"
403 LDFLAGS="$LDFLAGS -mno-cygwin"
414 LDFLAGS="$LDFLAGS -lm"
418 die "Unknown system $host, edit the configure"
426 ASFLAGS="$ASFLAGS -O2"
427 if [ $compiler = GNU ]; then
428 if [[ "$asm" == auto && "$CFLAGS" != *-march* ]]; then
429 CFLAGS="$CFLAGS -march=i686"
431 if [[ "$asm" == auto && "$CFLAGS" != *-mfpmath* ]]; then
432 CFLAGS="$CFLAGS -mfpmath=sse -msse"
435 # Intel Compiler >= 11 generally defaults to SSE2 optimization. -msse is also deprecated for -mia32
436 if cpp_check "" "" "__INTEL_COMPILER >= 1100" \
437 && ! (echo $CFLAGS | grep -Eiq "(${ARCHPRE}ia32|${ARCHPRE}sse|${ARCHPRE}ssse3|${ARCHPRE}avx)") \
438 && [[ "$CFLAGS" != *${QPRE}x* ]]; then
439 CFLAGS="$CFLAGS ${ARCHPRE}ia32"
441 # icc on linux has various degrees of mod16 stack support
442 if [ $SYS = LINUX ]; then
443 # < 11 is completely incapable of keeping a mod16 stack
444 if cpp_check "" "" "__INTEL_COMPILER < 1100" ; then
445 define BROKEN_STACK_ALIGNMENT
446 # 11 <= x < 12 is capable of keeping a mod16 stack, but defaults to not doing so.
447 elif cpp_check "" "" "__INTEL_COMPILER < 1200" ; then
448 CFLAGS="$CFLAGS -falign-stack=assume-16-byte"
450 # >= 12 defaults to a mod16 stack
452 # icl on windows has no mod16 stack support
453 [ $SYS = WINDOWS ] && define BROKEN_STACK_ALIGNMENT
455 if [ "$SYS" = MACOSX ]; then
456 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
457 elif [ "$SYS" = WINDOWS ]; then
458 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
459 LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
461 ASFLAGS="$ASFLAGS -f elf"
467 if [ "$SYS" = MACOSX ]; then
468 ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
469 if cc_check '' "-arch x86_64"; then
470 CFLAGS="$CFLAGS -arch x86_64"
471 LDFLAGS="$LDFLAGS -arch x86_64"
473 elif [ "$SYS" = WINDOWS ]; then
474 ASFLAGS="$ASFLAGS -f win32 -m amd64"
475 # only the GNU toolchain is inconsistent in prefixing function names with _
476 [ $compiler = GNU ] && cc_check "" "-S" && grep -q "_main:" conftest && ASFLAGS="$ASFLAGS -DPREFIX"
478 ASFLAGS="$ASFLAGS -f elf -m amd64"
483 if [ $asm = auto ] ; then
485 AS="${AS-${cross_prefix}gcc}"
486 if [ $SYS = MACOSX ] ; then
487 CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4"
489 CFLAGS="$CFLAGS -maltivec -mabi=altivec"
490 define HAVE_ALTIVEC_H
498 if [ $asm = auto ]; then
500 if ! echo $CFLAGS | grep -Eq '\-mcpu' ; then
501 CFLAGS="$CFLAGS -mcpu=ultrasparc"
502 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
504 AS="${AS-${cross_prefix}as}"
505 ASFLAGS="$ASFLAGS -xarch=v8plusa"
510 mips|mipsel|mips64|mips64el)
515 if [ "$SYS" = MACOSX ] ; then
516 AS="${AS-extras/gas-preprocessor.pl $CC}"
517 ASFLAGS="$ASFLAGS -DPREFIX -DPIC" # apple's ld doesn't support movw/movt relocations at all
518 # build for armv7 by default
519 if ! echo $CFLAGS | grep -Eq '\-arch' ; then
520 CFLAGS="$CFLAGS -arch armv7"
521 LDFLAGS="$LDFLAGS -arch armv7"
524 AS="${AS-${cross_prefix}gcc}"
537 ARCH="$(echo $host_cpu | tr a-z A-Z)"
541 log_msg "x264 configure script"
543 msg="Command line options:"
553 cc_check || die "No working C compiler found."
555 if [ $compiler != ICL ]; then
556 if cc_check '' -std=gnu99 ; then
557 CFLAGS="$CFLAGS -std=gnu99"
558 elif cc_check '' -std=c99 ; then
559 CFLAGS="$CFLAGS -std=c99 -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE"
563 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" -o $ARCH = "IA64" \) ] ; then
567 if [ $asm = auto -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
568 if ! as_check "vpaddw xmm0, xmm0, xmm0" ; then
569 VER=`($AS --version || echo no assembler) 2>$DEVNULL | head -n 1`
571 echo "Minimum version is yasm-0.7.0"
572 echo "If you really want to compile without asm, configure with --disable-asm."
575 if ! cc_check '' '' '__asm__("pabsw %xmm0, %xmm0");' ; then
576 VER=`(${cross_prefix}as --version || echo no gnu as) 2>$DEVNULL | head -n 1`
578 echo "Minimum version is binutils-2.17"
579 echo "Your compiler can't handle inline SSSE3 asm."
580 echo "If you really want to compile without asm, configure with --disable-asm."
586 if [ $asm = auto -a $ARCH = ARM ] ; then
587 # set flags so neon is built by default
588 echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu|-mfloat-abi)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp"
590 if cc_check '' '' '__asm__("rev ip, ip");' ; then define HAVE_ARMV6
591 cc_check '' '' '__asm__("movt r0, #0");' && define HAVE_ARMV6T2
592 cc_check '' '' '__asm__("vadd.i16 q0, q0, q0");' && define HAVE_NEON
593 ASFLAGS="$ASFLAGS $CFLAGS -c"
595 echo "You specified a pre-ARMv6 or Thumb-1 CPU in your CFLAGS."
596 echo "If you really want to run on such a CPU, configure with --disable-asm."
601 [ $asm = no ] && AS=""
602 [ "x$AS" = x ] && asm="no" || asm="yes"
607 # skip endianness check for Intel Compiler, as all supported platforms are little. the -ipo flag will also cause the check to fail
608 if [ $compiler = GNU ]; then
609 echo "int i[2] = {0x42494745,0}; double f[2] = {0x1.0656e6469616ep+102,0};" > conftest.c
610 $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed"
611 if (${cross_prefix}strings -a conftest.o | grep -q BIGE) && (${cross_prefix}strings -a conftest.o | grep -q FPendian) ; then
612 define WORDS_BIGENDIAN
613 elif !(${cross_prefix}strings -a conftest.o | grep -q EGIB && ${cross_prefix}strings -a conftest.o | grep -q naidnePF) ; then
614 die "endian test failed"
618 # autodetect options that weren't forced nor disabled
620 # pthread-win32 is lgpl, prevent its use if --disable-gpl is specified and targeting windows
621 [ "$SYS" = "WINDOWS" -a "$gpl" = "no" -a "$thread" = "auto" ] && thread="win32"
624 if [ "$thread" = "auto" ]; then
629 define HAVE_BEOSTHREAD
632 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
634 libpthread="-lpthread"
635 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
637 libpthread="-lpthreadGC2"
638 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
640 libpthread="-lpthreadGC2 -lwsock32"
641 define PTW32_STATIC_LIB
642 elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
644 libpthread="-lpthreadGC2 -lws2_32"
645 define PTW32_STATIC_LIB
647 # default to native threading if pthread-win32 is unavailable
652 cc_check pthread.h -pthread && thread="posix" && libpthread="-pthread"
655 cc_check pthread.h -lpthread && thread="posix" && libpthread="-lpthread"
659 if [ "$thread" = "posix" ]; then
660 LDFLAGS="$LDFLAGS $libpthread"
661 define HAVE_POSIXTHREAD
663 if [ "$thread" = "win32" ]; then
664 if [ "$SYS" = "WINDOWS" ]; then
665 define HAVE_WIN32THREAD
670 [ "$thread" != "no" ] && define HAVE_THREAD
672 if cc_check "math.h" "-Werror" "return log2f(2);" ; then
676 if [ "$vis" = "yes" ] ; then
677 save_CFLAGS="$CFLAGS"
678 CFLAGS="$CFLAGS -I/usr/X11R6/include"
679 if cc_check "X11/Xlib.h" "-L/usr/X11R6/lib -lX11" "XOpenDisplay(0);" ; then
680 LDFLAGS="-L/usr/X11R6/lib -lX11 $LDFLAGS"
681 define HAVE_VISUALIZE
684 CFLAGS="$save_CFLAGS"
688 if [ "$swscale" = "auto" ] ; then
690 if ${cross_prefix}pkg-config --exists libswscale 2>$DEVNULL; then
691 SWSCALE_LIBS="$SWSCALE_LIBS $(${cross_prefix}pkg-config --libs libswscale)"
692 SWSCALE_CFLAGS="$SWSCALE_CFLAGS $(${cross_prefix}pkg-config --cflags libswscale)"
694 [ -z "$SWSCALE_LIBS" ] && SWSCALE_LIBS="-lswscale -lavutil"
696 error="swscale must be at least version 0.9.0"
697 if cc_check "libswscale/swscale.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "sws_getContext(0,0,0,0,0,0,0,0,0,0);" ; then
698 if cpp_check "libswscale/swscale.h" "$SWSCALE_CFLAGS" "LIBSWSCALE_VERSION_INT >= AV_VERSION_INT(0,9,0)" "$error"; then
699 # we use colorspaces that were defined in libavutil r19775
700 if cc_check "libavutil/pixfmt.h" "$SWSCALE_CFLAGS" "enum PixelFormat pixfmt = PIX_FMT_YUV422P16LE;" ; then
703 echo "Warning: libavutil is too old, update to ffmpeg r19775+"
706 echo "Warning: ${error}"
711 if [ "$lavf" = "auto" ] ; then
713 if ${cross_prefix}pkg-config --exists libavformat libavcodec libswscale 2>$DEVNULL; then
714 LAVF_LIBS="$LAVF_LIBS $(${cross_prefix}pkg-config --libs libavformat libavcodec libavutil libswscale)"
715 LAVF_CFLAGS="$LAVF_CFLAGS $(${cross_prefix}pkg-config --cflags libavformat libavcodec libavutil libswscale)"
717 if [ -z "$LAVF_LIBS" -a -z "$LAVF_CFLAGS" ]; then
718 LAVF_LIBS="-lavformat"
719 for lib in -lpostproc -lavcodec -lavcore -lswscale -lavutil -lm -lz -lbz2 $libpthread -lavifil32; do
720 cc_check "" $lib && LAVF_LIBS="$LAVF_LIBS $lib"
723 LAVF_LIBS="-L. $LAVF_LIBS"
724 if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "avcodec_decode_video2(0,0,0,0);" ; then
725 # libvautil/pixdesc.h included the private header intreadwrite.h until r21854
726 if cc_check libavutil/pixdesc.h "$LAVF_CFLAGS $LAVF_LIBS" ; then
727 if [ "$swscale" = "yes" ]; then
730 echo "Warning: libavformat is not supported without swscale support"
733 echo "Warning: libavutil is too old, update to ffmpeg r21854+"
738 if [ "$ffms" = "auto" ] ; then
739 ffms_major="2"; ffms_minor="14"; ffms_micro="0"; ffms_bump="0"
742 if ${cross_prefix}pkg-config --exists ffms2 2>$DEVNULL; then
743 FFMS2_LIBS="$FFMS2_LIBS $(${cross_prefix}pkg-config --libs ffms2)"
744 FFMS2_CFLAGS="$FFMS2_CFLAGS $(${cross_prefix}pkg-config --cflags ffms2)"
746 [ -z "$FFMS2_LIBS" ] && FFMS2_LIBS="-lffms2"
748 if cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS" "FFMS_DestroyVideoSource(0);" ; then
750 elif cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS -lstdc++ $LAVF_LIBS" "FFMS_DestroyVideoSource(0);" ; then
752 FFMS2_LIBS="$FFMS2_LIBS -lstdc++ $LAVF_LIBS"
755 error="ffms must be at least version $ffms_major.$ffms_minor.$ffms_micro.$ffms_bump"
756 if [ $ffms = "yes" ] && ! cpp_check "ffms.h" "$FFMS2_CFLAGS" "FFMS_VERSION >= (($ffms_major << 24) | ($ffms_minor << 16) | ($ffms_micro << 8) | $ffms_bump)" "$error"; then
758 echo "Warning: $error"
760 if [ "$ffms" = "yes" -a "$swscale" = "no" ]; then
761 echo "Warning: ffms is not supported without swscale support"
766 if [ "$swscale" = "yes" ]; then
767 LDFLAGSCLI="$SWSCALE_LIBS $LDFLAGSCLI"
768 CFLAGS="$CFLAGS $SWSCALE_CFLAGS"
770 if [ "$lavf" = "yes" ]; then
771 LDFLAGSCLI="$LAVF_LIBS $LDFLAGSCLI"
772 CFLAGS="$CFLAGS $LAVF_CFLAGS"
775 if [ "$ffms" = "yes" ]; then
776 LDFLAGSCLI="$FFMS2_LIBS $LDFLAGSCLI"
777 CFLAGS="$CFLAGS $FFMS2_CFLAGS"
782 GPAC_LIBS="-lgpac_static"
783 if [ $SYS = WINDOWS ]; then
784 GPAC_LIBS="$GPAC_LIBS -lwinmm"
786 if [ "$gpac" = "auto" ] ; then
788 if cc_check gpac/isomedia.h "$GPAC_LIBS" ; then
789 if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0);" ; then
792 echo "Warning: gpac is too old, update to 2007-06-21 UTC or later"
796 if [ "$gpac" = "yes" ] ; then
798 if cc_check gpac/isomedia.h "-Werror $GPAC_LIBS" "gf_malloc(1); gf_free(NULL);" ; then
799 define HAVE_GF_MALLOC
801 LDFLAGSCLI="$GPAC_LIBS $LDFLAGSCLI"
804 if [ "$avs" = "auto" ] ; then
806 if [ $SYS = WINDOWS ] && cc_check extras/avisynth_c.h ; then
812 if [ "$pic" = "yes" ] ; then
813 CFLAGS="$CFLAGS -fPIC"
814 ASFLAGS="$ASFLAGS -DPIC"
815 # resolve textrels in the x86 asm
816 cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
819 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
820 CFLAGS="$CFLAGS -s -fomit-frame-pointer"
821 LDFLAGS="$LDFLAGS -s"
824 if [ "$debug" = "yes" ]; then
825 CFLAGS="-O1 -g $CFLAGS"
826 elif [ $ARCH = ARM ]; then
827 # arm-gcc-4.2 produces incorrect output with -ffast-math
828 # and it doesn't save any speed anyway on 4.4, so disable it
829 CFLAGS="-O3 -fno-fast-math $CFLAGS"
831 CFLAGS="-O3 -ffast-math $CFLAGS"
834 if cc_check '' -fno-tree-vectorize ; then
835 CFLAGS="$CFLAGS -fno-tree-vectorize"
838 if [ $SYS = WINDOWS -a $ARCH = X86 -a $compiler = GNU ] ; then
839 # workaround gcc/ld bug with alignment of static variables/arrays that are initialized to zero
840 cc_check '' -fno-zero-initialized-in-bss && CFLAGS="$CFLAGS -fno-zero-initialized-in-bss"
843 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
846 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
847 define fseek fseeko64
848 define ftell ftello64
849 elif cc_check "stdio.h" "" "_fseeki64(stdin,0,0);" ; then
850 define fseek _fseeki64
851 define ftell _ftelli64
854 if cc_check '' -Wshadow ; then
855 CFLAGS="-Wshadow $CFLAGS"
858 if [ "$bit_depth" -gt "8" ]; then
859 define HIGH_BIT_DEPTH
860 ASFLAGS="$ASFLAGS -DHIGH_BIT_DEPTH"
863 ASFLAGS="$ASFLAGS -DBIT_DEPTH=$bit_depth"
865 [ $gpl = yes ] && define HAVE_GPL && x264_gpl=1 || x264_gpl=0
867 #define undefined vars as 0
868 for var in $CONFIG_HAVE; do
869 grep -q "HAVE_$var 1" config.h || define HAVE_$var 0
872 if [ $compiler = ICL ]; then
873 AR="xilib -nologo -out:"
878 LDFLAGS="-nologo -incremental:no $(icl_ldflags $LDFLAGS)"
879 LDFLAGSCLI="$(icl_ldflags $LDFLAGSCLI)"
883 if [ $debug = yes ]; then
884 LDFLAGS="-debug $LDFLAGS"
885 CFLAGS="-D_DEBUG $CFLAGS"
887 CFLAGS="-DNDEBUG $CFLAGS"
896 if [ $compiler = GNU ]; then
897 PROF_GEN_CC="-fprofile-generate"
898 PROF_GEN_LD="-fprofile-generate"
899 PROF_USE_CC="-fprofile-use"
900 PROF_USE_LD="-fprofile-use"
902 CFLAGS="$(intel_cflags $CFLAGS)"
903 # icc does not define __SSE__ until SSE2 optimization and icl never defines it or _M_IX86_FP
904 [ \( $ARCH = X86_64 -o $ARCH = X86 \) -a $asm = yes ] && ! cpp_check "" "" "defined(__SSE__)" && define __SSE__
905 PROF_GEN_CC="${QPRE}prof-gen ${QPRE}prof-dir."
907 PROF_USE_CC="${QPRE}prof-use ${QPRE}prof-dir."
913 # generate exported config file
915 cat > x264_config.h << EOF
916 #define X264_BIT_DEPTH $bit_depth
917 #define X264_GPL $x264_gpl
920 # generate config files
922 cat > config.mak << EOF
924 exec_prefix=$exec_prefix
927 includedir=$includedir
936 LDFLAGSCLI=$LDFLAGSCLI
944 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
946 PROF_GEN_CC=$PROF_GEN_CC
947 PROF_GEN_LD=$PROF_GEN_LD
948 PROF_USE_CC=$PROF_USE_CC
949 PROF_USE_LD=$PROF_USE_LD
952 if [ $compiler = ICL ]; then
953 echo '%.o: %.c' >> config.mak
954 echo ' $(CC) $(CFLAGS) -c -Fo$@ $<' >> config.mak
957 if [ "$shared" = "yes" ]; then
958 API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
959 if [ "$SYS" = "WINDOWS" ]; then
960 echo "SONAME=libx264-$API.dll" >> config.mak
961 if [ $compiler = ICL ]; then
962 echo 'IMPLIBNAME=libx264.dll.lib' >> config.mak
963 # GNU ld on windows defaults to exporting all global functions if there are no explicit __declspec(dllexport) declarations
964 # 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
965 echo 'SOFLAGS=-dll -def:x264.def -implib:$(IMPLIBNAME)' >> config.mak
966 echo "EXPORTS" > x264.def
967 grep "^\(int\|void\|x264_t\|extern\).*x264.*[\[(;]" x264.h | sed -e "s/.*\(x264.*\)[\[(].*/\1/;s/.*\(x264.*\);/\1/;s/open/open_$API/g" >> x264.def
969 echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
970 echo 'SOFLAGS=-shared -Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
972 elif [ "$SYS" = "MACOSX" ]; then
973 echo "SOSUFFIX=dylib" >> config.mak
974 echo "SONAME=libx264.$API.dylib" >> config.mak
975 echo 'SOFLAGS=-shared -dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak
976 elif [ "$SYS" = "SunOS" ]; then
977 echo "SOSUFFIX=so" >> config.mak
978 echo "SONAME=libx264.so.$API" >> config.mak
979 echo 'SOFLAGS=-shared -Wl,-h,$(SONAME)' >> config.mak
981 echo "SOSUFFIX=so" >> config.mak
982 echo "SONAME=libx264.so.$API" >> config.mak
983 echo 'SOFLAGS=-shared -Wl,-soname,$(SONAME)' >> config.mak
985 echo 'default: $(SONAME)' >> config.mak
988 ./version.sh >> config.h
990 pclibs="-L$libdir -lx264 $libpthread"
994 exec_prefix=$exec_prefix
996 includedir=$includedir
999 Description: H.264 (MPEG4 AVC) encoder library
1000 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
1002 Cflags: -I$includedir
1005 filters="crop select_every"
1007 [ $swscale = yes ] && filters="resize $filters"
1008 [ $gpl = yes ] && filters="$filters $gpl_filters"
1010 cat > conftest.log <<EOF
1026 bit depth: $bit_depth
1030 cat conftest.log >> config.log
1035 echo "You can run 'make' or 'make fprofiled' now."