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.

2078 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/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 encoding via libvorbis,"
  91. echo " native implementation exists [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_encoder_deps="libvorbis"
  714. libx264_encoder_deps="libx264"
  715. libxvid_encoder_deps="libxvid"
  716. mpeg4aac_decoder_deps="libfaad"
  717. # demuxers / muxers
  718. ac3_demuxer_deps="ac3_parser"
  719. audio_beos_demuxer_deps="audio_beos"
  720. audio_beos_demuxer_extralibs="-lmedia -lbe"
  721. audio_beos_muxer_deps="audio_beos"
  722. audio_beos_muxer_extralibs="-lmedia -lbe"
  723. avisynth_demuxer_deps="avisynth"
  724. bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  725. dv1394_demuxer_deps="dv1394"
  726. libdc1394_demuxer_deps="libdc1394"
  727. libnut_demuxer_deps="libnut"
  728. libnut_muxer_deps="libnut"
  729. mp3_demuxer_deps="mpegaudio_parser"
  730. ogg_muxer_deps="libogg"
  731. oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
  732. oss_muxer_deps_any="soundcard_h sys_soundcard_h"
  733. redir_demuxer_deps="network"
  734. rtp_muxer_deps="network mpegts_demuxer"
  735. rtsp_demuxer_deps="rtp_protocol rtp_muxer"
  736. sdp_demuxer_deps="rtsp_demuxer"
  737. v4l2_demuxer_deps="linux_videodev2_h"
  738. v4l_demuxer_deps="linux_videodev_h"
  739. x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
  740. x11_grab_device_demuxer_extralibs="-lX11 -lXext"
  741. # protocols
  742. http_protocol_deps="network"
  743. rtp_protocol_deps="udp_protocol"
  744. tcp_protocol_deps="network"
  745. udp_protocol_deps="network"
  746. # programs
  747. ffplay_deps="sdl"
  748. ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
  749. ffserver_extralibs='$ldl'
  750. vhook_extralibs='$ldl'
  751. # set temporary file name
  752. if test ! -z "$TMPDIR" ; then
  753. TMPDIR1="${TMPDIR}"
  754. elif test ! -z "$TEMPDIR" ; then
  755. TMPDIR1="${TEMPDIR}"
  756. else
  757. TMPDIR1="/tmp"
  758. fi
  759. TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
  760. TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
  761. TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}"
  762. TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
  763. TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
  764. # default parameters
  765. enable logging
  766. logfile="config.err"
  767. # installation paths
  768. PREFIX="/usr/local"
  769. libdir='$(PREFIX)/lib'
  770. shlibdir="$libdir"
  771. incdir='$(PREFIX)/include/ffmpeg'
  772. mandir='$(PREFIX)/share/man'
  773. bindir='$(PREFIX)/bin'
  774. # toolchain
  775. cc="gcc"
  776. ar="ar"
  777. ranlib="ranlib"
  778. make="make"
  779. strip="strip"
  780. asmalign_pot="unknown"
  781. ln_s="ln -sf"
  782. # machine
  783. arch=`uname -m`
  784. cpu="generic"
  785. # OS
  786. targetos=$(tolower $(uname -s))
  787. # libraries
  788. enable zlib
  789. # configurable options
  790. enable debug
  791. enable dostrip
  792. enable ffmpeg
  793. enable ffplay
  794. enable ffserver
  795. enable ipv6
  796. enable static
  797. enable mpegaudio_hp
  798. enable network
  799. enable optimizations
  800. enable protocols
  801. vhook="default"
  802. # build settings
  803. SHFLAGS='-shared -Wl,-soname,$@'
  804. VHOOKSHFLAGS='$(SHFLAGS)'
  805. LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
  806. FFSERVERLDFLAGS=-Wl,-E
  807. LDCONFIG="ldconfig"
  808. LIBPREF="lib"
  809. LIBSUF=".a"
  810. FULLNAME='$(NAME)$(BUILDSUF)'
  811. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  812. SLIBPREF="lib"
  813. SLIBSUF=".so"
  814. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  815. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  816. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  817. LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  818. # find source path
  819. source_path="`dirname \"$0\"`"
  820. enable source_path_used
  821. if test -z "$source_path" -o "$source_path" = "." ; then
  822. source_path="`pwd`"
  823. disable source_path_used
  824. else
  825. source_path="`cd \"$source_path\"; pwd`"
  826. echo "$source_path" | grep -q '[[:blank:]]' &&
  827. die "Out of tree builds are impossible with whitespace in source path."
  828. fi
  829. FFMPEG_CONFIGURATION="$@"
  830. ENCODER_LIST=`sed -n 's/^[^#]*ENC.*(.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
  831. DECODER_LIST=`sed -n 's/^[^#]*DEC.*(.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
  832. PARSER_LIST=`sed -n 's/^[^#]*PARSER.*(.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
  833. BSF_LIST=`sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' "$source_path/libavcodec/allcodecs.c"`
  834. MUXER_LIST=`sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
  835. DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
  836. PROTOCOL_LIST=`sed -n 's/^[^#]*PROTOCOL.*(.*, *\(.*\)).*/\1_protocol/p' "$source_path/libavformat/allformats.c"`
  837. enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST $PROTOCOL_LIST $BSF_LIST
  838. enable $ARCH_EXT_LIST
  839. die_unknown(){
  840. echo "Unknown option \"$1\"."
  841. echo "See $0 --help for available options."
  842. exit 1
  843. }
  844. show_list() {
  845. suffix=_$1
  846. shift
  847. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
  848. exit 0
  849. }
  850. for opt do
  851. optval="${opt#*=}"
  852. case "$opt" in
  853. --log)
  854. ;;
  855. --log=*) logging="$optval"
  856. ;;
  857. --prefix=*) PREFIX="$optval"
  858. ;;
  859. --libdir=*) libdir="$optval"
  860. ;;
  861. --shlibdir=*) shlibdir="$optval"
  862. ;;
  863. --incdir=*) incdir="$optval"
  864. ;;
  865. --mandir=*) mandir="$optval"
  866. ;;
  867. --source-path=*) source_path="$optval"
  868. ;;
  869. --cross-prefix=*) cross_prefix="$optval"
  870. ;;
  871. --cross-compile) enable cross_compile
  872. ;;
  873. --target-os=*) targetos="$optval"
  874. ;;
  875. --cc=*) cc="$optval"
  876. ;;
  877. --make=*) make="$optval"
  878. ;;
  879. --extra-cflags=*) add_cflags "$optval"
  880. ;;
  881. --extra-ldflags=*) add_ldflags "$optval"
  882. ;;
  883. --extra-libs=*) add_extralibs "$optval"
  884. ;;
  885. --build-suffix=*) BUILDSUF="$optval"
  886. ;;
  887. --arch=*) arch="$optval"
  888. ;;
  889. --cpu=*) cpu="$optval"
  890. ;;
  891. --enable-sunmlib) enable mlib
  892. ;;
  893. --disable-strip) disable dostrip
  894. ;;
  895. --disable-encoders) disable $ENCODER_LIST
  896. ;;
  897. --disable-decoders) disable $DECODER_LIST
  898. ;;
  899. --disable-muxers) disable $MUXER_LIST
  900. ;;
  901. --disable-demuxers) disable $DEMUXER_LIST
  902. ;;
  903. --disable-parsers) disable $PARSER_LIST
  904. ;;
  905. --disable-bsfs) disable $BSF_LIST
  906. ;;
  907. --disable-protocols) disable $PROTOCOL_LIST
  908. ;;
  909. --enable-*=*|--disable-*=*)
  910. eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
  911. case "$thing" in
  912. encoder|decoder|muxer|demuxer|parser|bsf|protocol) $action ${optval}_${thing} ;;
  913. *) die_unknown "$opt" ;;
  914. esac
  915. ;;
  916. --enable-?*|--disable-?*)
  917. eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
  918. echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt
  919. $action $option
  920. ;;
  921. --list-*)
  922. NAME="${opt#--list-}"
  923. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  924. NAME=${NAME%s}
  925. eval show_list $NAME \$$(toupper $NAME)_LIST
  926. ;;
  927. --help|-h) show_help
  928. ;;
  929. *)
  930. die_unknown $opt
  931. ;;
  932. esac
  933. done
  934. case "$arch" in
  935. i386|i486|i586|i686|i86pc|BePC)
  936. arch="x86_32"
  937. enable fast_unaligned
  938. ;;
  939. x86_64|amd64)
  940. arch="x86_32"
  941. enable fast_unaligned
  942. canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
  943. if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
  944. if [ -z "`echo $CFLAGS | grep -- -m32`" ]; then
  945. arch="x86_64"
  946. enable fast_64bit
  947. fi
  948. fi
  949. ;;
  950. # armv4l is a subset of armv[567]*l
  951. arm|armv[4567]*l)
  952. arch="armv4l"
  953. ;;
  954. alpha)
  955. arch="alpha"
  956. enable fast_64bit
  957. ;;
  958. "Power Macintosh"|ppc|powerpc)
  959. arch="powerpc"
  960. ;;
  961. ppc64)
  962. arch="powerpc"
  963. enable fast_64bit
  964. ;;
  965. mips|mipsel|IP*)
  966. arch="mips"
  967. ;;
  968. sun4u|sparc64)
  969. arch="sparc64"
  970. enable fast_64bit
  971. ;;
  972. sparc)
  973. arch="sparc"
  974. ;;
  975. sh4)
  976. arch="sh4"
  977. ;;
  978. parisc)
  979. arch="parisc"
  980. ;;
  981. parisc64)
  982. arch="parisc"
  983. enable fast_64bit
  984. ;;
  985. s390|s390x)
  986. arch="s390"
  987. ;;
  988. m68k)
  989. arch="m68k"
  990. ;;
  991. ia64)
  992. arch="ia64"
  993. enable fast_64bit
  994. ;;
  995. bfin)
  996. arch="bfin"
  997. ;;
  998. *)
  999. arch="unknown"
  1000. ;;
  1001. esac
  1002. enable $arch
  1003. enabled_any x86_32 x86_64 && enable x86
  1004. enabled sparc64 && enable sparc
  1005. # OS specific
  1006. case $targetos in
  1007. beos|haiku|zeta)
  1008. PREFIX="$HOME/config"
  1009. # helps building libavcodec
  1010. add_cflags "-DPIC -fomit-frame-pointer"
  1011. # 3 gcc releases known for BeOS, each with ugly bugs
  1012. gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
  1013. case "$gcc_version" in
  1014. 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
  1015. disable mmx
  1016. ;;
  1017. *20010315*) echo "BeBits gcc"
  1018. add_cflags "-fno-expensive-optimizations"
  1019. ;;
  1020. esac
  1021. LDCONFIG="echo ignoring ldconfig"
  1022. SHFLAGS=-nostart
  1023. # enable BeOS things
  1024. enable audio_beos
  1025. # no need for libm, but the inet stuff
  1026. # Check for BONE
  1027. # XXX: actually should check for NOT net_server
  1028. if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
  1029. network_extralibs="-lbind -lsocket"
  1030. else
  1031. enable beos_netserver
  1032. network_extralibs="-lnet"
  1033. fi ;;
  1034. sunos)
  1035. FFSERVERLDFLAGS=""
  1036. SHFLAGS='-shared -Wl,-h,$@'
  1037. network_extralibs="-lsocket -lnsl"
  1038. ;;
  1039. netbsd)
  1040. oss_demuxer_extralibs="-lossaudio"
  1041. oss_muxer_extralibs="-lossaudio"
  1042. ;;
  1043. openbsd)
  1044. disable need_memalign
  1045. LIBOBJFLAGS='$(PIC)'
  1046. LDCONFIG='ldconfig -m $(SHLIBDIR)'
  1047. SHFLAGS='-shared'
  1048. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF).$(LIBVERSION)'
  1049. SLIBNAME_WITH_VERSION='$(SLIBNAME)'
  1050. SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
  1051. oss_demuxer_extralibs="-lossaudio"
  1052. oss_muxer_extralibs="-lossaudio"
  1053. ;;
  1054. freebsd)
  1055. disable need_memalign
  1056. ;;
  1057. bsd/os)
  1058. osextralibs="-lpoll -lgnugetopt"
  1059. strip="strip -d"
  1060. ;;
  1061. darwin)
  1062. disable need_memalign
  1063. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(SPPVERSION),-compatibility_version,$(SPPVERSION) -Wl,-read_only_relocs,suppress'
  1064. VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$@'
  1065. strip="strip -x"
  1066. FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
  1067. SLIBSUF=".dylib"
  1068. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  1069. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  1070. FFSERVERLDFLAGS=-Wl,-bind_at_load
  1071. ;;
  1072. mingw32*)
  1073. targetos=mingw32
  1074. shlibdir="$bindir"
  1075. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1076. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1077. if enabled swscaler; then
  1078. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1079. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1080. fi
  1081. disable ffserver
  1082. SLIBPREF=""
  1083. SLIBSUF=".dll"
  1084. EXESUF=".exe"
  1085. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1086. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1087. SLIB_EXTRA_CMD='-lib /machine:i386 /def:$(@:$(SLIBSUF)=.def)'
  1088. SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  1089. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  1090. SHFLAGS='-shared -Wl,--output-def,$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
  1091. ;;
  1092. cygwin*)
  1093. targetos=cygwin
  1094. shlibdir="$bindir"
  1095. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1096. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1097. if enabled swscaler; then
  1098. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1099. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1100. fi
  1101. EXESUF=".exe"
  1102. SLIBPREF="cyg"
  1103. SLIBSUF=".dll"
  1104. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1105. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1106. SHFLAGS='-shared -Wl,--enable-auto-image-base'
  1107. ;;
  1108. linux)
  1109. LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
  1110. enable dv1394
  1111. ;;
  1112. irix*)
  1113. targetos=irix
  1114. ranlib="echo ignoring ranlib"
  1115. ;;
  1116. *)
  1117. targetos="${targetos}-UNKNOWN"
  1118. ;;
  1119. esac
  1120. add_extralibs $osextralibs
  1121. if ! disabled logging ; then
  1122. enabled logging || logfile="$logging"
  1123. echo "# $0 $@" >$logfile
  1124. set >>$logfile
  1125. else
  1126. logfile=/dev/null
  1127. fi
  1128. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1129. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1130. test -n "$cross_prefix" && enable cross_compile
  1131. cc="${cross_prefix}${cc}"
  1132. ar="${cross_prefix}${ar}"
  1133. ranlib="${cross_prefix}${ranlib}"
  1134. strip="${cross_prefix}${strip}"
  1135. # we need to build at least one lib type
  1136. if ! enabled_any static shared; then
  1137. cat <<EOF
  1138. At least one library type must be built.
  1139. Specify --enable-static to build the static libraries or --enable-shared to
  1140. build the shared libraries as well. To only build the shared libraries specify
  1141. --disable-static in addition to --enable-shared.
  1142. EOF
  1143. exit 1;
  1144. fi
  1145. disabled static && LIBNAME=""
  1146. if ! enabled libogg; then
  1147. enabled libtheora && die "libogg must be enabled to enable libtheora."
  1148. enabled libvorbis && die "libogg must be enabled to enable libvorbis."
  1149. fi
  1150. if enabled_any libfaad libfaadbin ; then
  1151. if check_header faad.h; then
  1152. check_cc << EOF
  1153. #include <faad.h>
  1154. #ifndef FAAD2_VERSION
  1155. ok faad1
  1156. #endif
  1157. int main( void ) { return 0; }
  1158. EOF
  1159. test $? = 0 && enable libfaad2
  1160. else
  1161. die "FAAD test failed."
  1162. fi
  1163. fi
  1164. if ! enabled gpl; then
  1165. die_gpl_disabled(){
  1166. name=$1
  1167. shift
  1168. enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
  1169. }
  1170. die_gpl_disabled "The Postprocessing code" pp
  1171. die_gpl_disabled "liba52" liba52
  1172. die_gpl_disabled "libx264" libx264
  1173. die_gpl_disabled "libxvidcore" libxvid
  1174. die_gpl_disabled "FAAD2" libfaad2
  1175. die_gpl_disabled "The X11 grabber" x11grab
  1176. die_gpl_disabled "The software scaler" swscaler
  1177. fi
  1178. check_deps $ARCH_EXT_LIST
  1179. test -z "$need_memalign" && need_memalign="$mmx"
  1180. #Darwin CC versions
  1181. if test $targetos = darwin; then
  1182. if test -n "`$cc -v 2>&1 | grep xlc`"; then
  1183. add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
  1184. else
  1185. add_cflags "-no-cpp-precomp -pipe"
  1186. check_cflags "-force_cpusubtype_ALL"
  1187. check_cflags "-Wno-sign-compare"
  1188. disabled shared && add_cflags -mdynamic-no-pic
  1189. fi
  1190. fi
  1191. disabled optimizations || add_cflags -fomit-frame-pointer
  1192. # Add processor-specific flags
  1193. if test $cpu != "generic"; then
  1194. warn_altivec(){
  1195. $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
  1196. }
  1197. case $cpu in
  1198. 601|ppc601|PowerPC601)
  1199. add_cflags "-mcpu=601"
  1200. warn_altivec enabled PPC601
  1201. ;;
  1202. 603*|ppc603*|PowerPC603*)
  1203. add_cflags "-mcpu=603"
  1204. warn_altivec enabled PPC603
  1205. ;;
  1206. 604*|ppc604*|PowerPC604*)
  1207. add_cflags "-mcpu=604"
  1208. warn_altivec enabled PPC604
  1209. ;;
  1210. G3|g3|75*|ppc75*|PowerPC75*)
  1211. add_cflags "-mcpu=750 -mpowerpc-gfxopt"
  1212. warn_altivec enabled PPC75x
  1213. ;;
  1214. G4|g4|745*|ppc745*|PowerPC745*)
  1215. add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
  1216. warn_altivec disabled PPC745x
  1217. ;;
  1218. 74*|ppc74*|PowerPC74*)
  1219. add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
  1220. warn_altivec disabled PPC74xx
  1221. ;;
  1222. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1223. add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1224. warn_altivec disabled PPC970
  1225. enable ppc64
  1226. ;;
  1227. Cell|CELL|cell)
  1228. add_cflags "-mcpu=cell"
  1229. warn_altivec disabled Cell
  1230. enable ppc64
  1231. ;;
  1232. # targets that do NOT support conditional mov (cmov)
  1233. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1234. add_cflags "-march=$cpu"
  1235. disable cmov
  1236. ;;
  1237. # targets that do support conditional mov (cmov)
  1238. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1239. add_cflags "-march=$cpu"
  1240. enable cmov
  1241. enable fast_cmov
  1242. ;;
  1243. # targets that do support conditional mov but on which it's slow
  1244. pentium4|prescott|nocona)
  1245. add_cflags "-march=$cpu"
  1246. enable cmov
  1247. disable fast_cmov
  1248. ;;
  1249. sparc64)
  1250. add_cflags "-mcpu=v9"
  1251. ;;
  1252. bf*) #bf531 bf532 bf533 bf561 bf5xx all get this config
  1253. add_cflags "-mfdpic"
  1254. add_ldflags "-mfdpic"
  1255. ;;
  1256. arm*)
  1257. add_cflags "-mcpu=$cpu"
  1258. ;;
  1259. *)
  1260. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1261. ;;
  1262. esac
  1263. fi
  1264. gnu_make(){
  1265. $1 --version 2>&1 | grep -q GNU
  1266. }
  1267. if ! gnu_make $make; then
  1268. gnu_make gmake && make=gmake || die "GNU make not found."
  1269. fi
  1270. # make sure we can execute files in $TMPDIR
  1271. cat >$TMPE 2>>$logfile <<EOF
  1272. #! /bin/sh
  1273. EOF
  1274. chmod +x $TMPE >>$logfile 2>&1
  1275. if ! $TMPE >>$logfile 2>&1; then
  1276. cat <<EOF
  1277. Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
  1278. variable to another directory and make sure that $TMPDIR1 is not mounted
  1279. noexec.
  1280. EOF
  1281. die "Sanity test failed."
  1282. fi
  1283. rm $TMPE
  1284. # compiler sanity check
  1285. check_exec <<EOF
  1286. int main(){
  1287. return 0;
  1288. }
  1289. EOF
  1290. if test "$?" != 0; then
  1291. echo "$cc is unable to create an executable file."
  1292. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1293. echo "If $cc is a cross-compiler, use the --cross-compile option."
  1294. echo "Only do this if you know what cross compiling means."
  1295. fi
  1296. die "C compiler test failed."
  1297. fi
  1298. if enabled x86; then
  1299. # check whether EBP is available on x86
  1300. # As 'i' is stored on the stack, this program will crash
  1301. # if the base pointer is used to access it because the
  1302. # base pointer is cleared in the inline assembly code.
  1303. check_exec_crash <<EOF && enable ebp_available
  1304. volatile int i=0;
  1305. asm volatile (
  1306. "xorl %%ebp, %%ebp"
  1307. ::: "%ebp");
  1308. return i;
  1309. EOF
  1310. # check wether EBX is available on x86
  1311. check_asm ebx_available '"":::"%ebx"'
  1312. # check whether binutils is new enough to compile SSSE3
  1313. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  1314. fi
  1315. # check for assembler specific support
  1316. if test $arch = "powerpc"; then
  1317. check_cc <<EOF && enable dcbzl
  1318. int main(void) {
  1319. register long zero = 0;
  1320. char data[1024];
  1321. asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
  1322. return 0;
  1323. }
  1324. EOF
  1325. fi
  1326. # check for SIMD availability
  1327. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1328. if enabled altivec; then
  1329. test -n "`$cc -v 2>&1 | grep version | grep Apple`" &&
  1330. add_cflags "-faltivec" ||
  1331. add_cflags "-maltivec -mabi=altivec"
  1332. check_header altivec.h
  1333. # check if our compiler supports Motorola AltiVec C API
  1334. enabled altivec_h &&
  1335. inc_altivec_h="#include <altivec.h>" ||
  1336. inc_altivec_h=
  1337. check_cc <<EOF || disable altivec
  1338. $inc_altivec_h
  1339. int main(void) {
  1340. vector signed int v1, v2, v3;
  1341. v1 = vec_add(v2,v3);
  1342. return 0;
  1343. }
  1344. EOF
  1345. fi
  1346. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  1347. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  1348. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  1349. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  1350. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
  1351. enabled vis && add_cflags "-mcpu=ultrasparc -mtune=ultrasparc"
  1352. # ---
  1353. # big/little-endian test
  1354. check_cc <<EOF || die "endian test failed"
  1355. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  1356. EOF
  1357. grep -q BIGE $TMPO && enable bigendian
  1358. # ---
  1359. # check availability of some header files
  1360. if check_func dlopen; then
  1361. ldl=
  1362. elif check_func dlopen -ldl; then
  1363. ldl=-ldl
  1364. fi
  1365. check_func fork
  1366. check_func gethrtime
  1367. check_func getrusage
  1368. check_func inet_aton
  1369. check_func memalign
  1370. check_func mkstemp
  1371. check_func2 windows.h GetProcessTimes
  1372. check_header byteswap.h
  1373. check_header conio.h
  1374. check_header dlfcn.h
  1375. check_header malloc.h
  1376. check_header termios.h
  1377. if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
  1378. die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
  1379. fi
  1380. enabled zlib && check_lib zlib.h zlibVersion -lz || disable zlib
  1381. # ffserver uses poll(),
  1382. # if it's not found we can emulate it using select().
  1383. if enabled ffserver; then
  1384. check_header sys/poll.h
  1385. fi
  1386. # check for some common methods of building with pthread support
  1387. # do this before the optional library checks as some of them require pthreads
  1388. if enabled pthreads; then
  1389. if check_func pthread_create; then
  1390. :
  1391. elif check_func pthread_create -pthread; then
  1392. add_cflags -pthread
  1393. add_ldflags -pthread
  1394. elif check_func pthread_create -pthreads; then
  1395. add_cflags -pthreads
  1396. add_ldflags -pthreads
  1397. elif ! check_lib pthread.h pthread_create -lpthread; then
  1398. die "ERROR: can't find pthreads library"
  1399. fi
  1400. fi
  1401. for thread in $THREADS_LIST; do
  1402. if enabled $thread; then
  1403. test -n "$thread_type" &&
  1404. die "ERROR: Only one thread type must be selected." ||
  1405. thread_type="$thread"
  1406. fi
  1407. done
  1408. check_lib math.h sin -lm
  1409. # test for lrintf in math.h
  1410. check_exec <<EOF && enable lrintf || disable lrintf
  1411. #define _ISOC9X_SOURCE 1
  1412. #include <math.h>
  1413. int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
  1414. EOF
  1415. enabled_any libamr_nb libamr_wb && enable libamr
  1416. # these are off by default, so fail if requested and not available
  1417. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  1418. enabled liba52 && require liba52 a52dec/a52.h a52_init -la52
  1419. enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
  1420. enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
  1421. enabled libdc1394 && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
  1422. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  1423. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  1424. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1425. enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
  1426. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1427. enabled libogg && require libogg ogg/ogg.h ogg_sync_init -logg
  1428. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  1429. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -logg
  1430. enabled libx264 && require x264 x264.h x264_encoder_open -lx264
  1431. enabled libxvid && require Xvid xvid.h xvid_global -lxvidcore
  1432. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1433. # disable the native AC-3 decoder if liba52 is enabled
  1434. enabled liba52 && disable ac3_decoder
  1435. _restrict=
  1436. for restrict_keyword in restrict __restrict__ __restrict; do
  1437. check_cc <<EOF && _restrict=$restrict_keyword && break
  1438. void foo(char * $restrict_keyword p);
  1439. EOF
  1440. done
  1441. test "$vhook" = "default" && vhook="$dlopen"
  1442. if test "$targetos" = cygwin -o "$targetos" = mingw32 && enabled_all static vhook ; then
  1443. disable vhook
  1444. echo
  1445. echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
  1446. echo "Patches welcome."
  1447. echo
  1448. fi
  1449. if enabled vhook; then
  1450. check_ldflags -rdynamic
  1451. check_ldflags -export-dynamic
  1452. fi
  1453. check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
  1454. check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
  1455. ##########################################
  1456. # SDL check
  1457. disable sdl_too_old
  1458. disable sdl
  1459. SDL_CONFIG="${cross_prefix}sdl-config"
  1460. if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
  1461. sdl_cflags=`"${SDL_CONFIG}" --cflags`
  1462. temp_cflags $sdl_cflags
  1463. temp_extralibs `"${SDL_CONFIG}" --libs`
  1464. if check_lib SDL.h SDL_Init; then
  1465. _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
  1466. if test "$_sdlversion" -lt 121 ; then
  1467. enable sdl_too_old
  1468. else
  1469. enable sdl
  1470. check_cc $sdl_cflags <<EOF && enable sdl_video_size
  1471. #include <SDL.h>
  1472. int main(void){
  1473. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1474. int w = vi->current_w;
  1475. return 0;
  1476. }
  1477. EOF
  1478. fi
  1479. fi
  1480. restore_flags
  1481. fi
  1482. texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
  1483. ##########################################
  1484. # Network check
  1485. if enabled network; then
  1486. # Prefer arpa/inet.h over winsock2
  1487. if check_header arpa/inet.h ; then
  1488. check_func closesocket
  1489. elif check_header winsock2.h ; then
  1490. network_extralibs="-lws2_32"
  1491. check_func2 winsock2.h closesocket
  1492. fi
  1493. fi
  1494. ##########################################
  1495. # IPv6 check
  1496. enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
  1497. #include <sys/types.h>
  1498. #include <sys/socket.h>
  1499. #include <netinet/in.h>
  1500. #include <netdb.h>
  1501. int main( void ) {
  1502. struct sockaddr_storage saddr;
  1503. struct ipv6_mreq mreq6;
  1504. getaddrinfo(0,0,0,0);
  1505. getnameinfo(0,0,0,0,0,0,0);
  1506. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1507. }
  1508. EOF
  1509. check_header linux/videodev.h
  1510. check_header linux/videodev2.h
  1511. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1512. { check_header dev/bktr/ioctl_meteor.h &&
  1513. check_header dev/bktr/ioctl_bt848.h; } ||
  1514. { check_header machine/ioctl_meteor.h &&
  1515. check_header machine/ioctl_bt848.h; } ||
  1516. { check_header dev/video/meteor/ioctl_meteor.h &&
  1517. check_header dev/video/bktr/ioctl_bt848.h; } ||
  1518. check_header dev/ic/bt8xx.h
  1519. check_header sys/soundcard.h
  1520. check_header soundcard.h
  1521. # Deal with the x11 frame grabber
  1522. enabled x11grab &&
  1523. check_header X11/Xlib.h &&
  1524. check_header X11/extensions/XShm.h &&
  1525. check_func XOpenDisplay -lX11 &&
  1526. check_func XShmCreateImage -lX11 -lXext
  1527. enabled debug && add_cflags -g
  1528. # add some useful compiler flags if supported
  1529. check_cflags -Wdeclaration-after-statement
  1530. check_cflags -Wall
  1531. check_cflags -Wno-switch
  1532. check_cflags -Wdisabled-optimization
  1533. check_cflags -Wpointer-arith
  1534. check_cflags -Wredundant-decls
  1535. check_cflags -Wno-pointer-sign
  1536. enabled extra_warnings && check_cflags -Winline
  1537. # add some linker flags
  1538. check_ldflags -Wl,--warn-common
  1539. check_ldflags $LDLATEFLAGS
  1540. if enabled small; then
  1541. check_cflags -Os # not all compilers support -Os
  1542. optimizations="small"
  1543. elif enabled optimizations; then
  1544. if test -n "`$cc -v 2>&1 | grep xlc`"; then
  1545. add_cflags "-O5"
  1546. add_ldflags "-O5"
  1547. else
  1548. add_cflags "-O3"
  1549. fi
  1550. fi
  1551. # PIC flags for shared library objects where they are needed
  1552. if enabled shared; then
  1553. # LIBOBJFLAGS may have already been set in the OS configuration
  1554. if test -z "$LIBOBJFLAGS" ; then
  1555. case "$arch" in
  1556. x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS='$(PIC)' ;;
  1557. esac
  1558. fi
  1559. fi
  1560. if enabled gprof; then
  1561. add_cflags "-p"
  1562. add_ldflags "-p"
  1563. fi
  1564. VHOOKCFLAGS="-fPIC"
  1565. # Find out if the .align argument is a power of two or not.
  1566. if test $asmalign_pot = "unknown"; then
  1567. disable asmalign_pot
  1568. echo 'asm (".align 3");' | check_cc && enable asmalign_pot
  1569. fi
  1570. enabled_any $ENCODER_LIST && enable encoders
  1571. enabled_any $DECODER_LIST && enable decoders
  1572. enabled_any $MUXER_LIST && enable muxers
  1573. enabled_any $DEMUXER_LIST && enable demuxers
  1574. enabled_any $PROTOCOL_LIST && enable protocols
  1575. enabled_any $BSF_LIST && enable bsfs
  1576. enabled_any $THREADS_LIST && enable threads
  1577. check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
  1578. $BSF_LIST $DEMUXER_LIST $MUXER_LIST $PROTOCOL_LIST
  1579. enabled libdc1394 && append pkg_requires "libraw1394"
  1580. enabled libogg && append pkg_requires "ogg >= 1.1"
  1581. enabled libtheora && append pkg_requires "theora"
  1582. enabled libvorbis && append pkg_requires "vorbisenc"
  1583. echo "install prefix $PREFIX"
  1584. echo "source path $source_path"
  1585. echo "C compiler $cc"
  1586. echo "make $make"
  1587. echo ".align is power-of-two $asmalign_pot"
  1588. echo "ARCH $arch ($cpu)"
  1589. if test "$BUILDSUF" != ""; then
  1590. echo "build suffix $BUILDSUF"
  1591. fi
  1592. echo "big-endian ${bigendian-no}"
  1593. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1594. echo "MMX enabled ${mmx-no}"
  1595. echo "CMOV enabled ${cmov-no}"
  1596. echo "CMOV is fast ${fast_cmov-no}"
  1597. echo "EBX available ${ebx_available-no}"
  1598. echo "EBP available ${ebp_available-no}"
  1599. fi
  1600. if test $arch = "armv4l"; then
  1601. echo "ARMv5TE enabled ${armv5te-no}"
  1602. echo "ARMv6 enabled ${armv6-no}"
  1603. echo "IWMMXT enabled ${iwmmxt-no}"
  1604. fi
  1605. if test $arch = "mips"; then
  1606. echo "MMI enabled ${mmi-no}"
  1607. fi
  1608. if test $arch = "powerpc"; then
  1609. echo "AltiVec enabled ${altivec-no}"
  1610. echo "dcbzl available ${dcbzl-no}"
  1611. fi
  1612. echo "gprof enabled ${gprof-no}"
  1613. echo "debug symbols ${debug-no}"
  1614. echo "strip symbols ${dostrip-no}"
  1615. echo "optimizations ${optimizations-no}"
  1616. echo "static ${static-no}"
  1617. echo "shared ${shared-no}"
  1618. echo "postprocessing support ${pp-no}"
  1619. echo "software scaler enabled ${swscaler-no}"
  1620. echo "video hooking ${vhook-no}"
  1621. if enabled vhook; then
  1622. echo "Imlib2 support ${imlib2-no}"
  1623. echo "FreeType support ${freetype2-no}"
  1624. fi
  1625. echo "network support ${network-no}"
  1626. if enabled network; then
  1627. echo "IPv6 support ${ipv6-no}"
  1628. fi
  1629. echo "threading support ${thread_type-no}"
  1630. echo "SDL support ${sdl-no}"
  1631. if enabled sdl_too_old; then
  1632. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  1633. fi
  1634. echo "Sun medialib support ${mlib-no}"
  1635. echo "AVISynth enabled ${avisynth-no}"
  1636. echo "liba52 support ${liba52-no}"
  1637. echo "liba52 dlopened ${liba52bin-no}"
  1638. echo "libamr-nb support ${libamr_nb-no}"
  1639. echo "libamr-wb support ${libamr_wb-no}"
  1640. echo "libdc1394 support ${libdc1394-no}"
  1641. echo "libfaac enabled ${libfaac-no}"
  1642. echo "libfaad enabled ${libfaad-no}"
  1643. echo "libfaad dlopened ${libfaadbin-no}"
  1644. echo "libgsm enabled ${libgsm-no}"
  1645. echo "libmp3lame enabled ${libmp3lame-no}"
  1646. echo "libnut enabled ${libnut-no}"
  1647. echo "libogg enabled ${libogg-no}"
  1648. echo "libtheora enabled ${libtheora-no}"
  1649. echo "libvorbis enabled ${libvorbis-no}"
  1650. echo "x264 enabled ${libx264-no}"
  1651. echo "XviD enabled ${libxvid-no}"
  1652. echo "zlib enabled ${zlib-no}"
  1653. enabled gpl &&
  1654. echo "License: GPL" ||
  1655. echo "License: LGPL"
  1656. for type in decoder encoder parser demuxer muxer protocol bsf; do
  1657. echo "Enabled ${type}s:"
  1658. ucname="\$`toupper $type`_LIST"
  1659. list="`eval echo $ucname`"
  1660. partlist=""
  1661. for part in $list; do
  1662. enabled $part && partlist="$partlist $part"
  1663. done
  1664. partlist=`echo $partlist | sed s/_$type//g | tr ' ' '\n' | sort`
  1665. echo $partlist
  1666. done
  1667. echo "Creating config.mak and config.h..."
  1668. echo "# Automatically generated by configure - do not modify!" > config.mak
  1669. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  1670. echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
  1671. echo "#define FFMPEG_CONFIG_H" >> $TMPH
  1672. echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
  1673. echo "PREFIX=$PREFIX" >> config.mak
  1674. echo "prefix=\$(DESTDIR)\$(PREFIX)" >> config.mak
  1675. echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
  1676. echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
  1677. echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
  1678. echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
  1679. echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
  1680. echo "MAKE=$make" >> config.mak
  1681. echo "CC=$cc" >> config.mak
  1682. echo "AR=$ar" >> config.mak
  1683. echo "RANLIB=$ranlib" >> config.mak
  1684. echo "LDCONFIG=$LDCONFIG" >> config.mak
  1685. echo "LN_S=$ln_s" >> config.mak
  1686. enabled dostrip &&
  1687. echo "STRIP=$strip" >> config.mak ||
  1688. echo "STRIP=echo ignoring strip" >> config.mak
  1689. echo "OPTFLAGS=$CFLAGS" >> config.mak
  1690. echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
  1691. echo "LDFLAGS=$LDFLAGS" >> config.mak
  1692. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  1693. echo "SHFLAGS=$SHFLAGS" >> config.mak
  1694. echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
  1695. echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
  1696. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  1697. echo "BUILD_STATIC=$static" >> config.mak
  1698. echo "BUILDSUF=$BUILDSUF" >> config.mak
  1699. echo "FULLNAME=$FULLNAME" >> config.mak
  1700. echo "LIBPREF=$LIBPREF" >> config.mak
  1701. echo "LIBSUF=$LIBSUF" >> config.mak
  1702. echo "LIBNAME=$LIBNAME" >> config.mak
  1703. echo "SLIBPREF=$SLIBPREF" >> config.mak
  1704. echo "SLIBSUF=$SLIBSUF" >> config.mak
  1705. echo "EXESUF=$EXESUF" >> config.mak
  1706. if enabled bigendian; then
  1707. echo "WORDS_BIGENDIAN=yes" >> config.mak
  1708. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  1709. fi
  1710. if enabled mmx; then
  1711. echo "#define __CPU__ 586" >> $TMPH
  1712. fi
  1713. if enabled sdl; then
  1714. echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
  1715. echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
  1716. fi
  1717. if enabled texi2html; then
  1718. echo "BUILD_DOC=yes" >> config.mak
  1719. fi
  1720. sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
  1721. pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
  1722. lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
  1723. lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
  1724. lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
  1725. if enabled shared; then
  1726. echo "BUILD_SHARED=yes" >> config.mak
  1727. echo "PIC=-fPIC -DPIC" >> config.mak
  1728. echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
  1729. echo "SPPVERSION=$pp_version" >> config.mak
  1730. echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
  1731. echo "LAVCVERSION=$lavc_version" >> config.mak
  1732. echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
  1733. echo "LAVFVERSION=$lavf_version" >> config.mak
  1734. echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
  1735. echo "LAVUVERSION=$lavu_version" >> config.mak
  1736. echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
  1737. echo "SWSVERSION=$sws_version" >> config.mak
  1738. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  1739. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  1740. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  1741. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  1742. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  1743. echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
  1744. fi
  1745. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  1746. echo "EXTRALIBS=$extralibs" >> config.mak
  1747. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  1748. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  1749. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  1750. $DECODER_LIST \
  1751. $ENCODER_LIST \
  1752. $PARSER_LIST \
  1753. $BSF_LIST \
  1754. $DEMUXER_LIST \
  1755. $MUXER_LIST \
  1756. $PROTOCOL_LIST \
  1757. echo "#define restrict $_restrict" >> $TMPH
  1758. if enabled small; then
  1759. echo "#define av_always_inline" >> $TMPH
  1760. fi
  1761. echo "SRC_PATH=\"$source_path\"" >> config.mak
  1762. echo "SRC_PATH_BARE=$source_path" >> config.mak
  1763. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  1764. # Apparently it's not possible to portably echo a backslash.
  1765. enabled asmalign_pot &&
  1766. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
  1767. printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
  1768. echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
  1769. # Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
  1770. cmp -s $TMPH config.h &&
  1771. echo "config.h is unchanged" ||
  1772. mv -f $TMPH config.h
  1773. rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
  1774. # build tree in object directory if source path is different from current one
  1775. if enabled source_path_used; then
  1776. DIRS="\
  1777. doc \
  1778. libavcodec \
  1779. libavcodec/alpha \
  1780. libavcodec/armv4l \
  1781. libavcodec/bfin \
  1782. libavcodec/i386 \
  1783. libavcodec/mlib \
  1784. libavcodec/ppc \
  1785. libavcodec/sh4 \
  1786. libavcodec/sparc \
  1787. libavformat \
  1788. libavutil \
  1789. libpostproc \
  1790. libswscale \
  1791. tests \
  1792. tools \
  1793. vhook \
  1794. "
  1795. FILES="\
  1796. Makefile \
  1797. common.mak \
  1798. doc/texi2pod.pl \
  1799. libavcodec/Makefile \
  1800. libavformat/Makefile \
  1801. libavutil/Makefile \
  1802. libpostproc/Makefile \
  1803. libswscale/Makefile \
  1804. "
  1805. for dir in $DIRS ; do
  1806. mkdir -p $dir
  1807. done
  1808. for f in $FILES ; do
  1809. $ln_s "$source_path/$f" $f
  1810. done
  1811. fi
  1812. # build pkg-config files
  1813. # FIXME: libdir and includedir are hardcoded and may differ from the real path.
  1814. pkgconfig_generate(){
  1815. name=$1
  1816. comment=$2
  1817. version=$3
  1818. libs=$4
  1819. requires=$5
  1820. include=$6
  1821. cat <<EOF >$name.pc
  1822. prefix=$PREFIX
  1823. exec_prefix=\${prefix}
  1824. libdir=\${exec_prefix}/lib
  1825. includedir=\${prefix}/include
  1826. Name: $name
  1827. Description: $comment
  1828. Version: $version
  1829. Requires: $requires
  1830. Conflicts:
  1831. Libs: -L\${libdir} $libs
  1832. Cflags: -I\${includedir} -I\${includedir}/$include
  1833. EOF
  1834. }
  1835. pkgconfig_generate_uninstalled(){
  1836. name=$1
  1837. shortname=${name#lib}
  1838. comment=$2
  1839. version=$3
  1840. libs=$4
  1841. requires=$5
  1842. cat <<EOF >$name-uninstalled.pc
  1843. prefix=
  1844. exec_prefix=
  1845. libdir=\${pcfiledir}/$name
  1846. includedir=\${pcfiledir}/$name
  1847. Name: $name
  1848. Description: $comment
  1849. Version: $version
  1850. Requires: $requires
  1851. Conflicts:
  1852. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  1853. Cflags: -I\${includedir}
  1854. EOF
  1855. }
  1856. pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
  1857. pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
  1858. pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
  1859. pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
  1860. pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
  1861. pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
  1862. if enabled pp; then
  1863. pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
  1864. pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
  1865. fi
  1866. if enabled swscaler; then
  1867. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" -lswscale "libavutil = $lavu_version" ffmpeg
  1868. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
  1869. else
  1870. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" ffmpeg
  1871. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
  1872. apply libswscale.pc sed s/^Libs:.*$/Libs:/
  1873. apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
  1874. fi