Statistics
| Branch: | Revision:

ffmpeg / configure @ fbe98aee

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

    
161
External library support:
162
  --enable-avisynth        enable reading of AVISynth script files [no]
163
  --enable-bzlib           enable bzlib [autodetect]
164
  --enable-frei0r          enable frei0r video filtering
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-libopencv       enable video filtering via libopencv [no]
168
  --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394
169
                           and libraw1394 [no]
170
  --enable-libdirac        enable Dirac support via libdirac [no]
171
  --enable-libfaac         enable FAAC support via libfaac [no]
172
  --enable-libfreetype     enable libfreetype [no]
173
  --enable-libgsm          enable GSM support via libgsm [no]
174
  --enable-libmp3lame      enable MP3 encoding via libmp3lame [no]
175
  --enable-libnut          enable NUT (de)muxing via libnut,
176
                           native (de)muxer exists [no]
177
  --enable-libopenjpeg     enable JPEG 2000 decoding via OpenJPEG [no]
178
  --enable-librtmp         enable RTMP[E] support via librtmp [no]
179
  --enable-libschroedinger enable Dirac support via libschroedinger [no]
180
  --enable-libspeex        enable Speex decoding via libspeex [no]
181
  --enable-libtheora       enable Theora encoding via libtheora [no]
182
  --enable-libvorbis       enable Vorbis encoding via libvorbis,
183
                           native implementation exists [no]
184
  --enable-libvpx          enable VP8 support via libvpx [no]
185
  --enable-libx264         enable H.264 encoding via x264 [no]
186
  --enable-libxavs         enable AVS encoding via xavs [no]
187
  --enable-libxvid         enable Xvid encoding via xvidcore,
188
                           native MPEG-4/Xvid encoder exists [no]
189
  --enable-mlib            enable Sun medialib [no]
190
  --enable-zlib            enable zlib [autodetect]
191

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

    
241
Developer options (useful when working on FFmpeg itself):
242
  --disable-debug          disable debugging symbols
243
  --enable-debug=LEVEL     set the debug level [$debuglevel]
244
  --disable-optimizations  disable compiler optimizations
245
  --enable-extra-warnings  enable more compiler warnings
246
  --disable-stripping      disable stripping of executables and shared libraries
247
  --samples=PATH           location of test samples for FATE, if not set use
248
                           \$FATE_SAMPLES at make invocation time.
249

    
250
NOTE: Object files are built at the place where configure is launched.
251
EOF
252
  exit 0
253
}
254

    
255
quotes='""'
256

    
257
log(){
258
    echo "$@" >> $logfile
259
}
260

    
261
log_file(){
262
    log BEGIN $1
263
    pr -n -t $1 >> $logfile
264
    log END $1
265
}
266

    
267
echolog(){
268
    log "$@"
269
    echo "$@"
270
}
271

    
272
warn(){
273
    log "WARNING: $*"
274
    WARNINGS="${WARNINGS}WARNING: $*\n"
275
}
276

    
277
die(){
278
    echolog "$@"
279
    cat <<EOF
280

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

    
299
# Avoid locale weirdness, besides we really just want to translate ASCII.
300
toupper(){
301
    echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
302
}
303

    
304
tolower(){
305
    echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
306
}
307

    
308
c_escape(){
309
    echo "$*" | sed 's/["\\]/\\\0/g'
310
}
311

    
312
sh_quote(){
313
    v=$(echo "$1" | sed "s/'/'\\\\''/g")
314
    test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
315
    echo "$v"
316
}
317

    
318
cleanws(){
319
    echo "$@" | sed 's/^ *//;s/  */ /g;s/ *$//'
320
}
321

    
322
filter(){
323
    pat=$1
324
    shift
325
    for v; do
326
        eval "case $v in $pat) echo $v ;; esac"
327
    done
328
}
329

    
330
filter_out(){
331
    pat=$1
332
    shift
333
    for v; do
334
        eval "case $v in $pat) ;; *) echo $v ;; esac"
335
    done
336
}
337

    
338
map(){
339
    m=$1
340
    shift
341
    for v; do eval $m; done
342
}
343

    
344
set_all(){
345
    value=$1
346
    shift
347
    for var in $*; do
348
        eval $var=$value
349
    done
350
}
351

    
352
set_weak(){
353
    value=$1
354
    shift
355
    for var; do
356
        eval : \${$var:=$value}
357
    done
358
}
359

    
360
pushvar(){
361
    for var in $*; do
362
        eval level=\${${var}_level:=0}
363
        eval ${var}_${level}="\$$var"
364
        eval ${var}_level=$(($level+1))
365
    done
366
}
367

    
368
popvar(){
369
    for var in $*; do
370
        eval level=\${${var}_level:-0}
371
        test $level = 0 && continue
372
        eval level=$(($level-1))
373
        eval $var="\${${var}_${level}}"
374
        eval ${var}_level=$level
375
        eval unset ${var}_${level}
376
    done
377
}
378

    
379
enable(){
380
    set_all yes $*
381
}
382

    
383
disable(){
384
    set_all no $*
385
}
386

    
387
enable_weak(){
388
    set_weak yes $*
389
}
390

    
391
disable_weak(){
392
    set_weak no $*
393
}
394

    
395
enable_safe(){
396
    for var; do
397
        enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
398
    done
399
}
400

    
401
disable_safe(){
402
    for var; do
403
        disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
404
    done
405
}
406

    
407
do_enable_deep(){
408
    for var; do
409
        enabled $var && continue
410
        eval sel="\$${var}_select"
411
        eval sgs="\$${var}_suggest"
412
        pushvar var sgs
413
        enable_deep $sel
414
        popvar sgs
415
        enable_deep_weak $sgs
416
        popvar var
417
    done
418
}
419

    
420
enable_deep(){
421
    do_enable_deep $*
422
    enable $*
423
}
424

    
425
enable_deep_weak(){
426
    do_enable_deep $*
427
    enable_weak $*
428
}
429

    
430
enabled(){
431
    test "${1#!}" = "$1" && op== || op=!=
432
    eval test "x\$${1#!}" $op "xyes"
433
}
434

    
435
disabled(){
436
    test "${1#!}" = "$1" && op== || op=!=
437
    eval test "x\$${1#!}" $op "xno"
438
}
439

    
440
enabled_all(){
441
    for opt; do
442
        enabled $opt || return 1
443
    done
444
}
445

    
446
disabled_all(){
447
    for opt; do
448
        disabled $opt || return 1
449
    done
450
}
451

    
452
enabled_any(){
453
    for opt; do
454
        enabled $opt && return 0
455
    done
456
}
457

    
458
disabled_any(){
459
    for opt; do
460
        disabled $opt && return 0
461
    done
462
    return 1
463
}
464

    
465
set_default(){
466
    for opt; do
467
        eval : \${$opt:=\$${opt}_default}
468
    done
469
}
470

    
471
is_in(){
472
    value=$1
473
    shift
474
    for var in $*; do
475
        [ $var = $value ] && return 0
476
    done
477
    return 1
478
}
479

    
480
check_deps(){
481
    for cfg; do
482
        cfg="${cfg#!}"
483
        enabled ${cfg}_checking && die "Circular dependency for $cfg."
484
        disabled ${cfg}_checking && continue
485
        enable ${cfg}_checking
486

    
487
        eval dep_all="\$${cfg}_deps"
488
        eval dep_any="\$${cfg}_deps_any"
489
        eval dep_sel="\$${cfg}_select"
490
        eval dep_sgs="\$${cfg}_suggest"
491
        eval dep_ifa="\$${cfg}_if"
492
        eval dep_ifn="\$${cfg}_if_any"
493

    
494
        pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
495
        check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
496
        popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
497

    
498
        [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
499
        [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
500
        enabled_all  $dep_all || disable $cfg
501
        enabled_any  $dep_any || disable $cfg
502
        disabled_any $dep_sel && disable $cfg
503

    
504
        if enabled $cfg; then
505
            eval dep_extralibs="\$${cfg}_extralibs"
506
            test -n "$dep_extralibs" && add_extralibs $dep_extralibs
507
            enable_deep $dep_sel
508
            enable_deep_weak $dep_sgs
509
        fi
510

    
511
        disable ${cfg}_checking
512
    done
513
}
514

    
515
print_config_h(){
516
    enabled $1 && v=1 || v=0
517
    echo "#define $2 $v"
518
}
519

    
520
print_config_mak(){
521
    enabled $1 && v= || v=!
522
    echo "$v$2=yes"
523
}
524

    
525
print_config_asm(){
526
    enabled $1 && echo "%define $2"
527
}
528

    
529
print_config(){
530
    pfx=$1
531
    files=$2
532
    shift 2
533
    for cfg; do
534
        ucname="$(toupper $cfg)"
535
        for f in $files; do
536
            "print_config_${f##*.}" $cfg ${pfx}${ucname} >>$f
537
        done
538
    done
539
}
540

    
541
print_enabled(){
542
    test "$1" = -n && end=" " && shift || end="\n"
543
    suf=$1
544
    shift
545
    for v; do
546
        enabled $v && printf "%s$end" ${v%$suf};
547
    done
548
}
549

    
550
append(){
551
    var=$1
552
    shift
553
    eval "$var=\"\$$var $*\""
554
}
555

    
556
prepend(){
557
    var=$1
558
    shift
559
    eval "$var=\"$* \$$var\""
560
}
561

    
562
add_cppflags(){
563
    append CPPFLAGS $($filter_cppflags "$@")
564
}
565

    
566
add_cflags(){
567
    append CFLAGS $($filter_cflags "$@")
568
}
569

    
570
add_asflags(){
571
    append ASFLAGS $($filter_asflags "$@")
572
}
573

    
574
add_ldflags(){
575
    append LDFLAGS "$@"
576
}
577

    
578
add_extralibs(){
579
    prepend extralibs "$@"
580
}
581

    
582
check_cmd(){
583
    log "$@"
584
    "$@" >> $logfile 2>&1
585
}
586

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

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

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

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

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

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

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

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

    
654
test_ldflags(){
655
    log test_ldflags "$@"
656
    check_ld "$@" <<EOF
657
int main(void){ return 0; }
658
EOF
659
}
660

    
661
check_ldflags(){
662
    log check_ldflags "$@"
663
    test_ldflags "$@" && add_ldflags "$@"
664
}
665

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

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

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

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

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

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

    
740
check_lib2(){
741
    log check_lib2 "$@"
742
    headers="$1"
743
    func="$2"
744
    shift 2
745
    check_func_headers "$headers" $func "$@" && add_extralibs "$@"
746
}
747

    
748
check_exec(){
749
    check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
750
}
751

    
752
check_exec_crash(){
753
    code=$(cat)
754

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

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

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

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

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

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

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

    
836
check_host_cflags(){
837
    log check_host_cflags "$@"
838
    check_host_cc "$@" <<EOF && append host_cflags "$@"
839
int x;
840
EOF
841
}
842

    
843
apply(){
844
    file=$1
845
    shift
846
    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
847
}
848

    
849
cp_if_changed(){
850
    cmp -s "$1" "$2" &&
851
        echo "$2 is unchanged" ||
852
        cp -f "$1" "$2"
853
}
854

    
855
# CONFIG_LIST contains configurable options, while HAVE_LIST is for
856
# system-dependent things.
857

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

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

    
947
THREADS_LIST='
948
    pthreads
949
    w32threads
950
'
951

    
952
ARCH_LIST='
953
    alpha
954
    arm
955
    avr32
956
    avr32_ap
957
    avr32_uc
958
    bfin
959
    ia64
960
    m68k
961
    mips
962
    mips64
963
    parisc
964
    ppc
965
    ppc64
966
    s390
967
    sh4
968
    sparc
969
    sparc64
970
    tomi
971
    x86
972
    x86_32
973
    x86_64
974
'
975

    
976
ARCH_EXT_LIST='
977
    altivec
978
    amd3dnow
979
    amd3dnowext
980
    armv5te
981
    armv6
982
    armv6t2
983
    armvfp
984
    avx
985
    iwmmxt
986
    mmi
987
    mmx
988
    mmx2
989
    neon
990
    ppc4xx
991
    sse
992
    ssse3
993
    vis
994
'
995

    
996
HAVE_LIST_PUB='
997
    bigendian
998
    fast_unaligned
999
'
1000

    
1001
HAVE_LIST="
1002
    $ARCH_EXT_LIST
1003
    $HAVE_LIST_PUB
1004
    $THREADS_LIST
1005
    aligned_stack
1006
    alsa_asoundlib_h
1007
    altivec_h
1008
    arpa_inet_h
1009
    attribute_may_alias
1010
    attribute_packed
1011
    bswap
1012
    closesocket
1013
    cmov
1014
    conio_h
1015
    dcbzl
1016
    dev_bktr_ioctl_bt848_h
1017
    dev_bktr_ioctl_meteor_h
1018
    dev_ic_bt8xx_h
1019
    dev_video_meteor_ioctl_meteor_h
1020
    dev_video_bktr_ioctl_bt848_h
1021
    dlfcn_h
1022
    dlopen
1023
    dos_paths
1024
    ebp_available
1025
    ebx_available
1026
    exp2
1027
    exp2f
1028
    fast_64bit
1029
    fast_clz
1030
    fast_cmov
1031
    fcntl
1032
    fork
1033
    getaddrinfo
1034
    gethrtime
1035
    GetProcessMemoryInfo
1036
    GetProcessTimes
1037
    getrusage
1038
    gnu_as
1039
    struct_rusage_ru_maxrss
1040
    ibm_asm
1041
    inet_aton
1042
    inline_asm
1043
    isatty
1044
    ldbrx
1045
    libdc1394_1
1046
    libdc1394_2
1047
    llrint
1048
    llrintf
1049
    local_aligned_16
1050
    local_aligned_8
1051
    localtime_r
1052
    log2
1053
    log2f
1054
    loongson
1055
    lrint
1056
    lrintf
1057
    lzo1x_999_compress
1058
    machine_ioctl_bt848_h
1059
    machine_ioctl_meteor_h
1060
    malloc_h
1061
    MapViewOfFile
1062
    memalign
1063
    mkstemp
1064
    mmap
1065
    pld
1066
    posix_memalign
1067
    round
1068
    roundf
1069
    sdl
1070
    sdl_video_size
1071
    setmode
1072
    socklen_t
1073
    soundcard_h
1074
    poll_h
1075
    setrlimit
1076
    strerror_r
1077
    strtok_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
    xmm_clobbers
1100
    yasm
1101
"
1102

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

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

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

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

    
1165
CMDLINE_APPEND="
1166
    extra_cflags
1167
"
1168

    
1169
# code dependency declarations
1170

    
1171
# architecture extensions
1172

    
1173
armv5te_deps="arm"
1174
armv6_deps="arm"
1175
armv6t2_deps="arm"
1176
armvfp_deps="arm"
1177
iwmmxt_deps="arm"
1178
neon_deps="arm"
1179

    
1180
mmi_deps="mips"
1181

    
1182
altivec_deps="ppc"
1183
ppc4xx_deps="ppc"
1184

    
1185
vis_deps="sparc"
1186

    
1187
x86_64_suggest="cmov fast_cmov"
1188
amd3dnow_deps="mmx"
1189
amd3dnowext_deps="amd3dnow"
1190
mmx_deps="x86"
1191
mmx2_deps="mmx"
1192
sse_deps="mmx"
1193
ssse3_deps="sse"
1194
avx_deps="ssse3"
1195

    
1196
aligned_stack_if_any="ppc x86"
1197
fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1198
fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
1199
fast_unaligned_if_any="armv6 ppc x86"
1200

    
1201
need_memalign="altivec neon sse"
1202
inline_asm_deps="!tms470"
1203

    
1204
symver_if_any="symver_asm_label symver_gnu_asm"
1205

    
1206
# subsystems
1207
dct_select="rdft"
1208
mdct_select="fft"
1209
rdft_select="fft"
1210

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

    
1350
crystalhd_deps="libcrystalhd_libcrystalhd_if_h"
1351
vaapi_deps="va_va_h"
1352
vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1353

    
1354
# parsers
1355
h264_parser_select="golomb h264dsp h264pred"
1356

    
1357
# external libraries
1358
libdirac_decoder_deps="libdirac !libschroedinger"
1359
libdirac_encoder_deps="libdirac"
1360
libfaac_encoder_deps="libfaac"
1361
libgsm_decoder_deps="libgsm"
1362
libgsm_encoder_deps="libgsm"
1363
libgsm_ms_decoder_deps="libgsm"
1364
libgsm_ms_encoder_deps="libgsm"
1365
libmp3lame_encoder_deps="libmp3lame"
1366
libopencore_amrnb_decoder_deps="libopencore_amrnb"
1367
libopencore_amrnb_encoder_deps="libopencore_amrnb"
1368
libopencore_amrwb_decoder_deps="libopencore_amrwb"
1369
libopenjpeg_decoder_deps="libopenjpeg"
1370
libschroedinger_decoder_deps="libschroedinger"
1371
libschroedinger_encoder_deps="libschroedinger"
1372
libspeex_decoder_deps="libspeex"
1373
libtheora_encoder_deps="libtheora"
1374
libvorbis_encoder_deps="libvorbis"
1375
libvpx_decoder_deps="libvpx"
1376
libvpx_encoder_deps="libvpx"
1377
libx264_encoder_deps="libx264"
1378
libxavs_encoder_deps="libxavs"
1379
libxvid_encoder_deps="libxvid"
1380

    
1381
# demuxers / muxers
1382
ac3_demuxer_select="ac3_parser"
1383
asf_stream_muxer_select="asf_muxer"
1384
avisynth_demuxer_deps="avisynth"
1385
dirac_demuxer_select="dirac_parser"
1386
eac3_demuxer_select="ac3_parser"
1387
flac_demuxer_select="flac_parser"
1388
ipod_muxer_select="mov_muxer"
1389
libnut_demuxer_deps="libnut"
1390
libnut_muxer_deps="libnut"
1391
matroska_audio_muxer_select="matroska_muxer"
1392
matroska_demuxer_suggest="zlib bzlib"
1393
mov_demuxer_suggest="zlib"
1394
mp3_demuxer_select="mpegaudio_parser"
1395
mp4_muxer_select="mov_muxer"
1396
mpegtsraw_demuxer_select="mpegts_demuxer"
1397
mxf_d10_muxer_select="mxf_muxer"
1398
ogg_demuxer_select="golomb"
1399
psp_muxer_select="mov_muxer"
1400
rtp_demuxer_select="sdp_demuxer"
1401
rtpdec_select="asf_demuxer rm_demuxer rtp_protocol mpegts_demuxer mov_demuxer"
1402
rtsp_demuxer_select="http_protocol rtpdec"
1403
rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol"
1404
sap_demuxer_select="sdp_demuxer"
1405
sap_muxer_select="rtp_muxer rtp_protocol"
1406
sdp_demuxer_select="rtpdec"
1407
spdif_muxer_select="aac_parser"
1408
tg2_muxer_select="mov_muxer"
1409
tgp_muxer_select="mov_muxer"
1410
w64_demuxer_deps="wav_demuxer"
1411

    
1412
# indevs / outdevs
1413
alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1414
alsa_outdev_deps="alsa_asoundlib_h"
1415
bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
1416
dv1394_indev_deps="dv1394 dv_demuxer"
1417
fbdev_indev_deps="linux_fb_h"
1418
jack_indev_deps="jack_jack_h"
1419
libdc1394_indev_deps="libdc1394"
1420
oss_indev_deps_any="soundcard_h sys_soundcard_h"
1421
oss_outdev_deps_any="soundcard_h sys_soundcard_h"
1422
v4l_indev_deps="linux_videodev_h"
1423
v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
1424
vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
1425
vfwcap_indev_extralibs="-lavicap32"
1426
x11_grab_device_indev_deps="x11grab XShmCreateImage"
1427
x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
1428

    
1429
# protocols
1430
gopher_protocol_deps="network"
1431
http_protocol_deps="network"
1432
http_protocol_select="tcp_protocol"
1433
mmsh_protocol_select="http_protocol"
1434
mmst_protocol_deps="network"
1435
rtmp_protocol_select="tcp_protocol"
1436
rtp_protocol_select="udp_protocol"
1437
tcp_protocol_deps="network"
1438
udp_protocol_deps="network"
1439

    
1440
# filters
1441
blackframe_filter_deps="gpl"
1442
cropdetect_filter_deps="gpl"
1443
drawtext_filter_deps="libfreetype"
1444
frei0r_filter_deps="frei0r dlopen strtok_r"
1445
frei0r_src_filter_deps="frei0r dlopen strtok_r"
1446
hqdn3d_filter_deps="gpl"
1447
mp_filter_deps="gpl"
1448
scale_filter_deps="swscale"
1449
ocv_filter_deps="libopencv"
1450
yadif_filter_deps="gpl"
1451

    
1452
# libraries
1453
avdevice_deps="avcodec avformat"
1454
avformat_deps="avcodec"
1455

    
1456
# programs
1457
ffmpeg_deps="avcodec avformat swscale"
1458
ffmpeg_select="buffer_filter"
1459
ffplay_deps="avcodec avformat swscale sdl"
1460
ffplay_select="rdft"
1461
ffprobe_deps="avcodec avformat"
1462
ffserver_deps="avformat ffm_muxer rtp_protocol rtsp_demuxer"
1463
ffserver_extralibs='$ldl'
1464

    
1465
doc_deps="texi2html"
1466

    
1467
# tests
1468

    
1469
test_deps(){
1470
    suf1=$1
1471
    suf2=$2
1472
    shift 2
1473
    for v; do
1474
        dep=${v%=*}
1475
        tests=${v#*=}
1476
        for name in ${tests}; do
1477
            eval ${name}_test_deps="'${dep}$suf1 ${dep}$suf2'"
1478
        done
1479
    done
1480
}
1481

    
1482
set_ne_test_deps(){
1483
    eval ${1}_be_test_deps="bigendian"
1484
    eval ${1}_le_test_deps="!bigendian"
1485
}
1486

    
1487
test_deps _encoder _decoder                                             \
1488
    adpcm_g726=g726                                                     \
1489
    adpcm_ima_qt                                                        \
1490
    adpcm_ima_wav                                                       \
1491
    adpcm_ms                                                            \
1492
    adpcm_swf                                                           \
1493
    adpcm_yamaha=adpcm_yam                                              \
1494
    alac                                                                \
1495
    asv1                                                                \
1496
    asv2                                                                \
1497
    bmp                                                                 \
1498
    dnxhd="dnxhd_1080i dnxhd_720p dnxhd_720p_rd"                        \
1499
    dvvideo="dv dv50"                                                   \
1500
    ffv1                                                                \
1501
    flac                                                                \
1502
    flashsv                                                             \
1503
    flv                                                                 \
1504
    gif                                                                 \
1505
    h261                                                                \
1506
    h263="h263 h263p"                                                   \
1507
    huffyuv                                                             \
1508
    jpegls                                                              \
1509
    mjpeg="jpg mjpeg ljpeg"                                             \
1510
    mp2                                                                 \
1511
    mpeg1video="mpeg mpeg1b"                                            \
1512
    mpeg2video="mpeg2 mpeg2thread"                                      \
1513
    mpeg4="mpeg4 mpeg4adv mpeg4nr mpeg4thread error rc"                 \
1514
    msmpeg4v3=msmpeg4                                                   \
1515
    msmpeg4v2                                                           \
1516
    pbm=pbmpipe                                                         \
1517
    pcx                                                                 \
1518
    pgm="pgm pgmpipe"                                                   \
1519
    png                                                                 \
1520
    ppm="ppm ppmpipe"                                                   \
1521
    rawvideo="rgb yuv"                                                  \
1522
    roq                                                                 \
1523
    rv10                                                                \
1524
    rv20                                                                \
1525
    sgi                                                                 \
1526
    snow="snow snowll"                                                  \
1527
    svq1                                                                \
1528
    targa=tga                                                           \
1529
    tiff                                                                \
1530
    wmav1                                                               \
1531
    wmav2                                                               \
1532
    wmv1                                                                \
1533
    wmv2                                                                \
1534

    
1535
test_deps _muxer _demuxer                                               \
1536
    aiff                                                                \
1537
    pcm_alaw=alaw                                                       \
1538
    asf                                                                 \
1539
    au                                                                  \
1540
    avi                                                                 \
1541
    dv=dv_fmt                                                           \
1542
    ffm                                                                 \
1543
    flv=flv_fmt                                                         \
1544
    gxf                                                                 \
1545
    matroska=mkv                                                        \
1546
    mmf                                                                 \
1547
    mov                                                                 \
1548
    pcm_mulaw=mulaw                                                     \
1549
    mxf                                                                 \
1550
    nut                                                                 \
1551
    ogg                                                                 \
1552
    rawvideo=pixfmt                                                     \
1553
    rm                                                                  \
1554
    swf                                                                 \
1555
    mpegts=ts                                                           \
1556
    voc                                                                 \
1557
    wav                                                                 \
1558
    yuv4mpegpipe=yuv4mpeg                                               \
1559

    
1560
ac3_fixed_test_deps="ac3_fixed_encoder ac3_decoder rm_muxer rm_demuxer"
1561
mpg_test_deps="mpeg1system_muxer mpegps_demuxer"
1562

    
1563
set_ne_test_deps pixdesc
1564
set_ne_test_deps pixfmts_copy
1565
set_ne_test_deps pixfmts_crop
1566
set_ne_test_deps pixfmts_hflip
1567
set_ne_test_deps pixfmts_null
1568
set_ne_test_deps pixfmts_pad
1569
set_ne_test_deps pixfmts_scale
1570
set_ne_test_deps pixfmts_vflip
1571

    
1572
# default parameters
1573

    
1574
logfile="config.log"
1575

    
1576
# installation paths
1577
prefix_default="/usr/local"
1578
bindir_default='${prefix}/bin'
1579
datadir_default='${prefix}/share/ffmpeg'
1580
incdir_default='${prefix}/include'
1581
libdir_default='${prefix}/lib'
1582
mandir_default='${prefix}/share/man'
1583
shlibdir_default="$libdir_default"
1584

    
1585
# toolchain
1586
ar_default="ar"
1587
cc_default="gcc"
1588
cc_version=\"unknown\"
1589
host_cc_default="gcc"
1590
ln_s="ln -sf"
1591
nm_default="nm"
1592
objformat="elf"
1593
ranlib="ranlib"
1594
strip_default="strip"
1595
yasmexe="yasm"
1596
nogas=":"
1597

    
1598
nm_opts='-g'
1599

    
1600
# machine
1601
arch_default=$(uname -m)
1602
cpu="generic"
1603

    
1604
# OS
1605
target_os_default=$(tolower $(uname -s))
1606
host_os=$target_os_default
1607

    
1608
# configurable options
1609
enable avcodec
1610
enable avdevice
1611
enable avfilter
1612
enable avformat
1613
enable avutil
1614
enable asm
1615
enable debug
1616
enable doc
1617
enable fastdiv
1618
enable ffmpeg
1619
enable ffplay
1620
enable ffprobe
1621
enable ffserver
1622
enable mpegaudio_hp
1623
enable network
1624
enable optimizations
1625
enable protocols
1626
enable static
1627
enable stripping
1628
enable swscale
1629
enable swscale_alpha
1630

    
1631
# build settings
1632
SHFLAGS='-shared -Wl,-soname,$$(@F)'
1633
FFSERVERLDFLAGS=-Wl,-E
1634
LIBPREF="lib"
1635
LIBSUF=".a"
1636
FULLNAME='$(NAME)$(BUILDSUF)'
1637
LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
1638
SLIBPREF="lib"
1639
SLIBSUF=".so"
1640
SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
1641
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1642
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
1643
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
1644

    
1645
CC_O='-o $@'
1646

    
1647
host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
1648
host_libs='-lm'
1649

    
1650
target_path='$(CURDIR)'
1651

    
1652
# since the object filename is not given with the -MM flag, the compiler
1653
# is only able to print the basename, and we must add the path ourselves
1654
DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
1655
DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
1656

    
1657
# find source path
1658
source_path="$(dirname "$0")"
1659
enable source_path_used
1660
if test -f configure; then
1661
    source_path="$(pwd)"
1662
    disable source_path_used
1663
else
1664
    source_path="$(cd "$source_path"; pwd)"
1665
    echo "$source_path" | grep -q '[[:blank:]]' &&
1666
        die "Out of tree builds are impossible with whitespace in source path."
1667
    test -e "$source_path/config.h" &&
1668
        die "Out of tree builds are impossible with config.h in source dir."
1669
fi
1670

    
1671
for v in "$@"; do
1672
    r=${v#*=}
1673
    l=${v%"$r"}
1674
    r=$(sh_quote "$r")
1675
    FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
1676
done
1677

    
1678
find_things(){
1679
    thing=$1
1680
    pattern=$2
1681
    file=$source_path/$3
1682
    sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
1683
}
1684

    
1685
ENCODER_LIST=$(find_things  encoder  ENC      libavcodec/allcodecs.c)
1686
DECODER_LIST=$(find_things  decoder  DEC      libavcodec/allcodecs.c)
1687
HWACCEL_LIST=$(find_things  hwaccel  HWACCEL  libavcodec/allcodecs.c)
1688
PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
1689
BSF_LIST=$(find_things      bsf      BSF      libavcodec/allcodecs.c)
1690
MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
1691
DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
1692
OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
1693
INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
1694
PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
1695
FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
1696

    
1697
find_tests(){
1698
    map "echo ${2}\${v}_test" $(ls "$source_path"/tests/ref/$1 | grep -v '[^-a-z0-9_]')
1699
}
1700

    
1701
ACODEC_TESTS=$(find_tests acodec)
1702
VCODEC_TESTS=$(find_tests vsynth1)
1703
LAVF_TESTS=$(find_tests lavf)
1704
LAVFI_TESTS=$(find_tests lavfi)
1705
SEEK_TESTS=$(find_tests seek seek_)
1706

    
1707
pcm_test_deps=$(map 'echo ${v%_*}_decoder $v' $(filter pcm_* $ENCODER_LIST))
1708

    
1709
for n in $COMPONENT_LIST; do
1710
    v=$(toupper ${n%s})_LIST
1711
    eval enable \$$v
1712
    eval ${n}_if_any="\$$v"
1713
done
1714

    
1715
enable $ARCH_EXT_LIST $ACODEC_TESTS $VCODEC_TESTS $LAVF_TESTS $LAVFI_TESTS $SEEK_TESTS
1716

    
1717
die_unknown(){
1718
    echo "Unknown option \"$1\"."
1719
    echo "See $0 --help for available options."
1720
    exit 1
1721
}
1722

    
1723
show_list() {
1724
    suffix=_$1
1725
    shift
1726
    echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
1727
    exit 0
1728
}
1729

    
1730
for opt do
1731
    optval="${opt#*=}"
1732
    case "$opt" in
1733
    --extra-ldflags=*) add_ldflags $optval
1734
    ;;
1735
    --extra-libs=*) add_extralibs $optval
1736
    ;;
1737
    --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
1738
    ;;
1739
    --enable-debug=*) debuglevel="$optval"
1740
    ;;
1741
    --disable-everything)
1742
    map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
1743
    ;;
1744
    --enable-*=*|--disable-*=*)
1745
    eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
1746
    is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
1747
    eval list=\$$(toupper $thing)_LIST
1748
    name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
1749
    $action $(filter "$name" $list)
1750
    ;;
1751
    --enable-?*|--disable-?*)
1752
    eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
1753
    if is_in $option $COMPONENT_LIST; then
1754
        test $action = disable && action=unset
1755
        eval $action \$$(toupper ${option%s})_LIST
1756
    elif is_in $option $CMDLINE_SELECT; then
1757
        $action $option
1758
    else
1759
        die_unknown $opt
1760
    fi
1761
    ;;
1762
    --list-*)
1763
        NAME="${opt#--list-}"
1764
        is_in $NAME $COMPONENT_LIST || die_unknown $opt
1765
        NAME=${NAME%s}
1766
        eval show_list $NAME \$$(toupper $NAME)_LIST
1767
    ;;
1768
    --help|-h) show_help
1769
    ;;
1770
    *)
1771
    optname="${opt%%=*}"
1772
    optname="${optname#--}"
1773
    optname=$(echo "$optname" | sed 's/-/_/g')
1774
    if is_in $optname $CMDLINE_SET; then
1775
        eval $optname='$optval'
1776
    elif is_in $optname $CMDLINE_APPEND; then
1777
        append $optname "$optval"
1778
    else
1779
         die_unknown $opt
1780
    fi
1781
    ;;
1782
    esac
1783
done
1784

    
1785
disabled logging && logfile=/dev/null
1786

    
1787
echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
1788
set >> $logfile
1789

    
1790
test -n "$cross_prefix" && enable cross_compile
1791

    
1792
if enabled cross_compile; then
1793
    test -n "$arch" && test -n "$target_os" ||
1794
        die "Must specify target arch and OS when cross-compiling"
1795
fi
1796

    
1797
set_default arch target_os
1798

    
1799
ar_default="${cross_prefix}${ar_default}"
1800
cc_default="${cross_prefix}${cc_default}"
1801
nm_default="${cross_prefix}${nm_default}"
1802
ranlib="${cross_prefix}${ranlib}"
1803
strip_default="${cross_prefix}${strip_default}"
1804

    
1805
sysinclude_default="${sysroot}/usr/include"
1806

    
1807
set_default cc nm strip sysinclude
1808
enabled cross_compile || host_cc_default=$cc
1809
set_default host_cc
1810

    
1811
exesuf() {
1812
    case $1 in
1813
        mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
1814
    esac
1815
}
1816

    
1817
EXESUF=$(exesuf $target_os)
1818
HOSTEXESUF=$(exesuf $host_os)
1819

    
1820
# set temporary file name
1821
: ${TMPDIR:=$TEMPDIR}
1822
: ${TMPDIR:=$TMP}
1823
: ${TMPDIR:=/tmp}
1824

    
1825
if ! check_cmd mktemp -u XXXXXX; then
1826
    # simple replacement for missing mktemp
1827
    # NOT SAFE FOR GENERAL USE
1828
    mktemp(){
1829
        echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
1830
    }
1831
fi
1832

    
1833
tmpfile(){
1834
    tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
1835
        (set -C; exec > $tmp) 2>/dev/null ||
1836
        die "Unable to create temporary file in $TMPDIR."
1837
    append TMPFILES $tmp
1838
    eval $1=$tmp
1839
}
1840

    
1841
trap 'rm -f -- $TMPFILES' EXIT
1842

    
1843
tmpfile TMPC  .c
1844
tmpfile TMPE  $EXESUF
1845
tmpfile TMPH  .h
1846
tmpfile TMPO  .o
1847
tmpfile TMPS  .S
1848
tmpfile TMPV  .ver
1849
tmpfile TMPSH .sh
1850
tmpfile TMPASM .asm
1851

    
1852
unset -f mktemp
1853

    
1854
chmod +x $TMPE
1855

    
1856
# make sure we can execute files in $TMPDIR
1857
cat > $TMPSH 2>> $logfile <<EOF
1858
#! /bin/sh
1859
EOF
1860
chmod +x $TMPSH >> $logfile 2>&1
1861
if ! $TMPSH >> $logfile 2>&1; then
1862
    cat <<EOF
1863
Unable to create and execute files in $TMPDIR.  Set the TMPDIR environment
1864
variable to another directory and make sure that it is not mounted noexec.
1865
EOF
1866
    die "Sanity test failed."
1867
fi
1868

    
1869
filter_cflags=echo
1870
filter_cppflags=echo
1871
filter_asflags=echo
1872

    
1873
if   $cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
1874
    cc_type=llvm_gcc
1875
    cc_version=__VERSION__
1876
    gcc_extra_ver=$(expr "$($cc --version | head -n1)" : '.*\((.*)\)')
1877
    cc_ident="llvm-gcc $($cc -dumpversion) $gcc_extra_ver"
1878
    CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1879
    AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1880
    speed_cflags='-O3'
1881
    size_cflags='-Os'
1882
elif $cc -v 2>&1 | grep -qi ^gcc; then
1883
    cc_type=gcc
1884
    cc_version=__VERSION__
1885
    gcc_version=$($cc --version | head -n1)
1886
    gcc_basever=$($cc -dumpversion)
1887
    gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
1888
    gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
1889
    cc_ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
1890
    if ! $cc -dumpversion | grep -q '^2\.'; then
1891
        CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1892
        AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
1893
    fi
1894
    speed_cflags='-O3'
1895
    size_cflags='-Os'
1896
elif $cc --version 2>/dev/null | grep -q Intel; then
1897
    cc_type=icc
1898
    cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
1899
    cc_ident=$($cc --version | head -n1)
1900
    icc_version=$($cc -dumpversion)
1901
    CC_DEPFLAGS='-MMD'
1902
    AS_DEPFLAGS='-MMD'
1903
    speed_cflags='-O3'
1904
    size_cflags='-Os'
1905
    noopt_cflags='-O1'
1906
elif $cc -v 2>&1 | grep -q xlc; then
1907
    cc_type=xlc
1908
    cc_version="AV_STRINGIFY(__IBMC__)"
1909
    cc_ident=$($cc -qversion 2>/dev/null | head -n1)
1910
    speed_cflags='-O5'
1911
    size_cflags='-O5 -qcompact'
1912
elif $cc -V 2>/dev/null | grep -q Compaq; then
1913
    cc_type=ccc
1914
    cc_version="AV_STRINGIFY(__DECC_VER)"
1915
    cc_ident=$($cc -V | head -n1 | cut -d' ' -f1-3)
1916
    DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
1917
    debuglevel=3
1918
    add_ldflags -Wl,-z,now # calls to libots crash without this
1919
    speed_cflags='-fast'
1920
    size_cflags='-O1'
1921
elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
1922
    test -d "$sysroot" || die "No valid sysroot specified."
1923
    cc_type=armcc
1924
    cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
1925
    cc_ident=$($cc --vsn | head -n1)
1926
    armcc_conf="$PWD/armcc.conf"
1927
    $cc --arm_linux_configure                 \
1928
        --arm_linux_config_file="$armcc_conf" \
1929
        --configure_sysroot="$sysroot"        \
1930
        --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
1931
        die "Error creating armcc configuration file."
1932
    $cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
1933
    cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
1934
    as_default="${cross_prefix}gcc"
1935
    CC_DEPFLAGS='-MMD'
1936
    AS_DEPFLAGS='-MMD'
1937
    speed_cflags='-O3'
1938
    size_cflags='-Os'
1939
    filter_asflags="filter_out -W${armcc_opt}*"
1940
elif $cc -version 2>/dev/null | grep -q TMS470; then
1941
    cc_type=tms470
1942
    cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
1943
    cc_ident=$($cc -version | head -n1 | tr -s ' ')
1944
    cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
1945
    CC_O='-fr=$(@D)'
1946
    as_default="${cross_prefix}gcc"
1947
    ld_default="${cross_prefix}gcc"
1948
    TMPO=$(basename $TMPC .c).o
1949
    append TMPFILES $TMPO
1950
    add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
1951
    CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
1952
    AS_DEPFLAGS='-MMD'
1953
    speed_cflags='-O3 -mf=5'
1954
    size_cflags='-O3 -mf=2'
1955
    filter_cflags=tms470_flags
1956
    tms470_flags(){
1957
        for flag; do
1958
            case $flag in
1959
                -march=*|-mcpu=*)
1960
                    case "${flag#*=}" in
1961
                        armv7-a|cortex-a*)      echo -mv=7a8 ;;
1962
                        armv7-r|cortex-r*)      echo -mv=7r4 ;;
1963
                        armv7-m|cortex-m*)      echo -mv=7m3 ;;
1964
                        armv6*|arm11*)          echo -mv=6   ;;
1965
                        armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
1966
                                                echo -mv=5e  ;;
1967
                        armv4*|arm7*|arm9[24]*) echo -mv=4   ;;
1968
                    esac
1969
                    ;;
1970
                -mfpu=neon)     echo --float_support=vfpv3 --neon ;;
1971
                -mfpu=vfp)      echo --float_support=vfpv2        ;;
1972
                -mfpu=vfpv3)    echo --float_support=vfpv3        ;;
1973
                -msoft-float)   echo --float_support=vfplib       ;;
1974
                -O[0-3]|-mf=*)  echo $flag                        ;;
1975
                -g)             echo -g -mn                       ;;
1976
                -pds=*)         echo $flag                        ;;
1977
            esac
1978
        done
1979
    }
1980
elif $cc -v 2>&1 | grep -q clang; then
1981
    cc_type=clang
1982
    $cc -dM -E $TMPC | grep -q __clang_version__ &&
1983
        cc_version=__clang_version__ || cc_version=__VERSION__
1984
    cc_ident=$($cc --version | head -n1)
1985
    CC_DEPFLAGS='-MMD'
1986
    AS_DEPFLAGS='-MMD'
1987
    speed_cflags='-O3'
1988
    size_cflags='-Os'
1989
elif $cc -V 2>&1 | grep -q Sun; then
1990
    cc_type=suncc
1991
    cc_version="AV_STRINGIFY(__SUNPRO_C)"
1992
    cc_ident=$($cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
1993
    DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
1994
    DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
1995
    speed_cflags='-O5'
1996
    size_cflags='-O5 -xspace'
1997
    filter_cflags=suncc_flags
1998
    suncc_flags(){
1999
        for flag; do
2000
            case $flag in
2001
                -march=*|-mcpu=*)
2002
                    case "${flag#*=}" in
2003
                        native)                   echo -xtarget=native       ;;
2004
                        v9|niagara)               echo -xarch=sparc          ;;
2005
                        ultrasparc)               echo -xarch=sparcvis       ;;
2006
                        ultrasparc3|niagara2)     echo -xarch=sparcvis2      ;;
2007
                        i586|pentium)             echo -xchip=pentium        ;;
2008
                        i686|pentiumpro|pentium2) echo -xtarget=pentium_pro  ;;
2009
                        pentium3*|c3-2)           echo -xtarget=pentium3     ;;
2010
                        pentium-m)          echo -xarch=sse2 -xchip=pentium3 ;;
2011
                        pentium4*)          echo -xtarget=pentium4           ;;
2012
                        prescott|nocona)    echo -xarch=sse3 -xchip=pentium4 ;;
2013
                        *-sse3)             echo -xarch=sse3                 ;;
2014
                        core2)              echo -xarch=ssse3 -xchip=core2   ;;
2015
                        amdfam10|barcelona)       echo -xarch=sse4_1         ;;
2016
                        athlon-4|athlon-[mx]p)    echo -xarch=ssea           ;;
2017
                        k8|opteron|athlon64|athlon-fx)
2018
                                                  echo -xarch=sse2a          ;;
2019
                        athlon*)                  echo -xarch=pentium_proa   ;;
2020
                    esac
2021
                    ;;
2022
                -std=c99)             echo -xc99              ;;
2023
                -fomit-frame-pointer) echo -xregs=frameptr    ;;
2024
                -fPIC)                echo -KPIC -xcode=pic32 ;;
2025
                -W*,*)                echo $flag              ;;
2026
                -f*-*|-W*)                                    ;;
2027
                *)                    echo $flag              ;;
2028
            esac
2029
        done
2030
    }
2031
elif $cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
2032
    cc_type=pathscale
2033
    cc_version=__PATHSCALE__
2034
    cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
2035
    CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2036
    AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2037
    speed_cflags='-O2'
2038
    size_cflags='-Os'
2039
elif $cc -v 2>&1 | grep -q Open64; then
2040
    cc_type=open64
2041
    cc_version=__OPEN64__
2042
    cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
2043
    CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2044
    AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
2045
    speed_cflags='-O2'
2046
    size_cflags='-Os'
2047
fi
2048

    
2049
test -n "$cc_type" && enable $cc_type ||
2050
    warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
2051

    
2052
: ${as_default:=$cc}
2053
: ${dep_cc_default:=$cc}
2054
: ${ld_default:=$cc}
2055
set_default ar as dep_cc ld
2056

    
2057
test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
2058
test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
2059

    
2060
add_cflags $extra_cflags
2061
add_asflags $extra_cflags
2062

    
2063
if test -n "$sysroot"; then
2064
    case "$cc_type" in
2065
        gcc|llvm_gcc|clang)
2066
            add_cppflags --sysroot="$sysroot"
2067
            add_ldflags --sysroot="$sysroot"
2068
        ;;
2069
        tms470)
2070
            add_cppflags -I"$sysinclude"
2071
            add_ldflags  --sysroot="$sysroot"
2072
        ;;
2073
    esac
2074
fi
2075

    
2076
if test "$cpu" = host; then
2077
    enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
2078

    
2079
    case "$cc_type" in
2080
        gcc|llvm_gcc)
2081
            check_native(){
2082
                $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
2083
                sed -n "/$1=/{
2084
                            s/.*$1=\\([^ ]*\\).*/\\1/
2085
                            p
2086
                            q
2087
                        }" $TMPE
2088
            }
2089
            cpu=$(check_native -march || check_native -mcpu)
2090
        ;;
2091
    esac
2092

    
2093
    test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
2094
fi
2095

    
2096
# Deal with common $arch aliases
2097
case "$arch" in
2098
    arm*)
2099
        arch="arm"
2100
    ;;
2101
    mips|mipsel|IP*)
2102
        arch="mips"
2103
    ;;
2104
    mips64*)
2105
        arch="mips"
2106
        subarch="mips64"
2107
    ;;
2108
    parisc|hppa)
2109
        arch="parisc"
2110
    ;;
2111
    parisc64|hppa64)
2112
        arch="parisc"
2113
        subarch="parisc64"
2114
    ;;
2115
    "Power Macintosh"|ppc|powerpc)
2116
        arch="ppc"
2117
    ;;
2118
    ppc64|powerpc64)
2119
        arch="ppc"
2120
        subarch="ppc64"
2121
    ;;
2122
    s390|s390x)
2123
        arch="s390"
2124
    ;;
2125
    sh4|sh)
2126
        arch="sh4"
2127
    ;;
2128
    sun4u|sparc64)
2129
        arch="sparc"
2130
        subarch="sparc64"
2131
    ;;
2132
    i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64)
2133
        arch="x86"
2134
    ;;
2135
esac
2136

    
2137
is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
2138
enable $arch
2139

    
2140
# Add processor-specific flags
2141
if test "$cpu" = generic; then
2142
    : do nothing
2143
elif enabled ppc; then
2144

    
2145
    case $(tolower $cpu) in
2146
        601|ppc601|powerpc601)
2147
            cpuflags="-mcpu=601"
2148
            disable altivec
2149
        ;;
2150
        603*|ppc603*|powerpc603*)
2151
            cpuflags="-mcpu=603"
2152
            disable altivec
2153
        ;;
2154
        604*|ppc604*|powerpc604*)
2155
            cpuflags="-mcpu=604"
2156
            disable altivec
2157
        ;;
2158
        g3|75*|ppc75*|powerpc75*)
2159
            cpuflags="-mcpu=750 -mpowerpc-gfxopt"
2160
            disable altivec
2161
        ;;
2162
        g4|745*|ppc745*|powerpc745*)
2163
            cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
2164
        ;;
2165
        74*|ppc74*|powerpc74*)
2166
            cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
2167
        ;;
2168
        g5|970|ppc970|powerpc970|power4*)
2169
            cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
2170
        ;;
2171
        cell)
2172
            cpuflags="-mcpu=cell"
2173
            enable ldbrx
2174
        ;;
2175
        e500v2)
2176
            cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
2177
            disable altivec
2178
        ;;
2179
        e500)
2180
            cpuflags="-mcpu=8540 -mhard-float"
2181
            disable altivec
2182
        ;;
2183
    esac
2184

    
2185
elif enabled x86; then
2186

    
2187
    case $cpu in
2188
        i[345]86|pentium)
2189
            cpuflags="-march=$cpu"
2190
            disable mmx
2191
        ;;
2192
        # targets that do NOT support conditional mov (cmov)
2193
        pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
2194
            cpuflags="-march=$cpu"
2195
            disable cmov
2196
        ;;
2197
        # targets that do support conditional mov (cmov)
2198
        i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10|barcelona|atom)
2199
            cpuflags="-march=$cpu"
2200
            enable cmov
2201
            enable fast_cmov
2202
        ;;
2203
        # targets that do support conditional mov but on which it's slow
2204
        pentium4|pentium4m|prescott|nocona)
2205
            cpuflags="-march=$cpu"
2206
            enable cmov
2207
            disable fast_cmov
2208
        ;;
2209
    esac
2210

    
2211
elif enabled sparc; then
2212

    
2213
    case $cpu in
2214
        niagara)
2215
            cpuflags="-mcpu=$cpu"
2216
            disable vis
2217
        ;;
2218
        sparc64)
2219
            cpuflags="-mcpu=v9"
2220
        ;;
2221
    esac
2222

    
2223
elif enabled arm; then
2224

    
2225
    case $cpu in
2226
        armv*)
2227
            cpuflags="-march=$cpu"
2228
            subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
2229
        ;;
2230
        *)
2231
            cpuflags="-mcpu=$cpu"
2232
            case $cpu in
2233
                cortex-a*)                               subarch=armv7a  ;;
2234
                cortex-r*)                               subarch=armv7r  ;;
2235
                cortex-m*)                               subarch=armv7m  ;;
2236
                arm11*)                                  subarch=armv6   ;;
2237
                arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
2238
                armv4*|arm7*|arm9[24]*)                  subarch=armv4   ;;
2239
            esac
2240
        ;;
2241
    esac
2242

    
2243
elif enabled alpha; then
2244

    
2245
    enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
2246

    
2247
elif enabled bfin; then
2248

    
2249
    cpuflags="-mcpu=$cpu"
2250

    
2251
elif enabled mips; then
2252

    
2253
    cpuflags="-march=$cpu"
2254

    
2255
elif enabled avr32; then
2256

    
2257
    case $cpu in
2258
        ap7[02]0[0-2])
2259
            subarch="avr32_ap"
2260
            cpuflags="-mpart=$cpu"
2261
        ;;
2262
        ap)
2263
            subarch="avr32_ap"
2264
            cpuflags="-march=$cpu"
2265
        ;;
2266
        uc3[ab]*)
2267
            subarch="avr32_uc"
2268
            cpuflags="-mcpu=$cpu"
2269
        ;;
2270
        uc)
2271
            subarch="avr32_uc"
2272
            cpuflags="-march=$cpu"
2273
        ;;
2274
    esac
2275

    
2276
fi
2277

    
2278
add_cflags $cpuflags
2279
add_asflags $cpuflags
2280

    
2281
# compiler sanity check
2282
check_exec <<EOF
2283
int main(void){ return 0; }
2284
EOF
2285
if test "$?" != 0; then
2286
    echo "$cc is unable to create an executable file."
2287
    if test -z "$cross_prefix" && ! enabled cross_compile ; then
2288
        echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
2289
        echo "Only do this if you know what cross compiling means."
2290
    fi
2291
    die "C compiler test failed."
2292
fi
2293

    
2294
add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
2295
check_cflags -std=c99
2296
check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
2297
#include <stdlib.h>
2298
EOF
2299
check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
2300
#include <stdlib.h>
2301
EOF
2302

    
2303
check_host_cflags -std=c99
2304

    
2305
case "$arch" in
2306
    alpha|ia64|mips|parisc|sparc)
2307
        spic=$shared
2308
    ;;
2309
    x86)
2310
        subarch="x86_32"
2311
        check_cc <<EOF && subarch="x86_64"
2312
        int test[(int)sizeof(char*) - 7];
2313
EOF
2314
        if test "$subarch" = "x86_64"; then
2315
            spic=$shared
2316
        fi
2317
    ;;
2318
esac
2319

    
2320
enable $subarch
2321
enabled spic && enable pic
2322

    
2323
# OS specific
2324
case $target_os in
2325
    haiku)
2326
        prefix_default="/boot/common"
2327
        network_extralibs="-lnetwork"
2328
        host_libs=
2329
        ;;
2330
    sunos)
2331
        FFSERVERLDFLAGS=""
2332
        SHFLAGS='-shared -Wl,-h,$$(@F)'
2333
        enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
2334
        network_extralibs="-lsocket -lnsl"
2335
        add_cppflags -D__EXTENSIONS__
2336
        nm_opts='-P -g'
2337
        ;;
2338
    netbsd)
2339
        disable symver
2340
        oss_indev_extralibs="-lossaudio"
2341
        oss_outdev_extralibs="-lossaudio"
2342
        add_cppflags -D_XOPEN_SOURCE=600
2343
        ;;
2344
    openbsd)
2345
        enable malloc_aligned
2346
        # On OpenBSD 4.5. the compiler does not use PIC unless
2347
        # explicitly using -fPIC. FFmpeg builds fine without PIC,
2348
        # however the generated executable will not do anything
2349
        # (simply quits with exit-code 1, no crash, no output).
2350
        # Thus explicitly enable PIC here.
2351
        enable pic
2352
        disable symver
2353
        SHFLAGS='-shared'
2354
        oss_indev_extralibs="-lossaudio"
2355
        oss_outdev_extralibs="-lossaudio"
2356
        ;;
2357
    dragonfly)
2358
        enable malloc_aligned
2359
        disable symver
2360
        ;;
2361
    freebsd)
2362
        enable malloc_aligned
2363
        ;;
2364
    bsd/os)
2365
        add_extralibs -lpoll -lgnugetopt
2366
        strip="strip -d"
2367
        ;;
2368
    darwin)
2369
        enable malloc_aligned
2370
        gas="gas-preprocessor.pl $cc"
2371
        enabled ppc && add_asflags -force_cpusubtype_ALL
2372
        SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
2373
        strip="${strip} -x"
2374
        add_ldflags -Wl,-dynamic,-search_paths_first
2375
        SLIBSUF=".dylib"
2376
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
2377
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
2378
        FFSERVERLDFLAGS=-Wl,-bind_at_load
2379
        objformat="macho"
2380
        enabled x86_64 && objformat="macho64"
2381
        enabled_any pic shared ||
2382
            { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
2383
        ;;
2384
    mingw32*)
2385
        if test $target_os = "mingw32ce"; then
2386
            disable network
2387
        else
2388
            target_os=mingw32
2389
        fi
2390
        LIBTARGET=i386
2391
        if enabled x86_64; then
2392
            enable malloc_aligned
2393
            LIBTARGET=x64
2394
        elif enabled arm; then
2395
            LIBTARGET=arm
2396
        fi
2397
        shlibdir_default="$bindir_default"
2398
        disable ffserver
2399
        SLIBPREF=""
2400
        SLIBSUF=".dll"
2401
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2402
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2403
        SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
2404
        SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
2405
            install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
2406
            install -d "$(LIBDIR)"; \
2407
            install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"'
2408
        SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
2409
        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'
2410
        objformat="win32"
2411
        enable dos_paths
2412
        check_cflags -fno-common
2413
        check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \
2414
                                      || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
2415
                die "ERROR: MinGW runtime version must be >= 3.15."
2416
        ;;
2417
    cygwin*)
2418
        target_os=cygwin
2419
        shlibdir_default="$bindir_default"
2420
        SLIBPREF="cyg"
2421
        SLIBSUF=".dll"
2422
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
2423
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
2424
        SHFLAGS='-shared -Wl,--enable-auto-image-base'
2425
        objformat="win32"
2426
        enable dos_paths
2427
        check_cflags -fno-common
2428
        ;;
2429
    *-dos|freedos|opendos)
2430
        disable ffplay ffserver
2431
        disable $INDEV_LIST $OUTDEV_LIST
2432
        network_extralibs="-lsocket"
2433
        objformat="coff"
2434
        enable dos_paths
2435
        ;;
2436
    linux)
2437
        enable dv1394
2438
        ;;
2439
    irix*)
2440
        target_os=irix
2441
        ranlib="echo ignoring ranlib"
2442
        ;;
2443
    os/2*)
2444
        strip="lxlite -CS"
2445
        ln_s="cp -f"
2446
        add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
2447
        SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
2448
        FFSERVERLDFLAGS=""
2449
        LIBSUF="_s.a"
2450
        SLIBPREF=""
2451
        SLIBSUF=".dll"
2452
        SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
2453
        SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
2454
        SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
2455
          echo PROTMODE >> $(SUBDIR)$(NAME).def; \
2456
          echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
2457
          echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
2458
          echo EXPORTS >> $(SUBDIR)$(NAME).def; \
2459
          emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
2460
        SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
2461
          emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
2462
        SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
2463
        SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
2464
        enable dos_paths
2465
        ;;
2466
    gnu/kfreebsd)
2467
        ;;
2468
    gnu)
2469
        ;;
2470
    qnx)
2471
        add_cppflags -D_QNX_SOURCE
2472
        network_extralibs="-lsocket"
2473
        ;;
2474
    none)
2475
        ;;
2476
    *)
2477
        die "Unknown OS '$target_os'."
2478
        ;;
2479
esac
2480

    
2481
echo "config:$arch:$subarch:$cpu:$target_os:$cc_ident:$FFMPEG_CONFIGURATION" >config.fate
2482

    
2483
check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
2484

    
2485
set_default $PATHS_LIST
2486

    
2487
# we need to build at least one lib type
2488
if ! enabled_any static shared; then
2489
    cat <<EOF
2490
At least one library type must be built.
2491
Specify --enable-static to build the static libraries or --enable-shared to
2492
build the shared libraries as well. To only build the shared libraries specify
2493
--disable-static in addition to --enable-shared.
2494
EOF
2495
    exit 1;
2496
fi
2497

    
2498
disabled static && LIBNAME=""
2499

    
2500
die_license_disabled() {
2501
    enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2502
}
2503

    
2504
die_license_disabled gpl libx264
2505
die_license_disabled gpl libxavs
2506
die_license_disabled gpl libxvid
2507
die_license_disabled gpl postproc
2508
die_license_disabled gpl x11grab
2509

    
2510
die_license_disabled nonfree libfaac
2511

    
2512
die_license_disabled version3 libopencore_amrnb
2513
die_license_disabled version3 libopencore_amrwb
2514

    
2515
enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2516

    
2517
disabled optimizations || check_cflags -fomit-frame-pointer
2518

    
2519
enable_pic() {
2520
    enable pic
2521
    add_cppflags -DPIC
2522
    add_cflags   -fPIC
2523
    add_asflags  -fPIC
2524
}
2525

    
2526
enabled pic && enable_pic
2527

    
2528
check_cc <<EOF || die "Symbol mangling check failed."
2529
int ff_extern;
2530
EOF
2531
sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
2532
extern_prefix=${sym%%ff_extern*}
2533

    
2534
check_cc <<EOF && enable inline_asm
2535
void foo(void) { __asm__ volatile ("" ::); }
2536
EOF
2537

    
2538
_restrict=
2539
for restrict_keyword in restrict __restrict__ __restrict; do
2540
    check_cc <<EOF && _restrict=$restrict_keyword && break
2541
void foo(char * $restrict_keyword p);
2542
EOF
2543
done
2544

    
2545
check_cc <<EOF && enable attribute_packed
2546
struct { int x; } __attribute__((packed)) x;
2547
EOF
2548

    
2549
check_cc <<EOF && enable attribute_may_alias
2550
union { int x; } __attribute__((may_alias)) x;
2551
EOF
2552

    
2553
check_cc <<EOF || die "endian test failed"
2554
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2555
EOF
2556
od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2557

    
2558
if enabled alpha; then
2559

    
2560
    check_cflags -mieee
2561

    
2562
elif enabled arm; then
2563

    
2564
    check_cflags -marm
2565
    nogas=die
2566

    
2567
    if     check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
2568
        enable vfp_args
2569
    elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then
2570
        case "${cross_prefix:-$cc}" in
2571
            *hardfloat*)         enable vfp_args;   fpabi=vfp ;;
2572
            *) check_ld <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
2573
__asm__ (".eabi_attribute 28, 1");
2574
int main(void) { return 0; }
2575
EOF
2576
        esac
2577
        warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
2578
    fi
2579

    
2580
    # We have to check if pld is a nop and disable it.
2581
    check_asm pld '"pld [r0]"'
2582

    
2583
    enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2584
    enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
2585
    enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2586
    enabled armvfp  && check_asm armvfp  '"fadds s0, s0, s0"'
2587
    enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
2588
    enabled neon    && check_asm neon    '"vadd.i16 q0, q0, q0"'
2589

    
2590
    enabled_all armv6t2 shared !pic && enable_pic
2591

    
2592
elif enabled mips; then
2593

    
2594
    check_asm loongson '"dmult.g $1, $2, $3"'
2595
    enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
2596

    
2597
elif enabled ppc; then
2598

    
2599
    enable local_aligned_8 local_aligned_16
2600

    
2601
    check_asm dcbzl     '"dcbzl 0, %0" :: "r"(0)'
2602
    check_asm ibm_asm   '"add 0, 0, 0"'
2603
    check_asm ppc4xx    '"maclhw r10, r11, r12"'
2604
    check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
2605

    
2606
    # AltiVec flags: The FSF version of GCC differs from the Apple version
2607
    if enabled altivec; then
2608
        nogas=warn
2609
        check_cflags -maltivec -mabi=altivec &&
2610
        { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2611
        check_cflags -faltivec
2612

    
2613
        # check if our compiler supports Motorola AltiVec C API
2614
        check_cc <<EOF || disable altivec
2615
$inc_altivec_h
2616
int main(void) {
2617
    vector signed int v1, v2, v3;
2618
    v1 = vec_add(v2,v3);
2619
    return 0;
2620
}
2621
EOF
2622

    
2623
        # check if our compiler supports braces for vector declarations
2624
        check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
2625
$inc_altivec_h
2626
int main (void) { (vector int) {1}; return 0; }
2627
EOF
2628
    fi
2629

    
2630
elif enabled sparc; then
2631

    
2632
    enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2633
        add_cflags -mcpu=ultrasparc -mtune=ultrasparc
2634

    
2635
elif enabled x86; then
2636

    
2637
    enable local_aligned_8 local_aligned_16
2638

    
2639
    # check whether EBP is available on x86
2640
    # As 'i' is stored on the stack, this program will crash
2641
    # if the base pointer is used to access it because the
2642
    # base pointer is cleared in the inline assembly code.
2643
    check_exec_crash <<EOF && enable ebp_available
2644
    volatile int i=0;
2645
    __asm__ volatile (
2646
        "xorl %%ebp, %%ebp"
2647
    ::: "%ebp");
2648
    return i;
2649
EOF
2650

    
2651
    # check whether EBX is available on x86
2652
    check_asm ebx_available '""::"b"(0)' &&
2653
        check_asm ebx_available '"":::"%ebx"'
2654

    
2655
    # check whether xmm clobbers are supported
2656
    check_asm xmm_clobbers '"":::"%xmm0"'
2657

    
2658
    # check whether more than 10 operands are supported
2659
    check_cc <<EOF && enable ten_operands
2660
int main(void) {
2661
    int x=0;
2662
    __asm__ volatile(
2663
        ""
2664
        :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
2665
    );
2666
    return 0;
2667
}
2668
EOF
2669

    
2670
    # check whether binutils is new enough to compile SSSE3/MMX2
2671
    enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
2672
    enabled mmx2  && check_asm mmx2  '"pmaxub %mm0, %mm1"'
2673

    
2674
    check_asm bswap '"bswap %%eax" ::: "%eax"'
2675

    
2676
    if ! disabled_any asm mmx yasm; then
2677
        if check_cmd $yasmexe --version; then
2678
            enabled x86_64 && yasm_extra="-m amd64"
2679
            yasm_debug="-g dwarf2"
2680
        elif check_cmd nasm -v; then
2681
            yasmexe=nasm
2682
            yasm_debug="-g -F dwarf"
2683
            enabled x86_64 && test "$objformat" = elf && objformat=elf64
2684
        fi
2685

    
2686
        YASMFLAGS="-f $objformat $yasm_extra"
2687
        enabled pic               && append YASMFLAGS "-DPIC"
2688
        test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
2689
        case "$objformat" in
2690
            elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
2691
        esac
2692

    
2693
        check_yasm "pextrd [eax], xmm0, 1" && enable yasm ||
2694
            die "yasm not found, use --disable-yasm for a crippled build"
2695
        check_yasm "vpaddw xmm0, xmm0, xmm0" || disable avx
2696
    fi
2697

    
2698
    case "$cpu" in
2699
        athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
2700
            disable fast_clz
2701
        ;;
2702
    esac
2703

    
2704
fi
2705

    
2706
if enabled asm; then
2707
    as=${gas:=$as}
2708
    check_asm gnu_as '".macro m n\n\\n:.int 0\n.endm\nm x"' ||
2709
        $nogas "GNU assembler not found, install gas-preprocessor"
2710
fi
2711

    
2712
if check_func dlopen; then
2713
    ldl=
2714
elif check_func dlopen -ldl; then
2715
    ldl=-ldl
2716
fi
2717

    
2718
if enabled network; then
2719
    check_type "sys/types.h sys/socket.h" socklen_t
2720
    check_type netdb.h "struct addrinfo"
2721
    check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
2722
    check_type netinet/in.h "struct sockaddr_in6"
2723
    check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
2724
    check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
2725
    # Prefer arpa/inet.h over winsock2
2726
    if check_header arpa/inet.h ; then
2727
        check_func closesocket
2728
    elif check_header winsock2.h ; then
2729
        check_func_headers winsock2.h closesocket -lws2 && \
2730
            network_extralibs="-lws2" || \
2731
        { check_func_headers winsock2.h closesocket -lws2_32 && \
2732
            network_extralibs="-lws2_32"; }
2733
        check_type ws2tcpip.h socklen_t
2734
        check_type ws2tcpip.h "struct addrinfo"
2735
        check_type ws2tcpip.h "struct ipv6_mreq"
2736
        check_type ws2tcpip.h "struct sockaddr_in6"
2737
        check_type ws2tcpip.h "struct sockaddr_storage"
2738
        check_struct winsock2.h "struct sockaddr" sa_len
2739
    else
2740
        disable network
2741
    fi
2742
fi
2743

    
2744
# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2745
check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2746

    
2747
check_func  fcntl
2748
check_func  fork
2749
check_func  getaddrinfo $network_extralibs
2750
check_func  gethrtime
2751
check_func  getrusage
2752
check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
2753
check_func  inet_aton $network_extralibs
2754
check_func  isatty
2755
check_func  localtime_r
2756
check_func  ${malloc_prefix}memalign            && enable memalign
2757
check_func  mkstemp
2758
check_func  mmap
2759
check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
2760
check_func  setrlimit
2761
check_func  strerror_r
2762
check_func  strtok_r
2763
check_func_headers io.h setmode
2764
check_func_headers lzo/lzo1x.h lzo1x_999_compress
2765
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
2766
check_func_headers windows.h GetProcessTimes
2767
check_func_headers windows.h MapViewOfFile
2768
check_func_headers windows.h VirtualAlloc
2769

    
2770
check_header conio.h
2771
check_header dlfcn.h
2772
check_header dxva2api.h
2773
check_header libcrystalhd/libcrystalhd_if.h
2774
check_header malloc.h
2775
check_header poll.h
2776
check_header sys/mman.h
2777
check_header sys/resource.h
2778
check_header sys/select.h
2779
check_header termios.h
2780
check_header vdpau/vdpau.h
2781
check_header vdpau/vdpau_x11.h
2782
check_header X11/extensions/XvMClib.h
2783

    
2784
check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex
2785

    
2786
if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
2787
     enabled_any $need_memalign ; then
2788
    die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
2789
fi
2790

    
2791
disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
2792
disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
2793

    
2794
# check for some common methods of building with pthread support
2795
# do this before the optional library checks as some of them require pthreads
2796
if ! disabled pthreads && ! enabled w32threads; then
2797
    enable pthreads
2798
    if check_func pthread_create; then
2799
        :
2800
    elif check_func pthread_create -pthread; then
2801
        add_cflags -pthread
2802
        add_extralibs -pthread
2803
    elif check_func pthread_create -pthreads; then
2804
        add_cflags -pthreads
2805
        add_extralibs -pthreads
2806
    elif check_func pthread_create -lpthreadGC2; then
2807
        add_extralibs -lpthreadGC2
2808
    elif ! check_lib pthread.h pthread_create -lpthread; then
2809
        disable pthreads
2810
    fi
2811
fi
2812

    
2813
for thread in $THREADS_LIST; do
2814
    if enabled $thread; then
2815
        test -n "$thread_type" &&
2816
            die "ERROR: Only one thread type must be selected." ||
2817
            thread_type="$thread"
2818
    fi
2819
done
2820

    
2821
check_lib math.h sin -lm
2822
disabled crystalhd || check_lib libcrystalhd/libcrystalhd_if.h DtsGetVersion -lcrystalhd
2823
disabled vaapi || check_lib va/va.h vaInitialize -lva
2824

    
2825
check_mathfunc exp2
2826
check_mathfunc exp2f
2827
check_mathfunc llrint
2828
check_mathfunc llrintf
2829
check_mathfunc log2
2830
check_mathfunc log2f
2831
check_mathfunc lrint
2832
check_mathfunc lrintf
2833
check_mathfunc round
2834
check_mathfunc roundf
2835
check_mathfunc truncf
2836

    
2837
# these are off by default, so fail if requested and not available
2838
enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
2839
enabled frei0r     && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
2840
enabled libdirac   && add_cflags $(pkg-config --cflags dirac) &&
2841
                      require  libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
2842
                      require  libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
2843
enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
2844
enabled libfreetype && add_cflags $(pkg-config --cflags freetype2) && require libfreetype ft2build.h FT_Init_FreeType -lfreetype
2845
enabled libgsm     && require  libgsm gsm/gsm.h gsm_create -lgsm
2846
enabled libmp3lame && require  "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
2847
enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
2848
enabled libopencore_amrnb  && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
2849
enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
2850
enabled libopencv  && { check_lib opencv/cv.h cvCreateImageHeader $(pkg-config --libs opencv) ||
2851
                        die "ERROR: libopencv not found"; }
2852
enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
2853
enabled librtmp    && { check_lib librtmp/rtmp.h RTMP_Socket $(pkg-config --libs librtmp) ||
2854
                        die "ERROR: librtmp not found or RTMP_Socket() missing, librtmp version must be >= 2.2.f"; }
2855
enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
2856
                           require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
2857
enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
2858
enabled libtheora  && require  libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
2859
enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
2860
enabled libvpx     && {
2861
    enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
2862
                                die "ERROR: libvpx decoder version must be >=0.9.1"; }
2863
    enabled libvpx_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_enc_init_ver -lvpx ||
2864
                                die "ERROR: libvpx encoder version must be >=0.9.1"; } }
2865
enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 &&
2866
                      { check_cpp_condition x264.h "X264_BUILD >= 99" ||
2867
                        die "ERROR: libx264 version must be >= 0.99."; }
2868
enabled libxavs    && require  libxavs xavs.h xavs_encoder_encode -lxavs
2869
enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
2870
enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
2871

    
2872
# libdc1394 check
2873
if enabled libdc1394; then
2874
    { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2875
        enable libdc1394_2; } ||
2876
    { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2877
        enable libdc1394_1; } ||
2878
    die "ERROR: No version of libdc1394 found "
2879
fi
2880

    
2881
SDL_CONFIG="${cross_prefix}sdl-config"
2882
if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
2883
    sdl_cflags=$("${SDL_CONFIG}" --cflags)
2884
    sdl_libs=$("${SDL_CONFIG}" --libs)
2885
    check_func_headers SDL.h SDL_Init $sdl_cflags $sdl_libs &&
2886
    check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
2887
    enable sdl &&
2888
    check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
2889
fi
2890

    
2891
texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
2892

    
2893
check_header linux/fb.h
2894
check_header linux/videodev.h
2895
check_header linux/videodev2.h
2896
check_header sys/videoio.h
2897

    
2898
check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
2899
# check that WM_CAP_DRIVER_CONNECT is defined to the proper value
2900
# w32api 3.12 had it defined wrong
2901
check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
2902

    
2903
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
2904
{ check_header dev/bktr/ioctl_meteor.h &&
2905
  check_header dev/bktr/ioctl_bt848.h; } ||
2906
{ check_header machine/ioctl_meteor.h &&
2907
  check_header machine/ioctl_bt848.h; } ||
2908
{ check_header dev/video/meteor/ioctl_meteor.h &&
2909
  check_header dev/video/bktr/ioctl_bt848.h; } ||
2910
check_header dev/ic/bt8xx.h
2911

    
2912
check_header sys/soundcard.h
2913
check_header soundcard.h
2914

    
2915
enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
2916

    
2917
enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
2918

    
2919
enabled x11grab                         &&
2920
check_header X11/Xlib.h                 &&
2921
check_header X11/extensions/XShm.h      &&
2922
check_header X11/extensions/Xfixes.h    &&
2923
check_func XOpenDisplay -lX11           &&
2924
check_func XShmCreateImage -lX11 -lXext &&
2925
check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
2926

    
2927
if ! disabled vdpau && enabled vdpau_vdpau_h; then
2928
check_cpp_condition \
2929
    vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
2930
    { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
2931
      disable vdpau; }
2932
fi
2933

    
2934
enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
2935

    
2936
# add some useful compiler flags if supported
2937
check_cflags -Wdeclaration-after-statement
2938
check_cflags -Wall
2939
check_cflags -Wno-parentheses
2940
check_cflags -Wno-switch
2941
check_cflags -Wdisabled-optimization
2942
check_cflags -Wpointer-arith
2943
check_cflags -Wredundant-decls
2944
check_cflags -Wno-pointer-sign
2945
check_cflags -Wcast-qual
2946
check_cflags -Wwrite-strings
2947
check_cflags -Wtype-limits
2948
check_cflags -Wundef
2949
check_cflags -Wmissing-prototypes
2950
enabled extra_warnings && check_cflags -Winline
2951

    
2952
# add some linker flags
2953
check_ldflags -Wl,--warn-common
2954
check_ldflags -Wl,--as-needed
2955
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'
2956
test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
2957

    
2958
echo "X{};" > $TMPV
2959
if test_ldflags -Wl,--version-script,$TMPV; then
2960
    append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
2961
    check_cc <<EOF && enable symver_asm_label
2962
void ff_foo(void) __asm__ ("av_foo@VERSION");
2963
void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
2964
EOF
2965
    check_cc <<EOF && enable symver_gnu_asm
2966
__asm__(".symver ff_foo,av_foo@VERSION");
2967
void ff_foo(void) {}
2968
EOF
2969
fi
2970

    
2971
if enabled small; then
2972
    add_cflags $size_cflags
2973
    optimizations="small"
2974
elif enabled optimizations; then
2975
    add_cflags $speed_cflags
2976
else
2977
    add_cflags $noopt_cflags
2978
fi
2979
check_cflags -fno-math-errno
2980
check_cflags -fno-signed-zeros
2981

    
2982
if enabled icc; then
2983
    # Just warnings, no remarks
2984
    check_cflags -w1
2985
    # -wd: Disable following warnings
2986
    # 144, 167, 556: -Wno-pointer-sign
2987
    # 10006: ignoring unknown option -fno-signed-zeros
2988
    # 10148: ignoring unknown option -Wno-parentheses
2989
    # 10156: ignoring option '-W'; no argument required
2990
    check_cflags -wd144,167,556,10006,10148,10156
2991
    # 11030: Warning unknown option --as-needed
2992
    # 10156: ignoring option '-export'; no argument required
2993
    check_ldflags -wd10156,11030
2994
    # Allow to compile with optimizations
2995
    check_ldflags -march=$cpu
2996
    # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
2997
    enable ebp_available
2998
    if enabled x86_32; then
2999
        test ${icc_version%%.*} -ge 11 && \
3000
            check_cflags -falign-stack=maintain-16-byte || \
3001
            disable aligned_stack
3002
    fi
3003
elif enabled ccc; then
3004
    # disable some annoying warnings
3005
    add_cflags -msg_disable cvtu32to64
3006
    add_cflags -msg_disable embedcomment
3007
    add_cflags -msg_disable needconstext
3008
    add_cflags -msg_disable nomainieee
3009
    add_cflags -msg_disable ptrmismatch1
3010
    add_cflags -msg_disable unreachcode
3011
elif enabled gcc; then
3012
    check_cflags -fno-tree-vectorize
3013
    check_cflags -Werror=implicit-function-declaration
3014
    check_cflags -Werror=missing-prototypes
3015
elif enabled llvm_gcc; then
3016
    check_cflags -mllvm -stack-alignment=16
3017
elif enabled clang; then
3018
    check_cflags -mllvm -stack-alignment=16
3019
    check_cflags -Qunused-arguments
3020
elif enabled armcc; then
3021
    # 2523: use of inline assembler is deprecated
3022
    add_cflags -W${armcc_opt},--diag_suppress=2523
3023
    add_cflags -W${armcc_opt},--diag_suppress=1207
3024
    add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
3025
    add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
3026
elif enabled tms470; then
3027
    add_cflags -pds=824 -pds=837
3028
elif enabled pathscale; then
3029
    add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
3030
fi
3031

    
3032
enabled_any $THREADS_LIST      && enable threads
3033

    
3034
check_deps $CONFIG_LIST       \
3035
           $CONFIG_EXTRA      \
3036
           $HAVE_LIST         \
3037
           $DECODER_LIST      \
3038
           $ENCODER_LIST      \
3039
           $HWACCEL_LIST      \
3040
           $PARSER_LIST       \
3041
           $BSF_LIST          \
3042
           $DEMUXER_LIST      \
3043
           $MUXER_LIST        \
3044
           $FILTER_LIST       \
3045
           $INDEV_LIST        \
3046
           $OUTDEV_LIST       \
3047
           $PROTOCOL_LIST     \
3048
           $ACODEC_TESTS      \
3049
           $VCODEC_TESTS      \
3050
           $LAVF_TESTS        \
3051
           $LAVFI_TESTS       \
3052
           $SEEK_TESTS        \
3053

    
3054
enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
3055

    
3056
echo "install prefix            $prefix"
3057
echo "source path               $source_path"
3058
echo "C compiler                $cc"
3059
echo "ARCH                      $arch ($cpu)"
3060
if test "$build_suffix" != ""; then
3061
    echo "build suffix              $build_suffix"
3062
fi
3063
if test "$extra_version" != ""; then
3064
    echo "version string suffix     $extra_version"
3065
fi
3066
echo "big-endian                ${bigendian-no}"
3067
echo "runtime cpu detection     ${runtime_cpudetect-no}"
3068
if enabled x86; then
3069
    echo "yasm                      ${yasm-no}"
3070
    echo "MMX enabled               ${mmx-no}"
3071
    echo "MMX2 enabled              ${mmx2-no}"
3072
    echo "3DNow! enabled            ${amd3dnow-no}"
3073
    echo "3DNow! extended enabled   ${amd3dnowext-no}"
3074
    echo "SSE enabled               ${sse-no}"
3075
    echo "SSSE3 enabled             ${ssse3-no}"
3076
    echo "CMOV enabled              ${cmov-no}"
3077
    echo "CMOV is fast              ${fast_cmov-no}"
3078
    echo "EBX available             ${ebx_available-no}"
3079
    echo "EBP available             ${ebp_available-no}"
3080
    echo "10 operands supported     ${ten_operands-no}"
3081
fi
3082
if enabled arm; then
3083
    echo "ARMv5TE enabled           ${armv5te-no}"
3084
    echo "ARMv6 enabled             ${armv6-no}"
3085
    echo "ARMv6T2 enabled           ${armv6t2-no}"
3086
    echo "ARM VFP enabled           ${armvfp-no}"
3087
    echo "IWMMXT enabled            ${iwmmxt-no}"
3088
    echo "NEON enabled              ${neon-no}"
3089
fi
3090
if enabled mips; then
3091
    echo "MMI enabled               ${mmi-no}"
3092
fi
3093
if enabled ppc; then
3094
    echo "AltiVec enabled           ${altivec-no}"
3095
    echo "PPC 4xx optimizations     ${ppc4xx-no}"
3096
    echo "dcbzl available           ${dcbzl-no}"
3097
fi
3098
if enabled sparc; then
3099
    echo "VIS enabled               ${vis-no}"
3100
fi
3101
echo "debug symbols             ${debug-no}"
3102
echo "strip symbols             ${stripping-no}"
3103
echo "optimizations             ${optimizations-no}"
3104
echo "static                    ${static-no}"
3105
echo "shared                    ${shared-no}"
3106
echo "postprocessing support    ${postproc-no}"
3107
echo "new filter support        ${avfilter-no}"
3108
echo "network support           ${network-no}"
3109
echo "threading support         ${thread_type-no}"
3110
echo "SDL support               ${sdl-no}"
3111
echo "Sun medialib support      ${mlib-no}"
3112
echo "AVISynth enabled          ${avisynth-no}"
3113
echo "frei0r enabled            ${frei0r-no}"
3114
echo "libdc1394 support         ${libdc1394-no}"
3115
echo "libdirac enabled          ${libdirac-no}"
3116
echo "libfaac enabled           ${libfaac-no}"
3117
echo "libgsm enabled            ${libgsm-no}"
3118
echo "libmp3lame enabled        ${libmp3lame-no}"
3119
echo "libnut enabled            ${libnut-no}"
3120
echo "libopencore-amrnb support ${libopencore_amrnb-no}"
3121
echo "libopencore-amrwb support ${libopencore_amrwb-no}"
3122
echo "libopencv support         ${libopencv-no}"
3123
echo "libopenjpeg enabled       ${libopenjpeg-no}"
3124
echo "librtmp enabled           ${librtmp-no}"
3125
echo "libschroedinger enabled   ${libschroedinger-no}"
3126
echo "libspeex enabled          ${libspeex-no}"
3127
echo "libtheora enabled         ${libtheora-no}"
3128
echo "libvorbis enabled         ${libvorbis-no}"
3129
echo "libvpx enabled            ${libvpx-no}"
3130
echo "libx264 enabled           ${libx264-no}"
3131
echo "libxavs enabled           ${libxavs-no}"
3132
echo "libxvid enabled           ${libxvid-no}"
3133
echo "zlib enabled              ${zlib-no}"
3134
echo "bzlib enabled             ${bzlib-no}"
3135
echo
3136

    
3137
for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
3138
    echo "Enabled ${type}s:"
3139
    eval list=\$$(toupper $type)_LIST
3140
    print_enabled '_*' $list | sort | pr -3 -t
3141
    echo
3142
done
3143

    
3144
license="LGPL version 2.1 or later"
3145
if enabled nonfree; then
3146
    license="nonfree and unredistributable"
3147
elif enabled gplv3; then
3148
    license="GPL version 3 or later"
3149
elif enabled lgplv3; then
3150
    license="LGPL version 3 or later"
3151
elif enabled gpl; then
3152
    license="GPL version 2 or later"
3153
fi
3154

    
3155
echo "License: $license"
3156

    
3157
echo "Creating config.mak and config.h..."
3158

    
3159
# build tree in object directory if source path is different from current one
3160
if enabled source_path_used; then
3161
    DIRS="
3162
        doc
3163
        libavcodec
3164
        libavcodec/$arch
3165
        libavdevice
3166
        libavfilter
3167
        libavfilter/$arch
3168
        libavfilter/libmpcodecs
3169
        libavfilter/libmpcodecs/libvo
3170
        libavformat
3171
        libavutil
3172
        libavutil/$arch
3173
        libpostproc
3174
        libswscale
3175
        libswscale/$arch
3176
        tests
3177
        tools
3178
    "
3179
    FILES="
3180
        Makefile
3181
        common.mak
3182
        subdir.mak
3183
        doc/texi2pod.pl
3184
        libavcodec/Makefile
3185
        libavcodec/${arch}/Makefile
3186
        libavdevice/Makefile
3187
        libavfilter/Makefile
3188
        libavfilter/${arch}/Makefile
3189
        libavformat/Makefile
3190
        libavutil/Makefile
3191
        libpostproc/Makefile
3192
        libswscale/Makefile
3193
    "
3194
    map 'mkdir -p $v' $DIRS;
3195
    map 'test -f "$source_path/$v" && $ln_s "$source_path/$v" $v' $FILES
3196
fi
3197

    
3198
enabled stripping || strip="echo skipping strip"
3199

    
3200
config_files="$TMPH config.mak"
3201

    
3202
cat > config.mak <<EOF
3203
# Automatically generated by configure - do not modify!
3204
ifndef FFMPEG_CONFIG_MAK
3205
FFMPEG_CONFIG_MAK=1
3206
FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
3207
prefix=$prefix
3208
LIBDIR=\$(DESTDIR)$libdir
3209
SHLIBDIR=\$(DESTDIR)$shlibdir
3210
INCDIR=\$(DESTDIR)$incdir
3211
BINDIR=\$(DESTDIR)$bindir
3212
DATADIR=\$(DESTDIR)$datadir
3213
MANDIR=\$(DESTDIR)$mandir
3214
SRC_PATH="$source_path"
3215
SRC_PATH_BARE=$source_path
3216
BUILD_ROOT="$PWD"
3217
CC_IDENT=$cc_ident
3218
ARCH=$arch
3219
CC=$cc
3220
AS=$as
3221
LD=$ld
3222
DEPCC=$dep_cc
3223
YASM=$yasmexe
3224
YASMDEP=$yasmexe
3225
AR=$ar
3226
RANLIB=$ranlib
3227
CP=cp -p
3228
LN_S=$ln_s
3229
STRIP=$strip
3230
CPPFLAGS=$CPPFLAGS
3231
CFLAGS=$CFLAGS
3232
ASFLAGS=$ASFLAGS
3233
CC_O=$CC_O
3234
LDFLAGS=$LDFLAGS
3235
FFSERVERLDFLAGS=$FFSERVERLDFLAGS
3236
SHFLAGS=$SHFLAGS
3237
YASMFLAGS=$YASMFLAGS
3238
BUILDSUF=$build_suffix
3239
FULLNAME=$FULLNAME
3240
LIBPREF=$LIBPREF
3241
LIBSUF=$LIBSUF
3242
LIBNAME=$LIBNAME
3243
SLIBPREF=$SLIBPREF
3244
SLIBSUF=$SLIBSUF
3245
EXESUF=$EXESUF
3246
EXTRA_VERSION=$extra_version
3247
DEPFLAGS=$DEPFLAGS
3248
CCDEP=$CCDEP
3249
ASDEP=$ASDEP
3250
CC_DEPFLAGS=$CC_DEPFLAGS
3251
AS_DEPFLAGS=$AS_DEPFLAGS
3252
HOSTCC=$host_cc
3253
HOSTCFLAGS=$host_cflags
3254
HOSTEXESUF=$HOSTEXESUF
3255
HOSTLDFLAGS=$host_ldflags
3256
HOSTLIBS=$host_libs
3257
TARGET_EXEC=$target_exec
3258
TARGET_PATH=$target_path
3259
SDL_LIBS=$sdl_libs
3260
SDL_CFLAGS=$sdl_cflags
3261
LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
3262
EXTRALIBS=$extralibs
3263
INSTALL=install
3264
LIBTARGET=${LIBTARGET}
3265
SLIBNAME=${SLIBNAME}
3266
SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
3267
SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
3268
SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
3269
SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
3270
SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}
3271
SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}
3272
SAMPLES=${samples:-\$(FATE_SAMPLES)}
3273
EOF
3274

    
3275
get_version(){
3276
    name=$1
3277
    file=$source_path/$2
3278
    eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
3279
    eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
3280
    lcname=$(tolower $name)
3281
    eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
3282
    eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
3283
}
3284

    
3285
get_version LIBSWSCALE  libswscale/swscale.h
3286
get_version LIBPOSTPROC libpostproc/postprocess.h
3287
get_version LIBAVCODEC  libavcodec/avcodec.h
3288
get_version LIBAVDEVICE libavdevice/avdevice.h
3289
get_version LIBAVFORMAT libavformat/version.h
3290
get_version LIBAVUTIL   libavutil/avutil.h
3291
get_version LIBAVFILTER libavfilter/avfilter.h
3292

    
3293
cat > $TMPH <<EOF
3294
/* Automatically generated by configure - do not modify! */
3295
#ifndef FFMPEG_CONFIG_H
3296
#define FFMPEG_CONFIG_H
3297
#define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
3298
#define FFMPEG_LICENSE "$(c_escape $license)"
3299
#define FFMPEG_DATADIR "$(eval c_escape $datadir)"
3300
#define CC_TYPE "$cc_type"
3301
#define CC_VERSION $cc_version
3302
#define restrict $_restrict
3303
#define EXTERN_PREFIX "${extern_prefix}"
3304
#define EXTERN_ASM ${extern_prefix}
3305
#define SLIBSUF "$SLIBSUF"
3306
EOF
3307

    
3308
test -n "$malloc_prefix" &&
3309
    echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
3310

    
3311
if enabled small || disabled optimizations; then
3312
    echo "#undef  av_always_inline"  >> $TMPH
3313
    if enabled small; then
3314
        echo "#define av_always_inline inline"  >> $TMPH
3315
    else
3316
        echo "#define av_always_inline av_unused"  >> $TMPH
3317
    fi
3318
fi
3319

    
3320
if enabled yasm; then
3321
    append config_files $TMPASM
3322
    printf '' >$TMPASM
3323
fi
3324

    
3325
print_config ARCH_   "$config_files" $ARCH_LIST
3326
print_config HAVE_   "$config_files" $HAVE_LIST
3327
print_config CONFIG_ "$config_files" $CONFIG_LIST       \
3328
                                     $CONFIG_EXTRA      \
3329
                                     $DECODER_LIST      \
3330
                                     $ENCODER_LIST      \
3331
                                     $HWACCEL_LIST      \
3332
                                     $PARSER_LIST       \
3333
                                     $BSF_LIST          \
3334
                                     $DEMUXER_LIST      \
3335
                                     $MUXER_LIST        \
3336
                                     $FILTER_LIST       \
3337
                                     $PROTOCOL_LIST     \
3338
                                     $INDEV_LIST        \
3339
                                     $OUTDEV_LIST       \
3340

    
3341
cat >>config.mak <<EOF
3342
ACODEC_TESTS=$(print_enabled -n _test $ACODEC_TESTS)
3343
VCODEC_TESTS=$(print_enabled -n _test $VCODEC_TESTS)
3344
LAVF_TESTS=$(print_enabled   -n _test $LAVF_TESTS)
3345
LAVFI_TESTS=$(print_enabled  -n _test $LAVFI_TESTS)
3346
SEEK_TESTS=$(print_enabled   -n _test $SEEK_TESTS)
3347
EOF
3348

    
3349
echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
3350
echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
3351

    
3352
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3353
cp_if_changed $TMPH config.h
3354
touch .config
3355

    
3356
enabled yasm && cp_if_changed $TMPASM config.asm
3357

    
3358
cat > $TMPH <<EOF
3359
/* Generated by ffconf */
3360
#ifndef AVUTIL_AVCONFIG_H
3361
#define AVUTIL_AVCONFIG_H
3362
EOF
3363

    
3364
print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
3365

    
3366
echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
3367

    
3368
cp_if_changed $TMPH libavutil/avconfig.h
3369

    
3370
test -n "$WARNINGS" && printf "\n$WARNINGS"
3371

    
3372
# build pkg-config files
3373

    
3374
pkgconfig_generate(){
3375
name=$1
3376
shortname=${name#lib}${build_suffix}
3377
comment=$2
3378
version=$3
3379
libs=$4
3380
requires=$5
3381
enabled ${name#lib} || return 0
3382
cat <<EOF > $name/$name.pc
3383
prefix=$prefix
3384
exec_prefix=\${prefix}
3385
libdir=$libdir
3386
includedir=$incdir
3387

    
3388
Name: $name
3389
Description: $comment
3390
Version: $version
3391
Requires: $(enabled shared || echo $requires)
3392
Requires.private: $(enabled shared && echo $requires)
3393
Conflicts:
3394
Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
3395
Libs.private: $(enabled shared && echo $libs)
3396
Cflags: -I\${includedir}
3397
EOF
3398
cat <<EOF > $name/$name-uninstalled.pc
3399
prefix=
3400
exec_prefix=
3401
libdir=\${pcfiledir}
3402
includedir=${source_path}
3403

    
3404
Name: $name
3405
Description: $comment
3406
Version: $version
3407
Requires: $requires
3408
Conflicts:
3409
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
3410
Cflags: -I\${includedir}
3411
EOF
3412
}
3413

    
3414
pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
3415
pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs"
3416
pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
3417
pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3418
pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs"
3419
pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
3420
pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"