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.

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