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.

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