]> git.sesse.net Git - x264/blob - configure
Warn about shadowed variable declarations
[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            disables avisynth support (windows only)"
11 echo "  --disable-lavf           disables libavformat support"
12 echo "  --disable-ffms           disables ffmpegsource support"
13 echo "  --disable-gpac           disables gpac support"
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" || echo " 1")" >> 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="auto"
117 lavf="auto"
118 ffms="auto"
119 gpac="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)
161             avs="no"
162             ;;
163         --disable-lavf)
164             lavf="no"
165             ;;
166         --disable-ffms)
167             ffms="no"
168             ;;
169         --disable-gpac)
170             gpac="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" == auto && "$CFLAGS" != *-march* ]]; then
301       CFLAGS="$CFLAGS -march=i686"
302     fi
303     if [[ "$asm" == auto && "$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       LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
311     else
312       ASFLAGS="$ASFLAGS -f elf"
313     fi
314     ;;
315   x86_64)
316     ARCH="X86_64"
317     AS="yasm"
318     if [ "$SYS" = MACOSX ];then
319       ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
320       if cc_check '' "-arch x86_64"; then
321         CFLAGS="$CFLAGS -arch x86_64"
322         LDFLAGS="$LDFLAGS -arch x86_64"
323       fi
324     elif [ "$SYS" = MINGW ]; then
325       ASFLAGS="$ASFLAGS -f win32 -m amd64 -DPREFIX"
326     else
327       ASFLAGS="$ASFLAGS -f elf -m amd64"
328     fi
329     ;;
330   powerpc|powerpc64)
331     ARCH="PPC"
332     if [ $asm = auto ] ; then
333       define HAVE_ALTIVEC
334       AS="${AS-${cross_prefix}gcc}"
335       if [ $SYS = MACOSX ] ; then
336         CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4"
337       else
338         CFLAGS="$CFLAGS -maltivec -mabi=altivec"
339         define HAVE_ALTIVEC_H
340       fi
341     fi
342     ;;
343   sparc)
344     if [ $asm = auto ] && test "$(uname -m)" = "sun4u"; then
345       ARCH="UltraSparc"
346       CFLAGS="$CFLAGS -mcpu=ultrasparc"
347       LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
348       AS="${AS-${cross_prefix}as}"
349       ASFLAGS="$ASFLAGS -xarch=v8plusa"
350     else
351       ARCH="Sparc"
352     fi
353     ;;
354   mips|mipsel|mips64|mips64el)
355     ARCH="MIPS"
356     ;;
357   arm*)
358     ARCH="ARM"
359     if [ "$SYS" = MACOSX ] ; then
360       AS="${AS-extras/gas-preprocessor.pl $CC}"
361       ASFLAGS="$ASFLAGS -DPREFIX -DPIC"  # apple's ld doesn't support movw/movt relocations at all
362       # build for armv7 by default
363       if ! echo $CFLAGS | grep -Eq '\-arch' ; then
364         CFLAGS="$CFLAGS -arch armv7"
365         LDFLAGS="$LDFLAGS -arch armv7"
366       fi
367     else
368       AS="${AS-${cross_prefix}gcc}"
369     fi
370     ;;
371   s390|s390x)
372     ARCH="S390"
373     ;;
374   parisc|parisc64)
375     ARCH="PARISC"
376     ;;
377   ia64)
378     ARCH="IA64"
379     ;;
380   *)
381     ARCH="$(echo $host_cpu | tr a-z A-Z)"
382     ;;
383 esac
384
385 log_msg "x264 configure script"
386 if [ -n "$*" ]; then
387     msg="Command line options:"
388     for i in $@; do
389         msg="$msg \"$i\""
390     done
391     log_msg "$msg"
392 fi
393 log_msg ""
394
395 # check requirements
396
397 cc_check || die "No working C compiler found."
398
399 if cc_check '' -std=gnu99 ; then
400     CFLAGS="$CFLAGS -std=gnu99"
401 elif cc_check '' -std=c99 ; then
402     CFLAGS="$CFLAGS -std=c99 -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE"
403 fi
404
405 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" -o $ARCH = "IA64" \) ] ; then
406     pic="yes"
407 fi
408
409 if [ $asm = auto -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
410     if ! as_check "lzcnt eax, eax" ; then
411         VER=`($AS --version || echo no assembler) 2>$DEVNULL | head -n 1`
412         echo "Found $VER"
413         echo "Minimum version is yasm-0.6.2"
414         echo "If you really want to compile without asm, configure with --disable-asm."
415         exit 1
416     fi
417     if ! cc_check '' '' '__asm__("pabsw %xmm0, %xmm0");' ; then
418         VER=`(as --version || echo no gnu as) 2>$DEVNULL | head -n 1`
419         echo "Found $VER"
420         echo "Minimum version is binutils-2.17"
421         echo "Your compiler can't handle inline SSSE3 asm."
422         echo "If you really want to compile without asm, configure with --disable-asm."
423         exit 1
424     fi
425     define HAVE_MMX
426 fi
427
428 if [ $asm = auto -a $ARCH = ARM ] ; then
429     # set flags so neon is built by default
430     echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu|-mfloat-abi)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp"
431
432     if  cc_check '' '' '__asm__("rev ip, ip");' ; then      define HAVE_ARMV6
433         cc_check '' '' '__asm__("movt r0, #0");'         && define HAVE_ARMV6T2
434         cc_check '' '' '__asm__("vadd.i16 q0, q0, q0");' && define HAVE_NEON
435         ASFLAGS="$ASFLAGS $CFLAGS -c"
436     else
437         echo "You specified a pre-ARMv6 or Thumb-1 CPU in your CFLAGS."
438         echo "If you really want to run on such a CPU, configure with --disable-asm."
439         exit 1
440     fi
441 fi
442
443 [ $asm = no ] && AS=""
444 [ "x$AS" = x ] && asm="no" || asm="yes"
445
446 define ARCH_$ARCH
447 define SYS_$SYS
448
449 echo "int i = 0x42494745; double f = 0x1.0656e6469616ep+102;" > conftest.c
450 $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed"
451 if grep -q BIGE conftest.o && grep -q FPendian conftest.o ; then
452     define WORDS_BIGENDIAN
453 elif !(grep -q EGIB conftest.o && grep -q naidnePF conftest.o) ; then
454     die "endian test failed"
455 fi
456
457 # autodetect options that weren't forced nor disabled
458
459 libpthread=""
460 if test "$pthread" = "auto" ; then
461     pthread="no"
462     case $SYS in
463         BEOS)
464             pthread="yes"
465             ;;
466         MINGW)
467             if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
468                 pthread="yes"
469                 libpthread="-lpthread"
470             elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
471                 pthread="yes"
472                 libpthread="-lpthreadGC2"
473             elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
474                 pthread="yes"
475                 libpthread="-lpthreadGC2 -lwsock32"
476                 define PTW32_STATIC_LIB
477             elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
478                 pthread="yes"
479                 libpthread="-lpthreadGC2 -lws2_32"
480                 define PTW32_STATIC_LIB
481             fi
482             ;;
483         OPENBSD)
484             cc_check pthread.h -pthread && pthread="yes" && libpthread="-pthread"
485             ;;
486         *)
487             cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
488             ;;
489     esac
490 fi
491 if test "$pthread" = "yes" ; then
492     define HAVE_PTHREAD
493     LDFLAGS="$LDFLAGS $libpthread"
494 fi
495
496 if cc_check "math.h" "-Werror" "return log2f(2);" ; then
497     define HAVE_LOG2F
498 fi
499
500 if [ "$vis" = "yes" ] && cc_check "X11/Xlib.h" "-L/usr/X11R6/lib -lX11" "XOpenDisplay( 0 );" ; then
501     LDFLAGS="-L/usr/X11R6/lib -lX11 $LDFLAGS"
502     define HAVE_VISUALIZE
503 else
504     vis="no"
505 fi
506
507 if [ "$lavf" = "auto" ] ; then
508     lavf="no"
509     if ${cross_prefix}pkg-config --exists libavformat libavcodec libswscale 2>$DEVNULL; then
510         LAVF_LIBS="$LAVF_LIBS $(${cross_prefix}pkg-config --libs libavformat libavcodec libswscale)"
511         LAVF_CFLAGS="$LAVF_CFLAGS $(${cross_prefix}pkg-config --cflags libavformat libavcodec libswscale)"
512     fi
513     if [ -z "$LAVF_LIBS" -a -z "$LAVF_CFLAGS" ]; then
514         LAVF_LIBS="-lavformat -lswscale"
515         for lib in -lpostproc -lavcodec -lavutil -lm -lz -lbz2 $libpthread -lavifil32; do
516             cc_check "" $lib && LAVF_LIBS="$LAVF_LIBS $lib"
517         done
518     fi
519     LAVF_LIBS="-L. $LAVF_LIBS"
520     if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" && \
521        cc_check libswscale/swscale.h "$LAVF_CFLAGS $LAVF_LIBS" ; then
522         # avcodec_decode_video2 is currently the most recently added function that we use; it was added in r18351
523         if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "avcodec_decode_video2( NULL, NULL, NULL, NULL );" ; then
524             lavf="yes"
525             define HAVE_LAVF
526         else
527             echo "Warning: libavformat is too old, update to ffmpeg r18351+"
528         fi
529     fi
530 fi
531
532 if [ "$ffms" = "auto" ] ; then
533     ffms_major="2"; ffms_minor="13"; ffms_micro="1"; ffms_bump="0"
534
535     ffms="no"
536     [ $ffms_micro -gt 0 -o $ffms_bump -gt 0 ] && vmicro=".$ffms_micro"
537     [ $ffms_bump -gt 0 ] && vbump=".$ffms_bump"
538     if ${cross_prefix}pkg-config --atleast-version="$ffms_major.$ffms_minor$vmicro$vbump" ffms2 2>$DEVNULL; then
539         FFMS2_LIBS="$FFMS2_LIBS $(${cross_prefix}pkg-config --libs ffms2)"
540         FFMS2_CFLAGS="$FFMS2_CFLAGS $(${cross_prefix}pkg-config --cflags ffms2)"
541         api_check="no"
542     else
543         api_check="yes"
544     fi
545     [ -z "$FFMS2_LIBS" ] && FFMS2_LIBS="-lffms2"
546
547     if cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS" "FFMS_DestroyVideoSource(0);" ; then
548         ffms="yes"
549     elif cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS -lstdc++ $LAVF_LIBS" "FFMS_DestroyVideoSource(0);" ; then
550         ffms="yes"
551         FFMS2_LIBS="$FFMS2_LIBS -lstdc++ $LAVF_LIBS"
552     fi
553
554     if [ $api_check = "yes" -a $ffms = "yes" ]; then
555         log_check "whether ffms2 version is at least $ffms_major.$ffms_minor$vmicro$vbump"
556         $CC $CFLAGS $FFMS2_CFLAGS -c -o conftest -x c - >$DEVNULL 2>&1 <<EOF
557 #include <ffms.h>
558 #if FFMS_VERSION < (($ffms_major << 24) | ($ffms_minor << 16) | ($ffms_micro << 8) | $ffms_bump)
559 #error Requires ffms2 version 2.13.1
560 #endif
561 EOF
562         [ $? = 0 ] && log_ok || { ffms="no"; log_fail; }
563     fi
564 fi
565
566 if [ "$ffms" = "yes" ]; then
567     LDFLAGSCLI="$FFMS2_LIBS $LDFLAGSCLI"
568     [ -n "$FFMS2_CFLAGS" ] && CFLAGS="$CFLAGS $FFMS2_CFLAGS"
569     define HAVE_FFMS
570 elif [ "$lavf" = "yes" ]; then
571     LDFLAGSCLI="$LAVF_LIBS $LDFLAGSCLI"
572     [ -n "$LAVF_CFLAGS" ] && CFLAGS="$CFLAGS $LAVF_CFLAGS"
573 fi
574
575 GPAC_LIBS="-lgpac_static"
576 if [ $SYS = MINGW ]; then
577     GPAC_LIBS="$GPAC_LIBS -lwinmm"
578 fi
579 if [ "$gpac" = "auto" ] ; then
580     gpac="no"
581     if cc_check gpac/isomedia.h "$GPAC_LIBS" ; then
582         if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0);" ; then
583             gpac="yes"
584         else
585             echo "Warning: gpac is too old, update to 2007-06-21 UTC or later"
586         fi
587     fi
588 fi
589 if [ "$gpac" = "yes" ] ; then
590     define HAVE_GPAC
591     if cc_check gpac/isomedia.h "-Werror $GPAC_LIBS" "gf_malloc(1); gf_free(NULL);" ; then
592         define HAVE_GF_MALLOC
593     fi
594     LDFLAGSCLI="$LDFLAGSCLI $GPAC_LIBS"
595 fi
596
597 if [ "$avs" = "auto" ] ; then
598     avs=no
599     if [ $SYS = MINGW ] && cc_check avisynth_c.h ; then
600         avs="yes"
601         define HAVE_AVS
602         define HAVE_AVISYNTH_C_H
603     elif [ $SYS = MINGW ] && cc_check extras/avisynth_c.h ; then
604         avs="yes"
605         define HAVE_AVS
606     fi
607 fi
608
609 if [ "$pic" = "yes" ] ; then
610     CFLAGS="$CFLAGS -fPIC"
611     ASFLAGS="$ASFLAGS -DPIC"
612     # resolve textrels in the x86 asm
613     cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
614 fi
615
616 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
617     CFLAGS="$CFLAGS -s -fomit-frame-pointer"
618     LDFLAGS="$LDFLAGS -s"
619 fi
620
621 if [ "$debug" = "yes" ]; then
622     CFLAGS="-O1 -g $CFLAGS"
623 elif [ $ARCH = ARM ]; then
624     # arm-gcc-4.2 produces incorrect output with -ffast-math
625     # and it doesn't save any speed anyway on 4.4, so disable it
626     CFLAGS="-O3 -fno-fast-math $CFLAGS"
627 else
628     CFLAGS="-O3 -ffast-math $CFLAGS"
629 fi
630
631 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
632     define fseek fseeko
633     define ftell ftello
634 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
635     define fseek fseeko64
636     define ftell ftello64
637 fi
638
639 if cc_check '' -Wshadow ; then
640     CFLAGS="-Wshadow $CFLAGS"
641 fi
642
643 rm -f conftest*
644
645 # generate config files
646
647 cat > config.mak << EOF
648 prefix=$prefix
649 exec_prefix=$exec_prefix
650 bindir=$bindir
651 libdir=$libdir
652 includedir=$includedir
653 ARCH=$ARCH
654 SYS=$SYS
655 CC=$CC
656 CFLAGS=$CFLAGS
657 LDFLAGS=$LDFLAGS
658 LDFLAGSCLI=$LDFLAGSCLI
659 AR=$AR
660 RANLIB=$RANLIB
661 STRIP=$STRIP
662 AS=$AS
663 ASFLAGS=$ASFLAGS
664 EXE=$EXE
665 VIS=$vis
666 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
667 DEVNULL=$DEVNULL
668 EOF
669
670 if [ "$shared" = "yes" ]; then
671     API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
672     if [ "$SYS" = "MINGW" ]; then
673         echo "SONAME=libx264-$API.dll" >> config.mak
674         echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
675         echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
676     elif [ "$SYS" = "MACOSX" ]; then
677         echo "SOSUFFIX=dylib" >> config.mak
678         echo "SONAME=libx264.$API.dylib" >> config.mak
679         echo 'SOFLAGS=-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak
680     elif [ "$SYS" = "SunOS" ]; then
681         echo "SOSUFFIX=so" >> config.mak
682         echo "SONAME=libx264.so.$API" >> config.mak
683         echo 'SOFLAGS=-Wl,-h,$(SONAME)' >> config.mak
684     else
685         echo "SOSUFFIX=so" >> config.mak
686         echo "SONAME=libx264.so.$API" >> config.mak
687         echo 'SOFLAGS=-Wl,-soname,$(SONAME)' >> config.mak
688     fi
689     echo 'default: $(SONAME)' >> config.mak
690 fi
691
692 ./version.sh >> config.h
693
694 pclibs="-L$libdir -lx264 $libpthread"
695
696 cat > x264.pc << EOF
697 prefix=$prefix
698 exec_prefix=$exec_prefix
699 libdir=$libdir
700 includedir=$includedir
701
702 Name: x264
703 Description: H.264 (MPEG4 AVC) encoder library
704 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
705 Libs: $pclibs
706 Cflags: -I$includedir
707 EOF
708
709 cat > conftest.log <<EOF
710 Platform:   $ARCH
711 System:     $SYS
712 asm:        $asm
713 avs:        $avs
714 lavf:       $lavf
715 ffms:       $ffms
716 gpac:       $gpac
717 pthread:    $pthread
718 debug:      $debug
719 gprof:      $gprof
720 PIC:        $pic
721 shared:     $shared
722 visualize:  $vis
723 EOF
724
725 echo >> config.log
726 cat conftest.log >> config.log
727 cat conftest.log
728 rm conftest.log
729
730 echo
731 echo "You can run 'make' or 'make fprofiled' now."
732