Statistics
| Branch: | Revision:

ffmpeg / configure @ a77caa4d

History | View | Annotate | Download (55.1 KB)

1
#!/bin/sh
2
#
3
# FFmpeg configure script
4
#
5
# Copyright (c) 2000, 2001, 2002 Fabrice Bellard
6
# Copyright (c) 2005-2006 Diego Biurrun
7
# Copyright (c) 2005-2006 Mans Rullgard
8
#
9

    
10
# make sure we are running under a compatible shell
11
# try to make this part work with most shells
12

    
13
try_exec(){
14
    echo "Trying shell $1"
15
    type "$1" >/dev/null 2>&1 && exec "$@"
16
}
17

    
18
unset foo
19
(: ${foo%%bar}) 2>/dev/null
20
E1="$?"
21

    
22
(: ${foo?}) 2>/dev/null
23
E2="$?"
24

    
25
if test "$E1" != 0 || test "$E2" = 0; then
26
    echo "Broken shell detected.  Trying alternatives."
27
    export FF_CONF_EXEC
28
    if test "0$FF_CONF_EXEC" -lt 1; then
29
        FF_CONF_EXEC=1
30
        try_exec bash "$0" "$@"
31
    fi
32
    if test "0$FF_CONF_EXEC" -lt 2; then
33
        FF_CONF_EXEC=2
34
        try_exec ksh "$0" "$@"
35
    fi
36
    if test "0$FF_CONF_EXEC" -lt 3; then
37
        FF_CONF_EXEC=3
38
        try_exec /usr/xpg4/bin/sh "$0" "$@"
39
    fi
40
    echo "No compatible shell script interpreter found."
41
    echo "This configure script requires a POSIX compatible shell"
42
    echo "such as bash or ksh."
43
    if test "$BASH_VERSION" = '2.04.0(1)-release'; then
44
        echo "This bash version ($BASH_VERSION) is broken on your platform."
45
        echo "Upgrade to a later version if available."
46
    fi
47
    exit 1
48
fi
49

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

    
157
log(){
158
    echo "$@" >>$logfile
159
}
160

    
161
log_file(){
162
    log BEGIN $1
163
    cat -n $1 >>$logfile
164
    log END $1
165
}
166

    
167
echolog(){
168
    log "$@"
169
    echo "$@"
170
}
171

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

    
194
# "tr '[a-z]' '[A-Z]'" is a workaround for Solaris tr not grokking "tr a-z A-Z"
195
toupper(){
196
    echo "$@" | tr '[a-z]' '[A-Z]'
197
}
198

    
199
set_all(){
200
    value=$1
201
    shift
202
    for var in $*; do
203
        eval $var=$value
204
    done
205
}
206

    
207
enable(){
208
    set_all yes $*
209
}
210

    
211
disable(){
212
    set_all no $*
213
}
214

    
215
enabled(){
216
    eval test "x\$$1" = "xyes"
217
}
218

    
219
enabled_all(){
220
    for opt; do
221
        enabled $opt || return 1
222
    done
223
}
224

    
225
enabled_any(){
226
    for opt; do
227
        enabled $opt && return 0
228
    done
229
}
230

    
231
print_config(){
232
    pfx=$1
233
    header=$2
234
    makefile=$3
235
    shift 3
236
    for cfg; do
237
        if enabled $cfg; then
238
            ucname="${pfx}`toupper $cfg`"
239
            echo "#define ${ucname} 1" >> $header
240
            echo "${ucname}=yes" >> $makefile
241
        fi
242
    done
243
}
244

    
245
flags_saved(){
246
    (: ${SAVE_CFLAGS?}) 2>/dev/null
247
}
248

    
249
save_flags(){
250
    flags_saved && return
251
    SAVE_CFLAGS="$CFLAGS"
252
    SAVE_LDFLAGS="$LDFLAGS"
253
    SAVE_extralibs="$extralibs"
254
}
255

    
256
restore_flags(){
257
    CFLAGS="$SAVE_CFLAGS"
258
    LDFLAGS="$SAVE_LDFLAGS"
259
    extralibs="$SAVE_extralibs"
260
    unset SAVE_CFLAGS
261
    unset SAVE_LDFLAGS
262
    unset SAVE_extralibs
263
}
264

    
265
temp_cflags(){
266
    save_flags
267
    CFLAGS="$CFLAGS $*"
268
}
269

    
270
temp_ldflags(){
271
    save_flags
272
    LDFLAGS="$LDFLAGS $*"
273
}
274

    
275
temp_extralibs(){
276
    save_flags
277
    extralibs="$extralibs $*"
278
}
279

    
280
append(){
281
    var=$1
282
    shift
283
    flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
284
    eval "$var=\"\$$var $*\""
285
}
286

    
287
add_cflags(){
288
    append CFLAGS "$@"
289
}
290

    
291
add_ldflags(){
292
    append LDFLAGS "$@"
293
}
294

    
295
add_extralibs(){
296
    append extralibs "$@"
297
}
298

    
299
check_cmd(){
300
    log "$@"
301
    "$@" >>$logfile 2>&1
302
}
303

    
304
check_cc(){
305
    log check_cc "$@"
306
    cat >$TMPC
307
    log_file $TMPC
308
    check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
309
}
310

    
311
check_cpp(){
312
    log check_cpp "$@"
313
    cat >$TMPC
314
    log_file $TMPC
315
    check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
316
}
317

    
318
check_ld(){
319
    log check_ld "$@"
320
    check_cc || return
321
    check_cmd $cc $LDFLAGS "$@" -o $TMPE $TMPO $extralibs
322
}
323

    
324
check_cflags(){
325
    log check_cflags "$@"
326
    check_cc "$@" <<EOF && add_cflags "$@"
327
int x;
328
EOF
329
}
330

    
331
check_ldflags(){
332
    log check_ldflags "$@"
333
    check_ld "$@" <<EOF && add_ldflags "$@"
334
int main(){
335
    return 0;
336
}
337
EOF
338
}
339

    
340
check_header(){
341
    log check_header "$@"
342
    header=$1
343
    shift
344
    check_cpp "$@" <<EOF
345
#include <$header>
346
int x;
347
EOF
348
    err=$?
349
    var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
350
    test "$err" = 0 && enable $var || disable $var
351
    return $err
352
}
353

    
354
check_func(){
355
    log check_func "$@"
356
    func=$1
357
    shift
358
    check_ld "$@" <<EOF
359
extern int $func();
360
int main(){
361
    $func();
362
}
363
EOF
364
    err=$?
365
    test "$err" = 0 && enable $func || disable $func
366
    return $err
367
}
368

    
369
check_lib(){
370
    log check_lib "$@"
371
    header="$1"
372
    func="$2"
373
    shift 2
374
    temp_extralibs "$@"
375
    check_header $header && check_func $func && add_extralibs "$@"
376
    err=$?
377
    restore_flags
378
    return $err
379
}
380

    
381
check_exec(){
382
    check_ld "$@" && { test "$cross_compile" = yes || $TMPE >>$logfile 2>&1; }
383
}
384

    
385
require(){
386
    name="$1"
387
    header="$2"
388
    func="$3"
389
    shift 3
390
    check_lib $header $func "$@" || die "ERROR: $name not found"
391
}
392

    
393
CONFIG_LIST='
394
    encoders
395
    decoders
396
    parsers
397
    muxers
398
    demuxers
399
    a52
400
    a52bin
401
    amr
402
    amr_nb
403
    amr_nb_fixed
404
    amr_wb
405
    audio_beos
406
    audio_oss
407
    avisynth
408
    beos_netserver
409
    bktr
410
    dc1394
411
    dts
412
    dv1394
413
    faac
414
    faad
415
    faadbin
416
    ffmpeg
417
    ffplay
418
    ffserver
419
    gpl
420
    ipv6
421
    libgsm
422
    libnut
423
    libogg
424
    libvorbis
425
    memalign_hack
426
    mp3lame
427
    mpegaudio_hp
428
    network
429
    pp
430
    protocols
431
    swscaler
432
    vhook
433
    video4linux
434
    video4linux2
435
    wince
436
    x264
437
    xvid
438
    zlib
439
'
440

    
441
HAVE_LIST='
442
    altivec_h
443
    beosthreads
444
    byteswap_h
445
    dcbzl
446
    dlfcn_h
447
    dlopen
448
    freetype2
449
    gprof
450
    imlib2
451
    inet_aton
452
    localtime_r
453
    lrintf
454
    malloc_h
455
    memalign
456
    mlib
457
    os2
458
    os2threads
459
    pthreads
460
    sdl
461
    sdl_video_size
462
    threads
463
    w32threads
464
'
465

    
466
# set temporary file name
467
if test ! -z "$TMPDIR" ; then
468
    TMPDIR1="${TMPDIR}"
469
elif test ! -z "$TEMPDIR" ; then
470
    TMPDIR1="${TEMPDIR}"
471
else
472
    TMPDIR1="/tmp"
473
fi
474

    
475
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
476
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
477
TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
478
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
479
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
480

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

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

    
812
# find source path
813
source_path="`dirname \"$0\"`"
814
source_path_used="yes"
815
if test -z "$source_path" -o "$source_path" = "." ; then
816
    source_path="`pwd`"
817
    source_path_used="no"
818
else
819
    source_path="`cd \"$source_path\"; pwd`"
820
    echo "$source_path" | grep -q '[[:blank:]]' &&
821
      die "Out of tree builds are impossible with whitespace in source path."
822
fi
823

    
824
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
825
    show_help
826
fi
827

    
828
FFMPEG_CONFIGURATION=" "
829
for opt do
830
  FFMPEG_CONFIGURATION="$FFMPEG_CONFIGURATION""$opt "
831
done
832

    
833
ENCODER_LIST=`sed -n 's/^[^#]*ENC.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
834
DECODER_LIST=`sed -n 's/^[^#]*DEC.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
835
PARSER_LIST=`sed -n 's/^[^#]*PARSER.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
836
MUXER_LIST=`sed -n 's/^[^#]*_MUX.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
837
DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
838

    
839
enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST
840

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

    
1037
if test "$logging" != no; then
1038
    test "$logging" = yes || logfile="$logging"
1039
    echo "# $0 $@" >$logfile
1040
    set >>$logfile
1041
else
1042
    logfile=/dev/null
1043
fi
1044

    
1045
if test "$mingw32" = "yes" -o "$wince" = "yes"; then
1046
    if test "$lshared" = "yes" && test "$lstatic" = "yes" ; then
1047
        cat <<EOF
1048
You can only build one library type at once on MinGW.
1049
Specify --disable-static --enable-shared to only build
1050
the shared libraries. To build only the static libraries
1051
you do not need to pass additional options.
1052
EOF
1053
        exit 1
1054
    fi
1055
    video4linux="no"
1056
    video4linux2="no"
1057
    bktr="no"
1058
    audio_oss="no"
1059
    dv1394="no"
1060
    dc1394="no"
1061
    ffserver="no"
1062
    network="no"
1063
    if enabled mingw32; then
1064
        w32threads="yes"
1065
    fi
1066
    if test "$wince" = "yes"; then
1067
        protocols="no"
1068
    fi
1069
    SLIBPREF=""
1070
    SLIBSUF=".dll"
1071
    EXESUF=".exe"
1072
    SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1073
    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
1074
    SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
1075
    SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc"
1076
fi
1077

    
1078
# Combine FFLDFLAGS and the LDFLAGS environment variable.
1079
LDFLAGS="$FFLDFLAGS $LDFLAGS"
1080

    
1081
test -n "$cross_prefix" && cross_compile=yes
1082
cc="${cross_prefix}${cc}"
1083
ar="${cross_prefix}${ar}"
1084
ranlib="${cross_prefix}${ranlib}"
1085
strip="${cross_prefix}${strip}"
1086

    
1087
# we need to build at least one lib type
1088
if test "$lstatic" = "no" && test "$lshared" = "no" ; then
1089
    cat <<EOF
1090
At least one library type must be built.
1091
Specify --enable-static to build the static libraries or --enable-shared to
1092
build the shared libraries as well. To only build the shared libraries specify
1093
--disable-static in addition to --enable-shared.
1094
EOF
1095
    exit 1;
1096
fi
1097

    
1098
if test "$libvorbis" = "yes" ; then
1099
    if test "$libogg" = "no"; then
1100
        echo "libogg must be enabled to enable Vorbis."
1101
        fail="yes"
1102
    fi
1103
fi
1104

    
1105
if test "$gpl" != "yes"; then
1106
    if test "$pp" != "no"; then
1107
        echo "The Postprocessing code is under GPL and --enable-gpl is not specified."
1108
        fail="yes"
1109
    fi
1110

    
1111
    if test "$a52" != "no" -o "$a52bin" != "no"; then
1112
        echo "liba52 is under GPL and --enable-gpl is not specified."
1113
        fail="yes"
1114
    fi
1115

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

    
1121
    if test "$x264" != "no"; then
1122
        echo "x264 is under GPL and --enable-gpl is not specified."
1123
        fail="yes"
1124
    fi
1125

    
1126
    if test "$dts" != "no"; then
1127
        echo "libdts is under GPL and --enable-gpl is not specified."
1128
        fail="yes"
1129
    fi
1130

    
1131
    if test "$faad" != "no" -o "$faadbin" != "no"; then
1132
        if check_header faad.h; then
1133
            check_cc << EOF
1134
                #include <faad.h>
1135
                #ifndef FAAD2_VERSION
1136
                ok faad1
1137
                #endif
1138
                int main( void ) { return 0; }
1139
EOF
1140
            if test $? = 0 ; then
1141
                echo "FAAD2 is under GPL and --enable-gpl is not specified."
1142
                fail="yes"
1143
            fi
1144
        else
1145
            faad="no"
1146
            faadbin="no"
1147
            echo "FAAD test failed."
1148
        fi
1149
    fi
1150

    
1151
    if test "$swscaler" != "no"; then
1152
        echo "The software scaler is under GPL and --enable-gpl is not specified."
1153
        fail="yes"
1154
    fi
1155
fi
1156

    
1157
if test "$fail" = "yes"; then
1158
    exit 1
1159
fi
1160

    
1161
# compute MMX state
1162
if test $mmx = "default"; then
1163
    if test $arch = "x86_32" -o $arch = "x86_64"; then
1164
        mmx="yes"
1165
    else
1166
        mmx="no"
1167
    fi
1168
fi
1169

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

    
1197
if test $optimize != "no"; then
1198
    add_cflags "-fomit-frame-pointer"
1199
fi
1200

    
1201
# Can only do AltiVec on PowerPC
1202
if test $altivec = "default"; then
1203
    if test $arch = "powerpc"; then
1204
        altivec="yes"
1205
    else
1206
        altivec="no"
1207
    fi
1208
fi
1209

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

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

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

    
1313
# check for assembler specific support
1314

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

    
1326
# check for SIMD availability
1327

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

    
1339
check_header altivec.h
1340

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

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

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

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

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

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

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

    
1415
check_header malloc.h
1416
check_func memalign
1417

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

    
1424
check_header byteswap.h
1425

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

    
1430
# check for some common methods of building with pthread support
1431
# do this before the optional library checks as some of them require pthreads
1432
if enabled pthreads; then
1433
    if check_func pthread_create; then
1434
        :
1435
    elif check_func pthread_create -pthread; then
1436
        add_cflags -pthread
1437
        add_ldflags -pthread
1438
    elif check_func pthread_create -pthreads; then
1439
        add_cflags -pthreads
1440
        add_ldflags -pthreads
1441
    elif ! check_lib pthread.h pthread_create -lpthread; then
1442
        die "ERROR: can't find pthreads library"
1443
    fi
1444
fi
1445

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

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

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

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

    
1505

    
1506
# test for lrintf in math.h
1507
check_exec <<EOF && lrintf=yes || lrintf=no
1508
#define _ISOC9X_SOURCE  1
1509
#include <math.h>
1510
int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
1511
EOF
1512

    
1513
_restrict=
1514
for restrict_keyword in restrict __restrict__ __restrict; do
1515
    check_cc <<EOF && _restrict=$restrict_keyword && break
1516
void foo(char * $restrict_keyword p);
1517
EOF
1518
done
1519

    
1520
# dlopen/dlfcn.h probing
1521

    
1522
check_header dlfcn.h
1523

    
1524
if check_func dlopen; then
1525
    ldl=
1526
elif check_func dlopen -ldl; then
1527
    ldl=-ldl
1528
fi
1529

    
1530
if test "$vhook" = "default"; then
1531
    vhook="$dlopen"
1532
fi
1533

    
1534
if enabled_any vhook a52bin faadbin; then
1535
    add_extralibs $ldl
1536
fi
1537

    
1538
if test "$targetos" = "CYGWIN" -a "$lstatic" = "yes" ; then
1539
    vhook="no"
1540
    echo
1541
    echo "At the moment vhooks don't work on Cygwin static builds."
1542
    echo "Patches welcome."
1543
    echo
1544
fi
1545

    
1546
if enabled vhook; then
1547
    check_ldflags -rdynamic
1548
    check_ldflags -export-dynamic
1549
fi
1550

    
1551
if enabled audio_beos; then
1552
    add_extralibs "-lmedia -lbe"
1553
fi
1554

    
1555
##########################################
1556
# imlib check
1557

    
1558
temp_extralibs -lImlib2
1559
check_ld <<EOF && imlib2=yes || imlib2=no
1560
#include <X11/Xlib.h>
1561
#include <Imlib2.h>
1562
int main( void ) { return (int) imlib_load_font("foo"); }
1563
EOF
1564
restore_flags
1565

    
1566
##########################################
1567
# FreeType check
1568

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

    
1582
##########################################
1583
# SDL check
1584

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

    
1615
enabled sdl || ffplay=no
1616

    
1617
##########################################
1618
# texi2html check
1619

    
1620
texi2html=no
1621
if (texi2html -version) >/dev/null 2>&1; then
1622
texi2html=yes
1623
fi
1624

    
1625
##########################################
1626
# IPv6 check
1627

    
1628
enabled network && enabled ipv6 && check_ld <<EOF && ipv6=yes || ipv6=no
1629
#include <sys/types.h>
1630
#include <sys/socket.h>
1631
#include <netinet/in.h>
1632
#include <netdb.h>
1633
int main( void ) {
1634
  struct sockaddr_storage saddr;
1635
  struct ipv6_mreq mreq6;
1636
  getaddrinfo(0,0,0,0);
1637
  getnameinfo(0,0,0,0,0,0,0);
1638
  IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
1639
}
1640
EOF
1641

    
1642
# check for video4linux2 --- V4L2_PIX_FMT_YUV420
1643
enabled video4linux2 && check_cc <<EOF || video4linux2="no"
1644
#include <sys/time.h>
1645
#include <asm/types.h>
1646
#include <linux/videodev2.h>
1647
int dummy = V4L2_PIX_FMT_YUV420;
1648
struct v4l2_buffer dummy1;
1649
EOF
1650

    
1651
enabled debug && add_cflags -g
1652

    
1653
# add some useful compiler flags if supported
1654
check_cflags -Wdeclaration-after-statement
1655
check_cflags -Wall
1656
check_cflags -Wno-switch
1657
check_cflags -Wdisabled-optimization
1658
check_cflags -Wpointer-arith
1659
check_cflags -Wredundant-decls
1660
enabled extrawarnings && check_cflags -Winline
1661

    
1662
# add some linker flags
1663
check_ldflags $LDLATEFLAGS
1664

    
1665
# not all compilers support -Os
1666
test "$optimize" = "small" && check_cflags -Os
1667

    
1668
if enabled optimize; then
1669
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1670
        add_cflags  "-O5"
1671
        add_ldflags "-O5"
1672
    else
1673
        add_cflags "-O3"
1674
    fi
1675
fi
1676

    
1677
# PIC flags for shared library objects where they are needed
1678
if test "$lshared" = "yes" ; then
1679
    # LIBOBJFLAGS may have already been set in the OS configuration
1680
    if test -z "$LIBOBJFLAGS" ; then
1681
        case "$arch" in
1682
            x86_64|ia64|alpha|sparc*) LIBOBJFLAGS="\$(PIC)" ;;
1683
        esac
1684
    fi
1685
fi
1686

    
1687
if test "$gprof" = "yes" ; then
1688
    add_cflags  "-p"
1689
    add_ldflags "-p"
1690
fi
1691

    
1692
VHOOKCFLAGS="-fPIC $CFLAGS"
1693
test "$needmdynamicnopic" = yes && add_cflags -mdynamic-no-pic
1694

    
1695
# find if .align arg is power-of-two or not
1696
if test $asmalign_pot = "unknown"; then
1697
    asmalign_pot="no"
1698
    echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
1699
fi
1700

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

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

    
1776
echo "Creating config.mak and config.h..."
1777

    
1778
echo "# Automatically generated by configure - do not modify!" > config.mak
1779
echo "/* Automatically generated by configure - do not modify! */" > $TMPH
1780
echo "#define FFMPEG_CONFIGURATION "'"'"$FFMPEG_CONFIGURATION"'"' >> $TMPH
1781

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

    
1801
echo "OPTFLAGS=$CFLAGS" >> config.mak
1802
echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
1803
echo "LDFLAGS=$LDFLAGS" >> config.mak
1804
echo "LDCONFIG=$LDCONFIG" >> config.mak
1805
echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
1806
echo "SHFLAGS=$SHFLAGS" >> config.mak
1807
echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
1808
echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
1809
echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
1810
echo "BUILD_STATIC=$lstatic" >> config.mak
1811
echo "BUILDSUF=$BUILDSUF" >> config.mak
1812
echo "LIBPREF=$LIBPREF" >> config.mak
1813
echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
1814
if test "$lstatic" = "yes" ; then
1815
  echo "LIB=$LIB" >> config.mak
1816
else # Some Make complain if this variable does not exist.
1817
  echo "LIB=" >> config.mak
1818
fi
1819
echo "SLIBPREF=$SLIBPREF" >> config.mak
1820
echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
1821
echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
1822
echo "TARGET_OS=$targetos" >> config.mak
1823

    
1824
ucarch=`toupper $arch`
1825
echo "TARGET_ARCH_${ucarch}=yes" >> config.mak
1826
echo "#define ARCH_${ucarch} 1" >> $TMPH
1827

    
1828
# special cases
1829
case "$arch" in
1830
    x86_32|x86_64)
1831
        echo "TARGET_ARCH_X86=yes" >> config.mak
1832
        echo "#define ARCH_X86 1" >> $TMPH
1833
        ;;
1834
    powerpc)
1835
        if test "$POWERPCMODE" = "64bits"; then
1836
            echo "#define POWERPC_MODE_64BITS 1" >> $TMPH
1837
        fi
1838
        if test "$powerpc_perf" = "yes"; then
1839
            echo "#define POWERPC_PERFORMANCE_REPORT 1" >> $TMPH
1840
        fi
1841
        ;;
1842
    sparc64)
1843
        echo "TARGET_ARCH_SPARC=yes" >> config.mak
1844
        echo "#define ARCH_SPARC 1" >> $TMPH
1845
        ;;
1846
esac
1847

    
1848
if test "$bigendian" = "yes" ; then
1849
  echo "WORDS_BIGENDIAN=yes" >> config.mak
1850
  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
1851
fi
1852
if test "$mmx" = "yes" ; then
1853
  echo "TARGET_MMX=yes" >> config.mak
1854
  echo "#define HAVE_MMX 1" >> $TMPH
1855
  echo "#define __CPU__ 586" >> $TMPH
1856
fi
1857
if test "$cmov" = "yes" ; then
1858
  echo "TARGET_CMOV=yes" >> config.mak
1859
  echo "#define HAVE_CMOV 1" >> $TMPH
1860
fi
1861
if test "$cmov_is_fast" = "yes" ; then
1862
  echo "TARGET_CMOV_IS_FAST=yes" >> config.mak
1863
  echo "#define CMOV_IS_FAST 1" >> $TMPH
1864
fi
1865
if test "$armv5te" = "yes" ; then
1866
  echo "TARGET_ARMV5TE=yes" >> config.mak
1867
  echo "#define HAVE_ARMV5TE 1" >> $TMPH
1868
fi
1869
if test "$iwmmxt" = "yes" ; then
1870
  echo "TARGET_IWMMXT=yes" >> config.mak
1871
  echo "#define HAVE_IWMMXT 1" >> $TMPH
1872
fi
1873
if test "$mmi" = "yes" ; then
1874
  echo "TARGET_MMI=yes" >> config.mak
1875
  echo "#define HAVE_MMI 1" >> $TMPH
1876
fi
1877

    
1878
if test "$altivec" = "yes" ; then
1879
  echo "TARGET_ALTIVEC=yes" >> config.mak
1880
  echo "#define HAVE_ALTIVEC 1" >> $TMPH
1881
fi
1882

    
1883
if test "$sdl" = "yes" ; then
1884
  echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1885
  echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
1886
fi
1887
if test "$texi2html" = "yes"; then
1888
  echo "BUILD_DOC=yes" >> config.mak
1889
fi
1890

    
1891
sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
1892
pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
1893
lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
1894
lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
1895
lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
1896

    
1897

    
1898

    
1899
if test "$lshared" = "yes" ; then
1900
  echo "#define BUILD_SHARED_AV 1" >> $TMPH
1901
  echo "BUILD_SHARED=yes" >> config.mak
1902
  echo "PIC=-fPIC -DPIC" >> config.mak
1903
  echo "SPPMAJOR=${lavc_version%%.*}" >> config.mak
1904
  echo "SPPVERSION=$lavc_version" >> config.mak
1905
  echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
1906
  echo "LAVCVERSION=$lavc_version" >> config.mak
1907
  echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
1908
  echo "LAVFVERSION=$lavf_version" >> config.mak
1909
  echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
1910
  echo "LAVUVERSION=$lavu_version" >> config.mak
1911
  echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
1912
  echo "SWSVERSION=$sws_version" >> config.mak
1913
  echo "SLIBNAME=${SLIBNAME}" >> config.mak
1914
  echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
1915
  echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
1916
  echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
1917
fi
1918
echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
1919
echo "EXTRALIBS=$extralibs" >> config.mak
1920

    
1921
enabled_any $ENCODER_LIST && enable encoders
1922
enabled_any $DECODER_LIST && enable decoders
1923
enabled_any $MUXER_LIST   && enable muxers
1924
enabled_any $DEMUXER_LIST && enable demuxers
1925

    
1926
enabled_any pthreads beosthreads os2threads w32threads && enable threads
1927

    
1928
print_config HAVE_   $TMPH config.mak $HAVE_LIST
1929
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST
1930

    
1931
if test "$targetos" = "Darwin"; then
1932
  echo "#define CONFIG_DARWIN 1"  >> $TMPH
1933
fi
1934

    
1935
echo "#define restrict $_restrict" >> $TMPH
1936

    
1937
if test "$optimize" = "small"; then
1938
  echo "#define always_inline"  >> $TMPH
1939
  echo "#define CONFIG_SMALL 1" >> $TMPH
1940
fi
1941

    
1942
echo "SRC_PATH=\"$source_path\"" >> config.mak
1943
echo "SRC_PATH_BARE=$source_path" >> config.mak
1944
echo "BUILD_ROOT=\"$PWD\"" >> config.mak
1945

    
1946
if test "$amr_if2" = "yes" ; then
1947
  echo "AMR_CFLAGS=-DIF2=1" >> config.mak
1948
fi
1949

    
1950
# Apparently it's not possible to portably echo a backslash.
1951
if test "$asmalign_pot" = "yes" ; then
1952
  printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
1953
else
1954
  printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
1955
fi
1956

    
1957

    
1958
for codec in $DECODER_LIST $ENCODER_LIST $PARSER_LIST $DEMUXER_LIST $MUXER_LIST; do
1959
    ucname="`toupper $codec`"
1960
    config_name="CONFIG_$ucname"
1961
    enabled_name="ENABLE_$ucname"
1962
    if enabled $codec; then
1963
        echo "#define $config_name 1" >> $TMPH
1964
        echo "#define $enabled_name 1" >> $TMPH
1965
        echo "$config_name=yes" >> config.mak
1966
    else
1967
        echo "#define $enabled_name 0" >> $TMPH
1968
    fi
1969
done
1970

    
1971
# Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
1972
if ! cmp -s $TMPH config.h; then
1973
        mv -f $TMPH config.h
1974
else
1975
        echo "config.h is unchanged"
1976
fi
1977

    
1978
rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
1979

    
1980
# build tree in object directory if source path is different from current one
1981
if test "$source_path_used" = "yes" ; then
1982
    DIRS="\
1983
         doc \
1984
         libavformat \
1985
         libavcodec \
1986
         libavcodec/alpha \
1987
         libavcodec/armv4l \
1988
         libavcodec/bfin \
1989
         libavcodec/i386 \
1990
         libavcodec/sparc \
1991
         libavcodec/mlib \
1992
         libavcodec/ppc \
1993
         libavcodec/liba52 \
1994
         libpostproc \
1995
         libavutil \
1996
         libswscale \
1997
         tests \
1998
         vhook \
1999
         "
2000
    FILES="\
2001
          Makefile \
2002
          common.mak \
2003
          libavformat/Makefile \
2004
          libavcodec/Makefile \
2005
          libpostproc/Makefile \
2006
          libavutil/Makefile \
2007
          libswscale/Makefile \
2008
          tests/Makefile \
2009
          vhook/Makefile \
2010
          doc/Makefile \
2011
          doc/texi2pod.pl \
2012
          "
2013
    for dir in $DIRS ; do
2014
            mkdir -p $dir
2015
    done
2016
    for f in $FILES ; do
2017
        ln -sf "$source_path/$f" $f
2018
    done
2019
fi
2020

    
2021
# build pkg-config files libav*.pc and libpostproc.pc
2022
# libavutil.pc
2023
cat <<EOF >libavutil.pc
2024
prefix=$PREFIX
2025
exec_prefix=\${prefix}
2026
libdir=\${exec_prefix}/lib
2027
includedir=\${prefix}/include
2028

    
2029
Name: libavutil
2030
Description: FFmpeg utility library
2031
Version: $lavu_version
2032
Requires:
2033
Conflicts:
2034
Libs: -L\${libdir} -lavutil
2035
Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2036
EOF
2037

    
2038
cat <<EOF >libavutil-uninstalled.pc
2039
prefix=
2040
exec_prefix=
2041
libdir=\${pcfiledir}/libavutil
2042
includedir=\${pcfiledir}/libavutil
2043

    
2044
Name: libavutil
2045
Description: FFmpeg utility library
2046
Version: $lavu_version
2047
Requires:
2048
Conflicts:
2049
Libs: \${libdir}/${LIBPREF}avutil${LIBSUF}
2050
Cflags: -I\${includedir}
2051
EOF
2052

    
2053
# libavcodec.pc
2054
cat <<EOF >libavcodec.pc
2055
prefix=$PREFIX
2056
exec_prefix=\${prefix}
2057
libdir=\${exec_prefix}/lib
2058
includedir=\${prefix}/include
2059

    
2060
Name: libavcodec
2061
Description: FFmpeg codec library
2062
Version: $lavc_version
2063
Requires: $pkg_requires libavutil = $lavu_version
2064
Conflicts:
2065
Libs: -L\${libdir} -lavcodec $extralibs
2066
Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2067
EOF
2068

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

    
2075
Name: libavcodec
2076
Description: FFmpeg codec library
2077
Version: $lavc_version
2078
Requires: $pkg_requires libavutil = $lavu_version
2079
Conflicts:
2080
Libs: \${libdir}/${LIBPREF}avcodec${LIBSUF} $extralibs
2081
Cflags: -I\${includedir}
2082
EOF
2083

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

    
2091
Name: libavformat
2092
Description: FFmpeg container format library
2093
Version: $lavf_version
2094
Requires: $pkg_requires libavcodec = $lavc_version
2095
Conflicts:
2096
Libs: -L\${libdir} -lavformat $extralibs
2097
Cflags: -I\${includedir} -I\${includedir}/ffmpeg
2098
EOF
2099

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

    
2106
Name: libavformat
2107
Description: FFmpeg container format library
2108
Version: $lavf_version
2109
Requires: $pkg_requires libavcodec = $lavc_version
2110
Conflicts:
2111
Libs: \${libdir}/${LIBPREF}avformat${LIBSUF} $extralibs
2112
Cflags: -I\${includedir}
2113
EOF
2114

    
2115

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

    
2123
Name: libpostproc
2124
Description: FFmpeg post processing library
2125
Version: $lavc_version
2126
Requires:
2127
Conflicts:
2128
Libs: -L\${libdir} -lpostproc
2129
Cflags: -I\${includedir} -I\${includedir}/postproc
2130
EOF
2131

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

    
2138
Name: libpostproc
2139
Description: FFmpeg post processing library
2140
Version: $lavc_version
2141
Requires:
2142
Conflicts:
2143
Libs: \${libdir}/${LIBPREF}postproc${LIBSUF}
2144
Cflags: -I\${includedir}
2145
EOF
2146

    
2147
if test "$swscaler" != "no"; then
2148
  sws_pc_libs="-L\${libdir} -lswscale"
2149
  sws_pc_uninstalled_libs="\${libdir}/${LIBPREF}swscale${LIBSUF}"
2150
  sws_pc_requires="$pkg_requires libavutil = $lavu_version"
2151
else
2152
  sws_pc_libs=""
2153
  sws_pc_uninstalled_libs=""
2154
  sws_pc_requires="$pkg_requires libavcodec = $lavc_version"
2155
fi
2156
# libswscale.pc
2157
cat <<EOF >libswscale.pc
2158
prefix=$PREFIX
2159
exec_prefix=\${prefix}
2160
libdir=\${exec_prefix}/lib
2161
includedir=\${prefix}/include
2162

    
2163
Name: libswscale
2164
Description: FFmpeg image rescaling library
2165
Version: $sws_version
2166
Requires: $sws_pc_requires
2167
Conflicts:
2168
Libs: $sws_pc_libs
2169
Cflags: -I\${includedir} -I\${includedir}/swscale
2170
EOF
2171

    
2172
cat <<EOF >libswscale-uninstalled.pc
2173
prefix=
2174
exec_prefix=
2175
libdir=\${pcfiledir}/libswscale
2176
includedir=\${pcfiledir}/libswscale
2177

    
2178
Name: libswscale
2179
Description: FFmpeg image rescaling library
2180
Version: $sws_version
2181
Requires: $sws_pc_requires
2182
Conflicts:
2183
Libs: $sws_pc_uninstalled_libs
2184
Cflags: -I\${includedir}
2185
EOF