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.

2130 lines
58KB

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