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.

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