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.

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