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.

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