Statistics
| Branch: | Revision:

ffmpeg / configure @ 300cde27

History | View | Annotate | Download (84.3 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
LC_ALL=C
12
export LC_ALL
13

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

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

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

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

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

    
57
show_help(){
58
cat <<EOF
59
Usage: configure [options]
60
Options: [defaults in brackets after descriptions]
61

    
62
Standard options:
63
  --help                   print this message
64
  --logfile=FILE           log tests and output to FILE [config.err]
65
  --disable-logging        do not log configure debug information
66
  --prefix=PREFIX          install in PREFIX [$prefix]
67
  --bindir=DIR             install binaries in DIR [PREFIX/bin]
68
  --datadir=DIR            install data files in DIR [PREFIX/share/ffmpeg]
69
  --libdir=DIR             install libs in DIR [PREFIX/lib]
70
  --shlibdir=DIR           install shared libs in DIR [PREFIX/lib]
71
  --incdir=DIR             install includes in DIR [PREFIX/include]
72
  --mandir=DIR             install man page in DIR [PREFIX/share/man]
73

    
74
Configuration options:
75
  --disable-static         do not build static libraries [no]
76
  --enable-shared          build shared libraries [no]
77
  --enable-gpl             allow use of GPL code, the resulting libs
78
                           and binaries will be under GPL [no]
79
  --enable-version3        upgrade (L)GPL to version 3 [no]
80
  --enable-nonfree         allow use of nonfree code, the resulting libs
81
                           and binaries will be unredistributable [no]
82
  --disable-doc            do not build documentation
83
  --disable-ffmpeg         disable ffmpeg build
84
  --disable-ffplay         disable ffplay build
85
  --disable-ffserver       disable ffserver build
86
  --enable-postproc        enable GPLed postprocessing support [no]
87
  --enable-avfilter        video filter support [no]
88
  --enable-avfilter-lavf   video filters dependent on avformat [no]
89
  --enable-beosthreads     use BeOS threads [no]
90
  --enable-os2threads      use OS/2 threads [no]
91
  --enable-pthreads        use pthreads [no]
92
  --enable-w32threads      use Win32 threads [no]
93
  --enable-x11grab         enable X11 grabbing [no]
94
  --disable-network        disable network support [no]
95
  --disable-ipv6           disable IPv6 support [no]
96
  --disable-mpegaudio-hp   faster (but less accurate) MPEG audio decoding [no]
97
  --enable-gray            enable full grayscale support (slower color)
98
  --disable-swscale-alpha  disable alpha channel support in swscale
99
  --disable-fastdiv        disable table-based division
100
  --enable-small           optimize for size instead of speed
101
  --disable-aandct         disable AAN DCT code
102
  --disable-fft            disable FFT code
103
  --disable-golomb         disable Golomb code
104
  --disable-lpc            disable LPC code
105
  --disable-mdct           disable MDCT code
106
  --disable-rdft           disable RDFT code
107
  --disable-vaapi          disable VAAPI code
108
  --disable-vdpau          disable VDPAU code
109
  --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
110
  --enable-hardcoded-tables use hardcoded tables instead of runtime generation
111
  --enable-memalign-hack   emulate memalign, interferes with memory debuggers
112
  --enable-beos-netserver  enable BeOS netserver
113
  --disable-encoder=NAME   disable encoder NAME
114
  --enable-encoder=NAME    enable encoder NAME
115
  --disable-encoders       disable all encoders
116
  --disable-decoder=NAME   disable decoder NAME
117
  --enable-decoder=NAME    enable decoder NAME
118
  --disable-decoders       disable all decoders
119
  --disable-hwaccel=NAME   disable hwaccel NAME
120
  --enable-hwaccel=NAME    enable hwaccel NAME
121
  --disable-hwaccels       disable all hwaccels
122
  --disable-muxer=NAME     disable muxer NAME
123
  --enable-muxer=NAME      enable muxer NAME
124
  --disable-muxers         disable all muxers
125
  --disable-demuxer=NAME   disable demuxer NAME
126
  --enable-demuxer=NAME    enable demuxer NAME
127
  --disable-demuxers       disable all demuxers
128
  --enable-parser=NAME     enable parser NAME
129
  --disable-parser=NAME    disable parser NAME
130
  --disable-parsers        disable all parsers
131
  --enable-bsf=NAME        enable bitstream filter NAME
132
  --disable-bsf=NAME       disable bitstream filter NAME
133
  --disable-bsfs           disable all bitstream filters
134
  --enable-protocol=NAME   enable protocol NAME
135
  --disable-protocol=NAME  disable protocol NAME
136
  --disable-protocols      disable all protocols
137
  --disable-indev=NAME     disable input device NAME
138
  --disable-outdev=NAME    disable output device NAME
139
  --disable-indevs         disable input devices
140
  --disable-outdevs        disable output devices
141
  --disable-devices        disable all devices
142
  --enable-filter=NAME     enable filter NAME
143
  --disable-filter=NAME    disable filter NAME
144
  --disable-filters        disable all filters
145
  --list-decoders          show all available decoders
146
  --list-encoders          show all available encoders
147
  --list-hwaccels          show all available hardware accelerators
148
  --list-muxers            show all available muxers
149
  --list-demuxers          show all available demuxers
150
  --list-parsers           show all available parsers
151
  --list-protocols         show all available protocols
152
  --list-bsfs              show all available bitstream filters
153
  --list-indevs            show all available input devices
154
  --list-outdevs           show all available output devices
155
  --list-filters           show all available filters
156

    
157
External library support:
158
  --enable-avisynth        enable reading of AVISynth script files [no]
159
  --enable-bzlib           enable bzlib [autodetect]
160
  --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
161
  --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
162
  --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394
163
                           and libraw1394 [no]
164
  --enable-libdirac        enable Dirac support via libdirac [no]
165
  --enable-libfaac         enable FAAC support via libfaac [no]
166
  --enable-libfaad         enable FAAD support via libfaad [no]
167
  --enable-libfaadbin      open libfaad.so.0 at runtime [no]
168
  --enable-libgsm          enable GSM support via libgsm [no]
169
  --enable-libmp3lame      enable MP3 encoding via libmp3lame [no]
170
  --enable-libnut          enable NUT (de)muxing via libnut,
171
                           native (de)muxer exists [no]
172
  --enable-libopenjpeg     enable JPEG 2000 decoding via OpenJPEG [no]
173
  --enable-libschroedinger enable Dirac support via libschroedinger [no]
174
  --enable-libspeex        enable Speex decoding via libspeex [no]
175
  --enable-libtheora       enable Theora encoding via libtheora [no]
176
  --enable-libvorbis       enable Vorbis encoding via libvorbis,
177
                           native implementation exists [no]
178
  --enable-libx264         enable H.264 encoding via x264 [no]
179
  --enable-libxvid         enable Xvid encoding via xvidcore,
180
                           native MPEG-4/Xvid encoder exists [no]
181
  --enable-mlib            enable Sun medialib [no]
182
  --enable-zlib            enable zlib [autodetect]
183

    
184
Advanced options (experts only):
185
  --source-path=PATH       path to source code [$source_path]
186
  --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]
187
  --enable-cross-compile   assume a cross-compiler is used
188
  --sysroot=PATH           root of cross-build tree
189
  --sysinclude=PATH        location of cross-build system headers
190
  --target-os=OS           compiler targets OS [$target_os]
191
  --target-exec=CMD        command to run executables on target
192
  --target-path=DIR        path to view of build directory on target
193
  --nm=NM                  use nm tool
194
  --as=AS                  use assembler AS [$as_default]
195
  --cc=CC                  use C compiler CC [$cc_default]
196
  --ld=LD                  use linker LD
197
  --host-cc=HOSTCC         use host C compiler HOSTCC
198
  --host-cflags=HCFLAGS    use HCFLAGS when compiling for host
199
  --host-ldflags=HLDFLAGS  use HLDFLAGS when linking for host
200
  --host-libs=HLIBS        use libs HLIBS when linking for host
201
  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]
202
  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
203
  --extra-libs=ELIBS       add ELIBS [$ELIBS]
204
  --extra-version=STRING   version string suffix []
205
  --build-suffix=SUFFIX    library name suffix []
206
  --arch=ARCH              select architecture [$arch]
207
  --cpu=CPU                select the minimum required CPU (affects
208
                           instruction selection, may crash on older CPUs)
209
  --enable-powerpc-perf    enable performance report on PPC
210
                           (requires enabling PMC)
211
  --disable-altivec        disable AltiVec optimizations
212
  --disable-amd3dnow       disable 3DNow! optimizations
213
  --disable-amd3dnowext    disable 3DNow! extended optimizations
214
  --disable-mmx            disable MMX optimizations
215
  --disable-mmx2           disable MMX2 optimizations
216
  --disable-sse            disable SSE optimizations
217
  --disable-ssse3          disable SSSE3 optimizations
218
  --disable-armv5te        disable armv5te optimizations
219
  --disable-armv6          disable armv6 optimizations
220
  --disable-armv6t2        disable armv6t2 optimizations
221
  --disable-armvfp         disable ARM VFP optimizations
222
  --disable-iwmmxt         disable iwmmxt optimizations
223
  --disable-mmi            disable MMI optimizations
224
  --disable-neon           disable neon optimizations
225
  --disable-vis            disable VIS optimizations
226
  --disable-yasm           disable use of yasm assembler
227
  --enable-pic             build position-independent code
228

    
229
Developer options (useful when working on FFmpeg itself):
230
  --disable-debug          disable debugging symbols
231
  --enable-debug=LEVEL     set the debug level [$debuglevel]
232
  --enable-gprof           enable profiling with gprof [$gprof]
233
  --disable-optimizations  disable compiler optimizations
234
  --enable-extra-warnings  enable more compiler warnings
235
  --disable-stripping      disable stripping of executables and shared libraries
236

    
237
NOTE: Object files are built at the place where configure is launched.
238
EOF
239
  exit 0
240
}
241

    
242
log(){
243
    echo "$@" >> $logfile
244
}
245

    
246
log_file(){
247
    log BEGIN $1
248
    pr -n -t $1 >> $logfile
249
    log END $1
250
}
251

    
252
echolog(){
253
    log "$@"
254
    echo "$@"
255
}
256

    
257
die(){
258
    echolog "$@"
259
    cat <<EOF
260

    
261
If you think configure made a mistake, make sure you are using the latest
262
version from SVN.  If the latest version fails, report the problem to the
263
ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
264
EOF
265
    if disabled logging; then
266
        cat <<EOF
267
Rerun configure with logging enabled (do not use --disable-logging), and
268
include the log this produces with your report.
269
EOF
270
    else
271
cat <<EOF
272
Include the log file "$logfile" produced by configure as this will help
273
solving the problem.
274
EOF
275
    fi
276
    exit 1
277
}
278

    
279
# Avoid locale weirdness, besides we really just want to translate ASCII.
280
toupper(){
281
    echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
282
}
283

    
284
tolower(){
285
    echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
286
}
287

    
288
c_escape(){
289
    echo "$*" | sed 's/["\\]/\\\0/g'
290
}
291

    
292
sh_quote(){
293
    v=$(echo "$1" | sed "s/'/'\\\\''/g")
294
    test "$v" = "${v#*[ |&;<>()$\`\\\"\'*?\[\]#~=%]}" || v="'$v'"
295
    echo "$v"
296
}
297

    
298
filter(){
299
    pat=$1
300
    shift
301
    for v; do
302
        eval "case $v in $pat) echo $v ;; esac"
303
    done
304
}
305

    
306
set_all(){
307
    value=$1
308
    shift
309
    for var in $*; do
310
        eval $var=$value
311
    done
312
}
313

    
314
set_weak(){
315
    value=$1
316
    shift
317
    for var; do
318
        eval : \${$var:=$value}
319
    done
320
}
321

    
322
pushvar(){
323
    for var in $*; do
324
        eval level=\${${var}_level:=0}
325
        eval ${var}_${level}="\$$var"
326
        eval ${var}_level=$(($level+1))
327
    done
328
}
329

    
330
popvar(){
331
    for var in $*; do
332
        eval level=\${${var}_level:-0}
333
        test $level = 0 && continue
334
        eval level=$(($level-1))
335
        eval $var="\${${var}_${level}}"
336
        eval ${var}_level=$level
337
        eval unset ${var}_${level}
338
    done
339
}
340

    
341
enable(){
342
    set_all yes $*
343
}
344

    
345
disable(){
346
    set_all no $*
347
}
348

    
349
enable_weak(){
350
    set_weak yes $*
351
}
352

    
353
disable_weak(){
354
    set_weak no $*
355
}
356

    
357
enable_safe(){
358
    for var; do
359
        enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
360
    done
361
}
362

    
363
disable_safe(){
364
    for var; do
365
        disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
366
    done
367
}
368

    
369
do_enable_deep(){
370
    for var; do
371
        enabled $var && continue
372
        eval sel="\$${var}_select"
373
        eval sgs="\$${var}_suggest"
374
        pushvar var sgs
375
        enable_deep $sel
376
        popvar sgs
377
        enable_deep_weak $sgs
378
        popvar var
379
    done
380
}
381

    
382
enable_deep(){
383
    do_enable_deep $*
384
    enable $*
385
}
386

    
387
enable_deep_weak(){
388
    do_enable_deep $*
389
    enable_weak $*
390
}
391

    
392
enabled(){
393
    test "${1#!}" = "$1" && op== || op=!=
394
    eval test "x\$${1#!}" $op "xyes"
395
}
396

    
397
disabled(){
398
    test "${1#!}" = "$1" && op== || op=!=
399
    eval test "x\$${1#!}" $op "xno"
400
}
401

    
402
enabled_all(){
403
    for opt; do
404
        enabled $opt || return 1
405
    done
406
}
407

    
408
disabled_all(){
409
    for opt; do
410
        disabled $opt || return 1
411
    done
412
}
413

    
414
enabled_any(){
415
    for opt; do
416
        enabled $opt && return 0
417
    done
418
}
419

    
420
disabled_any(){
421
    for opt; do
422
        disabled $opt && return 0
423
    done
424
    return 1
425
}
426

    
427
set_default(){
428
    for opt; do
429
        eval : \${$opt:=\$${opt}_default}
430
    done
431
}
432

    
433
is_in(){
434
    value=$1
435
    shift
436
    for var in $*; do
437
        [ $var = $value ] && return 0
438
    done
439
    return 1
440
}
441

    
442
check_deps(){
443
    for cfg; do
444
        cfg="${cfg#!}"
445
        enabled ${cfg}_checking && die "Circular dependency for $cfg."
446
        disabled ${cfg}_checking && continue
447
        enable ${cfg}_checking
448

    
449
        eval dep_all="\$${cfg}_deps"
450
        eval dep_any="\$${cfg}_deps_any"
451
        eval dep_sel="\$${cfg}_select"
452
        eval dep_sgs="\$${cfg}_suggest"
453
        eval dep_ifa="\$${cfg}_if"
454
        eval dep_ifn="\$${cfg}_if_any"
455

    
456
        pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
457
        check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
458
        popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
459

    
460
        [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
461
        [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
462
        enabled_all  $dep_all || disable $cfg
463
        enabled_any  $dep_any || disable $cfg
464
        disabled_any $dep_sel && disable $cfg
465

    
466
        if enabled $cfg; then
467
            eval dep_extralibs="\$${cfg}_extralibs"
468
            test -n "$dep_extralibs" && add_extralibs $dep_extralibs
469
            enable_deep $dep_sel
470
            enable_deep_weak $dep_sgs
471
        fi
472

    
473
        disable ${cfg}_checking
474
    done
475
}
476

    
477
print_config(){
478
    pfx=$1
479
    header=$2
480
    makefile=$3
481
    shift 3
482
    for cfg; do
483
        ucname="$(toupper $cfg)"
484
        if enabled $cfg; then
485
            echo "#define ${pfx}${ucname} 1" >> $header
486
            echo "${pfx}${ucname}=yes" >> $makefile
487
        else
488
            echo "#define ${pfx}${ucname} 0" >> $header
489
            echo "!${pfx}${ucname}=yes" >> $makefile
490
        fi
491
    done
492
}
493

    
494
flags_saved(){
495
    (: ${SAVE_CFLAGS?}) 2> /dev/null
496
}
497

    
498
save_flags(){
499
    flags_saved && return
500
    SAVE_CFLAGS="$CFLAGS"
501
    SAVE_LDFLAGS="$LDFLAGS"
502
    SAVE_extralibs="$extralibs"
503
}
504

    
505
restore_flags(){
506
    flags_saved || return
507
    CFLAGS="$SAVE_CFLAGS"
508
    LDFLAGS="$SAVE_LDFLAGS"
509
    extralibs="$SAVE_extralibs"
510
    unset SAVE_CFLAGS
511
    unset SAVE_LDFLAGS
512
    unset SAVE_extralibs
513
}
514

    
515
temp_cflags(){
516
    save_flags
517
    CFLAGS="$CFLAGS $*"
518
}
519

    
520
temp_ldflags(){
521
    save_flags
522
    LDFLAGS="$LDFLAGS $*"
523
}
524

    
525
temp_extralibs(){
526
    save_flags
527
    extralibs="$extralibs $*"
528
}
529

    
530
append(){
531
    var=$1
532
    shift
533
    flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
534
    eval "$var=\"\$$var $*\""
535
}
536

    
537
add_cppflags(){
538
    append CPPFLAGS $($filter_cppflags "$@")
539
}
540

    
541
add_cflags(){
542
    append CFLAGS $($filter_cflags "$@")
543
}
544

    
545
add_asflags(){
546
    append ASFLAGS $($filter_asflags "$@")
547
}
548

    
549
add_ldflags(){
550
    append LDFLAGS "$@"
551
}
552

    
553
add_extralibs(){
554
    append extralibs "$@"
555
}
556

    
557
check_cmd(){
558
    log "$@"
559
    "$@" >> $logfile 2>&1
560
}
561

    
562
check_cc(){
563
    log check_cc "$@"
564
    cat > $TMPC
565
    log_file $TMPC
566
    check_cmd $cc $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
567
}
568

    
569
check_cpp(){
570
    log check_cpp "$@"
571
    cat > $TMPC
572
    log_file $TMPC
573
    check_cmd $cc $CPPFLAGS $CFLAGS "$@" -E -o $TMPO $TMPC
574
}
575

    
576
check_as(){
577
    log check_as "$@"
578
    cat > $TMPC
579
    log_file $TMPC
580
    check_cmd $as $CPPFLAGS $ASFLAGS "$@" -c -o $TMPO $TMPC
581
}
582

    
583
check_asm(){
584
    log check_asm "$@"
585
    name="$1"
586
    asm="$2"
587
    shift 2
588
    disable $name
589
    check_as "$@" <<EOF && enable $name
590
void foo(void){ __asm__ volatile($asm); }
591
EOF
592
}
593

    
594
check_yasm(){
595
    log check_yasm "$@"
596
    echo "$1" > $TMPS
597
    log_file $TMPS
598
    shift 1
599
    check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
600
}
601

    
602
check_ld(){
603
    log check_ld "$@"
604
    flags=''
605
    libs=''
606
    for f; do
607
        test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
608
    done
609
    check_cc $($filter_cflags $flags) || return
610
    check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
611
}
612

    
613
check_cppflags(){
614
    log check_cppflags "$@"
615
    set -- $($filter_cppflags "$@")
616
    check_cc "$@" <<EOF && append CPPFLAGS "$@"
617
int x;
618
EOF
619
}
620

    
621
check_cflags(){
622
    log check_cflags "$@"
623
    set -- $($filter_cflags "$@")
624
    check_cc "$@" <<EOF && append CFLAGS "$@"
625
int x;
626
EOF
627
}
628

    
629
test_ldflags(){
630
    log test_ldflags "$@"
631
    check_ld "$@" <<EOF
632
int main(void){ return 0; }
633
EOF
634
}
635

    
636
check_ldflags(){
637
    log check_ldflags "$@"
638
    test_ldflags "$@" && add_ldflags "$@"
639
}
640

    
641
check_header(){
642
    log check_header "$@"
643
    header=$1
644
    shift
645
    disable_safe $header
646
    check_cpp "$@" <<EOF && enable_safe $header
647
#include <$header>
648
int x;
649
EOF
650
}
651

    
652
check_func(){
653
    log check_func "$@"
654
    func=$1
655
    shift
656
    disable $func
657
    check_ld "$@" <<EOF && enable $func
658
extern int $func();
659
int main(void){ $func(); }
660
EOF
661
}
662

    
663
check_func_headers(){
664
    log check_func_headers "$@"
665
    headers=$1
666
    func=$2
667
    shift 2
668
    disable $func
669
    incs=""
670
    for hdr in $headers; do
671
        incs="$incs
672
#include <$hdr>"
673
    done
674
    check_ld "$@" <<EOF && enable $func && enable_safe $headers
675
$incs
676
int main(int argc, char **argv){
677
    return (long) $func;
678
}
679
EOF
680
}
681

    
682
check_cpp_condition(){
683
    log check_cpp_condition "$@"
684
    header=$1
685
    condition=$2
686
    shift 2
687
    check_cpp $($filter_cppflags "$@") <<EOF
688
#include <$header>
689
#if !($condition)
690
#error "unsatisfied condition: $condition"
691
#endif
692
EOF
693
}
694

    
695
check_lib(){
696
    log check_lib "$@"
697
    header="$1"
698
    func="$2"
699
    shift 2
700
    temp_extralibs "$@"
701
    check_header $header && check_func $func && add_extralibs "$@"
702
    err=$?
703
    restore_flags
704
    return $err
705
}
706

    
707
check_lib2(){
708
    log check_lib2 "$@"
709
    headers="$1"
710
    func="$2"
711
    shift 2
712
    check_func_headers "$headers" $func "$@" && add_extralibs "$@"
713
}
714

    
715
check_exec(){
716
    check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
717
}
718

    
719
check_exec_crash(){
720
    code=$(cat)
721

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

    
728
    (check_exec "$@") >> $logfile 2>&1 <<EOF
729
#include <signal.h>
730
static void sighandler(int sig){
731
    raise(SIGTERM);
732
}
733
int main(void){
734
    signal(SIGILL, sighandler);
735
    signal(SIGFPE, sighandler);
736
    signal(SIGSEGV, sighandler);
737
#ifdef SIGBUS
738
    signal(SIGBUS, sighandler);
739
#endif
740
    { $code }
741
}
742
EOF
743
}
744

    
745
check_type(){
746
    log check_type "$@"
747
    headers=$1
748
    type=$2
749
    shift 2
750
    disable_safe "$type"
751
    incs=""
752
    for hdr in $headers; do
753
        incs="$incs
754
#include <$hdr>"
755
    done
756
    check_cc "$@" <<EOF && enable_safe "$type"
757
$incs
758
$type v;
759
EOF
760
}
761

    
762
require(){
763
    name="$1"
764
    header="$2"
765
    func="$3"
766
    shift 3
767
    check_lib $header $func "$@" || die "ERROR: $name not found"
768
}
769

    
770
require2(){
771
    name="$1"
772
    headers="$2"
773
    func="$3"
774
    shift 3
775
    check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
776
}
777

    
778
check_foo_config(){
779
    cfg=$1
780
    pkg=$2
781
    header=$3
782
    func=$4
783
    shift 4
784
    disable $cfg
785
    check_cmd ${pkg}-config --version
786
    err=$?
787
    if test "$err" = 0; then
788
        temp_cflags $(${pkg}-config --cflags)
789
        temp_extralibs $(${pkg}-config --libs)
790
        check_lib "$@" $header $func && enable $cfg
791
    fi
792
    return $err
793
}
794

    
795
check_host_cc(){
796
    log check_host_cc "$@"
797
    cat > $TMPC
798
    log_file $TMPC
799
    check_cmd $host_cc $host_cflags "$@" -c -o $TMPO $TMPC
800
}
801

    
802
check_host_cflags(){
803
    log check_host_cflags "$@"
804
    check_host_cc "$@" <<EOF && append host_cflags "$@"
805
int x;
806
EOF
807
}
808

    
809
apply(){
810
    file=$1
811
    shift
812
    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
813
}
814

    
815
# CONFIG_LIST contains configurable options, while HAVE_LIST is for
816
# system-dependent things.
817

    
818
COMPONENT_LIST="
819
    bsfs
820
    decoders
821
    demuxers
822
    encoders
823
    filters
824
    hwaccels
825
    indevs
826
    muxers
827
    outdevs
828
    parsers
829
    protocols
830
"
831

    
832
CONFIG_LIST="
833
    $COMPONENT_LIST
834
    aandct
835
    avfilter
836
    avfilter_lavf
837
    avisynth
838
    beos_netserver
839
    bzlib
840
    doc
841
    fastdiv
842
    ffmpeg
843
    ffplay
844
    ffserver
845
    fft
846
    golomb
847
    gpl
848
    gprof
849
    gray
850
    hardcoded_tables
851
    ipv6
852
    libdc1394
853
    libdirac
854
    libfaac
855
    libfaad
856
    libfaadbin
857
    libgsm
858
    libmp3lame
859
    libnut
860
    libopencore_amrnb
861
    libopencore_amrwb
862
    libopenjpeg
863
    libschroedinger
864
    libspeex
865
    libtheora
866
    libvorbis
867
    libx264
868
    libxvid
869
    lpc
870
    mdct
871
    memalign_hack
872
    mlib
873
    mpegaudio_hp
874
    network
875
    nonfree
876
    pic
877
    postproc
878
    powerpc_perf
879
    rdft
880
    runtime_cpudetect
881
    shared
882
    small
883
    static
884
    swscale_alpha
885
    vaapi
886
    vdpau
887
    version3
888
    x11grab
889
    zlib
890
"
891

    
892
THREADS_LIST='
893
    beosthreads
894
    os2threads
895
    pthreads
896
    w32threads
897
'
898

    
899
ARCH_LIST='
900
    alpha
901
    arm
902
    avr32
903
    avr32_ap
904
    avr32_uc
905
    bfin
906
    ia64
907
    m68k
908
    mips
909
    mips64
910
    parisc
911
    ppc
912
    ppc64
913
    s390
914
    sh4
915
    sparc
916
    sparc64
917
    x86
918
    x86_32
919
    x86_64
920
'
921

    
922
ARCH_EXT_LIST='
923
    altivec
924
    amd3dnow
925
    amd3dnowext
926
    armv5te
927
    armv6
928
    armv6t2
929
    armvfp
930
    iwmmxt
931
    mmi
932
    mmx
933
    mmx2
934
    neon
935
    ppc4xx
936
    sse
937
    ssse3
938
    vis
939
'
940

    
941
HAVE_LIST="
942
    $ARCH_EXT_LIST
943
    $THREADS_LIST
944
    alsa_asoundlib_h
945
    altivec_h
946
    arpa_inet_h
947
    attribute_packed
948
    bigendian
949
    bswap
950
    closesocket
951
    cmov
952
    conio_h
953
    dcbzl
954
    dev_bktr_ioctl_bt848_h
955
    dev_bktr_ioctl_meteor_h
956
    dev_ic_bt8xx_h
957
    dev_video_meteor_ioctl_meteor_h
958
    dev_video_bktr_ioctl_bt848_h
959
    dlfcn_h
960
    dlopen
961
    dos_paths
962
    ebp_available
963
    ebx_available
964
    exp2
965
    exp2f
966
    fast_64bit
967
    fast_clz
968
    fast_cmov
969
    fast_unaligned
970
    fork
971
    getaddrinfo
972
    gethrtime
973
    GetProcessTimes
974
    getrusage
975
    inet_aton
976
    inline_asm
977
    isatty
978
    ldbrx
979
    libdc1394_1
980
    libdc1394_2
981
    llrint
982
    log2
983
    log2f
984
    loongson
985
    lrint
986
    lrintf
987
    lzo1x_999_compress
988
    machine_ioctl_bt848_h
989
    machine_ioctl_meteor_h
990
    malloc_h
991
    memalign
992
    mkstemp
993
    pld
994
    posix_memalign
995
    round
996
    roundf
997
    sdl
998
    sdl_video_size
999
    setmode
1000
    socklen_t
1001
    soundcard_h
1002
    poll_h
1003
    struct_addrinfo
1004
    struct_sockaddr_storage
1005
    sys_mman_h
1006
    sys_resource_h
1007
    sys_select_h
1008
    sys_soundcard_h
1009
    sys_videoio_h
1010
    ten_operands
1011
    termios_h
1012
    threads
1013
    truncf
1014
    vfp_args
1015
    VirtualAlloc
1016
    winsock2_h
1017
    xform_asm
1018
    yasm
1019
"
1020

    
1021
# options emitted with CONFIG_ prefix but not available on command line
1022
CONFIG_EXTRA="
1023
    gplv3
1024
    lgplv3
1025
"
1026

    
1027
CMDLINE_SELECT="
1028
    $ARCH_EXT_LIST
1029
    $CONFIG_LIST
1030
    $THREADS_LIST
1031
    cross_compile
1032
    debug
1033
    extra_warnings
1034
    logging
1035
    optimizations
1036
    stripping
1037
    yasm
1038
"
1039

    
1040
PATHS_LIST='
1041
    bindir
1042
    datadir
1043
    incdir
1044
    libdir
1045
    mandir
1046
    prefix
1047
    shlibdir
1048
'
1049

    
1050
CMDLINE_SET="
1051
    $PATHS_LIST
1052
    arch
1053
    as
1054
    build_suffix
1055
    cc
1056
    cpu
1057
    cross_prefix
1058
    dep_cc
1059
    extra_version
1060
    host_cc
1061
    host_cflags
1062
    host_ldflags
1063
    host_libs
1064
    host_os
1065
    ld
1066
    logfile
1067
    nm
1068
    source_path
1069
    sysinclude
1070
    sysroot
1071
    target_exec
1072
    target_os
1073
    target_path
1074
"
1075

    
1076
CMDLINE_APPEND="
1077
    extra_cflags
1078
"
1079

    
1080
# code dependency declarations
1081

    
1082
# architecture extensions
1083
altivec_deps="ppc"
1084
amd3dnow_deps="mmx"
1085
amd3dnowext_deps="amd3dnow"
1086
armv5te_deps="arm"
1087
armv6_deps="arm"
1088
armv6t2_deps="arm"
1089
armvfp_deps="arm"
1090
iwmmxt_deps="arm"
1091
mmi_deps="mips"
1092
mmx_deps="x86"
1093
mmx2_deps="mmx"
1094
neon_deps="arm"
1095
ppc4xx_deps="ppc"
1096
sse_deps="mmx"
1097
ssse3_deps="sse"
1098
vis_deps="sparc"
1099

    
1100
fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
1101

    
1102
need_memalign="altivec neon sse"
1103
inline_asm_deps="!tms470"
1104

    
1105
# decoders / encoders / hardware accelerators
1106
aac_decoder_select="fft mdct aac_parser"
1107
aac_encoder_select="fft mdct"
1108
ac3_decoder_select="fft mdct ac3_parser"
1109
alac_encoder_select="lpc"
1110
atrac3_decoder_select="fft mdct"
1111
cavs_decoder_select="golomb"
1112
cook_decoder_select="fft mdct"
1113
cscd_decoder_suggest="zlib"
1114
dca_decoder_select="fft mdct"
1115
dnxhd_encoder_select="aandct"
1116
dxa_decoder_select="zlib"
1117
eac3_decoder_select="ac3_decoder"
1118
eamad_decoder_select="aandct"
1119
eatgq_decoder_select="aandct"
1120
eatqi_decoder_select="aandct"
1121
ffv1_decoder_select="golomb"
1122
flac_decoder_select="golomb"
1123
flac_encoder_select="golomb lpc"
1124
flashsv_decoder_select="zlib"
1125
flashsv_encoder_select="zlib"
1126
flv_decoder_select="h263_decoder"
1127
flv_encoder_select="h263_encoder"
1128
h261_encoder_select="aandct"
1129
h263_decoder_select="h263_parser"
1130
h263_encoder_select="aandct"
1131
h263_vaapi_hwaccel_deps="va_va_h"
1132
h263_vaapi_hwaccel_select="vaapi h263_decoder"
1133
h263i_decoder_select="h263_decoder"
1134
h263p_encoder_select="h263_encoder"
1135
h264_decoder_select="golomb"
1136
h264_vaapi_hwaccel_deps="va_va_h"
1137
h264_vaapi_hwaccel_select="vaapi"
1138
h264_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1139
h264_vdpau_decoder_select="vdpau h264_decoder"
1140
imc_decoder_select="fft mdct"
1141
jpegls_decoder_select="golomb"
1142
jpegls_encoder_select="golomb"
1143
ljpeg_encoder_select="aandct"
1144
loco_decoder_select="golomb"
1145
mjpeg_encoder_select="aandct"
1146
mlp_decoder_select="mlp_parser"
1147
mpeg1video_encoder_select="aandct"
1148
mpeg2video_encoder_select="aandct"
1149
mpeg4_decoder_select="h263_decoder mpeg4video_parser"
1150
mpeg4_encoder_select="h263_encoder"
1151
mpeg_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1152
mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
1153
mpeg1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1154
mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
1155
mpeg2_vaapi_hwaccel_deps="va_va_h"
1156
mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
1157
mpeg4_vaapi_hwaccel_deps="va_va_h"
1158
mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
1159
mpeg4_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1160
mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
1161
mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
1162
mpeg_xvmc_decoder_select="mpegvideo_decoder"
1163
msmpeg4v1_decoder_select="h263_decoder"
1164
msmpeg4v1_encoder_select="h263_encoder"
1165
msmpeg4v2_decoder_select="h263_decoder"
1166
msmpeg4v2_encoder_select="h263_encoder"
1167
msmpeg4v3_decoder_select="h263_decoder"
1168
msmpeg4v3_encoder_select="h263_encoder"
1169
nellymoser_decoder_select="fft mdct"
1170
nellymoser_encoder_select="fft mdct"
1171
png_decoder_select="zlib"
1172
png_encoder_select="zlib"
1173
qdm2_decoder_select="fft mdct rdft"
1174
rv10_decoder_select="h263_decoder"
1175
rv10_encoder_select="h263_encoder"
1176
rv20_decoder_select="h263_decoder"
1177
rv20_encoder_select="h263_encoder"
1178
rv30_decoder_select="golomb"
1179
rv40_decoder_select="golomb"
1180
shorten_decoder_select="golomb"
1181
sonic_decoder_select="golomb"
1182
sonic_encoder_select="golomb"
1183
sonic_ls_encoder_select="golomb"
1184
svq3_decoder_select="golomb"
1185
svq3_decoder_suggest="zlib"
1186
theora_decoder_select="vp3_decoder"
1187
tiff_decoder_suggest="zlib"
1188
tiff_encoder_suggest="zlib"
1189
truehd_decoder_select="mlp_decoder"
1190
tscc_decoder_select="zlib"
1191
vc1_decoder_select="h263_decoder"
1192
vc1_vaapi_hwaccel_deps="va_va_h"
1193
vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
1194
vc1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1195
vc1_vdpau_decoder_select="vdpau vc1_decoder"
1196
vorbis_decoder_select="fft mdct"
1197
vorbis_encoder_select="fft mdct"
1198
vp6a_decoder_select="vp6_decoder"
1199
vp6f_decoder_select="vp6_decoder"
1200
wmav1_decoder_select="fft mdct"
1201
wmav1_encoder_select="fft mdct"
1202
wmav2_decoder_select="fft mdct"
1203
wmav2_encoder_select="fft mdct"
1204
wmv1_decoder_select="h263_decoder"
1205
wmv1_encoder_select="h263_encoder"
1206
wmv2_decoder_select="h263_decoder"
1207
wmv2_encoder_select="h263_encoder"
1208
wmv3_decoder_select="vc1_decoder"
1209
wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
1210
wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
1211
zlib_decoder_select="zlib"
1212
zlib_encoder_select="zlib"
1213
zmbv_decoder_select="zlib"
1214
zmbv_encoder_select="zlib"
1215

    
1216
# parsers
1217
h264_parser_select="golomb"
1218

    
1219
# bitstream_filters
1220
aac_adtstoasc_bsf_select="aac_parser"
1221

    
1222
# external libraries
1223
libdirac_decoder_deps="libdirac !libschroedinger"
1224
libdirac_encoder_deps="libdirac"
1225
libfaac_encoder_deps="libfaac"
1226
libfaad_decoder_deps="libfaad"
1227
libfaadbin_decoder_extralibs='$ldl'
1228
libgsm_decoder_deps="libgsm"
1229
libgsm_encoder_deps="libgsm"
1230
libgsm_ms_decoder_deps="libgsm"
1231
libgsm_ms_encoder_deps="libgsm"
1232
libmp3lame_encoder_deps="libmp3lame"
1233
libopencore_amrnb_decoder_deps="libopencore_amrnb"
1234
libopencore_amrnb_encoder_deps="libopencore_amrnb"
1235
libopencore_amrwb_decoder_deps="libopencore_amrwb"
1236
libopenjpeg_decoder_deps="libopenjpeg"
1237
libschroedinger_decoder_deps="libschroedinger"
1238
libschroedinger_encoder_deps="libschroedinger"
1239
libspeex_decoder_deps="libspeex"
1240
libtheora_encoder_deps="libtheora"
1241
libvorbis_encoder_deps="libvorbis"
1242
libx264_encoder_deps="libx264"
1243
libxvid_encoder_deps="libxvid"
1244

    
1245
# demuxers / muxers
1246
ac3_demuxer_deps="ac3_parser"
1247
asf_stream_muxer_select="asf_muxer"
1248
avisynth_demuxer_deps="avisynth"
1249
dirac_demuxer_deps="dirac_parser"
1250
eac3_demuxer_select="ac3_parser"
1251
ipod_muxer_select="mov_muxer"
1252
libnut_demuxer_deps="libnut"
1253
libnut_muxer_deps="libnut"
1254
matroska_audio_muxer_select="matroska_muxer"
1255
matroska_demuxer_suggest="zlib bzlib"
1256
mov_demuxer_suggest="zlib"
1257
mp3_demuxer_deps="mpegaudio_parser"
1258
mp4_muxer_select="mov_muxer"
1259
mpegtsraw_demuxer_select="mpegts_demuxer"
1260
mxf_d10_muxer_select="mxf_muxer"
1261
ogg_demuxer_select="golomb"
1262
psp_muxer_select="mov_muxer"
1263
rtsp_demuxer_deps="sdp_demuxer"
1264
sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
1265
spdif_muxer_select="aac_parser"
1266
tg2_muxer_select="mov_muxer"
1267
tgp_muxer_select="mov_muxer"
1268
w64_demuxer_deps="wav_demuxer"
1269

    
1270
# indevs / outdevs
1271
alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1272
alsa_indev_extralibs="-lasound"
1273
alsa_outdev_deps="alsa_asoundlib_h"
1274
alsa_outdev_extralibs="-lasound"
1275
audio_beos_indev_deps="audio_beos"
1276
audio_beos_indev_extralibs="-lmedia -lbe"
1277
audio_beos_outdev_deps="audio_beos"
1278
audio_beos_outdev_extralibs="-lmedia -lbe"
1279
bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
1280
dv1394_indev_deps="dv1394 dv_demuxer"
1281
jack_indev_deps="jack_jack_h"
1282
jack_indev_extralibs="-ljack"
1283
libdc1394_indev_deps="libdc1394"
1284
oss_indev_deps_any="soundcard_h sys_soundcard_h"
1285
oss_outdev_deps_any="soundcard_h sys_soundcard_h"
1286
v4l_indev_deps="linux_videodev_h"
1287
v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
1288
vfwcap_indev_deps="capCreateCaptureWindow"
1289
vfwcap_indev_extralibs="-lvfw32"
1290
x11_grab_device_indev_deps="x11grab XShmCreateImage"
1291
x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
1292

    
1293
# protocols
1294
gopher_protocol_deps="network"
1295
http_protocol_deps="network"
1296
rtmp_protocol_deps="tcp_protocol"
1297
rtp_protocol_deps="udp_protocol"
1298
tcp_protocol_deps="network"
1299
udp_protocol_deps="network"
1300

    
1301
# filters
1302
movie_filter_deps="avfilter_lavf"
1303

    
1304
# programs
1305
ffplay_deps="sdl"
1306
ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
1307
ffserver_extralibs='$ldl'
1308

    
1309
doc_deps="texi2html"
1310

    
1311
# default parameters
1312

    
1313
logfile="config.err"
1314

    
1315
# installation paths
1316
prefix_default="/usr/local"
1317
bindir_default='${prefix}/bin'
1318
datadir_default='${prefix}/share/ffmpeg'
1319
incdir_default='${prefix}/include'
1320
libdir_default='${prefix}/lib'
1321
mandir_default='${prefix}/share/man'
1322
shlibdir_default="$libdir_default"
1323

    
1324
# toolchain
1325
ar="ar"
1326
cc_default="gcc"
1327
cc_version=\"unknown\"
1328
host_cc_default="gcc"
1329
ln_s="ln -sf"
1330
nm_default="nm"
1331
objformat="elf"
1332
ranlib="ranlib"
1333
strip="strip"
1334
yasmexe="yasm"
1335

    
1336
# machine
1337
arch=$(uname -m)
1338
cpu="generic"
1339

    
1340
# OS
1341
target_os=$(tolower $(uname -s))
1342
host_os=$target_os
1343

    
1344
# configurable options
1345
enable debug
1346
enable doc
1347
enable fastdiv
1348
enable ffmpeg
1349
enable ffplay
1350
enable ffserver
1351
enable ipv6
1352
enable mpegaudio_hp
1353
enable network
1354
enable optimizations
1355
enable protocols
1356
enable static
1357
enable stripping
1358
enable swscale_alpha
1359

    
1360
# build settings
1361
SHFLAGS='-shared -Wl,-soname,$$(@F)'
1362
FFSERVERLDFLAGS=-Wl,-E
1363
LIBPREF="lib"
1364
LIBSUF=".a"
1365
FULLNAME='$(NAME)$(BUILDSUF)'
1366
LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
1367
SLIBPREF="lib"
1368
SLIBSUF=".so"
1369
SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
1370
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1371
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
1372
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
1373

    
1374
CC_O='-o $@'
1375

    
1376
host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
1377
host_libs='-lm'
1378

    
1379
target_path='.'
1380

    
1381
# gcc stupidly only outputs the basename of targets with -MM, but we need the
1382
# full relative path for objects in subdirectories for non-recursive Make.
1383
DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
1384
DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
1385

    
1386
# find source path
1387
source_path="$(dirname "$0")"
1388
enable source_path_used
1389
if test -f configure; then
1390
    source_path="$(pwd)"
1391
    disable source_path_used
1392
else
1393
    source_path="$(cd "$source_path"; pwd)"
1394
    echo "$source_path" | grep -q '[[:blank:]]' &&
1395
        die "Out of tree builds are impossible with whitespace in source path."
1396
    test -e "$source_path/config.h" &&
1397
        die "Out of tree builds are impossible with config.h in source dir."
1398
fi
1399

    
1400
for v in "$@"; do
1401
    r=${v#*=}
1402
    l=${v%"$r"}
1403
    r=$(sh_quote "$r")
1404
    FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
1405
done
1406

    
1407
find_things(){
1408
    thing=$1
1409
    pattern=$2
1410
    file=$source_path/$3
1411
    sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
1412
}
1413

    
1414
ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
1415
DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
1416
HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
1417
PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
1418
BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
1419
MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
1420
DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
1421
OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
1422
INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
1423
PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
1424
FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
1425

    
1426
enable $ARCH_EXT_LIST \
1427
       $DECODER_LIST \
1428
       $ENCODER_LIST \
1429
       $HWACCEL_LIST \
1430
       $PARSER_LIST \
1431
       $BSF_LIST \
1432
       $DEMUXER_LIST \
1433
       $MUXER_LIST \
1434
       $FILTER_LIST \
1435
       $PROTOCOL_LIST \
1436
       $INDEV_LIST \
1437
       $OUTDEV_LIST \
1438

    
1439
die_unknown(){
1440
    echo "Unknown option \"$1\"."
1441
    echo "See $0 --help for available options."
1442
    exit 1
1443
}
1444

    
1445
show_list() {
1446
    suffix=_$1
1447
    shift
1448
    echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
1449
    exit 0
1450
}
1451

    
1452
for opt do
1453
    optval="${opt#*=}"
1454
    case "$opt" in
1455
    --extra-ldflags=*) add_ldflags $optval
1456
    ;;
1457
    --extra-libs=*) add_extralibs $optval
1458
    ;;
1459
    --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
1460
    ;;
1461
    --enable-debug=*) debuglevel="$optval"
1462
    ;;
1463
    --enable-*=*|--disable-*=*)
1464
    eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
1465
    is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1466
    eval list=\$$(toupper $thing)_LIST
1467
    name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1468
    $action $(filter "$name" $list)
1469
    ;;
1470
    --enable-?*|--disable-?*)
1471
    eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
1472
    if is_in $option $COMPONENT_LIST; then
1473
        test $action = disable && action=unset
1474
        eval $action \$$(toupper ${option%s})_LIST
1475
    elif is_in $option $CMDLINE_SELECT; then
1476
        $action $option
1477
    else
1478
        die_unknown $opt
1479
    fi
1480
    ;;
1481
    --list-*)
1482
        NAME="${opt#--list-}"
1483
        is_in $NAME $COMPONENT_LIST || die_unknown $opt
1484
        NAME=${NAME%s}
1485
        eval show_list $NAME \$$(toupper $NAME)_LIST
1486
    ;;
1487
    --help|-h) show_help
1488
    ;;
1489
    *)
1490
    optname="${opt%%=*}"
1491
    optname="${optname#--}"
1492
    optname=$(echo "$optname" | sed 's/-/_/g')
1493
    if is_in $optname $CMDLINE_SET; then
1494
        eval $optname='$optval'
1495
    elif is_in $optname $CMDLINE_APPEND; then
1496
        append $optname "$optval"
1497
    else
1498
         die_unknown $opt
1499
    fi
1500
    ;;
1501
    esac
1502
done
1503

    
1504
disabled logging && logfile=/dev/null
1505

    
1506
echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
1507
set >> $logfile
1508

    
1509
test -n "$cross_prefix" && enable cross_compile
1510

    
1511
ar="${cross_prefix}${ar}"
1512
cc_default="${cross_prefix}${cc_default}"
1513
nm_default="${cross_prefix}${nm_default}"
1514
ranlib="${cross_prefix}${ranlib}"
1515
strip="${cross_prefix}${strip}"
1516

    
1517
sysinclude_default="${sysroot}/usr/include"
1518

    
1519
set_default cc nm sysinclude
1520
enabled cross_compile || host_cc_default=$cc
1521
set_default host_cc
1522

    
1523
exesuf() {
1524
    case $1 in
1525
        mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
1526
    esac
1527
}
1528

    
1529
EXESUF=$(exesuf $target_os)
1530
HOSTEXESUF=$(exesuf $host_os)
1531

    
1532
# set temporary file name
1533
: ${TMPDIR:=$TEMPDIR}
1534
: ${TMPDIR:=$TMP}
1535
: ${TMPDIR:=/tmp}
1536

    
1537
if ! check_cmd type mktemp; then
1538
    # simple replacement for missing mktemp
1539
    # NOT SAFE FOR GENERAL USE
1540
    mktemp(){
1541
        echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
1542
    }
1543
fi
1544

    
1545
tmpfile(){
1546
    tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
1547
        (set -C; exec > $tmp) 2>/dev/null ||
1548
        die "Unable to create temporary file in $TMPDIR."
1549
    append TMPFILES $tmp
1550
    eval $1=$tmp
1551
}
1552

    
1553
trap 'rm -f -- $TMPFILES' EXIT
1554
trap exit HUP INT TERM
1555

    
1556
tmpfile TMPC  .c
1557
tmpfile TMPE  $EXESUF
1558
tmpfile TMPH  .h
1559
tmpfile TMPO  .o
1560
tmpfile TMPS  .S
1561
tmpfile TMPV  .ver
1562
tmpfile TMPSH .sh
1563

    
1564
unset -f mktemp
1565

    
1566
# make sure we can execute files in $TMPDIR
1567
cat > $TMPSH 2>> $logfile <<EOF
1568
#! /bin/sh
1569
EOF
1570
chmod +x $TMPSH >> $logfile 2>&1
1571
if ! $TMPSH >> $logfile 2>&1; then
1572
    cat <<EOF
1573
Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
1574
variable to another directory and make sure that it is not mounted noexec.
1575
EOF
1576
    die "Sanity test failed."
1577
fi
1578

    
1579
filter_cflags=echo
1580
filter_cppflags=echo
1581
filter_asflags=echo
1582

    
1583
if   $cc -v 2>&1 | grep -qi ^gcc; then
1584
    cc_type=gcc
1585
    cc_version=__VERSION__
1586
    if ! $cc -dumpversion | grep -q '^2\.'; then
1587
        CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1588
        AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1589
    fi
1590
elif $cc --version 2>/dev/null | grep -q Intel; then
1591
    cc_type=icc
1592
    cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
1593
    CC_DEPFLAGS='-MMD'
1594
    AS_DEPFLAGS='-MMD'
1595
elif $cc -v 2>&1 | grep -q xlc; then
1596
    cc_type=xlc
1597
    cc_version="AV_STRINGIFY(__IBMC__)"
1598
elif $cc -V 2>/dev/null | grep -q Compaq; then
1599
    cc_type=ccc
1600
    cc_version="AV_STRINGIFY(__DECC_VER)"
1601
    DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
1602
    debuglevel=3
1603
    add_ldflags -Wl,-z,now # calls to libots crash without this
1604
elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
1605
    test -d "$sysroot" || die "No valid sysroot specified."
1606
    cc_type=armcc
1607
    cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
1608
    armcc_conf="$PWD/armcc.conf"
1609
    $cc --arm_linux_configure                 \
1610
        --arm_linux_config_file="$armcc_conf" \
1611
        --configure_sysroot="$sysroot"        \
1612
        --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
1613
        die "Error creating armcc configuration file."
1614
    cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
1615
    as_default="${cross_prefix}gcc"
1616
    CC_DEPFLAGS='-MMD'
1617
    AS_DEPFLAGS='-MMD'
1618
elif $cc -version 2>/dev/null | grep -q TMS470; then
1619
    cc_type=tms470
1620
    cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
1621
    cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
1622
    CC_O='-fr=$(@D)'
1623
    as_default="${cross_prefix}gcc"
1624
    ld_default="${cross_prefix}gcc"
1625
    TMPO=$(basename $TMPC .c).o
1626
    append TMPFILES $TMPO
1627
    add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
1628
    CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
1629
    AS_DEPFLAGS='-MMD'
1630
    filter_cflags=tms470_flags
1631
    tms470_flags(){
1632
        for flag; do
1633
            case $flag in
1634
                -march=*|-mcpu=*)
1635
                    case "${flag#*=}" in
1636
                        armv7-a|cortex-a*)      echo -mv=7a8 ;;
1637
                        armv7-r|cortex-r*)      echo -mv=7r4 ;;
1638
                        armv7-m|cortex-m*)      echo -mv=7m3 ;;
1639
                        armv6*|arm11*)          echo -mv=6   ;;
1640
                        armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
1641
                                                echo -mv=5e  ;;
1642
                        armv4*|arm7*|arm9[24]*) echo -mv=4   ;;
1643
                    esac
1644
                    ;;
1645
                -mfpu=neon)     echo --float_support=vfpv3 --neon ;;
1646
                -mfpu=vfp)      echo --float_support=vfpv2        ;;
1647
                -msoft-float)   echo --float_support=vfplib       ;;
1648
                -Os)            echo -O3 -mf=2                    ;;
1649
                -O[0-3])        echo $flag -mf=5                  ;;
1650
                -g)             echo -g -mn                       ;;
1651
            esac
1652
        done
1653
    }
1654
elif $cc -v 2>&1 | grep -q clang; then
1655
    cc_type=clang
1656
    cc_version=__VERSION__
1657
    CC_DEPFLAGS='-MMD'
1658
    AS_DEPFLAGS='-MMD'
1659
elif $cc -V 2>&1 | grep -q Sun; then
1660
    cc_type=suncc
1661
    cc_version="AV_STRINGIFY(__SUNPRO_C)"
1662
    DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
1663
    DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
1664
    filter_cflags=suncc_flags
1665
    suncc_flags(){
1666
        for flag; do
1667
            case $flag in
1668
                -march=*|-mcpu=*)
1669
                    case "${flag#*=}" in
1670
                        native)                   echo -xtarget=native       ;;
1671
                        v9)                       echo -xarch=sparc          ;;
1672
                        ultrasparc)               echo -xarch=sparcvis       ;;
1673
                        ultrasparc3|niagara*)     echo -xarch=sparcvis2      ;;
1674
                        i586|pentium)             echo -xchip=pentium        ;;
1675
                        i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
1676
                        pentium3*|c3-2)           echo -xtarget=pentium3     ;;
1677
                        pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
1678
                        pentium4*)          echo -xtarget=pentium4           ;;
1679
                        prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
1680
                        *-sse3)             echo -xarch=sse3                 ;;
1681
                        core2)              echo -xarch=ssse3 -xchip=core2   ;;
1682
                        amdfam10|barcelona)       echo -xarch=sse4_1         ;;
1683
                        athlon-4|athlon-[mx]p)    echo -xarch=ssea           ;;
1684
                        k8|opteron|athlon64|athlon-fx)
1685
                                                  echo -xarch=sse2a          ;;
1686
                        athlon*)                  echo -xarch=pentium_proa   ;;
1687
                    esac
1688
                    ;;
1689
                -std=c99)             echo -xc99              ;;
1690
                -fomit-frame-pointer) echo -xregs=frameptr    ;;
1691
                -fPIC)                echo -KPIC -xcode=pic32 ;;
1692
                -Os)                  echo -O5 -xspace        ;;
1693
                -W*,*)                echo $flag              ;;
1694
                -f*-*|-W*)                                    ;;
1695
                *)                    echo $flag              ;;
1696
            esac
1697
        done
1698
    }
1699
fi
1700

    
1701
test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
1702

    
1703
: ${as_default:=$cc}
1704
: ${dep_cc_default:=$cc}
1705
: ${ld_default:=$cc}
1706
set_default as dep_cc ld
1707

    
1708
test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
1709
test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
1710

    
1711
add_cflags $extra_cflags
1712
add_asflags $extra_cflags
1713

    
1714
if test -n "$sysroot"; then
1715
    case "$cc_type" in
1716
        gcc)
1717
            add_cppflags --sysroot="$sysroot"
1718
            add_ldflags --sysroot="$sysroot"
1719
        ;;
1720
        tms470)
1721
            add_cppflags -I"$sysinclude"
1722
            add_ldflags  --sysroot="$sysroot"
1723
        ;;
1724
        clang)
1725
            add_cppflags -isysroot="$sysroot"
1726
            add_ldflags -isysroot="$sysroot"
1727
        ;;
1728
    esac
1729
fi
1730

    
1731
if test "$cpu" = host; then
1732
    enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
1733

    
1734
    case "$cc_type" in
1735
        gcc)
1736
            check_native(){
1737
                $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
1738
                awk "/$1=/{ match(\$0, /$1=(\\w+)/, a);print a[1];exit }" $TMPE
1739
            }
1740
            cpu=$(check_native -march || check_native -mcpu)
1741
        ;;
1742
    esac
1743

    
1744
    test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
1745
fi
1746

    
1747
# Add processor-specific flags
1748
case $cpu in
1749
    601|ppc601|PowerPC601)
1750
        cpuflags="-mcpu=601"
1751
    ;;
1752
    603*|ppc603*|PowerPC603*)
1753
        cpuflags="-mcpu=603"
1754
    ;;
1755
    604*|ppc604*|PowerPC604*)
1756
        cpuflags="-mcpu=604"
1757
    ;;
1758
    G3|g3|75*|ppc75*|PowerPC75*)
1759
        cpuflags="-mcpu=750 -mpowerpc-gfxopt"
1760
    ;;
1761
    G4|g4|745*|ppc745*|PowerPC745*)
1762
        cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
1763
    ;;
1764
    74*|ppc74*|PowerPC74*)
1765
        cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
1766
    ;;
1767
    G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1768
        cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1769
    ;;
1770
    Cell|CELL|cell)
1771
        cpuflags="-mcpu=cell"
1772
        enable ldbrx
1773
    ;;
1774
    # targets that do NOT support conditional mov (cmov)
1775
    i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1776
        cpuflags="-march=$cpu"
1777
        disable cmov
1778
    ;;
1779
    # targets that do support conditional mov (cmov)
1780
    i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10)
1781
        cpuflags="-march=$cpu"
1782
        enable cmov
1783
        enable fast_cmov
1784
    ;;
1785
    # targets that do support conditional mov but on which it's slow
1786
    pentium4|pentium4m|prescott|nocona)
1787
        cpuflags="-march=$cpu"
1788
        enable cmov
1789
        disable fast_cmov
1790
    ;;
1791
    sparc64)
1792
        cpuflags="-mcpu=v9"
1793
    ;;
1794
    arm11*|cortex*)
1795
        cpuflags="-mcpu=$cpu"
1796
        enable fast_unaligned
1797
    ;;
1798
    armv[67]*)
1799
        cpuflags="-march=$cpu"
1800
        enable fast_unaligned
1801
    ;;
1802
    armv*)
1803
        cpuflags="-march=$cpu"
1804
    ;;
1805
    arm*)
1806
        cpuflags="-mcpu=$cpu"
1807
    ;;
1808
    ev4|ev45|ev5|ev56|pca56|ev6|ev67)
1809
        enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
1810
    ;;
1811
    bf*)
1812
        cpuflags="-mcpu=$cpu"
1813
    ;;
1814
    mips*|[45]k*|[237]4k*|m4k|r*000|loongson2[ef])
1815
        cpuflags="-march=$cpu"
1816
    ;;
1817
    ap7[02]0[0-2])
1818
        subarch="avr32_ap"
1819
        cpuflags="-mpart=$cpu"
1820
    ;;
1821
    ap)
1822
        subarch="avr32_ap"
1823
        cpuflags="-march=$cpu"
1824
    ;;
1825
    uc3[ab]*)
1826
        subarch="avr32_uc"
1827
        cpuflags="-mcpu=$cpu"
1828
    ;;
1829
    uc)
1830
        subarch="avr32_uc"
1831
        cpuflags="-march=$cpu"
1832
    ;;
1833
    generic)
1834
    ;;
1835
    *)
1836
        echo "WARNING: Unknown CPU \"$cpu\", ignored."
1837
    ;;
1838
esac
1839

    
1840
add_cflags $cpuflags
1841
add_asflags $cpuflags
1842

    
1843
# compiler sanity check
1844
check_exec <<EOF
1845
int main(void){ return 0; }
1846
EOF
1847
if test "$?" != 0; then
1848
    echo "$cc is unable to create an executable file."
1849
    if test -z "$cross_prefix" && ! enabled cross_compile ; then
1850
        echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
1851
        echo "Only do this if you know what cross compiling means."
1852
    fi
1853
    die "C compiler test failed."
1854
fi
1855

    
1856
add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
1857
check_cflags -std=c99
1858
check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
1859
#include <stdlib.h>
1860
EOF
1861
check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
1862
#include <stdlib.h>
1863
EOF
1864

    
1865
check_host_cflags -std=c99
1866

    
1867
case "$arch" in
1868
    alpha)
1869
        arch="alpha"
1870
        enable fast_64bit
1871
        check_cflags -mieee
1872
        spic=$shared
1873
    ;;
1874
    arm|armv[4567]*l)
1875
        arch="arm"
1876
    ;;
1877
    avr32)
1878
    ;;
1879
    bfin)
1880
        arch="bfin"
1881
    ;;
1882
    ia64)
1883
        arch="ia64"
1884
        enable fast_64bit
1885
        spic=$shared
1886
        # HACK: currently fails to build if .bss is > 4MB and shared libs are built
1887
        enabled shared && enable_weak hardcoded_tables
1888
    ;;
1889
    m68k)
1890
        arch="m68k"
1891
    ;;
1892
    mips|mipsel|IP*)
1893
        arch="mips"
1894
        spic=$shared
1895
    ;;
1896
    mips64)
1897
        arch="mips"
1898
        subarch="mips64"
1899
        enable fast_64bit
1900
        spic=$shared
1901
    ;;
1902
    parisc|hppa)
1903
        arch="parisc"
1904
        spic=$shared
1905
    ;;
1906
    parisc64|hppa64)
1907
        arch="parisc"
1908
        enable fast_64bit
1909
        spic=$shared
1910
    ;;
1911
    "Power Macintosh"|ppc|powerpc)
1912
        arch="ppc"
1913
        enable fast_unaligned
1914
    ;;
1915
    ppc64)
1916
        arch="ppc"
1917
        subarch="ppc64"
1918
        enable fast_64bit
1919
        enable fast_unaligned
1920
    ;;
1921
    s390|s390x)
1922
        arch="s390"
1923
    ;;
1924
    sh4|sh)
1925
        arch="sh4"
1926
    ;;
1927
    sparc)
1928
        arch="sparc"
1929
        spic=$shared
1930
    ;;
1931
    sun4u|sparc64)
1932
        arch="sparc"
1933
        subarch="sparc64"
1934
        enable fast_64bit
1935
        spic=$shared
1936
    ;;
1937
    i386|i486|i586|i686|i86pc|BePC|x86_64|amd64)
1938
        arch="x86"
1939
        subarch="x86_32"
1940
        enable fast_unaligned
1941
        check_cc <<EOF && enable fast_64bit && subarch="x86_64" && spic=$shared
1942
        int test[(int)sizeof(char*) - 7];
1943
EOF
1944
        if test "$subarch" = "x86_64"; then
1945
            enable cmov
1946
            enable fast_cmov
1947
        fi
1948
    ;;
1949
    *)
1950
        arch="unknown"
1951
    ;;
1952
esac
1953

    
1954
enable $arch $subarch
1955
enabled spic && enable pic
1956
check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
1957

    
1958
# OS specific
1959
case $target_os in
1960
    beos|haiku|zeta)
1961
        prefix_default="$HOME/config"
1962
        # 3 gcc releases known for BeOS, each with ugly bugs
1963
        gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
1964
        case "$gcc_version" in
1965
          2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1966
            disable mmx
1967
            ;;
1968
          *20010315*) echo "BeBits gcc"
1969
            add_cflags -fno-expensive-optimizations
1970
            ;;
1971
        esac
1972
        SHFLAGS=-nostart
1973
        # enable BeOS things
1974
        enable audio_beos
1975
        # no need for libm, but the inet stuff
1976
        # Check for BONE
1977
        # XXX: actually should check for NOT net_server
1978
        if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
1979
            network_extralibs="-lbind -lsocket"
1980
        else
1981
            enable beos_netserver
1982
            network_extralibs="-lnet"
1983
        fi ;;
1984
    sunos)
1985
        FFSERVERLDFLAGS=""
1986
        SHFLAGS='-shared -Wl,-h,$$(@F)'
1987
        enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
1988
        network_extralibs="-lsocket -lnsl"
1989
        add_cppflags -D__EXTENSIONS__
1990
        ;;
1991
    netbsd)
1992
        oss_indev_extralibs="-lossaudio"
1993
        oss_outdev_extralibs="-lossaudio"
1994
        ;;
1995
    openbsd)
1996
        enable malloc_aligned
1997
        # On OpenBSD 4.5. the compiler does not use PIC unless
1998
        # explicitly using -fPIC. FFmpeg builds fine without PIC,
1999
        # however the generated executable will not do anything
2000
        # (simply quits with exit-code 1, no crash, no output).
2001
        # Thus explicitly enable PIC here.
2002
        enable pic
2003
        SHFLAGS='-shared'
2004
        oss_indev_extralibs="-lossaudio"
2005
        oss_outdev_extralibs="-lossaudio"
2006
        ;;
2007
    freebsd|dragonfly)
2008
        enable malloc_aligned
2009
        ;;
2010
    bsd/os)
2011
        osextralibs="-lpoll -lgnugetopt"
2012
        strip="strip -d"
2013
        ;;
2014
    darwin)
2015
        enable malloc_aligned
2016
        SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
2017
        strip="strip -x"
2018
        FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
2019
        SLIBSUF=".dylib"
2020
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
2021
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
2022
        FFSERVERLDFLAGS=-Wl,-bind_at_load
2023
        objformat="macho"
2024
        enabled x86_64 && objformat="macho64"
2025
        enabled_any pic shared ||
2026
            { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
2027
        ;;
2028
    mingw32*)
2029
        # Only WinXP or greater are supported
2030
        add_cflags -D_WIN32_WINNT=0x0501
2031
        if test $target_os = "mingw32ce"; then
2032
            disable network
2033
        else
2034
            target_os=mingw32
2035
        fi
2036
        LIBTARGET=i386
2037
        if enabled x86_64; then
2038
            enable malloc_aligned
2039
            LIBTARGET=x64
2040
        elif enabled arm; then
2041
            LIBTARGET=arm
2042
        fi
2043
        shlibdir_default="$bindir_default"
2044
        disable ffserver
2045
        SLIBPREF=""
2046
        SLIBSUF=".dll"
2047
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2048
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2049
        SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
2050
        SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
2051
            install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
2052
            install -d "$(LIBDIR)"; \
2053
            install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"'
2054
        SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
2055
        SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
2056
        objformat="win32"
2057
        enable dos_paths
2058
        check_cflags -fno-common
2059
        if ! enabled x86_64; then
2060
            check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
2061
                die "ERROR: MinGW runtime version must be >= 3.15."
2062
            enabled_any avisynth vfwcap_indev &&
2063
                { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
2064
                  die "ERROR: avisynth and vfwcap_indev require w32api version 3.13 or later."; }
2065
            fi
2066
        ;;
2067
    cygwin*)
2068
        target_os=cygwin
2069
        shlibdir_default="$bindir_default"
2070
        SLIBPREF="cyg"
2071
        SLIBSUF=".dll"
2072
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2073
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2074
        SHFLAGS='-shared -Wl,--enable-auto-image-base'
2075
        objformat="win32"
2076
        enable dos_paths
2077
        check_cflags -fno-common
2078
        ;;
2079
    *-dos|freedos|opendos)
2080
        disable ffplay ffserver
2081
        disable $INDEV_LIST $OUTDEV_LIST
2082
        network_extralibs="-lsocket"
2083
        objformat="coff"
2084
        enable dos_paths
2085
        ;;
2086
    linux)
2087
        enable dv1394
2088
        ;;
2089
    irix*)
2090
        target_os=irix
2091
        ranlib="echo ignoring ranlib"
2092
        ;;
2093
    os/2*)
2094
        strip="lxlite"
2095
        ln_s="cp -f"
2096
        FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
2097
        SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
2098
        FFSERVERLDFLAGS=""
2099
        LIBSUF="_s.a"
2100
        SLIBPREF=""
2101
        SLIBSUF=".dll"
2102
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
2103
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
2104
        SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
2105
          echo PROTMODE >> $(SUBDIR)$(NAME).def; \
2106
          echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
2107
          echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
2108
          echo EXPORTS >> $(SUBDIR)$(NAME).def; \
2109
          emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
2110
        SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
2111
          emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
2112
        SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
2113
        SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
2114
        enable dos_paths
2115
        ;;
2116
    gnu/kfreebsd)
2117
        ;;
2118
    gnu)
2119
        ;;
2120

    
2121
    *)
2122
        die "Unknown OS '$target_os'."
2123
        ;;
2124
esac
2125

    
2126
set_default $PATHS_LIST
2127

    
2128
add_extralibs $osextralibs
2129

    
2130
# Combine FFLDFLAGS and the LDFLAGS environment variable.
2131
LDFLAGS="$FFLDFLAGS $LDFLAGS"
2132

    
2133
# we need to build at least one lib type
2134
if ! enabled_any static shared; then
2135
    cat <<EOF
2136
At least one library type must be built.
2137
Specify --enable-static to build the static libraries or --enable-shared to
2138
build the shared libraries as well. To only build the shared libraries specify
2139
--disable-static in addition to --enable-shared.
2140
EOF
2141
    exit 1;
2142
fi
2143

    
2144
disabled static && LIBNAME=""
2145

    
2146
if enabled_any libfaad libfaadbin ; then
2147
    if check_header faad.h; then
2148
        check_cc <<EOF
2149
#include <faad.h>
2150
#ifndef FAAD2_VERSION
2151
ok faad1
2152
#endif
2153
int main(void) { return 0; }
2154
EOF
2155
        test $? = 0 && enable libfaad2
2156
    else
2157
        die "FAAD test failed."
2158
    fi
2159
fi
2160

    
2161

    
2162
die_license_disabled() {
2163
    enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2164
}
2165

    
2166
die_license_disabled gpl libfaad2
2167
die_license_disabled gpl libx264
2168
die_license_disabled gpl libxvid
2169
die_license_disabled gpl postproc
2170
die_license_disabled gpl x11grab
2171

    
2172
die_license_disabled nonfree libfaac
2173

    
2174
die_license_disabled version3 libopencore_amrnb
2175
die_license_disabled version3 libopencore_amrwb
2176

    
2177
enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2178

    
2179
check_deps $ARCH_EXT_LIST
2180

    
2181
disabled optimizations || check_cflags -fomit-frame-pointer
2182

    
2183
enable_pic() {
2184
    enable pic
2185
    add_cppflags -DPIC
2186
    add_cflags   -fPIC
2187
    add_asflags  -fPIC
2188
}
2189

    
2190
enabled pic && enable_pic
2191

    
2192
check_cc <<EOF || die "Symbol mangling check failed."
2193
int ff_extern;
2194
EOF
2195
sym=$($nm -P -g $TMPO | grep ff_extern)
2196
extern_prefix=${sym%%ff_extern*}
2197

    
2198
check_cc <<EOF && enable inline_asm
2199
void foo(void) { __asm__ volatile ("" ::); }
2200
EOF
2201

    
2202
_restrict=
2203
for restrict_keyword in restrict __restrict__ __restrict; do
2204
    check_cc <<EOF && _restrict=$restrict_keyword && break
2205
void foo(char * $restrict_keyword p);
2206
EOF
2207
done
2208

    
2209
check_cc <<EOF && enable attribute_packed
2210
struct { int x; } __attribute__((packed)) x;
2211
EOF
2212

    
2213
check_cc <<EOF || die "endian test failed"
2214
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2215
EOF
2216
od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2217

    
2218
if enabled arm; then
2219

    
2220
    check_cflags -marm
2221

    
2222
    check_ld <<EOF && enable vfp_args
2223
__asm__ (".eabi_attribute 28, 1");
2224
int main(void) { return 0; }
2225
EOF
2226

    
2227
    # We have to check if pld is a nop and disable it.
2228
    check_asm pld '"pld [r0]"'
2229

    
2230
    enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2231
    enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
2232
    enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2233
    enabled armvfp  && check_asm armvfp  '"fadds s0, s0, s0"'
2234
    enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
2235
    enabled neon    && check_asm neon    '"vadd.i16 q0, q0, q0"'
2236

    
2237
    enabled_all armv6t2 shared !pic && enable_pic
2238

    
2239
elif enabled mips; then
2240

    
2241
    check_asm loongson '"dmult.g $1, $2, $3"'
2242
    enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
2243

    
2244
elif enabled ppc; then
2245

    
2246
    check_asm dcbzl     '"dcbzl 0, 1"'
2247
    check_asm ppc4xx    '"maclhw r10, r11, r12"'
2248
    check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
2249

    
2250
    # AltiVec flags: The FSF version of GCC differs from the Apple version
2251
    if enabled altivec; then
2252
        check_cflags -maltivec -mabi=altivec &&
2253
        { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2254
        check_cflags -faltivec
2255

    
2256
        # check if our compiler supports Motorola AltiVec C API
2257
        check_cc <<EOF || disable altivec
2258
$inc_altivec_h
2259
int main(void) {
2260
    vector signed int v1, v2, v3;
2261
    v1 = vec_add(v2,v3);
2262
    return 0;
2263
}
2264
EOF
2265

    
2266
        # check if our compiler supports braces for vector declarations
2267
        check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
2268
$inc_altivec_h
2269
int main (void) { (vector int) {1}; return 0; }
2270
EOF
2271
    fi
2272

    
2273
elif enabled sparc; then
2274

    
2275
    enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2276
        add_cflags -mcpu=ultrasparc -mtune=ultrasparc
2277

    
2278
elif enabled x86; then
2279

    
2280
    # check whether EBP is available on x86
2281
    # As 'i' is stored on the stack, this program will crash
2282
    # if the base pointer is used to access it because the
2283
    # base pointer is cleared in the inline assembly code.
2284
    check_exec_crash <<EOF && enable ebp_available
2285
    volatile int i=0;
2286
    __asm__ volatile (
2287
        "xorl %%ebp, %%ebp"
2288
    ::: "%ebp");
2289
    return i;
2290
EOF
2291

    
2292
    # check whether EBX is available on x86
2293
    check_asm ebx_available '""::"b"(0)' &&
2294
        check_asm ebx_available '"":::"%ebx"'
2295

    
2296
    # check whether more than 10 operands are supported
2297
    check_cc <<EOF && enable ten_operands
2298
int main(void) {
2299
    int x=0;
2300
    __asm__ volatile(
2301
        ""
2302
        :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
2303
    );
2304
    return 0;
2305
}
2306
EOF
2307

    
2308
    # check whether binutils is new enough to compile SSSE3/MMX2
2309
    enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
2310
    enabled mmx2  && check_asm mmx2  '"pmaxub %mm0, %mm1"'
2311

    
2312
    check_asm bswap '"bswap %%eax" ::: "%eax"'
2313

    
2314
    YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
2315
    enabled     x86_64        && append YASMFLAGS "-m amd64"
2316
    enabled     pic           && append YASMFLAGS "-DPIC"
2317
    test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
2318
    case "$objformat" in
2319
        elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
2320
    esac
2321
    disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
2322

    
2323
    case "$cpu" in
2324
        athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
2325
            disable fast_clz
2326
        ;;
2327
    esac
2328

    
2329
fi
2330

    
2331
if check_func dlopen; then
2332
    ldl=
2333
elif check_func dlopen -ldl; then
2334
    ldl=-ldl
2335
fi
2336

    
2337
# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2338
check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2339

    
2340
check_func  fork
2341
check_func  getaddrinfo $network_extralibs
2342
check_func  gethrtime
2343
check_func  getrusage
2344
check_func  inet_aton $network_extralibs
2345
check_func  isatty
2346
check_func  memalign
2347
check_func  mkstemp
2348
check_func  posix_memalign
2349
check_func_headers io.h setmode
2350
check_func_headers lzo/lzo1x.h lzo1x_999_compress
2351
check_func_headers windows.h GetProcessTimes
2352
check_func_headers windows.h VirtualAlloc
2353

    
2354
check_header conio.h
2355
check_header dlfcn.h
2356
check_header malloc.h
2357
check_header poll.h
2358
check_header sys/mman.h
2359
check_header sys/resource.h
2360
check_header sys/select.h
2361
check_header termios.h
2362
check_header vdpau/vdpau.h
2363
check_header vdpau/vdpau_x11.h
2364
check_header X11/extensions/XvMClib.h
2365

    
2366
if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
2367
     enabled_any $need_memalign ; then
2368
    die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
2369
fi
2370

    
2371
disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
2372
disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
2373

    
2374
# check for some common methods of building with pthread support
2375
# do this before the optional library checks as some of them require pthreads
2376
if enabled pthreads; then
2377
    if check_func pthread_create; then
2378
        :
2379
    elif check_func pthread_create -pthread; then
2380
        add_cflags -pthread
2381
        add_extralibs -pthread
2382
    elif check_func pthread_create -pthreads; then
2383
        add_cflags -pthreads
2384
        add_extralibs -pthreads
2385
    elif check_func pthread_create -lpthreadGC2; then
2386
        add_extralibs -lpthreadGC2
2387
    elif ! check_lib pthread.h pthread_create -lpthread; then
2388
        die "ERROR: can't find pthreads library"
2389
    fi
2390
fi
2391

    
2392
for thread in $THREADS_LIST; do
2393
    if enabled $thread; then
2394
        test -n "$thread_type" &&
2395
            die "ERROR: Only one thread type must be selected." ||
2396
            thread_type="$thread"
2397
    fi
2398
done
2399

    
2400
check_lib math.h sin -lm
2401
check_lib va/va.h vaInitialize -lva
2402

    
2403
check_func exp2
2404
check_func exp2f
2405
check_func llrint
2406
check_func log2
2407
check_func log2f
2408
check_func lrint
2409
check_func lrintf
2410
check_func round
2411
check_func roundf
2412
check_func truncf
2413

    
2414
# these are off by default, so fail if requested and not available
2415
enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
2416
enabled libdirac   && add_cflags $(pkg-config --cflags dirac) &&
2417
                      require  libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
2418
                      require  libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
2419
enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
2420
enabled libfaad    && require2 libfaad faad.h faacDecOpen -lfaad
2421
enabled libgsm     && require  libgsm gsm.h gsm_create -lgsm
2422
enabled libmp3lame && require  libmp3lame lame/lame.h lame_init -lmp3lame -lm
2423
enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
2424
enabled libopencore_amrnb  && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
2425
enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
2426
enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
2427
enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
2428
                           require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
2429
enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
2430
enabled libtheora  && require  libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
2431
enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
2432
enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 -lm &&
2433
                      { check_cpp_condition x264.h "X264_BUILD >= 79" ||
2434
                        die "ERROR: libx264 version must be >= 0.79."; }
2435
enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
2436
enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
2437

    
2438
# libdc1394 check
2439
if enabled libdc1394; then
2440
    { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2441
        enable libdc1394_2; } ||
2442
    { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2443
        enable libdc1394_1; } ||
2444
    die "ERROR: No version of libdc1394 found "
2445
fi
2446

    
2447
disable sdl_too_old
2448
disable sdl
2449
SDL_CONFIG="${cross_prefix}sdl-config"
2450
if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
2451
    sdl_cflags=$("${SDL_CONFIG}" --cflags)
2452
    sdl_libs=$("${SDL_CONFIG}" --libs)
2453
    temp_cflags $sdl_cflags
2454
    temp_extralibs $sdl_libs
2455
    if check_lib2 SDL.h SDL_Init; then
2456
        _sdlversion=$("${SDL_CONFIG}" --version | sed 's/[^0-9]//g')
2457
        if test "$_sdlversion" -lt 121 ; then
2458
            enable sdl_too_old
2459
        else
2460
            enable sdl
2461
            check_cc $sdl_cflags <<EOF && enable sdl_video_size
2462
#include <SDL.h>
2463
int main(int argc, char **argv){
2464
    const SDL_VideoInfo *vi = SDL_GetVideoInfo();
2465
    int w = vi->current_w;
2466
    return 0;
2467
}
2468
EOF
2469
        fi
2470
    fi
2471
    restore_flags
2472
fi
2473

    
2474
texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
2475

    
2476
if enabled network; then
2477
    check_type "sys/types.h sys/socket.h" socklen_t
2478
    check_type netdb.h "struct addrinfo"
2479
    check_type sys/socket.h "struct sockaddr_storage"
2480
    # Prefer arpa/inet.h over winsock2
2481
    if check_header arpa/inet.h ; then
2482
        check_func closesocket
2483
    elif check_header winsock2.h ; then
2484
        check_func_headers winsock2.h closesocket -lws2 && \
2485
            network_extralibs="-lws2" || \
2486
        { check_func_headers winsock2.h closesocket -lws2_32 && \
2487
            network_extralibs="-lws2_32"; }
2488
        check_type ws2tcpip.h socklen_t
2489
        check_type ws2tcpip.h "struct addrinfo"
2490
        check_type ws2tcpip.h "struct sockaddr_storage"
2491
    else
2492
        disable network
2493
    fi
2494
fi
2495

    
2496
enabled_all network ipv6 && check_ld <<EOF || disable ipv6
2497
#include <sys/types.h>
2498
#include <sys/socket.h>
2499
#include <netinet/in.h>
2500
#include <netdb.h>
2501
int main(void) {
2502
    struct sockaddr_storage saddr;
2503
    struct ipv6_mreq mreq6;
2504
    getaddrinfo(0,0,0,0);
2505
    getnameinfo(0,0,0,0,0,0,0);
2506
    IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
2507
}
2508
EOF
2509

    
2510
check_header linux/videodev.h
2511
check_header linux/videodev2.h
2512
check_header sys/videoio.h
2513

    
2514
check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
2515

    
2516
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
2517
{ check_header dev/bktr/ioctl_meteor.h &&
2518
  check_header dev/bktr/ioctl_bt848.h; } ||
2519
{ check_header machine/ioctl_meteor.h &&
2520
  check_header machine/ioctl_bt848.h; } ||
2521
{ check_header dev/video/meteor/ioctl_meteor.h &&
2522
  check_header dev/video/bktr/ioctl_bt848.h; } ||
2523
check_header dev/ic/bt8xx.h
2524

    
2525
check_header sys/soundcard.h
2526
check_header soundcard.h
2527

    
2528
enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
2529

    
2530
enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
2531

    
2532
enabled x11grab                         &&
2533
check_header X11/Xlib.h                 &&
2534
check_header X11/extensions/XShm.h      &&
2535
check_header X11/extensions/Xfixes.h    &&
2536
check_func XOpenDisplay -lX11           &&
2537
check_func XShmCreateImage -lX11 -lXext &&
2538
check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
2539

    
2540
if ! disabled vdpau && enabled vdpau_vdpau_h; then
2541
check_cpp_condition \
2542
    vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
2543
    { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
2544
      disable vdpau; }
2545
fi
2546

    
2547
enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
2548

    
2549
# add some useful compiler flags if supported
2550
check_cflags -Wdeclaration-after-statement
2551
check_cflags -Wall
2552
check_cflags -Wno-switch
2553
check_cflags -Wdisabled-optimization
2554
check_cflags -Wpointer-arith
2555
check_cflags -Wredundant-decls
2556
check_cflags -Wno-pointer-sign
2557
check_cflags -Wcast-qual
2558
check_cflags -Wwrite-strings
2559
check_cflags -Wtype-limits
2560
check_cflags -Wundef
2561
enabled extra_warnings && check_cflags -Winline
2562

    
2563
# add some linker flags
2564
check_ldflags -Wl,--warn-common
2565
check_ldflags -Wl,--as-needed
2566
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'
2567
check_ldflags -Wl,-Bsymbolic
2568

    
2569
echo "X{};" > $TMPV
2570
test_ldflags -Wl,--version-script,$TMPV &&
2571
    append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
2572

    
2573
if enabled small; then
2574
    check_cflags -Os            # not all compilers support -Os
2575
    optimizations="small"
2576
elif enabled optimizations; then
2577
    if enabled xlc; then
2578
        add_cflags  -O5
2579
        add_ldflags -O5
2580
    elif enabled suncc; then
2581
        add_cflags -O5
2582
    elif enabled ccc; then
2583
        add_cflags -fast
2584
    else
2585
        add_cflags -O3
2586
    fi
2587
fi
2588
check_cflags -fno-math-errno
2589
check_cflags -fno-signed-zeros
2590

    
2591
if enabled icc; then
2592
    # Just warnings, no remarks
2593
    check_cflags -w1
2594
    # -wd: Disable following warnings
2595
    # 144, 167, 556: -Wno-pointer-sign
2596
    # 10006: ignoring unknown option -fno-signed-zeros
2597
    # 10156: ignoring option '-W'; no argument required
2598
    check_cflags -wd144,167,556,10006,10156
2599
    # 11030: Warning unknown option --as-needed
2600
    # 10156: ignoring option '-export'; no argument required
2601
    check_ldflags -wd10156,11030
2602
    # Allow to compile with optimizations
2603
    check_ldflags -march=$cpu
2604
    # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
2605
    enable ebp_available
2606
elif enabled ccc; then
2607
    # disable some annoying warnings
2608
    add_cflags -msg_disable cvtu32to64
2609
    add_cflags -msg_disable embedcomment
2610
    add_cflags -msg_disable needconstext
2611
    add_cflags -msg_disable nomainieee
2612
    add_cflags -msg_disable ptrmismatch1
2613
    add_cflags -msg_disable unreachcode
2614
elif enabled gcc; then
2615
    check_cflags -fno-tree-vectorize
2616
elif enabled clang; then
2617
    check_cflags -Qunused-arguments
2618
fi
2619

    
2620
if enabled gprof; then
2621
    add_cflags  -p
2622
    add_ldflags -p
2623
fi
2624

    
2625
# Find out if the .align argument is a power of two or not.
2626
check_asm asmalign_pot '".align 3"'
2627

    
2628
enabled_any $DECODER_LIST      && enable decoders
2629
enabled_any $ENCODER_LIST      && enable encoders
2630
enabled_any $HWACCEL_LIST      && enable hwaccels
2631
enabled_any $BSF_LIST          && enable bsfs
2632
enabled_any $DEMUXER_LIST      && enable demuxers
2633
enabled_any $MUXER_LIST        && enable muxers
2634
enabled_any $FILTER_LIST       && enable filters
2635
enabled_any $INDEV_LIST        && enable indevs
2636
enabled_any $OUTDEV_LIST       && enable outdevs
2637
enabled_any $PROTOCOL_LIST     && enable protocols
2638

    
2639
enabled_any $THREADS_LIST      && enable threads
2640

    
2641
check_deps $CONFIG_LIST       \
2642
           $CONFIG_EXTRA      \
2643
           $HAVE_LIST         \
2644
           $DECODER_LIST      \
2645
           $ENCODER_LIST      \
2646
           $HWACCEL_LIST      \
2647
           $PARSER_LIST       \
2648
           $BSF_LIST          \
2649
           $DEMUXER_LIST      \
2650
           $MUXER_LIST        \
2651
           $FILTER_LIST       \
2652
           $INDEV_LIST        \
2653
           $OUTDEV_LIST       \
2654
           $PROTOCOL_LIST     \
2655

    
2656
echo "install prefix            $prefix"
2657
echo "source path               $source_path"
2658
echo "C compiler                $cc"
2659
echo ".align is power-of-two    $asmalign_pot"
2660
echo "ARCH                      $arch ($cpu)"
2661
if test "$build_suffix" != ""; then
2662
    echo "build suffix              $build_suffix"
2663
fi
2664
if test "$extra_version" != ""; then
2665
    echo "version string suffix     $extra_version"
2666
fi
2667
echo "big-endian                ${bigendian-no}"
2668
echo "runtime cpu detection     ${runtime_cpudetect-no}"
2669
if enabled x86; then
2670
    echo "yasm                      ${yasm-no}"
2671
    echo "MMX enabled               ${mmx-no}"
2672
    echo "MMX2 enabled              ${mmx2-no}"
2673
    echo "3DNow! enabled            ${amd3dnow-no}"
2674
    echo "3DNow! extended enabled   ${amd3dnowext-no}"
2675
    echo "SSE enabled               ${sse-no}"
2676
    echo "SSSE3 enabled             ${ssse3-no}"
2677
    echo "CMOV enabled              ${cmov-no}"
2678
    echo "CMOV is fast              ${fast_cmov-no}"
2679
    echo "EBX available             ${ebx_available-no}"
2680
    echo "EBP available             ${ebp_available-no}"
2681
    echo "10 operands supported     ${ten_operands-no}"
2682
fi
2683
if enabled arm; then
2684
    echo "ARMv5TE enabled           ${armv5te-no}"
2685
    echo "ARMv6 enabled             ${armv6-no}"
2686
    echo "ARMv6T2 enabled           ${armv6t2-no}"
2687
    echo "ARM VFP enabled           ${armvfp-no}"
2688
    echo "IWMMXT enabled            ${iwmmxt-no}"
2689
    echo "NEON enabled              ${neon-no}"
2690
fi
2691
if enabled mips; then
2692
    echo "MMI enabled               ${mmi-no}"
2693
fi
2694
if enabled ppc; then
2695
    echo "AltiVec enabled           ${altivec-no}"
2696
    echo "PPC 4xx optimizations     ${ppc4xx-no}"
2697
    echo "dcbzl available           ${dcbzl-no}"
2698
    echo "performance report        ${powerpc_perf-no}"
2699
fi
2700
if enabled sparc; then
2701
    echo "VIS enabled               ${vis-no}"
2702
fi
2703
echo "gprof enabled             ${gprof-no}"
2704
echo "debug symbols             ${debug-no}"
2705
echo "strip symbols             ${stripping-no}"
2706
echo "optimizations             ${optimizations-no}"
2707
echo "static                    ${static-no}"
2708
echo "shared                    ${shared-no}"
2709
echo "postprocessing support    ${postproc-no}"
2710
echo "new filter support        ${avfilter-no}"
2711
echo "filters using lavformat   ${avfilter_lavf-no}"
2712
echo "network support           ${network-no}"
2713
if enabled network; then
2714
    echo "IPv6 support              ${ipv6-no}"
2715
fi
2716
echo "threading support         ${thread_type-no}"
2717
echo "SDL support               ${sdl-no}"
2718
if enabled sdl_too_old; then
2719
    echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
2720
fi
2721
echo "Sun medialib support      ${mlib-no}"
2722
echo "AVISynth enabled          ${avisynth-no}"
2723
echo "libdc1394 support         ${libdc1394-no}"
2724
echo "libdirac enabled          ${libdirac-no}"
2725
echo "libfaac enabled           ${libfaac-no}"
2726
echo "libfaad enabled           ${libfaad-no}"
2727
echo "libfaad dlopened          ${libfaadbin-no}"
2728
echo "libgsm enabled            ${libgsm-no}"
2729
echo "libmp3lame enabled        ${libmp3lame-no}"
2730
echo "libnut enabled            ${libnut-no}"
2731
echo "libopencore-amrnb support ${libopencore_amrnb-no}"
2732
echo "libopencore-amrwb support ${libopencore_amrwb-no}"
2733
echo "libopenjpeg enabled       ${libopenjpeg-no}"
2734
echo "libschroedinger enabled   ${libschroedinger-no}"
2735
echo "libspeex enabled          ${libspeex-no}"
2736
echo "libtheora enabled         ${libtheora-no}"
2737
echo "libvorbis enabled         ${libvorbis-no}"
2738
echo "libx264 enabled           ${libx264-no}"
2739
echo "libxvid enabled           ${libxvid-no}"
2740
echo "zlib enabled              ${zlib-no}"
2741
echo "bzlib enabled             ${bzlib-no}"
2742
echo
2743

    
2744
for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
2745
    echo "Enabled ${type}s:"
2746
    eval list=\$$(toupper $type)_LIST
2747
    for part in $list; do
2748
        enabled $part && echo ${part%_*}
2749
    done | sort | pr -3 -t
2750
    echo
2751
done
2752

    
2753
license="LGPL version 2.1 or later"
2754
if enabled nonfree; then
2755
    license="nonfree and unredistributable"
2756
elif enabled gplv3; then
2757
    license="GPL version 3 or later"
2758
elif enabled lgplv3; then
2759
    license="LGPL version 3 or later"
2760
elif enabled gpl; then
2761
    license="GPL version 2 or later"
2762
fi
2763

    
2764
echo "License: $license"
2765

    
2766
echo "Creating config.mak and config.h..."
2767

    
2768
enabled stripping || strip="echo skipping strip"
2769

    
2770
cat > config.mak <<EOF
2771
# Automatically generated by configure - do not modify!
2772
ifndef FFMPEG_CONFIG_MAK
2773
FFMPEG_CONFIG_MAK=1
2774
FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
2775
prefix=$prefix
2776
LIBDIR=\$(DESTDIR)$libdir
2777
SHLIBDIR=\$(DESTDIR)$shlibdir
2778
INCDIR=\$(DESTDIR)$incdir
2779
BINDIR=\$(DESTDIR)$bindir
2780
DATADIR=\$(DESTDIR)$datadir
2781
MANDIR=\$(DESTDIR)$mandir
2782
SRC_PATH="$source_path"
2783
SRC_PATH_BARE=$source_path
2784
BUILD_ROOT="$PWD"
2785
ARCH=$arch
2786
CC=$cc
2787
AS=$as
2788
LD=$ld
2789
DEPCC=$dep_cc
2790
YASM=$yasmexe
2791
AR=$ar
2792
RANLIB=$ranlib
2793
LN_S=$ln_s
2794
STRIP=$strip
2795
CPPFLAGS=$CPPFLAGS
2796
CFLAGS=$CFLAGS
2797
ASFLAGS=$ASFLAGS
2798
CC_O=$CC_O
2799
LDFLAGS=$LDFLAGS
2800
FFSERVERLDFLAGS=$FFSERVERLDFLAGS
2801
SHFLAGS=$SHFLAGS
2802
YASMFLAGS=$YASMFLAGS
2803
BUILDSUF=$build_suffix
2804
FULLNAME=$FULLNAME
2805
LIBPREF=$LIBPREF
2806
LIBSUF=$LIBSUF
2807
LIBNAME=$LIBNAME
2808
SLIBPREF=$SLIBPREF
2809
SLIBSUF=$SLIBSUF
2810
EXESUF=$EXESUF
2811
EXTRA_VERSION=$extra_version
2812
DEPFLAGS=$DEPFLAGS
2813
CCDEP=$CCDEP
2814
ASDEP=$ASDEP
2815
CC_DEPFLAGS=$CC_DEPFLAGS
2816
AS_DEPFLAGS=$AS_DEPFLAGS
2817
HOSTCC=$host_cc
2818
HOSTCFLAGS=$host_cflags
2819
HOSTEXESUF=$HOSTEXESUF
2820
HOSTLDFLAGS=$host_ldflags
2821
HOSTLIBS=$host_libs
2822
TARGET_EXEC=$target_exec
2823
TARGET_PATH=$target_path
2824
SDL_LIBS=$sdl_libs
2825
SDL_CFLAGS=$sdl_cflags
2826
LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
2827
EXTRALIBS=$extralibs
2828
EOF
2829

    
2830
get_version(){
2831
    name=$1
2832
    file=$source_path/$2
2833
    eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
2834
    eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
2835
    lcname=$(tolower $name)
2836
    eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
2837
    eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
2838
}
2839

    
2840
get_version LIBSWSCALE  libswscale/swscale.h
2841
get_version LIBPOSTPROC libpostproc/postprocess.h
2842
get_version LIBAVCODEC  libavcodec/avcodec.h
2843
get_version LIBAVDEVICE libavdevice/avdevice.h
2844
get_version LIBAVFORMAT libavformat/avformat.h
2845
get_version LIBAVUTIL   libavutil/avutil.h
2846
get_version LIBAVFILTER libavfilter/avfilter.h
2847

    
2848
enabled shared && cat >> config.mak <<EOF
2849
LIBTARGET=${LIBTARGET}
2850
SLIBNAME=${SLIBNAME}
2851
SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
2852
SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
2853
SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
2854
SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
2855
SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}
2856
SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}
2857
EOF
2858

    
2859
enabled asmalign_pot || align_shift="1 <<"
2860

    
2861
cat > $TMPH <<EOF
2862
/* Automatically generated by configure - do not modify! */
2863
#ifndef FFMPEG_CONFIG_H
2864
#define FFMPEG_CONFIG_H
2865
#define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
2866
#define FFMPEG_LICENSE "$(c_escape $license)"
2867
#define FFMPEG_DATADIR "$(eval c_escape $datadir)"
2868
#define CC_TYPE "$cc_type"
2869
#define CC_VERSION $cc_version
2870
#define restrict $_restrict
2871
#define ASMALIGN(ZEROBITS) ".align $align_shift " #ZEROBITS "\\n\\t"
2872
#define EXTERN_PREFIX "${extern_prefix}"
2873
#define EXTERN_ASM ${extern_prefix}
2874
EOF
2875

    
2876
if enabled small || disabled optimizations; then
2877
    echo "#define av_always_inline"  >> $TMPH
2878
fi
2879

    
2880
print_config ARCH_   $TMPH config.mak $ARCH_LIST
2881
print_config HAVE_   $TMPH config.mak $HAVE_LIST
2882
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST       \
2883
                                      $CONFIG_EXTRA      \
2884
                                      $DECODER_LIST      \
2885
                                      $ENCODER_LIST      \
2886
                                      $HWACCEL_LIST      \
2887
                                      $PARSER_LIST       \
2888
                                      $BSF_LIST          \
2889
                                      $DEMUXER_LIST      \
2890
                                      $MUXER_LIST        \
2891
                                      $FILTER_LIST       \
2892
                                      $PROTOCOL_LIST     \
2893
                                      $INDEV_LIST        \
2894
                                      $OUTDEV_LIST       \
2895

    
2896
echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
2897
echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
2898

    
2899
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
2900
cmp -s $TMPH config.h &&
2901
    echo "config.h is unchanged" ||
2902
    mv -f $TMPH config.h
2903

    
2904
# build tree in object directory if source path is different from current one
2905
if enabled source_path_used; then
2906
    DIRS="
2907
        doc
2908
        libavcodec
2909
        libavcodec/$arch
2910
        libavdevice
2911
        libavfilter
2912
        libavformat
2913
        libavutil
2914
        libavutil/$arch
2915
        libpostproc
2916
        libswscale
2917
        libswscale/$arch
2918
        tests
2919
        tools
2920
    "
2921
    FILES="
2922
        Makefile
2923
        common.mak
2924
        subdir.mak
2925
        doc/texi2pod.pl
2926
        libavcodec/Makefile
2927
        libavdevice/Makefile
2928
        libavfilter/Makefile
2929
        libavformat/Makefile
2930
        libavutil/Makefile
2931
        libpostproc/Makefile
2932
        libswscale/Makefile
2933
    "
2934
    for dir in $DIRS ; do
2935
        mkdir -p $dir
2936
    done
2937
    for f in $FILES ; do
2938
        $ln_s "$source_path/$f" $f
2939
    done
2940
fi
2941

    
2942

    
2943
# build pkg-config files
2944

    
2945
pkgconfig_generate(){
2946
name=$1
2947
shortname=${name#lib}${build_suffix}
2948
comment=$2
2949
version=$3
2950
libs=$4
2951
requires=$5
2952
cat <<EOF > $name/$name.pc
2953
prefix=$prefix
2954
exec_prefix=\${prefix}
2955
libdir=$libdir
2956
includedir=$incdir
2957

    
2958
Name: $name
2959
Description: $comment
2960
Version: $version
2961
Requires: $(enabled shared || echo $requires)
2962
Requires.private: $(enabled shared && echo $requires)
2963
Conflicts:
2964
Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
2965
Libs.private: $(enabled shared && echo $libs)
2966
Cflags: -I\${includedir}
2967
EOF
2968
cat <<EOF > $name/$name-uninstalled.pc
2969
prefix=
2970
exec_prefix=
2971
libdir=\${pcfiledir}
2972
includedir=${source_path}
2973

    
2974
Name: $name
2975
Description: $comment
2976
Version: $version
2977
Requires: $requires
2978
Conflicts:
2979
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
2980
Cflags: -I\${includedir}
2981
EOF
2982
}
2983

    
2984
pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
2985
pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
2986
pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
2987
pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
2988
enabled avfilter &&
2989
    pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
2990
enabled postproc &&
2991
    pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
2992
pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"