Statistics
| Branch: | Revision:

ffmpeg / configure @ 3952471d

History | View | Annotate | Download (88.5 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-encoder=NAME   disable encoder NAME
120
  --enable-encoder=NAME    enable encoder NAME
121
  --disable-encoders       disable all encoders
122
  --disable-decoder=NAME   disable decoder NAME
123
  --enable-decoder=NAME    enable decoder NAME
124
  --disable-decoders       disable all decoders
125
  --disable-hwaccel=NAME   disable hwaccel NAME
126
  --enable-hwaccel=NAME    enable hwaccel NAME
127
  --disable-hwaccels       disable all hwaccels
128
  --disable-muxer=NAME     disable muxer NAME
129
  --enable-muxer=NAME      enable muxer NAME
130
  --disable-muxers         disable all muxers
131
  --disable-demuxer=NAME   disable demuxer NAME
132
  --enable-demuxer=NAME    enable demuxer NAME
133
  --disable-demuxers       disable all demuxers
134
  --enable-parser=NAME     enable parser NAME
135
  --disable-parser=NAME    disable parser NAME
136
  --disable-parsers        disable all parsers
137
  --enable-bsf=NAME        enable bitstream filter NAME
138
  --disable-bsf=NAME       disable bitstream filter NAME
139
  --disable-bsfs           disable all bitstream filters
140
  --enable-protocol=NAME   enable protocol NAME
141
  --disable-protocol=NAME  disable protocol NAME
142
  --disable-protocols      disable all protocols
143
  --disable-indev=NAME     disable input device NAME
144
  --disable-outdev=NAME    disable output device NAME
145
  --disable-indevs         disable input devices
146
  --disable-outdevs        disable output devices
147
  --disable-devices        disable all devices
148
  --enable-filter=NAME     enable filter NAME
149
  --disable-filter=NAME    disable filter NAME
150
  --disable-filters        disable all filters
151
  --list-decoders          show all available decoders
152
  --list-encoders          show all available encoders
153
  --list-hwaccels          show all available hardware accelerators
154
  --list-muxers            show all available muxers
155
  --list-demuxers          show all available demuxers
156
  --list-parsers           show all available parsers
157
  --list-protocols         show all available protocols
158
  --list-bsfs              show all available bitstream filters
159
  --list-indevs            show all available input devices
160
  --list-outdevs           show all available output devices
161
  --list-filters           show all available filters
162

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
951
THREADS_LIST='
952
    beosthreads
953
    os2threads
954
    pthreads
955
    w32threads
956
'
957

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

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

    
1001
HAVE_LIST_PUB='
1002
    bigendian
1003
'
1004

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

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

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

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

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

    
1153
CMDLINE_APPEND="
1154
    extra_cflags
1155
"
1156

    
1157
# code dependency declarations
1158

    
1159
# architecture extensions
1160

    
1161
armv5te_deps="arm"
1162
armv6_deps="arm"
1163
armv6t2_deps="arm"
1164
armvfp_deps="arm"
1165
iwmmxt_deps="arm"
1166
neon_deps="arm"
1167

    
1168
mmi_deps="mips"
1169

    
1170
altivec_deps="ppc"
1171
ppc4xx_deps="ppc"
1172

    
1173
vis_deps="sparc"
1174

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

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

    
1187
need_memalign="altivec neon sse"
1188
inline_asm_deps="!tms470"
1189

    
1190
# subsystems
1191
mdct_select="fft"
1192
rdft_select="fft"
1193

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

    
1321
# parsers
1322
h264_parser_select="golomb"
1323

    
1324
# bitstream_filters
1325
aac_adtstoasc_bsf_select="aac_parser"
1326

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

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

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

    
1400
# protocols
1401
gopher_protocol_deps="network"
1402
http_protocol_deps="network"
1403
http_protocol_select="tcp_protocol"
1404
rtmp_protocol_deps="tcp_protocol"
1405
rtp_protocol_deps="udp_protocol"
1406
tcp_protocol_deps="network"
1407
udp_protocol_deps="network"
1408

    
1409
# filters
1410
movie_filter_deps="avfilter_lavf"
1411
avfilter_lavf_deps="avformat"
1412

    
1413
# libraries
1414
avdevice_deps="avcodec avformat"
1415
avformat_deps="avcodec"
1416

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

    
1425
doc_deps="texi2html"
1426

    
1427
# default parameters
1428

    
1429
logfile="config.err"
1430

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

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

    
1452
nm_opts='-g'
1453

    
1454
# machine
1455
arch_default=$(uname -m)
1456
cpu="generic"
1457

    
1458
# OS
1459
target_os_default=$(tolower $(uname -s))
1460
host_os=$target_os_default
1461

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

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

    
1498
CC_O='-o $@'
1499

    
1500
host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
1501
host_libs='-lm'
1502

    
1503
target_path='$(CURDIR)'
1504

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

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

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

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

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

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

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

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

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

    
1631
disabled logging && logfile=/dev/null
1632

    
1633
echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
1634
set >> $logfile
1635

    
1636
test -n "$cross_prefix" && enable cross_compile
1637

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

    
1643
set_default arch target_os
1644

    
1645
ar="${cross_prefix}${ar}"
1646
cc_default="${cross_prefix}${cc_default}"
1647
nm_default="${cross_prefix}${nm_default}"
1648
ranlib="${cross_prefix}${ranlib}"
1649
strip_default="${cross_prefix}${strip_default}"
1650

    
1651
sysinclude_default="${sysroot}/usr/include"
1652

    
1653
set_default cc nm strip sysinclude
1654
enabled cross_compile || host_cc_default=$cc
1655
set_default host_cc
1656

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

    
1663
EXESUF=$(exesuf $target_os)
1664
HOSTEXESUF=$(exesuf $host_os)
1665

    
1666
# set temporary file name
1667
: ${TMPDIR:=$TEMPDIR}
1668
: ${TMPDIR:=$TMP}
1669
: ${TMPDIR:=/tmp}
1670

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

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

    
1687
trap 'rm -f -- $TMPFILES' EXIT
1688
trap exit HUP INT TERM
1689

    
1690
tmpfile TMPC  .c
1691
tmpfile TMPE  $EXESUF
1692
tmpfile TMPH  .h
1693
tmpfile TMPO  .o
1694
tmpfile TMPS  .S
1695
tmpfile TMPV  .ver
1696
tmpfile TMPSH .sh
1697

    
1698
unset -f mktemp
1699

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

    
1713
filter_cflags=echo
1714
filter_cppflags=echo
1715
filter_asflags=echo
1716

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

    
1851
test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
1852

    
1853
: ${as_default:=$cc}
1854
: ${dep_cc_default:=$cc}
1855
: ${ld_default:=$cc}
1856
set_default as dep_cc ld
1857

    
1858
test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
1859
test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
1860

    
1861
add_cflags $extra_cflags
1862
add_asflags $extra_cflags
1863

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

    
1881
if test "$cpu" = host; then
1882
    enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
1883

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

    
1898
    test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
1899
fi
1900

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

    
1942
is_in $arch $ARCH_LIST || echo "WARNING: unknown arch $arch"
1943
enable $arch
1944

    
1945
# Add processor-specific flags
1946
if test "$cpu" = generic; then
1947
    : do nothing
1948
elif enabled ppc; then
1949

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

    
1990
elif enabled x86; then
1991

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

    
2016
elif enabled sparc; then
2017

    
2018
    case $cpu in
2019
        sparc64)
2020
            cpuflags="-mcpu=v9"
2021
        ;;
2022
    esac
2023

    
2024
elif enabled arm; then
2025

    
2026
    case $cpu in
2027
        armv*)
2028
            cpuflags="-march=$cpu"
2029
        ;;
2030
        *)
2031
            cpuflags="-mcpu=$cpu"
2032
        ;;
2033
    esac
2034

    
2035
elif enabled alpha; then
2036

    
2037
    enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
2038

    
2039
elif enabled bfin; then
2040

    
2041
    cpuflags="-mcpu=$cpu"
2042

    
2043
elif enabled mips; then
2044

    
2045
    cpuflags="-march=$cpu"
2046

    
2047
elif enabled avr32; then
2048

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

    
2068
fi
2069

    
2070
add_cflags $cpuflags
2071
add_asflags $cpuflags
2072

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

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

    
2095
check_host_cflags -std=c99
2096

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

    
2112
enable $subarch
2113
enabled spic && enable pic
2114
check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
2115

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

    
2284
set_default $PATHS_LIST
2285

    
2286
add_extralibs $osextralibs
2287

    
2288
# Combine FFLDFLAGS and the LDFLAGS environment variable.
2289
LDFLAGS="$FFLDFLAGS $LDFLAGS"
2290

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

    
2302
disabled static && LIBNAME=""
2303

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

    
2319

    
2320
die_license_disabled() {
2321
    enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
2322
}
2323

    
2324
die_license_disabled gpl libfaad2
2325
die_license_disabled gpl libx264
2326
die_license_disabled gpl libxvid
2327
die_license_disabled gpl postproc
2328
die_license_disabled gpl x11grab
2329

    
2330
die_license_disabled nonfree libfaac
2331

    
2332
die_license_disabled version3 libopencore_amrnb
2333
die_license_disabled version3 libopencore_amrwb
2334

    
2335
enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
2336

    
2337
check_deps $ARCH_EXT_LIST
2338

    
2339
disabled optimizations || check_cflags -fomit-frame-pointer
2340

    
2341
enable_pic() {
2342
    enable pic
2343
    add_cppflags -DPIC
2344
    add_cflags   -fPIC
2345
    add_asflags  -fPIC
2346
}
2347

    
2348
enabled pic && enable_pic
2349

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

    
2356
check_cc <<EOF && enable inline_asm
2357
void foo(void) { __asm__ volatile ("" ::); }
2358
EOF
2359

    
2360
_restrict=
2361
for restrict_keyword in restrict __restrict__ __restrict; do
2362
    check_cc <<EOF && _restrict=$restrict_keyword && break
2363
void foo(char * $restrict_keyword p);
2364
EOF
2365
done
2366

    
2367
check_cc <<EOF && enable attribute_packed
2368
struct { int x; } __attribute__((packed)) x;
2369
EOF
2370

    
2371
check_cc <<EOF && enable attribute_may_alias
2372
union { int x; } __attribute__((may_alias)) x;
2373
EOF
2374

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

    
2380
if enabled alpha; then
2381

    
2382
    check_cflags -mieee
2383

    
2384
elif enabled arm; then
2385

    
2386
    check_cflags -marm
2387

    
2388
    check_ld <<EOF && enable vfp_args
2389
__asm__ (".eabi_attribute 28, 1");
2390
int main(void) { return 0; }
2391
EOF
2392

    
2393
    # We have to check if pld is a nop and disable it.
2394
    check_asm pld '"pld [r0]"'
2395

    
2396
    enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
2397
    enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
2398
    enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
2399
    enabled armvfp  && check_asm armvfp  '"fadds s0, s0, s0"'
2400
    enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
2401
    enabled neon    && check_asm neon    '"vadd.i16 q0, q0, q0"'
2402

    
2403
    enabled_all armv6t2 shared !pic && enable_pic
2404

    
2405
elif enabled ia64; then
2406

    
2407
    # HACK: currently fails to build if .bss is > 4MB and shared libs are built
2408
    enabled shared && enable_weak hardcoded_tables
2409

    
2410
elif enabled mips; then
2411

    
2412
    check_asm loongson '"dmult.g $1, $2, $3"'
2413
    enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
2414

    
2415
elif enabled ppc; then
2416

    
2417
    enable local_aligned_8 local_aligned_16
2418

    
2419
    check_asm dcbzl     '"dcbzl 0, 1"'
2420
    check_asm ppc4xx    '"maclhw r10, r11, r12"'
2421
    check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
2422

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

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

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

    
2446
elif enabled sparc; then
2447

    
2448
    enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
2449
        add_cflags -mcpu=ultrasparc -mtune=ultrasparc
2450

    
2451
elif enabled x86; then
2452

    
2453
    enable local_aligned_8 local_aligned_16
2454

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

    
2467
    # check whether EBX is available on x86
2468
    check_asm ebx_available '""::"b"(0)' &&
2469
        check_asm ebx_available '"":::"%ebx"'
2470

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

    
2483
    # check whether binutils is new enough to compile SSSE3/MMX2
2484
    enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
2485
    enabled mmx2  && check_asm mmx2  '"pmaxub %mm0, %mm1"'
2486

    
2487
    check_asm bswap '"bswap %%eax" ::: "%eax"'
2488

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

    
2498
    case "$cpu" in
2499
        athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
2500
            disable fast_clz
2501
        ;;
2502
    esac
2503

    
2504
fi
2505

    
2506
if check_func dlopen; then
2507
    ldl=
2508
elif check_func dlopen -ldl; then
2509
    ldl=-ldl
2510
fi
2511

    
2512
# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
2513
check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
2514

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

    
2532
check_header conio.h
2533
check_header dlfcn.h
2534
check_header dxva2api.h
2535
check_header malloc.h
2536
check_header poll.h
2537
check_header sys/mman.h
2538
check_header sys/resource.h
2539
check_header sys/select.h
2540
check_header termios.h
2541
check_header vdpau/vdpau.h
2542
check_header vdpau/vdpau_x11.h
2543
check_header X11/extensions/XvMClib.h
2544

    
2545
check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex
2546

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

    
2552
disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
2553
disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
2554

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

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

    
2581
check_lib math.h sin -lm
2582
check_lib va/va.h vaInitialize -lva
2583

    
2584
check_mathfunc exp2
2585
check_mathfunc exp2f
2586
check_mathfunc llrint
2587
check_mathfunc log2
2588
check_mathfunc log2f
2589
check_mathfunc lrint
2590
check_mathfunc lrintf
2591
check_mathfunc round
2592
check_mathfunc roundf
2593
check_mathfunc truncf
2594

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

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

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

    
2638
texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
2639

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

    
2666
check_header linux/videodev.h
2667
check_header linux/videodev2.h
2668
check_header sys/videoio.h
2669

    
2670
check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
2671

    
2672
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
2673
{ check_header dev/bktr/ioctl_meteor.h &&
2674
  check_header dev/bktr/ioctl_bt848.h; } ||
2675
{ check_header machine/ioctl_meteor.h &&
2676
  check_header machine/ioctl_bt848.h; } ||
2677
{ check_header dev/video/meteor/ioctl_meteor.h &&
2678
  check_header dev/video/bktr/ioctl_bt848.h; } ||
2679
check_header dev/ic/bt8xx.h
2680

    
2681
check_header sys/soundcard.h
2682
check_header soundcard.h
2683

    
2684
enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
2685

    
2686
enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
2687

    
2688
enabled x11grab                         &&
2689
check_header X11/Xlib.h                 &&
2690
check_header X11/extensions/XShm.h      &&
2691
check_header X11/extensions/Xfixes.h    &&
2692
check_func XOpenDisplay -lX11           &&
2693
check_func XShmCreateImage -lX11 -lXext &&
2694
check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
2695

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

    
2703
enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
2704

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

    
2720
# add some linker flags
2721
check_ldflags -Wl,--warn-common
2722
check_ldflags -Wl,--as-needed
2723
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'
2724
check_ldflags -Wl,-Bsymbolic
2725

    
2726
echo "X{};" > $TMPV
2727
test_ldflags -Wl,--version-script,$TMPV &&
2728
    append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
2729

    
2730
if enabled small; then
2731
    add_cflags $size_cflags
2732
    optimizations="small"
2733
elif enabled optimizations; then
2734
    add_cflags $speed_cflags
2735
fi
2736
check_cflags -fno-math-errno
2737
check_cflags -fno-signed-zeros
2738

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

    
2776
if enabled gprof; then
2777
    add_cflags  -p
2778
    add_ldflags -p
2779
fi
2780

    
2781
# Find out if the .align argument is a power of two or not.
2782
check_asm asmalign_pot '".align 3"'
2783

    
2784
enabled_any $DECODER_LIST      && enable decoders
2785
enabled_any $ENCODER_LIST      && enable encoders
2786
enabled_any $HWACCEL_LIST      && enable hwaccels
2787
enabled_any $BSF_LIST          && enable bsfs
2788
enabled_any $DEMUXER_LIST      && enable demuxers
2789
enabled_any $MUXER_LIST        && enable muxers
2790
enabled_any $FILTER_LIST       && enable filters
2791
enabled_any $INDEV_LIST        && enable indevs
2792
enabled_any $OUTDEV_LIST       && enable outdevs
2793
enabled_any $PROTOCOL_LIST     && enable protocols
2794

    
2795
enabled_any $THREADS_LIST      && enable threads
2796

    
2797
check_deps $CONFIG_LIST       \
2798
           $CONFIG_EXTRA      \
2799
           $HAVE_LIST         \
2800
           $DECODER_LIST      \
2801
           $ENCODER_LIST      \
2802
           $HWACCEL_LIST      \
2803
           $PARSER_LIST       \
2804
           $BSF_LIST          \
2805
           $DEMUXER_LIST      \
2806
           $MUXER_LIST        \
2807
           $FILTER_LIST       \
2808
           $INDEV_LIST        \
2809
           $OUTDEV_LIST       \
2810
           $PROTOCOL_LIST     \
2811

    
2812
enabled asm || disable $ARCH_LIST $ARCH_EXT_LIST
2813

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

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

    
2905
license="LGPL version 2.1 or later"
2906
if enabled nonfree; then
2907
    license="nonfree and unredistributable"
2908
elif enabled gplv3; then
2909
    license="GPL version 3 or later"
2910
elif enabled lgplv3; then
2911
    license="LGPL version 3 or later"
2912
elif enabled gpl; then
2913
    license="GPL version 2 or later"
2914
fi
2915

    
2916
echo "License: $license"
2917

    
2918
echo "Creating config.mak and config.h..."
2919

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

    
2954
enabled stripping || strip="echo skipping strip"
2955

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

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

    
3037
get_version LIBSWSCALE  libswscale/swscale.h
3038
get_version LIBPOSTPROC libpostproc/postprocess.h
3039
get_version LIBAVCODEC  libavcodec/avcodec.h
3040
get_version LIBAVDEVICE libavdevice/avdevice.h
3041
get_version LIBAVFORMAT libavformat/avformat.h
3042
get_version LIBAVUTIL   libavutil/avutil.h
3043
get_version LIBAVFILTER libavfilter/avfilter.h
3044

    
3045
enabled asmalign_pot || align_shift="1 <<"
3046

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

    
3062
test -n "$malloc_prefix" &&
3063
    echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
3064

    
3065
if enabled small || disabled optimizations; then
3066
    echo "#undef  av_always_inline"  >> $TMPH
3067
    echo "#define av_always_inline"  >> $TMPH
3068
fi
3069

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

    
3086
echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
3087
echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
3088

    
3089
# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3090
cp_if_changed $TMPH config.h
3091

    
3092
cat > $TMPH <<EOF
3093
/* Generated by ffconf */
3094
#ifndef AVUTIL_AVCONFIG_H
3095
#define AVUTIL_AVCONFIG_H
3096
EOF
3097

    
3098
print_config AV_HAVE_ $TMPH /dev/null $HAVE_LIST_PUB
3099

    
3100
echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
3101

    
3102
cp_if_changed $TMPH libavutil/avconfig.h
3103

    
3104
# build pkg-config files
3105

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

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

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

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