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.

2212 lines
57KB

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