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.

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