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.

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