Statistics
| Branch: | Revision:

ffmpeg / configure @ 05aec7bb

History | View | Annotate | Download (88.6 KB)

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

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

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

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

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

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

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

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

    
62
Standard options:
63
  --help                   print this message
64
  --logfile=FILE           log tests and output to FILE [config.err]
65
  --disable-logging        do not log configure debug information
66
  --prefix=PREFIX          install in PREFIX [$prefix]
67
  --bindir=DIR             install binaries in DIR [PREFIX/bin]
68
  --datadir=DIR            install data files in DIR [PREFIX/share/ffmpeg]
69
  --libdir=DIR             install libs in DIR [PREFIX/lib]
70
  --shlibdir=DIR           install shared libs in DIR [PREFIX/lib]
71
  --incdir=DIR             install includes in DIR [PREFIX/include]
72
  --mandir=DIR             install man page in DIR [PREFIX/share/man]
73

    
74
Configuration options:
75
  --disable-static         do not build static libraries [no]
76
  --enable-shared          build shared libraries [no]
77
  --enable-gpl             allow use of GPL code, the resulting libs
78
                           and binaries will be under GPL [no]
79
  --enable-version3        upgrade (L)GPL to version 3 [no]
80
  --enable-nonfree         allow use of nonfree code, the resulting libs
81
                           and binaries will be unredistributable [no]
82
  --disable-doc            do not build documentation
83
  --disable-ffmpeg         disable ffmpeg build
84
  --disable-ffplay         disable ffplay build
85
  --disable-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
  --enable-avfilter        video filter support [no]
93
  --enable-avfilter-lavf   video filters dependent on avformat [no]
94
  --enable-beosthreads     use BeOS threads [no]
95
  --enable-os2threads      use OS/2 threads [no]
96
  --enable-pthreads        use pthreads [no]
97
  --enable-w32threads      use Win32 threads [no]
98
  --enable-x11grab         enable X11 grabbing [no]
99
  --disable-network        disable network support [no]
100
  --disable-mpegaudio-hp   faster (but less accurate) MPEG audio decoding [no]
101
  --enable-gray            enable full grayscale support (slower color)
102
  --disable-swscale-alpha  disable alpha channel support in swscale
103
  --disable-fastdiv        disable table-based division
104
  --enable-small           optimize for size instead of speed
105
  --disable-aandct         disable AAN DCT code
106
  --disable-dct            disable DCT code
107
  --disable-fft            disable FFT code
108
  --disable-golomb         disable Golomb code
109
  --disable-lpc            disable LPC code
110
  --disable-mdct           disable MDCT code
111
  --disable-rdft           disable RDFT code
112
  --disable-vaapi          disable VAAPI code
113
  --disable-vdpau          disable VDPAU code
114
  --disable-dxva2          disable DXVA2 code
115
  --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
116
  --enable-hardcoded-tables use hardcoded tables instead of runtime generation
117
  --enable-memalign-hack   emulate memalign, interferes with memory debuggers
118
  --enable-beos-netserver  enable BeOS netserver
119
  --disable-everything     disable all components listed below
120
  --disable-encoder=NAME   disable encoder NAME
121
  --enable-encoder=NAME    enable encoder NAME
122
  --disable-encoders       disable all encoders
123
  --disable-decoder=NAME   disable decoder NAME
124
  --enable-decoder=NAME    enable decoder NAME
125
  --disable-decoders       disable all decoders
126
  --disable-hwaccel=NAME   disable hwaccel NAME
127
  --enable-hwaccel=NAME    enable hwaccel NAME
128
  --disable-hwaccels       disable all hwaccels
129
  --disable-muxer=NAME     disable muxer NAME
130
  --enable-muxer=NAME      enable muxer NAME
131
  --disable-muxers         disable all muxers
132
  --disable-demuxer=NAME   disable demuxer NAME
133
  --enable-demuxer=NAME    enable demuxer NAME
134
  --disable-demuxers       disable all demuxers
135
  --enable-parser=NAME     enable parser NAME
136
  --disable-parser=NAME    disable parser NAME
137
  --disable-parsers        disable all parsers
138
  --enable-bsf=NAME        enable bitstream filter NAME
139
  --disable-bsf=NAME       disable bitstream filter NAME
140
  --disable-bsfs           disable all bitstream filters
141
  --enable-protocol=NAME   enable protocol NAME
142
  --disable-protocol=NAME  disable protocol NAME
143
  --disable-protocols      disable all protocols
144
  --disable-indev=NAME     disable input device NAME
145
  --disable-outdev=NAME    disable output device NAME
146
  --disable-indevs         disable input devices
147
  --disable-outdevs        disable output devices
148
  --disable-devices        disable all devices
149
  --enable-filter=NAME     enable filter NAME
150
  --disable-filter=NAME    disable filter NAME
151
  --disable-filters        disable all filters
152
  --list-decoders          show all available decoders
153
  --list-encoders          show all available encoders
154
  --list-hwaccels          show all available hardware accelerators
155
  --list-muxers            show all available muxers
156
  --list-demuxers          show all available demuxers
157
  --list-parsers           show all available parsers
158
  --list-protocols         show all available protocols
159
  --list-bsfs              show all available bitstream filters
160
  --list-indevs            show all available input devices
161
  --list-outdevs           show all available output devices
162
  --list-filters           show all available filters
163

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

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

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

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

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

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

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

    
267
die(){
268
    echolog "$@"
269
    cat <<EOF
270

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

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

    
294
tolower(){
295
    echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
296
}
297

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

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

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

    
316
map(){
317
    m=$1
318
    shift
319
    for _; do eval $m; done
320
}
321

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

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

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

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

    
357
enable(){
358
    set_all yes $*
359
}
360

    
361
disable(){
362
    set_all no $*
363
}
364

    
365
enable_weak(){
366
    set_weak yes $*
367
}
368

    
369
disable_weak(){
370
    set_weak no $*
371
}
372

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

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

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

    
398
enable_deep(){
399
    do_enable_deep $*
400
    enable $*
401
}
402

    
403
enable_deep_weak(){
404
    do_enable_deep $*
405
    enable_weak $*
406
}
407

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

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

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

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

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

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

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

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

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

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

    
472
        pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
473
        check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
474
        popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
475

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

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

    
489
        disable ${cfg}_checking
490
    done
491
}
492

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

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

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

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

    
531
temp_cflags(){
532
    save_flags
533
    CFLAGS="$CFLAGS $*"
534
}
535

    
536
temp_ldflags(){
537
    save_flags
538
    LDFLAGS="$LDFLAGS $*"
539
}
540

    
541
temp_extralibs(){
542
    save_flags
543
    extralibs="$extralibs $*"
544
}
545

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

    
553
add_cppflags(){
554
    append CPPFLAGS $($filter_cppflags "$@")
555
}
556

    
557
add_cflags(){
558
    append CFLAGS $($filter_cflags "$@")
559
}
560

    
561
add_asflags(){
562
    append ASFLAGS $($filter_asflags "$@")
563
}
564

    
565
add_ldflags(){
566
    append LDFLAGS "$@"
567
}
568

    
569
add_extralibs(){
570
    append extralibs "$@"
571
}
572

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

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

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

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

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

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

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

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

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

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

    
652
check_ldflags(){
653
    log check_ldflags "$@"
654
    test_ldflags "$@" && add_ldflags "$@"
655
}
656

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

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

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

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

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

    
723
check_lib(){
724
    log check_lib "$@"
725
    header="$1"
726
    func="$2"
727
    shift 2
728
    temp_extralibs "$@"
729
    check_header $header && check_func $func && add_extralibs "$@"
730
    err=$?
731
    restore_flags
732
    return $err
733
}
734

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

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

    
747
check_exec_crash(){
748
    code=$(cat)
749

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

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

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

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

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

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

    
824
check_foo_config(){
825
    cfg=$1
826
    pkg=$2
827
    header=$3
828
    func=$4
829
    shift 4
830
    disable $cfg
831
    check_cmd ${pkg}-config --version
832
    err=$?
833
    if test "$err" = 0; then
834
        temp_cflags $(${pkg}-config --cflags)
835
        temp_extralibs $(${pkg}-config --libs)
836
        check_lib "$@" $header $func && enable $cfg
837
    fi
838
    return $err
839
}
840

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

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

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

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

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

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

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

    
953
THREADS_LIST='
954
    beosthreads
955
    os2threads
956
    pthreads
957
    w32threads
958
'
959

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

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

    
1003
HAVE_LIST_PUB='
1004
    bigendian
1005
'
1006

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

    
1096
# options emitted with CONFIG_ prefix but not available on command line
1097
CONFIG_EXTRA="
1098
    avutil
1099
    gplv3
1100
    lgplv3
1101
"
1102

    
1103
CMDLINE_SELECT="
1104
    $ARCH_EXT_LIST
1105
    $CONFIG_LIST
1106
    $THREADS_LIST
1107
    asm
1108
    cross_compile
1109
    debug
1110
    extra_warnings
1111
    logging
1112
    optimizations
1113
    stripping
1114
    yasm
1115
"
1116

    
1117
PATHS_LIST='
1118
    bindir
1119
    datadir
1120
    incdir
1121
    libdir
1122
    mandir
1123
    prefix
1124
    shlibdir
1125
'
1126

    
1127
CMDLINE_SET="
1128
    $PATHS_LIST
1129
    arch
1130
    as
1131
    build_suffix
1132
    cc
1133
    cpu
1134
    cross_prefix
1135
    dep_cc
1136
    extra_version
1137
    host_cc
1138
    host_cflags
1139
    host_ldflags
1140
    host_libs
1141
    host_os
1142
    ld
1143
    logfile
1144
    malloc_prefix
1145
    nm
1146
    source_path
1147
    strip
1148
    sysinclude
1149
    sysroot
1150
    target_exec
1151
    target_os
1152
    target_path
1153
"
1154

    
1155
CMDLINE_APPEND="
1156
    extra_cflags
1157
"
1158

    
1159
# code dependency declarations
1160

    
1161
# architecture extensions
1162

    
1163
armv5te_deps="arm"
1164
armv6_deps="arm"
1165
armv6t2_deps="arm"
1166
armvfp_deps="arm"
1167
iwmmxt_deps="arm"
1168
neon_deps="arm"
1169

    
1170
mmi_deps="mips"
1171

    
1172
altivec_deps="ppc"
1173
ppc4xx_deps="ppc"
1174

    
1175
vis_deps="sparc"
1176

    
1177
x86_64_suggest="cmov fast_cmov"
1178
amd3dnow_deps="mmx"
1179
amd3dnowext_deps="amd3dnow"
1180
mmx_deps="x86"
1181
mmx2_deps="mmx"
1182
sse_deps="mmx"
1183
ssse3_deps="sse"
1184

    
1185
fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
1186
fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
1187
fast_unaligned_if_any="armv6 ppc x86"
1188

    
1189
need_memalign="altivec neon sse"
1190
inline_asm_deps="!tms470"
1191

    
1192
# subsystems
1193
mdct_select="fft"
1194
rdft_select="fft"
1195

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

    
1324
# parsers
1325
h264_parser_select="golomb"
1326

    
1327
# bitstream_filters
1328
aac_adtstoasc_bsf_select="aac_parser"
1329

    
1330
# external libraries
1331
libdirac_decoder_deps="libdirac !libschroedinger"
1332
libdirac_encoder_deps="libdirac"
1333
libfaac_encoder_deps="libfaac"
1334
libfaad_decoder_deps="libfaad"
1335
libfaadbin_decoder_extralibs='$ldl'
1336
libgsm_decoder_deps="libgsm"
1337
libgsm_encoder_deps="libgsm"
1338
libgsm_ms_decoder_deps="libgsm"
1339
libgsm_ms_encoder_deps="libgsm"
1340
libmp3lame_encoder_deps="libmp3lame"
1341
libopencore_amrnb_decoder_deps="libopencore_amrnb"
1342
libopencore_amrnb_encoder_deps="libopencore_amrnb"
1343
libopencore_amrwb_decoder_deps="libopencore_amrwb"
1344
libopenjpeg_decoder_deps="libopenjpeg"
1345
libschroedinger_decoder_deps="libschroedinger"
1346
libschroedinger_encoder_deps="libschroedinger"
1347
libspeex_decoder_deps="libspeex"
1348
libtheora_encoder_deps="libtheora"
1349
libvorbis_encoder_deps="libvorbis"
1350
libx264_encoder_deps="libx264"
1351
libxvid_encoder_deps="libxvid"
1352

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

    
1380
# indevs / outdevs
1381
alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1382
alsa_indev_extralibs="-lasound"
1383
alsa_outdev_deps="alsa_asoundlib_h"
1384
alsa_outdev_extralibs="-lasound"
1385
audio_beos_indev_deps="audio_beos"
1386
audio_beos_indev_extralibs="-lmedia -lbe"
1387
audio_beos_outdev_deps="audio_beos"
1388
audio_beos_outdev_extralibs="-lmedia -lbe"
1389
bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
1390
dv1394_indev_deps="dv1394 dv_demuxer"
1391
jack_indev_deps="jack_jack_h"
1392
jack_indev_extralibs="-ljack"
1393
libdc1394_indev_deps="libdc1394"
1394
oss_indev_deps_any="soundcard_h sys_soundcard_h"
1395
oss_outdev_deps_any="soundcard_h sys_soundcard_h"
1396
v4l_indev_deps="linux_videodev_h"
1397
v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
1398
vfwcap_indev_deps="capCreateCaptureWindow"
1399
vfwcap_indev_extralibs="-lavicap32"
1400
x11_grab_device_indev_deps="x11grab XShmCreateImage"
1401
x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
1402

    
1403
# protocols
1404
gopher_protocol_deps="network"
1405
http_protocol_deps="network"
1406
http_protocol_select="tcp_protocol"
1407
rtmp_protocol_deps="tcp_protocol"
1408
rtp_protocol_deps="udp_protocol"
1409
tcp_protocol_deps="network"
1410
udp_protocol_deps="network"
1411

    
1412
# filters
1413
movie_filter_deps="avfilter_lavf"
1414
avfilter_lavf_deps="avformat"
1415

    
1416
# libraries
1417
avdevice_deps="avcodec avformat"
1418
avformat_deps="avcodec"
1419

    
1420
# programs
1421
ffmpeg_deps="avcodec avformat swscale"
1422
ffplay_deps="avcodec avformat swscale sdl"
1423
ffplay_select="rdft"
1424
ffprobe_deps="avcodec avformat"
1425
ffserver_deps="avformat ffm_muxer rtp_protocol rtsp_demuxer"
1426
ffserver_extralibs='$ldl'
1427

    
1428
doc_deps="texi2html"
1429

    
1430
# default parameters
1431

    
1432
logfile="config.err"
1433

    
1434
# installation paths
1435
prefix_default="/usr/local"
1436
bindir_default='${prefix}/bin'
1437
datadir_default='${prefix}/share/ffmpeg'
1438
incdir_default='${prefix}/include'
1439
libdir_default='${prefix}/lib'
1440
mandir_default='${prefix}/share/man'
1441
shlibdir_default="$libdir_default"
1442

    
1443
# toolchain
1444
ar="ar"
1445
cc_default="gcc"
1446
cc_version=\"unknown\"
1447
host_cc_default="gcc"
1448
ln_s="ln -sf"
1449
nm_default="nm"
1450
objformat="elf"
1451
ranlib="ranlib"
1452
strip_default="strip"
1453
yasmexe="yasm"
1454

    
1455
nm_opts='-g'
1456

    
1457
# machine
1458
arch_default=$(uname -m)
1459
cpu="generic"
1460

    
1461
# OS
1462
target_os_default=$(tolower $(uname -s))
1463
host_os=$target_os_default
1464

    
1465
# configurable options
1466
enable avcodec
1467
enable avdevice
1468
enable avformat
1469
enable avutil
1470
enable asm
1471
enable debug
1472
enable doc
1473
enable fastdiv
1474
enable ffmpeg
1475
enable ffplay
1476
enable ffprobe
1477
enable ffserver
1478
enable mpegaudio_hp
1479
enable network
1480
enable optimizations
1481
enable protocols
1482
enable static
1483
enable stripping
1484
enable swscale
1485
enable swscale_alpha
1486

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

    
1501
CC_O='-o $@'
1502

    
1503
host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
1504
host_libs='-lm'
1505

    
1506
target_path='$(CURDIR)'
1507

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

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

    
1527
for v in "$@"; do
1528
    r=${v#*=}
1529
    l=${v%"$r"}
1530
    r=$(sh_quote "$r")
1531
    FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
1532
done
1533

    
1534
find_things(){
1535
    thing=$1
1536
    pattern=$2
1537
    file=$source_path/$3
1538
    sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
1539
}
1540

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

    
1553
enable $ARCH_EXT_LIST \
1554
       $DECODER_LIST \
1555
       $ENCODER_LIST \
1556
       $HWACCEL_LIST \
1557
       $PARSER_LIST \
1558
       $BSF_LIST \
1559
       $DEMUXER_LIST \
1560
       $MUXER_LIST \
1561
       $FILTER_LIST \
1562
       $PROTOCOL_LIST \
1563
       $INDEV_LIST \
1564
       $OUTDEV_LIST \
1565

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

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

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

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

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

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

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

    
1646
set_default arch target_os
1647

    
1648
ar="${cross_prefix}${ar}"
1649
cc_default="${cross_prefix}${cc_default}"
1650
nm_default="${cross_prefix}${nm_default}"
1651
ranlib="${cross_prefix}${ranlib}"
1652
strip_default="${cross_prefix}${strip_default}"
1653

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

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

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

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

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

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

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

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

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

    
1701
unset -f mktemp
1702

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

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

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

    
1854
test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
1855

    
1856
: ${as_default:=$cc}
1857
: ${dep_cc_default:=$cc}
1858
: ${ld_default:=$cc}
1859
set_default as dep_cc ld
1860

    
1861
test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
1862
test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
1863

    
1864
add_cflags $extra_cflags
1865
add_asflags $extra_cflags
1866

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

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

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

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

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

    
1945
is_in $arch $ARCH_LIST || echo "WARNING: unknown arch $arch"
1946
enable $arch
1947

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

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

    
1993
elif enabled x86; then
1994

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

    
2019
elif enabled sparc; then
2020

    
2021
    case $cpu in
2022
        sparc64)
2023
            cpuflags="-mcpu=v9"
2024
        ;;
2025
    esac
2026

    
2027
elif enabled arm; then
2028

    
2029
    case $cpu in
2030
        armv*)
2031
            cpuflags="-march=$cpu"
2032
        ;;
2033
        *)
2034
            cpuflags="-mcpu=$cpu"
2035
        ;;
2036
    esac
2037

    
2038
elif enabled alpha; then
2039

    
2040
    enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
2041

    
2042
elif enabled bfin; then
2043

    
2044
    cpuflags="-mcpu=$cpu"
2045

    
2046
elif enabled mips; then
2047

    
2048
    cpuflags="-march=$cpu"
2049

    
2050
elif enabled avr32; then
2051

    
2052
    case $cpu in
2053
        ap7[02]0[0-2])
2054
            subarch="avr32_ap"
2055
            cpuflags="-mpart=$cpu"
2056
        ;;
2057
        ap)
2058
            subarch="avr32_ap"
2059
            cpuflags="-march=$cpu"
2060
        ;;
2061
        uc3[ab]*)
2062
            subarch="avr32_uc"
2063
            cpuflags="-mcpu=$cpu"
2064
        ;;
2065
        uc)
2066
            subarch="avr32_uc"
2067
            cpuflags="-march=$cpu"
2068
        ;;
2069
    esac
2070

    
2071
fi
2072

    
2073
add_cflags $cpuflags
2074
add_asflags $cpuflags
2075

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

    
2089
add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
2090
check_cflags -std=c99
2091
check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
2092
#include <stdlib.h>
2093
EOF
2094
check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
2095
#include <stdlib.h>
2096
EOF
2097

    
2098
check_host_cflags -std=c99
2099

    
2100
case "$arch" in
2101
    alpha|ia64|mips|parisc|sparc)
2102
        spic=$shared
2103
    ;;
2104
    x86)
2105
        subarch="x86_32"
2106
        check_cc <<EOF && subarch="x86_64"
2107
        int test[(int)sizeof(char*) - 7];
2108
EOF
2109
        if test "$subarch" = "x86_64"; then
2110
            spic=$shared
2111
        fi
2112
    ;;
2113
esac
2114

    
2115
enable $subarch
2116
enabled spic && enable pic
2117
check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
2118

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

    
2288
set_default $PATHS_LIST
2289

    
2290
add_extralibs $osextralibs
2291

    
2292
# Combine FFLDFLAGS and the LDFLAGS environment variable.
2293
LDFLAGS="$FFLDFLAGS $LDFLAGS"
2294

    
2295
# we need to build at least one lib type
2296
if ! enabled_any static shared; then
2297
    cat <<EOF
2298
At least one library type must be built.
2299
Specify --enable-static to build the static libraries or --enable-shared to
2300
build the shared libraries as well. To only build the shared libraries specify
2301
--disable-static in addition to --enable-shared.
2302
EOF
2303
    exit 1;
2304
fi
2305

    
2306
disabled static && LIBNAME=""
2307

    
2308
if enabled_any libfaad libfaadbin ; then
2309
    if check_header faad.h; then
2310
        check_cc <<EOF
2311
#include <faad.h>
2312
#ifndef FAAD2_VERSION
2313
ok faad1
2314
#endif
2315
int main(void) { return 0; }
2316
EOF
2317
        test $? = 0 && enable libfaad2
2318
    else
2319
        die "FAAD test failed."
2320
    fi
2321
fi
2322

    
2323

    
2324
die_license_disabled() {
2325
    enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2326
}
2327

    
2328
die_license_disabled gpl libfaad2
2329
die_license_disabled gpl libx264
2330
die_license_disabled gpl libxvid
2331
die_license_disabled gpl postproc
2332
die_license_disabled gpl x11grab
2333

    
2334
die_license_disabled nonfree libfaac
2335

    
2336
die_license_disabled version3 libopencore_amrnb
2337
die_license_disabled version3 libopencore_amrwb
2338

    
2339
enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2340

    
2341
check_deps $ARCH_EXT_LIST
2342

    
2343
disabled optimizations || check_cflags -fomit-frame-pointer
2344

    
2345
enable_pic() {
2346
    enable pic
2347
    add_cppflags -DPIC
2348
    add_cflags   -fPIC
2349
    add_asflags  -fPIC
2350
}
2351

    
2352
enabled pic && enable_pic
2353

    
2354
check_cc <<EOF || die "Symbol mangling check failed."
2355
int ff_extern;
2356
EOF
2357
sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
2358
extern_prefix=${sym%%ff_extern*}
2359

    
2360
check_cc <<EOF && enable inline_asm
2361
void foo(void) { __asm__ volatile ("" ::); }
2362
EOF
2363

    
2364
_restrict=
2365
for restrict_keyword in restrict __restrict__ __restrict; do
2366
    check_cc <<EOF && _restrict=$restrict_keyword && break
2367
void foo(char * $restrict_keyword p);
2368
EOF
2369
done
2370

    
2371
check_cc <<EOF && enable attribute_packed
2372
struct { int x; } __attribute__((packed)) x;
2373
EOF
2374

    
2375
check_cc <<EOF && enable attribute_may_alias
2376
union { int x; } __attribute__((may_alias)) x;
2377
EOF
2378

    
2379
check_cc <<EOF || die "endian test failed"
2380
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
2381
EOF
2382
od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
2383

    
2384
if enabled alpha; then
2385

    
2386
    check_cflags -mieee
2387

    
2388
elif enabled arm; then
2389

    
2390
    check_cflags -marm
2391

    
2392
    check_ld <<EOF && enable vfp_args
2393
__asm__ (".eabi_attribute 28, 1");
2394
int main(void) { return 0; }
2395
EOF
2396

    
2397
    # We have to check if pld is a nop and disable it.
2398
    check_asm pld '"pld [r0]"'
2399

    
2400
    enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2401
    enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
2402
    enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2403
    enabled armvfp  && check_asm armvfp  '"fadds s0, s0, s0"'
2404
    enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
2405
    enabled neon    && check_asm neon    '"vadd.i16 q0, q0, q0"'
2406

    
2407
    enabled_all armv6t2 shared !pic && enable_pic
2408

    
2409
elif enabled ia64; then
2410

    
2411
    # HACK: currently fails to build if .bss is > 4MB and shared libs are built
2412
    enabled shared && enable_weak hardcoded_tables
2413

    
2414
elif enabled mips; then
2415

    
2416
    check_asm loongson '"dmult.g $1, $2, $3"'
2417
    enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
2418

    
2419
elif enabled ppc; then
2420

    
2421
    enable local_aligned_8 local_aligned_16
2422

    
2423
    check_asm dcbzl     '"dcbzl 0, 1"'
2424
    check_asm ppc4xx    '"maclhw r10, r11, r12"'
2425
    check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
2426

    
2427
    # AltiVec flags: The FSF version of GCC differs from the Apple version
2428
    if enabled altivec; then
2429
        check_cflags -maltivec -mabi=altivec &&
2430
        { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
2431
        check_cflags -faltivec
2432

    
2433
        # check if our compiler supports Motorola AltiVec C API
2434
        check_cc <<EOF || disable altivec
2435
$inc_altivec_h
2436
int main(void) {
2437
    vector signed int v1, v2, v3;
2438
    v1 = vec_add(v2,v3);
2439
    return 0;
2440
}
2441
EOF
2442

    
2443
        # check if our compiler supports braces for vector declarations
2444
        check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
2445
$inc_altivec_h
2446
int main (void) { (vector int) {1}; return 0; }
2447
EOF
2448
    fi
2449

    
2450
elif enabled sparc; then
2451

    
2452
    enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2453
        add_cflags -mcpu=ultrasparc -mtune=ultrasparc
2454

    
2455
elif enabled x86; then
2456

    
2457
    enable local_aligned_8 local_aligned_16
2458

    
2459
    # check whether EBP is available on x86
2460
    # As 'i' is stored on the stack, this program will crash
2461
    # if the base pointer is used to access it because the
2462
    # base pointer is cleared in the inline assembly code.
2463
    check_exec_crash <<EOF && enable ebp_available
2464
    volatile int i=0;
2465
    __asm__ volatile (
2466
        "xorl %%ebp, %%ebp"
2467
    ::: "%ebp");
2468
    return i;
2469
EOF
2470

    
2471
    # check whether EBX is available on x86
2472
    check_asm ebx_available '""::"b"(0)' &&
2473
        check_asm ebx_available '"":::"%ebx"'
2474

    
2475
    # check whether more than 10 operands are supported
2476
    check_cc <<EOF && enable ten_operands
2477
int main(void) {
2478
    int x=0;
2479
    __asm__ volatile(
2480
        ""
2481
        :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
2482
    );
2483
    return 0;
2484
}
2485
EOF
2486

    
2487
    # check whether binutils is new enough to compile SSSE3/MMX2
2488
    enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
2489
    enabled mmx2  && check_asm mmx2  '"pmaxub %mm0, %mm1"'
2490

    
2491
    check_asm bswap '"bswap %%eax" ::: "%eax"'
2492

    
2493
    YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
2494
    enabled     x86_64        && append YASMFLAGS "-m amd64"
2495
    enabled     pic           && append YASMFLAGS "-DPIC"
2496
    test -n "$extern_prefix"  && append YASMFLAGS "-DPREFIX"
2497
    case "$objformat" in
2498
        elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
2499
    esac
2500
    disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
2501

    
2502
    case "$cpu" in
2503
        athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
2504
            disable fast_clz
2505
        ;;
2506
    esac
2507

    
2508
fi
2509

    
2510
if check_func dlopen; then
2511
    ldl=
2512
elif check_func dlopen -ldl; then
2513
    ldl=-ldl
2514
fi
2515

    
2516
# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2517
check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2518

    
2519
check_func  fork
2520
check_func  getaddrinfo $network_extralibs
2521
check_func  gethrtime
2522
check_func  getrusage
2523
check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
2524
check_func  inet_aton $network_extralibs
2525
check_func  isatty
2526
check_func  ${malloc_prefix}memalign            && enable memalign
2527
check_func  mkstemp
2528
check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
2529
check_func  setrlimit
2530
check_func_headers io.h setmode
2531
check_func_headers lzo/lzo1x.h lzo1x_999_compress
2532
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
2533
check_func_headers windows.h GetProcessTimes
2534
check_func_headers windows.h VirtualAlloc
2535

    
2536
check_header conio.h
2537
check_header dlfcn.h
2538
check_header dxva2api.h
2539
check_header malloc.h
2540
check_header poll.h
2541
check_header sys/mman.h
2542
check_header sys/resource.h
2543
check_header sys/select.h
2544
check_header termios.h
2545
check_header vdpau/vdpau.h
2546
check_header vdpau/vdpau_x11.h
2547
check_header X11/extensions/XvMClib.h
2548

    
2549
check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex
2550

    
2551
if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
2552
     enabled_any $need_memalign ; then
2553
    die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
2554
fi
2555

    
2556
disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
2557
disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
2558

    
2559
# check for some common methods of building with pthread support
2560
# do this before the optional library checks as some of them require pthreads
2561
if enabled pthreads; then
2562
    if check_func pthread_create; then
2563
        :
2564
    elif check_func pthread_create -pthread; then
2565
        add_cflags -pthread
2566
        add_extralibs -pthread
2567
    elif check_func pthread_create -pthreads; then
2568
        add_cflags -pthreads
2569
        add_extralibs -pthreads
2570
    elif check_func pthread_create -lpthreadGC2; then
2571
        add_extralibs -lpthreadGC2
2572
    elif ! check_lib pthread.h pthread_create -lpthread; then
2573
        die "ERROR: can't find pthreads library"
2574
    fi
2575
fi
2576

    
2577
for thread in $THREADS_LIST; do
2578
    if enabled $thread; then
2579
        test -n "$thread_type" &&
2580
            die "ERROR: Only one thread type must be selected." ||
2581
            thread_type="$thread"
2582
    fi
2583
done
2584

    
2585
check_lib math.h sin -lm
2586
check_lib va/va.h vaInitialize -lva
2587

    
2588
check_mathfunc exp2
2589
check_mathfunc exp2f
2590
check_mathfunc llrint
2591
check_mathfunc log2
2592
check_mathfunc log2f
2593
check_mathfunc lrint
2594
check_mathfunc lrintf
2595
check_mathfunc round
2596
check_mathfunc roundf
2597
check_mathfunc truncf
2598

    
2599
# these are off by default, so fail if requested and not available
2600
enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
2601
enabled libdirac   && add_cflags $(pkg-config --cflags dirac) &&
2602
                      require  libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
2603
                      require  libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
2604
enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
2605
enabled libfaad    && require2 libfaad faad.h faacDecOpen -lfaad
2606
enabled libgsm     && require  libgsm gsm/gsm.h gsm_create -lgsm
2607
enabled libmp3lame && require  libmp3lame lame/lame.h lame_init -lmp3lame -lm
2608
enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
2609
enabled libopencore_amrnb  && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
2610
enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
2611
enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
2612
enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
2613
                           require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
2614
enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
2615
enabled libtheora  && require  libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
2616
enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
2617
enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 -lm &&
2618
                      { check_cpp_condition x264.h "X264_BUILD >= 83" ||
2619
                        die "ERROR: libx264 version must be >= 0.83."; }
2620
enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
2621
enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
2622

    
2623
# libdc1394 check
2624
if enabled libdc1394; then
2625
    { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2626
        enable libdc1394_2; } ||
2627
    { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2628
        enable libdc1394_1; } ||
2629
    die "ERROR: No version of libdc1394 found "
2630
fi
2631

    
2632
SDL_CONFIG="${cross_prefix}sdl-config"
2633
if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
2634
    sdl_cflags=$("${SDL_CONFIG}" --cflags)
2635
    sdl_libs=$("${SDL_CONFIG}" --libs)
2636
    check_func_headers SDL.h SDL_Init $sdl_cflags $sdl_libs &&
2637
    check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
2638
    enable sdl &&
2639
    check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
2640
fi
2641

    
2642
texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
2643

    
2644
if enabled network; then
2645
    check_type "sys/types.h sys/socket.h" socklen_t
2646
    check_type netdb.h "struct addrinfo"
2647
    check_type netinet/in.h "struct ipv6_mreq"
2648
    check_type netinet/in.h "struct sockaddr_in6"
2649
    check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
2650
    check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
2651
    # Prefer arpa/inet.h over winsock2
2652
    if check_header arpa/inet.h ; then
2653
        check_func closesocket
2654
    elif check_header winsock2.h ; then
2655
        check_func_headers winsock2.h closesocket -lws2 && \
2656
            network_extralibs="-lws2" || \
2657
        { check_func_headers winsock2.h closesocket -lws2_32 && \
2658
            network_extralibs="-lws2_32"; }
2659
        check_type ws2tcpip.h socklen_t
2660
        check_type ws2tcpip.h "struct addrinfo"
2661
        check_type ws2tcpip.h "struct ipv6_mreq"
2662
        check_type ws2tcpip.h "struct sockaddr_in6"
2663
        check_type ws2tcpip.h "struct sockaddr_storage"
2664
        check_struct winsock2.h "struct sockaddr" sa_len
2665
    else
2666
        disable network
2667
    fi
2668
fi
2669

    
2670
check_header linux/videodev.h
2671
check_header linux/videodev2.h
2672
check_header sys/videoio.h
2673

    
2674
check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
2675

    
2676
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
2677
{ check_header dev/bktr/ioctl_meteor.h &&
2678
  check_header dev/bktr/ioctl_bt848.h; } ||
2679
{ check_header machine/ioctl_meteor.h &&
2680
  check_header machine/ioctl_bt848.h; } ||
2681
{ check_header dev/video/meteor/ioctl_meteor.h &&
2682
  check_header dev/video/bktr/ioctl_bt848.h; } ||
2683
check_header dev/ic/bt8xx.h
2684

    
2685
check_header sys/soundcard.h
2686
check_header soundcard.h
2687

    
2688
enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
2689

    
2690
enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
2691

    
2692
enabled x11grab                         &&
2693
check_header X11/Xlib.h                 &&
2694
check_header X11/extensions/XShm.h      &&
2695
check_header X11/extensions/Xfixes.h    &&
2696
check_func XOpenDisplay -lX11           &&
2697
check_func XShmCreateImage -lX11 -lXext &&
2698
check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
2699

    
2700
if ! disabled vdpau && enabled vdpau_vdpau_h; then
2701
check_cpp_condition \
2702
    vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
2703
    { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
2704
      disable vdpau; }
2705
fi
2706

    
2707
enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
2708

    
2709
# add some useful compiler flags if supported
2710
check_cflags -Wdeclaration-after-statement
2711
check_cflags -Wall
2712
check_cflags -Wno-switch
2713
check_cflags -Wdisabled-optimization
2714
check_cflags -Wpointer-arith
2715
check_cflags -Wredundant-decls
2716
check_cflags -Wno-pointer-sign
2717
check_cflags -Wcast-qual
2718
check_cflags -Wwrite-strings
2719
check_cflags -Wtype-limits
2720
check_cflags -Wundef
2721
check_cflags -Wmissing-prototypes
2722
enabled extra_warnings && check_cflags -Winline
2723

    
2724
# add some linker flags
2725
check_ldflags -Wl,--warn-common
2726
check_ldflags -Wl,--as-needed
2727
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'
2728
check_ldflags -Wl,-Bsymbolic
2729

    
2730
echo "X{};" > $TMPV
2731
test_ldflags -Wl,--version-script,$TMPV &&
2732
    append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
2733

    
2734
if enabled small; then
2735
    add_cflags $size_cflags
2736
    optimizations="small"
2737
elif enabled optimizations; then
2738
    add_cflags $speed_cflags
2739
fi
2740
check_cflags -fno-math-errno
2741
check_cflags -fno-signed-zeros
2742

    
2743
if enabled icc; then
2744
    # Just warnings, no remarks
2745
    check_cflags -w1
2746
    # -wd: Disable following warnings
2747
    # 144, 167, 556: -Wno-pointer-sign
2748
    # 10006: ignoring unknown option -fno-signed-zeros
2749
    # 10156: ignoring option '-W'; no argument required
2750
    check_cflags -wd144,167,556,10006,10156
2751
    # 11030: Warning unknown option --as-needed
2752
    # 10156: ignoring option '-export'; no argument required
2753
    check_ldflags -wd10156,11030
2754
    # Allow to compile with optimizations
2755
    check_ldflags -march=$cpu
2756
    # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
2757
    enable ebp_available
2758
elif enabled ccc; then
2759
    # disable some annoying warnings
2760
    add_cflags -msg_disable cvtu32to64
2761
    add_cflags -msg_disable embedcomment
2762
    add_cflags -msg_disable needconstext
2763
    add_cflags -msg_disable nomainieee
2764
    add_cflags -msg_disable ptrmismatch1
2765
    add_cflags -msg_disable unreachcode
2766
elif enabled gcc; then
2767
    check_cflags -fno-tree-vectorize
2768
    check_cflags -Werror=implicit
2769
    check_cflags -Werror=missing-prototypes
2770
elif enabled clang; then
2771
    check_cflags -Qunused-arguments
2772
elif enabled armcc; then
2773
    # 2523: use of inline assembler is deprecated
2774
    add_cflags -Wrvct,--diag_suppress=2523
2775
    add_cflags -Wrvct,--diag_suppress=1207
2776
elif enabled tms470; then
2777
    add_cflags -pds=824 -pds=837
2778
fi
2779

    
2780
if enabled gprof; then
2781
    add_cflags  -p
2782
    add_ldflags -p
2783
fi
2784

    
2785
# Find out if the .align argument is a power of two or not.
2786
check_asm asmalign_pot '".align 3"'
2787

    
2788
enabled_any $DECODER_LIST      && enable decoders
2789
enabled_any $ENCODER_LIST      && enable encoders
2790
enabled_any $HWACCEL_LIST      && enable hwaccels
2791
enabled_any $BSF_LIST          && enable bsfs
2792
enabled_any $DEMUXER_LIST      && enable demuxers
2793
enabled_any $MUXER_LIST        && enable muxers
2794
enabled_any $FILTER_LIST       && enable filters
2795
enabled_any $INDEV_LIST        && enable indevs
2796
enabled_any $OUTDEV_LIST       && enable outdevs
2797
enabled_any $PROTOCOL_LIST     && enable protocols
2798

    
2799
enabled_any $THREADS_LIST      && enable threads
2800

    
2801
check_deps $CONFIG_LIST       \
2802
           $CONFIG_EXTRA      \
2803
           $HAVE_LIST         \
2804
           $DECODER_LIST      \
2805
           $ENCODER_LIST      \
2806
           $HWACCEL_LIST      \
2807
           $PARSER_LIST       \
2808
           $BSF_LIST          \
2809
           $DEMUXER_LIST      \
2810
           $MUXER_LIST        \
2811
           $FILTER_LIST       \
2812
           $INDEV_LIST        \
2813
           $OUTDEV_LIST       \
2814
           $PROTOCOL_LIST     \
2815

    
2816
enabled asm || disable $ARCH_LIST $ARCH_EXT_LIST
2817

    
2818
echo "install prefix            $prefix"
2819
echo "source path               $source_path"
2820
echo "C compiler                $cc"
2821
echo ".align is power-of-two    $asmalign_pot"
2822
echo "ARCH                      $arch ($cpu)"
2823
if test "$build_suffix" != ""; then
2824
    echo "build suffix              $build_suffix"
2825
fi
2826
if test "$extra_version" != ""; then
2827
    echo "version string suffix     $extra_version"
2828
fi
2829
echo "big-endian                ${bigendian-no}"
2830
echo "runtime cpu detection     ${runtime_cpudetect-no}"
2831
if enabled x86; then
2832
    echo "yasm                      ${yasm-no}"
2833
    echo "MMX enabled               ${mmx-no}"
2834
    echo "MMX2 enabled              ${mmx2-no}"
2835
    echo "3DNow! enabled            ${amd3dnow-no}"
2836
    echo "3DNow! extended enabled   ${amd3dnowext-no}"
2837
    echo "SSE enabled               ${sse-no}"
2838
    echo "SSSE3 enabled             ${ssse3-no}"
2839
    echo "CMOV enabled              ${cmov-no}"
2840
    echo "CMOV is fast              ${fast_cmov-no}"
2841
    echo "EBX available             ${ebx_available-no}"
2842
    echo "EBP available             ${ebp_available-no}"
2843
    echo "10 operands supported     ${ten_operands-no}"
2844
fi
2845
if enabled arm; then
2846
    echo "ARMv5TE enabled           ${armv5te-no}"
2847
    echo "ARMv6 enabled             ${armv6-no}"
2848
    echo "ARMv6T2 enabled           ${armv6t2-no}"
2849
    echo "ARM VFP enabled           ${armvfp-no}"
2850
    echo "IWMMXT enabled            ${iwmmxt-no}"
2851
    echo "NEON enabled              ${neon-no}"
2852
fi
2853
if enabled mips; then
2854
    echo "MMI enabled               ${mmi-no}"
2855
fi
2856
if enabled ppc; then
2857
    echo "AltiVec enabled           ${altivec-no}"
2858
    echo "PPC 4xx optimizations     ${ppc4xx-no}"
2859
    echo "dcbzl available           ${dcbzl-no}"
2860
    echo "performance report        ${powerpc_perf-no}"
2861
fi
2862
if enabled sparc; then
2863
    echo "VIS enabled               ${vis-no}"
2864
fi
2865
echo "gprof enabled             ${gprof-no}"
2866
echo "debug symbols             ${debug-no}"
2867
echo "strip symbols             ${stripping-no}"
2868
echo "optimizations             ${optimizations-no}"
2869
echo "static                    ${static-no}"
2870
echo "shared                    ${shared-no}"
2871
echo "postprocessing support    ${postproc-no}"
2872
echo "new filter support        ${avfilter-no}"
2873
echo "filters using lavformat   ${avfilter_lavf-no}"
2874
echo "network support           ${network-no}"
2875
echo "threading support         ${thread_type-no}"
2876
echo "SDL support               ${sdl-no}"
2877
echo "Sun medialib support      ${mlib-no}"
2878
echo "AVISynth enabled          ${avisynth-no}"
2879
echo "libdc1394 support         ${libdc1394-no}"
2880
echo "libdirac enabled          ${libdirac-no}"
2881
echo "libfaac enabled           ${libfaac-no}"
2882
echo "libfaad enabled           ${libfaad-no}"
2883
echo "libfaad dlopened          ${libfaadbin-no}"
2884
echo "libgsm enabled            ${libgsm-no}"
2885
echo "libmp3lame enabled        ${libmp3lame-no}"
2886
echo "libnut enabled            ${libnut-no}"
2887
echo "libopencore-amrnb support ${libopencore_amrnb-no}"
2888
echo "libopencore-amrwb support ${libopencore_amrwb-no}"
2889
echo "libopenjpeg enabled       ${libopenjpeg-no}"
2890
echo "libschroedinger enabled   ${libschroedinger-no}"
2891
echo "libspeex enabled          ${libspeex-no}"
2892
echo "libtheora enabled         ${libtheora-no}"
2893
echo "libvorbis enabled         ${libvorbis-no}"
2894
echo "libx264 enabled           ${libx264-no}"
2895
echo "libxvid enabled           ${libxvid-no}"
2896
echo "zlib enabled              ${zlib-no}"
2897
echo "bzlib enabled             ${bzlib-no}"
2898
echo
2899

    
2900
for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
2901
    echo "Enabled ${type}s:"
2902
    eval list=\$$(toupper $type)_LIST
2903
    for part in $list; do
2904
        enabled $part && echo ${part%_*}
2905
    done | sort | pr -3 -t
2906
    echo
2907
done
2908

    
2909
license="LGPL version 2.1 or later"
2910
if enabled nonfree; then
2911
    license="nonfree and unredistributable"
2912
elif enabled gplv3; then
2913
    license="GPL version 3 or later"
2914
elif enabled lgplv3; then
2915
    license="LGPL version 3 or later"
2916
elif enabled gpl; then
2917
    license="GPL version 2 or later"
2918
fi
2919

    
2920
echo "License: $license"
2921

    
2922
echo "Creating config.mak and config.h..."
2923

    
2924
# build tree in object directory if source path is different from current one
2925
if enabled source_path_used; then
2926
    DIRS="
2927
        doc
2928
        libavcodec
2929
        libavcodec/$arch
2930
        libavdevice
2931
        libavfilter
2932
        libavformat
2933
        libavutil
2934
        libavutil/$arch
2935
        libpostproc
2936
        libswscale
2937
        libswscale/$arch
2938
        tests
2939
        tools
2940
    "
2941
    FILES="
2942
        Makefile
2943
        common.mak
2944
        subdir.mak
2945
        doc/texi2pod.pl
2946
        libavcodec/Makefile
2947
        libavdevice/Makefile
2948
        libavfilter/Makefile
2949
        libavformat/Makefile
2950
        libavutil/Makefile
2951
        libpostproc/Makefile
2952
        libswscale/Makefile
2953
    "
2954
    map 'mkdir -p $_' $DIRS;
2955
    map '$ln_s "$source_path/$_" $_' $FILES
2956
fi
2957

    
2958
enabled stripping || strip="echo skipping strip"
2959

    
2960
cat > config.mak <<EOF
2961
# Automatically generated by configure - do not modify!
2962
ifndef FFMPEG_CONFIG_MAK
2963
FFMPEG_CONFIG_MAK=1
2964
FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
2965
prefix=$prefix
2966
LIBDIR=\$(DESTDIR)$libdir
2967
SHLIBDIR=\$(DESTDIR)$shlibdir
2968
INCDIR=\$(DESTDIR)$incdir
2969
BINDIR=\$(DESTDIR)$bindir
2970
DATADIR=\$(DESTDIR)$datadir
2971
MANDIR=\$(DESTDIR)$mandir
2972
SRC_PATH="$source_path"
2973
SRC_PATH_BARE=$source_path
2974
BUILD_ROOT="$PWD"
2975
ARCH=$arch
2976
CC=$cc
2977
AS=$as
2978
LD=$ld
2979
DEPCC=$dep_cc
2980
YASM=$yasmexe
2981
YASMDEP=$yasmexe
2982
AR=$ar
2983
RANLIB=$ranlib
2984
CP=cp -p
2985
LN_S=$ln_s
2986
STRIP=$strip
2987
CPPFLAGS=$CPPFLAGS
2988
CFLAGS=$CFLAGS
2989
ASFLAGS=$ASFLAGS
2990
CC_O=$CC_O
2991
LDFLAGS=$LDFLAGS
2992
FFSERVERLDFLAGS=$FFSERVERLDFLAGS
2993
SHFLAGS=$SHFLAGS
2994
YASMFLAGS=$YASMFLAGS
2995
BUILDSUF=$build_suffix
2996
FULLNAME=$FULLNAME
2997
LIBPREF=$LIBPREF
2998
LIBSUF=$LIBSUF
2999
LIBNAME=$LIBNAME
3000
SLIBPREF=$SLIBPREF
3001
SLIBSUF=$SLIBSUF
3002
EXESUF=$EXESUF
3003
EXTRA_VERSION=$extra_version
3004
DEPFLAGS=$DEPFLAGS
3005
CCDEP=$CCDEP
3006
ASDEP=$ASDEP
3007
CC_DEPFLAGS=$CC_DEPFLAGS
3008
AS_DEPFLAGS=$AS_DEPFLAGS
3009
HOSTCC=$host_cc
3010
HOSTCFLAGS=$host_cflags
3011
HOSTEXESUF=$HOSTEXESUF
3012
HOSTLDFLAGS=$host_ldflags
3013
HOSTLIBS=$host_libs
3014
TARGET_EXEC=$target_exec
3015
TARGET_PATH=$target_path
3016
SDL_LIBS=$sdl_libs
3017
SDL_CFLAGS=$sdl_cflags
3018
LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
3019
EXTRALIBS=$extralibs
3020
INSTALL=install
3021
LIBTARGET=${LIBTARGET}
3022
SLIBNAME=${SLIBNAME}
3023
SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
3024
SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
3025
SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
3026
SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
3027
SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}
3028
SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}
3029
EOF
3030

    
3031
get_version(){
3032
    name=$1
3033
    file=$source_path/$2
3034
    eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
3035
    eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
3036
    lcname=$(tolower $name)
3037
    eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
3038
    eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
3039
}
3040

    
3041
get_version LIBSWSCALE  libswscale/swscale.h
3042
get_version LIBPOSTPROC libpostproc/postprocess.h
3043
get_version LIBAVCODEC  libavcodec/avcodec.h
3044
get_version LIBAVDEVICE libavdevice/avdevice.h
3045
get_version LIBAVFORMAT libavformat/avformat.h
3046
get_version LIBAVUTIL   libavutil/avutil.h
3047
get_version LIBAVFILTER libavfilter/avfilter.h
3048

    
3049
enabled asmalign_pot || align_shift="1 <<"
3050

    
3051
cat > $TMPH <<EOF
3052
/* Automatically generated by configure - do not modify! */
3053
#ifndef FFMPEG_CONFIG_H
3054
#define FFMPEG_CONFIG_H
3055
#define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
3056
#define FFMPEG_LICENSE "$(c_escape $license)"
3057
#define FFMPEG_DATADIR "$(eval c_escape $datadir)"
3058
#define CC_TYPE "$cc_type"
3059
#define CC_VERSION $cc_version
3060
#define restrict $_restrict
3061
#define ASMALIGN(ZEROBITS) ".align $align_shift " #ZEROBITS "\\n\\t"
3062
#define EXTERN_PREFIX "${extern_prefix}"
3063
#define EXTERN_ASM ${extern_prefix}
3064
EOF
3065

    
3066
test -n "$malloc_prefix" &&
3067
    echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
3068

    
3069
if enabled small || disabled optimizations; then
3070
    echo "#undef  av_always_inline"  >> $TMPH
3071
    echo "#define av_always_inline"  >> $TMPH
3072
fi
3073

    
3074
print_config ARCH_   $TMPH config.mak $ARCH_LIST
3075
print_config HAVE_   $TMPH config.mak $HAVE_LIST
3076
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST       \
3077
                                      $CONFIG_EXTRA      \
3078
                                      $DECODER_LIST      \
3079
                                      $ENCODER_LIST      \
3080
                                      $HWACCEL_LIST      \
3081
                                      $PARSER_LIST       \
3082
                                      $BSF_LIST          \
3083
                                      $DEMUXER_LIST      \
3084
                                      $MUXER_LIST        \
3085
                                      $FILTER_LIST       \
3086
                                      $PROTOCOL_LIST     \
3087
                                      $INDEV_LIST        \
3088
                                      $OUTDEV_LIST       \
3089

    
3090
echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
3091
echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
3092

    
3093
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3094
cp_if_changed $TMPH config.h
3095

    
3096
cat > $TMPH <<EOF
3097
/* Generated by ffconf */
3098
#ifndef AVUTIL_AVCONFIG_H
3099
#define AVUTIL_AVCONFIG_H
3100
EOF
3101

    
3102
print_config AV_HAVE_ $TMPH /dev/null $HAVE_LIST_PUB
3103

    
3104
echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
3105

    
3106
cp_if_changed $TMPH libavutil/avconfig.h
3107

    
3108
# build pkg-config files
3109

    
3110
pkgconfig_generate(){
3111
name=$1
3112
shortname=${name#lib}${build_suffix}
3113
comment=$2
3114
version=$3
3115
libs=$4
3116
requires=$5
3117
cat <<EOF > $name/$name.pc
3118
prefix=$prefix
3119
exec_prefix=\${prefix}
3120
libdir=$libdir
3121
includedir=$incdir
3122

    
3123
Name: $name
3124
Description: $comment
3125
Version: $version
3126
Requires: $(enabled shared || echo $requires)
3127
Requires.private: $(enabled shared && echo $requires)
3128
Conflicts:
3129
Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
3130
Libs.private: $(enabled shared && echo $libs)
3131
Cflags: -I\${includedir}
3132
EOF
3133
cat <<EOF > $name/$name-uninstalled.pc
3134
prefix=
3135
exec_prefix=
3136
libdir=\${pcfiledir}
3137
includedir=${source_path}
3138

    
3139
Name: $name
3140
Description: $comment
3141
Version: $version
3142
Requires: $requires
3143
Conflicts:
3144
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
3145
Cflags: -I\${includedir}
3146
EOF
3147
}
3148

    
3149
pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
3150
pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3151
pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
3152
pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3153
enabled avfilter &&
3154
    pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3155
enabled postproc &&
3156
    pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
3157
pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"