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.

2131 lines
55KB

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