Statistics
| Branch: | Revision:

ffmpeg / configure @ a53cc2a4

History | View | Annotate | Download (56.4 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-os2threads      use OS/2 threads [default=no]"
75
  echo "  --enable-pthreads        use pthreads [default=no]"
76
  echo "  --enable-w32threads      use Win32 threads [default=no]"
77
  echo "  --enable-x11grab         enable X11 grabbing [default=no]"
78
  echo
79
  echo "External library support:"
80
  echo "  --enable-sunmlib         use Sun medialib [default=no]"
81
  echo "  --enable-dc1394          enable IIDC-1394 grabbing using libdc1394"
82
  echo "                           and libraw1394 [default=no]"
83
  echo "  --enable-liba52          enable GPLed liba52 support [default=no]"
84
  echo "  --enable-liba52bin       open liba52.so.0 at runtime [default=no]"
85
  echo "  --enable-avisynth        allow reading AVISynth script files [default=no]"
86
  echo "  --enable-libdts          enable GPLed libdts support [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      build FAAD support with runtime linking [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-x264            enable H.264 encoding via x264 [default=no]"
99
  echo "  --enable-xvid            enable Xvid encoding via xvidcore,"
100
  echo "                           native MPEG-4/Xvid encoder exists [default=no]"
101
  echo "  --enable-amr-nb          enable amr-nb floating point audio codec"
102
  echo "  --enable-amr-wb          enable amr-wb floating point audio codec"
103
  echo ""
104
  echo "Advanced options (experts only):"
105
  echo "  --source-path=PATH       path to source code [$source_path]"
106
  echo "  --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]"
107
  echo "  --cross-compile          assume a cross-compiler is used"
108
  echo "  --target-os=OS           compiler targets OS [$targetos]"
109
  echo "  --cc=CC                  use C compiler CC [$cc]"
110
  echo "  --make=MAKE              use specified make [$make]"
111
  echo "  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS [$CFLAGS]"
112
  echo "  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
113
  echo "  --extra-libs=ELIBS       add ELIBS [$ELIBS]"
114
  echo "  --build-suffix=SUFFIX    suffix for application specific build []"
115
  echo "  --arch=ARCH              select architecture  [$arch]"
116
  echo "  --cpu=CPU                selects the minimum cpu required (affects"
117
  echo "                           instruction selection, may crash on older CPUs)"
118
  echo "  --enable-powerpc-perf    enable performance report on PPC"
119
  echo "                           (requires enabling PMC)"
120
  echo "  --disable-mmx            disable MMX usage"
121
  echo "  --disable-armv5te        disable armv5te usage"
122
  echo "  --disable-armv6          disable armv6 usage"
123
  echo "  --disable-iwmmxt         disable iwmmxt usage"
124
  echo "  --disable-altivec        disable AltiVec usage"
125
  echo "  --disable-audio-oss      disable OSS audio support [default=no]"
126
  echo "  --disable-audio-beos     disable BeOS audio support [default=no]"
127
  echo "  --disable-v4l            disable video4linux grabbing [default=no]"
128
  echo "  --disable-v4l2           disable video4linux2 grabbing [default=no]"
129
  echo "  --disable-bktr           disable bktr video grabbing [default=no]"
130
  echo "  --disable-dv1394         disable DV1394 grabbing [default=no]"
131
  echo "  --disable-network        disable network support [default=no]"
132
  echo "  --disable-ipv6           disable ipv6 support [default=no]"
133
  echo "  --disable-zlib           disable zlib [default=no]"
134
  echo "  --disable-vhook          disable video hooking support"
135
  echo "  --disable-debug          disable debugging symbols"
136
  echo "  --disable-mpegaudio-hp   faster (but less accurate)"
137
  echo "                           MPEG audio decoding [default=no]"
138
  echo "  --disable-protocols      disable I/O protocols support [default=no]"
139
  echo "  --disable-ffmpeg         disable ffmpeg build"
140
  echo "  --disable-ffserver       disable ffserver build"
141
  echo "  --disable-ffplay         disable ffplay build"
142
  echo "  --enable-small           optimize for size instead of speed"
143
  echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
144
  echo "  --disable-encoder=NAME   disables encoder NAME"
145
  echo "  --enable-encoder=NAME    enables encoder NAME"
146
  echo "  --disable-decoder=NAME   disables decoder NAME"
147
  echo "  --enable-decoder=NAME    enables decoder NAME"
148
  echo "  --disable-encoders       disables all encoders"
149
  echo "  --disable-decoders       disables all decoders"
150
  echo "  --disable-muxer=NAME     disables muxer NAME"
151
  echo "  --enable-muxer=NAME      enables muxer NAME"
152
  echo "  --disable-muxers         disables all muxers"
153
  echo "  --disable-demuxer=NAME   disables demuxer NAME"
154
  echo "  --enable-demuxer=NAME    enables demuxer NAME"
155
  echo "  --disable-demuxers       disables all demuxers"
156
  echo "  --enable-parser=NAME     enables parser NAME"
157
  echo "  --disable-parser=NAME    disables parser NAME"
158
  echo "  --disable-parsers        disables all parsers"
159
  echo
160
  echo "Developer options (useful when working on FFmpeg itself):"
161
  echo "  --enable-gprof           enable profiling with gprof [$gprof]"
162
  echo "  --disable-opts           disable compiler optimizations"
163
  echo "  --enable-extra-warnings  enable more compiler warnings"
164
  echo "  --disable-strip          disable stripping of executables and shared libraries"
165
  echo ""
166
  echo "NOTE: Object files are built at the place where configure is launched."
167
  exit 1
168
}
169

    
170
log(){
171
    echo "$@" >>$logfile
172
}
173

    
174
log_file(){
175
    log BEGIN $1
176
    cat -n $1 >>$logfile
177
    log END $1
178
}
179

    
180
echolog(){
181
    log "$@"
182
    echo "$@"
183
}
184

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

    
207
# "tr '[a-z]' '[A-Z]'" is a workaround for Solaris tr not grokking "tr a-z A-Z"
208
toupper(){
209
    echo "$@" | tr '[a-z]' '[A-Z]'
210
}
211

    
212
tolower(){
213
    echo "$@" | tr '[A-Z]' '[a-z]'
214
}
215

    
216
set_all(){
217
    value=$1
218
    shift
219
    for var in $*; do
220
        eval $var=$value
221
    done
222
}
223

    
224
pushvar(){
225
    for var in $*; do
226
        eval level=\${${var}_level:=0}
227
        eval ${var}_${level}="\$$var"
228
        eval ${var}_level=$(($level+1))
229
    done
230
}
231

    
232
popvar(){
233
    for var in $*; do
234
        eval level=\${${var}_level:-0}
235
        test $level = 0 && continue
236
        eval level=$(($level-1))
237
        eval $var="\${${var}_${level}}"
238
        eval ${var}_level=$level
239
        eval unset ${var}_${level}
240
    done
241
}
242

    
243
enable(){
244
    set_all yes $*
245
}
246

    
247
disable(){
248
    set_all no $*
249
}
250

    
251
enabled(){
252
    eval test "x\$$1" = "xyes"
253
}
254

    
255
disabled(){
256
    eval test "x\$$1" = "xno"
257
}
258

    
259
enabled_all(){
260
    for opt; do
261
        enabled $opt || return 1
262
    done
263
}
264

    
265
disabled_all(){
266
    for opt; do
267
        disabled $opt || return 1
268
    done
269
}
270

    
271
enabled_any(){
272
    for opt; do
273
        enabled $opt && return 0
274
    done
275
}
276

    
277
disabled_any(){
278
    for opt; do
279
        disabled $opt && return 0
280
    done
281
}
282

    
283
check_deps(){
284
    for cfg; do
285
        enabled ${cfg}_checking && die "Circular dependency for $cfg."
286
        disabled ${cfg}_checking && continue
287
        enable ${cfg}_checking
288

    
289
        eval dep_all="\$${cfg}_deps"
290
        eval dep_any="\$${cfg}_deps_any"
291

    
292
        pushvar cfg dep_all dep_any
293
        check_deps $dep_all $dep_any
294
        popvar cfg dep_all dep_any
295

    
296
        enabled_all $dep_all || disable $cfg
297
        enabled_any $dep_any || disable $cfg
298

    
299
        disable ${cfg}_checking
300
    done
301
}
302

    
303
print_config(){
304
    pfx=$1
305
    header=$2
306
    makefile=$3
307
    shift 3
308
    for cfg; do
309
        if enabled $cfg; then
310
            ucname="${pfx}`toupper $cfg`"
311
            echo "#define ${ucname} 1" >> $header
312
            echo "${ucname}=yes" >> $makefile
313
        fi
314
    done
315
}
316

    
317
flags_saved(){
318
    (: ${SAVE_CFLAGS?}) 2>/dev/null
319
}
320

    
321
save_flags(){
322
    flags_saved && return
323
    SAVE_CFLAGS="$CFLAGS"
324
    SAVE_LDFLAGS="$LDFLAGS"
325
    SAVE_extralibs="$extralibs"
326
}
327

    
328
restore_flags(){
329
    flags_saved || return
330
    CFLAGS="$SAVE_CFLAGS"
331
    LDFLAGS="$SAVE_LDFLAGS"
332
    extralibs="$SAVE_extralibs"
333
    unset SAVE_CFLAGS
334
    unset SAVE_LDFLAGS
335
    unset SAVE_extralibs
336
}
337

    
338
temp_cflags(){
339
    save_flags
340
    CFLAGS="$CFLAGS $*"
341
}
342

    
343
temp_ldflags(){
344
    save_flags
345
    LDFLAGS="$LDFLAGS $*"
346
}
347

    
348
temp_extralibs(){
349
    save_flags
350
    extralibs="$extralibs $*"
351
}
352

    
353
append(){
354
    var=$1
355
    shift
356
    flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
357
    eval "$var=\"\$$var $*\""
358
}
359

    
360
add_cflags(){
361
    append CFLAGS "$@"
362
}
363

    
364
add_ldflags(){
365
    append LDFLAGS "$@"
366
}
367

    
368
add_extralibs(){
369
    append extralibs "$@"
370
}
371

    
372
check_cmd(){
373
    log "$@"
374
    "$@" >>$logfile 2>&1
375
}
376

    
377
check_cc(){
378
    log check_cc "$@"
379
    cat >$TMPC
380
    log_file $TMPC
381
    check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
382
}
383

    
384
check_cpp(){
385
    log check_cpp "$@"
386
    cat >$TMPC
387
    log_file $TMPC
388
    check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
389
}
390

    
391
check_ld(){
392
    log check_ld "$@"
393
    check_cc || return
394
    check_cmd $cc $LDFLAGS "$@" -o $TMPE $TMPO $extralibs
395
}
396

    
397
check_cflags(){
398
    log check_cflags "$@"
399
    check_cc "$@" <<EOF && add_cflags "$@"
400
int x;
401
EOF
402
}
403

    
404
check_ldflags(){
405
    log check_ldflags "$@"
406
    check_ld "$@" <<EOF && add_ldflags "$@"
407
int main(){
408
    return 0;
409
}
410
EOF
411
}
412

    
413
check_header(){
414
    log check_header "$@"
415
    header=$1
416
    shift
417
    var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
418
    disable $var
419
    check_cpp "$@" <<EOF && enable $var
420
#include <$header>
421
int x;
422
EOF
423
}
424

    
425
check_func(){
426
    log check_func "$@"
427
    func=$1
428
    shift
429
    disable $func
430
    check_ld "$@" <<EOF && enable $func
431
extern int $func();
432
int main(){
433
    $func();
434
}
435
EOF
436
}
437

    
438
check_func2(){
439
    log check_func2 "$@"
440
    headers=$1
441
    func=$2
442
    shift 2
443
    disable $func
444
    incs=""
445
    for hdr in $headers; do
446
        incs="$incs
447
#include <$hdr>"
448
    done
449
    check_ld "$@" <<EOF && enable $func
450
$incs
451
int main(){
452
    (void) $func;
453
    return 0;
454
}
455
EOF
456
}
457

    
458
check_lib(){
459
    log check_lib "$@"
460
    header="$1"
461
    func="$2"
462
    shift 2
463
    temp_extralibs "$@"
464
    check_header $header && check_func $func && add_extralibs "$@"
465
    err=$?
466
    restore_flags
467
    return $err
468
}
469

    
470
check_lib2(){
471
    log check_lib2 "$@"
472
    headers="$1"
473
    func="$2"
474
    shift 2
475
    temp_extralibs "$@"
476
    check_func2 "$headers" $func && add_extralibs "$@"
477
    err=$?
478
    restore_flags
479
    return $err
480
}
481

    
482
check_exec(){
483
    check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
484
}
485

    
486
check_exec_crash(){
487
    code=`cat`
488

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

    
495
    (check_exec "$@") >>$logfile 2>&1 <<EOF
496
#include <signal.h>
497
static void sighandler(int sig){
498
    raise(SIGTERM);
499
}
500
int main(){
501
    signal(SIGILL, sighandler);
502
    signal(SIGFPE, sighandler);
503
    signal(SIGSEGV, sighandler);
504
#ifdef SIGBUS
505
    signal(SIGBUS, sighandler);
506
#endif
507
    { $code }
508
}
509
EOF
510
}
511

    
512
require(){
513
    name="$1"
514
    header="$2"
515
    func="$3"
516
    shift 3
517
    check_lib $header $func "$@" || die "ERROR: $name not found"
518
}
519

    
520
require2(){
521
    name="$1"
522
    headers="$2"
523
    func="$3"
524
    shift 3
525
    check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
526
}
527

    
528
check_foo_config(){
529
    cfg=$1
530
    pkg=$2
531
    header=$3
532
    func=$4
533
    shift 4
534
    disable $cfg
535
    check_cmd ${pkg}-config --version
536
    err=$?
537
    if test "$err" = 0; then
538
        temp_cflags `${pkg}-config --cflags`
539
        temp_extralibs `${pkg}-config --libs`
540
        check_lib "$@" $header $func && enable $cfg
541
    fi
542
    return $err
543
}
544

    
545
apply(){
546
    file=$1
547
    shift
548
    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
549
}
550

    
551
CONFIG_LIST='
552
    encoders
553
    decoders
554
    parsers
555
    muxers
556
    demuxers
557
    amr
558
    amr_nb
559
    amr_wb
560
    audio_beos
561
    audio_oss
562
    avisynth
563
    beos_netserver
564
    bktr
565
    dc1394
566
    dv1394
567
    ffmpeg
568
    ffplay
569
    ffserver
570
    gpl
571
    gprof
572
    ipv6
573
    liba52
574
    liba52bin
575
    libdts
576
    libfaac
577
    libfaad
578
    libfaadbin
579
    libgsm
580
    libmp3lame
581
    libnut
582
    libogg
583
    libtheora
584
    libvorbis
585
    memalign_hack
586
    mpegaudio_hp
587
    network
588
    powerpc_perf
589
    pp
590
    protocols
591
    swscaler
592
    vhook
593
    v4l
594
    v4l2
595
    x11grab
596
    x264
597
    xvid
598
    zlib
599
'
600

    
601
THREADS_LIST='
602
    beosthreads
603
    os2threads
604
    pthreads
605
    w32threads
606
'
607

    
608
HAVE_LIST="
609
    $THREADS_LIST
610
    altivec
611
    altivec_h
612
    armv5te
613
    armv6
614
    arpa_inet_h
615
    byteswap_h
616
    cmov
617
    dcbzl
618
    dev_bktr_ioctl_bt848_h
619
    dev_bktr_ioctl_meteor_h
620
    dev_ic_bt8xx_h
621
    dev_video_meteor_ioctl_meteor_h
622
    dev_video_bktr_ioctl_bt848_h
623
    dlfcn_h
624
    dlopen
625
    ebp_available
626
    ebx_available
627
    fast_64bit
628
    fast_cmov
629
    fast_unaligned
630
    freetype2
631
    imlib2
632
    inet_aton
633
    iwmmxt
634
    localtime_r
635
    lrintf
636
    machine_ioctl_bt848_h
637
    machine_ioctl_meteor_h
638
    malloc_h
639
    memalign
640
    mlib
641
    mmi
642
    mmx
643
    os2
644
    sdl
645
    sdl_video_size
646
    soundcard_h
647
    sys_poll_h
648
    sys_soundcard_h
649
    threads
650
"
651

    
652
TARGET_LIST='
653
    altivec
654
    armv5te
655
    armv6
656
    iwmmxt
657
    mmi
658
    mmx
659
'
660

    
661
CMDLINE_SELECT="
662
    $CONFIG_LIST
663
    $TARGET_LIST
664
    $THREADS_LIST
665
    debug
666
    extra_warnings
667
    shared
668
    static
669
"
670

    
671
dxa_decoder_deps="zlib"
672
flashsv_decoder_deps="zlib"
673
flashsv_encoder_deps="zlib"
674
mpeg_xvmc_decoder_deps="xvmc"
675
png_decoder_deps="zlib"
676
png_encoder_deps="zlib"
677
x264_encoder_deps="x264"
678
xvid_encoder_deps="xvid"
679
zmbv_decoder_deps="zlib"
680
zmbv_encoder_deps="zlib"
681

    
682
aac_decoder_deps="libfaad"
683
mpeg4aac_decoder_deps="libfaad"
684
amr_nb_decoder_deps="amr_nb"
685
amr_nb_encoder_deps="amr_nb"
686
amr_wb_decoder_deps="amr_wb"
687
amr_wb_encoder_deps="amr_wb"
688
dts_decoder_deps="libdts"
689
faac_encoder_deps="libfaac"
690
liba52_decoder_deps="liba52"
691
libgsm_decoder_deps="libgsm"
692
libgsm_encoder_deps="libgsm"
693
libgsm_ms_decoder_deps="libgsm"
694
libgsm_ms_encoder_deps="libgsm"
695
libtheora_encoder_deps="libtheora"
696
mp3lame_encoder_deps="libmp3lame"
697
oggvorbis_decoder_deps="libvorbis"
698
oggvorbis_encoder_deps="libvorbis"
699

    
700
ac3_demuxer_deps="ac3_parser"
701
audio_demuxer_deps_any="audio_oss audio_beos"
702
audio_muxer_deps_any="audio_oss audio_beos"
703
dc1394_demuxer_deps="dc1394"
704
dv1394_demuxer_deps="dv1394"
705
gxf_muxer_deps="gpl"
706
libnut_demuxer_deps="libnut"
707
libnut_muxer_deps="libnut"
708
ogg_muxer_deps="libogg"
709
redir_demuxer_deps="network"
710
rtp_muxer_deps="network"
711
rtsp_demuxer_deps="network"
712
sdp_demuxer_deps="network"
713
v4l2_demuxer_deps="v4l2"
714
video_grab_bktr_demuxer_deps="bktr"
715
video_grab_v4l_demuxer_deps="v4l"
716
x11_grab_device_demuxer_deps="x11grab"
717

    
718
ffplay_deps="sdl"
719
ffserver_deps="network muxers"
720
network_deps="protocols"
721

    
722
# set temporary file name
723
if test ! -z "$TMPDIR" ; then
724
    TMPDIR1="${TMPDIR}"
725
elif test ! -z "$TEMPDIR" ; then
726
    TMPDIR1="${TEMPDIR}"
727
else
728
    TMPDIR1="/tmp"
729
fi
730

    
731
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
732
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
733
TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
734
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
735
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
736

    
737
# default parameters
738

    
739
logging="yes"
740
logfile="config.err"
741

    
742
# installation paths
743
PREFIX="/usr/local"
744
libdir='${PREFIX}/lib'
745
shlibdir="$libdir"
746
incdir='${PREFIX}/include/ffmpeg'
747
mandir='${PREFIX}/man'
748
bindir='${PREFIX}/bin'
749

    
750
# toolchain
751
cross_prefix=""
752
cross_compile="no"
753
cc="gcc"
754
ar="ar"
755
ranlib="ranlib"
756
make="make"
757
strip="strip"
758
asmalign_pot="unknown"
759

    
760
# machine
761
arch=`uname -m`
762
cpu="generic"
763
powerpc_perf="no"
764
mmx="default"
765
cmov="no"
766
fast_cmov="no"
767
fast_unaligned="no"
768
armv5te="default"
769
armv6="default"
770
iwmmxt="default"
771
altivec="default"
772
dcbzl="no"
773
mmi="default"
774
bigendian="no"
775

    
776
# OS
777
targetos=$(tolower $(uname -s))
778
beos_netserver="no"
779
os2="no"
780

    
781
# non-library system interfaces
782
audio_beos="default"
783
audio_oss="yes"
784
bktr="yes"
785
dv1394="yes"
786
v4l2="yes"
787
v4l="yes"
788

    
789
# libraries
790
amr_nb="no"
791
amr_wb="no"
792
avisynth="no"
793
dc1394="no"
794
dlfcn_h="no"
795
dlopen="no"
796
liba52="no"
797
liba52bin="no"
798
libdts="no"
799
libfaac="no"
800
libfaad2="no"
801
libfaad="no"
802
libfaadbin="no"
803
libgsm="no"
804
libmp3lame="no"
805
libnut="no"
806
libogg="no"
807
libtheora="no"
808
libvorbis="no"
809
mlib="no"
810
x11grab="no"
811
x264="no"
812
xvid="no"
813
zlib="yes"
814

    
815
# configurable options
816
debug="yes"
817
dostrip="yes"
818
extra_warnings="no"
819
ffmpeg="yes"
820
ffplay="yes"
821
ffserver="yes"
822
gpl="no"
823
gprof="no"
824
ipv6="yes"
825
shared="no"
826
static="yes"
827
memalign_hack="no"
828
mpegaudio_hp="yes"
829
network="yes"
830
optimize="yes"
831
pp="no"
832
protocols="yes"
833
swscaler="no"
834
vhook="default"
835

    
836
# threading
837
beosthreads="no"
838
os2threads="no"
839
pthreads="no"
840
w32threads="no"
841
thread_type="no"
842

    
843
# build settings
844
SHFLAGS='-shared -Wl,-soname,$@'
845
VHOOKSHFLAGS='$(SHFLAGS)'
846
LIBOBJFLAGS=""
847
FFLDFLAGS=-Wl,--warn-common
848
LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
849
FFSERVERLDFLAGS=-Wl,-E
850
LDCONFIG="ldconfig"
851
LIBPREF="lib"
852
LIBSUF=".a"
853
LIB='$(LIBPREF)$(NAME)$(LIBSUF)'
854
SLIBPREF="lib"
855
SLIBSUF=".so"
856
SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
857
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
858
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
859
EXESUF=""
860
BUILDSUF=""
861
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(libdir)/$(LIB)"'
862

    
863
# find source path
864
source_path="`dirname \"$0\"`"
865
source_path_used="yes"
866
if test -z "$source_path" -o "$source_path" = "." ; then
867
    source_path="`pwd`"
868
    source_path_used="no"
869
else
870
    source_path="`cd \"$source_path\"; pwd`"
871
    echo "$source_path" | grep -q '[[:blank:]]' &&
872
      die "Out of tree builds are impossible with whitespace in source path."
873
fi
874

    
875
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
876
    show_help
877
fi
878

    
879
FFMPEG_CONFIGURATION="$@"
880

    
881
ENCODER_LIST=`sed -n 's/^[^#]*ENC.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
882
DECODER_LIST=`sed -n 's/^[^#]*DEC.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
883
PARSER_LIST=`sed -n 's/^[^#]*PARSER.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
884
MUXER_LIST=`sed -n 's/^[^#]*_MUX.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
885
DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
886

    
887
enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST
888

    
889
die_unknown(){
890
    echo "Unknown option \"$1\"."
891
    echo "See $0 --help for available options."
892
    exit 1
893
}
894

    
895
for opt do
896
  optval="${opt#*=}"
897
  case "$opt" in
898
  --log)
899
  ;;
900
  --log=*) logging="$optval"
901
  ;;
902
  --prefix=*) PREFIX="$optval"
903
  ;;
904
  --libdir=*) libdir="$optval"
905
  ;;
906
  --shlibdir=*) shlibdir="$optval"
907
  ;;
908
  --incdir=*) incdir="$optval"
909
  ;;
910
  --mandir=*) mandir="$optval"
911
  ;;
912
  --source-path=*) source_path="$optval"
913
  ;;
914
  --cross-prefix=*) cross_prefix="$optval"
915
  ;;
916
  --cross-compile) cross_compile="yes"
917
  ;;
918
  --target-os=*) targetos="$optval"
919
  ;;
920
  --cc=*) cc="$optval"
921
  ;;
922
  --make=*) make="$optval"
923
  ;;
924
  --extra-cflags=*) add_cflags "$optval"
925
  ;;
926
  --extra-ldflags=*) add_ldflags "$optval"
927
  ;;
928
  --extra-libs=*) add_extralibs "$optval"
929
  ;;
930
  --build-suffix=*) BUILDSUF="$optval"
931
  ;;
932
  --arch=*) arch="$optval"
933
  ;;
934
  --cpu=*) cpu="$optval"
935
  ;;
936
  --disable-opts) optimize="no"
937
  ;;
938
  --enable-small) optimize="small"
939
  ;;
940
  --enable-sunmlib) mlib="yes"
941
  ;;
942
  --disable-strip) dostrip="no"
943
  ;;
944
  --disable-encoders) disable $ENCODER_LIST
945
  ;;
946
  --disable-decoders) disable $DECODER_LIST
947
  ;;
948
  --disable-muxers) disable $MUXER_LIST
949
  ;;
950
  --disable-demuxers) disable $DEMUXER_LIST
951
  ;;
952
  --disable-parsers) disable $PARSER_LIST
953
  ;;
954
  --enable-*=*|--disable-*=*)
955
  eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
956
  case "$thing" in
957
      encoder|decoder|muxer|demuxer|parser) $action ${optval}_${thing} ;;
958
      *) die_unknown "$opt" ;;
959
  esac
960
  ;;
961
  --enable-?*|--disable-?*)
962
  eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
963
  echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt
964
  $action $option
965
  ;;
966
  --help) show_help
967
  ;;
968
  *)
969
  die_unknown $opt
970
  ;;
971
  esac
972
done
973

    
974
case "$arch" in
975
  i386|i486|i586|i686|i86pc|BePC)
976
    arch="x86_32"
977
    enable fast_unaligned
978
  ;;
979
  x86_64|amd64)
980
    arch="x86_32"
981
    enable fast_unaligned
982
    canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
983
    if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
984
      if [ -z "`echo $CFLAGS | grep -- -m32`"  ]; then
985
        arch="x86_64"
986
        enable fast_64bit
987
      fi
988
    fi
989
  ;;
990
  # armv4l is a subset of armv[567]*l
991
  arm|armv[4567]*l)
992
    arch="armv4l"
993
  ;;
994
  alpha)
995
    arch="alpha"
996
    enable fast_64bit
997
  ;;
998
  "Power Macintosh"|ppc|powerpc)
999
    arch="powerpc"
1000
  ;;
1001
  ppc64)
1002
    arch="powerpc"
1003
    enable fast_64bit
1004
  ;;
1005
  mips|mipsel|IP*)
1006
    arch="mips"
1007
  ;;
1008
  sun4u|sparc64)
1009
    arch="sparc64"
1010
    enable fast_64bit
1011
  ;;
1012
  sparc)
1013
    arch="sparc"
1014
  ;;
1015
  sh4)
1016
    arch="sh4"
1017
  ;;
1018
  parisc)
1019
    arch="parisc"
1020
  ;;
1021
  parisc64)
1022
    arch="parisc"
1023
    enable fast_64bit
1024
  ;;
1025
  s390|s390x)
1026
    arch="s390"
1027
  ;;
1028
  m68k)
1029
    arch="m68k"
1030
  ;;
1031
  ia64)
1032
    arch="ia64"
1033
    enable fast_64bit
1034
  ;;
1035
  bfin)
1036
    arch="bfin"
1037
  ;;
1038
  *)
1039
    arch="unknown"
1040
  ;;
1041
esac
1042

    
1043
# OS specific
1044
osextralibs="-lm"
1045
case $targetos in
1046
  beos|haiku|zeta)
1047
    PREFIX="$HOME/config"
1048
    # helps building libavcodec
1049
    add_cflags "-DPIC -fomit-frame-pointer"
1050
    # 3 gcc releases known for BeOS, each with ugly bugs
1051
    gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1052
    case "$gcc_version" in
1053
      2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1054
        mmx="no"
1055
        ;;
1056
      *20010315*) echo "BeBits gcc"
1057
        add_cflags "-fno-expensive-optimizations"
1058
        ;;
1059
    esac
1060
    LDCONFIG="echo ignoring ldconfig"
1061
    SHFLAGS=-nostart
1062
    # disable Linux things
1063
    dv1394="no"
1064
    # enable BeOS things
1065
    disabled audio_beos || enable_audio_beos
1066
    # no need for libm, but the inet stuff
1067
    # Check for BONE
1068
    # XXX: actually should check for NOT net_server
1069
    if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
1070
        osextralibs="-lbind -lsocket"
1071
    else
1072
        beos_netserver="yes"
1073
        osextralibs="-lnet"
1074
    fi ;;
1075
  sunos)
1076
    dv1394="no"
1077
    FFLDFLAGS=""
1078
    FFSERVERLDFLAGS=""
1079
    SHFLAGS="-shared -Wl,-h,\$@"
1080
    add_extralibs "-lsocket -lnsl"
1081
    ;;
1082
  netbsd)
1083
    dv1394="no"
1084
    add_extralibs "-lossaudio"
1085
    ;;
1086
  openbsd)
1087
    dv1394="no"
1088
    need_memalign="no"
1089
    LIBOBJFLAGS="\$(PIC)"
1090
    LDCONFIG="ldconfig -m \$(shlibdir)"
1091
    SHFLAGS='-shared'
1092
    SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF).$(LIBVERSION)'
1093
    SLIBNAME_WITH_VERSION='$(SLIBNAME)'
1094
    SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
1095
    add_extralibs "-lossaudio"
1096
    ;;
1097
  freebsd)
1098
    dv1394="no"
1099
    need_memalign="no"
1100
    add_cflags "-pthread"
1101
    ;;
1102
  gnu/kfreebsd)
1103
    dv1394="no"
1104
    add_cflags "-pthread"
1105
    ;;
1106
  bsd/os)
1107
    dv1394="no"
1108
    osextralibs="-lpoll -lgnugetopt -lm"
1109
    strip="strip -d"
1110
    ;;
1111
  darwin)
1112
    dv1394="no"
1113
    need_memalign="no"
1114
    SHFLAGS="-dynamiclib -Wl,-single_module -Wl,-install_name,\$(shlibdir)/\$(SLIBNAME),-current_version,\$(SPPVERSION),-compatibility_version,\$(SPPVERSION) -Wl,-read_only_relocs,suppress"
1115
    VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(shlibdir)/vhook/$@'
1116
    osextralibs=""
1117
    strip="strip -x"
1118
    FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1119
    SLIBSUF=".dylib"
1120
    SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
1121
    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
1122
    FFSERVERLDFLAGS=-Wl,-bind_at_load
1123
    ;;
1124
  mingw32*)
1125
    targetos=mingw32
1126
    if enabled_all shared static; then
1127
        cat <<EOF
1128
You can only build one library type at once on MinGW.
1129
Specify --disable-static --enable-shared to only build
1130
the shared libraries. To build only the static libraries
1131
you do not need to pass additional options.
1132
EOF
1133
        exit 1
1134
    fi
1135
    dv1394="no"
1136
    ffserver="no"
1137
    network="no"
1138
    SLIBPREF=""
1139
    SLIBSUF=".dll"
1140
    EXESUF=".exe"
1141
    SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1142
    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
1143
    SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
1144
    SLIB_INSTALL_EXTRA_CMD="-install -m 644 \$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib) \"\$(shlibdir)/\$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib)\""
1145
    SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc"
1146
    add_extralibs -lws2_32
1147
    ;;
1148
  cygwin*)
1149
    targetos=cygwin
1150
    shlibdir="$bindir"
1151
    dv1394="no"
1152
    VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libswscale -L$(BUILD_ROOT)/libavutil'
1153
    VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lswscale$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1154
    osextralibs=""
1155
    EXESUF=".exe"
1156
    SLIBPREF="cyg"
1157
    SLIBSUF=".dll"
1158
    SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1159
    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
1160
    SHFLAGS='-shared -Wl,--out-implib=lib$(NAME).dll.a'
1161
    ;;
1162
  linux)
1163
    LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
1164
    ;;
1165
  irix*)
1166
    targetos=irix
1167
    ranlib="echo ignoring ranlib"
1168
    ;;
1169
  os/2)
1170
    TMPE=$TMPE".exe"
1171
    ar="emxomfar -p128"
1172
    ranlib="echo ignoring ranlib"
1173
    strip="echo ignoring strip"
1174
    add_cflags "-Zomf"
1175
    FFLDFLAGS="-Zomf -Zstack 16384 -s"
1176
    SHFLAGS="-Zdll -Zomf"
1177
    FFSERVERLDFLAGS=""
1178
    LIBPREF=""
1179
    LIBSUF=".lib"
1180
    SLIBPREF=""
1181
    SLIBSUF=".dll"
1182
    EXESUF=".exe"
1183
    osextralibs=""
1184
    pkg_requires=""
1185
    dv1394="no"
1186
    ffserver="no"
1187
    vhook="no"
1188
    os2="yes"
1189
    ;;
1190
  *)
1191
    targetos="${targetos}-UNKNOWN"
1192
    ;;
1193
esac
1194

    
1195
add_extralibs $osextralibs
1196

    
1197
if ! disabled logging ; then
1198
    enabled logging || logfile="$logging"
1199
    echo "# $0 $@" >$logfile
1200
    set >>$logfile
1201
else
1202
    logfile=/dev/null
1203
fi
1204

    
1205
# Combine FFLDFLAGS and the LDFLAGS environment variable.
1206
LDFLAGS="$FFLDFLAGS $LDFLAGS"
1207

    
1208
test -n "$cross_prefix" && cross_compile=yes
1209
cc="${cross_prefix}${cc}"
1210
ar="${cross_prefix}${ar}"
1211
ranlib="${cross_prefix}${ranlib}"
1212
strip="${cross_prefix}${strip}"
1213

    
1214
# we need to build at least one lib type
1215
if disabled_all static shared; then
1216
    cat <<EOF
1217
At least one library type must be built.
1218
Specify --enable-static to build the static libraries or --enable-shared to
1219
build the shared libraries as well. To only build the shared libraries specify
1220
--disable-static in addition to --enable-shared.
1221
EOF
1222
    exit 1;
1223
fi
1224

    
1225
if disabled libogg; then
1226
    enabled libtheora && die "libogg must be enabled to enable libtheora."
1227
    enabled libvorbis && die "libogg must be enabled to enable libvorbis."
1228
fi
1229

    
1230
if enabled_any libfaad libfaadbin ; then
1231
    if check_header faad.h; then
1232
        check_cc << EOF
1233
#include <faad.h>
1234
#ifndef FAAD2_VERSION
1235
ok faad1
1236
#endif
1237
int main( void ) { return 0; }
1238
EOF
1239
        test $? = 0 && enable libfaad2
1240
    else
1241
        die "FAAD test failed."
1242
    fi
1243
fi
1244

    
1245

    
1246
if disabled gpl ; then
1247
    die_gpl_disabled(){
1248
        name=$1
1249
        shift
1250
        enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
1251
    }
1252
    die_gpl_disabled "The Postprocessing code" pp
1253
    die_gpl_disabled "liba52"                  liba52
1254
    die_gpl_disabled "libxvidcore"             xvid
1255
    die_gpl_disabled "x264"                    x264
1256
    die_gpl_disabled "libdts"                  libdts
1257
    die_gpl_disabled "FAAD2"                   libfaad2
1258
    die_gpl_disabled "The X11 grabber"         x11grab
1259
    die_gpl_disabled "The software scaler"     swscaler
1260
fi
1261

    
1262
# compute MMX state
1263
if test $mmx = "default"; then
1264
    if test $arch = "x86_32" -o $arch = "x86_64"; then
1265
        mmx="yes"
1266
    else
1267
        mmx="no"
1268
    fi
1269
fi
1270

    
1271
test -z "$need_memalign" && need_memalign="$mmx"
1272

    
1273
#Darwin CC versions
1274
needmdynamicnopic="no"
1275
if test $targetos = darwin; then
1276
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1277
        add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
1278
    else
1279
        add_cflags "-no-cpp-precomp -pipe"
1280
        check_cflags "-force_cpusubtype_ALL"
1281
        check_cflags "-Wno-sign-compare"
1282
        disabled shared && needmdynamicnopic="yes"
1283
    fi
1284
fi
1285

    
1286
disabled optimize || add_cflags -fomit-frame-pointer
1287

    
1288
# Can only do AltiVec on PowerPC
1289
if test $altivec = "default"; then
1290
    if test $arch = "powerpc"; then
1291
        altivec="yes"
1292
    else
1293
        altivec="no"
1294
    fi
1295
fi
1296

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

    
1363
gnu_make(){
1364
    $1 --version 2>&1 | grep -q GNU
1365
}
1366

    
1367
if ! gnu_make $make; then
1368
    gnu_make gmake && make=gmake || die "GNU make not found."
1369
fi
1370

    
1371
# make sure we can execute files in $TMPDIR
1372
cat >$TMPE 2>>$logfile <<EOF
1373
#! /bin/sh
1374
EOF
1375
chmod +x $TMPE >>$logfile 2>&1
1376
if ! $TMPE >>$logfile 2>&1; then
1377
    cat <<EOF
1378
Unable to create and execute files in $TMPDIR1.  Set the TMPDIR environment
1379
variable to another directory and make sure that $TMPDIR1 is not mounted
1380
noexec.
1381
EOF
1382
    die "Sanity test failed."
1383
fi
1384
rm $TMPE
1385

    
1386
# compiler sanity check
1387
check_exec <<EOF
1388
int main(){
1389
    return 0;
1390
}
1391
EOF
1392
if test "$?" != 0; then
1393
    echo "$cc is unable to create an executable file."
1394
    if test -z "$cross_prefix" && disabled cross_compile ; then
1395
        echo "If $cc is a cross-compiler, use the --cross-compile option."
1396
        echo "Only do this if you know what cross compiling means."
1397
    fi
1398
    die "C compiler test failed."
1399
fi
1400

    
1401
if test $arch = "x86_32" -o $arch = "x86_64"; then
1402
    # check whether EBP is available on x86
1403
    # As 'i' is stored on the stack, this program will crash
1404
    # if the base pointer is used to access it because the
1405
    # base pointer is cleared in the inline assembly code.
1406
    check_exec_crash <<EOF && enable ebp_available
1407
    volatile int i=0;
1408
    asm volatile (
1409
        "xorl %%ebp, %%ebp"
1410
    ::: "%ebp");
1411
    return i;
1412
EOF
1413

    
1414
    # check wether EBX is available on x86
1415
    check_cc <<EOF && enable ebx_available
1416
int main(){
1417
    asm volatile ("":::"%ebx");
1418
}
1419
EOF
1420
fi
1421

    
1422
# check for assembler specific support
1423

    
1424
if test $arch = "powerpc"; then
1425
check_cc <<EOF && dcbzl=yes
1426
int main(void) {
1427
    register long zero = 0;
1428
    char data[1024];
1429
    asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
1430
return 0;
1431
}
1432
EOF
1433
fi
1434

    
1435
# check for SIMD availability
1436

    
1437
# AltiVec flags: The FSF version of GCC differs from the Apple version
1438
if test $arch = "powerpc"; then
1439
    if enabled altivec; then
1440
        if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
1441
            add_cflags "-faltivec"
1442
        else
1443
            add_cflags "-maltivec -mabi=altivec"
1444
        fi
1445
    fi
1446
fi
1447

    
1448
check_header altivec.h
1449

    
1450
# check if our compiler supports Motorola AltiVec C API
1451
if enabled altivec; then
1452
    if enabled altivec_h; then
1453
        inc_altivec_h="#include <altivec.h>"
1454
    else
1455
        inc_altivec_h=
1456
    fi
1457
    check_cc <<EOF || altivec=no
1458
$inc_altivec_h
1459
int main(void) {
1460
    vector signed int v1, v2, v3;
1461
    v1 = vec_add(v2,v3);
1462
    return 0;
1463
}
1464
EOF
1465
fi
1466

    
1467
# check armv5te instructions support
1468
if test $armv5te = "default" -a $arch = "armv4l"; then
1469
    armv5te=no
1470
    check_cc <<EOF && armv5te=yes
1471
        int main(void) {
1472
        __asm__ __volatile__ ("qadd r0, r0, r0");
1473
        }
1474
EOF
1475
fi
1476

    
1477
if test $armv6 = "default" -a $arch = "armv4l"; then
1478
    check_cc <<EOF && armv6=yes || armv6=no
1479
int main(void) {
1480
    __asm__ __volatile__ ("sadd16 r0, r0, r0");
1481
}
1482
EOF
1483
fi
1484

    
1485
# check iwmmxt support
1486
if test $iwmmxt = "default" -a $arch = "armv4l"; then
1487
    iwmmxt=no
1488
    check_cc <<EOF && iwmmxt=yes
1489
        int main(void) {
1490
        __asm__ __volatile__ ("wunpckelub wr6, wr4");
1491
        }
1492
EOF
1493
fi
1494

    
1495
# mmi only available on mips
1496
if test $mmi = "default"; then
1497
    if test $arch = "mips"; then
1498
        mmi="yes"
1499
    else
1500
        mmi="no"
1501
    fi
1502
fi
1503

    
1504
# check if our compiler supports mmi
1505
enabled mmi && check_cc <<EOF || mmi="no"
1506
int main(void) {
1507
    __asm__ ("lq \$2, 0(\$2)");
1508
    return 0;
1509
}
1510
EOF
1511

    
1512
# ---
1513
# big/little-endian test
1514
if disabled cross_compile; then
1515
    check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
1516
#include <inttypes.h>
1517
int main(int argc, char ** argv){
1518
        volatile uint32_t i=0x01234567;
1519
        return (*((uint8_t*)(&i))) == 0x67;
1520
}
1521
EOF
1522
else
1523
    # programs cannot be launched if cross compiling, so make a static guess
1524
    if test "$arch" = "powerpc" -o "$arch" = "mips" ; then
1525
        bigendian="yes"
1526
    fi
1527
fi
1528

    
1529
# ---
1530
# check availability of some header files
1531

    
1532
check_header malloc.h
1533
check_func memalign
1534

    
1535
if disabled_all memalign memalign_hack && enabled need_memalign ; then
1536
    die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
1537
fi
1538

    
1539
check_header byteswap.h
1540

    
1541
check_header arpa/inet.h
1542

    
1543
check_func inet_aton
1544
check_func localtime_r
1545
enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
1546

    
1547
# ffserver uses poll(),
1548
# if it's not found we can emulate it using select().
1549
if enabled ffserver; then
1550
    check_header sys/poll.h
1551
fi
1552

    
1553
# check for some common methods of building with pthread support
1554
# do this before the optional library checks as some of them require pthreads
1555
if enabled pthreads; then
1556
    if check_func pthread_create; then
1557
        :
1558
    elif check_func pthread_create -pthread; then
1559
        add_cflags -pthread
1560
        add_ldflags -pthread
1561
    elif check_func pthread_create -pthreads; then
1562
        add_cflags -pthreads
1563
        add_ldflags -pthreads
1564
    elif ! check_lib pthread.h pthread_create -lpthread; then
1565
        die "ERROR: can't find pthreads library"
1566
    fi
1567
fi
1568

    
1569
for thread in $THREADS_LIST; do
1570
    if enabled $thread; then
1571
        if ! disabled thread_type ; then
1572
            die "ERROR: Only one thread type must be selected."
1573
        else
1574
            thread_type="$thread"
1575
        fi
1576
    fi
1577
done
1578

    
1579
enabled_any amr_nb amr_wb && enable amr
1580

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

    
1600
# test for lrintf in math.h
1601
check_exec <<EOF && lrintf=yes || lrintf=no
1602
#define _ISOC9X_SOURCE  1
1603
#include <math.h>
1604
int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
1605
EOF
1606

    
1607
_restrict=
1608
for restrict_keyword in restrict __restrict__ __restrict; do
1609
    check_cc <<EOF && _restrict=$restrict_keyword && break
1610
void foo(char * $restrict_keyword p);
1611
EOF
1612
done
1613

    
1614
# dlopen/dlfcn.h probing
1615

    
1616
check_header dlfcn.h
1617

    
1618
if check_func dlopen; then
1619
    ldl=
1620
elif check_func dlopen -ldl; then
1621
    ldl=-ldl
1622
fi
1623

    
1624
test "$vhook" = "default" && vhook="$dlopen"
1625

    
1626
enabled_any vhook liba52bin libfaadbin ffserver && add_extralibs $ldl
1627

    
1628
if test "$targetos" = cygwin && enabled static ; then
1629
    vhook="no"
1630
    echo
1631
    echo "At the moment vhooks don't work on Cygwin static builds."
1632
    echo "Patches welcome."
1633
    echo
1634
fi
1635

    
1636
if enabled vhook; then
1637
    check_ldflags -rdynamic
1638
    check_ldflags -export-dynamic
1639
fi
1640

    
1641
enabled audio_beos && add_extralibs "-lmedia -lbe"
1642

    
1643
check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
1644
check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
1645

    
1646
##########################################
1647
# SDL check
1648

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

    
1675
texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
1676

    
1677
##########################################
1678
# IPv6 check
1679

    
1680
enabled network && enabled ipv6 && check_ld <<EOF && ipv6=yes || ipv6=no
1681
#include <sys/types.h>
1682
#include <sys/socket.h>
1683
#include <netinet/in.h>
1684
#include <netdb.h>
1685
int main( void ) {
1686
  struct sockaddr_storage saddr;
1687
  struct ipv6_mreq mreq6;
1688
  getaddrinfo(0,0,0,0);
1689
  getnameinfo(0,0,0,0,0,0,0);
1690
  IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
1691
}
1692
EOF
1693

    
1694
enabled v4l  && check_header linux/videodev.h  || disable v4l
1695
enabled v4l2 && check_header linux/videodev2.h || disable v4l2
1696

    
1697
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1698
if enabled bktr; then
1699
    { check_header dev/bktr/ioctl_meteor.h &&
1700
      check_header dev/bktr/ioctl_bt848.h; } ||
1701
    { check_header machine/ioctl_meteor.h &&
1702
      check_header machine/ioctl_bt848.h; } ||
1703
    { check_header dev/video/meteor/ioctl_meteor.h &&
1704
      check_header dev/video/bktr/ioctl_bt848.h; } ||
1705
    check_header dev/ic/bt8xx.h ||
1706
    disable bktr
1707
fi
1708

    
1709
enabled audio_oss &&
1710
    check_header sys/soundcard.h ||
1711
    check_header soundcard.h ||
1712
    disable audio_oss
1713

    
1714
# Deal with the x11 frame grabber
1715
enabled x11grab                         &&
1716
enabled gpl                             &&
1717
enabled x11_grab_device_demuxer         &&
1718
check_header X11/Xlib.h                 &&
1719
check_header X11/extensions/XShm.h      &&
1720
check_func XOpenDisplay -lX11           &&
1721
check_func XShmCreateImage -lX11 -lXext &&
1722
add_extralibs -lX11 -lXext              ||
1723
disable x11_grab_device_demuxer
1724

    
1725
enabled debug && add_cflags -g
1726

    
1727
# add some useful compiler flags if supported
1728
check_cflags -Wdeclaration-after-statement
1729
check_cflags -Wall
1730
check_cflags -Wno-switch
1731
check_cflags -Wdisabled-optimization
1732
check_cflags -Wpointer-arith
1733
check_cflags -Wredundant-decls
1734
check_cflags -Wno-pointer-sign
1735
enabled extra_warnings && check_cflags -Winline
1736

    
1737
# add some linker flags
1738
check_ldflags $LDLATEFLAGS
1739

    
1740
# not all compilers support -Os
1741
test "$optimize" = "small" && check_cflags -Os
1742

    
1743
if enabled optimize; then
1744
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1745
        add_cflags  "-O5"
1746
        add_ldflags "-O5"
1747
    else
1748
        add_cflags "-O3"
1749
    fi
1750
fi
1751

    
1752
# PIC flags for shared library objects where they are needed
1753
if enabled shared; then
1754
    # LIBOBJFLAGS may have already been set in the OS configuration
1755
    if test -z "$LIBOBJFLAGS" ; then
1756
        case "$arch" in
1757
            x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS="\$(PIC)" ;;
1758
        esac
1759
    fi
1760
fi
1761

    
1762
if enabled gprof; then
1763
    add_cflags  "-p"
1764
    add_ldflags "-p"
1765
fi
1766

    
1767
VHOOKCFLAGS="-fPIC $CFLAGS"
1768
enabled needmdynamicnopic && add_cflags -mdynamic-no-pic
1769

    
1770
# find if .align arg is power-of-two or not
1771
if test $asmalign_pot = "unknown"; then
1772
    asmalign_pot="no"
1773
    echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
1774
fi
1775

    
1776
enabled_any $ENCODER_LIST && enable encoders
1777
enabled_any $DECODER_LIST && enable decoders
1778
enabled_any $MUXER_LIST   && enable muxers
1779
enabled_any $DEMUXER_LIST && enable demuxers
1780

    
1781
enabled_any $THREADS_LIST && enable threads
1782

    
1783
check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
1784
    $DEMUXER_LIST $MUXER_LIST
1785

    
1786
enabled libogg    && append pkg_requires "ogg >= 1.1"
1787
enabled libtheora && append pkg_requires "theora"
1788
enabled libvorbis && append pkg_requires "vorbis vorbisenc"
1789
enabled dc1394    && append pkg_requires "libraw1394"
1790

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

    
1865
echo "Creating config.mak and config.h..."
1866

    
1867
echo "# Automatically generated by configure - do not modify!" > config.mak
1868
echo "/* Automatically generated by configure - do not modify! */" > $TMPH
1869
echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
1870

    
1871
echo "PREFIX=$PREFIX" >> config.mak
1872
echo "prefix=\$(DESTDIR)\${PREFIX}" >> config.mak
1873
echo "libdir=\$(DESTDIR)$libdir" >> config.mak
1874
echo "shlibdir=\$(DESTDIR)$shlibdir" >> config.mak
1875
echo "incdir=\$(DESTDIR)$incdir" >> config.mak
1876
echo "bindir=\$(DESTDIR)$bindir" >> config.mak
1877
echo "mandir=\$(DESTDIR)$mandir" >> config.mak
1878
echo "MAKE=$make" >> config.mak
1879
echo "CC=$cc" >> config.mak
1880
echo "AR=$ar" >> config.mak
1881
echo "RANLIB=$ranlib" >> config.mak
1882
if enabled dostrip; then
1883
    echo "STRIP=$strip" >> config.mak
1884
else
1885
    echo "STRIP=echo ignoring strip" >> config.mak
1886
fi
1887

    
1888
echo "OPTFLAGS=$CFLAGS" >> config.mak
1889
echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
1890
echo "LDFLAGS=$LDFLAGS" >> config.mak
1891
echo "LDCONFIG=$LDCONFIG" >> config.mak
1892
echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
1893
echo "SHFLAGS=$SHFLAGS" >> config.mak
1894
echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
1895
echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
1896
echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
1897
echo "BUILD_STATIC=$static" >> config.mak
1898
echo "BUILDSUF=$BUILDSUF" >> config.mak
1899
echo "LIBPREF=$LIBPREF" >> config.mak
1900
echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
1901
if enabled static; then
1902
  echo "LIB=$LIB" >> config.mak
1903
else # Some Make complain if this variable does not exist.
1904
  echo "LIB=" >> config.mak
1905
fi
1906
echo "SLIBPREF=$SLIBPREF" >> config.mak
1907
echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
1908
echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
1909

    
1910
ucarch=`toupper $arch`
1911
echo "TARGET_ARCH_${ucarch}=yes" >> config.mak
1912
echo "#define ARCH_${ucarch} 1" >> $TMPH
1913

    
1914
# special cases
1915
case "$arch" in
1916
    x86_32|x86_64)
1917
        echo "TARGET_ARCH_X86=yes" >> config.mak
1918
        echo "#define ARCH_X86 1" >> $TMPH
1919
        ;;
1920
    powerpc)
1921
        if test "$POWERPCMODE" = "64bits"; then
1922
            echo "#define POWERPC_MODE_64BITS 1" >> $TMPH
1923
        fi
1924
        ;;
1925
    sparc64)
1926
        echo "TARGET_ARCH_SPARC=yes" >> config.mak
1927
        echo "#define ARCH_SPARC 1" >> $TMPH
1928
        ;;
1929
esac
1930

    
1931
if enabled bigendian; then
1932
  echo "WORDS_BIGENDIAN=yes" >> config.mak
1933
  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
1934
fi
1935
if enabled mmx; then
1936
  echo "#define __CPU__ 586" >> $TMPH
1937
fi
1938

    
1939
if enabled sdl; then
1940
  echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1941
  echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
1942
fi
1943
if enabled texi2html; then
1944
  echo "BUILD_DOC=yes" >> config.mak
1945
fi
1946

    
1947
sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
1948
pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
1949
lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
1950
lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
1951
lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
1952

    
1953

    
1954

    
1955
if enabled shared; then
1956
  echo "BUILD_SHARED=yes" >> config.mak
1957
  echo "PIC=-fPIC -DPIC" >> config.mak
1958
  echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
1959
  echo "SPPVERSION=$pp_version" >> config.mak
1960
  echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
1961
  echo "LAVCVERSION=$lavc_version" >> config.mak
1962
  echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
1963
  echo "LAVFVERSION=$lavf_version" >> config.mak
1964
  echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
1965
  echo "LAVUVERSION=$lavu_version" >> config.mak
1966
  echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
1967
  echo "SWSVERSION=$sws_version" >> config.mak
1968
  echo "SLIBNAME=${SLIBNAME}" >> config.mak
1969
  echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
1970
  echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
1971
  echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
1972
  echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
1973
fi
1974
echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
1975
echo "EXTRALIBS=$extralibs" >> config.mak
1976

    
1977
print_config HAVE_   $TMPH config.mak $HAVE_LIST
1978
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST
1979
print_config TARGET_ $TMPH config.mak $TARGET_LIST
1980

    
1981
if test "$targetos" = darwin; then
1982
  echo "#define CONFIG_DARWIN 1"  >> $TMPH
1983
fi
1984

    
1985
echo "#define restrict $_restrict" >> $TMPH
1986

    
1987
if test "$optimize" = "small"; then
1988
  echo "#define always_inline"  >> $TMPH
1989
  echo "#define CONFIG_SMALL 1" >> $TMPH
1990
fi
1991

    
1992
echo "SRC_PATH=\"$source_path\"" >> config.mak
1993
echo "SRC_PATH_BARE=$source_path" >> config.mak
1994
echo "BUILD_ROOT=\"$PWD\"" >> config.mak
1995

    
1996
# Apparently it's not possible to portably echo a backslash.
1997
if enabled asmalign_pot; then
1998
  printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
1999
else
2000
  printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
2001
fi
2002

    
2003

    
2004
for part in $DECODER_LIST $ENCODER_LIST $PARSER_LIST $DEMUXER_LIST $MUXER_LIST; do
2005
    ucname="`toupper $part`"
2006
    config_name="CONFIG_$ucname"
2007
    enabled_name="ENABLE_$ucname"
2008
    if enabled $part; then
2009
        echo "#define $config_name 1" >> $TMPH
2010
        echo "#define $enabled_name 1" >> $TMPH
2011
        echo "$config_name=yes" >> config.mak
2012
    else
2013
        echo "#define $enabled_name 0" >> $TMPH
2014
    fi
2015
done
2016

    
2017
# Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
2018
if ! cmp -s $TMPH config.h; then
2019
        mv -f $TMPH config.h
2020
else
2021
        echo "config.h is unchanged"
2022
fi
2023

    
2024
rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
2025

    
2026
# build tree in object directory if source path is different from current one
2027
if enabled source_path_used; then
2028
    DIRS="\
2029
         doc \
2030
         libavformat \
2031
         libavcodec \
2032
         libavcodec/alpha \
2033
         libavcodec/armv4l \
2034
         libavcodec/bfin \
2035
         libavcodec/i386 \
2036
         libavcodec/sparc \
2037
         libavcodec/mlib \
2038
         libavcodec/ppc \
2039
         libpostproc \
2040
         libavutil \
2041
         libswscale \
2042
         tests \
2043
         vhook \
2044
         "
2045
    FILES="\
2046
          Makefile \
2047
          common.mak \
2048
          libavformat/Makefile \
2049
          libavcodec/Makefile \
2050
          libpostproc/Makefile \
2051
          libavutil/Makefile \
2052
          libswscale/Makefile \
2053
          tests/Makefile \
2054
          vhook/Makefile \
2055
          doc/Makefile \
2056
          doc/texi2pod.pl \
2057
          "
2058
    for dir in $DIRS ; do
2059
            mkdir -p $dir
2060
    done
2061
    for f in $FILES ; do
2062
        ln -sf "$source_path/$f" $f
2063
    done
2064
fi
2065

    
2066

    
2067
# build pkg-config files
2068
# FIXME: libdir and includedir are hardcoded and may differ from the real path.
2069

    
2070
pkgconfig_generate(){
2071
name=$1
2072
comment=$2
2073
version=$3
2074
libs=$4
2075
requires=$5
2076
include=$6
2077
cat <<EOF >$name.pc
2078
prefix=$PREFIX
2079
exec_prefix=\${prefix}
2080
libdir=\${exec_prefix}/lib
2081
includedir=\${prefix}/include
2082

    
2083
Name: $name
2084
Description: $comment
2085
Version: $version
2086
Requires: $requires
2087
Conflicts:
2088
Libs: -L\${libdir} $libs
2089
Cflags: -I\${includedir} -I\${includedir}/$include
2090
EOF
2091
}
2092

    
2093
pkgconfig_generate_uninstalled(){
2094
name=$1
2095
shortname=${name#lib}
2096
comment=$2
2097
version=$3
2098
libs=$4
2099
requires=$5
2100
cat <<EOF >$name-uninstalled.pc
2101
prefix=
2102
exec_prefix=
2103
libdir=\${pcfiledir}/$name
2104
includedir=\${pcfiledir}/$name
2105

    
2106
Name: $name
2107
Description: $comment
2108
Version: $version
2109
Requires: $requires
2110
Conflicts:
2111
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
2112
Cflags: -I\${includedir}
2113
EOF
2114
}
2115

    
2116
pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
2117
pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
2118

    
2119
pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
2120
pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
2121

    
2122
pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2123
pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
2124

    
2125
if enabled pp; then
2126
  pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
2127
  pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
2128
fi
2129

    
2130
if enabled swscaler; then
2131
  pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" -lswscale "libavutil = $lavu_version" ffmpeg
2132
  pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
2133
else
2134
  pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2135
  pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
2136
  apply libswscale.pc sed s/^Libs:.*$/Libs:/
2137
  apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
2138
fi