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.

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