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.

2178 lines
57KB

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