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.

2062 lines
57KB

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