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.

2100 lines
60KB

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