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.

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