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