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.

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