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