Statistics
| Branch: | Revision:

ffmpeg / configure @ 15fe16f4

History | View | Annotate | Download (66.4 KB)

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

    
10
# Prevent locale nonsense from breaking basic text processing.
11
export LC_ALL=C
12

    
13
# make sure we are running under a compatible shell
14
# try to make this part work with most shells
15

    
16
try_exec(){
17
    echo "Trying shell $1"
18
    type "$1" > /dev/null 2>&1 && exec "$@"
19
}
20

    
21
unset foo
22
(: ${foo%%bar}) 2> /dev/null
23
E1="$?"
24

    
25
(: ${foo?}) 2> /dev/null
26
E2="$?"
27

    
28
if test "$E1" != 0 || test "$E2" = 0; then
29
    echo "Broken shell detected.  Trying alternatives."
30
    export FF_CONF_EXEC
31
    if test "0$FF_CONF_EXEC" -lt 1; then
32
        FF_CONF_EXEC=1
33
        try_exec bash "$0" "$@"
34
    fi
35
    if test "0$FF_CONF_EXEC" -lt 2; then
36
        FF_CONF_EXEC=2
37
        try_exec ksh "$0" "$@"
38
    fi
39
    if test "0$FF_CONF_EXEC" -lt 3; then
40
        FF_CONF_EXEC=3
41
        try_exec /usr/xpg4/bin/sh "$0" "$@"
42
    fi
43
    echo "No compatible shell script interpreter found."
44
    echo "This configure script requires a POSIX-compatible shell"
45
    echo "such as bash or ksh."
46
    echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
47
    echo "Instead, install a working POSIX-compatible shell."
48
    echo "Disabling this configure test will create a broken FFmpeg."
49
    if test "$BASH_VERSION" = '2.04.0(1)-release'; then
50
        echo "This bash version ($BASH_VERSION) is broken on your platform."
51
        echo "Upgrade to a later version if available."
52
    fi
53
    exit 1
54
fi
55

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

    
197
log(){
198
    echo "$@" >> $logfile
199
}
200

    
201
log_file(){
202
    log BEGIN $1
203
    pr -n -t $1 >> $logfile
204
    log END $1
205
}
206

    
207
echolog(){
208
    log "$@"
209
    echo "$@"
210
}
211

    
212
die(){
213
    echolog "$@"
214
    cat <<EOF
215
If you think configure made a mistake, make sure you are using the latest
216
version from SVN.  If the latest version fails, report the problem to the
217
ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
218
EOF
219
    if disabled logging; then
220
        cat <<EOF
221
Rerun configure with logging enabled (do not use --disable-logging), and
222
include the log this produces with your report.
223
EOF
224
    else
225
cat <<EOF
226
Include the log file "$logfile" produced by configure as this will help
227
solving the problem.
228
EOF
229
    fi
230
    rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
231
    exit 1
232
}
233

    
234
# Avoid locale weirdness, besides we really just want to translate ASCII.
235
toupper(){
236
    echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
237
}
238

    
239
tolower(){
240
    echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
241
}
242

    
243
set_all(){
244
    value=$1
245
    shift
246
    for var in $*; do
247
        eval $var=$value
248
    done
249
}
250

    
251
pushvar(){
252
    for var in $*; do
253
        eval level=\${${var}_level:=0}
254
        eval ${var}_${level}="\$$var"
255
        eval ${var}_level=$(($level+1))
256
    done
257
}
258

    
259
popvar(){
260
    for var in $*; do
261
        eval level=\${${var}_level:-0}
262
        test $level = 0 && continue
263
        eval level=$(($level-1))
264
        eval $var="\${${var}_${level}}"
265
        eval ${var}_level=$level
266
        eval unset ${var}_${level}
267
    done
268
}
269

    
270
enable(){
271
    set_all yes $*
272
}
273

    
274
disable(){
275
    set_all no $*
276
}
277

    
278
enabled(){
279
    test "${1#!}" = "$1" && op== || op=!=
280
    eval test "x\$${1#!}" $op "xyes"
281
}
282

    
283
disabled(){
284
    test "${1#!}" = "$1" && op== || op=!=
285
    eval test "x\$${1#!}" $op "xno"
286
}
287

    
288
enabled_all(){
289
    for opt; do
290
        enabled $opt || return 1
291
    done
292
}
293

    
294
disabled_all(){
295
    for opt; do
296
        disabled $opt || return 1
297
    done
298
}
299

    
300
enabled_any(){
301
    for opt; do
302
        enabled $opt && return 0
303
    done
304
}
305

    
306
disabled_any(){
307
    for opt; do
308
        disabled $opt && return 0
309
    done
310
}
311

    
312
set_default(){
313
    for opt; do
314
        eval test -z "\$$opt" && eval $opt=\$${opt}_default
315
    done
316
}
317

    
318
is_in(){
319
    value=$1
320
    shift
321
    for var in $*; do
322
        [ $var = $value ] && return 0
323
    done
324
    return 1
325
}
326

    
327
check_deps(){
328
    for cfg; do
329
        cfg="${cfg#!}"
330
        enabled ${cfg}_checking && die "Circular dependency for $cfg."
331
        disabled ${cfg}_checking && continue
332
        enable ${cfg}_checking
333

    
334
        eval dep_all="\$${cfg}_deps"
335
        eval dep_any="\$${cfg}_deps_any"
336

    
337
        pushvar cfg dep_all dep_any
338
        check_deps $dep_all $dep_any
339
        popvar cfg dep_all dep_any
340

    
341
        enabled_all $dep_all || disable $cfg
342
        enabled_any $dep_any || disable $cfg
343

    
344
        if enabled $cfg; then
345
            eval dep_extralibs="\$${cfg}_extralibs"
346
            test -n "$dep_extralibs" && add_extralibs $dep_extralibs
347
        fi
348

    
349
        disable ${cfg}_checking
350
    done
351
}
352

    
353
print_config(){
354
    pfx=$1
355
    header=$2
356
    makefile=$3
357
    shift 3
358
    for cfg; do
359
        ucname="`toupper $cfg`"
360
        if enabled $cfg; then
361
            echo "#define ${pfx}${ucname} 1" >> $header
362
            echo "#define ENABLE_${ucname} 1" >> $header
363
            echo "${pfx}${ucname}=yes" >> $makefile
364
        else
365
            echo "#define ENABLE_${ucname} 0" >> $header
366
        fi
367
    done
368
}
369

    
370
flags_saved(){
371
    (: ${SAVE_CFLAGS?}) 2> /dev/null
372
}
373

    
374
save_flags(){
375
    flags_saved && return
376
    SAVE_CFLAGS="$CFLAGS"
377
    SAVE_LDFLAGS="$LDFLAGS"
378
    SAVE_extralibs="$extralibs"
379
}
380

    
381
restore_flags(){
382
    flags_saved || return
383
    CFLAGS="$SAVE_CFLAGS"
384
    LDFLAGS="$SAVE_LDFLAGS"
385
    extralibs="$SAVE_extralibs"
386
    unset SAVE_CFLAGS
387
    unset SAVE_LDFLAGS
388
    unset SAVE_extralibs
389
}
390

    
391
temp_cflags(){
392
    save_flags
393
    CFLAGS="$CFLAGS $*"
394
}
395

    
396
temp_ldflags(){
397
    save_flags
398
    LDFLAGS="$LDFLAGS $*"
399
}
400

    
401
temp_extralibs(){
402
    save_flags
403
    extralibs="$extralibs $*"
404
}
405

    
406
append(){
407
    var=$1
408
    shift
409
    flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
410
    eval "$var=\"\$$var $*\""
411
}
412

    
413
add_cflags(){
414
    append CFLAGS "$@"
415
}
416

    
417
add_ldflags(){
418
    append LDFLAGS "$@"
419
}
420

    
421
add_extralibs(){
422
    append extralibs "$@"
423
}
424

    
425
check_cmd(){
426
    log "$@"
427
    "$@" >> $logfile 2>&1
428
}
429

    
430
check_cc(){
431
    log check_cc "$@"
432
    cat > $TMPC
433
    log_file $TMPC
434
    check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
435
}
436

    
437
check_cpp(){
438
    log check_cpp "$@"
439
    cat > $TMPC
440
    log_file $TMPC
441
    check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
442
}
443

    
444
check_asm(){
445
    log check_asm "$@"
446
    name="$1"
447
    asm="$2"
448
    shift 2
449
    check_cc "$@" <<EOF && enable $name || disable $name
450
int foo(void){ asm volatile($asm); }
451
EOF
452
}
453

    
454
check_yasm(){
455
    log check_yasm "$@"
456
    echo "$1" > $TMPS
457
    log_file $TMPS
458
    shift 1
459
    check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
460
}
461

    
462
check_ld(){
463
    log check_ld "$@"
464
    check_cc || return
465
    flags=''
466
    libs=''
467
    for f; do
468
        test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
469
    done
470
    check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
471
}
472

    
473
check_cflags(){
474
    log check_cflags "$@"
475
    check_cc "$@" <<EOF && add_cflags "$@"
476
int x;
477
EOF
478
}
479

    
480
check_ldflags(){
481
    log check_ldflags "$@"
482
    check_ld "$@" <<EOF && add_ldflags "$@"
483
int main(void){ return 0; }
484
EOF
485
}
486

    
487
check_header(){
488
    log check_header "$@"
489
    header=$1
490
    shift
491
    var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
492
    disable $var
493
    check_cpp "$@" <<EOF && enable $var
494
#include <$header>
495
int x;
496
EOF
497
}
498

    
499
check_func(){
500
    log check_func "$@"
501
    func=$1
502
    shift
503
    disable $func
504
    check_ld "$@" <<EOF && enable $func
505
extern int $func();
506
int main(void){ $func(); }
507
EOF
508
}
509

    
510
check_func_headers(){
511
    log check_func_headers "$@"
512
    headers=$1
513
    func=$2
514
    shift 2
515
    disable $func
516
    incs=""
517
    for hdr in $headers; do
518
        incs="$incs
519
#include <$hdr>"
520
    done
521
    check_ld "$@" <<EOF && enable $func
522
$incs
523
int main(int argc, char **argv){
524
    (void) $func;
525
    return 0;
526
}
527
EOF
528
}
529

    
530
check_cpp_condition(){
531
    log check_cpp_condition "$@"
532
    header=$1
533
    condition=$2
534
    check_cpp <<EOF
535
#include <$header>
536
#if !($condition)
537
#error "unsatisfied condition: $condition"
538
#endif
539
EOF
540
}
541

    
542
check_lib(){
543
    log check_lib "$@"
544
    header="$1"
545
    func="$2"
546
    shift 2
547
    temp_extralibs "$@"
548
    check_header $header && check_func $func && add_extralibs "$@"
549
    err=$?
550
    restore_flags
551
    return $err
552
}
553

    
554
check_lib2(){
555
    log check_lib2 "$@"
556
    headers="$1"
557
    func="$2"
558
    shift 2
559
    temp_extralibs "$@"
560
    check_func_headers "$headers" $func && add_extralibs "$@"
561
    err=$?
562
    restore_flags
563
    return $err
564
}
565

    
566
check_exec(){
567
    check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
568
}
569

    
570
check_exec_crash(){
571
    code=`cat`
572

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

    
579
    (check_exec "$@") >> $logfile 2>&1 <<EOF
580
#include <signal.h>
581
static void sighandler(int sig){
582
    raise(SIGTERM);
583
}
584
int main(void){
585
    signal(SIGILL, sighandler);
586
    signal(SIGFPE, sighandler);
587
    signal(SIGSEGV, sighandler);
588
#ifdef SIGBUS
589
    signal(SIGBUS, sighandler);
590
#endif
591
    { $code }
592
}
593
EOF
594
}
595

    
596
check_type(){
597
    log check_type "$@"
598
    headers=$1
599
    type=$2
600
    shift 2
601
    disable $type
602
    incs=""
603
    for hdr in $headers; do
604
        incs="$incs
605
#include <$hdr>"
606
    done
607
    check_cc "$@" <<EOF && enable $type
608
$incs
609
$type v;
610
EOF
611
}
612

    
613
require(){
614
    name="$1"
615
    header="$2"
616
    func="$3"
617
    shift 3
618
    check_lib $header $func "$@" || die "ERROR: $name not found"
619
}
620

    
621
require2(){
622
    name="$1"
623
    headers="$2"
624
    func="$3"
625
    shift 3
626
    check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
627
}
628

    
629
require_cpp_condition(){
630
    name="$1"
631
    header="$2"
632
    cpp_condition="$3"
633
    shift 3
634
    check_cpp_condition $header "$cpp_condition" || die "ERROR: $name does not satisfy CPP condition: $cpp_condition"
635
}
636

    
637
check_foo_config(){
638
    cfg=$1
639
    pkg=$2
640
    header=$3
641
    func=$4
642
    shift 4
643
    disable $cfg
644
    check_cmd ${pkg}-config --version
645
    err=$?
646
    if test "$err" = 0; then
647
        temp_cflags `${pkg}-config --cflags`
648
        temp_extralibs `${pkg}-config --libs`
649
        check_lib "$@" $header $func && enable $cfg
650
    fi
651
    return $err
652
}
653

    
654
apply(){
655
    file=$1
656
    shift
657
    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
658
}
659

    
660
# CONFIG_LIST contains configurable options, while HAVE_LIST is for
661
# system-dependent things.
662

    
663
COMPONENT_LIST="
664
    bsfs
665
    decoders
666
    demuxers
667
    encoders
668
    filters
669
    indevs
670
    muxers
671
    outdevs
672
    parsers
673
    protocols
674
"
675

    
676
CONFIG_LIST="
677
    $COMPONENT_LIST
678
    avfilter
679
    avfilter_lavf
680
    avisynth
681
    beos_netserver
682
    bzlib
683
    ffmpeg
684
    ffplay
685
    ffserver
686
    gpl
687
    gprof
688
    gray
689
    hardcoded_tables
690
    ipv6
691
    libamr_nb
692
    libamr_wb
693
    libdc1394
694
    libdirac
695
    libfaac
696
    libfaad
697
    libfaadbin
698
    libgsm
699
    libmp3lame
700
    libnut
701
    libschroedinger
702
    libtheora
703
    libvorbis
704
    libx264
705
    libxvid
706
    memalign_hack
707
    mlib
708
    mpegaudio_hp
709
    network
710
    nonfree
711
    postproc
712
    powerpc_perf
713
    small
714
    swscale
715
    vhook
716
    x11grab
717
    zlib
718
"
719

    
720
THREADS_LIST='
721
    beosthreads
722
    os2threads
723
    pthreads
724
    w32threads
725
'
726

    
727
ARCH_LIST='
728
    alpha
729
    armv4l
730
    bfin
731
    ia64
732
    m68k
733
    mips
734
    parisc
735
    powerpc
736
    s390
737
    sh4
738
    sparc
739
    sparc64
740
    x86
741
    x86_32
742
    x86_64
743
'
744

    
745
ARCH_EXT_LIST='
746
    altivec
747
    armv5te
748
    armv6
749
    armvfp
750
    iwmmxt
751
    mmi
752
    mmx
753
    mmx2
754
    neon
755
    ssse3
756
    vis
757
'
758

    
759
HAVE_LIST="
760
    $ARCH_EXT_LIST
761
    $THREADS_LIST
762
    altivec_h
763
    arpa_inet_h
764
    bswap
765
    byteswap_h
766
    closesocket
767
    cmov
768
    conio_h
769
    dcbzl
770
    dev_bktr_ioctl_bt848_h
771
    dev_bktr_ioctl_meteor_h
772
    dev_ic_bt8xx_h
773
    dev_video_meteor_ioctl_meteor_h
774
    dev_video_bktr_ioctl_bt848_h
775
    dlfcn_h
776
    dlopen
777
    dos_paths
778
    ebp_available
779
    ebx_available
780
    fast_64bit
781
    fast_cmov
782
    fast_unaligned
783
    fork
784
    freetype2
785
    gethrtime
786
    GetProcessTimes
787
    getrusage
788
    imlib2
789
    inet_aton
790
    inline_asm
791
    libdc1394_1
792
    libdc1394_2
793
    llrint
794
    lrint
795
    lrintf
796
    machine_ioctl_bt848_h
797
    machine_ioctl_meteor_h
798
    malloc_h
799
    memalign
800
    mkstemp
801
    pld
802
    ppc64
803
    round
804
    roundf
805
    sdl
806
    sdl_video_size
807
    socklen_t
808
    soundcard_h
809
    poll_h
810
    sys_mman_h
811
    sys_resource_h
812
    sys_select_h
813
    sys_soundcard_h
814
    sys_videoio_h
815
    termios_h
816
    threads
817
    winsock2_h
818
    yasm
819
"
820

    
821
CMDLINE_SELECT="
822
    $ARCH_EXT_LIST
823
    $CONFIG_LIST
824
    $THREADS_LIST
825
    cross_compile
826
    debug
827
    extra_warnings
828
    logging
829
    optimizations
830
    shared
831
    static
832
    stripping
833
"
834

    
835
PATHS_LIST='
836
    bindir
837
    incdir
838
    libdir
839
    mandir
840
    prefix
841
    shlibdir
842
'
843

    
844
CMDLINE_SET="
845
    $PATHS_LIST
846
    arch
847
    build_suffix
848
    cc
849
    cpu
850
    cross_prefix
851
    extra_version
852
    logfile
853
    source_path
854
    target_os
855
"
856

    
857
# code dependency declarations
858

    
859
# architecture extensions
860
altivec_deps="powerpc"
861
armv5te_deps="armv4l"
862
armv6_deps="armv4l"
863
armvfp_deps="armv4l"
864
iwmmxt_deps="armv4l"
865
mmi_deps="mips"
866
mmx_deps="x86"
867
mmx2_deps="x86 mmx"
868
neon_deps="armv4l"
869
ssse3_deps="x86"
870
vis_deps="sparc"
871

    
872
# system headers and functions
873
byteswap_h_deps="!armv4l"
874

    
875
# decoders / encoders
876
ac3_decoder_deps="gpl"
877
dxa_decoder_deps="zlib"
878
eac3_decoder_deps="gpl"
879
flashsv_decoder_deps="zlib"
880
flashsv_encoder_deps="zlib"
881
mlp_decoder_deps="mlp_parser"
882
mpeg_xvmc_decoder_deps="xvmc"
883
png_decoder_deps="zlib"
884
png_encoder_deps="zlib"
885
zmbv_decoder_deps="zlib"
886
zmbv_encoder_deps="zlib"
887

    
888
# external libraries
889
libamr_nb_decoder_deps="libamr_nb"
890
libamr_nb_encoder_deps="libamr_nb"
891
libamr_wb_decoder_deps="libamr_wb"
892
libamr_wb_encoder_deps="libamr_wb"
893
libdirac_decoder_deps="libdirac !libschroedinger"
894
libdirac_encoder_deps="libdirac"
895
libfaac_encoder_deps="libfaac"
896
libfaad_decoder_deps="libfaad"
897
libfaadbin_decoder_extralibs='$ldl'
898
libgsm_decoder_deps="libgsm"
899
libgsm_encoder_deps="libgsm"
900
libgsm_ms_decoder_deps="libgsm"
901
libgsm_ms_encoder_deps="libgsm"
902
libmp3lame_encoder_deps="libmp3lame"
903
libschroedinger_decoder_deps="libschroedinger"
904
libschroedinger_encoder_deps="libschroedinger"
905
libtheora_encoder_deps="libtheora"
906
libvorbis_encoder_deps="libvorbis"
907
libx264_encoder_deps="libx264"
908
libxvid_encoder_deps="libxvid"
909
mpeg4aac_decoder_deps="libfaad"
910

    
911
# demuxers / muxers
912
ac3_demuxer_deps="ac3_parser"
913
audio_beos_demuxer_deps="audio_beos"
914
audio_beos_demuxer_extralibs="-lmedia -lbe"
915
audio_beos_muxer_deps="audio_beos"
916
audio_beos_muxer_extralibs="-lmedia -lbe"
917
avisynth_demuxer_deps="avisynth"
918
bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
919
dirac_demuxer_deps="dirac_parser"
920
dv1394_demuxer_deps="dv1394 dv_demuxer"
921
libdc1394_demuxer_deps="libdc1394"
922
libnut_demuxer_deps="libnut"
923
libnut_muxer_deps="libnut"
924
mp3_demuxer_deps="mpegaudio_parser"
925
oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
926
oss_muxer_deps_any="soundcard_h sys_soundcard_h"
927
redir_demuxer_deps="network"
928
rtp_muxer_deps="network rtp_protocol"
929
rtsp_demuxer_deps="sdp_demuxer"
930
sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
931
v4l_demuxer_deps="linux_videodev_h"
932
v4l2_demuxer_deps_any="linux_videodev2_h sys_videoio_h"
933
vfwcap_demuxer_deps="capCreateCaptureWindow"
934
vfwcap_demuxer_extralibs="-lvfw32"
935
x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
936
x11_grab_device_demuxer_extralibs="-lX11 -lXext"
937

    
938
# protocols
939
http_protocol_deps="network"
940
rtp_protocol_deps="udp_protocol"
941
tcp_protocol_deps="network"
942
udp_protocol_deps="network"
943

    
944
# filters
945
movie_filter_deps="avfilter_lavf"
946

    
947
# programs
948
ffplay_deps="sdl"
949
ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
950
ffserver_extralibs='$ldl'
951
vhook_extralibs='$ldl'
952

    
953

    
954
# default parameters
955

    
956
logfile="config.err"
957

    
958
# installation paths
959
prefix_default="/usr/local"
960
bindir_default='${prefix}/bin'
961
incdir_default='${prefix}/include'
962
libdir_default='${prefix}/lib'
963
mandir_default='${prefix}/share/man'
964
shlibdir_default="$libdir_default"
965

    
966
# toolchain
967
cc="gcc"
968
yasmexe="yasm"
969
ar="ar"
970
nm="nm"
971
ranlib="ranlib"
972
strip="strip"
973
asmalign_pot="unknown"
974
ln_s="ln -sf"
975
objformat="elf"
976

    
977
# machine
978
arch=`uname -m`
979
cpu="generic"
980

    
981
# OS
982
target_os=$(tolower $(uname -s))
983

    
984
# libraries
985
enable bzlib
986
enable zlib
987

    
988
# configurable options
989
enable debug
990
enable ffmpeg
991
enable ffplay
992
enable ffserver
993
enable ipv6
994
enable mpegaudio_hp
995
enable network
996
enable optimizations
997
enable protocols
998
enable static
999
enable stripping
1000
vhook="default"
1001

    
1002
# build settings
1003
add_cflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
1004
SHFLAGS='-shared -Wl,-soname,$$(@F)'
1005
VHOOKSHFLAGS='$(SHFLAGS)'
1006
FFSERVERLDFLAGS=-Wl,-E
1007
LIBPREF="lib"
1008
LIBSUF=".a"
1009
FULLNAME='$(NAME)$(BUILDSUF)'
1010
LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
1011
SLIBPREF="lib"
1012
SLIBSUF=".so"
1013
SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
1014
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1015
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
1016
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
1017

    
1018
# gcc stupidly only outputs the basename of targets with -MM
1019
DEPEND_CMD='$(CC) $(CFLAGS) -MM -MG $< | sed -e "/^\#.*/d" -e "1s,^,$(@D)/," -e "s,\\([[:space:]]\\)\\(version\\.h\\),\\1\$$(BUILD_ROOT_REL)/\\2,"'
1020

    
1021
# find source path
1022
source_path="`dirname \"$0\"`"
1023
enable source_path_used
1024
if test -z "$source_path" -o "$source_path" = "." ; then
1025
    source_path="`pwd`"
1026
    disable source_path_used
1027
else
1028
    source_path="`cd \"$source_path\"; pwd`"
1029
    echo "$source_path" | grep -q '[[:blank:]]' &&
1030
        die "Out of tree builds are impossible with whitespace in source path."
1031
fi
1032

    
1033
FFMPEG_CONFIGURATION="$@"
1034

    
1035
find_things(){
1036
    thing=$1
1037
    pattern=$2
1038
    file=$source_path/$3
1039
    sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
1040
}
1041

    
1042
ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
1043
DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
1044
PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
1045
BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
1046
MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
1047
DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
1048
OUTDEV_LIST=$(find_things   muxer    _MUX     libavdevice/alldevices.c)
1049
INDEV_LIST=$(find_things    demuxer  DEMUX    libavdevice/alldevices.c)
1050
PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
1051
FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
1052

    
1053
enable $ARCH_EXT_LIST \
1054
       $DECODER_LIST \
1055
       $ENCODER_LIST \
1056
       $PARSER_LIST \
1057
       $BSF_LIST \
1058
       $DEMUXER_LIST \
1059
       $MUXER_LIST \
1060
       $FILTER_LIST \
1061
       $PROTOCOL_LIST \
1062
       $INDEV_LIST \
1063
       $OUTDEV_LIST \
1064

    
1065
die_unknown(){
1066
    echo "Unknown option \"$1\"."
1067
    echo "See $0 --help for available options."
1068
    exit 1
1069
}
1070

    
1071
show_list() {
1072
    suffix=_$1
1073
    shift
1074
    echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
1075
    exit 0
1076
}
1077

    
1078
for opt do
1079
    optval="${opt#*=}"
1080
    case "$opt" in
1081
    --extra-cflags=*) add_cflags "$optval"
1082
    ;;
1083
    --extra-ldflags=*) add_ldflags "$optval"
1084
    ;;
1085
    --extra-libs=*) add_extralibs "$optval"
1086
    ;;
1087
    --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
1088
    ;;
1089
    --enable-debug=*) debuglevel="$optval"
1090
    ;;
1091
    --enable-*=*|--disable-*=*)
1092
    eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
1093
    case "$thing" in
1094
        encoder|decoder|muxer|demuxer|parser|bsf|protocol|filter) $action ${optval}_${thing} ;;
1095
        *) die_unknown "$opt" ;;
1096
    esac
1097
    ;;
1098
    --enable-?*|--disable-?*)
1099
    eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
1100
    if is_in $option $COMPONENT_LIST; then
1101
        eval $action \$$(toupper ${option%s})_LIST
1102
    elif is_in $option $CMDLINE_SELECT; then
1103
        $action $option
1104
    else
1105
        die_unknown $opt
1106
    fi
1107
    ;;
1108
    --list-*)
1109
        NAME="${opt#--list-}"
1110
        is_in $NAME $COMPONENT_LIST || die_unknown $opt
1111
        NAME=${NAME%s}
1112
        eval show_list $NAME \$$(toupper $NAME)_LIST
1113
    ;;
1114
    --help|-h) show_help
1115
    ;;
1116
    *)
1117
    optname="${opt%=*}"
1118
    optname="${optname#--}"
1119
    optname=$(echo "$optname" | sed 's/-/_/g')
1120
    is_in $optname $CMDLINE_SET || die_unknown $opt
1121
    eval $optname='$optval'
1122
    ;;
1123
    esac
1124
done
1125

    
1126
disabled logging && logfile=/dev/null
1127

    
1128
echo "# $0 $@" > $logfile
1129
set >> $logfile
1130

    
1131
cc="${cross_prefix}${cc}"
1132
yasmexe="${cross_prefix}${yasmexe}"
1133
ar="${cross_prefix}${ar}"
1134
nm="${cross_prefix}${nm}"
1135
ranlib="${cross_prefix}${ranlib}"
1136
strip="${cross_prefix}${strip}"
1137

    
1138
# set temporary file name
1139
if test ! -z "$TMPDIR" ; then
1140
    TMPDIR1="${TMPDIR}"
1141
elif test ! -z "$TEMPDIR" ; then
1142
    TMPDIR1="${TEMPDIR}"
1143
else
1144
    TMPDIR1="/tmp"
1145
fi
1146

    
1147
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
1148
TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
1149
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
1150
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
1151
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
1152
TMPSH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
1153

    
1154
check_cflags -fasm
1155
check_cflags -std=c99
1156

    
1157
case "$arch" in
1158
    i386|i486|i586|i686|i86pc|BePC)
1159
        arch="x86_32"
1160
        enable fast_unaligned
1161
    ;;
1162
    x86_64|amd64)
1163
        arch="x86_32"
1164
        enable fast_unaligned
1165
        check_cc <<EOF && enable fast_64bit && arch="x86_64"
1166
        int test[sizeof(char*) - 7];
1167
EOF
1168
    ;;
1169
    # armv4l is a subset of armv[567]*l
1170
    arm|armv[4567]*l)
1171
        arch="armv4l"
1172
    ;;
1173
    alpha)
1174
        arch="alpha"
1175
        enable fast_64bit
1176
    ;;
1177
    "Power Macintosh"|ppc|powerpc)
1178
        arch="powerpc"
1179
    ;;
1180
    ppc64)
1181
        arch="powerpc"
1182
        enable fast_64bit
1183
    ;;
1184
    mips|mipsel|IP*)
1185
        arch="mips"
1186
    ;;
1187
    sun4u|sparc64)
1188
        arch="sparc64"
1189
        enable fast_64bit
1190
    ;;
1191
    sparc)
1192
        arch="sparc"
1193
    ;;
1194
    sh4)
1195
        arch="sh4"
1196
    ;;
1197
    parisc)
1198
        arch="parisc"
1199
    ;;
1200
    parisc64)
1201
        arch="parisc"
1202
        enable fast_64bit
1203
    ;;
1204
    s390|s390x)
1205
        arch="s390"
1206
    ;;
1207
    m68k)
1208
        arch="m68k"
1209
    ;;
1210
    ia64)
1211
        arch="ia64"
1212
        enable fast_64bit
1213
    ;;
1214
    bfin)
1215
        arch="bfin"
1216
    ;;
1217
    *)
1218
        arch="unknown"
1219
    ;;
1220
esac
1221

    
1222
enable $arch
1223
enabled_any x86_32 x86_64 && enable x86
1224
enabled     sparc64       && enable sparc
1225

    
1226
# OS specific
1227
case $target_os in
1228
    beos|haiku|zeta)
1229
        prefix_default="$HOME/config"
1230
        # helps building libavcodec
1231
        add_cflags "-DPIC -fomit-frame-pointer"
1232
        # 3 gcc releases known for BeOS, each with ugly bugs
1233
        gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1234
        case "$gcc_version" in
1235
          2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1236
            disable mmx
1237
            ;;
1238
          *20010315*) echo "BeBits gcc"
1239
            add_cflags "-fno-expensive-optimizations"
1240
            ;;
1241
        esac
1242
        SHFLAGS=-nostart
1243
        # enable BeOS things
1244
        enable audio_beos
1245
        # no need for libm, but the inet stuff
1246
        # Check for BONE
1247
        # XXX: actually should check for NOT net_server
1248
        if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
1249
            network_extralibs="-lbind -lsocket"
1250
        else
1251
            enable beos_netserver
1252
            network_extralibs="-lnet"
1253
        fi ;;
1254
    sunos)
1255
        FFSERVERLDFLAGS=""
1256
        SHFLAGS='-shared -Wl,-h,$$(@F)'
1257
        network_extralibs="-lsocket -lnsl"
1258
        ;;
1259
    netbsd)
1260
        oss_demuxer_extralibs="-lossaudio"
1261
        oss_muxer_extralibs="-lossaudio"
1262
        ;;
1263
    openbsd)
1264
        disable need_memalign
1265
        LIBOBJFLAGS='$(PIC)'
1266
        SHFLAGS='-shared'
1267
        SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF).$(LIBVERSION)'
1268
        SLIBNAME_WITH_VERSION='$(SLIBNAME)'
1269
        SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
1270
        oss_demuxer_extralibs="-lossaudio"
1271
        oss_muxer_extralibs="-lossaudio"
1272
        ;;
1273
    freebsd)
1274
        disable need_memalign
1275
        ;;
1276
    bsd/os)
1277
        osextralibs="-lpoll -lgnugetopt"
1278
        strip="strip -d"
1279
        ;;
1280
    darwin)
1281
        disable need_memalign
1282
        SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
1283
        VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$$(@F)'
1284
        strip="strip -x"
1285
        FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1286
        SLIBSUF=".dylib"
1287
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
1288
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
1289
        FFSERVERLDFLAGS=-Wl,-bind_at_load
1290
        objformat="macho"
1291
        enabled x86_64 && objformat="macho64"
1292
        ;;
1293
    mingw32*)
1294
        target_os=mingw32
1295
        LIBTARGET=i386
1296
        if test $arch = x86_64; then
1297
            disable need_memalign
1298
            LIBTARGET=x64
1299
        fi
1300
        shlibdir_default="$bindir_default"
1301
        VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1302
        VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1303
        if enabled swscale; then
1304
            VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1305
            VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1306
        fi
1307
        disable ffserver
1308
        SLIBPREF=""
1309
        SLIBSUF=".dll"
1310
        EXESUF=".exe"
1311
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1312
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1313
        SLIB_EXTRA_CMD='-lib /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
1314
        SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
1315
            install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"'
1316
        SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
1317
        SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
1318
        objformat="win32"
1319
        enable dos_paths
1320
        ;;
1321
    cygwin*)
1322
        target_os=cygwin
1323
        shlibdir_default="$bindir_default"
1324
        VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1325
        VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1326
        if enabled swscale; then
1327
            VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1328
            VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1329
        fi
1330
        EXESUF=".exe"
1331
        SLIBPREF="cyg"
1332
        SLIBSUF=".dll"
1333
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1334
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1335
        SHFLAGS='-shared -Wl,--enable-auto-image-base'
1336
        objformat="win32"
1337
        enable dos_paths
1338
        ;;
1339
    *-dos|freedos|opendos)
1340
        disable ffplay ffserver vhook
1341
        disable $INDEV_LIST $OUTDEV_LIST
1342
        network_extralibs="-lsocket"
1343
        EXESUF=".exe"
1344
        objformat="win32"
1345
        enable dos_paths
1346
        ;;
1347
    linux)
1348
        enable dv1394
1349
        ;;
1350
    irix*)
1351
        target_os=irix
1352
        ranlib="echo ignoring ranlib"
1353
        ;;
1354
    os/2*)
1355
        strip="lxlite"
1356
        ln_s="cp -f"
1357
        EXESUF=".exe"
1358
        FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
1359
        SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
1360
        FFSERVERLDFLAGS=""
1361
        LIBSUF="_s.a"
1362
        SLIBPREF=""
1363
        SLIBSUF=".dll"
1364
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1365
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
1366
        SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
1367
          echo PROTMODE >> $(SUBDIR)$(NAME).def; \
1368
          echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
1369
          echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
1370
          echo EXPORTS >> $(SUBDIR)$(NAME).def; \
1371
          emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
1372
        SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
1373
          emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
1374
        SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
1375
        SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
1376
        disable vhook
1377
        enable dos_paths
1378
        ;;
1379
    interix)
1380
        disable vhook
1381
        ;;
1382

    
1383
    *)
1384
        target_os="${target_os}-UNKNOWN"
1385
        ;;
1386
esac
1387

    
1388
set_default $PATHS_LIST
1389

    
1390
add_extralibs $osextralibs
1391

    
1392
# Combine FFLDFLAGS and the LDFLAGS environment variable.
1393
LDFLAGS="$FFLDFLAGS $LDFLAGS"
1394

    
1395
test -n "$cross_prefix" && enable cross_compile
1396

    
1397
# we need to build at least one lib type
1398
if ! enabled_any static shared; then
1399
    cat <<EOF
1400
At least one library type must be built.
1401
Specify --enable-static to build the static libraries or --enable-shared to
1402
build the shared libraries as well. To only build the shared libraries specify
1403
--disable-static in addition to --enable-shared.
1404
EOF
1405
    exit 1;
1406
fi
1407

    
1408
disabled static && LIBNAME=""
1409

    
1410
if enabled_any libfaad libfaadbin ; then
1411
    if check_header faad.h; then
1412
        check_cc <<EOF
1413
#include <faad.h>
1414
#ifndef FAAD2_VERSION
1415
ok faad1
1416
#endif
1417
int main(void) { return 0; }
1418
EOF
1419
        test $? = 0 && enable libfaad2
1420
    else
1421
        die "FAAD test failed."
1422
    fi
1423
fi
1424

    
1425

    
1426
if ! enabled gpl; then
1427
    die_gpl_disabled(){
1428
        name=$1
1429
        shift
1430
        enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
1431
    }
1432
    die_gpl_disabled "The Postprocessing code" postproc
1433
    die_gpl_disabled "libx264"                 libx264
1434
    die_gpl_disabled "libxvidcore"             libxvid
1435
    die_gpl_disabled "FAAD2"                   libfaad2
1436
    die_gpl_disabled "The X11 grabber"         x11grab
1437
    die_gpl_disabled "The software scaler"     swscale
1438
fi
1439

    
1440
if ! enabled nonfree && enabled_any libamr_nb libamr_wb; then
1441
    die "libamr is nonfree and --enable-nonfree is not specified."
1442
fi
1443

    
1444
check_deps $ARCH_EXT_LIST
1445

    
1446
test -z "$need_memalign" && need_memalign="$mmx"
1447

    
1448
#Darwin CC versions
1449
if test $target_os = darwin; then
1450
    if $cc -v 2>&1 | grep -q xlc; then
1451
        add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
1452
    else
1453
        add_cflags "-pipe"
1454
        check_cflags "-force_cpusubtype_ALL"
1455
        check_cflags "-Wno-sign-compare"
1456
        enabled shared || check_cflags -mdynamic-no-pic
1457
    fi
1458
fi
1459

    
1460
disabled optimizations || check_cflags -fomit-frame-pointer
1461

    
1462
# Add processor-specific flags
1463
if test $cpu != "generic"; then
1464
    warn_altivec(){
1465
        $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
1466
    }
1467
    case $cpu in
1468
        601|ppc601|PowerPC601)
1469
            add_cflags "-mcpu=601"
1470
            warn_altivec enabled PPC601
1471
        ;;
1472
        603*|ppc603*|PowerPC603*)
1473
            add_cflags "-mcpu=603"
1474
            warn_altivec enabled PPC603
1475
        ;;
1476
        604*|ppc604*|PowerPC604*)
1477
            add_cflags "-mcpu=604"
1478
            warn_altivec enabled PPC604
1479
        ;;
1480
        G3|g3|75*|ppc75*|PowerPC75*)
1481
            add_cflags "-mcpu=750 -mpowerpc-gfxopt"
1482
            warn_altivec enabled PPC75x
1483
        ;;
1484
        G4|g4|745*|ppc745*|PowerPC745*)
1485
            add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
1486
            warn_altivec disabled PPC745x
1487
        ;;
1488
        74*|ppc74*|PowerPC74*)
1489
            add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
1490
            warn_altivec disabled PPC74xx
1491
        ;;
1492
        G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1493
            add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1494
            warn_altivec disabled PPC970
1495
            enable ppc64
1496
        ;;
1497
        Cell|CELL|cell)
1498
            add_cflags "-mcpu=cell"
1499
            warn_altivec disabled Cell
1500
            enable ppc64
1501
        ;;
1502
        # targets that do NOT support conditional mov (cmov)
1503
        i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1504
            add_cflags "-march=$cpu"
1505
            disable cmov
1506
        ;;
1507
        # targets that do support conditional mov (cmov)
1508
        i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
1509
            add_cflags "-march=$cpu"
1510
            enable cmov
1511
            enable fast_cmov
1512
        ;;
1513
        # targets that do support conditional mov but on which it's slow
1514
        pentium4|pentium4m|prescott|nocona)
1515
            add_cflags "-march=$cpu"
1516
            enable cmov
1517
            disable fast_cmov
1518
        ;;
1519
        sparc64)
1520
            add_cflags "-mcpu=v9"
1521
        ;;
1522
        arm*|cortex*)
1523
            add_cflags "-mcpu=$cpu"
1524
        ;;
1525
        *)
1526
            echo "WARNING: Unknown CPU \"$cpu\", ignored."
1527
        ;;
1528
    esac
1529
fi
1530

    
1531
# make sure we can execute files in $TMPDIR
1532
cat > $TMPSH 2>> $logfile <<EOF
1533
#! /bin/sh
1534
EOF
1535
chmod +x $TMPSH >> $logfile 2>&1
1536
if ! $TMPSH >> $logfile 2>&1; then
1537
    cat <<EOF
1538
Unable to create and execute files in $TMPDIR1.  Set the TMPDIR environment
1539
variable to another directory and make sure that $TMPDIR1 is not mounted
1540
noexec.
1541
EOF
1542
    die "Sanity test failed."
1543
fi
1544
rm $TMPSH
1545

    
1546
# compiler sanity check
1547
check_exec <<EOF
1548
int main(void){ return 0; }
1549
EOF
1550
if test "$?" != 0; then
1551
    echo "$cc is unable to create an executable file."
1552
    if test -z "$cross_prefix" && ! enabled cross_compile ; then
1553
        echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
1554
        echo "Only do this if you know what cross compiling means."
1555
    fi
1556
    die "C compiler test failed."
1557
fi
1558

    
1559
check_cc <<EOF || die "Symbol mangling check failed."
1560
int ff_extern;
1561
EOF
1562
sym=$($nm -P -g $TMPO | grep ff_extern)
1563
extern_prefix=${sym%%ff_extern*}
1564

    
1565
check_asm inline_asm '""'
1566

    
1567
if enabled x86; then
1568
    # check whether EBP is available on x86
1569
    # As 'i' is stored on the stack, this program will crash
1570
    # if the base pointer is used to access it because the
1571
    # base pointer is cleared in the inline assembly code.
1572
    check_exec_crash <<EOF && enable ebp_available
1573
    volatile int i=0;
1574
    asm volatile (
1575
        "xorl %%ebp, %%ebp"
1576
    ::: "%ebp");
1577
    return i;
1578
EOF
1579

    
1580
    # check wether EBX is available on x86
1581
    check_asm ebx_available '"":::"%ebx"'
1582

    
1583
    # check whether binutils is new enough to compile SSSE3/MMX2
1584
    enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
1585
    enabled mmx2  && check_asm mmx2  '"movss %xmm0, %xmm0"'
1586

    
1587
    check_asm bswap '"bswap %%eax" ::: "%eax"'
1588

    
1589
    YASMFLAGS="-f $objformat -DARCH_$(toupper $arch)"
1590
    enabled     x86_64        && append YASMFLAGS "-m amd64"
1591
    enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
1592
    case "$objformat" in
1593
        elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
1594
        macho64)              append YASMFLAGS "-DPIC -DPREFIX" ;;
1595
        *)                    append YASMFLAGS "-DPREFIX"  ;;
1596
    esac
1597
    check_yasm "pabsw xmm0, xmm0" && enable yasm
1598
fi
1599

    
1600
# check for assembler specific support
1601

    
1602
if test $arch = "powerpc"; then
1603
check_cc <<EOF && enable dcbzl
1604
int main(void) {
1605
    register long zero = 0;
1606
    char data[1024];
1607
    asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
1608
return 0;
1609
}
1610
EOF
1611
fi
1612

    
1613
# check for SIMD availability
1614

    
1615
# AltiVec flags: The FSF version of GCC differs from the Apple version
1616
if enabled altivec; then
1617
    check_cflags -maltivec -mabi=altivec &&
1618
        { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
1619
        check_cflags -faltivec
1620

    
1621
    # check if our compiler supports Motorola AltiVec C API
1622
    check_cc <<EOF || disable altivec
1623
$inc_altivec_h
1624
int main(void) {
1625
    vector signed int v1, v2, v3;
1626
    v1 = vec_add(v2,v3);
1627
    return 0;
1628
}
1629
EOF
1630

    
1631
    # check if our compiler supports braces for vector declarations
1632
    check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
1633
$inc_altivec_h
1634
int main (void) { (vector int) {1}; return 0; }
1635
EOF
1636
fi
1637

    
1638
# We have to check if pld is a nop and disable it.
1639
enabled armv4l  && check_asm pld     '"pld [r0]"'
1640
enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
1641
enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
1642
enabled armvfp  && check_asm armvfp  '"fadds s0, s0, s0"'
1643
enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
1644
enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
1645
enabled neon    && check_asm neon    '"vadd.i16 q0, q0, q0"'
1646
enabled vis     && check_asm vis     '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
1647

    
1648
enabled vis && add_cflags "-mcpu=ultrasparc -mtune=ultrasparc"
1649

    
1650
# ---
1651
# big/little-endian test
1652
check_cc <<EOF || die "endian test failed"
1653
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
1654
EOF
1655
od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
1656

    
1657
# ---
1658
# check availability of some header files
1659

    
1660
if check_func dlopen; then
1661
    ldl=
1662
elif check_func dlopen -ldl; then
1663
    ldl=-ldl
1664
fi
1665

    
1666
check_func  fork
1667
check_func  gethrtime
1668
check_func  getrusage
1669
check_func  inet_aton $network_extralibs
1670
check_func  memalign
1671
check_func  mkstemp
1672
check_func_headers windows.h GetProcessTimes
1673

    
1674
check_header byteswap.h
1675
check_header conio.h
1676
check_header dlfcn.h
1677
check_header malloc.h
1678
check_header poll.h
1679
check_header sys/mman.h
1680
check_header sys/resource.h
1681
check_header sys/select.h
1682
check_header termios.h
1683

    
1684
if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
1685
    die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
1686
fi
1687

    
1688
enabled  zlib && check_lib  zlib.h      zlibVersion -lz   || disable  zlib
1689
enabled bzlib && check_lib bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
1690

    
1691
# check for some common methods of building with pthread support
1692
# do this before the optional library checks as some of them require pthreads
1693
if enabled pthreads; then
1694
    if check_func pthread_create; then
1695
        :
1696
    elif check_func pthread_create -pthread; then
1697
        add_cflags -pthread
1698
        add_extralibs -pthread
1699
    elif check_func pthread_create -pthreads; then
1700
        add_cflags -pthreads
1701
        add_extralibs -pthreads
1702
    elif check_func pthread_create -lpthreadGC2; then
1703
        add_extralibs -lpthreadGC2
1704
    elif ! check_lib pthread.h pthread_create -lpthread; then
1705
        die "ERROR: can't find pthreads library"
1706
    fi
1707
fi
1708

    
1709
for thread in $THREADS_LIST; do
1710
    if enabled $thread; then
1711
        test -n "$thread_type" &&
1712
            die "ERROR: Only one thread type must be selected." ||
1713
            thread_type="$thread"
1714
    fi
1715
done
1716

    
1717
check_lib math.h sin -lm
1718

    
1719
# test for C99 functions in math.h
1720
for func in llrint lrint lrintf round roundf; do
1721
    check_exec <<EOF && enable $func || disable $func
1722
#include <math.h>
1723
int main(void) { return ($func(3.999f) > 0)?0:1; }
1724
EOF
1725
done
1726

    
1727
# these are off by default, so fail if requested and not available
1728
enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
1729
enabled libamr_nb  && require  libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
1730
enabled libamr_wb  && require  libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
1731
enabled libdirac   && add_cflags "$(pkg-config --cflags dirac)" \
1732
                   && require  libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init -ldirac_decoder \
1733
                   && require  libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init -ldirac_encoder
1734
enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
1735
enabled libfaad    && require2 libfaad faad.h faacDecOpen -lfaad
1736
enabled libgsm     && require  libgsm gsm.h gsm_create -lgsm
1737
enabled libmp3lame && require  LAME lame/lame.h lame_init -lmp3lame -lm
1738
enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
1739
enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) \
1740
                        && require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
1741
enabled libtheora  && require  libtheora theora/theora.h theora_info_init -ltheora -logg
1742
enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
1743
enabled libx264    && require x264 x264.h x264_encoder_open -lx264 -lm \
1744
                   && require_cpp_condition x264 x264.h "X264_BUILD >= 65"
1745
enabled libxvid    && require  Xvid xvid.h xvid_global -lxvidcore
1746
enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
1747

    
1748
# libdc1394 check
1749
if enabled libdc1394; then
1750
    { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
1751
        enable libdc1394_2; } ||
1752
    { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
1753
        enable libdc1394_1; } ||
1754
    die "ERROR: No version of libdc1394 found "
1755
fi
1756

    
1757

    
1758
_restrict=
1759
for restrict_keyword in restrict __restrict__ __restrict; do
1760
    check_cc <<EOF && _restrict=$restrict_keyword && break
1761
void foo(char * $restrict_keyword p);
1762
EOF
1763
done
1764

    
1765
test "$vhook" = "default" && vhook="$dlopen"
1766

    
1767
if test "$target_os" = cygwin -o "$target_os" = mingw32 && enabled_all static vhook ; then
1768
    disable vhook
1769
    echo
1770
    echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
1771
    echo "Patches welcome."
1772
    echo
1773
fi
1774

    
1775
if enabled vhook; then
1776
    check_ldflags -rdynamic
1777
    check_ldflags -export-dynamic
1778
fi
1779

    
1780
check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
1781
check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
1782

    
1783
##########################################
1784
# SDL check
1785

    
1786
disable sdl_too_old
1787
disable sdl
1788
SDL_CONFIG="${cross_prefix}sdl-config"
1789
if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
1790
    sdl_cflags=`"${SDL_CONFIG}" --cflags`
1791
    temp_cflags $sdl_cflags
1792
    temp_extralibs `"${SDL_CONFIG}" --libs`
1793
    if check_lib2 SDL.h SDL_Init; then
1794
        _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
1795
        if test "$_sdlversion" -lt 121 ; then
1796
            enable sdl_too_old
1797
        else
1798
            enable sdl
1799
            check_cc $sdl_cflags <<EOF && enable sdl_video_size
1800
#include <SDL.h>
1801
int main(int argc, char **argv){
1802
    const SDL_VideoInfo *vi = SDL_GetVideoInfo();
1803
    int w = vi->current_w;
1804
    return 0;
1805
}
1806
EOF
1807
        fi
1808
    fi
1809
    restore_flags
1810
fi
1811

    
1812
texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
1813

    
1814
##########################################
1815
# Network check
1816

    
1817
if enabled network; then
1818
    check_type sys/socket.h socklen_t
1819
    # Prefer arpa/inet.h over winsock2
1820
    if check_header arpa/inet.h ; then
1821
        check_func closesocket
1822
    elif check_header winsock2.h ; then
1823
        network_extralibs="-lws2_32"
1824
        check_type ws2tcpip.h socklen_t
1825
        check_func_headers winsock2.h closesocket
1826
    fi
1827
fi
1828

    
1829
##########################################
1830
# IPv6 check
1831

    
1832
enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
1833
#include <sys/types.h>
1834
#include <sys/socket.h>
1835
#include <netinet/in.h>
1836
#include <netdb.h>
1837
int main(void) {
1838
    struct sockaddr_storage saddr;
1839
    struct ipv6_mreq mreq6;
1840
    getaddrinfo(0,0,0,0);
1841
    getnameinfo(0,0,0,0,0,0,0);
1842
    IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
1843
}
1844
EOF
1845

    
1846
check_header linux/videodev.h
1847
check_header linux/videodev2.h
1848
check_header sys/videoio.h
1849

    
1850
check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
1851

    
1852
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1853
{ check_header dev/bktr/ioctl_meteor.h &&
1854
  check_header dev/bktr/ioctl_bt848.h; } ||
1855
{ check_header machine/ioctl_meteor.h &&
1856
  check_header machine/ioctl_bt848.h; } ||
1857
{ check_header dev/video/meteor/ioctl_meteor.h &&
1858
  check_header dev/video/bktr/ioctl_bt848.h; } ||
1859
check_header dev/ic/bt8xx.h
1860

    
1861
check_header sys/soundcard.h
1862
check_header soundcard.h
1863

    
1864
# deal with the X11 frame grabber
1865
enabled x11grab                         &&
1866
check_header X11/Xlib.h                 &&
1867
check_header X11/extensions/XShm.h      &&
1868
check_func XOpenDisplay -lX11           &&
1869
check_func XShmCreateImage -lX11 -lXext
1870

    
1871
enabled debug && add_cflags -g"$debuglevel"
1872

    
1873
# add some useful compiler flags if supported
1874
check_cflags -Wdeclaration-after-statement
1875
check_cflags -Wall
1876
check_cflags -Wno-switch
1877
check_cflags -Wdisabled-optimization
1878
check_cflags -Wpointer-arith
1879
check_cflags -Wredundant-decls
1880
check_cflags -Wno-pointer-sign
1881
check_cflags -Wcast-qual
1882
check_cflags -Wwrite-strings
1883
check_cflags -Wtype-limits
1884
enabled extra_warnings && check_cflags -Winline
1885

    
1886
# add some linker flags
1887
check_ldflags -Wl,--warn-common
1888
check_ldflags -Wl,--as-needed
1889
check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
1890
check_ldflags -Wl,-Bsymbolic
1891

    
1892
if enabled small; then
1893
    check_cflags -Os            # not all compilers support -Os
1894
    optimizations="small"
1895
elif enabled optimizations; then
1896
    if $cc -v 2>&1 | grep -q xlc; then
1897
        add_cflags  "-O5"
1898
        add_ldflags "-O5"
1899
    else
1900
        add_cflags "-O3"
1901
    fi
1902
fi
1903
check_cflags -fno-math-errno
1904
check_cflags -fno-signed-zeros
1905

    
1906
# add some flags for Intel C Compiler
1907
if $cc --version 2> /dev/null | grep -q Intel; then
1908
  # Just warnings, no remarks
1909
  check_cflags -w1
1910
  # -wd: Disable following warnings
1911
  # 144, 167, 556: -Wno-pointer-sign
1912
  # 10006: ignoring unknown option -fno-signed-zeros
1913
  # 10156: ignoring option '-W'; no argument required
1914
  check_cflags -wd144,167,556,10006,10156
1915
  # 11030: Warning unknown option --as-needed
1916
  # 10156: ignoring option '-export'; no argument required
1917
  check_ldflags -wd10156,11030
1918
  # Allow to compile with optimizations
1919
  check_ldflags -march=$cpu
1920
fi
1921

    
1922
# PIC flags for shared library objects where they are needed
1923
if enabled shared; then
1924
    # LIBOBJFLAGS may have already been set in the OS configuration
1925
    if test -z "$LIBOBJFLAGS" ; then
1926
        case "$arch" in
1927
            x86_64|ia64|alpha|sparc*|power*|parisc*|mips*) LIBOBJFLAGS='$(PIC)' ;;
1928
        esac
1929
    fi
1930
fi
1931

    
1932
if enabled gprof; then
1933
    add_cflags  "-p"
1934
    add_ldflags "-p"
1935
fi
1936

    
1937
VHOOKCFLAGS="-fPIC"
1938

    
1939
# Find out if the .align argument is a power of two or not.
1940
if test $asmalign_pot = "unknown"; then
1941
    disable asmalign_pot
1942
    echo 'asm (".align 3");' | check_cc && enable asmalign_pot
1943
fi
1944

    
1945
enabled_any $DECODER_LIST      && enable decoders
1946
enabled_any $ENCODER_LIST      && enable encoders
1947
enabled_any $BSF_LIST          && enable bsfs
1948
enabled_any $DEMUXER_LIST      && enable demuxers
1949
enabled_any $MUXER_LIST        && enable muxers
1950
enabled_any $FILTER_LIST       && enable filters
1951
enabled_any $INDEV_LIST        && enable demuxers
1952
enabled_any $OUTDEV_LIST       && enable muxers
1953
enabled_any $PROTOCOL_LIST     && enable protocols
1954

    
1955
enabled_any $THREADS_LIST      && enable threads
1956

    
1957
check_deps $CONFIG_LIST       \
1958
           $HAVE_LIST         \
1959
           $DECODER_LIST      \
1960
           $ENCODER_LIST      \
1961
           $PARSER_LIST       \
1962
           $BSF_LIST          \
1963
           $DEMUXER_LIST      \
1964
           $MUXER_LIST        \
1965
           $FILTER_LIST       \
1966
           $INDEV_LIST        \
1967
           $OUTDEV_LIST       \
1968
           $PROTOCOL_LIST     \
1969

    
1970
enabled libdc1394 && append pkg_requires "libraw1394"
1971
enabled libdirac  && append pkg_requires "dirac"
1972
enabled libtheora && append pkg_requires "theora"
1973
enabled libvorbis && append pkg_requires "vorbisenc"
1974

    
1975
echo "install prefix            $prefix"
1976
echo "source path               $source_path"
1977
echo "C compiler                $cc"
1978
echo ".align is power-of-two    $asmalign_pot"
1979
echo "ARCH                      $arch ($cpu)"
1980
if test "$build_suffix" != ""; then
1981
    echo "build suffix              $build_suffix"
1982
fi
1983
if test "$extra_version" != ""; then
1984
    echo "version string suffix     $extra_version"
1985
fi
1986
echo "big-endian                ${bigendian-no}"
1987
if test $arch = "x86_32" -o $arch = "x86_64"; then
1988
    echo "yasm                      ${yasm-no}"
1989
    echo "MMX enabled               ${mmx-no}"
1990
    echo "CMOV enabled              ${cmov-no}"
1991
    echo "CMOV is fast              ${fast_cmov-no}"
1992
    echo "EBX available             ${ebx_available-no}"
1993
    echo "EBP available             ${ebp_available-no}"
1994
fi
1995
if test $arch = "armv4l"; then
1996
    echo "ARMv5TE enabled           ${armv5te-no}"
1997
    echo "ARMv6 enabled             ${armv6-no}"
1998
    echo "ARM VFP enabled           ${armvfp-no}"
1999
    echo "IWMMXT enabled            ${iwmmxt-no}"
2000
    echo "NEON enabled              ${neon-no}"
2001
fi
2002
if test $arch = "mips"; then
2003
    echo "MMI enabled               ${mmi-no}"
2004
fi
2005
if test $arch = "powerpc"; then
2006
    echo "AltiVec enabled           ${altivec-no}"
2007
    echo "dcbzl available           ${dcbzl-no}"
2008
fi
2009
echo "gprof enabled             ${gprof-no}"
2010
echo "debug symbols             ${debug-no}"
2011
echo "strip symbols             ${stripping-no}"
2012
echo "optimizations             ${optimizations-no}"
2013
echo "static                    ${static-no}"
2014
echo "shared                    ${shared-no}"
2015
echo "postprocessing support    ${postproc-no}"
2016
echo "software scaler enabled   ${swscale-no}"
2017
echo "new filter support        ${avfilter-no}"
2018
echo "filters using lavformat   ${avfilter_lavf-no}"
2019
echo "video hooking             ${vhook-no}"
2020
if enabled vhook; then
2021
    echo "Imlib2 support            ${imlib2-no}"
2022
    echo "FreeType support          ${freetype2-no}"
2023
fi
2024
echo "network support           ${network-no}"
2025
if enabled network; then
2026
    echo "IPv6 support              ${ipv6-no}"
2027
fi
2028
echo "threading support         ${thread_type-no}"
2029
echo "SDL support               ${sdl-no}"
2030
if enabled sdl_too_old; then
2031
    echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
2032
fi
2033
echo "Sun medialib support      ${mlib-no}"
2034
echo "AVISynth enabled          ${avisynth-no}"
2035
echo "libamr-nb support         ${libamr_nb-no}"
2036
echo "libamr-wb support         ${libamr_wb-no}"
2037
echo "libdc1394 support         ${libdc1394-no}"
2038
echo "libdirac enabled          ${libdirac-no}"
2039
echo "libfaac enabled           ${libfaac-no}"
2040
echo "libfaad enabled           ${libfaad-no}"
2041
echo "libfaad dlopened          ${libfaadbin-no}"
2042
echo "libgsm enabled            ${libgsm-no}"
2043
echo "libmp3lame enabled        ${libmp3lame-no}"
2044
echo "libnut enabled            ${libnut-no}"
2045
echo "libschroedinger enabled   ${libschroedinger-no}"
2046
echo "libtheora enabled         ${libtheora-no}"
2047
echo "libvorbis enabled         ${libvorbis-no}"
2048
echo "libx264 enabled           ${libx264-no}"
2049
echo "libxvid enabled           ${libxvid-no}"
2050
echo "zlib enabled              ${zlib-no}"
2051
echo "bzlib enabled             ${bzlib-no}"
2052
echo
2053

    
2054
for type in decoder encoder parser demuxer muxer protocol filter bsf indev outdev; do
2055
    echo "Enabled ${type}s:"
2056
    eval list=\$$(toupper $type)_LIST
2057
    for part in $list; do
2058
        enabled $part && echo ${part%_*}
2059
    done | sort | pr -3 -t
2060
    echo
2061
done
2062

    
2063
license="LGPL"
2064
if enabled nonfree; then
2065
    license="unredistributable"
2066
elif enabled gpl; then
2067
    license="GPL"
2068
fi
2069

    
2070
echo "License: $license"
2071

    
2072
echo "Creating config.mak and config.h..."
2073

    
2074
echo "# Automatically generated by configure - do not modify!" > config.mak
2075
echo "/* Automatically generated by configure - do not modify! */" > $TMPH
2076
echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
2077
echo "#define FFMPEG_CONFIG_H" >> $TMPH
2078
echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
2079

    
2080
echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
2081
echo "prefix=$prefix" >> config.mak
2082
echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
2083
echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
2084
echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
2085
echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
2086
echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
2087
echo "CC=$cc" >> config.mak
2088
echo "YASM=$yasmexe" >> config.mak
2089
echo "AR=$ar" >> config.mak
2090
echo "RANLIB=$ranlib" >> config.mak
2091
echo "LN_S=$ln_s" >> config.mak
2092
enabled stripping &&
2093
    echo "STRIP=$strip" >> config.mak ||
2094
    echo "STRIP=echo ignoring strip" >> config.mak
2095

    
2096
echo "OPTFLAGS=$CFLAGS" >> config.mak
2097
echo "VHOOKCFLAGS=$VHOOKCFLAGS" >> config.mak
2098
echo "LDFLAGS=$LDFLAGS" >> config.mak
2099
echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
2100
echo "SHFLAGS=$SHFLAGS" >> config.mak
2101
echo "YASMFLAGS=$YASMFLAGS" >> config.mak
2102
echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
2103
echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
2104
echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
2105
echo "BUILD_STATIC=$static" >> config.mak
2106
echo "BUILDSUF=$build_suffix" >> config.mak
2107
echo "FULLNAME=$FULLNAME" >> config.mak
2108
echo "LIBPREF=$LIBPREF" >> config.mak
2109
echo "LIBSUF=$LIBSUF" >> config.mak
2110
echo "LIBNAME=$LIBNAME" >> config.mak
2111
echo "SLIBPREF=$SLIBPREF" >> config.mak
2112
echo "SLIBSUF=$SLIBSUF" >> config.mak
2113
echo "EXESUF=$EXESUF" >> config.mak
2114
echo "EXTRA_VERSION=$extra_version" >> config.mak
2115
echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
2116

    
2117
if enabled bigendian; then
2118
    echo "WORDS_BIGENDIAN=yes" >> config.mak
2119
    echo "#define WORDS_BIGENDIAN 1" >> $TMPH
2120
fi
2121

    
2122
if enabled sdl; then
2123
    echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
2124
    echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
2125
fi
2126
if enabled texi2html; then
2127
    echo "BUILD_DOC=yes" >> config.mak
2128
fi
2129

    
2130
get_version(){
2131
    name=$1
2132
    file=$source_path/$2
2133
    eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
2134
    eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
2135
    lcname=$(tolower $name)
2136
    eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
2137
    eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
2138
}
2139

    
2140
get_version LIBSWSCALE  libswscale/swscale.h
2141
get_version LIBPOSTPROC libpostproc/postprocess.h
2142
get_version LIBAVCODEC  libavcodec/avcodec.h
2143
get_version LIBAVDEVICE libavdevice/avdevice.h
2144
get_version LIBAVFORMAT libavformat/avformat.h
2145
get_version LIBAVUTIL   libavutil/avutil.h
2146
get_version LIBAVFILTER libavfilter/avfilter.h
2147

    
2148
if enabled shared; then
2149
    echo "BUILD_SHARED=yes" >> config.mak
2150
    echo "PIC=-fPIC -DPIC" >> config.mak
2151
    echo "LIBTARGET=${LIBTARGET}" >> config.mak
2152
    echo "SLIBNAME=${SLIBNAME}" >> config.mak
2153
    echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
2154
    echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
2155
    echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
2156
    echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
2157
    echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
2158
    echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
2159
fi
2160
echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
2161
echo "EXTRALIBS=$extralibs" >> config.mak
2162

    
2163
print_config ARCH_   $TMPH config.mak $ARCH_LIST
2164
print_config HAVE_   $TMPH config.mak $HAVE_LIST
2165
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST       \
2166
                                      $DECODER_LIST      \
2167
                                      $ENCODER_LIST      \
2168
                                      $PARSER_LIST       \
2169
                                      $BSF_LIST          \
2170
                                      $DEMUXER_LIST      \
2171
                                      $MUXER_LIST        \
2172
                                      $FILTER_LIST       \
2173
                                      $PROTOCOL_LIST     \
2174
                                      $INDEV_LIST        \
2175
                                      $OUTDEV_LIST       \
2176

    
2177
echo "#define restrict $_restrict" >> $TMPH
2178

    
2179
if enabled small; then
2180
    echo "#define av_always_inline"  >> $TMPH
2181
fi
2182

    
2183
echo "SRC_PATH=\"$source_path\"" >> config.mak
2184
echo "SRC_PATH_BARE=$source_path" >> config.mak
2185
echo "BUILD_ROOT=\"$PWD\"" >> config.mak
2186

    
2187
# Apparently it's not possible to portably echo a backslash.
2188
enabled asmalign_pot &&
2189
    printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
2190
    printf '#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\\n\\t"\n' >> $TMPH
2191

    
2192
echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
2193

    
2194
echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
2195

    
2196
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
2197
cmp -s $TMPH config.h &&
2198
    echo "config.h is unchanged" ||
2199
    mv -f $TMPH config.h
2200

    
2201
rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
2202

    
2203
# build tree in object directory if source path is different from current one
2204
if enabled source_path_used; then
2205
    DIRS="\
2206
        doc               \
2207
        libavcodec        \
2208
        libavcodec/alpha  \
2209
        libavcodec/armv4l \
2210
        libavcodec/bfin   \
2211
        libavcodec/i386   \
2212
        libavcodec/mlib   \
2213
        libavcodec/ppc    \
2214
        libavcodec/sh4    \
2215
        libavcodec/sparc  \
2216
        libavdevice       \
2217
        libavfilter       \
2218
        libavformat       \
2219
        libavutil         \
2220
        libpostproc       \
2221
        libswscale        \
2222
        tests             \
2223
        tools             \
2224
        vhook             \
2225
        "
2226
    FILES="\
2227
        Makefile             \
2228
        common.mak           \
2229
        subdir.mak           \
2230
        doc/texi2pod.pl      \
2231
        libavcodec/Makefile  \
2232
        libavdevice/Makefile \
2233
        libavfilter/Makefile \
2234
        libavformat/Makefile \
2235
        libavutil/Makefile   \
2236
        libpostproc/Makefile \
2237
        libswscale/Makefile  \
2238
        "
2239
    for dir in $DIRS ; do
2240
        mkdir -p $dir
2241
    done
2242
    for f in $FILES ; do
2243
        $ln_s "$source_path/$f" $f
2244
    done
2245
fi
2246

    
2247

    
2248
# build pkg-config files
2249

    
2250
pkgconfig_generate(){
2251
name=$1
2252
shortname=${name#lib}
2253
comment=$2
2254
version=$3
2255
libs=$4
2256
requires=$5
2257
cat <<EOF > $name/$name.pc
2258
prefix=$prefix
2259
exec_prefix=\${prefix}
2260
libdir=$libdir
2261
includedir=$incdir
2262

    
2263
Name: $name
2264
Description: $comment
2265
Version: $version
2266
Requires: $(disabled shared && echo $requires)
2267
Requires.private: $(enabled shared && echo $requires)
2268
Conflicts:
2269
Libs: -L\${libdir} -l${shortname} $(disabled shared && echo $libs)
2270
Libs.private: $(enabled shared && echo $libs)
2271
Cflags: -I\${includedir}
2272
EOF
2273
cat <<EOF > $name/$name-uninstalled.pc
2274
prefix=
2275
exec_prefix=
2276
libdir=\${pcfiledir}
2277
includedir=${source_path}
2278

    
2279
Name: $name
2280
Description: $comment
2281
Version: $version
2282
Requires: $requires
2283
Conflicts:
2284
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
2285
Cflags: -I\${includedir}
2286
EOF
2287
}
2288

    
2289
pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
2290
pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
2291
pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
2292
pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "$pkg_requires libavformat = $LIBAVFORMAT_VERSION"
2293
enabled avfilter &&
2294
    pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
2295
enabled postproc &&
2296
    pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
2297
if enabled swscale; then
2298
    pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
2299
else
2300
    pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
2301
    apply libswscale/libswscale.pc sed s/^Libs:.*$/Libs:/
2302
fi