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.

2142 lines
57KB

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