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.

2127 lines
58KB

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