Statistics
| Branch: | Revision:

ffmpeg / configure @ 8182dc34

History | View | Annotate | Download (84.8 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-dct            disable DCT code
103
  --disable-fft            disable FFT code
104
  --disable-golomb         disable Golomb code
105
  --disable-lpc            disable LPC code
106
  --disable-mdct           disable MDCT code
107
  --disable-rdft           disable RDFT code
108
  --disable-vaapi          disable VAAPI code
109
  --disable-vdpau          disable VDPAU code
110
  --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
111
  --enable-hardcoded-tables use hardcoded tables instead of runtime generation
112
  --enable-memalign-hack   emulate memalign, interferes with memory debuggers
113
  --enable-beos-netserver  enable BeOS netserver
114
  --disable-encoder=NAME   disable encoder NAME
115
  --enable-encoder=NAME    enable encoder NAME
116
  --disable-encoders       disable all encoders
117
  --disable-decoder=NAME   disable decoder NAME
118
  --enable-decoder=NAME    enable decoder NAME
119
  --disable-decoders       disable all decoders
120
  --disable-hwaccel=NAME   disable hwaccel NAME
121
  --enable-hwaccel=NAME    enable hwaccel NAME
122
  --disable-hwaccels       disable all hwaccels
123
  --disable-muxer=NAME     disable muxer NAME
124
  --enable-muxer=NAME      enable muxer NAME
125
  --disable-muxers         disable all muxers
126
  --disable-demuxer=NAME   disable demuxer NAME
127
  --enable-demuxer=NAME    enable demuxer NAME
128
  --disable-demuxers       disable all demuxers
129
  --enable-parser=NAME     enable parser NAME
130
  --disable-parser=NAME    disable parser NAME
131
  --disable-parsers        disable all parsers
132
  --enable-bsf=NAME        enable bitstream filter NAME
133
  --disable-bsf=NAME       disable bitstream filter NAME
134
  --disable-bsfs           disable all bitstream filters
135
  --enable-protocol=NAME   enable protocol NAME
136
  --disable-protocol=NAME  disable protocol NAME
137
  --disable-protocols      disable all protocols
138
  --disable-indev=NAME     disable input device NAME
139
  --disable-outdev=NAME    disable output device NAME
140
  --disable-indevs         disable input devices
141
  --disable-outdevs        disable output devices
142
  --disable-devices        disable all devices
143
  --enable-filter=NAME     enable filter NAME
144
  --disable-filter=NAME    disable filter NAME
145
  --disable-filters        disable all filters
146
  --list-decoders          show all available decoders
147
  --list-encoders          show all available encoders
148
  --list-hwaccels          show all available hardware accelerators
149
  --list-muxers            show all available muxers
150
  --list-demuxers          show all available demuxers
151
  --list-parsers           show all available parsers
152
  --list-protocols         show all available protocols
153
  --list-bsfs              show all available bitstream filters
154
  --list-indevs            show all available input devices
155
  --list-outdevs           show all available output devices
156
  --list-filters           show all available filters
157

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

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

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

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

    
244
log(){
245
    echo "$@" >> $logfile
246
}
247

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

    
254
echolog(){
255
    log "$@"
256
    echo "$@"
257
}
258

    
259
die(){
260
    echolog "$@"
261
    cat <<EOF
262

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

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

    
286
tolower(){
287
    echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
288
}
289

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

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

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

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

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

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

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

    
343
enable(){
344
    set_all yes $*
345
}
346

    
347
disable(){
348
    set_all no $*
349
}
350

    
351
enable_weak(){
352
    set_weak yes $*
353
}
354

    
355
disable_weak(){
356
    set_weak no $*
357
}
358

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

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

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

    
384
enable_deep(){
385
    do_enable_deep $*
386
    enable $*
387
}
388

    
389
enable_deep_weak(){
390
    do_enable_deep $*
391
    enable_weak $*
392
}
393

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

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

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

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

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

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

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

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

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

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

    
458
        pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
459
        check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
460
        popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
461

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

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

    
475
        disable ${cfg}_checking
476
    done
477
}
478

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

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

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

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

    
517
temp_cflags(){
518
    save_flags
519
    CFLAGS="$CFLAGS $*"
520
}
521

    
522
temp_ldflags(){
523
    save_flags
524
    LDFLAGS="$LDFLAGS $*"
525
}
526

    
527
temp_extralibs(){
528
    save_flags
529
    extralibs="$extralibs $*"
530
}
531

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

    
539
add_cppflags(){
540
    append CPPFLAGS $($filter_cppflags "$@")
541
}
542

    
543
add_cflags(){
544
    append CFLAGS $($filter_cflags "$@")
545
}
546

    
547
add_asflags(){
548
    append ASFLAGS $($filter_asflags "$@")
549
}
550

    
551
add_ldflags(){
552
    append LDFLAGS "$@"
553
}
554

    
555
add_extralibs(){
556
    append extralibs "$@"
557
}
558

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

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

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

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

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

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

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

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

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

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

    
638
check_ldflags(){
639
    log check_ldflags "$@"
640
    test_ldflags "$@" && add_ldflags "$@"
641
}
642

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

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

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

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

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

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

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

    
721
check_exec_crash(){
722
    code=$(cat)
723

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

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

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

    
764
check_struct(){
765
    log check_type "$@"
766
    headers=$1
767
    struct=$2
768
    member=$3
769
    shift 3
770
    disable_safe "${struct}_${member}"
771
    incs=""
772
    for hdr in $headers; do
773
        incs="$incs
774
#include <$hdr>"
775
    done
776
    check_cc "$@" <<EOF && enable_safe "${struct}_${member}"
777
$incs
778
const void *p = &(($struct *)0)->$member;
779
EOF
780
}
781

    
782
require(){
783
    name="$1"
784
    header="$2"
785
    func="$3"
786
    shift 3
787
    check_lib $header $func "$@" || die "ERROR: $name not found"
788
}
789

    
790
require2(){
791
    name="$1"
792
    headers="$2"
793
    func="$3"
794
    shift 3
795
    check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
796
}
797

    
798
check_foo_config(){
799
    cfg=$1
800
    pkg=$2
801
    header=$3
802
    func=$4
803
    shift 4
804
    disable $cfg
805
    check_cmd ${pkg}-config --version
806
    err=$?
807
    if test "$err" = 0; then
808
        temp_cflags $(${pkg}-config --cflags)
809
        temp_extralibs $(${pkg}-config --libs)
810
        check_lib "$@" $header $func && enable $cfg
811
    fi
812
    return $err
813
}
814

    
815
check_host_cc(){
816
    log check_host_cc "$@"
817
    cat > $TMPC
818
    log_file $TMPC
819
    check_cmd $host_cc $host_cflags "$@" -c -o $TMPO $TMPC
820
}
821

    
822
check_host_cflags(){
823
    log check_host_cflags "$@"
824
    check_host_cc "$@" <<EOF && append host_cflags "$@"
825
int x;
826
EOF
827
}
828

    
829
apply(){
830
    file=$1
831
    shift
832
    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
833
}
834

    
835
cp_if_changed(){
836
    cmp -s "$1" "$2" &&
837
        echo "$2 is unchanged" ||
838
        cp -f "$1" "$2"
839
}
840

    
841
# CONFIG_LIST contains configurable options, while HAVE_LIST is for
842
# system-dependent things.
843

    
844
COMPONENT_LIST="
845
    bsfs
846
    decoders
847
    demuxers
848
    encoders
849
    filters
850
    hwaccels
851
    indevs
852
    muxers
853
    outdevs
854
    parsers
855
    protocols
856
"
857

    
858
CONFIG_LIST="
859
    $COMPONENT_LIST
860
    aandct
861
    avfilter
862
    avfilter_lavf
863
    avisynth
864
    beos_netserver
865
    bzlib
866
    dct
867
    doc
868
    fastdiv
869
    ffmpeg
870
    ffplay
871
    ffserver
872
    fft
873
    golomb
874
    gpl
875
    gprof
876
    gray
877
    hardcoded_tables
878
    ipv6
879
    libdc1394
880
    libdirac
881
    libfaac
882
    libfaad
883
    libfaadbin
884
    libgsm
885
    libmp3lame
886
    libnut
887
    libopencore_amrnb
888
    libopencore_amrwb
889
    libopenjpeg
890
    libschroedinger
891
    libspeex
892
    libtheora
893
    libvorbis
894
    libx264
895
    libxvid
896
    lpc
897
    mdct
898
    memalign_hack
899
    mlib
900
    mpegaudio_hp
901
    network
902
    nonfree
903
    pic
904
    postproc
905
    powerpc_perf
906
    rdft
907
    runtime_cpudetect
908
    shared
909
    small
910
    static
911
    swscale_alpha
912
    vaapi
913
    vdpau
914
    version3
915
    x11grab
916
    zlib
917
"
918

    
919
THREADS_LIST='
920
    beosthreads
921
    os2threads
922
    pthreads
923
    w32threads
924
'
925

    
926
ARCH_LIST='
927
    alpha
928
    arm
929
    avr32
930
    avr32_ap
931
    avr32_uc
932
    bfin
933
    ia64
934
    m68k
935
    mips
936
    mips64
937
    parisc
938
    ppc
939
    ppc64
940
    s390
941
    sh4
942
    sparc
943
    sparc64
944
    x86
945
    x86_32
946
    x86_64
947
'
948

    
949
ARCH_EXT_LIST='
950
    altivec
951
    amd3dnow
952
    amd3dnowext
953
    armv5te
954
    armv6
955
    armv6t2
956
    armvfp
957
    iwmmxt
958
    mmi
959
    mmx
960
    mmx2
961
    neon
962
    ppc4xx
963
    sse
964
    ssse3
965
    vis
966
'
967

    
968
HAVE_LIST_PUB='
969
    bigendian
970
'
971

    
972
HAVE_LIST="
973
    $ARCH_EXT_LIST
974
    $HAVE_LIST_PUB
975
    $THREADS_LIST
976
    alsa_asoundlib_h
977
    altivec_h
978
    arpa_inet_h
979
    attribute_packed
980
    bswap
981
    closesocket
982
    cmov
983
    conio_h
984
    dcbzl
985
    dev_bktr_ioctl_bt848_h
986
    dev_bktr_ioctl_meteor_h
987
    dev_ic_bt8xx_h
988
    dev_video_meteor_ioctl_meteor_h
989
    dev_video_bktr_ioctl_bt848_h
990
    dlfcn_h
991
    dlopen
992
    dos_paths
993
    ebp_available
994
    ebx_available
995
    exp2
996
    exp2f
997
    fast_64bit
998
    fast_clz
999
    fast_cmov
1000
    fast_unaligned
1001
    fork
1002
    getaddrinfo
1003
    gethrtime
1004
    GetProcessTimes
1005
    getrusage
1006
    inet_aton
1007
    inline_asm
1008
    isatty
1009
    ldbrx
1010
    libdc1394_1
1011
    libdc1394_2
1012
    llrint
1013
    log2
1014
    log2f
1015
    loongson
1016
    lrint
1017
    lrintf
1018
    lzo1x_999_compress
1019
    machine_ioctl_bt848_h
1020
    machine_ioctl_meteor_h
1021
    malloc_h
1022
    memalign
1023
    mkstemp
1024
    pld
1025
    posix_memalign
1026
    round
1027
    roundf
1028
    sdl
1029
    sdl_video_size
1030
    setmode
1031
    socklen_t
1032
    soundcard_h
1033
    poll_h
1034
    struct_addrinfo
1035
    struct_sockaddr_storage
1036
    sys_mman_h
1037
    sys_resource_h
1038
    sys_select_h
1039
    sys_soundcard_h
1040
    sys_videoio_h
1041
    ten_operands
1042
    termios_h
1043
    threads
1044
    truncf
1045
    vfp_args
1046
    VirtualAlloc
1047
    winsock2_h
1048
    xform_asm
1049
    yasm
1050
"
1051

    
1052
# options emitted with CONFIG_ prefix but not available on command line
1053
CONFIG_EXTRA="
1054
    gplv3
1055
    lgplv3
1056
"
1057

    
1058
CMDLINE_SELECT="
1059
    $ARCH_EXT_LIST
1060
    $CONFIG_LIST
1061
    $THREADS_LIST
1062
    asm
1063
    cross_compile
1064
    debug
1065
    extra_warnings
1066
    logging
1067
    optimizations
1068
    stripping
1069
    yasm
1070
"
1071

    
1072
PATHS_LIST='
1073
    bindir
1074
    datadir
1075
    incdir
1076
    libdir
1077
    mandir
1078
    prefix
1079
    shlibdir
1080
'
1081

    
1082
CMDLINE_SET="
1083
    $PATHS_LIST
1084
    arch
1085
    as
1086
    build_suffix
1087
    cc
1088
    cpu
1089
    cross_prefix
1090
    dep_cc
1091
    extra_version
1092
    host_cc
1093
    host_cflags
1094
    host_ldflags
1095
    host_libs
1096
    host_os
1097
    ld
1098
    logfile
1099
    nm
1100
    source_path
1101
    sysinclude
1102
    sysroot
1103
    target_exec
1104
    target_os
1105
    target_path
1106
"
1107

    
1108
CMDLINE_APPEND="
1109
    extra_cflags
1110
"
1111

    
1112
# code dependency declarations
1113

    
1114
# architecture extensions
1115

    
1116
armv5te_deps="arm"
1117
armv6_deps="arm"
1118
armv6t2_deps="arm"
1119
armvfp_deps="arm"
1120
iwmmxt_deps="arm"
1121
neon_deps="arm"
1122

    
1123
mmi_deps="mips"
1124

    
1125
altivec_deps="ppc"
1126
ppc4xx_deps="ppc"
1127

    
1128
vis_deps="sparc"
1129

    
1130
x86_64_select="cmov fast_cmov"
1131
amd3dnow_deps="mmx"
1132
amd3dnowext_deps="amd3dnow"
1133
mmx_deps="x86"
1134
mmx2_deps="mmx"
1135
sse_deps="mmx"
1136
ssse3_deps="sse"
1137

    
1138
fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1139
fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
1140
fast_unaligned_if_any="armv6 ppc x86"
1141

    
1142
need_memalign="altivec neon sse"
1143
inline_asm_deps="!tms470"
1144

    
1145
# decoders / encoders / hardware accelerators
1146
aac_decoder_select="fft mdct aac_parser"
1147
aac_encoder_select="fft mdct"
1148
ac3_decoder_select="fft mdct ac3_parser"
1149
alac_encoder_select="lpc"
1150
atrac3_decoder_select="fft mdct"
1151
cavs_decoder_select="golomb"
1152
cook_decoder_select="fft mdct"
1153
cscd_decoder_suggest="zlib"
1154
dca_decoder_select="fft mdct"
1155
dnxhd_encoder_select="aandct"
1156
dxa_decoder_select="zlib"
1157
eac3_decoder_select="ac3_decoder"
1158
eamad_decoder_select="aandct"
1159
eatgq_decoder_select="aandct"
1160
eatqi_decoder_select="aandct"
1161
ffv1_decoder_select="golomb"
1162
flac_decoder_select="golomb"
1163
flac_encoder_select="golomb lpc"
1164
flashsv_decoder_select="zlib"
1165
flashsv_encoder_select="zlib"
1166
flv_decoder_select="h263_decoder"
1167
flv_encoder_select="h263_encoder"
1168
h261_encoder_select="aandct"
1169
h263_decoder_select="h263_parser"
1170
h263_encoder_select="aandct"
1171
h263_vaapi_hwaccel_deps="va_va_h"
1172
h263_vaapi_hwaccel_select="vaapi h263_decoder"
1173
h263i_decoder_select="h263_decoder"
1174
h263p_encoder_select="h263_encoder"
1175
h264_decoder_select="golomb"
1176
h264_vaapi_hwaccel_deps="va_va_h"
1177
h264_vaapi_hwaccel_select="vaapi"
1178
h264_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1179
h264_vdpau_decoder_select="vdpau h264_decoder"
1180
imc_decoder_select="fft mdct"
1181
jpegls_decoder_select="golomb"
1182
jpegls_encoder_select="golomb"
1183
ljpeg_encoder_select="aandct"
1184
loco_decoder_select="golomb"
1185
mjpeg_encoder_select="aandct"
1186
mlp_decoder_select="mlp_parser"
1187
mpeg1video_encoder_select="aandct"
1188
mpeg2video_encoder_select="aandct"
1189
mpeg4_decoder_select="h263_decoder mpeg4video_parser"
1190
mpeg4_encoder_select="h263_encoder"
1191
mpeg_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1192
mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
1193
mpeg1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1194
mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
1195
mpeg2_vaapi_hwaccel_deps="va_va_h"
1196
mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
1197
mpeg4_vaapi_hwaccel_deps="va_va_h"
1198
mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
1199
mpeg4_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1200
mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
1201
mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
1202
mpeg_xvmc_decoder_select="mpegvideo_decoder"
1203
msmpeg4v1_decoder_select="h263_decoder"
1204
msmpeg4v1_encoder_select="h263_encoder"
1205
msmpeg4v2_decoder_select="h263_decoder"
1206
msmpeg4v2_encoder_select="h263_encoder"
1207
msmpeg4v3_decoder_select="h263_decoder"
1208
msmpeg4v3_encoder_select="h263_encoder"
1209
nellymoser_decoder_select="fft mdct"
1210
nellymoser_encoder_select="fft mdct"
1211
png_decoder_select="zlib"
1212
png_encoder_select="zlib"
1213
qdm2_decoder_select="fft mdct rdft"
1214
rv10_decoder_select="h263_decoder"
1215
rv10_encoder_select="h263_encoder"
1216
rv20_decoder_select="h263_decoder"
1217
rv20_encoder_select="h263_encoder"
1218
rv30_decoder_select="golomb"
1219
rv40_decoder_select="golomb"
1220
shorten_decoder_select="golomb"
1221
sonic_decoder_select="golomb"
1222
sonic_encoder_select="golomb"
1223
sonic_ls_encoder_select="golomb"
1224
svq3_decoder_select="golomb"
1225
svq3_decoder_suggest="zlib"
1226
theora_decoder_select="vp3_decoder"
1227
tiff_decoder_suggest="zlib"
1228
tiff_encoder_suggest="zlib"
1229
truehd_decoder_select="mlp_decoder"
1230
tscc_decoder_select="zlib"
1231
vc1_decoder_select="h263_decoder"
1232
vc1_vaapi_hwaccel_deps="va_va_h"
1233
vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
1234
vc1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1235
vc1_vdpau_decoder_select="vdpau vc1_decoder"
1236
vorbis_decoder_select="fft mdct"
1237
vorbis_encoder_select="fft mdct"
1238
vp6a_decoder_select="vp6_decoder"
1239
vp6f_decoder_select="vp6_decoder"
1240
wmav1_decoder_select="fft mdct"
1241
wmav1_encoder_select="fft mdct"
1242
wmav2_decoder_select="fft mdct"
1243
wmav2_encoder_select="fft mdct"
1244
wmv1_decoder_select="h263_decoder"
1245
wmv1_encoder_select="h263_encoder"
1246
wmv2_decoder_select="h263_decoder"
1247
wmv2_encoder_select="h263_encoder"
1248
wmv3_decoder_select="vc1_decoder"
1249
wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
1250
wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
1251
zlib_decoder_select="zlib"
1252
zlib_encoder_select="zlib"
1253
zmbv_decoder_select="zlib"
1254
zmbv_encoder_select="zlib"
1255

    
1256
# parsers
1257
h264_parser_select="golomb"
1258

    
1259
# bitstream_filters
1260
aac_adtstoasc_bsf_select="aac_parser"
1261

    
1262
# external libraries
1263
libdirac_decoder_deps="libdirac !libschroedinger"
1264
libdirac_encoder_deps="libdirac"
1265
libfaac_encoder_deps="libfaac"
1266
libfaad_decoder_deps="libfaad"
1267
libfaadbin_decoder_extralibs='$ldl'
1268
libgsm_decoder_deps="libgsm"
1269
libgsm_encoder_deps="libgsm"
1270
libgsm_ms_decoder_deps="libgsm"
1271
libgsm_ms_encoder_deps="libgsm"
1272
libmp3lame_encoder_deps="libmp3lame"
1273
libopencore_amrnb_decoder_deps="libopencore_amrnb"
1274
libopencore_amrnb_encoder_deps="libopencore_amrnb"
1275
libopencore_amrwb_decoder_deps="libopencore_amrwb"
1276
libopenjpeg_decoder_deps="libopenjpeg"
1277
libschroedinger_decoder_deps="libschroedinger"
1278
libschroedinger_encoder_deps="libschroedinger"
1279
libspeex_decoder_deps="libspeex"
1280
libtheora_encoder_deps="libtheora"
1281
libvorbis_encoder_deps="libvorbis"
1282
libx264_encoder_deps="libx264"
1283
libxvid_encoder_deps="libxvid"
1284

    
1285
# demuxers / muxers
1286
ac3_demuxer_deps="ac3_parser"
1287
asf_stream_muxer_select="asf_muxer"
1288
avisynth_demuxer_deps="avisynth"
1289
dirac_demuxer_deps="dirac_parser"
1290
eac3_demuxer_select="ac3_parser"
1291
ipod_muxer_select="mov_muxer"
1292
libnut_demuxer_deps="libnut"
1293
libnut_muxer_deps="libnut"
1294
matroska_audio_muxer_select="matroska_muxer"
1295
matroska_demuxer_suggest="zlib bzlib"
1296
mov_demuxer_suggest="zlib"
1297
mp3_demuxer_deps="mpegaudio_parser"
1298
mp4_muxer_select="mov_muxer"
1299
mpegtsraw_demuxer_select="mpegts_demuxer"
1300
mxf_d10_muxer_select="mxf_muxer"
1301
ogg_demuxer_select="golomb"
1302
psp_muxer_select="mov_muxer"
1303
rtsp_demuxer_deps="sdp_demuxer"
1304
sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
1305
spdif_muxer_select="aac_parser"
1306
tg2_muxer_select="mov_muxer"
1307
tgp_muxer_select="mov_muxer"
1308
w64_demuxer_deps="wav_demuxer"
1309

    
1310
# indevs / outdevs
1311
alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1312
alsa_indev_extralibs="-lasound"
1313
alsa_outdev_deps="alsa_asoundlib_h"
1314
alsa_outdev_extralibs="-lasound"
1315
audio_beos_indev_deps="audio_beos"
1316
audio_beos_indev_extralibs="-lmedia -lbe"
1317
audio_beos_outdev_deps="audio_beos"
1318
audio_beos_outdev_extralibs="-lmedia -lbe"
1319
bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
1320
dv1394_indev_deps="dv1394 dv_demuxer"
1321
jack_indev_deps="jack_jack_h"
1322
jack_indev_extralibs="-ljack"
1323
libdc1394_indev_deps="libdc1394"
1324
oss_indev_deps_any="soundcard_h sys_soundcard_h"
1325
oss_outdev_deps_any="soundcard_h sys_soundcard_h"
1326
v4l_indev_deps="linux_videodev_h"
1327
v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
1328
vfwcap_indev_deps="capCreateCaptureWindow"
1329
vfwcap_indev_extralibs="-lvfw32"
1330
x11_grab_device_indev_deps="x11grab XShmCreateImage"
1331
x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
1332

    
1333
# protocols
1334
gopher_protocol_deps="network"
1335
http_protocol_deps="network"
1336
rtmp_protocol_deps="tcp_protocol"
1337
rtp_protocol_deps="udp_protocol"
1338
tcp_protocol_deps="network"
1339
udp_protocol_deps="network"
1340

    
1341
# filters
1342
movie_filter_deps="avfilter_lavf"
1343

    
1344
# programs
1345
ffplay_deps="sdl"
1346
ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
1347
ffserver_extralibs='$ldl'
1348

    
1349
doc_deps="texi2html"
1350

    
1351
# default parameters
1352

    
1353
logfile="config.err"
1354

    
1355
# installation paths
1356
prefix_default="/usr/local"
1357
bindir_default='${prefix}/bin'
1358
datadir_default='${prefix}/share/ffmpeg'
1359
incdir_default='${prefix}/include'
1360
libdir_default='${prefix}/lib'
1361
mandir_default='${prefix}/share/man'
1362
shlibdir_default="$libdir_default"
1363

    
1364
# toolchain
1365
ar="ar"
1366
cc_default="gcc"
1367
cc_version=\"unknown\"
1368
host_cc_default="gcc"
1369
ln_s="ln -sf"
1370
nm_default="nm"
1371
objformat="elf"
1372
ranlib="ranlib"
1373
strip="strip"
1374
yasmexe="yasm"
1375

    
1376
nm_opts='-g'
1377

    
1378
# machine
1379
arch=$(uname -m)
1380
cpu="generic"
1381

    
1382
# OS
1383
target_os=$(tolower $(uname -s))
1384
host_os=$target_os
1385

    
1386
# configurable options
1387
enable asm
1388
enable debug
1389
enable doc
1390
enable fastdiv
1391
enable ffmpeg
1392
enable ffplay
1393
enable ffserver
1394
enable ipv6
1395
enable mpegaudio_hp
1396
enable network
1397
enable optimizations
1398
enable protocols
1399
enable static
1400
enable stripping
1401
enable swscale_alpha
1402

    
1403
# build settings
1404
SHFLAGS='-shared -Wl,-soname,$$(@F)'
1405
FFSERVERLDFLAGS=-Wl,-E
1406
LIBPREF="lib"
1407
LIBSUF=".a"
1408
FULLNAME='$(NAME)$(BUILDSUF)'
1409
LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
1410
SLIBPREF="lib"
1411
SLIBSUF=".so"
1412
SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
1413
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1414
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
1415
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
1416

    
1417
CC_O='-o $@'
1418

    
1419
host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
1420
host_libs='-lm'
1421

    
1422
target_path='.'
1423

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

    
1429
# find source path
1430
source_path="$(dirname "$0")"
1431
enable source_path_used
1432
if test -f configure; then
1433
    source_path="$(pwd)"
1434
    disable source_path_used
1435
else
1436
    source_path="$(cd "$source_path"; pwd)"
1437
    echo "$source_path" | grep -q '[[:blank:]]' &&
1438
        die "Out of tree builds are impossible with whitespace in source path."
1439
    test -e "$source_path/config.h" &&
1440
        die "Out of tree builds are impossible with config.h in source dir."
1441
fi
1442

    
1443
for v in "$@"; do
1444
    r=${v#*=}
1445
    l=${v%"$r"}
1446
    r=$(sh_quote "$r")
1447
    FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
1448
done
1449

    
1450
find_things(){
1451
    thing=$1
1452
    pattern=$2
1453
    file=$source_path/$3
1454
    sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
1455
}
1456

    
1457
ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
1458
DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
1459
HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
1460
PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
1461
BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
1462
MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
1463
DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
1464
OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
1465
INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
1466
PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
1467
FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
1468

    
1469
enable $ARCH_EXT_LIST \
1470
       $DECODER_LIST \
1471
       $ENCODER_LIST \
1472
       $HWACCEL_LIST \
1473
       $PARSER_LIST \
1474
       $BSF_LIST \
1475
       $DEMUXER_LIST \
1476
       $MUXER_LIST \
1477
       $FILTER_LIST \
1478
       $PROTOCOL_LIST \
1479
       $INDEV_LIST \
1480
       $OUTDEV_LIST \
1481

    
1482
die_unknown(){
1483
    echo "Unknown option \"$1\"."
1484
    echo "See $0 --help for available options."
1485
    exit 1
1486
}
1487

    
1488
show_list() {
1489
    suffix=_$1
1490
    shift
1491
    echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
1492
    exit 0
1493
}
1494

    
1495
for opt do
1496
    optval="${opt#*=}"
1497
    case "$opt" in
1498
    --extra-ldflags=*) add_ldflags $optval
1499
    ;;
1500
    --extra-libs=*) add_extralibs $optval
1501
    ;;
1502
    --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
1503
    ;;
1504
    --enable-debug=*) debuglevel="$optval"
1505
    ;;
1506
    --enable-*=*|--disable-*=*)
1507
    eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
1508
    is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1509
    eval list=\$$(toupper $thing)_LIST
1510
    name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1511
    $action $(filter "$name" $list)
1512
    ;;
1513
    --enable-?*|--disable-?*)
1514
    eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
1515
    if is_in $option $COMPONENT_LIST; then
1516
        test $action = disable && action=unset
1517
        eval $action \$$(toupper ${option%s})_LIST
1518
    elif is_in $option $CMDLINE_SELECT; then
1519
        $action $option
1520
    else
1521
        die_unknown $opt
1522
    fi
1523
    ;;
1524
    --list-*)
1525
        NAME="${opt#--list-}"
1526
        is_in $NAME $COMPONENT_LIST || die_unknown $opt
1527
        NAME=${NAME%s}
1528
        eval show_list $NAME \$$(toupper $NAME)_LIST
1529
    ;;
1530
    --help|-h) show_help
1531
    ;;
1532
    *)
1533
    optname="${opt%%=*}"
1534
    optname="${optname#--}"
1535
    optname=$(echo "$optname" | sed 's/-/_/g')
1536
    if is_in $optname $CMDLINE_SET; then
1537
        eval $optname='$optval'
1538
    elif is_in $optname $CMDLINE_APPEND; then
1539
        append $optname "$optval"
1540
    else
1541
         die_unknown $opt
1542
    fi
1543
    ;;
1544
    esac
1545
done
1546

    
1547
disabled logging && logfile=/dev/null
1548

    
1549
echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
1550
set >> $logfile
1551

    
1552
test -n "$cross_prefix" && enable cross_compile
1553

    
1554
ar="${cross_prefix}${ar}"
1555
cc_default="${cross_prefix}${cc_default}"
1556
nm_default="${cross_prefix}${nm_default}"
1557
ranlib="${cross_prefix}${ranlib}"
1558
strip="${cross_prefix}${strip}"
1559

    
1560
sysinclude_default="${sysroot}/usr/include"
1561

    
1562
set_default cc nm sysinclude
1563
enabled cross_compile || host_cc_default=$cc
1564
set_default host_cc
1565

    
1566
exesuf() {
1567
    case $1 in
1568
        mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
1569
    esac
1570
}
1571

    
1572
EXESUF=$(exesuf $target_os)
1573
HOSTEXESUF=$(exesuf $host_os)
1574

    
1575
# set temporary file name
1576
: ${TMPDIR:=$TEMPDIR}
1577
: ${TMPDIR:=$TMP}
1578
: ${TMPDIR:=/tmp}
1579

    
1580
if ! check_cmd type mktemp; then
1581
    # simple replacement for missing mktemp
1582
    # NOT SAFE FOR GENERAL USE
1583
    mktemp(){
1584
        echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
1585
    }
1586
fi
1587

    
1588
tmpfile(){
1589
    tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
1590
        (set -C; exec > $tmp) 2>/dev/null ||
1591
        die "Unable to create temporary file in $TMPDIR."
1592
    append TMPFILES $tmp
1593
    eval $1=$tmp
1594
}
1595

    
1596
trap 'rm -f -- $TMPFILES' EXIT
1597
trap exit HUP INT TERM
1598

    
1599
tmpfile TMPC  .c
1600
tmpfile TMPE  $EXESUF
1601
tmpfile TMPH  .h
1602
tmpfile TMPO  .o
1603
tmpfile TMPS  .S
1604
tmpfile TMPV  .ver
1605
tmpfile TMPSH .sh
1606

    
1607
unset -f mktemp
1608

    
1609
# make sure we can execute files in $TMPDIR
1610
cat > $TMPSH 2>> $logfile <<EOF
1611
#! /bin/sh
1612
EOF
1613
chmod +x $TMPSH >> $logfile 2>&1
1614
if ! $TMPSH >> $logfile 2>&1; then
1615
    cat <<EOF
1616
Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
1617
variable to another directory and make sure that it is not mounted noexec.
1618
EOF
1619
    die "Sanity test failed."
1620
fi
1621

    
1622
filter_cflags=echo
1623
filter_cppflags=echo
1624
filter_asflags=echo
1625

    
1626
if   $cc -v 2>&1 | grep -qi ^gcc; then
1627
    cc_type=gcc
1628
    cc_version=__VERSION__
1629
    if ! $cc -dumpversion | grep -q '^2\.'; then
1630
        CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1631
        AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1632
    fi
1633
elif $cc --version 2>/dev/null | grep -q Intel; then
1634
    cc_type=icc
1635
    cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
1636
    CC_DEPFLAGS='-MMD'
1637
    AS_DEPFLAGS='-MMD'
1638
elif $cc -v 2>&1 | grep -q xlc; then
1639
    cc_type=xlc
1640
    cc_version="AV_STRINGIFY(__IBMC__)"
1641
elif $cc -V 2>/dev/null | grep -q Compaq; then
1642
    cc_type=ccc
1643
    cc_version="AV_STRINGIFY(__DECC_VER)"
1644
    DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
1645
    debuglevel=3
1646
    add_ldflags -Wl,-z,now # calls to libots crash without this
1647
elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
1648
    test -d "$sysroot" || die "No valid sysroot specified."
1649
    cc_type=armcc
1650
    cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
1651
    armcc_conf="$PWD/armcc.conf"
1652
    $cc --arm_linux_configure                 \
1653
        --arm_linux_config_file="$armcc_conf" \
1654
        --configure_sysroot="$sysroot"        \
1655
        --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
1656
        die "Error creating armcc configuration file."
1657
    cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
1658
    as_default="${cross_prefix}gcc"
1659
    CC_DEPFLAGS='-MMD'
1660
    AS_DEPFLAGS='-MMD'
1661
elif $cc -version 2>/dev/null | grep -q TMS470; then
1662
    cc_type=tms470
1663
    cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
1664
    cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
1665
    CC_O='-fr=$(@D)'
1666
    as_default="${cross_prefix}gcc"
1667
    ld_default="${cross_prefix}gcc"
1668
    TMPO=$(basename $TMPC .c).o
1669
    append TMPFILES $TMPO
1670
    add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
1671
    CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
1672
    AS_DEPFLAGS='-MMD'
1673
    filter_cflags=tms470_flags
1674
    tms470_flags(){
1675
        for flag; do
1676
            case $flag in
1677
                -march=*|-mcpu=*)
1678
                    case "${flag#*=}" in
1679
                        armv7-a|cortex-a*)      echo -mv=7a8 ;;
1680
                        armv7-r|cortex-r*)      echo -mv=7r4 ;;
1681
                        armv7-m|cortex-m*)      echo -mv=7m3 ;;
1682
                        armv6*|arm11*)          echo -mv=6   ;;
1683
                        armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
1684
                                                echo -mv=5e  ;;
1685
                        armv4*|arm7*|arm9[24]*) echo -mv=4   ;;
1686
                    esac
1687
                    ;;
1688
                -mfpu=neon)     echo --float_support=vfpv3 --neon ;;
1689
                -mfpu=vfp)      echo --float_support=vfpv2        ;;
1690
                -msoft-float)   echo --float_support=vfplib       ;;
1691
                -Os)            echo -O3 -mf=2                    ;;
1692
                -O[0-3])        echo $flag -mf=5                  ;;
1693
                -g)             echo -g -mn                       ;;
1694
            esac
1695
        done
1696
    }
1697
elif $cc -v 2>&1 | grep -q clang; then
1698
    cc_type=clang
1699
    cc_version=__VERSION__
1700
    CC_DEPFLAGS='-MMD'
1701
    AS_DEPFLAGS='-MMD'
1702
elif $cc -V 2>&1 | grep -q Sun; then
1703
    cc_type=suncc
1704
    cc_version="AV_STRINGIFY(__SUNPRO_C)"
1705
    DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
1706
    DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
1707
    filter_cflags=suncc_flags
1708
    suncc_flags(){
1709
        for flag; do
1710
            case $flag in
1711
                -march=*|-mcpu=*)
1712
                    case "${flag#*=}" in
1713
                        native)                   echo -xtarget=native       ;;
1714
                        v9)                       echo -xarch=sparc          ;;
1715
                        ultrasparc)               echo -xarch=sparcvis       ;;
1716
                        ultrasparc3|niagara*)     echo -xarch=sparcvis2      ;;
1717
                        i586|pentium)             echo -xchip=pentium        ;;
1718
                        i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
1719
                        pentium3*|c3-2)           echo -xtarget=pentium3     ;;
1720
                        pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
1721
                        pentium4*)          echo -xtarget=pentium4           ;;
1722
                        prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
1723
                        *-sse3)             echo -xarch=sse3                 ;;
1724
                        core2)              echo -xarch=ssse3 -xchip=core2   ;;
1725
                        amdfam10|barcelona)       echo -xarch=sse4_1         ;;
1726
                        athlon-4|athlon-[mx]p)    echo -xarch=ssea           ;;
1727
                        k8|opteron|athlon64|athlon-fx)
1728
                                                  echo -xarch=sse2a          ;;
1729
                        athlon*)                  echo -xarch=pentium_proa   ;;
1730
                    esac
1731
                    ;;
1732
                -std=c99)             echo -xc99              ;;
1733
                -fomit-frame-pointer) echo -xregs=frameptr    ;;
1734
                -fPIC)                echo -KPIC -xcode=pic32 ;;
1735
                -Os)                  echo -O5 -xspace        ;;
1736
                -W*,*)                echo $flag              ;;
1737
                -f*-*|-W*)                                    ;;
1738
                *)                    echo $flag              ;;
1739
            esac
1740
        done
1741
    }
1742
fi
1743

    
1744
test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
1745

    
1746
: ${as_default:=$cc}
1747
: ${dep_cc_default:=$cc}
1748
: ${ld_default:=$cc}
1749
set_default as dep_cc ld
1750

    
1751
test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
1752
test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
1753

    
1754
add_cflags $extra_cflags
1755
add_asflags $extra_cflags
1756

    
1757
if test -n "$sysroot"; then
1758
    case "$cc_type" in
1759
        gcc)
1760
            add_cppflags --sysroot="$sysroot"
1761
            add_ldflags --sysroot="$sysroot"
1762
        ;;
1763
        tms470)
1764
            add_cppflags -I"$sysinclude"
1765
            add_ldflags  --sysroot="$sysroot"
1766
        ;;
1767
        clang)
1768
            add_cppflags -isysroot="$sysroot"
1769
            add_ldflags -isysroot="$sysroot"
1770
        ;;
1771
    esac
1772
fi
1773

    
1774
if test "$cpu" = host; then
1775
    enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
1776

    
1777
    case "$cc_type" in
1778
        gcc)
1779
            check_native(){
1780
                $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
1781
                awk "/$1=/{ match(\$0, /$1=(\\w+)/, a);print a[1];exit }" $TMPE
1782
            }
1783
            cpu=$(check_native -march || check_native -mcpu)
1784
        ;;
1785
    esac
1786

    
1787
    test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
1788
fi
1789

    
1790
# Deal with common $arch aliases
1791
case "$arch" in
1792
    arm*)
1793
        arch="arm"
1794
    ;;
1795
    mips|mipsel|IP*)
1796
        arch="mips"
1797
    ;;
1798
    mips64)
1799
        arch="mips"
1800
        subarch="mips64"
1801
    ;;
1802
    parisc|hppa)
1803
        arch="parisc"
1804
    ;;
1805
    parisc64|hppa64)
1806
        arch="parisc"
1807
        subarch="parisc64"
1808
    ;;
1809
    "Power Macintosh"|ppc|powerpc)
1810
        arch="ppc"
1811
    ;;
1812
    ppc64)
1813
        arch="ppc"
1814
        subarch="ppc64"
1815
    ;;
1816
    s390|s390x)
1817
        arch="s390"
1818
    ;;
1819
    sh4|sh)
1820
        arch="sh4"
1821
    ;;
1822
    sun4u|sparc64)
1823
        arch="sparc"
1824
        subarch="sparc64"
1825
    ;;
1826
    i[3-6]86|i86pc|BePC|x86_64|amd64)
1827
        arch="x86"
1828
    ;;
1829
esac
1830

    
1831
is_in $arch $ARCH_LIST || echo "WARNING: unknown arch $arch"
1832
enable $arch
1833

    
1834
# Add processor-specific flags
1835
if test "$cpu" = generic; then
1836
    : do nothing
1837
elif enabled ppc; then
1838

    
1839
    case $cpu in
1840
        601|ppc601|PowerPC601)
1841
            cpuflags="-mcpu=601"
1842
        ;;
1843
        603*|ppc603*|PowerPC603*)
1844
            cpuflags="-mcpu=603"
1845
        ;;
1846
        604*|ppc604*|PowerPC604*)
1847
            cpuflags="-mcpu=604"
1848
        ;;
1849
        G3|g3|75*|ppc75*|PowerPC75*)
1850
            cpuflags="-mcpu=750 -mpowerpc-gfxopt"
1851
        ;;
1852
        G4|g4|745*|ppc745*|PowerPC745*)
1853
            cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
1854
        ;;
1855
        74*|ppc74*|PowerPC74*)
1856
            cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
1857
        ;;
1858
        G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1859
            cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1860
        ;;
1861
        Cell|CELL|cell)
1862
            cpuflags="-mcpu=cell"
1863
            enable ldbrx
1864
        ;;
1865
    esac
1866

    
1867
elif enabled x86; then
1868

    
1869
    case $cpu in
1870
        i[345]86|pentium)
1871
            cpuflags="-march=$cpu"
1872
            disable mmx
1873
        ;;
1874
        # targets that do NOT support conditional mov (cmov)
1875
        pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1876
            cpuflags="-march=$cpu"
1877
            disable cmov
1878
        ;;
1879
        # targets that do support conditional mov (cmov)
1880
        i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10)
1881
            cpuflags="-march=$cpu"
1882
            enable cmov
1883
            enable fast_cmov
1884
        ;;
1885
        # targets that do support conditional mov but on which it's slow
1886
        pentium4|pentium4m|prescott|nocona)
1887
            cpuflags="-march=$cpu"
1888
            enable cmov
1889
            disable fast_cmov
1890
        ;;
1891
    esac
1892

    
1893
elif enabled sparc; then
1894

    
1895
    case $cpu in
1896
        sparc64)
1897
            cpuflags="-mcpu=v9"
1898
        ;;
1899
    esac
1900

    
1901
elif enabled arm; then
1902

    
1903
    case $cpu in
1904
        armv*)
1905
            cpuflags="-march=$cpu"
1906
        ;;
1907
        *)
1908
            cpuflags="-mcpu=$cpu"
1909
        ;;
1910
    esac
1911

    
1912
elif enabled alpha; then
1913

    
1914
    enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
1915

    
1916
elif enabled bfin; then
1917

    
1918
    cpuflags="-mcpu=$cpu"
1919

    
1920
elif enabled mips; then
1921

    
1922
    cpuflags="-march=$cpu"
1923

    
1924
elif enabled avr32; then
1925

    
1926
    case $cpu in
1927
        ap7[02]0[0-2])
1928
            subarch="avr32_ap"
1929
            cpuflags="-mpart=$cpu"
1930
        ;;
1931
        ap)
1932
            subarch="avr32_ap"
1933
            cpuflags="-march=$cpu"
1934
        ;;
1935
        uc3[ab]*)
1936
            subarch="avr32_uc"
1937
            cpuflags="-mcpu=$cpu"
1938
        ;;
1939
        uc)
1940
            subarch="avr32_uc"
1941
            cpuflags="-march=$cpu"
1942
        ;;
1943
    esac
1944

    
1945
fi
1946

    
1947
add_cflags $cpuflags
1948
add_asflags $cpuflags
1949

    
1950
# compiler sanity check
1951
check_exec <<EOF
1952
int main(void){ return 0; }
1953
EOF
1954
if test "$?" != 0; then
1955
    echo "$cc is unable to create an executable file."
1956
    if test -z "$cross_prefix" && ! enabled cross_compile ; then
1957
        echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
1958
        echo "Only do this if you know what cross compiling means."
1959
    fi
1960
    die "C compiler test failed."
1961
fi
1962

    
1963
add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
1964
check_cflags -std=c99
1965
check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
1966
#include <stdlib.h>
1967
EOF
1968
check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
1969
#include <stdlib.h>
1970
EOF
1971

    
1972
check_host_cflags -std=c99
1973

    
1974
case "$arch" in
1975
    alpha|ia64|mips|parisc|sparc)
1976
        spic=$shared
1977
    ;;
1978
    x86)
1979
        subarch="x86_32"
1980
        check_cc <<EOF && subarch="x86_64"
1981
        int test[(int)sizeof(char*) - 7];
1982
EOF
1983
        if test "$subarch" = "x86_64"; then
1984
            spic=$shared
1985
        fi
1986
    ;;
1987
esac
1988

    
1989
enable $subarch
1990
enabled spic && enable pic
1991
check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
1992

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

    
2157
    *)
2158
        die "Unknown OS '$target_os'."
2159
        ;;
2160
esac
2161

    
2162
set_default $PATHS_LIST
2163

    
2164
add_extralibs $osextralibs
2165

    
2166
# Combine FFLDFLAGS and the LDFLAGS environment variable.
2167
LDFLAGS="$FFLDFLAGS $LDFLAGS"
2168

    
2169
# we need to build at least one lib type
2170
if ! enabled_any static shared; then
2171
    cat <<EOF
2172
At least one library type must be built.
2173
Specify --enable-static to build the static libraries or --enable-shared to
2174
build the shared libraries as well. To only build the shared libraries specify
2175
--disable-static in addition to --enable-shared.
2176
EOF
2177
    exit 1;
2178
fi
2179

    
2180
disabled static && LIBNAME=""
2181

    
2182
if enabled_any libfaad libfaadbin ; then
2183
    if check_header faad.h; then
2184
        check_cc <<EOF
2185
#include <faad.h>
2186
#ifndef FAAD2_VERSION
2187
ok faad1
2188
#endif
2189
int main(void) { return 0; }
2190
EOF
2191
        test $? = 0 && enable libfaad2
2192
    else
2193
        die "FAAD test failed."
2194
    fi
2195
fi
2196

    
2197

    
2198
die_license_disabled() {
2199
    enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2200
}
2201

    
2202
die_license_disabled gpl libfaad2
2203
die_license_disabled gpl libx264
2204
die_license_disabled gpl libxvid
2205
die_license_disabled gpl postproc
2206
die_license_disabled gpl x11grab
2207

    
2208
die_license_disabled nonfree libfaac
2209

    
2210
die_license_disabled version3 libopencore_amrnb
2211
die_license_disabled version3 libopencore_amrwb
2212

    
2213
enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2214

    
2215
check_deps $ARCH_EXT_LIST
2216

    
2217
disabled optimizations || check_cflags -fomit-frame-pointer
2218

    
2219
enable_pic() {
2220
    enable pic
2221
    add_cppflags -DPIC
2222
    add_cflags   -fPIC
2223
    add_asflags  -fPIC
2224
}
2225

    
2226
enabled pic && enable_pic
2227

    
2228
check_cc <<EOF || die "Symbol mangling check failed."
2229
int ff_extern;
2230
EOF
2231
sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
2232
extern_prefix=${sym%%ff_extern*}
2233

    
2234
check_cc <<EOF && enable inline_asm
2235
void foo(void) { __asm__ volatile ("" ::); }
2236
EOF
2237

    
2238
_restrict=
2239
for restrict_keyword in restrict __restrict__ __restrict; do
2240
    check_cc <<EOF && _restrict=$restrict_keyword && break
2241
void foo(char * $restrict_keyword p);
2242
EOF
2243
done
2244

    
2245
check_cc <<EOF && enable attribute_packed
2246
struct { int x; } __attribute__((packed)) x;
2247
EOF
2248

    
2249
check_cc <<EOF || die "endian test failed"
2250
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2251
EOF
2252
od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2253

    
2254
if enabled alpha; then
2255

    
2256
    check_cflags -mieee
2257

    
2258
elif enabled arm; then
2259

    
2260
    check_cflags -marm
2261

    
2262
    check_ld <<EOF && enable vfp_args
2263
__asm__ (".eabi_attribute 28, 1");
2264
int main(void) { return 0; }
2265
EOF
2266

    
2267
    # We have to check if pld is a nop and disable it.
2268
    check_asm pld '"pld [r0]"'
2269

    
2270
    enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2271
    enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
2272
    enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2273
    enabled armvfp  && check_asm armvfp  '"fadds s0, s0, s0"'
2274
    enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
2275
    enabled neon    && check_asm neon    '"vadd.i16 q0, q0, q0"'
2276

    
2277
    enabled_all armv6t2 shared !pic && enable_pic
2278

    
2279
elif enabled ia64; then
2280

    
2281
    # HACK: currently fails to build if .bss is > 4MB and shared libs are built
2282
    enabled shared && enable_weak hardcoded_tables
2283

    
2284
elif enabled mips; then
2285

    
2286
    check_asm loongson '"dmult.g $1, $2, $3"'
2287
    enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
2288

    
2289
elif enabled ppc; then
2290

    
2291
    check_asm dcbzl     '"dcbzl 0, 1"'
2292
    check_asm ppc4xx    '"maclhw r10, r11, r12"'
2293
    check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
2294

    
2295
    # AltiVec flags: The FSF version of GCC differs from the Apple version
2296
    if enabled altivec; then
2297
        check_cflags -maltivec -mabi=altivec &&
2298
        { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2299
        check_cflags -faltivec
2300

    
2301
        # check if our compiler supports Motorola AltiVec C API
2302
        check_cc <<EOF || disable altivec
2303
$inc_altivec_h
2304
int main(void) {
2305
    vector signed int v1, v2, v3;
2306
    v1 = vec_add(v2,v3);
2307
    return 0;
2308
}
2309
EOF
2310

    
2311
        # check if our compiler supports braces for vector declarations
2312
        check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
2313
$inc_altivec_h
2314
int main (void) { (vector int) {1}; return 0; }
2315
EOF
2316
    fi
2317

    
2318
elif enabled sparc; then
2319

    
2320
    enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2321
        add_cflags -mcpu=ultrasparc -mtune=ultrasparc
2322

    
2323
elif enabled x86; then
2324

    
2325
    # check whether EBP is available on x86
2326
    # As 'i' is stored on the stack, this program will crash
2327
    # if the base pointer is used to access it because the
2328
    # base pointer is cleared in the inline assembly code.
2329
    check_exec_crash <<EOF && enable ebp_available
2330
    volatile int i=0;
2331
    __asm__ volatile (
2332
        "xorl %%ebp, %%ebp"
2333
    ::: "%ebp");
2334
    return i;
2335
EOF
2336

    
2337
    # check whether EBX is available on x86
2338
    check_asm ebx_available '""::"b"(0)' &&
2339
        check_asm ebx_available '"":::"%ebx"'
2340

    
2341
    # check whether more than 10 operands are supported
2342
    check_cc <<EOF && enable ten_operands
2343
int main(void) {
2344
    int x=0;
2345
    __asm__ volatile(
2346
        ""
2347
        :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
2348
    );
2349
    return 0;
2350
}
2351
EOF
2352

    
2353
    # check whether binutils is new enough to compile SSSE3/MMX2
2354
    enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
2355
    enabled mmx2  && check_asm mmx2  '"pmaxub %mm0, %mm1"'
2356

    
2357
    check_asm bswap '"bswap %%eax" ::: "%eax"'
2358

    
2359
    YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
2360
    enabled     x86_64        && append YASMFLAGS "-m amd64"
2361
    enabled     pic           && append YASMFLAGS "-DPIC"
2362
    test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
2363
    case "$objformat" in
2364
        elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
2365
    esac
2366
    disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
2367

    
2368
    case "$cpu" in
2369
        athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
2370
            disable fast_clz
2371
        ;;
2372
    esac
2373

    
2374
fi
2375

    
2376
if check_func dlopen; then
2377
    ldl=
2378
elif check_func dlopen -ldl; then
2379
    ldl=-ldl
2380
fi
2381

    
2382
# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2383
check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2384

    
2385
check_func  fork
2386
check_func  getaddrinfo $network_extralibs
2387
check_func  gethrtime
2388
check_func  getrusage
2389
check_func  inet_aton $network_extralibs
2390
check_func  isatty
2391
check_func  memalign
2392
check_func  mkstemp
2393
check_func  posix_memalign
2394
check_func_headers io.h setmode
2395
check_func_headers lzo/lzo1x.h lzo1x_999_compress
2396
check_func_headers windows.h GetProcessTimes
2397
check_func_headers windows.h VirtualAlloc
2398

    
2399
check_header conio.h
2400
check_header dlfcn.h
2401
check_header malloc.h
2402
check_header poll.h
2403
check_header sys/mman.h
2404
check_header sys/resource.h
2405
check_header sys/select.h
2406
check_header termios.h
2407
check_header vdpau/vdpau.h
2408
check_header vdpau/vdpau_x11.h
2409
check_header X11/extensions/XvMClib.h
2410

    
2411
if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
2412
     enabled_any $need_memalign ; then
2413
    die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
2414
fi
2415

    
2416
disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
2417
disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
2418

    
2419
# check for some common methods of building with pthread support
2420
# do this before the optional library checks as some of them require pthreads
2421
if enabled pthreads; then
2422
    if check_func pthread_create; then
2423
        :
2424
    elif check_func pthread_create -pthread; then
2425
        add_cflags -pthread
2426
        add_extralibs -pthread
2427
    elif check_func pthread_create -pthreads; then
2428
        add_cflags -pthreads
2429
        add_extralibs -pthreads
2430
    elif check_func pthread_create -lpthreadGC2; then
2431
        add_extralibs -lpthreadGC2
2432
    elif ! check_lib pthread.h pthread_create -lpthread; then
2433
        die "ERROR: can't find pthreads library"
2434
    fi
2435
fi
2436

    
2437
for thread in $THREADS_LIST; do
2438
    if enabled $thread; then
2439
        test -n "$thread_type" &&
2440
            die "ERROR: Only one thread type must be selected." ||
2441
            thread_type="$thread"
2442
    fi
2443
done
2444

    
2445
check_lib math.h sin -lm
2446
check_lib va/va.h vaInitialize -lva
2447

    
2448
check_func exp2
2449
check_func exp2f
2450
check_func llrint
2451
check_func log2
2452
check_func log2f
2453
check_func lrint
2454
check_func lrintf
2455
check_func round
2456
check_func roundf
2457
check_func truncf
2458

    
2459
# these are off by default, so fail if requested and not available
2460
enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
2461
enabled libdirac   && add_cflags $(pkg-config --cflags dirac) &&
2462
                      require  libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
2463
                      require  libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
2464
enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
2465
enabled libfaad    && require2 libfaad faad.h faacDecOpen -lfaad
2466
enabled libgsm     && require  libgsm gsm.h gsm_create -lgsm
2467
enabled libmp3lame && require  libmp3lame lame/lame.h lame_init -lmp3lame -lm
2468
enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
2469
enabled libopencore_amrnb  && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
2470
enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
2471
enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
2472
enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
2473
                           require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
2474
enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
2475
enabled libtheora  && require  libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
2476
enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
2477
enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 -lm &&
2478
                      { check_cpp_condition x264.h "X264_BUILD >= 83" ||
2479
                        die "ERROR: libx264 version must be >= 0.83."; }
2480
enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
2481
enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
2482

    
2483
# libdc1394 check
2484
if enabled libdc1394; then
2485
    { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2486
        enable libdc1394_2; } ||
2487
    { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2488
        enable libdc1394_1; } ||
2489
    die "ERROR: No version of libdc1394 found "
2490
fi
2491

    
2492
SDL_CONFIG="${cross_prefix}sdl-config"
2493
if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
2494
    sdl_cflags=$("${SDL_CONFIG}" --cflags)
2495
    sdl_libs=$("${SDL_CONFIG}" --libs)
2496
    check_func_headers SDL.h SDL_Init $sdl_cflags $sdl_libs &&
2497
    check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
2498
    enable sdl &&
2499
    check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
2500
fi
2501

    
2502
texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
2503

    
2504
if enabled network; then
2505
    check_type "sys/types.h sys/socket.h" socklen_t
2506
    check_type netdb.h "struct addrinfo"
2507
    check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
2508
    # Prefer arpa/inet.h over winsock2
2509
    if check_header arpa/inet.h ; then
2510
        check_func closesocket
2511
    elif check_header winsock2.h ; then
2512
        check_func_headers winsock2.h closesocket -lws2 && \
2513
            network_extralibs="-lws2" || \
2514
        { check_func_headers winsock2.h closesocket -lws2_32 && \
2515
            network_extralibs="-lws2_32"; }
2516
        check_type ws2tcpip.h socklen_t
2517
        check_type ws2tcpip.h "struct addrinfo"
2518
        check_type ws2tcpip.h "struct sockaddr_storage"
2519
    else
2520
        disable network
2521
    fi
2522
fi
2523

    
2524
enabled_all network ipv6 && check_ld <<EOF || disable ipv6
2525
#include <sys/types.h>
2526
#include <sys/socket.h>
2527
#include <netinet/in.h>
2528
#include <netdb.h>
2529
int main(void) {
2530
    struct sockaddr_storage saddr;
2531
    struct ipv6_mreq mreq6;
2532
    getaddrinfo(0,0,0,0);
2533
    getnameinfo(0,0,0,0,0,0,0);
2534
    IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
2535
}
2536
EOF
2537

    
2538
check_header linux/videodev.h
2539
check_header linux/videodev2.h
2540
check_header sys/videoio.h
2541

    
2542
check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
2543

    
2544
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
2545
{ check_header dev/bktr/ioctl_meteor.h &&
2546
  check_header dev/bktr/ioctl_bt848.h; } ||
2547
{ check_header machine/ioctl_meteor.h &&
2548
  check_header machine/ioctl_bt848.h; } ||
2549
{ check_header dev/video/meteor/ioctl_meteor.h &&
2550
  check_header dev/video/bktr/ioctl_bt848.h; } ||
2551
check_header dev/ic/bt8xx.h
2552

    
2553
check_header sys/soundcard.h
2554
check_header soundcard.h
2555

    
2556
enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
2557

    
2558
enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
2559

    
2560
enabled x11grab                         &&
2561
check_header X11/Xlib.h                 &&
2562
check_header X11/extensions/XShm.h      &&
2563
check_header X11/extensions/Xfixes.h    &&
2564
check_func XOpenDisplay -lX11           &&
2565
check_func XShmCreateImage -lX11 -lXext &&
2566
check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
2567

    
2568
if ! disabled vdpau && enabled vdpau_vdpau_h; then
2569
check_cpp_condition \
2570
    vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
2571
    { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
2572
      disable vdpau; }
2573
fi
2574

    
2575
enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
2576

    
2577
# add some useful compiler flags if supported
2578
check_cflags -Wdeclaration-after-statement
2579
check_cflags -Wall
2580
check_cflags -Wno-switch
2581
check_cflags -Wdisabled-optimization
2582
check_cflags -Wpointer-arith
2583
check_cflags -Wredundant-decls
2584
check_cflags -Wno-pointer-sign
2585
check_cflags -Wcast-qual
2586
check_cflags -Wwrite-strings
2587
check_cflags -Wtype-limits
2588
check_cflags -Wundef
2589
enabled extra_warnings && check_cflags -Winline
2590

    
2591
# add some linker flags
2592
check_ldflags -Wl,--warn-common
2593
check_ldflags -Wl,--as-needed
2594
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'
2595
check_ldflags -Wl,-Bsymbolic
2596

    
2597
echo "X{};" > $TMPV
2598
test_ldflags -Wl,--version-script,$TMPV &&
2599
    append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
2600

    
2601
if enabled small; then
2602
    check_cflags -Os            # not all compilers support -Os
2603
    optimizations="small"
2604
elif enabled optimizations; then
2605
    if enabled xlc; then
2606
        add_cflags  -O5
2607
        add_ldflags -O5
2608
    elif enabled suncc; then
2609
        add_cflags -O5
2610
    elif enabled ccc; then
2611
        add_cflags -fast
2612
    else
2613
        add_cflags -O3
2614
    fi
2615
fi
2616
check_cflags -fno-math-errno
2617
check_cflags -fno-signed-zeros
2618

    
2619
if enabled icc; then
2620
    # Just warnings, no remarks
2621
    check_cflags -w1
2622
    # -wd: Disable following warnings
2623
    # 144, 167, 556: -Wno-pointer-sign
2624
    # 10006: ignoring unknown option -fno-signed-zeros
2625
    # 10156: ignoring option '-W'; no argument required
2626
    check_cflags -wd144,167,556,10006,10156
2627
    # 11030: Warning unknown option --as-needed
2628
    # 10156: ignoring option '-export'; no argument required
2629
    check_ldflags -wd10156,11030
2630
    # Allow to compile with optimizations
2631
    check_ldflags -march=$cpu
2632
    # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
2633
    enable ebp_available
2634
elif enabled ccc; then
2635
    # disable some annoying warnings
2636
    add_cflags -msg_disable cvtu32to64
2637
    add_cflags -msg_disable embedcomment
2638
    add_cflags -msg_disable needconstext
2639
    add_cflags -msg_disable nomainieee
2640
    add_cflags -msg_disable ptrmismatch1
2641
    add_cflags -msg_disable unreachcode
2642
elif enabled gcc; then
2643
    check_cflags -fno-tree-vectorize
2644
elif enabled clang; then
2645
    check_cflags -Qunused-arguments
2646
fi
2647

    
2648
if enabled gprof; then
2649
    add_cflags  -p
2650
    add_ldflags -p
2651
fi
2652

    
2653
# Find out if the .align argument is a power of two or not.
2654
check_asm asmalign_pot '".align 3"'
2655

    
2656
enabled_any $DECODER_LIST      && enable decoders
2657
enabled_any $ENCODER_LIST      && enable encoders
2658
enabled_any $HWACCEL_LIST      && enable hwaccels
2659
enabled_any $BSF_LIST          && enable bsfs
2660
enabled_any $DEMUXER_LIST      && enable demuxers
2661
enabled_any $MUXER_LIST        && enable muxers
2662
enabled_any $FILTER_LIST       && enable filters
2663
enabled_any $INDEV_LIST        && enable indevs
2664
enabled_any $OUTDEV_LIST       && enable outdevs
2665
enabled_any $PROTOCOL_LIST     && enable protocols
2666

    
2667
enabled_any $THREADS_LIST      && enable threads
2668

    
2669
check_deps $CONFIG_LIST       \
2670
           $CONFIG_EXTRA      \
2671
           $HAVE_LIST         \
2672
           $DECODER_LIST      \
2673
           $ENCODER_LIST      \
2674
           $HWACCEL_LIST      \
2675
           $PARSER_LIST       \
2676
           $BSF_LIST          \
2677
           $DEMUXER_LIST      \
2678
           $MUXER_LIST        \
2679
           $FILTER_LIST       \
2680
           $INDEV_LIST        \
2681
           $OUTDEV_LIST       \
2682
           $PROTOCOL_LIST     \
2683

    
2684
enabled asm || disable $ARCH_LIST $ARCH_EXT_LIST
2685

    
2686
echo "install prefix            $prefix"
2687
echo "source path               $source_path"
2688
echo "C compiler                $cc"
2689
echo ".align is power-of-two    $asmalign_pot"
2690
echo "ARCH                      $arch ($cpu)"
2691
if test "$build_suffix" != ""; then
2692
    echo "build suffix              $build_suffix"
2693
fi
2694
if test "$extra_version" != ""; then
2695
    echo "version string suffix     $extra_version"
2696
fi
2697
echo "big-endian                ${bigendian-no}"
2698
echo "runtime cpu detection     ${runtime_cpudetect-no}"
2699
if enabled x86; then
2700
    echo "yasm                      ${yasm-no}"
2701
    echo "MMX enabled               ${mmx-no}"
2702
    echo "MMX2 enabled              ${mmx2-no}"
2703
    echo "3DNow! enabled            ${amd3dnow-no}"
2704
    echo "3DNow! extended enabled   ${amd3dnowext-no}"
2705
    echo "SSE enabled               ${sse-no}"
2706
    echo "SSSE3 enabled             ${ssse3-no}"
2707
    echo "CMOV enabled              ${cmov-no}"
2708
    echo "CMOV is fast              ${fast_cmov-no}"
2709
    echo "EBX available             ${ebx_available-no}"
2710
    echo "EBP available             ${ebp_available-no}"
2711
    echo "10 operands supported     ${ten_operands-no}"
2712
fi
2713
if enabled arm; then
2714
    echo "ARMv5TE enabled           ${armv5te-no}"
2715
    echo "ARMv6 enabled             ${armv6-no}"
2716
    echo "ARMv6T2 enabled           ${armv6t2-no}"
2717
    echo "ARM VFP enabled           ${armvfp-no}"
2718
    echo "IWMMXT enabled            ${iwmmxt-no}"
2719
    echo "NEON enabled              ${neon-no}"
2720
fi
2721
if enabled mips; then
2722
    echo "MMI enabled               ${mmi-no}"
2723
fi
2724
if enabled ppc; then
2725
    echo "AltiVec enabled           ${altivec-no}"
2726
    echo "PPC 4xx optimizations     ${ppc4xx-no}"
2727
    echo "dcbzl available           ${dcbzl-no}"
2728
    echo "performance report        ${powerpc_perf-no}"
2729
fi
2730
if enabled sparc; then
2731
    echo "VIS enabled               ${vis-no}"
2732
fi
2733
echo "gprof enabled             ${gprof-no}"
2734
echo "debug symbols             ${debug-no}"
2735
echo "strip symbols             ${stripping-no}"
2736
echo "optimizations             ${optimizations-no}"
2737
echo "static                    ${static-no}"
2738
echo "shared                    ${shared-no}"
2739
echo "postprocessing support    ${postproc-no}"
2740
echo "new filter support        ${avfilter-no}"
2741
echo "filters using lavformat   ${avfilter_lavf-no}"
2742
echo "network support           ${network-no}"
2743
if enabled network; then
2744
    echo "IPv6 support              ${ipv6-no}"
2745
fi
2746
echo "threading support         ${thread_type-no}"
2747
echo "SDL support               ${sdl-no}"
2748
echo "Sun medialib support      ${mlib-no}"
2749
echo "AVISynth enabled          ${avisynth-no}"
2750
echo "libdc1394 support         ${libdc1394-no}"
2751
echo "libdirac enabled          ${libdirac-no}"
2752
echo "libfaac enabled           ${libfaac-no}"
2753
echo "libfaad enabled           ${libfaad-no}"
2754
echo "libfaad dlopened          ${libfaadbin-no}"
2755
echo "libgsm enabled            ${libgsm-no}"
2756
echo "libmp3lame enabled        ${libmp3lame-no}"
2757
echo "libnut enabled            ${libnut-no}"
2758
echo "libopencore-amrnb support ${libopencore_amrnb-no}"
2759
echo "libopencore-amrwb support ${libopencore_amrwb-no}"
2760
echo "libopenjpeg enabled       ${libopenjpeg-no}"
2761
echo "libschroedinger enabled   ${libschroedinger-no}"
2762
echo "libspeex enabled          ${libspeex-no}"
2763
echo "libtheora enabled         ${libtheora-no}"
2764
echo "libvorbis enabled         ${libvorbis-no}"
2765
echo "libx264 enabled           ${libx264-no}"
2766
echo "libxvid enabled           ${libxvid-no}"
2767
echo "zlib enabled              ${zlib-no}"
2768
echo "bzlib enabled             ${bzlib-no}"
2769
echo
2770

    
2771
for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
2772
    echo "Enabled ${type}s:"
2773
    eval list=\$$(toupper $type)_LIST
2774
    for part in $list; do
2775
        enabled $part && echo ${part%_*}
2776
    done | sort | pr -3 -t
2777
    echo
2778
done
2779

    
2780
license="LGPL version 2.1 or later"
2781
if enabled nonfree; then
2782
    license="nonfree and unredistributable"
2783
elif enabled gplv3; then
2784
    license="GPL version 3 or later"
2785
elif enabled lgplv3; then
2786
    license="LGPL version 3 or later"
2787
elif enabled gpl; then
2788
    license="GPL version 2 or later"
2789
fi
2790

    
2791
echo "License: $license"
2792

    
2793
echo "Creating config.mak and config.h..."
2794

    
2795
# build tree in object directory if source path is different from current one
2796
if enabled source_path_used; then
2797
    DIRS="
2798
        doc
2799
        libavcodec
2800
        libavcodec/$arch
2801
        libavdevice
2802
        libavfilter
2803
        libavformat
2804
        libavutil
2805
        libavutil/$arch
2806
        libpostproc
2807
        libswscale
2808
        libswscale/$arch
2809
        tests
2810
        tools
2811
    "
2812
    FILES="
2813
        Makefile
2814
        common.mak
2815
        subdir.mak
2816
        doc/texi2pod.pl
2817
        libavcodec/Makefile
2818
        libavdevice/Makefile
2819
        libavfilter/Makefile
2820
        libavformat/Makefile
2821
        libavutil/Makefile
2822
        libpostproc/Makefile
2823
        libswscale/Makefile
2824
    "
2825
    for dir in $DIRS ; do
2826
        mkdir -p $dir
2827
    done
2828
    for f in $FILES ; do
2829
        $ln_s "$source_path/$f" $f
2830
    done
2831
fi
2832

    
2833
enabled stripping || strip="echo skipping strip"
2834

    
2835
cat > config.mak <<EOF
2836
# Automatically generated by configure - do not modify!
2837
ifndef FFMPEG_CONFIG_MAK
2838
FFMPEG_CONFIG_MAK=1
2839
FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
2840
prefix=$prefix
2841
LIBDIR=\$(DESTDIR)$libdir
2842
SHLIBDIR=\$(DESTDIR)$shlibdir
2843
INCDIR=\$(DESTDIR)$incdir
2844
BINDIR=\$(DESTDIR)$bindir
2845
DATADIR=\$(DESTDIR)$datadir
2846
MANDIR=\$(DESTDIR)$mandir
2847
SRC_PATH="$source_path"
2848
SRC_PATH_BARE=$source_path
2849
BUILD_ROOT="$PWD"
2850
ARCH=$arch
2851
CC=$cc
2852
AS=$as
2853
LD=$ld
2854
DEPCC=$dep_cc
2855
YASM=$yasmexe
2856
AR=$ar
2857
RANLIB=$ranlib
2858
LN_S=$ln_s
2859
STRIP=$strip
2860
CPPFLAGS=$CPPFLAGS
2861
CFLAGS=$CFLAGS
2862
ASFLAGS=$ASFLAGS
2863
CC_O=$CC_O
2864
LDFLAGS=$LDFLAGS
2865
FFSERVERLDFLAGS=$FFSERVERLDFLAGS
2866
SHFLAGS=$SHFLAGS
2867
YASMFLAGS=$YASMFLAGS
2868
BUILDSUF=$build_suffix
2869
FULLNAME=$FULLNAME
2870
LIBPREF=$LIBPREF
2871
LIBSUF=$LIBSUF
2872
LIBNAME=$LIBNAME
2873
SLIBPREF=$SLIBPREF
2874
SLIBSUF=$SLIBSUF
2875
EXESUF=$EXESUF
2876
EXTRA_VERSION=$extra_version
2877
DEPFLAGS=$DEPFLAGS
2878
CCDEP=$CCDEP
2879
ASDEP=$ASDEP
2880
CC_DEPFLAGS=$CC_DEPFLAGS
2881
AS_DEPFLAGS=$AS_DEPFLAGS
2882
HOSTCC=$host_cc
2883
HOSTCFLAGS=$host_cflags
2884
HOSTEXESUF=$HOSTEXESUF
2885
HOSTLDFLAGS=$host_ldflags
2886
HOSTLIBS=$host_libs
2887
TARGET_EXEC=$target_exec
2888
TARGET_PATH=$target_path
2889
SDL_LIBS=$sdl_libs
2890
SDL_CFLAGS=$sdl_cflags
2891
LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
2892
EXTRALIBS=$extralibs
2893
EOF
2894

    
2895
get_version(){
2896
    name=$1
2897
    file=$source_path/$2
2898
    eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
2899
    eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
2900
    lcname=$(tolower $name)
2901
    eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
2902
    eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
2903
}
2904

    
2905
get_version LIBSWSCALE  libswscale/swscale.h
2906
get_version LIBPOSTPROC libpostproc/postprocess.h
2907
get_version LIBAVCODEC  libavcodec/avcodec.h
2908
get_version LIBAVDEVICE libavdevice/avdevice.h
2909
get_version LIBAVFORMAT libavformat/avformat.h
2910
get_version LIBAVUTIL   libavutil/avutil.h
2911
get_version LIBAVFILTER libavfilter/avfilter.h
2912

    
2913
enabled shared && cat >> config.mak <<EOF
2914
LIBTARGET=${LIBTARGET}
2915
SLIBNAME=${SLIBNAME}
2916
SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
2917
SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
2918
SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
2919
SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
2920
SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}
2921
SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}
2922
EOF
2923

    
2924
enabled asmalign_pot || align_shift="1 <<"
2925

    
2926
cat > $TMPH <<EOF
2927
/* Automatically generated by configure - do not modify! */
2928
#ifndef FFMPEG_CONFIG_H
2929
#define FFMPEG_CONFIG_H
2930
#define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
2931
#define FFMPEG_LICENSE "$(c_escape $license)"
2932
#define FFMPEG_DATADIR "$(eval c_escape $datadir)"
2933
#define CC_TYPE "$cc_type"
2934
#define CC_VERSION $cc_version
2935
#define restrict $_restrict
2936
#define ASMALIGN(ZEROBITS) ".align $align_shift " #ZEROBITS "\\n\\t"
2937
#define EXTERN_PREFIX "${extern_prefix}"
2938
#define EXTERN_ASM ${extern_prefix}
2939
EOF
2940

    
2941
if enabled small || disabled optimizations; then
2942
    echo "#define av_always_inline"  >> $TMPH
2943
fi
2944

    
2945
print_config ARCH_   $TMPH config.mak $ARCH_LIST
2946
print_config HAVE_   $TMPH config.mak $HAVE_LIST
2947
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST       \
2948
                                      $CONFIG_EXTRA      \
2949
                                      $DECODER_LIST      \
2950
                                      $ENCODER_LIST      \
2951
                                      $HWACCEL_LIST      \
2952
                                      $PARSER_LIST       \
2953
                                      $BSF_LIST          \
2954
                                      $DEMUXER_LIST      \
2955
                                      $MUXER_LIST        \
2956
                                      $FILTER_LIST       \
2957
                                      $PROTOCOL_LIST     \
2958
                                      $INDEV_LIST        \
2959
                                      $OUTDEV_LIST       \
2960

    
2961
echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
2962
echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
2963

    
2964
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
2965
cp_if_changed $TMPH config.h
2966

    
2967
cat > $TMPH <<EOF
2968
/* Generated by ffconf */
2969
#ifndef AVUTIL_AVCONFIG_H
2970
#define AVUTIL_AVCONFIG_H
2971
EOF
2972

    
2973
print_config AV_HAVE_ $TMPH /dev/null $HAVE_LIST_PUB
2974

    
2975
echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
2976

    
2977
cp_if_changed $TMPH libavutil/avconfig.h
2978

    
2979
# build pkg-config files
2980

    
2981
pkgconfig_generate(){
2982
name=$1
2983
shortname=${name#lib}${build_suffix}
2984
comment=$2
2985
version=$3
2986
libs=$4
2987
requires=$5
2988
cat <<EOF > $name/$name.pc
2989
prefix=$prefix
2990
exec_prefix=\${prefix}
2991
libdir=$libdir
2992
includedir=$incdir
2993

    
2994
Name: $name
2995
Description: $comment
2996
Version: $version
2997
Requires: $(enabled shared || echo $requires)
2998
Requires.private: $(enabled shared && echo $requires)
2999
Conflicts:
3000
Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
3001
Libs.private: $(enabled shared && echo $libs)
3002
Cflags: -I\${includedir}
3003
EOF
3004
cat <<EOF > $name/$name-uninstalled.pc
3005
prefix=
3006
exec_prefix=
3007
libdir=\${pcfiledir}
3008
includedir=${source_path}
3009

    
3010
Name: $name
3011
Description: $comment
3012
Version: $version
3013
Requires: $requires
3014
Conflicts:
3015
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
3016
Cflags: -I\${includedir}
3017
EOF
3018
}
3019

    
3020
pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
3021
pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3022
pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
3023
pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3024
enabled avfilter &&
3025
    pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3026
enabled postproc &&
3027
    pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
3028
pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"