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.

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