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