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.

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