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.

2067 lines
57KB

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