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.

2125 lines
58KB

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