You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2102 lines
57KB

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