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.

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