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.

2101 lines
56KB

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