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.

2120 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 floating point audio codec"
  97. echo " --enable-amr-nb-fixed enable amr-nb fixed-point codec"
  98. echo " --enable-amr-wb enable amr-wb floating point audio codec"
  99. echo " --enable-amr-if2 enable amr-wb IF2 audio codec"
  100. echo ""
  101. echo "Advanced options (experts only):"
  102. echo " --source-path=PATH path to source code [$source_path]"
  103. echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
  104. echo " --cross-compile assume a cross-compiler is used"
  105. echo " --target-os=OS compiler targets OS [$targetos]"
  106. echo " --cc=CC use C compiler CC [$cc]"
  107. echo " --make=MAKE use specified make [$make]"
  108. echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
  109. echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
  110. echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
  111. echo " --build-suffix=SUFFIX suffix for application specific build []"
  112. echo " --arch=ARCH select architecture [$arch]"
  113. echo " --cpu=CPU selects the minimum cpu required (affects"
  114. echo " instruction selection, may crash on older CPUs)"
  115. echo " --enable-powerpc-perf enable performance report on PPC"
  116. echo " (requires enabling PMC)"
  117. echo " --disable-mmx disable MMX usage"
  118. echo " --disable-armv5te disable armv5te usage"
  119. echo " --disable-armv6 disable armv6 usage"
  120. echo " --disable-iwmmxt disable iwmmxt usage"
  121. echo " --disable-altivec disable AltiVec usage"
  122. echo " --disable-audio-oss disable OSS audio support [default=no]"
  123. echo " --disable-audio-beos disable BeOS audio support [default=no]"
  124. echo " --disable-v4l disable video4linux grabbing [default=no]"
  125. echo " --disable-v4l2 disable video4linux2 grabbing [default=no]"
  126. echo " --disable-bktr disable bktr video grabbing [default=no]"
  127. echo " --disable-dv1394 disable DV1394 grabbing [default=no]"
  128. echo " --disable-network disable network support [default=no]"
  129. echo " --disable-ipv6 disable ipv6 support [default=no]"
  130. echo " --disable-zlib disable zlib [default=no]"
  131. echo " --disable-vhook disable video hooking support"
  132. echo " --disable-debug disable debugging symbols"
  133. echo " --disable-mpegaudio-hp faster (but less accurate)"
  134. echo " MPEG audio decoding [default=no]"
  135. echo " --disable-protocols disable I/O protocols support [default=no]"
  136. echo " --disable-ffmpeg disable ffmpeg build"
  137. echo " --disable-ffserver disable ffserver build"
  138. echo " --disable-ffplay disable ffplay build"
  139. echo " --enable-small optimize for size instead of speed"
  140. echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
  141. echo " --disable-encoder=NAME disables encoder NAME"
  142. echo " --enable-encoder=NAME enables encoder NAME"
  143. echo " --disable-decoder=NAME disables decoder NAME"
  144. echo " --enable-decoder=NAME enables decoder NAME"
  145. echo " --disable-encoders disables all encoders"
  146. echo " --disable-decoders disables all decoders"
  147. echo " --disable-muxer=NAME disables muxer NAME"
  148. echo " --enable-muxer=NAME enables muxer NAME"
  149. echo " --disable-muxers disables all muxers"
  150. echo " --disable-demuxer=NAME disables demuxer NAME"
  151. echo " --enable-demuxer=NAME enables demuxer NAME"
  152. echo " --disable-demuxers disables all demuxers"
  153. echo " --enable-parser=NAME enables parser NAME"
  154. echo " --disable-parser=NAME disables parser NAME"
  155. echo " --disable-parsers disables all parsers"
  156. echo
  157. echo "Developer options (useful when working on FFmpeg itself):"
  158. echo " --enable-gprof enable profiling with gprof [$gprof]"
  159. echo " --disable-opts disable compiler optimizations"
  160. echo " --enable-extra-warnings enable more compiler warnings"
  161. echo " --disable-strip disable stripping of executables and shared libraries"
  162. echo ""
  163. echo "NOTE: Object files are built at the place where configure is launched."
  164. exit 1
  165. }
  166. log(){
  167. echo "$@" >>$logfile
  168. }
  169. log_file(){
  170. log BEGIN $1
  171. cat -n $1 >>$logfile
  172. log END $1
  173. }
  174. echolog(){
  175. log "$@"
  176. echo "$@"
  177. }
  178. die(){
  179. echolog "$@"
  180. cat <<EOF
  181. If you think configure made a mistake, make sure you are using the latest
  182. version from SVN. If the latest version fails, report the problem to the
  183. ffmpeg-devel@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
  184. EOF
  185. if enabled logging; then
  186. cat <<EOF
  187. Include the log file "$logfile" produced by configure as this will help
  188. solving the problem.
  189. EOF
  190. else
  191. cat <<EOF
  192. Rerun configure with logging enabled (do not use --log=no), and include the
  193. log this produces with your report.
  194. EOF
  195. fi
  196. rm -f $TMPC $TMPO $TMPE $TMPS $TMPH
  197. exit 1
  198. }
  199. # "tr '[a-z]' '[A-Z]'" is a workaround for Solaris tr not grokking "tr a-z A-Z"
  200. toupper(){
  201. echo "$@" | tr '[a-z]' '[A-Z]'
  202. }
  203. tolower(){
  204. echo "$@" | tr '[A-Z]' '[a-z]'
  205. }
  206. set_all(){
  207. value=$1
  208. shift
  209. for var in $*; do
  210. eval $var=$value
  211. done
  212. }
  213. pushvar(){
  214. for var in $*; do
  215. eval level=\${${var}_level:=0}
  216. eval ${var}_${level}="\$$var"
  217. eval ${var}_level=$(($level+1))
  218. done
  219. }
  220. popvar(){
  221. for var in $*; do
  222. eval level=\${${var}_level:-0}
  223. test $level = 0 && continue
  224. eval level=$(($level-1))
  225. eval $var="\${${var}_${level}}"
  226. eval ${var}_level=$level
  227. eval unset ${var}_${level}
  228. done
  229. }
  230. enable(){
  231. set_all yes $*
  232. }
  233. disable(){
  234. set_all no $*
  235. }
  236. enabled(){
  237. eval test "x\$$1" = "xyes"
  238. }
  239. disabled(){
  240. eval test "x\$$1" = "xno"
  241. }
  242. enabled_all(){
  243. for opt; do
  244. enabled $opt || return 1
  245. done
  246. }
  247. disabled_all(){
  248. for opt; do
  249. disabled $opt || return 1
  250. done
  251. }
  252. enabled_any(){
  253. for opt; do
  254. enabled $opt && return 0
  255. done
  256. }
  257. disabled_any(){
  258. for opt; do
  259. disabled $opt && return 0
  260. done
  261. }
  262. check_deps(){
  263. for cfg; do
  264. enabled ${cfg}_checking && die "Circular dependency for $cfg."
  265. disabled ${cfg}_checking && continue
  266. enable ${cfg}_checking
  267. eval dep_all="\$${cfg}_deps"
  268. eval dep_any="\$${cfg}_deps_any"
  269. pushvar cfg dep_all dep_any
  270. check_deps $dep_all $dep_any
  271. popvar cfg dep_all dep_any
  272. enabled_all $dep_all || disable $cfg
  273. enabled_any $dep_any || disable $cfg
  274. disable ${cfg}_checking
  275. done
  276. }
  277. print_config(){
  278. pfx=$1
  279. header=$2
  280. makefile=$3
  281. shift 3
  282. for cfg; do
  283. if enabled $cfg; then
  284. ucname="${pfx}`toupper $cfg`"
  285. echo "#define ${ucname} 1" >> $header
  286. echo "${ucname}=yes" >> $makefile
  287. fi
  288. done
  289. }
  290. flags_saved(){
  291. (: ${SAVE_CFLAGS?}) 2>/dev/null
  292. }
  293. save_flags(){
  294. flags_saved && return
  295. SAVE_CFLAGS="$CFLAGS"
  296. SAVE_LDFLAGS="$LDFLAGS"
  297. SAVE_extralibs="$extralibs"
  298. }
  299. restore_flags(){
  300. flags_saved || return
  301. CFLAGS="$SAVE_CFLAGS"
  302. LDFLAGS="$SAVE_LDFLAGS"
  303. extralibs="$SAVE_extralibs"
  304. unset SAVE_CFLAGS
  305. unset SAVE_LDFLAGS
  306. unset SAVE_extralibs
  307. }
  308. temp_cflags(){
  309. save_flags
  310. CFLAGS="$CFLAGS $*"
  311. }
  312. temp_ldflags(){
  313. save_flags
  314. LDFLAGS="$LDFLAGS $*"
  315. }
  316. temp_extralibs(){
  317. save_flags
  318. extralibs="$extralibs $*"
  319. }
  320. append(){
  321. var=$1
  322. shift
  323. flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
  324. eval "$var=\"\$$var $*\""
  325. }
  326. add_cflags(){
  327. append CFLAGS "$@"
  328. }
  329. add_ldflags(){
  330. append LDFLAGS "$@"
  331. }
  332. add_extralibs(){
  333. append extralibs "$@"
  334. }
  335. check_cmd(){
  336. log "$@"
  337. "$@" >>$logfile 2>&1
  338. }
  339. check_cc(){
  340. log check_cc "$@"
  341. cat >$TMPC
  342. log_file $TMPC
  343. check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
  344. }
  345. check_cpp(){
  346. log check_cpp "$@"
  347. cat >$TMPC
  348. log_file $TMPC
  349. check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
  350. }
  351. check_ld(){
  352. log check_ld "$@"
  353. check_cc || return
  354. check_cmd $cc $LDFLAGS "$@" -o $TMPE $TMPO $extralibs
  355. }
  356. check_cflags(){
  357. log check_cflags "$@"
  358. check_cc "$@" <<EOF && add_cflags "$@"
  359. int x;
  360. EOF
  361. }
  362. check_ldflags(){
  363. log check_ldflags "$@"
  364. check_ld "$@" <<EOF && add_ldflags "$@"
  365. int main(){
  366. return 0;
  367. }
  368. EOF
  369. }
  370. check_header(){
  371. log check_header "$@"
  372. header=$1
  373. shift
  374. var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
  375. disable $var
  376. check_cpp "$@" <<EOF && enable $var
  377. #include <$header>
  378. int x;
  379. EOF
  380. }
  381. check_func(){
  382. log check_func "$@"
  383. func=$1
  384. shift
  385. disable $func
  386. check_ld "$@" <<EOF && enable $func
  387. extern int $func();
  388. int main(){
  389. $func();
  390. }
  391. EOF
  392. }
  393. check_func2(){
  394. log check_func2 "$@"
  395. headers=$1
  396. func=$2
  397. shift 2
  398. disable $func
  399. incs=""
  400. for hdr in $headers; do
  401. incs="$incs
  402. #include <$hdr>"
  403. done
  404. check_ld "$@" <<EOF && enable $func
  405. $incs
  406. int main(){
  407. (void) $func;
  408. return 0;
  409. }
  410. EOF
  411. }
  412. check_lib(){
  413. log check_lib "$@"
  414. header="$1"
  415. func="$2"
  416. shift 2
  417. temp_extralibs "$@"
  418. check_header $header && check_func $func && add_extralibs "$@"
  419. err=$?
  420. restore_flags
  421. return $err
  422. }
  423. check_lib2(){
  424. log check_lib2 "$@"
  425. headers="$1"
  426. func="$2"
  427. shift 2
  428. temp_extralibs "$@"
  429. check_func2 "$headers" $func && add_extralibs "$@"
  430. err=$?
  431. restore_flags
  432. return $err
  433. }
  434. check_exec(){
  435. check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
  436. }
  437. require(){
  438. name="$1"
  439. header="$2"
  440. func="$3"
  441. shift 3
  442. check_lib $header $func "$@" || die "ERROR: $name not found"
  443. }
  444. require2(){
  445. name="$1"
  446. headers="$2"
  447. func="$3"
  448. shift 3
  449. check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
  450. }
  451. check_foo_config(){
  452. cfg=$1
  453. pkg=$2
  454. header=$3
  455. func=$4
  456. shift 4
  457. disable $cfg
  458. check_cmd ${pkg}-config --version
  459. err=$?
  460. if test "$err" = 0; then
  461. temp_cflags `${pkg}-config --cflags`
  462. temp_extralibs `${pkg}-config --libs`
  463. check_lib "$@" $header $func && enable $cfg
  464. fi
  465. return $err
  466. }
  467. apply(){
  468. file=$1
  469. shift
  470. "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
  471. }
  472. CONFIG_LIST='
  473. encoders
  474. decoders
  475. parsers
  476. muxers
  477. demuxers
  478. amr
  479. amr_nb
  480. amr_nb_fixed
  481. amr_wb
  482. audio_beos
  483. audio_oss
  484. avisynth
  485. beos_netserver
  486. bktr
  487. dc1394
  488. dv1394
  489. 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. THREADS_LIST='
  524. beosthreads
  525. os2threads
  526. pthreads
  527. w32threads
  528. '
  529. HAVE_LIST="
  530. $THREADS_LIST
  531. altivec
  532. altivec_h
  533. armv5te
  534. armv6
  535. arpa_inet_h
  536. byteswap_h
  537. cmov
  538. dcbzl
  539. dev_bktr_ioctl_bt848_h
  540. dev_bktr_ioctl_meteor_h
  541. dev_ic_bt8xx_h
  542. dev_video_meteor_ioctl_meteor_h
  543. dev_video_bktr_ioctl_bt848_h
  544. dlfcn_h
  545. dlopen
  546. fast_64bit
  547. fast_cmov
  548. freetype2
  549. imlib2
  550. inet_aton
  551. iwmmxt
  552. localtime_r
  553. lrintf
  554. machine_ioctl_bt848_h
  555. machine_ioctl_meteor_h
  556. malloc_h
  557. memalign
  558. mlib
  559. mmi
  560. mmx
  561. os2
  562. sdl
  563. sdl_video_size
  564. soundcard_h
  565. sys_poll_h
  566. sys_soundcard_h
  567. threads
  568. "
  569. TARGET_LIST='
  570. altivec
  571. armv5te
  572. armv6
  573. iwmmxt
  574. mmi
  575. mmx
  576. '
  577. CMDLINE_SELECT="
  578. $CONFIG_LIST
  579. $TARGET_LIST
  580. $THREADS_LIST
  581. amr_if2
  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_device_demuxer_deps_any="v4l bktr"
  628. x11_grab_device_demuxer_deps="x11grab"
  629. ffplay_deps="sdl"
  630. ffserver_deps="network protocols muxers"
  631. network_deps="protocols"
  632. # set temporary file name
  633. if test ! -z "$TMPDIR" ; then
  634. TMPDIR1="${TMPDIR}"
  635. elif test ! -z "$TEMPDIR" ; then
  636. TMPDIR1="${TEMPDIR}"
  637. else
  638. TMPDIR1="/tmp"
  639. fi
  640. TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
  641. TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
  642. TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
  643. TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
  644. TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
  645. # default parameters
  646. logging="yes"
  647. logfile="config.err"
  648. # installation paths
  649. PREFIX="/usr/local"
  650. libdir='${PREFIX}/lib'
  651. shlibdir="$libdir"
  652. incdir='${PREFIX}/include/ffmpeg'
  653. mandir='${PREFIX}/man'
  654. bindir='${PREFIX}/bin'
  655. # toolchain
  656. cross_prefix=""
  657. cross_compile="no"
  658. cc="gcc"
  659. ar="ar"
  660. ranlib="ranlib"
  661. make="make"
  662. strip="strip"
  663. asmalign_pot="unknown"
  664. # machine
  665. arch=`uname -m`
  666. cpu="generic"
  667. powerpc_perf="no"
  668. mmx="default"
  669. cmov="no"
  670. fast_cmov="no"
  671. armv5te="default"
  672. armv6="default"
  673. iwmmxt="default"
  674. altivec="default"
  675. dcbzl="no"
  676. mmi="default"
  677. bigendian="no"
  678. # OS
  679. targetos=`uname -s`
  680. beos_netserver="no"
  681. os2="no"
  682. wince="no"
  683. # non-library system interfaces
  684. audio_beos="default"
  685. audio_oss="yes"
  686. bktr="yes"
  687. dv1394="yes"
  688. v4l2="yes"
  689. v4l="yes"
  690. # libraries
  691. amr_if2="no"
  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 `tolower $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. if enabled_all shared static; then
  1017. cat <<EOF
  1018. You can only build one library type at once on MinGW.
  1019. Specify --disable-static --enable-shared to only build
  1020. the shared libraries. To build only the static libraries
  1021. you do not need to pass additional options.
  1022. EOF
  1023. exit 1
  1024. fi
  1025. dv1394="no"
  1026. ffserver="no"
  1027. network="no"
  1028. if enabled wince; then
  1029. protocols="no"
  1030. fi
  1031. SLIBPREF=""
  1032. SLIBSUF=".dll"
  1033. EXESUF=".exe"
  1034. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1035. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
  1036. SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
  1037. SLIB_INSTALL_EXTRA_CMD="-install -m 644 \$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib) \"\$(shlibdir)/\$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib)\""
  1038. SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc"
  1039. add_extralibs -lws2_32
  1040. ;;
  1041. cygwin*)
  1042. targetos=CYGWIN
  1043. shlibdir="$bindir"
  1044. dv1394="no"
  1045. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libswscale -L$(BUILD_ROOT)/libavutil'
  1046. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lswscale$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1047. osextralibs=""
  1048. EXESUF=".exe"
  1049. SLIBPREF="cyg"
  1050. SLIBSUF=".dll"
  1051. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1052. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
  1053. SHFLAGS='-shared -Wl,--out-implib=lib$(NAME).dll.a'
  1054. ;;
  1055. linux)
  1056. LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
  1057. ;;
  1058. irix*)
  1059. targetos=IRIX
  1060. ranlib="echo ignoring ranlib"
  1061. ;;
  1062. os/2)
  1063. TMPE=$TMPE".exe"
  1064. ar="emxomfar -p128"
  1065. ranlib="echo ignoring ranlib"
  1066. strip="echo ignoring strip"
  1067. add_cflags "-Zomf"
  1068. FFLDFLAGS="-Zomf -Zstack 16384 -s"
  1069. SHFLAGS="-Zdll -Zomf"
  1070. FFSERVERLDFLAGS=""
  1071. LIBPREF=""
  1072. LIBSUF=".lib"
  1073. SLIBPREF=""
  1074. SLIBSUF=".dll"
  1075. EXESUF=".exe"
  1076. osextralibs=""
  1077. pkg_requires=""
  1078. dv1394="no"
  1079. ffserver="no"
  1080. vhook="no"
  1081. os2="yes"
  1082. ;;
  1083. *)
  1084. targetos="${targetos}-UNKNOWN"
  1085. ;;
  1086. esac
  1087. add_extralibs $osextralibs
  1088. if ! disabled logging ; then
  1089. enabled logging || logfile="$logging"
  1090. echo "# $0 $@" >$logfile
  1091. set >>$logfile
  1092. else
  1093. logfile=/dev/null
  1094. fi
  1095. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1096. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1097. test -n "$cross_prefix" && cross_compile=yes
  1098. cc="${cross_prefix}${cc}"
  1099. ar="${cross_prefix}${ar}"
  1100. ranlib="${cross_prefix}${ranlib}"
  1101. strip="${cross_prefix}${strip}"
  1102. # we need to build at least one lib type
  1103. if disabled_all static shared; then
  1104. cat <<EOF
  1105. At least one library type must be built.
  1106. Specify --enable-static to build the static libraries or --enable-shared to
  1107. build the shared libraries as well. To only build the shared libraries specify
  1108. --disable-static in addition to --enable-shared.
  1109. EOF
  1110. exit 1;
  1111. fi
  1112. if disabled libogg; then
  1113. enabled libtheora && die "libogg must be enabled to enable libtheora."
  1114. enabled libvorbis && die "libogg must be enabled to enable libvorbis."
  1115. fi
  1116. if enabled_any libfaad libfaadbin ; then
  1117. if check_header faad.h; then
  1118. check_cc << EOF
  1119. #include <faad.h>
  1120. #ifndef FAAD2_VERSION
  1121. ok faad1
  1122. #endif
  1123. int main( void ) { return 0; }
  1124. EOF
  1125. test $? = 0 && enable libfaad2
  1126. else
  1127. die "FAAD test failed."
  1128. fi
  1129. fi
  1130. if disabled gpl ; then
  1131. die_gpl_disabled(){
  1132. name=$1
  1133. shift
  1134. enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
  1135. }
  1136. die_gpl_disabled "The Postprocessing code" pp
  1137. die_gpl_disabled "liba52" liba52
  1138. die_gpl_disabled "libxvidcore" xvid
  1139. die_gpl_disabled "x264" x264
  1140. die_gpl_disabled "libdts" libdts
  1141. die_gpl_disabled "FAAD2" libfaad2
  1142. die_gpl_disabled "The X11 grabber" x11grab
  1143. die_gpl_disabled "The software scaler" swscaler
  1144. fi
  1145. # compute MMX state
  1146. if test $mmx = "default"; then
  1147. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1148. mmx="yes"
  1149. else
  1150. mmx="no"
  1151. fi
  1152. fi
  1153. test -z "$need_memalign" && need_memalign="$mmx"
  1154. #Darwin CC versions
  1155. needmdynamicnopic="no"
  1156. if test $targetos = Darwin; then
  1157. if test -n "`$cc -v 2>&1 | grep xlc`"; then
  1158. add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
  1159. else
  1160. gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
  1161. case "$gcc_version" in
  1162. *2.95*)
  1163. add_cflags "-no-cpp-precomp -pipe"
  1164. ;;
  1165. *[34].*)
  1166. add_cflags "-no-cpp-precomp -pipe -force_cpusubtype_ALL -Wno-sign-compare"
  1167. if disabled shared; then
  1168. needmdynamicnopic="yes"
  1169. fi
  1170. ;;
  1171. *)
  1172. add_cflags "-no-cpp-precomp -pipe"
  1173. if disabled shared; then
  1174. needmdynamicnopic="yes"
  1175. fi
  1176. ;;
  1177. esac
  1178. fi
  1179. fi
  1180. disabled optimize || add_cflags -fomit-frame-pointer
  1181. # Can only do AltiVec on PowerPC
  1182. if test $altivec = "default"; then
  1183. if test $arch = "powerpc"; then
  1184. altivec="yes"
  1185. else
  1186. altivec="no"
  1187. fi
  1188. fi
  1189. # Add processor-specific flags
  1190. POWERPCMODE="32bits"
  1191. if test $cpu != "generic"; then
  1192. warn_altivec(){
  1193. $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
  1194. }
  1195. case $cpu in
  1196. 601|ppc601|PowerPC601)
  1197. add_cflags "-mcpu=601"
  1198. warn_altivec enabled PPC601
  1199. ;;
  1200. 603*|ppc603*|PowerPC603*)
  1201. add_cflags "-mcpu=603"
  1202. warn_altivec enabled PPC603
  1203. ;;
  1204. 604*|ppc604*|PowerPC604*)
  1205. add_cflags "-mcpu=604"
  1206. warn_altivec enabled PPC604
  1207. ;;
  1208. G3|g3|75*|ppc75*|PowerPC75*)
  1209. add_cflags "-mcpu=750 -mpowerpc-gfxopt"
  1210. warn_altivec enabled PPC75x
  1211. ;;
  1212. G4|g4|745*|ppc745*|PowerPC745*)
  1213. add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
  1214. warn_altivec disabled PPC745x
  1215. ;;
  1216. 74*|ppc74*|PowerPC74*)
  1217. add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
  1218. warn_altivec disabled PPC74xx
  1219. ;;
  1220. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1221. add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1222. warn_altivec disabled PPC970
  1223. POWERPCMODE="64bits"
  1224. ;;
  1225. # targets that do NOT support conditional mov (cmov)
  1226. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1227. add_cflags "-march=$cpu"
  1228. cmov="no"
  1229. ;;
  1230. # targets that do support conditional mov (cmov)
  1231. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1232. add_cflags "-march=$cpu"
  1233. cmov="yes"
  1234. fast_cmov="yes"
  1235. ;;
  1236. # targets that do support conditional mov but on which it's slow
  1237. pentium4|prescott|nocona)
  1238. add_cflags "-march=$cpu"
  1239. cmov="yes"
  1240. fast_cmov="no"
  1241. ;;
  1242. sparc64)
  1243. add_cflags "-mcpu=v9"
  1244. ;;
  1245. bf*) #bf531 bf532 bf533 bf561 bf5xx all get this config
  1246. add_cflags "-mfdpic"
  1247. add_ldflags "-mfdpic -Wl,--defsym,__stacksize=0x40000"
  1248. ;;
  1249. *)
  1250. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1251. ;;
  1252. esac
  1253. fi
  1254. gnu_make(){
  1255. $1 --version 2>&1 | grep -q GNU
  1256. }
  1257. if ! gnu_make $make; then
  1258. gnu_make gmake && make=gmake || die "GNU make not found."
  1259. fi
  1260. # make sure we can execute files in $TMPDIR
  1261. cat >$TMPE 2>>$logfile <<EOF
  1262. #! /bin/sh
  1263. EOF
  1264. chmod +x $TMPE >>$logfile 2>&1
  1265. if ! $TMPE >>$logfile 2>&1; then
  1266. cat <<EOF
  1267. Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
  1268. variable to another directory and make sure that $TMPDIR1 is not mounted
  1269. noexec.
  1270. EOF
  1271. die "Sanity test failed."
  1272. fi
  1273. rm $TMPE
  1274. # compiler sanity check
  1275. check_exec <<EOF
  1276. int main(){
  1277. return 0;
  1278. }
  1279. EOF
  1280. if test "$?" != 0; then
  1281. echo "$cc is unable to create an executable file."
  1282. if test -z "$cross_prefix" && disabled cross_compile ; then
  1283. echo "If $cc is a cross-compiler, use the --cross-compile option."
  1284. echo "Only do this if you know what cross compiling means."
  1285. fi
  1286. die "C compiler test failed."
  1287. fi
  1288. # check for assembler specific support
  1289. if test $arch = "powerpc"; then
  1290. check_cc <<EOF && dcbzl=yes
  1291. int main(void) {
  1292. register long zero = 0;
  1293. char data[1024];
  1294. asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
  1295. return 0;
  1296. }
  1297. EOF
  1298. fi
  1299. # check for SIMD availability
  1300. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1301. if test $arch = "powerpc"; then
  1302. if enabled altivec; then
  1303. if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
  1304. add_cflags "-faltivec"
  1305. else
  1306. add_cflags "-maltivec -mabi=altivec"
  1307. fi
  1308. fi
  1309. fi
  1310. check_header altivec.h
  1311. # check if our compiler supports Motorola AltiVec C API
  1312. if enabled altivec; then
  1313. if enabled altivec_h; then
  1314. inc_altivec_h="#include <altivec.h>"
  1315. else
  1316. inc_altivec_h=
  1317. fi
  1318. check_cc <<EOF || altivec=no
  1319. $inc_altivec_h
  1320. int main(void) {
  1321. vector signed int v1, v2, v3;
  1322. v1 = vec_add(v2,v3);
  1323. return 0;
  1324. }
  1325. EOF
  1326. fi
  1327. # check armv5te instructions support
  1328. if test $armv5te = "default" -a $arch = "armv4l"; then
  1329. armv5te=no
  1330. check_cc <<EOF && armv5te=yes
  1331. int main(void) {
  1332. __asm__ __volatile__ ("qadd r0, r0, r0");
  1333. }
  1334. EOF
  1335. fi
  1336. if test $armv6 = "default" -a $arch = "armv4l"; then
  1337. check_cc <<EOF && armv6=yes || armv6=no
  1338. int main(void) {
  1339. __asm__ __volatile__ ("sadd16 r0, r0, r0");
  1340. }
  1341. EOF
  1342. fi
  1343. # check iwmmxt support
  1344. if test $iwmmxt = "default" -a $arch = "armv4l"; then
  1345. iwmmxt=no
  1346. check_cc <<EOF && iwmmxt=yes
  1347. int main(void) {
  1348. __asm__ __volatile__ ("wunpckelub wr6, wr4");
  1349. }
  1350. EOF
  1351. fi
  1352. # mmi only available on mips
  1353. if test $mmi = "default"; then
  1354. if test $arch = "mips"; then
  1355. mmi="yes"
  1356. else
  1357. mmi="no"
  1358. fi
  1359. fi
  1360. # check if our compiler supports mmi
  1361. enabled mmi && check_cc <<EOF || mmi="no"
  1362. int main(void) {
  1363. __asm__ ("lq \$2, 0(\$2)");
  1364. return 0;
  1365. }
  1366. EOF
  1367. # ---
  1368. # big/little-endian test
  1369. if disabled cross_compile; then
  1370. check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
  1371. #include <inttypes.h>
  1372. int main(int argc, char ** argv){
  1373. volatile uint32_t i=0x01234567;
  1374. return (*((uint8_t*)(&i))) == 0x67;
  1375. }
  1376. EOF
  1377. else
  1378. # programs cannot be launched if cross compiling, so make a static guess
  1379. if test "$arch" = "powerpc" -o "$arch" = "mips" ; then
  1380. bigendian="yes"
  1381. fi
  1382. fi
  1383. # ---
  1384. # check availability of some header files
  1385. check_header malloc.h
  1386. check_func memalign
  1387. if disabled_all memalign memalign_hack && enabled need_memalign ; then
  1388. die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
  1389. fi
  1390. check_header byteswap.h
  1391. check_header arpa/inet.h
  1392. check_func inet_aton
  1393. check_func localtime_r
  1394. enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
  1395. # ffserver uses poll(),
  1396. # if it's not found we can emulate it using select().
  1397. if enabled ffserver; then
  1398. check_header sys/poll.h
  1399. fi
  1400. # check for some common methods of building with pthread support
  1401. # do this before the optional library checks as some of them require pthreads
  1402. if enabled pthreads; then
  1403. if check_func pthread_create; then
  1404. :
  1405. elif check_func pthread_create -pthread; then
  1406. add_cflags -pthread
  1407. add_ldflags -pthread
  1408. elif check_func pthread_create -pthreads; then
  1409. add_cflags -pthreads
  1410. add_ldflags -pthreads
  1411. elif ! check_lib pthread.h pthread_create -lpthread; then
  1412. die "ERROR: can't find pthreads library"
  1413. fi
  1414. fi
  1415. for thread in $THREADS_LIST; do
  1416. if enabled $thread; then
  1417. if ! disabled thread_type ; then
  1418. die "ERROR: Only one thread type must be selected."
  1419. else
  1420. thread_type="$thread"
  1421. fi
  1422. fi
  1423. done
  1424. enabled_any amr_nb amr_nb_fixed amr_wb amr_if2 && enable amr
  1425. enabled_all amr_nb amr_nb_fixed &&
  1426. die "Only one of amr_nb and amr_nb_fixed may be enabled."
  1427. # these are off by default, so fail if requested and not available
  1428. enabled liba52 && require liba52 a52dec/a52.h a52_init -la52
  1429. enabled libdts && require libdts dts.h dts_init -ldts -lm
  1430. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1431. enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
  1432. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  1433. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
  1434. enabled libogg && require libogg ogg/ogg.h ogg_sync_init -logg
  1435. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1436. enabled xvid && require XviD xvid.h xvid_global -lxvidcore
  1437. enabled x264 && require x264 x264.h x264_encoder_open -lx264
  1438. enabled dc1394 && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
  1439. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1440. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  1441. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  1442. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  1443. # test for lrintf in math.h
  1444. check_exec <<EOF && lrintf=yes || lrintf=no
  1445. #define _ISOC9X_SOURCE 1
  1446. #include <math.h>
  1447. int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
  1448. EOF
  1449. _restrict=
  1450. for restrict_keyword in restrict __restrict__ __restrict; do
  1451. check_cc <<EOF && _restrict=$restrict_keyword && break
  1452. void foo(char * $restrict_keyword p);
  1453. EOF
  1454. done
  1455. # dlopen/dlfcn.h probing
  1456. check_header dlfcn.h
  1457. if check_func dlopen; then
  1458. ldl=
  1459. elif check_func dlopen -ldl; then
  1460. ldl=-ldl
  1461. fi
  1462. test "$vhook" = "default" && vhook="$dlopen"
  1463. enabled_any vhook liba52bin libfaadbin ffserver && add_extralibs $ldl
  1464. if test "$targetos" = "CYGWIN" && enabled static ; then
  1465. vhook="no"
  1466. echo
  1467. echo "At the moment vhooks don't work on Cygwin static builds."
  1468. echo "Patches welcome."
  1469. echo
  1470. fi
  1471. if enabled vhook; then
  1472. check_ldflags -rdynamic
  1473. check_ldflags -export-dynamic
  1474. fi
  1475. enabled audio_beos && add_extralibs "-lmedia -lbe"
  1476. check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
  1477. check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
  1478. ##########################################
  1479. # SDL check
  1480. sdl_too_old=no
  1481. sdl=no
  1482. SDL_CONFIG="${cross_prefix}sdl-config"
  1483. if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
  1484. sdl_cflags=`"${SDL_CONFIG}" --cflags`
  1485. temp_cflags $sdl_cflags
  1486. temp_extralibs `"${SDL_CONFIG}" --libs`
  1487. if check_lib SDL.h SDL_Init; then
  1488. _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
  1489. if test "$_sdlversion" -lt 121 ; then
  1490. sdl_too_old=yes
  1491. else
  1492. sdl=yes
  1493. check_cc $sdl_cflags <<EOF && enable sdl_video_size
  1494. #include <SDL.h>
  1495. int main(void){
  1496. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1497. int w = vi->current_w;
  1498. return 0;
  1499. }
  1500. EOF
  1501. fi
  1502. fi
  1503. restore_flags
  1504. fi
  1505. texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
  1506. ##########################################
  1507. # IPv6 check
  1508. enabled network && enabled ipv6 && check_ld <<EOF && ipv6=yes || ipv6=no
  1509. #include <sys/types.h>
  1510. #include <sys/socket.h>
  1511. #include <netinet/in.h>
  1512. #include <netdb.h>
  1513. int main( void ) {
  1514. struct sockaddr_storage saddr;
  1515. struct ipv6_mreq mreq6;
  1516. getaddrinfo(0,0,0,0);
  1517. getnameinfo(0,0,0,0,0,0,0);
  1518. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1519. }
  1520. EOF
  1521. enabled v4l && check_header linux/videodev.h || disable v4l
  1522. enabled v4l2 && check_header linux/videodev2.h || disable v4l2
  1523. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1524. if enabled bktr; then
  1525. { check_header dev/bktr/ioctl_meteor.h &&
  1526. check_header dev/bktr/ioctl_bt848.h; } ||
  1527. { check_header machine/ioctl_meteor.h &&
  1528. check_header machine/ioctl_bt848.h; } ||
  1529. { check_header dev/video/meteor/ioctl_meteor.h &&
  1530. check_header dev/video/bktr/ioctl_bt848.h; } ||
  1531. check_header dev/ic/bt8xx.h ||
  1532. disable bktr
  1533. fi
  1534. enabled audio_oss &&
  1535. check_header sys/soundcard.h ||
  1536. check_header soundcard.h ||
  1537. disable audio_oss
  1538. # Deal with the x11 frame grabber
  1539. enabled x11grab &&
  1540. enabled gpl &&
  1541. enabled x11_grab_device_demuxer &&
  1542. check_header X11/Xlib.h &&
  1543. check_header X11/extensions/XShm.h &&
  1544. check_func XOpenDisplay -lX11 &&
  1545. check_func XShmCreateImage -lX11 -lXext &&
  1546. add_extralibs -lX11 -lXext ||
  1547. disable x11_grab_device_demuxer
  1548. enabled debug && add_cflags -g
  1549. # add some useful compiler flags if supported
  1550. check_cflags -Wdeclaration-after-statement
  1551. check_cflags -Wall
  1552. check_cflags -Wno-switch
  1553. check_cflags -Wdisabled-optimization
  1554. check_cflags -Wpointer-arith
  1555. check_cflags -Wredundant-decls
  1556. check_cflags -Wno-pointer-sign
  1557. enabled extra_warnings && check_cflags -Winline
  1558. # add some linker flags
  1559. check_ldflags $LDLATEFLAGS
  1560. # not all compilers support -Os
  1561. test "$optimize" = "small" && check_cflags -Os
  1562. if enabled optimize; then
  1563. if test -n "`$cc -v 2>&1 | grep xlc`"; then
  1564. add_cflags "-O5"
  1565. add_ldflags "-O5"
  1566. else
  1567. add_cflags "-O3"
  1568. fi
  1569. fi
  1570. # PIC flags for shared library objects where they are needed
  1571. if enabled shared; then
  1572. # LIBOBJFLAGS may have already been set in the OS configuration
  1573. if test -z "$LIBOBJFLAGS" ; then
  1574. case "$arch" in
  1575. x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS="\$(PIC)" ;;
  1576. esac
  1577. fi
  1578. fi
  1579. if enabled gprof; then
  1580. add_cflags "-p"
  1581. add_ldflags "-p"
  1582. fi
  1583. VHOOKCFLAGS="-fPIC $CFLAGS"
  1584. enabled needmdynamicnopic && add_cflags -mdynamic-no-pic
  1585. # find if .align arg is power-of-two or not
  1586. if test $asmalign_pot = "unknown"; then
  1587. asmalign_pot="no"
  1588. echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
  1589. fi
  1590. enabled_any $ENCODER_LIST && enable encoders
  1591. enabled_any $DECODER_LIST && enable decoders
  1592. enabled_any $MUXER_LIST && enable muxers
  1593. enabled_any $DEMUXER_LIST && enable demuxers
  1594. enabled_any $THREADS_LIST && enable threads
  1595. check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
  1596. $DEMUXER_LIST $MUXER_LIST
  1597. enabled libogg && append pkg_requires "ogg >= 1.1"
  1598. enabled libtheora && append pkg_requires "theora"
  1599. enabled libvorbis && append pkg_requires "vorbis vorbisenc"
  1600. enabled dc1394 && append pkg_requires "libraw1394"
  1601. echo "install prefix $PREFIX"
  1602. echo "source path $source_path"
  1603. echo "C compiler $cc"
  1604. echo "make $make"
  1605. echo ".align is power-of-two $asmalign_pot"
  1606. echo "ARCH $arch ($cpu)"
  1607. if test "$BUILDSUF" != ""; then
  1608. echo "build suffix $BUILDSUF"
  1609. fi
  1610. echo "big-endian $bigendian"
  1611. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1612. echo "MMX enabled $mmx"
  1613. echo "CMOV enabled $cmov"
  1614. echo "CMOV is fast $fast_cmov"
  1615. fi
  1616. if test $arch = "armv4l"; then
  1617. echo "ARMv5TE enabled $armv5te"
  1618. echo "ARMv6 enabled $armv6"
  1619. echo "IWMMXT enabled $iwmmxt"
  1620. fi
  1621. if test $arch = "mips"; then
  1622. echo "MMI enabled $mmi"
  1623. fi
  1624. if test $arch = "powerpc"; then
  1625. echo "AltiVec enabled $altivec"
  1626. echo "dcbzl available $dcbzl"
  1627. fi
  1628. echo "gprof enabled $gprof"
  1629. echo "debug symbols $debug"
  1630. echo "strip symbols $dostrip"
  1631. echo "optimize $optimize"
  1632. echo "static $static"
  1633. echo "shared $shared"
  1634. echo "postprocessing support $pp"
  1635. echo "software scaler enabled $swscaler"
  1636. echo "video hooking $vhook"
  1637. if enabled vhook; then
  1638. echo "Imlib2 support $imlib2"
  1639. echo "FreeType support $freetype2"
  1640. fi
  1641. echo "network support $network"
  1642. if enabled network; then
  1643. echo "IPv6 support $ipv6"
  1644. fi
  1645. echo "threading support $thread_type"
  1646. echo "SDL support $sdl"
  1647. if enabled sdl_too_old; then
  1648. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  1649. fi
  1650. echo "Sun medialib support $mlib"
  1651. echo "AVISynth enabled $avisynth"
  1652. echo "liba52 support $liba52"
  1653. echo "liba52 dlopened $liba52bin"
  1654. echo "libdts support $libdts"
  1655. echo "libfaac enabled $libfaac"
  1656. echo "libfaad enabled $libfaad"
  1657. echo "faadbin enabled $libfaadbin"
  1658. echo "libgsm enabled $libgsm"
  1659. echo "libmp3lame enabled $libmp3lame"
  1660. echo "libnut enabled $libnut"
  1661. echo "libogg enabled $libogg"
  1662. echo "libtheora enabled $libtheora"
  1663. echo "libvorbis enabled $libvorbis"
  1664. echo "x264 enabled $x264"
  1665. echo "XviD enabled $xvid"
  1666. echo "zlib enabled $zlib"
  1667. echo "AMR-NB float support $amr_nb"
  1668. echo "AMR-NB fixed support $amr_nb_fixed"
  1669. echo "AMR-WB float support $amr_wb"
  1670. echo "AMR-WB IF2 support $amr_if2"
  1671. if disabled gpl; then
  1672. echo "License: LGPL"
  1673. else
  1674. echo "License: GPL"
  1675. fi
  1676. echo "Creating config.mak and config.h..."
  1677. echo "# Automatically generated by configure - do not modify!" > config.mak
  1678. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  1679. echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
  1680. echo "PREFIX=$PREFIX" >> config.mak
  1681. echo "prefix=\$(DESTDIR)\${PREFIX}" >> config.mak
  1682. echo "libdir=\$(DESTDIR)$libdir" >> config.mak
  1683. echo "shlibdir=\$(DESTDIR)$shlibdir" >> config.mak
  1684. echo "incdir=\$(DESTDIR)$incdir" >> config.mak
  1685. echo "bindir=\$(DESTDIR)$bindir" >> config.mak
  1686. echo "mandir=\$(DESTDIR)$mandir" >> config.mak
  1687. echo "MAKE=$make" >> config.mak
  1688. echo "CC=$cc" >> config.mak
  1689. echo "AR=$ar" >> config.mak
  1690. echo "RANLIB=$ranlib" >> config.mak
  1691. if enabled dostrip; then
  1692. echo "STRIP=$strip" >> config.mak
  1693. else
  1694. echo "STRIP=echo ignoring strip" >> config.mak
  1695. fi
  1696. echo "OPTFLAGS=$CFLAGS" >> config.mak
  1697. echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
  1698. echo "LDFLAGS=$LDFLAGS" >> config.mak
  1699. echo "LDCONFIG=$LDCONFIG" >> config.mak
  1700. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  1701. echo "SHFLAGS=$SHFLAGS" >> config.mak
  1702. echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
  1703. echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
  1704. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  1705. echo "BUILD_STATIC=$static" >> config.mak
  1706. echo "BUILDSUF=$BUILDSUF" >> config.mak
  1707. echo "LIBPREF=$LIBPREF" >> config.mak
  1708. echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
  1709. if enabled static; then
  1710. echo "LIB=$LIB" >> config.mak
  1711. else # Some Make complain if this variable does not exist.
  1712. echo "LIB=" >> config.mak
  1713. fi
  1714. echo "SLIBPREF=$SLIBPREF" >> config.mak
  1715. echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
  1716. echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
  1717. ucarch=`toupper $arch`
  1718. echo "TARGET_ARCH_${ucarch}=yes" >> config.mak
  1719. echo "#define ARCH_${ucarch} 1" >> $TMPH
  1720. # special cases
  1721. case "$arch" in
  1722. x86_32|x86_64)
  1723. echo "TARGET_ARCH_X86=yes" >> config.mak
  1724. echo "#define ARCH_X86 1" >> $TMPH
  1725. ;;
  1726. powerpc)
  1727. if test "$POWERPCMODE" = "64bits"; then
  1728. echo "#define POWERPC_MODE_64BITS 1" >> $TMPH
  1729. fi
  1730. ;;
  1731. sparc64)
  1732. echo "TARGET_ARCH_SPARC=yes" >> config.mak
  1733. echo "#define ARCH_SPARC 1" >> $TMPH
  1734. ;;
  1735. esac
  1736. if enabled bigendian; then
  1737. echo "WORDS_BIGENDIAN=yes" >> config.mak
  1738. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  1739. fi
  1740. if enabled mmx; then
  1741. echo "#define __CPU__ 586" >> $TMPH
  1742. fi
  1743. if enabled sdl; then
  1744. echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
  1745. echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
  1746. fi
  1747. if enabled texi2html; then
  1748. echo "BUILD_DOC=yes" >> config.mak
  1749. fi
  1750. sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
  1751. pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
  1752. lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
  1753. lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
  1754. lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
  1755. if enabled shared; then
  1756. echo "BUILD_SHARED=yes" >> config.mak
  1757. echo "PIC=-fPIC -DPIC" >> config.mak
  1758. echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
  1759. echo "SPPVERSION=$pp_version" >> config.mak
  1760. echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
  1761. echo "LAVCVERSION=$lavc_version" >> config.mak
  1762. echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
  1763. echo "LAVFVERSION=$lavf_version" >> config.mak
  1764. echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
  1765. echo "LAVUVERSION=$lavu_version" >> config.mak
  1766. echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
  1767. echo "SWSVERSION=$sws_version" >> config.mak
  1768. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  1769. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  1770. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  1771. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  1772. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  1773. fi
  1774. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  1775. echo "EXTRALIBS=$extralibs" >> config.mak
  1776. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  1777. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST
  1778. print_config TARGET_ $TMPH config.mak $TARGET_LIST
  1779. if test "$targetos" = "Darwin"; then
  1780. echo "#define CONFIG_DARWIN 1" >> $TMPH
  1781. fi
  1782. echo "#define restrict $_restrict" >> $TMPH
  1783. if test "$optimize" = "small"; then
  1784. echo "#define always_inline" >> $TMPH
  1785. echo "#define CONFIG_SMALL 1" >> $TMPH
  1786. fi
  1787. echo "SRC_PATH=\"$source_path\"" >> config.mak
  1788. echo "SRC_PATH_BARE=$source_path" >> config.mak
  1789. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  1790. if enabled amr_if2; then
  1791. echo "AMR_CFLAGS=-DIF2=1" >> config.mak
  1792. fi
  1793. # Apparently it's not possible to portably echo a backslash.
  1794. if enabled asmalign_pot; then
  1795. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
  1796. else
  1797. printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
  1798. fi
  1799. for codec in $DECODER_LIST $ENCODER_LIST $PARSER_LIST $DEMUXER_LIST $MUXER_LIST; do
  1800. ucname="`toupper $codec`"
  1801. config_name="CONFIG_$ucname"
  1802. enabled_name="ENABLE_$ucname"
  1803. if enabled $codec; then
  1804. echo "#define $config_name 1" >> $TMPH
  1805. echo "#define $enabled_name 1" >> $TMPH
  1806. echo "$config_name=yes" >> config.mak
  1807. else
  1808. echo "#define $enabled_name 0" >> $TMPH
  1809. fi
  1810. done
  1811. # Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
  1812. if ! cmp -s $TMPH config.h; then
  1813. mv -f $TMPH config.h
  1814. else
  1815. echo "config.h is unchanged"
  1816. fi
  1817. rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
  1818. # build tree in object directory if source path is different from current one
  1819. if enabled source_path_used; then
  1820. DIRS="\
  1821. doc \
  1822. libavformat \
  1823. libavcodec \
  1824. libavcodec/alpha \
  1825. libavcodec/armv4l \
  1826. libavcodec/bfin \
  1827. libavcodec/i386 \
  1828. libavcodec/sparc \
  1829. libavcodec/mlib \
  1830. libavcodec/ppc \
  1831. libavcodec/amr \
  1832. libavcodec/amr_float \
  1833. libavcodec/amrwb_float \
  1834. libpostproc \
  1835. libavutil \
  1836. libswscale \
  1837. tests \
  1838. vhook \
  1839. "
  1840. FILES="\
  1841. Makefile \
  1842. common.mak \
  1843. libavformat/Makefile \
  1844. libavcodec/Makefile \
  1845. libpostproc/Makefile \
  1846. libavutil/Makefile \
  1847. libswscale/Makefile \
  1848. tests/Makefile \
  1849. vhook/Makefile \
  1850. doc/Makefile \
  1851. doc/texi2pod.pl \
  1852. "
  1853. for dir in $DIRS ; do
  1854. mkdir -p $dir
  1855. done
  1856. for f in $FILES ; do
  1857. ln -sf "$source_path/$f" $f
  1858. done
  1859. fi
  1860. # build pkg-config files
  1861. # FIXME: libdir and includedir are hardcoded and may differ from the real path.
  1862. pkgconfig_generate(){
  1863. name=$1
  1864. comment=$2
  1865. version=$3
  1866. libs=$4
  1867. requires=$5
  1868. include=$6
  1869. cat <<EOF >$name.pc
  1870. prefix=$PREFIX
  1871. exec_prefix=\${prefix}
  1872. libdir=\${exec_prefix}/lib
  1873. includedir=\${prefix}/include
  1874. Name: $name
  1875. Description: $comment
  1876. Version: $version
  1877. Requires: $requires
  1878. Conflicts:
  1879. Libs: -L\${libdir} $libs
  1880. Cflags: -I\${includedir} -I\${includedir}/$include
  1881. EOF
  1882. }
  1883. pkgconfig_generate_uninstalled(){
  1884. name=$1
  1885. shortname=${name#lib}
  1886. comment=$2
  1887. version=$3
  1888. libs=$4
  1889. requires=$5
  1890. cat <<EOF >$name-uninstalled.pc
  1891. prefix=
  1892. exec_prefix=
  1893. libdir=\${pcfiledir}/$name
  1894. includedir=\${pcfiledir}/$name
  1895. Name: $name
  1896. Description: $comment
  1897. Version: $version
  1898. Requires: $requires
  1899. Conflicts:
  1900. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  1901. Cflags: -I\${includedir}
  1902. EOF
  1903. }
  1904. pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
  1905. pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
  1906. pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
  1907. pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
  1908. pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
  1909. pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
  1910. if enabled pp; then
  1911. pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
  1912. pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
  1913. fi
  1914. if enabled swscaler; then
  1915. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" -lswscale "libavutil = $lavu_version" ffmpeg
  1916. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
  1917. else
  1918. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" ffmpeg
  1919. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
  1920. apply libswscale.pc sed s/^Libs:.*$/Libs:/
  1921. apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
  1922. fi