You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2157 lines
57KB

  1. #!/bin/sh
  2. #
  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
  8. #
  9. # make sure we are running under a compatible shell
  10. # try to make this part work with most shells
  11. try_exec(){
  12. echo "Trying shell $1"
  13. type "$1" >/dev/null 2>&1 && exec "$@"
  14. }
  15. unset foo
  16. (: ${foo%%bar}) 2>/dev/null
  17. E1="$?"
  18. (: ${foo?}) 2>/dev/null
  19. E2="$?"
  20. if test "$E1" != 0 || test "$E2" = 0; then
  21. echo "Broken shell detected. Trying alternatives."
  22. export FF_CONF_EXEC
  23. if test "0$FF_CONF_EXEC" -lt 1; then
  24. FF_CONF_EXEC=1
  25. try_exec bash "$0" "$@"
  26. fi
  27. if test "0$FF_CONF_EXEC" -lt 2; then
  28. FF_CONF_EXEC=2
  29. try_exec ksh "$0" "$@"
  30. fi
  31. if test "0$FF_CONF_EXEC" -lt 3; then
  32. FF_CONF_EXEC=3
  33. try_exec /usr/xpg4/bin/sh "$0" "$@"
  34. fi
  35. echo "No compatible shell script interpreter found."
  36. echo "This configure script requires a POSIX-compatible shell"
  37. echo "such as bash or ksh."
  38. echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
  39. echo "Instead, install a working POSIX-compatible shell."
  40. echo "Disabling this configure test will create a broken FFmpeg."
  41. if test "$BASH_VERSION" = '2.04.0(1)-release'; then
  42. echo "This bash version ($BASH_VERSION) is broken on your platform."
  43. echo "Upgrade to a later version if available."
  44. fi
  45. exit 1
  46. fi
  47. show_help(){
  48. echo "Usage: configure [options]"
  49. echo "Options: [defaults in brackets after descriptions]"
  50. echo
  51. echo "Standard options:"
  52. echo " --help print this message"
  53. echo " --log[=FILE|yes|no] log tests and output to FILE [config.err]"
  54. echo " --prefix=PREFIX install in PREFIX [$PREFIX]"
  55. echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
  56. echo " --shlibdir=DIR install shared libs in DIR [PREFIX/lib]"
  57. echo " --incdir=DIR install includes in DIR [PREFIX/include/ffmpeg]"
  58. echo " --mandir=DIR install man page in DIR [PREFIX/man]"
  59. echo " --enable-mingw32 enable MinGW native/cross Windows compile"
  60. echo " --enable-mingwce enable MinGW native/cross WinCE compile"
  61. echo " --enable-static build static libraries [default=yes]"
  62. echo " --disable-static do not build static libraries [default=no]"
  63. echo " --enable-shared build shared libraries [default=no]"
  64. echo " --disable-shared do not build shared libraries [default=yes]"
  65. echo " --enable-pp enable GPLed postprocessing support [default=no]"
  66. echo " --enable-swscaler software scaler support [default=no]"
  67. echo " --enable-sunmlib use Sun medialib [default=no]"
  68. echo " --enable-beosthreads use BeOS threads [default=no]"
  69. echo " --enable-os2threads use OS/2 threads [default=no]"
  70. echo " --enable-pthreads use pthreads [default=no]"
  71. echo " --enable-w32threads use Win32 threads [default=no]"
  72. echo " --enable-x11grab enable X11 grabbing [default=no]"
  73. echo " --enable-dc1394 enable IIDC-1394 grabbing using libdc1394"
  74. echo " and libraw1394 [default=no]"
  75. echo " --enable-a52 enable GPLed liba52 support [default=no]"
  76. echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
  77. echo " --enable-avisynth allow reading AVISynth script files [default=no]"
  78. echo " --enable-dts enable GPLed libdts support [default=no]"
  79. echo " --enable-faac enable FAAC support via libfaac [default=no]"
  80. echo " --enable-faad enable FAAD support via libfaad [default=no]"
  81. echo " --enable-faadbin build FAAD support with runtime linking [default=no]"
  82. echo " --enable-libgsm enable GSM support via libgsm [default=no]"
  83. echo " --enable-mp3lame enable MP3 encoding via libmp3lame [default=no]"
  84. echo " --enable-libnut enable NUT support via libnut [default=no]"
  85. echo " --enable-libogg enable Ogg support via libogg [default=no]"
  86. echo " --enable-vorbis enable Vorbis support via libvorbis [default=no]"
  87. echo " --enable-x264 enable H.264 encoding via x264 [default=no]"
  88. echo " --enable-xvid enable XviD support via xvidcore [default=no]"
  89. echo " --enable-amr_nb enable amr_nb float audio codec"
  90. echo " --enable-amr_nb-fixed use fixed point for amr-nb codec"
  91. echo " --enable-amr_wb enable amr_wb float audio codec"
  92. echo " --enable-amr_if2 enable amr_wb IF2 audio codec"
  93. echo " --enable-gpl allow use of GPL code, the resulting libav*"
  94. echo " and ffmpeg will be under GPL [default=no]"
  95. echo ""
  96. echo "Advanced options (experts only):"
  97. echo " --source-path=PATH path to source code [$source_path]"
  98. echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
  99. echo " --cross-compile assume a cross-compiler is used"
  100. echo " --cc=CC use C compiler CC [$cc]"
  101. echo " --make=MAKE use specified make [$make]"
  102. echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
  103. echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
  104. echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
  105. echo " --build-suffix=SUFFIX suffix for application specific build []"
  106. echo " --arch=ARCH select architecture [$arch]"
  107. echo " --cpu=CPU selects the minimum cpu required (affects
  108. instruction selection, may crash on older CPUs)"
  109. echo " --powerpc-perf-enable enable performance report on PPC"
  110. echo " (requires enabling PMC)"
  111. echo " --disable-mmx disable MMX usage"
  112. echo " --disable-armv5te disable armv5te usage"
  113. echo " --disable-iwmmxt disable iwmmxt usage"
  114. echo " --disable-altivec disable AltiVec usage"
  115. echo " --disable-audio-oss disable OSS audio support [default=no]"
  116. echo " --disable-audio-beos disable BeOS audio support [default=no]"
  117. echo " --disable-v4l disable video4linux grabbing [default=no]"
  118. echo " --disable-v4l2 disable video4linux2 grabbing [default=no]"
  119. echo " --disable-bktr disable bktr video grabbing [default=no]"
  120. echo " --disable-dv1394 disable DV1394 grabbing [default=no]"
  121. echo " --disable-network disable network support [default=no]"
  122. echo " --disable-ipv6 disable ipv6 support [default=no]"
  123. echo " --disable-zlib disable zlib [default=no]"
  124. echo " --disable-vhook disable video hooking support"
  125. echo " --enable-gprof enable profiling with gprof [$gprof]"
  126. echo " --disable-debug disable debugging symbols"
  127. echo " --disable-opts disable compiler optimizations"
  128. echo " --enable-extra-warnings enable more compiler warnings"
  129. echo " --disable-mpegaudio-hp faster (but less accurate)"
  130. echo " MPEG audio decoding [default=no]"
  131. echo " --disable-protocols disable I/O protocols support [default=no]"
  132. echo " --disable-ffmpeg disable ffmpeg build"
  133. echo " --disable-ffserver disable ffserver build"
  134. echo " --disable-ffplay disable ffplay build"
  135. echo " --enable-small optimize for size instead of speed"
  136. echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
  137. echo " --disable-strip disable stripping of executables and shared libraries"
  138. echo " --disable-encoder=NAME disables encoder NAME"
  139. echo " --enable-encoder=NAME enables encoder NAME"
  140. echo " --disable-decoder=NAME disables decoder NAME"
  141. echo " --enable-decoder=NAME enables decoder NAME"
  142. echo " --disable-encoders disables all encoders"
  143. echo " --disable-decoders disables all decoders"
  144. echo " --disable-muxer=NAME disables muxer NAME"
  145. echo " --enable-muxer=NAME enables muxer NAME"
  146. echo " --disable-muxers disables all muxers"
  147. echo " --disable-demuxer=NAME disables demuxer NAME"
  148. echo " --enable-demuxer=NAME enables demuxer NAME"
  149. echo " --disable-demuxers disables all demuxers"
  150. echo " --enable-parser=NAME enables parser NAME"
  151. echo " --disable-parser=NAME disables parser NAME"
  152. echo " --disable-parsers disables all parsers"
  153. echo ""
  154. echo "NOTE: Object files are built at the place where configure is launched."
  155. exit 1
  156. }
  157. log(){
  158. echo "$@" >>$logfile
  159. }
  160. log_file(){
  161. log BEGIN $1
  162. cat -n $1 >>$logfile
  163. log END $1
  164. }
  165. echolog(){
  166. log "$@"
  167. echo "$@"
  168. }
  169. die(){
  170. echolog "$@"
  171. cat <<EOF
  172. If you think configure made a mistake, make sure you are using the latest
  173. version from SVN. If the latest version fails, report the problem to the
  174. ffmpeg-devel@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
  175. EOF
  176. if enabled logging; then
  177. cat <<EOF
  178. Include the log file "$logfile" produced by configure as this will help
  179. solving the problem.
  180. EOF
  181. else
  182. cat <<EOF
  183. Rerun configure with logging enabled (do not use --log=no), and include the
  184. log this produces with your report.
  185. EOF
  186. fi
  187. rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
  188. exit 1
  189. }
  190. # "tr '[a-z]' '[A-Z]'" is a workaround for Solaris tr not grokking "tr a-z A-Z"
  191. toupper(){
  192. echo "$@" | tr '[a-z]' '[A-Z]'
  193. }
  194. set_all(){
  195. value=$1
  196. shift
  197. for var in $*; do
  198. eval $var=$value
  199. done
  200. }
  201. enable(){
  202. set_all yes $*
  203. }
  204. disable(){
  205. set_all no $*
  206. }
  207. enabled(){
  208. eval test "x\$$1" = "xyes"
  209. }
  210. enabled_all(){
  211. for opt; do
  212. enabled $opt || return 1
  213. done
  214. }
  215. enabled_any(){
  216. for opt; do
  217. enabled $opt && return 0
  218. done
  219. }
  220. print_config(){
  221. pfx=$1
  222. header=$2
  223. makefile=$3
  224. shift 3
  225. for cfg; do
  226. if enabled $cfg; then
  227. ucname="${pfx}`toupper $cfg`"
  228. echo "#define ${ucname} 1" >> $header
  229. echo "${ucname}=yes" >> $makefile
  230. fi
  231. done
  232. }
  233. flags_saved(){
  234. (: ${SAVE_CFLAGS?}) 2>/dev/null
  235. }
  236. save_flags(){
  237. flags_saved && return
  238. SAVE_CFLAGS="$CFLAGS"
  239. SAVE_LDFLAGS="$LDFLAGS"
  240. SAVE_extralibs="$extralibs"
  241. }
  242. restore_flags(){
  243. CFLAGS="$SAVE_CFLAGS"
  244. LDFLAGS="$SAVE_LDFLAGS"
  245. extralibs="$SAVE_extralibs"
  246. unset SAVE_CFLAGS
  247. unset SAVE_LDFLAGS
  248. unset SAVE_extralibs
  249. }
  250. temp_cflags(){
  251. save_flags
  252. CFLAGS="$CFLAGS $*"
  253. }
  254. temp_ldflags(){
  255. save_flags
  256. LDFLAGS="$LDFLAGS $*"
  257. }
  258. temp_extralibs(){
  259. save_flags
  260. extralibs="$extralibs $*"
  261. }
  262. append(){
  263. var=$1
  264. shift
  265. flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
  266. eval "$var=\"\$$var $*\""
  267. }
  268. add_cflags(){
  269. append CFLAGS "$@"
  270. }
  271. add_ldflags(){
  272. append LDFLAGS "$@"
  273. }
  274. add_extralibs(){
  275. append extralibs "$@"
  276. }
  277. check_cmd(){
  278. log "$@"
  279. "$@" >>$logfile 2>&1
  280. }
  281. check_cc(){
  282. log check_cc "$@"
  283. cat >$TMPC
  284. log_file $TMPC
  285. check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
  286. }
  287. check_cpp(){
  288. log check_cpp "$@"
  289. cat >$TMPC
  290. log_file $TMPC
  291. check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
  292. }
  293. check_ld(){
  294. log check_ld "$@"
  295. check_cc || return
  296. check_cmd $cc $LDFLAGS "$@" -o $TMPE $TMPO $extralibs
  297. }
  298. check_cflags(){
  299. log check_cflags "$@"
  300. check_cc "$@" <<EOF && add_cflags "$@"
  301. int x;
  302. EOF
  303. }
  304. check_ldflags(){
  305. log check_ldflags "$@"
  306. check_ld "$@" <<EOF && add_ldflags "$@"
  307. int main(){
  308. return 0;
  309. }
  310. EOF
  311. }
  312. check_header(){
  313. log check_header "$@"
  314. header=$1
  315. shift
  316. check_cpp "$@" <<EOF
  317. #include <$header>
  318. int x;
  319. EOF
  320. err=$?
  321. var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
  322. test "$err" = 0 && enable $var || disable $var
  323. return $err
  324. }
  325. check_func(){
  326. log check_func "$@"
  327. func=$1
  328. shift
  329. check_ld "$@" <<EOF
  330. extern int $func();
  331. int main(){
  332. $func();
  333. }
  334. EOF
  335. err=$?
  336. test "$err" = 0 && enable $func || disable $func
  337. return $err
  338. }
  339. check_lib(){
  340. log check_lib "$@"
  341. header="$1"
  342. func="$2"
  343. shift 2
  344. temp_extralibs "$@"
  345. check_header $header && check_func $func && add_extralibs "$@"
  346. err=$?
  347. restore_flags
  348. return $err
  349. }
  350. check_exec(){
  351. check_ld "$@" && { test "$cross_compile" = yes || $TMPE >>$logfile 2>&1; }
  352. }
  353. require(){
  354. name="$1"
  355. header="$2"
  356. func="$3"
  357. shift 3
  358. check_lib $header $func "$@" || die "ERROR: $name not found"
  359. }
  360. apply(){
  361. file=$1
  362. shift
  363. "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
  364. }
  365. CONFIG_LIST='
  366. encoders
  367. decoders
  368. parsers
  369. muxers
  370. demuxers
  371. amr
  372. amr_nb
  373. amr_nb_fixed
  374. amr_wb
  375. audio_beos
  376. audio_oss
  377. avisynth
  378. beos_netserver
  379. bktr
  380. dc1394
  381. dv1394
  382. ffmpeg
  383. ffplay
  384. ffserver
  385. gpl
  386. ipv6
  387. liba52
  388. liba52bin
  389. libdts
  390. libfaac
  391. libfaad
  392. libfaadbin
  393. libgsm
  394. libmp3lame
  395. libnut
  396. libogg
  397. libvorbis
  398. memalign_hack
  399. mpegaudio_hp
  400. network
  401. pp
  402. protocols
  403. swscaler
  404. vhook
  405. video4linux
  406. video4linux2
  407. wince
  408. x11grab
  409. x264
  410. xvid
  411. zlib
  412. '
  413. HAVE_LIST='
  414. altivec_h
  415. beosthreads
  416. byteswap_h
  417. dcbzl
  418. dev_bktr_ioctl_bt848_h
  419. dev_bktr_ioctl_meteor_h
  420. dev_ic_bt8xx_h
  421. dev_video_meteor_ioctl_meteor_h
  422. dev_video_bktr_ioctl_bt848_h
  423. dlfcn_h
  424. dlopen
  425. freetype2
  426. gprof
  427. imlib2
  428. inet_aton
  429. localtime_r
  430. lrintf
  431. machine_ioctl_bt848_h
  432. machine_ioctl_meteor_h
  433. malloc_h
  434. memalign
  435. mlib
  436. os2
  437. os2threads
  438. pthreads
  439. sdl
  440. sdl_video_size
  441. threads
  442. w32threads
  443. '
  444. # set temporary file name
  445. if test ! -z "$TMPDIR" ; then
  446. TMPDIR1="${TMPDIR}"
  447. elif test ! -z "$TEMPDIR" ; then
  448. TMPDIR1="${TEMPDIR}"
  449. else
  450. TMPDIR1="/tmp"
  451. fi
  452. TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
  453. TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
  454. TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
  455. TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
  456. TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
  457. # default parameters
  458. logging="yes"
  459. logfile="config.err"
  460. PREFIX="/usr/local"
  461. libdir='${PREFIX}/lib'
  462. shlibdir="$libdir"
  463. incdir='${PREFIX}/include/ffmpeg'
  464. mandir='${PREFIX}/man'
  465. bindir='${PREFIX}/bin'
  466. cross_prefix=""
  467. cross_compile="no"
  468. cc="gcc"
  469. ar="ar"
  470. ranlib="ranlib"
  471. make="make"
  472. strip="strip"
  473. arch=`uname -m`
  474. cpu="generic"
  475. powerpc_perf="no"
  476. mmx="default"
  477. cmov="no"
  478. cmov_is_fast="no"
  479. armv5te="default"
  480. iwmmxt="default"
  481. altivec="default"
  482. dcbzl="no"
  483. mmi="default"
  484. case "$arch" in
  485. i386|i486|i586|i686|i86pc|BePC)
  486. arch="x86_32"
  487. ;;
  488. x86_64|amd64)
  489. arch="x86_32"
  490. canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
  491. if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
  492. if [ -z "`echo $CFLAGS | grep -- -m32`" ]; then
  493. arch="x86_64"
  494. fi
  495. fi
  496. ;;
  497. # armv4l is a subset of armv[567]*l
  498. arm|armv[4567]*l)
  499. arch="armv4l"
  500. ;;
  501. alpha)
  502. arch="alpha"
  503. ;;
  504. "Power Macintosh"|ppc|ppc64|powerpc)
  505. arch="powerpc"
  506. ;;
  507. mips|mipsel|IP*)
  508. arch="mips"
  509. ;;
  510. sun4u|sparc64)
  511. arch="sparc64"
  512. ;;
  513. sparc)
  514. arch="sparc"
  515. ;;
  516. sh4)
  517. arch="sh4"
  518. ;;
  519. parisc|parisc64)
  520. arch="parisc"
  521. ;;
  522. s390|s390x)
  523. arch="s390"
  524. ;;
  525. m68k)
  526. arch="m68k"
  527. ;;
  528. ia64)
  529. arch="ia64"
  530. ;;
  531. bfin)
  532. arch="bfin"
  533. ;;
  534. *)
  535. arch="unknown"
  536. ;;
  537. esac
  538. gprof="no"
  539. video4linux="yes"
  540. video4linux2="yes"
  541. bktr="no"
  542. audio_oss="yes"
  543. audio_beos="no"
  544. x11grab="no"
  545. dv1394="yes"
  546. dc1394="no"
  547. network="yes"
  548. ipv6="yes"
  549. zlib="yes"
  550. liba52="no"
  551. liba52bin="no"
  552. libdts="no"
  553. libfaac="no"
  554. libfaad="no"
  555. libfaadbin="no"
  556. libgsm="no"
  557. libmp3lame="no"
  558. libnut="no"
  559. libogg="no"
  560. libvorbis="no"
  561. xvid="no"
  562. x264="no"
  563. pp="no"
  564. mingw32="no"
  565. wince="no"
  566. os2="no"
  567. lstatic="yes"
  568. lshared="no"
  569. optimize="yes"
  570. debug="yes"
  571. extrawarnings="no"
  572. dostrip="yes"
  573. installstrip="-s"
  574. extralibs="-lm"
  575. bigendian="no"
  576. vhook="default"
  577. avisynth="no"
  578. dlfcn_h="no"
  579. dlopen="no"
  580. mpegaudio_hp="yes"
  581. SHFLAGS='-shared -Wl,-soname,$@'
  582. VHOOKSHFLAGS='$(SHFLAGS)'
  583. beos_netserver="no"
  584. protocols="yes"
  585. ffmpeg="yes"
  586. ffserver="yes"
  587. ffplay="yes"
  588. LIBOBJFLAGS=""
  589. FFLDFLAGS=-Wl,--warn-common
  590. LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
  591. FFSERVERLDFLAGS=-Wl,-E
  592. LDCONFIG="ldconfig"
  593. LIBPREF="lib"
  594. LIBSUF=".a"
  595. LIB='$(LIBPREF)$(NAME)$(LIBSUF)'
  596. SLIBPREF="lib"
  597. SLIBSUF=".so"
  598. SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
  599. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  600. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  601. EXESUF=""
  602. BUILDSUF=""
  603. amr_nb="no"
  604. amr_wb="no"
  605. amr_nb_fixed="no"
  606. amr_if2="no"
  607. mlib="no"
  608. beosthreads="no"
  609. os2threads="no"
  610. pthreads="no"
  611. w32threads="no"
  612. thread_type="no"
  613. swscaler="no"
  614. gpl="no"
  615. memalign_hack="no"
  616. asmalign_pot="unknown"
  617. LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(libdir)/$(LIB)"'
  618. # OS specific
  619. targetos=`uname -s`
  620. case $targetos in
  621. BeOS)
  622. PREFIX="/boot/home/config"
  623. # helps building libavcodec
  624. add_cflags "-DPIC -fomit-frame-pointer"
  625. # 3 gcc releases known for BeOS, each with ugly bugs
  626. gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
  627. case "$gcc_version" in
  628. 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
  629. mmx="no"
  630. ;;
  631. *20010315*) echo "BeBits gcc"
  632. add_cflags "-fno-expensive-optimizations"
  633. ;;
  634. esac
  635. SHFLAGS=-nostart
  636. # disable Linux things
  637. audio_oss="no"
  638. video4linux="no"
  639. video4linux2="no"
  640. dv1394="no"
  641. # enable BeOS things
  642. audio_beos="yes"
  643. # no need for libm, but the inet stuff
  644. # Check for BONE
  645. if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
  646. extralibs="-lbind -lsocket"
  647. else
  648. beos_netserver="yes"
  649. extralibs="-lnet"
  650. fi ;;
  651. SunOS)
  652. video4linux="no"
  653. video4linux2="no"
  654. audio_oss="no"
  655. dv1394="no"
  656. make="gmake"
  657. FFLDFLAGS=""
  658. FFSERVERLDFLAGS=""
  659. SHFLAGS="-shared -Wl,-h,\$@"
  660. add_extralibs "-lsocket -lnsl"
  661. ;;
  662. NetBSD)
  663. video4linux="no"
  664. video4linux2="no"
  665. bktr="yes"
  666. audio_oss="yes"
  667. dv1394="no"
  668. make="gmake"
  669. add_extralibs "-lossaudio"
  670. ;;
  671. OpenBSD)
  672. video4linux="no"
  673. video4linux2="no"
  674. bktr="yes"
  675. audio_oss="yes"
  676. dv1394="no"
  677. need_memalign="no"
  678. make="gmake"
  679. LIBOBJFLAGS="\$(PIC)"
  680. LDCONFIG="ldconfig -m \$(shlibdir)"
  681. SHFLAGS='-shared'
  682. SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF).$(LIBVERSION)'
  683. SLIBNAME_WITH_VERSION='$(SLIBNAME)'
  684. SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
  685. add_extralibs "-lossaudio"
  686. ;;
  687. FreeBSD)
  688. video4linux="no"
  689. video4linux2="no"
  690. bktr="yes"
  691. audio_oss="yes"
  692. dv1394="no"
  693. make="gmake"
  694. need_memalign="no"
  695. add_cflags "-pthread"
  696. ;;
  697. GNU/kFreeBSD)
  698. video4linux="no"
  699. video4linux2="no"
  700. bktr="yes"
  701. audio_oss="yes"
  702. dv1394="no"
  703. add_cflags "-pthread"
  704. ;;
  705. BSD/OS)
  706. video4linux="no"
  707. video4linux2="no"
  708. bktr="yes"
  709. audio_oss="yes"
  710. dv1394="no"
  711. extralibs="-lpoll -lgnugetopt -lm"
  712. make="gmake"
  713. strip="strip -d"
  714. installstrip=""
  715. ;;
  716. Darwin)
  717. cc="cc"
  718. video4linux="no"
  719. video4linux2="no"
  720. audio_oss="no"
  721. dv1394="no"
  722. need_memalign="no"
  723. SHFLAGS="-dynamiclib -Wl,-single_module -Wl,-install_name,\$(shlibdir)/\$(SLIBNAME),-current_version,\$(SPPVERSION),-compatibility_version,\$(SPPVERSION) -Wl,-read_only_relocs,suppress"
  724. VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(shlibdir)/vhook/$@'
  725. extralibs=""
  726. strip="strip -x"
  727. installstrip=""
  728. FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
  729. SLIBSUF=".dylib"
  730. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
  731. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
  732. FFSERVERLDFLAGS=-Wl,-bind_at_load
  733. ;;
  734. MINGW32*)
  735. # Note: the rest of the mingw32 config is done afterwards as mingw32
  736. # can be forced on the command line for Linux cross compilation.
  737. mingw32="yes"
  738. ;;
  739. CYGWIN*)
  740. targetos=CYGWIN
  741. shlibdir="$bindir"
  742. video4linux="no"
  743. video4linux2="no"
  744. audio_oss="yes"
  745. dv1394="no"
  746. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  747. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  748. extralibs=""
  749. EXESUF=".exe"
  750. SLIBPREF="cyg"
  751. SLIBSUF=".dll"
  752. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  753. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
  754. SHFLAGS='-shared -Wl,--out-implib=lib$(NAME).dll.a'
  755. ;;
  756. Linux)
  757. LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
  758. ;;
  759. IRIX*)
  760. targetos=IRIX
  761. ranlib="echo ignoring ranlib"
  762. video4linux="no"
  763. video4linux2="no"
  764. audio_oss="no"
  765. make="gmake"
  766. ;;
  767. OS/2)
  768. TMPE=$TMPE".exe"
  769. ar="emxomfar -p128"
  770. ranlib="echo ignoring ranlib"
  771. strip="echo ignoring strip"
  772. add_cflags "-Zomf"
  773. FFLDFLAGS="-Zomf -Zstack 16384 -s"
  774. SHFLAGS="-Zdll -Zomf"
  775. FFSERVERLDFLAGS=""
  776. LIBPREF=""
  777. LIBSUF=".lib"
  778. SLIBPREF=""
  779. SLIBSUF=".dll"
  780. EXESUF=".exe"
  781. extralibs=""
  782. pkg_requires=""
  783. video4linux="no"
  784. video4linux2="no"
  785. audio_oss="no"
  786. dv1394="no"
  787. ffserver="no"
  788. vhook="no"
  789. os2="yes"
  790. ;;
  791. *)
  792. targetos="${targetos}-UNKNOWN"
  793. ;;
  794. esac
  795. # find source path
  796. source_path="`dirname \"$0\"`"
  797. source_path_used="yes"
  798. if test -z "$source_path" -o "$source_path" = "." ; then
  799. source_path="`pwd`"
  800. source_path_used="no"
  801. else
  802. source_path="`cd \"$source_path\"; pwd`"
  803. echo "$source_path" | grep -q '[[:blank:]]' &&
  804. die "Out of tree builds are impossible with whitespace in source path."
  805. fi
  806. if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
  807. show_help
  808. fi
  809. FFMPEG_CONFIGURATION=" "
  810. for opt do
  811. FFMPEG_CONFIGURATION="$FFMPEG_CONFIGURATION""$opt "
  812. done
  813. ENCODER_LIST=`sed -n 's/^[^#]*ENC.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
  814. DECODER_LIST=`sed -n 's/^[^#]*DEC.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
  815. PARSER_LIST=`sed -n 's/^[^#]*PARSER.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
  816. MUXER_LIST=`sed -n 's/^[^#]*_MUX.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
  817. DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
  818. enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST
  819. for opt do
  820. optval="${opt#*=}"
  821. case "$opt" in
  822. --log)
  823. ;;
  824. --log=*) logging="$optval"
  825. ;;
  826. --prefix=*) PREFIX="$optval"
  827. ;;
  828. --libdir=*) libdir="$optval"
  829. ;;
  830. --shlibdir=*) shlibdir="$optval"
  831. ;;
  832. --incdir=*) incdir="$optval"
  833. ;;
  834. --mandir=*) mandir="$optval"
  835. ;;
  836. --source-path=*) source_path="$optval"
  837. ;;
  838. --cross-prefix=*) cross_prefix="$optval"
  839. ;;
  840. --cross-compile) cross_compile=yes
  841. ;;
  842. --cc=*) cc="$optval"
  843. ;;
  844. --make=*) make="$optval"
  845. ;;
  846. --extra-cflags=*) add_cflags "$optval"
  847. ;;
  848. --extra-ldflags=*) add_ldflags "$optval"
  849. ;;
  850. --extra-libs=*) add_extralibs "$optval"
  851. ;;
  852. --build-suffix=*) BUILDSUF="$optval"
  853. ;;
  854. --arch=*) arch="$optval"
  855. ;;
  856. --cpu=*) cpu="$optval"
  857. ;;
  858. --powerpc-perf-enable) powerpc_perf="yes"
  859. ;;
  860. --disable-mmx) mmx="no"
  861. ;;
  862. --disable-armv5te) armv5te="no"
  863. ;;
  864. --disable-iwmmxt) iwmmxt="no"
  865. ;;
  866. --disable-altivec) altivec="no"
  867. ;;
  868. --enable-gprof) gprof="yes"
  869. ;;
  870. --disable-v4l) video4linux="no"
  871. ;;
  872. --disable-v4l2) video4linux2="no"
  873. ;;
  874. --disable-bktr) bktr="no"
  875. ;;
  876. --disable-audio-oss) audio_oss="no"
  877. ;;
  878. --disable-audio-beos) audio_beos="no"
  879. ;;
  880. --disable-dv1394) dv1394="no"
  881. ;;
  882. --disable-network) network="no"; ffserver="no"
  883. ;;
  884. --disable-ipv6) ipv6="no";
  885. ;;
  886. --disable-zlib) zlib="no"
  887. ;;
  888. --enable-a52) liba52="yes"
  889. ;;
  890. --enable-a52bin) liba52bin="yes"
  891. ;;
  892. --enable-dts) libdts="yes"
  893. ;;
  894. --enable-pp) pp="yes"
  895. ;;
  896. --enable-libgsm) libgsm="yes"
  897. ;;
  898. --enable-mp3lame) libmp3lame="yes"
  899. ;;
  900. --enable-libnut) libnut="yes"
  901. ;;
  902. --enable-libogg) libogg="yes"
  903. pkg_requires="$pkg_requires ogg >= 1.1"
  904. ;;
  905. --enable-vorbis) libvorbis="yes"
  906. pkg_requires="$pkg_requires vorbis vorbisenc"
  907. ;;
  908. --enable-faad) libfaad="yes"
  909. ;;
  910. --enable-faadbin) libfaadbin="yes"
  911. ;;
  912. --enable-faac) libfaac="yes"
  913. ;;
  914. --enable-xvid) xvid="yes"
  915. ;;
  916. --enable-x264) x264="yes"
  917. ;;
  918. --enable-avisynth) avisynth="yes";
  919. ;;
  920. --enable-x11grab) x11grab="yes";
  921. ;;
  922. --enable-dc1394) dc1394="yes"
  923. pkg_requires="$pkg_requires libraw1394"
  924. ;;
  925. --disable-vhook) vhook="no"
  926. ;;
  927. --enable-mingw32) mingw32="yes"
  928. ;;
  929. --enable-mingwce) wince="yes"
  930. ;;
  931. --enable-static) lstatic="yes"
  932. ;;
  933. --disable-static) lstatic="no"
  934. ;;
  935. --enable-shared) lshared="yes"
  936. ;;
  937. --disable-shared) lshared="no"
  938. ;;
  939. --disable-debug) debug="no"
  940. ;;
  941. --disable-opts) optimize="no"
  942. ;;
  943. --enable-extra-warnings) extrawarnings="yes"
  944. ;;
  945. --disable-mpegaudio-hp) mpegaudio_hp="no"
  946. ;;
  947. --disable-protocols) protocols="no"; network="no"; ffserver="no"
  948. ;;
  949. --disable-ffmpeg) ffmpeg="no"
  950. ;;
  951. --disable-ffserver) ffserver="no"
  952. ;;
  953. --disable-ffplay) ffplay="no"
  954. ;;
  955. --enable-small) optimize="small"
  956. ;;
  957. --enable-amr_nb) amr="yes"; amr_nb="yes"; amr_nb_fixed="no"
  958. ;;
  959. --enable-amr_nb-fixed) amr="yes"; amr_nb_fixed="yes"; amr_nb="no"
  960. ;;
  961. --enable-amr_wb) amr="yes"; amr_wb="yes"
  962. ;;
  963. --enable-amr_if2) amr="yes"; amr_if2="yes"
  964. ;;
  965. --enable-sunmlib) mlib="yes"
  966. ;;
  967. --enable-pthreads) pthreads="yes"
  968. ;;
  969. --enable-w32threads) w32threads="yes"
  970. ;;
  971. --enable-beosthreads) beosthreads="yes"
  972. ;;
  973. --enable-os2threads) os2threads="yes"
  974. ;;
  975. --enable-swscaler) swscaler="yes"
  976. ;;
  977. --enable-gpl) gpl="yes"
  978. ;;
  979. --enable-memalign-hack) memalign_hack="yes"
  980. ;;
  981. --disable-strip) dostrip="no"
  982. ;;
  983. --enable-encoder=*) enable ${optval}_encoder
  984. ;;
  985. --enable-decoder=*) enable ${optval}_decoder
  986. ;;
  987. --disable-encoder=*) disable ${optval}_encoder
  988. ;;
  989. --disable-decoder=*) disable ${optval}_decoder
  990. ;;
  991. --disable-encoders) disable $ENCODER_LIST
  992. ;;
  993. --disable-decoders) disable $DECODER_LIST
  994. ;;
  995. --enable-muxer=*) enable ${optval}_muxer
  996. ;;
  997. --disable-muxer=*) disable ${optval}_muxer
  998. ;;
  999. --disable-muxers) disable $MUXER_LIST; ffserver="no"
  1000. ;;
  1001. --enable-demuxer=*) enable ${optval}_demuxer
  1002. ;;
  1003. --disable-demuxer=*) disable ${optval}_demuxer
  1004. ;;
  1005. --disable-demuxers) disable $DEMUXER_LIST
  1006. ;;
  1007. --enable-parser=*) enable ${optval}_parser
  1008. ;;
  1009. --disable-parser=*) disable ${optval}_parser
  1010. ;;
  1011. --disable-parsers) disable $PARSER_LIST
  1012. ;;
  1013. --help) show_help
  1014. ;;
  1015. *)
  1016. echo "Unknown option \"$opt\"."
  1017. echo "See $0 --help for available options."
  1018. exit 1
  1019. ;;
  1020. esac
  1021. done
  1022. if test "$logging" != no; then
  1023. test "$logging" = yes || logfile="$logging"
  1024. echo "# $0 $@" >$logfile
  1025. set >>$logfile
  1026. else
  1027. logfile=/dev/null
  1028. fi
  1029. if test "$mingw32" = "yes" -o "$wince" = "yes"; then
  1030. if test "$lshared" = "yes" && test "$lstatic" = "yes" ; then
  1031. cat <<EOF
  1032. You can only build one library type at once on MinGW.
  1033. Specify --disable-static --enable-shared to only build
  1034. the shared libraries. To build only the static libraries
  1035. you do not need to pass additional options.
  1036. EOF
  1037. exit 1
  1038. fi
  1039. video4linux="no"
  1040. video4linux2="no"
  1041. audio_oss="no"
  1042. dv1394="no"
  1043. dc1394="no"
  1044. ffserver="no"
  1045. network="no"
  1046. if test "$wince" = "yes"; then
  1047. protocols="no"
  1048. fi
  1049. SLIBPREF=""
  1050. SLIBSUF=".dll"
  1051. EXESUF=".exe"
  1052. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1053. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
  1054. SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
  1055. SLIB_INSTALL_EXTRA_CMD="-install -m 644 \$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib) \"\$(shlibdir)/\$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib)\""
  1056. SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc"
  1057. fi
  1058. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1059. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1060. test -n "$cross_prefix" && cross_compile=yes
  1061. cc="${cross_prefix}${cc}"
  1062. ar="${cross_prefix}${ar}"
  1063. ranlib="${cross_prefix}${ranlib}"
  1064. strip="${cross_prefix}${strip}"
  1065. # we need to build at least one lib type
  1066. if test "$lstatic" = "no" && test "$lshared" = "no" ; then
  1067. cat <<EOF
  1068. At least one library type must be built.
  1069. Specify --enable-static to build the static libraries or --enable-shared to
  1070. build the shared libraries as well. To only build the shared libraries specify
  1071. --disable-static in addition to --enable-shared.
  1072. EOF
  1073. exit 1;
  1074. fi
  1075. if test "$libvorbis" = "yes" && test "$libogg" = "no"; then
  1076. die "libogg must be enabled to enable libvorbis."
  1077. fi
  1078. if test "$gpl" != "yes"; then
  1079. if test "$pp" != "no"; then
  1080. die "The Postprocessing code is under GPL and --enable-gpl is not specified."
  1081. fi
  1082. if test "$liba52" != "no" -o "$liba52bin" != "no"; then
  1083. die "liba52 is under GPL and --enable-gpl is not specified."
  1084. fi
  1085. if test "$xvid" != "no"; then
  1086. die "libxvidcore is under GPL and --enable-gpl is not specified."
  1087. fi
  1088. if test "$x264" != "no"; then
  1089. die "x264 is under GPL and --enable-gpl is not specified."
  1090. fi
  1091. if test "$libdts" != "no"; then
  1092. die "libdts is under GPL and --enable-gpl is not specified."
  1093. fi
  1094. if test "$libfaad" != "no" -o "$libfaadbin" != "no"; then
  1095. if check_header faad.h; then
  1096. check_cc << EOF
  1097. #include <faad.h>
  1098. #ifndef FAAD2_VERSION
  1099. ok faad1
  1100. #endif
  1101. int main( void ) { return 0; }
  1102. EOF
  1103. if test $? = 0 ; then
  1104. die "FAAD2 is under GPL and --enable-gpl is not specified."
  1105. fi
  1106. else
  1107. libfaad="no"
  1108. libfaadbin="no"
  1109. echo "FAAD test failed."
  1110. fi
  1111. fi
  1112. if test "$x11grab" != "no"; then
  1113. die "The X11 grabber is under GPL and --enable-gpl is not specified."
  1114. fi
  1115. if test "$swscaler" != "no"; then
  1116. die "The software scaler is under GPL and --enable-gpl is not specified."
  1117. fi
  1118. fi
  1119. # compute MMX state
  1120. if test $mmx = "default"; then
  1121. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1122. mmx="yes"
  1123. else
  1124. mmx="no"
  1125. fi
  1126. fi
  1127. test -z "$need_memalign" && need_memalign="$mmx"
  1128. #Darwin CC versions
  1129. needmdynamicnopic="no"
  1130. if test $targetos = Darwin; then
  1131. if test -n "`$cc -v 2>&1 | grep xlc`"; then
  1132. add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
  1133. else
  1134. gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
  1135. case "$gcc_version" in
  1136. *2.95*)
  1137. add_cflags "-no-cpp-precomp -pipe"
  1138. ;;
  1139. *[34].*)
  1140. add_cflags "-no-cpp-precomp -pipe -force_cpusubtype_ALL -Wno-sign-compare"
  1141. if test "$lshared" = no; then
  1142. needmdynamicnopic="yes"
  1143. fi
  1144. ;;
  1145. *)
  1146. add_cflags "-no-cpp-precomp -pipe"
  1147. if test "$lshared" = no; then
  1148. needmdynamicnopic="yes"
  1149. fi
  1150. ;;
  1151. esac
  1152. fi
  1153. fi
  1154. if test $optimize != "no"; then
  1155. add_cflags "-fomit-frame-pointer"
  1156. fi
  1157. # Can only do AltiVec on PowerPC
  1158. if test $altivec = "default"; then
  1159. if test $arch = "powerpc"; then
  1160. altivec="yes"
  1161. else
  1162. altivec="no"
  1163. fi
  1164. fi
  1165. # Add processor-specific flags
  1166. POWERPCMODE="32bits"
  1167. if test $cpu != "generic"; then
  1168. case $cpu in
  1169. 601|ppc601|PowerPC601)
  1170. add_cflags "-mcpu=601"
  1171. if test $altivec = "yes"; then
  1172. echo "WARNING: Tuning for PPC601 but AltiVec enabled!";
  1173. fi
  1174. ;;
  1175. 603*|ppc603*|PowerPC603*)
  1176. add_cflags "-mcpu=603"
  1177. if test $altivec = "yes"; then
  1178. echo "WARNING: Tuning for PPC603 but AltiVec enabled!";
  1179. fi
  1180. ;;
  1181. 604*|ppc604*|PowerPC604*)
  1182. add_cflags "-mcpu=604"
  1183. if test $altivec = "yes"; then
  1184. echo "WARNING: Tuning for PPC604 but AltiVec enabled!";
  1185. fi
  1186. ;;
  1187. G3|g3|75*|ppc75*|PowerPC75*)
  1188. add_cflags "-mcpu=750 -mpowerpc-gfxopt"
  1189. if test $altivec = "yes"; then
  1190. echo "WARNING: Tuning for PPC75x but AltiVec enabled!";
  1191. fi
  1192. ;;
  1193. G4|g4|745*|ppc745*|PowerPC745*)
  1194. add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
  1195. if test $altivec = "no"; then
  1196. echo "WARNING: Tuning for PPC745x but AltiVec disabled!";
  1197. fi
  1198. ;;
  1199. 74*|ppc74*|PowerPC74*)
  1200. add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
  1201. if test $altivec = "no"; then
  1202. echo "WARNING: Tuning for PPC74xx but AltiVec disabled!";
  1203. fi
  1204. ;;
  1205. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1206. add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1207. if test $altivec = "no"; then
  1208. echo "WARNING: Tuning for PPC970 but AltiVec disabled!";
  1209. fi
  1210. POWERPCMODE="64bits"
  1211. ;;
  1212. # targets that do NOT support conditional mov (cmov)
  1213. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1214. add_cflags "-march=$cpu"
  1215. cmov="no"
  1216. ;;
  1217. # targets that do support conditional mov (cmov)
  1218. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1219. add_cflags "-march=$cpu"
  1220. cmov="yes"
  1221. cmov_is_fast="yes"
  1222. ;;
  1223. # targets that do support conditional mov but on which it's slow
  1224. pentium4|prescott|nocona)
  1225. add_cflags "-march=$cpu"
  1226. cmov="yes"
  1227. cmov_is_fast="no"
  1228. ;;
  1229. sparc64)
  1230. add_cflags "-mcpu=v9"
  1231. ;;
  1232. *)
  1233. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1234. ;;
  1235. esac
  1236. fi
  1237. # make sure we can execute files in $TMPDIR
  1238. cat >$TMPE 2>>$logfile <<EOF
  1239. #! /bin/sh
  1240. EOF
  1241. chmod +x $TMPE >>$logfile 2>&1
  1242. if ! $TMPE >>$logfile 2>&1; then
  1243. cat <<EOF
  1244. Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
  1245. variable to another directory and make sure that $TMPDIR1 is not mounted
  1246. noexec.
  1247. EOF
  1248. die "Sanity test failed."
  1249. fi
  1250. rm $TMPE
  1251. # compiler sanity check
  1252. check_exec <<EOF
  1253. int main(){
  1254. return 0;
  1255. }
  1256. EOF
  1257. if test "$?" != 0; then
  1258. echo "$cc is unable to create an executable file."
  1259. if test -z "$cross_prefix" -a "$cross_compile" = no; then
  1260. echo "If $cc is a cross-compiler, use the --cross-compile option."
  1261. echo "Only do this if you know what cross compiling means."
  1262. fi
  1263. die "C compiler test failed."
  1264. fi
  1265. # check for assembler specific support
  1266. if test $arch = "powerpc"; then
  1267. check_cc <<EOF && dcbzl=yes
  1268. int main(void) {
  1269. register long zero = 0;
  1270. char data[1024];
  1271. asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
  1272. return 0;
  1273. }
  1274. EOF
  1275. fi
  1276. # check for SIMD availability
  1277. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1278. if test $arch = "powerpc"; then
  1279. if test $altivec = "yes"; then
  1280. if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
  1281. add_cflags "-faltivec"
  1282. else
  1283. add_cflags "-maltivec -mabi=altivec"
  1284. fi
  1285. fi
  1286. fi
  1287. check_header altivec.h
  1288. # check if our compiler supports Motorola AltiVec C API
  1289. if test $altivec = "yes"; then
  1290. if test $altivec_h = "yes"; then
  1291. inc_altivec_h="#include <altivec.h>"
  1292. else
  1293. inc_altivec_h=
  1294. fi
  1295. check_cc <<EOF || altivec=no
  1296. $inc_altivec_h
  1297. int main(void) {
  1298. vector signed int v1, v2, v3;
  1299. v1 = vec_add(v2,v3);
  1300. return 0;
  1301. }
  1302. EOF
  1303. fi
  1304. # check armv5te instructions support
  1305. if test $armv5te = "default" -a $arch = "armv4l"; then
  1306. armv5te=no
  1307. check_cc <<EOF && armv5te=yes
  1308. int main(void) {
  1309. __asm__ __volatile__ ("qadd r0, r0, r0");
  1310. }
  1311. EOF
  1312. fi
  1313. # check iwmmxt support
  1314. if test $iwmmxt = "default" -a $arch = "armv4l"; then
  1315. iwmmxt=no
  1316. check_cc <<EOF && iwmmxt=yes
  1317. int main(void) {
  1318. __asm__ __volatile__ ("wunpckelub wr6, wr4");
  1319. }
  1320. EOF
  1321. fi
  1322. # mmi only available on mips
  1323. if test $mmi = "default"; then
  1324. if test $arch = "mips"; then
  1325. mmi="yes"
  1326. else
  1327. mmi="no"
  1328. fi
  1329. fi
  1330. # check if our compiler supports mmi
  1331. enabled mmi && check_cc <<EOF || mmi="no"
  1332. int main(void) {
  1333. __asm__ ("lq \$2, 0(\$2)");
  1334. return 0;
  1335. }
  1336. EOF
  1337. # ---
  1338. # big/little-endian test
  1339. if test "$cross_compile" = "no"; then
  1340. check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
  1341. #include <inttypes.h>
  1342. int main(int argc, char ** argv){
  1343. volatile uint32_t i=0x01234567;
  1344. return (*((uint8_t*)(&i))) == 0x67;
  1345. }
  1346. EOF
  1347. else
  1348. # programs cannot be launched if cross compiling, so make a static guess
  1349. if test "$arch" = "powerpc" -o "$arch" = "mips" ; then
  1350. bigendian="yes"
  1351. fi
  1352. fi
  1353. # ---
  1354. # check availability of some header files
  1355. check_header malloc.h
  1356. check_func memalign
  1357. if test "$memalign" = "no" -a "$need_memalign" = "yes" -a \
  1358. "$memalign_hack" != "yes"; then
  1359. die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
  1360. fi
  1361. check_header byteswap.h
  1362. check_func inet_aton
  1363. check_func localtime_r
  1364. enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
  1365. # check for some common methods of building with pthread support
  1366. # do this before the optional library checks as some of them require pthreads
  1367. if enabled pthreads; then
  1368. if check_func pthread_create; then
  1369. :
  1370. elif check_func pthread_create -pthread; then
  1371. add_cflags -pthread
  1372. add_ldflags -pthread
  1373. elif check_func pthread_create -pthreads; then
  1374. add_cflags -pthreads
  1375. add_ldflags -pthreads
  1376. elif ! check_lib pthread.h pthread_create -lpthread; then
  1377. die "ERROR: can't find pthreads library"
  1378. fi
  1379. fi
  1380. for thread in pthreads beosthreads os2threads w32threads; do
  1381. if enabled $thread; then
  1382. if test $thread_type != "no"; then
  1383. die "ERROR: Only one thread type must be selected."
  1384. else
  1385. thread_type="$thread"
  1386. fi
  1387. fi
  1388. done
  1389. # these are off by default, so fail if requested and not available
  1390. enabled libdts && require libdts dts.h dts_init -ldts -lm
  1391. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1392. enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
  1393. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
  1394. enabled libogg && require libogg ogg/ogg.h ogg_sync_init -logg
  1395. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1396. enabled xvid && require XviD xvid.h xvid_global -lxvidcore
  1397. enabled x264 && require x264 x264.h x264_encoder_open -lx264
  1398. enabled dc1394 && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
  1399. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1400. # Ugh, libfaac uses stdcall calling convention on win32 so we can't use
  1401. # the generic test functions
  1402. if enabled libfaac; then
  1403. save_flags
  1404. temp_extralibs -lfaac
  1405. check_ld <<EOF && add_extralibs -lfaac || die "ERROR: libfaac not found"
  1406. #include <stdint.h>
  1407. #include <faac.h>
  1408. int main(){
  1409. char *id, *cpr;
  1410. faacEncGetVersion(&id, &cpr);
  1411. return 0;
  1412. }
  1413. EOF
  1414. restore_flags
  1415. fi
  1416. # Ugh, recent faad2 versions have renamed all functions and #define the
  1417. # old names in faad.h. Generic tests won't work.
  1418. if enabled libfaad; then
  1419. save_flags
  1420. temp_extralibs -lfaad
  1421. check_ld <<EOF && add_extralibs -lfaad || die "ERROR: libfaad not found"
  1422. #include <faad.h>
  1423. int main(){
  1424. faacDecOpen();
  1425. return 0;
  1426. }
  1427. EOF
  1428. restore_flags
  1429. fi
  1430. # Ugh, avisynth uses WINAPI calls. Generic tests won't work.
  1431. if enabled avisynth; then
  1432. save_flags
  1433. temp_extralibs -lvfw32
  1434. check_ld <<EOF && add_extralibs -lvfw32 || die "ERROR: vfw32 not found"
  1435. #include <windows.h>
  1436. #include <vfw.h>
  1437. int main(){
  1438. AVIFileInit();
  1439. return 0;
  1440. }
  1441. EOF
  1442. restore_flags
  1443. fi
  1444. # test for lrintf in math.h
  1445. check_exec <<EOF && lrintf=yes || lrintf=no
  1446. #define _ISOC9X_SOURCE 1
  1447. #include <math.h>
  1448. int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
  1449. EOF
  1450. _restrict=
  1451. for restrict_keyword in restrict __restrict__ __restrict; do
  1452. check_cc <<EOF && _restrict=$restrict_keyword && break
  1453. void foo(char * $restrict_keyword p);
  1454. EOF
  1455. done
  1456. # dlopen/dlfcn.h probing
  1457. check_header dlfcn.h
  1458. if check_func dlopen; then
  1459. ldl=
  1460. elif check_func dlopen -ldl; then
  1461. ldl=-ldl
  1462. fi
  1463. if test "$vhook" = "default"; then
  1464. vhook="$dlopen"
  1465. fi
  1466. if enabled_any vhook liba52bin libfaadbin; then
  1467. add_extralibs $ldl
  1468. fi
  1469. if test "$targetos" = "CYGWIN" -a "$lstatic" = "yes" ; then
  1470. vhook="no"
  1471. echo
  1472. echo "At the moment vhooks don't work on Cygwin static builds."
  1473. echo "Patches welcome."
  1474. echo
  1475. fi
  1476. if enabled vhook; then
  1477. check_ldflags -rdynamic
  1478. check_ldflags -export-dynamic
  1479. fi
  1480. if enabled audio_beos; then
  1481. add_extralibs "-lmedia -lbe"
  1482. fi
  1483. ##########################################
  1484. # imlib check
  1485. temp_extralibs -lImlib2
  1486. check_ld <<EOF && imlib2=yes || imlib2=no
  1487. #include <X11/Xlib.h>
  1488. #include <Imlib2.h>
  1489. int main( void ) { return (int) imlib_load_font("foo"); }
  1490. EOF
  1491. restore_flags
  1492. ##########################################
  1493. # FreeType check
  1494. freetype2=no
  1495. if test "x$targetos" != "xBeOS"; then
  1496. if (freetype-config --version) >/dev/null 2>&1 ; then
  1497. temp_cflags `freetype-config --cflags`
  1498. temp_extralibs `freetype-config --libs`
  1499. check_ld <<EOF && freetype2=yes
  1500. #include <ft2build.h>
  1501. int main( void ) { return (int) FT_Init_FreeType(0); }
  1502. EOF
  1503. restore_flags
  1504. fi
  1505. fi
  1506. ##########################################
  1507. # SDL check
  1508. sdl_too_old=no
  1509. sdl=no
  1510. SDL_CONFIG="${cross_prefix}sdl-config"
  1511. if ("${SDL_CONFIG}" --version) >/dev/null 2>&1 ; then
  1512. temp_cflags `"${SDL_CONFIG}" --cflags`
  1513. temp_extralibs `"${SDL_CONFIG}" --libs`
  1514. check_ld <<EOF
  1515. #include <SDL.h>
  1516. #undef main /* We don't want SDL to override our main() */
  1517. int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
  1518. EOF
  1519. if test $? = 0; then
  1520. _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
  1521. if test "$_sdlversion" -lt 121 ; then
  1522. sdl_too_old=yes
  1523. else
  1524. sdl=yes
  1525. check_cc <<EOF && sdl_video_size=yes || sdl_video_size=no
  1526. #include <SDL.h>
  1527. int main(void){
  1528. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1529. int w = vi->current_w;
  1530. return 0;
  1531. }
  1532. EOF
  1533. fi
  1534. fi
  1535. restore_flags
  1536. fi
  1537. enabled sdl || ffplay=no
  1538. ##########################################
  1539. # texi2html check
  1540. texi2html=no
  1541. if (texi2html -version) >/dev/null 2>&1; then
  1542. texi2html=yes
  1543. fi
  1544. ##########################################
  1545. # IPv6 check
  1546. enabled network && enabled ipv6 && check_ld <<EOF && ipv6=yes || ipv6=no
  1547. #include <sys/types.h>
  1548. #include <sys/socket.h>
  1549. #include <netinet/in.h>
  1550. #include <netdb.h>
  1551. int main( void ) {
  1552. struct sockaddr_storage saddr;
  1553. struct ipv6_mreq mreq6;
  1554. getaddrinfo(0,0,0,0);
  1555. getnameinfo(0,0,0,0,0,0,0);
  1556. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1557. }
  1558. EOF
  1559. # check for video4linux2 --- V4L2_PIX_FMT_YUV420
  1560. enabled video4linux2 && check_cc <<EOF || video4linux2="no"
  1561. #include <sys/time.h>
  1562. #include <asm/types.h>
  1563. #include <linux/videodev2.h>
  1564. int dummy = V4L2_PIX_FMT_YUV420;
  1565. struct v4l2_buffer dummy1;
  1566. EOF
  1567. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1568. if enabled bktr; then
  1569. check_header dev/bktr/ioctl_meteor.h
  1570. check_header dev/bktr/ioctl_bt848.h
  1571. check_header machine/ioctl_meteor.h
  1572. check_header machine/ioctl_bt848.h
  1573. check_header dev/video/meteor/ioctl_meteor.h
  1574. check_header dev/video/bktr/ioctl_bt848.h
  1575. check_header dev/ic/bt8xx.h
  1576. fi
  1577. # Deal with the x11 frame grabber
  1578. enabled x11grab &&
  1579. enabled gpl &&
  1580. enabled x11_grab_device_demuxer &&
  1581. check_header X11/Xlib.h &&
  1582. check_header X11/extensions/XShm.h &&
  1583. check_func XOpenDisplay -lX11 &&
  1584. check_func XShmCreateImage -lX11 -lXext &&
  1585. add_extralibs -lX11 -lXext ||
  1586. disable x11_grab_device_demuxer
  1587. enabled debug && add_cflags -g
  1588. # add some useful compiler flags if supported
  1589. check_cflags -Wdeclaration-after-statement
  1590. check_cflags -Wall
  1591. check_cflags -Wno-switch
  1592. check_cflags -Wdisabled-optimization
  1593. check_cflags -Wpointer-arith
  1594. check_cflags -Wredundant-decls
  1595. enabled extrawarnings && check_cflags -Winline
  1596. # add some linker flags
  1597. check_ldflags $LDLATEFLAGS
  1598. # not all compilers support -Os
  1599. test "$optimize" = "small" && check_cflags -Os
  1600. if enabled optimize; then
  1601. if test -n "`$cc -v 2>&1 | grep xlc`"; then
  1602. add_cflags "-O5"
  1603. add_ldflags "-O5"
  1604. else
  1605. add_cflags "-O3"
  1606. fi
  1607. fi
  1608. # PIC flags for shared library objects where they are needed
  1609. if test "$lshared" = "yes" ; then
  1610. # LIBOBJFLAGS may have already been set in the OS configuration
  1611. if test -z "$LIBOBJFLAGS" ; then
  1612. case "$arch" in
  1613. x86_64|ia64|alpha|sparc*) LIBOBJFLAGS="\$(PIC)" ;;
  1614. esac
  1615. fi
  1616. fi
  1617. if test "$gprof" = "yes" ; then
  1618. add_cflags "-p"
  1619. add_ldflags "-p"
  1620. fi
  1621. VHOOKCFLAGS="-fPIC $CFLAGS"
  1622. test "$needmdynamicnopic" = yes && add_cflags -mdynamic-no-pic
  1623. # find if .align arg is power-of-two or not
  1624. if test $asmalign_pot = "unknown"; then
  1625. asmalign_pot="no"
  1626. echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
  1627. fi
  1628. echo "install prefix $PREFIX"
  1629. echo "source path $source_path"
  1630. echo "C compiler $cc"
  1631. echo "make $make"
  1632. echo ".align is power-of-two $asmalign_pot"
  1633. echo "ARCH $arch ($cpu)"
  1634. if test "$BUILDSUF" != ""; then
  1635. echo "build suffix $BUILDSUF"
  1636. fi
  1637. echo "big-endian $bigendian"
  1638. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1639. echo "MMX enabled $mmx"
  1640. echo "CMOV enabled $cmov"
  1641. echo "CMOV is fast $cmov_is_fast"
  1642. fi
  1643. if test $arch = "armv4l"; then
  1644. echo "ARMv5TE enabled $armv5te"
  1645. echo "IWMMXT enabled $iwmmxt"
  1646. fi
  1647. if test $arch = "mips"; then
  1648. echo "MMI enabled $mmi"
  1649. fi
  1650. if test $arch = "powerpc"; then
  1651. echo "AltiVec enabled $altivec"
  1652. echo "dcbzl available $dcbzl"
  1653. fi
  1654. echo "gprof enabled $gprof"
  1655. echo "debug symbols $debug"
  1656. echo "strip symbols $dostrip"
  1657. echo "optimize $optimize"
  1658. echo "static $lstatic"
  1659. echo "shared $lshared"
  1660. echo "postprocessing support $pp"
  1661. echo "software scaler enabled $swscaler"
  1662. echo "video hooking $vhook"
  1663. if test "$vhook" = "yes"; then
  1664. echo "Imlib2 support $imlib2"
  1665. echo "FreeType support $freetype2"
  1666. fi
  1667. echo "network support $network"
  1668. if test "$network" = "yes" ; then
  1669. echo "IPv6 support $ipv6"
  1670. fi
  1671. echo "threading support $thread_type"
  1672. echo "SDL support $sdl"
  1673. if test $sdl_too_old = "yes"; then
  1674. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  1675. fi
  1676. echo "Sun medialib support $mlib"
  1677. echo "AVISynth enabled $avisynth"
  1678. echo "liba52 support $liba52"
  1679. echo "liba52 dlopened $liba52bin"
  1680. echo "libdts support $libdts"
  1681. echo "libfaac enabled $libfaac"
  1682. echo "libfaad enabled $libfaad"
  1683. echo "faadbin enabled $libfaadbin"
  1684. echo "libgsm enabled $libgsm"
  1685. echo "libmp3lame enabled $libmp3lame"
  1686. echo "libnut enabled $libnut"
  1687. echo "libogg enabled $libogg"
  1688. echo "libvorbis enabled $libvorbis"
  1689. echo "x264 enabled $x264"
  1690. echo "XviD enabled $xvid"
  1691. echo "zlib enabled $zlib"
  1692. echo "AMR-NB float support $amr_nb"
  1693. echo "AMR-NB fixed support $amr_nb_fixed"
  1694. echo "AMR-WB float support $amr_wb"
  1695. echo "AMR-WB IF2 support $amr_if2"
  1696. if test "$gpl" = "no" ; then
  1697. echo "License: LGPL"
  1698. else
  1699. echo "License: GPL"
  1700. fi
  1701. echo "Creating config.mak and config.h..."
  1702. echo "# Automatically generated by configure - do not modify!" > config.mak
  1703. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  1704. echo "#define FFMPEG_CONFIGURATION "'"'"$FFMPEG_CONFIGURATION"'"' >> $TMPH
  1705. echo "PREFIX=$PREFIX" >> config.mak
  1706. echo "prefix=\$(DESTDIR)\${PREFIX}" >> config.mak
  1707. echo "libdir=\$(DESTDIR)$libdir" >> config.mak
  1708. echo "shlibdir=\$(DESTDIR)$shlibdir" >> config.mak
  1709. echo "incdir=\$(DESTDIR)$incdir" >> config.mak
  1710. echo "bindir=\$(DESTDIR)$bindir" >> config.mak
  1711. echo "mandir=\$(DESTDIR)$mandir" >> config.mak
  1712. echo "MAKE=$make" >> config.mak
  1713. echo "CC=$cc" >> config.mak
  1714. echo "AR=$ar" >> config.mak
  1715. echo "RANLIB=$ranlib" >> config.mak
  1716. if test "$dostrip" = "yes" ; then
  1717. echo "STRIP=$strip" >> config.mak
  1718. echo "INSTALLSTRIP=$installstrip" >> config.mak
  1719. else
  1720. echo "STRIP=echo ignoring strip" >> config.mak
  1721. echo "INSTALLSTRIP=" >> config.mak
  1722. fi
  1723. echo "OPTFLAGS=$CFLAGS" >> config.mak
  1724. echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
  1725. echo "LDFLAGS=$LDFLAGS" >> config.mak
  1726. echo "LDCONFIG=$LDCONFIG" >> config.mak
  1727. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  1728. echo "SHFLAGS=$SHFLAGS" >> config.mak
  1729. echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
  1730. echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
  1731. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  1732. echo "BUILD_STATIC=$lstatic" >> config.mak
  1733. echo "BUILDSUF=$BUILDSUF" >> config.mak
  1734. echo "LIBPREF=$LIBPREF" >> config.mak
  1735. echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
  1736. if test "$lstatic" = "yes" ; then
  1737. echo "LIB=$LIB" >> config.mak
  1738. else # Some Make complain if this variable does not exist.
  1739. echo "LIB=" >> config.mak
  1740. fi
  1741. echo "SLIBPREF=$SLIBPREF" >> config.mak
  1742. echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
  1743. echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
  1744. echo "TARGET_OS=$targetos" >> config.mak
  1745. ucarch=`toupper $arch`
  1746. echo "TARGET_ARCH_${ucarch}=yes" >> config.mak
  1747. echo "#define ARCH_${ucarch} 1" >> $TMPH
  1748. # special cases
  1749. case "$arch" in
  1750. x86_32|x86_64)
  1751. echo "TARGET_ARCH_X86=yes" >> config.mak
  1752. echo "#define ARCH_X86 1" >> $TMPH
  1753. ;;
  1754. powerpc)
  1755. if test "$POWERPCMODE" = "64bits"; then
  1756. echo "#define POWERPC_MODE_64BITS 1" >> $TMPH
  1757. fi
  1758. if test "$powerpc_perf" = "yes"; then
  1759. echo "#define POWERPC_PERFORMANCE_REPORT 1" >> $TMPH
  1760. fi
  1761. ;;
  1762. sparc64)
  1763. echo "TARGET_ARCH_SPARC=yes" >> config.mak
  1764. echo "#define ARCH_SPARC 1" >> $TMPH
  1765. ;;
  1766. esac
  1767. if test "$bigendian" = "yes" ; then
  1768. echo "WORDS_BIGENDIAN=yes" >> config.mak
  1769. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  1770. fi
  1771. if test "$mmx" = "yes" ; then
  1772. echo "TARGET_MMX=yes" >> config.mak
  1773. echo "#define HAVE_MMX 1" >> $TMPH
  1774. echo "#define __CPU__ 586" >> $TMPH
  1775. fi
  1776. if test "$cmov" = "yes" ; then
  1777. echo "TARGET_CMOV=yes" >> config.mak
  1778. echo "#define HAVE_CMOV 1" >> $TMPH
  1779. fi
  1780. if test "$cmov_is_fast" = "yes" ; then
  1781. echo "TARGET_CMOV_IS_FAST=yes" >> config.mak
  1782. echo "#define CMOV_IS_FAST 1" >> $TMPH
  1783. fi
  1784. if test "$armv5te" = "yes" ; then
  1785. echo "TARGET_ARMV5TE=yes" >> config.mak
  1786. echo "#define HAVE_ARMV5TE 1" >> $TMPH
  1787. fi
  1788. if test "$iwmmxt" = "yes" ; then
  1789. echo "TARGET_IWMMXT=yes" >> config.mak
  1790. echo "#define HAVE_IWMMXT 1" >> $TMPH
  1791. fi
  1792. if test "$mmi" = "yes" ; then
  1793. echo "TARGET_MMI=yes" >> config.mak
  1794. echo "#define HAVE_MMI 1" >> $TMPH
  1795. fi
  1796. if test "$altivec" = "yes" ; then
  1797. echo "TARGET_ALTIVEC=yes" >> config.mak
  1798. echo "#define HAVE_ALTIVEC 1" >> $TMPH
  1799. fi
  1800. if test "$sdl" = "yes" ; then
  1801. echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
  1802. echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
  1803. fi
  1804. if test "$texi2html" = "yes"; then
  1805. echo "BUILD_DOC=yes" >> config.mak
  1806. fi
  1807. sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
  1808. pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
  1809. lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
  1810. lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
  1811. lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
  1812. if test "$lshared" = "yes" ; then
  1813. echo "BUILD_SHARED=yes" >> config.mak
  1814. echo "PIC=-fPIC -DPIC" >> config.mak
  1815. echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
  1816. echo "SPPVERSION=$pp_version" >> config.mak
  1817. echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
  1818. echo "LAVCVERSION=$lavc_version" >> config.mak
  1819. echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
  1820. echo "LAVFVERSION=$lavf_version" >> config.mak
  1821. echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
  1822. echo "LAVUVERSION=$lavu_version" >> config.mak
  1823. echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
  1824. echo "SWSVERSION=$sws_version" >> config.mak
  1825. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  1826. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  1827. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  1828. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  1829. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  1830. fi
  1831. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  1832. echo "EXTRALIBS=$extralibs" >> config.mak
  1833. enabled_any $ENCODER_LIST && enable encoders
  1834. enabled_any $DECODER_LIST && enable decoders
  1835. enabled_any $MUXER_LIST && enable muxers
  1836. enabled_any $DEMUXER_LIST && enable demuxers
  1837. enabled_any pthreads beosthreads os2threads w32threads && enable threads
  1838. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  1839. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST
  1840. if test "$targetos" = "Darwin"; then
  1841. echo "#define CONFIG_DARWIN 1" >> $TMPH
  1842. fi
  1843. echo "#define restrict $_restrict" >> $TMPH
  1844. if test "$optimize" = "small"; then
  1845. echo "#define always_inline" >> $TMPH
  1846. echo "#define CONFIG_SMALL 1" >> $TMPH
  1847. fi
  1848. echo "SRC_PATH=\"$source_path\"" >> config.mak
  1849. echo "SRC_PATH_BARE=$source_path" >> config.mak
  1850. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  1851. if test "$amr_if2" = "yes" ; then
  1852. echo "AMR_CFLAGS=-DIF2=1" >> config.mak
  1853. fi
  1854. # Apparently it's not possible to portably echo a backslash.
  1855. if test "$asmalign_pot" = "yes" ; then
  1856. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
  1857. else
  1858. printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
  1859. fi
  1860. for codec in $DECODER_LIST $ENCODER_LIST $PARSER_LIST $DEMUXER_LIST $MUXER_LIST; do
  1861. ucname="`toupper $codec`"
  1862. config_name="CONFIG_$ucname"
  1863. enabled_name="ENABLE_$ucname"
  1864. if enabled $codec; then
  1865. echo "#define $config_name 1" >> $TMPH
  1866. echo "#define $enabled_name 1" >> $TMPH
  1867. echo "$config_name=yes" >> config.mak
  1868. else
  1869. echo "#define $enabled_name 0" >> $TMPH
  1870. fi
  1871. done
  1872. # Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
  1873. if ! cmp -s $TMPH config.h; then
  1874. mv -f $TMPH config.h
  1875. else
  1876. echo "config.h is unchanged"
  1877. fi
  1878. rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
  1879. # build tree in object directory if source path is different from current one
  1880. if test "$source_path_used" = "yes" ; then
  1881. DIRS="\
  1882. doc \
  1883. libavformat \
  1884. libavcodec \
  1885. libavcodec/alpha \
  1886. libavcodec/armv4l \
  1887. libavcodec/bfin \
  1888. libavcodec/i386 \
  1889. libavcodec/sparc \
  1890. libavcodec/mlib \
  1891. libavcodec/ppc \
  1892. libavcodec/liba52 \
  1893. libavcodec/amr \
  1894. libavcodec/amr_float \
  1895. libavcodec/amrwb_float \
  1896. libpostproc \
  1897. libavutil \
  1898. libswscale \
  1899. tests \
  1900. vhook \
  1901. "
  1902. FILES="\
  1903. Makefile \
  1904. common.mak \
  1905. libavformat/Makefile \
  1906. libavcodec/Makefile \
  1907. libpostproc/Makefile \
  1908. libavutil/Makefile \
  1909. libswscale/Makefile \
  1910. tests/Makefile \
  1911. vhook/Makefile \
  1912. doc/Makefile \
  1913. doc/texi2pod.pl \
  1914. "
  1915. for dir in $DIRS ; do
  1916. mkdir -p $dir
  1917. done
  1918. for f in $FILES ; do
  1919. ln -sf "$source_path/$f" $f
  1920. done
  1921. fi
  1922. # build pkg-config files
  1923. # FIXME: libdir and includedir are hardcoded and may differ from the real path.
  1924. pkgconfig_generate(){
  1925. name=$1
  1926. comment=$2
  1927. version=$3
  1928. libs=$4
  1929. requires=$5
  1930. include=$6
  1931. cat <<EOF >$name.pc
  1932. prefix=$PREFIX
  1933. exec_prefix=\${prefix}
  1934. libdir=\${exec_prefix}/lib
  1935. includedir=\${prefix}/include
  1936. Name: $name
  1937. Description: $comment
  1938. Version: $version
  1939. Requires: $requires
  1940. Conflicts:
  1941. Libs: -L\${libdir} $libs
  1942. Cflags: -I\${includedir} -I\${includedir}/$include
  1943. EOF
  1944. }
  1945. pkgconfig_generate_uninstalled(){
  1946. name=$1
  1947. shortname=${name#lib}
  1948. comment=$2
  1949. version=$3
  1950. libs=$4
  1951. requires=$5
  1952. cat <<EOF >$name-uninstalled.pc
  1953. prefix=
  1954. exec_prefix=
  1955. libdir=\${pcfiledir}/$name
  1956. includedir=\${pcfiledir}/$name
  1957. Name: $name
  1958. Description: $comment
  1959. Version: $version
  1960. Requires: $requires
  1961. Conflicts:
  1962. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  1963. Cflags: -I\${includedir}
  1964. EOF
  1965. }
  1966. pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
  1967. pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
  1968. pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
  1969. pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
  1970. pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
  1971. pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
  1972. if test "$pp" = "yes"; then
  1973. pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
  1974. pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
  1975. fi
  1976. if test "$swscaler" != "no"; then
  1977. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "-lswscale" "libavutil = $lavu_version" swscale
  1978. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
  1979. else
  1980. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" swscale
  1981. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
  1982. apply libswscale.pc sed s/^Libs:.*$/Libs:/
  1983. apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
  1984. fi