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.

2134 lines
57KB

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