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