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.

2105 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. ln_s="ln -sf"
  759. # machine
  760. arch=`uname -m`
  761. cpu="generic"
  762. # OS
  763. targetos=$(tolower $(uname -s))
  764. # non-library system interfaces
  765. bktr="yes"
  766. # libraries
  767. zlib="yes"
  768. # configurable options
  769. debug="yes"
  770. dostrip="yes"
  771. ffmpeg="yes"
  772. ffplay="yes"
  773. ffserver="yes"
  774. ipv6="yes"
  775. static="yes"
  776. mpegaudio_hp="yes"
  777. network="yes"
  778. optimize="yes"
  779. protocols="yes"
  780. vhook="default"
  781. # build settings
  782. SHFLAGS='-shared -Wl,-soname,$@'
  783. VHOOKSHFLAGS='$(SHFLAGS)'
  784. LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
  785. FFSERVERLDFLAGS=-Wl,-E
  786. LDCONFIG="ldconfig"
  787. LIBPREF="lib"
  788. LIBSUF=".a"
  789. LIB='$(LIBPREF)$(NAME)$(LIBSUF)'
  790. SLIBPREF="lib"
  791. SLIBSUF=".so"
  792. SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF)'
  793. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  794. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  795. LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIB)"'
  796. # find source path
  797. source_path="`dirname \"$0\"`"
  798. source_path_used="yes"
  799. if test -z "$source_path" -o "$source_path" = "." ; then
  800. source_path="`pwd`"
  801. source_path_used="no"
  802. else
  803. source_path="`cd \"$source_path\"; pwd`"
  804. echo "$source_path" | grep -q '[[:blank:]]' &&
  805. die "Out of tree builds are impossible with whitespace in source path."
  806. fi
  807. if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
  808. show_help
  809. fi
  810. FFMPEG_CONFIGURATION="$@"
  811. ENCODER_LIST=`sed -n 's/^[^#]*ENC.*(.*, *\(.*\)).*/\1_encoder/p' "$source_path/libavcodec/allcodecs.c"`
  812. DECODER_LIST=`sed -n 's/^[^#]*DEC.*(.*, *\(.*\)).*/\1_decoder/p' "$source_path/libavcodec/allcodecs.c"`
  813. PARSER_LIST=`sed -n 's/^[^#]*PARSER.*(.*, *\(.*\)).*/\1_parser/p' "$source_path/libavcodec/allcodecs.c"`
  814. BSF_LIST=`sed -n 's/^[^#]*BSF.*(.*, *\(.*\)).*/\1_bsf/p' "$source_path/libavcodec/allcodecs.c"`
  815. MUXER_LIST=`sed -n 's/^[^#]*_MUX.*(.*, *\(.*\)).*/\1_muxer/p' "$source_path/libavformat/allformats.c"`
  816. DEMUXER_LIST=`sed -n 's/^[^#]*DEMUX.*(.*, *\(.*\)).*/\1_demuxer/p' "$source_path/libavformat/allformats.c"`
  817. PROTOCOL_LIST=`sed -n 's/^[^#]*PROTOCOL.*(.*, *\(.*\)).*/\1_protocol/p' "$source_path/libavformat/allformats.c"`
  818. enable $ENCODER_LIST $DECODER_LIST $PARSER_LIST $MUXER_LIST $DEMUXER_LIST $PROTOCOL_LIST $BSF_LIST
  819. enable $ARCH_EXT_LIST
  820. die_unknown(){
  821. echo "Unknown option \"$1\"."
  822. echo "See $0 --help for available options."
  823. exit 1
  824. }
  825. show_list() {
  826. for part in $*; do
  827. echo $part | sed 's/_[^_]*$//'
  828. done | sort
  829. exit 0
  830. }
  831. for opt do
  832. optval="${opt#*=}"
  833. case "$opt" in
  834. --log)
  835. ;;
  836. --log=*) logging="$optval"
  837. ;;
  838. --prefix=*) PREFIX="$optval"
  839. ;;
  840. --libdir=*) libdir="$optval"
  841. ;;
  842. --shlibdir=*) shlibdir="$optval"
  843. ;;
  844. --incdir=*) incdir="$optval"
  845. ;;
  846. --mandir=*) mandir="$optval"
  847. ;;
  848. --source-path=*) source_path="$optval"
  849. ;;
  850. --cross-prefix=*) cross_prefix="$optval"
  851. ;;
  852. --cross-compile) cross_compile="yes"
  853. ;;
  854. --target-os=*) targetos="$optval"
  855. ;;
  856. --cc=*) cc="$optval"
  857. ;;
  858. --make=*) make="$optval"
  859. ;;
  860. --extra-cflags=*) add_cflags "$optval"
  861. ;;
  862. --extra-ldflags=*) add_ldflags "$optval"
  863. ;;
  864. --extra-libs=*) add_extralibs "$optval"
  865. ;;
  866. --build-suffix=*) BUILDSUF="$optval"
  867. ;;
  868. --arch=*) arch="$optval"
  869. ;;
  870. --cpu=*) cpu="$optval"
  871. ;;
  872. --disable-opts) optimize="no"
  873. ;;
  874. --enable-sunmlib) mlib="yes"
  875. ;;
  876. --disable-strip) dostrip="no"
  877. ;;
  878. --disable-encoders) disable $ENCODER_LIST
  879. ;;
  880. --disable-decoders) disable $DECODER_LIST
  881. ;;
  882. --disable-muxers) disable $MUXER_LIST
  883. ;;
  884. --disable-demuxers) disable $DEMUXER_LIST
  885. ;;
  886. --disable-parsers) disable $PARSER_LIST
  887. ;;
  888. --disable-bsfs) disable $BSF_LIST
  889. ;;
  890. --disable-protocols) disable $PROTOCOL_LIST
  891. ;;
  892. --enable-*=*|--disable-*=*)
  893. eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
  894. case "$thing" in
  895. encoder|decoder|muxer|demuxer|parser|bsf|protocol) $action ${optval}_${thing} ;;
  896. *) die_unknown "$opt" ;;
  897. esac
  898. ;;
  899. --enable-?*|--disable-?*)
  900. eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
  901. echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt
  902. $action $option
  903. ;;
  904. --list-*)
  905. NAME="${opt#--list-}"
  906. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  907. NAME=$(toupper ${NAME%s})
  908. eval show_list \$${NAME}_LIST
  909. ;;
  910. --help) show_help
  911. ;;
  912. *)
  913. die_unknown $opt
  914. ;;
  915. esac
  916. done
  917. case "$arch" in
  918. i386|i486|i586|i686|i86pc|BePC)
  919. arch="x86_32"
  920. enable fast_unaligned
  921. ;;
  922. x86_64|amd64)
  923. arch="x86_32"
  924. enable fast_unaligned
  925. canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
  926. if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
  927. if [ -z "`echo $CFLAGS | grep -- -m32`" ]; then
  928. arch="x86_64"
  929. enable fast_64bit
  930. fi
  931. fi
  932. ;;
  933. # armv4l is a subset of armv[567]*l
  934. arm|armv[4567]*l)
  935. arch="armv4l"
  936. ;;
  937. alpha)
  938. arch="alpha"
  939. enable fast_64bit
  940. ;;
  941. "Power Macintosh"|ppc|powerpc)
  942. arch="powerpc"
  943. ;;
  944. ppc64)
  945. arch="powerpc"
  946. enable fast_64bit
  947. ;;
  948. mips|mipsel|IP*)
  949. arch="mips"
  950. ;;
  951. sun4u|sparc64)
  952. arch="sparc64"
  953. enable fast_64bit
  954. ;;
  955. sparc)
  956. arch="sparc"
  957. ;;
  958. sh4)
  959. arch="sh4"
  960. ;;
  961. parisc)
  962. arch="parisc"
  963. ;;
  964. parisc64)
  965. arch="parisc"
  966. enable fast_64bit
  967. ;;
  968. s390|s390x)
  969. arch="s390"
  970. ;;
  971. m68k)
  972. arch="m68k"
  973. ;;
  974. ia64)
  975. arch="ia64"
  976. enable fast_64bit
  977. ;;
  978. bfin)
  979. arch="bfin"
  980. ;;
  981. *)
  982. arch="unknown"
  983. ;;
  984. esac
  985. enable $arch
  986. enabled_any x86_32 x86_64 && enable x86
  987. enabled sparc64 && enable sparc
  988. # OS specific
  989. osextralibs="-lm"
  990. case $targetos in
  991. beos|haiku|zeta)
  992. PREFIX="$HOME/config"
  993. # helps building libavcodec
  994. add_cflags "-DPIC -fomit-frame-pointer"
  995. # 3 gcc releases known for BeOS, each with ugly bugs
  996. gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
  997. case "$gcc_version" in
  998. 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
  999. mmx="no"
  1000. ;;
  1001. *20010315*) echo "BeBits gcc"
  1002. add_cflags "-fno-expensive-optimizations"
  1003. ;;
  1004. esac
  1005. LDCONFIG="echo ignoring ldconfig"
  1006. SHFLAGS=-nostart
  1007. # enable BeOS things
  1008. audio_beos="yes"
  1009. # no need for libm, but the inet stuff
  1010. # Check for BONE
  1011. # XXX: actually should check for NOT net_server
  1012. if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
  1013. osextralibs="-lbind -lsocket"
  1014. else
  1015. beos_netserver="yes"
  1016. osextralibs="-lnet"
  1017. fi ;;
  1018. sunos)
  1019. FFSERVERLDFLAGS=""
  1020. SHFLAGS="-shared -Wl,-h,\$@"
  1021. add_extralibs "-lsocket -lnsl"
  1022. ;;
  1023. netbsd)
  1024. add_extralibs "-lossaudio"
  1025. ;;
  1026. openbsd)
  1027. need_memalign="no"
  1028. LIBOBJFLAGS="\$(PIC)"
  1029. LDCONFIG="ldconfig -m \$(SHLIBDIR)"
  1030. SHFLAGS='-shared'
  1031. SLIBNAME='$(SLIBPREF)$(NAME)$(SLIBSUF).$(LIBVERSION)'
  1032. SLIBNAME_WITH_VERSION='$(SLIBNAME)'
  1033. SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
  1034. add_extralibs "-lossaudio"
  1035. ;;
  1036. freebsd)
  1037. need_memalign="no"
  1038. add_cflags "-pthread"
  1039. ;;
  1040. gnu/kfreebsd)
  1041. add_cflags "-pthread"
  1042. ;;
  1043. bsd/os)
  1044. osextralibs="-lpoll -lgnugetopt -lm"
  1045. strip="strip -d"
  1046. ;;
  1047. darwin)
  1048. need_memalign="no"
  1049. SHFLAGS="-dynamiclib -Wl,-single_module -Wl,-install_name,\$(SHLIBDIR)/\$(SLIBNAME),-current_version,\$(SPPVERSION),-compatibility_version,\$(SPPVERSION) -Wl,-read_only_relocs,suppress"
  1050. VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$@'
  1051. osextralibs=""
  1052. strip="strip -x"
  1053. FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
  1054. SLIBSUF=".dylib"
  1055. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME).$(LIBVERSION)$(SLIBSUF)'
  1056. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME).$(LIBMAJOR)$(SLIBSUF)'
  1057. FFSERVERLDFLAGS=-Wl,-bind_at_load
  1058. ;;
  1059. mingw32*)
  1060. targetos=mingw32
  1061. shlibdir="$bindir"
  1062. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1063. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1064. if enabled swscaler; then
  1065. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1066. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1067. fi
  1068. ffserver="no"
  1069. SLIBPREF=""
  1070. SLIBSUF=".dll"
  1071. EXESUF=".exe"
  1072. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1073. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
  1074. SLIB_EXTRA_CMD="-lib /machine:i386 /def:\$(@:${SLIBSUF}=.def)"
  1075. SLIB_INSTALL_EXTRA_CMD="-install -m 644 \$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib) \"\$(SHLIBDIR)/\$(SLIBNAME_WITH_MAJOR:\$(SLIBSUF)=.lib)\""
  1076. SHFLAGS="-shared -Wl,--output-def,\$(@:${SLIBSUF}=.def),--out-implib,lib\$(SLIBNAME:\$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base"
  1077. ;;
  1078. cygwin*)
  1079. targetos=cygwin
  1080. shlibdir="$bindir"
  1081. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1082. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1083. if enabled swscaler; then
  1084. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1085. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1086. fi
  1087. osextralibs=""
  1088. EXESUF=".exe"
  1089. SLIBPREF="cyg"
  1090. SLIBSUF=".dll"
  1091. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1092. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
  1093. SHFLAGS='-shared -Wl,--out-implib=lib$(NAME).dll.a -Wl,--enable-auto-image-base'
  1094. ;;
  1095. linux)
  1096. LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
  1097. dv1394="yes"
  1098. ;;
  1099. irix*)
  1100. targetos=irix
  1101. ranlib="echo ignoring ranlib"
  1102. ;;
  1103. *)
  1104. targetos="${targetos}-UNKNOWN"
  1105. ;;
  1106. esac
  1107. add_extralibs $osextralibs
  1108. if ! disabled logging ; then
  1109. enabled logging || logfile="$logging"
  1110. echo "# $0 $@" >$logfile
  1111. set >>$logfile
  1112. else
  1113. logfile=/dev/null
  1114. fi
  1115. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1116. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1117. test -n "$cross_prefix" && cross_compile=yes
  1118. cc="${cross_prefix}${cc}"
  1119. ar="${cross_prefix}${ar}"
  1120. ranlib="${cross_prefix}${ranlib}"
  1121. strip="${cross_prefix}${strip}"
  1122. ln_s="${cross_prefix}${ln_s}"
  1123. # we need to build at least one lib type
  1124. if ! enabled_any static shared; then
  1125. cat <<EOF
  1126. At least one library type must be built.
  1127. Specify --enable-static to build the static libraries or --enable-shared to
  1128. build the shared libraries as well. To only build the shared libraries specify
  1129. --disable-static in addition to --enable-shared.
  1130. EOF
  1131. exit 1;
  1132. fi
  1133. if disabled static; then
  1134. LIB=""
  1135. fi
  1136. if ! enabled libogg; then
  1137. enabled libtheora && die "libogg must be enabled to enable libtheora."
  1138. enabled libvorbis && die "libogg must be enabled to enable libvorbis."
  1139. fi
  1140. if enabled_any libfaad libfaadbin ; then
  1141. if check_header faad.h; then
  1142. check_cc << EOF
  1143. #include <faad.h>
  1144. #ifndef FAAD2_VERSION
  1145. ok faad1
  1146. #endif
  1147. int main( void ) { return 0; }
  1148. EOF
  1149. test $? = 0 && enable libfaad2
  1150. else
  1151. die "FAAD test failed."
  1152. fi
  1153. fi
  1154. if ! enabled gpl; then
  1155. die_gpl_disabled(){
  1156. name=$1
  1157. shift
  1158. enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
  1159. }
  1160. die_gpl_disabled "The Postprocessing code" pp
  1161. die_gpl_disabled "liba52" liba52
  1162. die_gpl_disabled "libx264" libx264
  1163. die_gpl_disabled "libxvidcore" libxvid
  1164. die_gpl_disabled "FAAD2" libfaad2
  1165. die_gpl_disabled "The X11 grabber" x11grab
  1166. die_gpl_disabled "The software scaler" swscaler
  1167. fi
  1168. check_deps $ARCH_EXT_LIST
  1169. test -z "$need_memalign" && need_memalign="$mmx"
  1170. #Darwin CC versions
  1171. if test $targetos = darwin; then
  1172. if test -n "`$cc -v 2>&1 | grep xlc`"; then
  1173. add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
  1174. else
  1175. add_cflags "-no-cpp-precomp -pipe"
  1176. check_cflags "-force_cpusubtype_ALL"
  1177. check_cflags "-Wno-sign-compare"
  1178. disabled shared && add_cflags -mdynamic-no-pic
  1179. fi
  1180. fi
  1181. disabled optimize || add_cflags -fomit-frame-pointer
  1182. # Add processor-specific flags
  1183. if test $cpu != "generic"; then
  1184. warn_altivec(){
  1185. $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
  1186. }
  1187. case $cpu in
  1188. 601|ppc601|PowerPC601)
  1189. add_cflags "-mcpu=601"
  1190. warn_altivec enabled PPC601
  1191. ;;
  1192. 603*|ppc603*|PowerPC603*)
  1193. add_cflags "-mcpu=603"
  1194. warn_altivec enabled PPC603
  1195. ;;
  1196. 604*|ppc604*|PowerPC604*)
  1197. add_cflags "-mcpu=604"
  1198. warn_altivec enabled PPC604
  1199. ;;
  1200. G3|g3|75*|ppc75*|PowerPC75*)
  1201. add_cflags "-mcpu=750 -mpowerpc-gfxopt"
  1202. warn_altivec enabled PPC75x
  1203. ;;
  1204. G4|g4|745*|ppc745*|PowerPC745*)
  1205. add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
  1206. warn_altivec disabled PPC745x
  1207. ;;
  1208. 74*|ppc74*|PowerPC74*)
  1209. add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
  1210. warn_altivec disabled PPC74xx
  1211. ;;
  1212. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1213. add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1214. warn_altivec disabled PPC970
  1215. enable ppc64
  1216. ;;
  1217. Cell|CELL|cell)
  1218. add_cflags "-mcpu=cell"
  1219. warn_altivec disabled Cell
  1220. enable ppc64
  1221. ;;
  1222. # targets that do NOT support conditional mov (cmov)
  1223. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1224. add_cflags "-march=$cpu"
  1225. cmov="no"
  1226. ;;
  1227. # targets that do support conditional mov (cmov)
  1228. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1229. add_cflags "-march=$cpu"
  1230. cmov="yes"
  1231. fast_cmov="yes"
  1232. ;;
  1233. # targets that do support conditional mov but on which it's slow
  1234. pentium4|prescott|nocona)
  1235. add_cflags "-march=$cpu"
  1236. cmov="yes"
  1237. fast_cmov="no"
  1238. ;;
  1239. sparc64)
  1240. add_cflags "-mcpu=v9"
  1241. ;;
  1242. bf*) #bf531 bf532 bf533 bf561 bf5xx all get this config
  1243. add_cflags "-mfdpic"
  1244. add_ldflags "-mfdpic"
  1245. ;;
  1246. *)
  1247. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1248. ;;
  1249. esac
  1250. fi
  1251. gnu_make(){
  1252. $1 --version 2>&1 | grep -q GNU
  1253. }
  1254. if ! gnu_make $make; then
  1255. gnu_make gmake && make=gmake || die "GNU make not found."
  1256. fi
  1257. # make sure we can execute files in $TMPDIR
  1258. cat >$TMPE 2>>$logfile <<EOF
  1259. #! /bin/sh
  1260. EOF
  1261. chmod +x $TMPE >>$logfile 2>&1
  1262. if ! $TMPE >>$logfile 2>&1; then
  1263. cat <<EOF
  1264. Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
  1265. variable to another directory and make sure that $TMPDIR1 is not mounted
  1266. noexec.
  1267. EOF
  1268. die "Sanity test failed."
  1269. fi
  1270. rm $TMPE
  1271. # compiler sanity check
  1272. check_exec <<EOF
  1273. int main(){
  1274. return 0;
  1275. }
  1276. EOF
  1277. if test "$?" != 0; then
  1278. echo "$cc is unable to create an executable file."
  1279. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1280. echo "If $cc is a cross-compiler, use the --cross-compile option."
  1281. echo "Only do this if you know what cross compiling means."
  1282. fi
  1283. die "C compiler test failed."
  1284. fi
  1285. if enabled x86; then
  1286. # check whether EBP is available on x86
  1287. # As 'i' is stored on the stack, this program will crash
  1288. # if the base pointer is used to access it because the
  1289. # base pointer is cleared in the inline assembly code.
  1290. check_exec_crash <<EOF && enable ebp_available
  1291. volatile int i=0;
  1292. asm volatile (
  1293. "xorl %%ebp, %%ebp"
  1294. ::: "%ebp");
  1295. return i;
  1296. EOF
  1297. # check wether EBX is available on x86
  1298. check_cc <<EOF && enable ebx_available
  1299. int main(){
  1300. asm volatile ("":::"%ebx");
  1301. }
  1302. EOF
  1303. # check whether binutils is new enough to compile SSSE3
  1304. enabled ssse3 && check_cc <<EOF || disable ssse3
  1305. int main(){
  1306. asm volatile ("pabsw %xmm0, %xmm0");
  1307. }
  1308. EOF
  1309. fi
  1310. # check for assembler specific support
  1311. if test $arch = "powerpc"; then
  1312. check_cc <<EOF && dcbzl=yes
  1313. int main(void) {
  1314. register long zero = 0;
  1315. char data[1024];
  1316. asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
  1317. return 0;
  1318. }
  1319. EOF
  1320. fi
  1321. # check for SIMD availability
  1322. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1323. if enabled altivec; then
  1324. if test -n "`$cc -v 2>&1 | grep version | grep Apple`"; then
  1325. add_cflags "-faltivec"
  1326. else
  1327. add_cflags "-maltivec -mabi=altivec"
  1328. fi
  1329. check_header altivec.h
  1330. # check if our compiler supports Motorola AltiVec C API
  1331. if enabled altivec_h; then
  1332. inc_altivec_h="#include <altivec.h>"
  1333. else
  1334. inc_altivec_h=
  1335. fi
  1336. check_cc <<EOF || altivec=no
  1337. $inc_altivec_h
  1338. int main(void) {
  1339. vector signed int v1, v2, v3;
  1340. v1 = vec_add(v2,v3);
  1341. return 0;
  1342. }
  1343. EOF
  1344. fi
  1345. # check armv5te instructions support
  1346. enabled armv5te && check_cc <<EOF || disable armv5te
  1347. int main(void) {
  1348. __asm__ __volatile__ ("qadd r0, r0, r0");
  1349. }
  1350. EOF
  1351. enabled armv6 && check_cc <<EOF || disable armv6
  1352. int main(void) {
  1353. __asm__ __volatile__ ("sadd16 r0, r0, r0");
  1354. }
  1355. EOF
  1356. # check iwmmxt support
  1357. enabled iwmmxt && check_cc <<EOF || disable iwmmxt
  1358. int main(void) {
  1359. __asm__ __volatile__ ("wunpckelub wr6, wr4");
  1360. }
  1361. EOF
  1362. # check if our compiler supports mmi
  1363. enabled mmi && check_cc <<EOF || mmi="no"
  1364. int main(void) {
  1365. __asm__ ("lq \$2, 0(\$2)");
  1366. return 0;
  1367. }
  1368. EOF
  1369. # ---
  1370. # big/little-endian test
  1371. check_cc <<EOF || die "endian test failed"
  1372. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  1373. EOF
  1374. grep -q BIGE $TMPO && enable bigendian
  1375. # ---
  1376. # check availability of some header files
  1377. check_header malloc.h
  1378. check_func memalign
  1379. if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
  1380. die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
  1381. fi
  1382. check_header byteswap.h
  1383. check_func mkstemp
  1384. check_func gethrtime
  1385. check_header termios.h
  1386. check_header conio.h
  1387. check_func inet_aton
  1388. enabled zlib && check_lib zlib.h zlibVersion -lz || zlib="no"
  1389. # ffserver uses poll(),
  1390. # if it's not found we can emulate it using select().
  1391. if enabled ffserver; then
  1392. check_header sys/poll.h
  1393. fi
  1394. # check for some common methods of building with pthread support
  1395. # do this before the optional library checks as some of them require pthreads
  1396. if enabled pthreads; then
  1397. if check_func pthread_create; then
  1398. :
  1399. elif check_func pthread_create -pthread; then
  1400. add_cflags -pthread
  1401. add_ldflags -pthread
  1402. elif check_func pthread_create -pthreads; then
  1403. add_cflags -pthreads
  1404. add_ldflags -pthreads
  1405. elif ! check_lib pthread.h pthread_create -lpthread; then
  1406. die "ERROR: can't find pthreads library"
  1407. fi
  1408. fi
  1409. for thread in $THREADS_LIST; do
  1410. if enabled $thread; then
  1411. if test -n "$thread_type"; then
  1412. die "ERROR: Only one thread type must be selected."
  1413. else
  1414. thread_type="$thread"
  1415. fi
  1416. fi
  1417. done
  1418. # test for lrintf in math.h
  1419. check_exec <<EOF && lrintf=yes || lrintf=no
  1420. #define _ISOC9X_SOURCE 1
  1421. #include <math.h>
  1422. int main( void ) { return (lrintf(3.999f) > 0)?0:1; }
  1423. EOF
  1424. enabled_any libamr_nb libamr_wb && enable libamr
  1425. # these are off by default, so fail if requested and not available
  1426. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  1427. enabled liba52 && require liba52 a52dec/a52.h a52_init -la52
  1428. enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
  1429. enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
  1430. enabled libdc1394 && require libdc1394 libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394
  1431. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  1432. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  1433. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1434. enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
  1435. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1436. enabled libogg && require libogg ogg/ogg.h ogg_sync_init -logg
  1437. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  1438. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbis -lvorbisenc -logg
  1439. enabled libx264 && require x264 x264.h x264_encoder_open -lx264
  1440. enabled libxvid && require Xvid xvid.h xvid_global -lxvidcore
  1441. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1442. # disable the native AC-3 decoder if liba52 is enabled
  1443. enabled liba52 && disable ac3_decoder
  1444. _restrict=
  1445. for restrict_keyword in restrict __restrict__ __restrict; do
  1446. check_cc <<EOF && _restrict=$restrict_keyword && break
  1447. void foo(char * $restrict_keyword p);
  1448. EOF
  1449. done
  1450. # dlopen/dlfcn.h probing
  1451. check_header dlfcn.h
  1452. if check_func dlopen; then
  1453. ldl=
  1454. elif check_func dlopen -ldl; then
  1455. ldl=-ldl
  1456. fi
  1457. check_func getrusage
  1458. check_func2 windows.h GetProcessTimes
  1459. check_func fork
  1460. test "$vhook" = "default" && vhook="$dlopen"
  1461. enabled_any vhook liba52bin libfaadbin ffserver && add_extralibs $ldl
  1462. if test "$targetos" = cygwin -o "$targetos" = mingw32 && enabled_all static vhook ; then
  1463. vhook="no"
  1464. echo
  1465. echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
  1466. echo "Patches welcome."
  1467. echo
  1468. fi
  1469. if enabled vhook; then
  1470. check_ldflags -rdynamic
  1471. check_ldflags -export-dynamic
  1472. fi
  1473. enabled audio_beos && add_extralibs "-lmedia -lbe"
  1474. check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
  1475. check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
  1476. ##########################################
  1477. # SDL check
  1478. sdl_too_old=no
  1479. sdl=no
  1480. SDL_CONFIG="${cross_prefix}sdl-config"
  1481. if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
  1482. sdl_cflags=`"${SDL_CONFIG}" --cflags`
  1483. temp_cflags $sdl_cflags
  1484. temp_extralibs `"${SDL_CONFIG}" --libs`
  1485. if check_lib SDL.h SDL_Init; then
  1486. _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
  1487. if test "$_sdlversion" -lt 121 ; then
  1488. sdl_too_old=yes
  1489. else
  1490. sdl=yes
  1491. check_cc $sdl_cflags <<EOF && enable sdl_video_size
  1492. #include <SDL.h>
  1493. int main(void){
  1494. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1495. int w = vi->current_w;
  1496. return 0;
  1497. }
  1498. EOF
  1499. fi
  1500. fi
  1501. restore_flags
  1502. fi
  1503. texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
  1504. ##########################################
  1505. # Network check
  1506. if enabled network; then
  1507. # Prefer arpa/inet.h over winsock2
  1508. if check_header arpa/inet.h ; then
  1509. check_func closesocket
  1510. elif check_header winsock2.h ; then
  1511. add_extralibs -lws2_32
  1512. check_func2 winsock2.h closesocket
  1513. fi
  1514. fi
  1515. ##########################################
  1516. # IPv6 check
  1517. enabled network && enabled ipv6 && check_ld <<EOF && ipv6=yes || ipv6=no
  1518. #include <sys/types.h>
  1519. #include <sys/socket.h>
  1520. #include <netinet/in.h>
  1521. #include <netdb.h>
  1522. int main( void ) {
  1523. struct sockaddr_storage saddr;
  1524. struct ipv6_mreq mreq6;
  1525. getaddrinfo(0,0,0,0);
  1526. getnameinfo(0,0,0,0,0,0,0);
  1527. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1528. }
  1529. EOF
  1530. check_header linux/videodev.h
  1531. check_header linux/videodev2.h
  1532. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1533. if enabled bktr; then
  1534. { check_header dev/bktr/ioctl_meteor.h &&
  1535. check_header dev/bktr/ioctl_bt848.h; } ||
  1536. { check_header machine/ioctl_meteor.h &&
  1537. check_header machine/ioctl_bt848.h; } ||
  1538. { check_header dev/video/meteor/ioctl_meteor.h &&
  1539. check_header dev/video/bktr/ioctl_bt848.h; } ||
  1540. check_header dev/ic/bt8xx.h ||
  1541. disable bktr
  1542. fi
  1543. check_header sys/soundcard.h
  1544. check_header soundcard.h
  1545. # Deal with the x11 frame grabber
  1546. enabled x11grab &&
  1547. enabled gpl &&
  1548. enabled x11_grab_device_demuxer &&
  1549. check_header X11/Xlib.h &&
  1550. check_header X11/extensions/XShm.h &&
  1551. check_func XOpenDisplay -lX11 &&
  1552. check_func XShmCreateImage -lX11 -lXext &&
  1553. add_extralibs -lX11 -lXext ||
  1554. disable x11_grab_device_demuxer
  1555. enabled debug && add_cflags -g
  1556. # add some useful compiler flags if supported
  1557. check_cflags -Wdeclaration-after-statement
  1558. check_cflags -Wall
  1559. check_cflags -Wno-switch
  1560. check_cflags -Wdisabled-optimization
  1561. check_cflags -Wpointer-arith
  1562. check_cflags -Wredundant-decls
  1563. check_cflags -Wno-pointer-sign
  1564. enabled extra_warnings && check_cflags -Winline
  1565. # add some linker flags
  1566. check_ldflags -Wl,--warn-common
  1567. check_ldflags $LDLATEFLAGS
  1568. if enabled small; then
  1569. check_cflags -Os # not all compilers support -Os
  1570. optimize="small"
  1571. elif enabled optimize; then
  1572. if test -n "`$cc -v 2>&1 | grep xlc`"; then
  1573. add_cflags "-O5"
  1574. add_ldflags "-O5"
  1575. else
  1576. add_cflags "-O3"
  1577. fi
  1578. fi
  1579. # PIC flags for shared library objects where they are needed
  1580. if enabled shared; then
  1581. # LIBOBJFLAGS may have already been set in the OS configuration
  1582. if test -z "$LIBOBJFLAGS" ; then
  1583. case "$arch" in
  1584. x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS="\$(PIC)" ;;
  1585. esac
  1586. fi
  1587. fi
  1588. if enabled gprof; then
  1589. add_cflags "-p"
  1590. add_ldflags "-p"
  1591. fi
  1592. VHOOKCFLAGS="-fPIC"
  1593. # find if .align arg is power-of-two or not
  1594. if test $asmalign_pot = "unknown"; then
  1595. asmalign_pot="no"
  1596. echo 'asm (".align 3");' | check_cc && asmalign_pot="yes"
  1597. fi
  1598. enabled_any $ENCODER_LIST && enable encoders
  1599. enabled_any $DECODER_LIST && enable decoders
  1600. enabled_any $MUXER_LIST && enable muxers
  1601. enabled_any $DEMUXER_LIST && enable demuxers
  1602. enabled_any $PROTOCOL_LIST && enable protocols
  1603. enabled_any $BSF_LIST && enable bsfs
  1604. enabled_any $THREADS_LIST && enable threads
  1605. check_deps $CONFIG_LIST $HAVE_LIST $DECODER_LIST $ENCODER_LIST $PARSER_LIST \
  1606. $BSF_LIST $DEMUXER_LIST $MUXER_LIST $PROTOCOL_LIST
  1607. enabled libdc1394 && append pkg_requires "libraw1394"
  1608. enabled libogg && append pkg_requires "ogg >= 1.1"
  1609. enabled libtheora && append pkg_requires "theora"
  1610. enabled libvorbis && append pkg_requires "vorbis vorbisenc"
  1611. echo "install prefix $PREFIX"
  1612. echo "source path $source_path"
  1613. echo "C compiler $cc"
  1614. echo "make $make"
  1615. echo ".align is power-of-two $asmalign_pot"
  1616. echo "ARCH $arch ($cpu)"
  1617. if test "$BUILDSUF" != ""; then
  1618. echo "build suffix $BUILDSUF"
  1619. fi
  1620. echo "big-endian ${bigendian-no}"
  1621. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1622. echo "MMX enabled ${mmx-no}"
  1623. echo "CMOV enabled ${cmov-no}"
  1624. echo "CMOV is fast ${fast_cmov-no}"
  1625. echo "EBX available ${ebx_available-no}"
  1626. echo "EBP available ${ebp_available-no}"
  1627. fi
  1628. if test $arch = "armv4l"; then
  1629. echo "ARMv5TE enabled ${armv5te-no}"
  1630. echo "ARMv6 enabled ${armv6-no}"
  1631. echo "IWMMXT enabled ${iwmmxt-no}"
  1632. fi
  1633. if test $arch = "mips"; then
  1634. echo "MMI enabled ${mmi-no}"
  1635. fi
  1636. if test $arch = "powerpc"; then
  1637. echo "AltiVec enabled ${altivec-no}"
  1638. echo "dcbzl available ${dcbzl-no}"
  1639. fi
  1640. echo "gprof enabled ${gprof-no}"
  1641. echo "debug symbols ${debug-no}"
  1642. echo "strip symbols ${dostrip-no}"
  1643. echo "optimize ${optimize-no}"
  1644. echo "static ${static-no}"
  1645. echo "shared ${shared-no}"
  1646. echo "postprocessing support ${pp-no}"
  1647. echo "software scaler enabled ${swscaler-no}"
  1648. echo "video hooking ${vhook-no}"
  1649. if enabled vhook; then
  1650. echo "Imlib2 support ${imlib2-no}"
  1651. echo "FreeType support ${freetype2-no}"
  1652. fi
  1653. echo "network support ${network-no}"
  1654. if enabled network; then
  1655. echo "IPv6 support ${ipv6-no}"
  1656. fi
  1657. echo "threading support ${thread_type-no}"
  1658. echo "SDL support ${sdl-no}"
  1659. if enabled sdl_too_old; then
  1660. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  1661. fi
  1662. echo "Sun medialib support ${mlib-no}"
  1663. echo "AVISynth enabled ${avisynth-no}"
  1664. echo "liba52 support ${liba52-no}"
  1665. echo "liba52 dlopened ${liba52bin-no}"
  1666. echo "libamr-nb support ${libamr_nb-no}"
  1667. echo "libamr-wb support ${libamr_wb-no}"
  1668. echo "libdc1394 support ${libdc1394-no}"
  1669. echo "libfaac enabled ${libfaac-no}"
  1670. echo "libfaad enabled ${libfaad-no}"
  1671. echo "libfaad dlopened ${libfaadbin-no}"
  1672. echo "libgsm enabled ${libgsm-no}"
  1673. echo "libmp3lame enabled ${libmp3lame-no}"
  1674. echo "libnut enabled ${libnut-no}"
  1675. echo "libogg enabled ${libogg-no}"
  1676. echo "libtheora enabled ${libtheora-no}"
  1677. echo "libvorbis enabled ${libvorbis-no}"
  1678. echo "x264 enabled ${libx264-no}"
  1679. echo "XviD enabled ${libxvid-no}"
  1680. echo "zlib enabled ${zlib-no}"
  1681. if ! enabled gpl; then
  1682. echo "License: LGPL"
  1683. else
  1684. echo "License: GPL"
  1685. fi
  1686. echo "Creating config.mak and config.h..."
  1687. echo "# Automatically generated by configure - do not modify!" > config.mak
  1688. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  1689. echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
  1690. echo "PREFIX=$PREFIX" >> config.mak
  1691. echo "prefix=\$(DESTDIR)\$(PREFIX)" >> config.mak
  1692. echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
  1693. echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
  1694. echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
  1695. echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
  1696. echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
  1697. echo "MAKE=$make" >> config.mak
  1698. echo "CC=$cc" >> config.mak
  1699. echo "AR=$ar" >> config.mak
  1700. echo "RANLIB=$ranlib" >> config.mak
  1701. echo "LN_S=$ln_s" >> config.mak
  1702. if enabled dostrip; then
  1703. echo "STRIP=$strip" >> config.mak
  1704. else
  1705. echo "STRIP=echo ignoring strip" >> config.mak
  1706. fi
  1707. echo "OPTFLAGS=$CFLAGS" >> config.mak
  1708. echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
  1709. echo "LDFLAGS=$LDFLAGS" >> config.mak
  1710. echo "LDCONFIG=$LDCONFIG" >> config.mak
  1711. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  1712. echo "SHFLAGS=$SHFLAGS" >> config.mak
  1713. echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
  1714. echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
  1715. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  1716. echo "BUILD_STATIC=$static" >> config.mak
  1717. echo "BUILDSUF=$BUILDSUF" >> config.mak
  1718. echo "LIBPREF=$LIBPREF" >> config.mak
  1719. echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
  1720. echo "LIB=$LIB" >> config.mak
  1721. echo "SLIBPREF=$SLIBPREF" >> config.mak
  1722. echo "SLIBSUF=\${BUILDSUF}$SLIBSUF" >> config.mak
  1723. echo "EXESUF=\${BUILDSUF}$EXESUF" >> config.mak
  1724. if enabled bigendian; then
  1725. echo "WORDS_BIGENDIAN=yes" >> config.mak
  1726. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  1727. fi
  1728. if enabled mmx; then
  1729. echo "#define __CPU__ 586" >> $TMPH
  1730. fi
  1731. if enabled sdl; then
  1732. echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
  1733. echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
  1734. fi
  1735. if enabled texi2html; then
  1736. echo "BUILD_DOC=yes" >> config.mak
  1737. fi
  1738. sws_version=`grep '#define LIBSWSCALE_VERSION ' "$source_path/libswscale/swscale.h" | sed 's/[^0-9\.]//g'`
  1739. pp_version=`grep '#define LIBPOSTPROC_VERSION ' "$source_path/libpostproc/postprocess.h" | sed 's/[^0-9\.]//g'`
  1740. lavc_version=`grep '#define LIBAVCODEC_VERSION ' "$source_path/libavcodec/avcodec.h" | sed 's/[^0-9\.]//g'`
  1741. lavf_version=`grep '#define LIBAVFORMAT_VERSION ' "$source_path/libavformat/avformat.h" | sed 's/[^0-9\.]//g'`
  1742. lavu_version=`grep '#define LIBAVUTIL_VERSION ' "$source_path/libavutil/avutil.h" | sed 's/[^0-9\.]//g'`
  1743. if enabled shared; then
  1744. echo "BUILD_SHARED=yes" >> config.mak
  1745. echo "PIC=-fPIC -DPIC" >> config.mak
  1746. echo "SPPMAJOR=${pp_version%%.*}" >> config.mak
  1747. echo "SPPVERSION=$pp_version" >> config.mak
  1748. echo "LAVCMAJOR=${lavc_version%%.*}" >> config.mak
  1749. echo "LAVCVERSION=$lavc_version" >> config.mak
  1750. echo "LAVFMAJOR=${lavf_version%%.*}" >> config.mak
  1751. echo "LAVFVERSION=$lavf_version" >> config.mak
  1752. echo "LAVUMAJOR=${lavu_version%%.*}" >> config.mak
  1753. echo "LAVUVERSION=$lavu_version" >> config.mak
  1754. echo "SWSMAJOR=${sws_version%%.*}" >> config.mak
  1755. echo "SWSVERSION=$sws_version" >> config.mak
  1756. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  1757. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  1758. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  1759. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  1760. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  1761. fi
  1762. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  1763. echo "EXTRALIBS=$extralibs" >> config.mak
  1764. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  1765. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  1766. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  1767. $DECODER_LIST \
  1768. $ENCODER_LIST \
  1769. $PARSER_LIST \
  1770. $BSF_LIST \
  1771. $DEMUXER_LIST \
  1772. $MUXER_LIST \
  1773. $PROTOCOL_LIST \
  1774. echo "#define restrict $_restrict" >> $TMPH
  1775. if enabled small; then
  1776. echo "#define av_always_inline" >> $TMPH
  1777. fi
  1778. echo "SRC_PATH=\"$source_path\"" >> config.mak
  1779. echo "SRC_PATH_BARE=$source_path" >> config.mak
  1780. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  1781. # Apparently it's not possible to portably echo a backslash.
  1782. if enabled asmalign_pot; then
  1783. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH
  1784. else
  1785. printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
  1786. fi
  1787. # Do not overwrite config.h if unchanged to avoid superfluous rebuilds.
  1788. if ! cmp -s $TMPH config.h; then
  1789. mv -f $TMPH config.h
  1790. else
  1791. echo "config.h is unchanged"
  1792. fi
  1793. rm -f $TMPO $TMPC $TMPE $TMPS $TMPH
  1794. # build tree in object directory if source path is different from current one
  1795. if enabled source_path_used; then
  1796. DIRS="\
  1797. doc \
  1798. libavcodec \
  1799. libavcodec/alpha \
  1800. libavcodec/armv4l \
  1801. libavcodec/bfin \
  1802. libavcodec/i386 \
  1803. libavcodec/mlib \
  1804. libavcodec/ppc \
  1805. libavcodec/sh4 \
  1806. libavcodec/sparc \
  1807. libavformat \
  1808. libavutil \
  1809. libpostproc \
  1810. libswscale \
  1811. tests \
  1812. tools \
  1813. vhook \
  1814. "
  1815. FILES="\
  1816. Makefile \
  1817. common.mak \
  1818. doc/texi2pod.pl \
  1819. libavcodec/Makefile \
  1820. libavformat/Makefile \
  1821. libavutil/Makefile \
  1822. libpostproc/Makefile \
  1823. libswscale/Makefile \
  1824. "
  1825. for dir in $DIRS ; do
  1826. mkdir -p $dir
  1827. done
  1828. for f in $FILES ; do
  1829. $ln_s "$source_path/$f" $f
  1830. done
  1831. fi
  1832. # build pkg-config files
  1833. # FIXME: libdir and includedir are hardcoded and may differ from the real path.
  1834. pkgconfig_generate(){
  1835. name=$1
  1836. comment=$2
  1837. version=$3
  1838. libs=$4
  1839. requires=$5
  1840. include=$6
  1841. cat <<EOF >$name.pc
  1842. prefix=$PREFIX
  1843. exec_prefix=\${prefix}
  1844. libdir=\${exec_prefix}/lib
  1845. includedir=\${prefix}/include
  1846. Name: $name
  1847. Description: $comment
  1848. Version: $version
  1849. Requires: $requires
  1850. Conflicts:
  1851. Libs: -L\${libdir} $libs
  1852. Cflags: -I\${includedir} -I\${includedir}/$include
  1853. EOF
  1854. }
  1855. pkgconfig_generate_uninstalled(){
  1856. name=$1
  1857. shortname=${name#lib}
  1858. comment=$2
  1859. version=$3
  1860. libs=$4
  1861. requires=$5
  1862. cat <<EOF >$name-uninstalled.pc
  1863. prefix=
  1864. exec_prefix=
  1865. libdir=\${pcfiledir}/$name
  1866. includedir=\${pcfiledir}/$name
  1867. Name: $name
  1868. Description: $comment
  1869. Version: $version
  1870. Requires: $requires
  1871. Conflicts:
  1872. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  1873. Cflags: -I\${includedir}
  1874. EOF
  1875. }
  1876. pkgconfig_generate libavutil "FFmpeg utility library" "$lavu_version" -lavutil "" ffmpeg
  1877. pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$lavu_version"
  1878. pkgconfig_generate libavcodec "FFmpeg codec library" "$lavc_version" "-lavcodec $extralibs" "$pkg_requires libavutil = $lavu_version" ffmpeg
  1879. pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$lavc_version" "$extralibs" "$pkg_requires libavutil = $lavu_version"
  1880. pkgconfig_generate libavformat "FFmpeg container format library" "$lavf_version" "-lavformat $extralibs" "$pkg_requires libavcodec = $lavc_version" ffmpeg
  1881. pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$lavf_version" "$extralibs" "$pkg_requires libavcodec = $lavc_version"
  1882. if enabled pp; then
  1883. pkgconfig_generate libpostproc "FFmpeg post processing library" "$pp_version" -lpostproc "" postproc
  1884. pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$pp_version"
  1885. fi
  1886. if enabled swscaler; then
  1887. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" -lswscale "libavutil = $lavu_version" ffmpeg
  1888. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "libavutil = $lavu_version"
  1889. else
  1890. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version" ffmpeg
  1891. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$sws_version" "" "$pkg_requires libavcodec = $lavc_version"
  1892. apply libswscale.pc sed s/^Libs:.*$/Libs:/
  1893. apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
  1894. fi