Statistics
| Branch: | Revision:

ffmpeg / configure @ 3a74415d

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