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.

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