Statistics
| Branch: | Revision:

ffmpeg / configure @ 8876c8ae

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
    funcs=$2
704
    shift 2
705
    {
706
        for hdr in $headers; do
707
            echo "#include <$hdr>"
708
        done
709
        for func in $funcs; do
710
            echo "long check_$func(void) { return (long) $func; }"
711
        done
712
        echo "int main(void) { return 0; }"
713
    } | check_ld "$@" && enable $funcs && enable_safe $headers
714
}
715

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
944
THREADS_LIST='
945
    pthreads
946
    w32threads
947
'
948

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

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

    
993
HAVE_LIST_PUB='
994
    bigendian
995
    fast_unaligned
996
'
997

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

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

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

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

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

    
1162
CMDLINE_APPEND="
1163
    extra_cflags
1164
"
1165

    
1166
# code dependency declarations
1167

    
1168
# architecture extensions
1169

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

    
1177
mmi_deps="mips"
1178

    
1179
altivec_deps="ppc"
1180
ppc4xx_deps="ppc"
1181

    
1182
vis_deps="sparc"
1183

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

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

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

    
1201
symver_if_any="symver_asm_label symver_gnu_asm"
1202

    
1203
# subsystems
1204
dct_select="rdft"
1205
mdct_select="fft"
1206
rdft_select="fft"
1207

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

    
1347
crystalhd_deps="libcrystalhd_libcrystalhd_if_h"
1348
vaapi_deps="va_va_h"
1349
vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1350

    
1351
# parsers
1352
h264_parser_select="golomb h264dsp h264pred"
1353

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

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

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

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

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

    
1449
# libraries
1450
avdevice_deps="avcodec avformat"
1451
avformat_deps="avcodec"
1452

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

    
1462
doc_deps="texi2html"
1463

    
1464
# tests
1465

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

    
1479
set_ne_test_deps(){
1480
    eval ${1}_be_test_deps="bigendian"
1481
    eval ${1}_le_test_deps="!bigendian"
1482
}
1483

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

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

    
1557
ac3_fixed_test_deps="ac3_fixed_encoder ac3_decoder rm_muxer rm_demuxer"
1558
mpg_test_deps="mpeg1system_muxer mpegps_demuxer"
1559

    
1560
set_ne_test_deps pixdesc
1561
set_ne_test_deps pixfmts_copy
1562
set_ne_test_deps pixfmts_crop
1563
set_ne_test_deps pixfmts_hflip
1564
set_ne_test_deps pixfmts_null
1565
set_ne_test_deps pixfmts_pad
1566
set_ne_test_deps pixfmts_scale
1567
set_ne_test_deps pixfmts_vflip
1568

    
1569
# default parameters
1570

    
1571
logfile="config.log"
1572

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

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

    
1595
nm_opts='-g'
1596

    
1597
# machine
1598
arch_default=$(uname -m)
1599
cpu="generic"
1600

    
1601
# OS
1602
target_os_default=$(tolower $(uname -s))
1603
host_os=$target_os_default
1604

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

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

    
1642
CC_O='-o $@'
1643

    
1644
host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
1645
host_libs='-lm'
1646

    
1647
target_path='$(CURDIR)'
1648

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

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

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

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

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

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

    
1698
ACODEC_TESTS=$(find_tests acodec)
1699
VCODEC_TESTS=$(find_tests vsynth1)
1700
LAVF_TESTS=$(find_tests lavf)
1701
LAVFI_TESTS=$(find_tests lavfi)
1702
SEEK_TESTS=$(find_tests seek seek_)
1703

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

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

    
1712
enable $ARCH_EXT_LIST $ACODEC_TESTS $VCODEC_TESTS $LAVF_TESTS $LAVFI_TESTS $SEEK_TESTS
1713

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

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

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

    
1782
disabled logging && logfile=/dev/null
1783

    
1784
echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
1785
set >> $logfile
1786

    
1787
test -n "$cross_prefix" && enable cross_compile
1788

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

    
1794
set_default arch target_os
1795

    
1796
ar_default="${cross_prefix}${ar_default}"
1797
cc_default="${cross_prefix}${cc_default}"
1798
nm_default="${cross_prefix}${nm_default}"
1799
ranlib="${cross_prefix}${ranlib}"
1800
strip_default="${cross_prefix}${strip_default}"
1801

    
1802
sysinclude_default="${sysroot}/usr/include"
1803

    
1804
set_default cc nm strip sysinclude
1805
enabled cross_compile || host_cc_default=$cc
1806
set_default host_cc
1807

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

    
1814
EXESUF=$(exesuf $target_os)
1815
HOSTEXESUF=$(exesuf $host_os)
1816

    
1817
# set temporary file name
1818
: ${TMPDIR:=$TEMPDIR}
1819
: ${TMPDIR:=$TMP}
1820
: ${TMPDIR:=/tmp}
1821

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

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

    
1838
trap 'rm -f -- $TMPFILES' EXIT
1839

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

    
1849
unset -f mktemp
1850

    
1851
chmod +x $TMPE
1852

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

    
1866
filter_cflags=echo
1867
filter_cppflags=echo
1868
filter_asflags=echo
1869

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

    
2046
test -n "$cc_type" && enable $cc_type ||
2047
    warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
2048

    
2049
: ${as_default:=$cc}
2050
: ${dep_cc_default:=$cc}
2051
: ${ld_default:=$cc}
2052
set_default ar as dep_cc ld
2053

    
2054
test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
2055
test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
2056

    
2057
add_cflags $extra_cflags
2058
add_asflags $extra_cflags
2059

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

    
2073
if test "$cpu" = host; then
2074
    enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
2075

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

    
2090
    test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
2091
fi
2092

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

    
2134
is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
2135
enable $arch
2136

    
2137
# Add processor-specific flags
2138
if test "$cpu" = generic; then
2139
    : do nothing
2140
elif enabled ppc; then
2141

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

    
2182
elif enabled x86; then
2183

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

    
2208
elif enabled sparc; then
2209

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

    
2220
elif enabled arm; then
2221

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

    
2240
elif enabled alpha; then
2241

    
2242
    enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
2243

    
2244
elif enabled bfin; then
2245

    
2246
    cpuflags="-mcpu=$cpu"
2247

    
2248
elif enabled mips; then
2249

    
2250
    cpuflags="-march=$cpu"
2251

    
2252
elif enabled avr32; then
2253

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

    
2273
fi
2274

    
2275
add_cflags $cpuflags
2276
add_asflags $cpuflags
2277

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

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

    
2300
check_host_cflags -std=c99
2301

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

    
2317
enable $subarch
2318
enabled spic && enable pic
2319

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

    
2478
echo "config:$arch:$subarch:$cpu:$target_os:$cc_ident:$FFMPEG_CONFIGURATION" >config.fate
2479

    
2480
check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
2481

    
2482
set_default $PATHS_LIST
2483

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

    
2495
disabled static && LIBNAME=""
2496

    
2497
die_license_disabled() {
2498
    enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2499
}
2500

    
2501
die_license_disabled gpl libx264
2502
die_license_disabled gpl libxavs
2503
die_license_disabled gpl libxvid
2504
die_license_disabled gpl postproc
2505
die_license_disabled gpl x11grab
2506

    
2507
die_license_disabled nonfree libfaac
2508

    
2509
die_license_disabled version3 libopencore_amrnb
2510
die_license_disabled version3 libopencore_amrwb
2511

    
2512
enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2513

    
2514
disabled optimizations || check_cflags -fomit-frame-pointer
2515

    
2516
enable_pic() {
2517
    enable pic
2518
    add_cppflags -DPIC
2519
    add_cflags   -fPIC
2520
    add_asflags  -fPIC
2521
}
2522

    
2523
enabled pic && enable_pic
2524

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

    
2531
check_cc <<EOF && enable inline_asm
2532
void foo(void) { __asm__ volatile ("" ::); }
2533
EOF
2534

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

    
2542
check_cc <<EOF && enable attribute_packed
2543
struct { int x; } __attribute__((packed)) x;
2544
EOF
2545

    
2546
check_cc <<EOF && enable attribute_may_alias
2547
union { int x; } __attribute__((may_alias)) x;
2548
EOF
2549

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

    
2555
if enabled alpha; then
2556

    
2557
    check_cflags -mieee
2558

    
2559
elif enabled arm; then
2560

    
2561
    check_cflags -marm
2562
    nogas=die
2563

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

    
2577
    # We have to check if pld is a nop and disable it.
2578
    check_asm pld '"pld [r0]"'
2579

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

    
2587
    enabled_all armv6t2 shared !pic && enable_pic
2588

    
2589
elif enabled mips; then
2590

    
2591
    check_asm loongson '"dmult.g $1, $2, $3"'
2592
    enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
2593

    
2594
elif enabled ppc; then
2595

    
2596
    enable local_aligned_8 local_aligned_16
2597

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

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

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

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

    
2627
elif enabled sparc; then
2628

    
2629
    enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2630
        add_cflags -mcpu=ultrasparc -mtune=ultrasparc
2631

    
2632
elif enabled x86; then
2633

    
2634
    enable local_aligned_8 local_aligned_16
2635

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

    
2648
    # check whether EBX is available on x86
2649
    check_asm ebx_available '""::"b"(0)' &&
2650
        check_asm ebx_available '"":::"%ebx"'
2651

    
2652
    # check whether xmm clobbers are supported
2653
    check_asm xmm_clobbers '"":::"%xmm0"'
2654

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

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

    
2671
    check_asm bswap '"bswap %%eax" ::: "%eax"'
2672

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

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

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

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

    
2701
fi
2702

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

    
2709
if check_func dlopen; then
2710
    ldl=
2711
elif check_func dlopen -ldl; then
2712
    ldl=-ldl
2713
fi
2714

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

    
2741
# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2742
check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2743

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

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

    
2781
check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex
2782

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

    
2788
disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
2789
disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
2790

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

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

    
2818
check_lib math.h sin -lm
2819
disabled crystalhd || check_lib libcrystalhd/libcrystalhd_if.h DtsGetVersion -lcrystalhd
2820
disabled vaapi || check_lib va/va.h vaInitialize -lva
2821

    
2822
check_mathfunc exp2
2823
check_mathfunc exp2f
2824
check_mathfunc llrint
2825
check_mathfunc llrintf
2826
check_mathfunc log2
2827
check_mathfunc log2f
2828
check_mathfunc lrint
2829
check_mathfunc lrintf
2830
check_mathfunc round
2831
check_mathfunc roundf
2832
check_mathfunc truncf
2833

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

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

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

    
2888
texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
2889

    
2890
check_header linux/fb.h
2891
check_header linux/videodev.h
2892
check_header linux/videodev2.h
2893
check_header sys/videoio.h
2894

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

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

    
2909
check_header sys/soundcard.h
2910
check_header soundcard.h
2911

    
2912
enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
2913

    
2914
enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
2915

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

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

    
2931
enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
2932

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

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

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

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

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

    
3029
enabled_any $THREADS_LIST      && enable threads
3030

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

    
3051
enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
3052

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

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

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

    
3152
echo "License: $license"
3153

    
3154
echo "Creating config.mak and config.h..."
3155

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

    
3195
enabled stripping || strip="echo skipping strip"
3196

    
3197
config_files="$TMPH config.mak"
3198

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

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

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

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

    
3305
test -n "$malloc_prefix" &&
3306
    echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
3307

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

    
3317
if enabled yasm; then
3318
    append config_files $TMPASM
3319
    printf '' >$TMPASM
3320
fi
3321

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

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

    
3346
echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
3347
echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
3348

    
3349
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3350
cp_if_changed $TMPH config.h
3351
touch .config
3352

    
3353
enabled yasm && cp_if_changed $TMPASM config.asm
3354

    
3355
cat > $TMPH <<EOF
3356
/* Generated by ffconf */
3357
#ifndef AVUTIL_AVCONFIG_H
3358
#define AVUTIL_AVCONFIG_H
3359
EOF
3360

    
3361
print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
3362

    
3363
echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
3364

    
3365
cp_if_changed $TMPH libavutil/avconfig.h
3366

    
3367
test -n "$WARNINGS" && printf "\n$WARNINGS"
3368

    
3369
# build pkg-config files
3370

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

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

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

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