flacdec: Warn about invalid max blocksize and limit the minimum value.
[libav.git] / configure
CommitLineData
aeb29222 1#!/bin/sh
0f3cb305 2#
f57620d5
MR
3# FFmpeg configure script
4#
949906ea
DB
5# Copyright (c) 2000-2002 Fabrice Bellard
6# Copyright (c) 2005-2008 Diego Biurrun
7# Copyright (c) 2005-2008 Mans Rullgard
0f3cb305 8#
cf9d24ad 9
31e647f8 10# Prevent locale nonsense from breaking basic text processing.
79ab96ba
DB
11LC_ALL=C
12export LC_ALL
31e647f8 13
cde2d79a 14# make sure we are running under a compatible shell
c21d6325
MR
15# try to make this part work with most shells
16
17try_exec(){
0dbe81bb 18 echo "Trying shell $1"
2270b4b2 19 type "$1" > /dev/null 2>&1 && exec "$@"
c21d6325
MR
20}
21
5237ce67 22unset foo
2270b4b2 23(: ${foo%%bar}) 2> /dev/null
0dbe81bb
MR
24E1="$?"
25
2270b4b2 26(: ${foo?}) 2> /dev/null
0dbe81bb
MR
27E2="$?"
28
29if test "$E1" != 0 || test "$E2" = 0; then
30 echo "Broken shell detected. Trying alternatives."
c21d6325
MR
31 export FF_CONF_EXEC
32 if test "0$FF_CONF_EXEC" -lt 1; then
33 FF_CONF_EXEC=1
34 try_exec bash "$0" "$@"
35 fi
36 if test "0$FF_CONF_EXEC" -lt 2; then
37 FF_CONF_EXEC=2
38 try_exec ksh "$0" "$@"
39 fi
40 if test "0$FF_CONF_EXEC" -lt 3; then
41 FF_CONF_EXEC=3
42 try_exec /usr/xpg4/bin/sh "$0" "$@"
cde2d79a
MR
43 fi
44 echo "No compatible shell script interpreter found."
fc53da20 45 echo "This configure script requires a POSIX-compatible shell"
c21d6325 46 echo "such as bash or ksh."
505dfb09
DB
47 echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
48 echo "Instead, install a working POSIX-compatible shell."
49 echo "Disabling this configure test will create a broken FFmpeg."
c21d6325
MR
50 if test "$BASH_VERSION" = '2.04.0(1)-release'; then
51 echo "This bash version ($BASH_VERSION) is broken on your platform."
52 echo "Upgrade to a later version if available."
53 fi
cde2d79a
MR
54 exit 1
55fi
56
74c53c2d
MR
57show_help(){
58 echo "Usage: configure [options]"
59 echo "Options: [defaults in brackets after descriptions]"
60 echo
61 echo "Standard options:"
62 echo " --help print this message"
8c6afa4d
DB
63 echo " --logfile=FILE log tests and output to FILE [config.err]"
64 echo " --disable-logging do not log configure debug information"
3e89171a 65 echo " --prefix=PREFIX install in PREFIX [$prefix]"
d156bede 66 echo " --bindir=DIR install binaries in DIR [PREFIX/bin]"
14a8acf1 67 echo " --datadir=DIR install data files in DIR [PREFIX/share/ffmpeg]"
74c53c2d 68 echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
84c22efd 69 echo " --shlibdir=DIR install shared libs in DIR [PREFIX/lib]"
5341d856 70 echo " --incdir=DIR install includes in DIR [PREFIX/include]"
4ca5ece5 71 echo " --mandir=DIR install man page in DIR [PREFIX/share/man]"
62560865
DB
72 echo
73 echo "Configuration options:"
e6b9d588
DB
74 echo " --disable-static do not build static libraries [no]"
75 echo " --enable-shared build shared libraries [no]"
0a23c0bb
DB
76 echo " --enable-gpl allow use of GPL code, the resulting libs"
77 echo " and binaries will be under GPL [no]"
78 echo " --enable-nonfree allow use of nonfree code, the resulting libs"
79 echo " and binaries will be unredistributable [no]"
62560865
DB
80 echo " --disable-ffmpeg disable ffmpeg build"
81 echo " --disable-ffplay disable ffplay build"
82 echo " --disable-ffserver disable ffserver build"
e6b9d588 83 echo " --enable-postproc enable GPLed postprocessing support [no]"
76022763 84 echo " --enable-swscale enable GPLed software scaler support [no]"
e6b9d588 85 echo " --enable-avfilter video filter support (replaces vhook) [no]"
0a23c0bb 86 echo " --enable-avfilter-lavf video filters dependent on avformat [no]"
4f50c3d5 87 echo " --disable-vhook disable video hooking support"
e6b9d588
DB
88 echo " --enable-beosthreads use BeOS threads [no]"
89 echo " --enable-os2threads use OS/2 threads [no]"
90 echo " --enable-pthreads use pthreads [no]"
91 echo " --enable-w32threads use Win32 threads [no]"
92 echo " --enable-x11grab enable X11 grabbing [no]"
732c9a34 93 echo " --enable-vdpau enable VDPAU support [no]"
62560865
DB
94 echo " --disable-network disable network support [no]"
95 echo " --disable-ipv6 disable IPv6 support [no]"
96 echo " --disable-mpegaudio-hp faster (but less accurate) MPEG audio decoding [no]"
97 echo " --enable-gray enable full grayscale support (slower color)"
242e2270 98 echo " --enable-fastdiv enable table-based division"
62560865
DB
99 echo " --enable-small optimize for size instead of speed"
100 echo " --disable-aandct disable AAN DCT code"
101 echo " --disable-fft disable FFT code"
102 echo " --disable-golomb disable Golomb code"
103 echo " --disable-mdct disable MDCT code"
68602540 104 echo " --disable-rdft disable RDFT code"
62560865
DB
105 echo " --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
106 echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
107 echo " --enable-beos-netserver enable BeOS netserver"
108 echo " --disable-encoder=NAME disable encoder NAME"
109 echo " --enable-encoder=NAME enable encoder NAME"
110 echo " --disable-encoders disable all encoders"
111 echo " --disable-decoder=NAME disable decoder NAME"
112 echo " --enable-decoder=NAME enable decoder NAME"
113 echo " --disable-decoders disable all decoders"
114 echo " --disable-muxer=NAME disable muxer NAME"
115 echo " --enable-muxer=NAME enable muxer NAME"
116 echo " --disable-muxers disable all muxers"
117 echo " --disable-demuxer=NAME disable demuxer NAME"
118 echo " --enable-demuxer=NAME enable demuxer NAME"
119 echo " --disable-demuxers disable all demuxers"
120 echo " --enable-parser=NAME enable parser NAME"
121 echo " --disable-parser=NAME disable parser NAME"
122 echo " --disable-parsers disable all parsers"
123 echo " --enable-bsf=NAME enable bitstream filter NAME"
124 echo " --disable-bsf=NAME disable bitstream filter NAME"
125 echo " --disable-bsfs disable all bitstream filters"
126 echo " --enable-protocol=NAME enable protocol NAME"
127 echo " --disable-protocol=NAME disable protocol NAME"
128 echo " --disable-protocols disable all protocols"
129 echo " --disable-indevs disable input devices"
130 echo " --disable-outdevs disable output devices"
131 echo " --disable-devices disable all devices"
132 echo " --enable-filter=NAME enable filter NAME"
133 echo " --disable-filter=NAME disable filter NAME"
134 echo " --disable-filters disable all filters"
135 echo " --list-decoders show all available decoders"
136 echo " --list-encoders show all available encoders"
137 echo " --list-muxers show all available muxers"
138 echo " --list-demuxers show all available demuxers"
139 echo " --list-parsers show all available parsers"
140 echo " --list-protocols show all available protocols"
141 echo " --list-bsfs show all available bitstream filters"
142 echo " --list-indevs show all available input devices"
143 echo " --list-outdevs show all available output devices"
144 echo " --list-filters show all available filters"
0a622b98
MR
145 echo
146 echo "External library support:"
0a23c0bb 147 echo " --enable-avisynth enable reading of AVISynth script files [no]"
27cb5cbc
CEH
148 echo " --enable-bzlib enable bzlib [autodetect]"
149 echo " --enable-libamr-nb enable libamr-nb floating point audio codec [no]"
150 echo " --enable-libamr-wb enable libamr-wb floating point audio codec [no]"
f7b8bffe 151 echo " --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394"
e6b9d588
DB
152 echo " and libraw1394 [no]"
153 echo " --enable-libdirac enable Dirac support via libdirac [no]"
154 echo " --enable-libfaac enable FAAC support via libfaac [no]"
155 echo " --enable-libfaad enable FAAD support via libfaad [no]"
156 echo " --enable-libfaadbin open libfaad.so.0 at runtime [no]"
157 echo " --enable-libgsm enable GSM support via libgsm [no]"
158 echo " --enable-libmp3lame enable MP3 encoding via libmp3lame [no]"
31235134 159 echo " --enable-libnut enable NUT (de)muxing via libnut,"
0a23c0bb 160 echo " native (de)muxer exists [no]"
9a77d59a 161 echo " --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no]"
e6b9d588
DB
162 echo " --enable-libschroedinger enable Dirac support via libschroedinger [no]"
163 echo " --enable-libspeex enable Speex decoding via libspeex [no]"
164 echo " --enable-libtheora enable Theora encoding via libtheora [no]"
f9def9cc 165 echo " --enable-libvorbis enable Vorbis encoding via libvorbis,"
e6b9d588
DB
166 echo " native implementation exists [no]"
167 echo " --enable-libx264 enable H.264 encoding via x264 [no]"
1cc60c47 168 echo " --enable-libxvid enable Xvid encoding via xvidcore,"
e6b9d588 169 echo " native MPEG-4/Xvid encoder exists [no]"
732c9a34 170 echo " --enable-mlib enable Sun medialib [no]"
27cb5cbc 171 echo " --enable-zlib enable zlib [autodetect]"
74c53c2d
MR
172 echo ""
173 echo "Advanced options (experts only):"
174 echo " --source-path=PATH path to source code [$source_path]"
175 echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
db6107b6 176 echo " --enable-cross-compile assume a cross-compiler is used"
c5200f17
MR
177 echo " --sysroot=PATH root of cross-build tree"
178 echo " --sysinclude=PATH location of cross-build system headers"
4f854758 179 echo " --target-os=OS compiler targets OS [$target_os]"
a7ada2ba
MR
180 echo " --target-exec=CMD command to run executables on target"
181 echo " --target-path=DIR path to view of build directory on target"
89641463 182 echo " --nm=NM use nm tool"
15396d5c 183 echo " --cc=CC use C compiler CC [$cc_default]"
9da6609f
MR
184 echo " --host-cc=HOSTCC use host C compiler HOSTCC"
185 echo " --host-cflags=HCFLAGS use HCFLAGS when compiling for host"
186 echo " --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host"
187 echo " --host-libs=HLIBS use libs HLIBS when linking for host"
74c53c2d
MR
188 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
189 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
190 echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
ac63af34 191 echo " --extra-version=STRING version string suffix []"
0a23c0bb
DB
192 echo " --build-suffix=SUFFIX library name suffix []"
193 echo " --arch=ARCH select architecture [$arch]"
194 echo " --cpu=CPU select the minimum required CPU (affects"
7c758d33 195 echo " instruction selection, may crash on older CPUs)"
2b4c3615 196 echo " --enable-powerpc-perf enable performance report on PPC"
74c53c2d 197 echo " (requires enabling PMC)"
4f50c3d5 198 echo " --disable-altivec disable AltiVec optimizations"
3bf96eec 199 echo " --disable-amd3dnow disable 3DNow! optimizations"
a1ef9f08 200 echo " --disable-amd3dnowext disable 3DNow! extended optimizations"
0a23c0bb
DB
201 echo " --disable-mmx disable MMX optimizations"
202 echo " --disable-mmx2 disable MMX2 optimizations"
1bb04d5a 203 echo " --disable-sse disable SSE optimizations"
0a23c0bb
DB
204 echo " --disable-ssse3 disable SSSE3 optimizations"
205 echo " --disable-armv5te disable armv5te optimizations"
206 echo " --disable-armv6 disable armv6 optimizations"
26c7aa17 207 echo " --disable-armv6t2 disable armv6t2 optimizations"
3bbcba32 208 echo " --disable-armvfp disable ARM VFP optimizations"
0a23c0bb 209 echo " --disable-iwmmxt disable iwmmxt optimizations"
49276307
DB
210 echo " --disable-mmi disable MMI optimizations"
211 echo " --disable-neon disable neon optimizations"
212 echo " --disable-vis disable VIS optimizations"
7595a5e4 213 echo " --disable-yasm disable use of yasm assembler"
0a622b98
MR
214 echo
215 echo "Developer options (useful when working on FFmpeg itself):"
9c56a1f9 216 echo " --disable-debug disable debugging symbols"
b7d49373 217 echo " --enable-debug=LEVEL set the debug level [$debuglevel]"
0a622b98 218 echo " --enable-gprof enable profiling with gprof [$gprof]"
d2bbb2f7 219 echo " --disable-optimizations disable compiler optimizations"
0a622b98 220 echo " --enable-extra-warnings enable more compiler warnings"
87a0fb62 221 echo " --disable-stripping disable stripping of executables and shared libraries"
74c53c2d
MR
222 echo ""
223 echo "NOTE: Object files are built at the place where configure is launched."
60e8bc13 224 exit 0
74c53c2d 225}
cf9d24ad 226
57bd82d4 227log(){
2270b4b2 228 echo "$@" >> $logfile
57bd82d4
MR
229}
230
720c69da 231log_file(){
c8e9f801 232 log BEGIN $1
2270b4b2 233 pr -n -t $1 >> $logfile
c8e9f801
MR
234 log END $1
235}
236
2ba042a7 237echolog(){
c8e9f801 238 log "$@"
57bd82d4 239 echo "$@"
2ba042a7
MR
240}
241
242die(){
243 echolog "$@"
244 cat <<EOF
245If you think configure made a mistake, make sure you are using the latest
246version from SVN. If the latest version fails, report the problem to the
e5d8ccd7 247ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
2ba042a7 248EOF
e155a21a 249 if disabled logging; then
2ba042a7 250 cat <<EOF
e155a21a
DB
251Rerun configure with logging enabled (do not use --disable-logging), and
252include the log this produces with your report.
2ba042a7
MR
253EOF
254 else
255cat <<EOF
e155a21a
DB
256Include the log file "$logfile" produced by configure as this will help
257solving the problem.
2ba042a7
MR
258EOF
259 fi
cea0ac52 260 rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
57bd82d4
MR
261 exit 1
262}
263
6c6007d6 264# Avoid locale weirdness, besides we really just want to translate ASCII.
44161118 265toupper(){
6c6007d6 266 echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
44161118
MR
267}
268
4a5444db 269tolower(){
6c6007d6 270 echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
4a5444db
MR
271}
272
14a8acf1
MR
273c_escape(){
274 echo "$*" | sed 's/["\\]/\\\0/g'
275}
276
a8d04fba
MR
277set_all(){
278 value=$1
279 shift
280 for var in $*; do
281 eval $var=$value
282 done
283}
284
72a43668
MR
285set_weak(){
286 value=$1
287 shift
288 for var; do
289 eval : \${$var:=$value}
290 done
291}
292
799c9e9b
MR
293pushvar(){
294 for var in $*; do
295 eval level=\${${var}_level:=0}
296 eval ${var}_${level}="\$$var"
297 eval ${var}_level=$(($level+1))
298 done
299}
300
301popvar(){
302 for var in $*; do
303 eval level=\${${var}_level:-0}
304 test $level = 0 && continue
305 eval level=$(($level-1))
306 eval $var="\${${var}_${level}}"
307 eval ${var}_level=$level
308 eval unset ${var}_${level}
309 done
310}
311
a8d04fba
MR
312enable(){
313 set_all yes $*
314}
315
316disable(){
317 set_all no $*
318}
319
72a43668
MR
320enable_weak(){
321 set_weak yes $*
322}
323
324disable_weak(){
325 set_weak no $*
326}
327
72702705
MR
328enable_safe(){
329 enable $(echo "$*" | sed 's/[^A-Za-z0-9_ ]/_/g')
330}
331
332disable_safe(){
333 disable $(echo "$*" | sed 's/[^A-Za-z0-9_ ]/_/g')
334}
335
f9d328da
MR
336do_enable_deep(){
337 for var; do
338 enabled $var && continue
339 eval sel="\$${var}_select"
c510c7b5
MR
340 eval sgs="\$${var}_suggest"
341 pushvar var sgs
f9d328da 342 enable_deep $sel
c510c7b5
MR
343 popvar sgs
344 enable_deep_weak $sgs
f9d328da
MR
345 popvar var
346 done
347}
348
349enable_deep(){
350 do_enable_deep $*
351 enable $*
352}
353
72a43668
MR
354enable_deep_weak(){
355 do_enable_deep $*
356 enable_weak $*
357}
358
57bd82d4 359enabled(){
3250003c
MR
360 test "${1#!}" = "$1" && op== || op=!=
361 eval test "x\$${1#!}" $op "xyes"
44161118
MR
362}
363
37970ebf 364disabled(){
3250003c
MR
365 test "${1#!}" = "$1" && op== || op=!=
366 eval test "x\$${1#!}" $op "xno"
37970ebf
RP
367}
368
44161118
MR
369enabled_all(){
370 for opt; do
371 enabled $opt || return 1
372 done
373}
374
85bca2c5
DB
375disabled_all(){
376 for opt; do
377 disabled $opt || return 1
378 done
379}
380
44161118
MR
381enabled_any(){
382 for opt; do
383 enabled $opt && return 0
384 done
385}
386
85bca2c5
DB
387disabled_any(){
388 for opt; do
389 disabled $opt && return 0
390 done
f7b230a7 391 return 1
85bca2c5
DB
392}
393
c9d19248
MR
394set_default(){
395 for opt; do
88268e94 396 eval : \${$opt:=\$${opt}_default}
c9d19248
MR
397 done
398}
399
4a0d6686
AJ
400is_in(){
401 value=$1
402 shift
403 for var in $*; do
404 [ $var = $value ] && return 0
405 done
406 return 1
407}
408
30fd06be
MR
409check_deps(){
410 for cfg; do
3250003c 411 cfg="${cfg#!}"
799c9e9b
MR
412 enabled ${cfg}_checking && die "Circular dependency for $cfg."
413 disabled ${cfg}_checking && continue
414 enable ${cfg}_checking
415
30fd06be
MR
416 eval dep_all="\$${cfg}_deps"
417 eval dep_any="\$${cfg}_deps_any"
7ef3425f 418 eval dep_sel="\$${cfg}_select"
c510c7b5 419 eval dep_sgs="\$${cfg}_suggest"
799c9e9b 420
c510c7b5
MR
421 pushvar cfg dep_all dep_any dep_sel dep_sgs
422 check_deps $dep_all $dep_any $dep_sel $dep_sgs
423 popvar cfg dep_all dep_any dep_sel dep_sgs
799c9e9b 424
6a702d4c
MR
425 enabled_all $dep_all || disable $cfg
426 enabled_any $dep_any || disable $cfg
7ef3425f 427 disabled_any $dep_sel && disable $cfg
799c9e9b 428
4ec45764
RP
429 if enabled $cfg; then
430 eval dep_extralibs="\$${cfg}_extralibs"
431 test -n "$dep_extralibs" && add_extralibs $dep_extralibs
f9d328da 432 enable_deep $dep_sel
c510c7b5 433 enable_deep_weak $dep_sgs
4ec45764
RP
434 fi
435
799c9e9b 436 disable ${cfg}_checking
30fd06be
MR
437 done
438}
439
44161118
MR
440print_config(){
441 pfx=$1
442 header=$2
443 makefile=$3
444 shift 3
445 for cfg; do
3d907e22 446 ucname="`toupper $cfg`"
44161118 447 if enabled $cfg; then
3d907e22 448 echo "#define ${pfx}${ucname} 1" >> $header
3d907e22
MR
449 echo "${pfx}${ucname}=yes" >> $makefile
450 else
b250f9c6 451 echo "#define ${pfx}${ucname} 0" >> $header
44161118
MR
452 fi
453 done
57bd82d4
MR
454}
455
456flags_saved(){
2270b4b2 457 (: ${SAVE_CFLAGS?}) 2> /dev/null
57bd82d4
MR
458}
459
dcd479c0 460save_flags(){
57bd82d4 461 flags_saved && return
dcd479c0
MR
462 SAVE_CFLAGS="$CFLAGS"
463 SAVE_LDFLAGS="$LDFLAGS"
464 SAVE_extralibs="$extralibs"
465}
466
467restore_flags(){
f5d28d10 468 flags_saved || return
dcd479c0
MR
469 CFLAGS="$SAVE_CFLAGS"
470 LDFLAGS="$SAVE_LDFLAGS"
471 extralibs="$SAVE_extralibs"
472 unset SAVE_CFLAGS
473 unset SAVE_LDFLAGS
474 unset SAVE_extralibs
475}
476
477temp_cflags(){
478 save_flags
479 CFLAGS="$CFLAGS $*"
480}
481
482temp_ldflags(){
483 save_flags
484 LDFLAGS="$LDFLAGS $*"
485}
486
487temp_extralibs(){
488 save_flags
489 extralibs="$extralibs $*"
490}
491
57bd82d4
MR
492append(){
493 var=$1
494 shift
495 flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
496 eval "$var=\"\$$var $*\""
497}
498
499add_cflags(){
500 append CFLAGS "$@"
501}
502
503add_ldflags(){
504 append LDFLAGS "$@"
505}
506
507add_extralibs(){
508 append extralibs "$@"
509}
510
b0cfb663 511check_cmd(){
b3cb5d51 512 log "$@"
2270b4b2 513 "$@" >> $logfile 2>&1
b0cfb663
MR
514}
515
dcd479c0 516check_cc(){
57bd82d4 517 log check_cc "$@"
2270b4b2 518 cat > $TMPC
720c69da 519 log_file $TMPC
b0cfb663 520 check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
57bd82d4
MR
521}
522
523check_cpp(){
524 log check_cpp "$@"
2270b4b2 525 cat > $TMPC
720c69da 526 log_file $TMPC
b0cfb663 527 check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
dcd479c0
MR
528}
529
940f335a
MR
530check_asm(){
531 log check_asm "$@"
532 name="$1"
533 asm="$2"
534 shift 2
535 check_cc "$@" <<EOF && enable $name || disable $name
124c21d7 536void foo(void){ __asm__ volatile($asm); }
940f335a
MR
537EOF
538}
539
304d586d
LM
540check_yasm(){
541 log check_yasm "$@"
542 echo "$1" > $TMPS
543 log_file $TMPS
544 shift 1
545 check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
546}
547
dcd479c0 548check_ld(){
57bd82d4 549 log check_ld "$@"
0607887f 550 check_cc || return
3155a644
MR
551 flags=''
552 libs=''
553 for f; do
554 test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
555 done
556 check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
dcd479c0
MR
557}
558
559check_cflags(){
57bd82d4
MR
560 log check_cflags "$@"
561 check_cc "$@" <<EOF && add_cflags "$@"
dcd479c0
MR
562int x;
563EOF
564}
565
566check_ldflags(){
57bd82d4
MR
567 log check_ldflags "$@"
568 check_ld "$@" <<EOF && add_ldflags "$@"
c23a0ac8 569int main(void){ return 0; }
dcd479c0
MR
570EOF
571}
572
573check_header(){
57bd82d4 574 log check_header "$@"
dcd479c0
MR
575 header=$1
576 shift
b77df637
MR
577 disable_safe $header
578 check_cpp "$@" <<EOF && enable_safe $header
dcd479c0
MR
579#include <$header>
580int x;
581EOF
582}
583
584check_func(){
57bd82d4 585 log check_func "$@"
dcd479c0
MR
586 func=$1
587 shift
d8bc5f06
MR
588 disable $func
589 check_ld "$@" <<EOF && enable $func
dcd479c0 590extern int $func();
c23a0ac8 591int main(void){ $func(); }
dcd479c0
MR
592EOF
593}
594
2446d3d6
DB
595check_func_headers(){
596 log check_func_headers "$@"
f8d7b072
MR
597 headers=$1
598 func=$2
599 shift 2
600 disable $func
601 incs=""
602 for hdr in $headers; do
603 incs="$incs
604#include <$hdr>"
605 done
cd0d9a9d 606 check_ld "$@" <<EOF && enable $func && enable_safe $headers
f8d7b072 607$incs
d6773f56 608int main(int argc, char **argv){
f8d7b072
MR
609 (void) $func;
610 return 0;
611}
612EOF
613}
614
a5344cf7
SS
615check_cpp_condition(){
616 log check_cpp_condition "$@"
617 header=$1
618 condition=$2
619 check_cpp <<EOF
620#include <$header>
621#if !($condition)
622#error "unsatisfied condition: $condition"
623#endif
624EOF
625}
626
57bd82d4
MR
627check_lib(){
628 log check_lib "$@"
629 header="$1"
630 func="$2"
631 shift 2
fcfcde17
MR
632 temp_extralibs "$@"
633 check_header $header && check_func $func && add_extralibs "$@"
634 err=$?
635 restore_flags
636 return $err
57bd82d4
MR
637}
638
f8d7b072
MR
639check_lib2(){
640 log check_lib2 "$@"
641 headers="$1"
642 func="$2"
643 shift 2
644 temp_extralibs "$@"
2446d3d6 645 check_func_headers "$headers" $func && add_extralibs "$@"
f8d7b072
MR
646 err=$?
647 restore_flags
648 return $err
649}
650
dcd479c0 651check_exec(){
2270b4b2 652 check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
57bd82d4
MR
653}
654
7dfef245
MR
655check_exec_crash(){
656 code=`cat`
657
658 # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
659 # are safe but may not be available everywhere. Thus we use
660 # raise(SIGTERM) instead. The check is run in a subshell so we
661 # can redirect the "Terminated" message from the shell. SIGBUS
662 # is not defined by standard C so it is used conditionally.
663
2270b4b2 664 (check_exec "$@") >> $logfile 2>&1 <<EOF
7dfef245
MR
665#include <signal.h>
666static void sighandler(int sig){
667 raise(SIGTERM);
668}
e5af4a11 669int main(void){
7dfef245
MR
670 signal(SIGILL, sighandler);
671 signal(SIGFPE, sighandler);
672 signal(SIGSEGV, sighandler);
673#ifdef SIGBUS
674 signal(SIGBUS, sighandler);
675#endif
676 { $code }
677}
678EOF
679}
680
72be9e73
DY
681check_type(){
682 log check_type "$@"
683 headers=$1
684 type=$2
685 shift 2
686 disable $type
687 incs=""
688 for hdr in $headers; do
689 incs="$incs
690#include <$hdr>"
691 done
692 check_cc "$@" <<EOF && enable $type
693$incs
694$type v;
695EOF
696}
697
57bd82d4
MR
698require(){
699 name="$1"
700 header="$2"
701 func="$3"
702 shift 3
703 check_lib $header $func "$@" || die "ERROR: $name not found"
dcd479c0
MR
704}
705
f8d7b072
MR
706require2(){
707 name="$1"
708 headers="$2"
709 func="$3"
710 shift 3
711 check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
712}
713
eea50282
MR
714check_foo_config(){
715 cfg=$1
716 pkg=$2
717 header=$3
718 func=$4
719 shift 4
720 disable $cfg
721 check_cmd ${pkg}-config --version
722 err=$?
723 if test "$err" = 0; then
724 temp_cflags `${pkg}-config --cflags`
725 temp_extralibs `${pkg}-config --libs`
726 check_lib "$@" $header $func && enable $cfg
727 fi
728 return $err
729}
730
c505dd31
MR
731apply(){
732 file=$1
733 shift
734 "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
735}
736
dcd61286
DB
737# CONFIG_LIST contains configurable options, while HAVE_LIST is for
738# system-dependent things.
739
4a0d6686
AJ
740COMPONENT_LIST="
741 bsfs
742 decoders
743 demuxers
744 encoders
3cde40aa 745 filters
c552605c 746 indevs
4a0d6686 747 muxers
c552605c 748 outdevs
4a0d6686
AJ
749 parsers
750 protocols
751"
752
753CONFIG_LIST="
754 $COMPONENT_LIST
e8ed9b7a 755 aandct
f7679c54
VS
756 avfilter
757 avfilter_lavf
c88f5d72
MR
758 avisynth
759 beos_netserver
f402916e 760 bzlib
27a9466b 761 fastdiv
c88f5d72
MR
762 ffmpeg
763 ffplay
764 ffserver
1848f7d9 765 fft
4f034993 766 golomb
c88f5d72 767 gpl
ecfc4f44 768 gprof
d8d0d0b2 769 gray
3abe5fbd 770 hardcoded_tables
c88f5d72 771 ipv6
f5a756ef
DB
772 libamr_nb
773 libamr_wb
f7b8bffe 774 libdc1394
690bfceb 775 libdirac
2eed5a46
DB
776 libfaac
777 libfaad
778 libfaadbin
c88f5d72 779 libgsm
6ebe07fb 780 libmp3lame
c88f5d72 781 libnut
9a77d59a 782 libopenjpeg
f7cd9eed 783 libschroedinger
ae14f311 784 libspeex
150d2772 785 libtheora
c88f5d72 786 libvorbis
1cc60c47
DB
787 libx264
788 libxvid
47a158cb 789 mdct
c88f5d72 790 memalign_hack
a8150374 791 mlib
c88f5d72
MR
792 mpegaudio_hp
793 network
3fe142e2 794 nonfree
4a24ab64 795 postproc
2b4c3615 796 powerpc_perf
68602540 797 rdft
2e35e684 798 shared
bd2216e4 799 small
2e35e684 800 static
13ca50f3 801 swscale
272081b0 802 vdpau
c88f5d72 803 vhook
56a059ac 804 x11grab
c88f5d72 805 zlib
4a0d6686 806"
c88f5d72 807
8eee7025
DB
808THREADS_LIST='
809 beosthreads
d22e8442 810 os2threads
8eee7025
DB
811 pthreads
812 w32threads
813'
814
3f5b56e5
MR
815ARCH_LIST='
816 alpha
a2fc0f6a 817 arm
3f5b56e5
MR
818 bfin
819 ia64
820 m68k
821 mips
822 parisc
79cb09b2 823 ppc
3f5b56e5
MR
824 s390
825 sh4
826 sparc
827 sparc64
828 x86
829 x86_32
830 x86_64
831'
832
833ARCH_EXT_LIST='
1ac9331a 834 altivec
3bf96eec 835 amd3dnow
a1ef9f08 836 amd3dnowext
1ac9331a 837 armv5te
edab3048 838 armv6
ab5cb084 839 armv6t2
f55b299a 840 armvfp
3f5b56e5
MR
841 iwmmxt
842 mmi
843 mmx
d7f0920b 844 mmx2
6b18d278 845 neon
799fde37 846 ppc4xx
1bb04d5a 847 sse
9eeed841 848 ssse3
bd9d34a0 849 vis
3f5b56e5
MR
850'
851
852HAVE_LIST="
853 $ARCH_EXT_LIST
854 $THREADS_LIST
35fd8122 855 alsa_asoundlib_h
3f5b56e5 856 altivec_h
c9fdab0d 857 arpa_inet_h
6bd859d6 858 bswap
ecf97f22 859 closesocket
1ac9331a 860 cmov
e16e49ac 861 conio_h
c88f5d72 862 dcbzl
f8aa696f
DB
863 dev_bktr_ioctl_bt848_h
864 dev_bktr_ioctl_meteor_h
865 dev_ic_bt8xx_h
866 dev_video_meteor_ioctl_meteor_h
867 dev_video_bktr_ioctl_bt848_h
18b67ae5 868 dlfcn_h
c88f5d72 869 dlopen
bc574408 870 dos_paths
245626d0
DB
871 ebp_available
872 ebx_available
c2a29455 873 fast_64bit
7073e9fc 874 fast_cmov
7b829d2a 875 fast_unaligned
9d99cc5a 876 fork
c88f5d72 877 freetype2
da9e86f8 878 gethrtime
4e68cb8a 879 GetProcessTimes
66be5b45 880 getrusage
c88f5d72 881 imlib2
2e1913b1 882 inet_aton
61d251db 883 inline_asm
0b4a1821
AS
884 libdc1394_1
885 libdc1394_2
a33cab3a
MK
886 llrint
887 lrint
c88f5d72 888 lrintf
f8aa696f
DB
889 machine_ioctl_bt848_h
890 machine_ioctl_meteor_h
c88f5d72
MR
891 malloc_h
892 memalign
6ffa87d3 893 mkstemp
b4e806b2 894 pld
1f91cdce 895 posix_memalign
9cafbd6c 896 ppc64
a33cab3a
MK
897 round
898 roundf
c88f5d72
MR
899 sdl
900 sdl_video_size
b507ebd1 901 setmode
72be9e73 902 socklen_t
deb29777 903 soundcard_h
f8cda19e 904 poll_h
b58412f1 905 sys_mman_h
b091aa44 906 sys_resource_h
81644c2e 907 sys_select_h
deb29777 908 sys_soundcard_h
1b6e8b73 909 sys_videoio_h
d3a4b4e0 910 ten_operands
e16e49ac 911 termios_h
b265431e 912 threads
7b04b8a0 913 truncf
6ff3f3e7 914 winsock2_h
304d586d 915 yasm
0cb78cef 916"
44161118 917
b6bb00b0
MR
918# options emitted with CONFIG_ prefix but not available on command line
919CONFIG_EXTRA="
40b509b3 920 oldscaler
b6bb00b0
MR
921"
922
520cc7f1 923CMDLINE_SELECT="
3f5b56e5 924 $ARCH_EXT_LIST
520cc7f1 925 $CONFIG_LIST
8eee7025 926 $THREADS_LIST
db6107b6 927 cross_compile
520cc7f1
MR
928 debug
929 extra_warnings
8c6afa4d 930 logging
d2bbb2f7 931 optimizations
87a0fb62 932 stripping
7595a5e4 933 yasm
520cc7f1 934"
426be5dc
DB
935
936PATHS_LIST='
d156bede 937 bindir
14a8acf1 938 datadir
26759c44
MR
939 incdir
940 libdir
26759c44
MR
941 mandir
942 prefix
943 shlibdir
426be5dc
DB
944'
945
946CMDLINE_SET="
947 $PATHS_LIST
948 arch
949 build_suffix
950 cc
951 cpu
952 cross_prefix
ac63af34 953 extra_version
9da6609f
MR
954 host_cc
955 host_cflags
956 host_ldflags
957 host_libs
426be5dc 958 logfile
89641463 959 nm
26759c44 960 source_path
c5200f17
MR
961 sysinclude
962 sysroot
a7ada2ba 963 target_exec
26759c44 964 target_os
a7ada2ba 965 target_path
426be5dc 966"
520cc7f1 967
912f3148
DB
968# code dependency declarations
969
9eeed841 970# architecture extensions
79cb09b2 971altivec_deps="ppc"
3bf96eec 972amd3dnow_deps="mmx"
a1ef9f08 973amd3dnowext_deps="amd3dnow"
a2fc0f6a
MR
974armv5te_deps="arm"
975armv6_deps="arm"
ab5cb084 976armv6t2_deps="arm"
a2fc0f6a
MR
977armvfp_deps="arm"
978iwmmxt_deps="arm"
e241ba14 979mmi_deps="mips"
9eeed841 980mmx_deps="x86"
75aa95a6 981mmx2_deps="mmx"
a2fc0f6a 982neon_deps="arm"
799fde37 983ppc4xx_deps="ppc"
75aa95a6
DB
984sse_deps="mmx"
985ssse3_deps="sse"
bd9d34a0 986vis_deps="sparc"
9eeed841 987
b6bb00b0 988# common features
40b509b3 989oldscaler_deps="!swscale"
b6bb00b0 990
912f3148 991# decoders / encoders
47a158cb 992aac_decoder_select="fft mdct"
d8d12c15 993ac3_decoder_deps="gpl"
47a158cb
MR
994ac3_decoder_select="fft mdct"
995atrac3_decoder_select="fft mdct"
4f034993 996cavs_decoder_select="golomb"
47a158cb 997cook_decoder_select="fft mdct"
2eef7c62 998cscd_decoder_suggest="zlib"
47a158cb 999dca_decoder_select="fft mdct"
e8ed9b7a 1000dnxhd_encoder_select="aandct"
2eef7c62 1001dxa_decoder_select="zlib"
406ab5cc 1002eac3_decoder_deps="gpl"
47a158cb 1003eac3_decoder_select="fft mdct"
e8ed9b7a 1004eatgq_decoder_select="aandct"
d52b39c7 1005eatqi_decoder_select="aandct"
4f034993
MR
1006ffv1_decoder_select="golomb"
1007flac_decoder_select="golomb"
1008flac_encoder_select="golomb"
2eef7c62
AJ
1009flashsv_decoder_select="zlib"
1010flashsv_encoder_select="zlib"
e8ed9b7a
DB
1011flv_encoder_select="aandct"
1012h261_encoder_select="aandct"
1013h263_encoder_select="aandct"
1014h263p_encoder_select="aandct"
4f034993 1015h264_decoder_select="golomb"
369122dd 1016h264_vdpau_decoder_deps="vdpau"
47a158cb 1017imc_decoder_select="fft mdct"
4f034993
MR
1018jpegls_decoder_select="golomb"
1019jpegls_encoder_select="golomb"
e8ed9b7a 1020ljpeg_encoder_select="aandct"
4f034993 1021loco_decoder_select="golomb"
e8ed9b7a
DB
1022mjpeg_encoder_select="aandct"
1023mpeg1video_encoder_select="aandct"
1024mpeg2video_encoder_select="aandct"
1025mpeg4_encoder_select="aandct"
d37edddc 1026mpeg_vdpau_decoder_deps="vdpau"
2b324225 1027mpeg1_vdpau_decoder_deps="vdpau"
8f6f050a 1028mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
e8ed9b7a
DB
1029msmpeg4v1_encoder_select="aandct"
1030msmpeg4v2_encoder_select="aandct"
1031msmpeg4v3_encoder_select="aandct"
47a158cb
MR
1032nellymoser_decoder_select="fft mdct"
1033nellymoser_encoder_select="fft mdct"
2eef7c62
AJ
1034png_decoder_select="zlib"
1035png_encoder_select="zlib"
63cae55d 1036qdm2_decoder_select="fft mdct rdft"
e8ed9b7a
DB
1037rv10_encoder_select="aandct"
1038rv20_encoder_select="aandct"
d52b39c7
AJ
1039rv30_decoder_select="golomb"
1040rv40_decoder_select="golomb"
4f034993
MR
1041shorten_decoder_select="golomb"
1042sonic_decoder_select="golomb"
1043sonic_encoder_select="golomb"
1044sonic_ls_encoder_select="golomb"
1045svq3_decoder_select="golomb"
bee2eac5 1046svq3_decoder_suggest="zlib"
2eef7c62
AJ
1047tiff_decoder_suggest="zlib"
1048tiff_encoder_suggest="zlib"
1049tscc_decoder_select="zlib"
c5b42f4a 1050vc1_vdpau_decoder_deps="vdpau"
47a158cb
MR
1051vorbis_decoder_select="fft mdct"
1052vorbis_encoder_select="fft mdct"
1053wmav1_decoder_select="fft mdct"
1054wmav1_encoder_select="fft mdct"
1055wmav2_decoder_select="fft mdct"
1056wmav2_encoder_select="fft mdct"
e8ed9b7a
DB
1057wmv1_encoder_select="aandct"
1058wmv2_encoder_select="aandct"
c5b42f4a 1059wmv3_vdpau_decoder_deps="vdpau"
2eef7c62
AJ
1060zlib_decoder_select="zlib"
1061zlib_encoder_select="zlib"
1062zmbv_decoder_select="zlib"
1063zmbv_encoder_select="zlib"
30fd06be 1064
912f3148 1065# external libraries
f5a756ef
DB
1066libamr_nb_decoder_deps="libamr_nb"
1067libamr_nb_encoder_deps="libamr_nb"
1068libamr_wb_decoder_deps="libamr_wb"
1069libamr_wb_encoder_deps="libamr_wb"
1b71f045 1070libdirac_decoder_deps="libdirac !libschroedinger"
690bfceb 1071libdirac_encoder_deps="libdirac"
c9171a83 1072libfaac_encoder_deps="libfaac"
69ddbd1d 1073libfaad_decoder_deps="libfaad"
4ec45764 1074libfaadbin_decoder_extralibs='$ldl'
299c77d5
MR
1075libgsm_decoder_deps="libgsm"
1076libgsm_encoder_deps="libgsm"
8ffed8d8
MR
1077libgsm_ms_decoder_deps="libgsm"
1078libgsm_ms_encoder_deps="libgsm"
1cc60c47 1079libmp3lame_encoder_deps="libmp3lame"
9a77d59a 1080libopenjpeg_decoder_deps="libopenjpeg"
f7cd9eed
AS
1081libschroedinger_decoder_deps="libschroedinger"
1082libschroedinger_encoder_deps="libschroedinger"
ae14f311 1083libspeex_decoder_deps="libspeex"
150d2772 1084libtheora_encoder_deps="libtheora"
b0caf888 1085libvorbis_encoder_deps="libvorbis"
1cc60c47
DB
1086libx264_encoder_deps="libx264"
1087libxvid_encoder_deps="libxvid"
13566c31 1088mpeg4aac_decoder_deps="libfaad"
272081b0 1089vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
30fd06be 1090
912f3148 1091# demuxers / muxers
03a76ba9 1092ac3_demuxer_deps="ac3_parser"
35fd8122
NG
1093alsa_demuxer_deps="alsa_asoundlib_h snd_pcm_htimestamp"
1094alsa_demuxer_extralibs="-lasound"
1095alsa_muxer_deps="alsa_asoundlib_h"
1096alsa_muxer_extralibs="-lasound"
50383e88 1097audio_beos_demuxer_deps="audio_beos"
4ec45764 1098audio_beos_demuxer_extralibs="-lmedia -lbe"
50383e88 1099audio_beos_muxer_deps="audio_beos"
4ec45764 1100audio_beos_muxer_extralibs="-lmedia -lbe"
53b73365 1101avisynth_demuxer_deps="avisynth"
73483024 1102bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
17ac9f1c 1103dirac_demuxer_deps="dirac_parser"
fe9bb347 1104dv1394_demuxer_deps="dv1394 dv_demuxer"
f7b8bffe 1105libdc1394_demuxer_deps="libdc1394"
d7c59247
DB
1106libnut_demuxer_deps="libnut"
1107libnut_muxer_deps="libnut"
2eef7c62
AJ
1108matroska_demuxer_suggest="zlib bzlib"
1109mov_demuxer_suggest="zlib"
4bd8e17c 1110mp3_demuxer_deps="mpegaudio_parser"
c7682de0
RP
1111oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
1112oss_muxer_deps_any="soundcard_h sys_soundcard_h"
30fd06be 1113redir_demuxer_deps="network"
8eb793c4 1114rtp_muxer_deps="network rtp_protocol"
95c21842
LA
1115rtsp_demuxer_deps="sdp_demuxer"
1116sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
06e31011 1117v4l_demuxer_deps="linux_videodev_h"
1b6e8b73 1118v4l2_demuxer_deps_any="linux_videodev2_h sys_videoio_h"
c2345207
RP
1119vfwcap_demuxer_deps="capCreateCaptureWindow"
1120vfwcap_demuxer_extralibs="-lvfw32"
06eab4ba 1121x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
4ec45764 1122x11_grab_device_demuxer_extralibs="-lX11 -lXext"
30fd06be 1123
912f3148 1124# protocols
3fff6382 1125gopher_protocol_deps="network"
c08fb000
AB
1126http_protocol_deps="network"
1127rtp_protocol_deps="udp_protocol"
1128tcp_protocol_deps="network"
1129udp_protocol_deps="network"
1130
f7679c54 1131# filters
81124ba0 1132movie_filter_deps="avfilter_lavf"
f7679c54 1133
912f3148 1134# programs
fa859b4d 1135ffplay_deps="sdl"
6ad42348 1136ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
4ec45764
RP
1137ffserver_extralibs='$ldl'
1138vhook_extralibs='$ldl'
a2830dca 1139
912f3148 1140
de6d9b64 1141# default parameters
8a608357 1142
2ba042a7 1143logfile="config.err"
8a608357
MR
1144
1145# installation paths
c9d19248
MR
1146prefix_default="/usr/local"
1147bindir_default='${prefix}/bin'
14a8acf1 1148datadir_default='${prefix}/share/ffmpeg'
c9d19248
MR
1149incdir_default='${prefix}/include'
1150libdir_default='${prefix}/lib'
1151mandir_default='${prefix}/share/man'
1152shlibdir_default="$libdir_default"
8a608357
MR
1153
1154# toolchain
11e6d03a 1155ar="ar"
13c7df3d 1156cc_default="gcc"
9da6609f 1157host_cc_default="gcc"
11e6d03a 1158ln_s="ln -sf"
89641463 1159nm_default="nm"
11e6d03a 1160objformat="elf"
be7109c1 1161ranlib="ranlib"
0f3cb305 1162strip="strip"
11e6d03a 1163yasmexe="yasm"
8a608357
MR
1164
1165# machine
cc6a90dd 1166arch=`uname -m`
38d0a8aa 1167cpu="generic"
8a608357 1168
8a608357 1169# OS
4f854758 1170target_os=$(tolower $(uname -s))
8a608357 1171
8a608357 1172# configurable options
497237c7 1173enable debug
497237c7
RP
1174enable ffmpeg
1175enable ffplay
1176enable ffserver
1177enable ipv6
497237c7
RP
1178enable mpegaudio_hp
1179enable network
40b509b3 1180enable oldscaler
8400d6b8 1181enable optimizations
497237c7 1182enable protocols
530dc538 1183enable static
87a0fb62 1184enable stripping
8a608357
MR
1185vhook="default"
1186
8a608357 1187# build settings
11a9d3e8 1188add_cflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
9987769a 1189SHFLAGS='-shared -Wl,-soname,$$(@F)'
cab3ef82 1190VHOOKSHFLAGS='$(SHFLAGS)'
c536cb09 1191FFSERVERLDFLAGS=-Wl,-E
f3ec2d46
SG
1192LIBPREF="lib"
1193LIBSUF=".a"
c5f14466
RP
1194FULLNAME='$(NAME)$(BUILDSUF)'
1195LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
f3ec2d46
SG
1196SLIBPREF="lib"
1197SLIBSUF=".so"
c5f14466 1198SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
b29bddab
DB
1199SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
1200SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
24743a76 1201LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
ef0bc4c9 1202
9da6609f
MR
1203host_cflags='-O3 -g -Wall'
1204host_libs='-lm'
1205
a7ada2ba
MR
1206target_path='.'
1207
0d7dca36
DB
1208# gcc stupidly only outputs the basename of targets with -MM, but we need the
1209# full relative path for objects in subdirectories for non-recursive Make.
333d5374 1210DEPEND_CMD='$(CC) $(CFLAGS) -MM $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
315c741d 1211
c597172e
MR
1212# find source path
1213source_path="`dirname \"$0\"`"
497237c7 1214enable source_path_used
c597172e
MR
1215if test -z "$source_path" -o "$source_path" = "." ; then
1216 source_path="`pwd`"
497237c7 1217 disable source_path_used
c597172e
MR
1218else
1219 source_path="`cd \"$source_path\"; pwd`"
1220 echo "$source_path" | grep -q '[[:blank:]]' &&
7483e694 1221 die "Out of tree builds are impossible with whitespace in source path."
c597172e
MR
1222fi
1223
c597172e
MR
1224FFMPEG_CONFIGURATION="$@"
1225
73ef8980
MR
1226find_things(){
1227 thing=$1
1228 pattern=$2
1229 file=$source_path/$3
932ccf39 1230 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
73ef8980
MR
1231}
1232
1233ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
1234DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
1235PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
1236BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
1237MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
1238DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
1239OUTDEV_LIST=$(find_things muxer _MUX libavdevice/alldevices.c)
1240INDEV_LIST=$(find_things demuxer DEMUX libavdevice/alldevices.c)
1241PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
81124ba0 1242FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
c597172e 1243
7483e694
DB
1244enable $ARCH_EXT_LIST \
1245 $DECODER_LIST \
1246 $ENCODER_LIST \
1247 $PARSER_LIST \
1248 $BSF_LIST \
1249 $DEMUXER_LIST \
1250 $MUXER_LIST \
f7679c54 1251 $FILTER_LIST \
7483e694
DB
1252 $PROTOCOL_LIST \
1253 $INDEV_LIST \
1254 $OUTDEV_LIST \
c597172e
MR
1255
1256die_unknown(){
1257 echo "Unknown option \"$1\"."
1258 echo "See $0 --help for available options."
1259 exit 1
1260}
1261
794f8e97 1262show_list() {
bf0c4afa
RP
1263 suffix=_$1
1264 shift
1265 echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
794f8e97
PI
1266 exit 0
1267}
1268
c597172e 1269for opt do
7483e694
DB
1270 optval="${opt#*=}"
1271 case "$opt" in
0f010b2f 1272 --extra-cflags=*) add_cflags $optval
7483e694 1273 ;;
0f010b2f 1274 --extra-ldflags=*) add_ldflags $optval
7483e694 1275 ;;
0f010b2f 1276 --extra-libs=*) add_extralibs $optval
7483e694 1277 ;;
8fb1cb58 1278 --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
9aa8ed9d 1279 ;;
40bcf4c7
BL
1280 --enable-debug=*) debuglevel="$optval"
1281 ;;
7483e694
DB
1282 --enable-*=*|--disable-*=*)
1283 eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
1284 case "$thing" in
81124ba0 1285 encoder|decoder|muxer|demuxer|parser|bsf|protocol|filter) $action ${optval}_${thing} ;;
7483e694
DB
1286 *) die_unknown "$opt" ;;
1287 esac
1288 ;;
1289 --enable-?*|--disable-?*)
1290 eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
e3773a55
MR
1291 if is_in $option $COMPONENT_LIST; then
1292 eval $action \$$(toupper ${option%s})_LIST
1293 elif is_in $option $CMDLINE_SELECT; then
1294 $action $option
1295 else
1296 die_unknown $opt
1297 fi
7483e694
DB
1298 ;;
1299 --list-*)
1300 NAME="${opt#--list-}"
1301 is_in $NAME $COMPONENT_LIST || die_unknown $opt
1302 NAME=${NAME%s}
1303 eval show_list $NAME \$$(toupper $NAME)_LIST
1304 ;;
1305 --help|-h) show_help
1306 ;;
1307 *)
884a36a7 1308 optname="${opt%%=*}"
26759c44
MR
1309 optname="${optname#--}"
1310 optname=$(echo "$optname" | sed 's/-/_/g')
1311 is_in $optname $CMDLINE_SET || die_unknown $opt
1312 eval $optname='$optval'
7483e694
DB
1313 ;;
1314 esac
c597172e
MR
1315done
1316
bcea99bb
MR
1317disabled logging && logfile=/dev/null
1318
1319echo "# $0 $@" > $logfile
1320set >> $logfile
1321
9da6609f
MR
1322test -n "$cross_prefix" && enable cross_compile
1323
adb2b908 1324ar="${cross_prefix}${ar}"
11e6d03a 1325cc_default="${cross_prefix}${cc_default}"
20e0ed95 1326nm_default="${cross_prefix}${nm_default}"
adb2b908
RP
1327ranlib="${cross_prefix}${ranlib}"
1328strip="${cross_prefix}${strip}"
1329
c5200f17
MR
1330sysinclude_default="${sysroot}/usr/include"
1331
1332set_default cc nm sysinclude
9da6609f
MR
1333enabled cross_compile || host_cc_default=$cc
1334set_default host_cc
13c7df3d 1335
c0f5b7f1
MR
1336case $target_os in
1337 mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) EXESUF=.exe ;;
1338esac
1339
e4e69e0b 1340# set temporary file name
a49d42c2 1341: ${TMPDIR:=$TEMPDIR}
c51fafa1 1342: ${TMPDIR:=$TMP}
a49d42c2 1343: ${TMPDIR:=/tmp}
e4e69e0b 1344
a49d42c2
MR
1345TMPC="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
1346TMPE="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
1347TMPH="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
1348TMPO="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
1349TMPS="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
1350TMPSH="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
e4e69e0b 1351
993f2d0f
MR
1352# make sure we can execute files in $TMPDIR
1353cat > $TMPSH 2>> $logfile <<EOF
1354#! /bin/sh
1355EOF
1356chmod +x $TMPSH >> $logfile 2>&1
1357if ! $TMPSH >> $logfile 2>&1; then
1358 cat <<EOF
1359Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
1360variable to another directory and make sure that it is not mounted noexec.
1361EOF
1362 die "Sanity test failed."
1363fi
1364rm $TMPSH
1365
3a636b6f 1366if $cc --version 2>/dev/null | grep -qi gcc; then
629687f6
MR
1367 cc_type=gcc
1368elif $cc --version 2>/dev/null | grep -q Intel; then
1369 cc_type=icc
1370elif $cc -v 2>&1 | grep -q xlc; then
1371 cc_type=xlc
df442a8d
MR
1372elif $cc -V 2>/dev/null | grep -q Compaq; then
1373 cc_type=ccc
1374 DEPEND_CMD='$(CC) $(CFLAGS) -M $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
1375 add_ldflags -Wl,-z,now # calls to libots crash without this
629687f6
MR
1376fi
1377
1378test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
1379
154d432c
MR
1380if test -n "$sysroot"; then
1381 case "$cc_type" in
1382 gcc)
1383 add_cflags --sysroot="$sysroot"
1384 add_ldflags --sysroot="$sysroot"
1385 ;;
1386 esac
1387fi
1388
993f2d0f
MR
1389# compiler sanity check
1390check_exec <<EOF
1391int main(void){ return 0; }
1392EOF
1393if test "$?" != 0; then
1394 echo "$cc is unable to create an executable file."
1395 if test -z "$cross_prefix" && ! enabled cross_compile ; then
1396 echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
1397 echo "Only do this if you know what cross compiling means."
1398 fi
1399 die "C compiler test failed."
1400fi
1401
e9b9a2f8
MN
1402check_cflags -std=c99
1403
b24dbcbd 1404case "$arch" in
b24dbcbd
RP
1405 alpha)
1406 arch="alpha"
1407 enable fast_64bit
c0a02a3e 1408 check_cflags -mieee
b24dbcbd 1409 ;;
cfdb6148
MR
1410 arm|armv[4567]*l)
1411 arch="arm"
b24dbcbd 1412 ;;
f4870943
MR
1413 avr32)
1414 ;;
cfdb6148
MR
1415 bfin)
1416 arch="bfin"
1417 ;;
1418 ia64)
1419 arch="ia64"
b24dbcbd 1420 enable fast_64bit
cfdb6148
MR
1421 ;;
1422 m68k)
1423 arch="m68k"
b24dbcbd 1424 ;;
de3a1240 1425 mips|mipsel|IP*)
b24dbcbd
RP
1426 arch="mips"
1427 ;;
de3a1240
DB
1428 mips64)
1429 arch="mips"
1430 enable fast_64bit
1431 ;;
61597a98 1432 parisc|hppa)
b24dbcbd
RP
1433 arch="parisc"
1434 ;;
61597a98 1435 parisc64|hppa64)
b24dbcbd
RP
1436 arch="parisc"
1437 enable fast_64bit
1438 ;;
cfdb6148
MR
1439 "Power Macintosh"|ppc|powerpc)
1440 arch="ppc"
1441 enable fast_unaligned
1442 ;;
1443 ppc64)
1444 arch="ppc"
1445 enable fast_64bit
1446 enable fast_unaligned
1447 ;;
b24dbcbd
RP
1448 s390|s390x)
1449 arch="s390"
1450 ;;
cfdb6148
MR
1451 sh4|sh)
1452 arch="sh4"
b24dbcbd 1453 ;;
cfdb6148
MR
1454 sparc)
1455 arch="sparc"
1456 ;;
1457 sun4u|sparc64)
1458 arch="sparc"
1459 subarch="sparc64"
b24dbcbd
RP
1460 enable fast_64bit
1461 ;;
cfdb6148
MR
1462 i386|i486|i586|i686|i86pc|BePC)
1463 arch="x86"
1464 subarch="x86_32"
1465 enable fast_unaligned
1466 ;;
1467 x86_64|amd64)
1468 arch="x86"
1469 subarch="x86_32"
1470 enable cmov
1471 enable fast_cmov
1472 enable fast_unaligned
1473 check_cc <<EOF && enable fast_64bit && subarch="x86_64"
1474 int test[sizeof(char*) - 7];
1475EOF
b24dbcbd
RP
1476 ;;
1477 *)
1478 arch="unknown"
1479 ;;
1480esac
1481
62045d48 1482enable $arch $subarch
b24dbcbd 1483
7483e694 1484# OS specific
4f854758 1485case $target_os in
7483e694 1486 beos|haiku|zeta)
c9d19248 1487 prefix_default="$HOME/config"
7483e694 1488 # helps building libavcodec
0f010b2f 1489 add_cflags -DPIC -fomit-frame-pointer
7483e694
DB
1490 # 3 gcc releases known for BeOS, each with ugly bugs
1491 gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
1492 case "$gcc_version" in
1493 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
1494 disable mmx
1495 ;;
1496 *20010315*) echo "BeBits gcc"
0f010b2f 1497 add_cflags -fno-expensive-optimizations
7483e694
DB
1498 ;;
1499 esac
7483e694
DB
1500 SHFLAGS=-nostart
1501 # enable BeOS things
1502 enable audio_beos
1503 # no need for libm, but the inet stuff
1504 # Check for BONE
1505 # XXX: actually should check for NOT net_server
78fe7631 1506 if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
7483e694
DB
1507 network_extralibs="-lbind -lsocket"
1508 else
1509 enable beos_netserver
1510 network_extralibs="-lnet"
1511 fi ;;
1512 sunos)
1513 FFSERVERLDFLAGS=""
9987769a 1514 SHFLAGS='-shared -Wl,-h,$$(@F)'
7483e694 1515 network_extralibs="-lsocket -lnsl"
e193c74e 1516 add_cflags -D__EXTENSIONS__
7483e694
DB
1517 ;;
1518 netbsd)
1519 oss_demuxer_extralibs="-lossaudio"
1520 oss_muxer_extralibs="-lossaudio"
1521 ;;
1522 openbsd)
1523 disable need_memalign
1524 LIBOBJFLAGS='$(PIC)'
7483e694 1525 SHFLAGS='-shared'
7483e694
DB
1526 oss_demuxer_extralibs="-lossaudio"
1527 oss_muxer_extralibs="-lossaudio"
1528 ;;
1529 freebsd)
1530 disable need_memalign
1531 ;;
1532 bsd/os)
1533 osextralibs="-lpoll -lgnugetopt"
1534 strip="strip -d"
1535 ;;
1536 darwin)
1537 disable need_memalign
0138c54e 1538 SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
9987769a 1539 VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$$(@F)'
7483e694
DB
1540 strip="strip -x"
1541 FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
1542 SLIBSUF=".dylib"
1543 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
1544 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
1545 FFSERVERLDFLAGS=-Wl,-bind_at_load
304d586d 1546 objformat="macho"
1b0f6fb8 1547 enabled x86_64 && objformat="macho64"
7483e694
DB
1548 ;;
1549 mingw32*)
4f854758 1550 target_os=mingw32
dcc01c06 1551 LIBTARGET=i386
1fc9fb8a 1552 if enabled x86_64; then
dcc01c06
RP
1553 disable need_memalign
1554 LIBTARGET=x64
1555 fi
fbd971a4 1556 shlibdir_default="$bindir_default"
7483e694
DB
1557 VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1558 VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
13ca50f3 1559 if enabled swscale; then
7483e694
DB
1560 VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1561 VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1562 fi
1563 disable ffserver
1564 SLIBPREF=""
1565 SLIBSUF=".dll"
7483e694
DB
1566 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1567 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
dcc01c06 1568 SLIB_EXTRA_CMD='-lib /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
4c25d159
RP
1569 SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
1570 install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"'
7483e694 1571 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
71c61f62 1572 SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
304d586d 1573 objformat="win32"
bc574408 1574 enable dos_paths
b1549d61 1575 if ! enabled x86_64; then
f7ad5aa2
RP
1576 check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
1577 die "ERROR: MinGW runtime version must be >= 3.15."
1578 enabled_any avisynth vfwcap_demuxer &&
1579 { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
1580 die "ERROR: avisynth and vfwcap_demuxer require w32api version 3.13 or later."; }
1581 fi
7483e694
DB
1582 ;;
1583 cygwin*)
4f854758 1584 target_os=cygwin
fbd971a4 1585 shlibdir_default="$bindir_default"
7483e694
DB
1586 VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
1587 VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
13ca50f3 1588 if enabled swscale; then
7483e694
DB
1589 VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
1590 VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
1591 fi
7483e694
DB
1592 SLIBPREF="cyg"
1593 SLIBSUF=".dll"
1594 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
1595 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
1596 SHFLAGS='-shared -Wl,--enable-auto-image-base'
304d586d 1597 objformat="win32"
bc574408 1598 enable dos_paths
7483e694 1599 ;;
4f365f37 1600 *-dos|freedos|opendos)
4f365f37
MK
1601 disable ffplay ffserver vhook
1602 disable $INDEV_LIST $OUTDEV_LIST
1603 network_extralibs="-lsocket"
ff1c015d 1604 objformat="coff"
bc574408 1605 enable dos_paths
4f365f37 1606 ;;
7483e694 1607 linux)
7483e694
DB
1608 enable dv1394
1609 ;;
1610 irix*)
4f854758 1611 target_os=irix
7483e694
DB
1612 ranlib="echo ignoring ranlib"
1613 ;;
d22e8442 1614 os/2*)
d22e8442
DY
1615 strip="lxlite"
1616 ln_s="cp -f"
d22e8442 1617 FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
71c61f62 1618 SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
d22e8442 1619 FFSERVERLDFLAGS=""
287d3b13 1620 LIBSUF="_s.a"
d22e8442
DY
1621 SLIBPREF=""
1622 SLIBSUF=".dll"
1623 SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
1624 SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
71c61f62
MR
1625 SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
1626 echo PROTMODE >> $(SUBDIR)$(NAME).def; \
1627 echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
1628 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
1629 echo EXPORTS >> $(SUBDIR)$(NAME).def; \
1630 emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
1631 SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
1632 emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
1633 SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
d22e8442 1634 SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
c6eed369 1635 disable vhook
bc574408 1636 enable dos_paths
d22e8442 1637 ;;
269820f1
PR
1638 interix)
1639 disable vhook
1640 ;;
d22e8442 1641
7483e694 1642 *)
4f924f9a 1643 die "Unknown OS '$target_os'."
7483e694
DB
1644 ;;
1645esac
1646
c9d19248
MR
1647set_default $PATHS_LIST
1648
c597172e 1649add_extralibs $osextralibs
de6d9b64 1650
28d8e661
DB
1651# Combine FFLDFLAGS and the LDFLAGS environment variable.
1652LDFLAGS="$FFLDFLAGS $LDFLAGS"
e89b8b0a 1653
320d060a 1654# we need to build at least one lib type
93b3c083 1655if ! enabled_any static shared; then
320d060a
DB
1656 cat <<EOF
1657At least one library type must be built.
1658Specify --enable-static to build the static libraries or --enable-shared to
1659build the shared libraries as well. To only build the shared libraries specify
1660--disable-static in addition to --enable-shared.
1661EOF
1662 exit 1;
1663fi
1664
abc4e572 1665disabled static && LIBNAME=""
2a320695 1666
a2234ceb
RP
1667if enabled_any libfaad libfaadbin ; then
1668 if check_header faad.h; then
295b8c70 1669 check_cc <<EOF
a2234ceb
RP
1670#include <faad.h>
1671#ifndef FAAD2_VERSION
1672ok faad1
1673#endif
db817cf3 1674int main(void) { return 0; }
a2234ceb
RP
1675EOF
1676 test $? = 0 && enable libfaad2
1677 else
ff3dac65 1678 die "FAAD test failed."
a2234ceb
RP
1679 fi
1680fi
1681
1682
93b3c083 1683if ! enabled gpl; then
54118497
RP
1684 die_gpl_disabled(){
1685 name=$1
1686 shift
1687 enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
1688 }
4a24ab64 1689 die_gpl_disabled "The Postprocessing code" postproc
1cc60c47
DB
1690 die_gpl_disabled "libx264" libx264
1691 die_gpl_disabled "libxvidcore" libxvid
54118497
RP
1692 die_gpl_disabled "FAAD2" libfaad2
1693 die_gpl_disabled "The X11 grabber" x11grab
76022763 1694 die_gpl_disabled "The software scaler" swscale
ebb810d9 1695fi
b2e3c528 1696
3fe142e2
DB
1697if ! enabled nonfree && enabled_any libamr_nb libamr_wb; then
1698 die "libamr is nonfree and --enable-nonfree is not specified."
1699fi
1700
9eeed841 1701check_deps $ARCH_EXT_LIST
0f3cb305 1702
5d323602
MR
1703test -z "$need_memalign" && need_memalign="$mmx"
1704
cf9d24ad 1705#Darwin CC versions
4f854758 1706if test $target_os = darwin; then
629687f6 1707 if enabled xlc; then
0f010b2f 1708 add_cflags -qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto
cf9d24ad 1709 else
0f010b2f
DB
1710 add_cflags -pipe
1711 check_cflags -force_cpusubtype_ALL
1712 check_cflags -Wno-sign-compare
f946a9a4 1713 enabled shared || check_cflags -mdynamic-no-pic
cf9d24ad 1714 fi
2a1a6b64
MN
1715fi
1716
40617a6d 1717disabled optimizations || check_cflags -fomit-frame-pointer
cf9d24ad 1718
a4adb608 1719# Add processor-specific flags
38d0a8aa 1720if test $cpu != "generic"; then
bc8ec47b
MR
1721 warn_altivec(){
1722 $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
1658bc4f 1723 }
38d0a8aa 1724 case $cpu in
bb270c08 1725 601|ppc601|PowerPC601)
0f010b2f 1726 add_cflags -mcpu=601
bc8ec47b 1727 warn_altivec enabled PPC601
bb270c08
DB
1728 ;;
1729 603*|ppc603*|PowerPC603*)
0f010b2f 1730 add_cflags -mcpu=603
bc8ec47b 1731 warn_altivec enabled PPC603
bb270c08
DB
1732 ;;
1733 604*|ppc604*|PowerPC604*)
0f010b2f 1734 add_cflags -mcpu=604
bc8ec47b 1735 warn_altivec enabled PPC604
bb270c08
DB
1736 ;;
1737 G3|g3|75*|ppc75*|PowerPC75*)
0f010b2f 1738 add_cflags -mcpu=750 -mpowerpc-gfxopt
bc8ec47b 1739 warn_altivec enabled PPC75x
bb270c08
DB
1740 ;;
1741 G4|g4|745*|ppc745*|PowerPC745*)
0f010b2f 1742 add_cflags -mcpu=7450 -mpowerpc-gfxopt
bc8ec47b 1743 warn_altivec disabled PPC745x
bb270c08
DB
1744 ;;
1745 74*|ppc74*|PowerPC74*)
0f010b2f 1746 add_cflags -mcpu=7400 -mpowerpc-gfxopt
bc8ec47b 1747 warn_altivec disabled PPC74xx
bb270c08
DB
1748 ;;
1749 G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
0f010b2f 1750 add_cflags -mcpu=970 -mpowerpc-gfxopt -mpowerpc64
bc8ec47b 1751 warn_altivec disabled PPC970
9cafbd6c 1752 enable ppc64
bb270c08 1753 ;;
e07e357d 1754 Cell|CELL|cell)
0f010b2f 1755 add_cflags -mcpu=cell
e07e357d 1756 warn_altivec disabled Cell
9cafbd6c 1757 enable ppc64
e07e357d 1758 ;;
e7768fc5
GP
1759 # targets that do NOT support conditional mov (cmov)
1760 i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
0f010b2f 1761 add_cflags -march=$cpu
497237c7 1762 disable cmov
e7768fc5
GP
1763 ;;
1764 # targets that do support conditional mov (cmov)
416519dd 1765 i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
0f010b2f 1766 add_cflags -march=$cpu
497237c7
RP
1767 enable cmov
1768 enable fast_cmov
94e4c3a3
GP
1769 ;;
1770 # targets that do support conditional mov but on which it's slow
800a5a19 1771 pentium4|pentium4m|prescott|nocona)
0f010b2f 1772 add_cflags -march=$cpu
497237c7
RP
1773 enable cmov
1774 disable fast_cmov
bb270c08 1775 ;;
d7b34d08 1776 sparc64)
0f010b2f 1777 add_cflags -mcpu=v9
d7b34d08 1778 ;;
f2e49553 1779 arm11*|cortex*)
0f010b2f 1780 add_cflags -mcpu=$cpu
f2e49553
MR
1781 enable fast_unaligned
1782 ;;
0223bd6f 1783 armv*)
0f010b2f 1784 add_cflags -march=$cpu
0223bd6f 1785 ;;
f2e49553 1786 arm*)
0f010b2f 1787 add_cflags -mcpu=$cpu
6b19786b 1788 ;;
1cd11856 1789 ev4|ev45|ev5|ev56|pca56|ev6|ev67)
df442a8d 1790 enabled ccc && add_cflags -arch $cpu || add_cflags -mcpu=$cpu
1cd11856 1791 ;;
bb270c08 1792 *)
7483e694 1793 echo "WARNING: Unknown CPU \"$cpu\", ignored."
bb270c08 1794 ;;
a4adb608
MN
1795 esac
1796fi
1797
b4d96ba2
MR
1798check_cc <<EOF || die "Symbol mangling check failed."
1799int ff_extern;
1800EOF
2f05d9c1 1801sym=$($nm -P -g $TMPO | grep ff_extern)
b4d96ba2
MR
1802extern_prefix=${sym%%ff_extern*}
1803
61d251db
MR
1804check_asm inline_asm '""'
1805
9eeed841 1806if enabled x86; then
44965991
PI
1807 # check whether EBP is available on x86
1808 # As 'i' is stored on the stack, this program will crash
1809 # if the base pointer is used to access it because the
1810 # base pointer is cleared in the inline assembly code.
7dfef245 1811 check_exec_crash <<EOF && enable ebp_available
44965991 1812 volatile int i=0;
be449fca 1813 __asm__ volatile (
44965991
PI
1814 "xorl %%ebp, %%ebp"
1815 ::: "%ebp");
1816 return i;
44965991
PI
1817EOF
1818
1819 # check wether EBX is available on x86
940f335a 1820 check_asm ebx_available '"":::"%ebx"'
8e380710 1821
d3a4b4e0
DB
1822 # check whether more than 10 operands are supported
1823 check_cc <<EOF && enable ten_operands
1824int main(void) {
1825 int x=0;
1826 __asm__ volatile(
1827 ""
1828 :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
1829 );
1830 return 0;
1831}
1832EOF
1833
d7f0920b 1834 # check whether binutils is new enough to compile SSSE3/MMX2
940f335a 1835 enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
d7f0920b 1836 enabled mmx2 && check_asm mmx2 '"movss %xmm0, %xmm0"'
6bd859d6
MR
1837
1838 check_asm bswap '"bswap %%eax" ::: "%eax"'
304d586d 1839
d52481b9 1840 YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
304d586d
LM
1841 enabled x86_64 && append YASMFLAGS "-m amd64"
1842 enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
1843 case "$objformat" in
1844 elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
1b0f6fb8 1845 macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
304d586d
LM
1846 *) append YASMFLAGS "-DPREFIX" ;;
1847 esac
7595a5e4 1848 disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
44965991
PI
1849fi
1850
87ea51e0
LB
1851# check for assembler specific support
1852
5b6c2cbd 1853enabled ppc && check_asm dcbzl '"dcbzl 0, 1"'
799fde37 1854enabled ppc && check_asm ppc4xx '"maclhw r10, r11, r12"'
87ea51e0 1855
57bd82d4
MR
1856# check for SIMD availability
1857
115329f1 1858# AltiVec flags: The FSF version of GCC differs from the Apple version
9eeed841 1859if enabled altivec; then
3ed1a2ee
DB
1860 check_cflags -maltivec -mabi=altivec &&
1861 { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
4477b9f4 1862 check_cflags -faltivec
b6e52719 1863
0182fee8 1864 # check if our compiler supports Motorola AltiVec C API
497237c7 1865 check_cc <<EOF || disable altivec
dcd479c0 1866$inc_altivec_h
a9a07762
MN
1867int main(void) {
1868 vector signed int v1, v2, v3;
1869 v1 = vec_add(v2,v3);
1870 return 0;
1871}
1872EOF
b006b26c
DB
1873
1874 # check if our compiler supports braces for vector declarations
80a61f08 1875 check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
b006b26c 1876$inc_altivec_h
80a61f08 1877int main (void) { (vector int) {1}; return 0; }
b006b26c 1878EOF
a9a07762 1879fi
ab6c65f6 1880
b4e806b2 1881# We have to check if pld is a nop and disable it.
a2fc0f6a 1882enabled arm && check_asm pld '"pld [r0]"'
940f335a
MR
1883enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
1884enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
ab5cb084 1885enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
f55b299a 1886enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
940f335a
MR
1887enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
1888enabled mmi && check_asm mmi '"lq $2, 0($2)"'
6b18d278 1889enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
940f335a 1890enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
bd9d34a0 1891
0f010b2f 1892enabled vis && add_cflags -mcpu=ultrasparc -mtune=ultrasparc
8b03def6 1893
57bd82d4
MR
1894# ---
1895# big/little-endian test
9eebe687
MR
1896check_cc <<EOF || die "endian test failed"
1897unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
a3999908 1898EOF
d04d9e16 1899od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
487a54d7 1900
a3999908 1901# ---
3d204385
NK
1902# check availability of some header files
1903
a98bb16d
RP
1904if check_func dlopen; then
1905 ldl=
1906elif check_func dlopen -ldl; then
1907 ldl=-ldl
8bf5d58f
MN
1908fi
1909
75ecf149
DB
1910# Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
1911check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
1912
7483e694
DB
1913check_func fork
1914check_func gethrtime
1915check_func getrusage
094c09bb 1916check_func inet_aton $network_extralibs
7483e694
DB
1917check_func memalign
1918check_func mkstemp
1f91cdce 1919check_func posix_memalign
b507ebd1 1920check_func_headers io.h setmode
2446d3d6 1921check_func_headers windows.h GetProcessTimes
6ffa87d3 1922
e16e49ac 1923check_header conio.h
a98bb16d
RP
1924check_header dlfcn.h
1925check_header malloc.h
bf6ce82d 1926check_header poll.h
b58412f1 1927check_header sys/mman.h
b091aa44 1928check_header sys/resource.h
bf6ce82d 1929check_header sys/select.h
a98bb16d 1930check_header termios.h
272081b0
CEH
1931check_header vdpau/vdpau.h
1932check_header vdpau/vdpau_x11.h
68178ca9 1933check_header X11/extensions/XvMClib.h
a98bb16d 1934
1f91cdce
RP
1935if ! enabled_any memalign memalign_hack posix_memalign && enabled need_memalign ; then
1936 die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
a98bb16d 1937fi
e16e49ac 1938
a4fa192c 1939disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
632948bd 1940disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
57bd82d4
MR
1941
1942# check for some common methods of building with pthread support
1943# do this before the optional library checks as some of them require pthreads
1944if enabled pthreads; then
9e7fd101
MR
1945 if check_func pthread_create; then
1946 :
1947 elif check_func pthread_create -pthread; then
1948 add_cflags -pthread
afc9aee2 1949 add_extralibs -pthread
9e7fd101
MR
1950 elif check_func pthread_create -pthreads; then
1951 add_cflags -pthreads
afc9aee2 1952 add_extralibs -pthreads
8d94f606
GT
1953 elif check_func pthread_create -lpthreadGC2; then
1954 add_extralibs -lpthreadGC2
9e7fd101
MR
1955 elif ! check_lib pthread.h pthread_create -lpthread; then
1956 die "ERROR: can't find pthreads library"
1957 fi
57bd82d4
MR
1958fi
1959
8eee7025 1960for thread in $THREADS_LIST; do
e5f94c2b 1961 if enabled $thread; then
3ae3b721
RP
1962 test -n "$thread_type" &&
1963 die "ERROR: Only one thread type must be selected." ||
e5f94c2b 1964 thread_type="$thread"
e5f94c2b
RP
1965 fi
1966done
1967
fdf88598
MR
1968check_lib math.h sin -lm
1969
a33cab3a 1970# test for C99 functions in math.h
7b04b8a0 1971for func in llrint lrint lrintf round roundf truncf; do
a33cab3a 1972 check_exec <<EOF && enable $func || disable $func
f32adb22 1973#include <math.h>
a33cab3a 1974int main(void) { return ($func(3.999f) > 0)?0:1; }
f32adb22 1975EOF
a33cab3a 1976done
f32adb22 1977
57bd82d4 1978# these are off by default, so fail if requested and not available
79fda097 1979enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
7483e694
DB
1980enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
1981enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
e3cc7d6f 1982enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
36718e51
DB
1983 require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init -ldirac_decoder &&
1984 require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init -ldirac_encoder
79fda097
DB
1985enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
1986enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
7483e694 1987enabled libgsm && require libgsm gsm.h gsm_create -lgsm
2bfecf73 1988enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame -lm
7483e694 1989enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
3d6fac8c 1990enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
36718e51
DB
1991enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
1992 require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
ae14f311 1993enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
7483e694
DB
1994enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
1995enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
2bfecf73 1996enabled libx264 && require libx264 x264.h x264_encoder_open -lx264 -lm &&
57f0ec6e
MR
1997 { check_cpp_condition x264.h "X264_BUILD >= 65" ||
1998 die "ERROR: libx264 version must be >= 0.65."; }
2bfecf73 1999enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
7483e694 2000enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
8ac17293 2001
0b4a1821
AS
2002# libdc1394 check
2003if enabled libdc1394; then
2004 { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
2005 enable libdc1394_2; } ||
2006 { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
2007 enable libdc1394_1; } ||
2008 die "ERROR: No version of libdc1394 found "
2009fi
2010
2011
c13e1abd
FH
2012_restrict=
2013for restrict_keyword in restrict __restrict__ __restrict; do
57bd82d4 2014 check_cc <<EOF && _restrict=$restrict_keyword && break
dcd479c0
MR
2015void foo(char * $restrict_keyword p);
2016EOF
c13e1abd
FH
2017done
2018
703afd07 2019test "$vhook" = "default" && vhook="$dlopen"
a8721c09 2020
4f854758 2021if test "$target_os" = cygwin -o "$target_os" = mingw32 && enabled_all static vhook ; then
497237c7 2022 disable vhook
fbb9d104 2023 echo
b0268cc0 2024 echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
fbb9d104
VP
2025 echo "Patches welcome."
2026 echo
2027fi
2028
8d923001
MR
2029if enabled vhook; then
2030 check_ldflags -rdynamic
2031 check_ldflags -export-dynamic
2032fi
bfd2edeb 2033
eea50282
MR
2034check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
2035check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
04511d53 2036
a86b921c 2037##########################################
29799f8b 2038# SDL check
a86b921c 2039
497237c7
RP
2040disable sdl_too_old
2041disable sdl
6a1a892f 2042SDL_CONFIG="${cross_prefix}sdl-config"
2270b4b2 2043if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
225e21ef
MR
2044 sdl_cflags=`"${SDL_CONFIG}" --cflags`
2045 temp_cflags $sdl_cflags
dcd479c0 2046 temp_extralibs `"${SDL_CONFIG}" --libs`
1ca5d97f 2047 if check_lib2 SDL.h SDL_Init; then
dcd479c0 2048 _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
29f3b38a 2049 if test "$_sdlversion" -lt 121 ; then
497237c7 2050 enable sdl_too_old
dcd479c0 2051 else
497237c7 2052 enable sdl
225e21ef 2053 check_cc $sdl_cflags <<EOF && enable sdl_video_size
29f3b38a 2054#include <SDL.h>
d6773f56 2055int main(int argc, char **argv){
29f3b38a
MR
2056 const SDL_VideoInfo *vi = SDL_GetVideoInfo();
2057 int w = vi->current_w;
2058 return 0;
2059}
2060EOF
dcd479c0
MR
2061 fi
2062 fi
29f3b38a 2063 restore_flags
c3f6b472 2064fi
57bd82d4 2065
2270b4b2 2066texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
146ea952 2067
7a91333f 2068##########################################
73b46a95
RP
2069# Network check
2070
2071if enabled network; then
96000432 2072 check_type "sys/types.h sys/socket.h" socklen_t
73b46a95
RP
2073 # Prefer arpa/inet.h over winsock2
2074 if check_header arpa/inet.h ; then
2075 check_func closesocket
2076 elif check_header winsock2.h ; then
ea10ddde 2077 network_extralibs="-lws2_32"
72be9e73 2078 check_type ws2tcpip.h socklen_t
2446d3d6 2079 check_func_headers winsock2.h closesocket
73b46a95
RP
2080 fi
2081fi
2082
2083##########################################
29799f8b 2084# IPv6 check
7a91333f 2085
497237c7 2086enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
7a91333f
HZ
2087#include <sys/types.h>
2088#include <sys/socket.h>
2089#include <netinet/in.h>
2090#include <netdb.h>
db817cf3 2091int main(void) {
7483e694
DB
2092 struct sockaddr_storage saddr;
2093 struct ipv6_mreq mreq6;
2094 getaddrinfo(0,0,0,0);
2095 getnameinfo(0,0,0,0,0,0,0);
2096 IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
7a91333f
HZ
2097}
2098EOF
2099
06e31011
RP
2100check_header linux/videodev.h
2101check_header linux/videodev2.h
1b6e8b73 2102check_header sys/videoio.h
47f38850 2103
2446d3d6 2104check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
c2345207 2105
f8aa696f 2106# check for ioctl_meteor.h, ioctl_bt848.h and alternatives
1c915f83
RP
2107{ check_header dev/bktr/ioctl_meteor.h &&
2108 check_header dev/bktr/ioctl_bt848.h; } ||
2109{ check_header machine/ioctl_meteor.h &&
2110 check_header machine/ioctl_bt848.h; } ||
2111{ check_header dev/video/meteor/ioctl_meteor.h &&
2112 check_header dev/video/bktr/ioctl_bt848.h; } ||
2113check_header dev/ic/bt8xx.h
f8aa696f 2114
c7682de0
RP
2115check_header sys/soundcard.h
2116check_header soundcard.h
deb29777 2117
35fd8122
NG
2118check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
2119
7483e694 2120# deal with the X11 frame grabber
56a059ac 2121enabled x11grab &&
f58f4ce1
GP
2122check_header X11/Xlib.h &&
2123check_header X11/extensions/XShm.h &&
2124check_func XOpenDisplay -lX11 &&
06eab4ba 2125check_func XShmCreateImage -lX11 -lXext
f58f4ce1 2126
40bcf4c7 2127enabled debug && add_cflags -g"$debuglevel"
57bd82d4
MR
2128
2129# add some useful compiler flags if supported
2130check_cflags -Wdeclaration-after-statement
dcd479c0
MR
2131check_cflags -Wall
2132check_cflags -Wno-switch
c07bd6a9
MN
2133check_cflags -Wdisabled-optimization
2134check_cflags -Wpointer-arith
2135check_cflags -Wredundant-decls
cc1fb623 2136check_cflags -Wno-pointer-sign
f4929996 2137check_cflags -Wcast-qual
9aceb3cf 2138check_cflags -Wwrite-strings
652a5bf6 2139check_cflags -Wtype-limits
764551c6 2140check_cflags -Wundef
5af4e0cc 2141enabled extra_warnings && check_cflags -Winline
cf9d24ad 2142
57bd82d4 2143# add some linker flags
5c0e9479 2144check_ldflags -Wl,--warn-common
8351d2ba
DB
2145check_ldflags -Wl,--as-needed
2146check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
c2fd6530 2147check_ldflags -Wl,-Bsymbolic
94a3401e 2148
bd2216e4
MR
2149if enabled small; then
2150 check_cflags -Os # not all compilers support -Os
8400d6b8
DB
2151 optimizations="small"
2152elif enabled optimizations; then
629687f6 2153 if enabled xlc; then
0f010b2f
DB
2154 add_cflags -O5
2155 add_ldflags -O5
df442a8d
MR
2156 elif enabled ccc; then
2157 add_cflags -fast
cf9d24ad 2158 else
0f010b2f 2159 add_cflags -O3
cf9d24ad 2160 fi
cddf3f45 2161fi
11fdbc44 2162check_cflags -fno-math-errno
b2eb2ff0 2163check_cflags -fno-signed-zeros
cddf3f45 2164
504a64b9 2165# add some flags for Intel C Compiler
629687f6 2166if enabled icc; then
b1598b58
MR
2167 # Just warnings, no remarks
2168 check_cflags -w1
2169 # -wd: Disable following warnings
2170 # 144, 167, 556: -Wno-pointer-sign
2171 # 10006: ignoring unknown option -fno-signed-zeros
2172 # 10156: ignoring option '-W'; no argument required
2173 check_cflags -wd144,167,556,10006,10156
2174 # 11030: Warning unknown option --as-needed
2175 # 10156: ignoring option '-export'; no argument required
2176 check_ldflags -wd10156,11030
2177 # Allow to compile with optimizations
2178 check_ldflags -march=$cpu
df442a8d
MR
2179elif enabled ccc; then
2180 # disable some annoying warnings
2181 add_cflags -msg_disable cvtu32to64
2182 add_cflags -msg_disable embedcomment
2183 add_cflags -msg_disable needconstext
2184 add_cflags -msg_disable nomainieee
2185 add_cflags -msg_disable ptrmismatch1
2186 add_cflags -msg_disable unreachcode
504a64b9
CEH
2187fi
2188
80581e98 2189# PIC flags for shared library objects where they are needed
5af4e0cc 2190if enabled shared; then
569cb218
MR
2191 # LIBOBJFLAGS may have already been set in the OS configuration
2192 if test -z "$LIBOBJFLAGS" ; then
a8e28698 2193 case "${subarch-$arch}" in
b6bd7268 2194 x86_64|ia64|alpha|sparc*|power*|parisc*|mips*) LIBOBJFLAGS='$(PIC)' ;;
569cb218
MR
2195 esac
2196 fi
80581e98
MN
2197fi
2198
90be59ef 2199if enabled gprof; then
0f010b2f
DB
2200 add_cflags -p
2201 add_ldflags -p
1db54e20
DB
2202fi
2203
3b26ee47 2204VHOOKCFLAGS="-fPIC"
18451f7d 2205
7f3c02fc 2206# Find out if the .align argument is a power of two or not.
9377b6ce 2207check_asm asmalign_pot '".align 3"'
4454dc1b 2208
7483e694
DB
2209enabled_any $DECODER_LIST && enable decoders
2210enabled_any $ENCODER_LIST && enable encoders
2211enabled_any $BSF_LIST && enable bsfs
2212enabled_any $DEMUXER_LIST && enable demuxers
2213enabled_any $MUXER_LIST && enable muxers
f7679c54 2214enabled_any $FILTER_LIST && enable filters
7483e694
DB
2215enabled_any $INDEV_LIST && enable demuxers
2216enabled_any $OUTDEV_LIST && enable muxers
2217enabled_any $PROTOCOL_LIST && enable protocols
2218
2219enabled_any $THREADS_LIST && enable threads
2220
2221check_deps $CONFIG_LIST \
b6bb00b0 2222 $CONFIG_EXTRA \
7483e694
DB
2223 $HAVE_LIST \
2224 $DECODER_LIST \
2225 $ENCODER_LIST \
2226 $PARSER_LIST \
2227 $BSF_LIST \
2228 $DEMUXER_LIST \
2229 $MUXER_LIST \
f7679c54 2230 $FILTER_LIST \
7483e694
DB
2231 $INDEV_LIST \
2232 $OUTDEV_LIST \
2233 $PROTOCOL_LIST \
f70f03f6 2234
3e89171a 2235echo "install prefix $prefix"
f36958f8
DB
2236echo "source path $source_path"
2237echo "C compiler $cc"
bfd5afd8 2238echo ".align is power-of-two $asmalign_pot"
f36958f8 2239echo "ARCH $arch ($cpu)"
ce8871c2
MR
2240if test "$build_suffix" != ""; then
2241 echo "build suffix $build_suffix"
eb94aca9 2242fi
ac63af34
DB
2243if test "$extra_version" != ""; then
2244 echo "version string suffix $extra_version"
2245fi
0db2ce77 2246echo "big-endian ${bigendian-no}"
5b6c2cbd 2247if enabled x86; then
af44e8e4 2248 echo "yasm ${yasm-no}"
0db2ce77 2249 echo "MMX enabled ${mmx-no}"
30e98e62 2250 echo "MMX2 enabled ${mmx2-no}"
3bf96eec 2251 echo "3DNow! enabled ${amd3dnow-no}"
a1ef9f08 2252 echo "3DNow! extended enabled ${amd3dnowext-no}"
1bb04d5a 2253 echo "SSE enabled ${sse-no}"
30e98e62 2254 echo "SSSE3 enabled ${ssse3-no}"
0db2ce77
MR
2255 echo "CMOV enabled ${cmov-no}"
2256 echo "CMOV is fast ${fast_cmov-no}"
971cc990
MN
2257 echo "EBX available ${ebx_available-no}"
2258 echo "EBP available ${ebp_available-no}"
d3a4b4e0 2259 echo "10 operands supported ${ten_operands-no}"
e41e8342 2260fi
5b6c2cbd 2261if enabled arm; then
0db2ce77
MR
2262 echo "ARMv5TE enabled ${armv5te-no}"
2263 echo "ARMv6 enabled ${armv6-no}"
ab5cb084 2264 echo "ARMv6T2 enabled ${armv6t2-no}"
f55b299a 2265 echo "ARM VFP enabled ${armvfp-no}"
0db2ce77 2266 echo "IWMMXT enabled ${iwmmxt-no}"
6b18d278 2267 echo "NEON enabled ${neon-no}"
eba9ae3c 2268fi
5b6c2cbd 2269if enabled mips; then
0db2ce77 2270 echo "MMI enabled ${mmi-no}"
e41e8342 2271fi
5b6c2cbd 2272if enabled ppc; then
0db2ce77 2273 echo "AltiVec enabled ${altivec-no}"
30e98e62 2274 echo "PPC 4xx optimizations ${ppc4xx-no}"
0db2ce77 2275 echo "dcbzl available ${dcbzl-no}"
30e98e62
DB
2276 echo "performance report ${powerpc_perf-no}"
2277fi
2278if enabled sparc; then
2279 echo "VIS enabled ${vis-no}"
e41e8342 2280fi
0db2ce77
MR
2281echo "gprof enabled ${gprof-no}"
2282echo "debug symbols ${debug-no}"
87a0fb62 2283echo "strip symbols ${stripping-no}"
8400d6b8 2284echo "optimizations ${optimizations-no}"
0db2ce77
MR
2285echo "static ${static-no}"
2286echo "shared ${shared-no}"
4a24ab64 2287echo "postprocessing support ${postproc-no}"
13ca50f3 2288echo "software scaler enabled ${swscale-no}"
f7679c54 2289echo "new filter support ${avfilter-no}"
81124ba0 2290echo "filters using lavformat ${avfilter_lavf-no}"
0db2ce77 2291echo "video hooking ${vhook-no}"
90be59ef 2292if enabled vhook; then
0db2ce77
MR
2293 echo "Imlib2 support ${imlib2-no}"
2294 echo "FreeType support ${freetype2-no}"
68892110 2295fi
0db2ce77 2296echo "network support ${network-no}"
90be59ef 2297if enabled network; then
0db2ce77 2298 echo "IPv6 support ${ipv6-no}"
bfd5afd8 2299fi
0db2ce77
MR
2300echo "threading support ${thread_type-no}"
2301echo "SDL support ${sdl-no}"
90be59ef 2302if enabled sdl_too_old; then
bfd5afd8
DB
2303 echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
2304fi
0db2ce77
MR
2305echo "Sun medialib support ${mlib-no}"
2306echo "AVISynth enabled ${avisynth-no}"
0db2ce77
MR
2307echo "libamr-nb support ${libamr_nb-no}"
2308echo "libamr-wb support ${libamr_wb-no}"
f7b8bffe 2309echo "libdc1394 support ${libdc1394-no}"
690bfceb 2310echo "libdirac enabled ${libdirac-no}"
0db2ce77
MR
2311echo "libfaac enabled ${libfaac-no}"
2312echo "libfaad enabled ${libfaad-no}"
7e0871a7 2313echo "libfaad dlopened ${libfaadbin-no}"
0db2ce77
MR
2314echo "libgsm enabled ${libgsm-no}"
2315echo "libmp3lame enabled ${libmp3lame-no}"
2316echo "libnut enabled ${libnut-no}"
9a77d59a 2317echo "libopenjpeg enabled ${libopenjpeg-no}"
f7cd9eed 2318echo "libschroedinger enabled ${libschroedinger-no}"
ae14f311 2319echo "libspeex enabled ${libspeex-no}"
0db2ce77
MR
2320echo "libtheora enabled ${libtheora-no}"
2321echo "libvorbis enabled ${libvorbis-no}"
d6bd62db
DB
2322echo "libx264 enabled ${libx264-no}"
2323echo "libxvid enabled ${libxvid-no}"
272081b0 2324echo "vdpau enabled ${vdpau-no}"
0db2ce77 2325echo "zlib enabled ${zlib-no}"
f402916e 2326echo "bzlib enabled ${bzlib-no}"
2c62e737 2327echo
de6d9b64 2328
f7679c54 2329for type in decoder encoder parser demuxer muxer protocol filter bsf indev outdev; do
8138b9db 2330 echo "Enabled ${type}s:"
f65c9da1 2331 eval list=\$$(toupper $type)_LIST
8138b9db 2332 for part in $list; do
f65c9da1
MR
2333 enabled $part && echo ${part%_*}
2334 done | sort | pr -3 -t
2335 echo
8138b9db
RP
2336done
2337
ba321adb
JK
2338license="LGPL"
2339if enabled nonfree; then
2340 license="unredistributable"
2341elif enabled gpl; then
2342 license="GPL"
2343fi
2344
2345echo "License: $license"
ca5323af 2346
cf1392e9
DB
2347echo "Creating config.mak and config.h..."
2348
29799f8b
DB
2349echo "# Automatically generated by configure - do not modify!" > config.mak
2350echo "/* Automatically generated by configure - do not modify! */" > $TMPH
9c05103f
DB
2351echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
2352echo "#define FFMPEG_CONFIG_H" >> $TMPH
0fd12426 2353echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
14a8acf1 2354echo "#define FFMPEG_DATADIR \"$(eval c_escape $datadir)\"" >> $TMPH
de6d9b64 2355
d921f03f 2356echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
c9d19248 2357echo "prefix=$prefix" >> config.mak
22a324da
DB
2358echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
2359echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
2360echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
2361echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
14a8acf1 2362echo "DATADIR=\$(DESTDIR)$datadir" >> config.mak
22a324da 2363echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
980fc7b8 2364echo "CC=$cc" >> config.mak
304d586d 2365echo "YASM=$yasmexe" >> config.mak
980fc7b8 2366echo "AR=$ar" >> config.mak
be7109c1 2367echo "RANLIB=$ranlib" >> config.mak
20369773 2368echo "LN_S=$ln_s" >> config.mak
87a0fb62 2369enabled stripping &&
3ae3b721 2370 echo "STRIP=$strip" >> config.mak ||
f25fc9b1 2371 echo "STRIP=echo ignoring strip" >> config.mak
75388c74 2372
a9b3f630 2373echo "OPTFLAGS=$CFLAGS" >> config.mak
2270b4b2 2374echo "VHOOKCFLAGS=$VHOOKCFLAGS" >> config.mak
0f3cb305 2375echo "LDFLAGS=$LDFLAGS" >> config.mak
c536cb09 2376echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
e1707f52 2377echo "SHFLAGS=$SHFLAGS" >> config.mak
304d586d 2378echo "YASMFLAGS=$YASMFLAGS" >> config.mak
408382a4 2379echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
fbb9d104 2380echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
80581e98 2381echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
5af4e0cc 2382echo "BUILD_STATIC=$static" >> config.mak
ce8871c2 2383echo "BUILDSUF=$build_suffix" >> config.mak
c5f14466 2384echo "FULLNAME=$FULLNAME" >> config.mak
f3ec2d46 2385echo "LIBPREF=$LIBPREF" >> config.mak
c5f14466 2386echo "LIBSUF=$LIBSUF" >> config.mak
24743a76 2387echo "LIBNAME=$LIBNAME" >> config.mak
f3ec2d46 2388echo "SLIBPREF=$SLIBPREF" >> config.mak
c5f14466
RP
2389echo "SLIBSUF=$SLIBSUF" >> config.mak
2390echo "EXESUF=$EXESUF" >> config.mak
ac63af34 2391echo "EXTRA_VERSION=$extra_version" >> config.mak
315c741d 2392echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
9da6609f
MR
2393echo "HOSTCC=$host_cc" >> config.mak
2394echo "HOSTCFLAGS=$host_cflags" >> config.mak
2395echo "HOSTLDFLAGS=$host_ldflags" >> config.mak
2396echo "HOSTLIBS=$host_libs" >> config.mak
a7ada2ba
MR
2397echo "TARGET_EXEC=$target_exec" >> config.mak
2398echo "TARGET_PATH=$target_path" >> config.mak
4dc62701 2399
90be59ef 2400if enabled bigendian; then
7483e694
DB
2401 echo "WORDS_BIGENDIAN=yes" >> config.mak
2402 echo "#define WORDS_BIGENDIAN 1" >> $TMPH
91d1f1a4 2403fi
44161118 2404
90be59ef 2405if enabled sdl; then
7483e694
DB
2406 echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
2407 echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
a86b921c 2408fi
90be59ef 2409if enabled texi2html; then
7483e694 2410 echo "BUILD_DOC=yes" >> config.mak
146ea952 2411fi
5a872801 2412
719c8e00
MR
2413get_version(){
2414 name=$1
2415 file=$source_path/$2
147e7692
MR
2416 eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
2417 eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
0e32c8c6
MR
2418 lcname=$(tolower $name)
2419 eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
2420 eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
719c8e00
MR
2421}
2422
147e7692
MR
2423get_version LIBSWSCALE libswscale/swscale.h
2424get_version LIBPOSTPROC libpostproc/postprocess.h
2425get_version LIBAVCODEC libavcodec/avcodec.h
2426get_version LIBAVDEVICE libavdevice/avdevice.h
2427get_version LIBAVFORMAT libavformat/avformat.h
2428get_version LIBAVUTIL libavutil/avutil.h
a6601d69 2429get_version LIBAVFILTER libavfilter/avfilter.h
5a872801 2430
5af4e0cc 2431if enabled shared; then
7483e694
DB
2432 echo "BUILD_SHARED=yes" >> config.mak
2433 echo "PIC=-fPIC -DPIC" >> config.mak
dcc01c06 2434 echo "LIBTARGET=${LIBTARGET}" >> config.mak
7483e694
DB
2435 echo "SLIBNAME=${SLIBNAME}" >> config.mak
2436 echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
2437 echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
d22e8442 2438 echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
7483e694
DB
2439 echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
2440 echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
2441 echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
0319c531 2442fi
d7e27559 2443echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
ef0bc4c9 2444echo "EXTRALIBS=$extralibs" >> config.mak
d2845d68 2445
7b5e8a27
DB
2446echo "ARCH=$arch" >> config.mak
2447
3d907e22
MR
2448print_config ARCH_ $TMPH config.mak $ARCH_LIST
2449print_config HAVE_ $TMPH config.mak $HAVE_LIST
7483e694 2450print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
b6bb00b0 2451 $CONFIG_EXTRA \
7483e694
DB
2452 $DECODER_LIST \
2453 $ENCODER_LIST \
2454 $PARSER_LIST \
2455 $BSF_LIST \
2456 $DEMUXER_LIST \
2457 $MUXER_LIST \
f7679c54 2458 $FILTER_LIST \
7483e694
DB
2459 $PROTOCOL_LIST \
2460 $INDEV_LIST \
2461 $OUTDEV_LIST \
8ac17293 2462
c13e1abd
FH
2463echo "#define restrict $_restrict" >> $TMPH
2464
bd2216e4 2465if enabled small; then
7483e694 2466 echo "#define av_always_inline" >> $TMPH
bb801c97
MN
2467fi
2468
997baf01
MR
2469echo "SRC_PATH=\"$source_path\"" >> config.mak
2470echo "SRC_PATH_BARE=$source_path" >> config.mak
2471echo "BUILD_ROOT=\"$PWD\"" >> config.mak
0f3cb305 2472
8156056e 2473# Apparently it's not possible to portably echo a backslash.
3ae3b721 2474enabled asmalign_pot &&
7483e694 2475 printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
295b8c70 2476 printf '#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\\n\\t"\n' >> $TMPH
4454dc1b 2477
b4d96ba2 2478echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
bc634f6f 2479
9c05103f
DB
2480echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
2481
b7860763 2482# Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
3ae3b721
RP
2483cmp -s $TMPH config.h &&
2484 echo "config.h is unchanged" ||
2485 mv -f $TMPH config.h
3d204385 2486
cea0ac52 2487rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
def4272a 2488
165af439 2489# build tree in object directory if source path is different from current one
90be59ef 2490if enabled source_path_used; then
165af439 2491 DIRS="\
7483e694
DB
2492 doc \
2493 libavcodec \
2494 libavcodec/alpha \
a2fc0f6a 2495 libavcodec/arm \
7483e694 2496 libavcodec/bfin \
7483e694
DB
2497 libavcodec/mlib \
2498 libavcodec/ppc \
2499 libavcodec/sh4 \
2500 libavcodec/sparc \
a6493a8f 2501 libavcodec/x86 \
52a9cf34 2502 libavdevice \
f7679c54 2503 libavfilter \
7483e694
DB
2504 libavformat \
2505 libavutil \
2506 libpostproc \
2507 libswscale \
2508 tests \
2509 tools \
2510 vhook \
2511 "
165af439 2512 FILES="\
7483e694
DB
2513 Makefile \
2514 common.mak \
71c61f62 2515 subdir.mak \
7483e694
DB
2516 doc/texi2pod.pl \
2517 libavcodec/Makefile \
52a9cf34 2518 libavdevice/Makefile \
f7679c54 2519 libavfilter/Makefile \
7483e694
DB
2520 libavformat/Makefile \
2521 libavutil/Makefile \
2522 libpostproc/Makefile \
2523 libswscale/Makefile \
2524 "
165af439 2525 for dir in $DIRS ; do
7483e694 2526 mkdir -p $dir
165af439
MR
2527 done
2528 for f in $FILES ; do
20369773 2529 $ln_s "$source_path/$f" $f
165af439
MR
2530 done
2531fi
def4272a 2532
def4272a 2533
d0674868 2534# build pkg-config files
def4272a 2535
d0674868
DB
2536pkgconfig_generate(){
2537name=$1
b0dfd108 2538shortname=${name#lib}${build_suffix}
d0674868
DB
2539comment=$2
2540version=$3
2541libs=$4
2542requires=$5
25cd5cb3 2543cat <<EOF > $name/$name.pc
3e89171a 2544prefix=$prefix
a94e666c 2545exec_prefix=\${prefix}
f2b7382c 2546libdir=$libdir
7622778e 2547includedir=$incdir
def4272a 2548
d0674868
DB
2549Name: $name
2550Description: $comment
2551Version: $version
5dcfe9f8
AH
2552Requires: $(disabled shared && echo $requires)
2553Requires.private: $(enabled shared && echo $requires)
def4272a 2554Conflicts:
12701f6e
AH
2555Libs: -L\${libdir} -l${shortname} $(disabled shared && echo $libs)
2556Libs.private: $(enabled shared && echo $libs)
76a448ed 2557Cflags: -I\${includedir}
def4272a 2558EOF
25cd5cb3 2559cat <<EOF > $name/$name-uninstalled.pc
def4272a
AJ
2560prefix=
2561exec_prefix=
46d1ff83 2562libdir=\${pcfiledir}
1d44d365 2563includedir=${source_path}
def4272a 2564
d0674868
DB
2565Name: $name
2566Description: $comment
2567Version: $version
2568Requires: $requires
def4272a 2569Conflicts:
12701f6e 2570Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
def4272a
AJ
2571Cflags: -I\${includedir}
2572EOF
d0674868 2573}
def4272a 2574
e426941d 2575pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
46983309
RT
2576pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
2577pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
2578pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
3ed1a2ee 2579enabled avfilter &&
46983309 2580 pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
3ed1a2ee 2581enabled postproc &&
e426941d 2582 pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
13ca50f3 2583if enabled swscale; then
e426941d 2584 pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
6c0d0413 2585else
46983309 2586 pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavcodec = $LIBAVCODEC_VERSION"
25cd5cb3 2587 apply libswscale/libswscale.pc sed s/^Libs:.*$/Libs:/
6c0d0413 2588fi