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.

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