Statistics
| Branch: | Revision:

ffmpeg / configure @ 2ce92289

History | View | Annotate | Download (58.8 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
unset foo
8
(: ${foo%%bar}) 2>/dev/null && ! (: ${foo?}) 2>/dev/null
9
if test "$?" != 0; then
10
    if test "x$FFMPEG_CONFIGURE_EXEC" = x; then
11
        FFMPEG_CONFIGURE_EXEC=1
12
        export FFMPEG_CONFIGURE_EXEC
13
        exec bash "$0" "$@"
14
        exec ksh "$0" "$@"
15
        exec /usr/xpg4/bin/sh "$0" "$@"
16
    fi
17
    echo "No compatible shell script interpreter found."
18
    exit 1
19
fi
20

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

    
128
log(){
129
    echo "$@" >>$logfile
130
}
131

    
132
log_file(){
133
    log BEGIN $1
134
    cat -n $1 >>$logfile
135
    log END $1
136
}
137

    
138
echolog(){
139
    log "$@"
140
    echo "$@"
141
}
142

    
143
die(){
144
    echolog "$@"
145
    cat <<EOF
146
If you think configure made a mistake, make sure you are using the latest
147
version from SVN.  If the latest version fails, report the problem to the
148
ffmpeg-devel@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
149
EOF
150
    if enabled logging; then
151
        cat <<EOF
152
Include the log file "$logfile" produced by configure as this will help
153
solving the problem.
154
EOF
155
    else
156
cat <<EOF
157
Rerun configure with logging enabled (do not use --log=no), and include the
158
log this produces with your report.
159
EOF
160
    fi
161
    rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
162
    exit 1
163
}
164

    
165
toupper(){
166
    echo "$@" | tr '[a-z]' '[A-Z]'
167
}
168

    
169
set_all(){
170
    value=$1
171
    shift
172
    for var in $*; do
173
        eval $var=$value
174
    done
175
}
176

    
177
enable(){
178
    set_all yes $*
179
}
180

    
181
disable(){
182
    set_all no $*
183
}
184

    
185
enabled(){
186
    eval test "x\$$1" = "xyes"
187
}
188

    
189
enabled_all(){
190
    for opt; do
191
        enabled $opt || return 1
192
    done
193
}
194

    
195
enabled_any(){
196
    for opt; do
197
        enabled $opt && return 0
198
    done
199
}
200

    
201
print_config(){
202
    pfx=$1
203
    header=$2
204
    makefile=$3
205
    shift 3
206
    for cfg; do
207
        if enabled $cfg; then
208
            ucname="${pfx}`toupper $cfg`"
209
            echo "#define ${ucname} 1" >> $header
210
            echo "${ucname}=yes" >> $makefile
211
        fi
212
    done
213
}
214

    
215
flags_saved(){
216
    (: ${SAVE_CFLAGS?}) 2>/dev/null
217
}
218

    
219
save_flags(){
220
    flags_saved && return
221
    SAVE_CFLAGS="$CFLAGS"
222
    SAVE_LDFLAGS="$LDFLAGS"
223
    SAVE_extralibs="$extralibs"
224
}
225

    
226
restore_flags(){
227
    CFLAGS="$SAVE_CFLAGS"
228
    LDFLAGS="$SAVE_LDFLAGS"
229
    extralibs="$SAVE_extralibs"
230
    unset SAVE_CFLAGS
231
    unset SAVE_LDFLAGS
232
    unset SAVE_extralibs
233
}
234

    
235
temp_cflags(){
236
    save_flags
237
    CFLAGS="$CFLAGS $*"
238
}
239

    
240
temp_ldflags(){
241
    save_flags
242
    LDFLAGS="$LDFLAGS $*"
243
}
244

    
245
temp_extralibs(){
246
    save_flags
247
    extralibs="$extralibs $*"
248
}
249

    
250
append(){
251
    var=$1
252
    shift
253
    flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
254
    eval "$var=\"\$$var $*\""
255
}
256

    
257
add_cflags(){
258
    append CFLAGS "$@"
259
}
260

    
261
add_ldflags(){
262
    append LDFLAGS "$@"
263
}
264

    
265
add_extralibs(){
266
    append extralibs "$@"
267
}
268

    
269
check_cmd(){
270
    log "$@"
271
    "$@" >>$logfile 2>&1
272
}
273

    
274
check_cc(){
275
    log check_cc "$@"
276
    cat >$TMPC
277
    log_file $TMPC
278
    check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
279
}
280

    
281
check_cpp(){
282
    log check_cpp "$@"
283
    cat >$TMPC
284
    log_file $TMPC
285
    check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
286
}
287

    
288
check_ld(){
289
    log check_ld "$@"
290
    check_cc || return
291
    check_cmd $cc $LDFLAGS "$@" -o $TMPE $TMPO $extralibs
292
}
293

    
294
check_cflags(){
295
    log check_cflags "$@"
296
    check_cc "$@" <<EOF && add_cflags "$@"
297
int x;
298
EOF
299
}
300

    
301
check_ldflags(){
302
    log check_ldflags "$@"
303
    check_ld "$@" <<EOF && add_ldflags "$@"
304
int main(){
305
    return 0;
306
}
307
EOF
308
}
309

    
310
check_header(){
311
    log check_header "$@"
312
    header=$1
313
    shift
314
    check_cpp "$@" <<EOF
315
#include <$header>
316
int x;
317
EOF
318
}
319

    
320
check_func(){
321
    log check_func "$@"
322
    func=$1
323
    shift
324
    check_ld "$@" <<EOF
325
extern int $func();
326
int main(){
327
    $func();
328
}
329
EOF
330
}
331

    
332
check_lib(){
333
    log check_lib "$@"
334
    header="$1"
335
    func="$2"
336
    shift 2
337
    temp_extralibs "$@"
338
    check_header $header && check_func $func && add_extralibs "$@"
339
    err=$?
340
    restore_flags
341
    return $err
342
}
343

    
344
check_exec(){
345
    check_ld "$@" && { test "$cross_compile" = yes || $TMPE >>$logfile 2>&1; }
346
}
347

    
348
require(){
349
    name="$1"
350
    header="$2"
351
    func="$3"
352
    shift 3
353
    check_lib $header $func "$@" || die "ERROR: $name not found"
354
}
355

    
356
CONFIG_LIST='
357
    encoders
358
    decoders
359
    parsers
360
    muxers
361
    demuxers
362
    a52
363
    a52bin
364
    amr
365
    amr_nb
366
    amr_nb_fixed
367
    amr_wb
368
    audio_beos
369
    audio_oss
370
    avisynth
371
    beos_netserver
372
    bktr
373
    dc1394
374
    dts
375
    dv1394
376
    faac
377
    faad
378
    faadbin
379
    ffmpeg
380
    ffplay
381
    ffserver
382
    gpl
383
    ipv6
384
    libgsm
385
    libnut
386
    libogg
387
    libvorbis
388
    memalign_hack
389
    mp3lame
390
    mpegaudio_hp
391
    network
392
    pp
393
    protocols
394
    swscaler
395
    vhook
396
    video4linux
397
    video4linux2
398
    x264
399
    xvid
400
    zlib
401
'
402

    
403
HAVE_LIST='
404
    altivec_h
405
    byteswap_h
406
    dcbzl
407
    dlfcn
408
    dlopen
409
    freetype2
410
    gprof
411
    imlib2
412
    localtime_r
413
    lrintf
414
    malloc_h
415
    memalign
416
    mlib
417
    sdl
418
    sdl_video_size
419
'
420

    
421
# set temporary file name
422
if test ! -z "$TMPDIR" ; then
423
    TMPDIR1="${TMPDIR}"
424
elif test ! -z "$TEMPDIR" ; then
425
    TMPDIR1="${TEMPDIR}"
426
else
427
    TMPDIR1="/tmp"
428
fi
429

    
430
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
431
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
432
TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
433
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
434
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
435

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

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

    
765
;;
766
*)
767
targetos="${targetos}-UNKNOWN"
768
;;
769
esac
770

    
771
# find source path
772
source_path="`dirname \"$0\"`"
773
source_path_used="yes"
774
if test -z "$source_path" -o "$source_path" = "." ; then
775
    source_path="`pwd`"
776
    source_path_used="no"
777
else
778
    source_path="`cd \"$source_path\"; pwd`"
779
    echo "$source_path" | grep -q '[[:blank:]]' &&
780
      die "Out of tree builds are impossible with whitespace in source path."
781
fi
782

    
783
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
784
    show_help
785
fi
786

    
787
FFMPEG_CONFIGURATION=" "
788
for opt do
789
  FFMPEG_CONFIGURATION="$FFMPEG_CONFIGURATION""$opt "
790
done
791

    
792
ENCODER_LIST=`grep 'register_avcodec(&[a-z0-9_]*_encoder)' "$source_path/libavcodec/allcodecs.c"  | sed 's/.*&\(.*\)).*/\1/'`
793
DECODER_LIST=`grep 'register_avcodec(&[a-z0-9_]*_decoder)' "$source_path/libavcodec/allcodecs.c"  | sed 's/.*&\(.*\)).*/\1/'`
794
PARSER_LIST=`grep 'av_register_codec_parser(&[a-z]' "$source_path/libavcodec/allcodecs.c"  | sed 's/.*&\(.*\)).*/\1/'`
795
MUXER_LIST=`grep 'av_register_output_format(&[a-z]' "$source_path/libavformat/allformats.c"  | sed 's/.*&\(.*\)).*/\1/'`
796
DEMUXER_LIST=`grep 'av_register_input_format(&[a-z]' "$source_path/libavformat/allformats.c"  | sed 's/.*&\(.*\)).*/\1/'`
797

    
798
enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST
799

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

    
996
if test "$logging" != no; then
997
    test "$logging" = yes || logfile="$logging"
998
    echo "# $0 $@" >$logfile
999
    set >>$logfile
1000
else
1001
    logfile=/dev/null
1002
fi
1003

    
1004
if test "$mingw32" = "yes" -o "$mingwce" = "yes"; then
1005
    if test "$lshared" = "yes" && test "$lstatic" = "yes" ; then
1006
        cat <<EOF
1007
You can only build one library type at once on MinGW.
1008
Specify --disable-static --enable-shared to only build
1009
the shared libraries. To build only the static libraries
1010
you do not need to pass additional options.
1011
EOF
1012
        exit 1
1013
    fi
1014
    video4linux="no"
1015
    video4linux2="no"
1016
    bktr="no"
1017
    audio_oss="no"
1018
    dv1394="no"
1019
    dc1394="no"
1020
    ffserver="no"
1021
    network="no"
1022
    if test "$mingwce" = "yes"; then
1023
        protocols="no"
1024
    fi
1025
    SLIBPREF=""
1026
    SLIBSUF=".dll"
1027
    EXESUF=".exe"
1028
    SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1029
    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
1030
    SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
1031
    SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a)"
1032
    if test "$force_prefix" != yes; then PREFIX="$PROGRAMFILES/FFmpeg"; fi
1033
    if test "$force_libdir" != yes; then bindir='${PREFIX}'; fi
1034
    shlibdir='${PREFIX}'
1035
fi
1036

    
1037
# Combine FFLDFLAGS and the LDFLAGS environment variable.
1038
LDFLAGS="$FFLDFLAGS $LDFLAGS"
1039

    
1040
test -n "$cross_prefix" && cross_compile=yes
1041
cc="${cross_prefix}${cc}"
1042
ar="${cross_prefix}${ar}"
1043
ranlib="${cross_prefix}${ranlib}"
1044
strip="${cross_prefix}${strip}"
1045

    
1046
# we need to build at least one lib type
1047
if test "$lstatic" = "no" && test "$lshared" = "no" ; then
1048
    cat <<EOF
1049
At least one library type must be built.
1050
Specify --enable-static to build the static libraries or --enable-shared to
1051
build the shared libraries as well. To only build the shared libraries specify
1052
--disable-static in addition to --enable-shared.
1053
EOF
1054
    exit 1;
1055
fi
1056

    
1057
if test "$libvorbis" = "yes" ; then
1058
    if test "$libogg" = "no"; then
1059
        echo "libogg must be enabled to enable Vorbis."
1060
        fail="yes"
1061
    fi
1062
fi
1063

    
1064
if test "$gpl" != "yes"; then
1065
    if test "$pp" != "no"; then
1066
        echo "The Postprocessing code is under GPL and --enable-gpl is not specified."
1067
        fail="yes"
1068
    fi
1069

    
1070
    if test "$a52" != "no" -o "$a52bin" != "no"; then
1071
        echo "liba52 is under GPL and --enable-gpl is not specified."
1072
        fail="yes"
1073
    fi
1074

    
1075
    if test "$xvid" != "no"; then
1076
        echo "libxvidcore is under GPL and --enable-gpl is not specified."
1077
        fail="yes"
1078
    fi
1079

    
1080
    if test "$x264" != "no"; then
1081
        echo "x264 is under GPL and --enable-gpl is not specified."
1082
        fail="yes"
1083
    fi
1084

    
1085
    if test "$dts" != "no"; then
1086
        echo "libdts is under GPL and --enable-gpl is not specified."
1087
        fail="yes"
1088
    fi
1089

    
1090
    if test "$faad" != "no" -o "$faadbin" != "no"; then
1091
        if check_header faad.h; then
1092
            check_cc << EOF
1093
                #include <faad.h>
1094
                #ifndef FAAD2_VERSION
1095
                ok faad1
1096
                #endif
1097
                int main( void ) { return 0; }
1098
EOF
1099
            if test $? = 0 ; then
1100
                echo "FAAD2 is under GPL and --enable-gpl is not specified."
1101
                fail="yes"
1102
            fi
1103
        else
1104
            faad="no"
1105
            faadbin="no"
1106
            echo "FAAD test failed."
1107
        fi
1108
    fi
1109

    
1110
    if test "$swscaler" != "no"; then
1111
        echo "The software scaler is under GPL and --enable-gpl is not specified."
1112
        fail="yes"
1113
    fi
1114
fi
1115

    
1116
if test "$fail" = "yes"; then
1117
    exit 1
1118
fi
1119

    
1120
# compute MMX state
1121
if test $mmx = "default"; then
1122
    if test $arch = "x86_32" -o $arch = "x86_64"; then
1123
        mmx="yes"
1124
    else
1125
        mmx="no"
1126
    fi
1127
fi
1128

    
1129
#Darwin CC versions
1130
needmdynamicnopic="no"
1131
if test $targetos = Darwin; then
1132
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1133
        add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
1134
    else
1135
        gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1136
        case "$gcc_version" in
1137
            *2.95*)
1138
                add_cflags "-no-cpp-precomp -pipe"
1139
                ;;
1140
            *[34].*)
1141
                add_cflags "-no-cpp-precomp -pipe -force_cpusubtype_ALL -Wno-sign-compare"
1142
                if test "$lshared" = no; then
1143
                   needmdynamicnopic="yes"
1144
                fi
1145
                ;;
1146
            *)
1147
                add_cflags "-no-cpp-precomp -pipe"
1148
                if test "$lshared" = no; then
1149
                   needmdynamicnopic="yes"
1150
                fi
1151
                ;;
1152
        esac
1153
    fi
1154
fi
1155

    
1156
if test $optimize != "no"; then
1157
    add_cflags "-fomit-frame-pointer"
1158
fi
1159

    
1160
# Can only do AltiVec on PowerPC
1161
if test $altivec = "default"; then
1162
    if test $arch = "powerpc"; then
1163
        altivec="yes"
1164
    else
1165
        altivec="no"
1166
    fi
1167
fi
1168

    
1169
# Add processor-specific flags
1170
TUNECPU="generic"
1171
POWERPCMODE="32bits"
1172
if test $cpu != "generic"; then
1173
    case $cpu in
1174
        601|ppc601|PowerPC601)
1175
            add_cflags "-mcpu=601"
1176
            if test $altivec = "yes"; then
1177
                echo "WARNING: Tuning for PPC601 but AltiVec enabled!";
1178
            fi
1179
            TUNECPU=ppc601
1180
        ;;
1181
        603*|ppc603*|PowerPC603*)
1182
            add_cflags "-mcpu=603"
1183
            if test $altivec = "yes"; then
1184
                echo "WARNING: Tuning for PPC603 but AltiVec enabled!";
1185
            fi
1186
            TUNECPU=ppc603
1187
        ;;
1188
        604*|ppc604*|PowerPC604*)
1189
            add_cflags "-mcpu=604"
1190
            if test $altivec = "yes"; then
1191
                echo "WARNING: Tuning for PPC604 but AltiVec enabled!";
1192
            fi
1193
            TUNECPU=ppc604
1194
        ;;
1195
        G3|g3|75*|ppc75*|PowerPC75*)
1196
            add_cflags "-mcpu=750 -mpowerpc-gfxopt"
1197
            if test $altivec = "yes"; then
1198
                echo "WARNING: Tuning for PPC75x but AltiVec enabled!";
1199
            fi
1200
            TUNECPU=ppc750
1201
        ;;
1202
        G4|g4|745*|ppc745*|PowerPC745*)
1203
            add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
1204
            if test $altivec = "no"; then
1205
                echo "WARNING: Tuning for PPC745x but AltiVec disabled!";
1206
            fi
1207
            TUNECPU=ppc7450
1208
        ;;
1209
        74*|ppc74*|PowerPC74*)
1210
            add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
1211
            if test $altivec = "no"; then
1212
                echo "WARNING: Tuning for PPC74xx but AltiVec disabled!";
1213
            fi
1214
            TUNECPU=ppc7400
1215
        ;;
1216
        G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1217
            add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1218
            if test $altivec = "no"; then
1219
                echo "WARNING: Tuning for PPC970 but AltiVec disabled!";
1220
            fi
1221
            TUNECPU=ppc970
1222
            POWERPCMODE="64bits"
1223
        ;;
1224
        # targets that do NOT support conditional mov (cmov)
1225
        i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1226
            add_cflags "-march=$cpu"
1227
            cmov="no"
1228
        ;;
1229
        # targets that do support conditional mov (cmov)
1230
        i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx)
1231
            add_cflags "-march=$cpu"
1232
            cmov="yes"
1233
            cmov_is_fast="yes"
1234
        ;;
1235
        # targets that do support conditional mov but on which it's slow
1236
        pentium4|prescott|nocona)
1237
            add_cflags "-march=$cpu"
1238
            cmov="yes"
1239
            cmov_is_fast="no"
1240
        ;;
1241
        sparc64)
1242
            add_cflags "-mcpu=v9"
1243
        ;;
1244
        *)
1245
        echo "WARNING: Unknown CPU \"$cpu\", ignored."
1246
        ;;
1247
    esac
1248
fi
1249

    
1250
# make sure we can execute files in $TMPDIR
1251
cat >$TMPE 2>>$logfile <<EOF
1252
#! /bin/sh
1253
EOF
1254
chmod +x $TMPE >>$logfile 2>&1
1255
if ! $TMPE >>$logfile 2>&1; then
1256
    cat <<EOF
1257
Unable to create and execute files in $TMPDIR1.  Set the TMPDIR environment
1258
variable to another directory and make sure that $TMPDIR1 is not mounted
1259
noexec.
1260
EOF
1261
    die "Sanity test failed."
1262
fi
1263
rm $TMPE
1264

    
1265
# compiler sanity check
1266
check_exec <<EOF
1267
int main(){
1268
    return 0;
1269
}
1270
EOF
1271
if test "$?" != 0; then
1272
    echo "$cc is unable to create an executable file."
1273
    if test -z "$cross_prefix" -a "$cross_compile" = no; then
1274
        echo "If $cc is a cross-compiler, use the --cross-compile option."
1275
        echo "Only do this if you know what cross compiling means."
1276
    fi
1277
    die "C compiler test failed."
1278
fi
1279

    
1280
# check for assembler specific support
1281

    
1282
if test $arch = "powerpc"; then
1283
check_cc <<EOF && dcbzl=yes
1284
int main(void) {
1285
    register long zero = 0;
1286
    char data[1024];
1287
    asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
1288
return 0;
1289
}
1290
EOF
1291
fi
1292

    
1293
# check for SIMD availability
1294

    
1295
# AltiVec flags: The FSF version of GCC differs from the Apple version
1296
if test $arch = "powerpc"; then
1297
    if test $altivec = "yes"; then
1298
        if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
1299
            add_cflags "-faltivec"
1300
        else
1301
            add_cflags "-maltivec -mabi=altivec"
1302
        fi
1303
    fi
1304
fi
1305

    
1306
check_header altivec.h && altivec_h=yes || altivec_h=no
1307

    
1308
# check if our compiler supports Motorola AltiVec C API
1309
if test $altivec = "yes"; then
1310
    if test $altivec_h = "yes"; then
1311
        inc_altivec_h="#include <altivec.h>"
1312
    else
1313
        inc_altivec_h=
1314
    fi
1315
    check_cc <<EOF || altivec=no
1316
$inc_altivec_h
1317
int main(void) {
1318
    vector signed int v1, v2, v3;
1319
    v1 = vec_add(v2,v3);
1320
    return 0;
1321
}
1322
EOF
1323
fi
1324

    
1325
# check armv5te instructions support
1326
if test $armv5te = "default" -a $arch = "armv4l"; then
1327
    armv5te=no
1328
    check_cc <<EOF && armv5te=yes
1329
        int main(void) {
1330
        __asm__ __volatile__ ("qadd r0, r0, r0");
1331
        }
1332
EOF
1333
fi
1334

    
1335
# check iwmmxt support
1336
if test $iwmmxt = "default" -a $arch = "armv4l"; then
1337
    iwmmxt=no
1338
    check_cc <<EOF && iwmmxt=yes
1339
        int main(void) {
1340
        __asm__ __volatile__ ("wunpckelub wr6, wr4");
1341
        }
1342
EOF
1343
fi
1344

    
1345
# mmi only available on mips
1346
if test $mmi = "default"; then
1347
    if test $arch = "mips"; then
1348
        mmi="yes"
1349
    else
1350
        mmi="no"
1351
    fi
1352
fi
1353

    
1354
# check if our compiler supports mmi
1355
enabled mmi && check_cc <<EOF || mmi="no"
1356
int main(void) {
1357
    __asm__ ("lq \$2, 0(\$2)");
1358
    return 0;
1359
}
1360
EOF
1361

    
1362
# ---
1363
# big/little-endian test
1364
if test "$cross_compile" = "no"; then
1365
    check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
1366
#include <inttypes.h>
1367
int main(int argc, char ** argv){
1368
        volatile uint32_t i=0x01234567;
1369
        return (*((uint8_t*)(&i))) == 0x67;
1370
}
1371
EOF
1372
else
1373
    # programs cannot be launched if cross compiling, so make a static guess
1374
    if test "$arch" = "powerpc" -o "$arch" = "mips" ; then
1375
        bigendian="yes"
1376
    fi
1377
fi
1378

    
1379
# ---
1380
# *inttypes.h* test
1381
check_header inttypes.h || inttypes=no
1382

    
1383
# ---
1384
# *int_fast* test
1385
check_cc <<EOF || emu_fast_int=yes
1386
#include <inttypes.h>
1387
int main(int argc, char ** argv){
1388
        volatile uint_fast64_t i=0x01234567;
1389
        return 0;
1390
}
1391
EOF
1392

    
1393
# ---
1394
# check availability of some header files
1395

    
1396
memalign=no
1397
malloc_h=no
1398
if check_header malloc.h; then
1399
    malloc_h=yes
1400
    memalign=yes
1401
    check_func memalign || memalign="no"
1402
fi
1403

    
1404
if test "$memalign" = "no" -a "$mmx" = "yes" -a \
1405
        "$memalign_hack" != "yes" -a "$targetos" != "Darwin" -a \
1406
        "$targetos" != "FreeBSD" ; then
1407
    die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
1408
fi
1409

    
1410
check_header byteswap.h && byteswap_h=yes || byteswap_h=no
1411

    
1412
check_func localtime_r && localtime_r=yes || localtime_r=no
1413
enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
1414

    
1415
# check for some common methods of building with pthread support
1416
# do this before the optional library checks as some of them require pthreads
1417
if enabled pthreads; then
1418
    { check_cflags -pthread && check_ldflags -pthread; } ||
1419
    { check_cflags -pthreads && check_ldflags -pthreads; } ||
1420
    check_lib pthread.h pthread_create -lpthread ||
1421
    check_func pthread_create ||
1422
    die "ERROR: can't find pthreads library"
1423
fi
1424

    
1425
# these are off by default, so fail if requested and not available
1426
enabled dts     && require libdts dts.h dts_init -ldts -lm
1427
enabled libgsm  && require libgsm gsm.h gsm_create -lgsm
1428
enabled mp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
1429
enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
1430
enabled libogg  && require libogg ogg/ogg.h ogg_sync_init -logg
1431
enabled libnut  && require libnut nut.h nut_demuxer_init -lnut
1432
enabled xvid    && require XviD xvid.h xvid_global -lxvidcore
1433
enabled x264    && require x264 x264.h x264_encoder_open -lx264
1434
enabled dc1394  && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
1435
enabled mlib    && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
1436

    
1437
# Ugh, faac uses stdcall calling convention on win32 so we can't use
1438
# the generic test functions
1439
if enabled faac; then
1440
    save_flags
1441
    temp_extralibs -lfaac
1442
    check_ld <<EOF && add_extralibs -lfaac || die "ERROR: libfaac not found"
1443
#include <stdint.h>
1444
#include <faac.h>
1445
int main(){
1446
    char *id, *cpr;
1447
    faacEncGetVersion(&id, &cpr);
1448
    return 0;
1449
}
1450
EOF
1451
    restore_flags
1452
fi
1453

    
1454
# Ugh, recent faad2 versions have renamed all functions and #define the
1455
# old names in faad.h.  Generic tests won't work.
1456
if enabled faad; then
1457
    save_flags
1458
    temp_extralibs -lfaad
1459
    check_ld <<EOF && add_extralibs -lfaad || die "ERROR: libfaad not found"
1460
#include <faad.h>
1461
int main(){
1462
    faacDecOpen();
1463
    return 0;
1464
}
1465
EOF
1466
    restore_flags
1467
fi
1468

    
1469
# Ugh, avisynth uses WINAPI calls. Generic tests won't work.
1470
if enabled avisynth; then
1471
    save_flags
1472
    temp_extralibs -lvfw32
1473
    check_ld <<EOF && add_extralibs -lvfw32 || die "ERROR: vfw32 not found"
1474
#include <windows.h>
1475
#include <vfw.h>
1476
int main(){
1477
    AVIFileInit();
1478
    return 0;
1479
}
1480
EOF
1481
    restore_flags
1482
fi
1483

    
1484

    
1485
# test for lrintf in math.h
1486
check_exec <<EOF && lrintf=yes || lrintf=no
1487
#define _ISOC9X_SOURCE  1
1488
#include <math.h>
1489
int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
1490
EOF
1491

    
1492
_restrict=
1493
for restrict_keyword in restrict __restrict__ __restrict; do
1494
    check_cc <<EOF && _restrict=$restrict_keyword && break
1495
void foo(char * $restrict_keyword p);
1496
EOF
1497
done
1498

    
1499
# dlopen/dlfcn.h probing
1500

    
1501
check_header dlfcn.h && dlfcn=yes
1502

    
1503
temp_extralibs -ldl
1504
if check_func dlopen; then
1505
    dlopen=yes
1506
    ldl=-ldl
1507
fi
1508
restore_flags
1509

    
1510
if check_func dlopen; then
1511
    dlopen=yes
1512
    ldl=
1513
fi
1514

    
1515
if test "$vhook" = "default"; then
1516
    vhook="$dlopen"
1517
fi
1518

    
1519
if test "$vhook" = "yes" -o "$a52bin" = "yes" -o "$faadbin" = "yes"; then
1520
    add_extralibs $ldl
1521
fi
1522

    
1523
if test "$targetos" = "CYGWIN" -a "$lstatic" = "yes" ; then
1524
    vhook="no"
1525
    echo
1526
    echo "At the moment vhooks don't work on Cygwin static builds."
1527
    echo "Patches welcome."
1528
    echo
1529
fi
1530

    
1531
if enabled vhook; then
1532
    check_ldflags -rdynamic
1533
    check_ldflags -export-dynamic
1534
fi
1535

    
1536
##########################################
1537
# imlib check
1538

    
1539
temp_extralibs -lImlib2
1540
check_ld <<EOF && imlib2=yes || imlib2=no
1541
#include <X11/Xlib.h>
1542
#include <Imlib2.h>
1543
int main( void ) { return (int) imlib_load_font("foo"); }
1544
EOF
1545
restore_flags
1546

    
1547
##########################################
1548
# FreeType check
1549

    
1550
freetype2=no
1551
if test "x$targetos" != "xBeOS"; then
1552
  if (freetype-config --version) >/dev/null 2>&1 ; then
1553
      temp_cflags `freetype-config --cflags`
1554
      temp_extralibs `freetype-config --libs`
1555
      check_ld <<EOF && freetype2=yes
1556
#include <ft2build.h>
1557
int main( void ) { return (int) FT_Init_FreeType(0); }
1558
EOF
1559
      restore_flags
1560
  fi
1561
fi
1562

    
1563
##########################################
1564
# SDL check
1565

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

    
1596
enabled sdl || ffplay=no
1597

    
1598
##########################################
1599
# texi2html check
1600

    
1601
texi2html=no
1602
if (texi2html -version) >/dev/null 2>&1; then
1603
texi2html=yes
1604
fi
1605

    
1606
##########################################
1607
# IPv6 check
1608

    
1609
enabled network && enabled ipv6 && check_ld <<EOF && ipv6=yes || ipv6=no
1610
#include <sys/types.h>
1611
#include <sys/socket.h>
1612
#include <netinet/in.h>
1613
#include <netdb.h>
1614
int main( void ) {
1615
  struct sockaddr_storage saddr;
1616
  struct ipv6_mreq mreq6;
1617
  getaddrinfo(0,0,0,0);
1618
  getnameinfo(0,0,0,0,0,0,0);
1619
  IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
1620
}
1621
EOF
1622

    
1623
# check for video4linux2 --- V4L2_PIX_FMT_YUV420
1624
enabled video4linux2 && check_cc <<EOF || video4linux2="no"
1625
#include <sys/time.h>
1626
#include <asm/types.h>
1627
#include <linux/videodev2.h>
1628
int dummy = V4L2_PIX_FMT_YUV420;
1629
struct v4l2_buffer dummy1;
1630
EOF
1631

    
1632
enabled debug && add_cflags -g
1633

    
1634
# add some useful compiler flags if supported
1635
check_cflags -Wdeclaration-after-statement
1636
check_cflags -Wall
1637
check_cflags -Wno-switch
1638
check_cflags -Wdisabled-optimization
1639
check_cflags -Wpointer-arith
1640
check_cflags -Wredundant-decls
1641
enabled extrawarnings && check_cflags -Winline
1642

    
1643
# add some linker flags
1644
check_ldflags $LDLATEFLAGS
1645

    
1646
# not all compilers support -Os
1647
test "$optimize" = "small" && check_cflags -Os
1648

    
1649
if enabled optimize; then
1650
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1651
        add_cflags  "-O5"
1652
        add_ldflags "-O5"
1653
    else
1654
        add_cflags "-O3"
1655
    fi
1656
fi
1657

    
1658
# PIC flags for shared library objects where they are needed
1659
if test "$lshared" = "yes" ; then
1660
    # LIBOBJFLAGS may have already been set in the OS configuration
1661
    if test -z "$LIBOBJFLAGS" ; then
1662
        case "$arch" in
1663
            x86_64|ia64|alpha|sparc*) LIBOBJFLAGS="\$(PIC)" ;;
1664
        esac
1665
    fi
1666
fi
1667

    
1668
if test "$gprof" = "yes" ; then
1669
    add_cflags  "-p"
1670
    add_ldflags "-p"
1671
fi
1672

    
1673
# find if .align arg is power-of-two or not
1674
if test $asmalign_pot = "unknown"; then
1675
    asmalign_pot="no"
1676
    echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
1677
fi
1678

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

    
1735
if test "$vhook" = "yes"; then
1736
    echo "Imlib2 support   $imlib2"
1737
    echo "FreeType support $freetype2"
1738
fi
1739
echo "Sun medialib support"  $mlib
1740
echo "pthreads support"      $pthreads
1741
echo "AMR-NB float support"  $amr_nb
1742
echo "AMR-NB fixed support"  $amr_nb_fixed
1743
echo "AMR-WB float support"  $amr_wb
1744
echo "AMR-WB IF2 support"    $amr_if2
1745
echo "network support      $network"
1746
if test "$network" = "yes" ; then
1747
    echo "IPv6 support         $ipv6"
1748
fi
1749
echo ".align is power-of-two" $asmalign_pot
1750
if test "$gpl" = "no" ; then
1751
    echo "License: LGPL"
1752
else
1753
    echo "License: GPL"
1754
fi
1755

    
1756
echo "Creating config.mak and config.h..."
1757

    
1758
date >> config.log
1759
echo "   $0 $FFMPEG_CONFIGURATION" >> config.log
1760
echo "# Automatically generated by configure - do not modify!" > config.mak
1761
echo "/* Automatically generated by configure - do not modify! */" > $TMPH
1762
echo "#define FFMPEG_CONFIGURATION "'"'"$FFMPEG_CONFIGURATION"'"' >> $TMPH
1763

    
1764
echo "PREFIX=$PREFIX" >> config.mak
1765
echo "prefix=\$(DESTDIR)\${PREFIX}" >> config.mak
1766
echo "libdir=\$(DESTDIR)$libdir" >> config.mak
1767
echo "shlibdir=\$(DESTDIR)$shlibdir" >> config.mak
1768
echo "incdir=\$(DESTDIR)$incdir" >> config.mak
1769
echo "bindir=\$(DESTDIR)$bindir" >> config.mak
1770
echo "mandir=\$(DESTDIR)$mandir" >> config.mak
1771
echo "MAKE=$make" >> config.mak
1772
echo "CC=$cc" >> config.mak
1773
echo "AR=$ar" >> config.mak
1774
echo "RANLIB=$ranlib" >> config.mak
1775
if test "$dostrip" = "yes" ; then
1776
    echo "STRIP=$strip" >> config.mak
1777
    echo "INSTALLSTRIP=$installstrip" >> config.mak
1778
else
1779
    echo "STRIP=echo ignoring strip" >> config.mak
1780
    echo "INSTALLSTRIP=" >> config.mak
1781
fi
1782

    
1783
VHOOKCFLAGS="-fPIC $CFLAGS"
1784
test "$needmdynamicnopic" = yes && add_cflags -mdynamic-no-pic
1785

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

    
1902
if test "$altivec" = "yes" ; then
1903
  echo "TARGET_ALTIVEC=yes" >> config.mak
1904
  echo "#define HAVE_ALTIVEC 1" >> $TMPH
1905
fi
1906

    
1907
if test "$pthreads" = "yes" ; then
1908
  echo "HAVE_PTHREADS=yes" >> config.mak
1909
  echo "#define HAVE_PTHREADS 1" >> $TMPH
1910
  echo "#define HAVE_THREADS 1" >> $TMPH
1911
fi
1912
if test "$sdl" = "yes" ; then
1913
  echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1914
  echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
1915
fi
1916
if test "$texi2html" = "yes"; then
1917
  echo "BUILD_DOC=yes" >> config.mak
1918
fi
1919

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

    
1926

    
1927

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

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

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

    
1958
if test "$mingw32" = "yes" ; then
1959
  echo "HAVE_W32THREADS=yes" >> config.mak
1960
  echo "#define HAVE_W32THREADS 1" >> $TMPH
1961
  echo "#define HAVE_THREADS 1" >> $TMPH
1962
  echo "#ifndef __MINGW32__" >> $TMPH
1963
  echo "#define __MINGW32__ 1" >> $TMPH
1964
  echo "#endif" >> $TMPH
1965
fi
1966

    
1967
if test "$mingwce" = "yes" ; then
1968
  echo "#define CONFIG_WINCE 1" >> $TMPH
1969
  echo "#ifndef __MINGW32__" >> $TMPH
1970
  echo "#define __MINGW32__ 1" >> $TMPH
1971
  echo "#endif" >> $TMPH
1972
fi
1973

    
1974
if test "$os2" = "yes" ; then
1975
  echo "#define CONFIG_OS2 1" >> $TMPH
1976
  echo "HAVE_OS2THREADS=yes" >> config.mak
1977
  echo "#define HAVE_OS2THREADS 1" >> $TMPH
1978
  echo "#define HAVE_THREADS 1" >> $TMPH
1979
fi
1980

    
1981
if test "$targetos" = "BeOS" ; then
1982
  echo "HAVE_BEOSTHREADS=yes" >> config.mak
1983
  echo "#define HAVE_BEOSTHREADS 1" >> $TMPH
1984
  echo "#define HAVE_THREADS 1" >> $TMPH
1985
fi
1986

    
1987
if test "$targetos" = "Darwin"; then
1988
  echo "#define CONFIG_DARWIN 1"  >> $TMPH
1989
fi
1990

    
1991
if test "$need_inet_aton" = "yes" ; then
1992
  echo "NEED_INET_ATON=yes" >> config.mak
1993
fi
1994

    
1995
echo "#define restrict $_restrict" >> $TMPH
1996

    
1997
if test "$optimize" = "small"; then
1998
  echo "#define always_inline"  >> $TMPH
1999
  echo "#define CONFIG_SMALL 1" >> $TMPH
2000
fi
2001

    
2002
# build tree in object directory if source path is different from current one
2003
if test "$source_path_used" = "yes" ; then
2004
    DIRS="\
2005
         doc \
2006
         libavformat \
2007
         libavcodec \
2008
         libavcodec/alpha \
2009
         libavcodec/armv4l \
2010
         libavcodec/bfin \
2011
         libavcodec/i386 \
2012
         libavcodec/sparc \
2013
         libavcodec/mlib \
2014
         libavcodec/ppc \
2015
         libavcodec/liba52 \
2016
         libpostproc \
2017
         libavutil \
2018
         libswscale \
2019
         tests \
2020
         vhook \
2021
         "
2022
    FILES="\
2023
          Makefile \
2024
          common.mak \
2025
          libavformat/Makefile \
2026
          libavcodec/Makefile \
2027
          libpostproc/Makefile \
2028
          libavutil/Makefile \
2029
          libswscale/Makefile \
2030
          tests/Makefile \
2031
          vhook/Makefile \
2032
          doc/Makefile \
2033
          doc/texi2pod.pl \
2034
          "
2035
    for dir in $DIRS ; do
2036
            mkdir -p $dir
2037
    done
2038
    for f in $FILES ; do
2039
        ln -sf "$source_path/$f" $f
2040
    done
2041
fi
2042
echo "SRC_PATH=\"$source_path\"" >> config.mak
2043
echo "SRC_PATH_BARE=$source_path" >> config.mak
2044
echo "BUILD_ROOT=\"$PWD\"" >> config.mak
2045

    
2046
if test "$amr_wb" = "yes" ; then
2047
  echo
2048
  echo "AMR WB FLOAT NOTICE ! Make sure you have downloaded TS26.204"
2049
  echo "V5.1.0 from "
2050
  echo "http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-510.zip"
2051
  echo "and extracted the source to libavcodec/amrwb_float"
2052
fi
2053

    
2054
if test "$amr_nb" = "yes" ; then
2055
  echo
2056
  echo "AMR NB FLOAT NOTICE ! Make sure you have downloaded TS26.104"
2057
  echo "REL-5 V5.1.0 from "
2058
  echo "http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-510.zip"
2059
  echo "and extracted the source to libavcodec/amr_float"
2060
  echo "If you try this on alpha, you may need to change Word32 to int in amr/typedef.h"
2061
fi
2062

    
2063
if test "$amr_nb_fixed" = "yes" ; then
2064
  echo
2065
  echo "AMR NB FIXED POINT NOTICE! Make sure you have downloaded TS26.073 "
2066
  echo "REL-5 version 5.1.0 from "
2067
  echo "http://www.3gpp.org/ftp/Specs/archive/26_series/26.073/26073-510.zip"
2068
  echo "and extracted src to libavcodec/amr"
2069
  echo "You must also add -DMMS_IO and remove -pedantic-errors to/from CFLAGS in libavcodec/amr/makefile."
2070
  echo "i.e. CFLAGS = -Wall -I. \$(CFLAGS_\$(MODE)) -D\$(VAD) -DMMS_IO"
2071
fi
2072

    
2073
if test "$amr_if2" = "yes" ; then
2074
  echo "AMR_CFLAGS=-DIF2=1" >> config.mak
2075
fi
2076

    
2077
# Apparently it's not possible to portably echo a backslash.
2078
if test "$asmalign_pot" = "yes" ; then
2079
  printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
2080
else
2081
  printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
2082
fi
2083

    
2084

    
2085
# "tr '[a-z]' '[A-Z]'" is a workaround for Solaris tr not grokking "tr a-z A-Z"
2086
for codec in $DECODER_LIST $ENCODER_LIST $PARSER_LIST $DEMUXER_LIST $MUXER_LIST; do
2087
    ucname="`toupper $codec`"
2088
    config_name="CONFIG_$ucname"
2089
    enabled_name="ENABLE_$ucname"
2090
    if enabled $codec; then
2091
        echo "#define $config_name 1" >> $TMPH
2092
        echo "#define $enabled_name 1" >> $TMPH
2093
        echo "$config_name=yes" >> config.mak
2094
    else
2095
        echo "#define $enabled_name 0" >> $TMPH
2096
    fi
2097
done
2098

    
2099
# Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
2100
diff $TMPH config.h >/dev/null 2>&1
2101
if test "$?" != "0" ; then
2102
        mv -f $TMPH config.h
2103
else
2104
        echo "config.h is unchanged"
2105
fi
2106

    
2107
rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
2108

    
2109

    
2110
# build pkg-config files libav*.pc and libpostproc.pc
2111
# libavutil.pc
2112
cat <<EOF >libavutil.pc
2113
prefix=$PREFIX
2114
exec_prefix=\${prefix}
2115
libdir=\${exec_prefix}/lib
2116
includedir=\${prefix}/include
2117

    
2118
Name: libavutil
2119
Description: FFmpeg utility library
2120
Version: $lavu_version
2121
Requires:
2122
Conflicts:
2123
Libs: -L\${libdir} -lavutil
2124
Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2125
EOF
2126

    
2127
cat <<EOF >libavutil-uninstalled.pc
2128
prefix=
2129
exec_prefix=
2130
libdir=\${pcfiledir}/libavutil
2131
includedir=\${pcfiledir}/libavutil
2132

    
2133
Name: libavutil
2134
Description: FFmpeg utility library
2135
Version: $lavu_version
2136
Requires:
2137
Conflicts:
2138
Libs: \${libdir}/${LIBPREF}avutil${LIBSUF}
2139
Cflags: -I\${includedir}
2140
EOF
2141

    
2142
# libavcodec.pc
2143
cat <<EOF >libavcodec.pc
2144
prefix=$PREFIX
2145
exec_prefix=\${prefix}
2146
libdir=\${exec_prefix}/lib
2147
includedir=\${prefix}/include
2148

    
2149
Name: libavcodec
2150
Description: FFmpeg codec library
2151
Version: $lavc_version
2152
Requires: $pkg_requires libavutil = $lavu_version
2153
Conflicts:
2154
Libs: -L\${libdir} -lavcodec $extralibs
2155
Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2156
EOF
2157

    
2158
cat <<EOF >libavcodec-uninstalled.pc
2159
prefix=
2160
exec_prefix=
2161
libdir=\${pcfiledir}/libavcodec
2162
includedir=\${pcfiledir}/libavcodec
2163

    
2164
Name: libavcodec
2165
Description: FFmpeg codec library
2166
Version: $lavc_version
2167
Requires: $pkg_requires libavutil = $lavu_version
2168
Conflicts:
2169
Libs: \${libdir}/${LIBPREF}avcodec${LIBSUF} $extralibs
2170
Cflags: -I\${includedir}
2171
EOF
2172

    
2173
# libavformat.pc
2174
cat <<EOF >libavformat.pc
2175
prefix=$PREFIX
2176
exec_prefix=\${prefix}
2177
libdir=\${exec_prefix}/lib
2178
includedir=\${prefix}/include
2179

    
2180
Name: libavformat
2181
Description: FFmpeg container format library
2182
Version: $lavf_version
2183
Requires: $pkg_requires libavcodec = $lavc_version
2184
Conflicts:
2185
Libs: -L\${libdir} -lavformat $extralibs
2186
Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2187
EOF
2188

    
2189
cat <<EOF >libavformat-uninstalled.pc
2190
prefix=
2191
exec_prefix=
2192
libdir=\${pcfiledir}/libavformat
2193
includedir=\${pcfiledir}/libavformat
2194

    
2195
Name: libavformat
2196
Description: FFmpeg container format library
2197
Version: $lavf_version
2198
Requires: $pkg_requires libavcodec = $lavc_version
2199
Conflicts:
2200
Libs: \${libdir}/${LIBPREF}avformat${LIBSUF} $extralibs
2201
Cflags: -I\${includedir}
2202
EOF
2203

    
2204

    
2205
# libpostproc.pc
2206
cat <<EOF >libpostproc.pc
2207
prefix=$PREFIX
2208
exec_prefix=\${prefix}
2209
libdir=\${exec_prefix}/lib
2210
includedir=\${prefix}/include
2211

    
2212
Name: libpostproc
2213
Description: FFmpeg post processing library
2214
Version: $lavc_version
2215
Requires:
2216
Conflicts:
2217
Libs: -L\${libdir} -lpostproc
2218
Cflags: -I\${includedir} -I\${includedir}/postproc
2219
EOF
2220

    
2221
cat <<EOF >libpostproc-uninstalled.pc
2222
prefix=
2223
exec_prefix=
2224
libdir=\${pcfiledir}/libpostproc
2225
includedir=\${pcfiledir}/libpostproc
2226

    
2227
Name: libpostproc
2228
Description: FFmpeg post processing library
2229
Version: $lavc_version
2230
Requires:
2231
Conflicts:
2232
Libs: \${libdir}/${LIBPREF}postproc${LIBSUF}
2233
Cflags: -I\${includedir}
2234
EOF
2235

    
2236
if test "$swscaler" != "no"; then
2237
  sws_pc_libs="-L\${libdir} -lswscale"
2238
  sws_pc_uninstalled_libs="\${libdir}/${LIBPREF}swscale${LIBSUF}"
2239
  sws_pc_requires="$pkg_requires libavutil = $lavu_version"
2240
else
2241
  sws_pc_libs=""
2242
  sws_pc_uninstalled_libs=""
2243
  sws_pc_requires="$pkg_requires libavcodec = $lavc_version"
2244
fi
2245
# libswscale.pc
2246
cat <<EOF >libswscale.pc
2247
prefix=$PREFIX
2248
exec_prefix=\${prefix}
2249
libdir=\${exec_prefix}/lib
2250
includedir=\${prefix}/include
2251

    
2252
Name: libswscale
2253
Description: FFmpeg image rescaling library
2254
Version: $sws_version
2255
Requires: $sws_pc_requires
2256
Conflicts:
2257
Libs: $sws_pc_libs
2258
Cflags: -I\${includedir} -I\${includedir}/swscale
2259
EOF
2260

    
2261
cat <<EOF >libswscale-uninstalled.pc
2262
prefix=
2263
exec_prefix=
2264
libdir=\${pcfiledir}/libswscale
2265
includedir=\${pcfiledir}/libswscale
2266

    
2267
Name: libswscale
2268
Description: FFmpeg image rescaling library
2269
Version: $sws_version
2270
Requires: $sws_pc_requires
2271
Conflicts:
2272
Libs: $sws_pc_uninstalled_libs
2273
Cflags: -I\${includedir}
2274
EOF