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