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.

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