Statistics
| Branch: | Revision:

ffmpeg / configure @ 860391a5

History | View | Annotate | Download (56.9 KB)

1
#!/bin/sh
2
#
3
# ffmpeg configure script (c) 2000, 2001, 2002 Fabrice Bellard
4
#
5

    
6
# make sure we are running under a compatible shell
7
# try to make this part work with most shells
8

    
9
try_exec(){
10
    type "$1" >/dev/null 2>&1 && exec "$@"
11
}
12

    
13
unset foo
14
(: ${foo%%bar}) 2>/dev/null && ! (: ${foo?}) 2>/dev/null
15
if test "$?" != 0; then
16
    export FF_CONF_EXEC
17
    if test "0$FF_CONF_EXEC" -lt 1; then
18
        FF_CONF_EXEC=1
19
        try_exec bash "$0" "$@"
20
    fi
21
    if test "0$FF_CONF_EXEC" -lt 2; then
22
        FF_CONF_EXEC=2
23
        try_exec ksh "$0" "$@"
24
    fi
25
    if test "0$FF_CONF_EXEC" -lt 3; then
26
        FF_CONF_EXEC=3
27
        try_exec /usr/xpg4/bin/sh "$0" "$@"
28
    fi
29
    echo "No compatible shell script interpreter found."
30
    echo "This configure script requires a POSIX compatible shell"
31
    echo "such as bash or ksh."
32
    if test "$BASH_VERSION" = '2.04.0(1)-release'; then
33
        echo "This bash version ($BASH_VERSION) is broken on your platform."
34
        echo "Upgrade to a later version if available."
35
    fi
36
    exit 1
37
fi
38

    
39
show_help(){
40
  echo "Usage: configure [options]"
41
  echo "Options: [defaults in brackets after descriptions]"
42
  echo
43
  echo "Standard options:"
44
  echo "  --help                   print this message"
45
  echo "  --log[=FILE|yes|no]      log tests and output to FILE [config.err]"
46
  echo "  --prefix=PREFIX          install in PREFIX [$PREFIX]"
47
  echo "  --libdir=DIR             install libs in DIR [PREFIX/lib]"
48
  echo "  --shlibdir=DIR           install shared libs in DIR [PREFIX/lib]"
49
  echo "  --incdir=DIR             install includes in DIR [PREFIX/include/ffmpeg]"
50
  echo "  --mandir=DIR             install man page in DIR [PREFIX/man]"
51
  echo "  --enable-mp3lame         enable MP3 encoding via libmp3lame [default=no]"
52
  echo "  --enable-libnut          enable NUT support via libnut [default=no]"
53
  echo "  --enable-libogg          enable Ogg support via libogg [default=no]"
54
  echo "  --enable-vorbis          enable Vorbis support via libvorbis [default=no]"
55
  echo "  --enable-faad            enable FAAD support via libfaad [default=no]"
56
  echo "  --enable-faadbin         build FAAD support with runtime linking [default=no]"
57
  echo "  --enable-faac            enable FAAC support via libfaac [default=no]"
58
  echo "  --enable-libgsm          enable GSM support via libgsm [default=no]"
59
  echo "  --enable-xvid            enable XviD support via xvidcore [default=no]"
60
  echo "  --enable-x264            enable H.264 encoding via x264 [default=no]"
61
  echo "  --enable-mingw32         enable MinGW native/cross Windows compile"
62
  echo "  --enable-mingwce         enable MinGW native/cross WinCE compile"
63
  echo "  --enable-a52             enable GPLed A52 support [default=no]"
64
  echo "  --enable-a52bin          open liba52.so.0 at runtime [default=no]"
65
  echo "  --enable-dts             enable GPLed DTS support [default=no]"
66
  echo "  --enable-pp              enable GPLed postprocessing support [default=no]"
67
  echo "  --enable-static          build static libraries [default=yes]"
68
  echo "  --disable-static         do not build static libraries [default=no]"
69
  echo "  --enable-shared          build shared libraries [default=no]"
70
  echo "  --disable-shared         do not build shared libraries [default=yes]"
71
  echo "  --enable-amr_nb          enable amr_nb float audio codec"
72
  echo "  --enable-amr_nb-fixed    use fixed point for amr-nb codec"
73
  echo "  --enable-amr_wb          enable amr_wb float audio codec"
74
  echo "  --enable-amr_if2         enable amr_wb IF2 audio codec"
75
  echo "  --enable-sunmlib         use Sun medialib [default=no]"
76
  echo "  --enable-pthreads        use pthreads [default=no]"
77
  echo "  --enable-dc1394          enable IIDC-1394 grabbing using libdc1394"
78
  echo "                           and libraw1394 [default=no]"
79
  echo "  --enable-swscaler        software scaler support [default=no]"
80
  echo "  --enable-avisynth        allow reading AVISynth script files [default=no]"
81
  echo "  --enable-gpl             allow use of GPL code, the resulting libav*"
82
  echo "                           and ffmpeg will be under GPL [default=no]"
83
  echo ""
84
  echo "Advanced options (experts only):"
85
  echo "  --source-path=PATH       path to source code [$source_path]"
86
  echo "  --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]"
87
  echo "  --cross-compile          assume a cross-compiler is used"
88
  echo "  --cc=CC                  use C compiler CC [$cc]"
89
  echo "  --make=MAKE              use specified make [$make]"
90
  echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
91
  echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
92
  echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
93
  echo "  --build-suffix=SUFFIX    suffix for application specific build []"
94
  echo "  --arch=ARCH              select architecture  [$arch]"
95
  echo "  --cpu=CPU                selects the minimum cpu required (affects
96
                                   instruction selection, may crash on older CPUs)"
97
  echo "  --powerpc-perf-enable    enable performance report on PPC"
98
  echo "                           (requires enabling PMC)"
99
  echo "  --disable-mmx            disable MMX usage"
100
  echo "  --disable-armv5te        disable armv5te usage"
101
  echo "  --disable-iwmmxt         disable iwmmxt usage"
102
  echo "  --disable-altivec        disable AltiVec usage"
103
  echo "  --disable-audio-oss      disable OSS audio support [default=no]"
104
  echo "  --disable-audio-beos     disable BeOS audio support [default=no]"
105
  echo "  --disable-v4l            disable video4linux grabbing [default=no]"
106
  echo "  --disable-v4l2           disable video4linux2 grabbing [default=no]"
107
  echo "  --disable-bktr           disable bktr video grabbing [default=no]"
108
  echo "  --disable-dv1394         disable DV1394 grabbing [default=no]"
109
  echo "  --disable-network        disable network support [default=no]"
110
  echo "  --disable-ipv6           disable ipv6 support [default=no]"
111
  echo "  --disable-zlib           disable zlib [default=no]"
112
  echo "  --disable-vhook          disable video hooking support"
113
  echo "  --enable-gprof           enable profiling with gprof [$gprof]"
114
  echo "  --disable-debug          disable debugging symbols"
115
  echo "  --disable-opts           disable compiler optimizations"
116
  echo "  --enable-extra-warnings  enable more compiler warnings"
117
  echo "  --disable-mpegaudio-hp   faster (but less accurate)"
118
  echo "                           MPEG audio decoding [default=no]"
119
  echo "  --disable-protocols      disable I/O protocols support [default=no]"
120
  echo "  --disable-ffmpeg         disable ffmpeg build"
121
  echo "  --disable-ffserver       disable ffserver build"
122
  echo "  --disable-ffplay         disable ffplay build"
123
  echo "  --enable-small           optimize for size instead of speed"
124
  echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
125
  echo "  --disable-strip          disable stripping of executables and shared libraries"
126
  echo "  --disable-encoder=NAME   disables encoder NAME"
127
  echo "  --enable-encoder=NAME    enables encoder NAME"
128
  echo "  --disable-decoder=NAME   disables decoder NAME"
129
  echo "  --enable-decoder=NAME    enables decoder NAME"
130
  echo "  --disable-encoders       disables all encoders"
131
  echo "  --disable-decoders       disables all decoders"
132
  echo "  --disable-muxer=NAME     disables muxer NAME"
133
  echo "  --enable-muxer=NAME      enables muxer NAME"
134
  echo "  --disable-muxers         disables all muxers"
135
  echo "  --disable-demuxer=NAME   disables demuxer NAME"
136
  echo "  --enable-demuxer=NAME    enables demuxer NAME"
137
  echo "  --disable-demuxers       disables all demuxers"
138
  echo "  --enable-parser=NAME     enables parser NAME"
139
  echo "  --disable-parser=NAME    disables parser NAME"
140
  echo "  --disable-parsers        disables all parsers"
141
  echo ""
142
  echo "NOTE: Object files are built at the place where configure is launched."
143
  exit 1
144
}
145

    
146
log(){
147
    echo "$@" >>$logfile
148
}
149

    
150
log_file(){
151
    log BEGIN $1
152
    cat -n $1 >>$logfile
153
    log END $1
154
}
155

    
156
echolog(){
157
    log "$@"
158
    echo "$@"
159
}
160

    
161
die(){
162
    echolog "$@"
163
    cat <<EOF
164
If you think configure made a mistake, make sure you are using the latest
165
version from SVN.  If the latest version fails, report the problem to the
166
ffmpeg-devel@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
167
EOF
168
    if enabled logging; then
169
        cat <<EOF
170
Include the log file "$logfile" produced by configure as this will help
171
solving the problem.
172
EOF
173
    else
174
cat <<EOF
175
Rerun configure with logging enabled (do not use --log=no), and include the
176
log this produces with your report.
177
EOF
178
    fi
179
    rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
180
    exit 1
181
}
182

    
183
# "tr '[a-z]' '[A-Z]'" is a workaround for Solaris tr not grokking "tr a-z A-Z"
184
toupper(){
185
    echo "$@" | tr '[a-z]' '[A-Z]'
186
}
187

    
188
set_all(){
189
    value=$1
190
    shift
191
    for var in $*; do
192
        eval $var=$value
193
    done
194
}
195

    
196
enable(){
197
    set_all yes $*
198
}
199

    
200
disable(){
201
    set_all no $*
202
}
203

    
204
enabled(){
205
    eval test "x\$$1" = "xyes"
206
}
207

    
208
enabled_all(){
209
    for opt; do
210
        enabled $opt || return 1
211
    done
212
}
213

    
214
enabled_any(){
215
    for opt; do
216
        enabled $opt && return 0
217
    done
218
}
219

    
220
print_config(){
221
    pfx=$1
222
    header=$2
223
    makefile=$3
224
    shift 3
225
    for cfg; do
226
        if enabled $cfg; then
227
            ucname="${pfx}`toupper $cfg`"
228
            echo "#define ${ucname} 1" >> $header
229
            echo "${ucname}=yes" >> $makefile
230
        fi
231
    done
232
}
233

    
234
flags_saved(){
235
    (: ${SAVE_CFLAGS?}) 2>/dev/null
236
}
237

    
238
save_flags(){
239
    flags_saved && return
240
    SAVE_CFLAGS="$CFLAGS"
241
    SAVE_LDFLAGS="$LDFLAGS"
242
    SAVE_extralibs="$extralibs"
243
}
244

    
245
restore_flags(){
246
    CFLAGS="$SAVE_CFLAGS"
247
    LDFLAGS="$SAVE_LDFLAGS"
248
    extralibs="$SAVE_extralibs"
249
    unset SAVE_CFLAGS
250
    unset SAVE_LDFLAGS
251
    unset SAVE_extralibs
252
}
253

    
254
temp_cflags(){
255
    save_flags
256
    CFLAGS="$CFLAGS $*"
257
}
258

    
259
temp_ldflags(){
260
    save_flags
261
    LDFLAGS="$LDFLAGS $*"
262
}
263

    
264
temp_extralibs(){
265
    save_flags
266
    extralibs="$extralibs $*"
267
}
268

    
269
append(){
270
    var=$1
271
    shift
272
    flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
273
    eval "$var=\"\$$var $*\""
274
}
275

    
276
add_cflags(){
277
    append CFLAGS "$@"
278
}
279

    
280
add_ldflags(){
281
    append LDFLAGS "$@"
282
}
283

    
284
add_extralibs(){
285
    append extralibs "$@"
286
}
287

    
288
check_cmd(){
289
    log "$@"
290
    "$@" >>$logfile 2>&1
291
}
292

    
293
check_cc(){
294
    log check_cc "$@"
295
    cat >$TMPC
296
    log_file $TMPC
297
    check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
298
}
299

    
300
check_cpp(){
301
    log check_cpp "$@"
302
    cat >$TMPC
303
    log_file $TMPC
304
    check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
305
}
306

    
307
check_ld(){
308
    log check_ld "$@"
309
    check_cc || return
310
    check_cmd $cc $LDFLAGS "$@" -o $TMPE $TMPO $extralibs
311
}
312

    
313
check_cflags(){
314
    log check_cflags "$@"
315
    check_cc "$@" <<EOF && add_cflags "$@"
316
int x;
317
EOF
318
}
319

    
320
check_ldflags(){
321
    log check_ldflags "$@"
322
    check_ld "$@" <<EOF && add_ldflags "$@"
323
int main(){
324
    return 0;
325
}
326
EOF
327
}
328

    
329
check_header(){
330
    log check_header "$@"
331
    header=$1
332
    shift
333
    check_cpp "$@" <<EOF
334
#include <$header>
335
int x;
336
EOF
337
    err=$?
338
    var=`echo $header | sed 's/[^[:alnum:]]/_/g'`
339
    test "$err" = 0 && enable $var || disable $var
340
    return $err
341
}
342

    
343
check_func(){
344
    log check_func "$@"
345
    func=$1
346
    shift
347
    check_ld "$@" <<EOF
348
extern int $func();
349
int main(){
350
    $func();
351
}
352
EOF
353
    err=$?
354
    test "$err" = 0 && enable $func || disable $func
355
    return $err
356
}
357

    
358
check_lib(){
359
    log check_lib "$@"
360
    header="$1"
361
    func="$2"
362
    shift 2
363
    temp_extralibs "$@"
364
    check_header $header && check_func $func && add_extralibs "$@"
365
    err=$?
366
    restore_flags
367
    return $err
368
}
369

    
370
check_exec(){
371
    check_ld "$@" && { test "$cross_compile" = yes || $TMPE >>$logfile 2>&1; }
372
}
373

    
374
require(){
375
    name="$1"
376
    header="$2"
377
    func="$3"
378
    shift 3
379
    check_lib $header $func "$@" || die "ERROR: $name not found"
380
}
381

    
382
CONFIG_LIST='
383
    encoders
384
    decoders
385
    parsers
386
    muxers
387
    demuxers
388
    a52
389
    a52bin
390
    amr
391
    amr_nb
392
    amr_nb_fixed
393
    amr_wb
394
    audio_beos
395
    audio_oss
396
    avisynth
397
    beos_netserver
398
    bktr
399
    dc1394
400
    dts
401
    dv1394
402
    faac
403
    faad
404
    faadbin
405
    ffmpeg
406
    ffplay
407
    ffserver
408
    gpl
409
    ipv6
410
    libgsm
411
    libnut
412
    libogg
413
    libvorbis
414
    memalign_hack
415
    mp3lame
416
    mpegaudio_hp
417
    network
418
    pp
419
    protocols
420
    swscaler
421
    vhook
422
    video4linux
423
    video4linux2
424
    wince
425
    x264
426
    xvid
427
    zlib
428
'
429

    
430
HAVE_LIST='
431
    altivec_h
432
    beosthreads
433
    byteswap_h
434
    dcbzl
435
    dlfcn_h
436
    dlopen
437
    freetype2
438
    gprof
439
    imlib2
440
    inet_aton
441
    localtime_r
442
    lrintf
443
    malloc_h
444
    memalign
445
    mlib
446
    os2threads
447
    pthreads
448
    sdl
449
    sdl_video_size
450
    threads
451
    w32threads
452
'
453

    
454
# set temporary file name
455
if test ! -z "$TMPDIR" ; then
456
    TMPDIR1="${TMPDIR}"
457
elif test ! -z "$TEMPDIR" ; then
458
    TMPDIR1="${TEMPDIR}"
459
else
460
    TMPDIR1="/tmp"
461
fi
462

    
463
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
464
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
465
TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
466
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
467
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
468

    
469
# default parameters
470
logging="yes"
471
logfile="config.err"
472
PREFIX="/usr/local"
473
libdir='${PREFIX}/lib'
474
shlibdir="$libdir"
475
incdir='${PREFIX}/include/ffmpeg'
476
mandir='${PREFIX}/man'
477
bindir='${PREFIX}/bin'
478
cross_prefix=""
479
cross_compile="no"
480
cc="gcc"
481
ar="ar"
482
ranlib="ranlib"
483
make="make"
484
strip="strip"
485
arch=`uname -m`
486
cpu="generic"
487
powerpc_perf="no"
488
mmx="default"
489
cmov="no"
490
cmov_is_fast="no"
491
armv5te="default"
492
iwmmxt="default"
493
altivec="default"
494
dcbzl="no"
495
mmi="default"
496
case "$arch" in
497
  i386|i486|i586|i686|i86pc|BePC)
498
    arch="x86_32"
499
  ;;
500
  x86_64|amd64)
501
    arch="x86_32"
502
    canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
503
    if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
504
      if [ -z "`echo $CFLAGS | grep -- -m32`"  ]; then
505
        arch="x86_64"
506
      fi
507
    fi
508
  ;;
509
  # armv4l is a subset of armv[567]*l
510
  arm|armv[4567]*l)
511
    arch="armv4l"
512
  ;;
513
  alpha)
514
    arch="alpha"
515
  ;;
516
  "Power Macintosh"|ppc|ppc64|powerpc)
517
    arch="powerpc"
518
  ;;
519
  mips|mipsel|IP*)
520
    arch="mips"
521
  ;;
522
  sun4u|sparc64)
523
    arch="sparc64"
524
  ;;
525
  sparc)
526
    arch="sparc"
527
  ;;
528
  sh4)
529
    arch="sh4"
530
  ;;
531
  parisc|parisc64)
532
    arch="parisc"
533
  ;;
534
  s390|s390x)
535
    arch="s390"
536
  ;;
537
  m68k)
538
    arch="m68k"
539
  ;;
540
  ia64)
541
    arch="ia64"
542
  ;;
543
  bfin)
544
    arch="bfin"
545
  ;;
546
  *)
547
    arch="unknown"
548
  ;;
549
esac
550
gprof="no"
551
video4linux="yes"
552
video4linux2="yes"
553
bktr="no"
554
audio_oss="yes"
555
audio_beos="no"
556
dv1394="yes"
557
dc1394="no"
558
network="yes"
559
ipv6="yes"
560
zlib="yes"
561
libgsm="no"
562
mp3lame="no"
563
libnut="no"
564
libogg="no"
565
libvorbis="no"
566
faad="no"
567
faadbin="no"
568
faac="no"
569
xvid="no"
570
x264="no"
571
a52="no"
572
a52bin="no"
573
dts="no"
574
pp="no"
575
mingw32="no"
576
wince="no"
577
os2="no"
578
lstatic="yes"
579
lshared="no"
580
optimize="yes"
581
debug="yes"
582
extrawarnings="no"
583
dostrip="yes"
584
installstrip="-s"
585
extralibs="-lm"
586
bigendian="no"
587
vhook="default"
588
avisynth="no"
589
dlfcn_h="no"
590
dlopen="no"
591
mpegaudio_hp="yes"
592
SHFLAGS='-shared -Wl,-soname,$@'
593
VHOOKSHFLAGS='$(SHFLAGS)'
594
beos_netserver="no"
595
protocols="yes"
596
ffmpeg="yes"
597
ffserver="yes"
598
ffplay="yes"
599
LIBOBJFLAGS=""
600
FFLDFLAGS=-Wl,--warn-common
601
LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
602
FFSERVERLDFLAGS=-Wl,-E
603
LDCONFIG="ldconfig"
604
LIBPREF="lib"
605
LIBSUF=".a"
606
LIB='$(LIBPREF)$(NAME)$(LIBSUF)'
607
SLIBPREF="lib"
608
SLIBSUF=".so"
609
SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
610
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
611
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
612
EXESUF=""
613
BUILDSUF=""
614
amr_nb="no"
615
amr_wb="no"
616
amr_nb_fixed="no"
617
amr_if2="no"
618
mlib="no"
619
pthreads="no"
620
swscaler="no"
621
gpl="no"
622
memalign_hack="no"
623
asmalign_pot="unknown"
624
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(libdir)/$(LIB)"'
625

    
626
# OS specific
627
targetos=`uname -s`
628
case $targetos in
629
BeOS)
630
PREFIX="/boot/home/config"
631
# helps building libavcodec
632
add_cflags "-DPIC -fomit-frame-pointer"
633
# 3 gcc releases known for BeOS, each with ugly bugs
634
gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
635
case "$gcc_version" in
636
2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
637
mmx="no"
638
;;
639
*20010315*) echo "BeBits gcc"
640
add_cflags "-fno-expensive-optimizations"
641
;;
642
esac
643
SHFLAGS=-nostart
644
# disable Linux things
645
audio_oss="no"
646
video4linux="no"
647
video4linux2="no"
648
dv1394="no"
649
# enable BeOS things
650
audio_beos="yes"
651
beosthreads="yes"
652
# no need for libm, but the inet stuff
653
# Check for BONE
654
if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
655
extralibs="-lbind -lsocket"
656
else
657
beos_netserver="yes"
658
extralibs="-lnet"
659
fi ;;
660
SunOS)
661
video4linux="no"
662
video4linux2="no"
663
audio_oss="no"
664
dv1394="no"
665
make="gmake"
666
FFLDFLAGS=""
667
FFSERVERLDFLAGS=""
668
SHFLAGS="-shared -Wl,-h,\$@"
669
add_extralibs "-lsocket -lnsl"
670
;;
671
NetBSD)
672
video4linux="no"
673
video4linux2="no"
674
bktr="yes"
675
audio_oss="yes"
676
dv1394="no"
677
make="gmake"
678
add_extralibs "-lossaudio"
679
;;
680
OpenBSD)
681
video4linux="no"
682
video4linux2="no"
683
bktr="yes"
684
audio_oss="yes"
685
dv1394="no"
686
make="gmake"
687
LIBOBJFLAGS="\$(PIC)"
688
LDCONFIG="ldconfig -m \$(shlibdir)"
689
add_extralibs "-lossaudio"
690
;;
691
FreeBSD)
692
video4linux="no"
693
video4linux2="no"
694
bktr="yes"
695
audio_oss="yes"
696
dv1394="no"
697
make="gmake"
698
add_cflags "-pthread"
699
;;
700
GNU/kFreeBSD)
701
video4linux="no"
702
video4linux2="no"
703
bktr="yes"
704
audio_oss="yes"
705
dv1394="no"
706
add_cflags "-pthread"
707
;;
708
BSD/OS)
709
video4linux="no"
710
video4linux2="no"
711
bktr="yes"
712
audio_oss="yes"
713
dv1394="no"
714
extralibs="-lpoll -lgnugetopt -lm"
715
make="gmake"
716
strip="strip -d"
717
installstrip=""
718
;;
719
Darwin)
720
cc="cc"
721
video4linux="no"
722
video4linux2="no"
723
audio_oss="no"
724
dv1394="no"
725
SHFLAGS="-dynamiclib -Wl,-single_module -Wl,-install_name,\$(shlibdir)/\$(SLIBNAME),-current_version,\$(SPPVERSION),-compatibility_version,\$(SPPVERSION)"
726
VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(shlibdir)/vhook/$@'
727
extralibs=""
728
strip="strip -x"
729
installstrip=""
730
FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
731
SLIBSUF=".dylib"
732
SLIBNAME_WITH_FULLVERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
733
SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
734
FFSERVERLDFLAGS=-Wl,-bind_at_load
735
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(libdir)/$(LIB)"'
736
;;
737
MINGW32*)
738
# Note: the rest of the mingw32 config is done afterwards as mingw32
739
# can be forced on the command line for Linux cross compilation.
740
mingw32="yes"
741
;;
742
CYGWIN*)
743
targetos=CYGWIN
744
shlibdir='${PREFIX}/bin'
745
video4linux="no"
746
video4linux2="no"
747
audio_oss="yes"
748
dv1394="no"
749
VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
750
VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
751
extralibs=""
752
EXESUF=".exe"
753
SLIBPREF="cyg"
754
SLIBSUF=".dll"
755
SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
756
SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
757
SHFLAGS='-shared -Wl,--out-implib=lib$(NAME).dll.a'
758
;;
759
Linux)
760
LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
761
;;
762
IRIX*)
763
targetos=IRIX
764
ranlib="echo ignoring ranlib"
765
video4linux="no"
766
video4linux2="no"
767
audio_oss="no"
768
make="gmake"
769
;;
770
OS/2)
771
TMPE=$TMPE".exe"
772
ar="emxomfar -p128"
773
ranlib="echo ignoring ranlib"
774
strip="echo ignoring strip"
775
add_cflags "-Zomf"
776
FFLDFLAGS="-Zomf -Zstack 16384 -s"
777
SHFLAGS="-Zdll -Zomf"
778
FFSERVERLDFLAGS=""
779
LIBPREF=""
780
LIBSUF=".lib"
781
SLIBPREF=""
782
SLIBSUF=".dll"
783
EXESUF=".exe"
784
extralibs=""
785
pkg_requires=""
786
video4linux="no"
787
video4linux2="no"
788
audio_oss="no"
789
dv1394="no"
790
ffserver="no"
791
vhook="no"
792
os2="yes"
793
os2threads="yes"
794
;;
795
*)
796
targetos="${targetos}-UNKNOWN"
797
;;
798
esac
799

    
800
# find source path
801
source_path="`dirname \"$0\"`"
802
source_path_used="yes"
803
if test -z "$source_path" -o "$source_path" = "." ; then
804
    source_path="`pwd`"
805
    source_path_used="no"
806
else
807
    source_path="`cd \"$source_path\"; pwd`"
808
    echo "$source_path" | grep -q '[[:blank:]]' &&
809
      die "Out of tree builds are impossible with whitespace in source path."
810
fi
811

    
812
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
813
    show_help
814
fi
815

    
816
FFMPEG_CONFIGURATION=" "
817
for opt do
818
  FFMPEG_CONFIGURATION="$FFMPEG_CONFIGURATION""$opt "
819
done
820

    
821
ENCODER_LIST=`grep 'register_avcodec(&[a-z0-9_]*_encoder)' "$source_path/libavcodec/allcodecs.c"  | sed 's/.*&\(.*\)).*/\1/'`
822
DECODER_LIST=`grep 'register_avcodec(&[a-z0-9_]*_decoder)' "$source_path/libavcodec/allcodecs.c"  | sed 's/.*&\(.*\)).*/\1/'`
823
PARSER_LIST=`grep 'av_register_codec_parser(&[a-z]' "$source_path/libavcodec/allcodecs.c"  | sed 's/.*&\(.*\)).*/\1/'`
824
MUXER_LIST=`grep 'av_register_output_format(&[a-z]' "$source_path/libavformat/allformats.c"  | sed 's/.*&\(.*\)).*/\1/'`
825
DEMUXER_LIST=`grep 'av_register_input_format(&[a-z]' "$source_path/libavformat/allformats.c"  | sed 's/.*&\(.*\)).*/\1/'`
826

    
827
enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST
828

    
829
for opt do
830
  optval="${opt#*=}"
831
  case "$opt" in
832
  --log)
833
  ;;
834
  --log=*) logging="$optval"
835
  ;;
836
  --prefix=*) PREFIX="$optval"; force_prefix=yes
837
  ;;
838
  --libdir=*) libdir="$optval"; force_libdir=yes
839
  ;;
840
  --shlibdir=*) shlibdir="$optval"
841
  ;;
842
  --incdir=*) incdir="$optval"
843
  ;;
844
  --mandir=*) mandir="$optval"
845
  ;;
846
  --source-path=*) source_path="$optval"
847
  ;;
848
  --cross-prefix=*) cross_prefix="$optval"
849
  ;;
850
  --cross-compile) cross_compile=yes
851
  ;;
852
  --cc=*) cc="$optval"
853
  ;;
854
  --make=*) make="$optval"
855
  ;;
856
  --extra-cflags=*) add_cflags "$optval"
857
  ;;
858
  --extra-ldflags=*) add_ldflags "$optval"
859
  ;;
860
  --extra-libs=*) add_extralibs "$optval"
861
  ;;
862
  --build-suffix=*) BUILDSUF="$optval"
863
  ;;
864
  --arch=*) arch="$optval"
865
  ;;
866
  --cpu=*) cpu="$optval"
867
  ;;
868
  --powerpc-perf-enable) powerpc_perf="yes"
869
  ;;
870
  --disable-mmx) mmx="no"
871
  ;;
872
  --disable-armv5te) armv5te="no"
873
  ;;
874
  --disable-iwmmxt) iwmmxt="no"
875
  ;;
876
  --disable-altivec) altivec="no"
877
  ;;
878
  --enable-gprof) gprof="yes"
879
  ;;
880
  --disable-v4l) video4linux="no"
881
  ;;
882
  --disable-v4l2) video4linux2="no"
883
  ;;
884
  --disable-bktr) bktr="no"
885
  ;;
886
  --disable-audio-oss) audio_oss="no"
887
  ;;
888
  --disable-audio-beos) audio_beos="no"
889
  ;;
890
  --disable-dv1394) dv1394="no"
891
  ;;
892
  --disable-network) network="no"; ffserver="no"
893
  ;;
894
  --disable-ipv6) ipv6="no";
895
  ;;
896
  --disable-zlib) zlib="no"
897
  ;;
898
  --enable-a52) a52="yes"
899
  ;;
900
  --enable-a52bin) a52bin="yes"
901
  ;;
902
  --enable-dts) dts="yes"
903
  ;;
904
  --enable-pp) pp="yes"
905
  ;;
906
  --enable-libgsm) libgsm="yes"
907
  ;;
908
  --enable-mp3lame) mp3lame="yes"
909
  ;;
910
  --enable-libnut) libnut="yes"
911
  ;;
912
  --enable-libogg) libogg="yes"
913
    pkg_requires="$pkg_requires ogg >= 1.1"
914
  ;;
915
  --enable-vorbis) libvorbis="yes"
916
    pkg_requires="$pkg_requires vorbis vorbisenc"
917
  ;;
918
  --enable-faad) faad="yes"
919
  ;;
920
  --enable-faadbin) faadbin="yes"
921
  ;;
922
  --enable-faac) faac="yes"
923
  ;;
924
  --enable-xvid) xvid="yes"
925
  ;;
926
  --enable-x264) x264="yes"
927
  ;;
928
  --enable-avisynth) avisynth="yes";
929
  ;;
930
  --enable-dc1394) dc1394="yes"
931
    pkg_requires="$pkg_requires libraw1394"
932
  ;;
933
  --disable-vhook) vhook="no"
934
  ;;
935
  --enable-mingw32) mingw32="yes"
936
  ;;
937
  --enable-mingwce) wince="yes"
938
  ;;
939
  --enable-static) lstatic="yes"
940
  ;;
941
  --disable-static) lstatic="no"
942
  ;;
943
  --enable-shared) lshared="yes"
944
  ;;
945
  --disable-shared) lshared="no"
946
  ;;
947
  --disable-debug) debug="no"
948
  ;;
949
  --disable-opts) optimize="no"
950
  ;;
951
  --enable-extra-warnings) extrawarnings="yes"
952
  ;;
953
  --disable-mpegaudio-hp) mpegaudio_hp="no"
954
  ;;
955
  --disable-protocols) protocols="no"; network="no"; ffserver="no"
956
  ;;
957
  --disable-ffmpeg) ffmpeg="no"
958
  ;;
959
  --disable-ffserver) ffserver="no"
960
  ;;
961
  --disable-ffplay) ffplay="no"
962
  ;;
963
  --enable-small) optimize="small"
964
  ;;
965
  --enable-amr_nb) amr="yes"; amr_nb="yes"; amr_nb_fixed="no"
966
  ;;
967
  --enable-amr_nb-fixed) amr="yes"; amr_nb_fixed="yes"; amr_nb="no"
968
  ;;
969
  --enable-amr_wb) amr="yes"; amr_wb="yes"
970
  ;;
971
  --enable-amr_if2) amr="yes"; amr_if2="yes"
972
  ;;
973
  --enable-sunmlib) mlib="yes"
974
  ;;
975
  --enable-pthreads) pthreads="yes"
976
  ;;
977
  --enable-swscaler) swscaler="yes"
978
  ;;
979
  --enable-gpl) gpl="yes"
980
  ;;
981
  --enable-memalign-hack) memalign_hack="yes"
982
  ;;
983
  --disable-strip) dostrip="no"
984
  ;;
985
  --enable-encoder=*) enable ${optval}_encoder
986
  ;;
987
  --enable-decoder=*) enable ${optval}_decoder
988
  ;;
989
  --disable-encoder=*) disable ${optval}_encoder
990
  ;;
991
  --disable-decoder=*) disable ${optval}_decoder
992
  ;;
993
  --disable-encoders) disable $ENCODER_LIST
994
  ;;
995
  --disable-decoders) disable $DECODER_LIST
996
  ;;
997
  --enable-muxer=*) enable ${optval}_muxer
998
  ;;
999
  --disable-muxer=*) disable ${optval}_muxer
1000
  ;;
1001
  --disable-muxers) disable $MUXER_LIST; ffserver="no"
1002
  ;;
1003
  --enable-demuxer=*) enable ${optval}_demuxer
1004
  ;;
1005
  --disable-demuxer=*) disable ${optval}_demuxer
1006
  ;;
1007
  --disable-demuxers) disable $DEMUXER_LIST
1008
  ;;
1009
  --enable-parser=*) enable ${optval}_parser
1010
  ;;
1011
  --disable-parser=*) disable ${optval}_parser
1012
  ;;
1013
  --disable-parsers) disable $PARSER_LIST
1014
  ;;
1015
  --help) show_help
1016
  ;;
1017
  *)
1018
  echo "Unknown option \"$opt\"."
1019
  echo "See $0 --help for available options."
1020
  exit 1
1021
  ;;
1022
  esac
1023
done
1024

    
1025
if test "$logging" != no; then
1026
    test "$logging" = yes || logfile="$logging"
1027
    echo "# $0 $@" >$logfile
1028
    set >>$logfile
1029
else
1030
    logfile=/dev/null
1031
fi
1032

    
1033
if test "$mingw32" = "yes" -o "$wince" = "yes"; then
1034
    if test "$lshared" = "yes" && test "$lstatic" = "yes" ; then
1035
        cat <<EOF
1036
You can only build one library type at once on MinGW.
1037
Specify --disable-static --enable-shared to only build
1038
the shared libraries. To build only the static libraries
1039
you do not need to pass additional options.
1040
EOF
1041
        exit 1
1042
    fi
1043
    video4linux="no"
1044
    video4linux2="no"
1045
    bktr="no"
1046
    audio_oss="no"
1047
    dv1394="no"
1048
    dc1394="no"
1049
    ffserver="no"
1050
    network="no"
1051
    if enabled mingw32; then
1052
        w32threads="yes"
1053
    fi
1054
    if test "$wince" = "yes"; then
1055
        protocols="no"
1056
    fi
1057
    SLIBPREF=""
1058
    SLIBSUF=".dll"
1059
    EXESUF=".exe"
1060
    SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1061
    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
1062
    SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
1063
    SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a)"
1064
    if test "$force_prefix" != yes; then PREFIX="$PROGRAMFILES/FFmpeg"; fi
1065
    if test "$force_libdir" != yes; then bindir='${PREFIX}'; fi
1066
    shlibdir='${PREFIX}'
1067
fi
1068

    
1069
# Combine FFLDFLAGS and the LDFLAGS environment variable.
1070
LDFLAGS="$FFLDFLAGS $LDFLAGS"
1071

    
1072
test -n "$cross_prefix" && cross_compile=yes
1073
cc="${cross_prefix}${cc}"
1074
ar="${cross_prefix}${ar}"
1075
ranlib="${cross_prefix}${ranlib}"
1076
strip="${cross_prefix}${strip}"
1077

    
1078
# we need to build at least one lib type
1079
if test "$lstatic" = "no" && test "$lshared" = "no" ; then
1080
    cat <<EOF
1081
At least one library type must be built.
1082
Specify --enable-static to build the static libraries or --enable-shared to
1083
build the shared libraries as well. To only build the shared libraries specify
1084
--disable-static in addition to --enable-shared.
1085
EOF
1086
    exit 1;
1087
fi
1088

    
1089
if test "$libvorbis" = "yes" ; then
1090
    if test "$libogg" = "no"; then
1091
        echo "libogg must be enabled to enable Vorbis."
1092
        fail="yes"
1093
    fi
1094
fi
1095

    
1096
if test "$gpl" != "yes"; then
1097
    if test "$pp" != "no"; then
1098
        echo "The Postprocessing code is under GPL and --enable-gpl is not specified."
1099
        fail="yes"
1100
    fi
1101

    
1102
    if test "$a52" != "no" -o "$a52bin" != "no"; then
1103
        echo "liba52 is under GPL and --enable-gpl is not specified."
1104
        fail="yes"
1105
    fi
1106

    
1107
    if test "$xvid" != "no"; then
1108
        echo "libxvidcore is under GPL and --enable-gpl is not specified."
1109
        fail="yes"
1110
    fi
1111

    
1112
    if test "$x264" != "no"; then
1113
        echo "x264 is under GPL and --enable-gpl is not specified."
1114
        fail="yes"
1115
    fi
1116

    
1117
    if test "$dts" != "no"; then
1118
        echo "libdts is under GPL and --enable-gpl is not specified."
1119
        fail="yes"
1120
    fi
1121

    
1122
    if test "$faad" != "no" -o "$faadbin" != "no"; then
1123
        if check_header faad.h; then
1124
            check_cc << EOF
1125
                #include <faad.h>
1126
                #ifndef FAAD2_VERSION
1127
                ok faad1
1128
                #endif
1129
                int main( void ) { return 0; }
1130
EOF
1131
            if test $? = 0 ; then
1132
                echo "FAAD2 is under GPL and --enable-gpl is not specified."
1133
                fail="yes"
1134
            fi
1135
        else
1136
            faad="no"
1137
            faadbin="no"
1138
            echo "FAAD test failed."
1139
        fi
1140
    fi
1141

    
1142
    if test "$swscaler" != "no"; then
1143
        echo "The software scaler is under GPL and --enable-gpl is not specified."
1144
        fail="yes"
1145
    fi
1146
fi
1147

    
1148
if test "$fail" = "yes"; then
1149
    exit 1
1150
fi
1151

    
1152
# compute MMX state
1153
if test $mmx = "default"; then
1154
    if test $arch = "x86_32" -o $arch = "x86_64"; then
1155
        mmx="yes"
1156
    else
1157
        mmx="no"
1158
    fi
1159
fi
1160

    
1161
#Darwin CC versions
1162
needmdynamicnopic="no"
1163
if test $targetos = Darwin; then
1164
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1165
        add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
1166
    else
1167
        gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1168
        case "$gcc_version" in
1169
            *2.95*)
1170
                add_cflags "-no-cpp-precomp -pipe"
1171
                ;;
1172
            *[34].*)
1173
                add_cflags "-no-cpp-precomp -pipe -force_cpusubtype_ALL -Wno-sign-compare"
1174
                if test "$lshared" = no; then
1175
                   needmdynamicnopic="yes"
1176
                fi
1177
                ;;
1178
            *)
1179
                add_cflags "-no-cpp-precomp -pipe"
1180
                if test "$lshared" = no; then
1181
                   needmdynamicnopic="yes"
1182
                fi
1183
                ;;
1184
        esac
1185
    fi
1186
fi
1187

    
1188
if test $optimize != "no"; then
1189
    add_cflags "-fomit-frame-pointer"
1190
fi
1191

    
1192
# Can only do AltiVec on PowerPC
1193
if test $altivec = "default"; then
1194
    if test $arch = "powerpc"; then
1195
        altivec="yes"
1196
    else
1197
        altivec="no"
1198
    fi
1199
fi
1200

    
1201
# Add processor-specific flags
1202
TUNECPU="generic"
1203
POWERPCMODE="32bits"
1204
if test $cpu != "generic"; then
1205
    case $cpu in
1206
        601|ppc601|PowerPC601)
1207
            add_cflags "-mcpu=601"
1208
            if test $altivec = "yes"; then
1209
                echo "WARNING: Tuning for PPC601 but AltiVec enabled!";
1210
            fi
1211
            TUNECPU=ppc601
1212
        ;;
1213
        603*|ppc603*|PowerPC603*)
1214
            add_cflags "-mcpu=603"
1215
            if test $altivec = "yes"; then
1216
                echo "WARNING: Tuning for PPC603 but AltiVec enabled!";
1217
            fi
1218
            TUNECPU=ppc603
1219
        ;;
1220
        604*|ppc604*|PowerPC604*)
1221
            add_cflags "-mcpu=604"
1222
            if test $altivec = "yes"; then
1223
                echo "WARNING: Tuning for PPC604 but AltiVec enabled!";
1224
            fi
1225
            TUNECPU=ppc604
1226
        ;;
1227
        G3|g3|75*|ppc75*|PowerPC75*)
1228
            add_cflags "-mcpu=750 -mpowerpc-gfxopt"
1229
            if test $altivec = "yes"; then
1230
                echo "WARNING: Tuning for PPC75x but AltiVec enabled!";
1231
            fi
1232
            TUNECPU=ppc750
1233
        ;;
1234
        G4|g4|745*|ppc745*|PowerPC745*)
1235
            add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
1236
            if test $altivec = "no"; then
1237
                echo "WARNING: Tuning for PPC745x but AltiVec disabled!";
1238
            fi
1239
            TUNECPU=ppc7450
1240
        ;;
1241
        74*|ppc74*|PowerPC74*)
1242
            add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
1243
            if test $altivec = "no"; then
1244
                echo "WARNING: Tuning for PPC74xx but AltiVec disabled!";
1245
            fi
1246
            TUNECPU=ppc7400
1247
        ;;
1248
        G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1249
            add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1250
            if test $altivec = "no"; then
1251
                echo "WARNING: Tuning for PPC970 but AltiVec disabled!";
1252
            fi
1253
            TUNECPU=ppc970
1254
            POWERPCMODE="64bits"
1255
        ;;
1256
        # targets that do NOT support conditional mov (cmov)
1257
        i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1258
            add_cflags "-march=$cpu"
1259
            cmov="no"
1260
        ;;
1261
        # targets that do support conditional mov (cmov)
1262
        i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx)
1263
            add_cflags "-march=$cpu"
1264
            cmov="yes"
1265
            cmov_is_fast="yes"
1266
        ;;
1267
        # targets that do support conditional mov but on which it's slow
1268
        pentium4|prescott|nocona)
1269
            add_cflags "-march=$cpu"
1270
            cmov="yes"
1271
            cmov_is_fast="no"
1272
        ;;
1273
        sparc64)
1274
            add_cflags "-mcpu=v9"
1275
        ;;
1276
        *)
1277
        echo "WARNING: Unknown CPU \"$cpu\", ignored."
1278
        ;;
1279
    esac
1280
fi
1281

    
1282
# make sure we can execute files in $TMPDIR
1283
cat >$TMPE 2>>$logfile <<EOF
1284
#! /bin/sh
1285
EOF
1286
chmod +x $TMPE >>$logfile 2>&1
1287
if ! $TMPE >>$logfile 2>&1; then
1288
    cat <<EOF
1289
Unable to create and execute files in $TMPDIR1.  Set the TMPDIR environment
1290
variable to another directory and make sure that $TMPDIR1 is not mounted
1291
noexec.
1292
EOF
1293
    die "Sanity test failed."
1294
fi
1295
rm $TMPE
1296

    
1297
# compiler sanity check
1298
check_exec <<EOF
1299
int main(){
1300
    return 0;
1301
}
1302
EOF
1303
if test "$?" != 0; then
1304
    echo "$cc is unable to create an executable file."
1305
    if test -z "$cross_prefix" -a "$cross_compile" = no; then
1306
        echo "If $cc is a cross-compiler, use the --cross-compile option."
1307
        echo "Only do this if you know what cross compiling means."
1308
    fi
1309
    die "C compiler test failed."
1310
fi
1311

    
1312
# check for assembler specific support
1313

    
1314
if test $arch = "powerpc"; then
1315
check_cc <<EOF && dcbzl=yes
1316
int main(void) {
1317
    register long zero = 0;
1318
    char data[1024];
1319
    asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
1320
return 0;
1321
}
1322
EOF
1323
fi
1324

    
1325
# check for SIMD availability
1326

    
1327
# AltiVec flags: The FSF version of GCC differs from the Apple version
1328
if test $arch = "powerpc"; then
1329
    if test $altivec = "yes"; then
1330
        if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
1331
            add_cflags "-faltivec"
1332
        else
1333
            add_cflags "-maltivec -mabi=altivec"
1334
        fi
1335
    fi
1336
fi
1337

    
1338
check_header altivec.h
1339

    
1340
# check if our compiler supports Motorola AltiVec C API
1341
if test $altivec = "yes"; then
1342
    if test $altivec_h = "yes"; then
1343
        inc_altivec_h="#include <altivec.h>"
1344
    else
1345
        inc_altivec_h=
1346
    fi
1347
    check_cc <<EOF || altivec=no
1348
$inc_altivec_h
1349
int main(void) {
1350
    vector signed int v1, v2, v3;
1351
    v1 = vec_add(v2,v3);
1352
    return 0;
1353
}
1354
EOF
1355
fi
1356

    
1357
# check armv5te instructions support
1358
if test $armv5te = "default" -a $arch = "armv4l"; then
1359
    armv5te=no
1360
    check_cc <<EOF && armv5te=yes
1361
        int main(void) {
1362
        __asm__ __volatile__ ("qadd r0, r0, r0");
1363
        }
1364
EOF
1365
fi
1366

    
1367
# check iwmmxt support
1368
if test $iwmmxt = "default" -a $arch = "armv4l"; then
1369
    iwmmxt=no
1370
    check_cc <<EOF && iwmmxt=yes
1371
        int main(void) {
1372
        __asm__ __volatile__ ("wunpckelub wr6, wr4");
1373
        }
1374
EOF
1375
fi
1376

    
1377
# mmi only available on mips
1378
if test $mmi = "default"; then
1379
    if test $arch = "mips"; then
1380
        mmi="yes"
1381
    else
1382
        mmi="no"
1383
    fi
1384
fi
1385

    
1386
# check if our compiler supports mmi
1387
enabled mmi && check_cc <<EOF || mmi="no"
1388
int main(void) {
1389
    __asm__ ("lq \$2, 0(\$2)");
1390
    return 0;
1391
}
1392
EOF
1393

    
1394
# ---
1395
# big/little-endian test
1396
if test "$cross_compile" = "no"; then
1397
    check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
1398
#include <inttypes.h>
1399
int main(int argc, char ** argv){
1400
        volatile uint32_t i=0x01234567;
1401
        return (*((uint8_t*)(&i))) == 0x67;
1402
}
1403
EOF
1404
else
1405
    # programs cannot be launched if cross compiling, so make a static guess
1406
    if test "$arch" = "powerpc" -o "$arch" = "mips" ; then
1407
        bigendian="yes"
1408
    fi
1409
fi
1410

    
1411
# ---
1412
# check availability of some header files
1413

    
1414
check_header malloc.h
1415
check_func memalign
1416

    
1417
if test "$memalign" = "no" -a "$mmx" = "yes" -a \
1418
        "$memalign_hack" != "yes" -a "$targetos" != "Darwin" -a \
1419
        "$targetos" != "FreeBSD" ; then
1420
    die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
1421
fi
1422

    
1423
check_header byteswap.h
1424

    
1425
check_func inet_aton
1426
check_func localtime_r
1427
enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
1428

    
1429
# check for some common methods of building with pthread support
1430
# do this before the optional library checks as some of them require pthreads
1431
if enabled pthreads; then
1432
    { check_cflags -pthread && check_ldflags -pthread; } ||
1433
    { check_cflags -pthreads && check_ldflags -pthreads; } ||
1434
    check_lib pthread.h pthread_create -lpthread ||
1435
    check_func pthread_create ||
1436
    die "ERROR: can't find pthreads library"
1437
fi
1438

    
1439
# these are off by default, so fail if requested and not available
1440
enabled dts     && require libdts dts.h dts_init -ldts -lm
1441
enabled libgsm  && require libgsm gsm.h gsm_create -lgsm
1442
enabled mp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
1443
enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
1444
enabled libogg  && require libogg ogg/ogg.h ogg_sync_init -logg
1445
enabled libnut  && require libnut libnut.h nut_demuxer_init -lnut
1446
enabled xvid    && require XviD xvid.h xvid_global -lxvidcore
1447
enabled x264    && require x264 x264.h x264_encoder_open -lx264
1448
enabled dc1394  && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
1449
enabled mlib    && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
1450

    
1451
# Ugh, faac uses stdcall calling convention on win32 so we can't use
1452
# the generic test functions
1453
if enabled faac; then
1454
    save_flags
1455
    temp_extralibs -lfaac
1456
    check_ld <<EOF && add_extralibs -lfaac || die "ERROR: libfaac not found"
1457
#include <stdint.h>
1458
#include <faac.h>
1459
int main(){
1460
    char *id, *cpr;
1461
    faacEncGetVersion(&id, &cpr);
1462
    return 0;
1463
}
1464
EOF
1465
    restore_flags
1466
fi
1467

    
1468
# Ugh, recent faad2 versions have renamed all functions and #define the
1469
# old names in faad.h.  Generic tests won't work.
1470
if enabled faad; then
1471
    save_flags
1472
    temp_extralibs -lfaad
1473
    check_ld <<EOF && add_extralibs -lfaad || die "ERROR: libfaad not found"
1474
#include <faad.h>
1475
int main(){
1476
    faacDecOpen();
1477
    return 0;
1478
}
1479
EOF
1480
    restore_flags
1481
fi
1482

    
1483
# Ugh, avisynth uses WINAPI calls. Generic tests won't work.
1484
if enabled avisynth; then
1485
    save_flags
1486
    temp_extralibs -lvfw32
1487
    check_ld <<EOF && add_extralibs -lvfw32 || die "ERROR: vfw32 not found"
1488
#include <windows.h>
1489
#include <vfw.h>
1490
int main(){
1491
    AVIFileInit();
1492
    return 0;
1493
}
1494
EOF
1495
    restore_flags
1496
fi
1497

    
1498

    
1499
# test for lrintf in math.h
1500
check_exec <<EOF && lrintf=yes || lrintf=no
1501
#define _ISOC9X_SOURCE  1
1502
#include <math.h>
1503
int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
1504
EOF
1505

    
1506
_restrict=
1507
for restrict_keyword in restrict __restrict__ __restrict; do
1508
    check_cc <<EOF && _restrict=$restrict_keyword && break
1509
void foo(char * $restrict_keyword p);
1510
EOF
1511
done
1512

    
1513
# dlopen/dlfcn.h probing
1514

    
1515
check_header dlfcn.h
1516

    
1517
if check_func dlopen; then
1518
    ldl=
1519
elif check_func dlopen -ldl; then
1520
    ldl=-ldl
1521
fi
1522

    
1523
if test "$vhook" = "default"; then
1524
    vhook="$dlopen"
1525
fi
1526

    
1527
if enabled_any vhook a52bin faadbin; then
1528
    add_extralibs $ldl
1529
fi
1530

    
1531
if test "$targetos" = "CYGWIN" -a "$lstatic" = "yes" ; then
1532
    vhook="no"
1533
    echo
1534
    echo "At the moment vhooks don't work on Cygwin static builds."
1535
    echo "Patches welcome."
1536
    echo
1537
fi
1538

    
1539
if enabled vhook; then
1540
    check_ldflags -rdynamic
1541
    check_ldflags -export-dynamic
1542
fi
1543

    
1544
if enabled audio_beos; then
1545
    add_extralibs "-lmedia -lbe"
1546
fi
1547

    
1548
##########################################
1549
# imlib check
1550

    
1551
temp_extralibs -lImlib2
1552
check_ld <<EOF && imlib2=yes || imlib2=no
1553
#include <X11/Xlib.h>
1554
#include <Imlib2.h>
1555
int main( void ) { return (int) imlib_load_font("foo"); }
1556
EOF
1557
restore_flags
1558

    
1559
##########################################
1560
# FreeType check
1561

    
1562
freetype2=no
1563
if test "x$targetos" != "xBeOS"; then
1564
  if (freetype-config --version) >/dev/null 2>&1 ; then
1565
      temp_cflags `freetype-config --cflags`
1566
      temp_extralibs `freetype-config --libs`
1567
      check_ld <<EOF && freetype2=yes
1568
#include <ft2build.h>
1569
int main( void ) { return (int) FT_Init_FreeType(0); }
1570
EOF
1571
      restore_flags
1572
  fi
1573
fi
1574

    
1575
##########################################
1576
# SDL check
1577

    
1578
sdl_too_old=no
1579
sdl=no
1580
SDL_CONFIG="${cross_prefix}sdl-config"
1581
if ("${SDL_CONFIG}" --version) >/dev/null 2>&1 ; then
1582
    temp_cflags `"${SDL_CONFIG}" --cflags`
1583
    temp_extralibs `"${SDL_CONFIG}" --libs`
1584
    check_ld <<EOF
1585
#include <SDL.h>
1586
#undef main /* We don't want SDL to override our main() */
1587
int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
1588
EOF
1589
    if test $? = 0; then
1590
        _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
1591
        if test "$_sdlversion" -lt 121 ; then
1592
            sdl_too_old=yes
1593
        else
1594
            sdl=yes
1595
            check_cc <<EOF && sdl_video_size=yes || sdl_video_size=no
1596
#include <SDL.h>
1597
int main(void){
1598
    const SDL_VideoInfo *vi = SDL_GetVideoInfo();
1599
    int w = vi->current_w;
1600
    return 0;
1601
}
1602
EOF
1603
        fi
1604
    fi
1605
    restore_flags
1606
fi
1607

    
1608
enabled sdl || ffplay=no
1609

    
1610
##########################################
1611
# texi2html check
1612

    
1613
texi2html=no
1614
if (texi2html -version) >/dev/null 2>&1; then
1615
texi2html=yes
1616
fi
1617

    
1618
##########################################
1619
# IPv6 check
1620

    
1621
enabled network && enabled ipv6 && check_ld <<EOF && ipv6=yes || ipv6=no
1622
#include <sys/types.h>
1623
#include <sys/socket.h>
1624
#include <netinet/in.h>
1625
#include <netdb.h>
1626
int main( void ) {
1627
  struct sockaddr_storage saddr;
1628
  struct ipv6_mreq mreq6;
1629
  getaddrinfo(0,0,0,0);
1630
  getnameinfo(0,0,0,0,0,0,0);
1631
  IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
1632
}
1633
EOF
1634

    
1635
# check for video4linux2 --- V4L2_PIX_FMT_YUV420
1636
enabled video4linux2 && check_cc <<EOF || video4linux2="no"
1637
#include <sys/time.h>
1638
#include <asm/types.h>
1639
#include <linux/videodev2.h>
1640
int dummy = V4L2_PIX_FMT_YUV420;
1641
struct v4l2_buffer dummy1;
1642
EOF
1643

    
1644
enabled debug && add_cflags -g
1645

    
1646
# add some useful compiler flags if supported
1647
check_cflags -Wdeclaration-after-statement
1648
check_cflags -Wall
1649
check_cflags -Wno-switch
1650
check_cflags -Wdisabled-optimization
1651
check_cflags -Wpointer-arith
1652
check_cflags -Wredundant-decls
1653
enabled extrawarnings && check_cflags -Winline
1654

    
1655
# add some linker flags
1656
check_ldflags $LDLATEFLAGS
1657

    
1658
# not all compilers support -Os
1659
test "$optimize" = "small" && check_cflags -Os
1660

    
1661
if enabled optimize; then
1662
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1663
        add_cflags  "-O5"
1664
        add_ldflags "-O5"
1665
    else
1666
        add_cflags "-O3"
1667
    fi
1668
fi
1669

    
1670
# PIC flags for shared library objects where they are needed
1671
if test "$lshared" = "yes" ; then
1672
    # LIBOBJFLAGS may have already been set in the OS configuration
1673
    if test -z "$LIBOBJFLAGS" ; then
1674
        case "$arch" in
1675
            x86_64|ia64|alpha|sparc*) LIBOBJFLAGS="\$(PIC)" ;;
1676
        esac
1677
    fi
1678
fi
1679

    
1680
if test "$gprof" = "yes" ; then
1681
    add_cflags  "-p"
1682
    add_ldflags "-p"
1683
fi
1684

    
1685
VHOOKCFLAGS="-fPIC $CFLAGS"
1686
test "$needmdynamicnopic" = yes && add_cflags -mdynamic-no-pic
1687

    
1688
# find if .align arg is power-of-two or not
1689
if test $asmalign_pot = "unknown"; then
1690
    asmalign_pot="no"
1691
    echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
1692
fi
1693

    
1694
echo "install prefix   $PREFIX"
1695
echo "source path      $source_path"
1696
echo "C compiler       $cc"
1697
echo "make             $make"
1698
echo "ARCH             $arch ($cpu)"
1699
if test "$BUILDSUF" != ""; then
1700
    echo "build suffix     $BUILDSUF"
1701
fi
1702
echo "big-endian       $bigendian"
1703
if test $arch = "x86_32" -o $arch = "x86_64"; then
1704
    echo "MMX enabled      $mmx"
1705
    echo "CMOV enabled     $cmov"
1706
    echo "CMOV is fast     $cmov_is_fast"
1707
fi
1708
if test $arch = "armv4l"; then
1709
    echo "ARMv5TE enabled  $armv5te"
1710
    echo "IWMMXT enabled   $iwmmxt"
1711
fi
1712
if test $arch = "mips"; then
1713
    echo "MMI enabled      $mmi"
1714
fi
1715
if test $arch = "powerpc"; then
1716
    echo "AltiVec enabled  $altivec"
1717
    echo "dcbzl available  $dcbzl"
1718
fi
1719
echo "gprof enabled    $gprof"
1720
echo "zlib enabled     $zlib"
1721
echo "libgsm enabled   $libgsm"
1722
echo "mp3lame enabled  $mp3lame"
1723
echo "libnut enabled   $libnut"
1724
echo "libogg enabled   $libogg"
1725
echo "Vorbis enabled   $libvorbis"
1726
echo "FAAD enabled     $faad"
1727
echo "faadbin enabled  $faadbin"
1728
echo "FAAC enabled     $faac"
1729
echo "XviD enabled     $xvid"
1730
echo "x264 enabled     $x264"
1731
echo "a52 support      $a52"
1732
echo "a52 dlopened     $a52bin"
1733
echo "DTS support      $dts"
1734
echo "pp support       $pp"
1735
echo "Software Scaler enabled $swscaler"
1736
echo "AVISynth enabled $avisynth"
1737
echo "debug symbols    $debug"
1738
echo "strip symbols    $dostrip"
1739
echo "optimize         $optimize"
1740
echo "static           $lstatic"
1741
echo "shared           $lshared"
1742
echo "video hooking    $vhook"
1743
echo "SDL support      $sdl"
1744
if test $sdl_too_old = "yes"; then
1745
    echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
1746
fi
1747

    
1748
if test "$vhook" = "yes"; then
1749
    echo "Imlib2 support   $imlib2"
1750
    echo "FreeType support $freetype2"
1751
fi
1752
echo "Sun medialib support"  $mlib
1753
echo "pthreads support"      $pthreads
1754
echo "AMR-NB float support"  $amr_nb
1755
echo "AMR-NB fixed support"  $amr_nb_fixed
1756
echo "AMR-WB float support"  $amr_wb
1757
echo "AMR-WB IF2 support"    $amr_if2
1758
echo "network support      $network"
1759
if test "$network" = "yes" ; then
1760
    echo "IPv6 support         $ipv6"
1761
fi
1762
echo ".align is power-of-two" $asmalign_pot
1763
if test "$gpl" = "no" ; then
1764
    echo "License: LGPL"
1765
else
1766
    echo "License: GPL"
1767
fi
1768

    
1769
echo "Creating config.mak and config.h..."
1770

    
1771
date >> config.log
1772
echo "   $0 $FFMPEG_CONFIGURATION" >> config.log
1773
echo "# Automatically generated by configure - do not modify!" > config.mak
1774
echo "/* Automatically generated by configure - do not modify! */" > $TMPH
1775
echo "#define FFMPEG_CONFIGURATION "'"'"$FFMPEG_CONFIGURATION"'"' >> $TMPH
1776

    
1777
echo "PREFIX=$PREFIX" >> config.mak
1778
echo "prefix=\$(DESTDIR)\${PREFIX}" >> config.mak
1779
echo "libdir=\$(DESTDIR)$libdir" >> config.mak
1780
echo "shlibdir=\$(DESTDIR)$shlibdir" >> config.mak
1781
echo "incdir=\$(DESTDIR)$incdir" >> config.mak
1782
echo "bindir=\$(DESTDIR)$bindir" >> config.mak
1783
echo "mandir=\$(DESTDIR)$mandir" >> config.mak
1784
echo "MAKE=$make" >> config.mak
1785
echo "CC=$cc" >> config.mak
1786
echo "AR=$ar" >> config.mak
1787
echo "RANLIB=$ranlib" >> config.mak
1788
if test "$dostrip" = "yes" ; then
1789
    echo "STRIP=$strip" >> config.mak
1790
    echo "INSTALLSTRIP=$installstrip" >> config.mak
1791
else
1792
    echo "STRIP=echo ignoring strip" >> config.mak
1793
    echo "INSTALLSTRIP=" >> config.mak
1794
fi
1795

    
1796
echo "OPTFLAGS=$CFLAGS" >> config.mak
1797
echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
1798
echo "LDFLAGS=$LDFLAGS" >> config.mak
1799
echo "LDCONFIG=$LDCONFIG" >> config.mak
1800
echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
1801
echo "SHFLAGS=$SHFLAGS" >> config.mak
1802
echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
1803
echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
1804
echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
1805
echo "BUILD_STATIC=$lstatic" >> config.mak
1806
echo "BUILDSUF=$BUILDSUF" >> config.mak
1807
echo "LIBPREF=$LIBPREF" >> config.mak
1808
echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
1809
if test "$lstatic" = "yes" ; then
1810
  echo "LIB=$LIB" >> config.mak
1811
else # Some Make complain if this variable does not exist.
1812
  echo "LIB=" >> config.mak
1813
fi
1814
echo "SLIBPREF=$SLIBPREF" >> config.mak
1815
echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
1816
echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
1817
echo "TARGET_OS=$targetos" >> config.mak
1818
if test "$arch" = "x86_32" -o "$arch" = "x86_64" ; then
1819
  echo "TARGET_ARCH_X86=yes" >> config.mak
1820
  echo "#define ARCH_X86 1" >> $TMPH
1821
fi
1822
if test "$arch" = "x86_32" ; then
1823
  echo "TARGET_ARCH_X86_32=yes" >> config.mak
1824
  echo "#define ARCH_X86_32 1" >> $TMPH
1825
elif test "$arch" = "x86_64" ; then
1826
  echo "TARGET_ARCH_X86_64=yes" >> config.mak
1827
  echo "#define ARCH_X86_64 1" >> $TMPH
1828
elif test "$arch" = "armv4l" ; then
1829
  echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
1830
  echo "#define ARCH_ARMV4L 1" >> $TMPH
1831
elif test "$arch" = "alpha" ; then
1832
  echo "TARGET_ARCH_ALPHA=yes" >> config.mak
1833
  echo "#define ARCH_ALPHA 1" >> $TMPH
1834
elif test "$arch" = "sparc64" ; then
1835
  echo "TARGET_ARCH_SPARC64=yes" >> config.mak
1836
  echo "#define ARCH_SPARC64 1" >> $TMPH
1837
  echo "TARGET_ARCH_SPARC=yes" >> config.mak
1838
  echo "#define ARCH_SPARC 1" >> $TMPH
1839
elif test "$arch" = "sparc" ; then
1840
  echo "TARGET_ARCH_SPARC=yes" >> config.mak
1841
  echo "#define ARCH_SPARC 1" >> $TMPH
1842
elif test "$arch" = "powerpc" ; then
1843
  echo "TARGET_ARCH_POWERPC=yes" >> config.mak
1844
  echo "#define ARCH_POWERPC 1" >> $TMPH
1845
  if test $POWERPCMODE = "32bits"; then
1846
    echo "#define POWERPC_MODE_32BITS 1" >> $TMPH
1847
  else
1848
    echo "#define POWERPC_MODE_64BITS 1" >> $TMPH
1849
  fi
1850
  if test "$powerpc_perf" = "yes"; then
1851
    echo "#define POWERPC_PERFORMANCE_REPORT 1" >> $TMPH
1852
  fi
1853
elif test "$arch" = "mips" ; then
1854
  echo "TARGET_ARCH_MIPS=yes" >> config.mak
1855
  echo "#define ARCH_MIPS 1" >> $TMPH
1856
elif test "$arch" = "sh4" ; then
1857
  echo "TARGET_ARCH_SH4=yes" >> config.mak
1858
  echo "#define ARCH_SH4 1" >> $TMPH
1859
elif test "$arch" = "parisc" ; then
1860
  echo "TARGET_ARCH_PARISC=yes" >> config.mak
1861
  echo "#define ARCH_PARISC 1" >> $TMPH
1862
elif test "$arch" = "s390" ; then
1863
  echo "TARGET_ARCH_S390=yes" >> config.mak
1864
  echo "#define ARCH_S390 1" >> $TMPH
1865
elif test "$arch" = "m68k" ; then
1866
  echo "TARGET_ARCH_M68K=yes" >> config.mak
1867
  echo "#define ARCH_M68K 1" >> $TMPH
1868
elif test "$arch" = "ia64" ; then
1869
  echo "TARGET_ARCH_IA64=yes" >> config.mak
1870
  echo "#define ARCH_IA64 1" >> $TMPH
1871
elif test "$arch" = "bfin" ; then
1872
  echo "TARGET_ARCH_BFIN=yes" >> config.mak
1873
  echo "#define ARCH_BFIN 1" >> $TMPH
1874
fi
1875
echo "#define TUNECPU $TUNECPU" >> $TMPH
1876
if test "$bigendian" = "yes" ; then
1877
  echo "WORDS_BIGENDIAN=yes" >> config.mak
1878
  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
1879
fi
1880
if test "$mmx" = "yes" ; then
1881
  echo "TARGET_MMX=yes" >> config.mak
1882
  echo "#define HAVE_MMX 1" >> $TMPH
1883
  echo "#define __CPU__ 586" >> $TMPH
1884
fi
1885
if test "$cmov" = "yes" ; then
1886
  echo "TARGET_CMOV=yes" >> config.mak
1887
  echo "#define HAVE_CMOV 1" >> $TMPH
1888
fi
1889
if test "$cmov_is_fast" = "yes" ; then
1890
  echo "TARGET_CMOV_IS_FAST=yes" >> config.mak
1891
  echo "#define CMOV_IS_FAST 1" >> $TMPH
1892
fi
1893
if test "$armv5te" = "yes" ; then
1894
  echo "TARGET_ARMV5TE=yes" >> config.mak
1895
  echo "#define HAVE_ARMV5TE 1" >> $TMPH
1896
fi
1897
if test "$iwmmxt" = "yes" ; then
1898
  echo "TARGET_IWMMXT=yes" >> config.mak
1899
  echo "#define HAVE_IWMMXT 1" >> $TMPH
1900
fi
1901
if test "$mmi" = "yes" ; then
1902
  echo "TARGET_MMI=yes" >> config.mak
1903
  echo "#define HAVE_MMI 1" >> $TMPH
1904
fi
1905

    
1906
if test "$altivec" = "yes" ; then
1907
  echo "TARGET_ALTIVEC=yes" >> config.mak
1908
  echo "#define HAVE_ALTIVEC 1" >> $TMPH
1909
fi
1910

    
1911
if test "$sdl" = "yes" ; then
1912
  echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1913
  echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
1914
fi
1915
if test "$texi2html" = "yes"; then
1916
  echo "BUILD_DOC=yes" >> config.mak
1917
fi
1918

    
1919
sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
1920
pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
1921
lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
1922
lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
1923
lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
1924

    
1925

    
1926

    
1927
if test "$lshared" = "yes" ; then
1928
  echo "#define BUILD_SHARED_AV 1" >> $TMPH
1929
  echo "BUILD_SHARED=yes" >> config.mak
1930
  echo "PIC=-fPIC -DPIC" >> config.mak
1931
  echo "SPPMAJOR=${lavc_version%%.*}" >> config.mak
1932
  echo "SPPVERSION=$lavc_version" >> config.mak
1933
  echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
1934
  echo "LAVCVERSION=$lavc_version" >> config.mak
1935
  echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
1936
  echo "LAVFVERSION=$lavf_version" >> config.mak
1937
  echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
1938
  echo "LAVUVERSION=$lavu_version" >> config.mak
1939
  echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
1940
  echo "SWSVERSION=$sws_version" >> config.mak
1941
  echo "SLIBNAME=${SLIBNAME}" >> config.mak
1942
  echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
1943
  echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
1944
  echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
1945
fi
1946
echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
1947
echo "EXTRALIBS=$extralibs" >> config.mak
1948

    
1949
enabled_any $ENCODER_LIST && enable encoders
1950
enabled_any $DECODER_LIST && enable decoders
1951
enabled_any $MUXER_LIST   && enable muxers
1952
enabled_any $DEMUXER_LIST && enable demuxers
1953

    
1954
enabled_any pthreads beosthreads os2threads w32threads && enable threads
1955

    
1956
print_config HAVE_   $TMPH config.mak $HAVE_LIST
1957
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST
1958

    
1959
if test "$os2" = "yes" ; then
1960
  echo "#define CONFIG_OS2 1" >> $TMPH
1961
fi
1962

    
1963
if test "$targetos" = "Darwin"; then
1964
  echo "#define CONFIG_DARWIN 1"  >> $TMPH
1965
fi
1966

    
1967
echo "#define restrict $_restrict" >> $TMPH
1968

    
1969
if test "$optimize" = "small"; then
1970
  echo "#define always_inline"  >> $TMPH
1971
  echo "#define CONFIG_SMALL 1" >> $TMPH
1972
fi
1973

    
1974
echo "SRC_PATH=\"$source_path\"" >> config.mak
1975
echo "SRC_PATH_BARE=$source_path" >> config.mak
1976
echo "BUILD_ROOT=\"$PWD\"" >> config.mak
1977

    
1978
if test "$amr_if2" = "yes" ; then
1979
  echo "AMR_CFLAGS=-DIF2=1" >> config.mak
1980
fi
1981

    
1982
# Apparently it's not possible to portably echo a backslash.
1983
if test "$asmalign_pot" = "yes" ; then
1984
  printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
1985
else
1986
  printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
1987
fi
1988

    
1989

    
1990
for codec in $DECODER_LIST $ENCODER_LIST $PARSER_LIST $DEMUXER_LIST $MUXER_LIST; do
1991
    ucname="`toupper $codec`"
1992
    config_name="CONFIG_$ucname"
1993
    enabled_name="ENABLE_$ucname"
1994
    if enabled $codec; then
1995
        echo "#define $config_name 1" >> $TMPH
1996
        echo "#define $enabled_name 1" >> $TMPH
1997
        echo "$config_name=yes" >> config.mak
1998
    else
1999
        echo "#define $enabled_name 0" >> $TMPH
2000
    fi
2001
done
2002

    
2003
# Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
2004
if ! cmp -s $TMPH config.h; then
2005
        mv -f $TMPH config.h
2006
else
2007
        echo "config.h is unchanged"
2008
fi
2009

    
2010
rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
2011

    
2012
# build tree in object directory if source path is different from current one
2013
if test "$source_path_used" = "yes" ; then
2014
    DIRS="\
2015
         doc \
2016
         libavformat \
2017
         libavcodec \
2018
         libavcodec/alpha \
2019
         libavcodec/armv4l \
2020
         libavcodec/bfin \
2021
         libavcodec/i386 \
2022
         libavcodec/sparc \
2023
         libavcodec/mlib \
2024
         libavcodec/ppc \
2025
         libavcodec/liba52 \
2026
         libpostproc \
2027
         libavutil \
2028
         libswscale \
2029
         tests \
2030
         vhook \
2031
         "
2032
    FILES="\
2033
          Makefile \
2034
          common.mak \
2035
          libavformat/Makefile \
2036
          libavcodec/Makefile \
2037
          libpostproc/Makefile \
2038
          libavutil/Makefile \
2039
          libswscale/Makefile \
2040
          tests/Makefile \
2041
          vhook/Makefile \
2042
          doc/Makefile \
2043
          doc/texi2pod.pl \
2044
          "
2045
    for dir in $DIRS ; do
2046
            mkdir -p $dir
2047
    done
2048
    for f in $FILES ; do
2049
        ln -sf "$source_path/$f" $f
2050
    done
2051
fi
2052

    
2053
# build pkg-config files libav*.pc and libpostproc.pc
2054
# libavutil.pc
2055
cat <<EOF >libavutil.pc
2056
prefix=$PREFIX
2057
exec_prefix=\${prefix}
2058
libdir=\${exec_prefix}/lib
2059
includedir=\${prefix}/include
2060

    
2061
Name: libavutil
2062
Description: FFmpeg utility library
2063
Version: $lavu_version
2064
Requires:
2065
Conflicts:
2066
Libs: -L\${libdir} -lavutil
2067
Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2068
EOF
2069

    
2070
cat <<EOF >libavutil-uninstalled.pc
2071
prefix=
2072
exec_prefix=
2073
libdir=\${pcfiledir}/libavutil
2074
includedir=\${pcfiledir}/libavutil
2075

    
2076
Name: libavutil
2077
Description: FFmpeg utility library
2078
Version: $lavu_version
2079
Requires:
2080
Conflicts:
2081
Libs: \${libdir}/${LIBPREF}avutil${LIBSUF}
2082
Cflags: -I\${includedir}
2083
EOF
2084

    
2085
# libavcodec.pc
2086
cat <<EOF >libavcodec.pc
2087
prefix=$PREFIX
2088
exec_prefix=\${prefix}
2089
libdir=\${exec_prefix}/lib
2090
includedir=\${prefix}/include
2091

    
2092
Name: libavcodec
2093
Description: FFmpeg codec library
2094
Version: $lavc_version
2095
Requires: $pkg_requires libavutil = $lavu_version
2096
Conflicts:
2097
Libs: -L\${libdir} -lavcodec $extralibs
2098
Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2099
EOF
2100

    
2101
cat <<EOF >libavcodec-uninstalled.pc
2102
prefix=
2103
exec_prefix=
2104
libdir=\${pcfiledir}/libavcodec
2105
includedir=\${pcfiledir}/libavcodec
2106

    
2107
Name: libavcodec
2108
Description: FFmpeg codec library
2109
Version: $lavc_version
2110
Requires: $pkg_requires libavutil = $lavu_version
2111
Conflicts:
2112
Libs: \${libdir}/${LIBPREF}avcodec${LIBSUF} $extralibs
2113
Cflags: -I\${includedir}
2114
EOF
2115

    
2116
# libavformat.pc
2117
cat <<EOF >libavformat.pc
2118
prefix=$PREFIX
2119
exec_prefix=\${prefix}
2120
libdir=\${exec_prefix}/lib
2121
includedir=\${prefix}/include
2122

    
2123
Name: libavformat
2124
Description: FFmpeg container format library
2125
Version: $lavf_version
2126
Requires: $pkg_requires libavcodec = $lavc_version
2127
Conflicts:
2128
Libs: -L\${libdir} -lavformat $extralibs
2129
Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2130
EOF
2131

    
2132
cat <<EOF >libavformat-uninstalled.pc
2133
prefix=
2134
exec_prefix=
2135
libdir=\${pcfiledir}/libavformat
2136
includedir=\${pcfiledir}/libavformat
2137

    
2138
Name: libavformat
2139
Description: FFmpeg container format library
2140
Version: $lavf_version
2141
Requires: $pkg_requires libavcodec = $lavc_version
2142
Conflicts:
2143
Libs: \${libdir}/${LIBPREF}avformat${LIBSUF} $extralibs
2144
Cflags: -I\${includedir}
2145
EOF
2146

    
2147

    
2148
# libpostproc.pc
2149
cat <<EOF >libpostproc.pc
2150
prefix=$PREFIX
2151
exec_prefix=\${prefix}
2152
libdir=\${exec_prefix}/lib
2153
includedir=\${prefix}/include
2154

    
2155
Name: libpostproc
2156
Description: FFmpeg post processing library
2157
Version: $lavc_version
2158
Requires:
2159
Conflicts:
2160
Libs: -L\${libdir} -lpostproc
2161
Cflags: -I\${includedir} -I\${includedir}/postproc
2162
EOF
2163

    
2164
cat <<EOF >libpostproc-uninstalled.pc
2165
prefix=
2166
exec_prefix=
2167
libdir=\${pcfiledir}/libpostproc
2168
includedir=\${pcfiledir}/libpostproc
2169

    
2170
Name: libpostproc
2171
Description: FFmpeg post processing library
2172
Version: $lavc_version
2173
Requires:
2174
Conflicts:
2175
Libs: \${libdir}/${LIBPREF}postproc${LIBSUF}
2176
Cflags: -I\${includedir}
2177
EOF
2178

    
2179
if test "$swscaler" != "no"; then
2180
  sws_pc_libs="-L\${libdir} -lswscale"
2181
  sws_pc_uninstalled_libs="\${libdir}/${LIBPREF}swscale${LIBSUF}"
2182
  sws_pc_requires="$pkg_requires libavutil = $lavu_version"
2183
else
2184
  sws_pc_libs=""
2185
  sws_pc_uninstalled_libs=""
2186
  sws_pc_requires="$pkg_requires libavcodec = $lavc_version"
2187
fi
2188
# libswscale.pc
2189
cat <<EOF >libswscale.pc
2190
prefix=$PREFIX
2191
exec_prefix=\${prefix}
2192
libdir=\${exec_prefix}/lib
2193
includedir=\${prefix}/include
2194

    
2195
Name: libswscale
2196
Description: FFmpeg image rescaling library
2197
Version: $sws_version
2198
Requires: $sws_pc_requires
2199
Conflicts:
2200
Libs: $sws_pc_libs
2201
Cflags: -I\${includedir} -I\${includedir}/swscale
2202
EOF
2203

    
2204
cat <<EOF >libswscale-uninstalled.pc
2205
prefix=
2206
exec_prefix=
2207
libdir=\${pcfiledir}/libswscale
2208
includedir=\${pcfiledir}/libswscale
2209

    
2210
Name: libswscale
2211
Description: FFmpeg image rescaling library
2212
Version: $sws_version
2213
Requires: $sws_pc_requires
2214
Conflicts:
2215
Libs: $sws_pc_uninstalled_libs
2216
Cflags: -I\${includedir}
2217
EOF