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.

2218 lines
59KB

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