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.

2117 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. cc="cc"
  1002. dv1394="no"
  1003. need_memalign="no"
  1004. SHFLAGS="-dynamiclib -Wl,-single_module -Wl,-install_name,\$(shlibdir)/\$(SLIBNAME),-current_version,\$(SPPVERSION),-compatibility_version,\$(SPPVERSION) -Wl,-read_only_relocs,suppress"
  1005. VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(shlibdir)/vhook/$@'
  1006. osextralibs=""
  1007. strip="strip -x"
  1008. FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
  1009. SLIBSUF=".dylib"
  1010. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
  1011. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
  1012. FFSERVERLDFLAGS=-Wl,-bind_at_load
  1013. ;;
  1014. mingw32*)
  1015. if enabled_all shared static; then
  1016. cat <<EOF
  1017. You can only build one library type at once on MinGW.
  1018. Specify --disable-static --enable-shared to only build
  1019. the shared libraries. To build only the static libraries
  1020. you do not need to pass additional options.
  1021. EOF
  1022. exit 1
  1023. fi
  1024. dv1394="no"
  1025. ffserver="no"
  1026. network="no"
  1027. if enabled wince; then
  1028. protocols="no"
  1029. fi
  1030. SLIBPREF=""
  1031. SLIBSUF=".dll"
  1032. EXESUF=".exe"
  1033. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1034. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
  1035. SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
  1036. SLIB_INSTALL_EXTRA_CMD="-install -m 644 \$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib) \"\$(shlibdir)/\$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib)\""
  1037. SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc"
  1038. add_extralibs -lws2_32
  1039. ;;
  1040. cygwin*)
  1041. targetos=CYGWIN
  1042. shlibdir="$bindir"
  1043. dv1394="no"
  1044. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libswscale -L$(BUILD_ROOT)/libavutil'
  1045. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lswscale$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1046. osextralibs=""
  1047. EXESUF=".exe"
  1048. SLIBPREF="cyg"
  1049. SLIBSUF=".dll"
  1050. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1051. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
  1052. SHFLAGS='-shared -Wl,--out-implib=lib$(NAME).dll.a'
  1053. ;;
  1054. linux)
  1055. LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
  1056. ;;
  1057. irix*)
  1058. targetos=IRIX
  1059. ranlib="echo ignoring ranlib"
  1060. ;;
  1061. os/2)
  1062. TMPE=$TMPE".exe"
  1063. ar="emxomfar -p128"
  1064. ranlib="echo ignoring ranlib"
  1065. strip="echo ignoring strip"
  1066. add_cflags "-Zomf"
  1067. FFLDFLAGS="-Zomf -Zstack 16384 -s"
  1068. SHFLAGS="-Zdll -Zomf"
  1069. FFSERVERLDFLAGS=""
  1070. LIBPREF=""
  1071. LIBSUF=".lib"
  1072. SLIBPREF=""
  1073. SLIBSUF=".dll"
  1074. EXESUF=".exe"
  1075. osextralibs=""
  1076. pkg_requires=""
  1077. dv1394="no"
  1078. ffserver="no"
  1079. vhook="no"
  1080. os2="yes"
  1081. ;;
  1082. *)
  1083. targetos="${targetos}-UNKNOWN"
  1084. ;;
  1085. esac
  1086. add_extralibs $osextralibs
  1087. if ! disabled logging ; then
  1088. enabled logging || logfile="$logging"
  1089. echo "# $0 $@" >$logfile
  1090. set >>$logfile
  1091. else
  1092. logfile=/dev/null
  1093. fi
  1094. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1095. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1096. test -n "$cross_prefix" && cross_compile=yes
  1097. cc="${cross_prefix}${cc}"
  1098. ar="${cross_prefix}${ar}"
  1099. ranlib="${cross_prefix}${ranlib}"
  1100. strip="${cross_prefix}${strip}"
  1101. # we need to build at least one lib type
  1102. if disabled_all static shared; then
  1103. cat <<EOF
  1104. At least one library type must be built.
  1105. Specify --enable-static to build the static libraries or --enable-shared to
  1106. build the shared libraries as well. To only build the shared libraries specify
  1107. --disable-static in addition to --enable-shared.
  1108. EOF
  1109. exit 1;
  1110. fi
  1111. if disabled libogg; then
  1112. enabled libtheora && die "libogg must be enabled to enable libtheora."
  1113. enabled libvorbis && die "libogg must be enabled to enable libvorbis."
  1114. fi
  1115. if enabled_any libfaad libfaadbin ; then
  1116. if check_header faad.h; then
  1117. check_cc << EOF
  1118. #include <faad.h>
  1119. #ifndef FAAD2_VERSION
  1120. ok faad1
  1121. #endif
  1122. int main( void ) { return 0; }
  1123. EOF
  1124. test $? = 0 && enable libfaad2
  1125. else
  1126. die "FAAD test failed."
  1127. fi
  1128. fi
  1129. if disabled gpl ; then
  1130. die_gpl_disabled(){
  1131. name=$1
  1132. shift
  1133. enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
  1134. }
  1135. die_gpl_disabled "The Postprocessing code" pp
  1136. die_gpl_disabled "liba52" liba52
  1137. die_gpl_disabled "libxvidcore" xvid
  1138. die_gpl_disabled "x264" x264
  1139. die_gpl_disabled "libdts" libdts
  1140. die_gpl_disabled "FAAD2" libfaad2
  1141. die_gpl_disabled "The X11 grabber" x11grab
  1142. die_gpl_disabled "The software scaler" swscaler
  1143. fi
  1144. # compute MMX state
  1145. if test $mmx = "default"; then
  1146. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1147. mmx="yes"
  1148. else
  1149. mmx="no"
  1150. fi
  1151. fi
  1152. test -z "$need_memalign" && need_memalign="$mmx"
  1153. #Darwin CC versions
  1154. needmdynamicnopic="no"
  1155. if test $targetos = Darwin; then
  1156. if test -n "`$cc -v 2>&1 | grep xlc`"; then
  1157. add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
  1158. else
  1159. gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
  1160. case "$gcc_version" in
  1161. *2.95*)
  1162. add_cflags "-no-cpp-precomp -pipe"
  1163. ;;
  1164. *[34].*)
  1165. add_cflags "-no-cpp-precomp -pipe -force_cpusubtype_ALL -Wno-sign-compare"
  1166. if disabled shared; then
  1167. needmdynamicnopic="yes"
  1168. fi
  1169. ;;
  1170. *)
  1171. add_cflags "-no-cpp-precomp -pipe"
  1172. if disabled shared; then
  1173. needmdynamicnopic="yes"
  1174. fi
  1175. ;;
  1176. esac
  1177. fi
  1178. fi
  1179. disabled optimize || add_cflags -fomit-frame-pointer
  1180. # Can only do AltiVec on PowerPC
  1181. if test $altivec = "default"; then
  1182. if test $arch = "powerpc"; then
  1183. altivec="yes"
  1184. else
  1185. altivec="no"
  1186. fi
  1187. fi
  1188. # Add processor-specific flags
  1189. POWERPCMODE="32bits"
  1190. if test $cpu != "generic"; then
  1191. warn_altivec(){
  1192. $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
  1193. }
  1194. case $cpu in
  1195. 601|ppc601|PowerPC601)
  1196. add_cflags "-mcpu=601"
  1197. warn_altivec enabled PPC601
  1198. ;;
  1199. 603*|ppc603*|PowerPC603*)
  1200. add_cflags "-mcpu=603"
  1201. warn_altivec enabled PPC603
  1202. ;;
  1203. 604*|ppc604*|PowerPC604*)
  1204. add_cflags "-mcpu=604"
  1205. warn_altivec enabled PPC604
  1206. ;;
  1207. G3|g3|75*|ppc75*|PowerPC75*)
  1208. add_cflags "-mcpu=750 -mpowerpc-gfxopt"
  1209. warn_altivec enabled PPC75x
  1210. ;;
  1211. G4|g4|745*|ppc745*|PowerPC745*)
  1212. add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
  1213. warn_altivec disabled PPC745x
  1214. ;;
  1215. 74*|ppc74*|PowerPC74*)
  1216. add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
  1217. warn_altivec disabled PPC74xx
  1218. ;;
  1219. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1220. add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1221. warn_altivec disabled PPC970
  1222. POWERPCMODE="64bits"
  1223. ;;
  1224. # targets that do NOT support conditional mov (cmov)
  1225. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1226. add_cflags "-march=$cpu"
  1227. cmov="no"
  1228. ;;
  1229. # targets that do support conditional mov (cmov)
  1230. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1231. add_cflags "-march=$cpu"
  1232. cmov="yes"
  1233. fast_cmov="yes"
  1234. ;;
  1235. # targets that do support conditional mov but on which it's slow
  1236. pentium4|prescott|nocona)
  1237. add_cflags "-march=$cpu"
  1238. cmov="yes"
  1239. fast_cmov="no"
  1240. ;;
  1241. sparc64)
  1242. add_cflags "-mcpu=v9"
  1243. ;;
  1244. bf*) #bf531 bf532 bf533 bf561 bf5xx all get this config
  1245. add_cflags "-mfdpic"
  1246. add_ldflags "-mfdpic -Wl,--defsym,__stacksize=0x40000"
  1247. ;;
  1248. *)
  1249. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1250. ;;
  1251. esac
  1252. fi
  1253. gnu_make(){
  1254. $1 --version 2>&1 | grep -q GNU
  1255. }
  1256. if ! gnu_make $make; then
  1257. gnu_make gmake && make=gmake || die "GNU make not found."
  1258. fi
  1259. # make sure we can execute files in $TMPDIR
  1260. cat >$TMPE 2>>$logfile <<EOF
  1261. #! /bin/sh
  1262. EOF
  1263. chmod +x $TMPE >>$logfile 2>&1
  1264. if ! $TMPE >>$logfile 2>&1; then
  1265. cat <<EOF
  1266. Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
  1267. variable to another directory and make sure that $TMPDIR1 is not mounted
  1268. noexec.
  1269. EOF
  1270. die "Sanity test failed."
  1271. fi
  1272. rm $TMPE
  1273. # compiler sanity check
  1274. check_exec <<EOF
  1275. int main(){
  1276. return 0;
  1277. }
  1278. EOF
  1279. if test "$?" != 0; then
  1280. echo "$cc is unable to create an executable file."
  1281. if test -z "$cross_prefix" && disabled cross_compile ; then
  1282. echo "If $cc is a cross-compiler, use the --cross-compile option."
  1283. echo "Only do this if you know what cross compiling means."
  1284. fi
  1285. die "C compiler test failed."
  1286. fi
  1287. # check for assembler specific support
  1288. if test $arch = "powerpc"; then
  1289. check_cc <<EOF && dcbzl=yes
  1290. int main(void) {
  1291. register long zero = 0;
  1292. char data[1024];
  1293. asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
  1294. return 0;
  1295. }
  1296. EOF
  1297. fi
  1298. # check for SIMD availability
  1299. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1300. if test $arch = "powerpc"; then
  1301. if enabled altivec; then
  1302. if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
  1303. add_cflags "-faltivec"
  1304. else
  1305. add_cflags "-maltivec -mabi=altivec"
  1306. fi
  1307. fi
  1308. fi
  1309. check_header altivec.h
  1310. # check if our compiler supports Motorola AltiVec C API
  1311. if enabled altivec; then
  1312. if enabled altivec_h; then
  1313. inc_altivec_h="#include <altivec.h>"
  1314. else
  1315. inc_altivec_h=
  1316. fi
  1317. check_cc <<EOF || altivec=no
  1318. $inc_altivec_h
  1319. int main(void) {
  1320. vector signed int v1, v2, v3;
  1321. v1 = vec_add(v2,v3);
  1322. return 0;
  1323. }
  1324. EOF
  1325. fi
  1326. # check armv5te instructions support
  1327. if test $armv5te = "default" -a $arch = "armv4l"; then
  1328. armv5te=no
  1329. check_cc <<EOF && armv5te=yes
  1330. int main(void) {
  1331. __asm__ __volatile__ ("qadd r0, r0, r0");
  1332. }
  1333. EOF
  1334. fi
  1335. if test $armv6 = "default" -a $arch = "armv4l"; then
  1336. check_cc <<EOF && armv6=yes || armv6=no
  1337. int main(void) {
  1338. __asm__ __volatile__ ("sadd16 r0, r0, r0");
  1339. }
  1340. EOF
  1341. fi
  1342. # check iwmmxt support
  1343. if test $iwmmxt = "default" -a $arch = "armv4l"; then
  1344. iwmmxt=no
  1345. check_cc <<EOF && iwmmxt=yes
  1346. int main(void) {
  1347. __asm__ __volatile__ ("wunpckelub wr6, wr4");
  1348. }
  1349. EOF
  1350. fi
  1351. # mmi only available on mips
  1352. if test $mmi = "default"; then
  1353. if test $arch = "mips"; then
  1354. mmi="yes"
  1355. else
  1356. mmi="no"
  1357. fi
  1358. fi
  1359. # check if our compiler supports mmi
  1360. enabled mmi && check_cc <<EOF || mmi="no"
  1361. int main(void) {
  1362. __asm__ ("lq \$2, 0(\$2)");
  1363. return 0;
  1364. }
  1365. EOF
  1366. # ---
  1367. # big/little-endian test
  1368. if disabled cross_compile; then
  1369. check_ld <<EOF || die "endian test failed" && $TMPE && bigendian="yes"
  1370. #include <inttypes.h>
  1371. int main(int argc, char ** argv){
  1372. volatile uint32_t i=0x01234567;
  1373. return (*((uint8_t*)(&i))) == 0x67;
  1374. }
  1375. EOF
  1376. else
  1377. # programs cannot be launched if cross compiling, so make a static guess
  1378. if test "$arch" = "powerpc" -o "$arch" = "mips" ; then
  1379. bigendian="yes"
  1380. fi
  1381. fi
  1382. # ---
  1383. # check availability of some header files
  1384. check_header malloc.h
  1385. check_func memalign
  1386. if disabled_all memalign memalign_hack && enabled need_memalign ; then
  1387. die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
  1388. fi
  1389. check_header byteswap.h
  1390. check_func inet_aton
  1391. check_func localtime_r
  1392. enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
  1393. # ffserver uses poll(),
  1394. # if it's not found we can emulate it using select().
  1395. if enabled ffserver; then
  1396. check_header sys/poll.h
  1397. fi
  1398. # check for some common methods of building with pthread support
  1399. # do this before the optional library checks as some of them require pthreads
  1400. if enabled pthreads; then
  1401. if check_func pthread_create; then
  1402. :
  1403. elif check_func pthread_create -pthread; then
  1404. add_cflags -pthread
  1405. add_ldflags -pthread
  1406. elif check_func pthread_create -pthreads; then
  1407. add_cflags -pthreads
  1408. add_ldflags -pthreads
  1409. elif ! check_lib pthread.h pthread_create -lpthread; then
  1410. die "ERROR: can't find pthreads library"
  1411. fi
  1412. fi
  1413. for thread in $THREADS_LIST; do
  1414. if enabled $thread; then
  1415. if ! disabled thread_type ; then
  1416. die "ERROR: Only one thread type must be selected."
  1417. else
  1418. thread_type="$thread"
  1419. fi
  1420. fi
  1421. done
  1422. enabled_any amr_nb amr_nb_fixed amr_wb amr_if2 && enable amr
  1423. enabled_all amr_nb amr_nb_fixed &&
  1424. die "Only one of amr_nb and amr_nb_fixed may be enabled."
  1425. # these are off by default, so fail if requested and not available
  1426. enabled liba52 && require liba52 a52dec/a52.h a52_init -la52
  1427. enabled libdts && require libdts dts.h dts_init -ldts -lm
  1428. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1429. enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
  1430. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  1431. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
  1432. enabled libogg && require libogg ogg/ogg.h ogg_sync_init -logg
  1433. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1434. enabled xvid && require XviD xvid.h xvid_global -lxvidcore
  1435. enabled x264 && require x264 x264.h x264_encoder_open -lx264
  1436. enabled dc1394 && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
  1437. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1438. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  1439. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  1440. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  1441. # test for lrintf in math.h
  1442. check_exec <<EOF && lrintf=yes || lrintf=no
  1443. #define _ISOC9X_SOURCE 1
  1444. #include <math.h>
  1445. int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
  1446. EOF
  1447. _restrict=
  1448. for restrict_keyword in restrict __restrict__ __restrict; do
  1449. check_cc <<EOF && _restrict=$restrict_keyword && break
  1450. void foo(char * $restrict_keyword p);
  1451. EOF
  1452. done
  1453. # dlopen/dlfcn.h probing
  1454. check_header dlfcn.h
  1455. if check_func dlopen; then
  1456. ldl=
  1457. elif check_func dlopen -ldl; then
  1458. ldl=-ldl
  1459. fi
  1460. test "$vhook" = "default" && vhook="$dlopen"
  1461. enabled_any vhook liba52bin libfaadbin ffserver && add_extralibs $ldl
  1462. if test "$targetos" = "CYGWIN" && enabled static ; then
  1463. vhook="no"
  1464. echo
  1465. echo "At the moment vhooks don't work on Cygwin static builds."
  1466. echo "Patches welcome."
  1467. echo
  1468. fi
  1469. if enabled vhook; then
  1470. check_ldflags -rdynamic
  1471. check_ldflags -export-dynamic
  1472. fi
  1473. enabled audio_beos && add_extralibs "-lmedia -lbe"
  1474. check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
  1475. check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
  1476. ##########################################
  1477. # SDL check
  1478. sdl_too_old=no
  1479. sdl=no
  1480. SDL_CONFIG="${cross_prefix}sdl-config"
  1481. if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
  1482. sdl_cflags=`"${SDL_CONFIG}" --cflags`
  1483. temp_cflags $sdl_cflags
  1484. temp_extralibs `"${SDL_CONFIG}" --libs`
  1485. if check_lib SDL.h SDL_Init; then
  1486. _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
  1487. if test "$_sdlversion" -lt 121 ; then
  1488. sdl_too_old=yes
  1489. else
  1490. sdl=yes
  1491. check_cc $sdl_cflags <<EOF && enable sdl_video_size
  1492. #include <SDL.h>
  1493. int main(void){
  1494. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1495. int w = vi->current_w;
  1496. return 0;
  1497. }
  1498. EOF
  1499. fi
  1500. fi
  1501. restore_flags
  1502. fi
  1503. texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
  1504. ##########################################
  1505. # IPv6 check
  1506. enabled network && enabled ipv6 && check_ld <<EOF && ipv6=yes || ipv6=no
  1507. #include <sys/types.h>
  1508. #include <sys/socket.h>
  1509. #include <netinet/in.h>
  1510. #include <netdb.h>
  1511. int main( void ) {
  1512. struct sockaddr_storage saddr;
  1513. struct ipv6_mreq mreq6;
  1514. getaddrinfo(0,0,0,0);
  1515. getnameinfo(0,0,0,0,0,0,0);
  1516. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1517. }
  1518. EOF
  1519. enabled v4l && check_header linux/videodev.h || disable v4l
  1520. enabled v4l2 && check_header linux/videodev2.h || disable v4l2
  1521. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1522. if enabled bktr; then
  1523. { check_header dev/bktr/ioctl_meteor.h &&
  1524. check_header dev/bktr/ioctl_bt848.h; } ||
  1525. { check_header machine/ioctl_meteor.h &&
  1526. check_header machine/ioctl_bt848.h; } ||
  1527. { check_header dev/video/meteor/ioctl_meteor.h &&
  1528. check_header dev/video/bktr/ioctl_bt848.h; } ||
  1529. check_header dev/ic/bt8xx.h ||
  1530. disable bktr
  1531. fi
  1532. enabled audio_oss &&
  1533. check_header sys/soundcard.h ||
  1534. check_header soundcard.h ||
  1535. disable audio_oss
  1536. # Deal with the x11 frame grabber
  1537. enabled x11grab &&
  1538. enabled gpl &&
  1539. enabled x11_grab_device_demuxer &&
  1540. check_header X11/Xlib.h &&
  1541. check_header X11/extensions/XShm.h &&
  1542. check_func XOpenDisplay -lX11 &&
  1543. check_func XShmCreateImage -lX11 -lXext &&
  1544. add_extralibs -lX11 -lXext ||
  1545. disable x11_grab_device_demuxer
  1546. enabled debug && add_cflags -g
  1547. # add some useful compiler flags if supported
  1548. check_cflags -Wdeclaration-after-statement
  1549. check_cflags -Wall
  1550. check_cflags -Wno-switch
  1551. check_cflags -Wdisabled-optimization
  1552. check_cflags -Wpointer-arith
  1553. check_cflags -Wredundant-decls
  1554. check_cflags -Wno-pointer-sign
  1555. enabled extra_warnings && check_cflags -Winline
  1556. # add some linker flags
  1557. check_ldflags $LDLATEFLAGS
  1558. # not all compilers support -Os
  1559. test "$optimize" = "small" && check_cflags -Os
  1560. if enabled optimize; then
  1561. if test -n "`$cc -v 2>&1 | grep xlc`"; then
  1562. add_cflags "-O5"
  1563. add_ldflags "-O5"
  1564. else
  1565. add_cflags "-O3"
  1566. fi
  1567. fi
  1568. # PIC flags for shared library objects where they are needed
  1569. if enabled shared; then
  1570. # LIBOBJFLAGS may have already been set in the OS configuration
  1571. if test -z "$LIBOBJFLAGS" ; then
  1572. case "$arch" in
  1573. x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS="\$(PIC)" ;;
  1574. esac
  1575. fi
  1576. fi
  1577. if enabled gprof; then
  1578. add_cflags "-p"
  1579. add_ldflags "-p"
  1580. fi
  1581. VHOOKCFLAGS="-fPIC $CFLAGS"
  1582. enabled needmdynamicnopic && add_cflags -mdynamic-no-pic
  1583. # find if .align arg is power-of-two or not
  1584. if test $asmalign_pot = "unknown"; then
  1585. asmalign_pot="no"
  1586. echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
  1587. fi
  1588. enabled_any $ENCODER_LIST && enable encoders
  1589. enabled_any $DECODER_LIST && enable decoders
  1590. enabled_any $MUXER_LIST && enable muxers
  1591. enabled_any $DEMUXER_LIST && enable demuxers
  1592. enabled_any $THREADS_LIST && enable threads
  1593. check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
  1594. $DEMUXER_LIST $MUXER_LIST
  1595. enabled libogg && append pkg_requires "ogg >= 1.1"
  1596. enabled libtheora && append pkg_requires "theora"
  1597. enabled libvorbis && append pkg_requires "vorbis vorbisenc"
  1598. enabled dc1394 && append pkg_requires "libraw1394"
  1599. echo "install prefix $PREFIX"
  1600. echo "source path $source_path"
  1601. echo "C compiler $cc"
  1602. echo "make $make"
  1603. echo ".align is power-of-two $asmalign_pot"
  1604. echo "ARCH $arch ($cpu)"
  1605. if test "$BUILDSUF" != ""; then
  1606. echo "build suffix $BUILDSUF"
  1607. fi
  1608. echo "big-endian $bigendian"
  1609. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1610. echo "MMX enabled $mmx"
  1611. echo "CMOV enabled $cmov"
  1612. echo "CMOV is fast $fast_cmov"
  1613. fi
  1614. if test $arch = "armv4l"; then
  1615. echo "ARMv5TE enabled $armv5te"
  1616. echo "ARMv6 enabled $armv6"
  1617. echo "IWMMXT enabled $iwmmxt"
  1618. fi
  1619. if test $arch = "mips"; then
  1620. echo "MMI enabled $mmi"
  1621. fi
  1622. if test $arch = "powerpc"; then
  1623. echo "AltiVec enabled $altivec"
  1624. echo "dcbzl available $dcbzl"
  1625. fi
  1626. echo "gprof enabled $gprof"
  1627. echo "debug symbols $debug"
  1628. echo "strip symbols $dostrip"
  1629. echo "optimize $optimize"
  1630. echo "static $static"
  1631. echo "shared $shared"
  1632. echo "postprocessing support $pp"
  1633. echo "software scaler enabled $swscaler"
  1634. echo "video hooking $vhook"
  1635. if enabled vhook; then
  1636. echo "Imlib2 support $imlib2"
  1637. echo "FreeType support $freetype2"
  1638. fi
  1639. echo "network support $network"
  1640. if enabled network; then
  1641. echo "IPv6 support $ipv6"
  1642. fi
  1643. echo "threading support $thread_type"
  1644. echo "SDL support $sdl"
  1645. if enabled sdl_too_old; then
  1646. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  1647. fi
  1648. echo "Sun medialib support $mlib"
  1649. echo "AVISynth enabled $avisynth"
  1650. echo "liba52 support $liba52"
  1651. echo "liba52 dlopened $liba52bin"
  1652. echo "libdts support $libdts"
  1653. echo "libfaac enabled $libfaac"
  1654. echo "libfaad enabled $libfaad"
  1655. echo "faadbin enabled $libfaadbin"
  1656. echo "libgsm enabled $libgsm"
  1657. echo "libmp3lame enabled $libmp3lame"
  1658. echo "libnut enabled $libnut"
  1659. echo "libogg enabled $libogg"
  1660. echo "libtheora enabled $libtheora"
  1661. echo "libvorbis enabled $libvorbis"
  1662. echo "x264 enabled $x264"
  1663. echo "XviD enabled $xvid"
  1664. echo "zlib enabled $zlib"
  1665. echo "AMR-NB float support $amr_nb"
  1666. echo "AMR-NB fixed support $amr_nb_fixed"
  1667. echo "AMR-WB float support $amr_wb"
  1668. echo "AMR-WB IF2 support $amr_if2"
  1669. if disabled gpl; then
  1670. echo "License: LGPL"
  1671. else
  1672. echo "License: GPL"
  1673. fi
  1674. echo "Creating config.mak and config.h..."
  1675. echo "# Automatically generated by configure - do not modify!" > config.mak
  1676. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  1677. echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
  1678. echo "PREFIX=$PREFIX" >> config.mak
  1679. echo "prefix=\$(DESTDIR)\${PREFIX}" >> config.mak
  1680. echo "libdir=\$(DESTDIR)$libdir" >> config.mak
  1681. echo "shlibdir=\$(DESTDIR)$shlibdir" >> config.mak
  1682. echo "incdir=\$(DESTDIR)$incdir" >> config.mak
  1683. echo "bindir=\$(DESTDIR)$bindir" >> config.mak
  1684. echo "mandir=\$(DESTDIR)$mandir" >> config.mak
  1685. echo "MAKE=$make" >> config.mak
  1686. echo "CC=$cc" >> config.mak
  1687. echo "AR=$ar" >> config.mak
  1688. echo "RANLIB=$ranlib" >> config.mak
  1689. if enabled dostrip; then
  1690. echo "STRIP=$strip" >> config.mak
  1691. else
  1692. echo "STRIP=echo ignoring strip" >> config.mak
  1693. fi
  1694. echo "OPTFLAGS=$CFLAGS" >> config.mak
  1695. echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
  1696. echo "LDFLAGS=$LDFLAGS" >> config.mak
  1697. echo "LDCONFIG=$LDCONFIG" >> config.mak
  1698. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  1699. echo "SHFLAGS=$SHFLAGS" >> config.mak
  1700. echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
  1701. echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
  1702. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  1703. echo "BUILD_STATIC=$static" >> config.mak
  1704. echo "BUILDSUF=$BUILDSUF" >> config.mak
  1705. echo "LIBPREF=$LIBPREF" >> config.mak
  1706. echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
  1707. if enabled static; then
  1708. echo "LIB=$LIB" >> config.mak
  1709. else # Some Make complain if this variable does not exist.
  1710. echo "LIB=" >> config.mak
  1711. fi
  1712. echo "SLIBPREF=$SLIBPREF" >> config.mak
  1713. echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
  1714. echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
  1715. ucarch=`toupper $arch`
  1716. echo "TARGET_ARCH_${ucarch}=yes" >> config.mak
  1717. echo "#define ARCH_${ucarch} 1" >> $TMPH
  1718. # special cases
  1719. case "$arch" in
  1720. x86_32|x86_64)
  1721. echo "TARGET_ARCH_X86=yes" >> config.mak
  1722. echo "#define ARCH_X86 1" >> $TMPH
  1723. ;;
  1724. powerpc)
  1725. if test "$POWERPCMODE" = "64bits"; then
  1726. echo "#define POWERPC_MODE_64BITS 1" >> $TMPH
  1727. fi
  1728. ;;
  1729. sparc64)
  1730. echo "TARGET_ARCH_SPARC=yes" >> config.mak
  1731. echo "#define ARCH_SPARC 1" >> $TMPH
  1732. ;;
  1733. esac
  1734. if enabled bigendian; then
  1735. echo "WORDS_BIGENDIAN=yes" >> config.mak
  1736. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  1737. fi
  1738. if enabled mmx; then
  1739. echo "#define __CPU__ 586" >> $TMPH
  1740. fi
  1741. if enabled sdl; then
  1742. echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
  1743. echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
  1744. fi
  1745. if enabled texi2html; then
  1746. echo "BUILD_DOC=yes" >> config.mak
  1747. fi
  1748. sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
  1749. pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
  1750. lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
  1751. lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
  1752. lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
  1753. if enabled shared; then
  1754. echo "BUILD_SHARED=yes" >> config.mak
  1755. echo "PIC=-fPIC -DPIC" >> config.mak
  1756. echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
  1757. echo "SPPVERSION=$pp_version" >> config.mak
  1758. echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
  1759. echo "LAVCVERSION=$lavc_version" >> config.mak
  1760. echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
  1761. echo "LAVFVERSION=$lavf_version" >> config.mak
  1762. echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
  1763. echo "LAVUVERSION=$lavu_version" >> config.mak
  1764. echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
  1765. echo "SWSVERSION=$sws_version" >> config.mak
  1766. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  1767. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  1768. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  1769. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  1770. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  1771. fi
  1772. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  1773. echo "EXTRALIBS=$extralibs" >> config.mak
  1774. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  1775. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST
  1776. print_config TARGET_ $TMPH config.mak $TARGET_LIST
  1777. if test "$targetos" = "Darwin"; then
  1778. echo "#define CONFIG_DARWIN 1" >> $TMPH
  1779. fi
  1780. echo "#define restrict $_restrict" >> $TMPH
  1781. if test "$optimize" = "small"; then
  1782. echo "#define always_inline" >> $TMPH
  1783. echo "#define CONFIG_SMALL 1" >> $TMPH
  1784. fi
  1785. echo "SRC_PATH=\"$source_path\"" >> config.mak
  1786. echo "SRC_PATH_BARE=$source_path" >> config.mak
  1787. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  1788. if enabled amr_if2; then
  1789. echo "AMR_CFLAGS=-DIF2=1" >> config.mak
  1790. fi
  1791. # Apparently it's not possible to portably echo a backslash.
  1792. if enabled asmalign_pot; then
  1793. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
  1794. else
  1795. printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
  1796. fi
  1797. for codec in $DECODER_LIST $ENCODER_LIST $PARSER_LIST $DEMUXER_LIST $MUXER_LIST; do
  1798. ucname="`toupper $codec`"
  1799. config_name="CONFIG_$ucname"
  1800. enabled_name="ENABLE_$ucname"
  1801. if enabled $codec; then
  1802. echo "#define $config_name 1" >> $TMPH
  1803. echo "#define $enabled_name 1" >> $TMPH
  1804. echo "$config_name=yes" >> config.mak
  1805. else
  1806. echo "#define $enabled_name 0" >> $TMPH
  1807. fi
  1808. done
  1809. # Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
  1810. if ! cmp -s $TMPH config.h; then
  1811. mv -f $TMPH config.h
  1812. else
  1813. echo "config.h is unchanged"
  1814. fi
  1815. rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
  1816. # build tree in object directory if source path is different from current one
  1817. if enabled source_path_used; then
  1818. DIRS="\
  1819. doc \
  1820. libavformat \
  1821. libavcodec \
  1822. libavcodec/alpha \
  1823. libavcodec/armv4l \
  1824. libavcodec/bfin \
  1825. libavcodec/i386 \
  1826. libavcodec/sparc \
  1827. libavcodec/mlib \
  1828. libavcodec/ppc \
  1829. libavcodec/amr \
  1830. libavcodec/amr_float \
  1831. libavcodec/amrwb_float \
  1832. libpostproc \
  1833. libavutil \
  1834. libswscale \
  1835. tests \
  1836. vhook \
  1837. "
  1838. FILES="\
  1839. Makefile \
  1840. common.mak \
  1841. libavformat/Makefile \
  1842. libavcodec/Makefile \
  1843. libpostproc/Makefile \
  1844. libavutil/Makefile \
  1845. libswscale/Makefile \
  1846. tests/Makefile \
  1847. vhook/Makefile \
  1848. doc/Makefile \
  1849. doc/texi2pod.pl \
  1850. "
  1851. for dir in $DIRS ; do
  1852. mkdir -p $dir
  1853. done
  1854. for f in $FILES ; do
  1855. ln -sf "$source_path/$f" $f
  1856. done
  1857. fi
  1858. # build pkg-config files
  1859. # FIXME: libdir and includedir are hardcoded and may differ from the real path.
  1860. pkgconfig_generate(){
  1861. name=$1
  1862. comment=$2
  1863. version=$3
  1864. libs=$4
  1865. requires=$5
  1866. include=$6
  1867. cat <<EOF >$name.pc
  1868. prefix=$PREFIX
  1869. exec_prefix=\${prefix}
  1870. libdir=\${exec_prefix}/lib
  1871. includedir=\${prefix}/include
  1872. Name: $name
  1873. Description: $comment
  1874. Version: $version
  1875. Requires: $requires
  1876. Conflicts:
  1877. Libs: -L\${libdir} $libs
  1878. Cflags: -I\${includedir} -I\${includedir}/$include
  1879. EOF
  1880. }
  1881. pkgconfig_generate_uninstalled(){
  1882. name=$1
  1883. shortname=${name#lib}
  1884. comment=$2
  1885. version=$3
  1886. libs=$4
  1887. requires=$5
  1888. cat <<EOF >$name-uninstalled.pc
  1889. prefix=
  1890. exec_prefix=
  1891. libdir=\${pcfiledir}/$name
  1892. includedir=\${pcfiledir}/$name
  1893. Name: $name
  1894. Description: $comment
  1895. Version: $version
  1896. Requires: $requires
  1897. Conflicts:
  1898. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  1899. Cflags: -I\${includedir}
  1900. EOF
  1901. }
  1902. pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
  1903. pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
  1904. pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
  1905. pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
  1906. pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
  1907. pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
  1908. if enabled pp; then
  1909. pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
  1910. pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
  1911. fi
  1912. if enabled swscaler; then
  1913. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "-lswscale" "libavutil = $lavu_version" swscale
  1914. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
  1915. else
  1916. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" swscale
  1917. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
  1918. apply libswscale.pc sed s/^Libs:.*$/Libs:/
  1919. apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
  1920. fi