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.

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