Statistics
| Branch: | Revision:

ffmpeg / configure @ a65e687b

History | View | Annotate | Download (87.3 KB)

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

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

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

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

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

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

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

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

    
62
Standard options:
63
  --help                   print this message
64
  --logfile=FILE           log tests and output to FILE [config.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
  --enable-os2threads      use OS/2 threads [no]
95
  --enable-pthreads        use pthreads [no]
96
  --enable-w32threads      use Win32 threads [no]
97
  --enable-x11grab         enable X11 grabbing [no]
98
  --disable-network        disable network support [no]
99
  --disable-mpegaudio-hp   faster (but less accurate) MPEG audio decoding [no]
100
  --enable-gray            enable full grayscale support (slower color)
101
  --disable-swscale-alpha  disable alpha channel support in swscale
102
  --disable-fastdiv        disable table-based division
103
  --enable-small           optimize for size instead of speed
104
  --disable-aandct         disable AAN DCT code
105
  --disable-dct            disable DCT code
106
  --disable-fft            disable FFT code
107
  --disable-golomb         disable Golomb code
108
  --disable-lpc            disable LPC code
109
  --disable-mdct           disable MDCT code
110
  --disable-rdft           disable RDFT code
111
  --disable-vaapi          disable VAAPI code
112
  --disable-vdpau          disable VDPAU code
113
  --disable-dxva2          disable DXVA2 code
114
  --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
115
  --enable-hardcoded-tables use hardcoded tables instead of runtime generation
116
  --enable-memalign-hack   emulate memalign, interferes with memory debuggers
117
  --disable-everything     disable all components listed below
118
  --disable-encoder=NAME   disable encoder NAME
119
  --enable-encoder=NAME    enable encoder NAME
120
  --disable-encoders       disable all encoders
121
  --disable-decoder=NAME   disable decoder NAME
122
  --enable-decoder=NAME    enable decoder NAME
123
  --disable-decoders       disable all decoders
124
  --disable-hwaccel=NAME   disable hwaccel NAME
125
  --enable-hwaccel=NAME    enable hwaccel NAME
126
  --disable-hwaccels       disable all hwaccels
127
  --disable-muxer=NAME     disable muxer NAME
128
  --enable-muxer=NAME      enable muxer NAME
129
  --disable-muxers         disable all muxers
130
  --disable-demuxer=NAME   disable demuxer NAME
131
  --enable-demuxer=NAME    enable demuxer NAME
132
  --disable-demuxers       disable all demuxers
133
  --enable-parser=NAME     enable parser NAME
134
  --disable-parser=NAME    disable parser NAME
135
  --disable-parsers        disable all parsers
136
  --enable-bsf=NAME        enable bitstream filter NAME
137
  --disable-bsf=NAME       disable bitstream filter NAME
138
  --disable-bsfs           disable all bitstream filters
139
  --enable-protocol=NAME   enable protocol NAME
140
  --disable-protocol=NAME  disable protocol NAME
141
  --disable-protocols      disable all protocols
142
  --disable-indev=NAME     disable input device NAME
143
  --disable-outdev=NAME    disable output device NAME
144
  --disable-indevs         disable input devices
145
  --disable-outdevs        disable output devices
146
  --disable-devices        disable all devices
147
  --enable-filter=NAME     enable filter NAME
148
  --disable-filter=NAME    disable filter NAME
149
  --disable-filters        disable all filters
150
  --list-decoders          show all available decoders
151
  --list-encoders          show all available encoders
152
  --list-hwaccels          show all available hardware accelerators
153
  --list-muxers            show all available muxers
154
  --list-demuxers          show all available demuxers
155
  --list-parsers           show all available parsers
156
  --list-protocols         show all available protocols
157
  --list-bsfs              show all available bitstream filters
158
  --list-indevs            show all available input devices
159
  --list-outdevs           show all available output devices
160
  --list-filters           show all available filters
161

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

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

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

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

    
252
quotes='""'
253

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

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

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

    
269
die(){
270
    echolog "$@"
271
    cat <<EOF
272

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

    
291
# Avoid locale weirdness, besides we really just want to translate ASCII.
292
toupper(){
293
    echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
294
}
295

    
296
tolower(){
297
    echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
298
}
299

    
300
c_escape(){
301
    echo "$*" | sed 's/["\\]/\\\0/g'
302
}
303

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

    
310
filter(){
311
    pat=$1
312
    shift
313
    for v; do
314
        eval "case $v in $pat) echo $v ;; esac"
315
    done
316
}
317

    
318
map(){
319
    m=$1
320
    shift
321
    for v; do eval $m; done
322
}
323

    
324
set_all(){
325
    value=$1
326
    shift
327
    for var in $*; do
328
        eval $var=$value
329
    done
330
}
331

    
332
set_weak(){
333
    value=$1
334
    shift
335
    for var; do
336
        eval : \${$var:=$value}
337
    done
338
}
339

    
340
pushvar(){
341
    for var in $*; do
342
        eval level=\${${var}_level:=0}
343
        eval ${var}_${level}="\$$var"
344
        eval ${var}_level=$(($level+1))
345
    done
346
}
347

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

    
359
enable(){
360
    set_all yes $*
361
}
362

    
363
disable(){
364
    set_all no $*
365
}
366

    
367
enable_weak(){
368
    set_weak yes $*
369
}
370

    
371
disable_weak(){
372
    set_weak no $*
373
}
374

    
375
enable_safe(){
376
    for var; do
377
        enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
378
    done
379
}
380

    
381
disable_safe(){
382
    for var; do
383
        disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
384
    done
385
}
386

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

    
400
enable_deep(){
401
    do_enable_deep $*
402
    enable $*
403
}
404

    
405
enable_deep_weak(){
406
    do_enable_deep $*
407
    enable_weak $*
408
}
409

    
410
enabled(){
411
    test "${1#!}" = "$1" && op== || op=!=
412
    eval test "x\$${1#!}" $op "xyes"
413
}
414

    
415
disabled(){
416
    test "${1#!}" = "$1" && op== || op=!=
417
    eval test "x\$${1#!}" $op "xno"
418
}
419

    
420
enabled_all(){
421
    for opt; do
422
        enabled $opt || return 1
423
    done
424
}
425

    
426
disabled_all(){
427
    for opt; do
428
        disabled $opt || return 1
429
    done
430
}
431

    
432
enabled_any(){
433
    for opt; do
434
        enabled $opt && return 0
435
    done
436
}
437

    
438
disabled_any(){
439
    for opt; do
440
        disabled $opt && return 0
441
    done
442
    return 1
443
}
444

    
445
set_default(){
446
    for opt; do
447
        eval : \${$opt:=\$${opt}_default}
448
    done
449
}
450

    
451
is_in(){
452
    value=$1
453
    shift
454
    for var in $*; do
455
        [ $var = $value ] && return 0
456
    done
457
    return 1
458
}
459

    
460
check_deps(){
461
    for cfg; do
462
        cfg="${cfg#!}"
463
        enabled ${cfg}_checking && die "Circular dependency for $cfg."
464
        disabled ${cfg}_checking && continue
465
        enable ${cfg}_checking
466

    
467
        eval dep_all="\$${cfg}_deps"
468
        eval dep_any="\$${cfg}_deps_any"
469
        eval dep_sel="\$${cfg}_select"
470
        eval dep_sgs="\$${cfg}_suggest"
471
        eval dep_ifa="\$${cfg}_if"
472
        eval dep_ifn="\$${cfg}_if_any"
473

    
474
        pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
475
        check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
476
        popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
477

    
478
        [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
479
        [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
480
        enabled_all  $dep_all || disable $cfg
481
        enabled_any  $dep_any || disable $cfg
482
        disabled_any $dep_sel && disable $cfg
483

    
484
        if enabled $cfg; then
485
            eval dep_extralibs="\$${cfg}_extralibs"
486
            test -n "$dep_extralibs" && add_extralibs $dep_extralibs
487
            enable_deep $dep_sel
488
            enable_deep_weak $dep_sgs
489
        fi
490

    
491
        disable ${cfg}_checking
492
    done
493
}
494

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

    
512
flags_saved(){
513
    (: ${SAVE_CFLAGS?}) 2> /dev/null
514
}
515

    
516
save_flags(){
517
    flags_saved && return
518
    SAVE_CFLAGS="$CFLAGS"
519
    SAVE_LDFLAGS="$LDFLAGS"
520
    SAVE_extralibs="$extralibs"
521
}
522

    
523
restore_flags(){
524
    flags_saved || return
525
    CFLAGS="$SAVE_CFLAGS"
526
    LDFLAGS="$SAVE_LDFLAGS"
527
    extralibs="$SAVE_extralibs"
528
    unset SAVE_CFLAGS
529
    unset SAVE_LDFLAGS
530
    unset SAVE_extralibs
531
}
532

    
533
temp_cflags(){
534
    save_flags
535
    CFLAGS="$CFLAGS $*"
536
}
537

    
538
temp_ldflags(){
539
    save_flags
540
    LDFLAGS="$LDFLAGS $*"
541
}
542

    
543
temp_extralibs(){
544
    save_flags
545
    extralibs="$extralibs $*"
546
}
547

    
548
append(){
549
    var=$1
550
    shift
551
    flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
552
    eval "$var=\"\$$var $*\""
553
}
554

    
555
add_cppflags(){
556
    append CPPFLAGS $($filter_cppflags "$@")
557
}
558

    
559
add_cflags(){
560
    append CFLAGS $($filter_cflags "$@")
561
}
562

    
563
add_asflags(){
564
    append ASFLAGS $($filter_asflags "$@")
565
}
566

    
567
add_ldflags(){
568
    append LDFLAGS "$@"
569
}
570

    
571
add_extralibs(){
572
    append extralibs "$@"
573
}
574

    
575
check_cmd(){
576
    log "$@"
577
    "$@" >> $logfile 2>&1
578
}
579

    
580
check_cc(){
581
    log check_cc "$@"
582
    cat > $TMPC
583
    log_file $TMPC
584
    check_cmd $cc $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
585
}
586

    
587
check_cpp(){
588
    log check_cpp "$@"
589
    cat > $TMPC
590
    log_file $TMPC
591
    check_cmd $cc $CPPFLAGS $CFLAGS "$@" -E -o $TMPO $TMPC
592
}
593

    
594
check_as(){
595
    log check_as "$@"
596
    cat > $TMPC
597
    log_file $TMPC
598
    check_cmd $as $CPPFLAGS $ASFLAGS "$@" -c -o $TMPO $TMPC
599
}
600

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

    
612
check_yasm(){
613
    log check_yasm "$@"
614
    echo "$1" > $TMPS
615
    log_file $TMPS
616
    shift 1
617
    check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
618
}
619

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

    
631
check_cppflags(){
632
    log check_cppflags "$@"
633
    set -- $($filter_cppflags "$@")
634
    check_cc "$@" <<EOF && append CPPFLAGS "$@"
635
int x;
636
EOF
637
}
638

    
639
check_cflags(){
640
    log check_cflags "$@"
641
    set -- $($filter_cflags "$@")
642
    check_cc "$@" <<EOF && append CFLAGS "$@"
643
int x;
644
EOF
645
}
646

    
647
test_ldflags(){
648
    log test_ldflags "$@"
649
    check_ld "$@" <<EOF
650
int main(void){ return 0; }
651
EOF
652
}
653

    
654
check_ldflags(){
655
    log check_ldflags "$@"
656
    test_ldflags "$@" && add_ldflags "$@"
657
}
658

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

    
670
check_func(){
671
    log check_func "$@"
672
    func=$1
673
    shift
674
    disable $func
675
    check_ld "$@" <<EOF && enable $func
676
extern int $func();
677
int main(void){ $func(); }
678
EOF
679
}
680

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

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

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

    
725
check_lib(){
726
    log check_lib "$@"
727
    header="$1"
728
    func="$2"
729
    shift 2
730
    temp_extralibs "$@"
731
    check_header $header && check_func $func && add_extralibs "$@"
732
    err=$?
733
    restore_flags
734
    return $err
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_foo_config(){
827
    cfg=$1
828
    pkg=$2
829
    header=$3
830
    func=$4
831
    shift 4
832
    disable $cfg
833
    check_cmd ${pkg}-config --version
834
    err=$?
835
    if test "$err" = 0; then
836
        temp_cflags $(${pkg}-config --cflags)
837
        temp_extralibs $(${pkg}-config --libs)
838
        check_lib "$@" $header $func && enable $cfg
839
    fi
840
    return $err
841
}
842

    
843
check_host_cc(){
844
    log check_host_cc "$@"
845
    cat > $TMPC
846
    log_file $TMPC
847
    check_cmd $host_cc $host_cflags "$@" -c -o $TMPO $TMPC
848
}
849

    
850
check_host_cflags(){
851
    log check_host_cflags "$@"
852
    check_host_cc "$@" <<EOF && append host_cflags "$@"
853
int x;
854
EOF
855
}
856

    
857
apply(){
858
    file=$1
859
    shift
860
    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
861
}
862

    
863
cp_if_changed(){
864
    cmp -s "$1" "$2" &&
865
        echo "$2 is unchanged" ||
866
        cp -f "$1" "$2"
867
}
868

    
869
# CONFIG_LIST contains configurable options, while HAVE_LIST is for
870
# system-dependent things.
871

    
872
COMPONENT_LIST="
873
    bsfs
874
    decoders
875
    demuxers
876
    encoders
877
    filters
878
    hwaccels
879
    indevs
880
    muxers
881
    outdevs
882
    parsers
883
    protocols
884
"
885

    
886
CONFIG_LIST="
887
    $COMPONENT_LIST
888
    aandct
889
    avcodec
890
    avdevice
891
    avfilter
892
    avfilter_lavf
893
    avformat
894
    avisynth
895
    bzlib
896
    dct
897
    doc
898
    dwt
899
    dxva2
900
    fastdiv
901
    ffmpeg
902
    ffplay
903
    ffprobe
904
    ffserver
905
    fft
906
    golomb
907
    gpl
908
    gprof
909
    gray
910
    h264dsp
911
    hardcoded_tables
912
    libdc1394
913
    libdirac
914
    libfaac
915
    libgsm
916
    libmp3lame
917
    libnut
918
    libopencore_amrnb
919
    libopencore_amrwb
920
    libopenjpeg
921
    librtmp
922
    libschroedinger
923
    libspeex
924
    libtheora
925
    libvorbis
926
    libvpx
927
    libx264
928
    libxvid
929
    lpc
930
    lsp
931
    mdct
932
    memalign_hack
933
    mlib
934
    mpegaudio_hp
935
    network
936
    nonfree
937
    pic
938
    postproc
939
    powerpc_perf
940
    rdft
941
    runtime_cpudetect
942
    shared
943
    small
944
    sram
945
    static
946
    swscale
947
    swscale_alpha
948
    vaapi
949
    vdpau
950
    version3
951
    x11grab
952
    zlib
953
"
954

    
955
THREADS_LIST='
956
    os2threads
957
    pthreads
958
    w32threads
959
'
960

    
961
ARCH_LIST='
962
    alpha
963
    arm
964
    avr32
965
    avr32_ap
966
    avr32_uc
967
    bfin
968
    ia64
969
    m68k
970
    mips
971
    mips64
972
    parisc
973
    ppc
974
    ppc64
975
    s390
976
    sh4
977
    sparc
978
    sparc64
979
    tomi
980
    x86
981
    x86_32
982
    x86_64
983
'
984

    
985
ARCH_EXT_LIST='
986
    altivec
987
    amd3dnow
988
    amd3dnowext
989
    armv5te
990
    armv6
991
    armv6t2
992
    armvfp
993
    iwmmxt
994
    mmi
995
    mmx
996
    mmx2
997
    neon
998
    ppc4xx
999
    sse
1000
    ssse3
1001
    vis
1002
'
1003

    
1004
HAVE_LIST_PUB='
1005
    bigendian
1006
'
1007

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

    
1102
# options emitted with CONFIG_ prefix but not available on command line
1103
CONFIG_EXTRA="
1104
    avutil
1105
    gplv3
1106
    lgplv3
1107
"
1108

    
1109
CMDLINE_SELECT="
1110
    $ARCH_EXT_LIST
1111
    $CONFIG_LIST
1112
    $THREADS_LIST
1113
    asm
1114
    cross_compile
1115
    debug
1116
    extra_warnings
1117
    logging
1118
    optimizations
1119
    stripping
1120
    yasm
1121
"
1122

    
1123
PATHS_LIST='
1124
    bindir
1125
    datadir
1126
    incdir
1127
    libdir
1128
    mandir
1129
    prefix
1130
    shlibdir
1131
'
1132

    
1133
CMDLINE_SET="
1134
    $PATHS_LIST
1135
    ar
1136
    arch
1137
    as
1138
    build_suffix
1139
    cc
1140
    cpu
1141
    cross_prefix
1142
    dep_cc
1143
    extra_version
1144
    host_cc
1145
    host_cflags
1146
    host_ldflags
1147
    host_libs
1148
    host_os
1149
    ld
1150
    logfile
1151
    malloc_prefix
1152
    nm
1153
    samples
1154
    source_path
1155
    strip
1156
    sysinclude
1157
    sysroot
1158
    target_exec
1159
    target_os
1160
    target_path
1161
"
1162

    
1163
CMDLINE_APPEND="
1164
    extra_cflags
1165
"
1166

    
1167
# code dependency declarations
1168

    
1169
# architecture extensions
1170

    
1171
armv5te_deps="arm"
1172
armv6_deps="arm"
1173
armv6t2_deps="arm"
1174
armvfp_deps="arm"
1175
iwmmxt_deps="arm"
1176
neon_deps="arm"
1177

    
1178
mmi_deps="mips"
1179

    
1180
altivec_deps="ppc"
1181
ppc4xx_deps="ppc"
1182

    
1183
vis_deps="sparc"
1184

    
1185
x86_64_suggest="cmov fast_cmov"
1186
amd3dnow_deps="mmx"
1187
amd3dnowext_deps="amd3dnow"
1188
mmx_deps="x86"
1189
mmx2_deps="mmx"
1190
sse_deps="mmx"
1191
ssse3_deps="sse"
1192

    
1193
fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1194
fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
1195
fast_unaligned_if_any="armv6 ppc x86"
1196

    
1197
need_memalign="altivec neon sse"
1198
inline_asm_deps="!tms470"
1199

    
1200
symver_if_any="symver_asm_label symver_gnu_asm"
1201

    
1202
# subsystems
1203
mdct_select="fft"
1204
rdft_select="fft"
1205

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

    
1327
vaapi_deps="va_va_h"
1328
vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1329

    
1330
# parsers
1331
h264_parser_select="golomb h264dsp"
1332

    
1333
# bitstream_filters
1334
aac_adtstoasc_bsf_select="aac_parser"
1335

    
1336
# external libraries
1337
libdirac_decoder_deps="libdirac !libschroedinger"
1338
libdirac_encoder_deps="libdirac"
1339
libfaac_encoder_deps="libfaac"
1340
libgsm_decoder_deps="libgsm"
1341
libgsm_encoder_deps="libgsm"
1342
libgsm_ms_decoder_deps="libgsm"
1343
libgsm_ms_encoder_deps="libgsm"
1344
libmp3lame_encoder_deps="libmp3lame"
1345
libopencore_amrnb_decoder_deps="libopencore_amrnb"
1346
libopencore_amrnb_encoder_deps="libopencore_amrnb"
1347
libopencore_amrwb_decoder_deps="libopencore_amrwb"
1348
libopenjpeg_decoder_deps="libopenjpeg"
1349
libschroedinger_decoder_deps="libschroedinger"
1350
libschroedinger_encoder_deps="libschroedinger"
1351
libspeex_decoder_deps="libspeex"
1352
libtheora_encoder_deps="libtheora"
1353
libvorbis_encoder_deps="libvorbis"
1354
libvpx_decoder_deps="libvpx"
1355
libvpx_encoder_deps="libvpx"
1356
libx264_encoder_deps="libx264"
1357
libxvid_encoder_deps="libxvid"
1358

    
1359
# demuxers / muxers
1360
ac3_demuxer_deps="ac3_parser"
1361
asf_stream_muxer_select="asf_muxer"
1362
avisynth_demuxer_deps="avisynth"
1363
dirac_demuxer_deps="dirac_parser"
1364
eac3_demuxer_select="ac3_parser"
1365
ipod_muxer_select="mov_muxer"
1366
libnut_demuxer_deps="libnut"
1367
libnut_muxer_deps="libnut"
1368
matroska_audio_muxer_select="matroska_muxer"
1369
matroska_demuxer_suggest="zlib bzlib"
1370
mov_demuxer_suggest="zlib"
1371
mp3_demuxer_deps="mpegaudio_parser"
1372
mp4_muxer_select="mov_muxer"
1373
mpegtsraw_demuxer_select="mpegts_demuxer"
1374
mxf_d10_muxer_select="mxf_muxer"
1375
ogg_demuxer_select="golomb"
1376
psp_muxer_select="mov_muxer"
1377
rtsp_demuxer_deps="sdp_demuxer"
1378
rtsp_muxer_deps="sdp_demuxer"
1379
rtsp_muxer_select="rtp_muxer"
1380
sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
1381
sdp_demuxer_select="asf_demuxer rm_demuxer"
1382
spdif_muxer_select="aac_parser"
1383
tg2_muxer_select="mov_muxer"
1384
tgp_muxer_select="mov_muxer"
1385
w64_demuxer_deps="wav_demuxer"
1386

    
1387
# indevs / outdevs
1388
alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1389
alsa_indev_extralibs="-lasound"
1390
alsa_outdev_deps="alsa_asoundlib_h"
1391
alsa_outdev_extralibs="-lasound"
1392
bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
1393
dv1394_indev_deps="dv1394 dv_demuxer"
1394
jack_indev_deps="jack_jack_h"
1395
jack_indev_extralibs="-ljack"
1396
libdc1394_indev_deps="libdc1394"
1397
oss_indev_deps_any="soundcard_h sys_soundcard_h"
1398
oss_outdev_deps_any="soundcard_h sys_soundcard_h"
1399
v4l_indev_deps="linux_videodev_h"
1400
v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
1401
vfwcap_indev_deps="capCreateCaptureWindow"
1402
vfwcap_indev_extralibs="-lavicap32"
1403
x11_grab_device_indev_deps="x11grab XShmCreateImage"
1404
x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
1405

    
1406
# protocols
1407
gopher_protocol_deps="network"
1408
http_protocol_deps="network"
1409
http_protocol_select="tcp_protocol"
1410
mmst_protocol_deps="network"
1411
rtmp_protocol_select="tcp_protocol"
1412
rtp_protocol_select="udp_protocol"
1413
tcp_protocol_deps="network"
1414
udp_protocol_deps="network"
1415

    
1416
# filters
1417
movie_filter_deps="avfilter_lavf"
1418
avfilter_lavf_deps="avformat"
1419

    
1420
# libraries
1421
avdevice_deps="avcodec avformat"
1422
avformat_deps="avcodec"
1423

    
1424
# programs
1425
ffmpeg_deps="avcodec avformat swscale"
1426
ffmpeg_select="buffer_filter"
1427
ffplay_deps="avcodec avformat swscale sdl"
1428
ffplay_select="rdft"
1429
ffprobe_deps="avcodec avformat"
1430
ffserver_deps="avformat ffm_muxer rtp_protocol rtsp_demuxer"
1431
ffserver_extralibs='$ldl'
1432

    
1433
doc_deps="texi2html"
1434

    
1435
# default parameters
1436

    
1437
logfile="config.log"
1438

    
1439
# installation paths
1440
prefix_default="/usr/local"
1441
bindir_default='${prefix}/bin'
1442
datadir_default='${prefix}/share/ffmpeg'
1443
incdir_default='${prefix}/include'
1444
libdir_default='${prefix}/lib'
1445
mandir_default='${prefix}/share/man'
1446
shlibdir_default="$libdir_default"
1447

    
1448
# toolchain
1449
ar_default="ar"
1450
cc_default="gcc"
1451
cc_version=\"unknown\"
1452
host_cc_default="gcc"
1453
ln_s="ln -sf"
1454
nm_default="nm"
1455
objformat="elf"
1456
ranlib="ranlib"
1457
strip_default="strip"
1458
yasmexe="yasm"
1459

    
1460
nm_opts='-g'
1461

    
1462
# machine
1463
arch_default=$(uname -m)
1464
cpu="generic"
1465

    
1466
# OS
1467
target_os_default=$(tolower $(uname -s))
1468
host_os=$target_os_default
1469

    
1470
# configurable options
1471
enable avcodec
1472
enable avdevice
1473
enable avfilter
1474
enable avformat
1475
enable avutil
1476
enable asm
1477
enable debug
1478
enable doc
1479
enable fastdiv
1480
enable ffmpeg
1481
enable ffplay
1482
enable ffprobe
1483
enable ffserver
1484
enable mpegaudio_hp
1485
enable network
1486
enable optimizations
1487
enable protocols
1488
enable static
1489
enable stripping
1490
enable swscale
1491
enable swscale_alpha
1492

    
1493
# build settings
1494
SHFLAGS='-shared -Wl,-soname,$$(@F)'
1495
FFSERVERLDFLAGS=-Wl,-E
1496
LIBPREF="lib"
1497
LIBSUF=".a"
1498
FULLNAME='$(NAME)$(BUILDSUF)'
1499
LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
1500
SLIBPREF="lib"
1501
SLIBSUF=".so"
1502
SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
1503
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1504
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
1505
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
1506

    
1507
CC_O='-o $@'
1508

    
1509
host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
1510
host_libs='-lm'
1511

    
1512
target_path='$(CURDIR)'
1513

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

    
1519
# find source path
1520
source_path="$(dirname "$0")"
1521
enable source_path_used
1522
if test -f configure; then
1523
    source_path="$(pwd)"
1524
    disable source_path_used
1525
else
1526
    source_path="$(cd "$source_path"; pwd)"
1527
    echo "$source_path" | grep -q '[[:blank:]]' &&
1528
        die "Out of tree builds are impossible with whitespace in source path."
1529
    test -e "$source_path/config.h" &&
1530
        die "Out of tree builds are impossible with config.h in source dir."
1531
fi
1532

    
1533
for v in "$@"; do
1534
    r=${v#*=}
1535
    l=${v%"$r"}
1536
    r=$(sh_quote "$r")
1537
    FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
1538
done
1539

    
1540
find_things(){
1541
    thing=$1
1542
    pattern=$2
1543
    file=$source_path/$3
1544
    sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
1545
}
1546

    
1547
ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
1548
DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
1549
HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
1550
PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
1551
BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
1552
MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
1553
DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
1554
OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
1555
INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
1556
PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
1557
FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
1558

    
1559
for n in $COMPONENT_LIST; do
1560
    v=$(toupper ${n%s})_LIST
1561
    eval enable \$$v
1562
    eval ${n}_if_any="\$$v"
1563
done
1564

    
1565
enable $ARCH_EXT_LIST
1566

    
1567
die_unknown(){
1568
    echo "Unknown option \"$1\"."
1569
    echo "See $0 --help for available options."
1570
    exit 1
1571
}
1572

    
1573
show_list() {
1574
    suffix=_$1
1575
    shift
1576
    echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
1577
    exit 0
1578
}
1579

    
1580
for opt do
1581
    optval="${opt#*=}"
1582
    case "$opt" in
1583
    --extra-ldflags=*) add_ldflags $optval
1584
    ;;
1585
    --extra-libs=*) add_extralibs $optval
1586
    ;;
1587
    --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
1588
    ;;
1589
    --enable-debug=*) debuglevel="$optval"
1590
    ;;
1591
    --disable-everything)
1592
    map 'eval disable \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
1593
    ;;
1594
    --enable-*=*|--disable-*=*)
1595
    eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
1596
    is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1597
    eval list=\$$(toupper $thing)_LIST
1598
    name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1599
    $action $(filter "$name" $list)
1600
    ;;
1601
    --enable-?*|--disable-?*)
1602
    eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
1603
    if is_in $option $COMPONENT_LIST; then
1604
        test $action = disable && action=unset
1605
        eval $action \$$(toupper ${option%s})_LIST
1606
    elif is_in $option $CMDLINE_SELECT; then
1607
        $action $option
1608
    else
1609
        die_unknown $opt
1610
    fi
1611
    ;;
1612
    --list-*)
1613
        NAME="${opt#--list-}"
1614
        is_in $NAME $COMPONENT_LIST || die_unknown $opt
1615
        NAME=${NAME%s}
1616
        eval show_list $NAME \$$(toupper $NAME)_LIST
1617
    ;;
1618
    --help|-h) show_help
1619
    ;;
1620
    *)
1621
    optname="${opt%%=*}"
1622
    optname="${optname#--}"
1623
    optname=$(echo "$optname" | sed 's/-/_/g')
1624
    if is_in $optname $CMDLINE_SET; then
1625
        eval $optname='$optval'
1626
    elif is_in $optname $CMDLINE_APPEND; then
1627
        append $optname "$optval"
1628
    else
1629
         die_unknown $opt
1630
    fi
1631
    ;;
1632
    esac
1633
done
1634

    
1635
disabled logging && logfile=/dev/null
1636

    
1637
echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
1638
set >> $logfile
1639

    
1640
test -n "$cross_prefix" && enable cross_compile
1641

    
1642
if enabled cross_compile; then
1643
    test -n "$arch" && test -n "$target_os" ||
1644
        die "Must specify target arch and OS when cross-compiling"
1645
fi
1646

    
1647
set_default arch target_os
1648

    
1649
ar_default="${cross_prefix}${ar_default}"
1650
cc_default="${cross_prefix}${cc_default}"
1651
nm_default="${cross_prefix}${nm_default}"
1652
ranlib="${cross_prefix}${ranlib}"
1653
strip_default="${cross_prefix}${strip_default}"
1654

    
1655
sysinclude_default="${sysroot}/usr/include"
1656

    
1657
set_default cc nm strip sysinclude
1658
enabled cross_compile || host_cc_default=$cc
1659
set_default host_cc
1660

    
1661
exesuf() {
1662
    case $1 in
1663
        mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
1664
    esac
1665
}
1666

    
1667
EXESUF=$(exesuf $target_os)
1668
HOSTEXESUF=$(exesuf $host_os)
1669

    
1670
# set temporary file name
1671
: ${TMPDIR:=$TEMPDIR}
1672
: ${TMPDIR:=$TMP}
1673
: ${TMPDIR:=/tmp}
1674

    
1675
if ! check_cmd type mktemp; then
1676
    # simple replacement for missing mktemp
1677
    # NOT SAFE FOR GENERAL USE
1678
    mktemp(){
1679
        echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
1680
    }
1681
fi
1682

    
1683
tmpfile(){
1684
    tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
1685
        (set -C; exec > $tmp) 2>/dev/null ||
1686
        die "Unable to create temporary file in $TMPDIR."
1687
    append TMPFILES $tmp
1688
    eval $1=$tmp
1689
}
1690

    
1691
trap 'rm -f -- $TMPFILES' EXIT
1692
trap exit HUP INT TERM
1693

    
1694
tmpfile TMPC  .c
1695
tmpfile TMPE  $EXESUF
1696
tmpfile TMPH  .h
1697
tmpfile TMPO  .o
1698
tmpfile TMPS  .S
1699
tmpfile TMPV  .ver
1700
tmpfile TMPSH .sh
1701

    
1702
unset -f mktemp
1703

    
1704
# make sure we can execute files in $TMPDIR
1705
cat > $TMPSH 2>> $logfile <<EOF
1706
#! /bin/sh
1707
EOF
1708
chmod +x $TMPSH >> $logfile 2>&1
1709
if ! $TMPSH >> $logfile 2>&1; then
1710
    cat <<EOF
1711
Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
1712
variable to another directory and make sure that it is not mounted noexec.
1713
EOF
1714
    die "Sanity test failed."
1715
fi
1716

    
1717
filter_cflags=echo
1718
filter_cppflags=echo
1719
filter_asflags=echo
1720

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

    
1856
test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
1857

    
1858
: ${as_default:=$cc}
1859
: ${dep_cc_default:=$cc}
1860
: ${ld_default:=$cc}
1861
set_default ar as dep_cc ld
1862

    
1863
test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
1864
test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
1865

    
1866
add_cflags $extra_cflags
1867
add_asflags $extra_cflags
1868

    
1869
if test -n "$sysroot"; then
1870
    case "$cc_type" in
1871
        gcc)
1872
            add_cppflags --sysroot="$sysroot"
1873
            add_ldflags --sysroot="$sysroot"
1874
        ;;
1875
        tms470)
1876
            add_cppflags -I"$sysinclude"
1877
            add_ldflags  --sysroot="$sysroot"
1878
        ;;
1879
        clang)
1880
            add_cppflags -isysroot "$sysroot"
1881
            add_ldflags -isysroot "$sysroot"
1882
        ;;
1883
    esac
1884
fi
1885

    
1886
if test "$cpu" = host; then
1887
    enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
1888

    
1889
    case "$cc_type" in
1890
        gcc)
1891
            check_native(){
1892
                $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
1893
                sed -n "/$1=/{
1894
                            s/.*$1=\\([^ ]*\\).*/\\1/
1895
                            p
1896
                            q
1897
                        }" $TMPE
1898
            }
1899
            cpu=$(check_native -march || check_native -mcpu)
1900
        ;;
1901
    esac
1902

    
1903
    test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
1904
fi
1905

    
1906
# Deal with common $arch aliases
1907
case "$arch" in
1908
    arm*)
1909
        arch="arm"
1910
    ;;
1911
    mips|mipsel|IP*)
1912
        arch="mips"
1913
    ;;
1914
    mips64*)
1915
        arch="mips"
1916
        subarch="mips64"
1917
    ;;
1918
    parisc|hppa)
1919
        arch="parisc"
1920
    ;;
1921
    parisc64|hppa64)
1922
        arch="parisc"
1923
        subarch="parisc64"
1924
    ;;
1925
    "Power Macintosh"|ppc|powerpc)
1926
        arch="ppc"
1927
    ;;
1928
    ppc64|powerpc64)
1929
        arch="ppc"
1930
        subarch="ppc64"
1931
    ;;
1932
    s390|s390x)
1933
        arch="s390"
1934
    ;;
1935
    sh4|sh)
1936
        arch="sh4"
1937
    ;;
1938
    sun4u|sparc64)
1939
        arch="sparc"
1940
        subarch="sparc64"
1941
    ;;
1942
    i[3-6]86|i86pc|BePC|x86_64|amd64)
1943
        arch="x86"
1944
    ;;
1945
esac
1946

    
1947
is_in $arch $ARCH_LIST || echo "WARNING: unknown arch $arch"
1948
enable $arch
1949

    
1950
# Add processor-specific flags
1951
if test "$cpu" = generic; then
1952
    : do nothing
1953
elif enabled ppc; then
1954

    
1955
    case $(tolower $cpu) in
1956
        601|ppc601|powerpc601)
1957
            cpuflags="-mcpu=601"
1958
            disable altivec
1959
        ;;
1960
        603*|ppc603*|powerpc603*)
1961
            cpuflags="-mcpu=603"
1962
            disable altivec
1963
        ;;
1964
        604*|ppc604*|powerpc604*)
1965
            cpuflags="-mcpu=604"
1966
            disable altivec
1967
        ;;
1968
        g3|75*|ppc75*|powerpc75*)
1969
            cpuflags="-mcpu=750 -mpowerpc-gfxopt"
1970
            disable altivec
1971
        ;;
1972
        g4|745*|ppc745*|powerpc745*)
1973
            cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
1974
        ;;
1975
        74*|ppc74*|powerpc74*)
1976
            cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
1977
        ;;
1978
        g5|970|ppc970|powerpc970|power4*)
1979
            cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1980
        ;;
1981
        cell)
1982
            cpuflags="-mcpu=cell"
1983
            enable ldbrx
1984
        ;;
1985
        e500v2)
1986
            cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
1987
            disable altivec
1988
        ;;
1989
        e500)
1990
            cpuflags="-mcpu=8540 -mhard-float"
1991
            disable altivec
1992
        ;;
1993
    esac
1994

    
1995
elif enabled x86; then
1996

    
1997
    case $cpu in
1998
        i[345]86|pentium)
1999
            cpuflags="-march=$cpu"
2000
            disable mmx
2001
        ;;
2002
        # targets that do NOT support conditional mov (cmov)
2003
        pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
2004
            cpuflags="-march=$cpu"
2005
            disable cmov
2006
        ;;
2007
        # targets that do support conditional mov (cmov)
2008
        i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10|barcelona)
2009
            cpuflags="-march=$cpu"
2010
            enable cmov
2011
            enable fast_cmov
2012
        ;;
2013
        # targets that do support conditional mov but on which it's slow
2014
        pentium4|pentium4m|prescott|nocona)
2015
            cpuflags="-march=$cpu"
2016
            enable cmov
2017
            disable fast_cmov
2018
        ;;
2019
    esac
2020

    
2021
elif enabled sparc; then
2022

    
2023
    case $cpu in
2024
        niagara)
2025
            cpuflags="-mcpu=$cpu"
2026
            disable vis
2027
        ;;
2028
        sparc64)
2029
            cpuflags="-mcpu=v9"
2030
        ;;
2031
    esac
2032

    
2033
elif enabled arm; then
2034

    
2035
    case $cpu in
2036
        armv*)
2037
            cpuflags="-march=$cpu"
2038
        ;;
2039
        *)
2040
            cpuflags="-mcpu=$cpu"
2041
        ;;
2042
    esac
2043

    
2044
elif enabled alpha; then
2045

    
2046
    enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
2047

    
2048
elif enabled bfin; then
2049

    
2050
    cpuflags="-mcpu=$cpu"
2051

    
2052
elif enabled mips; then
2053

    
2054
    cpuflags="-march=$cpu"
2055

    
2056
elif enabled avr32; then
2057

    
2058
    case $cpu in
2059
        ap7[02]0[0-2])
2060
            subarch="avr32_ap"
2061
            cpuflags="-mpart=$cpu"
2062
        ;;
2063
        ap)
2064
            subarch="avr32_ap"
2065
            cpuflags="-march=$cpu"
2066
        ;;
2067
        uc3[ab]*)
2068
            subarch="avr32_uc"
2069
            cpuflags="-mcpu=$cpu"
2070
        ;;
2071
        uc)
2072
            subarch="avr32_uc"
2073
            cpuflags="-march=$cpu"
2074
        ;;
2075
    esac
2076

    
2077
fi
2078

    
2079
add_cflags $cpuflags
2080
add_asflags $cpuflags
2081

    
2082
# compiler sanity check
2083
check_exec <<EOF
2084
int main(void){ return 0; }
2085
EOF
2086
if test "$?" != 0; then
2087
    echo "$cc is unable to create an executable file."
2088
    if test -z "$cross_prefix" && ! enabled cross_compile ; then
2089
        echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
2090
        echo "Only do this if you know what cross compiling means."
2091
    fi
2092
    die "C compiler test failed."
2093
fi
2094

    
2095
add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
2096
check_cflags -std=c99
2097
check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
2098
#include <stdlib.h>
2099
EOF
2100
check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
2101
#include <stdlib.h>
2102
EOF
2103

    
2104
check_host_cflags -std=c99
2105

    
2106
case "$arch" in
2107
    alpha|ia64|mips|parisc|sparc)
2108
        spic=$shared
2109
    ;;
2110
    x86)
2111
        subarch="x86_32"
2112
        check_cc <<EOF && subarch="x86_64"
2113
        int test[(int)sizeof(char*) - 7];
2114
EOF
2115
        if test "$subarch" = "x86_64"; then
2116
            spic=$shared
2117
        fi
2118
    ;;
2119
esac
2120

    
2121
enable $subarch
2122
enabled spic && enable pic
2123

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

    
2273
check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
2274

    
2275
set_default $PATHS_LIST
2276

    
2277
add_extralibs $osextralibs
2278

    
2279
# Combine FFLDFLAGS and the LDFLAGS environment variable.
2280
LDFLAGS="$FFLDFLAGS $LDFLAGS"
2281

    
2282
# we need to build at least one lib type
2283
if ! enabled_any static shared; then
2284
    cat <<EOF
2285
At least one library type must be built.
2286
Specify --enable-static to build the static libraries or --enable-shared to
2287
build the shared libraries as well. To only build the shared libraries specify
2288
--disable-static in addition to --enable-shared.
2289
EOF
2290
    exit 1;
2291
fi
2292

    
2293
disabled static && LIBNAME=""
2294

    
2295
die_license_disabled() {
2296
    enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2297
}
2298

    
2299
die_license_disabled gpl libx264
2300
die_license_disabled gpl libxvid
2301
die_license_disabled gpl postproc
2302
die_license_disabled gpl x11grab
2303

    
2304
die_license_disabled nonfree libfaac
2305

    
2306
die_license_disabled version3 libopencore_amrnb
2307
die_license_disabled version3 libopencore_amrwb
2308

    
2309
enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2310

    
2311
check_deps $ARCH_EXT_LIST
2312

    
2313
disabled optimizations || check_cflags -fomit-frame-pointer
2314

    
2315
enable_pic() {
2316
    enable pic
2317
    add_cppflags -DPIC
2318
    add_cflags   -fPIC
2319
    add_asflags  -fPIC
2320
}
2321

    
2322
enabled pic && enable_pic
2323

    
2324
check_cc <<EOF || die "Symbol mangling check failed."
2325
int ff_extern;
2326
EOF
2327
sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
2328
extern_prefix=${sym%%ff_extern*}
2329

    
2330
check_cc <<EOF && enable inline_asm
2331
void foo(void) { __asm__ volatile ("" ::); }
2332
EOF
2333

    
2334
_restrict=
2335
for restrict_keyword in restrict __restrict__ __restrict; do
2336
    check_cc <<EOF && _restrict=$restrict_keyword && break
2337
void foo(char * $restrict_keyword p);
2338
EOF
2339
done
2340

    
2341
check_cc <<EOF && enable attribute_packed
2342
struct { int x; } __attribute__((packed)) x;
2343
EOF
2344

    
2345
check_cc <<EOF && enable attribute_may_alias
2346
union { int x; } __attribute__((may_alias)) x;
2347
EOF
2348

    
2349
check_cc <<EOF || die "endian test failed"
2350
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2351
EOF
2352
od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2353

    
2354
if enabled alpha; then
2355

    
2356
    check_cflags -mieee
2357

    
2358
elif enabled arm; then
2359

    
2360
    check_cflags -marm
2361

    
2362
    check_ld <<EOF && enable vfp_args
2363
__asm__ (".eabi_attribute 28, 1");
2364
int main(void) { return 0; }
2365
EOF
2366

    
2367
    # We have to check if pld is a nop and disable it.
2368
    check_asm pld '"pld [r0]"'
2369

    
2370
    enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2371
    enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
2372
    enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2373
    enabled armvfp  && check_asm armvfp  '"fadds s0, s0, s0"'
2374
    enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
2375
    enabled neon    && check_asm neon    '"vadd.i16 q0, q0, q0"'
2376

    
2377
    enabled_all armv6t2 shared !pic && enable_pic
2378

    
2379
elif enabled mips; then
2380

    
2381
    check_asm loongson '"dmult.g $1, $2, $3"'
2382
    enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
2383

    
2384
elif enabled ppc; then
2385

    
2386
    enable local_aligned_8 local_aligned_16
2387

    
2388
    check_asm dcbzl     '"dcbzl 0, 1"'
2389
    check_asm ppc4xx    '"maclhw r10, r11, r12"'
2390
    check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
2391

    
2392
    # AltiVec flags: The FSF version of GCC differs from the Apple version
2393
    if enabled altivec; then
2394
        check_cflags -maltivec -mabi=altivec &&
2395
        { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2396
        check_cflags -faltivec
2397

    
2398
        # check if our compiler supports Motorola AltiVec C API
2399
        check_cc <<EOF || disable altivec
2400
$inc_altivec_h
2401
int main(void) {
2402
    vector signed int v1, v2, v3;
2403
    v1 = vec_add(v2,v3);
2404
    return 0;
2405
}
2406
EOF
2407

    
2408
        # check if our compiler supports braces for vector declarations
2409
        check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
2410
$inc_altivec_h
2411
int main (void) { (vector int) {1}; return 0; }
2412
EOF
2413
    fi
2414

    
2415
elif enabled sparc; then
2416

    
2417
    enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2418
        add_cflags -mcpu=ultrasparc -mtune=ultrasparc
2419

    
2420
elif enabled x86; then
2421

    
2422
    enable local_aligned_8 local_aligned_16
2423

    
2424
    # check whether EBP is available on x86
2425
    # As 'i' is stored on the stack, this program will crash
2426
    # if the base pointer is used to access it because the
2427
    # base pointer is cleared in the inline assembly code.
2428
    check_exec_crash <<EOF && enable ebp_available
2429
    volatile int i=0;
2430
    __asm__ volatile (
2431
        "xorl %%ebp, %%ebp"
2432
    ::: "%ebp");
2433
    return i;
2434
EOF
2435

    
2436
    # check whether EBX is available on x86
2437
    check_asm ebx_available '""::"b"(0)' &&
2438
        check_asm ebx_available '"":::"%ebx"'
2439

    
2440
    # check whether more than 10 operands are supported
2441
    check_cc <<EOF && enable ten_operands
2442
int main(void) {
2443
    int x=0;
2444
    __asm__ volatile(
2445
        ""
2446
        :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
2447
    );
2448
    return 0;
2449
}
2450
EOF
2451

    
2452
    # check whether binutils is new enough to compile SSSE3/MMX2
2453
    enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
2454
    enabled mmx2  && check_asm mmx2  '"pmaxub %mm0, %mm1"'
2455

    
2456
    check_asm bswap '"bswap %%eax" ::: "%eax"'
2457

    
2458
    YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
2459
    enabled     x86_64        && append YASMFLAGS "-m amd64"
2460
    enabled     pic           && append YASMFLAGS "-DPIC"
2461
    test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
2462
    case "$objformat" in
2463
        elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
2464
    esac
2465
    disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
2466

    
2467
    case "$cpu" in
2468
        athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
2469
            disable fast_clz
2470
        ;;
2471
    esac
2472

    
2473
fi
2474

    
2475
if check_func dlopen; then
2476
    ldl=
2477
elif check_func dlopen -ldl; then
2478
    ldl=-ldl
2479
fi
2480

    
2481
# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2482
check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2483

    
2484
check_func  fork
2485
check_func  getaddrinfo $network_extralibs
2486
check_func  gethrtime
2487
check_func  getrusage
2488
check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
2489
check_func  inet_aton $network_extralibs
2490
check_func  isatty
2491
check_func  ${malloc_prefix}memalign            && enable memalign
2492
check_func  mkstemp
2493
check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
2494
check_func  setrlimit
2495
check_func  strerror_r
2496
check_func_headers io.h setmode
2497
check_func_headers lzo/lzo1x.h lzo1x_999_compress
2498
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
2499
check_func_headers windows.h GetProcessTimes
2500
check_func_headers windows.h VirtualAlloc
2501

    
2502
check_header conio.h
2503
check_header dlfcn.h
2504
check_header dxva2api.h
2505
check_header malloc.h
2506
check_header poll.h
2507
check_header sys/mman.h
2508
check_header sys/resource.h
2509
check_header sys/select.h
2510
check_header termios.h
2511
check_header vdpau/vdpau.h
2512
check_header vdpau/vdpau_x11.h
2513
check_header X11/extensions/XvMClib.h
2514

    
2515
check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex
2516

    
2517
if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
2518
     enabled_any $need_memalign ; then
2519
    die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
2520
fi
2521

    
2522
disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
2523
disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
2524

    
2525
# check for some common methods of building with pthread support
2526
# do this before the optional library checks as some of them require pthreads
2527
if enabled pthreads; then
2528
    if check_func pthread_create; then
2529
        :
2530
    elif check_func pthread_create -pthread; then
2531
        add_cflags -pthread
2532
        add_extralibs -pthread
2533
    elif check_func pthread_create -pthreads; then
2534
        add_cflags -pthreads
2535
        add_extralibs -pthreads
2536
    elif check_func pthread_create -lpthreadGC2; then
2537
        add_extralibs -lpthreadGC2
2538
    elif ! check_lib pthread.h pthread_create -lpthread; then
2539
        die "ERROR: can't find pthreads library"
2540
    fi
2541
fi
2542

    
2543
for thread in $THREADS_LIST; do
2544
    if enabled $thread; then
2545
        test -n "$thread_type" &&
2546
            die "ERROR: Only one thread type must be selected." ||
2547
            thread_type="$thread"
2548
    fi
2549
done
2550

    
2551
check_lib math.h sin -lm
2552
disabled vaapi || check_lib va/va.h vaInitialize -lva
2553

    
2554
check_mathfunc exp2
2555
check_mathfunc exp2f
2556
check_mathfunc llrint
2557
check_mathfunc llrintf
2558
check_mathfunc log2
2559
check_mathfunc log2f
2560
check_mathfunc lrint
2561
check_mathfunc lrintf
2562
check_mathfunc round
2563
check_mathfunc roundf
2564
check_mathfunc truncf
2565

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

    
2592
# libdc1394 check
2593
if enabled libdc1394; then
2594
    { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2595
        enable libdc1394_2; } ||
2596
    { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2597
        enable libdc1394_1; } ||
2598
    die "ERROR: No version of libdc1394 found "
2599
fi
2600

    
2601
SDL_CONFIG="${cross_prefix}sdl-config"
2602
if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
2603
    sdl_cflags=$("${SDL_CONFIG}" --cflags)
2604
    sdl_libs=$("${SDL_CONFIG}" --libs)
2605
    check_func_headers SDL.h SDL_Init $sdl_cflags $sdl_libs &&
2606
    check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
2607
    enable sdl &&
2608
    check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
2609
fi
2610

    
2611
texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
2612

    
2613
if enabled network; then
2614
    check_type "sys/types.h sys/socket.h" socklen_t
2615
    check_type netdb.h "struct addrinfo"
2616
    check_type netinet/in.h "struct ipv6_mreq"
2617
    check_type netinet/in.h "struct sockaddr_in6"
2618
    check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
2619
    check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
2620
    # Prefer arpa/inet.h over winsock2
2621
    if check_header arpa/inet.h ; then
2622
        check_func closesocket
2623
    elif check_header winsock2.h ; then
2624
        check_func_headers winsock2.h closesocket -lws2 && \
2625
            network_extralibs="-lws2" || \
2626
        { check_func_headers winsock2.h closesocket -lws2_32 && \
2627
            network_extralibs="-lws2_32"; }
2628
        check_type ws2tcpip.h socklen_t
2629
        check_type ws2tcpip.h "struct addrinfo"
2630
        check_type ws2tcpip.h "struct ipv6_mreq"
2631
        check_type ws2tcpip.h "struct sockaddr_in6"
2632
        check_type ws2tcpip.h "struct sockaddr_storage"
2633
        check_struct winsock2.h "struct sockaddr" sa_len
2634
    else
2635
        disable network
2636
    fi
2637
fi
2638

    
2639
check_header linux/videodev.h
2640
check_header linux/videodev2.h
2641
check_header sys/videoio.h
2642

    
2643
check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
2644

    
2645
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
2646
{ check_header dev/bktr/ioctl_meteor.h &&
2647
  check_header dev/bktr/ioctl_bt848.h; } ||
2648
{ check_header machine/ioctl_meteor.h &&
2649
  check_header machine/ioctl_bt848.h; } ||
2650
{ check_header dev/video/meteor/ioctl_meteor.h &&
2651
  check_header dev/video/bktr/ioctl_bt848.h; } ||
2652
check_header dev/ic/bt8xx.h
2653

    
2654
check_header sys/soundcard.h
2655
check_header soundcard.h
2656

    
2657
enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
2658

    
2659
enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
2660

    
2661
enabled x11grab                         &&
2662
check_header X11/Xlib.h                 &&
2663
check_header X11/extensions/XShm.h      &&
2664
check_header X11/extensions/Xfixes.h    &&
2665
check_func XOpenDisplay -lX11           &&
2666
check_func XShmCreateImage -lX11 -lXext &&
2667
check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
2668

    
2669
if ! disabled vdpau && enabled vdpau_vdpau_h; then
2670
check_cpp_condition \
2671
    vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
2672
    { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
2673
      disable vdpau; }
2674
fi
2675

    
2676
enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
2677

    
2678
# add some useful compiler flags if supported
2679
check_cflags -Wdeclaration-after-statement
2680
check_cflags -Wall
2681
check_cflags -Wno-switch
2682
check_cflags -Wdisabled-optimization
2683
check_cflags -Wpointer-arith
2684
check_cflags -Wredundant-decls
2685
check_cflags -Wno-pointer-sign
2686
check_cflags -Wcast-qual
2687
check_cflags -Wwrite-strings
2688
check_cflags -Wtype-limits
2689
check_cflags -Wundef
2690
check_cflags -Wmissing-prototypes
2691
enabled extra_warnings && check_cflags -Winline
2692

    
2693
# add some linker flags
2694
check_ldflags -Wl,--warn-common
2695
check_ldflags -Wl,--as-needed
2696
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'
2697
check_ldflags -Wl,-Bsymbolic
2698

    
2699
echo "X{};" > $TMPV
2700
if test_ldflags -Wl,--version-script,$TMPV; then
2701
    append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
2702
    check_cc <<EOF && enable symver_asm_label
2703
void ff_foo(void) __asm__ ("av_foo@VERSION");
2704
void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
2705
EOF
2706
    check_cc <<EOF && enable symver_gnu_asm
2707
__asm__(".symver ff_foo,av_foo@VERSION");
2708
void ff_foo(void) {}
2709
EOF
2710
fi
2711

    
2712
if enabled small; then
2713
    add_cflags $size_cflags
2714
    optimizations="small"
2715
elif enabled optimizations; then
2716
    add_cflags $speed_cflags
2717
else
2718
    add_cflags $noopt_cflags
2719
fi
2720
check_cflags -fno-math-errno
2721
check_cflags -fno-signed-zeros
2722

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

    
2760
if enabled gprof; then
2761
    add_cflags  -p
2762
    add_ldflags -p
2763
fi
2764

    
2765
enabled_any $THREADS_LIST      && enable threads
2766

    
2767
check_deps $CONFIG_LIST       \
2768
           $CONFIG_EXTRA      \
2769
           $HAVE_LIST         \
2770
           $DECODER_LIST      \
2771
           $ENCODER_LIST      \
2772
           $HWACCEL_LIST      \
2773
           $PARSER_LIST       \
2774
           $BSF_LIST          \
2775
           $DEMUXER_LIST      \
2776
           $MUXER_LIST        \
2777
           $FILTER_LIST       \
2778
           $INDEV_LIST        \
2779
           $OUTDEV_LIST       \
2780
           $PROTOCOL_LIST     \
2781

    
2782
enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
2783

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

    
2865
for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
2866
    echo "Enabled ${type}s:"
2867
    eval list=\$$(toupper $type)_LIST
2868
    for part in $list; do
2869
        enabled $part && echo ${part%_*}
2870
    done | sort | pr -3 -t
2871
    echo
2872
done
2873

    
2874
license="LGPL version 2.1 or later"
2875
if enabled nonfree; then
2876
    license="nonfree and unredistributable"
2877
elif enabled gplv3; then
2878
    license="GPL version 3 or later"
2879
elif enabled lgplv3; then
2880
    license="LGPL version 3 or later"
2881
elif enabled gpl; then
2882
    license="GPL version 2 or later"
2883
fi
2884

    
2885
echo "License: $license"
2886

    
2887
echo "Creating config.mak and config.h..."
2888

    
2889
# build tree in object directory if source path is different from current one
2890
if enabled source_path_used; then
2891
    DIRS="
2892
        doc
2893
        libavcodec
2894
        libavcodec/$arch
2895
        libavdevice
2896
        libavfilter
2897
        libavformat
2898
        libavutil
2899
        libavutil/$arch
2900
        libpostproc
2901
        libswscale
2902
        libswscale/$arch
2903
        tests
2904
        tools
2905
    "
2906
    FILES="
2907
        Makefile
2908
        common.mak
2909
        subdir.mak
2910
        doc/texi2pod.pl
2911
        libavcodec/Makefile
2912
        libavcodec/${arch}/Makefile
2913
        libavdevice/Makefile
2914
        libavfilter/Makefile
2915
        libavformat/Makefile
2916
        libavutil/Makefile
2917
        libpostproc/Makefile
2918
        libswscale/Makefile
2919
    "
2920
    map 'mkdir -p $v' $DIRS;
2921
    map 'test -f "$source_path/$v" && $ln_s "$source_path/$v" $v' $FILES
2922
fi
2923

    
2924
enabled stripping || strip="echo skipping strip"
2925

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

    
2998
get_version(){
2999
    name=$1
3000
    file=$source_path/$2
3001
    eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
3002
    eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
3003
    lcname=$(tolower $name)
3004
    eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
3005
    eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
3006
}
3007

    
3008
get_version LIBSWSCALE  libswscale/swscale.h
3009
get_version LIBPOSTPROC libpostproc/postprocess.h
3010
get_version LIBAVCODEC  libavcodec/avcodec.h
3011
get_version LIBAVDEVICE libavdevice/avdevice.h
3012
get_version LIBAVFORMAT libavformat/avformat.h
3013
get_version LIBAVUTIL   libavutil/avutil.h
3014
get_version LIBAVFILTER libavfilter/avfilter.h
3015

    
3016
cat > $TMPH <<EOF
3017
/* Automatically generated by configure - do not modify! */
3018
#ifndef FFMPEG_CONFIG_H
3019
#define FFMPEG_CONFIG_H
3020
#define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
3021
#define FFMPEG_LICENSE "$(c_escape $license)"
3022
#define FFMPEG_DATADIR "$(eval c_escape $datadir)"
3023
#define CC_TYPE "$cc_type"
3024
#define CC_VERSION $cc_version
3025
#define restrict $_restrict
3026
#define ASMALIGN(ZEROBITS) ".p2align " #ZEROBITS "\\n\\t"
3027
#define EXTERN_PREFIX "${extern_prefix}"
3028
#define EXTERN_ASM ${extern_prefix}
3029
EOF
3030

    
3031
test -n "$malloc_prefix" &&
3032
    echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
3033

    
3034
if enabled small || disabled optimizations; then
3035
    echo "#undef  av_always_inline"  >> $TMPH
3036
    echo "#define av_always_inline"  >> $TMPH
3037
fi
3038

    
3039
print_config ARCH_   $TMPH config.mak $ARCH_LIST
3040
print_config HAVE_   $TMPH config.mak $HAVE_LIST
3041
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST       \
3042
                                      $CONFIG_EXTRA      \
3043
                                      $DECODER_LIST      \
3044
                                      $ENCODER_LIST      \
3045
                                      $HWACCEL_LIST      \
3046
                                      $PARSER_LIST       \
3047
                                      $BSF_LIST          \
3048
                                      $DEMUXER_LIST      \
3049
                                      $MUXER_LIST        \
3050
                                      $FILTER_LIST       \
3051
                                      $PROTOCOL_LIST     \
3052
                                      $INDEV_LIST        \
3053
                                      $OUTDEV_LIST       \
3054

    
3055
echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
3056
echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
3057

    
3058
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3059
cp_if_changed $TMPH config.h
3060

    
3061
cat > $TMPH <<EOF
3062
/* Generated by ffconf */
3063
#ifndef AVUTIL_AVCONFIG_H
3064
#define AVUTIL_AVCONFIG_H
3065
EOF
3066

    
3067
print_config AV_HAVE_ $TMPH /dev/null $HAVE_LIST_PUB
3068

    
3069
echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
3070

    
3071
cp_if_changed $TMPH libavutil/avconfig.h
3072

    
3073
# build pkg-config files
3074

    
3075
pkgconfig_generate(){
3076
name=$1
3077
shortname=${name#lib}${build_suffix}
3078
comment=$2
3079
version=$3
3080
libs=$4
3081
requires=$5
3082
cat <<EOF > $name/$name.pc
3083
prefix=$prefix
3084
exec_prefix=\${prefix}
3085
libdir=$libdir
3086
includedir=$incdir
3087

    
3088
Name: $name
3089
Description: $comment
3090
Version: $version
3091
Requires: $(enabled shared || echo $requires)
3092
Requires.private: $(enabled shared && echo $requires)
3093
Conflicts:
3094
Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
3095
Libs.private: $(enabled shared && echo $libs)
3096
Cflags: -I\${includedir}
3097
EOF
3098
cat <<EOF > $name/$name-uninstalled.pc
3099
prefix=
3100
exec_prefix=
3101
libdir=\${pcfiledir}
3102
includedir=${source_path}
3103

    
3104
Name: $name
3105
Description: $comment
3106
Version: $version
3107
Requires: $requires
3108
Conflicts:
3109
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
3110
Cflags: -I\${includedir}
3111
EOF
3112
}
3113

    
3114
pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
3115
pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3116
pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
3117
pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3118
enabled avfilter &&
3119
    pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3120
enabled postproc &&
3121
    pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
3122
pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"