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