Statistics
| Branch: | Revision:

ffmpeg / configure @ 0828e476

History | View | Annotate | Download (57.3 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/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-dc1394          enable IIDC-1394 grabbing using libdc1394"
81
  echo "                           and libraw1394 [default=no]"
82
  echo "  --enable-liba52          enable GPLed liba52 support [default=no]"
83
  echo "  --enable-liba52bin       open liba52.so.0 at runtime [default=no]"
84
  echo "  --enable-avisynth        allow reading AVISynth script files [default=no]"
85
  echo "  --enable-libamr-nb       enable libamr-nb floating point audio codec"
86
  echo "  --enable-libamr-wb       enable libamr-wb floating point audio codec"
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 en/decoding via libvorbis,"
97
  echo "                           native implementations exist [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-audio-oss      disable OSS audio support [default=no]"
124
  echo "  --disable-audio-beos     disable BeOS audio support [default=no]"
125
  echo "  --disable-v4l            disable video4linux grabbing [default=no]"
126
  echo "  --disable-v4l2           disable video4linux2 grabbing [default=no]"
127
  echo "  --disable-bktr           disable bktr video grabbing [default=no]"
128
  echo "  --disable-network        disable network support [default=no]"
129
  echo "  --disable-ipv6           disable ipv6 support [default=no]"
130
  echo "  --disable-zlib           disable zlib [default=no]"
131
  echo "  --disable-vhook          disable video hooking support"
132
  echo "  --disable-debug          disable debugging symbols"
133
  echo "  --disable-mpegaudio-hp   faster (but less accurate)"
134
  echo "                           MPEG audio decoding [default=no]"
135
  echo "  --enable-gray            enable full grayscale support (slower color)"
136
  echo "  --disable-ffmpeg         disable ffmpeg build"
137
  echo "  --disable-ffserver       disable ffserver build"
138
  echo "  --disable-ffplay         disable ffplay build"
139
  echo "  --enable-small           optimize for size instead of speed"
140
  echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
141
  echo "  --disable-encoder=NAME   disables encoder NAME"
142
  echo "  --enable-encoder=NAME    enables encoder NAME"
143
  echo "  --disable-decoder=NAME   disables decoder NAME"
144
  echo "  --enable-decoder=NAME    enables decoder NAME"
145
  echo "  --disable-encoders       disables all encoders"
146
  echo "  --disable-decoders       disables all decoders"
147
  echo "  --disable-muxer=NAME     disables muxer NAME"
148
  echo "  --enable-muxer=NAME      enables muxer NAME"
149
  echo "  --disable-muxers         disables all muxers"
150
  echo "  --disable-demuxer=NAME   disables demuxer NAME"
151
  echo "  --enable-demuxer=NAME    enables demuxer NAME"
152
  echo "  --disable-demuxers       disables all demuxers"
153
  echo "  --enable-parser=NAME     enables parser NAME"
154
  echo "  --disable-parser=NAME    disables parser NAME"
155
  echo "  --disable-parsers        disables all parsers"
156
  echo "  --enable-bsf=NAME        enables bitstream filter NAME"
157
  echo "  --disable-bsf=NAME       disables bitstream filter NAME"
158
  echo "  --disable-bsfs           disables all bitstream filters"
159
  echo "  --enable-protocol=NAME   enables protocol NAME"
160
  echo "  --disable-protocol=NAME  disables protocol NAME"
161
  echo "  --disable-protocols      disables all protocols"
162
  echo "  --list-decoders          show all available decoders"
163
  echo "  --list-encoders          show all available encoders"
164
  echo "  --list-muxers            show all available muxers"
165
  echo "  --list-demuxers          show all available demuxers"
166
  echo "  --list-parsers           show all available parsers"
167
  echo "  --list-protocols         show all available protocols"
168
  echo "  --list-bsfs              show all available bitstream filters"
169
  echo
170
  echo "Developer options (useful when working on FFmpeg itself):"
171
  echo "  --enable-gprof           enable profiling with gprof [$gprof]"
172
  echo "  --disable-opts           disable compiler optimizations"
173
  echo "  --enable-extra-warnings  enable more compiler warnings"
174
  echo "  --disable-strip          disable stripping of executables and shared libraries"
175
  echo ""
176
  echo "NOTE: Object files are built at the place where configure is launched."
177
  exit 1
178
}
179

    
180
log(){
181
    echo "$@" >>$logfile
182
}
183

    
184
log_file(){
185
    log BEGIN $1
186
    cat -n $1 >>$logfile
187
    log END $1
188
}
189

    
190
echolog(){
191
    log "$@"
192
    echo "$@"
193
}
194

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

    
217
# "tr '[a-z]' '[A-Z]'" is a workaround for Solaris tr not grokking "tr a-z A-Z"
218
toupper(){
219
    echo "$@" | tr '[a-z]' '[A-Z]'
220
}
221

    
222
tolower(){
223
    echo "$@" | tr '[A-Z]' '[a-z]'
224
}
225

    
226
set_all(){
227
    value=$1
228
    shift
229
    for var in $*; do
230
        eval $var=$value
231
    done
232
}
233

    
234
pushvar(){
235
    for var in $*; do
236
        eval level=\${${var}_level:=0}
237
        eval ${var}_${level}="\$$var"
238
        eval ${var}_level=$(($level+1))
239
    done
240
}
241

    
242
popvar(){
243
    for var in $*; do
244
        eval level=\${${var}_level:-0}
245
        test $level = 0 && continue
246
        eval level=$(($level-1))
247
        eval $var="\${${var}_${level}}"
248
        eval ${var}_level=$level
249
        eval unset ${var}_${level}
250
    done
251
}
252

    
253
enable(){
254
    set_all yes $*
255
}
256

    
257
disable(){
258
    set_all no $*
259
}
260

    
261
enabled(){
262
    eval test "x\$$1" = "xyes"
263
}
264

    
265
disabled(){
266
    eval test "x\$$1" = "xno"
267
}
268

    
269
enabled_all(){
270
    for opt; do
271
        enabled $opt || return 1
272
    done
273
}
274

    
275
disabled_all(){
276
    for opt; do
277
        disabled $opt || return 1
278
    done
279
}
280

    
281
enabled_any(){
282
    for opt; do
283
        enabled $opt && return 0
284
    done
285
}
286

    
287
disabled_any(){
288
    for opt; do
289
        disabled $opt && return 0
290
    done
291
}
292

    
293
is_in(){
294
    value=$1
295
    shift
296
    for var in $*; do
297
        [ $var = $value ] && return 0
298
    done
299
    return 1
300
}
301

    
302
check_deps(){
303
    for cfg; do
304
        enabled ${cfg}_checking && die "Circular dependency for $cfg."
305
        disabled ${cfg}_checking && continue
306
        enable ${cfg}_checking
307

    
308
        eval dep_all="\$${cfg}_deps"
309
        eval dep_any="\$${cfg}_deps_any"
310

    
311
        pushvar cfg dep_all dep_any
312
        check_deps $dep_all $dep_any
313
        popvar cfg dep_all dep_any
314

    
315
        enabled_all $dep_all || disable $cfg
316
        enabled_any $dep_any || disable $cfg
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_ld(){
414
    log check_ld "$@"
415
    check_cc || return
416
    flags=''
417
    libs=''
418
    for f; do
419
        test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
420
    done
421
    check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
422
}
423

    
424
check_cflags(){
425
    log check_cflags "$@"
426
    check_cc "$@" <<EOF && add_cflags "$@"
427
int x;
428
EOF
429
}
430

    
431
check_ldflags(){
432
    log check_ldflags "$@"
433
    check_ld "$@" <<EOF && add_ldflags "$@"
434
int main(){
435
    return 0;
436
}
437
EOF
438
}
439

    
440
check_header(){
441
    log check_header "$@"
442
    header=$1
443
    shift
444
    var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
445
    disable $var
446
    check_cpp "$@" <<EOF && enable $var
447
#include <$header>
448
int x;
449
EOF
450
}
451

    
452
check_func(){
453
    log check_func "$@"
454
    func=$1
455
    shift
456
    disable $func
457
    check_ld "$@" <<EOF && enable $func
458
extern int $func();
459
int main(){
460
    $func();
461
}
462
EOF
463
}
464

    
465
check_func2(){
466
    log check_func2 "$@"
467
    headers=$1
468
    func=$2
469
    shift 2
470
    disable $func
471
    incs=""
472
    for hdr in $headers; do
473
        incs="$incs
474
#include <$hdr>"
475
    done
476
    check_ld "$@" <<EOF && enable $func
477
$incs
478
int main(){
479
    (void) $func;
480
    return 0;
481
}
482
EOF
483
}
484

    
485
check_lib(){
486
    log check_lib "$@"
487
    header="$1"
488
    func="$2"
489
    shift 2
490
    temp_extralibs "$@"
491
    check_header $header && check_func $func && add_extralibs "$@"
492
    err=$?
493
    restore_flags
494
    return $err
495
}
496

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

    
509
check_exec(){
510
    check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
511
}
512

    
513
check_exec_crash(){
514
    code=`cat`
515

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

    
522
    (check_exec "$@") >>$logfile 2>&1 <<EOF
523
#include <signal.h>
524
static void sighandler(int sig){
525
    raise(SIGTERM);
526
}
527
int main(){
528
    signal(SIGILL, sighandler);
529
    signal(SIGFPE, sighandler);
530
    signal(SIGSEGV, sighandler);
531
#ifdef SIGBUS
532
    signal(SIGBUS, sighandler);
533
#endif
534
    { $code }
535
}
536
EOF
537
}
538

    
539
require(){
540
    name="$1"
541
    header="$2"
542
    func="$3"
543
    shift 3
544
    check_lib $header $func "$@" || die "ERROR: $name not found"
545
}
546

    
547
require2(){
548
    name="$1"
549
    headers="$2"
550
    func="$3"
551
    shift 3
552
    check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
553
}
554

    
555
check_foo_config(){
556
    cfg=$1
557
    pkg=$2
558
    header=$3
559
    func=$4
560
    shift 4
561
    disable $cfg
562
    check_cmd ${pkg}-config --version
563
    err=$?
564
    if test "$err" = 0; then
565
        temp_cflags `${pkg}-config --cflags`
566
        temp_extralibs `${pkg}-config --libs`
567
        check_lib "$@" $header $func && enable $cfg
568
    fi
569
    return $err
570
}
571

    
572
apply(){
573
    file=$1
574
    shift
575
    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
576
}
577

    
578
COMPONENT_LIST="
579
    bsfs
580
    decoders
581
    demuxers
582
    encoders
583
    muxers
584
    parsers
585
    protocols
586
"
587

    
588
CONFIG_LIST="
589
    $COMPONENT_LIST
590
    audio_beos
591
    audio_oss
592
    avisynth
593
    beos_netserver
594
    bktr
595
    dc1394
596
    ffmpeg
597
    ffplay
598
    ffserver
599
    gpl
600
    gprof
601
    gray
602
    ipv6
603
    liba52
604
    liba52bin
605
    libamr
606
    libamr_nb
607
    libamr_wb
608
    libfaac
609
    libfaad
610
    libfaadbin
611
    libgsm
612
    libmp3lame
613
    libnut
614
    libogg
615
    libtheora
616
    libvorbis
617
    libx264
618
    libxvid
619
    memalign_hack
620
    mpegaudio_hp
621
    network
622
    powerpc_perf
623
    pp
624
    small
625
    swscaler
626
    vhook
627
    v4l
628
    v4l2
629
    x11grab
630
    zlib
631
"
632

    
633
THREADS_LIST='
634
    beosthreads
635
    pthreads
636
    w32threads
637
'
638

    
639
ARCH_LIST='
640
    alpha
641
    armv4l
642
    bfin
643
    ia64
644
    m68k
645
    mips
646
    parisc
647
    powerpc
648
    s390
649
    sh4
650
    sparc
651
    sparc64
652
    x86
653
    x86_32
654
    x86_64
655
'
656

    
657
ARCH_EXT_LIST='
658
    altivec
659
    armv5te
660
    armv6
661
    iwmmxt
662
    mmi
663
    mmx
664
    ssse3
665
'
666

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

    
714
CMDLINE_SELECT="
715
    $ARCH_EXT_LIST
716
    $CONFIG_LIST
717
    $THREADS_LIST
718
    debug
719
    extra_warnings
720
    shared
721
    static
722
"
723

    
724
# code dependency declarations
725

    
726
# architecture extensions
727
altivec_deps="powerpc"
728
armv5te_deps="armv4l"
729
armv6_deps="armv4l"
730
iwmmxt_deps="armv4l"
731
mmi_deps="mips"
732
mmx_deps="x86"
733
ssse3_deps="x86"
734

    
735
# decoders / encoders
736
ac3_decoder_deps="gpl"
737
dxa_decoder_deps="zlib"
738
flashsv_decoder_deps="zlib"
739
flashsv_encoder_deps="zlib"
740
flv_decoder_deps="h263_decoder"
741
h263_decoder_deps="h263_parser mpeg4video_parser"
742
h263i_decoder_deps="h263_decoder"
743
h264_decoder_deps="h264_parser"
744
mpeg_xvmc_decoder_deps="xvmc"
745
mpeg4_decoder_deps="h263_decoder"
746
msmpeg4v1_decoder_deps="h263_decoder"
747
msmpeg4v2_decoder_deps="h263_decoder"
748
msmpeg4v3_decoder_deps="h263_decoder"
749
png_decoder_deps="zlib"
750
png_encoder_deps="zlib"
751
svq3_decoder_deps="h264_parser"
752
vc1_decoder_deps="h263_decoder"
753
wmv1_decoder_deps="h263_decoder"
754
wmv2_decoder_deps="h263_decoder"
755
wmv3_decoder_deps="h263_decoder"
756
zmbv_decoder_deps="zlib"
757
zmbv_encoder_deps="zlib"
758

    
759
# external libraries
760
mpeg4aac_decoder_deps="libfaad"
761
liba52_decoder_deps="liba52"
762
libamr_nb_decoder_deps="libamr_nb"
763
libamr_nb_encoder_deps="libamr_nb"
764
libamr_wb_decoder_deps="libamr_wb"
765
libamr_wb_encoder_deps="libamr_wb"
766
libfaac_encoder_deps="libfaac"
767
libfaad_decoder_deps="libfaad"
768
libgsm_decoder_deps="libgsm"
769
libgsm_encoder_deps="libgsm"
770
libgsm_ms_decoder_deps="libgsm"
771
libgsm_ms_encoder_deps="libgsm"
772
libmp3lame_encoder_deps="libmp3lame"
773
libtheora_encoder_deps="libtheora"
774
libvorbis_decoder_deps="libvorbis"
775
libvorbis_encoder_deps="libvorbis"
776
libx264_encoder_deps="libx264"
777
libxvid_encoder_deps="libxvid"
778

    
779
# demuxers / muxers
780
ac3_demuxer_deps="ac3_parser"
781
audio_demuxer_deps_any="audio_oss audio_beos"
782
audio_muxer_deps_any="audio_oss audio_beos"
783
dc1394_demuxer_deps="dc1394"
784
dv1394_demuxer_deps="dv1394"
785
libnut_demuxer_deps="libnut"
786
libnut_muxer_deps="libnut"
787
mp3_demuxer_deps="mpegaudio_parser"
788
ogg_muxer_deps="libogg"
789
redir_demuxer_deps="network"
790
rtp_muxer_deps="network mpegts_demuxer"
791
rtsp_demuxer_deps="rtp_protocol rtp_muxer"
792
sdp_demuxer_deps="rtsp_demuxer"
793
v4l2_demuxer_deps="v4l2"
794
video_grab_bktr_demuxer_deps="bktr"
795
video_grab_v4l_demuxer_deps="v4l"
796
x11_grab_device_demuxer_deps="x11grab"
797

    
798
# protocols
799
http_protocol_deps="network"
800
rtp_protocol_deps="udp_protocol"
801
tcp_protocol_deps="network"
802
udp_protocol_deps="network"
803

    
804
# programs
805
ffplay_deps="sdl"
806
ffserver_deps="muxers rtp_protocol"
807

    
808

    
809
# set temporary file name
810
if test ! -z "$TMPDIR" ; then
811
    TMPDIR1="${TMPDIR}"
812
elif test ! -z "$TEMPDIR" ; then
813
    TMPDIR1="${TEMPDIR}"
814
else
815
    TMPDIR1="/tmp"
816
fi
817

    
818
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
819
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
820
TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
821
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
822
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
823

    
824
# default parameters
825

    
826
logging="yes"
827
logfile="config.err"
828

    
829
# installation paths
830
PREFIX="/usr/local"
831
libdir='$(PREFIX)/lib'
832
shlibdir="$libdir"
833
incdir='$(PREFIX)/include/ffmpeg'
834
mandir='$(PREFIX)/man'
835
bindir='$(PREFIX)/bin'
836

    
837
# toolchain
838
cc="gcc"
839
ar="ar"
840
ranlib="ranlib"
841
make="make"
842
strip="strip"
843
asmalign_pot="unknown"
844

    
845
# machine
846
arch=`uname -m`
847
cpu="generic"
848

    
849
# OS
850
targetos=$(tolower $(uname -s))
851

    
852
# non-library system interfaces
853
audio_oss="yes"
854
bktr="yes"
855
v4l2="yes"
856
v4l="yes"
857

    
858
# libraries
859
zlib="yes"
860

    
861
# configurable options
862
debug="yes"
863
dostrip="yes"
864
ffmpeg="yes"
865
ffplay="yes"
866
ffserver="yes"
867
ipv6="yes"
868
static="yes"
869
mpegaudio_hp="yes"
870
network="yes"
871
optimize="yes"
872
protocols="yes"
873
vhook="default"
874

    
875
# build settings
876
SHFLAGS='-shared -Wl,-soname,$@'
877
VHOOKSHFLAGS='$(SHFLAGS)'
878
LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
879
FFSERVERLDFLAGS=-Wl,-E
880
LDCONFIG="ldconfig"
881
LIBPREF="lib"
882
LIBSUF=".a"
883
LIB='$(LIBPREF)$(NAME)$(LIBSUF)'
884
SLIBPREF="lib"
885
SLIBSUF=".so"
886
SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
887
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
888
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
889
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIB)"'
890

    
891
# find source path
892
source_path="`dirname \"$0\"`"
893
source_path_used="yes"
894
if test -z "$source_path" -o "$source_path" = "." ; then
895
    source_path="`pwd`"
896
    source_path_used="no"
897
else
898
    source_path="`cd \"$source_path\"; pwd`"
899
    echo "$source_path" | grep -q '[[:blank:]]' &&
900
      die "Out of tree builds are impossible with whitespace in source path."
901
fi
902

    
903
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
904
    show_help
905
fi
906

    
907
FFMPEG_CONFIGURATION="$@"
908

    
909
ENCODER_LIST=`sed -n 's/^[^#]*ENC.*(.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
910
DECODER_LIST=`sed -n 's/^[^#]*DEC.*(.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
911
PARSER_LIST=`sed -n 's/^[^#]*PARSER.*(.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
912
BSF_LIST=`sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' "$source_path/libavcodec/allcodecs.c"`
913
MUXER_LIST=`sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
914
DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
915
PROTOCOL_LIST=`sed -n 's/^[^#]*PROTOCOL.*(.*, *\(.*\)).*/\1_protocol/p' "$source_path/libavformat/allformats.c"`
916

    
917
enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST $PROTOCOL_LIST $BSF_LIST
918
enable $ARCH_EXT_LIST
919

    
920
die_unknown(){
921
    echo "Unknown option \"$1\"."
922
    echo "See $0 --help for available options."
923
    exit 1
924
}
925

    
926
show_list() {
927
    for part in $*; do
928
        echo $part | sed 's/_[^_]*$//'
929
    done | sort
930
    exit 0
931
}
932

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

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

    
1089
enable $arch
1090
enabled_any x86_32 x86_64 && enable x86
1091
enabled     sparc64       && enable sparc
1092

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

    
1213
add_extralibs $osextralibs
1214

    
1215
if ! disabled logging ; then
1216
    enabled logging || logfile="$logging"
1217
    echo "# $0 $@" >$logfile
1218
    set >>$logfile
1219
else
1220
    logfile=/dev/null
1221
fi
1222

    
1223
# Combine FFLDFLAGS and the LDFLAGS environment variable.
1224
LDFLAGS="$FFLDFLAGS $LDFLAGS"
1225

    
1226
test -n "$cross_prefix" && cross_compile=yes
1227
cc="${cross_prefix}${cc}"
1228
ar="${cross_prefix}${ar}"
1229
ranlib="${cross_prefix}${ranlib}"
1230
strip="${cross_prefix}${strip}"
1231

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

    
1243
if disabled static; then
1244
    LIB=""
1245
fi
1246

    
1247
if ! enabled libogg; then
1248
    enabled libtheora && die "libogg must be enabled to enable libtheora."
1249
    enabled libvorbis && die "libogg must be enabled to enable libvorbis."
1250
fi
1251

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

    
1267

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

    
1283
check_deps $ARCH_EXT_LIST
1284

    
1285
test -z "$need_memalign" && need_memalign="$mmx"
1286

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

    
1299
disabled optimize || add_cflags -fomit-frame-pointer
1300

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

    
1371
gnu_make(){
1372
    $1 --version 2>&1 | grep -q GNU
1373
}
1374

    
1375
if ! gnu_make $make; then
1376
    gnu_make gmake && make=gmake || die "GNU make not found."
1377
fi
1378

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

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

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

    
1422
    # check wether EBX is available on x86
1423
    check_cc <<EOF && enable ebx_available
1424
int main(){
1425
    asm volatile ("":::"%ebx");
1426
}
1427
EOF
1428

    
1429
    # check whether binutils is new enough to compile SSSE3
1430
    enabled ssse3 && check_cc <<EOF || disable ssse3
1431
int main(){
1432
    asm volatile ("pabsw %xmm0, %xmm0");
1433
}
1434
EOF
1435
fi
1436

    
1437
# check for assembler specific support
1438

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

    
1450
# check for SIMD availability
1451

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

    
1460
    check_header altivec.h
1461

    
1462
    # check if our compiler supports Motorola AltiVec C API
1463
    if enabled altivec_h; then
1464
        inc_altivec_h="#include <altivec.h>"
1465
    else
1466
        inc_altivec_h=
1467
    fi
1468
    check_cc <<EOF || altivec=no
1469
$inc_altivec_h
1470
int main(void) {
1471
    vector signed int v1, v2, v3;
1472
    v1 = vec_add(v2,v3);
1473
    return 0;
1474
}
1475
EOF
1476
fi
1477

    
1478
# check armv5te instructions support
1479
enabled armv5te && check_cc <<EOF || disable armv5te
1480
int main(void) {
1481
    __asm__ __volatile__ ("qadd r0, r0, r0");
1482
}
1483
EOF
1484

    
1485
enabled armv6 && check_cc <<EOF || disable armv6
1486
int main(void) {
1487
    __asm__ __volatile__ ("sadd16 r0, r0, r0");
1488
}
1489
EOF
1490

    
1491
# check iwmmxt support
1492
enabled iwmmxt && check_cc <<EOF || disable iwmmxt
1493
int main(void) {
1494
    __asm__ __volatile__ ("wunpckelub wr6, wr4");
1495
}
1496
EOF
1497

    
1498
# check if our compiler supports mmi
1499
enabled mmi && check_cc <<EOF || mmi="no"
1500
int main(void) {
1501
    __asm__ ("lq \$2, 0(\$2)");
1502
    return 0;
1503
}
1504
EOF
1505

    
1506
# ---
1507
# big/little-endian test
1508
check_cc <<EOF || die "endian test failed"
1509
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
1510
EOF
1511
strings - $TMPO | grep -q BIGE && enable bigendian
1512

    
1513
# ---
1514
# check availability of some header files
1515

    
1516
check_header malloc.h
1517
check_func memalign
1518

    
1519
if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
1520
    die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
1521
fi
1522

    
1523
check_header byteswap.h
1524

    
1525
check_func mkstemp
1526
check_func gethrtime
1527

    
1528
check_header termios.h
1529
check_header conio.h
1530

    
1531
check_func inet_aton
1532
enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
1533

    
1534
# ffserver uses poll(),
1535
# if it's not found we can emulate it using select().
1536
if enabled ffserver; then
1537
    check_header sys/poll.h
1538
fi
1539

    
1540
# check for some common methods of building with pthread support
1541
# do this before the optional library checks as some of them require pthreads
1542
if enabled pthreads; then
1543
    if check_func pthread_create; then
1544
        :
1545
    elif check_func pthread_create -pthread; then
1546
        add_cflags -pthread
1547
        add_ldflags -pthread
1548
    elif check_func pthread_create -pthreads; then
1549
        add_cflags -pthreads
1550
        add_ldflags -pthreads
1551
    elif ! check_lib pthread.h pthread_create -lpthread; then
1552
        die "ERROR: can't find pthreads library"
1553
    fi
1554
fi
1555

    
1556
for thread in $THREADS_LIST; do
1557
    if enabled $thread; then
1558
        if test -n "$thread_type"; then
1559
            die "ERROR: Only one thread type must be selected."
1560
        else
1561
            thread_type="$thread"
1562
        fi
1563
    fi
1564
done
1565

    
1566
# test for lrintf in math.h
1567
check_exec <<EOF && lrintf=yes || lrintf=no
1568
#define _ISOC9X_SOURCE  1
1569
#include <math.h>
1570
int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
1571
EOF
1572

    
1573
enabled_any libamr_nb libamr_wb && enable libamr
1574

    
1575
# these are off by default, so fail if requested and not available
1576
enabled liba52     && require liba52 a52dec/a52.h a52_init -la52
1577
enabled libamr_nb  && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
1578
enabled libamr_wb  && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
1579
enabled libgsm     && require libgsm gsm.h gsm_create -lgsm
1580
enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
1581
enabled libtheora  && require libtheora theora/theora.h theora_info_init -ltheora -logg
1582
enabled libvorbis  && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
1583
enabled libogg     && require libogg ogg/ogg.h ogg_sync_init -logg
1584
enabled libnut     && require libnut libnut.h nut_demuxer_init -lnut
1585
enabled libx264    && require x264 x264.h x264_encoder_open -lx264
1586
enabled libxvid    && require Xvid xvid.h xvid_global -lxvidcore
1587
enabled dc1394     && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
1588
enabled mlib       && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
1589
enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
1590
enabled libfaad    && require2 libfaad faad.h faacDecOpen -lfaad
1591
enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
1592

    
1593
# disable the native AC-3 decoder if liba52 is enabled
1594
enabled liba52 && disable ac3_decoder
1595

    
1596
_restrict=
1597
for restrict_keyword in restrict __restrict__ __restrict; do
1598
    check_cc <<EOF && _restrict=$restrict_keyword && break
1599
void foo(char * $restrict_keyword p);
1600
EOF
1601
done
1602

    
1603
# dlopen/dlfcn.h probing
1604

    
1605
check_header dlfcn.h
1606

    
1607
if check_func dlopen; then
1608
    ldl=
1609
elif check_func dlopen -ldl; then
1610
    ldl=-ldl
1611
fi
1612

    
1613
check_func getrusage
1614
check_func2 windows.h GetProcessTimes
1615

    
1616
check_func fork
1617

    
1618
test "$vhook" = "default" && vhook="$dlopen"
1619

    
1620
enabled_any vhook liba52bin libfaadbin ffserver && add_extralibs $ldl
1621

    
1622
if test "$targetos" = cygwin -o "$targetos" = mingw32 && enabled_all static vhook ; then
1623
    vhook="no"
1624
    echo
1625
    echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
1626
    echo "Patches welcome."
1627
    echo
1628
fi
1629

    
1630
if enabled vhook; then
1631
    check_ldflags -rdynamic
1632
    check_ldflags -export-dynamic
1633
fi
1634

    
1635
enabled audio_beos && add_extralibs "-lmedia -lbe"
1636

    
1637
check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
1638
check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
1639

    
1640
##########################################
1641
# SDL check
1642

    
1643
sdl_too_old=no
1644
sdl=no
1645
SDL_CONFIG="${cross_prefix}sdl-config"
1646
if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
1647
    sdl_cflags=`"${SDL_CONFIG}" --cflags`
1648
    temp_cflags $sdl_cflags
1649
    temp_extralibs `"${SDL_CONFIG}" --libs`
1650
    if check_lib SDL.h SDL_Init; then
1651
        _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
1652
        if test "$_sdlversion" -lt 121 ; then
1653
            sdl_too_old=yes
1654
        else
1655
            sdl=yes
1656
            check_cc $sdl_cflags <<EOF && enable sdl_video_size
1657
#include <SDL.h>
1658
int main(void){
1659
    const SDL_VideoInfo *vi = SDL_GetVideoInfo();
1660
    int w = vi->current_w;
1661
    return 0;
1662
}
1663
EOF
1664
        fi
1665
    fi
1666
    restore_flags
1667
fi
1668

    
1669
texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
1670

    
1671
##########################################
1672
# Network check
1673

    
1674
if enabled network; then
1675
    # Prefer arpa/inet.h over winsock2
1676
    if check_header arpa/inet.h ; then
1677
        check_func closesocket
1678
    elif check_header winsock2.h ; then
1679
        add_extralibs -lws2_32
1680
        check_func2 winsock2.h closesocket
1681
    fi
1682
fi
1683

    
1684
##########################################
1685
# IPv6 check
1686

    
1687
enabled network && enabled ipv6 && check_ld <<EOF && ipv6=yes || ipv6=no
1688
#include <sys/types.h>
1689
#include <sys/socket.h>
1690
#include <netinet/in.h>
1691
#include <netdb.h>
1692
int main( void ) {
1693
  struct sockaddr_storage saddr;
1694
  struct ipv6_mreq mreq6;
1695
  getaddrinfo(0,0,0,0);
1696
  getnameinfo(0,0,0,0,0,0,0);
1697
  IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
1698
}
1699
EOF
1700

    
1701
enabled v4l  && check_header linux/videodev.h  || disable v4l
1702
enabled v4l2 && check_header linux/videodev2.h || disable v4l2
1703

    
1704
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1705
if enabled bktr; then
1706
    { check_header dev/bktr/ioctl_meteor.h &&
1707
      check_header dev/bktr/ioctl_bt848.h; } ||
1708
    { check_header machine/ioctl_meteor.h &&
1709
      check_header machine/ioctl_bt848.h; } ||
1710
    { check_header dev/video/meteor/ioctl_meteor.h &&
1711
      check_header dev/video/bktr/ioctl_bt848.h; } ||
1712
    check_header dev/ic/bt8xx.h ||
1713
    disable bktr
1714
fi
1715

    
1716
enabled audio_oss &&
1717
    check_header sys/soundcard.h ||
1718
    check_header soundcard.h ||
1719
    disable audio_oss
1720

    
1721
# Deal with the x11 frame grabber
1722
enabled x11grab                         &&
1723
enabled gpl                             &&
1724
enabled x11_grab_device_demuxer         &&
1725
check_header X11/Xlib.h                 &&
1726
check_header X11/extensions/XShm.h      &&
1727
check_func XOpenDisplay -lX11           &&
1728
check_func XShmCreateImage -lX11 -lXext &&
1729
add_extralibs -lX11 -lXext              ||
1730
disable x11_grab_device_demuxer
1731

    
1732
enabled debug && add_cflags -g
1733

    
1734
# add some useful compiler flags if supported
1735
check_cflags -Wdeclaration-after-statement
1736
check_cflags -Wall
1737
check_cflags -Wno-switch
1738
check_cflags -Wdisabled-optimization
1739
check_cflags -Wpointer-arith
1740
check_cflags -Wredundant-decls
1741
check_cflags -Wno-pointer-sign
1742
enabled extra_warnings && check_cflags -Winline
1743

    
1744
# add some linker flags
1745
check_ldflags -Wl,--warn-common
1746
check_ldflags $LDLATEFLAGS
1747

    
1748
if enabled small; then
1749
    check_cflags -Os            # not all compilers support -Os
1750
    optimize="small"
1751
elif enabled optimize; then
1752
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1753
        add_cflags  "-O5"
1754
        add_ldflags "-O5"
1755
    else
1756
        add_cflags "-O3"
1757
    fi
1758
fi
1759

    
1760
# PIC flags for shared library objects where they are needed
1761
if enabled shared; then
1762
    # LIBOBJFLAGS may have already been set in the OS configuration
1763
    if test -z "$LIBOBJFLAGS" ; then
1764
        case "$arch" in
1765
            x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS="\$(PIC)" ;;
1766
        esac
1767
    fi
1768
fi
1769

    
1770
if enabled gprof; then
1771
    add_cflags  "-p"
1772
    add_ldflags "-p"
1773
fi
1774

    
1775
VHOOKCFLAGS="-fPIC"
1776

    
1777
# find if .align arg is power-of-two or not
1778
if test $asmalign_pot = "unknown"; then
1779
    asmalign_pot="no"
1780
    echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
1781
fi
1782

    
1783
enabled_any $ENCODER_LIST  && enable encoders
1784
enabled_any $DECODER_LIST  && enable decoders
1785
enabled_any $MUXER_LIST    && enable muxers
1786
enabled_any $DEMUXER_LIST  && enable demuxers
1787
enabled_any $PROTOCOL_LIST && enable protocols
1788
enabled_any $BSF_LIST      && enable bsfs
1789

    
1790
enabled_any $THREADS_LIST  && enable threads
1791

    
1792
check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
1793
    $BSF_LIST $DEMUXER_LIST $MUXER_LIST $PROTOCOL_LIST
1794

    
1795
enabled libogg    && append pkg_requires "ogg >= 1.1"
1796
enabled libtheora && append pkg_requires "theora"
1797
enabled libvorbis && append pkg_requires "vorbis vorbisenc"
1798
enabled dc1394    && append pkg_requires "libraw1394"
1799

    
1800
echo "install prefix            $PREFIX"
1801
echo "source path               $source_path"
1802
echo "C compiler                $cc"
1803
echo "make                      $make"
1804
echo ".align is power-of-two    $asmalign_pot"
1805
echo "ARCH                      $arch ($cpu)"
1806
if test "$BUILDSUF" != ""; then
1807
    echo "build suffix              $BUILDSUF"
1808
fi
1809
echo "big-endian                ${bigendian-no}"
1810
if test $arch = "x86_32" -o $arch = "x86_64"; then
1811
    echo "MMX enabled               ${mmx-no}"
1812
    echo "CMOV enabled              ${cmov-no}"
1813
    echo "CMOV is fast              ${fast_cmov-no}"
1814
fi
1815
if test $arch = "armv4l"; then
1816
    echo "ARMv5TE enabled           ${armv5te-no}"
1817
    echo "ARMv6 enabled             ${armv6-no}"
1818
    echo "IWMMXT enabled            ${iwmmxt-no}"
1819
fi
1820
if test $arch = "mips"; then
1821
    echo "MMI enabled               ${mmi-no}"
1822
fi
1823
if test $arch = "powerpc"; then
1824
    echo "AltiVec enabled           ${altivec-no}"
1825
    echo "dcbzl available           ${dcbzl-no}"
1826
fi
1827
echo "gprof enabled             ${gprof-no}"
1828
echo "debug symbols             ${debug-no}"
1829
echo "strip symbols             ${dostrip-no}"
1830
echo "optimize                  ${optimize-no}"
1831
echo "static                    ${static-no}"
1832
echo "shared                    ${shared-no}"
1833
echo "postprocessing support    ${pp-no}"
1834
echo "software scaler enabled   ${swscaler-no}"
1835
echo "video hooking             ${vhook-no}"
1836
if enabled vhook; then
1837
    echo "Imlib2 support            ${imlib2-no}"
1838
    echo "FreeType support          ${freetype2-no}"
1839
fi
1840
echo "network support           ${network-no}"
1841
if enabled network; then
1842
    echo "IPv6 support              ${ipv6-no}"
1843
fi
1844
echo "threading support         ${thread_type-no}"
1845
echo "SDL support               ${sdl-no}"
1846
if enabled sdl_too_old; then
1847
    echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
1848
fi
1849
echo "Sun medialib support      ${mlib-no}"
1850
echo "AVISynth enabled          ${avisynth-no}"
1851
echo "liba52 support            ${liba52-no}"
1852
echo "liba52 dlopened           ${liba52bin-no}"
1853
echo "libamr-nb support         ${libamr_nb-no}"
1854
echo "libamr-wb support         ${libamr_wb-no}"
1855
echo "libfaac enabled           ${libfaac-no}"
1856
echo "libfaad enabled           ${libfaad-no}"
1857
echo "libfaad dlopened          ${libfaadbin-no}"
1858
echo "libgsm enabled            ${libgsm-no}"
1859
echo "libmp3lame enabled        ${libmp3lame-no}"
1860
echo "libnut enabled            ${libnut-no}"
1861
echo "libogg enabled            ${libogg-no}"
1862
echo "libtheora enabled         ${libtheora-no}"
1863
echo "libvorbis enabled         ${libvorbis-no}"
1864
echo "x264 enabled              ${libx264-no}"
1865
echo "XviD enabled              ${libxvid-no}"
1866
echo "zlib enabled              ${zlib-no}"
1867
if ! enabled gpl; then
1868
    echo "License: LGPL"
1869
else
1870
    echo "License: GPL"
1871
fi
1872

    
1873
echo "Creating config.mak and config.h..."
1874

    
1875
echo "# Automatically generated by configure - do not modify!" > config.mak
1876
echo "/* Automatically generated by configure - do not modify! */" > $TMPH
1877
echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
1878

    
1879
echo "PREFIX=$PREFIX" >> config.mak
1880
echo "prefix=\$(DESTDIR)\$(PREFIX)" >> config.mak
1881
echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
1882
echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
1883
echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
1884
echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
1885
echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
1886
echo "MAKE=$make" >> config.mak
1887
echo "CC=$cc" >> config.mak
1888
echo "AR=$ar" >> config.mak
1889
echo "RANLIB=$ranlib" >> config.mak
1890
if enabled dostrip; then
1891
    echo "STRIP=$strip" >> config.mak
1892
else
1893
    echo "STRIP=echo ignoring strip" >> config.mak
1894
fi
1895

    
1896
echo "OPTFLAGS=$CFLAGS" >> config.mak
1897
echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
1898
echo "LDFLAGS=$LDFLAGS" >> config.mak
1899
echo "LDCONFIG=$LDCONFIG" >> config.mak
1900
echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
1901
echo "SHFLAGS=$SHFLAGS" >> config.mak
1902
echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
1903
echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
1904
echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
1905
echo "BUILD_STATIC=$static" >> config.mak
1906
echo "BUILDSUF=$BUILDSUF" >> config.mak
1907
echo "LIBPREF=$LIBPREF" >> config.mak
1908
echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
1909
echo "LIB=$LIB" >> config.mak
1910
echo "SLIBPREF=$SLIBPREF" >> config.mak
1911
echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
1912
echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
1913

    
1914
if enabled bigendian; then
1915
  echo "WORDS_BIGENDIAN=yes" >> config.mak
1916
  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
1917
fi
1918
if enabled mmx; then
1919
  echo "#define __CPU__ 586" >> $TMPH
1920
fi
1921

    
1922
if enabled sdl; then
1923
  echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1924
  echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
1925
fi
1926
if enabled texi2html; then
1927
  echo "BUILD_DOC=yes" >> config.mak
1928
fi
1929

    
1930
sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
1931
pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
1932
lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
1933
lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
1934
lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
1935

    
1936

    
1937

    
1938
if enabled shared; then
1939
  echo "BUILD_SHARED=yes" >> config.mak
1940
  echo "PIC=-fPIC -DPIC" >> config.mak
1941
  echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
1942
  echo "SPPVERSION=$pp_version" >> config.mak
1943
  echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
1944
  echo "LAVCVERSION=$lavc_version" >> config.mak
1945
  echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
1946
  echo "LAVFVERSION=$lavf_version" >> config.mak
1947
  echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
1948
  echo "LAVUVERSION=$lavu_version" >> config.mak
1949
  echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
1950
  echo "SWSVERSION=$sws_version" >> config.mak
1951
  echo "SLIBNAME=${SLIBNAME}" >> config.mak
1952
  echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
1953
  echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
1954
  echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
1955
  echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
1956
fi
1957
echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
1958
echo "EXTRALIBS=$extralibs" >> config.mak
1959

    
1960
print_config ARCH_   $TMPH config.mak $ARCH_LIST
1961
print_config HAVE_   $TMPH config.mak $HAVE_LIST
1962
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST   \
1963
                                      $DECODER_LIST  \
1964
                                      $ENCODER_LIST  \
1965
                                      $PARSER_LIST   \
1966
                                      $BSF_LIST      \
1967
                                      $DEMUXER_LIST  \
1968
                                      $MUXER_LIST    \
1969
                                      $PROTOCOL_LIST \
1970

    
1971
if test "$targetos" = darwin; then
1972
  echo "#define SYS_DARWIN 1"  >> $TMPH
1973
fi
1974

    
1975
echo "#define restrict $_restrict" >> $TMPH
1976

    
1977
if enabled small; then
1978
  echo "#define av_always_inline"  >> $TMPH
1979
fi
1980

    
1981
echo "SRC_PATH=\"$source_path\"" >> config.mak
1982
echo "SRC_PATH_BARE=$source_path" >> config.mak
1983
echo "BUILD_ROOT=\"$PWD\"" >> config.mak
1984

    
1985
# Apparently it's not possible to portably echo a backslash.
1986
if enabled asmalign_pot; then
1987
  printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
1988
else
1989
  printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
1990
fi
1991

    
1992

    
1993
# Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
1994
if ! cmp -s $TMPH config.h; then
1995
        mv -f $TMPH config.h
1996
else
1997
        echo "config.h is unchanged"
1998
fi
1999

    
2000
rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
2001

    
2002
# build tree in object directory if source path is different from current one
2003
if enabled source_path_used; then
2004
    DIRS="\
2005
         doc \
2006
         libavcodec \
2007
         libavcodec/alpha \
2008
         libavcodec/armv4l \
2009
         libavcodec/bfin \
2010
         libavcodec/i386 \
2011
         libavcodec/mlib \
2012
         libavcodec/ppc \
2013
         libavcodec/sh4 \
2014
         libavcodec/sparc \
2015
         libavformat \
2016
         libavutil \
2017
         libpostproc \
2018
         libswscale \
2019
         tests \
2020
         tools \
2021
         vhook \
2022
         "
2023
    FILES="\
2024
          Makefile \
2025
          common.mak \
2026
          doc/texi2pod.pl \
2027
          libavcodec/Makefile \
2028
          libavformat/Makefile \
2029
          libavutil/Makefile \
2030
          libpostproc/Makefile \
2031
          libswscale/Makefile \
2032
          "
2033
    for dir in $DIRS ; do
2034
            mkdir -p $dir
2035
    done
2036
    for f in $FILES ; do
2037
        ln -sf "$source_path/$f" $f
2038
    done
2039
fi
2040

    
2041

    
2042
# build pkg-config files
2043
# FIXME: libdir and includedir are hardcoded and may differ from the real path.
2044

    
2045
pkgconfig_generate(){
2046
name=$1
2047
comment=$2
2048
version=$3
2049
libs=$4
2050
requires=$5
2051
include=$6
2052
cat <<EOF >$name.pc
2053
prefix=$PREFIX
2054
exec_prefix=\${prefix}
2055
libdir=\${exec_prefix}/lib
2056
includedir=\${prefix}/include
2057

    
2058
Name: $name
2059
Description: $comment
2060
Version: $version
2061
Requires: $requires
2062
Conflicts:
2063
Libs: -L\${libdir} $libs
2064
Cflags: -I\${includedir} -I\${includedir}/$include
2065
EOF
2066
}
2067

    
2068
pkgconfig_generate_uninstalled(){
2069
name=$1
2070
shortname=${name#lib}
2071
comment=$2
2072
version=$3
2073
libs=$4
2074
requires=$5
2075
cat <<EOF >$name-uninstalled.pc
2076
prefix=
2077
exec_prefix=
2078
libdir=\${pcfiledir}/$name
2079
includedir=\${pcfiledir}/$name
2080

    
2081
Name: $name
2082
Description: $comment
2083
Version: $version
2084
Requires: $requires
2085
Conflicts:
2086
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
2087
Cflags: -I\${includedir}
2088
EOF
2089
}
2090

    
2091
pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
2092
pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
2093

    
2094
pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
2095
pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
2096

    
2097
pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2098
pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
2099

    
2100
if enabled pp; then
2101
  pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
2102
  pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
2103
fi
2104

    
2105
if enabled swscaler; then
2106
  pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" -lswscale "libavutil = $lavu_version" ffmpeg
2107
  pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
2108
else
2109
  pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2110
  pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
2111
  apply libswscale.pc sed s/^Libs:.*$/Libs:/
2112
  apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
2113
fi