Statistics
| Branch: | Revision:

ffmpeg / configure @ b4e806b2

History | View | Annotate | Download (63.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
    echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
44
    echo "Instead, install a working POSIX-compatible shell."
45
    echo "Disabling this configure test will create a broken FFmpeg."
46
    if test "$BASH_VERSION" = '2.04.0(1)-release'; then
47
        echo "This bash version ($BASH_VERSION) is broken on your platform."
48
        echo "Upgrade to a later version if available."
49
    fi
50
    exit 1
51
fi
52

    
53
show_help(){
54
  echo "Usage: configure [options]"
55
  echo "Options: [defaults in brackets after descriptions]"
56
  echo
57
  echo "Standard options:"
58
  echo "  --help                   print this message"
59
  echo "  --log[=FILE|yes|no]      log tests and output to FILE [config.err]"
60
  echo "  --prefix=PREFIX          install in PREFIX [$PREFIX]"
61
  echo "  --libdir=DIR             install libs in DIR [PREFIX/lib]"
62
  echo "  --shlibdir=DIR           install shared libs in DIR [PREFIX/lib]"
63
  echo "  --incdir=DIR             install includes in DIR [PREFIX/include]"
64
  echo "  --mandir=DIR             install man page in DIR [PREFIX/share/man]"
65
  echo "  --enable-static          build static libraries [default=yes]"
66
  echo "  --disable-static         do not build static libraries [default=no]"
67
  echo "  --enable-shared          build shared libraries [default=no]"
68
  echo "  --disable-shared         do not build shared libraries [default=yes]"
69
  echo "  --enable-gpl             allow use of GPL code, the resulting libav*"
70
  echo "                           and ffmpeg will be under GPL [default=no]"
71
  echo "  --enable-nonfree         allow use of nonfree code, the resulting libav*"
72
  echo "                           and ffmpeg will be unredistributable [default=no]"
73
  echo "  --enable-postproc        enable GPLed postprocessing support [default=no]"
74
  echo "  --enable-swscale         software scaler support [default=no]"
75
  echo "  --enable-avfilter        video filter support (replaces vhook) [default=no]"
76
  echo "  --enable-avfilter-lavf   video filters dependant on avformat [default=no]"
77
  echo "  --enable-beosthreads     use BeOS threads [default=no]"
78
  echo "  --enable-os2threads      use OS/2 threads [default=no]"
79
  echo "  --enable-pthreads        use pthreads [default=no]"
80
  echo "  --enable-w32threads      use Win32 threads [default=no]"
81
  echo "  --enable-x11grab         enable X11 grabbing [default=no]"
82
  echo
83
  echo "External library support:"
84
  echo "  --enable-sunmlib         use Sun medialib [default=no]"
85
  echo "  --enable-liba52          enable GPLed liba52 support [default=no]"
86
  echo "  --enable-liba52bin       open liba52.so.0 at runtime [default=no]"
87
  echo "  --enable-avisynth        allow reading AVISynth script files [default=no]"
88
  echo "  --enable-libamr-nb       enable libamr-nb floating point audio codec"
89
  echo "  --enable-libamr-wb       enable libamr-wb floating point audio codec"
90
  echo "  --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394"
91
  echo "                           and libraw1394 [default=no]"
92
  echo "  --enable-libfaac         enable FAAC support via libfaac [default=no]"
93
  echo "  --enable-libfaad         enable FAAD support via libfaad [default=no]"
94
  echo "  --enable-libfaadbin      open libfaad.so.0 at runtime [default=no]"
95
  echo "  --enable-libgsm          enable GSM support via libgsm [default=no]"
96
  echo "  --enable-libmp3lame      enable MP3 encoding via libmp3lame [default=no]"
97
  echo "  --enable-libnut          enable NUT (de)muxing via libnut,"
98
  echo "                           native demuxer exists [default=no]"
99
  echo "  --enable-libtheora       enable Theora encoding via libtheora [default=no]"
100
  echo "  --enable-libvorbis       enable Vorbis encoding via libvorbis,"
101
  echo "                           native implementation exists [default=no]"
102
  echo "  --enable-libx264         enable H.264 encoding via x264 [default=no]"
103
  echo "  --enable-libxvid         enable Xvid encoding via xvidcore,"
104
  echo "                           native MPEG-4/Xvid encoder exists [default=no]"
105
  echo ""
106
  echo "Advanced options (experts only):"
107
  echo "  --source-path=PATH       path to source code [$source_path]"
108
  echo "  --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]"
109
  echo "  --cross-compile          assume a cross-compiler is used"
110
  echo "  --target-os=OS           compiler targets OS [$targetos]"
111
  echo "  --cc=CC                  use C compiler CC [$cc]"
112
  echo "  --make=MAKE              use specified make [$make]"
113
  echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
114
  echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
115
  echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
116
  echo "  --build-suffix=SUFFIX    suffix for application specific build []"
117
  echo "  --arch=ARCH              select architecture  [$arch]"
118
  echo "  --cpu=CPU                selects the minimum cpu required (affects"
119
  echo "                           instruction selection, may crash on older CPUs)"
120
  echo "  --enable-powerpc-perf    enable performance report on PPC"
121
  echo "                           (requires enabling PMC)"
122
  echo "  --disable-mmx            disable MMX usage"
123
  echo "  --disable-mmx2           disable MMX2 usage"
124
  echo "  --disable-ssse3          disable SSSE3 usage"
125
  echo "  --disable-armv5te        disable armv5te usage"
126
  echo "  --disable-armv6          disable armv6 usage"
127
  echo "  --disable-iwmmxt         disable iwmmxt usage"
128
  echo "  --disable-altivec        disable AltiVec usage"
129
  echo "  --disable-network        disable network support [default=no]"
130
  echo "  --disable-ipv6           disable ipv6 support [default=no]"
131
  echo "  --disable-zlib           disable zlib [default=no]"
132
  echo "  --disable-vhook          disable video hooking support"
133
  echo "  --disable-debug          disable debugging symbols"
134
  echo "  --disable-mpegaudio-hp   faster (but less accurate)"
135
  echo "                           MPEG audio decoding [default=no]"
136
  echo "  --enable-gray            enable full grayscale support (slower color)"
137
  echo "  --disable-ffmpeg         disable ffmpeg build"
138
  echo "  --disable-ffserver       disable ffserver build"
139
  echo "  --disable-ffplay         disable ffplay build"
140
  echo "  --enable-small           optimize for size instead of speed"
141
  echo "  --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
142
  echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
143
  echo "  --disable-encoder=NAME   disables encoder NAME"
144
  echo "  --enable-encoder=NAME    enables encoder NAME"
145
  echo "  --disable-decoder=NAME   disables decoder NAME"
146
  echo "  --enable-decoder=NAME    enables decoder NAME"
147
  echo "  --disable-encoders       disables all encoders"
148
  echo "  --disable-decoders       disables all decoders"
149
  echo "  --disable-muxer=NAME     disables muxer NAME"
150
  echo "  --enable-muxer=NAME      enables muxer NAME"
151
  echo "  --disable-muxers         disables all muxers"
152
  echo "  --disable-demuxer=NAME   disables demuxer NAME"
153
  echo "  --enable-demuxer=NAME    enables demuxer NAME"
154
  echo "  --disable-demuxers       disables all demuxers"
155
  echo "  --enable-parser=NAME     enables parser NAME"
156
  echo "  --disable-parser=NAME    disables parser NAME"
157
  echo "  --disable-parsers        disables all parsers"
158
  echo "  --enable-bsf=NAME        enables bitstream filter NAME"
159
  echo "  --disable-bsf=NAME       disables bitstream filter NAME"
160
  echo "  --disable-bsfs           disables all bitstream filters"
161
  echo "  --enable-protocol=NAME   enables protocol NAME"
162
  echo "  --disable-protocol=NAME  disables protocol NAME"
163
  echo "  --disable-protocols      disables all protocols"
164
  echo "  --disable-devices        disables all devices"
165
  echo "  --list-decoders          show all available decoders"
166
  echo "  --list-encoders          show all available encoders"
167
  echo "  --list-muxers            show all available muxers"
168
  echo "  --list-demuxers          show all available demuxers"
169
  echo "  --list-parsers           show all available parsers"
170
  echo "  --list-protocols         show all available protocols"
171
  echo "  --list-bsfs              show all available bitstream filters"
172
  echo "  --list-indevs            show all available input devices"
173
  echo "  --list-outdevs           show all available output devices"
174
  echo
175
  echo "Developer options (useful when working on FFmpeg itself):"
176
  echo "  --enable-gprof           enable profiling with gprof [$gprof]"
177
  echo "  --disable-optimizations  disable compiler optimizations"
178
  echo "  --enable-extra-warnings  enable more compiler warnings"
179
  echo "  --disable-strip          disable stripping of executables and shared libraries"
180
  echo ""
181
  echo "NOTE: Object files are built at the place where configure is launched."
182
  exit 1
183
}
184

    
185
log(){
186
    echo "$@" >>$logfile
187
}
188

    
189
log_file(){
190
    log BEGIN $1
191
    pr -n -t $1 >>$logfile
192
    log END $1
193
}
194

    
195
echolog(){
196
    log "$@"
197
    echo "$@"
198
}
199

    
200
die(){
201
    echolog "$@"
202
    cat <<EOF
203
If you think configure made a mistake, make sure you are using the latest
204
version from SVN.  If the latest version fails, report the problem to the
205
ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
206
EOF
207
    if enabled logging; then
208
        cat <<EOF
209
Include the log file "$logfile" produced by configure as this will help
210
solving the problem.
211
EOF
212
    else
213
cat <<EOF
214
Rerun configure with logging enabled (do not use --log=no), and include the
215
log this produces with your report.
216
EOF
217
    fi
218
    rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
219
    exit 1
220
}
221

    
222
# Avoid locale weirdness, besides we really just want to translate ASCII.
223
toupper(){
224
    echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
225
}
226

    
227
tolower(){
228
    echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
229
}
230

    
231
set_all(){
232
    value=$1
233
    shift
234
    for var in $*; do
235
        eval $var=$value
236
    done
237
}
238

    
239
pushvar(){
240
    for var in $*; do
241
        eval level=\${${var}_level:=0}
242
        eval ${var}_${level}="\$$var"
243
        eval ${var}_level=$(($level+1))
244
    done
245
}
246

    
247
popvar(){
248
    for var in $*; do
249
        eval level=\${${var}_level:-0}
250
        test $level = 0 && continue
251
        eval level=$(($level-1))
252
        eval $var="\${${var}_${level}}"
253
        eval ${var}_level=$level
254
        eval unset ${var}_${level}
255
    done
256
}
257

    
258
enable(){
259
    set_all yes $*
260
}
261

    
262
disable(){
263
    set_all no $*
264
}
265

    
266
enabled(){
267
    eval test "x\$$1" = "xyes"
268
}
269

    
270
disabled(){
271
    eval test "x\$$1" = "xno"
272
}
273

    
274
enabled_all(){
275
    for opt; do
276
        enabled $opt || return 1
277
    done
278
}
279

    
280
disabled_all(){
281
    for opt; do
282
        disabled $opt || return 1
283
    done
284
}
285

    
286
enabled_any(){
287
    for opt; do
288
        enabled $opt && return 0
289
    done
290
}
291

    
292
disabled_any(){
293
    for opt; do
294
        disabled $opt && return 0
295
    done
296
}
297

    
298
is_in(){
299
    value=$1
300
    shift
301
    for var in $*; do
302
        [ $var = $value ] && return 0
303
    done
304
    return 1
305
}
306

    
307
check_deps(){
308
    for cfg; do
309
        enabled ${cfg}_checking && die "Circular dependency for $cfg."
310
        disabled ${cfg}_checking && continue
311
        enable ${cfg}_checking
312

    
313
        eval dep_all="\$${cfg}_deps"
314
        eval dep_any="\$${cfg}_deps_any"
315

    
316
        pushvar cfg dep_all dep_any
317
        check_deps $dep_all $dep_any
318
        popvar cfg dep_all dep_any
319

    
320
        enabled_all $dep_all || disable $cfg
321
        enabled_any $dep_any || disable $cfg
322

    
323
        if enabled $cfg; then
324
            eval dep_extralibs="\$${cfg}_extralibs"
325
            test -n "$dep_extralibs" && add_extralibs $dep_extralibs
326
        fi
327

    
328
        disable ${cfg}_checking
329
    done
330
}
331

    
332
print_config(){
333
    pfx=$1
334
    header=$2
335
    makefile=$3
336
    shift 3
337
    for cfg; do
338
        ucname="`toupper $cfg`"
339
        if enabled $cfg; then
340
            echo "#define ${pfx}${ucname} 1" >> $header
341
            echo "#define ENABLE_${ucname} 1" >> $header
342
            echo "${pfx}${ucname}=yes" >> $makefile
343
        else
344
            echo "#define ENABLE_${ucname} 0" >> $header
345
        fi
346
    done
347
}
348

    
349
flags_saved(){
350
    (: ${SAVE_CFLAGS?}) 2>/dev/null
351
}
352

    
353
save_flags(){
354
    flags_saved && return
355
    SAVE_CFLAGS="$CFLAGS"
356
    SAVE_LDFLAGS="$LDFLAGS"
357
    SAVE_extralibs="$extralibs"
358
}
359

    
360
restore_flags(){
361
    flags_saved || return
362
    CFLAGS="$SAVE_CFLAGS"
363
    LDFLAGS="$SAVE_LDFLAGS"
364
    extralibs="$SAVE_extralibs"
365
    unset SAVE_CFLAGS
366
    unset SAVE_LDFLAGS
367
    unset SAVE_extralibs
368
}
369

    
370
temp_cflags(){
371
    save_flags
372
    CFLAGS="$CFLAGS $*"
373
}
374

    
375
temp_ldflags(){
376
    save_flags
377
    LDFLAGS="$LDFLAGS $*"
378
}
379

    
380
temp_extralibs(){
381
    save_flags
382
    extralibs="$extralibs $*"
383
}
384

    
385
append(){
386
    var=$1
387
    shift
388
    flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
389
    eval "$var=\"\$$var $*\""
390
}
391

    
392
add_cflags(){
393
    append CFLAGS "$@"
394
}
395

    
396
add_ldflags(){
397
    append LDFLAGS "$@"
398
}
399

    
400
add_extralibs(){
401
    append extralibs "$@"
402
}
403

    
404
check_cmd(){
405
    log "$@"
406
    "$@" >>$logfile 2>&1
407
}
408

    
409
check_cc(){
410
    log check_cc "$@"
411
    cat >$TMPC
412
    log_file $TMPC
413
    check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
414
}
415

    
416
check_cpp(){
417
    log check_cpp "$@"
418
    cat >$TMPC
419
    log_file $TMPC
420
    check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
421
}
422

    
423
check_asm(){
424
    log check_asm "$@"
425
    name="$1"
426
    asm="$2"
427
    shift 2
428
    check_cc "$@" <<EOF && enable $name || disable $name
429
int foo(void){
430
    asm volatile($asm);
431
}
432
EOF
433
}
434

    
435
check_ld(){
436
    log check_ld "$@"
437
    check_cc || return
438
    flags=''
439
    libs=''
440
    for f; do
441
        test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
442
    done
443
    check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
444
}
445

    
446
check_cflags(){
447
    log check_cflags "$@"
448
    check_cc "$@" <<EOF && add_cflags "$@"
449
int x;
450
EOF
451
}
452

    
453
check_ldflags(){
454
    log check_ldflags "$@"
455
    check_ld "$@" <<EOF && add_ldflags "$@"
456
int main(void){
457
    return 0;
458
}
459
EOF
460
}
461

    
462
check_header(){
463
    log check_header "$@"
464
    header=$1
465
    shift
466
    var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
467
    disable $var
468
    check_cpp "$@" <<EOF && enable $var
469
#include <$header>
470
int x;
471
EOF
472
}
473

    
474
check_func(){
475
    log check_func "$@"
476
    func=$1
477
    shift
478
    disable $func
479
    check_ld "$@" <<EOF && enable $func
480
extern int $func();
481
int main(void){
482
    $func();
483
}
484
EOF
485
}
486

    
487
check_func2(){
488
    log check_func2 "$@"
489
    headers=$1
490
    func=$2
491
    shift 2
492
    disable $func
493
    incs=""
494
    for hdr in $headers; do
495
        incs="$incs
496
#include <$hdr>"
497
    done
498
    check_ld "$@" <<EOF && enable $func
499
$incs
500
int main(int argc, char **argv){
501
    (void) $func;
502
    return 0;
503
}
504
EOF
505
}
506

    
507
check_lib(){
508
    log check_lib "$@"
509
    header="$1"
510
    func="$2"
511
    shift 2
512
    temp_extralibs "$@"
513
    check_header $header && check_func $func && add_extralibs "$@"
514
    err=$?
515
    restore_flags
516
    return $err
517
}
518

    
519
check_lib2(){
520
    log check_lib2 "$@"
521
    headers="$1"
522
    func="$2"
523
    shift 2
524
    temp_extralibs "$@"
525
    check_func2 "$headers" $func && add_extralibs "$@"
526
    err=$?
527
    restore_flags
528
    return $err
529
}
530

    
531
check_exec(){
532
    check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
533
}
534

    
535
check_exec_crash(){
536
    code=`cat`
537

    
538
    # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
539
    # are safe but may not be available everywhere.  Thus we use
540
    # raise(SIGTERM) instead.  The check is run in a subshell so we
541
    # can redirect the "Terminated" message from the shell.  SIGBUS
542
    # is not defined by standard C so it is used conditionally.
543

    
544
    (check_exec "$@") >>$logfile 2>&1 <<EOF
545
#include <signal.h>
546
static void sighandler(int sig){
547
    raise(SIGTERM);
548
}
549
int main(void){
550
    signal(SIGILL, sighandler);
551
    signal(SIGFPE, sighandler);
552
    signal(SIGSEGV, sighandler);
553
#ifdef SIGBUS
554
    signal(SIGBUS, sighandler);
555
#endif
556
    { $code }
557
}
558
EOF
559
}
560

    
561
check_type(){
562
    log check_type "$@"
563
    headers=$1
564
    type=$2
565
    shift 2
566
    disable $type
567
    incs=""
568
    for hdr in $headers; do
569
        incs="$incs
570
#include <$hdr>"
571
    done
572
    check_cc "$@" <<EOF && enable $type
573
$incs
574
$type v;
575
EOF
576
}
577

    
578
require(){
579
    name="$1"
580
    header="$2"
581
    func="$3"
582
    shift 3
583
    check_lib $header $func "$@" || die "ERROR: $name not found"
584
}
585

    
586
require2(){
587
    name="$1"
588
    headers="$2"
589
    func="$3"
590
    shift 3
591
    check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
592
}
593

    
594
check_foo_config(){
595
    cfg=$1
596
    pkg=$2
597
    header=$3
598
    func=$4
599
    shift 4
600
    disable $cfg
601
    check_cmd ${pkg}-config --version
602
    err=$?
603
    if test "$err" = 0; then
604
        temp_cflags `${pkg}-config --cflags`
605
        temp_extralibs `${pkg}-config --libs`
606
        check_lib "$@" $header $func && enable $cfg
607
    fi
608
    return $err
609
}
610

    
611
apply(){
612
    file=$1
613
    shift
614
    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
615
}
616

    
617
COMPONENT_LIST="
618
    bsfs
619
    decoders
620
    demuxers
621
    encoders
622
    filters
623
    indevs
624
    muxers
625
    outdevs
626
    parsers
627
    protocols
628
"
629

    
630
CONFIG_LIST="
631
    $COMPONENT_LIST
632
    avfilter
633
    avfilter_lavf
634
    avisynth
635
    beos_netserver
636
    ffmpeg
637
    ffplay
638
    ffserver
639
    gpl
640
    gprof
641
    gray
642
    hardcoded_tables
643
    ipv6
644
    liba52
645
    liba52bin
646
    libamr_nb
647
    libamr_wb
648
    libdc1394
649
    libfaac
650
    libfaad
651
    libfaadbin
652
    libgsm
653
    libmp3lame
654
    libnut
655
    libtheora
656
    libvorbis
657
    libx264
658
    libxvid
659
    memalign_hack
660
    mpegaudio_hp
661
    network
662
    nonfree
663
    postproc
664
    powerpc_perf
665
    small
666
    swscale
667
    vhook
668
    x11grab
669
    zlib
670
"
671

    
672
THREADS_LIST='
673
    beosthreads
674
    os2threads
675
    pthreads
676
    w32threads
677
'
678

    
679
ARCH_LIST='
680
    alpha
681
    armv4l
682
    bfin
683
    ia64
684
    m68k
685
    mips
686
    parisc
687
    powerpc
688
    s390
689
    sh4
690
    sparc
691
    sparc64
692
    x86
693
    x86_32
694
    x86_64
695
'
696

    
697
ARCH_EXT_LIST='
698
    altivec
699
    armv5te
700
    armv6
701
    iwmmxt
702
    mmi
703
    mmx
704
    mmx2
705
    ssse3
706
    vis
707
'
708

    
709
HAVE_LIST="
710
    $ARCH_EXT_LIST
711
    $THREADS_LIST
712
    altivec_h
713
    arpa_inet_h
714
    bswap
715
    byteswap_h
716
    closesocket
717
    cmov
718
    conio_h
719
    dcbzl
720
    dev_bktr_ioctl_bt848_h
721
    dev_bktr_ioctl_meteor_h
722
    dev_ic_bt8xx_h
723
    dev_video_meteor_ioctl_meteor_h
724
    dev_video_bktr_ioctl_bt848_h
725
    dlfcn_h
726
    dlopen
727
    ebp_available
728
    ebx_available
729
    fast_64bit
730
    fast_cmov
731
    fast_unaligned
732
    fork
733
    freetype2
734
    gethrtime
735
    GetProcessTimes
736
    getrusage
737
    imlib2
738
    inet_aton
739
    inline_asm
740
    libdc1394_1
741
    libdc1394_2
742
    llrint
743
    lrint
744
    lrintf
745
    machine_ioctl_bt848_h
746
    machine_ioctl_meteor_h
747
    malloc_h
748
    memalign
749
    mkstemp
750
    mlib
751
    pld
752
    ppc64
753
    round
754
    roundf
755
    sdl
756
    sdl_video_size
757
    socklen_t
758
    soundcard_h
759
    poll_h
760
    sys_mman_h
761
    sys_select_h
762
    sys_soundcard_h
763
    termios_h
764
    threads
765
    winsock2_h
766
"
767

    
768
CMDLINE_SELECT="
769
    $ARCH_EXT_LIST
770
    $CONFIG_LIST
771
    $THREADS_LIST
772
    debug
773
    extra_warnings
774
    optimizations
775
    shared
776
    static
777
"
778

    
779
# code dependency declarations
780

    
781
# architecture extensions
782
altivec_deps="powerpc"
783
armv5te_deps="armv4l"
784
armv6_deps="armv4l"
785
iwmmxt_deps="armv4l"
786
mmi_deps="mips"
787
mmx_deps="x86"
788
mmx2_deps="x86"
789
ssse3_deps="x86"
790
vis_deps="sparc"
791

    
792
# decoders / encoders
793
ac3_decoder_deps="gpl"
794
dxa_decoder_deps="zlib"
795
flashsv_decoder_deps="zlib"
796
flashsv_encoder_deps="zlib"
797
mpeg_xvmc_decoder_deps="xvmc"
798
png_decoder_deps="zlib"
799
png_encoder_deps="zlib"
800
zmbv_decoder_deps="zlib"
801
zmbv_encoder_deps="zlib"
802

    
803
# external libraries
804
liba52_decoder_deps="liba52"
805
liba52bin_decoder_extralibs='$ldl'
806
libamr_nb_decoder_deps="libamr_nb"
807
libamr_nb_encoder_deps="libamr_nb"
808
libamr_wb_decoder_deps="libamr_wb"
809
libamr_wb_encoder_deps="libamr_wb"
810
libfaac_encoder_deps="libfaac"
811
libfaad_decoder_deps="libfaad"
812
libfaadbin_decoder_extralibs='$ldl'
813
libgsm_decoder_deps="libgsm"
814
libgsm_encoder_deps="libgsm"
815
libgsm_ms_decoder_deps="libgsm"
816
libgsm_ms_encoder_deps="libgsm"
817
libmp3lame_encoder_deps="libmp3lame"
818
libtheora_encoder_deps="libtheora"
819
libvorbis_encoder_deps="libvorbis"
820
libx264_encoder_deps="libx264"
821
libxvid_encoder_deps="libxvid"
822
mpeg4aac_decoder_deps="libfaad"
823

    
824
# demuxers / muxers
825
ac3_demuxer_deps="ac3_parser"
826
audio_beos_demuxer_deps="audio_beos"
827
audio_beos_demuxer_extralibs="-lmedia -lbe"
828
audio_beos_muxer_deps="audio_beos"
829
audio_beos_muxer_extralibs="-lmedia -lbe"
830
avisynth_demuxer_deps="avisynth"
831
bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
832
dv1394_demuxer_deps="dv1394 dv_demuxer"
833
libdc1394_demuxer_deps="libdc1394"
834
libnut_demuxer_deps="libnut"
835
libnut_muxer_deps="libnut"
836
mp3_demuxer_deps="mpegaudio_parser"
837
oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
838
oss_muxer_deps_any="soundcard_h sys_soundcard_h"
839
redir_demuxer_deps="network"
840
rtp_muxer_deps="network rtp_protocol"
841
rtsp_demuxer_deps="sdp_demuxer"
842
sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
843
v4l2_demuxer_deps="linux_videodev2_h"
844
v4l_demuxer_deps="linux_videodev_h"
845
vfwcap_demuxer_deps="capCreateCaptureWindow"
846
vfwcap_demuxer_extralibs="-lvfw32"
847
x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
848
x11_grab_device_demuxer_extralibs="-lX11 -lXext"
849

    
850
# protocols
851
http_protocol_deps="network"
852
rtp_protocol_deps="udp_protocol"
853
tcp_protocol_deps="network"
854
udp_protocol_deps="network"
855

    
856
# filters
857
movie_filter_deps="avfilter_lavf"
858

    
859
# programs
860
ffplay_deps="sdl"
861
ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
862
ffserver_extralibs='$ldl'
863
vhook_extralibs='$ldl'
864

    
865

    
866
# set temporary file name
867
if test ! -z "$TMPDIR" ; then
868
    TMPDIR1="${TMPDIR}"
869
elif test ! -z "$TEMPDIR" ; then
870
    TMPDIR1="${TEMPDIR}"
871
else
872
    TMPDIR1="/tmp"
873
fi
874

    
875
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
876
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
877
TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
878
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
879
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
880

    
881
# default parameters
882

    
883
enable logging
884
logfile="config.err"
885

    
886
# installation paths
887
PREFIX="/usr/local"
888
libdir='$(PREFIX)/lib'
889
shlibdir="$libdir"
890
incdir='$(PREFIX)/include'
891
mandir='$(PREFIX)/share/man'
892
bindir='$(PREFIX)/bin'
893

    
894
# toolchain
895
cc="gcc"
896
ar="ar"
897
nm="nm"
898
ranlib="ranlib"
899
make="make"
900
strip="strip"
901
asmalign_pot="unknown"
902
ln_s="ln -sf"
903

    
904
# machine
905
arch=`uname -m`
906
cpu="generic"
907

    
908
# OS
909
targetos=$(tolower $(uname -s))
910

    
911
# libraries
912
enable zlib
913

    
914
# configurable options
915
enable debug
916
enable dostrip
917
enable ffmpeg
918
enable ffplay
919
enable ffserver
920
enable ipv6
921
enable static
922
enable mpegaudio_hp
923
enable network
924
enable optimizations
925
enable protocols
926
vhook="default"
927

    
928
# build settings
929
SHFLAGS='-shared -Wl,-soname,$@'
930
VHOOKSHFLAGS='$(SHFLAGS)'
931
LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
932
FFSERVERLDFLAGS=-Wl,-E
933
LIBPREF="lib"
934
LIBSUF=".a"
935
FULLNAME='$(NAME)$(BUILDSUF)'
936
LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
937
SLIBPREF="lib"
938
SLIBSUF=".so"
939
SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
940
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
941
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
942
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
943

    
944
# gcc stupidly only outputs the basename of targets with -MM
945
DEPEND_CMD='$(CC) -MM $(CFLAGS) $(filter-out %.h,$^) | sed "s,[0-9a-z._-]*: \($(SRC_DIR)/\)*\([a-z0-9]*/\)[^/]* ,\\2&,"'
946
VHOOK_DEPEND_CMD='$(CC) -MM $(VHOOKCFLAGS) $(filter-out %.h,$^) | sed "s,^\([a-z]\),vhook/\\1,"'
947

    
948
# find source path
949
source_path="`dirname \"$0\"`"
950
enable source_path_used
951
if test -z "$source_path" -o "$source_path" = "." ; then
952
    source_path="`pwd`"
953
    disable source_path_used
954
else
955
    source_path="`cd \"$source_path\"; pwd`"
956
    echo "$source_path" | grep -q '[[:blank:]]' &&
957
        die "Out of tree builds are impossible with whitespace in source path."
958
fi
959

    
960
FFMPEG_CONFIGURATION="$@"
961

    
962
find_things(){
963
    thing=$1
964
    pattern=$2
965
    file=$source_path/$3
966
    sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
967
}
968

    
969
ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
970
DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
971
PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
972
BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
973
MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
974
DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
975
OUTDEV_LIST=$(find_things   muxer    _MUX     libavdevice/alldevices.c)
976
INDEV_LIST=$(find_things    demuxer  DEMUX    libavdevice/alldevices.c)
977
PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
978
FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
979

    
980
enable $ARCH_EXT_LIST \
981
       $DECODER_LIST \
982
       $ENCODER_LIST \
983
       $PARSER_LIST \
984
       $BSF_LIST \
985
       $DEMUXER_LIST \
986
       $MUXER_LIST \
987
       $FILTER_LIST \
988
       $PROTOCOL_LIST \
989
       $INDEV_LIST \
990
       $OUTDEV_LIST \
991

    
992
die_unknown(){
993
    echo "Unknown option \"$1\"."
994
    echo "See $0 --help for available options."
995
    exit 1
996
}
997

    
998
show_list() {
999
    suffix=_$1
1000
    shift
1001
    echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
1002
    exit 0
1003
}
1004

    
1005
for opt do
1006
    optval="${opt#*=}"
1007
    case "$opt" in
1008
    --log)
1009
    ;;
1010
    --log=*) logging="$optval"
1011
    ;;
1012
    --prefix=*) PREFIX="$optval"
1013
    ;;
1014
    --libdir=*) libdir="$optval"
1015
    ;;
1016
    --shlibdir=*) shlibdir="$optval"
1017
    ;;
1018
    --incdir=*) incdir="$optval"
1019
    ;;
1020
    --mandir=*) mandir="$optval"
1021
    ;;
1022
    --source-path=*) source_path="$optval"
1023
    ;;
1024
    --cross-prefix=*) cross_prefix="$optval"
1025
    ;;
1026
    --cross-compile) enable cross_compile
1027
    ;;
1028
    --target-os=*) targetos="$optval"
1029
    ;;
1030
    --cc=*) cc="$optval"
1031
    ;;
1032
    --make=*) make="$optval"
1033
    ;;
1034
    --extra-cflags=*) add_cflags "$optval"
1035
    ;;
1036
    --extra-ldflags=*) add_ldflags "$optval"
1037
    ;;
1038
    --extra-libs=*) add_extralibs "$optval"
1039
    ;;
1040
    --build-suffix=*) BUILDSUF="$optval"
1041
    ;;
1042
    --arch=*) arch="$optval"
1043
    ;;
1044
    --cpu=*) cpu="$optval"
1045
    ;;
1046
    --enable-sunmlib) enable mlib
1047
    ;;
1048
    --disable-strip) disable dostrip
1049
    ;;
1050
    --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
1051
    ;;
1052
    --enable-debug=*) debuglevel="$optval"
1053
    ;;
1054
    --enable-*=*|--disable-*=*)
1055
    eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
1056
    case "$thing" in
1057
        encoder|decoder|muxer|demuxer|parser|bsf|protocol|filter) $action ${optval}_${thing} ;;
1058
        *) die_unknown "$opt" ;;
1059
    esac
1060
    ;;
1061
    --enable-?*|--disable-?*)
1062
    eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
1063
    if is_in $option $COMPONENT_LIST; then
1064
        eval $action \$$(toupper ${option%s})_LIST
1065
    elif is_in $option $CMDLINE_SELECT; then
1066
        $action $option
1067
    else
1068
        die_unknown $opt
1069
    fi
1070
    ;;
1071
    --list-*)
1072
        NAME="${opt#--list-}"
1073
        is_in $NAME $COMPONENT_LIST || die_unknown $opt
1074
        NAME=${NAME%s}
1075
        eval show_list $NAME \$$(toupper $NAME)_LIST
1076
    ;;
1077
    --help|-h) show_help
1078
    ;;
1079
    *)
1080
    die_unknown $opt
1081
    ;;
1082
    esac
1083
done
1084

    
1085
case "$arch" in
1086
    i386|i486|i586|i686|i86pc|BePC)
1087
        arch="x86_32"
1088
        enable fast_unaligned
1089
    ;;
1090
    x86_64|amd64)
1091
        arch="x86_32"
1092
        enable fast_unaligned
1093
        canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
1094
        if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
1095
            if ! echo $CFLAGS | grep -q -- -m32; then
1096
                arch="x86_64"
1097
                enable fast_64bit
1098
            fi
1099
        fi
1100
    ;;
1101
    # armv4l is a subset of armv[567]*l
1102
    arm|armv[4567]*l)
1103
        arch="armv4l"
1104
    ;;
1105
    alpha)
1106
        arch="alpha"
1107
        enable fast_64bit
1108
    ;;
1109
    "Power Macintosh"|ppc|powerpc)
1110
        arch="powerpc"
1111
    ;;
1112
    ppc64)
1113
        arch="powerpc"
1114
        enable fast_64bit
1115
    ;;
1116
    mips|mipsel|IP*)
1117
        arch="mips"
1118
    ;;
1119
    sun4u|sparc64)
1120
        arch="sparc64"
1121
        enable fast_64bit
1122
    ;;
1123
    sparc)
1124
        arch="sparc"
1125
    ;;
1126
    sh4)
1127
        arch="sh4"
1128
    ;;
1129
    parisc)
1130
        arch="parisc"
1131
    ;;
1132
    parisc64)
1133
        arch="parisc"
1134
        enable fast_64bit
1135
    ;;
1136
    s390|s390x)
1137
        arch="s390"
1138
    ;;
1139
    m68k)
1140
        arch="m68k"
1141
    ;;
1142
    ia64)
1143
        arch="ia64"
1144
        enable fast_64bit
1145
    ;;
1146
    bfin)
1147
        arch="bfin"
1148
    ;;
1149
    *)
1150
        arch="unknown"
1151
    ;;
1152
esac
1153

    
1154
enable $arch
1155
enabled_any x86_32 x86_64 && enable x86
1156
enabled     sparc64       && enable sparc
1157

    
1158
# OS specific
1159
case $targetos in
1160
    beos|haiku|zeta)
1161
        PREFIX="$HOME/config"
1162
        # helps building libavcodec
1163
        add_cflags "-DPIC -fomit-frame-pointer"
1164
        # 3 gcc releases known for BeOS, each with ugly bugs
1165
        gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1166
        case "$gcc_version" in
1167
          2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1168
            disable mmx
1169
            ;;
1170
          *20010315*) echo "BeBits gcc"
1171
            add_cflags "-fno-expensive-optimizations"
1172
            ;;
1173
        esac
1174
        SHFLAGS=-nostart
1175
        # enable BeOS things
1176
        enable audio_beos
1177
        # no need for libm, but the inet stuff
1178
        # Check for BONE
1179
        # XXX: actually should check for NOT net_server
1180
        if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
1181
            network_extralibs="-lbind -lsocket"
1182
        else
1183
            enable beos_netserver
1184
            network_extralibs="-lnet"
1185
        fi ;;
1186
    sunos)
1187
        FFSERVERLDFLAGS=""
1188
        SHFLAGS='-shared -Wl,-h,$@'
1189
        network_extralibs="-lsocket -lnsl"
1190
        ;;
1191
    netbsd)
1192
        oss_demuxer_extralibs="-lossaudio"
1193
        oss_muxer_extralibs="-lossaudio"
1194
        ;;
1195
    openbsd)
1196
        disable need_memalign
1197
        LIBOBJFLAGS='$(PIC)'
1198
        SHFLAGS='-shared'
1199
        SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF).$(LIBVERSION)'
1200
        SLIBNAME_WITH_VERSION='$(SLIBNAME)'
1201
        SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
1202
        oss_demuxer_extralibs="-lossaudio"
1203
        oss_muxer_extralibs="-lossaudio"
1204
        ;;
1205
    freebsd)
1206
        disable need_memalign
1207
        ;;
1208
    bsd/os)
1209
        osextralibs="-lpoll -lgnugetopt"
1210
        strip="strip -d"
1211
        ;;
1212
    darwin)
1213
        disable need_memalign
1214
        SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
1215
        VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$@'
1216
        strip="strip -x"
1217
        FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1218
        SLIBSUF=".dylib"
1219
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
1220
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
1221
        FFSERVERLDFLAGS=-Wl,-bind_at_load
1222
        ;;
1223
    mingw32*)
1224
        targetos=mingw32
1225
        shlibdir="$bindir"
1226
        VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1227
        VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1228
        if enabled swscale; then
1229
            VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1230
            VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1231
        fi
1232
        disable ffserver
1233
        SLIBPREF=""
1234
        SLIBSUF=".dll"
1235
        EXESUF=".exe"
1236
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1237
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1238
        SLIB_EXTRA_CMD='-lib /machine:i386 /def:$(@:$(SLIBSUF)=.def)'
1239
        SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
1240
        SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
1241
        SHFLAGS='-shared -Wl,--output-def,$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
1242
        ;;
1243
    cygwin*)
1244
        targetos=cygwin
1245
        shlibdir="$bindir"
1246
        VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1247
        VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1248
        if enabled swscale; then
1249
            VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1250
            VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1251
        fi
1252
        EXESUF=".exe"
1253
        SLIBPREF="cyg"
1254
        SLIBSUF=".dll"
1255
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1256
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1257
        SHFLAGS='-shared -Wl,--enable-auto-image-base'
1258
        ;;
1259
    *-dos|freedos|opendos)
1260
        disable ffplay ffserver vhook
1261
        disable $INDEV_LIST $OUTDEV_LIST
1262
        network_extralibs="-lsocket"
1263
        EXESUF=".exe"
1264
        ;;
1265
    linux)
1266
        LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
1267
        enable dv1394
1268
        ;;
1269
    irix*)
1270
        targetos=irix
1271
        ranlib="echo ignoring ranlib"
1272
        ;;
1273
    os/2*)
1274
        strip="lxlite"
1275
        ln_s="cp -f"
1276
        EXESUF=".exe"
1277
        FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
1278
        SHFLAGS='$(NAME).def -Zdll -Zomf'
1279
        FFSERVERLDFLAGS=""
1280
        LIBSUF="_s.a"
1281
        SLIBPREF=""
1282
        SLIBSUF=".dll"
1283
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1284
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
1285
        SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(NAME).def; \
1286
          echo PROTMODE >> $(NAME).def; \
1287
          echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(NAME).def; \
1288
          echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(NAME).def; \
1289
          echo EXPORTS >> $(NAME).def; \
1290
          emxexp -o $(OBJS) >> $(NAME).def'
1291
        SLIB_EXTRA_CMD='emximp -o $(LIBPREF)$(NAME)_dll.a $(NAME).def; \
1292
          emximp -o $(LIBPREF)$(NAME)_dll.lib $(NAME).def;'
1293
        SLIB_INSTALL_EXTRA_CMD='install -m 644 $(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
1294
        SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
1295
        disable vhook
1296
        ;;
1297
    interix)
1298
        disable vhook
1299
        ;;
1300

    
1301
    *)
1302
        targetos="${targetos}-UNKNOWN"
1303
        ;;
1304
esac
1305

    
1306
add_extralibs $osextralibs
1307

    
1308
if ! disabled logging ; then
1309
    enabled logging || logfile="$logging"
1310
    echo "# $0 $@" >$logfile
1311
    set >>$logfile
1312
else
1313
    logfile=/dev/null
1314
fi
1315

    
1316
# Combine FFLDFLAGS and the LDFLAGS environment variable.
1317
LDFLAGS="$FFLDFLAGS $LDFLAGS"
1318

    
1319
test -n "$cross_prefix" && enable cross_compile
1320
cc="${cross_prefix}${cc}"
1321
ar="${cross_prefix}${ar}"
1322
nm="${cross_prefix}${nm}"
1323
ranlib="${cross_prefix}${ranlib}"
1324
strip="${cross_prefix}${strip}"
1325

    
1326
# we need to build at least one lib type
1327
if ! enabled_any static shared; then
1328
    cat <<EOF
1329
At least one library type must be built.
1330
Specify --enable-static to build the static libraries or --enable-shared to
1331
build the shared libraries as well. To only build the shared libraries specify
1332
--disable-static in addition to --enable-shared.
1333
EOF
1334
    exit 1;
1335
fi
1336

    
1337
disabled static && LIBNAME=""
1338

    
1339
if enabled_any libfaad libfaadbin ; then
1340
    if check_header faad.h; then
1341
        check_cc << EOF
1342
#include <faad.h>
1343
#ifndef FAAD2_VERSION
1344
ok faad1
1345
#endif
1346
int main(void) { return 0; }
1347
EOF
1348
        test $? = 0 && enable libfaad2
1349
    else
1350
        die "FAAD test failed."
1351
    fi
1352
fi
1353

    
1354

    
1355
if ! enabled gpl; then
1356
    die_gpl_disabled(){
1357
        name=$1
1358
        shift
1359
        enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
1360
    }
1361
    die_gpl_disabled "The Postprocessing code" postproc
1362
    die_gpl_disabled "liba52"                  liba52
1363
    die_gpl_disabled "libx264"                 libx264
1364
    die_gpl_disabled "libxvidcore"             libxvid
1365
    die_gpl_disabled "FAAD2"                   libfaad2
1366
    die_gpl_disabled "The X11 grabber"         x11grab
1367
    die_gpl_disabled "The software scaler"     swscale
1368
fi
1369

    
1370
if ! enabled nonfree && enabled_any libamr_nb libamr_wb; then
1371
    die "libamr is nonfree and --enable-nonfree is not specified."
1372
fi
1373

    
1374
check_deps $ARCH_EXT_LIST
1375

    
1376
test -z "$need_memalign" && need_memalign="$mmx"
1377

    
1378
#Darwin CC versions
1379
if test $targetos = darwin; then
1380
    if $cc -v 2>&1 | grep -q xlc; then
1381
        add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
1382
    else
1383
        add_cflags "-pipe"
1384
        check_cflags "-force_cpusubtype_ALL"
1385
        check_cflags "-Wno-sign-compare"
1386
        enabled shared || add_cflags -mdynamic-no-pic
1387
    fi
1388
fi
1389

    
1390
disabled optimizations || add_cflags -fomit-frame-pointer
1391

    
1392
# Add processor-specific flags
1393
if test $cpu != "generic"; then
1394
    warn_altivec(){
1395
        $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
1396
    }
1397
    case $cpu in
1398
        601|ppc601|PowerPC601)
1399
            add_cflags "-mcpu=601"
1400
            warn_altivec enabled PPC601
1401
        ;;
1402
        603*|ppc603*|PowerPC603*)
1403
            add_cflags "-mcpu=603"
1404
            warn_altivec enabled PPC603
1405
        ;;
1406
        604*|ppc604*|PowerPC604*)
1407
            add_cflags "-mcpu=604"
1408
            warn_altivec enabled PPC604
1409
        ;;
1410
        G3|g3|75*|ppc75*|PowerPC75*)
1411
            add_cflags "-mcpu=750 -mpowerpc-gfxopt"
1412
            warn_altivec enabled PPC75x
1413
        ;;
1414
        G4|g4|745*|ppc745*|PowerPC745*)
1415
            add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
1416
            warn_altivec disabled PPC745x
1417
        ;;
1418
        74*|ppc74*|PowerPC74*)
1419
            add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
1420
            warn_altivec disabled PPC74xx
1421
        ;;
1422
        G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1423
            add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1424
            warn_altivec disabled PPC970
1425
            enable ppc64
1426
        ;;
1427
        Cell|CELL|cell)
1428
            add_cflags "-mcpu=cell"
1429
            warn_altivec disabled Cell
1430
            enable ppc64
1431
        ;;
1432
        # targets that do NOT support conditional mov (cmov)
1433
        i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1434
            add_cflags "-march=$cpu"
1435
            disable cmov
1436
        ;;
1437
        # targets that do support conditional mov (cmov)
1438
        i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
1439
            add_cflags "-march=$cpu"
1440
            enable cmov
1441
            enable fast_cmov
1442
        ;;
1443
        # targets that do support conditional mov but on which it's slow
1444
        pentium4|pentium4m|prescott|nocona)
1445
            add_cflags "-march=$cpu"
1446
            enable cmov
1447
            disable fast_cmov
1448
        ;;
1449
        sparc64)
1450
            add_cflags "-mcpu=v9"
1451
        ;;
1452
        arm*)
1453
            add_cflags "-mcpu=$cpu"
1454
        ;;
1455
        *)
1456
            echo "WARNING: Unknown CPU \"$cpu\", ignored."
1457
        ;;
1458
    esac
1459
fi
1460

    
1461
gnu_make(){
1462
    $1 --version 2>&1 | grep -q GNU
1463
}
1464

    
1465
if ! gnu_make $make; then
1466
    gnu_make gmake && make=gmake || die "GNU make not found."
1467
fi
1468

    
1469
# make sure we can execute files in $TMPDIR
1470
cat >$TMPE 2>>$logfile <<EOF
1471
#! /bin/sh
1472
EOF
1473
chmod +x $TMPE >>$logfile 2>&1
1474
if ! $TMPE >>$logfile 2>&1; then
1475
    cat <<EOF
1476
Unable to create and execute files in $TMPDIR1.  Set the TMPDIR environment
1477
variable to another directory and make sure that $TMPDIR1 is not mounted
1478
noexec.
1479
EOF
1480
    die "Sanity test failed."
1481
fi
1482
rm $TMPE
1483

    
1484
# compiler sanity check
1485
check_exec <<EOF
1486
int main(void){
1487
    return 0;
1488
}
1489
EOF
1490
if test "$?" != 0; then
1491
    echo "$cc is unable to create an executable file."
1492
    if test -z "$cross_prefix" && ! enabled cross_compile ; then
1493
        echo "If $cc is a cross-compiler, use the --cross-compile option."
1494
        echo "Only do this if you know what cross compiling means."
1495
    fi
1496
    die "C compiler test failed."
1497
fi
1498

    
1499
check_cc <<EOF || die "Symbol mangling check failed."
1500
int ff_extern;
1501
EOF
1502
sym=$($nm -P -g $TMPO)
1503
extern_prefix=${sym%%ff_extern*}
1504

    
1505
check_asm inline_asm '""'
1506

    
1507
if enabled x86; then
1508
    # check whether EBP is available on x86
1509
    # As 'i' is stored on the stack, this program will crash
1510
    # if the base pointer is used to access it because the
1511
    # base pointer is cleared in the inline assembly code.
1512
    check_exec_crash <<EOF && enable ebp_available
1513
    volatile int i=0;
1514
    asm volatile (
1515
        "xorl %%ebp, %%ebp"
1516
    ::: "%ebp");
1517
    return i;
1518
EOF
1519

    
1520
    # check wether EBX is available on x86
1521
    check_asm ebx_available '"":::"%ebx"'
1522

    
1523
    # check whether binutils is new enough to compile SSSE3/MMX2
1524
    enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
1525
    enabled mmx2  && check_asm mmx2  '"movss %xmm0, %xmm0"'
1526

    
1527
    check_asm bswap '"bswap %%eax" ::: "%eax"'
1528
fi
1529

    
1530
# check for assembler specific support
1531

    
1532
if test $arch = "powerpc"; then
1533
check_cc <<EOF && enable dcbzl
1534
int main(void) {
1535
    register long zero = 0;
1536
    char data[1024];
1537
    asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
1538
return 0;
1539
}
1540
EOF
1541
fi
1542

    
1543
# check for SIMD availability
1544

    
1545
# AltiVec flags: The FSF version of GCC differs from the Apple version
1546
if enabled altivec; then
1547
    check_cflags -maltivec -mabi=altivec &&
1548
        check_header altivec.h ||
1549
        check_cflags -faltivec
1550

    
1551
    # check if our compiler supports Motorola AltiVec C API
1552
    enabled altivec_h &&
1553
        inc_altivec_h="#include <altivec.h>" ||
1554
        inc_altivec_h=
1555
    check_cc <<EOF || disable altivec
1556
$inc_altivec_h
1557
int main(void) {
1558
    vector signed int v1, v2, v3;
1559
    v1 = vec_add(v2,v3);
1560
    return 0;
1561
}
1562
EOF
1563
fi
1564

    
1565
# We have to check if pld is a nop and disable it.
1566
enabled armv4l  && check_asm pld     '"pld [r0]"'
1567
enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
1568
enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
1569
enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
1570
enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
1571
enabled vis     && check_asm vis     '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
1572

    
1573
enabled vis && add_cflags "-mcpu=ultrasparc -mtune=ultrasparc"
1574

    
1575
# ---
1576
# big/little-endian test
1577
check_cc <<EOF || die "endian test failed"
1578
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
1579
EOF
1580
od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
1581

    
1582
# ---
1583
# check availability of some header files
1584

    
1585
if check_func dlopen; then
1586
    ldl=
1587
elif check_func dlopen -ldl; then
1588
    ldl=-ldl
1589
fi
1590

    
1591
check_func  fork
1592
check_func  gethrtime
1593
check_func  getrusage
1594
check_func  inet_aton $network_extralibs
1595
check_func  memalign
1596
check_func  mkstemp
1597
check_func2 windows.h GetProcessTimes
1598

    
1599
check_header byteswap.h
1600
check_header conio.h
1601
check_header dlfcn.h
1602
check_header malloc.h
1603
check_header sys/mman.h
1604
check_header termios.h
1605

    
1606
if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
1607
    die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
1608
fi
1609

    
1610
enabled zlib && check_lib zlib.h zlibVersion -lz || disable zlib
1611

    
1612
# ffserver uses poll(),
1613
# if it's not found we can emulate it using select().
1614
if enabled ffserver; then
1615
    check_header poll.h
1616
    check_header sys/select.h
1617
fi
1618

    
1619
# check for some common methods of building with pthread support
1620
# do this before the optional library checks as some of them require pthreads
1621
if enabled pthreads; then
1622
    if check_func pthread_create; then
1623
        :
1624
    elif check_func pthread_create -pthread; then
1625
        add_cflags -pthread
1626
        add_extralibs -pthread
1627
    elif check_func pthread_create -pthreads; then
1628
        add_cflags -pthreads
1629
        add_extralibs -pthreads
1630
    elif ! check_lib pthread.h pthread_create -lpthread; then
1631
        die "ERROR: can't find pthreads library"
1632
    fi
1633
fi
1634

    
1635
for thread in $THREADS_LIST; do
1636
    if enabled $thread; then
1637
        test -n "$thread_type" &&
1638
            die "ERROR: Only one thread type must be selected." ||
1639
            thread_type="$thread"
1640
    fi
1641
done
1642

    
1643
check_lib math.h sin -lm
1644

    
1645
# test for C99 functions in math.h
1646
for func in llrint lrint lrintf round roundf; do
1647
    check_exec <<EOF && enable $func || disable $func
1648
#define _ISOC9X_SOURCE  1
1649
#include <math.h>
1650
int main(void) { return ($func(3.999f) > 0)?0:1; }
1651
EOF
1652
done
1653

    
1654
# these are off by default, so fail if requested and not available
1655
enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
1656
enabled liba52     && require  liba52 a52dec/a52.h a52_init -la52
1657
enabled libamr_nb  && require  libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
1658
enabled libamr_wb  && require  libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
1659
enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
1660
enabled libfaad    && require2 libfaad faad.h faacDecOpen -lfaad
1661
enabled libgsm     && require  libgsm gsm.h gsm_create -lgsm
1662
enabled libmp3lame && require  LAME lame/lame.h lame_init -lmp3lame -lm
1663
enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
1664
enabled libtheora  && require  libtheora theora/theora.h theora_info_init -ltheora -logg
1665
enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
1666
enabled libx264    && require  x264 x264.h x264_encoder_open -lx264 -lm
1667
enabled libxvid    && require  Xvid xvid.h xvid_global -lxvidcore
1668
enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
1669

    
1670
# disable the native AC-3 decoder if liba52 is enabled
1671
enabled liba52 && disable ac3_decoder
1672

    
1673
# libdc1394 check
1674
if enabled libdc1394; then
1675
    { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
1676
        enable libdc1394_2; } ||
1677
    { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
1678
        enable libdc1394_1; } ||
1679
    die "ERROR: No version of libdc1394 found "
1680
fi
1681

    
1682

    
1683
_restrict=
1684
for restrict_keyword in restrict __restrict__ __restrict; do
1685
    check_cc <<EOF && _restrict=$restrict_keyword && break
1686
void foo(char * $restrict_keyword p);
1687
EOF
1688
done
1689

    
1690
test "$vhook" = "default" && vhook="$dlopen"
1691

    
1692
if test "$targetos" = cygwin -o "$targetos" = mingw32 && enabled_all static vhook ; then
1693
    disable vhook
1694
    echo
1695
    echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
1696
    echo "Patches welcome."
1697
    echo
1698
fi
1699

    
1700
if enabled vhook; then
1701
    check_ldflags -rdynamic
1702
    check_ldflags -export-dynamic
1703
fi
1704

    
1705
check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
1706
check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
1707

    
1708
##########################################
1709
# SDL check
1710

    
1711
disable sdl_too_old
1712
disable sdl
1713
SDL_CONFIG="${cross_prefix}sdl-config"
1714
if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
1715
    sdl_cflags=`"${SDL_CONFIG}" --cflags`
1716
    temp_cflags $sdl_cflags
1717
    temp_extralibs `"${SDL_CONFIG}" --libs`
1718
    if check_lib2 SDL.h SDL_Init; then
1719
        _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
1720
        if test "$_sdlversion" -lt 121 ; then
1721
            enable sdl_too_old
1722
        else
1723
            enable sdl
1724
            check_cc $sdl_cflags <<EOF && enable sdl_video_size
1725
#include <SDL.h>
1726
int main(int argc, char **argv){
1727
    const SDL_VideoInfo *vi = SDL_GetVideoInfo();
1728
    int w = vi->current_w;
1729
    return 0;
1730
}
1731
EOF
1732
        fi
1733
    fi
1734
    restore_flags
1735
fi
1736

    
1737
texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
1738

    
1739
check_type sys/socket.h socklen_t
1740

    
1741
##########################################
1742
# Network check
1743

    
1744
if enabled network; then
1745
    # Prefer arpa/inet.h over winsock2
1746
    if check_header arpa/inet.h ; then
1747
        check_func closesocket
1748
    elif check_header winsock2.h ; then
1749
        network_extralibs="-lws2_32"
1750
        check_type ws2tcpip.h socklen_t
1751
        check_func2 winsock2.h closesocket
1752
    fi
1753
fi
1754

    
1755
##########################################
1756
# IPv6 check
1757

    
1758
enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
1759
#include <sys/types.h>
1760
#include <sys/socket.h>
1761
#include <netinet/in.h>
1762
#include <netdb.h>
1763
int main(void) {
1764
    struct sockaddr_storage saddr;
1765
    struct ipv6_mreq mreq6;
1766
    getaddrinfo(0,0,0,0);
1767
    getnameinfo(0,0,0,0,0,0,0);
1768
    IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
1769
}
1770
EOF
1771

    
1772
check_header linux/videodev.h
1773
check_header linux/videodev2.h
1774

    
1775
check_func2 "windows.h vfw.h" capCreateCaptureWindow -lvfw32
1776

    
1777
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1778
{ check_header dev/bktr/ioctl_meteor.h &&
1779
  check_header dev/bktr/ioctl_bt848.h; } ||
1780
{ check_header machine/ioctl_meteor.h &&
1781
  check_header machine/ioctl_bt848.h; } ||
1782
{ check_header dev/video/meteor/ioctl_meteor.h &&
1783
  check_header dev/video/bktr/ioctl_bt848.h; } ||
1784
check_header dev/ic/bt8xx.h
1785

    
1786
check_header sys/soundcard.h
1787
check_header soundcard.h
1788

    
1789
# deal with the X11 frame grabber
1790
enabled x11grab                         &&
1791
check_header X11/Xlib.h                 &&
1792
check_header X11/extensions/XShm.h      &&
1793
check_func XOpenDisplay -lX11           &&
1794
check_func XShmCreateImage -lX11 -lXext
1795

    
1796
enabled debug && add_cflags -g"$debuglevel"
1797

    
1798
# add some useful compiler flags if supported
1799
check_cflags -Wdeclaration-after-statement
1800
check_cflags -Wall
1801
check_cflags -Wno-switch
1802
check_cflags -Wdisabled-optimization
1803
check_cflags -Wpointer-arith
1804
check_cflags -Wredundant-decls
1805
check_cflags -Wno-pointer-sign
1806
check_cflags -Wcast-qual
1807
check_cflags -Wwrite-strings
1808
check_cflags -Wtype-limits
1809
enabled extra_warnings && check_cflags -Winline
1810

    
1811
# add some linker flags
1812
check_ldflags -Wl,--warn-common
1813
check_ldflags $LDLATEFLAGS
1814
check_ldflags -Wl,-Bsymbolic
1815

    
1816
if enabled small; then
1817
    check_cflags -Os            # not all compilers support -Os
1818
    optimizations="small"
1819
elif enabled optimizations; then
1820
    if $cc -v 2>&1 | grep -q xlc; then
1821
        add_cflags  "-O5"
1822
        add_ldflags "-O5"
1823
    else
1824
        add_cflags "-O3"
1825
    fi
1826
fi
1827
check_cflags -fno-math-errno
1828
check_cflags -fno-signed-zeros
1829

    
1830
# PIC flags for shared library objects where they are needed
1831
if enabled shared; then
1832
    # LIBOBJFLAGS may have already been set in the OS configuration
1833
    if test -z "$LIBOBJFLAGS" ; then
1834
        case "$arch" in
1835
            x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS='$(PIC)' ;;
1836
        esac
1837
    fi
1838
fi
1839

    
1840
if enabled gprof; then
1841
    add_cflags  "-p"
1842
    add_ldflags "-p"
1843
fi
1844

    
1845
VHOOKCFLAGS="-fPIC"
1846

    
1847
# Find out if the .align argument is a power of two or not.
1848
if test $asmalign_pot = "unknown"; then
1849
    disable asmalign_pot
1850
    echo 'asm (".align 3");' | check_cc && enable asmalign_pot
1851
fi
1852

    
1853
enabled_any $DECODER_LIST      && enable decoders
1854
enabled_any $ENCODER_LIST      && enable encoders
1855
enabled_any $BSF_LIST          && enable bsfs
1856
enabled_any $DEMUXER_LIST      && enable demuxers
1857
enabled_any $MUXER_LIST        && enable muxers
1858
enabled_any $FILTER_LIST       && enable filters
1859
enabled_any $INDEV_LIST        && enable demuxers
1860
enabled_any $OUTDEV_LIST       && enable muxers
1861
enabled_any $PROTOCOL_LIST     && enable protocols
1862

    
1863
enabled_any $THREADS_LIST      && enable threads
1864

    
1865
check_deps $CONFIG_LIST       \
1866
           $HAVE_LIST         \
1867
           $DECODER_LIST      \
1868
           $ENCODER_LIST      \
1869
           $PARSER_LIST       \
1870
           $BSF_LIST          \
1871
           $DEMUXER_LIST      \
1872
           $MUXER_LIST        \
1873
           $FILTER_LIST       \
1874
           $INDEV_LIST        \
1875
           $OUTDEV_LIST       \
1876
           $PROTOCOL_LIST     \
1877

    
1878
enabled libdc1394 && append pkg_requires "libraw1394"
1879
enabled libtheora && append pkg_requires "theora"
1880
enabled libvorbis && append pkg_requires "vorbisenc"
1881

    
1882
echo "install prefix            $PREFIX"
1883
echo "source path               $source_path"
1884
echo "C compiler                $cc"
1885
echo "make                      $make"
1886
echo ".align is power-of-two    $asmalign_pot"
1887
echo "ARCH                      $arch ($cpu)"
1888
if test "$BUILDSUF" != ""; then
1889
    echo "build suffix              $BUILDSUF"
1890
fi
1891
echo "big-endian                ${bigendian-no}"
1892
if test $arch = "x86_32" -o $arch = "x86_64"; then
1893
    echo "MMX enabled               ${mmx-no}"
1894
    echo "CMOV enabled              ${cmov-no}"
1895
    echo "CMOV is fast              ${fast_cmov-no}"
1896
    echo "EBX available             ${ebx_available-no}"
1897
    echo "EBP available             ${ebp_available-no}"
1898
fi
1899
if test $arch = "armv4l"; then
1900
    echo "ARMv5TE enabled           ${armv5te-no}"
1901
    echo "ARMv6 enabled             ${armv6-no}"
1902
    echo "IWMMXT enabled            ${iwmmxt-no}"
1903
fi
1904
if test $arch = "mips"; then
1905
    echo "MMI enabled               ${mmi-no}"
1906
fi
1907
if test $arch = "powerpc"; then
1908
    echo "AltiVec enabled           ${altivec-no}"
1909
    echo "dcbzl available           ${dcbzl-no}"
1910
fi
1911
echo "gprof enabled             ${gprof-no}"
1912
echo "debug symbols             ${debug-no}"
1913
echo "strip symbols             ${dostrip-no}"
1914
echo "optimizations             ${optimizations-no}"
1915
echo "static                    ${static-no}"
1916
echo "shared                    ${shared-no}"
1917
echo "postprocessing support    ${postproc-no}"
1918
echo "software scaler enabled   ${swscale-no}"
1919
echo "new filter support        ${avfilter-no}"
1920
echo "filters using lavformat   ${avfilter_lavf-no}"
1921
echo "video hooking             ${vhook-no}"
1922
if enabled vhook; then
1923
    echo "Imlib2 support            ${imlib2-no}"
1924
    echo "FreeType support          ${freetype2-no}"
1925
fi
1926
echo "network support           ${network-no}"
1927
if enabled network; then
1928
    echo "IPv6 support              ${ipv6-no}"
1929
fi
1930
echo "threading support         ${thread_type-no}"
1931
echo "SDL support               ${sdl-no}"
1932
if enabled sdl_too_old; then
1933
    echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
1934
fi
1935
echo "Sun medialib support      ${mlib-no}"
1936
echo "AVISynth enabled          ${avisynth-no}"
1937
echo "liba52 support            ${liba52-no}"
1938
echo "liba52 dlopened           ${liba52bin-no}"
1939
echo "libamr-nb support         ${libamr_nb-no}"
1940
echo "libamr-wb support         ${libamr_wb-no}"
1941
echo "libdc1394 support         ${libdc1394-no}"
1942
echo "libfaac enabled           ${libfaac-no}"
1943
echo "libfaad enabled           ${libfaad-no}"
1944
echo "libfaad dlopened          ${libfaadbin-no}"
1945
echo "libgsm enabled            ${libgsm-no}"
1946
echo "libmp3lame enabled        ${libmp3lame-no}"
1947
echo "libnut enabled            ${libnut-no}"
1948
echo "libtheora enabled         ${libtheora-no}"
1949
echo "libvorbis enabled         ${libvorbis-no}"
1950
echo "x264 enabled              ${libx264-no}"
1951
echo "XviD enabled              ${libxvid-no}"
1952
echo "zlib enabled              ${zlib-no}"
1953
echo
1954

    
1955
for type in decoder encoder parser demuxer muxer protocol filter bsf indev outdev; do
1956
    echo "Enabled ${type}s:"
1957
    eval list=\$$(toupper $type)_LIST
1958
    for part in $list; do
1959
        enabled $part && echo ${part%_*}
1960
    done | sort | pr -3 -t
1961
    echo
1962
done
1963

    
1964
enabled nonfree &&
1965
    echo "License: unredistributable" ||
1966
    (enabled gpl &&
1967
        echo "License: GPL" ||
1968
        echo "License: LGPL")
1969

    
1970
echo "Creating config.mak and config.h..."
1971

    
1972
echo "# Automatically generated by configure - do not modify!" > config.mak
1973
echo "/* Automatically generated by configure - do not modify! */" > $TMPH
1974
echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
1975
echo "#define FFMPEG_CONFIG_H" >> $TMPH
1976
echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
1977

    
1978
echo "PREFIX=$PREFIX" >> config.mak
1979
echo "prefix=\$(DESTDIR)\$(PREFIX)" >> config.mak
1980
echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
1981
echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
1982
echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
1983
echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
1984
echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
1985
echo "MAKE=$make" >> config.mak
1986
echo "CC=$cc" >> config.mak
1987
echo "AR=$ar" >> config.mak
1988
echo "RANLIB=$ranlib" >> config.mak
1989
echo "LN_S=$ln_s" >> config.mak
1990
enabled dostrip &&
1991
    echo "STRIP=$strip" >> config.mak ||
1992
    echo "STRIP=echo ignoring strip" >> config.mak
1993

    
1994
echo "OPTFLAGS=$CFLAGS" >> config.mak
1995
echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
1996
echo "LDFLAGS=$LDFLAGS" >> config.mak
1997
echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
1998
echo "SHFLAGS=$SHFLAGS" >> config.mak
1999
echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
2000
echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
2001
echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
2002
echo "BUILD_STATIC=$static" >> config.mak
2003
echo "BUILDSUF=$BUILDSUF" >> config.mak
2004
echo "FULLNAME=$FULLNAME" >> config.mak
2005
echo "LIBPREF=$LIBPREF" >> config.mak
2006
echo "LIBSUF=$LIBSUF" >> config.mak
2007
echo "LIBNAME=$LIBNAME" >> config.mak
2008
echo "SLIBPREF=$SLIBPREF" >> config.mak
2009
echo "SLIBSUF=$SLIBSUF" >> config.mak
2010
echo "EXESUF=$EXESUF" >> config.mak
2011
echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
2012
echo "VHOOK_DEPEND_CMD=$VHOOK_DEPEND_CMD" >> config.mak
2013

    
2014
if enabled bigendian; then
2015
    echo "WORDS_BIGENDIAN=yes" >> config.mak
2016
    echo "#define WORDS_BIGENDIAN 1" >> $TMPH
2017
fi
2018

    
2019
if enabled sdl; then
2020
    echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
2021
    echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
2022
fi
2023
if enabled texi2html; then
2024
    echo "BUILD_DOC=yes" >> config.mak
2025
fi
2026

    
2027
get_version(){
2028
    name=$1
2029
    file=$source_path/$2
2030
    eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
2031
    eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
2032
    lcname=$(tolower $name)
2033
    eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
2034
    eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
2035
}
2036

    
2037
get_version LIBSWSCALE  libswscale/swscale.h
2038
get_version LIBPOSTPROC libpostproc/postprocess.h
2039
get_version LIBAVCODEC  libavcodec/avcodec.h
2040
get_version LIBAVDEVICE libavdevice/avdevice.h
2041
get_version LIBAVFORMAT libavformat/avformat.h
2042
get_version LIBAVUTIL   libavutil/avutil.h
2043
get_version LIBAVFILTER libavfilter/avfilter.h
2044

    
2045
if enabled shared; then
2046
    echo "BUILD_SHARED=yes" >> config.mak
2047
    echo "PIC=-fPIC -DPIC" >> config.mak
2048
    echo "SLIBNAME=${SLIBNAME}" >> config.mak
2049
    echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
2050
    echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
2051
    echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
2052
    echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
2053
    echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
2054
    echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
2055
fi
2056
echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
2057
echo "EXTRALIBS=$extralibs" >> config.mak
2058

    
2059
print_config ARCH_   $TMPH config.mak $ARCH_LIST
2060
print_config HAVE_   $TMPH config.mak $HAVE_LIST
2061
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST       \
2062
                                      $DECODER_LIST      \
2063
                                      $ENCODER_LIST      \
2064
                                      $PARSER_LIST       \
2065
                                      $BSF_LIST          \
2066
                                      $DEMUXER_LIST      \
2067
                                      $MUXER_LIST        \
2068
                                      $FILTER_LIST       \
2069
                                      $PROTOCOL_LIST     \
2070
                                      $INDEV_LIST        \
2071
                                      $OUTDEV_LIST       \
2072

    
2073
echo "#define restrict $_restrict" >> $TMPH
2074

    
2075
if enabled small; then
2076
    echo "#define av_always_inline"  >> $TMPH
2077
fi
2078

    
2079
echo "SRC_PATH=\"$source_path\"" >> config.mak
2080
echo "SRC_PATH_BARE=$source_path" >> config.mak
2081
echo "BUILD_ROOT=\"$PWD\"" >> config.mak
2082

    
2083
# Apparently it's not possible to portably echo a backslash.
2084
enabled asmalign_pot &&
2085
    printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
2086
    printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
2087

    
2088
echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
2089

    
2090
echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
2091

    
2092
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
2093
cmp -s $TMPH config.h &&
2094
    echo "config.h is unchanged" ||
2095
    mv -f $TMPH config.h
2096

    
2097
rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
2098

    
2099
# build tree in object directory if source path is different from current one
2100
if enabled source_path_used; then
2101
    DIRS="\
2102
        doc               \
2103
        libavcodec        \
2104
        libavcodec/alpha  \
2105
        libavcodec/armv4l \
2106
        libavcodec/bfin   \
2107
        libavcodec/i386   \
2108
        libavcodec/mlib   \
2109
        libavcodec/ppc    \
2110
        libavcodec/sh4    \
2111
        libavcodec/sparc  \
2112
        libavdevice       \
2113
        libavfilter       \
2114
        libavformat       \
2115
        libavutil         \
2116
        libpostproc       \
2117
        libswscale        \
2118
        tests             \
2119
        tools             \
2120
        vhook             \
2121
        "
2122
    FILES="\
2123
        Makefile             \
2124
        common.mak           \
2125
        doc/texi2pod.pl      \
2126
        libavcodec/Makefile  \
2127
        libavdevice/Makefile \
2128
        libavfilter/Makefile \
2129
        libavformat/Makefile \
2130
        libavutil/Makefile   \
2131
        libpostproc/Makefile \
2132
        libswscale/Makefile  \
2133
        "
2134
    for dir in $DIRS ; do
2135
        mkdir -p $dir
2136
    done
2137
    for f in $FILES ; do
2138
        $ln_s "$source_path/$f" $f
2139
    done
2140
fi
2141

    
2142

    
2143
# build pkg-config files
2144
# FIXME: libdir and includedir are hardcoded and may differ from the real path.
2145

    
2146
pkgconfig_generate(){
2147
name=$1
2148
comment=$2
2149
version=$3
2150
libs=$4
2151
requires=$5
2152
cat <<EOF >$name.pc
2153
prefix=$PREFIX
2154
exec_prefix=\${prefix}
2155
libdir=\${exec_prefix}/lib
2156
includedir=\${prefix}/include
2157

    
2158
Name: $name
2159
Description: $comment
2160
Version: $version
2161
Requires: $requires
2162
Conflicts:
2163
Libs: -L\${libdir} $libs
2164
Cflags: -I\${includedir}
2165
EOF
2166
}
2167

    
2168
pkgconfig_generate_uninstalled(){
2169
name=$1
2170
shortname=${name#lib}
2171
comment=$2
2172
version=$3
2173
libs=$4
2174
requires=$5
2175
cat <<EOF >$name-uninstalled.pc
2176
prefix=
2177
exec_prefix=
2178
libdir=\${pcfiledir}/$name
2179
includedir=\${pcfiledir}
2180

    
2181
Name: $name
2182
Description: $comment
2183
Version: $version
2184
Requires: $requires
2185
Conflicts:
2186
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
2187
Cflags: -I\${includedir}
2188
EOF
2189
}
2190

    
2191
pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION" -lavutil ""
2192
pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
2193

    
2194
pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "-lavcodec $extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
2195
pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
2196

    
2197
pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "-lavformat $extralibs" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
2198
pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
2199

    
2200
pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "-lavdevice $extralibs" "$pkg_requires libavformat = $LIBAVFORMAT_VERSION"
2201
pkgconfig_generate_uninstalled libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "$pkg_requires libavformat = $LIBAVFORMAT_VERSION"
2202
if enabled postproc; then
2203
    pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION" -lpostproc ""
2204
    pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
2205
fi
2206

    
2207
if enabled swscale; then
2208
    pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" -lswscale "libavutil = $LIBAVUTIL_VERSION"
2209
    pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
2210
else
2211
    pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
2212
    pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
2213
    apply libswscale.pc sed s/^Libs:.*$/Libs:/
2214
    apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
2215
fi
2216

    
2217
if enabled avfilter; then
2218
  pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "-lavfilter $extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION" ffmpeg
2219
  pkgconfig_generate_uninstalled libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
2220
fi