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.

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