]> git.sesse.net Git - x264/blob - configure
Add "Fake interlaced" option
[x264] / configure
1 #!/bin/bash
2
3 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
4
5 echo "Usage: ./configure [options]"
6 echo ""
7 echo "available options:"
8 echo ""
9 echo "  --help                   print this message"
10 echo "  --disable-avs-input      disables avisynth input (win32 only)"
11 echo "  --disable-lavf-input     disables libavformat input"
12 echo "  --disable-ffms-input     disables ffmpegsource input"
13 echo "  --disable-mp4-output     disables mp4 output (using gpac)"
14 echo "  --disable-pthread        disables multithreaded encoding"
15 echo "  --disable-asm            disables platform-specific assembly optimizations"
16 echo "  --enable-debug           adds -g, doesn't strip"
17 echo "  --enable-gprof           adds -pg, doesn't strip"
18 echo "  --enable-visualize       enables visualization (X11 only)"
19 echo "  --enable-pic             build position-independent code"
20 echo "  --enable-shared          build libx264.so"
21 echo "  --extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS"
22 echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS"
23 echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS"
24 echo "  --host=HOST              build programs to run on HOST"
25 echo "  --cross-prefix=PREFIX    use PREFIX for compilation tools"
26 echo "  --sysroot=SYSROOT        root of cross-build tree"
27 echo ""
28 exit 1
29 fi
30
31 log_check() {
32     echo -n "checking $1... " >> config.log
33 }
34
35 log_ok() {
36     echo "yes" >> config.log
37 }
38
39 log_fail() {
40     echo "no" >> config.log
41 }
42
43 log_msg() {
44     echo "$1" >> config.log
45 }
46
47 cc_check() {
48     if [ -z "$3" ]; then
49         if [ -z "$1$2" ]; then
50             log_check "whether $CC works"
51         elif [ -z "$1" ]; then
52             log_check "for $2"
53         else
54             log_check "for $1"
55         fi
56     elif [ -z "$1" ]; then
57         log_check "whether $CC supports $3"
58     else
59         log_check "for $3 in $1";
60     fi
61     rm -f conftest.c
62     [ -n "$1" ] && echo "#include <$1>" > conftest.c
63     echo "int main () { $3 return 0; }" >> conftest.c
64     if $CC conftest.c $CFLAGS $LDFLAGS $LDFLAGSCLI $2 -o conftest >conftest.log 2>&1; then
65         res=$?
66         log_ok
67     else
68         res=$?
69         log_fail
70         log_msg "Failed commandline was:"
71         log_msg "--------------------------------------------------"
72         log_msg "$CC conftest.c $CFLAGS $LDFLAGS $LDFLAGSCLI $2"
73         cat conftest.log >> config.log
74         log_msg "--------------------------------------------------"
75     fi
76     return $res
77 }
78
79 as_check() {
80     log_check "whether $AS supports $1"
81     echo "$1" > conftest.asm
82     if $AS conftest.asm $ASFLAGS $2 -o conftest.o >conftest.log 2>&1; then
83         res=$?
84         log_ok
85     else
86         res=$?
87         log_fail
88         log_msg "Failed commandline was:"
89         log_msg "--------------------------------------------------"
90         log_msg "$AS conftest.asm $ASFLAGS $2 -o conftest.o"
91         cat conftest.log >> config.log
92         log_msg "--------------------------------------------------"
93     fi
94     return $res
95 }
96
97 define() {
98     echo "#define $1$([ -n "$2" ] && echo " $2")" >> config.h
99 }
100
101 die() {
102     log_msg "DIED: $@"
103     echo "$@"
104     exit 1
105 }
106
107 rm -f config.h config.mak config.log x264.pc conftest*
108
109 prefix='/usr/local'
110 exec_prefix='${prefix}'
111 bindir='${exec_prefix}/bin'
112 libdir='${exec_prefix}/lib'
113 includedir='${prefix}/include'
114 DEVNULL='/dev/null'
115
116 avs_input="auto"
117 lavf_input="auto"
118 ffms_input="auto"
119 mp4_output="auto"
120 pthread="auto"
121 asm="auto"
122 debug="no"
123 gprof="no"
124 pic="no"
125 vis="no"
126 shared="no"
127
128 CFLAGS="$CFLAGS -Wall -I."
129 LDFLAGS="$LDFLAGS"
130 LDFLAGSCLI="$LDFLAGSCLI"
131 ASFLAGS="$ASFLAGS"
132 HAVE_GETOPT_LONG=1
133 cross_prefix=""
134
135 EXE=""
136
137 # parse options
138
139 for opt do
140     optarg="${opt#*=}"
141     case "$opt" in
142         --prefix=*)
143             prefix="$optarg"
144             ;;
145         --exec-prefix=*)
146             exec_prefix="$optarg"
147             ;;
148         --bindir=*)
149             bindir="$optarg"
150             ;;
151         --libdir=*)
152             libdir="$optarg"
153             ;;
154         --includedir=*)
155             includedir="$optarg"
156             ;;
157         --disable-asm)
158             asm="no"
159             ;;
160         --disable-avs-input)
161             avs_input="no"
162             ;;
163         --disable-lavf-input)
164             lavf_input="no"
165             ;;
166         --disable-ffms-input)
167             ffms_input="no"
168             ;;
169         --disable-mp4-output)
170             mp4_output="no"
171             ;;
172         --extra-asflags=*)
173             ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
174             ;;
175         --extra-cflags=*)
176             CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
177             ;;
178         --extra-ldflags=*)
179             LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
180             ;;
181         --disable-pthread)
182             pthread="no"
183             ;;
184         --enable-debug)
185             debug="yes"
186             ;;
187         --enable-gprof)
188             CFLAGS="$CFLAGS -pg"
189             LDFLAGS="$LDFLAGS -pg"
190             gprof="yes"
191             ;;
192         --enable-pic)
193             pic="yes"
194             ;;
195         --enable-shared)
196             shared="yes"
197             ;;
198         --enable-visualize)
199             vis="yes"
200             ;;
201         --host=*)
202             host="${opt#--host=}"
203             ;;
204         --cross-prefix=*)
205             cross_prefix="${opt#--cross-prefix=}"
206             ;;
207         --sysroot=*)
208             CFLAGS="$CFLAGS --sysroot=${opt#--sysroot=}"
209             LDFLAGS="$LDFLAGS --sysroot=${opt#--sysroot=}"
210             ;;
211         *)
212             echo "Unknown option $opt, ignored"
213             ;;
214     esac
215 done
216
217 CC="${CC-${cross_prefix}gcc}"
218 AR="${AR-${cross_prefix}ar}"
219 RANLIB="${RANLIB-${cross_prefix}ranlib}"
220 STRIP="${STRIP-${cross_prefix}strip}"
221
222 if [ "x$host" = x ]; then
223     host=`./config.guess`
224 fi
225 # normalize a triplet into a quadruplet
226 host=`./config.sub $host`
227
228 # split $host
229 host_cpu="${host%%-*}"
230 host="${host#*-}"
231 host_vendor="${host%%-*}"
232 host_os="${host#*-}"
233
234 case $host_os in
235   beos*)
236     SYS="BEOS"
237     define HAVE_MALLOC_H
238     ;;
239   darwin*)
240     SYS="MACOSX"
241     CFLAGS="$CFLAGS -falign-loops=16"
242     LDFLAGS="$LDFLAGS -lm"
243     if [ "$pic" = "no" ]; then
244         cc_check "" -mdynamic-no-pic && CFLAGS="$CFLAGS -mdynamic-no-pic"
245     fi
246     ;;
247   freebsd*)
248     SYS="FREEBSD"
249     LDFLAGS="$LDFLAGS -lm"
250     ;;
251   kfreebsd*-gnu)
252     SYS="FREEBSD"
253     define HAVE_MALLOC_H
254     LDFLAGS="$LDFLAGS -lm"
255     ;;
256   netbsd*)
257     SYS="NETBSD"
258     LDFLAGS="$LDFLAGS -lm"
259     ;;
260   openbsd*)
261     SYS="OPENBSD"
262     CFLAGS="$CFLAGS -I/usr/X11R6/include"
263     LDFLAGS="$LDFLAGS -lm"
264     ;;
265   *linux*)
266     SYS="LINUX"
267     define HAVE_MALLOC_H
268     LDFLAGS="$LDFLAGS -lm"
269     ;;
270   cygwin*)
271     SYS="MINGW"
272     EXE=".exe"
273     DEVNULL="NUL"
274     if cc_check "" -mno-cygwin; then
275         CFLAGS="$CFLAGS -mno-cygwin"
276         LDFLAGS="$LDFLAGS -mno-cygwin"
277     fi
278     ;;
279   mingw*)
280     SYS="MINGW"
281     EXE=".exe"
282     DEVNULL="NUL"
283     ;;
284   sunos*|solaris*)
285     SYS="SunOS"
286     define HAVE_MALLOC_H
287     LDFLAGS="$LDFLAGS -lm"
288     HAVE_GETOPT_LONG=0
289     ;;
290   *)
291     die "Unknown system $host, edit the configure"
292     ;;
293 esac
294
295 case $host_cpu in
296   i*86)
297     ARCH="X86"
298     AS="yasm"
299     ASFLAGS="$ASFLAGS -O2"
300     if [[ "$asm" == yes && "$CFLAGS" != *-march* ]]; then
301       CFLAGS="$CFLAGS -march=i686"
302     fi
303     if [[ "$asm" == yes && "$CFLAGS" != *-mfpmath* ]]; then
304       CFLAGS="$CFLAGS -mfpmath=sse -msse"
305     fi
306     if [ "$SYS" = MACOSX ]; then
307       ASFLAGS="$ASFLAGS -f macho -DPREFIX"
308     elif [ "$SYS" = MINGW ]; then
309       ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
310     else
311       ASFLAGS="$ASFLAGS -f elf"
312     fi
313     ;;
314   x86_64)
315     ARCH="X86_64"
316     AS="yasm"
317     if [ "$SYS" = MACOSX ];then
318       ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
319       if cc_check '' "-arch x86_64"; then
320         CFLAGS="$CFLAGS -arch x86_64"
321         LDFLAGS="$LDFLAGS -arch x86_64"
322       fi
323     elif [ "$SYS" = MINGW ]; then
324       ASFLAGS="$ASFLAGS -f win32 -m amd64 -DPREFIX"
325     else
326       ASFLAGS="$ASFLAGS -f elf -m amd64"
327     fi
328     ;;
329   powerpc|powerpc64)
330     ARCH="PPC"
331     if [ $asm = yes ] ; then
332       define HAVE_ALTIVEC
333       AS="${AS-${cross_prefix}gcc}"
334       if [ $SYS = MACOSX ] ; then
335         CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4"
336       else
337         CFLAGS="$CFLAGS -maltivec -mabi=altivec"
338         define HAVE_ALTIVEC_H
339       fi
340     fi
341     ;;
342   sparc)
343     if [ $asm = yes ] && test "$(uname -m)" = "sun4u"; then
344       ARCH="UltraSparc"
345       CFLAGS="$CFLAGS -mcpu=ultrasparc"
346       LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
347       AS="${AS-${cross_prefix}as}"
348       ASFLAGS="$ASFLAGS -xarch=v8plusa"
349     else
350       ARCH="Sparc"
351     fi
352     ;;
353   mips|mipsel|mips64|mips64el)
354     ARCH="MIPS"
355     ;;
356   arm*)
357     ARCH="ARM"
358     if [ "$SYS" = MACOSX ] ; then
359       AS="${AS-extras/gas-preprocessor.pl $CC}"
360       ASFLAGS="$ASFLAGS -DPREFIX -DPIC"  # apple's ld doesn't support movw/movt relocations at all
361       # build for armv7 by default
362       if ! echo $CFLAGS | grep -Eq '\-arch' ; then
363         CFLAGS="$CFLAGS -arch armv7"
364         LDFLAGS="$LDFLAGS -arch armv7"
365       fi
366     else
367       AS="${AS-${cross_prefix}gcc}"
368     fi
369     ;;
370   s390|s390x)
371     ARCH="S390"
372     ;;
373   parisc|parisc64)
374     ARCH="PARISC"
375     ;;
376   ia64)
377     ARCH="IA64"
378     ;;
379   *)
380     ARCH="$(echo $host_cpu | tr a-z A-Z)"
381     ;;
382 esac
383
384 log_msg "x264 configure script"
385 if [ -n "$*" ]; then
386     msg="Command line options:"
387     for i in $@; do
388         msg="$msg \"$i\""
389     done
390     log_msg "$msg"
391 fi
392 log_msg ""
393
394 # check requirements
395
396 cc_check || die "No working C compiler found."
397
398 if cc_check '' -std=gnu99 ; then
399     CFLAGS="$CFLAGS -std=gnu99"
400 elif cc_check '' -std=c99 ; then
401     CFLAGS="$CFLAGS -std=c99 -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE"
402 fi
403
404 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" -o $ARCH = "IA64" \) ] ; then
405     pic="yes"
406 fi
407
408 if [ $asm = auto -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
409     if ! as_check "lzcnt eax, eax" ; then
410         VER=`($AS --version || echo no assembler) 2>$DEVNULL | head -n 1`
411         echo "Found $VER"
412         echo "Minimum version is yasm-0.6.2"
413         echo "If you really want to compile without asm, configure with --disable-asm."
414         exit 1
415     fi
416     if ! cc_check '' '' '__asm__("pabsw %xmm0, %xmm0");' ; then
417         VER=`(as --version || echo no gnu as) 2>$DEVNULL | head -n 1`
418         echo "Found $VER"
419         echo "Minimum version is binutils-2.17"
420         echo "Your compiler can't handle inline SSSE3 asm."
421         echo "If you really want to compile without asm, configure with --disable-asm."
422         exit 1
423     fi
424     define HAVE_MMX
425 fi
426
427 if [ $asm = auto -a $ARCH = ARM ] ; then
428     # set flags so neon is built by default
429     echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu|-mfloat-abi)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp"
430
431     if  cc_check '' '' '__asm__("rev ip, ip");' ; then      define HAVE_ARMV6
432         cc_check '' '' '__asm__("movt r0, #0");'         && define HAVE_ARMV6T2
433         cc_check '' '' '__asm__("vadd.i16 q0, q0, q0");' && define HAVE_NEON
434         ASFLAGS="$ASFLAGS $CFLAGS -c"
435     else
436         echo "You specified a pre-ARMv6 or Thumb-1 CPU in your CFLAGS."
437         echo "If you really want to run on such a CPU, configure with --disable-asm."
438         exit 1
439     fi
440 fi
441
442 [ $asm = no ] && AS=""
443 [ "x$AS" = x ] && asm="no" || asm="yes"
444
445 define ARCH_$ARCH
446 define SYS_$SYS
447
448 echo "int i = 0x42494745; double f = 0x1.0656e6469616ep+102;" > conftest.c
449 $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed"
450 if grep -q BIGE conftest.o && grep -q FPendian conftest.o ; then
451     define WORDS_BIGENDIAN
452 elif !(grep -q EGIB conftest.o && grep -q naidnePF conftest.o) ; then
453     die "endian test failed"
454 fi
455
456 # autodetect options that weren't forced nor disabled
457
458 libpthread=""
459 if test "$pthread" = "auto" ; then
460     pthread="no"
461     case $SYS in
462         BEOS)
463             pthread="yes"
464             ;;
465         MINGW)
466             if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
467                 pthread="yes"
468                 libpthread="-lpthread"
469             elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
470                 pthread="yes"
471                 libpthread="-lpthreadGC2"
472             elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
473                 pthread="yes"
474                 libpthread="-lpthreadGC2 -lwsock32"
475                 define PTW32_STATIC_LIB
476             elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
477                 pthread="yes"
478                 libpthread="-lpthreadGC2 -lws2_32"
479                 define PTW32_STATIC_LIB
480             fi
481             ;;
482         OPENBSD)
483             cc_check pthread.h -pthread && pthread="yes" && libpthread="-pthread"
484             ;;
485         *)
486             cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
487             ;;
488     esac
489 fi
490 if test "$pthread" = "yes" ; then
491     define HAVE_PTHREAD
492     LDFLAGS="$LDFLAGS $libpthread"
493 fi
494
495 if cc_check "math.h" "-Werror" "return log2f(2);" ; then
496     define HAVE_LOG2F
497 fi
498
499 if [ "$vis" = "yes" ] && cc_check "X11/Xlib.h" "-L/usr/X11R6/lib -lX11" "XOpenDisplay( 0 );" ; then
500     LDFLAGS="-L/usr/X11R6/lib -lX11 $LDFLAGS"
501     define HAVE_VISUALIZE
502 else
503     vis="no"
504 fi
505
506 if [ "$lavf_input" = "auto" ] ; then
507     lavf_input="no"
508     if ${cross_prefix}pkg-config --exists libavformat libavcodec libswscale 2>$DEVNULL; then
509         LAVF_LIBS="$LAVF_LIBS $(${cross_prefix}pkg-config --libs libavformat libavcodec libswscale)"
510         LAVF_CFLAGS="$LAVF_CFLAGS $(${cross_prefix}pkg-config --cflags libavformat libavcodec libswscale)"
511     fi
512     if [ -z "$LAVF_LIBS" -a -z "$LAVF_CFLAGS" ]; then
513         LAVF_LIBS="-lavformat -lswscale"
514         for lib in -lpostproc -lavcodec -lavutil -lm -lz -lbz2 $libpthread -lavifil32; do
515             cc_check "" $lib && LAVF_LIBS="$LAVF_LIBS $lib"
516         done
517     fi
518     LAVF_LIBS="-L. $LAVF_LIBS"
519     if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" && \
520        cc_check libswscale/swscale.h "$LAVF_CFLAGS $LAVF_LIBS" ; then
521         # avcodec_decode_video2 is currently the most recently added function that we use; it was added in r18351
522         if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "avcodec_decode_video2( NULL, NULL, NULL, NULL );" ; then
523             lavf_input="yes"
524             define LAVF_INPUT
525         else
526             echo "Warning: libavformat is too old, update to ffmpeg r18351+"
527         fi
528     fi
529 fi
530
531 if [ "$ffms_input" = "auto" ] ; then
532     ffms_major="2"; ffms_minor="13"; ffms_micro="1"; ffms_bump="0"
533
534     ffms_input="no"
535     [ $ffms_micro -gt 0 -o $ffms_bump -gt 0 ] && vmicro=".$ffms_micro"
536     [ $ffms_bump -gt 0 ] && vbump=".$ffms_bump"
537     if ${cross_prefix}pkg-config --atleast-version="$ffms_major.$ffms_minor$vmicro$vbump" ffms2 2>$DEVNULL; then
538         FFMS2_LIBS="$FFMS2_LIBS $(${cross_prefix}pkg-config --libs ffms2)"
539         FFMS2_CFLAGS="$FFMS2_CFLAGS $(${cross_prefix}pkg-config --cflags ffms2)"
540         api_check="no"
541     else
542         api_check="yes"
543     fi
544     [ -z "$FFMS2_LIBS" ] && FFMS2_LIBS="-lffms2"
545
546     if cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS" "FFMS_DestroyVideoSource(0);" ; then
547         ffms_input="yes"
548     elif cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS -lstdc++ $LAVF_LIBS" "FFMS_DestroyVideoSource(0);" ; then
549         ffms_input="yes"
550         FFMS2_LIBS="$FFMS2_LIBS -lstdc++ $LAVF_LIBS"
551     fi
552
553     if [ $api_check = "yes" -a $ffms_input = "yes" ]; then
554         log_check "whether ffms2 version is at least $ffms_major.$ffms_minor$vmicro$vbump"
555         $CC $CFLAGS $FFMS2_CFLAGS -c -o conftest -x c - >$DEVNULL 2>&1 <<EOF
556 #include <ffms.h>
557 #if FFMS_VERSION < (($ffms_major << 24) | ($ffms_minor << 16) | ($ffms_micro << 8) | $ffms_bump)
558 #error Requires ffms2 version 2.13.1
559 #endif
560 EOF
561         [ $? = 0 ] && log_ok || { ffms_input="no"; log_fail; }
562     fi
563 fi
564
565 if [ "$ffms_input" = "yes" ]; then
566     LDFLAGSCLI="$FFMS2_LIBS $LDFLAGSCLI"
567     [ -n "$FFMS2_CFLAGS" ] && CFLAGS="$CFLAGS $FFMS2_CFLAGS"
568     define FFMS_INPUT
569 elif [ "$lavf_input" = "yes" ]; then
570     LDFLAGSCLI="$LAVF_LIBS $LDFLAGSCLI"
571     [ -n "$LAVF_CFLAGS" ] && CFLAGS="$CFLAGS $LAVF_CFLAGS"
572 fi
573
574 MP4_LDFLAGS="-lgpac_static"
575 if [ $SYS = MINGW ]; then
576     MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm"
577 fi
578 if [ "$mp4_output" = "auto" ] ; then
579     mp4_output="no"
580     if cc_check gpac/isomedia.h "$MP4_LDFLAGS" ; then
581         if cc_check gpac/isomedia.h "$MP4_LDFLAGS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0);" ; then
582             mp4_output="yes"
583         else
584             echo "Warning: gpac is too old, update to 2007-06-21 UTC or later"
585         fi
586     fi
587 fi
588 if [ "$mp4_output" = "yes" ] ; then
589     define MP4_OUTPUT
590     if cc_check gpac/isomedia.h "-Werror $MP4_LDFLAGS" "gf_malloc(1); gf_free(NULL);" ; then
591         define HAVE_GF_MALLOC
592     fi
593     LDFLAGSCLI="$LDFLAGSCLI $MP4_LDFLAGS"
594 fi
595
596 if [ "$avs_input" = "auto" ] ; then
597     avs_input=no
598     if [ $SYS = MINGW ] && cc_check avisynth_c.h ; then
599         avs_input="yes"
600         define AVS_INPUT
601         define HAVE_AVISYNTH_C_H
602     elif [ $SYS = MINGW ] && cc_check extras/avisynth_c.h ; then
603         avs_input="yes"
604         define AVS_INPUT
605     fi
606 fi
607
608 if [ "$pic" = "yes" ] ; then
609     CFLAGS="$CFLAGS -fPIC"
610     ASFLAGS="$ASFLAGS -DPIC"
611     # resolve textrels in the x86 asm
612     cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
613 fi
614
615 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
616     CFLAGS="$CFLAGS -s -fomit-frame-pointer"
617     LDFLAGS="$LDFLAGS -s"
618 fi
619
620 if [ "$debug" = "yes" ]; then
621     CFLAGS="-O1 -g $CFLAGS"
622 elif [ $ARCH = ARM ]; then
623     # arm-gcc-4.2 produces incorrect output with -ffast-math
624     # and it doesn't save any speed anyway on 4.4, so disable it
625     CFLAGS="-O3 -fno-fast-math $CFLAGS"
626 else
627     CFLAGS="-O3 -ffast-math $CFLAGS"
628 fi
629
630 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
631     define fseek fseeko
632     define ftell ftello
633 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
634     define fseek fseeko64
635     define ftell ftello64
636 fi
637
638 rm -f conftest*
639
640 # generate config files
641
642 cat > config.mak << EOF
643 prefix=$prefix
644 exec_prefix=$exec_prefix
645 bindir=$bindir
646 libdir=$libdir
647 includedir=$includedir
648 ARCH=$ARCH
649 SYS=$SYS
650 CC=$CC
651 CFLAGS=$CFLAGS
652 LDFLAGS=$LDFLAGS
653 LDFLAGSCLI=$LDFLAGSCLI
654 AR=$AR
655 RANLIB=$RANLIB
656 STRIP=$STRIP
657 AS=$AS
658 ASFLAGS=$ASFLAGS
659 EXE=$EXE
660 VIS=$vis
661 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
662 DEVNULL=$DEVNULL
663 EOF
664
665 if [ "$shared" = "yes" ]; then
666     API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
667     if [ "$SYS" = "MINGW" ]; then
668         echo "SONAME=libx264-$API.dll" >> config.mak
669         echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
670         echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
671     elif [ "$SYS" = "MACOSX" ]; then
672         echo "SOSUFFIX=dylib" >> config.mak
673         echo "SONAME=libx264.$API.dylib" >> config.mak
674         echo 'SOFLAGS=-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak
675     elif [ "$SYS" = "SunOS" ]; then
676         echo "SOSUFFIX=so" >> config.mak
677         echo "SONAME=libx264.so.$API" >> config.mak
678         echo 'SOFLAGS=-Wl,-h,$(SONAME)' >> config.mak
679     else
680         echo "SOSUFFIX=so" >> config.mak
681         echo "SONAME=libx264.so.$API" >> config.mak
682         echo 'SOFLAGS=-Wl,-soname,$(SONAME)' >> config.mak
683     fi
684     echo 'default: $(SONAME)' >> config.mak
685 fi
686
687 ./version.sh >> config.h
688
689 pclibs="-L$libdir -lx264 $libpthread"
690
691 cat > x264.pc << EOF
692 prefix=$prefix
693 exec_prefix=$exec_prefix
694 libdir=$libdir
695 includedir=$includedir
696
697 Name: x264
698 Description: H.264 (MPEG4 AVC) encoder library
699 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
700 Libs: $pclibs
701 Cflags: -I$includedir
702 EOF
703
704 cat > conftest.log <<EOF
705 Platform:   $ARCH
706 System:     $SYS
707 asm:        $asm
708 avs input:  $avs_input
709 lavf input: $lavf_input
710 ffms input: $ffms_input
711 mp4 output: $mp4_output
712 pthread:    $pthread
713 debug:      $debug
714 gprof:      $gprof
715 PIC:        $pic
716 shared:     $shared
717 visualize:  $vis
718 EOF
719
720 echo >> config.log
721 cat conftest.log >> config.log
722 cat conftest.log
723 rm conftest.log
724
725 echo
726 echo "You can run 'make' or 'make fprofiled' now."
727