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.

2104 lines
56KB

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