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.

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