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.

2102 lines
56KB

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