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.

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