Statistics
| Branch: | Revision:

ffmpeg / configure @ 84400e9d

History | View | Annotate | Download (87.1 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.log]
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-ffprobe        disable ffprobe build
86
  --disable-ffserver       disable ffserver build
87
  --disable-avdevice       disable libavdevice build
88
  --disable-avcodec        disable libavcodec build
89
  --disable-avformat       disable libavformat build
90
  --disable-swscale        disable libswscale build
91
  --enable-postproc        enable GPLed postprocessing support [no]
92
  --disable-avfilter       disable video filter support [no]
93
  --enable-avfilter-lavf   video filters dependent on avformat [no]
94
  --disable-pthreads       disable pthreads [auto]
95
  --enable-w32threads      use Win32 threads [no]
96
  --enable-x11grab         enable X11 grabbing [no]
97
  --disable-network        disable network support [no]
98
  --disable-mpegaudio-hp   faster (but less accurate) MPEG audio decoding [no]
99
  --enable-gray            enable full grayscale support (slower color)
100
  --disable-swscale-alpha  disable alpha channel support in swscale
101
  --disable-fastdiv        disable table-based division
102
  --enable-small           optimize for size instead of speed
103
  --disable-aandct         disable AAN DCT code
104
  --disable-dct            disable DCT code
105
  --disable-fft            disable FFT code
106
  --disable-golomb         disable Golomb code
107
  --disable-lpc            disable LPC code
108
  --disable-mdct           disable MDCT code
109
  --disable-rdft           disable RDFT code
110
  --disable-vaapi          disable VAAPI code
111
  --disable-vdpau          disable VDPAU code
112
  --disable-dxva2          disable DXVA2 code
113
  --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
114
  --enable-hardcoded-tables use hardcoded tables instead of runtime generation
115
  --enable-memalign-hack   emulate memalign, interferes with memory debuggers
116
  --disable-everything     disable all components listed below
117
  --disable-encoder=NAME   disable encoder NAME
118
  --enable-encoder=NAME    enable encoder NAME
119
  --disable-encoders       disable all encoders
120
  --disable-decoder=NAME   disable decoder NAME
121
  --enable-decoder=NAME    enable decoder NAME
122
  --disable-decoders       disable all decoders
123
  --disable-hwaccel=NAME   disable hwaccel NAME
124
  --enable-hwaccel=NAME    enable hwaccel NAME
125
  --disable-hwaccels       disable all hwaccels
126
  --disable-muxer=NAME     disable muxer NAME
127
  --enable-muxer=NAME      enable muxer NAME
128
  --disable-muxers         disable all muxers
129
  --disable-demuxer=NAME   disable demuxer NAME
130
  --enable-demuxer=NAME    enable demuxer NAME
131
  --disable-demuxers       disable all demuxers
132
  --enable-parser=NAME     enable parser NAME
133
  --disable-parser=NAME    disable parser NAME
134
  --disable-parsers        disable all parsers
135
  --enable-bsf=NAME        enable bitstream filter NAME
136
  --disable-bsf=NAME       disable bitstream filter NAME
137
  --disable-bsfs           disable all bitstream filters
138
  --enable-protocol=NAME   enable protocol NAME
139
  --disable-protocol=NAME  disable protocol NAME
140
  --disable-protocols      disable all protocols
141
  --disable-indev=NAME     disable input device NAME
142
  --disable-outdev=NAME    disable output device NAME
143
  --disable-indevs         disable input devices
144
  --disable-outdevs        disable output devices
145
  --disable-devices        disable all devices
146
  --enable-filter=NAME     enable filter NAME
147
  --disable-filter=NAME    disable filter NAME
148
  --disable-filters        disable all filters
149
  --list-decoders          show all available decoders
150
  --list-encoders          show all available encoders
151
  --list-hwaccels          show all available hardware accelerators
152
  --list-muxers            show all available muxers
153
  --list-demuxers          show all available demuxers
154
  --list-parsers           show all available parsers
155
  --list-protocols         show all available protocols
156
  --list-bsfs              show all available bitstream filters
157
  --list-indevs            show all available input devices
158
  --list-outdevs           show all available output devices
159
  --list-filters           show all available filters
160

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

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

    
237
Developer options (useful when working on FFmpeg itself):
238
  --disable-debug          disable debugging symbols
239
  --enable-debug=LEVEL     set the debug level [$debuglevel]
240
  --enable-gprof           enable profiling with gprof [$gprof]
241
  --disable-optimizations  disable compiler optimizations
242
  --enable-extra-warnings  enable more compiler warnings
243
  --disable-stripping      disable stripping of executables and shared libraries
244
  --samples=PATH           location of test samples for FATE
245

    
246
NOTE: Object files are built at the place where configure is launched.
247
EOF
248
  exit 0
249
}
250

    
251
quotes='""'
252

    
253
log(){
254
    echo "$@" >> $logfile
255
}
256

    
257
log_file(){
258
    log BEGIN $1
259
    pr -n -t $1 >> $logfile
260
    log END $1
261
}
262

    
263
echolog(){
264
    log "$@"
265
    echo "$@"
266
}
267

    
268
warn(){
269
    log "WARNING: $*"
270
    WARNINGS="${WARNINGS}WARNING: $*\n"
271
}
272

    
273
die(){
274
    echolog "$@"
275
    cat <<EOF
276

    
277
If you think configure made a mistake, make sure you are using the latest
278
version from SVN.  If the latest version fails, report the problem to the
279
ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
280
EOF
281
    if disabled logging; then
282
        cat <<EOF
283
Rerun configure with logging enabled (do not use --disable-logging), and
284
include the log this produces with your report.
285
EOF
286
    else
287
cat <<EOF
288
Include the log file "$logfile" produced by configure as this will help
289
solving the problem.
290
EOF
291
    fi
292
    exit 1
293
}
294

    
295
# Avoid locale weirdness, besides we really just want to translate ASCII.
296
toupper(){
297
    echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
298
}
299

    
300
tolower(){
301
    echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
302
}
303

    
304
c_escape(){
305
    echo "$*" | sed 's/["\\]/\\\0/g'
306
}
307

    
308
sh_quote(){
309
    v=$(echo "$1" | sed "s/'/'\\\\''/g")
310
    test "$v" = "${v#*[ |&;<>()$\`\\\"\'*?\[\]#~=%]}" || v="'$v'"
311
    echo "$v"
312
}
313

    
314
filter(){
315
    pat=$1
316
    shift
317
    for v; do
318
        eval "case $v in $pat) echo $v ;; esac"
319
    done
320
}
321

    
322
map(){
323
    m=$1
324
    shift
325
    for v; do eval $m; done
326
}
327

    
328
set_all(){
329
    value=$1
330
    shift
331
    for var in $*; do
332
        eval $var=$value
333
    done
334
}
335

    
336
set_weak(){
337
    value=$1
338
    shift
339
    for var; do
340
        eval : \${$var:=$value}
341
    done
342
}
343

    
344
pushvar(){
345
    for var in $*; do
346
        eval level=\${${var}_level:=0}
347
        eval ${var}_${level}="\$$var"
348
        eval ${var}_level=$(($level+1))
349
    done
350
}
351

    
352
popvar(){
353
    for var in $*; do
354
        eval level=\${${var}_level:-0}
355
        test $level = 0 && continue
356
        eval level=$(($level-1))
357
        eval $var="\${${var}_${level}}"
358
        eval ${var}_level=$level
359
        eval unset ${var}_${level}
360
    done
361
}
362

    
363
enable(){
364
    set_all yes $*
365
}
366

    
367
disable(){
368
    set_all no $*
369
}
370

    
371
enable_weak(){
372
    set_weak yes $*
373
}
374

    
375
disable_weak(){
376
    set_weak no $*
377
}
378

    
379
enable_safe(){
380
    for var; do
381
        enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
382
    done
383
}
384

    
385
disable_safe(){
386
    for var; do
387
        disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
388
    done
389
}
390

    
391
do_enable_deep(){
392
    for var; do
393
        enabled $var && continue
394
        eval sel="\$${var}_select"
395
        eval sgs="\$${var}_suggest"
396
        pushvar var sgs
397
        enable_deep $sel
398
        popvar sgs
399
        enable_deep_weak $sgs
400
        popvar var
401
    done
402
}
403

    
404
enable_deep(){
405
    do_enable_deep $*
406
    enable $*
407
}
408

    
409
enable_deep_weak(){
410
    do_enable_deep $*
411
    enable_weak $*
412
}
413

    
414
enabled(){
415
    test "${1#!}" = "$1" && op== || op=!=
416
    eval test "x\$${1#!}" $op "xyes"
417
}
418

    
419
disabled(){
420
    test "${1#!}" = "$1" && op== || op=!=
421
    eval test "x\$${1#!}" $op "xno"
422
}
423

    
424
enabled_all(){
425
    for opt; do
426
        enabled $opt || return 1
427
    done
428
}
429

    
430
disabled_all(){
431
    for opt; do
432
        disabled $opt || return 1
433
    done
434
}
435

    
436
enabled_any(){
437
    for opt; do
438
        enabled $opt && return 0
439
    done
440
}
441

    
442
disabled_any(){
443
    for opt; do
444
        disabled $opt && return 0
445
    done
446
    return 1
447
}
448

    
449
set_default(){
450
    for opt; do
451
        eval : \${$opt:=\$${opt}_default}
452
    done
453
}
454

    
455
is_in(){
456
    value=$1
457
    shift
458
    for var in $*; do
459
        [ $var = $value ] && return 0
460
    done
461
    return 1
462
}
463

    
464
check_deps(){
465
    for cfg; do
466
        cfg="${cfg#!}"
467
        enabled ${cfg}_checking && die "Circular dependency for $cfg."
468
        disabled ${cfg}_checking && continue
469
        enable ${cfg}_checking
470

    
471
        eval dep_all="\$${cfg}_deps"
472
        eval dep_any="\$${cfg}_deps_any"
473
        eval dep_sel="\$${cfg}_select"
474
        eval dep_sgs="\$${cfg}_suggest"
475
        eval dep_ifa="\$${cfg}_if"
476
        eval dep_ifn="\$${cfg}_if_any"
477

    
478
        pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
479
        check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
480
        popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
481

    
482
        [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
483
        [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
484
        enabled_all  $dep_all || disable $cfg
485
        enabled_any  $dep_any || disable $cfg
486
        disabled_any $dep_sel && disable $cfg
487

    
488
        if enabled $cfg; then
489
            eval dep_extralibs="\$${cfg}_extralibs"
490
            test -n "$dep_extralibs" && add_extralibs $dep_extralibs
491
            enable_deep $dep_sel
492
            enable_deep_weak $dep_sgs
493
        fi
494

    
495
        disable ${cfg}_checking
496
    done
497
}
498

    
499
print_config(){
500
    pfx=$1
501
    header=$2
502
    makefile=$3
503
    shift 3
504
    for cfg; do
505
        ucname="$(toupper $cfg)"
506
        if enabled $cfg; then
507
            echo "#define ${pfx}${ucname} 1" >> $header
508
            echo "${pfx}${ucname}=yes" >> $makefile
509
        else
510
            echo "#define ${pfx}${ucname} 0" >> $header
511
            echo "!${pfx}${ucname}=yes" >> $makefile
512
        fi
513
    done
514
}
515

    
516
flags_saved(){
517
    (: ${SAVE_CFLAGS?}) 2> /dev/null
518
}
519

    
520
save_flags(){
521
    flags_saved && return
522
    SAVE_CFLAGS="$CFLAGS"
523
    SAVE_LDFLAGS="$LDFLAGS"
524
    SAVE_extralibs="$extralibs"
525
}
526

    
527
restore_flags(){
528
    flags_saved || return
529
    CFLAGS="$SAVE_CFLAGS"
530
    LDFLAGS="$SAVE_LDFLAGS"
531
    extralibs="$SAVE_extralibs"
532
    unset SAVE_CFLAGS
533
    unset SAVE_LDFLAGS
534
    unset SAVE_extralibs
535
}
536

    
537
temp_cflags(){
538
    save_flags
539
    CFLAGS="$CFLAGS $*"
540
}
541

    
542
temp_ldflags(){
543
    save_flags
544
    LDFLAGS="$LDFLAGS $*"
545
}
546

    
547
temp_extralibs(){
548
    save_flags
549
    extralibs="$extralibs $*"
550
}
551

    
552
append(){
553
    var=$1
554
    shift
555
    flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
556
    eval "$var=\"\$$var $*\""
557
}
558

    
559
add_cppflags(){
560
    append CPPFLAGS $($filter_cppflags "$@")
561
}
562

    
563
add_cflags(){
564
    append CFLAGS $($filter_cflags "$@")
565
}
566

    
567
add_asflags(){
568
    append ASFLAGS $($filter_asflags "$@")
569
}
570

    
571
add_ldflags(){
572
    append LDFLAGS "$@"
573
}
574

    
575
add_extralibs(){
576
    append extralibs "$@"
577
}
578

    
579
check_cmd(){
580
    log "$@"
581
    "$@" >> $logfile 2>&1
582
}
583

    
584
check_cc(){
585
    log check_cc "$@"
586
    cat > $TMPC
587
    log_file $TMPC
588
    check_cmd $cc $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
589
}
590

    
591
check_cpp(){
592
    log check_cpp "$@"
593
    cat > $TMPC
594
    log_file $TMPC
595
    check_cmd $cc $CPPFLAGS $CFLAGS "$@" -E -o $TMPO $TMPC
596
}
597

    
598
check_as(){
599
    log check_as "$@"
600
    cat > $TMPC
601
    log_file $TMPC
602
    check_cmd $as $CPPFLAGS $ASFLAGS "$@" -c -o $TMPO $TMPC
603
}
604

    
605
check_asm(){
606
    log check_asm "$@"
607
    name="$1"
608
    code="$2"
609
    shift 2
610
    disable $name
611
    check_as "$@" <<EOF && enable $name
612
void foo(void){ __asm__ volatile($code); }
613
EOF
614
}
615

    
616
check_yasm(){
617
    log check_yasm "$@"
618
    echo "$1" > $TMPS
619
    log_file $TMPS
620
    shift 1
621
    check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
622
}
623

    
624
check_ld(){
625
    log check_ld "$@"
626
    flags=''
627
    libs=''
628
    for f; do
629
        test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
630
    done
631
    check_cc $($filter_cflags $flags) || return
632
    check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
633
}
634

    
635
check_cppflags(){
636
    log check_cppflags "$@"
637
    set -- $($filter_cppflags "$@")
638
    check_cc "$@" <<EOF && append CPPFLAGS "$@"
639
int x;
640
EOF
641
}
642

    
643
check_cflags(){
644
    log check_cflags "$@"
645
    set -- $($filter_cflags "$@")
646
    check_cc "$@" <<EOF && append CFLAGS "$@"
647
int x;
648
EOF
649
}
650

    
651
test_ldflags(){
652
    log test_ldflags "$@"
653
    check_ld "$@" <<EOF
654
int main(void){ return 0; }
655
EOF
656
}
657

    
658
check_ldflags(){
659
    log check_ldflags "$@"
660
    test_ldflags "$@" && add_ldflags "$@"
661
}
662

    
663
check_header(){
664
    log check_header "$@"
665
    header=$1
666
    shift
667
    disable_safe $header
668
    check_cpp "$@" <<EOF && enable_safe $header
669
#include <$header>
670
int x;
671
EOF
672
}
673

    
674
check_func(){
675
    log check_func "$@"
676
    func=$1
677
    shift
678
    disable $func
679
    check_ld "$@" <<EOF && enable $func
680
extern int $func();
681
int main(void){ $func(); }
682
EOF
683
}
684

    
685
check_mathfunc(){
686
    log check_mathfunc "$@"
687
    func=$1
688
    shift
689
    disable $func
690
    check_ld "$@" <<EOF && enable $func
691
#include <math.h>
692
float foo(float f) { return $func(f); }
693
int main(void){ return 0; }
694
EOF
695
}
696

    
697
check_func_headers(){
698
    log check_func_headers "$@"
699
    headers=$1
700
    func=$2
701
    shift 2
702
    disable $func
703
    incs=""
704
    for hdr in $headers; do
705
        incs="$incs
706
#include <$hdr>"
707
    done
708
    check_ld "$@" <<EOF && enable $func && enable_safe $headers
709
$incs
710
int main(int argc, char **argv){
711
    return (long) $func;
712
}
713
EOF
714
}
715

    
716
check_cpp_condition(){
717
    log check_cpp_condition "$@"
718
    header=$1
719
    condition=$2
720
    shift 2
721
    check_cpp $($filter_cppflags "$@") <<EOF
722
#include <$header>
723
#if !($condition)
724
#error "unsatisfied condition: $condition"
725
#endif
726
EOF
727
}
728

    
729
check_lib(){
730
    log check_lib "$@"
731
    header="$1"
732
    func="$2"
733
    shift 2
734
    check_header $header && check_func $func "$@" && add_extralibs "$@"
735
}
736

    
737
check_lib2(){
738
    log check_lib2 "$@"
739
    headers="$1"
740
    func="$2"
741
    shift 2
742
    check_func_headers "$headers" $func "$@" && add_extralibs "$@"
743
}
744

    
745
check_exec(){
746
    check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
747
}
748

    
749
check_exec_crash(){
750
    code=$(cat)
751

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

    
758
    (check_exec "$@") >> $logfile 2>&1 <<EOF
759
#include <signal.h>
760
static void sighandler(int sig){
761
    raise(SIGTERM);
762
}
763
int main(void){
764
    signal(SIGILL, sighandler);
765
    signal(SIGFPE, sighandler);
766
    signal(SIGSEGV, sighandler);
767
#ifdef SIGBUS
768
    signal(SIGBUS, sighandler);
769
#endif
770
    { $code }
771
}
772
EOF
773
}
774

    
775
check_type(){
776
    log check_type "$@"
777
    headers=$1
778
    type=$2
779
    shift 2
780
    disable_safe "$type"
781
    incs=""
782
    for hdr in $headers; do
783
        incs="$incs
784
#include <$hdr>"
785
    done
786
    check_cc "$@" <<EOF && enable_safe "$type"
787
$incs
788
$type v;
789
EOF
790
}
791

    
792
check_struct(){
793
    log check_type "$@"
794
    headers=$1
795
    struct=$2
796
    member=$3
797
    shift 3
798
    disable_safe "${struct}_${member}"
799
    incs=""
800
    for hdr in $headers; do
801
        incs="$incs
802
#include <$hdr>"
803
    done
804
    check_cc "$@" <<EOF && enable_safe "${struct}_${member}"
805
$incs
806
const void *p = &(($struct *)0)->$member;
807
EOF
808
}
809

    
810
require(){
811
    name="$1"
812
    header="$2"
813
    func="$3"
814
    shift 3
815
    check_lib $header $func "$@" || die "ERROR: $name not found"
816
}
817

    
818
require2(){
819
    name="$1"
820
    headers="$2"
821
    func="$3"
822
    shift 3
823
    check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
824
}
825

    
826
check_host_cc(){
827
    log check_host_cc "$@"
828
    cat > $TMPC
829
    log_file $TMPC
830
    check_cmd $host_cc $host_cflags "$@" -c -o $TMPO $TMPC
831
}
832

    
833
check_host_cflags(){
834
    log check_host_cflags "$@"
835
    check_host_cc "$@" <<EOF && append host_cflags "$@"
836
int x;
837
EOF
838
}
839

    
840
apply(){
841
    file=$1
842
    shift
843
    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
844
}
845

    
846
cp_if_changed(){
847
    cmp -s "$1" "$2" &&
848
        echo "$2 is unchanged" ||
849
        cp -f "$1" "$2"
850
}
851

    
852
# CONFIG_LIST contains configurable options, while HAVE_LIST is for
853
# system-dependent things.
854

    
855
COMPONENT_LIST="
856
    bsfs
857
    decoders
858
    demuxers
859
    encoders
860
    filters
861
    hwaccels
862
    indevs
863
    muxers
864
    outdevs
865
    parsers
866
    protocols
867
"
868

    
869
CONFIG_LIST="
870
    $COMPONENT_LIST
871
    aandct
872
    avcodec
873
    avdevice
874
    avfilter
875
    avfilter_lavf
876
    avformat
877
    avisynth
878
    bzlib
879
    dct
880
    doc
881
    dwt
882
    dxva2
883
    fastdiv
884
    ffmpeg
885
    ffplay
886
    ffprobe
887
    ffserver
888
    fft
889
    golomb
890
    gpl
891
    gprof
892
    gray
893
    h264dsp
894
    hardcoded_tables
895
    libdc1394
896
    libdirac
897
    libfaac
898
    libgsm
899
    libmp3lame
900
    libnut
901
    libopencore_amrnb
902
    libopencore_amrwb
903
    libopenjpeg
904
    librtmp
905
    libschroedinger
906
    libspeex
907
    libtheora
908
    libvorbis
909
    libvpx
910
    libx264
911
    libxvid
912
    lpc
913
    lsp
914
    mdct
915
    memalign_hack
916
    mlib
917
    mpegaudio_hp
918
    network
919
    nonfree
920
    pic
921
    postproc
922
    powerpc_perf
923
    rdft
924
    runtime_cpudetect
925
    shared
926
    small
927
    sram
928
    static
929
    swscale
930
    swscale_alpha
931
    vaapi
932
    vdpau
933
    version3
934
    x11grab
935
    zlib
936
"
937

    
938
THREADS_LIST='
939
    pthreads
940
    w32threads
941
'
942

    
943
ARCH_LIST='
944
    alpha
945
    arm
946
    avr32
947
    avr32_ap
948
    avr32_uc
949
    bfin
950
    ia64
951
    m68k
952
    mips
953
    mips64
954
    parisc
955
    ppc
956
    ppc64
957
    s390
958
    sh4
959
    sparc
960
    sparc64
961
    tomi
962
    x86
963
    x86_32
964
    x86_64
965
'
966

    
967
ARCH_EXT_LIST='
968
    altivec
969
    amd3dnow
970
    amd3dnowext
971
    armv5te
972
    armv6
973
    armv6t2
974
    armvfp
975
    iwmmxt
976
    mmi
977
    mmx
978
    mmx2
979
    neon
980
    ppc4xx
981
    sse
982
    ssse3
983
    vis
984
'
985

    
986
HAVE_LIST_PUB='
987
    bigendian
988
'
989

    
990
HAVE_LIST="
991
    $ARCH_EXT_LIST
992
    $HAVE_LIST_PUB
993
    $THREADS_LIST
994
    alsa_asoundlib_h
995
    altivec_h
996
    arpa_inet_h
997
    attribute_may_alias
998
    attribute_packed
999
    bswap
1000
    closesocket
1001
    cmov
1002
    conio_h
1003
    dcbzl
1004
    dev_bktr_ioctl_bt848_h
1005
    dev_bktr_ioctl_meteor_h
1006
    dev_ic_bt8xx_h
1007
    dev_video_meteor_ioctl_meteor_h
1008
    dev_video_bktr_ioctl_bt848_h
1009
    dlfcn_h
1010
    dlopen
1011
    dos_paths
1012
    ebp_available
1013
    ebx_available
1014
    exp2
1015
    exp2f
1016
    fast_64bit
1017
    fast_clz
1018
    fast_cmov
1019
    fast_unaligned
1020
    fork
1021
    getaddrinfo
1022
    gethrtime
1023
    GetProcessMemoryInfo
1024
    GetProcessTimes
1025
    getrusage
1026
    struct_rusage_ru_maxrss
1027
    inet_aton
1028
    inline_asm
1029
    isatty
1030
    ldbrx
1031
    libdc1394_1
1032
    libdc1394_2
1033
    llrint
1034
    llrintf
1035
    local_aligned_16
1036
    local_aligned_8
1037
    log2
1038
    log2f
1039
    loongson
1040
    lrint
1041
    lrintf
1042
    lzo1x_999_compress
1043
    machine_ioctl_bt848_h
1044
    machine_ioctl_meteor_h
1045
    malloc_h
1046
    memalign
1047
    mkstemp
1048
    pld
1049
    posix_memalign
1050
    round
1051
    roundf
1052
    sdl
1053
    sdl_video_size
1054
    setmode
1055
    socklen_t
1056
    soundcard_h
1057
    poll_h
1058
    setrlimit
1059
    strerror_r
1060
    struct_addrinfo
1061
    struct_ipv6_mreq
1062
    struct_sockaddr_in6
1063
    struct_sockaddr_sa_len
1064
    struct_sockaddr_storage
1065
    symver
1066
    symver_gnu_asm
1067
    symver_asm_label
1068
    sys_mman_h
1069
    sys_resource_h
1070
    sys_select_h
1071
    sys_soundcard_h
1072
    sys_videoio_h
1073
    ten_operands
1074
    termios_h
1075
    threads
1076
    truncf
1077
    vfp_args
1078
    VirtualAlloc
1079
    winsock2_h
1080
    xform_asm
1081
    yasm
1082
"
1083

    
1084
# options emitted with CONFIG_ prefix but not available on command line
1085
CONFIG_EXTRA="
1086
    avutil
1087
    gplv3
1088
    lgplv3
1089
"
1090

    
1091
CMDLINE_SELECT="
1092
    $ARCH_EXT_LIST
1093
    $CONFIG_LIST
1094
    $THREADS_LIST
1095
    asm
1096
    cross_compile
1097
    debug
1098
    extra_warnings
1099
    logging
1100
    optimizations
1101
    stripping
1102
    yasm
1103
"
1104

    
1105
PATHS_LIST='
1106
    bindir
1107
    datadir
1108
    incdir
1109
    libdir
1110
    mandir
1111
    prefix
1112
    shlibdir
1113
'
1114

    
1115
CMDLINE_SET="
1116
    $PATHS_LIST
1117
    ar
1118
    arch
1119
    as
1120
    build_suffix
1121
    cc
1122
    cpu
1123
    cross_prefix
1124
    dep_cc
1125
    extra_version
1126
    host_cc
1127
    host_cflags
1128
    host_ldflags
1129
    host_libs
1130
    host_os
1131
    ld
1132
    logfile
1133
    malloc_prefix
1134
    nm
1135
    samples
1136
    source_path
1137
    strip
1138
    sysinclude
1139
    sysroot
1140
    target_exec
1141
    target_os
1142
    target_path
1143
"
1144

    
1145
CMDLINE_APPEND="
1146
    extra_cflags
1147
"
1148

    
1149
# code dependency declarations
1150

    
1151
# architecture extensions
1152

    
1153
armv5te_deps="arm"
1154
armv6_deps="arm"
1155
armv6t2_deps="arm"
1156
armvfp_deps="arm"
1157
iwmmxt_deps="arm"
1158
neon_deps="arm"
1159

    
1160
mmi_deps="mips"
1161

    
1162
altivec_deps="ppc"
1163
ppc4xx_deps="ppc"
1164

    
1165
vis_deps="sparc"
1166

    
1167
x86_64_suggest="cmov fast_cmov"
1168
amd3dnow_deps="mmx"
1169
amd3dnowext_deps="amd3dnow"
1170
mmx_deps="x86"
1171
mmx2_deps="mmx"
1172
sse_deps="mmx"
1173
ssse3_deps="sse"
1174

    
1175
fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1176
fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
1177
fast_unaligned_if_any="armv6 ppc x86"
1178

    
1179
need_memalign="altivec neon sse"
1180
inline_asm_deps="!tms470"
1181

    
1182
symver_if_any="symver_asm_label symver_gnu_asm"
1183

    
1184
# subsystems
1185
mdct_select="fft"
1186
rdft_select="fft"
1187

    
1188
# decoders / encoders / hardware accelerators
1189
aac_decoder_select="mdct rdft aac_parser"
1190
aac_encoder_select="mdct"
1191
ac3_decoder_select="mdct ac3_parser"
1192
alac_encoder_select="lpc"
1193
amrnb_decoder_select="lsp"
1194
atrac1_decoder_select="mdct"
1195
atrac3_decoder_select="mdct"
1196
binkaudio_dct_decoder_select="mdct rdft dct"
1197
binkaudio_rdft_decoder_select="mdct rdft"
1198
cavs_decoder_select="golomb"
1199
cook_decoder_select="mdct"
1200
cscd_decoder_suggest="zlib"
1201
dca_decoder_select="mdct"
1202
dnxhd_encoder_select="aandct"
1203
dxa_decoder_select="zlib"
1204
eac3_decoder_select="ac3_decoder"
1205
eamad_decoder_select="aandct"
1206
eatgq_decoder_select="aandct"
1207
eatqi_decoder_select="aandct"
1208
ffv1_decoder_select="golomb"
1209
flac_decoder_select="golomb"
1210
flac_encoder_select="golomb lpc"
1211
flashsv_decoder_select="zlib"
1212
flashsv_encoder_select="zlib"
1213
flv_decoder_select="h263_decoder"
1214
flv_encoder_select="h263_encoder"
1215
h261_encoder_select="aandct"
1216
h263_decoder_select="h263_parser"
1217
h263_encoder_select="aandct"
1218
h263_vaapi_hwaccel_select="vaapi h263_decoder"
1219
h263i_decoder_select="h263_decoder"
1220
h263p_encoder_select="h263_encoder"
1221
h264_decoder_select="golomb h264dsp"
1222
h264_dxva2_hwaccel_deps="dxva2api_h"
1223
h264_dxva2_hwaccel_select="dxva2 h264_decoder"
1224
h264_vaapi_hwaccel_select="vaapi"
1225
h264_vdpau_decoder_select="vdpau h264_decoder"
1226
imc_decoder_select="fft mdct"
1227
jpegls_decoder_select="golomb"
1228
jpegls_encoder_select="golomb"
1229
ljpeg_encoder_select="aandct"
1230
loco_decoder_select="golomb"
1231
mjpeg_encoder_select="aandct"
1232
mlp_decoder_select="mlp_parser"
1233
mpeg1video_encoder_select="aandct"
1234
mpeg2video_encoder_select="aandct"
1235
mpeg4_decoder_select="h263_decoder mpeg4video_parser"
1236
mpeg4_encoder_select="h263_encoder"
1237
mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
1238
mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
1239
mpeg2_dxva2_hwaccel_deps="dxva2api_h"
1240
mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder"
1241
mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
1242
mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
1243
mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
1244
mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
1245
mpeg_xvmc_decoder_select="mpegvideo_decoder"
1246
msmpeg4v1_decoder_select="h263_decoder"
1247
msmpeg4v1_encoder_select="h263_encoder"
1248
msmpeg4v2_decoder_select="h263_decoder"
1249
msmpeg4v2_encoder_select="h263_encoder"
1250
msmpeg4v3_decoder_select="h263_decoder"
1251
msmpeg4v3_encoder_select="h263_encoder"
1252
nellymoser_decoder_select="mdct"
1253
nellymoser_encoder_select="mdct"
1254
png_decoder_select="zlib"
1255
png_encoder_select="zlib"
1256
qcelp_decoder_select="lsp"
1257
qdm2_decoder_select="mdct rdft"
1258
ra_144_encoder_select="lpc"
1259
rv10_decoder_select="h263_decoder"
1260
rv10_encoder_select="h263_encoder"
1261
rv20_decoder_select="h263_decoder"
1262
rv20_encoder_select="h263_encoder"
1263
rv30_decoder_select="golomb h264dsp"
1264
rv40_decoder_select="golomb h264dsp"
1265
shorten_decoder_select="golomb"
1266
sipr_decoder_select="lsp"
1267
snow_decoder_select="dwt"
1268
snow_encoder_select="aandct dwt"
1269
sonic_decoder_select="golomb"
1270
sonic_encoder_select="golomb"
1271
sonic_ls_encoder_select="golomb"
1272
svq1_encoder_select="aandct"
1273
svq3_decoder_select="golomb h264dsp"
1274
svq3_decoder_suggest="zlib"
1275
theora_decoder_select="vp3_decoder"
1276
tiff_decoder_suggest="zlib"
1277
tiff_encoder_suggest="zlib"
1278
truehd_decoder_select="mlp_decoder"
1279
tscc_decoder_select="zlib"
1280
twinvq_decoder_select="mdct lsp"
1281
vc1_decoder_select="h263_decoder"
1282
vc1_dxva2_hwaccel_deps="dxva2api_h DXVA_PictureParameters_wDecodedPictureIndex"
1283
vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
1284
vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
1285
vc1_vdpau_decoder_select="vdpau vc1_decoder"
1286
vorbis_decoder_select="mdct"
1287
vorbis_encoder_select="mdct"
1288
vp6a_decoder_select="vp6_decoder"
1289
vp6f_decoder_select="vp6_decoder"
1290
wmapro_decoder_select="mdct"
1291
wmav1_decoder_select="mdct"
1292
wmav1_encoder_select="mdct"
1293
wmav2_decoder_select="mdct"
1294
wmav2_encoder_select="mdct"
1295
wmavoice_decoder_select="lsp rdft dct"
1296
wmv1_decoder_select="h263_decoder"
1297
wmv1_encoder_select="h263_encoder"
1298
wmv2_decoder_select="h263_decoder"
1299
wmv2_encoder_select="h263_encoder"
1300
wmv3_decoder_select="vc1_decoder"
1301
wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
1302
wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
1303
wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
1304
zlib_decoder_select="zlib"
1305
zlib_encoder_select="zlib"
1306
zmbv_decoder_select="zlib"
1307
zmbv_encoder_select="zlib"
1308

    
1309
vaapi_deps="va_va_h"
1310
vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1311

    
1312
# parsers
1313
h264_parser_select="golomb h264dsp"
1314

    
1315
# bitstream_filters
1316
aac_adtstoasc_bsf_select="aac_parser"
1317

    
1318
# external libraries
1319
libdirac_decoder_deps="libdirac !libschroedinger"
1320
libdirac_encoder_deps="libdirac"
1321
libfaac_encoder_deps="libfaac"
1322
libgsm_decoder_deps="libgsm"
1323
libgsm_encoder_deps="libgsm"
1324
libgsm_ms_decoder_deps="libgsm"
1325
libgsm_ms_encoder_deps="libgsm"
1326
libmp3lame_encoder_deps="libmp3lame"
1327
libopencore_amrnb_decoder_deps="libopencore_amrnb"
1328
libopencore_amrnb_encoder_deps="libopencore_amrnb"
1329
libopencore_amrwb_decoder_deps="libopencore_amrwb"
1330
libopenjpeg_decoder_deps="libopenjpeg"
1331
libschroedinger_decoder_deps="libschroedinger"
1332
libschroedinger_encoder_deps="libschroedinger"
1333
libspeex_decoder_deps="libspeex"
1334
libtheora_encoder_deps="libtheora"
1335
libvorbis_encoder_deps="libvorbis"
1336
libvpx_decoder_deps="libvpx"
1337
libvpx_encoder_deps="libvpx"
1338
libx264_encoder_deps="libx264"
1339
libxvid_encoder_deps="libxvid"
1340

    
1341
# demuxers / muxers
1342
ac3_demuxer_deps="ac3_parser"
1343
asf_stream_muxer_select="asf_muxer"
1344
avisynth_demuxer_deps="avisynth"
1345
dirac_demuxer_deps="dirac_parser"
1346
eac3_demuxer_select="ac3_parser"
1347
ipod_muxer_select="mov_muxer"
1348
libnut_demuxer_deps="libnut"
1349
libnut_muxer_deps="libnut"
1350
matroska_audio_muxer_select="matroska_muxer"
1351
matroska_demuxer_suggest="zlib bzlib"
1352
mov_demuxer_suggest="zlib"
1353
mp3_demuxer_deps="mpegaudio_parser"
1354
mp4_muxer_select="mov_muxer"
1355
mpegtsraw_demuxer_select="mpegts_demuxer"
1356
mxf_d10_muxer_select="mxf_muxer"
1357
ogg_demuxer_select="golomb"
1358
psp_muxer_select="mov_muxer"
1359
rtsp_demuxer_deps="sdp_demuxer"
1360
rtsp_muxer_deps="sdp_demuxer"
1361
rtsp_muxer_select="rtp_muxer"
1362
sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
1363
sdp_demuxer_select="asf_demuxer rm_demuxer"
1364
spdif_muxer_select="aac_parser"
1365
tg2_muxer_select="mov_muxer"
1366
tgp_muxer_select="mov_muxer"
1367
w64_demuxer_deps="wav_demuxer"
1368

    
1369
# indevs / outdevs
1370
alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1371
alsa_indev_extralibs="-lasound"
1372
alsa_outdev_deps="alsa_asoundlib_h"
1373
alsa_outdev_extralibs="-lasound"
1374
bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
1375
dv1394_indev_deps="dv1394 dv_demuxer"
1376
jack_indev_deps="jack_jack_h"
1377
jack_indev_extralibs="-ljack"
1378
libdc1394_indev_deps="libdc1394"
1379
oss_indev_deps_any="soundcard_h sys_soundcard_h"
1380
oss_outdev_deps_any="soundcard_h sys_soundcard_h"
1381
v4l_indev_deps="linux_videodev_h"
1382
v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
1383
vfwcap_indev_deps="capCreateCaptureWindow"
1384
vfwcap_indev_extralibs="-lavicap32"
1385
x11_grab_device_indev_deps="x11grab XShmCreateImage"
1386
x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
1387

    
1388
# protocols
1389
gopher_protocol_deps="network"
1390
http_protocol_deps="network"
1391
http_protocol_select="tcp_protocol"
1392
mmst_protocol_deps="network"
1393
rtmp_protocol_select="tcp_protocol"
1394
rtp_protocol_select="udp_protocol"
1395
tcp_protocol_deps="network"
1396
udp_protocol_deps="network"
1397

    
1398
# filters
1399
movie_filter_deps="avfilter_lavf"
1400
avfilter_lavf_deps="avformat"
1401

    
1402
# libraries
1403
avdevice_deps="avcodec avformat"
1404
avformat_deps="avcodec"
1405

    
1406
# programs
1407
ffmpeg_deps="avcodec avformat swscale"
1408
ffmpeg_select="buffer_filter"
1409
ffplay_deps="avcodec avformat swscale sdl"
1410
ffplay_select="rdft"
1411
ffprobe_deps="avcodec avformat"
1412
ffserver_deps="avformat ffm_muxer rtp_protocol rtsp_demuxer"
1413
ffserver_extralibs='$ldl'
1414

    
1415
doc_deps="texi2html"
1416

    
1417
# default parameters
1418

    
1419
logfile="config.log"
1420

    
1421
# installation paths
1422
prefix_default="/usr/local"
1423
bindir_default='${prefix}/bin'
1424
datadir_default='${prefix}/share/ffmpeg'
1425
incdir_default='${prefix}/include'
1426
libdir_default='${prefix}/lib'
1427
mandir_default='${prefix}/share/man'
1428
shlibdir_default="$libdir_default"
1429

    
1430
# toolchain
1431
ar_default="ar"
1432
cc_default="gcc"
1433
cc_version=\"unknown\"
1434
host_cc_default="gcc"
1435
ln_s="ln -sf"
1436
nm_default="nm"
1437
objformat="elf"
1438
ranlib="ranlib"
1439
strip_default="strip"
1440
yasmexe="yasm"
1441

    
1442
nm_opts='-g'
1443

    
1444
# machine
1445
arch_default=$(uname -m)
1446
cpu="generic"
1447

    
1448
# OS
1449
target_os_default=$(tolower $(uname -s))
1450
host_os=$target_os_default
1451

    
1452
# configurable options
1453
enable avcodec
1454
enable avdevice
1455
enable avfilter
1456
enable avformat
1457
enable avutil
1458
enable asm
1459
enable debug
1460
enable doc
1461
enable fastdiv
1462
enable ffmpeg
1463
enable ffplay
1464
enable ffprobe
1465
enable ffserver
1466
enable mpegaudio_hp
1467
enable network
1468
enable optimizations
1469
enable protocols
1470
enable static
1471
enable stripping
1472
enable swscale
1473
enable swscale_alpha
1474

    
1475
# build settings
1476
SHFLAGS='-shared -Wl,-soname,$$(@F)'
1477
FFSERVERLDFLAGS=-Wl,-E
1478
LIBPREF="lib"
1479
LIBSUF=".a"
1480
FULLNAME='$(NAME)$(BUILDSUF)'
1481
LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
1482
SLIBPREF="lib"
1483
SLIBSUF=".so"
1484
SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
1485
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1486
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
1487
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
1488

    
1489
CC_O='-o $@'
1490

    
1491
host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
1492
host_libs='-lm'
1493

    
1494
target_path='$(CURDIR)'
1495

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

    
1501
# find source path
1502
source_path="$(dirname "$0")"
1503
enable source_path_used
1504
if test -f configure; then
1505
    source_path="$(pwd)"
1506
    disable source_path_used
1507
else
1508
    source_path="$(cd "$source_path"; pwd)"
1509
    echo "$source_path" | grep -q '[[:blank:]]' &&
1510
        die "Out of tree builds are impossible with whitespace in source path."
1511
    test -e "$source_path/config.h" &&
1512
        die "Out of tree builds are impossible with config.h in source dir."
1513
fi
1514

    
1515
for v in "$@"; do
1516
    r=${v#*=}
1517
    l=${v%"$r"}
1518
    r=$(sh_quote "$r")
1519
    FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
1520
done
1521

    
1522
find_things(){
1523
    thing=$1
1524
    pattern=$2
1525
    file=$source_path/$3
1526
    sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
1527
}
1528

    
1529
ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
1530
DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
1531
HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
1532
PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
1533
BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
1534
MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
1535
DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
1536
OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
1537
INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
1538
PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
1539
FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
1540

    
1541
for n in $COMPONENT_LIST; do
1542
    v=$(toupper ${n%s})_LIST
1543
    eval enable \$$v
1544
    eval ${n}_if_any="\$$v"
1545
done
1546

    
1547
enable $ARCH_EXT_LIST
1548

    
1549
die_unknown(){
1550
    echo "Unknown option \"$1\"."
1551
    echo "See $0 --help for available options."
1552
    exit 1
1553
}
1554

    
1555
show_list() {
1556
    suffix=_$1
1557
    shift
1558
    echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
1559
    exit 0
1560
}
1561

    
1562
for opt do
1563
    optval="${opt#*=}"
1564
    case "$opt" in
1565
    --extra-ldflags=*) add_ldflags $optval
1566
    ;;
1567
    --extra-libs=*) add_extralibs $optval
1568
    ;;
1569
    --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
1570
    ;;
1571
    --enable-debug=*) debuglevel="$optval"
1572
    ;;
1573
    --disable-everything)
1574
    map 'eval disable \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
1575
    ;;
1576
    --enable-*=*|--disable-*=*)
1577
    eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
1578
    is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1579
    eval list=\$$(toupper $thing)_LIST
1580
    name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1581
    $action $(filter "$name" $list)
1582
    ;;
1583
    --enable-?*|--disable-?*)
1584
    eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
1585
    if is_in $option $COMPONENT_LIST; then
1586
        test $action = disable && action=unset
1587
        eval $action \$$(toupper ${option%s})_LIST
1588
    elif is_in $option $CMDLINE_SELECT; then
1589
        $action $option
1590
    else
1591
        die_unknown $opt
1592
    fi
1593
    ;;
1594
    --list-*)
1595
        NAME="${opt#--list-}"
1596
        is_in $NAME $COMPONENT_LIST || die_unknown $opt
1597
        NAME=${NAME%s}
1598
        eval show_list $NAME \$$(toupper $NAME)_LIST
1599
    ;;
1600
    --help|-h) show_help
1601
    ;;
1602
    *)
1603
    optname="${opt%%=*}"
1604
    optname="${optname#--}"
1605
    optname=$(echo "$optname" | sed 's/-/_/g')
1606
    if is_in $optname $CMDLINE_SET; then
1607
        eval $optname='$optval'
1608
    elif is_in $optname $CMDLINE_APPEND; then
1609
        append $optname "$optval"
1610
    else
1611
         die_unknown $opt
1612
    fi
1613
    ;;
1614
    esac
1615
done
1616

    
1617
disabled logging && logfile=/dev/null
1618

    
1619
echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
1620
set >> $logfile
1621

    
1622
test -n "$cross_prefix" && enable cross_compile
1623

    
1624
if enabled cross_compile; then
1625
    test -n "$arch" && test -n "$target_os" ||
1626
        die "Must specify target arch and OS when cross-compiling"
1627
fi
1628

    
1629
set_default arch target_os
1630

    
1631
ar_default="${cross_prefix}${ar_default}"
1632
cc_default="${cross_prefix}${cc_default}"
1633
nm_default="${cross_prefix}${nm_default}"
1634
ranlib="${cross_prefix}${ranlib}"
1635
strip_default="${cross_prefix}${strip_default}"
1636

    
1637
sysinclude_default="${sysroot}/usr/include"
1638

    
1639
set_default cc nm strip sysinclude
1640
enabled cross_compile || host_cc_default=$cc
1641
set_default host_cc
1642

    
1643
exesuf() {
1644
    case $1 in
1645
        mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
1646
    esac
1647
}
1648

    
1649
EXESUF=$(exesuf $target_os)
1650
HOSTEXESUF=$(exesuf $host_os)
1651

    
1652
# set temporary file name
1653
: ${TMPDIR:=$TEMPDIR}
1654
: ${TMPDIR:=$TMP}
1655
: ${TMPDIR:=/tmp}
1656

    
1657
if ! check_cmd type mktemp; then
1658
    # simple replacement for missing mktemp
1659
    # NOT SAFE FOR GENERAL USE
1660
    mktemp(){
1661
        echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
1662
    }
1663
fi
1664

    
1665
tmpfile(){
1666
    tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
1667
        (set -C; exec > $tmp) 2>/dev/null ||
1668
        die "Unable to create temporary file in $TMPDIR."
1669
    append TMPFILES $tmp
1670
    eval $1=$tmp
1671
}
1672

    
1673
trap 'rm -f -- $TMPFILES' EXIT
1674
trap exit HUP INT TERM
1675

    
1676
tmpfile TMPC  .c
1677
tmpfile TMPE  $EXESUF
1678
tmpfile TMPH  .h
1679
tmpfile TMPO  .o
1680
tmpfile TMPS  .S
1681
tmpfile TMPV  .ver
1682
tmpfile TMPSH .sh
1683

    
1684
unset -f mktemp
1685

    
1686
# make sure we can execute files in $TMPDIR
1687
cat > $TMPSH 2>> $logfile <<EOF
1688
#! /bin/sh
1689
EOF
1690
chmod +x $TMPSH >> $logfile 2>&1
1691
if ! $TMPSH >> $logfile 2>&1; then
1692
    cat <<EOF
1693
Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
1694
variable to another directory and make sure that it is not mounted noexec.
1695
EOF
1696
    die "Sanity test failed."
1697
fi
1698

    
1699
filter_cflags=echo
1700
filter_cppflags=echo
1701
filter_asflags=echo
1702

    
1703
if   $cc -v 2>&1 | grep -qi ^gcc; then
1704
    cc_type=gcc
1705
    cc_version=__VERSION__
1706
    if ! $cc -dumpversion | grep -q '^2\.'; then
1707
        CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1708
        AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1709
    fi
1710
    speed_cflags='-O3'
1711
    size_cflags='-Os'
1712
elif $cc --version 2>/dev/null | grep -q Intel; then
1713
    cc_type=icc
1714
    cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
1715
    CC_DEPFLAGS='-MMD'
1716
    AS_DEPFLAGS='-MMD'
1717
    speed_cflags='-O3'
1718
    size_cflags='-Os'
1719
    noopt_cflags='-O1'
1720
elif $cc -v 2>&1 | grep -q xlc; then
1721
    cc_type=xlc
1722
    cc_version="AV_STRINGIFY(__IBMC__)"
1723
    speed_cflags='-O5'
1724
    size_cflags='-O5 -qcompact'
1725
elif $cc -V 2>/dev/null | grep -q Compaq; then
1726
    cc_type=ccc
1727
    cc_version="AV_STRINGIFY(__DECC_VER)"
1728
    DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
1729
    debuglevel=3
1730
    add_ldflags -Wl,-z,now # calls to libots crash without this
1731
    speed_cflags='-fast'
1732
    size_cflags='-O1'
1733
elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
1734
    test -d "$sysroot" || die "No valid sysroot specified."
1735
    cc_type=armcc
1736
    cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
1737
    armcc_conf="$PWD/armcc.conf"
1738
    $cc --arm_linux_configure                 \
1739
        --arm_linux_config_file="$armcc_conf" \
1740
        --configure_sysroot="$sysroot"        \
1741
        --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
1742
        die "Error creating armcc configuration file."
1743
    cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
1744
    as_default="${cross_prefix}gcc"
1745
    CC_DEPFLAGS='-MMD'
1746
    AS_DEPFLAGS='-MMD'
1747
    speed_cflags='-O3'
1748
    size_cflags='-Os'
1749
elif $cc -version 2>/dev/null | grep -q TMS470; then
1750
    cc_type=tms470
1751
    cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
1752
    cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
1753
    CC_O='-fr=$(@D)'
1754
    as_default="${cross_prefix}gcc"
1755
    ld_default="${cross_prefix}gcc"
1756
    TMPO=$(basename $TMPC .c).o
1757
    append TMPFILES $TMPO
1758
    add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
1759
    CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
1760
    AS_DEPFLAGS='-MMD'
1761
    speed_cflags='-O3 -mf=5'
1762
    size_cflags='-O3 -mf=2'
1763
    filter_cflags=tms470_flags
1764
    tms470_flags(){
1765
        for flag; do
1766
            case $flag in
1767
                -march=*|-mcpu=*)
1768
                    case "${flag#*=}" in
1769
                        armv7-a|cortex-a*)      echo -mv=7a8 ;;
1770
                        armv7-r|cortex-r*)      echo -mv=7r4 ;;
1771
                        armv7-m|cortex-m*)      echo -mv=7m3 ;;
1772
                        armv6*|arm11*)          echo -mv=6   ;;
1773
                        armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
1774
                                                echo -mv=5e  ;;
1775
                        armv4*|arm7*|arm9[24]*) echo -mv=4   ;;
1776
                    esac
1777
                    ;;
1778
                -mfpu=neon)     echo --float_support=vfpv3 --neon ;;
1779
                -mfpu=vfp)      echo --float_support=vfpv2        ;;
1780
                -mfpu=vfpv3)    echo --float_support=vfpv3        ;;
1781
                -msoft-float)   echo --float_support=vfplib       ;;
1782
                -O[0-3]|-mf=*)  echo $flag                        ;;
1783
                -g)             echo -g -mn                       ;;
1784
                -pds=*)         echo $flag                        ;;
1785
            esac
1786
        done
1787
    }
1788
elif $cc -v 2>&1 | grep -q clang; then
1789
    cc_type=clang
1790
    cc_version=__VERSION__
1791
    CC_DEPFLAGS='-MMD'
1792
    AS_DEPFLAGS='-MMD'
1793
    speed_cflags='-O3'
1794
    size_cflags='-Os'
1795
elif $cc -V 2>&1 | grep -q Sun; then
1796
    cc_type=suncc
1797
    cc_version="AV_STRINGIFY(__SUNPRO_C)"
1798
    DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
1799
    DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
1800
    speed_cflags='-O5'
1801
    size_cflags='-O5 -xspace'
1802
    filter_cflags=suncc_flags
1803
    suncc_flags(){
1804
        for flag; do
1805
            case $flag in
1806
                -march=*|-mcpu=*)
1807
                    case "${flag#*=}" in
1808
                        native)                   echo -xtarget=native       ;;
1809
                        v9|niagara)               echo -xarch=sparc          ;;
1810
                        ultrasparc)               echo -xarch=sparcvis       ;;
1811
                        ultrasparc3|niagara2)     echo -xarch=sparcvis2      ;;
1812
                        i586|pentium)             echo -xchip=pentium        ;;
1813
                        i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
1814
                        pentium3*|c3-2)           echo -xtarget=pentium3     ;;
1815
                        pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
1816
                        pentium4*)          echo -xtarget=pentium4           ;;
1817
                        prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
1818
                        *-sse3)             echo -xarch=sse3                 ;;
1819
                        core2)              echo -xarch=ssse3 -xchip=core2   ;;
1820
                        amdfam10|barcelona)       echo -xarch=sse4_1         ;;
1821
                        athlon-4|athlon-[mx]p)    echo -xarch=ssea           ;;
1822
                        k8|opteron|athlon64|athlon-fx)
1823
                                                  echo -xarch=sse2a          ;;
1824
                        athlon*)                  echo -xarch=pentium_proa   ;;
1825
                    esac
1826
                    ;;
1827
                -std=c99)             echo -xc99              ;;
1828
                -fomit-frame-pointer) echo -xregs=frameptr    ;;
1829
                -fPIC)                echo -KPIC -xcode=pic32 ;;
1830
                -W*,*)                echo $flag              ;;
1831
                -f*-*|-W*)                                    ;;
1832
                *)                    echo $flag              ;;
1833
            esac
1834
        done
1835
    }
1836
fi
1837

    
1838
test -n "$cc_type" && enable $cc_type ||
1839
    warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
1840

    
1841
: ${as_default:=$cc}
1842
: ${dep_cc_default:=$cc}
1843
: ${ld_default:=$cc}
1844
set_default ar as dep_cc ld
1845

    
1846
test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
1847
test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
1848

    
1849
add_cflags $extra_cflags
1850
add_asflags $extra_cflags
1851

    
1852
if test -n "$sysroot"; then
1853
    case "$cc_type" in
1854
        gcc)
1855
            add_cppflags --sysroot="$sysroot"
1856
            add_ldflags --sysroot="$sysroot"
1857
        ;;
1858
        tms470)
1859
            add_cppflags -I"$sysinclude"
1860
            add_ldflags  --sysroot="$sysroot"
1861
        ;;
1862
        clang)
1863
            add_cppflags -isysroot "$sysroot"
1864
            add_ldflags -isysroot "$sysroot"
1865
        ;;
1866
    esac
1867
fi
1868

    
1869
if test "$cpu" = host; then
1870
    enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
1871

    
1872
    case "$cc_type" in
1873
        gcc)
1874
            check_native(){
1875
                $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
1876
                sed -n "/$1=/{
1877
                            s/.*$1=\\([^ ]*\\).*/\\1/
1878
                            p
1879
                            q
1880
                        }" $TMPE
1881
            }
1882
            cpu=$(check_native -march || check_native -mcpu)
1883
        ;;
1884
    esac
1885

    
1886
    test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
1887
fi
1888

    
1889
# Deal with common $arch aliases
1890
case "$arch" in
1891
    arm*)
1892
        arch="arm"
1893
    ;;
1894
    mips|mipsel|IP*)
1895
        arch="mips"
1896
    ;;
1897
    mips64*)
1898
        arch="mips"
1899
        subarch="mips64"
1900
    ;;
1901
    parisc|hppa)
1902
        arch="parisc"
1903
    ;;
1904
    parisc64|hppa64)
1905
        arch="parisc"
1906
        subarch="parisc64"
1907
    ;;
1908
    "Power Macintosh"|ppc|powerpc)
1909
        arch="ppc"
1910
    ;;
1911
    ppc64|powerpc64)
1912
        arch="ppc"
1913
        subarch="ppc64"
1914
    ;;
1915
    s390|s390x)
1916
        arch="s390"
1917
    ;;
1918
    sh4|sh)
1919
        arch="sh4"
1920
    ;;
1921
    sun4u|sparc64)
1922
        arch="sparc"
1923
        subarch="sparc64"
1924
    ;;
1925
    i[3-6]86|i86pc|BePC|x86_64|amd64)
1926
        arch="x86"
1927
    ;;
1928
esac
1929

    
1930
is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
1931
enable $arch
1932

    
1933
# Add processor-specific flags
1934
if test "$cpu" = generic; then
1935
    : do nothing
1936
elif enabled ppc; then
1937

    
1938
    case $(tolower $cpu) in
1939
        601|ppc601|powerpc601)
1940
            cpuflags="-mcpu=601"
1941
            disable altivec
1942
        ;;
1943
        603*|ppc603*|powerpc603*)
1944
            cpuflags="-mcpu=603"
1945
            disable altivec
1946
        ;;
1947
        604*|ppc604*|powerpc604*)
1948
            cpuflags="-mcpu=604"
1949
            disable altivec
1950
        ;;
1951
        g3|75*|ppc75*|powerpc75*)
1952
            cpuflags="-mcpu=750 -mpowerpc-gfxopt"
1953
            disable altivec
1954
        ;;
1955
        g4|745*|ppc745*|powerpc745*)
1956
            cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
1957
        ;;
1958
        74*|ppc74*|powerpc74*)
1959
            cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
1960
        ;;
1961
        g5|970|ppc970|powerpc970|power4*)
1962
            cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1963
        ;;
1964
        cell)
1965
            cpuflags="-mcpu=cell"
1966
            enable ldbrx
1967
        ;;
1968
        e500v2)
1969
            cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
1970
            disable altivec
1971
        ;;
1972
        e500)
1973
            cpuflags="-mcpu=8540 -mhard-float"
1974
            disable altivec
1975
        ;;
1976
    esac
1977

    
1978
elif enabled x86; then
1979

    
1980
    case $cpu in
1981
        i[345]86|pentium)
1982
            cpuflags="-march=$cpu"
1983
            disable mmx
1984
        ;;
1985
        # targets that do NOT support conditional mov (cmov)
1986
        pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1987
            cpuflags="-march=$cpu"
1988
            disable cmov
1989
        ;;
1990
        # targets that do support conditional mov (cmov)
1991
        i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10|barcelona)
1992
            cpuflags="-march=$cpu"
1993
            enable cmov
1994
            enable fast_cmov
1995
        ;;
1996
        # targets that do support conditional mov but on which it's slow
1997
        pentium4|pentium4m|prescott|nocona)
1998
            cpuflags="-march=$cpu"
1999
            enable cmov
2000
            disable fast_cmov
2001
        ;;
2002
    esac
2003

    
2004
elif enabled sparc; then
2005

    
2006
    case $cpu in
2007
        niagara)
2008
            cpuflags="-mcpu=$cpu"
2009
            disable vis
2010
        ;;
2011
        sparc64)
2012
            cpuflags="-mcpu=v9"
2013
        ;;
2014
    esac
2015

    
2016
elif enabled arm; then
2017

    
2018
    case $cpu in
2019
        armv*)
2020
            cpuflags="-march=$cpu"
2021
        ;;
2022
        *)
2023
            cpuflags="-mcpu=$cpu"
2024
        ;;
2025
    esac
2026

    
2027
elif enabled alpha; then
2028

    
2029
    enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
2030

    
2031
elif enabled bfin; then
2032

    
2033
    cpuflags="-mcpu=$cpu"
2034

    
2035
elif enabled mips; then
2036

    
2037
    cpuflags="-march=$cpu"
2038

    
2039
elif enabled avr32; then
2040

    
2041
    case $cpu in
2042
        ap7[02]0[0-2])
2043
            subarch="avr32_ap"
2044
            cpuflags="-mpart=$cpu"
2045
        ;;
2046
        ap)
2047
            subarch="avr32_ap"
2048
            cpuflags="-march=$cpu"
2049
        ;;
2050
        uc3[ab]*)
2051
            subarch="avr32_uc"
2052
            cpuflags="-mcpu=$cpu"
2053
        ;;
2054
        uc)
2055
            subarch="avr32_uc"
2056
            cpuflags="-march=$cpu"
2057
        ;;
2058
    esac
2059

    
2060
fi
2061

    
2062
add_cflags $cpuflags
2063
add_asflags $cpuflags
2064

    
2065
# compiler sanity check
2066
check_exec <<EOF
2067
int main(void){ return 0; }
2068
EOF
2069
if test "$?" != 0; then
2070
    echo "$cc is unable to create an executable file."
2071
    if test -z "$cross_prefix" && ! enabled cross_compile ; then
2072
        echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
2073
        echo "Only do this if you know what cross compiling means."
2074
    fi
2075
    die "C compiler test failed."
2076
fi
2077

    
2078
add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
2079
check_cflags -std=c99
2080
check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
2081
#include <stdlib.h>
2082
EOF
2083
check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
2084
#include <stdlib.h>
2085
EOF
2086

    
2087
check_host_cflags -std=c99
2088

    
2089
case "$arch" in
2090
    alpha|ia64|mips|parisc|sparc)
2091
        spic=$shared
2092
    ;;
2093
    x86)
2094
        subarch="x86_32"
2095
        check_cc <<EOF && subarch="x86_64"
2096
        int test[(int)sizeof(char*) - 7];
2097
EOF
2098
        if test "$subarch" = "x86_64"; then
2099
            spic=$shared
2100
        fi
2101
    ;;
2102
esac
2103

    
2104
enable $subarch
2105
enabled spic && enable pic
2106

    
2107
# OS specific
2108
case $target_os in
2109
    haiku)
2110
        prefix_default="/boot/common"
2111
        network_extralibs="-lnetwork"
2112
        ;;
2113
    sunos)
2114
        FFSERVERLDFLAGS=""
2115
        SHFLAGS='-shared -Wl,-h,$$(@F)'
2116
        enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
2117
        network_extralibs="-lsocket -lnsl"
2118
        add_cppflags -D__EXTENSIONS__
2119
        nm_opts='-P -g'
2120
        ;;
2121
    netbsd)
2122
        oss_indev_extralibs="-lossaudio"
2123
        oss_outdev_extralibs="-lossaudio"
2124
        add_cppflags -D_XOPEN_SOURCE=600
2125
        ;;
2126
    openbsd)
2127
        enable malloc_aligned
2128
        # On OpenBSD 4.5. the compiler does not use PIC unless
2129
        # explicitly using -fPIC. FFmpeg builds fine without PIC,
2130
        # however the generated executable will not do anything
2131
        # (simply quits with exit-code 1, no crash, no output).
2132
        # Thus explicitly enable PIC here.
2133
        enable pic
2134
        SHFLAGS='-shared'
2135
        oss_indev_extralibs="-lossaudio"
2136
        oss_outdev_extralibs="-lossaudio"
2137
        ;;
2138
    freebsd|dragonfly)
2139
        enable malloc_aligned
2140
        ;;
2141
    bsd/os)
2142
        osextralibs="-lpoll -lgnugetopt"
2143
        strip="strip -d"
2144
        ;;
2145
    darwin)
2146
        enable malloc_aligned
2147
        SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
2148
        strip="${strip} -x"
2149
        FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
2150
        SLIBSUF=".dylib"
2151
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
2152
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
2153
        FFSERVERLDFLAGS=-Wl,-bind_at_load
2154
        objformat="macho"
2155
        enabled x86_64 && objformat="macho64"
2156
        enabled_any pic shared ||
2157
            { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
2158
        ;;
2159
    mingw32*)
2160
        if test $target_os = "mingw32ce"; then
2161
            disable network
2162
        else
2163
            target_os=mingw32
2164
        fi
2165
        LIBTARGET=i386
2166
        if enabled x86_64; then
2167
            enable malloc_aligned
2168
            LIBTARGET=x64
2169
        elif enabled arm; then
2170
            LIBTARGET=arm
2171
        fi
2172
        shlibdir_default="$bindir_default"
2173
        disable ffserver
2174
        SLIBPREF=""
2175
        SLIBSUF=".dll"
2176
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2177
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2178
        SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
2179
        SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
2180
            install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
2181
            install -d "$(LIBDIR)"; \
2182
            install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"'
2183
        SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
2184
        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'
2185
        objformat="win32"
2186
        enable dos_paths
2187
        check_cflags -fno-common
2188
        if ! enabled x86_64; then
2189
            check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
2190
                die "ERROR: MinGW runtime version must be >= 3.15."
2191
            enabled_any avisynth vfwcap_indev &&
2192
                { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
2193
                  die "ERROR: avisynth and vfwcap_indev require w32api version 3.13 or later."; }
2194
        fi
2195
        ;;
2196
    cygwin*)
2197
        target_os=cygwin
2198
        shlibdir_default="$bindir_default"
2199
        SLIBPREF="cyg"
2200
        SLIBSUF=".dll"
2201
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2202
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2203
        SHFLAGS='-shared -Wl,--enable-auto-image-base'
2204
        objformat="win32"
2205
        enable dos_paths
2206
        check_cflags -fno-common
2207
        ;;
2208
    *-dos|freedos|opendos)
2209
        disable ffplay ffserver
2210
        disable $INDEV_LIST $OUTDEV_LIST
2211
        network_extralibs="-lsocket"
2212
        objformat="coff"
2213
        enable dos_paths
2214
        ;;
2215
    linux)
2216
        enable dv1394
2217
        ;;
2218
    irix*)
2219
        target_os=irix
2220
        ranlib="echo ignoring ranlib"
2221
        ;;
2222
    os/2*)
2223
        strip="lxlite"
2224
        ln_s="cp -f"
2225
        FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
2226
        SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
2227
        FFSERVERLDFLAGS=""
2228
        LIBSUF="_s.a"
2229
        SLIBPREF=""
2230
        SLIBSUF=".dll"
2231
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
2232
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
2233
        SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
2234
          echo PROTMODE >> $(SUBDIR)$(NAME).def; \
2235
          echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
2236
          echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
2237
          echo EXPORTS >> $(SUBDIR)$(NAME).def; \
2238
          emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
2239
        SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
2240
          emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
2241
        SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
2242
        SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
2243
        enable dos_paths
2244
        ;;
2245
    gnu/kfreebsd)
2246
        ;;
2247
    gnu)
2248
        ;;
2249
    none)
2250
        ;;
2251
    *)
2252
        die "Unknown OS '$target_os'."
2253
        ;;
2254
esac
2255

    
2256
check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
2257

    
2258
set_default $PATHS_LIST
2259

    
2260
add_extralibs $osextralibs
2261

    
2262
# Combine FFLDFLAGS and the LDFLAGS environment variable.
2263
LDFLAGS="$FFLDFLAGS $LDFLAGS"
2264

    
2265
# we need to build at least one lib type
2266
if ! enabled_any static shared; then
2267
    cat <<EOF
2268
At least one library type must be built.
2269
Specify --enable-static to build the static libraries or --enable-shared to
2270
build the shared libraries as well. To only build the shared libraries specify
2271
--disable-static in addition to --enable-shared.
2272
EOF
2273
    exit 1;
2274
fi
2275

    
2276
disabled static && LIBNAME=""
2277

    
2278
die_license_disabled() {
2279
    enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2280
}
2281

    
2282
die_license_disabled gpl libx264
2283
die_license_disabled gpl libxvid
2284
die_license_disabled gpl postproc
2285
die_license_disabled gpl x11grab
2286

    
2287
die_license_disabled nonfree libfaac
2288

    
2289
die_license_disabled version3 libopencore_amrnb
2290
die_license_disabled version3 libopencore_amrwb
2291

    
2292
enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2293

    
2294
check_deps $ARCH_EXT_LIST
2295

    
2296
disabled optimizations || check_cflags -fomit-frame-pointer
2297

    
2298
enable_pic() {
2299
    enable pic
2300
    add_cppflags -DPIC
2301
    add_cflags   -fPIC
2302
    add_asflags  -fPIC
2303
}
2304

    
2305
enabled pic && enable_pic
2306

    
2307
check_cc <<EOF || die "Symbol mangling check failed."
2308
int ff_extern;
2309
EOF
2310
sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
2311
extern_prefix=${sym%%ff_extern*}
2312

    
2313
check_cc <<EOF && enable inline_asm
2314
void foo(void) { __asm__ volatile ("" ::); }
2315
EOF
2316

    
2317
_restrict=
2318
for restrict_keyword in restrict __restrict__ __restrict; do
2319
    check_cc <<EOF && _restrict=$restrict_keyword && break
2320
void foo(char * $restrict_keyword p);
2321
EOF
2322
done
2323

    
2324
check_cc <<EOF && enable attribute_packed
2325
struct { int x; } __attribute__((packed)) x;
2326
EOF
2327

    
2328
check_cc <<EOF && enable attribute_may_alias
2329
union { int x; } __attribute__((may_alias)) x;
2330
EOF
2331

    
2332
check_cc <<EOF || die "endian test failed"
2333
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2334
EOF
2335
od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2336

    
2337
if enabled alpha; then
2338

    
2339
    check_cflags -mieee
2340

    
2341
elif enabled arm; then
2342

    
2343
    check_cflags -marm
2344

    
2345
    check_ld <<EOF && enable vfp_args
2346
__asm__ (".eabi_attribute 28, 1");
2347
int main(void) { return 0; }
2348
EOF
2349

    
2350
    # We have to check if pld is a nop and disable it.
2351
    check_asm pld '"pld [r0]"'
2352

    
2353
    enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2354
    enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
2355
    enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2356
    enabled armvfp  && check_asm armvfp  '"fadds s0, s0, s0"'
2357
    enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
2358
    enabled neon    && check_asm neon    '"vadd.i16 q0, q0, q0"'
2359

    
2360
    enabled_all armv6t2 shared !pic && enable_pic
2361

    
2362
elif enabled mips; then
2363

    
2364
    check_asm loongson '"dmult.g $1, $2, $3"'
2365
    enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
2366

    
2367
elif enabled ppc; then
2368

    
2369
    enable local_aligned_8 local_aligned_16
2370

    
2371
    check_asm dcbzl     '"dcbzl 0, 1"'
2372
    check_asm ppc4xx    '"maclhw r10, r11, r12"'
2373
    check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
2374

    
2375
    # AltiVec flags: The FSF version of GCC differs from the Apple version
2376
    if enabled altivec; then
2377
        check_cflags -maltivec -mabi=altivec &&
2378
        { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2379
        check_cflags -faltivec
2380

    
2381
        # check if our compiler supports Motorola AltiVec C API
2382
        check_cc <<EOF || disable altivec
2383
$inc_altivec_h
2384
int main(void) {
2385
    vector signed int v1, v2, v3;
2386
    v1 = vec_add(v2,v3);
2387
    return 0;
2388
}
2389
EOF
2390

    
2391
        # check if our compiler supports braces for vector declarations
2392
        check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
2393
$inc_altivec_h
2394
int main (void) { (vector int) {1}; return 0; }
2395
EOF
2396
    fi
2397

    
2398
elif enabled sparc; then
2399

    
2400
    enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2401
        add_cflags -mcpu=ultrasparc -mtune=ultrasparc
2402

    
2403
elif enabled x86; then
2404

    
2405
    enable local_aligned_8 local_aligned_16
2406

    
2407
    # check whether EBP is available on x86
2408
    # As 'i' is stored on the stack, this program will crash
2409
    # if the base pointer is used to access it because the
2410
    # base pointer is cleared in the inline assembly code.
2411
    check_exec_crash <<EOF && enable ebp_available
2412
    volatile int i=0;
2413
    __asm__ volatile (
2414
        "xorl %%ebp, %%ebp"
2415
    ::: "%ebp");
2416
    return i;
2417
EOF
2418

    
2419
    # check whether EBX is available on x86
2420
    check_asm ebx_available '""::"b"(0)' &&
2421
        check_asm ebx_available '"":::"%ebx"'
2422

    
2423
    # check whether more than 10 operands are supported
2424
    check_cc <<EOF && enable ten_operands
2425
int main(void) {
2426
    int x=0;
2427
    __asm__ volatile(
2428
        ""
2429
        :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
2430
    );
2431
    return 0;
2432
}
2433
EOF
2434

    
2435
    # check whether binutils is new enough to compile SSSE3/MMX2
2436
    enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
2437
    enabled mmx2  && check_asm mmx2  '"pmaxub %mm0, %mm1"'
2438

    
2439
    check_asm bswap '"bswap %%eax" ::: "%eax"'
2440

    
2441
    YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
2442
    enabled     x86_64        && append YASMFLAGS "-m amd64"
2443
    enabled     pic           && append YASMFLAGS "-DPIC"
2444
    test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
2445
    case "$objformat" in
2446
        elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
2447
    esac
2448
    if ! disabled yasm; then
2449
        check_yasm "pabsw xmm0, xmm0" && enable yasm ||
2450
            warn "yasm not found, performance will suffer"
2451
    fi
2452

    
2453
    case "$cpu" in
2454
        athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
2455
            disable fast_clz
2456
        ;;
2457
    esac
2458

    
2459
fi
2460

    
2461
if check_func dlopen; then
2462
    ldl=
2463
elif check_func dlopen -ldl; then
2464
    ldl=-ldl
2465
fi
2466

    
2467
# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2468
check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2469

    
2470
check_func  fork
2471
check_func  getaddrinfo $network_extralibs
2472
check_func  gethrtime
2473
check_func  getrusage
2474
check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
2475
check_func  inet_aton $network_extralibs
2476
check_func  isatty
2477
check_func  ${malloc_prefix}memalign            && enable memalign
2478
check_func  mkstemp
2479
check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
2480
check_func  setrlimit
2481
check_func  strerror_r
2482
check_func_headers io.h setmode
2483
check_func_headers lzo/lzo1x.h lzo1x_999_compress
2484
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
2485
check_func_headers windows.h GetProcessTimes
2486
check_func_headers windows.h VirtualAlloc
2487

    
2488
check_header conio.h
2489
check_header dlfcn.h
2490
check_header dxva2api.h
2491
check_header malloc.h
2492
check_header poll.h
2493
check_header sys/mman.h
2494
check_header sys/resource.h
2495
check_header sys/select.h
2496
check_header termios.h
2497
check_header vdpau/vdpau.h
2498
check_header vdpau/vdpau_x11.h
2499
check_header X11/extensions/XvMClib.h
2500

    
2501
check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex
2502

    
2503
if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
2504
     enabled_any $need_memalign ; then
2505
    die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
2506
fi
2507

    
2508
disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
2509
disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
2510

    
2511
# check for some common methods of building with pthread support
2512
# do this before the optional library checks as some of them require pthreads
2513
if ! disabled pthreads && ! enabled w32threads; then
2514
    enable pthreads
2515
    if check_func pthread_create; then
2516
        :
2517
    elif check_func pthread_create -pthread; then
2518
        add_cflags -pthread
2519
        add_extralibs -pthread
2520
    elif check_func pthread_create -pthreads; then
2521
        add_cflags -pthreads
2522
        add_extralibs -pthreads
2523
    elif check_func pthread_create -lpthreadGC2; then
2524
        add_extralibs -lpthreadGC2
2525
    elif ! check_lib pthread.h pthread_create -lpthread; then
2526
        disable pthreads
2527
    fi
2528
fi
2529

    
2530
for thread in $THREADS_LIST; do
2531
    if enabled $thread; then
2532
        test -n "$thread_type" &&
2533
            die "ERROR: Only one thread type must be selected." ||
2534
            thread_type="$thread"
2535
    fi
2536
done
2537

    
2538
check_lib math.h sin -lm
2539
disabled vaapi || check_lib va/va.h vaInitialize -lva
2540

    
2541
check_mathfunc exp2
2542
check_mathfunc exp2f
2543
check_mathfunc llrint
2544
check_mathfunc llrintf
2545
check_mathfunc log2
2546
check_mathfunc log2f
2547
check_mathfunc lrint
2548
check_mathfunc lrintf
2549
check_mathfunc round
2550
check_mathfunc roundf
2551
check_mathfunc truncf
2552

    
2553
# these are off by default, so fail if requested and not available
2554
enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
2555
enabled libdirac   && add_cflags $(pkg-config --cflags dirac) &&
2556
                      require  libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
2557
                      require  libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
2558
enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
2559
enabled libgsm     && require  libgsm gsm/gsm.h gsm_create -lgsm
2560
enabled libmp3lame && require  libmp3lame lame/lame.h lame_init -lmp3lame -lm
2561
enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
2562
enabled libopencore_amrnb  && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
2563
enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
2564
enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
2565
enabled librtmp    && require  librtmp librtmp/rtmp.h RTMP_Init $(pkg-config --libs librtmp)
2566
enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
2567
                           require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
2568
enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
2569
enabled libtheora  && require  libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
2570
enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
2571
enabled libvpx     && require2 libvpx "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_dec_init_ver" -lvpx &&
2572
                      require2 libvpx "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver" -lvpx
2573
enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 -lm &&
2574
                      { check_cpp_condition x264.h "X264_BUILD >= 98" ||
2575
                        die "ERROR: libx264 version must be >= 0.98."; }
2576
enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
2577
enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
2578

    
2579
# libdc1394 check
2580
if enabled libdc1394; then
2581
    { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2582
        enable libdc1394_2; } ||
2583
    { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2584
        enable libdc1394_1; } ||
2585
    die "ERROR: No version of libdc1394 found "
2586
fi
2587

    
2588
SDL_CONFIG="${cross_prefix}sdl-config"
2589
if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
2590
    sdl_cflags=$("${SDL_CONFIG}" --cflags)
2591
    sdl_libs=$("${SDL_CONFIG}" --libs)
2592
    check_func_headers SDL.h SDL_Init $sdl_cflags $sdl_libs &&
2593
    check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
2594
    enable sdl &&
2595
    check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
2596
fi
2597

    
2598
texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
2599

    
2600
if enabled network; then
2601
    check_type "sys/types.h sys/socket.h" socklen_t
2602
    check_type netdb.h "struct addrinfo"
2603
    check_type netinet/in.h "struct ipv6_mreq"
2604
    check_type netinet/in.h "struct sockaddr_in6"
2605
    check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
2606
    check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
2607
    # Prefer arpa/inet.h over winsock2
2608
    if check_header arpa/inet.h ; then
2609
        check_func closesocket
2610
    elif check_header winsock2.h ; then
2611
        check_func_headers winsock2.h closesocket -lws2 && \
2612
            network_extralibs="-lws2" || \
2613
        { check_func_headers winsock2.h closesocket -lws2_32 && \
2614
            network_extralibs="-lws2_32"; }
2615
        check_type ws2tcpip.h socklen_t
2616
        check_type ws2tcpip.h "struct addrinfo"
2617
        check_type ws2tcpip.h "struct ipv6_mreq"
2618
        check_type ws2tcpip.h "struct sockaddr_in6"
2619
        check_type ws2tcpip.h "struct sockaddr_storage"
2620
        check_struct winsock2.h "struct sockaddr" sa_len
2621
    else
2622
        disable network
2623
    fi
2624
fi
2625

    
2626
check_header linux/videodev.h
2627
check_header linux/videodev2.h
2628
check_header sys/videoio.h
2629

    
2630
check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
2631

    
2632
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
2633
{ check_header dev/bktr/ioctl_meteor.h &&
2634
  check_header dev/bktr/ioctl_bt848.h; } ||
2635
{ check_header machine/ioctl_meteor.h &&
2636
  check_header machine/ioctl_bt848.h; } ||
2637
{ check_header dev/video/meteor/ioctl_meteor.h &&
2638
  check_header dev/video/bktr/ioctl_bt848.h; } ||
2639
check_header dev/ic/bt8xx.h
2640

    
2641
check_header sys/soundcard.h
2642
check_header soundcard.h
2643

    
2644
enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
2645

    
2646
enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
2647

    
2648
enabled x11grab                         &&
2649
check_header X11/Xlib.h                 &&
2650
check_header X11/extensions/XShm.h      &&
2651
check_header X11/extensions/Xfixes.h    &&
2652
check_func XOpenDisplay -lX11           &&
2653
check_func XShmCreateImage -lX11 -lXext &&
2654
check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
2655

    
2656
if ! disabled vdpau && enabled vdpau_vdpau_h; then
2657
check_cpp_condition \
2658
    vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
2659
    { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
2660
      disable vdpau; }
2661
fi
2662

    
2663
enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
2664

    
2665
# add some useful compiler flags if supported
2666
check_cflags -Wdeclaration-after-statement
2667
check_cflags -Wall
2668
check_cflags -Wno-switch
2669
check_cflags -Wdisabled-optimization
2670
check_cflags -Wpointer-arith
2671
check_cflags -Wredundant-decls
2672
check_cflags -Wno-pointer-sign
2673
check_cflags -Wcast-qual
2674
check_cflags -Wwrite-strings
2675
check_cflags -Wtype-limits
2676
check_cflags -Wundef
2677
check_cflags -Wmissing-prototypes
2678
enabled extra_warnings && check_cflags -Winline
2679

    
2680
# add some linker flags
2681
check_ldflags -Wl,--warn-common
2682
check_ldflags -Wl,--as-needed
2683
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'
2684
check_ldflags -Wl,-Bsymbolic
2685

    
2686
echo "X{};" > $TMPV
2687
if test_ldflags -Wl,--version-script,$TMPV; then
2688
    append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
2689
    check_cc <<EOF && enable symver_asm_label
2690
void ff_foo(void) __asm__ ("av_foo@VERSION");
2691
void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
2692
EOF
2693
    check_cc <<EOF && enable symver_gnu_asm
2694
__asm__(".symver ff_foo,av_foo@VERSION");
2695
void ff_foo(void) {}
2696
EOF
2697
fi
2698

    
2699
if enabled small; then
2700
    add_cflags $size_cflags
2701
    optimizations="small"
2702
elif enabled optimizations; then
2703
    add_cflags $speed_cflags
2704
else
2705
    add_cflags $noopt_cflags
2706
fi
2707
check_cflags -fno-math-errno
2708
check_cflags -fno-signed-zeros
2709

    
2710
if enabled icc; then
2711
    # Just warnings, no remarks
2712
    check_cflags -w1
2713
    # -wd: Disable following warnings
2714
    # 144, 167, 556: -Wno-pointer-sign
2715
    # 10006: ignoring unknown option -fno-signed-zeros
2716
    # 10156: ignoring option '-W'; no argument required
2717
    check_cflags -wd144,167,556,10006,10156
2718
    # 11030: Warning unknown option --as-needed
2719
    # 10156: ignoring option '-export'; no argument required
2720
    check_ldflags -wd10156,11030
2721
    # Allow to compile with optimizations
2722
    check_ldflags -march=$cpu
2723
    # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
2724
    enable ebp_available
2725
elif enabled ccc; then
2726
    # disable some annoying warnings
2727
    add_cflags -msg_disable cvtu32to64
2728
    add_cflags -msg_disable embedcomment
2729
    add_cflags -msg_disable needconstext
2730
    add_cflags -msg_disable nomainieee
2731
    add_cflags -msg_disable ptrmismatch1
2732
    add_cflags -msg_disable unreachcode
2733
elif enabled gcc; then
2734
    check_cflags -fno-tree-vectorize
2735
    check_cflags -Werror=implicit
2736
    check_cflags -Werror=missing-prototypes
2737
elif enabled clang; then
2738
    check_cflags -Qunused-arguments
2739
elif enabled armcc; then
2740
    # 2523: use of inline assembler is deprecated
2741
    add_cflags -Wrvct,--diag_suppress=2523
2742
    add_cflags -Wrvct,--diag_suppress=1207
2743
elif enabled tms470; then
2744
    add_cflags -pds=824 -pds=837
2745
fi
2746

    
2747
if enabled gprof; then
2748
    add_cflags  -p
2749
    add_ldflags -p
2750
fi
2751

    
2752
enabled_any $THREADS_LIST      && enable threads
2753

    
2754
check_deps $CONFIG_LIST       \
2755
           $CONFIG_EXTRA      \
2756
           $HAVE_LIST         \
2757
           $DECODER_LIST      \
2758
           $ENCODER_LIST      \
2759
           $HWACCEL_LIST      \
2760
           $PARSER_LIST       \
2761
           $BSF_LIST          \
2762
           $DEMUXER_LIST      \
2763
           $MUXER_LIST        \
2764
           $FILTER_LIST       \
2765
           $INDEV_LIST        \
2766
           $OUTDEV_LIST       \
2767
           $PROTOCOL_LIST     \
2768

    
2769
enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
2770

    
2771
echo "install prefix            $prefix"
2772
echo "source path               $source_path"
2773
echo "C compiler                $cc"
2774
echo "ARCH                      $arch ($cpu)"
2775
if test "$build_suffix" != ""; then
2776
    echo "build suffix              $build_suffix"
2777
fi
2778
if test "$extra_version" != ""; then
2779
    echo "version string suffix     $extra_version"
2780
fi
2781
echo "big-endian                ${bigendian-no}"
2782
echo "runtime cpu detection     ${runtime_cpudetect-no}"
2783
if enabled x86; then
2784
    echo "yasm                      ${yasm-no}"
2785
    echo "MMX enabled               ${mmx-no}"
2786
    echo "MMX2 enabled              ${mmx2-no}"
2787
    echo "3DNow! enabled            ${amd3dnow-no}"
2788
    echo "3DNow! extended enabled   ${amd3dnowext-no}"
2789
    echo "SSE enabled               ${sse-no}"
2790
    echo "SSSE3 enabled             ${ssse3-no}"
2791
    echo "CMOV enabled              ${cmov-no}"
2792
    echo "CMOV is fast              ${fast_cmov-no}"
2793
    echo "EBX available             ${ebx_available-no}"
2794
    echo "EBP available             ${ebp_available-no}"
2795
    echo "10 operands supported     ${ten_operands-no}"
2796
fi
2797
if enabled arm; then
2798
    echo "ARMv5TE enabled           ${armv5te-no}"
2799
    echo "ARMv6 enabled             ${armv6-no}"
2800
    echo "ARMv6T2 enabled           ${armv6t2-no}"
2801
    echo "ARM VFP enabled           ${armvfp-no}"
2802
    echo "IWMMXT enabled            ${iwmmxt-no}"
2803
    echo "NEON enabled              ${neon-no}"
2804
fi
2805
if enabled mips; then
2806
    echo "MMI enabled               ${mmi-no}"
2807
fi
2808
if enabled ppc; then
2809
    echo "AltiVec enabled           ${altivec-no}"
2810
    echo "PPC 4xx optimizations     ${ppc4xx-no}"
2811
    echo "dcbzl available           ${dcbzl-no}"
2812
    echo "performance report        ${powerpc_perf-no}"
2813
fi
2814
if enabled sparc; then
2815
    echo "VIS enabled               ${vis-no}"
2816
fi
2817
echo "gprof enabled             ${gprof-no}"
2818
echo "debug symbols             ${debug-no}"
2819
echo "strip symbols             ${stripping-no}"
2820
echo "optimizations             ${optimizations-no}"
2821
echo "static                    ${static-no}"
2822
echo "shared                    ${shared-no}"
2823
echo "postprocessing support    ${postproc-no}"
2824
echo "new filter support        ${avfilter-no}"
2825
echo "filters using lavformat   ${avfilter_lavf-no}"
2826
echo "network support           ${network-no}"
2827
echo "threading support         ${thread_type-no}"
2828
echo "SDL support               ${sdl-no}"
2829
echo "Sun medialib support      ${mlib-no}"
2830
echo "AVISynth enabled          ${avisynth-no}"
2831
echo "libdc1394 support         ${libdc1394-no}"
2832
echo "libdirac enabled          ${libdirac-no}"
2833
echo "libfaac enabled           ${libfaac-no}"
2834
echo "libgsm enabled            ${libgsm-no}"
2835
echo "libmp3lame enabled        ${libmp3lame-no}"
2836
echo "libnut enabled            ${libnut-no}"
2837
echo "libopencore-amrnb support ${libopencore_amrnb-no}"
2838
echo "libopencore-amrwb support ${libopencore_amrwb-no}"
2839
echo "libopenjpeg enabled       ${libopenjpeg-no}"
2840
echo "librtmp enabled           ${librtmp-no}"
2841
echo "libschroedinger enabled   ${libschroedinger-no}"
2842
echo "libspeex enabled          ${libspeex-no}"
2843
echo "libtheora enabled         ${libtheora-no}"
2844
echo "libvorbis enabled         ${libvorbis-no}"
2845
echo "libvpx enabled            ${libvpx-no}"
2846
echo "libx264 enabled           ${libx264-no}"
2847
echo "libxvid enabled           ${libxvid-no}"
2848
echo "zlib enabled              ${zlib-no}"
2849
echo "bzlib enabled             ${bzlib-no}"
2850
echo
2851

    
2852
for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
2853
    echo "Enabled ${type}s:"
2854
    eval list=\$$(toupper $type)_LIST
2855
    for part in $list; do
2856
        enabled $part && echo ${part%_*}
2857
    done | sort | pr -3 -t
2858
    echo
2859
done
2860

    
2861
license="LGPL version 2.1 or later"
2862
if enabled nonfree; then
2863
    license="nonfree and unredistributable"
2864
elif enabled gplv3; then
2865
    license="GPL version 3 or later"
2866
elif enabled lgplv3; then
2867
    license="LGPL version 3 or later"
2868
elif enabled gpl; then
2869
    license="GPL version 2 or later"
2870
fi
2871

    
2872
echo "License: $license"
2873

    
2874
echo "Creating config.mak and config.h..."
2875

    
2876
# build tree in object directory if source path is different from current one
2877
if enabled source_path_used; then
2878
    DIRS="
2879
        doc
2880
        libavcodec
2881
        libavcodec/$arch
2882
        libavdevice
2883
        libavfilter
2884
        libavformat
2885
        libavutil
2886
        libavutil/$arch
2887
        libpostproc
2888
        libswscale
2889
        libswscale/$arch
2890
        tests
2891
        tools
2892
    "
2893
    FILES="
2894
        Makefile
2895
        common.mak
2896
        subdir.mak
2897
        doc/texi2pod.pl
2898
        libavcodec/Makefile
2899
        libavcodec/${arch}/Makefile
2900
        libavdevice/Makefile
2901
        libavfilter/Makefile
2902
        libavformat/Makefile
2903
        libavutil/Makefile
2904
        libpostproc/Makefile
2905
        libswscale/Makefile
2906
    "
2907
    map 'mkdir -p $v' $DIRS;
2908
    map 'test -f "$source_path/$v" && $ln_s "$source_path/$v" $v' $FILES
2909
fi
2910

    
2911
enabled stripping || strip="echo skipping strip"
2912

    
2913
cat > config.mak <<EOF
2914
# Automatically generated by configure - do not modify!
2915
ifndef FFMPEG_CONFIG_MAK
2916
FFMPEG_CONFIG_MAK=1
2917
FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
2918
prefix=$prefix
2919
LIBDIR=\$(DESTDIR)$libdir
2920
SHLIBDIR=\$(DESTDIR)$shlibdir
2921
INCDIR=\$(DESTDIR)$incdir
2922
BINDIR=\$(DESTDIR)$bindir
2923
DATADIR=\$(DESTDIR)$datadir
2924
MANDIR=\$(DESTDIR)$mandir
2925
SRC_PATH="$source_path"
2926
SRC_PATH_BARE=$source_path
2927
BUILD_ROOT="$PWD"
2928
ARCH=$arch
2929
CC=$cc
2930
AS=$as
2931
LD=$ld
2932
DEPCC=$dep_cc
2933
YASM=$yasmexe
2934
YASMDEP=$yasmexe
2935
AR=$ar
2936
RANLIB=$ranlib
2937
CP=cp -p
2938
LN_S=$ln_s
2939
STRIP=$strip
2940
CPPFLAGS=$CPPFLAGS
2941
CFLAGS=$CFLAGS
2942
ASFLAGS=$ASFLAGS
2943
CC_O=$CC_O
2944
LDFLAGS=$LDFLAGS
2945
FFSERVERLDFLAGS=$FFSERVERLDFLAGS
2946
SHFLAGS=$SHFLAGS
2947
YASMFLAGS=$YASMFLAGS
2948
BUILDSUF=$build_suffix
2949
FULLNAME=$FULLNAME
2950
LIBPREF=$LIBPREF
2951
LIBSUF=$LIBSUF
2952
LIBNAME=$LIBNAME
2953
SLIBPREF=$SLIBPREF
2954
SLIBSUF=$SLIBSUF
2955
EXESUF=$EXESUF
2956
EXTRA_VERSION=$extra_version
2957
DEPFLAGS=$DEPFLAGS
2958
CCDEP=$CCDEP
2959
ASDEP=$ASDEP
2960
CC_DEPFLAGS=$CC_DEPFLAGS
2961
AS_DEPFLAGS=$AS_DEPFLAGS
2962
HOSTCC=$host_cc
2963
HOSTCFLAGS=$host_cflags
2964
HOSTEXESUF=$HOSTEXESUF
2965
HOSTLDFLAGS=$host_ldflags
2966
HOSTLIBS=$host_libs
2967
TARGET_EXEC=$target_exec
2968
TARGET_PATH=$target_path
2969
SDL_LIBS=$sdl_libs
2970
SDL_CFLAGS=$sdl_cflags
2971
LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
2972
EXTRALIBS=$extralibs
2973
INSTALL=install
2974
LIBTARGET=${LIBTARGET}
2975
SLIBNAME=${SLIBNAME}
2976
SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
2977
SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
2978
SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
2979
SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
2980
SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}
2981
SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}
2982
SAMPLES=$samples
2983
EOF
2984

    
2985
get_version(){
2986
    name=$1
2987
    file=$source_path/$2
2988
    eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
2989
    eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
2990
    lcname=$(tolower $name)
2991
    eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
2992
    eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
2993
}
2994

    
2995
get_version LIBSWSCALE  libswscale/swscale.h
2996
get_version LIBPOSTPROC libpostproc/postprocess.h
2997
get_version LIBAVCODEC  libavcodec/avcodec.h
2998
get_version LIBAVDEVICE libavdevice/avdevice.h
2999
get_version LIBAVFORMAT libavformat/avformat.h
3000
get_version LIBAVUTIL   libavutil/avutil.h
3001
get_version LIBAVFILTER libavfilter/avfilter.h
3002

    
3003
cat > $TMPH <<EOF
3004
/* Automatically generated by configure - do not modify! */
3005
#ifndef FFMPEG_CONFIG_H
3006
#define FFMPEG_CONFIG_H
3007
#define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
3008
#define FFMPEG_LICENSE "$(c_escape $license)"
3009
#define FFMPEG_DATADIR "$(eval c_escape $datadir)"
3010
#define CC_TYPE "$cc_type"
3011
#define CC_VERSION $cc_version
3012
#define restrict $_restrict
3013
#define ASMALIGN(ZEROBITS) ".p2align " #ZEROBITS "\\n\\t"
3014
#define EXTERN_PREFIX "${extern_prefix}"
3015
#define EXTERN_ASM ${extern_prefix}
3016
EOF
3017

    
3018
test -n "$malloc_prefix" &&
3019
    echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
3020

    
3021
if enabled small || disabled optimizations; then
3022
    echo "#undef  av_always_inline"  >> $TMPH
3023
    echo "#define av_always_inline"  >> $TMPH
3024
fi
3025

    
3026
print_config ARCH_   $TMPH config.mak $ARCH_LIST
3027
print_config HAVE_   $TMPH config.mak $HAVE_LIST
3028
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST       \
3029
                                      $CONFIG_EXTRA      \
3030
                                      $DECODER_LIST      \
3031
                                      $ENCODER_LIST      \
3032
                                      $HWACCEL_LIST      \
3033
                                      $PARSER_LIST       \
3034
                                      $BSF_LIST          \
3035
                                      $DEMUXER_LIST      \
3036
                                      $MUXER_LIST        \
3037
                                      $FILTER_LIST       \
3038
                                      $PROTOCOL_LIST     \
3039
                                      $INDEV_LIST        \
3040
                                      $OUTDEV_LIST       \
3041

    
3042
echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
3043
echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
3044

    
3045
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3046
cp_if_changed $TMPH config.h
3047

    
3048
cat > $TMPH <<EOF
3049
/* Generated by ffconf */
3050
#ifndef AVUTIL_AVCONFIG_H
3051
#define AVUTIL_AVCONFIG_H
3052
EOF
3053

    
3054
print_config AV_HAVE_ $TMPH /dev/null $HAVE_LIST_PUB
3055

    
3056
echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
3057

    
3058
cp_if_changed $TMPH libavutil/avconfig.h
3059

    
3060
test -n "$WARNINGS" && printf "\n$WARNINGS"
3061

    
3062
# build pkg-config files
3063

    
3064
pkgconfig_generate(){
3065
name=$1
3066
shortname=${name#lib}${build_suffix}
3067
comment=$2
3068
version=$3
3069
libs=$4
3070
requires=$5
3071
cat <<EOF > $name/$name.pc
3072
prefix=$prefix
3073
exec_prefix=\${prefix}
3074
libdir=$libdir
3075
includedir=$incdir
3076

    
3077
Name: $name
3078
Description: $comment
3079
Version: $version
3080
Requires: $(enabled shared || echo $requires)
3081
Requires.private: $(enabled shared && echo $requires)
3082
Conflicts:
3083
Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
3084
Libs.private: $(enabled shared && echo $libs)
3085
Cflags: -I\${includedir}
3086
EOF
3087
cat <<EOF > $name/$name-uninstalled.pc
3088
prefix=
3089
exec_prefix=
3090
libdir=\${pcfiledir}
3091
includedir=${source_path}
3092

    
3093
Name: $name
3094
Description: $comment
3095
Version: $version
3096
Requires: $requires
3097
Conflicts:
3098
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
3099
Cflags: -I\${includedir}
3100
EOF
3101
}
3102

    
3103
pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
3104
pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3105
pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
3106
pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3107
enabled avfilter &&
3108
    pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3109
enabled postproc &&
3110
    pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
3111
pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"