Statistics
| Branch: | Revision:

ffmpeg / configure @ 3a74415d

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

    
172
log(){
173
    echo "$@" >>$logfile
174
}
175

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

    
182
echolog(){
183
    log "$@"
184
    echo "$@"
185
}
186

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

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

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

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

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

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

    
245
enable(){
246
    set_all yes $*
247
}
248

    
249
disable(){
250
    set_all no $*
251
}
252

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

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

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

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

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

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

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

    
291
        eval dep_all="\$${cfg}_deps"
292
        eval dep_any="\$${cfg}_deps_any"
293

    
294
        pushvar cfg dep_all dep_any
295
        check_deps $dep_all $dep_any
296
        popvar cfg dep_all dep_any
297

    
298
        enabled_all $dep_all || disable $cfg
299
        enabled_any $dep_any || disable $cfg
300

    
301
        disable ${cfg}_checking
302
    done
303
}
304

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

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

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

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

    
340
temp_cflags(){
341
    save_flags
342
    CFLAGS="$CFLAGS $*"
343
}
344

    
345
temp_ldflags(){
346
    save_flags
347
    LDFLAGS="$LDFLAGS $*"
348
}
349

    
350
temp_extralibs(){
351
    save_flags
352
    extralibs="$extralibs $*"
353
}
354

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

    
362
add_cflags(){
363
    append CFLAGS "$@"
364
}
365

    
366
add_ldflags(){
367
    append LDFLAGS "$@"
368
}
369

    
370
add_extralibs(){
371
    append extralibs "$@"
372
}
373

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

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

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

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

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

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

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

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

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

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

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

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

    
488
require(){
489
    name="$1"
490
    header="$2"
491
    func="$3"
492
    shift 3
493
    check_lib $header $func "$@" || die "ERROR: $name not found"
494
}
495

    
496
require2(){
497
    name="$1"
498
    headers="$2"
499
    func="$3"
500
    shift 3
501
    check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
502
}
503

    
504
check_foo_config(){
505
    cfg=$1
506
    pkg=$2
507
    header=$3
508
    func=$4
509
    shift 4
510
    disable $cfg
511
    check_cmd ${pkg}-config --version
512
    err=$?
513
    if test "$err" = 0; then
514
        temp_cflags `${pkg}-config --cflags`
515
        temp_extralibs `${pkg}-config --libs`
516
        check_lib "$@" $header $func && enable $cfg
517
    fi
518
    return $err
519
}
520

    
521
apply(){
522
    file=$1
523
    shift
524
    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
525
}
526

    
527
CONFIG_LIST='
528
    encoders
529
    decoders
530
    parsers
531
    muxers
532
    demuxers
533
    amr
534
    amr_nb
535
    amr_nb_fixed
536
    amr_wb
537
    audio_beos
538
    audio_oss
539
    avisynth
540
    beos_netserver
541
    bktr
542
    dc1394
543
    dv1394
544
    ebp_available
545
    ebx_available
546
    ffmpeg
547
    ffplay
548
    ffserver
549
    gpl
550
    gprof
551
    ipv6
552
    liba52
553
    liba52bin
554
    libdts
555
    libfaac
556
    libfaad
557
    libfaadbin
558
    libgsm
559
    libmp3lame
560
    libnut
561
    libogg
562
    libtheora
563
    libvorbis
564
    memalign_hack
565
    mpegaudio_hp
566
    network
567
    powerpc_perf
568
    pp
569
    protocols
570
    swscaler
571
    vhook
572
    v4l
573
    v4l2
574
    wince
575
    x11grab
576
    x264
577
    xvid
578
    zlib
579
'
580

    
581
THREADS_LIST='
582
    beosthreads
583
    os2threads
584
    pthreads
585
    w32threads
586
'
587

    
588
HAVE_LIST="
589
    $THREADS_LIST
590
    altivec
591
    altivec_h
592
    armv5te
593
    armv6
594
    arpa_inet_h
595
    byteswap_h
596
    cmov
597
    dcbzl
598
    dev_bktr_ioctl_bt848_h
599
    dev_bktr_ioctl_meteor_h
600
    dev_ic_bt8xx_h
601
    dev_video_meteor_ioctl_meteor_h
602
    dev_video_bktr_ioctl_bt848_h
603
    dlfcn_h
604
    dlopen
605
    fast_64bit
606
    fast_cmov
607
    freetype2
608
    imlib2
609
    inet_aton
610
    iwmmxt
611
    localtime_r
612
    lrintf
613
    machine_ioctl_bt848_h
614
    machine_ioctl_meteor_h
615
    malloc_h
616
    memalign
617
    mlib
618
    mmi
619
    mmx
620
    os2
621
    sdl
622
    sdl_video_size
623
    soundcard_h
624
    sys_poll_h
625
    sys_soundcard_h
626
    threads
627
"
628

    
629
TARGET_LIST='
630
    altivec
631
    armv5te
632
    armv6
633
    iwmmxt
634
    mmi
635
    mmx
636
'
637

    
638
CMDLINE_SELECT="
639
    $CONFIG_LIST
640
    $TARGET_LIST
641
    $THREADS_LIST
642
    debug
643
    extra_warnings
644
    shared
645
    static
646
"
647

    
648
dxa_decoder_deps="zlib"
649
flashsv_decoder_deps="zlib"
650
flashsv_encoder_deps="zlib"
651
mpeg_xvmc_decoder_deps="xvmc"
652
png_decoder_deps="zlib"
653
png_encoder_deps="zlib"
654
x264_encoder_deps="x264"
655
xvid_encoder_deps="xvid"
656
zmbv_decoder_deps="zlib"
657
zmbv_encoder_deps="zlib"
658

    
659
aac_decoder_deps="libfaad"
660
mpeg4aac_decoder_deps="libfaad"
661
amr_nb_decoder_deps_any="amr_nb amr_nb_fixed"
662
amr_nb_encoder_deps_any="amr_nb amr_nb_fixed"
663
amr_wb_decoder_deps="amr_wb"
664
amr_wb_encoder_deps="amr_wb"
665
dts_decoder_deps="libdts"
666
faac_encoder_deps="libfaac"
667
liba52_decoder_deps="liba52"
668
libgsm_decoder_deps="libgsm"
669
libgsm_encoder_deps="libgsm"
670
libgsm_ms_decoder_deps="libgsm"
671
libgsm_ms_encoder_deps="libgsm"
672
libtheora_encoder_deps="libtheora"
673
mp3lame_encoder_deps="libmp3lame"
674
oggvorbis_decoder_deps="libvorbis"
675
oggvorbis_encoder_deps="libvorbis"
676

    
677
audio_demuxer_deps_any="audio_oss audio_beos"
678
audio_muxer_deps_any="audio_oss audio_beos"
679
dc1394_demuxer_deps="dc1394"
680
dv1394_demuxer_deps="dv1394"
681
gxf_muxer_deps="gpl"
682
libnut_demuxer_deps="libnut"
683
libnut_muxer_deps="libnut"
684
ogg_muxer_deps="libogg"
685
redir_demuxer_deps="network"
686
rtp_muxer_deps="network"
687
rtsp_demuxer_deps="network"
688
sdp_demuxer_deps="network"
689
v4l2_demuxer_deps="v4l2"
690
video_grab_bktr_demuxer_deps="bktr"
691
video_grab_v4l_demuxer_deps="v4l"
692
x11_grab_device_demuxer_deps="x11grab"
693

    
694
ffplay_deps="sdl"
695
ffserver_deps="network protocols muxers"
696
network_deps="protocols"
697

    
698
# set temporary file name
699
if test ! -z "$TMPDIR" ; then
700
    TMPDIR1="${TMPDIR}"
701
elif test ! -z "$TEMPDIR" ; then
702
    TMPDIR1="${TEMPDIR}"
703
else
704
    TMPDIR1="/tmp"
705
fi
706

    
707
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
708
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
709
TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
710
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
711
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
712

    
713
# default parameters
714

    
715
logging="yes"
716
logfile="config.err"
717

    
718
# installation paths
719
PREFIX="/usr/local"
720
libdir='${PREFIX}/lib'
721
shlibdir="$libdir"
722
incdir='${PREFIX}/include/ffmpeg'
723
mandir='${PREFIX}/man'
724
bindir='${PREFIX}/bin'
725

    
726
# toolchain
727
cross_prefix=""
728
cross_compile="no"
729
cc="gcc"
730
ar="ar"
731
ranlib="ranlib"
732
make="make"
733
strip="strip"
734
asmalign_pot="unknown"
735

    
736
# machine
737
arch=`uname -m`
738
cpu="generic"
739
powerpc_perf="no"
740
mmx="default"
741
cmov="no"
742
fast_cmov="no"
743
armv5te="default"
744
armv6="default"
745
iwmmxt="default"
746
altivec="default"
747
dcbzl="no"
748
mmi="default"
749
bigendian="no"
750

    
751
# OS
752
targetos=$(tolower $(uname -s))
753
beos_netserver="no"
754
os2="no"
755
wince="no"
756

    
757
# non-library system interfaces
758
audio_beos="default"
759
audio_oss="yes"
760
bktr="yes"
761
dv1394="yes"
762
v4l2="yes"
763
v4l="yes"
764

    
765
# libraries
766
amr_nb="no"
767
amr_nb_fixed="no"
768
amr_wb="no"
769
avisynth="no"
770
dc1394="no"
771
dlfcn_h="no"
772
dlopen="no"
773
liba52="no"
774
liba52bin="no"
775
libdts="no"
776
libfaac="no"
777
libfaad2="no"
778
libfaad="no"
779
libfaadbin="no"
780
libgsm="no"
781
libmp3lame="no"
782
libnut="no"
783
libogg="no"
784
libtheora="no"
785
libvorbis="no"
786
mlib="no"
787
x11grab="no"
788
x264="no"
789
xvid="no"
790
zlib="yes"
791

    
792
# configurable options
793
debug="yes"
794
dostrip="yes"
795
extra_warnings="no"
796
ffmpeg="yes"
797
ffplay="yes"
798
ffserver="yes"
799
gpl="no"
800
gprof="no"
801
ipv6="yes"
802
shared="no"
803
static="yes"
804
memalign_hack="no"
805
mpegaudio_hp="yes"
806
network="yes"
807
optimize="yes"
808
pp="no"
809
protocols="yes"
810
swscaler="no"
811
vhook="default"
812

    
813
# threading
814
beosthreads="no"
815
os2threads="no"
816
pthreads="no"
817
w32threads="no"
818
thread_type="no"
819

    
820
# build settings
821
SHFLAGS='-shared -Wl,-soname,$@'
822
VHOOKSHFLAGS='$(SHFLAGS)'
823
LIBOBJFLAGS=""
824
FFLDFLAGS=-Wl,--warn-common
825
LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
826
FFSERVERLDFLAGS=-Wl,-E
827
LDCONFIG="ldconfig"
828
LIBPREF="lib"
829
LIBSUF=".a"
830
LIB='$(LIBPREF)$(NAME)$(LIBSUF)'
831
SLIBPREF="lib"
832
SLIBSUF=".so"
833
SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
834
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
835
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
836
EXESUF=""
837
BUILDSUF=""
838
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(libdir)/$(LIB)"'
839

    
840
# find source path
841
source_path="`dirname \"$0\"`"
842
source_path_used="yes"
843
if test -z "$source_path" -o "$source_path" = "." ; then
844
    source_path="`pwd`"
845
    source_path_used="no"
846
else
847
    source_path="`cd \"$source_path\"; pwd`"
848
    echo "$source_path" | grep -q '[[:blank:]]' &&
849
      die "Out of tree builds are impossible with whitespace in source path."
850
fi
851

    
852
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
853
    show_help
854
fi
855

    
856
FFMPEG_CONFIGURATION="$@"
857

    
858
ENCODER_LIST=`sed -n 's/^[^#]*ENC.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
859
DECODER_LIST=`sed -n 's/^[^#]*DEC.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
860
PARSER_LIST=`sed -n 's/^[^#]*PARSER.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
861
MUXER_LIST=`sed -n 's/^[^#]*_MUX.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
862
DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
863

    
864
enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST
865

    
866
die_unknown(){
867
    echo "Unknown option \"$1\"."
868
    echo "See $0 --help for available options."
869
    exit 1
870
}
871

    
872
for opt do
873
  optval="${opt#*=}"
874
  case "$opt" in
875
  --log)
876
  ;;
877
  --log=*) logging="$optval"
878
  ;;
879
  --prefix=*) PREFIX="$optval"
880
  ;;
881
  --libdir=*) libdir="$optval"
882
  ;;
883
  --shlibdir=*) shlibdir="$optval"
884
  ;;
885
  --incdir=*) incdir="$optval"
886
  ;;
887
  --mandir=*) mandir="$optval"
888
  ;;
889
  --source-path=*) source_path="$optval"
890
  ;;
891
  --cross-prefix=*) cross_prefix="$optval"
892
  ;;
893
  --cross-compile) cross_compile="yes"
894
  ;;
895
  --target-os=*) targetos="$optval"
896
  ;;
897
  --cc=*) cc="$optval"
898
  ;;
899
  --make=*) make="$optval"
900
  ;;
901
  --extra-cflags=*) add_cflags "$optval"
902
  ;;
903
  --extra-ldflags=*) add_ldflags "$optval"
904
  ;;
905
  --extra-libs=*) add_extralibs "$optval"
906
  ;;
907
  --build-suffix=*) BUILDSUF="$optval"
908
  ;;
909
  --arch=*) arch="$optval"
910
  ;;
911
  --cpu=*) cpu="$optval"
912
  ;;
913
  --enable-mingwce) wince="yes"
914
  ;;
915
  --disable-opts) optimize="no"
916
  ;;
917
  --enable-small) optimize="small"
918
  ;;
919
  --enable-sunmlib) mlib="yes"
920
  ;;
921
  --disable-strip) dostrip="no"
922
  ;;
923
  --disable-encoders) disable $ENCODER_LIST
924
  ;;
925
  --disable-decoders) disable $DECODER_LIST
926
  ;;
927
  --disable-muxers) disable $MUXER_LIST
928
  ;;
929
  --disable-demuxers) disable $DEMUXER_LIST
930
  ;;
931
  --disable-parsers) disable $PARSER_LIST
932
  ;;
933
  --enable-*=*|--disable-*=*)
934
  eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
935
  case "$thing" in
936
      encoder|decoder|muxer|demuxer|parser) $action ${optval}_${thing} ;;
937
      *) die_unknown "$opt" ;;
938
  esac
939
  ;;
940
  --enable-?*|--disable-?*)
941
  eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
942
  echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt
943
  $action $option
944
  ;;
945
  --help) show_help
946
  ;;
947
  *)
948
  die_unknown $opt
949
  ;;
950
  esac
951
done
952

    
953
case "$arch" in
954
  i386|i486|i586|i686|i86pc|BePC)
955
    arch="x86_32"
956
  ;;
957
  x86_64|amd64)
958
    arch="x86_32"
959
    canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
960
    if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
961
      if [ -z "`echo $CFLAGS | grep -- -m32`"  ]; then
962
        arch="x86_64"
963
        enable fast_64bit
964
      fi
965
    fi
966
  ;;
967
  # armv4l is a subset of armv[567]*l
968
  arm|armv[4567]*l)
969
    arch="armv4l"
970
  ;;
971
  alpha)
972
    arch="alpha"
973
    enable fast_64bit
974
  ;;
975
  "Power Macintosh"|ppc|powerpc)
976
    arch="powerpc"
977
  ;;
978
  ppc64)
979
    arch="powerpc"
980
    enable fast_64bit
981
  ;;
982
  mips|mipsel|IP*)
983
    arch="mips"
984
  ;;
985
  sun4u|sparc64)
986
    arch="sparc64"
987
    enable fast_64bit
988
  ;;
989
  sparc)
990
    arch="sparc"
991
  ;;
992
  sh4)
993
    arch="sh4"
994
  ;;
995
  parisc)
996
    arch="parisc"
997
  ;;
998
  parisc64)
999
    arch="parisc"
1000
    enable fast_64bit
1001
  ;;
1002
  s390|s390x)
1003
    arch="s390"
1004
  ;;
1005
  m68k)
1006
    arch="m68k"
1007
  ;;
1008
  ia64)
1009
    arch="ia64"
1010
    enable fast_64bit
1011
  ;;
1012
  bfin)
1013
    arch="bfin"
1014
  ;;
1015
  *)
1016
    arch="unknown"
1017
  ;;
1018
esac
1019

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

    
1175
add_extralibs $osextralibs
1176

    
1177
if ! disabled logging ; then
1178
    enabled logging || logfile="$logging"
1179
    echo "# $0 $@" >$logfile
1180
    set >>$logfile
1181
else
1182
    logfile=/dev/null
1183
fi
1184

    
1185
# Combine FFLDFLAGS and the LDFLAGS environment variable.
1186
LDFLAGS="$FFLDFLAGS $LDFLAGS"
1187

    
1188
test -n "$cross_prefix" && cross_compile=yes
1189
cc="${cross_prefix}${cc}"
1190
ar="${cross_prefix}${ar}"
1191
ranlib="${cross_prefix}${ranlib}"
1192
strip="${cross_prefix}${strip}"
1193

    
1194
# Disable core dumps so that intentional execution of broken apps doesn't
1195
# pollute the current directory.
1196
ulimit -c 0 >/dev/null 2>&1
1197

    
1198
# we need to build at least one lib type
1199
if disabled_all static shared; then
1200
    cat <<EOF
1201
At least one library type must be built.
1202
Specify --enable-static to build the static libraries or --enable-shared to
1203
build the shared libraries as well. To only build the shared libraries specify
1204
--disable-static in addition to --enable-shared.
1205
EOF
1206
    exit 1;
1207
fi
1208

    
1209
if disabled libogg; then
1210
    enabled libtheora && die "libogg must be enabled to enable libtheora."
1211
    enabled libvorbis && die "libogg must be enabled to enable libvorbis."
1212
fi
1213

    
1214
if enabled_any libfaad libfaadbin ; then
1215
    if check_header faad.h; then
1216
        check_cc << EOF
1217
#include <faad.h>
1218
#ifndef FAAD2_VERSION
1219
ok faad1
1220
#endif
1221
int main( void ) { return 0; }
1222
EOF
1223
        test $? = 0 && enable libfaad2
1224
    else
1225
        die "FAAD test failed."
1226
    fi
1227
fi
1228

    
1229

    
1230
if disabled gpl ; then
1231
    die_gpl_disabled(){
1232
        name=$1
1233
        shift
1234
        enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
1235
    }
1236
    die_gpl_disabled "The Postprocessing code" pp
1237
    die_gpl_disabled "liba52"                  liba52
1238
    die_gpl_disabled "libxvidcore"             xvid
1239
    die_gpl_disabled "x264"                    x264
1240
    die_gpl_disabled "libdts"                  libdts
1241
    die_gpl_disabled "FAAD2"                   libfaad2
1242
    die_gpl_disabled "The X11 grabber"         x11grab
1243
    die_gpl_disabled "The software scaler"     swscaler
1244
fi
1245

    
1246
# compute MMX state
1247
if test $mmx = "default"; then
1248
    if test $arch = "x86_32" -o $arch = "x86_64"; then
1249
        mmx="yes"
1250
    else
1251
        mmx="no"
1252
    fi
1253
fi
1254

    
1255
test -z "$need_memalign" && need_memalign="$mmx"
1256

    
1257
#Darwin CC versions
1258
needmdynamicnopic="no"
1259
if test $targetos = darwin; then
1260
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1261
        add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
1262
    else
1263
        gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1264
        case "$gcc_version" in
1265
            *2.95*)
1266
                add_cflags "-no-cpp-precomp -pipe"
1267
                ;;
1268
            *[34].*)
1269
                add_cflags "-no-cpp-precomp -pipe -force_cpusubtype_ALL -Wno-sign-compare"
1270
                if disabled shared; then
1271
                   needmdynamicnopic="yes"
1272
                fi
1273
                ;;
1274
            *)
1275
                add_cflags "-no-cpp-precomp -pipe"
1276
                if disabled shared; then
1277
                   needmdynamicnopic="yes"
1278
                fi
1279
                ;;
1280
        esac
1281
    fi
1282
fi
1283

    
1284
disabled optimize || add_cflags -fomit-frame-pointer
1285

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

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

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

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

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

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

    
1399
if test $arch = "x86_32" -o $arch = "x86_64"; then
1400
    if test "$targetos" = mingw32 -o "$targetos" = cygwin; then
1401
        cat <<EOF
1402
WARNING: The following test might cause a testapp to crash (intentionally)
1403
resulting in the appearance of a dialog box. Please click "Don't send" and
1404
ignore it.
1405
EOF
1406
    fi
1407

    
1408
    # check whether EBP is available on x86
1409
    # As 'i' is stored on the stack, this program will crash
1410
    # if the base pointer is used to access it because the
1411
    # base pointer is cleared in the inline assembly code.
1412
    (check_exec) <<EOF >>$logfile 2>&1 && enable ebp_available
1413
int main(){
1414
    volatile int i=0;
1415
    asm volatile (
1416
        "xorl %%ebp, %%ebp"
1417
    ::: "%ebp");
1418
    return i;
1419
}
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
fi
1429

    
1430
# check for assembler specific support
1431

    
1432
if test $arch = "powerpc"; then
1433
check_cc <<EOF && dcbzl=yes
1434
int main(void) {
1435
    register long zero = 0;
1436
    char data[1024];
1437
    asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
1438
return 0;
1439
}
1440
EOF
1441
fi
1442

    
1443
# check for SIMD availability
1444

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

    
1456
check_header altivec.h
1457

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

    
1475
# check armv5te instructions support
1476
if test $armv5te = "default" -a $arch = "armv4l"; then
1477
    armv5te=no
1478
    check_cc <<EOF && armv5te=yes
1479
        int main(void) {
1480
        __asm__ __volatile__ ("qadd r0, r0, r0");
1481
        }
1482
EOF
1483
fi
1484

    
1485
if test $armv6 = "default" -a $arch = "armv4l"; then
1486
    check_cc <<EOF && armv6=yes || armv6=no
1487
int main(void) {
1488
    __asm__ __volatile__ ("sadd16 r0, r0, r0");
1489
}
1490
EOF
1491
fi
1492

    
1493
# check iwmmxt support
1494
if test $iwmmxt = "default" -a $arch = "armv4l"; then
1495
    iwmmxt=no
1496
    check_cc <<EOF && iwmmxt=yes
1497
        int main(void) {
1498
        __asm__ __volatile__ ("wunpckelub wr6, wr4");
1499
        }
1500
EOF
1501
fi
1502

    
1503
# mmi only available on mips
1504
if test $mmi = "default"; then
1505
    if test $arch = "mips"; then
1506
        mmi="yes"
1507
    else
1508
        mmi="no"
1509
    fi
1510
fi
1511

    
1512
# check if our compiler supports mmi
1513
enabled mmi && check_cc <<EOF || mmi="no"
1514
int main(void) {
1515
    __asm__ ("lq \$2, 0(\$2)");
1516
    return 0;
1517
}
1518
EOF
1519

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

    
1537
# ---
1538
# check availability of some header files
1539

    
1540
check_header malloc.h
1541
check_func memalign
1542

    
1543
if disabled_all memalign memalign_hack && enabled need_memalign ; then
1544
    die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
1545
fi
1546

    
1547
check_header byteswap.h
1548

    
1549
check_header arpa/inet.h
1550

    
1551
check_func inet_aton
1552
check_func localtime_r
1553
enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
1554

    
1555
# ffserver uses poll(),
1556
# if it's not found we can emulate it using select().
1557
if enabled ffserver; then
1558
    check_header sys/poll.h
1559
fi
1560

    
1561
# check for some common methods of building with pthread support
1562
# do this before the optional library checks as some of them require pthreads
1563
if enabled pthreads; then
1564
    if check_func pthread_create; then
1565
        :
1566
    elif check_func pthread_create -pthread; then
1567
        add_cflags -pthread
1568
        add_ldflags -pthread
1569
    elif check_func pthread_create -pthreads; then
1570
        add_cflags -pthreads
1571
        add_ldflags -pthreads
1572
    elif ! check_lib pthread.h pthread_create -lpthread; then
1573
        die "ERROR: can't find pthreads library"
1574
    fi
1575
fi
1576

    
1577
for thread in $THREADS_LIST; do
1578
    if enabled $thread; then
1579
        if ! disabled thread_type ; then
1580
            die "ERROR: Only one thread type must be selected."
1581
        else
1582
            thread_type="$thread"
1583
        fi
1584
    fi
1585
done
1586

    
1587
enabled_any amr_nb amr_nb_fixed amr_wb && enable amr
1588
enabled_all amr_nb amr_nb_fixed &&
1589
    die "Only one of amr_nb and amr_nb_fixed may be enabled."
1590

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

    
1610
# test for lrintf in math.h
1611
check_exec <<EOF && lrintf=yes || lrintf=no
1612
#define _ISOC9X_SOURCE  1
1613
#include <math.h>
1614
int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
1615
EOF
1616

    
1617
_restrict=
1618
for restrict_keyword in restrict __restrict__ __restrict; do
1619
    check_cc <<EOF && _restrict=$restrict_keyword && break
1620
void foo(char * $restrict_keyword p);
1621
EOF
1622
done
1623

    
1624
# dlopen/dlfcn.h probing
1625

    
1626
check_header dlfcn.h
1627

    
1628
if check_func dlopen; then
1629
    ldl=
1630
elif check_func dlopen -ldl; then
1631
    ldl=-ldl
1632
fi
1633

    
1634
test "$vhook" = "default" && vhook="$dlopen"
1635

    
1636
enabled_any vhook liba52bin libfaadbin ffserver && add_extralibs $ldl
1637

    
1638
if test "$targetos" = cygwin && enabled static ; then
1639
    vhook="no"
1640
    echo
1641
    echo "At the moment vhooks don't work on Cygwin static builds."
1642
    echo "Patches welcome."
1643
    echo
1644
fi
1645

    
1646
if enabled vhook; then
1647
    check_ldflags -rdynamic
1648
    check_ldflags -export-dynamic
1649
fi
1650

    
1651
enabled audio_beos && add_extralibs "-lmedia -lbe"
1652

    
1653
check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
1654
check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
1655

    
1656
##########################################
1657
# SDL check
1658

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

    
1685
texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
1686

    
1687
##########################################
1688
# IPv6 check
1689

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

    
1704
enabled v4l  && check_header linux/videodev.h  || disable v4l
1705
enabled v4l2 && check_header linux/videodev2.h || disable v4l2
1706

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

    
1719
enabled audio_oss &&
1720
    check_header sys/soundcard.h ||
1721
    check_header soundcard.h ||
1722
    disable audio_oss
1723

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

    
1735
enabled debug && add_cflags -g
1736

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

    
1747
# add some linker flags
1748
check_ldflags $LDLATEFLAGS
1749

    
1750
# not all compilers support -Os
1751
test "$optimize" = "small" && check_cflags -Os
1752

    
1753
if enabled optimize; then
1754
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1755
        add_cflags  "-O5"
1756
        add_ldflags "-O5"
1757
    else
1758
        add_cflags "-O3"
1759
    fi
1760
fi
1761

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

    
1772
if enabled gprof; then
1773
    add_cflags  "-p"
1774
    add_ldflags "-p"
1775
fi
1776

    
1777
VHOOKCFLAGS="-fPIC $CFLAGS"
1778
enabled needmdynamicnopic && add_cflags -mdynamic-no-pic
1779

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

    
1786
enabled_any $ENCODER_LIST && enable encoders
1787
enabled_any $DECODER_LIST && enable decoders
1788
enabled_any $MUXER_LIST   && enable muxers
1789
enabled_any $DEMUXER_LIST && enable demuxers
1790

    
1791
enabled_any $THREADS_LIST && enable threads
1792

    
1793
check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
1794
    $DEMUXER_LIST $MUXER_LIST
1795

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

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

    
1876
echo "Creating config.mak and config.h..."
1877

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

    
1882
echo "PREFIX=$PREFIX" >> config.mak
1883
echo "prefix=\$(DESTDIR)\${PREFIX}" >> config.mak
1884
echo "libdir=\$(DESTDIR)$libdir" >> config.mak
1885
echo "shlibdir=\$(DESTDIR)$shlibdir" >> config.mak
1886
echo "incdir=\$(DESTDIR)$incdir" >> config.mak
1887
echo "bindir=\$(DESTDIR)$bindir" >> config.mak
1888
echo "mandir=\$(DESTDIR)$mandir" >> config.mak
1889
echo "MAKE=$make" >> config.mak
1890
echo "CC=$cc" >> config.mak
1891
echo "AR=$ar" >> config.mak
1892
echo "RANLIB=$ranlib" >> config.mak
1893
if enabled dostrip; then
1894
    echo "STRIP=$strip" >> config.mak
1895
else
1896
    echo "STRIP=echo ignoring strip" >> config.mak
1897
fi
1898

    
1899
echo "OPTFLAGS=$CFLAGS" >> config.mak
1900
echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
1901
echo "LDFLAGS=$LDFLAGS" >> config.mak
1902
echo "LDCONFIG=$LDCONFIG" >> config.mak
1903
echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
1904
echo "SHFLAGS=$SHFLAGS" >> config.mak
1905
echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
1906
echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
1907
echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
1908
echo "BUILD_STATIC=$static" >> config.mak
1909
echo "BUILDSUF=$BUILDSUF" >> config.mak
1910
echo "LIBPREF=$LIBPREF" >> config.mak
1911
echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
1912
if enabled static; then
1913
  echo "LIB=$LIB" >> config.mak
1914
else # Some Make complain if this variable does not exist.
1915
  echo "LIB=" >> config.mak
1916
fi
1917
echo "SLIBPREF=$SLIBPREF" >> config.mak
1918
echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
1919
echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
1920

    
1921
ucarch=`toupper $arch`
1922
echo "TARGET_ARCH_${ucarch}=yes" >> config.mak
1923
echo "#define ARCH_${ucarch} 1" >> $TMPH
1924

    
1925
# special cases
1926
case "$arch" in
1927
    x86_32|x86_64)
1928
        echo "TARGET_ARCH_X86=yes" >> config.mak
1929
        echo "#define ARCH_X86 1" >> $TMPH
1930
        ;;
1931
    powerpc)
1932
        if test "$POWERPCMODE" = "64bits"; then
1933
            echo "#define POWERPC_MODE_64BITS 1" >> $TMPH
1934
        fi
1935
        ;;
1936
    sparc64)
1937
        echo "TARGET_ARCH_SPARC=yes" >> config.mak
1938
        echo "#define ARCH_SPARC 1" >> $TMPH
1939
        ;;
1940
esac
1941

    
1942
if enabled bigendian; then
1943
  echo "WORDS_BIGENDIAN=yes" >> config.mak
1944
  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
1945
fi
1946
if enabled mmx; then
1947
  echo "#define __CPU__ 586" >> $TMPH
1948
fi
1949

    
1950
if enabled sdl; then
1951
  echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1952
  echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
1953
fi
1954
if enabled texi2html; then
1955
  echo "BUILD_DOC=yes" >> config.mak
1956
fi
1957

    
1958
sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
1959
pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
1960
lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
1961
lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
1962
lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
1963

    
1964

    
1965

    
1966
if enabled shared; then
1967
  echo "BUILD_SHARED=yes" >> config.mak
1968
  echo "PIC=-fPIC -DPIC" >> config.mak
1969
  echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
1970
  echo "SPPVERSION=$pp_version" >> config.mak
1971
  echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
1972
  echo "LAVCVERSION=$lavc_version" >> config.mak
1973
  echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
1974
  echo "LAVFVERSION=$lavf_version" >> config.mak
1975
  echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
1976
  echo "LAVUVERSION=$lavu_version" >> config.mak
1977
  echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
1978
  echo "SWSVERSION=$sws_version" >> config.mak
1979
  echo "SLIBNAME=${SLIBNAME}" >> config.mak
1980
  echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
1981
  echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
1982
  echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
1983
  echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
1984
fi
1985
echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
1986
echo "EXTRALIBS=$extralibs" >> config.mak
1987

    
1988
print_config HAVE_   $TMPH config.mak $HAVE_LIST
1989
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST
1990
print_config TARGET_ $TMPH config.mak $TARGET_LIST
1991

    
1992
if test "$targetos" = darwin; then
1993
  echo "#define CONFIG_DARWIN 1"  >> $TMPH
1994
fi
1995

    
1996
echo "#define restrict $_restrict" >> $TMPH
1997

    
1998
if test "$optimize" = "small"; then
1999
  echo "#define always_inline"  >> $TMPH
2000
  echo "#define CONFIG_SMALL 1" >> $TMPH
2001
fi
2002

    
2003
echo "SRC_PATH=\"$source_path\"" >> config.mak
2004
echo "SRC_PATH_BARE=$source_path" >> config.mak
2005
echo "BUILD_ROOT=\"$PWD\"" >> config.mak
2006

    
2007
# Apparently it's not possible to portably echo a backslash.
2008
if enabled asmalign_pot; then
2009
  printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
2010
else
2011
  printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
2012
fi
2013

    
2014

    
2015
for part in $DECODER_LIST $ENCODER_LIST $PARSER_LIST $DEMUXER_LIST $MUXER_LIST; do
2016
    ucname="`toupper $part`"
2017
    config_name="CONFIG_$ucname"
2018
    enabled_name="ENABLE_$ucname"
2019
    if enabled $part; then
2020
        echo "#define $config_name 1" >> $TMPH
2021
        echo "#define $enabled_name 1" >> $TMPH
2022
        echo "$config_name=yes" >> config.mak
2023
    else
2024
        echo "#define $enabled_name 0" >> $TMPH
2025
    fi
2026
done
2027

    
2028
# Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
2029
if ! cmp -s $TMPH config.h; then
2030
        mv -f $TMPH config.h
2031
else
2032
        echo "config.h is unchanged"
2033
fi
2034

    
2035
rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
2036

    
2037
# build tree in object directory if source path is different from current one
2038
if enabled source_path_used; then
2039
    DIRS="\
2040
         doc \
2041
         libavformat \
2042
         libavcodec \
2043
         libavcodec/alpha \
2044
         libavcodec/armv4l \
2045
         libavcodec/bfin \
2046
         libavcodec/i386 \
2047
         libavcodec/sparc \
2048
         libavcodec/mlib \
2049
         libavcodec/ppc \
2050
         libavcodec/amr \
2051
         libpostproc \
2052
         libavutil \
2053
         libswscale \
2054
         tests \
2055
         vhook \
2056
         "
2057
    FILES="\
2058
          Makefile \
2059
          common.mak \
2060
          libavformat/Makefile \
2061
          libavcodec/Makefile \
2062
          libpostproc/Makefile \
2063
          libavutil/Makefile \
2064
          libswscale/Makefile \
2065
          tests/Makefile \
2066
          vhook/Makefile \
2067
          doc/Makefile \
2068
          doc/texi2pod.pl \
2069
          "
2070
    for dir in $DIRS ; do
2071
            mkdir -p $dir
2072
    done
2073
    for f in $FILES ; do
2074
        ln -sf "$source_path/$f" $f
2075
    done
2076
fi
2077

    
2078

    
2079
# build pkg-config files
2080
# FIXME: libdir and includedir are hardcoded and may differ from the real path.
2081

    
2082
pkgconfig_generate(){
2083
name=$1
2084
comment=$2
2085
version=$3
2086
libs=$4
2087
requires=$5
2088
include=$6
2089
cat <<EOF >$name.pc
2090
prefix=$PREFIX
2091
exec_prefix=\${prefix}
2092
libdir=\${exec_prefix}/lib
2093
includedir=\${prefix}/include
2094

    
2095
Name: $name
2096
Description: $comment
2097
Version: $version
2098
Requires: $requires
2099
Conflicts:
2100
Libs: -L\${libdir} $libs
2101
Cflags: -I\${includedir} -I\${includedir}/$include
2102
EOF
2103
}
2104

    
2105
pkgconfig_generate_uninstalled(){
2106
name=$1
2107
shortname=${name#lib}
2108
comment=$2
2109
version=$3
2110
libs=$4
2111
requires=$5
2112
cat <<EOF >$name-uninstalled.pc
2113
prefix=
2114
exec_prefix=
2115
libdir=\${pcfiledir}/$name
2116
includedir=\${pcfiledir}/$name
2117

    
2118
Name: $name
2119
Description: $comment
2120
Version: $version
2121
Requires: $requires
2122
Conflicts:
2123
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
2124
Cflags: -I\${includedir}
2125
EOF
2126
}
2127

    
2128
pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
2129
pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
2130

    
2131
pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
2132
pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
2133

    
2134
pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2135
pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
2136

    
2137
if enabled pp; then
2138
  pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
2139
  pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
2140
fi
2141

    
2142
if enabled swscaler; then
2143
  pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" -lswscale "libavutil = $lavu_version" ffmpeg
2144
  pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
2145
else
2146
  pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2147
  pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
2148
  apply libswscale.pc sed s/^Libs:.*$/Libs:/
2149
  apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
2150
fi