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.

2234 lines
58KB

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