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.

2232 lines
58KB

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