Statistics
| Branch: | Revision:

ffmpeg / configure @ 3837d107

History | View | Annotate | Download (57.5 KB)

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

    
10
# make sure we are running under a compatible shell
11
# try to make this part work with most shells
12

    
13
try_exec(){
14
    echo "Trying shell $1"
15
    type "$1" >/dev/null 2>&1 && exec "$@"
16
}
17

    
18
unset foo
19
(: ${foo%%bar}) 2>/dev/null
20
E1="$?"
21

    
22
(: ${foo?}) 2>/dev/null
23
E2="$?"
24

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

    
53
show_help(){
54
  echo "Usage: configure [options]"
55
  echo "Options: [defaults in brackets after descriptions]"
56
  echo
57
  echo "Standard options:"
58
  echo "  --help                   print this message"
59
  echo "  --log[=FILE|yes|no]      log tests and output to FILE [config.err]"
60
  echo "  --prefix=PREFIX          install in PREFIX [$PREFIX]"
61
  echo "  --libdir=DIR             install libs in DIR [PREFIX/lib]"
62
  echo "  --shlibdir=DIR           install shared libs in DIR [PREFIX/lib]"
63
  echo "  --incdir=DIR             install includes in DIR [PREFIX/include/ffmpeg]"
64
  echo "  --mandir=DIR             install man page in DIR [PREFIX/share/man]"
65
  echo "  --enable-static          build static libraries [default=yes]"
66
  echo "  --disable-static         do not build static libraries [default=no]"
67
  echo "  --enable-shared          build shared libraries [default=no]"
68
  echo "  --disable-shared         do not build shared libraries [default=yes]"
69
  echo "  --enable-gpl             allow use of GPL code, the resulting libav*"
70
  echo "                           and ffmpeg will be under GPL [default=no]"
71
  echo "  --enable-pp              enable GPLed postprocessing support [default=no]"
72
  echo "  --enable-swscaler        software scaler support [default=no]"
73
  echo "  --enable-beosthreads     use BeOS threads [default=no]"
74
  echo "  --enable-pthreads        use pthreads [default=no]"
75
  echo "  --enable-w32threads      use Win32 threads [default=no]"
76
  echo "  --enable-x11grab         enable X11 grabbing [default=no]"
77
  echo
78
  echo "External library support:"
79
  echo "  --enable-sunmlib         use Sun medialib [default=no]"
80
  echo "  --enable-liba52          enable GPLed liba52 support [default=no]"
81
  echo "  --enable-liba52bin       open liba52.so.0 at runtime [default=no]"
82
  echo "  --enable-avisynth        allow reading AVISynth script files [default=no]"
83
  echo "  --enable-libamr-nb       enable libamr-nb floating point audio codec"
84
  echo "  --enable-libamr-wb       enable libamr-wb floating point audio codec"
85
  echo "  --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394"
86
  echo "                           and libraw1394 [default=no]"
87
  echo "  --enable-libfaac         enable FAAC support via libfaac [default=no]"
88
  echo "  --enable-libfaad         enable FAAD support via libfaad [default=no]"
89
  echo "  --enable-libfaadbin      open libfaad.so.0 at runtime [default=no]"
90
  echo "  --enable-libgsm          enable GSM support via libgsm [default=no]"
91
  echo "  --enable-libmp3lame      enable MP3 encoding via libmp3lame [default=no]"
92
  echo "  --enable-libnut          enable NUT (de)muxing via libnut,"
93
  echo "                           native demuxer exists [default=no]"
94
  echo "  --enable-libogg          enable Ogg muxing via libogg [default=no]"
95
  echo "  --enable-libtheora       enable Theora encoding via libtheora [default=no]"
96
  echo "  --enable-libvorbis       enable Vorbis encoding via libvorbis,"
97
  echo "                           native implementation exists [default=no]"
98
  echo "  --enable-libx264         enable H.264 encoding via x264 [default=no]"
99
  echo "  --enable-libxvid         enable Xvid encoding via xvidcore,"
100
  echo "                           native MPEG-4/Xvid encoder exists [default=no]"
101
  echo ""
102
  echo "Advanced options (experts only):"
103
  echo "  --source-path=PATH       path to source code [$source_path]"
104
  echo "  --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]"
105
  echo "  --cross-compile          assume a cross-compiler is used"
106
  echo "  --target-os=OS           compiler targets OS [$targetos]"
107
  echo "  --cc=CC                  use C compiler CC [$cc]"
108
  echo "  --make=MAKE              use specified make [$make]"
109
  echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
110
  echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
111
  echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
112
  echo "  --build-suffix=SUFFIX    suffix for application specific build []"
113
  echo "  --arch=ARCH              select architecture  [$arch]"
114
  echo "  --cpu=CPU                selects the minimum cpu required (affects"
115
  echo "                           instruction selection, may crash on older CPUs)"
116
  echo "  --enable-powerpc-perf    enable performance report on PPC"
117
  echo "                           (requires enabling PMC)"
118
  echo "  --disable-mmx            disable MMX usage"
119
  echo "  --disable-armv5te        disable armv5te usage"
120
  echo "  --disable-armv6          disable armv6 usage"
121
  echo "  --disable-iwmmxt         disable iwmmxt usage"
122
  echo "  --disable-altivec        disable AltiVec usage"
123
  echo "  --disable-network        disable network support [default=no]"
124
  echo "  --disable-ipv6           disable ipv6 support [default=no]"
125
  echo "  --disable-zlib           disable zlib [default=no]"
126
  echo "  --disable-vhook          disable video hooking support"
127
  echo "  --disable-debug          disable debugging symbols"
128
  echo "  --disable-mpegaudio-hp   faster (but less accurate)"
129
  echo "                           MPEG audio decoding [default=no]"
130
  echo "  --enable-gray            enable full grayscale support (slower color)"
131
  echo "  --disable-ffmpeg         disable ffmpeg build"
132
  echo "  --disable-ffserver       disable ffserver build"
133
  echo "  --disable-ffplay         disable ffplay build"
134
  echo "  --enable-small           optimize for size instead of speed"
135
  echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
136
  echo "  --disable-encoder=NAME   disables encoder NAME"
137
  echo "  --enable-encoder=NAME    enables encoder NAME"
138
  echo "  --disable-decoder=NAME   disables decoder NAME"
139
  echo "  --enable-decoder=NAME    enables decoder NAME"
140
  echo "  --disable-encoders       disables all encoders"
141
  echo "  --disable-decoders       disables all decoders"
142
  echo "  --disable-muxer=NAME     disables muxer NAME"
143
  echo "  --enable-muxer=NAME      enables muxer NAME"
144
  echo "  --disable-muxers         disables all muxers"
145
  echo "  --disable-demuxer=NAME   disables demuxer NAME"
146
  echo "  --enable-demuxer=NAME    enables demuxer NAME"
147
  echo "  --disable-demuxers       disables all demuxers"
148
  echo "  --enable-parser=NAME     enables parser NAME"
149
  echo "  --disable-parser=NAME    disables parser NAME"
150
  echo "  --disable-parsers        disables all parsers"
151
  echo "  --enable-bsf=NAME        enables bitstream filter NAME"
152
  echo "  --disable-bsf=NAME       disables bitstream filter NAME"
153
  echo "  --disable-bsfs           disables all bitstream filters"
154
  echo "  --enable-protocol=NAME   enables protocol NAME"
155
  echo "  --disable-protocol=NAME  disables protocol NAME"
156
  echo "  --disable-protocols      disables all protocols"
157
  echo "  --list-decoders          show all available decoders"
158
  echo "  --list-encoders          show all available encoders"
159
  echo "  --list-muxers            show all available muxers"
160
  echo "  --list-demuxers          show all available demuxers"
161
  echo "  --list-parsers           show all available parsers"
162
  echo "  --list-protocols         show all available protocols"
163
  echo "  --list-bsfs              show all available bitstream filters"
164
  echo
165
  echo "Developer options (useful when working on FFmpeg itself):"
166
  echo "  --enable-gprof           enable profiling with gprof [$gprof]"
167
  echo "  --disable-optimizations  disable compiler optimizations"
168
  echo "  --enable-extra-warnings  enable more compiler warnings"
169
  echo "  --disable-strip          disable stripping of executables and shared libraries"
170
  echo ""
171
  echo "NOTE: Object files are built at the place where configure is launched."
172
  exit 1
173
}
174

    
175
log(){
176
    echo "$@" >>$logfile
177
}
178

    
179
log_file(){
180
    log BEGIN $1
181
    pr -n -t $1 >>$logfile
182
    log END $1
183
}
184

    
185
echolog(){
186
    log "$@"
187
    echo "$@"
188
}
189

    
190
die(){
191
    echolog "$@"
192
    cat <<EOF
193
If you think configure made a mistake, make sure you are using the latest
194
version from SVN.  If the latest version fails, report the problem to the
195
ffmpeg-devel@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
196
EOF
197
    if enabled logging; then
198
        cat <<EOF
199
Include the log file "$logfile" produced by configure as this will help
200
solving the problem.
201
EOF
202
    else
203
cat <<EOF
204
Rerun configure with logging enabled (do not use --log=no), and include the
205
log this produces with your report.
206
EOF
207
    fi
208
    rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
209
    exit 1
210
}
211

    
212
# "tr '[a-z]' '[A-Z]'" is a workaround for Solaris tr not grokking "tr a-z A-Z"
213
toupper(){
214
    echo "$@" | tr '[a-z]' '[A-Z]'
215
}
216

    
217
tolower(){
218
    echo "$@" | tr '[A-Z]' '[a-z]'
219
}
220

    
221
set_all(){
222
    value=$1
223
    shift
224
    for var in $*; do
225
        eval $var=$value
226
    done
227
}
228

    
229
pushvar(){
230
    for var in $*; do
231
        eval level=\${${var}_level:=0}
232
        eval ${var}_${level}="\$$var"
233
        eval ${var}_level=$(($level+1))
234
    done
235
}
236

    
237
popvar(){
238
    for var in $*; do
239
        eval level=\${${var}_level:-0}
240
        test $level = 0 && continue
241
        eval level=$(($level-1))
242
        eval $var="\${${var}_${level}}"
243
        eval ${var}_level=$level
244
        eval unset ${var}_${level}
245
    done
246
}
247

    
248
enable(){
249
    set_all yes $*
250
}
251

    
252
disable(){
253
    set_all no $*
254
}
255

    
256
enabled(){
257
    eval test "x\$$1" = "xyes"
258
}
259

    
260
disabled(){
261
    eval test "x\$$1" = "xno"
262
}
263

    
264
enabled_all(){
265
    for opt; do
266
        enabled $opt || return 1
267
    done
268
}
269

    
270
disabled_all(){
271
    for opt; do
272
        disabled $opt || return 1
273
    done
274
}
275

    
276
enabled_any(){
277
    for opt; do
278
        enabled $opt && return 0
279
    done
280
}
281

    
282
disabled_any(){
283
    for opt; do
284
        disabled $opt && return 0
285
    done
286
}
287

    
288
is_in(){
289
    value=$1
290
    shift
291
    for var in $*; do
292
        [ $var = $value ] && return 0
293
    done
294
    return 1
295
}
296

    
297
check_deps(){
298
    for cfg; do
299
        enabled ${cfg}_checking && die "Circular dependency for $cfg."
300
        disabled ${cfg}_checking && continue
301
        enable ${cfg}_checking
302

    
303
        eval dep_all="\$${cfg}_deps"
304
        eval dep_any="\$${cfg}_deps_any"
305

    
306
        pushvar cfg dep_all dep_any
307
        check_deps $dep_all $dep_any
308
        popvar cfg dep_all dep_any
309

    
310
        enabled_all $dep_all || disable $cfg
311
        enabled_any $dep_any || disable $cfg
312

    
313
        if enabled $cfg; then
314
            eval dep_extralibs="\$${cfg}_extralibs"
315
            test -n "$dep_extralibs" && add_extralibs $dep_extralibs
316
        fi
317

    
318
        disable ${cfg}_checking
319
    done
320
}
321

    
322
print_config(){
323
    pfx=$1
324
    header=$2
325
    makefile=$3
326
    shift 3
327
    for cfg; do
328
        ucname="`toupper $cfg`"
329
        if enabled $cfg; then
330
            echo "#define ${pfx}${ucname} 1" >> $header
331
            echo "#define ENABLE_${ucname} 1" >> $header
332
            echo "${pfx}${ucname}=yes" >> $makefile
333
        else
334
            echo "#define ENABLE_${ucname} 0" >> $header
335
        fi
336
    done
337
}
338

    
339
flags_saved(){
340
    (: ${SAVE_CFLAGS?}) 2>/dev/null
341
}
342

    
343
save_flags(){
344
    flags_saved && return
345
    SAVE_CFLAGS="$CFLAGS"
346
    SAVE_LDFLAGS="$LDFLAGS"
347
    SAVE_extralibs="$extralibs"
348
}
349

    
350
restore_flags(){
351
    flags_saved || return
352
    CFLAGS="$SAVE_CFLAGS"
353
    LDFLAGS="$SAVE_LDFLAGS"
354
    extralibs="$SAVE_extralibs"
355
    unset SAVE_CFLAGS
356
    unset SAVE_LDFLAGS
357
    unset SAVE_extralibs
358
}
359

    
360
temp_cflags(){
361
    save_flags
362
    CFLAGS="$CFLAGS $*"
363
}
364

    
365
temp_ldflags(){
366
    save_flags
367
    LDFLAGS="$LDFLAGS $*"
368
}
369

    
370
temp_extralibs(){
371
    save_flags
372
    extralibs="$extralibs $*"
373
}
374

    
375
append(){
376
    var=$1
377
    shift
378
    flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
379
    eval "$var=\"\$$var $*\""
380
}
381

    
382
add_cflags(){
383
    append CFLAGS "$@"
384
}
385

    
386
add_ldflags(){
387
    append LDFLAGS "$@"
388
}
389

    
390
add_extralibs(){
391
    append extralibs "$@"
392
}
393

    
394
check_cmd(){
395
    log "$@"
396
    "$@" >>$logfile 2>&1
397
}
398

    
399
check_cc(){
400
    log check_cc "$@"
401
    cat >$TMPC
402
    log_file $TMPC
403
    check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
404
}
405

    
406
check_cpp(){
407
    log check_cpp "$@"
408
    cat >$TMPC
409
    log_file $TMPC
410
    check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
411
}
412

    
413
check_asm(){
414
    log check_asm "$@"
415
    name="$1"
416
    asm="$2"
417
    shift 2
418
    check_cc "$@" <<EOF && enable $name || disable $name
419
int foo(void){
420
    asm volatile($asm);
421
}
422
EOF
423
}
424

    
425
check_ld(){
426
    log check_ld "$@"
427
    check_cc || return
428
    flags=''
429
    libs=''
430
    for f; do
431
        test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
432
    done
433
    check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
434
}
435

    
436
check_cflags(){
437
    log check_cflags "$@"
438
    check_cc "$@" <<EOF && add_cflags "$@"
439
int x;
440
EOF
441
}
442

    
443
check_ldflags(){
444
    log check_ldflags "$@"
445
    check_ld "$@" <<EOF && add_ldflags "$@"
446
int main(){
447
    return 0;
448
}
449
EOF
450
}
451

    
452
check_header(){
453
    log check_header "$@"
454
    header=$1
455
    shift
456
    var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
457
    disable $var
458
    check_cpp "$@" <<EOF && enable $var
459
#include <$header>
460
int x;
461
EOF
462
}
463

    
464
check_func(){
465
    log check_func "$@"
466
    func=$1
467
    shift
468
    disable $func
469
    check_ld "$@" <<EOF && enable $func
470
extern int $func();
471
int main(){
472
    $func();
473
}
474
EOF
475
}
476

    
477
check_func2(){
478
    log check_func2 "$@"
479
    headers=$1
480
    func=$2
481
    shift 2
482
    disable $func
483
    incs=""
484
    for hdr in $headers; do
485
        incs="$incs
486
#include <$hdr>"
487
    done
488
    check_ld "$@" <<EOF && enable $func
489
$incs
490
int main(){
491
    (void) $func;
492
    return 0;
493
}
494
EOF
495
}
496

    
497
check_lib(){
498
    log check_lib "$@"
499
    header="$1"
500
    func="$2"
501
    shift 2
502
    temp_extralibs "$@"
503
    check_header $header && check_func $func && add_extralibs "$@"
504
    err=$?
505
    restore_flags
506
    return $err
507
}
508

    
509
check_lib2(){
510
    log check_lib2 "$@"
511
    headers="$1"
512
    func="$2"
513
    shift 2
514
    temp_extralibs "$@"
515
    check_func2 "$headers" $func && add_extralibs "$@"
516
    err=$?
517
    restore_flags
518
    return $err
519
}
520

    
521
check_exec(){
522
    check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
523
}
524

    
525
check_exec_crash(){
526
    code=`cat`
527

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

    
534
    (check_exec "$@") >>$logfile 2>&1 <<EOF
535
#include <signal.h>
536
static void sighandler(int sig){
537
    raise(SIGTERM);
538
}
539
int main(){
540
    signal(SIGILL, sighandler);
541
    signal(SIGFPE, sighandler);
542
    signal(SIGSEGV, sighandler);
543
#ifdef SIGBUS
544
    signal(SIGBUS, sighandler);
545
#endif
546
    { $code }
547
}
548
EOF
549
}
550

    
551
require(){
552
    name="$1"
553
    header="$2"
554
    func="$3"
555
    shift 3
556
    check_lib $header $func "$@" || die "ERROR: $name not found"
557
}
558

    
559
require2(){
560
    name="$1"
561
    headers="$2"
562
    func="$3"
563
    shift 3
564
    check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
565
}
566

    
567
check_foo_config(){
568
    cfg=$1
569
    pkg=$2
570
    header=$3
571
    func=$4
572
    shift 4
573
    disable $cfg
574
    check_cmd ${pkg}-config --version
575
    err=$?
576
    if test "$err" = 0; then
577
        temp_cflags `${pkg}-config --cflags`
578
        temp_extralibs `${pkg}-config --libs`
579
        check_lib "$@" $header $func && enable $cfg
580
    fi
581
    return $err
582
}
583

    
584
apply(){
585
    file=$1
586
    shift
587
    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
588
}
589

    
590
COMPONENT_LIST="
591
    bsfs
592
    decoders
593
    demuxers
594
    encoders
595
    muxers
596
    parsers
597
    protocols
598
"
599

    
600
CONFIG_LIST="
601
    $COMPONENT_LIST
602
    avisynth
603
    beos_netserver
604
    ffmpeg
605
    ffplay
606
    ffserver
607
    gpl
608
    gprof
609
    gray
610
    ipv6
611
    liba52
612
    liba52bin
613
    libamr
614
    libamr_nb
615
    libamr_wb
616
    libdc1394
617
    libfaac
618
    libfaad
619
    libfaadbin
620
    libgsm
621
    libmp3lame
622
    libnut
623
    libogg
624
    libtheora
625
    libvorbis
626
    libx264
627
    libxvid
628
    memalign_hack
629
    mpegaudio_hp
630
    network
631
    powerpc_perf
632
    pp
633
    small
634
    swscaler
635
    vhook
636
    x11grab
637
    zlib
638
"
639

    
640
THREADS_LIST='
641
    beosthreads
642
    pthreads
643
    w32threads
644
'
645

    
646
ARCH_LIST='
647
    alpha
648
    armv4l
649
    bfin
650
    ia64
651
    m68k
652
    mips
653
    parisc
654
    powerpc
655
    s390
656
    sh4
657
    sparc
658
    sparc64
659
    x86
660
    x86_32
661
    x86_64
662
'
663

    
664
ARCH_EXT_LIST='
665
    altivec
666
    armv5te
667
    armv6
668
    iwmmxt
669
    mmi
670
    mmx
671
    ssse3
672
    vis
673
'
674

    
675
HAVE_LIST="
676
    $ARCH_EXT_LIST
677
    $THREADS_LIST
678
    altivec_h
679
    arpa_inet_h
680
    byteswap_h
681
    closesocket
682
    cmov
683
    conio_h
684
    dcbzl
685
    dev_bktr_ioctl_bt848_h
686
    dev_bktr_ioctl_meteor_h
687
    dev_ic_bt8xx_h
688
    dev_video_meteor_ioctl_meteor_h
689
    dev_video_bktr_ioctl_bt848_h
690
    dlfcn_h
691
    dlopen
692
    ebp_available
693
    ebx_available
694
    fast_64bit
695
    fast_cmov
696
    fast_unaligned
697
    fork
698
    freetype2
699
    gethrtime
700
    GetProcessTimes
701
    getrusage
702
    imlib2
703
    inet_aton
704
    lrintf
705
    machine_ioctl_bt848_h
706
    machine_ioctl_meteor_h
707
    malloc_h
708
    memalign
709
    mkstemp
710
    mlib
711
    ppc64
712
    sdl
713
    sdl_video_size
714
    soundcard_h
715
    sys_poll_h
716
    sys_soundcard_h
717
    termios_h
718
    threads
719
    winsock2_h
720
"
721

    
722
CMDLINE_SELECT="
723
    $ARCH_EXT_LIST
724
    $CONFIG_LIST
725
    $THREADS_LIST
726
    debug
727
    extra_warnings
728
    optimizations
729
    shared
730
    static
731
"
732

    
733
# code dependency declarations
734

    
735
# architecture extensions
736
altivec_deps="powerpc"
737
armv5te_deps="armv4l"
738
armv6_deps="armv4l"
739
iwmmxt_deps="armv4l"
740
mmi_deps="mips"
741
mmx_deps="x86"
742
ssse3_deps="x86"
743
vis_deps="sparc"
744

    
745
# decoders / encoders
746
ac3_decoder_deps="gpl"
747
dxa_decoder_deps="zlib"
748
flashsv_decoder_deps="zlib"
749
flashsv_encoder_deps="zlib"
750
flv_decoder_deps="h263_decoder"
751
h263_decoder_deps="h263_parser mpeg4video_parser"
752
h263i_decoder_deps="h263_decoder"
753
h264_decoder_deps="h264_parser"
754
mpeg_xvmc_decoder_deps="xvmc"
755
mpeg4_decoder_deps="h263_decoder"
756
msmpeg4v1_decoder_deps="h263_decoder"
757
msmpeg4v2_decoder_deps="h263_decoder"
758
msmpeg4v3_decoder_deps="h263_decoder"
759
png_decoder_deps="zlib"
760
png_encoder_deps="zlib"
761
svq3_decoder_deps="h264_parser"
762
vc1_decoder_deps="h263_decoder"
763
wmv1_decoder_deps="h263_decoder"
764
wmv2_decoder_deps="h263_decoder"
765
wmv3_decoder_deps="h263_decoder"
766
zmbv_decoder_deps="zlib"
767
zmbv_encoder_deps="zlib"
768

    
769
# external libraries
770
liba52_decoder_deps="liba52"
771
liba52bin_decoder_extralibs='$ldl'
772
libamr_nb_decoder_deps="libamr_nb"
773
libamr_nb_encoder_deps="libamr_nb"
774
libamr_wb_decoder_deps="libamr_wb"
775
libamr_wb_encoder_deps="libamr_wb"
776
libfaac_encoder_deps="libfaac"
777
libfaad_decoder_deps="libfaad"
778
libfaadbin_decoder_extralibs='$ldl'
779
libgsm_decoder_deps="libgsm"
780
libgsm_encoder_deps="libgsm"
781
libgsm_ms_decoder_deps="libgsm"
782
libgsm_ms_encoder_deps="libgsm"
783
libmp3lame_encoder_deps="libmp3lame"
784
libtheora_encoder_deps="libtheora"
785
libvorbis_encoder_deps="libvorbis"
786
libx264_encoder_deps="libx264"
787
libxvid_encoder_deps="libxvid"
788
mpeg4aac_decoder_deps="libfaad"
789

    
790
# demuxers / muxers
791
ac3_demuxer_deps="ac3_parser"
792
audio_beos_demuxer_deps="audio_beos"
793
audio_beos_demuxer_extralibs="-lmedia -lbe"
794
audio_beos_muxer_deps="audio_beos"
795
audio_beos_muxer_extralibs="-lmedia -lbe"
796
avisynth_demuxer_deps="avisynth"
797
bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
798
dv1394_demuxer_deps="dv1394"
799
libdc1394_demuxer_deps="libdc1394"
800
libnut_demuxer_deps="libnut"
801
libnut_muxer_deps="libnut"
802
mp3_demuxer_deps="mpegaudio_parser"
803
ogg_muxer_deps="libogg"
804
oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
805
oss_muxer_deps_any="soundcard_h sys_soundcard_h"
806
redir_demuxer_deps="network"
807
rtp_muxer_deps="network mpegts_demuxer"
808
rtsp_demuxer_deps="rtp_protocol rtp_muxer"
809
sdp_demuxer_deps="rtsp_demuxer"
810
v4l2_demuxer_deps="linux_videodev2_h"
811
v4l_demuxer_deps="linux_videodev_h"
812
x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
813
x11_grab_device_demuxer_extralibs="-lX11 -lXext"
814

    
815
# protocols
816
http_protocol_deps="network"
817
rtp_protocol_deps="udp_protocol"
818
tcp_protocol_deps="network"
819
udp_protocol_deps="network"
820

    
821
# programs
822
ffplay_deps="sdl"
823
ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
824
ffserver_extralibs='$ldl'
825
vhook_extralibs='$ldl'
826

    
827

    
828
# set temporary file name
829
if test ! -z "$TMPDIR" ; then
830
    TMPDIR1="${TMPDIR}"
831
elif test ! -z "$TEMPDIR" ; then
832
    TMPDIR1="${TEMPDIR}"
833
else
834
    TMPDIR1="/tmp"
835
fi
836

    
837
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
838
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
839
TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
840
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
841
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
842

    
843
# default parameters
844

    
845
enable logging
846
logfile="config.err"
847

    
848
# installation paths
849
PREFIX="/usr/local"
850
libdir='$(PREFIX)/lib'
851
shlibdir="$libdir"
852
incdir='$(PREFIX)/include/ffmpeg'
853
mandir='$(PREFIX)/share/man'
854
bindir='$(PREFIX)/bin'
855

    
856
# toolchain
857
cc="gcc"
858
ar="ar"
859
ranlib="ranlib"
860
make="make"
861
strip="strip"
862
asmalign_pot="unknown"
863
ln_s="ln -sf"
864

    
865
# machine
866
arch=`uname -m`
867
cpu="generic"
868

    
869
# OS
870
targetos=$(tolower $(uname -s))
871

    
872
# libraries
873
enable zlib
874

    
875
# configurable options
876
enable debug
877
enable dostrip
878
enable ffmpeg
879
enable ffplay
880
enable ffserver
881
enable ipv6
882
enable static
883
enable mpegaudio_hp
884
enable network
885
enable optimizations
886
enable protocols
887
vhook="default"
888

    
889
# build settings
890
SHFLAGS='-shared -Wl,-soname,$@'
891
VHOOKSHFLAGS='$(SHFLAGS)'
892
LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
893
FFSERVERLDFLAGS=-Wl,-E
894
LDCONFIG="ldconfig"
895
LIBPREF="lib"
896
LIBSUF=".a"
897
FULLNAME='$(NAME)$(BUILDSUF)'
898
LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
899
SLIBPREF="lib"
900
SLIBSUF=".so"
901
SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
902
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
903
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
904
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
905

    
906
# find source path
907
source_path="`dirname \"$0\"`"
908
enable source_path_used
909
if test -z "$source_path" -o "$source_path" = "." ; then
910
    source_path="`pwd`"
911
    disable source_path_used
912
else
913
    source_path="`cd \"$source_path\"; pwd`"
914
    echo "$source_path" | grep -q '[[:blank:]]' &&
915
      die "Out of tree builds are impossible with whitespace in source path."
916
fi
917

    
918
FFMPEG_CONFIGURATION="$@"
919

    
920
ENCODER_LIST=`sed -n 's/^[^#]*ENC.*(.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
921
DECODER_LIST=`sed -n 's/^[^#]*DEC.*(.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
922
PARSER_LIST=`sed -n 's/^[^#]*PARSER.*(.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
923
BSF_LIST=`sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' "$source_path/libavcodec/allcodecs.c"`
924
MUXER_LIST=`sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
925
DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
926
PROTOCOL_LIST=`sed -n 's/^[^#]*PROTOCOL.*(.*, *\(.*\)).*/\1_protocol/p' "$source_path/libavformat/allformats.c"`
927

    
928
enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST $PROTOCOL_LIST $BSF_LIST
929
enable $ARCH_EXT_LIST
930

    
931
die_unknown(){
932
    echo "Unknown option \"$1\"."
933
    echo "See $0 --help for available options."
934
    exit 1
935
}
936

    
937
show_list() {
938
    suffix=_$1
939
    shift
940
    echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
941
    exit 0
942
}
943

    
944
for opt do
945
  optval="${opt#*=}"
946
  case "$opt" in
947
  --log)
948
  ;;
949
  --log=*) logging="$optval"
950
  ;;
951
  --prefix=*) PREFIX="$optval"
952
  ;;
953
  --libdir=*) libdir="$optval"
954
  ;;
955
  --shlibdir=*) shlibdir="$optval"
956
  ;;
957
  --incdir=*) incdir="$optval"
958
  ;;
959
  --mandir=*) mandir="$optval"
960
  ;;
961
  --source-path=*) source_path="$optval"
962
  ;;
963
  --cross-prefix=*) cross_prefix="$optval"
964
  ;;
965
  --cross-compile) enable cross_compile
966
  ;;
967
  --target-os=*) targetos="$optval"
968
  ;;
969
  --cc=*) cc="$optval"
970
  ;;
971
  --make=*) make="$optval"
972
  ;;
973
  --extra-cflags=*) add_cflags "$optval"
974
  ;;
975
  --extra-ldflags=*) add_ldflags "$optval"
976
  ;;
977
  --extra-libs=*) add_extralibs "$optval"
978
  ;;
979
  --build-suffix=*) BUILDSUF="$optval"
980
  ;;
981
  --arch=*) arch="$optval"
982
  ;;
983
  --cpu=*) cpu="$optval"
984
  ;;
985
  --enable-sunmlib) enable mlib
986
  ;;
987
  --disable-strip) disable dostrip
988
  ;;
989
  --disable-encoders) disable $ENCODER_LIST
990
  ;;
991
  --disable-decoders) disable $DECODER_LIST
992
  ;;
993
  --disable-muxers) disable $MUXER_LIST
994
  ;;
995
  --disable-demuxers) disable $DEMUXER_LIST
996
  ;;
997
  --disable-parsers) disable $PARSER_LIST
998
  ;;
999
  --disable-bsfs) disable $BSF_LIST
1000
  ;;
1001
  --disable-protocols) disable $PROTOCOL_LIST
1002
  ;;
1003
  --enable-*=*|--disable-*=*)
1004
  eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
1005
  case "$thing" in
1006
      encoder|decoder|muxer|demuxer|parser|bsf|protocol) $action ${optval}_${thing} ;;
1007
      *) die_unknown "$opt" ;;
1008
  esac
1009
  ;;
1010
  --enable-?*|--disable-?*)
1011
  eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
1012
  echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt
1013
  $action $option
1014
  ;;
1015
  --list-*)
1016
    NAME="${opt#--list-}"
1017
    is_in $NAME $COMPONENT_LIST || die_unknown $opt
1018
    NAME=${NAME%s}
1019
    eval show_list $NAME \$$(toupper $NAME)_LIST
1020
  ;;
1021
  --help|-h) show_help
1022
  ;;
1023
  *)
1024
  die_unknown $opt
1025
  ;;
1026
  esac
1027
done
1028

    
1029
case "$arch" in
1030
  i386|i486|i586|i686|i86pc|BePC)
1031
    arch="x86_32"
1032
    enable fast_unaligned
1033
  ;;
1034
  x86_64|amd64)
1035
    arch="x86_32"
1036
    enable fast_unaligned
1037
    canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
1038
    if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
1039
      if [ -z "`echo $CFLAGS | grep -- -m32`"  ]; then
1040
        arch="x86_64"
1041
        enable fast_64bit
1042
      fi
1043
    fi
1044
  ;;
1045
  # armv4l is a subset of armv[567]*l
1046
  arm|armv[4567]*l)
1047
    arch="armv4l"
1048
  ;;
1049
  alpha)
1050
    arch="alpha"
1051
    enable fast_64bit
1052
  ;;
1053
  "Power Macintosh"|ppc|powerpc)
1054
    arch="powerpc"
1055
  ;;
1056
  ppc64)
1057
    arch="powerpc"
1058
    enable fast_64bit
1059
  ;;
1060
  mips|mipsel|IP*)
1061
    arch="mips"
1062
  ;;
1063
  sun4u|sparc64)
1064
    arch="sparc64"
1065
    enable fast_64bit
1066
  ;;
1067
  sparc)
1068
    arch="sparc"
1069
  ;;
1070
  sh4)
1071
    arch="sh4"
1072
  ;;
1073
  parisc)
1074
    arch="parisc"
1075
  ;;
1076
  parisc64)
1077
    arch="parisc"
1078
    enable fast_64bit
1079
  ;;
1080
  s390|s390x)
1081
    arch="s390"
1082
  ;;
1083
  m68k)
1084
    arch="m68k"
1085
  ;;
1086
  ia64)
1087
    arch="ia64"
1088
    enable fast_64bit
1089
  ;;
1090
  bfin)
1091
    arch="bfin"
1092
  ;;
1093
  *)
1094
    arch="unknown"
1095
  ;;
1096
esac
1097

    
1098
enable $arch
1099
enabled_any x86_32 x86_64 && enable x86
1100
enabled     sparc64       && enable sparc
1101

    
1102
# OS specific
1103
case $targetos in
1104
  beos|haiku|zeta)
1105
    PREFIX="$HOME/config"
1106
    # helps building libavcodec
1107
    add_cflags "-DPIC -fomit-frame-pointer"
1108
    # 3 gcc releases known for BeOS, each with ugly bugs
1109
    gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1110
    case "$gcc_version" in
1111
      2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1112
        disable mmx
1113
        ;;
1114
      *20010315*) echo "BeBits gcc"
1115
        add_cflags "-fno-expensive-optimizations"
1116
        ;;
1117
    esac
1118
    LDCONFIG="echo ignoring ldconfig"
1119
    SHFLAGS=-nostart
1120
    # enable BeOS things
1121
    enable audio_beos
1122
    # no need for libm, but the inet stuff
1123
    # Check for BONE
1124
    # XXX: actually should check for NOT net_server
1125
    if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
1126
        network_extralibs="-lbind -lsocket"
1127
    else
1128
        enable beos_netserver
1129
        network_extralibs="-lnet"
1130
    fi ;;
1131
  sunos)
1132
    FFSERVERLDFLAGS=""
1133
    SHFLAGS='-shared -Wl,-h,$@'
1134
    network_extralibs="-lsocket -lnsl"
1135
    ;;
1136
  netbsd)
1137
    oss_demuxer_extralibs="-lossaudio"
1138
    oss_muxer_extralibs="-lossaudio"
1139
    ;;
1140
  openbsd)
1141
    disable need_memalign
1142
    LIBOBJFLAGS='$(PIC)'
1143
    LDCONFIG='ldconfig -m $(SHLIBDIR)'
1144
    SHFLAGS='-shared'
1145
    SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF).$(LIBVERSION)'
1146
    SLIBNAME_WITH_VERSION='$(SLIBNAME)'
1147
    SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
1148
    oss_demuxer_extralibs="-lossaudio"
1149
    oss_muxer_extralibs="-lossaudio"
1150
    ;;
1151
  freebsd)
1152
    disable need_memalign
1153
    ;;
1154
  bsd/os)
1155
    osextralibs="-lpoll -lgnugetopt"
1156
    strip="strip -d"
1157
    ;;
1158
  darwin)
1159
    disable need_memalign
1160
    SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(SPPVERSION),-compatibility_version,$(SPPVERSION) -Wl,-read_only_relocs,suppress'
1161
    VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$@'
1162
    strip="strip -x"
1163
    FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1164
    SLIBSUF=".dylib"
1165
    SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
1166
    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
1167
    FFSERVERLDFLAGS=-Wl,-bind_at_load
1168
    ;;
1169
  mingw32*)
1170
    targetos=mingw32
1171
    shlibdir="$bindir"
1172
    VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1173
    VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1174
    if enabled swscaler; then
1175
        VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1176
        VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1177
    fi
1178
    disable ffserver
1179
    SLIBPREF=""
1180
    SLIBSUF=".dll"
1181
    EXESUF=".exe"
1182
    SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1183
    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1184
    SLIB_EXTRA_CMD='-lib /machine:i386 /def:$(@:$(SLIBSUF)=.def)'
1185
    SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
1186
    SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
1187
    SHFLAGS='-shared -Wl,--output-def,$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
1188
    ;;
1189
  cygwin*)
1190
    targetos=cygwin
1191
    shlibdir="$bindir"
1192
    VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1193
    VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1194
    if enabled swscaler; then
1195
        VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1196
        VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1197
    fi
1198
    EXESUF=".exe"
1199
    SLIBPREF="cyg"
1200
    SLIBSUF=".dll"
1201
    SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1202
    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1203
    SHFLAGS='-shared -Wl,--enable-auto-image-base'
1204
    ;;
1205
  linux)
1206
    LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
1207
    enable dv1394
1208
    ;;
1209
  irix*)
1210
    targetos=irix
1211
    ranlib="echo ignoring ranlib"
1212
    ;;
1213
  *)
1214
    targetos="${targetos}-UNKNOWN"
1215
    ;;
1216
esac
1217

    
1218
add_extralibs $osextralibs
1219

    
1220
if ! disabled logging ; then
1221
    enabled logging || logfile="$logging"
1222
    echo "# $0 $@" >$logfile
1223
    set >>$logfile
1224
else
1225
    logfile=/dev/null
1226
fi
1227

    
1228
# Combine FFLDFLAGS and the LDFLAGS environment variable.
1229
LDFLAGS="$FFLDFLAGS $LDFLAGS"
1230

    
1231
test -n "$cross_prefix" && enable cross_compile
1232
cc="${cross_prefix}${cc}"
1233
ar="${cross_prefix}${ar}"
1234
ranlib="${cross_prefix}${ranlib}"
1235
strip="${cross_prefix}${strip}"
1236

    
1237
# we need to build at least one lib type
1238
if ! enabled_any static shared; then
1239
    cat <<EOF
1240
At least one library type must be built.
1241
Specify --enable-static to build the static libraries or --enable-shared to
1242
build the shared libraries as well. To only build the shared libraries specify
1243
--disable-static in addition to --enable-shared.
1244
EOF
1245
    exit 1;
1246
fi
1247

    
1248
disabled static && LIBNAME=""
1249

    
1250
if ! enabled libogg; then
1251
    enabled libtheora && die "libogg must be enabled to enable libtheora."
1252
    enabled libvorbis && die "libogg must be enabled to enable libvorbis."
1253
fi
1254

    
1255
if enabled_any libfaad libfaadbin ; then
1256
    if check_header faad.h; then
1257
        check_cc << EOF
1258
#include <faad.h>
1259
#ifndef FAAD2_VERSION
1260
ok faad1
1261
#endif
1262
int main( void ) { return 0; }
1263
EOF
1264
        test $? = 0 && enable libfaad2
1265
    else
1266
        die "FAAD test failed."
1267
    fi
1268
fi
1269

    
1270

    
1271
if ! enabled gpl; then
1272
    die_gpl_disabled(){
1273
        name=$1
1274
        shift
1275
        enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
1276
    }
1277
    die_gpl_disabled "The Postprocessing code" pp
1278
    die_gpl_disabled "liba52"                  liba52
1279
    die_gpl_disabled "libx264"                 libx264
1280
    die_gpl_disabled "libxvidcore"             libxvid
1281
    die_gpl_disabled "FAAD2"                   libfaad2
1282
    die_gpl_disabled "The X11 grabber"         x11grab
1283
    die_gpl_disabled "The software scaler"     swscaler
1284
fi
1285

    
1286
check_deps $ARCH_EXT_LIST
1287

    
1288
test -z "$need_memalign" && need_memalign="$mmx"
1289

    
1290
#Darwin CC versions
1291
if test $targetos = darwin; then
1292
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1293
        add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
1294
    else
1295
        add_cflags "-no-cpp-precomp -pipe"
1296
        check_cflags "-force_cpusubtype_ALL"
1297
        check_cflags "-Wno-sign-compare"
1298
        disabled shared && add_cflags -mdynamic-no-pic
1299
    fi
1300
fi
1301

    
1302
disabled optimizations || add_cflags -fomit-frame-pointer
1303

    
1304
# Add processor-specific flags
1305
if test $cpu != "generic"; then
1306
    warn_altivec(){
1307
        $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
1308
    }
1309
    case $cpu in
1310
        601|ppc601|PowerPC601)
1311
            add_cflags "-mcpu=601"
1312
            warn_altivec enabled PPC601
1313
        ;;
1314
        603*|ppc603*|PowerPC603*)
1315
            add_cflags "-mcpu=603"
1316
            warn_altivec enabled PPC603
1317
        ;;
1318
        604*|ppc604*|PowerPC604*)
1319
            add_cflags "-mcpu=604"
1320
            warn_altivec enabled PPC604
1321
        ;;
1322
        G3|g3|75*|ppc75*|PowerPC75*)
1323
            add_cflags "-mcpu=750 -mpowerpc-gfxopt"
1324
            warn_altivec enabled PPC75x
1325
        ;;
1326
        G4|g4|745*|ppc745*|PowerPC745*)
1327
            add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
1328
            warn_altivec disabled PPC745x
1329
        ;;
1330
        74*|ppc74*|PowerPC74*)
1331
            add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
1332
            warn_altivec disabled PPC74xx
1333
        ;;
1334
        G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1335
            add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1336
            warn_altivec disabled PPC970
1337
            enable ppc64
1338
        ;;
1339
        Cell|CELL|cell)
1340
            add_cflags "-mcpu=cell"
1341
            warn_altivec disabled Cell
1342
            enable ppc64
1343
        ;;
1344
        # targets that do NOT support conditional mov (cmov)
1345
        i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1346
            add_cflags "-march=$cpu"
1347
            disable cmov
1348
        ;;
1349
        # targets that do support conditional mov (cmov)
1350
        i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
1351
            add_cflags "-march=$cpu"
1352
            enable cmov
1353
            enable fast_cmov
1354
        ;;
1355
        # targets that do support conditional mov but on which it's slow
1356
        pentium4|prescott|nocona)
1357
            add_cflags "-march=$cpu"
1358
            enable cmov
1359
            disable fast_cmov
1360
        ;;
1361
        sparc64)
1362
            add_cflags "-mcpu=v9"
1363
        ;;
1364
        bf*) #bf531 bf532 bf533 bf561 bf5xx all get this config
1365
            add_cflags "-mfdpic"
1366
            add_ldflags "-mfdpic"
1367
        ;;
1368
        arm*)
1369
            add_cflags "-mcpu=$cpu"
1370
        ;;
1371
        *)
1372
        echo "WARNING: Unknown CPU \"$cpu\", ignored."
1373
        ;;
1374
    esac
1375
fi
1376

    
1377
gnu_make(){
1378
    $1 --version 2>&1 | grep -q GNU
1379
}
1380

    
1381
if ! gnu_make $make; then
1382
    gnu_make gmake && make=gmake || die "GNU make not found."
1383
fi
1384

    
1385
# make sure we can execute files in $TMPDIR
1386
cat >$TMPE 2>>$logfile <<EOF
1387
#! /bin/sh
1388
EOF
1389
chmod +x $TMPE >>$logfile 2>&1
1390
if ! $TMPE >>$logfile 2>&1; then
1391
    cat <<EOF
1392
Unable to create and execute files in $TMPDIR1.  Set the TMPDIR environment
1393
variable to another directory and make sure that $TMPDIR1 is not mounted
1394
noexec.
1395
EOF
1396
    die "Sanity test failed."
1397
fi
1398
rm $TMPE
1399

    
1400
# compiler sanity check
1401
check_exec <<EOF
1402
int main(){
1403
    return 0;
1404
}
1405
EOF
1406
if test "$?" != 0; then
1407
    echo "$cc is unable to create an executable file."
1408
    if test -z "$cross_prefix" && ! enabled cross_compile ; then
1409
        echo "If $cc is a cross-compiler, use the --cross-compile option."
1410
        echo "Only do this if you know what cross compiling means."
1411
    fi
1412
    die "C compiler test failed."
1413
fi
1414

    
1415
if enabled x86; then
1416
    # check whether EBP is available on x86
1417
    # As 'i' is stored on the stack, this program will crash
1418
    # if the base pointer is used to access it because the
1419
    # base pointer is cleared in the inline assembly code.
1420
    check_exec_crash <<EOF && enable ebp_available
1421
    volatile int i=0;
1422
    asm volatile (
1423
        "xorl %%ebp, %%ebp"
1424
    ::: "%ebp");
1425
    return i;
1426
EOF
1427

    
1428
    # check wether EBX is available on x86
1429
    check_asm ebx_available '"":::"%ebx"'
1430

    
1431
    # check whether binutils is new enough to compile SSSE3
1432
    enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
1433
fi
1434

    
1435
# check for assembler specific support
1436

    
1437
if test $arch = "powerpc"; then
1438
check_cc <<EOF && enable dcbzl
1439
int main(void) {
1440
    register long zero = 0;
1441
    char data[1024];
1442
    asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
1443
return 0;
1444
}
1445
EOF
1446
fi
1447

    
1448
# check for SIMD availability
1449

    
1450
# AltiVec flags: The FSF version of GCC differs from the Apple version
1451
if enabled altivec; then
1452
    test -n "`$cc -v 2>&1 | grep version | grep Apple`" &&
1453
        add_cflags "-faltivec" ||
1454
        add_cflags "-maltivec -mabi=altivec"
1455

    
1456
    check_header altivec.h
1457

    
1458
    # check if our compiler supports Motorola AltiVec C API
1459
    enabled altivec_h &&
1460
        inc_altivec_h="#include <altivec.h>" ||
1461
        inc_altivec_h=
1462
    check_cc <<EOF || disable altivec
1463
$inc_altivec_h
1464
int main(void) {
1465
    vector signed int v1, v2, v3;
1466
    v1 = vec_add(v2,v3);
1467
    return 0;
1468
}
1469
EOF
1470
fi
1471

    
1472
enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
1473
enabled armv6   && check_asm armv6   '"sadd16 r0, r0, r0"'
1474
enabled iwmmxt  && check_asm iwmmxt  '"wunpckelub wr6, wr4"'
1475
enabled mmi     && check_asm mmi     '"lq $2, 0($2)"'
1476
enabled vis     && check_asm vis     '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
1477

    
1478
enabled vis && add_cflags "-mcpu=ultrasparc -mtune=ultrasparc"
1479

    
1480
# ---
1481
# big/little-endian test
1482
check_cc <<EOF || die "endian test failed"
1483
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
1484
EOF
1485
grep -q BIGE $TMPO && enable bigendian
1486

    
1487
# ---
1488
# check availability of some header files
1489

    
1490
if check_func dlopen; then
1491
    ldl=
1492
elif check_func dlopen -ldl; then
1493
    ldl=-ldl
1494
fi
1495

    
1496
check_func fork
1497
check_func gethrtime
1498
check_func getrusage
1499
check_func inet_aton
1500
check_func memalign
1501
check_func mkstemp
1502
check_func2 windows.h GetProcessTimes
1503

    
1504
check_header byteswap.h
1505
check_header conio.h
1506
check_header dlfcn.h
1507
check_header malloc.h
1508
check_header termios.h
1509

    
1510
if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
1511
    die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
1512
fi
1513

    
1514
enabled zlib && check_lib zlib.h zlibVersion -lz || disable zlib
1515

    
1516
# ffserver uses poll(),
1517
# if it's not found we can emulate it using select().
1518
if enabled ffserver; then
1519
    check_header sys/poll.h
1520
fi
1521

    
1522
# check for some common methods of building with pthread support
1523
# do this before the optional library checks as some of them require pthreads
1524
if enabled pthreads; then
1525
    if check_func pthread_create; then
1526
        :
1527
    elif check_func pthread_create -pthread; then
1528
        add_cflags -pthread
1529
        add_ldflags -pthread
1530
    elif check_func pthread_create -pthreads; then
1531
        add_cflags -pthreads
1532
        add_ldflags -pthreads
1533
    elif ! check_lib pthread.h pthread_create -lpthread; then
1534
        die "ERROR: can't find pthreads library"
1535
    fi
1536
fi
1537

    
1538
for thread in $THREADS_LIST; do
1539
    if enabled $thread; then
1540
        test -n "$thread_type" &&
1541
            die "ERROR: Only one thread type must be selected." ||
1542
            thread_type="$thread"
1543
    fi
1544
done
1545

    
1546
check_lib math.h sin -lm
1547

    
1548
# test for lrintf in math.h
1549
check_exec <<EOF && enable lrintf || disable lrintf
1550
#define _ISOC9X_SOURCE  1
1551
#include <math.h>
1552
int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
1553
EOF
1554

    
1555
enabled_any libamr_nb libamr_wb && enable libamr
1556

    
1557
# these are off by default, so fail if requested and not available
1558
enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
1559
enabled liba52     && require liba52 a52dec/a52.h a52_init -la52
1560
enabled libamr_nb  && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
1561
enabled libamr_wb  && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
1562
enabled libdc1394  && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
1563
enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
1564
enabled libfaad    && require2 libfaad faad.h faacDecOpen -lfaad
1565
enabled libgsm     && require libgsm gsm.h gsm_create -lgsm
1566
enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
1567
enabled libnut     && require libnut libnut.h nut_demuxer_init -lnut
1568
enabled libogg     && require libogg ogg/ogg.h ogg_sync_init -logg
1569
enabled libtheora  && require libtheora theora/theora.h theora_info_init -ltheora -logg
1570
enabled libvorbis  && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
1571
enabled libx264    && require x264 x264.h x264_encoder_open -lx264
1572
enabled libxvid    && require Xvid xvid.h xvid_global -lxvidcore
1573
enabled mlib       && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
1574

    
1575
# disable the native AC-3 decoder if liba52 is enabled
1576
enabled liba52 && disable ac3_decoder
1577

    
1578
_restrict=
1579
for restrict_keyword in restrict __restrict__ __restrict; do
1580
    check_cc <<EOF && _restrict=$restrict_keyword && break
1581
void foo(char * $restrict_keyword p);
1582
EOF
1583
done
1584

    
1585
test "$vhook" = "default" && vhook="$dlopen"
1586

    
1587
if test "$targetos" = cygwin -o "$targetos" = mingw32 && enabled_all static vhook ; then
1588
    disable vhook
1589
    echo
1590
    echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
1591
    echo "Patches welcome."
1592
    echo
1593
fi
1594

    
1595
if enabled vhook; then
1596
    check_ldflags -rdynamic
1597
    check_ldflags -export-dynamic
1598
fi
1599

    
1600
check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
1601
check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
1602

    
1603
##########################################
1604
# SDL check
1605

    
1606
disable sdl_too_old
1607
disable sdl
1608
SDL_CONFIG="${cross_prefix}sdl-config"
1609
if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
1610
    sdl_cflags=`"${SDL_CONFIG}" --cflags`
1611
    temp_cflags $sdl_cflags
1612
    temp_extralibs `"${SDL_CONFIG}" --libs`
1613
    if check_lib SDL.h SDL_Init; then
1614
        _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
1615
        if test "$_sdlversion" -lt 121 ; then
1616
            enable sdl_too_old
1617
        else
1618
            enable sdl
1619
            check_cc $sdl_cflags <<EOF && enable sdl_video_size
1620
#include <SDL.h>
1621
int main(void){
1622
    const SDL_VideoInfo *vi = SDL_GetVideoInfo();
1623
    int w = vi->current_w;
1624
    return 0;
1625
}
1626
EOF
1627
        fi
1628
    fi
1629
    restore_flags
1630
fi
1631

    
1632
texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
1633

    
1634
##########################################
1635
# Network check
1636

    
1637
if enabled network; then
1638
    # Prefer arpa/inet.h over winsock2
1639
    if check_header arpa/inet.h ; then
1640
        check_func closesocket
1641
    elif check_header winsock2.h ; then
1642
        network_extralibs="-lws2_32"
1643
        check_func2 winsock2.h closesocket
1644
    fi
1645
fi
1646

    
1647
##########################################
1648
# IPv6 check
1649

    
1650
enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
1651
#include <sys/types.h>
1652
#include <sys/socket.h>
1653
#include <netinet/in.h>
1654
#include <netdb.h>
1655
int main( void ) {
1656
  struct sockaddr_storage saddr;
1657
  struct ipv6_mreq mreq6;
1658
  getaddrinfo(0,0,0,0);
1659
  getnameinfo(0,0,0,0,0,0,0);
1660
  IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
1661
}
1662
EOF
1663

    
1664
check_header linux/videodev.h
1665
check_header linux/videodev2.h
1666

    
1667
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1668
{ check_header dev/bktr/ioctl_meteor.h &&
1669
  check_header dev/bktr/ioctl_bt848.h; } ||
1670
{ check_header machine/ioctl_meteor.h &&
1671
  check_header machine/ioctl_bt848.h; } ||
1672
{ check_header dev/video/meteor/ioctl_meteor.h &&
1673
  check_header dev/video/bktr/ioctl_bt848.h; } ||
1674
check_header dev/ic/bt8xx.h
1675

    
1676
check_header sys/soundcard.h
1677
check_header soundcard.h
1678

    
1679
# Deal with the x11 frame grabber
1680
enabled x11grab                         &&
1681
check_header X11/Xlib.h                 &&
1682
check_header X11/extensions/XShm.h      &&
1683
check_func XOpenDisplay -lX11           &&
1684
check_func XShmCreateImage -lX11 -lXext
1685

    
1686
enabled debug && add_cflags -g
1687

    
1688
# add some useful compiler flags if supported
1689
check_cflags -Wdeclaration-after-statement
1690
check_cflags -Wall
1691
check_cflags -Wno-switch
1692
check_cflags -Wdisabled-optimization
1693
check_cflags -Wpointer-arith
1694
check_cflags -Wredundant-decls
1695
check_cflags -Wno-pointer-sign
1696
enabled extra_warnings && check_cflags -Winline
1697

    
1698
# add some linker flags
1699
check_ldflags -Wl,--warn-common
1700
check_ldflags $LDLATEFLAGS
1701

    
1702
if enabled small; then
1703
    check_cflags -Os            # not all compilers support -Os
1704
    optimizations="small"
1705
elif enabled optimizations; then
1706
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1707
        add_cflags  "-O5"
1708
        add_ldflags "-O5"
1709
    else
1710
        add_cflags "-O3"
1711
    fi
1712
fi
1713

    
1714
# PIC flags for shared library objects where they are needed
1715
if enabled shared; then
1716
    # LIBOBJFLAGS may have already been set in the OS configuration
1717
    if test -z "$LIBOBJFLAGS" ; then
1718
        case "$arch" in
1719
            x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS='$(PIC)' ;;
1720
        esac
1721
    fi
1722
fi
1723

    
1724
if enabled gprof; then
1725
    add_cflags  "-p"
1726
    add_ldflags "-p"
1727
fi
1728

    
1729
VHOOKCFLAGS="-fPIC"
1730

    
1731
# Find out if the .align argument is a power of two or not.
1732
if test $asmalign_pot = "unknown"; then
1733
    disable asmalign_pot
1734
    echo 'asm (".align 3");' | check_cc && enable asmalign_pot
1735
fi
1736

    
1737
enabled_any $ENCODER_LIST  && enable encoders
1738
enabled_any $DECODER_LIST  && enable decoders
1739
enabled_any $MUXER_LIST    && enable muxers
1740
enabled_any $DEMUXER_LIST  && enable demuxers
1741
enabled_any $PROTOCOL_LIST && enable protocols
1742
enabled_any $BSF_LIST      && enable bsfs
1743

    
1744
enabled_any $THREADS_LIST  && enable threads
1745

    
1746
check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
1747
    $BSF_LIST $DEMUXER_LIST $MUXER_LIST $PROTOCOL_LIST
1748

    
1749
enabled libdc1394 && append pkg_requires "libraw1394"
1750
enabled libogg    && append pkg_requires "ogg >= 1.1"
1751
enabled libtheora && append pkg_requires "theora"
1752
enabled libvorbis && append pkg_requires "vorbisenc"
1753

    
1754
echo "install prefix            $PREFIX"
1755
echo "source path               $source_path"
1756
echo "C compiler                $cc"
1757
echo "make                      $make"
1758
echo ".align is power-of-two    $asmalign_pot"
1759
echo "ARCH                      $arch ($cpu)"
1760
if test "$BUILDSUF" != ""; then
1761
    echo "build suffix              $BUILDSUF"
1762
fi
1763
echo "big-endian                ${bigendian-no}"
1764
if test $arch = "x86_32" -o $arch = "x86_64"; then
1765
    echo "MMX enabled               ${mmx-no}"
1766
    echo "CMOV enabled              ${cmov-no}"
1767
    echo "CMOV is fast              ${fast_cmov-no}"
1768
    echo "EBX available             ${ebx_available-no}"
1769
    echo "EBP available             ${ebp_available-no}"
1770
fi
1771
if test $arch = "armv4l"; then
1772
    echo "ARMv5TE enabled           ${armv5te-no}"
1773
    echo "ARMv6 enabled             ${armv6-no}"
1774
    echo "IWMMXT enabled            ${iwmmxt-no}"
1775
fi
1776
if test $arch = "mips"; then
1777
    echo "MMI enabled               ${mmi-no}"
1778
fi
1779
if test $arch = "powerpc"; then
1780
    echo "AltiVec enabled           ${altivec-no}"
1781
    echo "dcbzl available           ${dcbzl-no}"
1782
fi
1783
echo "gprof enabled             ${gprof-no}"
1784
echo "debug symbols             ${debug-no}"
1785
echo "strip symbols             ${dostrip-no}"
1786
echo "optimizations             ${optimizations-no}"
1787
echo "static                    ${static-no}"
1788
echo "shared                    ${shared-no}"
1789
echo "postprocessing support    ${pp-no}"
1790
echo "software scaler enabled   ${swscaler-no}"
1791
echo "video hooking             ${vhook-no}"
1792
if enabled vhook; then
1793
    echo "Imlib2 support            ${imlib2-no}"
1794
    echo "FreeType support          ${freetype2-no}"
1795
fi
1796
echo "network support           ${network-no}"
1797
if enabled network; then
1798
    echo "IPv6 support              ${ipv6-no}"
1799
fi
1800
echo "threading support         ${thread_type-no}"
1801
echo "SDL support               ${sdl-no}"
1802
if enabled sdl_too_old; then
1803
    echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
1804
fi
1805
echo "Sun medialib support      ${mlib-no}"
1806
echo "AVISynth enabled          ${avisynth-no}"
1807
echo "liba52 support            ${liba52-no}"
1808
echo "liba52 dlopened           ${liba52bin-no}"
1809
echo "libamr-nb support         ${libamr_nb-no}"
1810
echo "libamr-wb support         ${libamr_wb-no}"
1811
echo "libdc1394 support         ${libdc1394-no}"
1812
echo "libfaac enabled           ${libfaac-no}"
1813
echo "libfaad enabled           ${libfaad-no}"
1814
echo "libfaad dlopened          ${libfaadbin-no}"
1815
echo "libgsm enabled            ${libgsm-no}"
1816
echo "libmp3lame enabled        ${libmp3lame-no}"
1817
echo "libnut enabled            ${libnut-no}"
1818
echo "libogg enabled            ${libogg-no}"
1819
echo "libtheora enabled         ${libtheora-no}"
1820
echo "libvorbis enabled         ${libvorbis-no}"
1821
echo "x264 enabled              ${libx264-no}"
1822
echo "XviD enabled              ${libxvid-no}"
1823
echo "zlib enabled              ${zlib-no}"
1824
enabled gpl &&
1825
    echo "License: GPL" ||
1826
    echo "License: LGPL"
1827

    
1828
for type in decoder encoder parser demuxer muxer protocol bsf; do
1829
    echo "Enabled ${type}s:"
1830
    ucname="\$`toupper $type`_LIST"
1831
    list="`eval echo $ucname`"
1832
    partlist=""
1833
    for part in $list; do
1834
        enabled $part && partlist="$partlist $part"
1835
    done
1836
    partlist=`echo $partlist | sed s/_$type//g | tr ' ' '\n' | sort`
1837
    echo $partlist
1838
done
1839

    
1840
echo "Creating config.mak and config.h..."
1841

    
1842
echo "# Automatically generated by configure - do not modify!" > config.mak
1843
echo "/* Automatically generated by configure - do not modify! */" > $TMPH
1844
echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
1845
echo "#define FFMPEG_CONFIG_H" >> $TMPH
1846
echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
1847

    
1848
echo "PREFIX=$PREFIX" >> config.mak
1849
echo "prefix=\$(DESTDIR)\$(PREFIX)" >> config.mak
1850
echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
1851
echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
1852
echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
1853
echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
1854
echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
1855
echo "MAKE=$make" >> config.mak
1856
echo "CC=$cc" >> config.mak
1857
echo "AR=$ar" >> config.mak
1858
echo "RANLIB=$ranlib" >> config.mak
1859
echo "LDCONFIG=$LDCONFIG" >> config.mak
1860
echo "LN_S=$ln_s" >> config.mak
1861
enabled dostrip &&
1862
    echo "STRIP=$strip" >> config.mak ||
1863
    echo "STRIP=echo ignoring strip" >> config.mak
1864

    
1865
echo "OPTFLAGS=$CFLAGS" >> config.mak
1866
echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
1867
echo "LDFLAGS=$LDFLAGS" >> config.mak
1868
echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
1869
echo "SHFLAGS=$SHFLAGS" >> config.mak
1870
echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
1871
echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
1872
echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
1873
echo "BUILD_STATIC=$static" >> config.mak
1874
echo "BUILDSUF=$BUILDSUF" >> config.mak
1875
echo "FULLNAME=$FULLNAME" >> config.mak
1876
echo "LIBPREF=$LIBPREF" >> config.mak
1877
echo "LIBSUF=$LIBSUF" >> config.mak
1878
echo "LIBNAME=$LIBNAME" >> config.mak
1879
echo "SLIBPREF=$SLIBPREF" >> config.mak
1880
echo "SLIBSUF=$SLIBSUF" >> config.mak
1881
echo "EXESUF=$EXESUF" >> config.mak
1882

    
1883
if enabled bigendian; then
1884
  echo "WORDS_BIGENDIAN=yes" >> config.mak
1885
  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
1886
fi
1887
if enabled mmx; then
1888
  echo "#define __CPU__ 586" >> $TMPH
1889
fi
1890

    
1891
if enabled sdl; then
1892
  echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1893
  echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
1894
fi
1895
if enabled texi2html; then
1896
  echo "BUILD_DOC=yes" >> config.mak
1897
fi
1898

    
1899
sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
1900
pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
1901
lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
1902
lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
1903
lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
1904

    
1905

    
1906

    
1907
if enabled shared; then
1908
  echo "BUILD_SHARED=yes" >> config.mak
1909
  echo "PIC=-fPIC -DPIC" >> config.mak
1910
  echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
1911
  echo "SPPVERSION=$pp_version" >> config.mak
1912
  echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
1913
  echo "LAVCVERSION=$lavc_version" >> config.mak
1914
  echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
1915
  echo "LAVFVERSION=$lavf_version" >> config.mak
1916
  echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
1917
  echo "LAVUVERSION=$lavu_version" >> config.mak
1918
  echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
1919
  echo "SWSVERSION=$sws_version" >> config.mak
1920
  echo "SLIBNAME=${SLIBNAME}" >> config.mak
1921
  echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
1922
  echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
1923
  echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
1924
  echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
1925
  echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
1926
fi
1927
echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
1928
echo "EXTRALIBS=$extralibs" >> config.mak
1929

    
1930
print_config ARCH_   $TMPH config.mak $ARCH_LIST
1931
print_config HAVE_   $TMPH config.mak $HAVE_LIST
1932
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST   \
1933
                                      $DECODER_LIST  \
1934
                                      $ENCODER_LIST  \
1935
                                      $PARSER_LIST   \
1936
                                      $BSF_LIST      \
1937
                                      $DEMUXER_LIST  \
1938
                                      $MUXER_LIST    \
1939
                                      $PROTOCOL_LIST \
1940

    
1941
echo "#define restrict $_restrict" >> $TMPH
1942

    
1943
if enabled small; then
1944
  echo "#define av_always_inline"  >> $TMPH
1945
fi
1946

    
1947
echo "SRC_PATH=\"$source_path\"" >> config.mak
1948
echo "SRC_PATH_BARE=$source_path" >> config.mak
1949
echo "BUILD_ROOT=\"$PWD\"" >> config.mak
1950

    
1951
# Apparently it's not possible to portably echo a backslash.
1952
enabled asmalign_pot &&
1953
  printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
1954
  printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
1955

    
1956

    
1957
echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
1958

    
1959
# Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
1960
cmp -s $TMPH config.h &&
1961
    echo "config.h is unchanged" ||
1962
    mv -f $TMPH config.h
1963

    
1964
rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
1965

    
1966
# build tree in object directory if source path is different from current one
1967
if enabled source_path_used; then
1968
    DIRS="\
1969
         doc \
1970
         libavcodec \
1971
         libavcodec/alpha \
1972
         libavcodec/armv4l \
1973
         libavcodec/bfin \
1974
         libavcodec/i386 \
1975
         libavcodec/mlib \
1976
         libavcodec/ppc \
1977
         libavcodec/sh4 \
1978
         libavcodec/sparc \
1979
         libavformat \
1980
         libavutil \
1981
         libpostproc \
1982
         libswscale \
1983
         tests \
1984
         tools \
1985
         vhook \
1986
         "
1987
    FILES="\
1988
          Makefile \
1989
          common.mak \
1990
          doc/texi2pod.pl \
1991
          libavcodec/Makefile \
1992
          libavformat/Makefile \
1993
          libavutil/Makefile \
1994
          libpostproc/Makefile \
1995
          libswscale/Makefile \
1996
          "
1997
    for dir in $DIRS ; do
1998
            mkdir -p $dir
1999
    done
2000
    for f in $FILES ; do
2001
        $ln_s "$source_path/$f" $f
2002
    done
2003
fi
2004

    
2005

    
2006
# build pkg-config files
2007
# FIXME: libdir and includedir are hardcoded and may differ from the real path.
2008

    
2009
pkgconfig_generate(){
2010
name=$1
2011
comment=$2
2012
version=$3
2013
libs=$4
2014
requires=$5
2015
include=$6
2016
cat <<EOF >$name.pc
2017
prefix=$PREFIX
2018
exec_prefix=\${prefix}
2019
libdir=\${exec_prefix}/lib
2020
includedir=\${prefix}/include
2021

    
2022
Name: $name
2023
Description: $comment
2024
Version: $version
2025
Requires: $requires
2026
Conflicts:
2027
Libs: -L\${libdir} $libs
2028
Cflags: -I\${includedir} -I\${includedir}/$include
2029
EOF
2030
}
2031

    
2032
pkgconfig_generate_uninstalled(){
2033
name=$1
2034
shortname=${name#lib}
2035
comment=$2
2036
version=$3
2037
libs=$4
2038
requires=$5
2039
cat <<EOF >$name-uninstalled.pc
2040
prefix=
2041
exec_prefix=
2042
libdir=\${pcfiledir}/$name
2043
includedir=\${pcfiledir}/$name
2044

    
2045
Name: $name
2046
Description: $comment
2047
Version: $version
2048
Requires: $requires
2049
Conflicts:
2050
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
2051
Cflags: -I\${includedir}
2052
EOF
2053
}
2054

    
2055
pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
2056
pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
2057

    
2058
pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
2059
pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
2060

    
2061
pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2062
pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
2063

    
2064
if enabled pp; then
2065
  pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
2066
  pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
2067
fi
2068

    
2069
if enabled swscaler; then
2070
  pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" -lswscale "libavutil = $lavu_version" ffmpeg
2071
  pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
2072
else
2073
  pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2074
  pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
2075
  apply libswscale.pc sed s/^Libs:.*$/Libs:/
2076
  apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
2077
fi