Statistics
| Branch: | Revision:

ffmpeg / configure @ 7506d47a

History | View | Annotate | Download (57.7 KB)

1 aeb29222 Måns Rullgård
#!/bin/sh
2 0f3cb305 Fabrice Bellard
#
3 f57620d5 Måns Rullgård
# 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 0f3cb305 Fabrice Bellard
#
9 cf9d24ad Dan Christiansen
10 cde2d79a Måns Rullgård
# make sure we are running under a compatible shell
11 c21d6325 Måns Rullgård
# try to make this part work with most shells
12
13
try_exec(){
14 0dbe81bb Måns Rullgård
    echo "Trying shell $1"
15 c21d6325 Måns Rullgård
    type "$1" >/dev/null 2>&1 && exec "$@"
16
}
17
18 5237ce67 Måns Rullgård
unset foo
19 0dbe81bb Måns Rullgård
(: ${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 c21d6325 Måns Rullgård
    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 cde2d79a Måns Rullgård
    fi
40
    echo "No compatible shell script interpreter found."
41 fc53da20 Diego Biurrun
    echo "This configure script requires a POSIX-compatible shell"
42 c21d6325 Måns Rullgård
    echo "such as bash or ksh."
43 505dfb09 Diego Biurrun
    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 c21d6325 Måns Rullgård
    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 cde2d79a Måns Rullgård
    exit 1
51
fi
52
53 74c53c2d Måns Rullgård
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 2ba042a7 Måns Rullgård
  echo "  --log[=FILE|yes|no]      log tests and output to FILE [config.err]"
60 2266e085 Diego Biurrun
  echo "  --prefix=PREFIX          install in PREFIX [$PREFIX]"
61 74c53c2d Måns Rullgård
  echo "  --libdir=DIR             install libs in DIR [PREFIX/lib]"
62 84c22efd Diego Biurrun
  echo "  --shlibdir=DIR           install shared libs in DIR [PREFIX/lib]"
63 74c53c2d Måns Rullgård
  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 0a622b98 Måns Rullgård
  echo "  --enable-gpl             allow use of GPL code, the resulting libav*"
70
  echo "                           and ffmpeg will be under GPL [default=no]"
71 dc922953 Diego Biurrun
  echo "  --enable-pp              enable GPLed postprocessing support [default=no]"
72
  echo "  --enable-swscaler        software scaler support [default=no]"
73 e5f94c2b Ramiro Polla
  echo "  --enable-beosthreads     use BeOS threads [default=no]"
74 74c53c2d Måns Rullgård
  echo "  --enable-pthreads        use pthreads [default=no]"
75 eb113804 Diego Biurrun
  echo "  --enable-w32threads      use Win32 threads [default=no]"
76 56a059ac Diego Biurrun
  echo "  --enable-x11grab         enable X11 grabbing [default=no]"
77 0a622b98 Måns Rullgård
  echo
78
  echo "External library support:"
79
  echo "  --enable-sunmlib         use Sun medialib [default=no]"
80 74c53c2d Måns Rullgård
  echo "  --enable-dc1394          enable IIDC-1394 grabbing using libdc1394"
81
  echo "                           and libraw1394 [default=no]"
82 e2745046 Måns Rullgård
  echo "  --enable-liba52          enable GPLed liba52 support [default=no]"
83
  echo "  --enable-liba52bin       open liba52.so.0 at runtime [default=no]"
84 8ac17293 Steve L'Homme
  echo "  --enable-avisynth        allow reading AVISynth script files [default=no]"
85 f5a756ef Diego Biurrun
  echo "  --enable-libamr-nb       enable libamr-nb floating point audio codec"
86
  echo "  --enable-libamr-wb       enable libamr-wb floating point audio codec"
87 e2745046 Måns Rullgård
  echo "  --enable-libfaac         enable FAAC support via libfaac [default=no]"
88
  echo "  --enable-libfaad         enable FAAD support via libfaad [default=no]"
89 06f32b26 Diego Biurrun
  echo "  --enable-libfaadbin      open libfaad.so.0 at runtime [default=no]"
90 dc922953 Diego Biurrun
  echo "  --enable-libgsm          enable GSM support via libgsm [default=no]"
91 e2745046 Måns Rullgård
  echo "  --enable-libmp3lame      enable MP3 encoding via libmp3lame [default=no]"
92 31235134 Diego Biurrun
  echo "  --enable-libnut          enable NUT (de)muxing via libnut,"
93
  echo "                           native demuxer exists [default=no]"
94 ba5fd8c5 Diego Biurrun
  echo "  --enable-libogg          enable Ogg muxing via libogg [default=no]"
95 71757822 Diego Biurrun
  echo "  --enable-libtheora       enable Theora encoding via libtheora [default=no]"
96 e2745046 Måns Rullgård
  echo "  --enable-libvorbis       enable Vorbis en/decoding via libvorbis,"
97 31235134 Diego Biurrun
  echo "                           native implementations exist [default=no]"
98 1cc60c47 Diego Biurrun
  echo "  --enable-libx264         enable H.264 encoding via x264 [default=no]"
99
  echo "  --enable-libxvid         enable Xvid encoding via xvidcore,"
100 31235134 Diego Biurrun
  echo "                           native MPEG-4/Xvid encoder exists [default=no]"
101 74c53c2d Måns Rullgård
  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 fac252f9 Måns Rullgård
  echo "  --cross-compile          assume a cross-compiler is used"
106 abcd6d60 Måns Rullgård
  echo "  --target-os=OS           compiler targets OS [$targetos]"
107 74c53c2d Måns Rullgård
  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 cc6a90dd Guillaume Poirier
  echo "  --arch=ARCH              select architecture  [$arch]"
114 7c758d33 Diego Biurrun
  echo "  --cpu=CPU                selects the minimum cpu required (affects"
115
  echo "                           instruction selection, may crash on older CPUs)"
116 2b4c3615 Måns Rullgård
  echo "  --enable-powerpc-perf    enable performance report on PPC"
117 74c53c2d Måns Rullgård
  echo "                           (requires enabling PMC)"
118
  echo "  --disable-mmx            disable MMX usage"
119 1839e854 Siarhei Siamashka
  echo "  --disable-armv5te        disable armv5te usage"
120 edab3048 Måns Rullgård
  echo "  --disable-armv6          disable armv6 usage"
121 74c53c2d Måns Rullgård
  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 0c7bb0e5 Luca Barbato
  echo "  --disable-ipv6           disable ipv6 support [default=no]"
131 74c53c2d Måns Rullgård
  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 cde9e780 Michael Niedermayer
  echo "  --enable-gray            enable full grayscale support (slower color)"
137 786b30af Diego Biurrun
  echo "  --disable-ffmpeg         disable ffmpeg build"
138 74c53c2d Måns Rullgård
  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 "  --disable-encoder=NAME   disables encoder NAME"
143
  echo "  --enable-encoder=NAME    enables encoder NAME"
144
  echo "  --disable-decoder=NAME   disables decoder NAME"
145
  echo "  --enable-decoder=NAME    enables decoder NAME"
146
  echo "  --disable-encoders       disables all encoders"
147
  echo "  --disable-decoders       disables all decoders"
148 ff70e601 Måns Rullgård
  echo "  --disable-muxer=NAME     disables muxer NAME"
149
  echo "  --enable-muxer=NAME      enables muxer NAME"
150 74c53c2d Måns Rullgård
  echo "  --disable-muxers         disables all muxers"
151 ff70e601 Måns Rullgård
  echo "  --disable-demuxer=NAME   disables demuxer NAME"
152
  echo "  --enable-demuxer=NAME    enables demuxer NAME"
153 74c53c2d Måns Rullgård
  echo "  --disable-demuxers       disables all demuxers"
154 af9e7d18 Måns Rullgård
  echo "  --enable-parser=NAME     enables parser NAME"
155
  echo "  --disable-parser=NAME    disables parser NAME"
156
  echo "  --disable-parsers        disables all parsers"
157 cd61e407 Jason Millard
  echo "  --enable-bsf=NAME        enables bitstream filter NAME"
158
  echo "  --disable-bsf=NAME       disables bitstream filter NAME"
159
  echo "  --disable-bsfs           disables all bitstream filters"
160 c08fb000 Alex Beregszaszi
  echo "  --enable-protocol=NAME   enables protocol NAME"
161
  echo "  --disable-protocol=NAME  disables protocol NAME"
162
  echo "  --disable-protocols      disables all protocols"
163 794f8e97 Panagiotis Issaris
  echo "  --list-decoders          show all available decoders"
164
  echo "  --list-encoders          show all available encoders"
165
  echo "  --list-muxers            show all available muxers"
166
  echo "  --list-demuxers          show all available demuxers"
167
  echo "  --list-parsers           show all available parsers"
168
  echo "  --list-protocols         show all available protocols"
169
  echo "  --list-bsfs              show all available bitstream filters"
170 0a622b98 Måns Rullgård
  echo
171
  echo "Developer options (useful when working on FFmpeg itself):"
172
  echo "  --enable-gprof           enable profiling with gprof [$gprof]"
173
  echo "  --disable-opts           disable compiler optimizations"
174
  echo "  --enable-extra-warnings  enable more compiler warnings"
175
  echo "  --disable-strip          disable stripping of executables and shared libraries"
176 74c53c2d Måns Rullgård
  echo ""
177
  echo "NOTE: Object files are built at the place where configure is launched."
178
  exit 1
179
}
180 cf9d24ad Dan Christiansen
181 57bd82d4 Måns Rullgård
log(){
182
    echo "$@" >>$logfile
183
}
184
185 720c69da Måns Rullgård
log_file(){
186 c8e9f801 Måns Rullgård
    log BEGIN $1
187
    cat -n $1 >>$logfile
188
    log END $1
189
}
190
191 2ba042a7 Måns Rullgård
echolog(){
192 c8e9f801 Måns Rullgård
    log "$@"
193 57bd82d4 Måns Rullgård
    echo "$@"
194 2ba042a7 Måns Rullgård
}
195
196
die(){
197
    echolog "$@"
198
    cat <<EOF
199
If you think configure made a mistake, make sure you are using the latest
200
version from SVN.  If the latest version fails, report the problem to the
201
ffmpeg-devel@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
202
EOF
203 720c69da Måns Rullgård
    if enabled logging; then
204 2ba042a7 Måns Rullgård
        cat <<EOF
205
Include the log file "$logfile" produced by configure as this will help
206
solving the problem.
207
EOF
208
    else
209
cat <<EOF
210
Rerun configure with logging enabled (do not use --log=no), and include the
211
log this produces with your report.
212
EOF
213
    fi
214 57bd82d4 Måns Rullgård
    rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
215
    exit 1
216
}
217
218 904e48f1 Måns Rullgård
# "tr '[a-z]' '[A-Z]'" is a workaround for Solaris tr not grokking "tr a-z A-Z"
219 44161118 Måns Rullgård
toupper(){
220
    echo "$@" | tr '[a-z]' '[A-Z]'
221
}
222
223 4a5444db Måns Rullgård
tolower(){
224
    echo "$@" | tr '[A-Z]' '[a-z]'
225
}
226
227 a8d04fba Måns Rullgård
set_all(){
228
    value=$1
229
    shift
230
    for var in $*; do
231
        eval $var=$value
232
    done
233
}
234
235 799c9e9b Måns Rullgård
pushvar(){
236
    for var in $*; do
237
        eval level=\${${var}_level:=0}
238
        eval ${var}_${level}="\$$var"
239
        eval ${var}_level=$(($level+1))
240
    done
241
}
242
243
popvar(){
244
    for var in $*; do
245
        eval level=\${${var}_level:-0}
246
        test $level = 0 && continue
247
        eval level=$(($level-1))
248
        eval $var="\${${var}_${level}}"
249
        eval ${var}_level=$level
250
        eval unset ${var}_${level}
251
    done
252
}
253
254 a8d04fba Måns Rullgård
enable(){
255
    set_all yes $*
256
}
257
258
disable(){
259
    set_all no $*
260
}
261
262 57bd82d4 Måns Rullgård
enabled(){
263 44161118 Måns Rullgård
    eval test "x\$$1" = "xyes"
264
}
265
266 37970ebf Ramiro Polla
disabled(){
267
    eval test "x\$$1" = "xno"
268
}
269
270 44161118 Måns Rullgård
enabled_all(){
271
    for opt; do
272
        enabled $opt || return 1
273
    done
274
}
275
276 85bca2c5 Diego Biurrun
disabled_all(){
277
    for opt; do
278
        disabled $opt || return 1
279
    done
280
}
281
282 44161118 Måns Rullgård
enabled_any(){
283
    for opt; do
284
        enabled $opt && return 0
285
    done
286
}
287
288 85bca2c5 Diego Biurrun
disabled_any(){
289
    for opt; do
290
        disabled $opt && return 0
291
    done
292
}
293
294 4a0d6686 Aurelien Jacobs
is_in(){
295
    value=$1
296
    shift
297
    for var in $*; do
298
        [ $var = $value ] && return 0
299
    done
300
    return 1
301
}
302
303 30fd06be Måns Rullgård
check_deps(){
304
    for cfg; do
305 799c9e9b Måns Rullgård
        enabled ${cfg}_checking && die "Circular dependency for $cfg."
306
        disabled ${cfg}_checking && continue
307
        enable ${cfg}_checking
308
309 30fd06be Måns Rullgård
        eval dep_all="\$${cfg}_deps"
310
        eval dep_any="\$${cfg}_deps_any"
311 799c9e9b Måns Rullgård
312
        pushvar cfg dep_all dep_any
313
        check_deps $dep_all $dep_any
314
        popvar cfg dep_all dep_any
315
316 30fd06be Måns Rullgård
        enabled_all $dep_all || disable $cfg
317
        enabled_any $dep_any || disable $cfg
318 799c9e9b Måns Rullgård
319
        disable ${cfg}_checking
320 30fd06be Måns Rullgård
    done
321
}
322
323 44161118 Måns Rullgård
print_config(){
324
    pfx=$1
325
    header=$2
326
    makefile=$3
327
    shift 3
328
    for cfg; do
329 3d907e22 Måns Rullgård
        ucname="`toupper $cfg`"
330 44161118 Måns Rullgård
        if enabled $cfg; then
331 3d907e22 Måns Rullgård
            echo "#define ${pfx}${ucname} 1" >> $header
332
            echo "#define ENABLE_${ucname} 1" >> $header
333
            echo "${pfx}${ucname}=yes" >> $makefile
334
        else
335
            echo "#define ENABLE_${ucname} 0" >> $header
336 44161118 Måns Rullgård
        fi
337
    done
338 57bd82d4 Måns Rullgård
}
339
340
flags_saved(){
341
    (: ${SAVE_CFLAGS?}) 2>/dev/null
342
}
343
344 dcd479c0 Måns Rullgård
save_flags(){
345 57bd82d4 Måns Rullgård
    flags_saved && return
346 dcd479c0 Måns Rullgård
    SAVE_CFLAGS="$CFLAGS"
347
    SAVE_LDFLAGS="$LDFLAGS"
348
    SAVE_extralibs="$extralibs"
349
}
350
351
restore_flags(){
352 f5d28d10 Måns Rullgård
    flags_saved || return
353 dcd479c0 Måns Rullgård
    CFLAGS="$SAVE_CFLAGS"
354
    LDFLAGS="$SAVE_LDFLAGS"
355
    extralibs="$SAVE_extralibs"
356
    unset SAVE_CFLAGS
357
    unset SAVE_LDFLAGS
358
    unset SAVE_extralibs
359
}
360
361
temp_cflags(){
362
    save_flags
363
    CFLAGS="$CFLAGS $*"
364
}
365
366
temp_ldflags(){
367
    save_flags
368
    LDFLAGS="$LDFLAGS $*"
369
}
370
371
temp_extralibs(){
372
    save_flags
373
    extralibs="$extralibs $*"
374
}
375
376 57bd82d4 Måns Rullgård
append(){
377
    var=$1
378
    shift
379
    flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
380
    eval "$var=\"\$$var $*\""
381
}
382
383
add_cflags(){
384
    append CFLAGS "$@"
385
}
386
387
add_ldflags(){
388
    append LDFLAGS "$@"
389
}
390
391
add_extralibs(){
392
    append extralibs "$@"
393
}
394
395 b0cfb663 Måns Rullgård
check_cmd(){
396 b3cb5d51 Måns Rullgård
    log "$@"
397 9b4f605c Måns Rullgård
    "$@" >>$logfile 2>&1
398 b0cfb663 Måns Rullgård
}
399
400 dcd479c0 Måns Rullgård
check_cc(){
401 57bd82d4 Måns Rullgård
    log check_cc "$@"
402
    cat >$TMPC
403 720c69da Måns Rullgård
    log_file $TMPC
404 b0cfb663 Måns Rullgård
    check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
405 57bd82d4 Måns Rullgård
}
406
407
check_cpp(){
408
    log check_cpp "$@"
409 dcd479c0 Måns Rullgård
    cat >$TMPC
410 720c69da Måns Rullgård
    log_file $TMPC
411 b0cfb663 Måns Rullgård
    check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
412 dcd479c0 Måns Rullgård
}
413
414
check_ld(){
415 57bd82d4 Måns Rullgård
    log check_ld "$@"
416 0607887f Måns Rullgård
    check_cc || return
417 3155a644 Måns Rullgård
    flags=''
418
    libs=''
419
    for f; do
420
        test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
421
    done
422
    check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
423 dcd479c0 Måns Rullgård
}
424
425
check_cflags(){
426 57bd82d4 Måns Rullgård
    log check_cflags "$@"
427
    check_cc "$@" <<EOF && add_cflags "$@"
428 dcd479c0 Måns Rullgård
int x;
429
EOF
430
}
431
432
check_ldflags(){
433 57bd82d4 Måns Rullgård
    log check_ldflags "$@"
434
    check_ld "$@" <<EOF && add_ldflags "$@"
435
int main(){
436
    return 0;
437
}
438 dcd479c0 Måns Rullgård
EOF
439
}
440
441
check_header(){
442 57bd82d4 Måns Rullgård
    log check_header "$@"
443 dcd479c0 Måns Rullgård
    header=$1
444
    shift
445 d8bc5f06 Måns Rullgård
    var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
446
    disable $var
447
    check_cpp "$@" <<EOF && enable $var
448 dcd479c0 Måns Rullgård
#include <$header>
449
int x;
450
EOF
451
}
452
453
check_func(){
454 57bd82d4 Måns Rullgård
    log check_func "$@"
455 dcd479c0 Måns Rullgård
    func=$1
456
    shift
457 d8bc5f06 Måns Rullgård
    disable $func
458
    check_ld "$@" <<EOF && enable $func
459 dcd479c0 Måns Rullgård
extern int $func();
460
int main(){
461
    $func();
462
}
463
EOF
464
}
465
466 f8d7b072 Måns Rullgård
check_func2(){
467
    log check_func2 "$@"
468
    headers=$1
469
    func=$2
470
    shift 2
471
    disable $func
472
    incs=""
473
    for hdr in $headers; do
474
        incs="$incs
475
#include <$hdr>"
476
    done
477
    check_ld "$@" <<EOF && enable $func
478
$incs
479
int main(){
480
    (void) $func;
481
    return 0;
482
}
483
EOF
484
}
485
486 57bd82d4 Måns Rullgård
check_lib(){
487
    log check_lib "$@"
488
    header="$1"
489
    func="$2"
490
    shift 2
491 fcfcde17 Måns Rullgård
    temp_extralibs "$@"
492
    check_header $header && check_func $func && add_extralibs "$@"
493
    err=$?
494
    restore_flags
495
    return $err
496 57bd82d4 Måns Rullgård
}
497
498 f8d7b072 Måns Rullgård
check_lib2(){
499
    log check_lib2 "$@"
500
    headers="$1"
501
    func="$2"
502
    shift 2
503
    temp_extralibs "$@"
504
    check_func2 "$headers" $func && add_extralibs "$@"
505
    err=$?
506
    restore_flags
507
    return $err
508
}
509
510 dcd479c0 Måns Rullgård
check_exec(){
511 90be59ef Ramiro Polla
    check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
512 57bd82d4 Måns Rullgård
}
513
514 7dfef245 Måns Rullgård
check_exec_crash(){
515
    code=`cat`
516
517
    # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
518
    # are safe but may not be available everywhere.  Thus we use
519
    # raise(SIGTERM) instead.  The check is run in a subshell so we
520
    # can redirect the "Terminated" message from the shell.  SIGBUS
521
    # is not defined by standard C so it is used conditionally.
522
523
    (check_exec "$@") >>$logfile 2>&1 <<EOF
524
#include <signal.h>
525
static void sighandler(int sig){
526
    raise(SIGTERM);
527
}
528
int main(){
529
    signal(SIGILL, sighandler);
530
    signal(SIGFPE, sighandler);
531
    signal(SIGSEGV, sighandler);
532
#ifdef SIGBUS
533
    signal(SIGBUS, sighandler);
534
#endif
535
    { $code }
536
}
537
EOF
538
}
539
540 57bd82d4 Måns Rullgård
require(){
541
    name="$1"
542
    header="$2"
543
    func="$3"
544
    shift 3
545
    check_lib $header $func "$@" || die "ERROR: $name not found"
546 dcd479c0 Måns Rullgård
}
547
548 f8d7b072 Måns Rullgård
require2(){
549
    name="$1"
550
    headers="$2"
551
    func="$3"
552
    shift 3
553
    check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
554
}
555
556 eea50282 Måns Rullgård
check_foo_config(){
557
    cfg=$1
558
    pkg=$2
559
    header=$3
560
    func=$4
561
    shift 4
562
    disable $cfg
563
    check_cmd ${pkg}-config --version
564
    err=$?
565
    if test "$err" = 0; then
566
        temp_cflags `${pkg}-config --cflags`
567
        temp_extralibs `${pkg}-config --libs`
568
        check_lib "$@" $header $func && enable $cfg
569
    fi
570
    return $err
571
}
572
573 c505dd31 Måns Rullgård
apply(){
574
    file=$1
575
    shift
576
    "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
577
}
578
579 4a0d6686 Aurelien Jacobs
COMPONENT_LIST="
580
    bsfs
581
    decoders
582
    demuxers
583
    encoders
584
    muxers
585
    parsers
586
    protocols
587
"
588
589
CONFIG_LIST="
590
    $COMPONENT_LIST
591 c88f5d72 Måns Rullgård
    audio_beos
592
    audio_oss
593
    avisynth
594
    beos_netserver
595
    bktr
596
    dc1394
597
    dv1394
598
    ffmpeg
599
    ffplay
600
    ffserver
601
    gpl
602 ecfc4f44 Måns Rullgård
    gprof
603 d8d0d0b2 Michael Niedermayer
    gray
604 c88f5d72 Måns Rullgård
    ipv6
605 7bc5f2a8 Diego Biurrun
    liba52
606 f8904fd9 Diego Biurrun
    liba52bin
607 f5a756ef Diego Biurrun
    libamr
608
    libamr_nb
609
    libamr_wb
610 2eed5a46 Diego Biurrun
    libfaac
611
    libfaad
612
    libfaadbin
613 c88f5d72 Måns Rullgård
    libgsm
614 6ebe07fb Diego Biurrun
    libmp3lame
615 c88f5d72 Måns Rullgård
    libnut
616
    libogg
617 150d2772 Diego Biurrun
    libtheora
618 c88f5d72 Måns Rullgård
    libvorbis
619 1cc60c47 Diego Biurrun
    libx264
620
    libxvid
621 c88f5d72 Måns Rullgård
    memalign_hack
622
    mpegaudio_hp
623
    network
624 2b4c3615 Måns Rullgård
    powerpc_perf
625 c88f5d72 Måns Rullgård
    pp
626 bd2216e4 Måns Rullgård
    small
627 c88f5d72 Måns Rullgård
    swscaler
628
    vhook
629 afde41b4 Måns Rullgård
    v4l
630
    v4l2
631 56a059ac Diego Biurrun
    x11grab
632 c88f5d72 Måns Rullgård
    zlib
633 4a0d6686 Aurelien Jacobs
"
634 c88f5d72 Måns Rullgård
635 8eee7025 Diego Biurrun
THREADS_LIST='
636
    beosthreads
637
    pthreads
638
    w32threads
639
'
640
641 3f5b56e5 Måns Rullgård
ARCH_LIST='
642
    alpha
643
    armv4l
644
    bfin
645
    ia64
646
    m68k
647
    mips
648
    parisc
649
    powerpc
650
    s390
651
    sh4
652
    sparc
653
    sparc64
654
    x86
655
    x86_32
656
    x86_64
657
'
658
659
ARCH_EXT_LIST='
660 1ac9331a Måns Rullgård
    altivec
661
    armv5te
662 edab3048 Måns Rullgård
    armv6
663 3f5b56e5 Måns Rullgård
    iwmmxt
664
    mmi
665
    mmx
666 9eeed841 Måns Rullgård
    ssse3
667 3f5b56e5 Måns Rullgård
'
668
669
HAVE_LIST="
670
    $ARCH_EXT_LIST
671
    $THREADS_LIST
672
    altivec_h
673 c9fdab0d François Revol
    arpa_inet_h
674 c88f5d72 Måns Rullgård
    byteswap_h
675 ecf97f22 Alex Beregszaszi
    closesocket
676 1ac9331a Måns Rullgård
    cmov
677 e16e49ac Ramiro Polla
    conio_h
678 c88f5d72 Måns Rullgård
    dcbzl
679 f8aa696f Diego Biurrun
    dev_bktr_ioctl_bt848_h
680
    dev_bktr_ioctl_meteor_h
681
    dev_ic_bt8xx_h
682
    dev_video_meteor_ioctl_meteor_h
683
    dev_video_bktr_ioctl_bt848_h
684 18b67ae5 Måns Rullgård
    dlfcn_h
685 c88f5d72 Måns Rullgård
    dlopen
686 245626d0 Diego Biurrun
    ebp_available
687
    ebx_available
688 c2a29455 Aurelien Jacobs
    fast_64bit
689 7073e9fc Måns Rullgård
    fast_cmov
690 7b829d2a Ramiro Polla
    fast_unaligned
691 9d99cc5a Måns Rullgård
    fork
692 c88f5d72 Måns Rullgård
    freetype2
693 da9e86f8 Roman Shaposhnik
    gethrtime
694 4e68cb8a Roman Shaposhnik
    GetProcessTimes
695 66be5b45 Ramiro Polla
    getrusage
696 c88f5d72 Måns Rullgård
    imlib2
697 2e1913b1 Måns Rullgård
    inet_aton
698 c88f5d72 Måns Rullgård
    lrintf
699 f8aa696f Diego Biurrun
    machine_ioctl_bt848_h
700
    machine_ioctl_meteor_h
701 c88f5d72 Måns Rullgård
    malloc_h
702
    memalign
703 6ffa87d3 Ramiro Polla
    mkstemp
704 c88f5d72 Måns Rullgård
    mlib
705 9cafbd6c Måns Rullgård
    ppc64
706 c88f5d72 Måns Rullgård
    sdl
707
    sdl_video_size
708 deb29777 Måns Rullgård
    soundcard_h
709 b0c858d8 François Revol
    sys_poll_h
710 deb29777 Måns Rullgård
    sys_soundcard_h
711 e16e49ac Ramiro Polla
    termios_h
712 b265431e Måns Rullgård
    threads
713 6ff3f3e7 Ramiro Polla
    winsock2_h
714 0cb78cef Diego Biurrun
"
715 44161118 Måns Rullgård
716 520cc7f1 Måns Rullgård
CMDLINE_SELECT="
717 3f5b56e5 Måns Rullgård
    $ARCH_EXT_LIST
718 520cc7f1 Måns Rullgård
    $CONFIG_LIST
719 8eee7025 Diego Biurrun
    $THREADS_LIST
720 520cc7f1 Måns Rullgård
    debug
721
    extra_warnings
722
    shared
723
    static
724
"
725
726 912f3148 Diego Biurrun
# code dependency declarations
727
728 9eeed841 Måns Rullgård
# architecture extensions
729
altivec_deps="powerpc"
730
armv5te_deps="armv4l"
731
armv6_deps="armv4l"
732
iwmmxt_deps="armv4l"
733
mmi_deps="mips"
734
mmx_deps="x86"
735
ssse3_deps="x86"
736
737 912f3148 Diego Biurrun
# decoders / encoders
738 6ea67bbb Justin Ruggles
ac3_decoder_deps="gpl"
739 33a0dd37 Kostya Shishkov
dxa_decoder_deps="zlib"
740 30fd06be Måns Rullgård
flashsv_decoder_deps="zlib"
741 773be23a Aurelien Jacobs
flashsv_encoder_deps="zlib"
742 4a815a7f Diego Biurrun
flv_decoder_deps="h263_decoder"
743 df495dbd Aurelien Jacobs
h263_decoder_deps="h263_parser mpeg4video_parser"
744 4a815a7f Diego Biurrun
h263i_decoder_deps="h263_decoder"
745 26b4fe82 Aurelien Jacobs
h264_decoder_deps="h264_parser"
746 30fd06be Måns Rullgård
mpeg_xvmc_decoder_deps="xvmc"
747 4a815a7f Diego Biurrun
mpeg4_decoder_deps="h263_decoder"
748
msmpeg4v1_decoder_deps="h263_decoder"
749
msmpeg4v2_decoder_deps="h263_decoder"
750
msmpeg4v3_decoder_deps="h263_decoder"
751 30fd06be Måns Rullgård
png_decoder_deps="zlib"
752
png_encoder_deps="zlib"
753 e2525c6f Aurelien Jacobs
svq3_decoder_deps="h264_parser"
754 4a815a7f Diego Biurrun
vc1_decoder_deps="h263_decoder"
755
wmv1_decoder_deps="h263_decoder"
756
wmv2_decoder_deps="h263_decoder"
757
wmv3_decoder_deps="h263_decoder"
758 30fd06be Måns Rullgård
zmbv_decoder_deps="zlib"
759
zmbv_encoder_deps="zlib"
760
761 912f3148 Diego Biurrun
# external libraries
762 30fd06be Måns Rullgård
mpeg4aac_decoder_deps="libfaad"
763 7bc5f2a8 Diego Biurrun
liba52_decoder_deps="liba52"
764 f5a756ef Diego Biurrun
libamr_nb_decoder_deps="libamr_nb"
765
libamr_nb_encoder_deps="libamr_nb"
766
libamr_wb_decoder_deps="libamr_wb"
767
libamr_wb_encoder_deps="libamr_wb"
768 c9171a83 Diego Biurrun
libfaac_encoder_deps="libfaac"
769 69ddbd1d Diego Biurrun
libfaad_decoder_deps="libfaad"
770 299c77d5 Måns Rullgård
libgsm_decoder_deps="libgsm"
771
libgsm_encoder_deps="libgsm"
772 8ffed8d8 Måns Rullgård
libgsm_ms_decoder_deps="libgsm"
773
libgsm_ms_encoder_deps="libgsm"
774 1cc60c47 Diego Biurrun
libmp3lame_encoder_deps="libmp3lame"
775 150d2772 Diego Biurrun
libtheora_encoder_deps="libtheora"
776 b0caf888 Diego Biurrun
libvorbis_decoder_deps="libvorbis"
777
libvorbis_encoder_deps="libvorbis"
778 1cc60c47 Diego Biurrun
libx264_encoder_deps="libx264"
779
libxvid_encoder_deps="libxvid"
780 30fd06be Måns Rullgård
781 912f3148 Diego Biurrun
# demuxers / muxers
782 03a76ba9 Diego Biurrun
ac3_demuxer_deps="ac3_parser"
783 30fd06be Måns Rullgård
audio_demuxer_deps_any="audio_oss audio_beos"
784
audio_muxer_deps_any="audio_oss audio_beos"
785
dc1394_demuxer_deps="dc1394"
786
dv1394_demuxer_deps="dv1394"
787 d7c59247 Diego Biurrun
libnut_demuxer_deps="libnut"
788
libnut_muxer_deps="libnut"
789 4bd8e17c Aurelien Jacobs
mp3_demuxer_deps="mpegaudio_parser"
790 30fd06be Måns Rullgård
ogg_muxer_deps="libogg"
791
redir_demuxer_deps="network"
792 47b515bf Alex Beregszaszi
rtp_muxer_deps="network mpegts_demuxer"
793 c08fb000 Alex Beregszaszi
rtsp_demuxer_deps="rtp_protocol rtp_muxer"
794
sdp_demuxer_deps="rtsp_demuxer"
795 afde41b4 Måns Rullgård
v4l2_demuxer_deps="v4l2"
796 3af6d5cf Diego Biurrun
video_grab_bktr_demuxer_deps="bktr"
797
video_grab_v4l_demuxer_deps="v4l"
798 30fd06be Måns Rullgård
x11_grab_device_demuxer_deps="x11grab"
799
800 912f3148 Diego Biurrun
# protocols
801 c08fb000 Alex Beregszaszi
http_protocol_deps="network"
802
rtp_protocol_deps="udp_protocol"
803
tcp_protocol_deps="network"
804
udp_protocol_deps="network"
805
806 912f3148 Diego Biurrun
# programs
807 fa859b4d Måns Rullgård
ffplay_deps="sdl"
808 c08fb000 Alex Beregszaszi
ffserver_deps="muxers rtp_protocol"
809 a2830dca Måns Rullgård
810 912f3148 Diego Biurrun
811 0f3cb305 Fabrice Bellard
# set temporary file name
812 57514323 Zdenek Kabelac
if test ! -z "$TMPDIR" ; then
813 0f3cb305 Fabrice Bellard
    TMPDIR1="${TMPDIR}"
814 57514323 Zdenek Kabelac
elif test ! -z "$TEMPDIR" ; then
815 0f3cb305 Fabrice Bellard
    TMPDIR1="${TEMPDIR}"
816 3d204385 Nick Kurshev
else
817 0f3cb305 Fabrice Bellard
    TMPDIR1="/tmp"
818 3d204385 Nick Kurshev
fi
819
820 0f3cb305 Fabrice Bellard
TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
821
TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
822 f3ec2d46 Slavik Gnatenko
TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
823 0f3cb305 Fabrice Bellard
TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
824
TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
825
826 de6d9b64 Fabrice Bellard
# default parameters
827 8a608357 Måns Rullgård
828 720c69da Måns Rullgård
logging="yes"
829 2ba042a7 Måns Rullgård
logfile="config.err"
830 8a608357 Måns Rullgård
831
# installation paths
832 2266e085 Diego Biurrun
PREFIX="/usr/local"
833 c75560ae Diego Biurrun
libdir='$(PREFIX)/lib'
834 84c22efd Diego Biurrun
shlibdir="$libdir"
835 c75560ae Diego Biurrun
incdir='$(PREFIX)/include/ffmpeg'
836
mandir='$(PREFIX)/man'
837
bindir='$(PREFIX)/bin'
838 8a608357 Måns Rullgård
839
# toolchain
840 de6d9b64 Fabrice Bellard
cc="gcc"
841
ar="ar"
842 be7109c1 Michael Niedermayer
ranlib="ranlib"
843 4a908fbc Alex Beregszaszi
make="make"
844 0f3cb305 Fabrice Bellard
strip="strip"
845 8a608357 Måns Rullgård
asmalign_pot="unknown"
846
847
# machine
848 cc6a90dd Guillaume Poirier
arch=`uname -m`
849 38d0a8aa Guillaume Poirier
cpu="generic"
850 8a608357 Måns Rullgård
851
# OS
852 b9663405 Diego Biurrun
targetos=$(tolower $(uname -s))
853 8a608357 Måns Rullgård
854
# non-library system interfaces
855
audio_oss="yes"
856 3eac5c63 Måns Rullgård
bktr="yes"
857 8aa3ee32 Max Krasnyansky
dv1394="yes"
858 afde41b4 Måns Rullgård
v4l2="yes"
859
v4l="yes"
860 8a608357 Måns Rullgård
861
# libraries
862
zlib="yes"
863
864
# configurable options
865 cddf3f45 Glenn Maynard
debug="yes"
866 65d1bea2 Michel Bardiaux
dostrip="yes"
867 8a608357 Måns Rullgård
ffmpeg="yes"
868
ffplay="yes"
869
ffserver="yes"
870
ipv6="yes"
871 5af4e0cc Måns Rullgård
static="yes"
872 1eb2212e Fabrice Bellard
mpegaudio_hp="yes"
873 8a608357 Måns Rullgård
network="yes"
874
optimize="yes"
875
protocols="yes"
876
vhook="default"
877
878
# build settings
879 baa3a937 Måns Rullgård
SHFLAGS='-shared -Wl,-soname,$@'
880 cab3ef82 Diego Biurrun
VHOOKSHFLAGS='$(SHFLAGS)'
881 e240ee67 Luca Barbato
LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
882 c536cb09 Diego Biurrun
FFSERVERLDFLAGS=-Wl,-E
883 f39e56a8 Jacob Meuser
LDCONFIG="ldconfig"
884 f3ec2d46 Slavik Gnatenko
LIBPREF="lib"
885
LIBSUF=".a"
886 4bdd05e7 Diego Biurrun
LIB='$(LIBPREF)$(NAME)$(LIBSUF)'
887 f3ec2d46 Slavik Gnatenko
SLIBPREF="lib"
888
SLIBSUF=".so"
889 4bdd05e7 Diego Biurrun
SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
890 b29bddab Diego Biurrun
SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
891
SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
892 21d0a823 Diego Biurrun
LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIB)"'
893 ef0bc4c9 François Revol
894 c597172e Måns Rullgård
# find source path
895
source_path="`dirname \"$0\"`"
896
source_path_used="yes"
897
if test -z "$source_path" -o "$source_path" = "." ; then
898
    source_path="`pwd`"
899
    source_path_used="no"
900
else
901
    source_path="`cd \"$source_path\"; pwd`"
902
    echo "$source_path" | grep -q '[[:blank:]]' &&
903
      die "Out of tree builds are impossible with whitespace in source path."
904
fi
905
906
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
907
    show_help
908
fi
909
910
FFMPEG_CONFIGURATION="$@"
911
912 facbea95 Aurelien Jacobs
ENCODER_LIST=`sed -n 's/^[^#]*ENC.*(.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
913
DECODER_LIST=`sed -n 's/^[^#]*DEC.*(.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
914
PARSER_LIST=`sed -n 's/^[^#]*PARSER.*(.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
915
BSF_LIST=`sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' "$source_path/libavcodec/allcodecs.c"`
916
MUXER_LIST=`sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
917
DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
918
PROTOCOL_LIST=`sed -n 's/^[^#]*PROTOCOL.*(.*, *\(.*\)).*/\1_protocol/p' "$source_path/libavformat/allformats.c"`
919 c597172e Måns Rullgård
920 cd61e407 Jason Millard
enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST $PROTOCOL_LIST $BSF_LIST
921 d3ea5692 Måns Rullgård
enable $ARCH_EXT_LIST
922 c597172e Måns Rullgård
923
die_unknown(){
924
    echo "Unknown option \"$1\"."
925
    echo "See $0 --help for available options."
926
    exit 1
927
}
928
929 794f8e97 Panagiotis Issaris
show_list() {
930
    for part in $*; do
931
        echo $part | sed 's/_[^_]*$//'
932
    done | sort
933
    exit 0
934
}
935
936 c597172e Måns Rullgård
for opt do
937
  optval="${opt#*=}"
938
  case "$opt" in
939
  --log)
940
  ;;
941
  --log=*) logging="$optval"
942
  ;;
943
  --prefix=*) PREFIX="$optval"
944
  ;;
945
  --libdir=*) libdir="$optval"
946
  ;;
947
  --shlibdir=*) shlibdir="$optval"
948
  ;;
949
  --incdir=*) incdir="$optval"
950
  ;;
951
  --mandir=*) mandir="$optval"
952
  ;;
953
  --source-path=*) source_path="$optval"
954
  ;;
955
  --cross-prefix=*) cross_prefix="$optval"
956
  ;;
957
  --cross-compile) cross_compile="yes"
958
  ;;
959
  --target-os=*) targetos="$optval"
960
  ;;
961
  --cc=*) cc="$optval"
962
  ;;
963
  --make=*) make="$optval"
964
  ;;
965
  --extra-cflags=*) add_cflags "$optval"
966
  ;;
967
  --extra-ldflags=*) add_ldflags "$optval"
968
  ;;
969
  --extra-libs=*) add_extralibs "$optval"
970
  ;;
971
  --build-suffix=*) BUILDSUF="$optval"
972
  ;;
973
  --arch=*) arch="$optval"
974
  ;;
975
  --cpu=*) cpu="$optval"
976
  ;;
977
  --disable-opts) optimize="no"
978
  ;;
979
  --enable-sunmlib) mlib="yes"
980
  ;;
981
  --disable-strip) dostrip="no"
982
  ;;
983
  --disable-encoders) disable $ENCODER_LIST
984
  ;;
985
  --disable-decoders) disable $DECODER_LIST
986
  ;;
987
  --disable-muxers) disable $MUXER_LIST
988
  ;;
989
  --disable-demuxers) disable $DEMUXER_LIST
990
  ;;
991
  --disable-parsers) disable $PARSER_LIST
992
  ;;
993 cd61e407 Jason Millard
  --disable-bsfs) disable $BSF_LIST
994
  ;;
995 c08fb000 Alex Beregszaszi
  --disable-protocols) disable $PROTOCOL_LIST
996
  ;;
997 c597172e Måns Rullgård
  --enable-*=*|--disable-*=*)
998
  eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
999
  case "$thing" in
1000 cd61e407 Jason Millard
      encoder|decoder|muxer|demuxer|parser|bsf|protocol) $action ${optval}_${thing} ;;
1001 c597172e Måns Rullgård
      *) die_unknown "$opt" ;;
1002
  esac
1003
  ;;
1004
  --enable-?*|--disable-?*)
1005
  eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
1006
  echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt
1007
  $action $option
1008
  ;;
1009 794f8e97 Panagiotis Issaris
  --list-*)
1010
    NAME="${opt#--list-}"
1011 4a0d6686 Aurelien Jacobs
    is_in $NAME $COMPONENT_LIST || die_unknown $opt
1012 794f8e97 Panagiotis Issaris
    NAME=$(toupper ${NAME%s})
1013
    eval show_list \$${NAME}_LIST
1014
  ;;
1015 c597172e Måns Rullgård
  --help) show_help
1016
  ;;
1017
  *)
1018
  die_unknown $opt
1019
  ;;
1020
  esac
1021
done
1022
1023 270739bb Måns Rullgård
case "$arch" in
1024
  i386|i486|i586|i686|i86pc|BePC)
1025
    arch="x86_32"
1026 7b829d2a Ramiro Polla
    enable fast_unaligned
1027 270739bb Måns Rullgård
  ;;
1028
  x86_64|amd64)
1029
    arch="x86_32"
1030 7b829d2a Ramiro Polla
    enable fast_unaligned
1031 270739bb Måns Rullgård
    canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
1032
    if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
1033
      if [ -z "`echo $CFLAGS | grep -- -m32`"  ]; then
1034
        arch="x86_64"
1035 c2a29455 Aurelien Jacobs
        enable fast_64bit
1036 270739bb Måns Rullgård
      fi
1037
    fi
1038
  ;;
1039
  # armv4l is a subset of armv[567]*l
1040
  arm|armv[4567]*l)
1041
    arch="armv4l"
1042
  ;;
1043
  alpha)
1044
    arch="alpha"
1045 c2a29455 Aurelien Jacobs
    enable fast_64bit
1046 270739bb Måns Rullgård
  ;;
1047 c2a29455 Aurelien Jacobs
  "Power Macintosh"|ppc|powerpc)
1048 270739bb Måns Rullgård
    arch="powerpc"
1049
  ;;
1050 c2a29455 Aurelien Jacobs
  ppc64)
1051
    arch="powerpc"
1052
    enable fast_64bit
1053
  ;;
1054 270739bb Måns Rullgård
  mips|mipsel|IP*)
1055
    arch="mips"
1056
  ;;
1057
  sun4u|sparc64)
1058
    arch="sparc64"
1059 c2a29455 Aurelien Jacobs
    enable fast_64bit
1060 270739bb Måns Rullgård
  ;;
1061
  sparc)
1062
    arch="sparc"
1063
  ;;
1064
  sh4)
1065
    arch="sh4"
1066
  ;;
1067 c2a29455 Aurelien Jacobs
  parisc)
1068
    arch="parisc"
1069
  ;;
1070
  parisc64)
1071 270739bb Måns Rullgård
    arch="parisc"
1072 c2a29455 Aurelien Jacobs
    enable fast_64bit
1073 270739bb Måns Rullgård
  ;;
1074
  s390|s390x)
1075
    arch="s390"
1076
  ;;
1077
  m68k)
1078
    arch="m68k"
1079
  ;;
1080
  ia64)
1081
    arch="ia64"
1082 c2a29455 Aurelien Jacobs
    enable fast_64bit
1083 270739bb Måns Rullgård
  ;;
1084
  bfin)
1085
    arch="bfin"
1086
  ;;
1087
  *)
1088
    arch="unknown"
1089
  ;;
1090
esac
1091
1092 9eeed841 Måns Rullgård
enable $arch
1093
enabled_any x86_32 x86_64 && enable x86
1094
enabled     sparc64       && enable sparc
1095
1096 ef0bc4c9 François Revol
# OS specific
1097 c597172e Måns Rullgård
osextralibs="-lm"
1098 ced75d92 Diego Biurrun
case $targetos in
1099 4a5444db Måns Rullgård
  beos|haiku|zeta)
1100 74cec57d François Revol
    PREFIX="$HOME/config"
1101 d474299a Måns Rullgård
    # helps building libavcodec
1102
    add_cflags "-DPIC -fomit-frame-pointer"
1103
    # 3 gcc releases known for BeOS, each with ugly bugs
1104
    gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1105
    case "$gcc_version" in
1106
      2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1107
        mmx="no"
1108
        ;;
1109
      *20010315*) echo "BeBits gcc"
1110
        add_cflags "-fno-expensive-optimizations"
1111
        ;;
1112
    esac
1113 74cec57d François Revol
    LDCONFIG="echo ignoring ldconfig"
1114 d474299a Måns Rullgård
    SHFLAGS=-nostart
1115
    # disable Linux things
1116
    dv1394="no"
1117
    # enable BeOS things
1118 c597172e Måns Rullgård
    disabled audio_beos || enable_audio_beos
1119 d474299a Måns Rullgård
    # no need for libm, but the inet stuff
1120
    # Check for BONE
1121 74cec57d François Revol
    # XXX: actually should check for NOT net_server
1122 d474299a Måns Rullgård
    if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
1123 c597172e Måns Rullgård
        osextralibs="-lbind -lsocket"
1124 d474299a Måns Rullgård
    else
1125
        beos_netserver="yes"
1126 c597172e Måns Rullgård
        osextralibs="-lnet"
1127 d474299a Måns Rullgård
    fi ;;
1128 4a5444db Måns Rullgård
  sunos)
1129 d474299a Måns Rullgård
    dv1394="no"
1130
    FFSERVERLDFLAGS=""
1131
    SHFLAGS="-shared -Wl,-h,\$@"
1132
    add_extralibs "-lsocket -lnsl"
1133
    ;;
1134 4a5444db Måns Rullgård
  netbsd)
1135 d474299a Måns Rullgård
    dv1394="no"
1136
    add_extralibs "-lossaudio"
1137
    ;;
1138 4a5444db Måns Rullgård
  openbsd)
1139 d474299a Måns Rullgård
    dv1394="no"
1140
    need_memalign="no"
1141
    LIBOBJFLAGS="\$(PIC)"
1142 21d0a823 Diego Biurrun
    LDCONFIG="ldconfig -m \$(SHLIBDIR)"
1143 d474299a Måns Rullgård
    SHFLAGS='-shared'
1144
    SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF).$(LIBVERSION)'
1145
    SLIBNAME_WITH_VERSION='$(SLIBNAME)'
1146
    SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
1147
    add_extralibs "-lossaudio"
1148
    ;;
1149 4a5444db Måns Rullgård
  freebsd)
1150 d474299a Måns Rullgård
    dv1394="no"
1151
    need_memalign="no"
1152
    add_cflags "-pthread"
1153
    ;;
1154 4a5444db Måns Rullgård
  gnu/kfreebsd)
1155 d474299a Måns Rullgård
    dv1394="no"
1156
    add_cflags "-pthread"
1157
    ;;
1158 4a5444db Måns Rullgård
  bsd/os)
1159 d474299a Måns Rullgård
    dv1394="no"
1160 c597172e Måns Rullgård
    osextralibs="-lpoll -lgnugetopt -lm"
1161 d474299a Måns Rullgård
    strip="strip -d"
1162
    ;;
1163 4a5444db Måns Rullgård
  darwin)
1164 d474299a Måns Rullgård
    dv1394="no"
1165
    need_memalign="no"
1166 21d0a823 Diego Biurrun
    SHFLAGS="-dynamiclib -Wl,-single_module -Wl,-install_name,\$(SHLIBDIR)/\$(SLIBNAME),-current_version,\$(SPPVERSION),-compatibility_version,\$(SPPVERSION) -Wl,-read_only_relocs,suppress"
1167
    VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$@'
1168 c597172e Måns Rullgård
    osextralibs=""
1169 d474299a Måns Rullgård
    strip="strip -x"
1170
    FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1171
    SLIBSUF=".dylib"
1172
    SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
1173
    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
1174
    FFSERVERLDFLAGS=-Wl,-bind_at_load
1175
    ;;
1176 4a5444db Måns Rullgård
  mingw32*)
1177 91c5172d Diego Biurrun
    targetos=mingw32
1178 5880d5b5 Ramiro Polla
    shlibdir="$bindir"
1179 4ec9ec81 Måns Rullgård
    dv1394="no"
1180 70b4d492 Ramiro Polla
    VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1181
    VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1182
    if enabled swscaler; then
1183
        VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1184
        VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1185
    fi
1186 4ec9ec81 Måns Rullgård
    ffserver="no"
1187
    SLIBPREF=""
1188
    SLIBSUF=".dll"
1189
    EXESUF=".exe"
1190
    SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1191
    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
1192
    SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
1193 21d0a823 Diego Biurrun
    SLIB_INSTALL_EXTRA_CMD="-install -m 644 \$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib) \"\$(SHLIBDIR)/\$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib)\""
1194 d205abe9 Zuxy Meng
    SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base"
1195 124bed6f Alex Beregszaszi
    enabled network && add_extralibs -lws2_32
1196 d474299a Måns Rullgård
    ;;
1197 4a5444db Måns Rullgård
  cygwin*)
1198 ced75d92 Diego Biurrun
    targetos=cygwin
1199 d474299a Måns Rullgård
    shlibdir="$bindir"
1200
    dv1394="no"
1201 41d5a86a Víctor Paesa
    VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1202
    VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
1203
    if enabled swscaler; then
1204
        VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1205
        VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1206
    fi
1207 c597172e Måns Rullgård
    osextralibs=""
1208 d474299a Måns Rullgård
    EXESUF=".exe"
1209
    SLIBPREF="cyg"
1210
    SLIBSUF=".dll"
1211
    SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1212
    SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
1213 d205abe9 Zuxy Meng
    SHFLAGS='-shared -Wl,--out-implib=lib$(NAME).dll.a -Wl,--enable-auto-image-base'
1214 d474299a Måns Rullgård
    ;;
1215 4a5444db Måns Rullgård
  linux)
1216 d474299a Måns Rullgård
    LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
1217
    ;;
1218 4a5444db Måns Rullgård
  irix*)
1219 ced75d92 Diego Biurrun
    targetos=irix
1220 d474299a Måns Rullgård
    ranlib="echo ignoring ranlib"
1221
    ;;
1222
  *)
1223
    targetos="${targetos}-UNKNOWN"
1224
    ;;
1225 ef0bc4c9 François Revol
esac
1226 de6d9b64 Fabrice Bellard
1227 c597172e Måns Rullgård
add_extralibs $osextralibs
1228 de6d9b64 Fabrice Bellard
1229 e3c00e34 Diego Biurrun
if ! disabled logging ; then
1230 90be59ef Ramiro Polla
    enabled logging || logfile="$logging"
1231 57bd82d4 Måns Rullgård
    echo "# $0 $@" >$logfile
1232
    set >>$logfile
1233 2ba042a7 Måns Rullgård
else
1234
    logfile=/dev/null
1235 57bd82d4 Måns Rullgård
fi
1236 e89b8b0a Diego Biurrun
1237 28d8e661 Diego Biurrun
# Combine FFLDFLAGS and the LDFLAGS environment variable.
1238
LDFLAGS="$FFLDFLAGS $LDFLAGS"
1239 e89b8b0a Diego Biurrun
1240 fac252f9 Måns Rullgård
test -n "$cross_prefix" && cross_compile=yes
1241 1ea46bed Måns Rullgård
cc="${cross_prefix}${cc}"
1242
ar="${cross_prefix}${ar}"
1243
ranlib="${cross_prefix}${ranlib}"
1244
strip="${cross_prefix}${strip}"
1245
1246 320d060a Diego Biurrun
# we need to build at least one lib type
1247 93b3c083 Måns Rullgård
if ! enabled_any static shared; then
1248 320d060a Diego Biurrun
    cat <<EOF
1249
At least one library type must be built.
1250
Specify --enable-static to build the static libraries or --enable-shared to
1251
build the shared libraries as well. To only build the shared libraries specify
1252
--disable-static in addition to --enable-shared.
1253
EOF
1254
    exit 1;
1255
fi
1256
1257 2a320695 Ramiro Polla
if disabled static; then
1258
    LIB=""
1259
fi
1260
1261 93b3c083 Måns Rullgård
if ! enabled libogg; then
1262 ddf50e4c Ramiro Polla
    enabled libtheora && die "libogg must be enabled to enable libtheora."
1263
    enabled libvorbis && die "libogg must be enabled to enable libvorbis."
1264 5c5dea3f Nilesh Bansal
fi
1265
1266 a2234ceb Ramiro Polla
if enabled_any libfaad libfaadbin ; then
1267
    if check_header faad.h; then
1268
        check_cc << EOF
1269
#include <faad.h>
1270
#ifndef FAAD2_VERSION
1271
ok faad1
1272
#endif
1273
int main( void ) { return 0; }
1274
EOF
1275
        test $? = 0 && enable libfaad2
1276
    else
1277 ff3dac65 Diego Biurrun
        die "FAAD test failed."
1278 a2234ceb Ramiro Polla
    fi
1279
fi
1280
1281
1282 93b3c083 Måns Rullgård
if ! enabled gpl; then
1283 54118497 Ramiro Polla
    die_gpl_disabled(){
1284
        name=$1
1285
        shift
1286
        enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
1287
    }
1288
    die_gpl_disabled "The Postprocessing code" pp
1289 7bc5f2a8 Diego Biurrun
    die_gpl_disabled "liba52"                  liba52
1290 1cc60c47 Diego Biurrun
    die_gpl_disabled "libx264"                 libx264
1291
    die_gpl_disabled "libxvidcore"             libxvid
1292 54118497 Ramiro Polla
    die_gpl_disabled "FAAD2"                   libfaad2
1293
    die_gpl_disabled "The X11 grabber"         x11grab
1294
    die_gpl_disabled "The software scaler"     swscaler
1295 ebb810d9 Ramiro Polla
fi
1296 b2e3c528 Michael Niedermayer
1297 9eeed841 Måns Rullgård
check_deps $ARCH_EXT_LIST
1298 0f3cb305 Fabrice Bellard
1299 5d323602 Måns Rullgård
test -z "$need_memalign" && need_memalign="$mmx"
1300
1301 cf9d24ad Dan Christiansen
#Darwin CC versions
1302 ced75d92 Diego Biurrun
if test $targetos = darwin; then
1303 b2924696 Roman Shaposhnik
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1304 30a3e5d4 Nigel Pearson
        add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
1305 cf9d24ad Dan Christiansen
    else
1306 26c1b3be Diego Biurrun
        add_cflags "-no-cpp-precomp -pipe"
1307
        check_cflags "-force_cpusubtype_ALL"
1308
        check_cflags "-Wno-sign-compare"
1309 7799eeec Diego Biurrun
        disabled shared && add_cflags -mdynamic-no-pic
1310 cf9d24ad Dan Christiansen
    fi
1311 2a1a6b64 Michael Niedermayer
fi
1312
1313 703afd07 Måns Rullgård
disabled optimize || add_cflags -fomit-frame-pointer
1314 cf9d24ad Dan Christiansen
1315 a4adb608 Michael Niedermayer
# Add processor-specific flags
1316 38d0a8aa Guillaume Poirier
if test $cpu != "generic"; then
1317 bc8ec47b Måns Rullgård
    warn_altivec(){
1318
        $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
1319 1658bc4f Diego Biurrun
    }
1320 38d0a8aa Guillaume Poirier
    case $cpu in
1321 bb270c08 Diego Biurrun
        601|ppc601|PowerPC601)
1322 1c5d830c Guillaume Poirier
            add_cflags "-mcpu=601"
1323 bc8ec47b Måns Rullgård
            warn_altivec enabled PPC601
1324 bb270c08 Diego Biurrun
        ;;
1325
        603*|ppc603*|PowerPC603*)
1326 1c5d830c Guillaume Poirier
            add_cflags "-mcpu=603"
1327 bc8ec47b Måns Rullgård
            warn_altivec enabled PPC603
1328 bb270c08 Diego Biurrun
        ;;
1329
        604*|ppc604*|PowerPC604*)
1330 1c5d830c Guillaume Poirier
            add_cflags "-mcpu=604"
1331 bc8ec47b Måns Rullgård
            warn_altivec enabled PPC604
1332 bb270c08 Diego Biurrun
        ;;
1333
        G3|g3|75*|ppc75*|PowerPC75*)
1334 1c5d830c Guillaume Poirier
            add_cflags "-mcpu=750 -mpowerpc-gfxopt"
1335 bc8ec47b Måns Rullgård
            warn_altivec enabled PPC75x
1336 bb270c08 Diego Biurrun
        ;;
1337
        G4|g4|745*|ppc745*|PowerPC745*)
1338 1c5d830c Guillaume Poirier
            add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
1339 bc8ec47b Måns Rullgård
            warn_altivec disabled PPC745x
1340 bb270c08 Diego Biurrun
        ;;
1341
        74*|ppc74*|PowerPC74*)
1342 1c5d830c Guillaume Poirier
            add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
1343 bc8ec47b Måns Rullgård
            warn_altivec disabled PPC74xx
1344 bb270c08 Diego Biurrun
        ;;
1345
        G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
1346 1c5d830c Guillaume Poirier
            add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
1347 bc8ec47b Måns Rullgård
            warn_altivec disabled PPC970
1348 9cafbd6c Måns Rullgård
            enable ppc64
1349 bb270c08 Diego Biurrun
        ;;
1350 e07e357d Luca Barbato
        Cell|CELL|cell)
1351
            add_cflags "-mcpu=cell"
1352
            warn_altivec disabled Cell
1353 9cafbd6c Måns Rullgård
            enable ppc64
1354 e07e357d Luca Barbato
        ;;
1355 e7768fc5 Guillaume Poirier
        # targets that do NOT support conditional mov (cmov)
1356
        i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
1357 38d0a8aa Guillaume Poirier
            add_cflags "-march=$cpu"
1358 e7768fc5 Guillaume Poirier
            cmov="no"
1359
        ;;
1360
        # targets that do support conditional mov (cmov)
1361 416519dd Måns Rullgård
        i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
1362 e7768fc5 Guillaume Poirier
            add_cflags "-march=$cpu"
1363 4c8d81fa Guillaume Poirier
            cmov="yes"
1364 7073e9fc Måns Rullgård
            fast_cmov="yes"
1365 94e4c3a3 Guillaume Poirier
        ;;
1366
        # targets that do support conditional mov but on which it's slow
1367
        pentium4|prescott|nocona)
1368
            add_cflags "-march=$cpu"
1369
            cmov="yes"
1370 7073e9fc Måns Rullgård
            fast_cmov="no"
1371 bb270c08 Diego Biurrun
        ;;
1372 d7b34d08 Diego Biurrun
        sparc64)
1373 1c5d830c Guillaume Poirier
            add_cflags "-mcpu=v9"
1374 d7b34d08 Diego Biurrun
        ;;
1375 8684704b Marc Hoffman
        bf*) #bf531 bf532 bf533 bf561 bf5xx all get this config
1376
            add_cflags "-mfdpic"
1377 846dffeb Diego Biurrun
            add_ldflags "-mfdpic"
1378 8684704b Marc Hoffman
        ;;
1379 bb270c08 Diego Biurrun
        *)
1380 38d0a8aa Guillaume Poirier
        echo "WARNING: Unknown CPU \"$cpu\", ignored."
1381 bb270c08 Diego Biurrun
        ;;
1382 a4adb608 Michael Niedermayer
    esac
1383
fi
1384
1385 412c1562 Måns Rullgård
gnu_make(){
1386
    $1 --version 2>&1 | grep -q GNU
1387
}
1388
1389
if ! gnu_make $make; then
1390
    gnu_make gmake && make=gmake || die "GNU make not found."
1391
fi
1392
1393 be0d52ab Måns Rullgård
# make sure we can execute files in $TMPDIR
1394
cat >$TMPE 2>>$logfile <<EOF
1395
#! /bin/sh
1396
EOF
1397
chmod +x $TMPE >>$logfile 2>&1
1398
if ! $TMPE >>$logfile 2>&1; then
1399
    cat <<EOF
1400
Unable to create and execute files in $TMPDIR1.  Set the TMPDIR environment
1401 68300911 Diego Biurrun
variable to another directory and make sure that $TMPDIR1 is not mounted
1402
noexec.
1403 be0d52ab Måns Rullgård
EOF
1404
    die "Sanity test failed."
1405
fi
1406 0244f743 Måns Rullgård
rm $TMPE
1407 be0d52ab Måns Rullgård
1408 1a268acc Måns Rullgård
# compiler sanity check
1409
check_exec <<EOF
1410
int main(){
1411
    return 0;
1412
}
1413
EOF
1414
if test "$?" != 0; then
1415
    echo "$cc is unable to create an executable file."
1416 93b3c083 Måns Rullgård
    if test -z "$cross_prefix" && ! enabled cross_compile ; then
1417 1a268acc Måns Rullgård
        echo "If $cc is a cross-compiler, use the --cross-compile option."
1418 c7ae6345 Måns Rullgård
        echo "Only do this if you know what cross compiling means."
1419 1a268acc Måns Rullgård
    fi
1420
    die "C compiler test failed."
1421
fi
1422
1423 9eeed841 Måns Rullgård
if enabled x86; then
1424 44965991 Panagiotis Issaris
    # check whether EBP is available on x86
1425
    # As 'i' is stored on the stack, this program will crash
1426
    # if the base pointer is used to access it because the
1427
    # base pointer is cleared in the inline assembly code.
1428 7dfef245 Måns Rullgård
    check_exec_crash <<EOF && enable ebp_available
1429 44965991 Panagiotis Issaris
    volatile int i=0;
1430
    asm volatile (
1431
        "xorl %%ebp, %%ebp"
1432
    ::: "%ebp");
1433
    return i;
1434
EOF
1435
1436
    # check wether EBX is available on x86
1437
    check_cc <<EOF && enable ebx_available
1438
int main(){
1439
    asm volatile ("":::"%ebx");
1440
}
1441
EOF
1442 8e380710 Loren Merritt
1443
    # check whether binutils is new enough to compile SSSE3
1444 9eeed841 Måns Rullgård
    enabled ssse3 && check_cc <<EOF || disable ssse3
1445 8e380710 Loren Merritt
int main(){
1446
    asm volatile ("pabsw %xmm0, %xmm0");
1447
}
1448
EOF
1449 44965991 Panagiotis Issaris
fi
1450
1451 87ea51e0 Luca Barbato
# check for assembler specific support
1452
1453 cc6a90dd Guillaume Poirier
if test $arch = "powerpc"; then
1454 87ea51e0 Luca Barbato
check_cc <<EOF && dcbzl=yes
1455
int main(void) {
1456
    register long zero = 0;
1457
    char data[1024];
1458
    asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
1459
return 0;
1460
}
1461
EOF
1462
fi
1463
1464 57bd82d4 Måns Rullgård
# check for SIMD availability
1465
1466 115329f1 Diego Biurrun
# AltiVec flags: The FSF version of GCC differs from the Apple version
1467 9eeed841 Måns Rullgård
if enabled altivec; then
1468 0182fee8 Måns Rullgård
    if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
1469
        add_cflags "-faltivec"
1470
    else
1471
        add_cflags "-maltivec -mabi=altivec"
1472
    fi
1473 b6e52719 Magnus Damm
1474 0182fee8 Måns Rullgård
    check_header altivec.h
1475 a9a07762 Michael Niedermayer
1476 0182fee8 Måns Rullgård
    # check if our compiler supports Motorola AltiVec C API
1477 90be59ef Ramiro Polla
    if enabled altivec_h; then
1478 f25fc9b1 Måns Rullgård
        inc_altivec_h="#include <altivec.h>"
1479
    else
1480
        inc_altivec_h=
1481
    fi
1482
    check_cc <<EOF || altivec=no
1483 dcd479c0 Måns Rullgård
$inc_altivec_h
1484 a9a07762 Michael Niedermayer
int main(void) {
1485
    vector signed int v1, v2, v3;
1486
    v1 = vec_add(v2,v3);
1487
    return 0;
1488
}
1489
EOF
1490
fi
1491 ab6c65f6 Brian Foley
1492 854fdb51 Måns Rullgård
# check armv5te instructions support
1493 9eeed841 Måns Rullgård
enabled armv5te && check_cc <<EOF || disable armv5te
1494 0182fee8 Måns Rullgård
int main(void) {
1495
    __asm__ __volatile__ ("qadd r0, r0, r0");
1496
}
1497 854fdb51 Måns Rullgård
EOF
1498
1499 9eeed841 Måns Rullgård
enabled armv6 && check_cc <<EOF || disable armv6
1500 edab3048 Måns Rullgård
int main(void) {
1501
    __asm__ __volatile__ ("sadd16 r0, r0, r0");
1502
}
1503
EOF
1504
1505 854fdb51 Måns Rullgård
# check iwmmxt support
1506 9eeed841 Måns Rullgård
enabled iwmmxt && check_cc <<EOF || disable iwmmxt
1507 0182fee8 Måns Rullgård
int main(void) {
1508
    __asm__ __volatile__ ("wunpckelub wr6, wr4");
1509
}
1510 854fdb51 Måns Rullgård
EOF
1511 d46aba26 Leon van Stuivenberg
1512 29799f8b Diego Biurrun
# check if our compiler supports mmi
1513 57bd82d4 Måns Rullgård
enabled mmi && check_cc <<EOF || mmi="no"
1514 d46aba26 Leon van Stuivenberg
int main(void) {
1515
    __asm__ ("lq \$2, 0(\$2)");
1516
    return 0;
1517
}
1518
EOF
1519 57bd82d4 Måns Rullgård
1520
# ---
1521
# big/little-endian test
1522 93b3c083 Måns Rullgård
if ! enabled cross_compile; then
1523 57bd82d4 Måns Rullgård
    check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
1524 a3999908 Michael Niedermayer
#include <inttypes.h>
1525
int main(int argc, char ** argv){
1526 bb270c08 Diego Biurrun
        volatile uint32_t i=0x01234567;
1527
        return (*((uint8_t*)(&i))) == 0x67;
1528 a3999908 Michael Niedermayer
}
1529
EOF
1530 487a54d7 Fabrice Bellard
else
1531 f25fc9b1 Måns Rullgård
    # programs cannot be launched if cross compiling, so make a static guess
1532 cc6a90dd Guillaume Poirier
    if test "$arch" = "powerpc" -o "$arch" = "mips" ; then
1533 f25fc9b1 Måns Rullgård
        bigendian="yes"
1534
    fi
1535 487a54d7 Fabrice Bellard
fi
1536
1537 a3999908 Michael Niedermayer
# ---
1538 3d204385 Nick Kurshev
# check availability of some header files
1539
1540 0701ca7f Måns Rullgård
check_header malloc.h
1541
check_func memalign
1542 3d204385 Nick Kurshev
1543 93b3c083 Måns Rullgård
if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
1544 57bd82d4 Måns Rullgård
    die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
1545 8bf5d58f Michael Niedermayer
fi
1546
1547 0701ca7f Måns Rullgård
check_header byteswap.h
1548 47d23bbf Måns Rullgård
1549 6ffa87d3 Ramiro Polla
check_func mkstemp
1550 b6c748ed Roman Shaposhnik
check_func gethrtime
1551 6ffa87d3 Ramiro Polla
1552 e16e49ac Ramiro Polla
check_header termios.h
1553
check_header conio.h
1554
1555 c9fdab0d François Revol
check_header arpa/inet.h
1556 6ff3f3e7 Ramiro Polla
check_header winsock2.h
1557 c9fdab0d François Revol
1558 0701ca7f Måns Rullgård
check_func inet_aton
1559 57bd82d4 Måns Rullgård
enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
1560
1561 b0c858d8 François Revol
# ffserver uses poll(),
1562
# if it's not found we can emulate it using select().
1563
if enabled ffserver; then
1564
    check_header sys/poll.h
1565
fi
1566
1567 57bd82d4 Måns Rullgård
# check for some common methods of building with pthread support
1568
# do this before the optional library checks as some of them require pthreads
1569
if enabled pthreads; then
1570 9e7fd101 Måns Rullgård
    if check_func pthread_create; then
1571
        :
1572
    elif check_func pthread_create -pthread; then
1573
        add_cflags -pthread
1574
        add_ldflags -pthread
1575
    elif check_func pthread_create -pthreads; then
1576
        add_cflags -pthreads
1577
        add_ldflags -pthreads
1578
    elif ! check_lib pthread.h pthread_create -lpthread; then
1579
        die "ERROR: can't find pthreads library"
1580
    fi
1581 57bd82d4 Måns Rullgård
fi
1582
1583 8eee7025 Diego Biurrun
for thread in $THREADS_LIST; do
1584 e5f94c2b Ramiro Polla
    if enabled $thread; then
1585 aa45201d Måns Rullgård
        if test -n "$thread_type"; then
1586 e5f94c2b Ramiro Polla
            die "ERROR: Only one thread type must be selected."
1587
        else
1588
            thread_type="$thread"
1589
        fi
1590
    fi
1591
done
1592
1593 f32adb22 Måns Rullgård
# test for lrintf in math.h
1594
check_exec <<EOF && lrintf=yes || lrintf=no
1595
#define _ISOC9X_SOURCE  1
1596
#include <math.h>
1597
int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
1598
EOF
1599
1600 f5a756ef Diego Biurrun
enabled_any libamr_nb libamr_wb && enable libamr
1601 12b61a74 Måns Rullgård
1602 57bd82d4 Måns Rullgård
# these are off by default, so fail if requested and not available
1603 7bc5f2a8 Diego Biurrun
enabled liba52     && require liba52 a52dec/a52.h a52_init -la52
1604 f5a756ef Diego Biurrun
enabled libamr_nb  && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
1605
enabled libamr_wb  && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
1606 910c62e1 Diego Biurrun
enabled libgsm     && require libgsm gsm.h gsm_create -lgsm
1607 6ebe07fb Diego Biurrun
enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
1608 910c62e1 Diego Biurrun
enabled libtheora  && require libtheora theora/theora.h theora_info_init -ltheora -logg
1609
enabled libvorbis  && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
1610
enabled libogg     && require libogg ogg/ogg.h ogg_sync_init -logg
1611
enabled libnut     && require libnut libnut.h nut_demuxer_init -lnut
1612 1cc60c47 Diego Biurrun
enabled libx264    && require x264 x264.h x264_encoder_open -lx264
1613
enabled libxvid    && require Xvid xvid.h xvid_global -lxvidcore
1614 910c62e1 Diego Biurrun
enabled dc1394     && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
1615
enabled mlib       && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
1616 f8d7b072 Måns Rullgård
enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
1617
enabled libfaad    && require2 libfaad faad.h faacDecOpen -lfaad
1618
enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
1619 8ac17293 Steve L'Homme
1620 6ea67bbb Justin Ruggles
# disable the native AC-3 decoder if liba52 is enabled
1621
enabled liba52 && disable ac3_decoder
1622
1623 c13e1abd Falk Hüffner
_restrict=
1624
for restrict_keyword in restrict __restrict__ __restrict; do
1625 57bd82d4 Måns Rullgård
    check_cc <<EOF && _restrict=$restrict_keyword && break
1626 dcd479c0 Måns Rullgård
void foo(char * $restrict_keyword p);
1627
EOF
1628 c13e1abd Falk Hüffner
done
1629
1630 a8721c09 Fabrice Bellard
# dlopen/dlfcn.h probing
1631
1632 0701ca7f Måns Rullgård
check_header dlfcn.h
1633 a8721c09 Fabrice Bellard
1634 dcd479c0 Måns Rullgård
if check_func dlopen; then
1635
    ldl=
1636 0701ca7f Måns Rullgård
elif check_func dlopen -ldl; then
1637
    ldl=-ldl
1638 a8721c09 Fabrice Bellard
fi
1639
1640 66be5b45 Ramiro Polla
check_func getrusage
1641 7495c306 Ramiro Polla
check_func2 windows.h GetProcessTimes
1642 66be5b45 Ramiro Polla
1643 4f3da985 Ramiro Polla
check_func fork
1644 3b4e7bb3 Ramiro Polla
check_func closesocket ||
1645
    check_func2 winsock2.h closesocket
1646 4f3da985 Ramiro Polla
1647 703afd07 Måns Rullgård
test "$vhook" = "default" && vhook="$dlopen"
1648 a8721c09 Fabrice Bellard
1649 81a409c8 François Revol
enabled_any vhook liba52bin libfaadbin ffserver && add_extralibs $ldl
1650 bfd2edeb Michael Niedermayer
1651 b0268cc0 Ramiro Polla
if test "$targetos" = cygwin -o "$targetos" = mingw32 && enabled_all static vhook ; then
1652 fbb9d104 Víctor Paesa
    vhook="no"
1653
    echo
1654 b0268cc0 Ramiro Polla
    echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
1655 fbb9d104 Víctor Paesa
    echo "Patches welcome."
1656
    echo
1657
fi
1658
1659 8d923001 Måns Rullgård
if enabled vhook; then
1660
    check_ldflags -rdynamic
1661
    check_ldflags -export-dynamic
1662
fi
1663 bfd2edeb Michael Niedermayer
1664 703afd07 Måns Rullgård
enabled audio_beos && add_extralibs "-lmedia -lbe"
1665 9464f2b8 Diego Biurrun
1666 eea50282 Måns Rullgård
check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
1667
check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
1668 04511d53 Philip Gladstone
1669 a86b921c Fabrice Bellard
##########################################
1670 29799f8b Diego Biurrun
# SDL check
1671 a86b921c Fabrice Bellard
1672
sdl_too_old=no
1673
sdl=no
1674 6a1a892f Frantisek Dvorak
SDL_CONFIG="${cross_prefix}sdl-config"
1675 225e21ef Måns Rullgård
if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
1676
    sdl_cflags=`"${SDL_CONFIG}" --cflags`
1677
    temp_cflags $sdl_cflags
1678 dcd479c0 Måns Rullgård
    temp_extralibs `"${SDL_CONFIG}" --libs`
1679 225e21ef Måns Rullgård
    if check_lib SDL.h SDL_Init; then
1680 dcd479c0 Måns Rullgård
        _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
1681 29f3b38a Måns Rullgård
        if test "$_sdlversion" -lt 121 ; then
1682 dcd479c0 Måns Rullgård
            sdl_too_old=yes
1683
        else
1684
            sdl=yes
1685 225e21ef Måns Rullgård
            check_cc $sdl_cflags <<EOF && enable sdl_video_size
1686 29f3b38a Måns Rullgård
#include <SDL.h>
1687
int main(void){
1688
    const SDL_VideoInfo *vi = SDL_GetVideoInfo();
1689
    int w = vi->current_w;
1690
    return 0;
1691
}
1692
EOF
1693 dcd479c0 Måns Rullgård
        fi
1694
    fi
1695 29f3b38a Måns Rullgård
    restore_flags
1696 c3f6b472 Michael Niedermayer
fi
1697 57bd82d4 Måns Rullgård
1698 d5697779 Måns Rullgård
texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
1699 146ea952 Nicolas Boos
1700 7a91333f Hans Zandbelt
##########################################
1701 29799f8b Diego Biurrun
# IPv6 check
1702 7a91333f Hans Zandbelt
1703 0c7bb0e5 Luca Barbato
enabled network && enabled ipv6 && check_ld <<EOF && ipv6=yes || ipv6=no
1704 7a91333f Hans Zandbelt
#include <sys/types.h>
1705
#include <sys/socket.h>
1706
#include <netinet/in.h>
1707
#include <netdb.h>
1708
int main( void ) {
1709
  struct sockaddr_storage saddr;
1710
  struct ipv6_mreq mreq6;
1711
  getaddrinfo(0,0,0,0);
1712
  getnameinfo(0,0,0,0,0,0,0);
1713 12fe88b4 Dan Villiom Podlaski Christiansen
  IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
1714 7a91333f Hans Zandbelt
}
1715
EOF
1716
1717 afde41b4 Måns Rullgård
enabled v4l  && check_header linux/videodev.h  || disable v4l
1718
enabled v4l2 && check_header linux/videodev2.h || disable v4l2
1719 47f38850 Luca Abeni
1720 f8aa696f Diego Biurrun
# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1721
if enabled bktr; then
1722 3eac5c63 Måns Rullgård
    { check_header dev/bktr/ioctl_meteor.h &&
1723
      check_header dev/bktr/ioctl_bt848.h; } ||
1724
    { check_header machine/ioctl_meteor.h &&
1725
      check_header machine/ioctl_bt848.h; } ||
1726
    { check_header dev/video/meteor/ioctl_meteor.h &&
1727
      check_header dev/video/bktr/ioctl_bt848.h; } ||
1728
    check_header dev/ic/bt8xx.h ||
1729
    disable bktr
1730 f8aa696f Diego Biurrun
fi
1731
1732 deb29777 Måns Rullgård
enabled audio_oss &&
1733
    check_header sys/soundcard.h ||
1734
    check_header soundcard.h ||
1735
    disable audio_oss
1736
1737 f58f4ce1 Guillaume Poirier
# Deal with the x11 frame grabber
1738 56a059ac Diego Biurrun
enabled x11grab                         &&
1739 f58f4ce1 Guillaume Poirier
enabled gpl                             &&
1740
enabled x11_grab_device_demuxer         &&
1741
check_header X11/Xlib.h                 &&
1742
check_header X11/extensions/XShm.h      &&
1743
check_func XOpenDisplay -lX11           &&
1744
check_func XShmCreateImage -lX11 -lXext &&
1745
add_extralibs -lX11 -lXext              ||
1746
disable x11_grab_device_demuxer
1747
1748 57bd82d4 Måns Rullgård
enabled debug && add_cflags -g
1749
1750
# add some useful compiler flags if supported
1751
check_cflags -Wdeclaration-after-statement
1752 dcd479c0 Måns Rullgård
check_cflags -Wall
1753
check_cflags -Wno-switch
1754 c07bd6a9 Michael Niedermayer
check_cflags -Wdisabled-optimization
1755
check_cflags -Wpointer-arith
1756
check_cflags -Wredundant-decls
1757 cc1fb623 Måns Rullgård
check_cflags -Wno-pointer-sign
1758 5af4e0cc Måns Rullgård
enabled extra_warnings && check_cflags -Winline
1759 cf9d24ad Dan Christiansen
1760 57bd82d4 Måns Rullgård
# add some linker flags
1761 5c0e9479 Måns Rullgård
check_ldflags -Wl,--warn-common
1762 e240ee67 Luca Barbato
check_ldflags $LDLATEFLAGS
1763 94a3401e Fabrice Bellard
1764 bd2216e4 Måns Rullgård
if enabled small; then
1765
    check_cflags -Os            # not all compilers support -Os
1766
    optimize="small"
1767
elif enabled optimize; then
1768 b2924696 Roman Shaposhnik
    if test -n "`$cc -v 2>&1 | grep xlc`"; then
1769 30a3e5d4 Nigel Pearson
        add_cflags  "-O5"
1770
        add_ldflags "-O5"
1771 cf9d24ad Dan Christiansen
    else
1772 30a3e5d4 Nigel Pearson
        add_cflags "-O3"
1773 cf9d24ad Dan Christiansen
    fi
1774 cddf3f45 Glenn Maynard
fi
1775
1776 80581e98 Michael Niedermayer
# PIC flags for shared library objects where they are needed
1777 5af4e0cc Måns Rullgård
if enabled shared; then
1778 f25fc9b1 Måns Rullgård
    # LIBOBJFLAGS may have already been set in the OS configuration
1779
    if test -z "$LIBOBJFLAGS" ; then
1780 cc6a90dd Guillaume Poirier
        case "$arch" in
1781 f824ba7b Luca Barbato
            x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS="\$(PIC)" ;;
1782 813457e5 Måns Rullgård
        esac
1783 80581e98 Michael Niedermayer
    fi
1784
fi
1785
1786 90be59ef Ramiro Polla
if enabled gprof; then
1787 30a3e5d4 Nigel Pearson
    add_cflags  "-p"
1788
    add_ldflags "-p"
1789 1db54e20 Diego Biurrun
fi
1790
1791 3b26ee47 Måns Rullgård
VHOOKCFLAGS="-fPIC"
1792 18451f7d Måns Rullgård
1793 4454dc1b John Dalgliesh
# find if .align arg is power-of-two or not
1794
if test $asmalign_pot = "unknown"; then
1795
    asmalign_pot="no"
1796
    echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
1797
fi
1798
1799 660db1d6 Diego Biurrun
enabled_any $ENCODER_LIST  && enable encoders
1800
enabled_any $DECODER_LIST  && enable decoders
1801
enabled_any $MUXER_LIST    && enable muxers
1802
enabled_any $DEMUXER_LIST  && enable demuxers
1803 c08fb000 Alex Beregszaszi
enabled_any $PROTOCOL_LIST && enable protocols
1804 cd61e407 Jason Millard
enabled_any $BSF_LIST      && enable bsfs
1805 f70f03f6 Måns Rullgård
1806 660db1d6 Diego Biurrun
enabled_any $THREADS_LIST  && enable threads
1807 f70f03f6 Måns Rullgård
1808
check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
1809 cd61e407 Jason Millard
    $BSF_LIST $DEMUXER_LIST $MUXER_LIST $PROTOCOL_LIST
1810 f70f03f6 Måns Rullgård
1811 fb2ce7d9 Måns Rullgård
enabled libogg    && append pkg_requires "ogg >= 1.1"
1812
enabled libtheora && append pkg_requires "theora"
1813
enabled libvorbis && append pkg_requires "vorbis vorbisenc"
1814
enabled dc1394    && append pkg_requires "libraw1394"
1815
1816 f36958f8 Diego Biurrun
echo "install prefix            $PREFIX"
1817
echo "source path               $source_path"
1818
echo "C compiler                $cc"
1819
echo "make                      $make"
1820 bfd5afd8 Diego Biurrun
echo ".align is power-of-two    $asmalign_pot"
1821 f36958f8 Diego Biurrun
echo "ARCH                      $arch ($cpu)"
1822 eb94aca9 Charles Yates
if test "$BUILDSUF" != ""; then
1823 f36958f8 Diego Biurrun
    echo "build suffix              $BUILDSUF"
1824 eb94aca9 Charles Yates
fi
1825 0db2ce77 Måns Rullgård
echo "big-endian                ${bigendian-no}"
1826 419b8784 Diego Biurrun
if test $arch = "x86_32" -o $arch = "x86_64"; then
1827 0db2ce77 Måns Rullgård
    echo "MMX enabled               ${mmx-no}"
1828
    echo "CMOV enabled              ${cmov-no}"
1829
    echo "CMOV is fast              ${fast_cmov-no}"
1830 e41e8342 Fabrice Bellard
fi
1831 cc6a90dd Guillaume Poirier
if test $arch = "armv4l"; then
1832 0db2ce77 Måns Rullgård
    echo "ARMv5TE enabled           ${armv5te-no}"
1833
    echo "ARMv6 enabled             ${armv6-no}"
1834
    echo "IWMMXT enabled            ${iwmmxt-no}"
1835 eba9ae3c Gildas Bazin
fi
1836 cc6a90dd Guillaume Poirier
if test $arch = "mips"; then
1837 0db2ce77 Måns Rullgård
    echo "MMI enabled               ${mmi-no}"
1838 e41e8342 Fabrice Bellard
fi
1839 cc6a90dd Guillaume Poirier
if test $arch = "powerpc"; then
1840 0db2ce77 Måns Rullgård
    echo "AltiVec enabled           ${altivec-no}"
1841
    echo "dcbzl available           ${dcbzl-no}"
1842 e41e8342 Fabrice Bellard
fi
1843 0db2ce77 Måns Rullgård
echo "gprof enabled             ${gprof-no}"
1844
echo "debug symbols             ${debug-no}"
1845
echo "strip symbols             ${dostrip-no}"
1846
echo "optimize                  ${optimize-no}"
1847
echo "static                    ${static-no}"
1848
echo "shared                    ${shared-no}"
1849
echo "postprocessing support    ${pp-no}"
1850
echo "software scaler enabled   ${swscaler-no}"
1851
echo "video hooking             ${vhook-no}"
1852 90be59ef Ramiro Polla
if enabled vhook; then
1853 0db2ce77 Måns Rullgård
    echo "Imlib2 support            ${imlib2-no}"
1854
    echo "FreeType support          ${freetype2-no}"
1855 68892110 Philip Gladstone
fi
1856 0db2ce77 Måns Rullgård
echo "network support           ${network-no}"
1857 90be59ef Ramiro Polla
if enabled network; then
1858 0db2ce77 Måns Rullgård
    echo "IPv6 support              ${ipv6-no}"
1859 bfd5afd8 Diego Biurrun
fi
1860 0db2ce77 Måns Rullgård
echo "threading support         ${thread_type-no}"
1861
echo "SDL support               ${sdl-no}"
1862 90be59ef Ramiro Polla
if enabled sdl_too_old; then
1863 bfd5afd8 Diego Biurrun
    echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
1864
fi
1865 0db2ce77 Måns Rullgård
echo "Sun medialib support      ${mlib-no}"
1866
echo "AVISynth enabled          ${avisynth-no}"
1867
echo "liba52 support            ${liba52-no}"
1868
echo "liba52 dlopened           ${liba52bin-no}"
1869
echo "libamr-nb support         ${libamr_nb-no}"
1870
echo "libamr-wb support         ${libamr_wb-no}"
1871
echo "libfaac enabled           ${libfaac-no}"
1872
echo "libfaad enabled           ${libfaad-no}"
1873 7e0871a7 Diego Biurrun
echo "libfaad dlopened          ${libfaadbin-no}"
1874 0db2ce77 Måns Rullgård
echo "libgsm enabled            ${libgsm-no}"
1875
echo "libmp3lame enabled        ${libmp3lame-no}"
1876
echo "libnut enabled            ${libnut-no}"
1877
echo "libogg enabled            ${libogg-no}"
1878
echo "libtheora enabled         ${libtheora-no}"
1879
echo "libvorbis enabled         ${libvorbis-no}"
1880
echo "x264 enabled              ${libx264-no}"
1881
echo "XviD enabled              ${libxvid-no}"
1882
echo "zlib enabled              ${zlib-no}"
1883 93b3c083 Måns Rullgård
if ! enabled gpl; then
1884 f25fc9b1 Måns Rullgård
    echo "License: LGPL"
1885 b2e3c528 Michael Niedermayer
else
1886 f25fc9b1 Måns Rullgård
    echo "License: GPL"
1887 b2e3c528 Michael Niedermayer
fi
1888 de6d9b64 Fabrice Bellard
1889 29799f8b Diego Biurrun
echo "Creating config.mak and config.h..."
1890 de6d9b64 Fabrice Bellard
1891 29799f8b Diego Biurrun
echo "# Automatically generated by configure - do not modify!" > config.mak
1892
echo "/* Automatically generated by configure - do not modify! */" > $TMPH
1893 0fd12426 Diego Biurrun
echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
1894 de6d9b64 Fabrice Bellard
1895 2266e085 Diego Biurrun
echo "PREFIX=$PREFIX" >> config.mak
1896 c75560ae Diego Biurrun
echo "prefix=\$(DESTDIR)\$(PREFIX)" >> config.mak
1897 22a324da Diego Biurrun
echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
1898
echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
1899
echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
1900
echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
1901
echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
1902 4a908fbc Alex Beregszaszi
echo "MAKE=$make" >> config.mak
1903 980fc7b8 Fabrice Bellard
echo "CC=$cc" >> config.mak
1904
echo "AR=$ar" >> config.mak
1905 be7109c1 Michael Niedermayer
echo "RANLIB=$ranlib" >> config.mak
1906 90be59ef Ramiro Polla
if enabled dostrip; then
1907 f25fc9b1 Måns Rullgård
    echo "STRIP=$strip" >> config.mak
1908 65d1bea2 Michel Bardiaux
else
1909 f25fc9b1 Måns Rullgård
    echo "STRIP=echo ignoring strip" >> config.mak
1910 65d1bea2 Michel Bardiaux
fi
1911 75388c74 Michael Niedermayer
1912 a9b3f630 Nick Kurshev
echo "OPTFLAGS=$CFLAGS" >> config.mak
1913 408382a4 Diego Biurrun
echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
1914 0f3cb305 Fabrice Bellard
echo "LDFLAGS=$LDFLAGS" >> config.mak
1915 f39e56a8 Jacob Meuser
echo "LDCONFIG=$LDCONFIG" >> config.mak
1916 c536cb09 Diego Biurrun
echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
1917 e1707f52 Michael Niedermayer
echo "SHFLAGS=$SHFLAGS" >> config.mak
1918 408382a4 Diego Biurrun
echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
1919 fbb9d104 Víctor Paesa
echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
1920 80581e98 Michael Niedermayer
echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
1921 5af4e0cc Måns Rullgård
echo "BUILD_STATIC=$static" >> config.mak
1922 eb94aca9 Charles Yates
echo "BUILDSUF=$BUILDSUF" >> config.mak
1923 f3ec2d46 Slavik Gnatenko
echo "LIBPREF=$LIBPREF" >> config.mak
1924 eb94aca9 Charles Yates
echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
1925 60147de8 Ramiro Polla
echo "LIB=$LIB" >> config.mak
1926 f3ec2d46 Slavik Gnatenko
echo "SLIBPREF=$SLIBPREF" >> config.mak
1927 eb94aca9 Charles Yates
echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
1928
echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
1929 4dc62701 Måns Rullgård
1930 90be59ef Ramiro Polla
if enabled bigendian; then
1931 0f3cb305 Fabrice Bellard
  echo "WORDS_BIGENDIAN=yes" >> config.mak
1932
  echo "#define WORDS_BIGENDIAN 1" >> $TMPH
1933 91d1f1a4 Nick Kurshev
fi
1934 90be59ef Ramiro Polla
if enabled mmx; then
1935 e82c5a8c Michael Niedermayer
  echo "#define __CPU__ 586" >> $TMPH
1936 de6d9b64 Fabrice Bellard
fi
1937 44161118 Måns Rullgård
1938 90be59ef Ramiro Polla
if enabled sdl; then
1939 6a1a892f Frantisek Dvorak
  echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
1940
  echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
1941 a86b921c Fabrice Bellard
fi
1942 90be59ef Ramiro Polla
if enabled texi2html; then
1943 146ea952 Nicolas Boos
  echo "BUILD_DOC=yes" >> config.mak
1944
fi
1945 5a872801 Luca Barbato
1946 790c9ca7 Luca Abeni
sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
1947 6d9a2421 Diego Biurrun
pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
1948 5a872801 Luca Barbato
lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
1949
lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
1950
lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
1951
1952
1953
1954 5af4e0cc Måns Rullgård
if enabled shared; then
1955 0319c531 Nick Kurshev
  echo "BUILD_SHARED=yes" >> config.mak
1956 97006039 Jacob Meuser
  echo "PIC=-fPIC -DPIC" >> config.mak
1957 7e303556 Diego Biurrun
  echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
1958
  echo "SPPVERSION=$pp_version" >> config.mak
1959 39503a27 Diego Biurrun
  echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
1960 5a872801 Luca Barbato
  echo "LAVCVERSION=$lavc_version" >> config.mak
1961 39503a27 Diego Biurrun
  echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
1962 5a872801 Luca Barbato
  echo "LAVFVERSION=$lavf_version" >> config.mak
1963 39503a27 Diego Biurrun
  echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
1964 5a872801 Luca Barbato
  echo "LAVUVERSION=$lavu_version" >> config.mak
1965 790c9ca7 Luca Abeni
  echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
1966
  echo "SWSVERSION=$sws_version" >> config.mak
1967 4bdd05e7 Diego Biurrun
  echo "SLIBNAME=${SLIBNAME}" >> config.mak
1968 f3b60109 Diego Biurrun
  echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
1969
  echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
1970 5cb854e1 Diego Biurrun
  echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
1971 8fbec4f4 Ramiro Polla
  echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
1972 0319c531 Nick Kurshev
fi
1973 d7e27559 Diego Biurrun
echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
1974 ef0bc4c9 François Revol
echo "EXTRALIBS=$extralibs" >> config.mak
1975 d2845d68 Diego Biurrun
1976 3d907e22 Måns Rullgård
print_config ARCH_   $TMPH config.mak $ARCH_LIST
1977
print_config HAVE_   $TMPH config.mak $HAVE_LIST
1978
print_config CONFIG_ $TMPH config.mak $CONFIG_LIST   \
1979
                                      $DECODER_LIST  \
1980
                                      $ENCODER_LIST  \
1981
                                      $PARSER_LIST   \
1982
                                      $BSF_LIST      \
1983
                                      $DEMUXER_LIST  \
1984
                                      $MUXER_LIST    \
1985
                                      $PROTOCOL_LIST \
1986 8ac17293 Steve L'Homme
1987 ced75d92 Diego Biurrun
if test "$targetos" = darwin; then
1988 90cee0c3 Michael Niedermayer
  echo "#define CONFIG_DARWIN 1"  >> $TMPH
1989
fi
1990
1991 c13e1abd Falk Hüffner
echo "#define restrict $_restrict" >> $TMPH
1992
1993 bd2216e4 Måns Rullgård
if enabled small; then
1994 3bf98161 Michael Niedermayer
  echo "#define av_always_inline"  >> $TMPH
1995 bb801c97 Michael Niedermayer
fi
1996
1997 997baf01 Måns Rullgård
echo "SRC_PATH=\"$source_path\"" >> config.mak
1998
echo "SRC_PATH_BARE=$source_path" >> config.mak
1999
echo "BUILD_ROOT=\"$PWD\"" >> config.mak
2000 0f3cb305 Fabrice Bellard
2001 8156056e John Dalgliesh
# Apparently it's not possible to portably echo a backslash.
2002 90be59ef Ramiro Polla
if enabled asmalign_pot; then
2003 8156056e John Dalgliesh
  printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
2004 4454dc1b John Dalgliesh
else
2005 8156056e John Dalgliesh
  printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
2006 4454dc1b John Dalgliesh
fi
2007
2008 bc634f6f Zdenek Kabelac
2009 9cb2cf10 Diego Biurrun
# Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
2010 c683a5d1 Måns Rullgård
if ! cmp -s $TMPH config.h; then
2011 9cb2cf10 Diego Biurrun
        mv -f $TMPH config.h
2012
else
2013
        echo "config.h is unchanged"
2014
fi
2015 3d204385 Nick Kurshev
2016 f3ec2d46 Slavik Gnatenko
rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
2017 def4272a Aurelien Jacobs
2018 165af439 Måns Rullgård
# build tree in object directory if source path is different from current one
2019 90be59ef Ramiro Polla
if enabled source_path_used; then
2020 165af439 Måns Rullgård
    DIRS="\
2021
         doc \
2022
         libavcodec \
2023
         libavcodec/alpha \
2024
         libavcodec/armv4l \
2025
         libavcodec/bfin \
2026
         libavcodec/i386 \
2027
         libavcodec/mlib \
2028
         libavcodec/ppc \
2029 7506d47a Aurelien Jacobs
         libavcodec/sh4 \
2030 862a70f1 Aurelien Jacobs
         libavcodec/sparc \
2031
         libavformat \
2032 165af439 Måns Rullgård
         libavutil \
2033 862a70f1 Aurelien Jacobs
         libpostproc \
2034 165af439 Måns Rullgård
         libswscale \
2035
         tests \
2036 c07ed8c8 Måns Rullgård
         tools \
2037 165af439 Måns Rullgård
         vhook \
2038
         "
2039
    FILES="\
2040
          Makefile \
2041
          common.mak \
2042 862a70f1 Aurelien Jacobs
          doc/texi2pod.pl \
2043 165af439 Måns Rullgård
          libavcodec/Makefile \
2044 862a70f1 Aurelien Jacobs
          libavformat/Makefile \
2045 165af439 Måns Rullgård
          libavutil/Makefile \
2046 862a70f1 Aurelien Jacobs
          libpostproc/Makefile \
2047 165af439 Måns Rullgård
          libswscale/Makefile \
2048
          "
2049
    for dir in $DIRS ; do
2050
            mkdir -p $dir
2051
    done
2052
    for f in $FILES ; do
2053
        ln -sf "$source_path/$f" $f
2054
    done
2055
fi
2056 def4272a Aurelien Jacobs
2057
2058 d0674868 Diego Biurrun
# build pkg-config files
2059 77aee36c Diego Biurrun
# FIXME: libdir and includedir are hardcoded and may differ from the real path.
2060 def4272a Aurelien Jacobs
2061 d0674868 Diego Biurrun
pkgconfig_generate(){
2062
name=$1
2063
comment=$2
2064
version=$3
2065
libs=$4
2066
requires=$5
2067
include=$6
2068
cat <<EOF >$name.pc
2069 2266e085 Diego Biurrun
prefix=$PREFIX
2070 a94e666c Diego Biurrun
exec_prefix=\${prefix}
2071 def4272a Aurelien Jacobs
libdir=\${exec_prefix}/lib
2072 a94e666c Diego Biurrun
includedir=\${prefix}/include
2073 def4272a Aurelien Jacobs
2074 d0674868 Diego Biurrun
Name: $name
2075
Description: $comment
2076
Version: $version
2077
Requires: $requires
2078 def4272a Aurelien Jacobs
Conflicts:
2079 d0674868 Diego Biurrun
Libs: -L\${libdir} $libs
2080
Cflags: -I\${includedir} -I\${includedir}/$include
2081 def4272a Aurelien Jacobs
EOF
2082 d0674868 Diego Biurrun
}
2083 def4272a Aurelien Jacobs
2084 d0674868 Diego Biurrun
pkgconfig_generate_uninstalled(){
2085
name=$1
2086 9c476fd6 Måns Rullgård
shortname=${name#lib}
2087 d0674868 Diego Biurrun
comment=$2
2088
version=$3
2089
libs=$4
2090
requires=$5
2091
cat <<EOF >$name-uninstalled.pc
2092 def4272a Aurelien Jacobs
prefix=
2093
exec_prefix=
2094 d0674868 Diego Biurrun
libdir=\${pcfiledir}/$name
2095
includedir=\${pcfiledir}/$name
2096 def4272a Aurelien Jacobs
2097 d0674868 Diego Biurrun
Name: $name
2098
Description: $comment
2099
Version: $version
2100
Requires: $requires
2101 def4272a Aurelien Jacobs
Conflicts:
2102 d0674868 Diego Biurrun
Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
2103 def4272a Aurelien Jacobs
Cflags: -I\${includedir}
2104
EOF
2105 d0674868 Diego Biurrun
}
2106 def4272a Aurelien Jacobs
2107 9d824ad1 Måns Rullgård
pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
2108 d0674868 Diego Biurrun
pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
2109 def4272a Aurelien Jacobs
2110 d0674868 Diego Biurrun
pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
2111
pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
2112 def4272a Aurelien Jacobs
2113 d0674868 Diego Biurrun
pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2114
pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
2115 def4272a Aurelien Jacobs
2116 90be59ef Ramiro Polla
if enabled pp; then
2117 2e3bcd38 Diego Biurrun
  pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
2118
  pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
2119
fi
2120 790c9ca7 Luca Abeni
2121 c839db53 Ramiro Polla
if enabled swscaler; then
2122 3d3361e5 Diego Biurrun
  pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" -lswscale "libavutil = $lavu_version" ffmpeg
2123 20c516c6 Dominik Mierzejewski
  pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
2124 6c0d0413 j@v2v.cc
else
2125 3d3361e5 Diego Biurrun
  pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" ffmpeg
2126 d0674868 Diego Biurrun
  pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
2127 c505dd31 Måns Rullgård
  apply libswscale.pc sed s/^Libs:.*$/Libs:/
2128
  apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
2129 6c0d0413 j@v2v.cc
fi