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.

2092 lines
57KB

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