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.

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