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.

2081 lines
56KB

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