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