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.

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