Statistics
| Branch: | Revision:

ffmpeg / configure @ c16c584a

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

    
182
log(){
183
    echo "$@" >>$logfile
184
}
185

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

    
192
echolog(){
193
    log "$@"
194
    echo "$@"
195
}
196

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

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

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

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

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

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

    
255
enable(){
256
    set_all yes $*
257
}
258

    
259
disable(){
260
    set_all no $*
261
}
262

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

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

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

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

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

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

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

    
301
        eval dep_all="\$${cfg}_deps"
302
        eval dep_any="\$${cfg}_deps_any"
303

    
304
        pushvar cfg dep_all dep_any
305
        check_deps $dep_all $dep_any
306
        popvar cfg dep_all dep_any
307

    
308
        enabled_all $dep_all || disable $cfg
309
        enabled_any $dep_any || disable $cfg
310

    
311
        disable ${cfg}_checking
312
    done
313
}
314

    
315
print_config(){
316
    pfx=$1
317
    header=$2
318
    makefile=$3
319
    shift 3
320
    for cfg; do
321
        ucname="`toupper $cfg`"
322
        if enabled $cfg; then
323
            echo "#define ${pfx}${ucname} 1" >> $header
324
            echo "#define ENABLE_${ucname} 1" >> $header
325
            echo "${pfx}${ucname}=yes" >> $makefile
326
        else
327
            echo "#define ENABLE_${ucname} 0" >> $header
328
        fi
329
    done
330
}
331

    
332
flags_saved(){
333
    (: ${SAVE_CFLAGS?}) 2>/dev/null
334
}
335

    
336
save_flags(){
337
    flags_saved && return
338
    SAVE_CFLAGS="$CFLAGS"
339
    SAVE_LDFLAGS="$LDFLAGS"
340
    SAVE_extralibs="$extralibs"
341
}
342

    
343
restore_flags(){
344
    flags_saved || return
345
    CFLAGS="$SAVE_CFLAGS"
346
    LDFLAGS="$SAVE_LDFLAGS"
347
    extralibs="$SAVE_extralibs"
348
    unset SAVE_CFLAGS
349
    unset SAVE_LDFLAGS
350
    unset SAVE_extralibs
351
}
352

    
353
temp_cflags(){
354
    save_flags
355
    CFLAGS="$CFLAGS $*"
356
}
357

    
358
temp_ldflags(){
359
    save_flags
360
    LDFLAGS="$LDFLAGS $*"
361
}
362

    
363
temp_extralibs(){
364
    save_flags
365
    extralibs="$extralibs $*"
366
}
367

    
368
append(){
369
    var=$1
370
    shift
371
    flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
372
    eval "$var=\"\$$var $*\""
373
}
374

    
375
add_cflags(){
376
    append CFLAGS "$@"
377
}
378

    
379
add_ldflags(){
380
    append LDFLAGS "$@"
381
}
382

    
383
add_extralibs(){
384
    append extralibs "$@"
385
}
386

    
387
check_cmd(){
388
    log "$@"
389
    "$@" >>$logfile 2>&1
390
}
391

    
392
check_cc(){
393
    log check_cc "$@"
394
    cat >$TMPC
395
    log_file $TMPC
396
    check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
397
}
398

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

    
406
check_ld(){
407
    log check_ld "$@"
408
    check_cc || return
409
    flags=''
410
    libs=''
411
    for f; do
412
        test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
413
    done
414
    check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
415
}
416

    
417
check_cflags(){
418
    log check_cflags "$@"
419
    check_cc "$@" <<EOF && add_cflags "$@"
420
int x;
421
EOF
422
}
423

    
424
check_ldflags(){
425
    log check_ldflags "$@"
426
    check_ld "$@" <<EOF && add_ldflags "$@"
427
int main(){
428
    return 0;
429
}
430
EOF
431
}
432

    
433
check_header(){
434
    log check_header "$@"
435
    header=$1
436
    shift
437
    var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
438
    disable $var
439
    check_cpp "$@" <<EOF && enable $var
440
#include <$header>
441
int x;
442
EOF
443
}
444

    
445
check_func(){
446
    log check_func "$@"
447
    func=$1
448
    shift
449
    disable $func
450
    check_ld "$@" <<EOF && enable $func
451
extern int $func();
452
int main(){
453
    $func();
454
}
455
EOF
456
}
457

    
458
check_func2(){
459
    log check_func2 "$@"
460
    headers=$1
461
    func=$2
462
    shift 2
463
    disable $func
464
    incs=""
465
    for hdr in $headers; do
466
        incs="$incs
467
#include <$hdr>"
468
    done
469
    check_ld "$@" <<EOF && enable $func
470
$incs
471
int main(){
472
    (void) $func;
473
    return 0;
474
}
475
EOF
476
}
477

    
478
check_lib(){
479
    log check_lib "$@"
480
    header="$1"
481
    func="$2"
482
    shift 2
483
    temp_extralibs "$@"
484
    check_header $header && check_func $func && add_extralibs "$@"
485
    err=$?
486
    restore_flags
487
    return $err
488
}
489

    
490
check_lib2(){
491
    log check_lib2 "$@"
492
    headers="$1"
493
    func="$2"
494
    shift 2
495
    temp_extralibs "$@"
496
    check_func2 "$headers" $func && add_extralibs "$@"
497
    err=$?
498
    restore_flags
499
    return $err
500
}
501

    
502
check_exec(){
503
    check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
504
}
505

    
506
check_exec_crash(){
507
    code=`cat`
508

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

    
515
    (check_exec "$@") >>$logfile 2>&1 <<EOF
516
#include <signal.h>
517
static void sighandler(int sig){
518
    raise(SIGTERM);
519
}
520
int main(){
521
    signal(SIGILL, sighandler);
522
    signal(SIGFPE, sighandler);
523
    signal(SIGSEGV, sighandler);
524
#ifdef SIGBUS
525
    signal(SIGBUS, sighandler);
526
#endif
527
    { $code }
528
}
529
EOF
530
}
531

    
532
require(){
533
    name="$1"
534
    header="$2"
535
    func="$3"
536
    shift 3
537
    check_lib $header $func "$@" || die "ERROR: $name not found"
538
}
539

    
540
require2(){
541
    name="$1"
542
    headers="$2"
543
    func="$3"
544
    shift 3
545
    check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
546
}
547

    
548
check_foo_config(){
549
    cfg=$1
550
    pkg=$2
551
    header=$3
552
    func=$4
553
    shift 4
554
    disable $cfg
555
    check_cmd ${pkg}-config --version
556
    err=$?
557
    if test "$err" = 0; then
558
        temp_cflags `${pkg}-config --cflags`
559
        temp_extralibs `${pkg}-config --libs`
560
        check_lib "$@" $header $func && enable $cfg
561
    fi
562
    return $err
563
}
564

    
565
apply(){
566
    file=$1
567
    shift
568
    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
569
}
570

    
571
CONFIG_LIST='
572
    audio_beos
573
    audio_oss
574
    avisynth
575
    beos_netserver
576
    bktr
577
    bsfs
578
    dc1394
579
    decoders
580
    demuxers
581
    dv1394
582
    encoders
583
    fixedpoint
584
    ffmpeg
585
    ffplay
586
    ffserver
587
    gpl
588
    gprof
589
    gray
590
    ipv6
591
    liba52
592
    liba52bin
593
    libamr
594
    libamr_nb
595
    libamr_wb
596
    libfaac
597
    libfaad
598
    libfaadbin
599
    libgsm
600
    libmp3lame
601
    libnut
602
    libogg
603
    libtheora
604
    libvorbis
605
    libx264
606
    libxvid
607
    memalign_hack
608
    mpegaudio_hp
609
    muxers
610
    network
611
    parsers
612
    powerpc_perf
613
    pp
614
    protocols
615
    small
616
    swscaler
617
    vhook
618
    v4l
619
    v4l2
620
    x11grab
621
    zlib
622
'
623

    
624
THREADS_LIST='
625
    beosthreads
626
    pthreads
627
    w32threads
628
'
629

    
630
ARCH_LIST='
631
    alpha
632
    armv4l
633
    bfin
634
    ia64
635
    m68k
636
    mips
637
    parisc
638
    powerpc
639
    s390
640
    sh4
641
    sparc
642
    sparc64
643
    x86
644
    x86_32
645
    x86_64
646
'
647

    
648
ARCH_EXT_LIST='
649
    altivec
650
    armv5te
651
    armv6
652
    iwmmxt
653
    mmi
654
    mmx
655
    ssse3
656
'
657

    
658
HAVE_LIST="
659
    $ARCH_EXT_LIST
660
    $THREADS_LIST
661
    altivec_h
662
    arpa_inet_h
663
    byteswap_h
664
    cmov
665
    conio_h
666
    dcbzl
667
    dev_bktr_ioctl_bt848_h
668
    dev_bktr_ioctl_meteor_h
669
    dev_ic_bt8xx_h
670
    dev_video_meteor_ioctl_meteor_h
671
    dev_video_bktr_ioctl_bt848_h
672
    dlfcn_h
673
    dlopen
674
    ebp_available
675
    ebx_available
676
    fast_64bit
677
    fast_cmov
678
    fast_unaligned
679
    fork
680
    freetype2
681
    GetProcessTimes
682
    getrusage
683
    imlib2
684
    inet_aton
685
    lrintf
686
    machine_ioctl_bt848_h
687
    machine_ioctl_meteor_h
688
    malloc_h
689
    memalign
690
    mkstemp
691
    mlib
692
    ppc64
693
    sdl
694
    sdl_video_size
695
    soundcard_h
696
    sys_poll_h
697
    sys_soundcard_h
698
    termios_h
699
    threads
700
"
701

    
702
CMDLINE_SELECT="
703
    $ARCH_EXT_LIST
704
    $CONFIG_LIST
705
    $THREADS_LIST
706
    debug
707
    extra_warnings
708
    shared
709
    static
710
"
711

    
712
# code dependency declarations
713

    
714
# architecture extensions
715
altivec_deps="powerpc"
716
armv5te_deps="armv4l"
717
armv6_deps="armv4l"
718
iwmmxt_deps="armv4l"
719
mmi_deps="mips"
720
mmx_deps="x86"
721
ssse3_deps="x86"
722

    
723
# decoders / encoders
724
dxa_decoder_deps="zlib"
725
flashsv_decoder_deps="zlib"
726
flashsv_encoder_deps="zlib"
727
flv_decoder_deps="h263_decoder"
728
h263_decoder_deps="h263_parser mpeg4video_parser"
729
h263i_decoder_deps="h263_decoder"
730
h264_decoder_deps="h264_parser"
731
mpeg_xvmc_decoder_deps="xvmc"
732
mpeg4_decoder_deps="h263_decoder"
733
msmpeg4v1_decoder_deps="h263_decoder"
734
msmpeg4v2_decoder_deps="h263_decoder"
735
msmpeg4v3_decoder_deps="h263_decoder"
736
png_decoder_deps="zlib"
737
png_encoder_deps="zlib"
738
svq3_decoder_deps="h264_parser"
739
vc1_decoder_deps="h263_decoder"
740
wmv1_decoder_deps="h263_decoder"
741
wmv2_decoder_deps="h263_decoder"
742
wmv3_decoder_deps="h263_decoder"
743
zmbv_decoder_deps="zlib"
744
zmbv_encoder_deps="zlib"
745

    
746
# external libraries
747
mpeg4aac_decoder_deps="libfaad"
748
liba52_decoder_deps="liba52"
749
libamr_nb_decoder_deps="libamr_nb"
750
libamr_nb_encoder_deps="libamr_nb"
751
libamr_wb_decoder_deps="libamr_wb"
752
libamr_wb_encoder_deps="libamr_wb"
753
libfaac_encoder_deps="libfaac"
754
libfaad_decoder_deps="libfaad"
755
libgsm_decoder_deps="libgsm"
756
libgsm_encoder_deps="libgsm"
757
libgsm_ms_decoder_deps="libgsm"
758
libgsm_ms_encoder_deps="libgsm"
759
libmp3lame_encoder_deps="libmp3lame"
760
libtheora_encoder_deps="libtheora"
761
libvorbis_decoder_deps="libvorbis"
762
libvorbis_encoder_deps="libvorbis"
763
libx264_encoder_deps="libx264"
764
libxvid_encoder_deps="libxvid"
765

    
766
# demuxers / muxers
767
ac3_demuxer_deps="ac3_parser"
768
audio_demuxer_deps_any="audio_oss audio_beos"
769
audio_muxer_deps_any="audio_oss audio_beos"
770
dc1394_demuxer_deps="dc1394"
771
dv1394_demuxer_deps="dv1394"
772
libnut_demuxer_deps="libnut"
773
libnut_muxer_deps="libnut"
774
mp3_demuxer_deps="mpegaudio_parser"
775
ogg_muxer_deps="libogg"
776
redir_demuxer_deps="network"
777
rtp_muxer_deps="network mpegts_demuxer"
778
rtsp_demuxer_deps="rtp_protocol rtp_muxer"
779
sdp_demuxer_deps="rtsp_demuxer"
780
v4l2_demuxer_deps="v4l2"
781
video_grab_bktr_demuxer_deps="bktr"
782
video_grab_v4l_demuxer_deps="v4l"
783
x11_grab_device_demuxer_deps="x11grab"
784

    
785
# protocols
786
http_protocol_deps="network"
787
rtp_protocol_deps="udp_protocol"
788
tcp_protocol_deps="network"
789
udp_protocol_deps="network"
790

    
791
# programs
792
ffplay_deps="sdl"
793
ffserver_deps="muxers rtp_protocol"
794

    
795

    
796
# set temporary file name
797
if test ! -z "$TMPDIR" ; then
798
    TMPDIR1="${TMPDIR}"
799
elif test ! -z "$TEMPDIR" ; then
800
    TMPDIR1="${TEMPDIR}"
801
else
802
    TMPDIR1="/tmp"
803
fi
804

    
805
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
806
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
807
TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
808
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
809
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
810

    
811
# default parameters
812

    
813
logging="yes"
814
logfile="config.err"
815

    
816
# installation paths
817
PREFIX="/usr/local"
818
libdir='$(PREFIX)/lib'
819
shlibdir="$libdir"
820
incdir='$(PREFIX)/include/ffmpeg'
821
mandir='$(PREFIX)/man'
822
bindir='$(PREFIX)/bin'
823

    
824
# toolchain
825
cc="gcc"
826
ar="ar"
827
ranlib="ranlib"
828
make="make"
829
strip="strip"
830
asmalign_pot="unknown"
831

    
832
# machine
833
arch=`uname -m`
834
cpu="generic"
835

    
836
# OS
837
targetos=$(tolower $(uname -s))
838

    
839
# non-library system interfaces
840
audio_oss="yes"
841
bktr="yes"
842
dv1394="yes"
843
v4l2="yes"
844
v4l="yes"
845

    
846
# libraries
847
zlib="yes"
848

    
849
# configurable options
850
debug="yes"
851
dostrip="yes"
852
ffmpeg="yes"
853
ffplay="yes"
854
ffserver="yes"
855
ipv6="yes"
856
static="yes"
857
mpegaudio_hp="yes"
858
network="yes"
859
optimize="yes"
860
protocols="yes"
861
vhook="default"
862

    
863
# build settings
864
SHFLAGS='-shared -Wl,-soname,$@'
865
VHOOKSHFLAGS='$(SHFLAGS)'
866
LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
867
FFSERVERLDFLAGS=-Wl,-E
868
LDCONFIG="ldconfig"
869
LIBPREF="lib"
870
LIBSUF=".a"
871
LIB='$(LIBPREF)$(NAME)$(LIBSUF)'
872
SLIBPREF="lib"
873
SLIBSUF=".so"
874
SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
875
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
876
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
877
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIB)"'
878

    
879
# find source path
880
source_path="`dirname \"$0\"`"
881
source_path_used="yes"
882
if test -z "$source_path" -o "$source_path" = "." ; then
883
    source_path="`pwd`"
884
    source_path_used="no"
885
else
886
    source_path="`cd \"$source_path\"; pwd`"
887
    echo "$source_path" | grep -q '[[:blank:]]' &&
888
      die "Out of tree builds are impossible with whitespace in source path."
889
fi
890

    
891
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
892
    show_help
893
fi
894

    
895
FFMPEG_CONFIGURATION="$@"
896

    
897
ENCODER_LIST=`sed -n 's/^[^#]*ENC.*(.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
898
DECODER_LIST=`sed -n 's/^[^#]*DEC.*(.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
899
PARSER_LIST=`sed -n 's/^[^#]*PARSER.*(.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
900
BSF_LIST=`sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' "$source_path/libavcodec/allcodecs.c"`
901
MUXER_LIST=`sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
902
DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
903
PROTOCOL_LIST=`sed -n 's/^[^#]*PROTOCOL.*(.*, *\(.*\)).*/\1_protocol/p' "$source_path/libavformat/allformats.c"`
904

    
905
enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST $PROTOCOL_LIST $BSF_LIST
906
enable $ARCH_EXT_LIST
907

    
908
die_unknown(){
909
    echo "Unknown option \"$1\"."
910
    echo "See $0 --help for available options."
911
    exit 1
912
}
913

    
914
show_list() {
915
    for part in $*; do
916
        echo $part | sed 's/_[^_]*$//'
917
    done | sort
918
    exit 0
919
}
920

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

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

    
1076
enable $arch
1077
enabled_any x86_32 x86_64 && enable x86
1078
enabled     sparc64       && enable sparc
1079

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

    
1208
add_extralibs $osextralibs
1209

    
1210
if ! disabled logging ; then
1211
    enabled logging || logfile="$logging"
1212
    echo "# $0 $@" >$logfile
1213
    set >>$logfile
1214
else
1215
    logfile=/dev/null
1216
fi
1217

    
1218
# Combine FFLDFLAGS and the LDFLAGS environment variable.
1219
LDFLAGS="$FFLDFLAGS $LDFLAGS"
1220

    
1221
test -n "$cross_prefix" && cross_compile=yes
1222
cc="${cross_prefix}${cc}"
1223
ar="${cross_prefix}${ar}"
1224
ranlib="${cross_prefix}${ranlib}"
1225
strip="${cross_prefix}${strip}"
1226

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

    
1238
if ! enabled libogg; then
1239
    enabled libtheora && die "libogg must be enabled to enable libtheora."
1240
    enabled libvorbis && die "libogg must be enabled to enable libvorbis."
1241
fi
1242

    
1243
if enabled_any libfaad libfaadbin ; then
1244
    if check_header faad.h; then
1245
        check_cc << EOF
1246
#include <faad.h>
1247
#ifndef FAAD2_VERSION
1248
ok faad1
1249
#endif
1250
int main( void ) { return 0; }
1251
EOF
1252
        test $? = 0 && enable libfaad2
1253
    else
1254
        die "FAAD test failed."
1255
    fi
1256
fi
1257

    
1258

    
1259
if ! enabled gpl; then
1260
    die_gpl_disabled(){
1261
        name=$1
1262
        shift
1263
        enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
1264
    }
1265
    die_gpl_disabled "The Postprocessing code" pp
1266
    die_gpl_disabled "liba52"                  liba52
1267
    die_gpl_disabled "libx264"                 libx264
1268
    die_gpl_disabled "libxvidcore"             libxvid
1269
    die_gpl_disabled "FAAD2"                   libfaad2
1270
    die_gpl_disabled "The X11 grabber"         x11grab
1271
    die_gpl_disabled "The software scaler"     swscaler
1272
fi
1273

    
1274
check_deps $ARCH_EXT_LIST
1275

    
1276
test -z "$need_memalign" && need_memalign="$mmx"
1277

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

    
1292
disabled optimize || add_cflags -fomit-frame-pointer
1293

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

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

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

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

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

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

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

    
1422
    # check whether binutils is new enough to compile SSSE3
1423
    enabled ssse3 && check_cc <<EOF || disable ssse3
1424
int main(){
1425
    asm volatile ("pabsw %xmm0, %xmm0");
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 enabled altivec; then
1447
    if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
1448
        add_cflags "-faltivec"
1449
    else
1450
        add_cflags "-maltivec -mabi=altivec"
1451
    fi
1452

    
1453
    check_header altivec.h
1454

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

    
1471
# check armv5te instructions support
1472
enabled armv5te && check_cc <<EOF || disable armv5te
1473
int main(void) {
1474
    __asm__ __volatile__ ("qadd r0, r0, r0");
1475
}
1476
EOF
1477

    
1478
enabled armv6 && check_cc <<EOF || disable armv6
1479
int main(void) {
1480
    __asm__ __volatile__ ("sadd16 r0, r0, r0");
1481
}
1482
EOF
1483

    
1484
# check iwmmxt support
1485
enabled iwmmxt && check_cc <<EOF || disable iwmmxt
1486
int main(void) {
1487
    __asm__ __volatile__ ("wunpckelub wr6, wr4");
1488
}
1489
EOF
1490

    
1491
# check if our compiler supports mmi
1492
enabled mmi && check_cc <<EOF || mmi="no"
1493
int main(void) {
1494
    __asm__ ("lq \$2, 0(\$2)");
1495
    return 0;
1496
}
1497
EOF
1498

    
1499
# ---
1500
# big/little-endian test
1501
if ! enabled cross_compile; then
1502
    check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
1503
#include <inttypes.h>
1504
int main(int argc, char ** argv){
1505
        volatile uint32_t i=0x01234567;
1506
        return (*((uint8_t*)(&i))) == 0x67;
1507
}
1508
EOF
1509
else
1510
    # programs cannot be launched if cross compiling, so make a static guess
1511
    if test "$arch" = "powerpc" -o "$arch" = "mips" ; then
1512
        bigendian="yes"
1513
    fi
1514
fi
1515

    
1516
# ---
1517
# check availability of some header files
1518

    
1519
check_header malloc.h
1520
check_func memalign
1521

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

    
1526
check_header byteswap.h
1527

    
1528
check_func mkstemp
1529

    
1530
check_header termios.h
1531
check_header conio.h
1532

    
1533
check_header arpa/inet.h
1534

    
1535
check_func inet_aton
1536
enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
1537

    
1538
# ffserver uses poll(),
1539
# if it's not found we can emulate it using select().
1540
if enabled ffserver; then
1541
    check_header sys/poll.h
1542
fi
1543

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

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

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

    
1577
enabled_any libamr_nb libamr_wb && enable libamr
1578

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

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

    
1604
# dlopen/dlfcn.h probing
1605

    
1606
check_header dlfcn.h
1607

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

    
1614
check_func getrusage
1615
check_func2 windows.h GetProcessTimes
1616

    
1617
check_func fork
1618

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

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

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

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

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

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

    
1641
##########################################
1642
# SDL check
1643

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

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

    
1672
##########################################
1673
# IPv6 check
1674

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

    
1689
enabled v4l  && check_header linux/videodev.h  || disable v4l
1690
enabled v4l2 && check_header linux/videodev2.h || disable v4l2
1691

    
1692
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1693
if enabled bktr; then
1694
    { check_header dev/bktr/ioctl_meteor.h &&
1695
      check_header dev/bktr/ioctl_bt848.h; } ||
1696
    { check_header machine/ioctl_meteor.h &&
1697
      check_header machine/ioctl_bt848.h; } ||
1698
    { check_header dev/video/meteor/ioctl_meteor.h &&
1699
      check_header dev/video/bktr/ioctl_bt848.h; } ||
1700
    check_header dev/ic/bt8xx.h ||
1701
    disable bktr
1702
fi
1703

    
1704
enabled audio_oss &&
1705
    check_header sys/soundcard.h ||
1706
    check_header soundcard.h ||
1707
    disable audio_oss
1708

    
1709
# Deal with the x11 frame grabber
1710
enabled x11grab                         &&
1711
enabled gpl                             &&
1712
enabled x11_grab_device_demuxer         &&
1713
check_header X11/Xlib.h                 &&
1714
check_header X11/extensions/XShm.h      &&
1715
check_func XOpenDisplay -lX11           &&
1716
check_func XShmCreateImage -lX11 -lXext &&
1717
add_extralibs -lX11 -lXext              ||
1718
disable x11_grab_device_demuxer
1719

    
1720
enabled debug && add_cflags -g
1721

    
1722
# add some useful compiler flags if supported
1723
check_cflags -Wdeclaration-after-statement
1724
check_cflags -Wall
1725
check_cflags -Wno-switch
1726
check_cflags -Wdisabled-optimization
1727
check_cflags -Wpointer-arith
1728
check_cflags -Wredundant-decls
1729
check_cflags -Wno-pointer-sign
1730
enabled extra_warnings && check_cflags -Winline
1731

    
1732
# add some linker flags
1733
check_ldflags -Wl,--warn-common
1734
check_ldflags $LDLATEFLAGS
1735

    
1736
if enabled small; then
1737
    check_cflags -Os            # not all compilers support -Os
1738
    optimize="small"
1739
elif enabled optimize; then
1740
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1741
        add_cflags  "-O5"
1742
        add_ldflags "-O5"
1743
    else
1744
        add_cflags "-O3"
1745
    fi
1746
fi
1747

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

    
1758
if enabled gprof; then
1759
    add_cflags  "-p"
1760
    add_ldflags "-p"
1761
fi
1762

    
1763
VHOOKCFLAGS="-fPIC"
1764

    
1765
# find if .align arg is power-of-two or not
1766
if test $asmalign_pot = "unknown"; then
1767
    asmalign_pot="no"
1768
    echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
1769
fi
1770

    
1771
enabled_any $ENCODER_LIST  && enable encoders
1772
enabled_any $DECODER_LIST  && enable decoders
1773
enabled_any $MUXER_LIST    && enable muxers
1774
enabled_any $DEMUXER_LIST  && enable demuxers
1775
enabled_any $PROTOCOL_LIST && enable protocols
1776
enabled_any $BSF_LIST      && enable bsfs
1777

    
1778
enabled_any $THREADS_LIST  && enable threads
1779

    
1780
check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
1781
    $BSF_LIST $DEMUXER_LIST $MUXER_LIST $PROTOCOL_LIST
1782

    
1783
enabled libogg    && append pkg_requires "ogg >= 1.1"
1784
enabled libtheora && append pkg_requires "theora"
1785
enabled libvorbis && append pkg_requires "vorbis vorbisenc"
1786
enabled dc1394    && append pkg_requires "libraw1394"
1787

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

    
1861
echo "Creating config.mak and config.h..."
1862

    
1863
echo "# Automatically generated by configure - do not modify!" > config.mak
1864
echo "/* Automatically generated by configure - do not modify! */" > $TMPH
1865
echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
1866

    
1867
echo "PREFIX=$PREFIX" >> config.mak
1868
echo "prefix=\$(DESTDIR)\$(PREFIX)" >> config.mak
1869
echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
1870
echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
1871
echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
1872
echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
1873
echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
1874
echo "MAKE=$make" >> config.mak
1875
echo "CC=$cc" >> config.mak
1876
echo "AR=$ar" >> config.mak
1877
echo "RANLIB=$ranlib" >> config.mak
1878
if enabled dostrip; then
1879
    echo "STRIP=$strip" >> config.mak
1880
else
1881
    echo "STRIP=echo ignoring strip" >> config.mak
1882
fi
1883

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

    
1906
if enabled bigendian; then
1907
  echo "WORDS_BIGENDIAN=yes" >> config.mak
1908
  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
1909
fi
1910
if enabled mmx; then
1911
  echo "#define __CPU__ 586" >> $TMPH
1912
fi
1913

    
1914
if enabled sdl; then
1915
  echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1916
  echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
1917
fi
1918
if enabled texi2html; then
1919
  echo "BUILD_DOC=yes" >> config.mak
1920
fi
1921

    
1922
sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
1923
pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
1924
lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
1925
lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
1926
lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
1927

    
1928

    
1929

    
1930
if enabled shared; then
1931
  echo "BUILD_SHARED=yes" >> config.mak
1932
  echo "PIC=-fPIC -DPIC" >> config.mak
1933
  echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
1934
  echo "SPPVERSION=$pp_version" >> config.mak
1935
  echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
1936
  echo "LAVCVERSION=$lavc_version" >> config.mak
1937
  echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
1938
  echo "LAVFVERSION=$lavf_version" >> config.mak
1939
  echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
1940
  echo "LAVUVERSION=$lavu_version" >> config.mak
1941
  echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
1942
  echo "SWSVERSION=$sws_version" >> config.mak
1943
  echo "SLIBNAME=${SLIBNAME}" >> config.mak
1944
  echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
1945
  echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
1946
  echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
1947
  echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
1948
fi
1949
echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
1950
echo "EXTRALIBS=$extralibs" >> config.mak
1951

    
1952
print_config ARCH_   $TMPH config.mak $ARCH_LIST
1953
print_config HAVE_   $TMPH config.mak $HAVE_LIST
1954
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST   \
1955
                                      $DECODER_LIST  \
1956
                                      $ENCODER_LIST  \
1957
                                      $PARSER_LIST   \
1958
                                      $BSF_LIST      \
1959
                                      $DEMUXER_LIST  \
1960
                                      $MUXER_LIST    \
1961
                                      $PROTOCOL_LIST \
1962

    
1963
if test "$targetos" = darwin; then
1964
  echo "#define CONFIG_DARWIN 1"  >> $TMPH
1965
fi
1966

    
1967
echo "#define restrict $_restrict" >> $TMPH
1968

    
1969
if enabled small; then
1970
  echo "#define always_inline"  >> $TMPH
1971
fi
1972

    
1973
echo "SRC_PATH=\"$source_path\"" >> config.mak
1974
echo "SRC_PATH_BARE=$source_path" >> config.mak
1975
echo "BUILD_ROOT=\"$PWD\"" >> config.mak
1976

    
1977
# Apparently it's not possible to portably echo a backslash.
1978
if enabled asmalign_pot; then
1979
  printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
1980
else
1981
  printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
1982
fi
1983

    
1984

    
1985
# Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
1986
if ! cmp -s $TMPH config.h; then
1987
        mv -f $TMPH config.h
1988
else
1989
        echo "config.h is unchanged"
1990
fi
1991

    
1992
rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
1993

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

    
2032

    
2033
# build pkg-config files
2034
# FIXME: libdir and includedir are hardcoded and may differ from the real path.
2035

    
2036
pkgconfig_generate(){
2037
name=$1
2038
comment=$2
2039
version=$3
2040
libs=$4
2041
requires=$5
2042
include=$6
2043
cat <<EOF >$name.pc
2044
prefix=$PREFIX
2045
exec_prefix=\${prefix}
2046
libdir=\${exec_prefix}/lib
2047
includedir=\${prefix}/include
2048

    
2049
Name: $name
2050
Description: $comment
2051
Version: $version
2052
Requires: $requires
2053
Conflicts:
2054
Libs: -L\${libdir} $libs
2055
Cflags: -I\${includedir} -I\${includedir}/$include
2056
EOF
2057
}
2058

    
2059
pkgconfig_generate_uninstalled(){
2060
name=$1
2061
shortname=${name#lib}
2062
comment=$2
2063
version=$3
2064
libs=$4
2065
requires=$5
2066
cat <<EOF >$name-uninstalled.pc
2067
prefix=
2068
exec_prefix=
2069
libdir=\${pcfiledir}/$name
2070
includedir=\${pcfiledir}/$name
2071

    
2072
Name: $name
2073
Description: $comment
2074
Version: $version
2075
Requires: $requires
2076
Conflicts:
2077
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
2078
Cflags: -I\${includedir}
2079
EOF
2080
}
2081

    
2082
pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
2083
pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
2084

    
2085
pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
2086
pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
2087

    
2088
pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2089
pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
2090

    
2091
if enabled pp; then
2092
  pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
2093
  pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
2094
fi
2095

    
2096
if enabled swscaler; then
2097
  pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" -lswscale "libavutil = $lavu_version" ffmpeg
2098
  pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
2099
else
2100
  pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2101
  pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
2102
  apply libswscale.pc sed s/^Libs:.*$/Libs:/
2103
  apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
2104
fi