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