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.

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