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.

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