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.

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