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.

2186 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="yes"
  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. FFLDFLAGS=""
  747. FFSERVERLDFLAGS=""
  748. SHFLAGS="-shared -Wl,-h,\$@"
  749. add_extralibs "-lsocket -lnsl"
  750. ;;
  751. NetBSD)
  752. dv1394="no"
  753. add_extralibs "-lossaudio"
  754. ;;
  755. OpenBSD)
  756. dv1394="no"
  757. need_memalign="no"
  758. LIBOBJFLAGS="\$(PIC)"
  759. LDCONFIG="ldconfig -m \$(shlibdir)"
  760. SHFLAGS='-shared'
  761. SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF).$(LIBVERSION)'
  762. SLIBNAME_WITH_VERSION='$(SLIBNAME)'
  763. SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
  764. add_extralibs "-lossaudio"
  765. ;;
  766. FreeBSD)
  767. dv1394="no"
  768. need_memalign="no"
  769. add_cflags "-pthread"
  770. ;;
  771. GNU/kFreeBSD)
  772. dv1394="no"
  773. add_cflags "-pthread"
  774. ;;
  775. BSD/OS)
  776. dv1394="no"
  777. extralibs="-lpoll -lgnugetopt -lm"
  778. strip="strip -d"
  779. ;;
  780. Darwin)
  781. cc="cc"
  782. dv1394="no"
  783. need_memalign="no"
  784. SHFLAGS="-dynamiclib -Wl,-single_module -Wl,-install_name,\$(shlibdir)/\$(SLIBNAME),-current_version,\$(SPPVERSION),-compatibility_version,\$(SPPVERSION) -Wl,-read_only_relocs,suppress"
  785. VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(shlibdir)/vhook/$@'
  786. extralibs=""
  787. strip="strip -x"
  788. FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
  789. SLIBSUF=".dylib"
  790. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
  791. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
  792. FFSERVERLDFLAGS=-Wl,-bind_at_load
  793. ;;
  794. MINGW32*)
  795. # Note: the rest of the mingw32 config is done afterwards as mingw32
  796. # can be forced on the command line for Linux cross compilation.
  797. mingw32="yes"
  798. ;;
  799. CYGWIN*)
  800. targetos=CYGWIN
  801. shlibdir="$bindir"
  802. dv1394="no"
  803. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  804. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  805. extralibs=""
  806. EXESUF=".exe"
  807. SLIBPREF="cyg"
  808. SLIBSUF=".dll"
  809. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  810. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
  811. SHFLAGS='-shared -Wl,--out-implib=lib$(NAME).dll.a'
  812. ;;
  813. Linux)
  814. LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
  815. ;;
  816. IRIX*)
  817. targetos=IRIX
  818. ranlib="echo ignoring ranlib"
  819. ;;
  820. OS/2)
  821. TMPE=$TMPE".exe"
  822. ar="emxomfar -p128"
  823. ranlib="echo ignoring ranlib"
  824. strip="echo ignoring strip"
  825. add_cflags "-Zomf"
  826. FFLDFLAGS="-Zomf -Zstack 16384 -s"
  827. SHFLAGS="-Zdll -Zomf"
  828. FFSERVERLDFLAGS=""
  829. LIBPREF=""
  830. LIBSUF=".lib"
  831. SLIBPREF=""
  832. SLIBSUF=".dll"
  833. EXESUF=".exe"
  834. extralibs=""
  835. pkg_requires=""
  836. dv1394="no"
  837. ffserver="no"
  838. vhook="no"
  839. os2="yes"
  840. ;;
  841. *)
  842. targetos="${targetos}-UNKNOWN"
  843. ;;
  844. esac
  845. # find source path
  846. source_path="`dirname \"$0\"`"
  847. source_path_used="yes"
  848. if test -z "$source_path" -o "$source_path" = "." ; then
  849. source_path="`pwd`"
  850. source_path_used="no"
  851. else
  852. source_path="`cd \"$source_path\"; pwd`"
  853. echo "$source_path" | grep -q '[[:blank:]]' &&
  854. die "Out of tree builds are impossible with whitespace in source path."
  855. fi
  856. if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
  857. show_help
  858. fi
  859. FFMPEG_CONFIGURATION="$@"
  860. ENCODER_LIST=`sed -n 's/^[^#]*ENC.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
  861. DECODER_LIST=`sed -n 's/^[^#]*DEC.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
  862. PARSER_LIST=`sed -n 's/^[^#]*PARSER.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
  863. MUXER_LIST=`sed -n 's/^[^#]*_MUX.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
  864. DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
  865. enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST
  866. for opt do
  867. optval="${opt#*=}"
  868. case "$opt" in
  869. --log)
  870. ;;
  871. --log=*) logging="$optval"
  872. ;;
  873. --prefix=*) PREFIX="$optval"
  874. ;;
  875. --libdir=*) libdir="$optval"
  876. ;;
  877. --shlibdir=*) shlibdir="$optval"
  878. ;;
  879. --incdir=*) incdir="$optval"
  880. ;;
  881. --mandir=*) mandir="$optval"
  882. ;;
  883. --source-path=*) source_path="$optval"
  884. ;;
  885. --cross-prefix=*) cross_prefix="$optval"
  886. ;;
  887. --cross-compile) cross_compile=yes
  888. ;;
  889. --cc=*) cc="$optval"
  890. ;;
  891. --make=*) make="$optval"
  892. ;;
  893. --extra-cflags=*) add_cflags "$optval"
  894. ;;
  895. --extra-ldflags=*) add_ldflags "$optval"
  896. ;;
  897. --extra-libs=*) add_extralibs "$optval"
  898. ;;
  899. --build-suffix=*) BUILDSUF="$optval"
  900. ;;
  901. --arch=*) arch="$optval"
  902. ;;
  903. --cpu=*) cpu="$optval"
  904. ;;
  905. --powerpc-perf-enable) powerpc_perf="yes"
  906. ;;
  907. --disable-mmx) mmx="no"
  908. ;;
  909. --disable-armv5te) armv5te="no"
  910. ;;
  911. --disable-armv6) armv6="no"
  912. ;;
  913. --disable-iwmmxt) iwmmxt="no"
  914. ;;
  915. --disable-altivec) altivec="no"
  916. ;;
  917. --enable-gprof) gprof="yes"
  918. ;;
  919. --disable-v4l) video4linux="no"
  920. ;;
  921. --disable-v4l2) video4linux2="no"
  922. ;;
  923. --disable-bktr) bktr="no"
  924. ;;
  925. --disable-audio-oss) audio_oss="no"
  926. ;;
  927. --disable-audio-beos) audio_beos="no"
  928. ;;
  929. --disable-dv1394) dv1394="no"
  930. ;;
  931. --disable-network) network="no"; ffserver="no"
  932. ;;
  933. --disable-ipv6) ipv6="no";
  934. ;;
  935. --disable-zlib) zlib="no"
  936. ;;
  937. --enable-a52) liba52="yes"
  938. ;;
  939. --enable-a52bin) liba52bin="yes"
  940. ;;
  941. --enable-dts) libdts="yes"
  942. ;;
  943. --enable-pp) pp="yes"
  944. ;;
  945. --enable-libgsm) libgsm="yes"
  946. ;;
  947. --enable-mp3lame) libmp3lame="yes"
  948. ;;
  949. --enable-libnut) libnut="yes"
  950. ;;
  951. --enable-libogg) libogg="yes"
  952. pkg_requires="$pkg_requires ogg >= 1.1"
  953. ;;
  954. --enable-libtheora) libtheora="yes"
  955. pkg_requires="$pkg_requires theora"
  956. ;;
  957. --enable-vorbis) libvorbis="yes"
  958. pkg_requires="$pkg_requires vorbis vorbisenc"
  959. ;;
  960. --enable-faad) libfaad="yes"
  961. ;;
  962. --enable-faadbin) libfaadbin="yes"
  963. ;;
  964. --enable-faac) libfaac="yes"
  965. ;;
  966. --enable-xvid) xvid="yes"
  967. ;;
  968. --enable-x264) x264="yes"
  969. ;;
  970. --enable-avisynth) avisynth="yes";
  971. ;;
  972. --enable-x11grab) x11grab="yes";
  973. ;;
  974. --enable-dc1394) dc1394="yes"
  975. pkg_requires="$pkg_requires libraw1394"
  976. ;;
  977. --disable-vhook) vhook="no"
  978. ;;
  979. --enable-mingw32) mingw32="yes"
  980. ;;
  981. --enable-mingwce) wince="yes"
  982. ;;
  983. --enable-static) lstatic="yes"
  984. ;;
  985. --disable-static) lstatic="no"
  986. ;;
  987. --enable-shared) lshared="yes"
  988. ;;
  989. --disable-shared) lshared="no"
  990. ;;
  991. --disable-debug) debug="no"
  992. ;;
  993. --disable-opts) optimize="no"
  994. ;;
  995. --enable-extra-warnings) extrawarnings="yes"
  996. ;;
  997. --disable-mpegaudio-hp) mpegaudio_hp="no"
  998. ;;
  999. --disable-protocols) protocols="no"; network="no"; ffserver="no"
  1000. ;;
  1001. --disable-ffmpeg) ffmpeg="no"
  1002. ;;
  1003. --disable-ffserver) ffserver="no"
  1004. ;;
  1005. --disable-ffplay) ffplay="no"
  1006. ;;
  1007. --enable-small) optimize="small"
  1008. ;;
  1009. --enable-amr_nb) amr="yes"; amr_nb="yes"; amr_nb_fixed="no"
  1010. ;;
  1011. --enable-amr_nb-fixed) amr="yes"; amr_nb_fixed="yes"; amr_nb="no"
  1012. ;;
  1013. --enable-amr_wb) amr="yes"; amr_wb="yes"
  1014. ;;
  1015. --enable-amr_if2) amr="yes"; amr_if2="yes"
  1016. ;;
  1017. --enable-sunmlib) mlib="yes"
  1018. ;;
  1019. --enable-pthreads) pthreads="yes"
  1020. ;;
  1021. --enable-w32threads) w32threads="yes"
  1022. ;;
  1023. --enable-beosthreads) beosthreads="yes"
  1024. ;;
  1025. --enable-os2threads) os2threads="yes"
  1026. ;;
  1027. --enable-swscaler) swscaler="yes"
  1028. ;;
  1029. --enable-gpl) gpl="yes"
  1030. ;;
  1031. --enable-memalign-hack) memalign_hack="yes"
  1032. ;;
  1033. --disable-strip) dostrip="no"
  1034. ;;
  1035. --enable-encoder=*) enable ${optval}_encoder
  1036. ;;
  1037. --enable-decoder=*) enable ${optval}_decoder
  1038. ;;
  1039. --disable-encoder=*) disable ${optval}_encoder
  1040. ;;
  1041. --disable-decoder=*) disable ${optval}_decoder
  1042. ;;
  1043. --disable-encoders) disable $ENCODER_LIST
  1044. ;;
  1045. --disable-decoders) disable $DECODER_LIST
  1046. ;;
  1047. --enable-muxer=*) enable ${optval}_muxer
  1048. ;;
  1049. --disable-muxer=*) disable ${optval}_muxer
  1050. ;;
  1051. --disable-muxers) disable $MUXER_LIST; ffserver="no"
  1052. ;;
  1053. --enable-demuxer=*) enable ${optval}_demuxer
  1054. ;;
  1055. --disable-demuxer=*) disable ${optval}_demuxer
  1056. ;;
  1057. --disable-demuxers) disable $DEMUXER_LIST
  1058. ;;
  1059. --enable-parser=*) enable ${optval}_parser
  1060. ;;
  1061. --disable-parser=*) disable ${optval}_parser
  1062. ;;
  1063. --disable-parsers) disable $PARSER_LIST
  1064. ;;
  1065. --help) show_help
  1066. ;;
  1067. *)
  1068. echo "Unknown option \"$opt\"."
  1069. echo "See $0 --help for available options."
  1070. exit 1
  1071. ;;
  1072. esac
  1073. done
  1074. if ! disabled logging ; then
  1075. enabled logging || logfile="$logging"
  1076. echo "# $0 $@" >$logfile
  1077. set >>$logfile
  1078. else
  1079. logfile=/dev/null
  1080. fi
  1081. if enabled_any mingw32 wince; then
  1082. if enabled_all lshared lstatic; then
  1083. cat <<EOF
  1084. You can only build one library type at once on MinGW.
  1085. Specify --disable-static --enable-shared to only build
  1086. the shared libraries. To build only the static libraries
  1087. you do not need to pass additional options.
  1088. EOF
  1089. exit 1
  1090. fi
  1091. dv1394="no"
  1092. dc1394="no"
  1093. ffserver="no"
  1094. network="no"
  1095. if enabled wince; then
  1096. protocols="no"
  1097. fi
  1098. SLIBPREF=""
  1099. SLIBSUF=".dll"
  1100. EXESUF=".exe"
  1101. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1102. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
  1103. SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
  1104. SLIB_INSTALL_EXTRA_CMD="-install -m 644 \$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib) \"\$(shlibdir)/\$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib)\""
  1105. SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc"
  1106. fi
  1107. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1108. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1109. test -n "$cross_prefix" && cross_compile=yes
  1110. cc="${cross_prefix}${cc}"
  1111. ar="${cross_prefix}${ar}"
  1112. ranlib="${cross_prefix}${ranlib}"
  1113. strip="${cross_prefix}${strip}"
  1114. # we need to build at least one lib type
  1115. if disabled_all lstatic lshared; then
  1116. cat <<EOF
  1117. At least one library type must be built.
  1118. Specify --enable-static to build the static libraries or --enable-shared to
  1119. build the shared libraries as well. To only build the shared libraries specify
  1120. --disable-static in addition to --enable-shared.
  1121. EOF
  1122. exit 1;
  1123. fi
  1124. if disabled libogg; then
  1125. enabled libtheora && die "libogg must be enabled to enable libtheora."
  1126. enabled libvorbis && die "libogg must be enabled to enable libvorbis."
  1127. fi
  1128. if enabled_any libfaad libfaadbin ; then
  1129. if check_header faad.h; then
  1130. check_cc << EOF
  1131. #include <faad.h>
  1132. #ifndef FAAD2_VERSION
  1133. ok faad1
  1134. #endif
  1135. int main( void ) { return 0; }
  1136. EOF
  1137. test $? = 0 && enable libfaad2
  1138. else
  1139. die "FAAD test failed."
  1140. fi
  1141. fi
  1142. if disabled gpl ; then
  1143. die_gpl_disabled(){
  1144. name=$1
  1145. shift
  1146. enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
  1147. }
  1148. die_gpl_disabled "The Postprocessing code" pp
  1149. die_gpl_disabled "liba52" liba52 liba52bin
  1150. die_gpl_disabled "libxvidcore" xvid
  1151. die_gpl_disabled "x264" x264
  1152. die_gpl_disabled "libdts" libdts
  1153. die_gpl_disabled "FAAD2" libfaad2
  1154. die_gpl_disabled "The X11 grabber" x11grab
  1155. die_gpl_disabled "The software scaler" swscaler
  1156. fi
  1157. # compute MMX state
  1158. if test $mmx = "default"; then
  1159. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1160. mmx="yes"
  1161. else
  1162. mmx="no"
  1163. fi
  1164. fi
  1165. test -z "$need_memalign" && need_memalign="$mmx"
  1166. #Darwin CC versions
  1167. needmdynamicnopic="no"
  1168. if test $targetos = Darwin; then
  1169. if test -n "`$cc -v 2>&1 | grep xlc`"; then
  1170. add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
  1171. else
  1172. gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
  1173. case "$gcc_version" in
  1174. *2.95*)
  1175. add_cflags "-no-cpp-precomp -pipe"
  1176. ;;
  1177. *[34].*)
  1178. add_cflags "-no-cpp-precomp -pipe -force_cpusubtype_ALL -Wno-sign-compare"
  1179. if disabled lshared; then
  1180. needmdynamicnopic="yes"
  1181. fi
  1182. ;;
  1183. *)
  1184. add_cflags "-no-cpp-precomp -pipe"
  1185. if disabled lshared; then
  1186. needmdynamicnopic="yes"
  1187. fi
  1188. ;;
  1189. esac
  1190. fi
  1191. fi
  1192. if ! disabled optimize ; then
  1193. add_cflags "-fomit-frame-pointer"
  1194. fi
  1195. # Can only do AltiVec on PowerPC
  1196. if test $altivec = "default"; then
  1197. if test $arch = "powerpc"; then
  1198. altivec="yes"
  1199. else
  1200. altivec="no"
  1201. fi
  1202. fi
  1203. # Add processor-specific flags
  1204. POWERPCMODE="32bits"
  1205. if test $cpu != "generic"; then
  1206. warn_altivec(){
  1207. $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
  1208. }
  1209. case $cpu in
  1210. 601|ppc601|PowerPC601)
  1211. add_cflags "-mcpu=601"
  1212. warn_altivec enabled PPC601
  1213. ;;
  1214. 603*|ppc603*|PowerPC603*)
  1215. add_cflags "-mcpu=603"
  1216. warn_altivec enabled PPC603
  1217. ;;
  1218. 604*|ppc604*|PowerPC604*)
  1219. add_cflags "-mcpu=604"
  1220. warn_altivec enabled PPC604
  1221. ;;
  1222. G3|g3|75*|ppc75*|PowerPC75*)
  1223. add_cflags "-mcpu=750 -mpowerpc-gfxopt"
  1224. warn_altivec enabled PPC75x
  1225. ;;
  1226. G4|g4|745*|ppc745*|PowerPC745*)
  1227. add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
  1228. warn_altivec disabled PPC745x
  1229. ;;
  1230. 74*|ppc74*|PowerPC74*)
  1231. add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
  1232. warn_altivec disabled PPC74xx
  1233. ;;
  1234. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1235. add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1236. warn_altivec disabled PPC970
  1237. POWERPCMODE="64bits"
  1238. ;;
  1239. # targets that do NOT support conditional mov (cmov)
  1240. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1241. add_cflags "-march=$cpu"
  1242. cmov="no"
  1243. ;;
  1244. # targets that do support conditional mov (cmov)
  1245. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1246. add_cflags "-march=$cpu"
  1247. cmov="yes"
  1248. fast_cmov="yes"
  1249. ;;
  1250. # targets that do support conditional mov but on which it's slow
  1251. pentium4|prescott|nocona)
  1252. add_cflags "-march=$cpu"
  1253. cmov="yes"
  1254. fast_cmov="no"
  1255. ;;
  1256. sparc64)
  1257. add_cflags "-mcpu=v9"
  1258. ;;
  1259. *)
  1260. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1261. ;;
  1262. esac
  1263. fi
  1264. gnu_make(){
  1265. $1 --version 2>&1 | grep -q GNU
  1266. }
  1267. if ! gnu_make $make; then
  1268. gnu_make gmake && make=gmake || die "GNU make not found."
  1269. fi
  1270. # make sure we can execute files in $TMPDIR
  1271. cat >$TMPE 2>>$logfile <<EOF
  1272. #! /bin/sh
  1273. EOF
  1274. chmod +x $TMPE >>$logfile 2>&1
  1275. if ! $TMPE >>$logfile 2>&1; then
  1276. cat <<EOF
  1277. Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
  1278. variable to another directory and make sure that $TMPDIR1 is not mounted
  1279. noexec.
  1280. EOF
  1281. die "Sanity test failed."
  1282. fi
  1283. rm $TMPE
  1284. # compiler sanity check
  1285. check_exec <<EOF
  1286. int main(){
  1287. return 0;
  1288. }
  1289. EOF
  1290. if test "$?" != 0; then
  1291. echo "$cc is unable to create an executable file."
  1292. if test -z "$cross_prefix" && disabled cross_compile ; then
  1293. echo "If $cc is a cross-compiler, use the --cross-compile option."
  1294. echo "Only do this if you know what cross compiling means."
  1295. fi
  1296. die "C compiler test failed."
  1297. fi
  1298. # check for assembler specific support
  1299. if test $arch = "powerpc"; then
  1300. check_cc <<EOF && dcbzl=yes
  1301. int main(void) {
  1302. register long zero = 0;
  1303. char data[1024];
  1304. asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
  1305. return 0;
  1306. }
  1307. EOF
  1308. fi
  1309. # check for SIMD availability
  1310. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1311. if test $arch = "powerpc"; then
  1312. if enabled altivec; then
  1313. if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
  1314. add_cflags "-faltivec"
  1315. else
  1316. add_cflags "-maltivec -mabi=altivec"
  1317. fi
  1318. fi
  1319. fi
  1320. check_header altivec.h
  1321. # check if our compiler supports Motorola AltiVec C API
  1322. if enabled altivec; then
  1323. if enabled altivec_h; then
  1324. inc_altivec_h="#include <altivec.h>"
  1325. else
  1326. inc_altivec_h=
  1327. fi
  1328. check_cc <<EOF || altivec=no
  1329. $inc_altivec_h
  1330. int main(void) {
  1331. vector signed int v1, v2, v3;
  1332. v1 = vec_add(v2,v3);
  1333. return 0;
  1334. }
  1335. EOF
  1336. fi
  1337. # check armv5te instructions support
  1338. if test $armv5te = "default" -a $arch = "armv4l"; then
  1339. armv5te=no
  1340. check_cc <<EOF && armv5te=yes
  1341. int main(void) {
  1342. __asm__ __volatile__ ("qadd r0, r0, r0");
  1343. }
  1344. EOF
  1345. fi
  1346. if test $armv6 = "default" -a $arch = "armv4l"; then
  1347. check_cc <<EOF && armv6=yes || armv6=no
  1348. int main(void) {
  1349. __asm__ __volatile__ ("sadd16 r0, r0, r0");
  1350. }
  1351. EOF
  1352. fi
  1353. # check iwmmxt support
  1354. if test $iwmmxt = "default" -a $arch = "armv4l"; then
  1355. iwmmxt=no
  1356. check_cc <<EOF && iwmmxt=yes
  1357. int main(void) {
  1358. __asm__ __volatile__ ("wunpckelub wr6, wr4");
  1359. }
  1360. EOF
  1361. fi
  1362. # mmi only available on mips
  1363. if test $mmi = "default"; then
  1364. if test $arch = "mips"; then
  1365. mmi="yes"
  1366. else
  1367. mmi="no"
  1368. fi
  1369. fi
  1370. # check if our compiler supports mmi
  1371. enabled mmi && check_cc <<EOF || mmi="no"
  1372. int main(void) {
  1373. __asm__ ("lq \$2, 0(\$2)");
  1374. return 0;
  1375. }
  1376. EOF
  1377. # ---
  1378. # big/little-endian test
  1379. if disabled cross_compile; then
  1380. check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
  1381. #include <inttypes.h>
  1382. int main(int argc, char ** argv){
  1383. volatile uint32_t i=0x01234567;
  1384. return (*((uint8_t*)(&i))) == 0x67;
  1385. }
  1386. EOF
  1387. else
  1388. # programs cannot be launched if cross compiling, so make a static guess
  1389. if test "$arch" = "powerpc" -o "$arch" = "mips" ; then
  1390. bigendian="yes"
  1391. fi
  1392. fi
  1393. # ---
  1394. # check availability of some header files
  1395. check_header malloc.h
  1396. check_func memalign
  1397. if disabled_all memalign memalign_hack && enabled need_memalign ; then
  1398. die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
  1399. fi
  1400. check_header byteswap.h
  1401. check_func inet_aton
  1402. check_func localtime_r
  1403. enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
  1404. # check for some common methods of building with pthread support
  1405. # do this before the optional library checks as some of them require pthreads
  1406. if enabled pthreads; then
  1407. if check_func pthread_create; then
  1408. :
  1409. elif check_func pthread_create -pthread; then
  1410. add_cflags -pthread
  1411. add_ldflags -pthread
  1412. elif check_func pthread_create -pthreads; then
  1413. add_cflags -pthreads
  1414. add_ldflags -pthreads
  1415. elif ! check_lib pthread.h pthread_create -lpthread; then
  1416. die "ERROR: can't find pthreads library"
  1417. fi
  1418. fi
  1419. for thread in pthreads beosthreads os2threads w32threads; do
  1420. if enabled $thread; then
  1421. if ! disabled thread_type ; then
  1422. die "ERROR: Only one thread type must be selected."
  1423. else
  1424. thread_type="$thread"
  1425. fi
  1426. fi
  1427. done
  1428. # these are off by default, so fail if requested and not available
  1429. enabled libdts && require libdts dts.h dts_init -ldts -lm
  1430. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1431. enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
  1432. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  1433. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
  1434. enabled libogg && require libogg ogg/ogg.h ogg_sync_init -logg
  1435. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1436. enabled xvid && require XviD xvid.h xvid_global -lxvidcore
  1437. enabled x264 && require x264 x264.h x264_encoder_open -lx264
  1438. enabled dc1394 && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
  1439. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1440. # Ugh, libfaac uses stdcall calling convention on win32 so we can't use
  1441. # the generic test functions
  1442. if enabled libfaac; then
  1443. save_flags
  1444. temp_extralibs -lfaac
  1445. check_ld <<EOF && add_extralibs -lfaac || die "ERROR: libfaac not found"
  1446. #include <stdint.h>
  1447. #include <faac.h>
  1448. int main(){
  1449. char *id, *cpr;
  1450. faacEncGetVersion(&id, &cpr);
  1451. return 0;
  1452. }
  1453. EOF
  1454. restore_flags
  1455. fi
  1456. # Ugh, recent faad2 versions have renamed all functions and #define the
  1457. # old names in faad.h. Generic tests won't work.
  1458. if enabled libfaad; then
  1459. save_flags
  1460. temp_extralibs -lfaad
  1461. check_ld <<EOF && add_extralibs -lfaad || die "ERROR: libfaad not found"
  1462. #include <faad.h>
  1463. int main(){
  1464. faacDecOpen();
  1465. return 0;
  1466. }
  1467. EOF
  1468. restore_flags
  1469. fi
  1470. # Ugh, avisynth uses WINAPI calls. Generic tests won't work.
  1471. if enabled avisynth; then
  1472. save_flags
  1473. temp_extralibs -lvfw32
  1474. check_ld <<EOF && add_extralibs -lvfw32 || die "ERROR: vfw32 not found"
  1475. #include <windows.h>
  1476. #include <vfw.h>
  1477. int main(){
  1478. AVIFileInit();
  1479. return 0;
  1480. }
  1481. EOF
  1482. restore_flags
  1483. fi
  1484. # test for lrintf in math.h
  1485. check_exec <<EOF && lrintf=yes || lrintf=no
  1486. #define _ISOC9X_SOURCE 1
  1487. #include <math.h>
  1488. int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
  1489. EOF
  1490. _restrict=
  1491. for restrict_keyword in restrict __restrict__ __restrict; do
  1492. check_cc <<EOF && _restrict=$restrict_keyword && break
  1493. void foo(char * $restrict_keyword p);
  1494. EOF
  1495. done
  1496. # dlopen/dlfcn.h probing
  1497. check_header dlfcn.h
  1498. if check_func dlopen; then
  1499. ldl=
  1500. elif check_func dlopen -ldl; then
  1501. ldl=-ldl
  1502. fi
  1503. if test "$vhook" = "default"; then
  1504. vhook="$dlopen"
  1505. fi
  1506. if enabled_any vhook liba52bin libfaadbin; then
  1507. add_extralibs $ldl
  1508. fi
  1509. if test "$targetos" = "CYGWIN" && enabled lstatic ; then
  1510. vhook="no"
  1511. echo
  1512. echo "At the moment vhooks don't work on Cygwin static builds."
  1513. echo "Patches welcome."
  1514. echo
  1515. fi
  1516. if enabled vhook; then
  1517. check_ldflags -rdynamic
  1518. check_ldflags -export-dynamic
  1519. fi
  1520. if enabled audio_beos; then
  1521. add_extralibs "-lmedia -lbe"
  1522. fi
  1523. ##########################################
  1524. # imlib check
  1525. imlib2=no
  1526. if (imlib2-config --version) >/dev/null 2>&1 ; then
  1527. temp_cflags `imlib2-config --cflags`
  1528. temp_extralibs `imlib2-config --libs`
  1529. check_ld <<EOF && imlib2=yes
  1530. #include <Imlib2.h>
  1531. int main( void ) { return (int) imlib_load_font("foo"); }
  1532. EOF
  1533. restore_flags
  1534. fi
  1535. ##########################################
  1536. # FreeType check
  1537. freetype2=no
  1538. if test "x$targetos" != "xBeOS"; then
  1539. if (freetype-config --version) >/dev/null 2>&1 ; then
  1540. temp_cflags `freetype-config --cflags`
  1541. temp_extralibs `freetype-config --libs`
  1542. check_ld <<EOF && freetype2=yes
  1543. #include <ft2build.h>
  1544. int main( void ) { return (int) FT_Init_FreeType(0); }
  1545. EOF
  1546. restore_flags
  1547. fi
  1548. fi
  1549. ##########################################
  1550. # SDL check
  1551. sdl_too_old=no
  1552. sdl=no
  1553. SDL_CONFIG="${cross_prefix}sdl-config"
  1554. if ("${SDL_CONFIG}" --version) >/dev/null 2>&1 ; then
  1555. temp_cflags `"${SDL_CONFIG}" --cflags`
  1556. temp_extralibs `"${SDL_CONFIG}" --libs`
  1557. check_ld <<EOF
  1558. #include <SDL.h>
  1559. #undef main /* We don't want SDL to override our main() */
  1560. int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
  1561. EOF
  1562. if test $? = 0; then
  1563. _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
  1564. if test "$_sdlversion" -lt 121 ; then
  1565. sdl_too_old=yes
  1566. else
  1567. sdl=yes
  1568. check_cc <<EOF && sdl_video_size=yes || sdl_video_size=no
  1569. #include <SDL.h>
  1570. int main(void){
  1571. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1572. int w = vi->current_w;
  1573. return 0;
  1574. }
  1575. EOF
  1576. fi
  1577. fi
  1578. restore_flags
  1579. fi
  1580. enabled sdl || ffplay=no
  1581. texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
  1582. ##########################################
  1583. # IPv6 check
  1584. enabled network && enabled ipv6 && check_ld <<EOF && ipv6=yes || ipv6=no
  1585. #include <sys/types.h>
  1586. #include <sys/socket.h>
  1587. #include <netinet/in.h>
  1588. #include <netdb.h>
  1589. int main( void ) {
  1590. struct sockaddr_storage saddr;
  1591. struct ipv6_mreq mreq6;
  1592. getaddrinfo(0,0,0,0);
  1593. getnameinfo(0,0,0,0,0,0,0);
  1594. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1595. }
  1596. EOF
  1597. enabled video4linux && check_header linux/videodev.h || disable video4linux
  1598. enabled video4linux2 && check_header linux/videodev2.h || disable video4linux2
  1599. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1600. if enabled bktr; then
  1601. { check_header dev/bktr/ioctl_meteor.h &&
  1602. check_header dev/bktr/ioctl_bt848.h; } ||
  1603. { check_header machine/ioctl_meteor.h &&
  1604. check_header machine/ioctl_bt848.h; } ||
  1605. { check_header dev/video/meteor/ioctl_meteor.h &&
  1606. check_header dev/video/bktr/ioctl_bt848.h; } ||
  1607. check_header dev/ic/bt8xx.h ||
  1608. disable bktr
  1609. fi
  1610. enabled audio_oss &&
  1611. check_header sys/soundcard.h ||
  1612. check_header soundcard.h ||
  1613. disable audio_oss
  1614. # Deal with the x11 frame grabber
  1615. enabled x11grab &&
  1616. enabled gpl &&
  1617. enabled x11_grab_device_demuxer &&
  1618. check_header X11/Xlib.h &&
  1619. check_header X11/extensions/XShm.h &&
  1620. check_func XOpenDisplay -lX11 &&
  1621. check_func XShmCreateImage -lX11 -lXext &&
  1622. add_extralibs -lX11 -lXext ||
  1623. disable x11_grab_device_demuxer
  1624. enabled debug && add_cflags -g
  1625. # add some useful compiler flags if supported
  1626. check_cflags -Wdeclaration-after-statement
  1627. check_cflags -Wall
  1628. check_cflags -Wno-switch
  1629. check_cflags -Wdisabled-optimization
  1630. check_cflags -Wpointer-arith
  1631. check_cflags -Wredundant-decls
  1632. check_cflags -Wno-pointer-sign
  1633. enabled extrawarnings && check_cflags -Winline
  1634. # add some linker flags
  1635. check_ldflags $LDLATEFLAGS
  1636. # not all compilers support -Os
  1637. test "$optimize" = "small" && check_cflags -Os
  1638. if enabled optimize; then
  1639. if test -n "`$cc -v 2>&1 | grep xlc`"; then
  1640. add_cflags "-O5"
  1641. add_ldflags "-O5"
  1642. else
  1643. add_cflags "-O3"
  1644. fi
  1645. fi
  1646. # PIC flags for shared library objects where they are needed
  1647. if enabled lshared; then
  1648. # LIBOBJFLAGS may have already been set in the OS configuration
  1649. if test -z "$LIBOBJFLAGS" ; then
  1650. case "$arch" in
  1651. x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS="\$(PIC)" ;;
  1652. esac
  1653. fi
  1654. fi
  1655. if enabled gprof; then
  1656. add_cflags "-p"
  1657. add_ldflags "-p"
  1658. fi
  1659. VHOOKCFLAGS="-fPIC $CFLAGS"
  1660. enabled needmdynamicnopic && add_cflags -mdynamic-no-pic
  1661. # find if .align arg is power-of-two or not
  1662. if test $asmalign_pot = "unknown"; then
  1663. asmalign_pot="no"
  1664. echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
  1665. fi
  1666. echo "install prefix $PREFIX"
  1667. echo "source path $source_path"
  1668. echo "C compiler $cc"
  1669. echo "make $make"
  1670. echo ".align is power-of-two $asmalign_pot"
  1671. echo "ARCH $arch ($cpu)"
  1672. if test "$BUILDSUF" != ""; then
  1673. echo "build suffix $BUILDSUF"
  1674. fi
  1675. echo "big-endian $bigendian"
  1676. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1677. echo "MMX enabled $mmx"
  1678. echo "CMOV enabled $cmov"
  1679. echo "CMOV is fast $fast_cmov"
  1680. fi
  1681. if test $arch = "armv4l"; then
  1682. echo "ARMv5TE enabled $armv5te"
  1683. echo "ARMv6 enabled $armv6"
  1684. echo "IWMMXT enabled $iwmmxt"
  1685. fi
  1686. if test $arch = "mips"; then
  1687. echo "MMI enabled $mmi"
  1688. fi
  1689. if test $arch = "powerpc"; then
  1690. echo "AltiVec enabled $altivec"
  1691. echo "dcbzl available $dcbzl"
  1692. fi
  1693. echo "gprof enabled $gprof"
  1694. echo "debug symbols $debug"
  1695. echo "strip symbols $dostrip"
  1696. echo "optimize $optimize"
  1697. echo "static $lstatic"
  1698. echo "shared $lshared"
  1699. echo "postprocessing support $pp"
  1700. echo "software scaler enabled $swscaler"
  1701. echo "video hooking $vhook"
  1702. if enabled vhook; then
  1703. echo "Imlib2 support $imlib2"
  1704. echo "FreeType support $freetype2"
  1705. fi
  1706. echo "network support $network"
  1707. if enabled network; then
  1708. echo "IPv6 support $ipv6"
  1709. fi
  1710. echo "threading support $thread_type"
  1711. echo "SDL support $sdl"
  1712. if enabled sdl_too_old; then
  1713. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  1714. fi
  1715. echo "Sun medialib support $mlib"
  1716. echo "AVISynth enabled $avisynth"
  1717. echo "liba52 support $liba52"
  1718. echo "liba52 dlopened $liba52bin"
  1719. echo "libdts support $libdts"
  1720. echo "libfaac enabled $libfaac"
  1721. echo "libfaad enabled $libfaad"
  1722. echo "faadbin enabled $libfaadbin"
  1723. echo "libgsm enabled $libgsm"
  1724. echo "libmp3lame enabled $libmp3lame"
  1725. echo "libnut enabled $libnut"
  1726. echo "libogg enabled $libogg"
  1727. echo "libtheora enabled $libtheora"
  1728. echo "libvorbis enabled $libvorbis"
  1729. echo "x264 enabled $x264"
  1730. echo "XviD enabled $xvid"
  1731. echo "zlib enabled $zlib"
  1732. echo "AMR-NB float support $amr_nb"
  1733. echo "AMR-NB fixed support $amr_nb_fixed"
  1734. echo "AMR-WB float support $amr_wb"
  1735. echo "AMR-WB IF2 support $amr_if2"
  1736. if disabled gpl; then
  1737. echo "License: LGPL"
  1738. else
  1739. echo "License: GPL"
  1740. fi
  1741. echo "Creating config.mak and config.h..."
  1742. echo "# Automatically generated by configure - do not modify!" > config.mak
  1743. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  1744. echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
  1745. echo "PREFIX=$PREFIX" >> config.mak
  1746. echo "prefix=\$(DESTDIR)\${PREFIX}" >> config.mak
  1747. echo "libdir=\$(DESTDIR)$libdir" >> config.mak
  1748. echo "shlibdir=\$(DESTDIR)$shlibdir" >> config.mak
  1749. echo "incdir=\$(DESTDIR)$incdir" >> config.mak
  1750. echo "bindir=\$(DESTDIR)$bindir" >> config.mak
  1751. echo "mandir=\$(DESTDIR)$mandir" >> config.mak
  1752. echo "MAKE=$make" >> config.mak
  1753. echo "CC=$cc" >> config.mak
  1754. echo "AR=$ar" >> config.mak
  1755. echo "RANLIB=$ranlib" >> config.mak
  1756. if enabled dostrip; then
  1757. echo "STRIP=$strip" >> config.mak
  1758. else
  1759. echo "STRIP=echo ignoring strip" >> config.mak
  1760. fi
  1761. echo "OPTFLAGS=$CFLAGS" >> config.mak
  1762. echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
  1763. echo "LDFLAGS=$LDFLAGS" >> config.mak
  1764. echo "LDCONFIG=$LDCONFIG" >> config.mak
  1765. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  1766. echo "SHFLAGS=$SHFLAGS" >> config.mak
  1767. echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
  1768. echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
  1769. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  1770. echo "BUILD_STATIC=$lstatic" >> config.mak
  1771. echo "BUILDSUF=$BUILDSUF" >> config.mak
  1772. echo "LIBPREF=$LIBPREF" >> config.mak
  1773. echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
  1774. if enabled lstatic; then
  1775. echo "LIB=$LIB" >> config.mak
  1776. else # Some Make complain if this variable does not exist.
  1777. echo "LIB=" >> config.mak
  1778. fi
  1779. echo "SLIBPREF=$SLIBPREF" >> config.mak
  1780. echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
  1781. echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
  1782. echo "TARGET_OS=$targetos" >> config.mak
  1783. ucarch=`toupper $arch`
  1784. echo "TARGET_ARCH_${ucarch}=yes" >> config.mak
  1785. echo "#define ARCH_${ucarch} 1" >> $TMPH
  1786. # special cases
  1787. case "$arch" in
  1788. x86_32|x86_64)
  1789. echo "TARGET_ARCH_X86=yes" >> config.mak
  1790. echo "#define ARCH_X86 1" >> $TMPH
  1791. ;;
  1792. powerpc)
  1793. if test "$POWERPCMODE" = "64bits"; then
  1794. echo "#define POWERPC_MODE_64BITS 1" >> $TMPH
  1795. fi
  1796. if enabled powerpc_perf; then
  1797. echo "#define POWERPC_PERFORMANCE_REPORT 1" >> $TMPH
  1798. fi
  1799. ;;
  1800. sparc64)
  1801. echo "TARGET_ARCH_SPARC=yes" >> config.mak
  1802. echo "#define ARCH_SPARC 1" >> $TMPH
  1803. ;;
  1804. esac
  1805. if enabled bigendian; then
  1806. echo "WORDS_BIGENDIAN=yes" >> config.mak
  1807. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  1808. fi
  1809. if enabled mmx; then
  1810. echo "#define __CPU__ 586" >> $TMPH
  1811. fi
  1812. if enabled sdl; then
  1813. echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
  1814. echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
  1815. fi
  1816. if enabled texi2html; then
  1817. echo "BUILD_DOC=yes" >> config.mak
  1818. fi
  1819. sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
  1820. pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
  1821. lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
  1822. lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
  1823. lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
  1824. if enabled lshared; then
  1825. echo "BUILD_SHARED=yes" >> config.mak
  1826. echo "PIC=-fPIC -DPIC" >> config.mak
  1827. echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
  1828. echo "SPPVERSION=$pp_version" >> config.mak
  1829. echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
  1830. echo "LAVCVERSION=$lavc_version" >> config.mak
  1831. echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
  1832. echo "LAVFVERSION=$lavf_version" >> config.mak
  1833. echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
  1834. echo "LAVUVERSION=$lavu_version" >> config.mak
  1835. echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
  1836. echo "SWSVERSION=$sws_version" >> config.mak
  1837. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  1838. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  1839. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  1840. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  1841. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  1842. fi
  1843. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  1844. echo "EXTRALIBS=$extralibs" >> config.mak
  1845. enabled_any $ENCODER_LIST && enable encoders
  1846. enabled_any $DECODER_LIST && enable decoders
  1847. enabled_any $MUXER_LIST && enable muxers
  1848. enabled_any $DEMUXER_LIST && enable demuxers
  1849. enabled_any pthreads beosthreads os2threads w32threads && enable threads
  1850. check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
  1851. $DEMUXER_LIST $MUXER_LIST
  1852. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  1853. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST
  1854. print_config TARGET_ $TMPH config.mak $TARGET_LIST
  1855. if test "$targetos" = "Darwin"; then
  1856. echo "#define CONFIG_DARWIN 1" >> $TMPH
  1857. fi
  1858. echo "#define restrict $_restrict" >> $TMPH
  1859. if test "$optimize" = "small"; then
  1860. echo "#define always_inline" >> $TMPH
  1861. echo "#define CONFIG_SMALL 1" >> $TMPH
  1862. fi
  1863. echo "SRC_PATH=\"$source_path\"" >> config.mak
  1864. echo "SRC_PATH_BARE=$source_path" >> config.mak
  1865. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  1866. if enabled amr_if2; then
  1867. echo "AMR_CFLAGS=-DIF2=1" >> config.mak
  1868. fi
  1869. # Apparently it's not possible to portably echo a backslash.
  1870. if enabled asmalign_pot; then
  1871. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
  1872. else
  1873. printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
  1874. fi
  1875. for codec in $DECODER_LIST $ENCODER_LIST $PARSER_LIST $DEMUXER_LIST $MUXER_LIST; do
  1876. ucname="`toupper $codec`"
  1877. config_name="CONFIG_$ucname"
  1878. enabled_name="ENABLE_$ucname"
  1879. if enabled $codec; then
  1880. echo "#define $config_name 1" >> $TMPH
  1881. echo "#define $enabled_name 1" >> $TMPH
  1882. echo "$config_name=yes" >> config.mak
  1883. else
  1884. echo "#define $enabled_name 0" >> $TMPH
  1885. fi
  1886. done
  1887. # Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
  1888. if ! cmp -s $TMPH config.h; then
  1889. mv -f $TMPH config.h
  1890. else
  1891. echo "config.h is unchanged"
  1892. fi
  1893. rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
  1894. # build tree in object directory if source path is different from current one
  1895. if enabled source_path_used; then
  1896. DIRS="\
  1897. doc \
  1898. libavformat \
  1899. libavcodec \
  1900. libavcodec/alpha \
  1901. libavcodec/armv4l \
  1902. libavcodec/bfin \
  1903. libavcodec/i386 \
  1904. libavcodec/sparc \
  1905. libavcodec/mlib \
  1906. libavcodec/ppc \
  1907. libavcodec/liba52 \
  1908. libavcodec/amr \
  1909. libavcodec/amr_float \
  1910. libavcodec/amrwb_float \
  1911. libpostproc \
  1912. libavutil \
  1913. libswscale \
  1914. tests \
  1915. vhook \
  1916. "
  1917. FILES="\
  1918. Makefile \
  1919. common.mak \
  1920. libavformat/Makefile \
  1921. libavcodec/Makefile \
  1922. libpostproc/Makefile \
  1923. libavutil/Makefile \
  1924. libswscale/Makefile \
  1925. tests/Makefile \
  1926. vhook/Makefile \
  1927. doc/Makefile \
  1928. doc/texi2pod.pl \
  1929. "
  1930. for dir in $DIRS ; do
  1931. mkdir -p $dir
  1932. done
  1933. for f in $FILES ; do
  1934. ln -sf "$source_path/$f" $f
  1935. done
  1936. fi
  1937. # build pkg-config files
  1938. # FIXME: libdir and includedir are hardcoded and may differ from the real path.
  1939. pkgconfig_generate(){
  1940. name=$1
  1941. comment=$2
  1942. version=$3
  1943. libs=$4
  1944. requires=$5
  1945. include=$6
  1946. cat <<EOF >$name.pc
  1947. prefix=$PREFIX
  1948. exec_prefix=\${prefix}
  1949. libdir=\${exec_prefix}/lib
  1950. includedir=\${prefix}/include
  1951. Name: $name
  1952. Description: $comment
  1953. Version: $version
  1954. Requires: $requires
  1955. Conflicts:
  1956. Libs: -L\${libdir} $libs
  1957. Cflags: -I\${includedir} -I\${includedir}/$include
  1958. EOF
  1959. }
  1960. pkgconfig_generate_uninstalled(){
  1961. name=$1
  1962. shortname=${name#lib}
  1963. comment=$2
  1964. version=$3
  1965. libs=$4
  1966. requires=$5
  1967. cat <<EOF >$name-uninstalled.pc
  1968. prefix=
  1969. exec_prefix=
  1970. libdir=\${pcfiledir}/$name
  1971. includedir=\${pcfiledir}/$name
  1972. Name: $name
  1973. Description: $comment
  1974. Version: $version
  1975. Requires: $requires
  1976. Conflicts:
  1977. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  1978. Cflags: -I\${includedir}
  1979. EOF
  1980. }
  1981. pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
  1982. pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
  1983. pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
  1984. pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
  1985. pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
  1986. pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
  1987. if enabled pp; then
  1988. pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
  1989. pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
  1990. fi
  1991. if enabled swscaler; then
  1992. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "-lswscale" "libavutil = $lavu_version" swscale
  1993. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
  1994. else
  1995. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" swscale
  1996. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
  1997. apply libswscale.pc sed s/^Libs:.*$/Libs:/
  1998. apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
  1999. fi