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.

2102 lines
57KB

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