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.

2200 lines
58KB

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