You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2067 lines
57KB

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