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