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.

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