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.

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