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.

2589 lines
75KB

  1. #!/bin/sh
  2. #
  3. # FFmpeg configure script
  4. #
  5. # Copyright (c) 2000-2002 Fabrice Bellard
  6. # Copyright (c) 2005-2008 Diego Biurrun
  7. # Copyright (c) 2005-2008 Mans Rullgard
  8. #
  9. # Prevent locale nonsense from breaking basic text processing.
  10. LC_ALL=C
  11. export LC_ALL
  12. # make sure we are running under a compatible shell
  13. # try to make this part work with most shells
  14. try_exec(){
  15. echo "Trying shell $1"
  16. type "$1" > /dev/null 2>&1 && exec "$@"
  17. }
  18. unset foo
  19. (: ${foo%%bar}) 2> /dev/null
  20. E1="$?"
  21. (: ${foo?}) 2> /dev/null
  22. E2="$?"
  23. if test "$E1" != 0 || test "$E2" = 0; then
  24. echo "Broken shell detected. Trying alternatives."
  25. export FF_CONF_EXEC
  26. if test "0$FF_CONF_EXEC" -lt 1; then
  27. FF_CONF_EXEC=1
  28. try_exec bash "$0" "$@"
  29. fi
  30. if test "0$FF_CONF_EXEC" -lt 2; then
  31. FF_CONF_EXEC=2
  32. try_exec ksh "$0" "$@"
  33. fi
  34. if test "0$FF_CONF_EXEC" -lt 3; then
  35. FF_CONF_EXEC=3
  36. try_exec /usr/xpg4/bin/sh "$0" "$@"
  37. fi
  38. echo "No compatible shell script interpreter found."
  39. echo "This configure script requires a POSIX-compatible shell"
  40. echo "such as bash or ksh."
  41. echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
  42. echo "Instead, install a working POSIX-compatible shell."
  43. echo "Disabling this configure test will create a broken FFmpeg."
  44. if test "$BASH_VERSION" = '2.04.0(1)-release'; then
  45. echo "This bash version ($BASH_VERSION) is broken on your platform."
  46. echo "Upgrade to a later version if available."
  47. fi
  48. exit 1
  49. fi
  50. show_help(){
  51. echo "Usage: configure [options]"
  52. echo "Options: [defaults in brackets after descriptions]"
  53. echo
  54. echo "Standard options:"
  55. echo " --help print this message"
  56. echo " --logfile=FILE log tests and output to FILE [config.err]"
  57. echo " --disable-logging do not log configure debug information"
  58. echo " --prefix=PREFIX install in PREFIX [$prefix]"
  59. echo " --bindir=DIR install binaries in DIR [PREFIX/bin]"
  60. echo " --datadir=DIR install data files in DIR [PREFIX/share/ffmpeg]"
  61. echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
  62. echo " --shlibdir=DIR install shared libs in DIR [PREFIX/lib]"
  63. echo " --incdir=DIR install includes in DIR [PREFIX/include]"
  64. echo " --mandir=DIR install man page in DIR [PREFIX/share/man]"
  65. echo
  66. echo "Configuration options:"
  67. echo " --disable-static do not build static libraries [no]"
  68. echo " --enable-shared build shared libraries [no]"
  69. echo " --enable-gpl allow use of GPL code, the resulting libs"
  70. echo " and binaries will be under GPL [no]"
  71. echo " --enable-nonfree allow use of nonfree code, the resulting libs"
  72. echo " and binaries will be unredistributable [no]"
  73. echo " --disable-ffmpeg disable ffmpeg build"
  74. echo " --disable-ffplay disable ffplay build"
  75. echo " --disable-ffserver disable ffserver build"
  76. echo " --enable-postproc enable GPLed postprocessing support [no]"
  77. echo " --enable-swscale enable GPLed software scaler support [no]"
  78. echo " --enable-avfilter video filter support (replaces vhook) [no]"
  79. echo " --enable-avfilter-lavf video filters dependent on avformat [no]"
  80. echo " --disable-vhook disable video hooking support"
  81. echo " --enable-beosthreads use BeOS threads [no]"
  82. echo " --enable-os2threads use OS/2 threads [no]"
  83. echo " --enable-pthreads use pthreads [no]"
  84. echo " --enable-w32threads use Win32 threads [no]"
  85. echo " --enable-x11grab enable X11 grabbing [no]"
  86. echo " --enable-vdpau enable VDPAU support [no]"
  87. echo " --disable-network disable network support [no]"
  88. echo " --disable-ipv6 disable IPv6 support [no]"
  89. echo " --disable-mpegaudio-hp faster (but less accurate) MPEG audio decoding [no]"
  90. echo " --enable-gray enable full grayscale support (slower color)"
  91. echo " --enable-fastdiv enable table-based division"
  92. echo " --enable-small optimize for size instead of speed"
  93. echo " --disable-aandct disable AAN DCT code"
  94. echo " --disable-fft disable FFT code"
  95. echo " --disable-golomb disable Golomb code"
  96. echo " --disable-mdct disable MDCT code"
  97. echo " --disable-rdft disable RDFT code"
  98. echo " --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
  99. echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
  100. echo " --enable-beos-netserver enable BeOS netserver"
  101. echo " --disable-encoder=NAME disable encoder NAME"
  102. echo " --enable-encoder=NAME enable encoder NAME"
  103. echo " --disable-encoders disable all encoders"
  104. echo " --disable-decoder=NAME disable decoder NAME"
  105. echo " --enable-decoder=NAME enable decoder NAME"
  106. echo " --disable-decoders disable all decoders"
  107. echo " --disable-muxer=NAME disable muxer NAME"
  108. echo " --enable-muxer=NAME enable muxer NAME"
  109. echo " --disable-muxers disable all muxers"
  110. echo " --disable-demuxer=NAME disable demuxer NAME"
  111. echo " --enable-demuxer=NAME enable demuxer NAME"
  112. echo " --disable-demuxers disable all demuxers"
  113. echo " --enable-parser=NAME enable parser NAME"
  114. echo " --disable-parser=NAME disable parser NAME"
  115. echo " --disable-parsers disable all parsers"
  116. echo " --enable-bsf=NAME enable bitstream filter NAME"
  117. echo " --disable-bsf=NAME disable bitstream filter NAME"
  118. echo " --disable-bsfs disable all bitstream filters"
  119. echo " --enable-protocol=NAME enable protocol NAME"
  120. echo " --disable-protocol=NAME disable protocol NAME"
  121. echo " --disable-protocols disable all protocols"
  122. echo " --disable-indevs disable input devices"
  123. echo " --disable-outdevs disable output devices"
  124. echo " --disable-devices disable all devices"
  125. echo " --enable-filter=NAME enable filter NAME"
  126. echo " --disable-filter=NAME disable filter NAME"
  127. echo " --disable-filters disable all filters"
  128. echo " --list-decoders show all available decoders"
  129. echo " --list-encoders show all available encoders"
  130. echo " --list-muxers show all available muxers"
  131. echo " --list-demuxers show all available demuxers"
  132. echo " --list-parsers show all available parsers"
  133. echo " --list-protocols show all available protocols"
  134. echo " --list-bsfs show all available bitstream filters"
  135. echo " --list-indevs show all available input devices"
  136. echo " --list-outdevs show all available output devices"
  137. echo " --list-filters show all available filters"
  138. echo
  139. echo "External library support:"
  140. echo " --enable-avisynth enable reading of AVISynth script files [no]"
  141. echo " --enable-bzlib enable bzlib [autodetect]"
  142. echo " --enable-libamr-nb enable libamr-nb floating point audio codec [no]"
  143. echo " --enable-libamr-wb enable libamr-wb floating point audio codec [no]"
  144. echo " --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394"
  145. echo " and libraw1394 [no]"
  146. echo " --enable-libdirac enable Dirac support via libdirac [no]"
  147. echo " --enable-libfaac enable FAAC support via libfaac [no]"
  148. echo " --enable-libfaad enable FAAD support via libfaad [no]"
  149. echo " --enable-libfaadbin open libfaad.so.0 at runtime [no]"
  150. echo " --enable-libgsm enable GSM support via libgsm [no]"
  151. echo " --enable-libmp3lame enable MP3 encoding via libmp3lame [no]"
  152. echo " --enable-libnut enable NUT (de)muxing via libnut,"
  153. echo " native (de)muxer exists [no]"
  154. echo " --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no]"
  155. echo " --enable-libschroedinger enable Dirac support via libschroedinger [no]"
  156. echo " --enable-libspeex enable Speex decoding via libspeex [no]"
  157. echo " --enable-libtheora enable Theora encoding via libtheora [no]"
  158. echo " --enable-libvorbis enable Vorbis encoding via libvorbis,"
  159. echo " native implementation exists [no]"
  160. echo " --enable-libx264 enable H.264 encoding via x264 [no]"
  161. echo " --enable-libxvid enable Xvid encoding via xvidcore,"
  162. echo " native MPEG-4/Xvid encoder exists [no]"
  163. echo " --enable-mlib enable Sun medialib [no]"
  164. echo " --enable-zlib enable zlib [autodetect]"
  165. echo ""
  166. echo "Advanced options (experts only):"
  167. echo " --source-path=PATH path to source code [$source_path]"
  168. echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
  169. echo " --enable-cross-compile assume a cross-compiler is used"
  170. echo " --sysroot=PATH root of cross-build tree"
  171. echo " --sysinclude=PATH location of cross-build system headers"
  172. echo " --target-os=OS compiler targets OS [$target_os]"
  173. echo " --target-exec=CMD command to run executables on target"
  174. echo " --target-path=DIR path to view of build directory on target"
  175. echo " --nm=NM use nm tool"
  176. echo " --cc=CC use C compiler CC [$cc_default]"
  177. echo " --host-cc=HOSTCC use host C compiler HOSTCC"
  178. echo " --host-cflags=HCFLAGS use HCFLAGS when compiling for host"
  179. echo " --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host"
  180. echo " --host-libs=HLIBS use libs HLIBS when linking for host"
  181. echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
  182. echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
  183. echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
  184. echo " --extra-version=STRING version string suffix []"
  185. echo " --build-suffix=SUFFIX library name suffix []"
  186. echo " --arch=ARCH select architecture [$arch]"
  187. echo " --cpu=CPU select the minimum required CPU (affects"
  188. echo " instruction selection, may crash on older CPUs)"
  189. echo " --enable-powerpc-perf enable performance report on PPC"
  190. echo " (requires enabling PMC)"
  191. echo " --disable-altivec disable AltiVec optimizations"
  192. echo " --disable-amd3dnow disable 3DNow! optimizations"
  193. echo " --disable-amd3dnowext disable 3DNow! extended optimizations"
  194. echo " --disable-mmx disable MMX optimizations"
  195. echo " --disable-mmx2 disable MMX2 optimizations"
  196. echo " --disable-sse disable SSE optimizations"
  197. echo " --disable-ssse3 disable SSSE3 optimizations"
  198. echo " --disable-armv5te disable armv5te optimizations"
  199. echo " --disable-armv6 disable armv6 optimizations"
  200. echo " --disable-armv6t2 disable armv6t2 optimizations"
  201. echo " --disable-armvfp disable ARM VFP optimizations"
  202. echo " --disable-iwmmxt disable iwmmxt optimizations"
  203. echo " --disable-mmi disable MMI optimizations"
  204. echo " --disable-neon disable neon optimizations"
  205. echo " --disable-vis disable VIS optimizations"
  206. echo " --disable-yasm disable use of yasm assembler"
  207. echo
  208. echo "Developer options (useful when working on FFmpeg itself):"
  209. echo " --disable-debug disable debugging symbols"
  210. echo " --enable-debug=LEVEL set the debug level [$debuglevel]"
  211. echo " --enable-gprof enable profiling with gprof [$gprof]"
  212. echo " --disable-optimizations disable compiler optimizations"
  213. echo " --enable-extra-warnings enable more compiler warnings"
  214. echo " --disable-stripping disable stripping of executables and shared libraries"
  215. echo ""
  216. echo "NOTE: Object files are built at the place where configure is launched."
  217. exit 0
  218. }
  219. log(){
  220. echo "$@" >> $logfile
  221. }
  222. log_file(){
  223. log BEGIN $1
  224. pr -n -t $1 >> $logfile
  225. log END $1
  226. }
  227. echolog(){
  228. log "$@"
  229. echo "$@"
  230. }
  231. die(){
  232. echolog "$@"
  233. cat <<EOF
  234. If you think configure made a mistake, make sure you are using the latest
  235. version from SVN. If the latest version fails, report the problem to the
  236. ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
  237. EOF
  238. if disabled logging; then
  239. cat <<EOF
  240. Rerun configure with logging enabled (do not use --disable-logging), and
  241. include the log this produces with your report.
  242. EOF
  243. else
  244. cat <<EOF
  245. Include the log file "$logfile" produced by configure as this will help
  246. solving the problem.
  247. EOF
  248. fi
  249. rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
  250. exit 1
  251. }
  252. # Avoid locale weirdness, besides we really just want to translate ASCII.
  253. toupper(){
  254. echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  255. }
  256. tolower(){
  257. echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
  258. }
  259. c_escape(){
  260. echo "$*" | sed 's/["\\]/\\\0/g'
  261. }
  262. set_all(){
  263. value=$1
  264. shift
  265. for var in $*; do
  266. eval $var=$value
  267. done
  268. }
  269. set_weak(){
  270. value=$1
  271. shift
  272. for var; do
  273. eval : \${$var:=$value}
  274. done
  275. }
  276. pushvar(){
  277. for var in $*; do
  278. eval level=\${${var}_level:=0}
  279. eval ${var}_${level}="\$$var"
  280. eval ${var}_level=$(($level+1))
  281. done
  282. }
  283. popvar(){
  284. for var in $*; do
  285. eval level=\${${var}_level:-0}
  286. test $level = 0 && continue
  287. eval level=$(($level-1))
  288. eval $var="\${${var}_${level}}"
  289. eval ${var}_level=$level
  290. eval unset ${var}_${level}
  291. done
  292. }
  293. enable(){
  294. set_all yes $*
  295. }
  296. disable(){
  297. set_all no $*
  298. }
  299. enable_weak(){
  300. set_weak yes $*
  301. }
  302. disable_weak(){
  303. set_weak no $*
  304. }
  305. enable_safe(){
  306. enable $(echo "$*" | sed 's/[^A-Za-z0-9_ ]/_/g')
  307. }
  308. disable_safe(){
  309. disable $(echo "$*" | sed 's/[^A-Za-z0-9_ ]/_/g')
  310. }
  311. do_enable_deep(){
  312. for var; do
  313. enabled $var && continue
  314. eval sel="\$${var}_select"
  315. eval sgs="\$${var}_suggest"
  316. pushvar var sgs
  317. enable_deep $sel
  318. popvar sgs
  319. enable_deep_weak $sgs
  320. popvar var
  321. done
  322. }
  323. enable_deep(){
  324. do_enable_deep $*
  325. enable $*
  326. }
  327. enable_deep_weak(){
  328. do_enable_deep $*
  329. enable_weak $*
  330. }
  331. enabled(){
  332. test "${1#!}" = "$1" && op== || op=!=
  333. eval test "x\$${1#!}" $op "xyes"
  334. }
  335. disabled(){
  336. test "${1#!}" = "$1" && op== || op=!=
  337. eval test "x\$${1#!}" $op "xno"
  338. }
  339. enabled_all(){
  340. for opt; do
  341. enabled $opt || return 1
  342. done
  343. }
  344. disabled_all(){
  345. for opt; do
  346. disabled $opt || return 1
  347. done
  348. }
  349. enabled_any(){
  350. for opt; do
  351. enabled $opt && return 0
  352. done
  353. }
  354. disabled_any(){
  355. for opt; do
  356. disabled $opt && return 0
  357. done
  358. return 1
  359. }
  360. set_default(){
  361. for opt; do
  362. eval : \${$opt:=\$${opt}_default}
  363. done
  364. }
  365. is_in(){
  366. value=$1
  367. shift
  368. for var in $*; do
  369. [ $var = $value ] && return 0
  370. done
  371. return 1
  372. }
  373. check_deps(){
  374. for cfg; do
  375. cfg="${cfg#!}"
  376. enabled ${cfg}_checking && die "Circular dependency for $cfg."
  377. disabled ${cfg}_checking && continue
  378. enable ${cfg}_checking
  379. eval dep_all="\$${cfg}_deps"
  380. eval dep_any="\$${cfg}_deps_any"
  381. eval dep_sel="\$${cfg}_select"
  382. eval dep_sgs="\$${cfg}_suggest"
  383. pushvar cfg dep_all dep_any dep_sel dep_sgs
  384. check_deps $dep_all $dep_any $dep_sel $dep_sgs
  385. popvar cfg dep_all dep_any dep_sel dep_sgs
  386. enabled_all $dep_all || disable $cfg
  387. enabled_any $dep_any || disable $cfg
  388. disabled_any $dep_sel && disable $cfg
  389. if enabled $cfg; then
  390. eval dep_extralibs="\$${cfg}_extralibs"
  391. test -n "$dep_extralibs" && add_extralibs $dep_extralibs
  392. enable_deep $dep_sel
  393. enable_deep_weak $dep_sgs
  394. fi
  395. disable ${cfg}_checking
  396. done
  397. }
  398. print_config(){
  399. pfx=$1
  400. header=$2
  401. makefile=$3
  402. shift 3
  403. for cfg; do
  404. ucname="`toupper $cfg`"
  405. if enabled $cfg; then
  406. echo "#define ${pfx}${ucname} 1" >> $header
  407. echo "${pfx}${ucname}=yes" >> $makefile
  408. else
  409. echo "#define ${pfx}${ucname} 0" >> $header
  410. fi
  411. done
  412. }
  413. flags_saved(){
  414. (: ${SAVE_CFLAGS?}) 2> /dev/null
  415. }
  416. save_flags(){
  417. flags_saved && return
  418. SAVE_CFLAGS="$CFLAGS"
  419. SAVE_LDFLAGS="$LDFLAGS"
  420. SAVE_extralibs="$extralibs"
  421. }
  422. restore_flags(){
  423. flags_saved || return
  424. CFLAGS="$SAVE_CFLAGS"
  425. LDFLAGS="$SAVE_LDFLAGS"
  426. extralibs="$SAVE_extralibs"
  427. unset SAVE_CFLAGS
  428. unset SAVE_LDFLAGS
  429. unset SAVE_extralibs
  430. }
  431. temp_cflags(){
  432. save_flags
  433. CFLAGS="$CFLAGS $*"
  434. }
  435. temp_ldflags(){
  436. save_flags
  437. LDFLAGS="$LDFLAGS $*"
  438. }
  439. temp_extralibs(){
  440. save_flags
  441. extralibs="$extralibs $*"
  442. }
  443. append(){
  444. var=$1
  445. shift
  446. flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
  447. eval "$var=\"\$$var $*\""
  448. }
  449. add_cflags(){
  450. append CFLAGS "$@"
  451. }
  452. add_ldflags(){
  453. append LDFLAGS "$@"
  454. }
  455. add_extralibs(){
  456. append extralibs "$@"
  457. }
  458. check_cmd(){
  459. log "$@"
  460. "$@" >> $logfile 2>&1
  461. }
  462. check_cc(){
  463. log check_cc "$@"
  464. cat > $TMPC
  465. log_file $TMPC
  466. check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
  467. }
  468. check_cpp(){
  469. log check_cpp "$@"
  470. cat > $TMPC
  471. log_file $TMPC
  472. check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
  473. }
  474. check_asm(){
  475. log check_asm "$@"
  476. name="$1"
  477. asm="$2"
  478. shift 2
  479. check_cc "$@" <<EOF && enable $name || disable $name
  480. void foo(void){ __asm__ volatile($asm); }
  481. EOF
  482. }
  483. check_yasm(){
  484. log check_yasm "$@"
  485. echo "$1" > $TMPS
  486. log_file $TMPS
  487. shift 1
  488. check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
  489. }
  490. check_ld(){
  491. log check_ld "$@"
  492. check_cc || return
  493. flags=''
  494. libs=''
  495. for f; do
  496. test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
  497. done
  498. check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
  499. }
  500. check_cflags(){
  501. log check_cflags "$@"
  502. check_cc "$@" <<EOF && add_cflags "$@"
  503. int x;
  504. EOF
  505. }
  506. check_ldflags(){
  507. log check_ldflags "$@"
  508. check_ld "$@" <<EOF && add_ldflags "$@"
  509. int main(void){ return 0; }
  510. EOF
  511. }
  512. check_header(){
  513. log check_header "$@"
  514. header=$1
  515. shift
  516. disable_safe $header
  517. check_cpp "$@" <<EOF && enable_safe $header
  518. #include <$header>
  519. int x;
  520. EOF
  521. }
  522. check_func(){
  523. log check_func "$@"
  524. func=$1
  525. shift
  526. disable $func
  527. check_ld "$@" <<EOF && enable $func
  528. extern int $func();
  529. int main(void){ $func(); }
  530. EOF
  531. }
  532. check_func_headers(){
  533. log check_func_headers "$@"
  534. headers=$1
  535. func=$2
  536. shift 2
  537. disable $func
  538. incs=""
  539. for hdr in $headers; do
  540. incs="$incs
  541. #include <$hdr>"
  542. done
  543. check_ld "$@" <<EOF && enable $func && enable_safe $headers
  544. $incs
  545. int main(int argc, char **argv){
  546. (void) $func;
  547. return 0;
  548. }
  549. EOF
  550. }
  551. check_cpp_condition(){
  552. log check_cpp_condition "$@"
  553. header=$1
  554. condition=$2
  555. check_cpp <<EOF
  556. #include <$header>
  557. #if !($condition)
  558. #error "unsatisfied condition: $condition"
  559. #endif
  560. EOF
  561. }
  562. check_lib(){
  563. log check_lib "$@"
  564. header="$1"
  565. func="$2"
  566. shift 2
  567. temp_extralibs "$@"
  568. check_header $header && check_func $func && add_extralibs "$@"
  569. err=$?
  570. restore_flags
  571. return $err
  572. }
  573. check_lib2(){
  574. log check_lib2 "$@"
  575. headers="$1"
  576. func="$2"
  577. shift 2
  578. temp_extralibs "$@"
  579. check_func_headers "$headers" $func && add_extralibs "$@"
  580. err=$?
  581. restore_flags
  582. return $err
  583. }
  584. check_exec(){
  585. check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
  586. }
  587. check_exec_crash(){
  588. code=`cat`
  589. # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
  590. # are safe but may not be available everywhere. Thus we use
  591. # raise(SIGTERM) instead. The check is run in a subshell so we
  592. # can redirect the "Terminated" message from the shell. SIGBUS
  593. # is not defined by standard C so it is used conditionally.
  594. (check_exec "$@") >> $logfile 2>&1 <<EOF
  595. #include <signal.h>
  596. static void sighandler(int sig){
  597. raise(SIGTERM);
  598. }
  599. int main(void){
  600. signal(SIGILL, sighandler);
  601. signal(SIGFPE, sighandler);
  602. signal(SIGSEGV, sighandler);
  603. #ifdef SIGBUS
  604. signal(SIGBUS, sighandler);
  605. #endif
  606. { $code }
  607. }
  608. EOF
  609. }
  610. check_type(){
  611. log check_type "$@"
  612. headers=$1
  613. type=$2
  614. shift 2
  615. disable $type
  616. incs=""
  617. for hdr in $headers; do
  618. incs="$incs
  619. #include <$hdr>"
  620. done
  621. check_cc "$@" <<EOF && enable $type
  622. $incs
  623. $type v;
  624. EOF
  625. }
  626. require(){
  627. name="$1"
  628. header="$2"
  629. func="$3"
  630. shift 3
  631. check_lib $header $func "$@" || die "ERROR: $name not found"
  632. }
  633. require2(){
  634. name="$1"
  635. headers="$2"
  636. func="$3"
  637. shift 3
  638. check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
  639. }
  640. check_foo_config(){
  641. cfg=$1
  642. pkg=$2
  643. header=$3
  644. func=$4
  645. shift 4
  646. disable $cfg
  647. check_cmd ${pkg}-config --version
  648. err=$?
  649. if test "$err" = 0; then
  650. temp_cflags `${pkg}-config --cflags`
  651. temp_extralibs `${pkg}-config --libs`
  652. check_lib "$@" $header $func && enable $cfg
  653. fi
  654. return $err
  655. }
  656. apply(){
  657. file=$1
  658. shift
  659. "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
  660. }
  661. # CONFIG_LIST contains configurable options, while HAVE_LIST is for
  662. # system-dependent things.
  663. COMPONENT_LIST="
  664. bsfs
  665. decoders
  666. demuxers
  667. encoders
  668. filters
  669. indevs
  670. muxers
  671. outdevs
  672. parsers
  673. protocols
  674. "
  675. CONFIG_LIST="
  676. $COMPONENT_LIST
  677. aandct
  678. avfilter
  679. avfilter_lavf
  680. avisynth
  681. beos_netserver
  682. bzlib
  683. fastdiv
  684. ffmpeg
  685. ffplay
  686. ffserver
  687. fft
  688. golomb
  689. gpl
  690. gprof
  691. gray
  692. hardcoded_tables
  693. ipv6
  694. libamr_nb
  695. libamr_wb
  696. libdc1394
  697. libdirac
  698. libfaac
  699. libfaad
  700. libfaadbin
  701. libgsm
  702. libmp3lame
  703. libnut
  704. libopenjpeg
  705. libschroedinger
  706. libspeex
  707. libtheora
  708. libvorbis
  709. libx264
  710. libxvid
  711. mdct
  712. memalign_hack
  713. mlib
  714. mpegaudio_hp
  715. network
  716. nonfree
  717. postproc
  718. powerpc_perf
  719. rdft
  720. shared
  721. small
  722. static
  723. swscale
  724. vdpau
  725. vhook
  726. x11grab
  727. zlib
  728. "
  729. THREADS_LIST='
  730. beosthreads
  731. os2threads
  732. pthreads
  733. w32threads
  734. '
  735. ARCH_LIST='
  736. alpha
  737. arm
  738. bfin
  739. ia64
  740. m68k
  741. mips
  742. parisc
  743. ppc
  744. s390
  745. sh4
  746. sparc
  747. sparc64
  748. x86
  749. x86_32
  750. x86_64
  751. '
  752. ARCH_EXT_LIST='
  753. altivec
  754. amd3dnow
  755. amd3dnowext
  756. armv5te
  757. armv6
  758. armv6t2
  759. armvfp
  760. iwmmxt
  761. mmi
  762. mmx
  763. mmx2
  764. neon
  765. ppc4xx
  766. sse
  767. ssse3
  768. vis
  769. '
  770. HAVE_LIST="
  771. $ARCH_EXT_LIST
  772. $THREADS_LIST
  773. alsa_asoundlib_h
  774. altivec_h
  775. arpa_inet_h
  776. bswap
  777. closesocket
  778. cmov
  779. conio_h
  780. dcbzl
  781. dev_bktr_ioctl_bt848_h
  782. dev_bktr_ioctl_meteor_h
  783. dev_ic_bt8xx_h
  784. dev_video_meteor_ioctl_meteor_h
  785. dev_video_bktr_ioctl_bt848_h
  786. dlfcn_h
  787. dlopen
  788. dos_paths
  789. ebp_available
  790. ebx_available
  791. fast_64bit
  792. fast_cmov
  793. fast_unaligned
  794. fork
  795. freetype2
  796. gethrtime
  797. GetProcessTimes
  798. getrusage
  799. imlib2
  800. inet_aton
  801. inline_asm
  802. libdc1394_1
  803. libdc1394_2
  804. llrint
  805. lrint
  806. lrintf
  807. machine_ioctl_bt848_h
  808. machine_ioctl_meteor_h
  809. malloc_h
  810. memalign
  811. mkstemp
  812. pld
  813. posix_memalign
  814. ppc64
  815. round
  816. roundf
  817. sdl
  818. sdl_video_size
  819. setmode
  820. socklen_t
  821. soundcard_h
  822. poll_h
  823. sys_mman_h
  824. sys_resource_h
  825. sys_select_h
  826. sys_soundcard_h
  827. sys_videoio_h
  828. ten_operands
  829. termios_h
  830. threads
  831. truncf
  832. winsock2_h
  833. yasm
  834. "
  835. # options emitted with CONFIG_ prefix but not available on command line
  836. CONFIG_EXTRA="
  837. oldscaler
  838. "
  839. CMDLINE_SELECT="
  840. $ARCH_EXT_LIST
  841. $CONFIG_LIST
  842. $THREADS_LIST
  843. cross_compile
  844. debug
  845. extra_warnings
  846. logging
  847. optimizations
  848. stripping
  849. yasm
  850. "
  851. PATHS_LIST='
  852. bindir
  853. datadir
  854. incdir
  855. libdir
  856. mandir
  857. prefix
  858. shlibdir
  859. '
  860. CMDLINE_SET="
  861. $PATHS_LIST
  862. arch
  863. build_suffix
  864. cc
  865. cpu
  866. cross_prefix
  867. extra_version
  868. host_cc
  869. host_cflags
  870. host_ldflags
  871. host_libs
  872. logfile
  873. nm
  874. source_path
  875. sysinclude
  876. sysroot
  877. target_exec
  878. target_os
  879. target_path
  880. "
  881. # code dependency declarations
  882. # architecture extensions
  883. altivec_deps="ppc"
  884. amd3dnow_deps="mmx"
  885. amd3dnowext_deps="amd3dnow"
  886. armv5te_deps="arm"
  887. armv6_deps="arm"
  888. armv6t2_deps="arm"
  889. armvfp_deps="arm"
  890. iwmmxt_deps="arm"
  891. mmi_deps="mips"
  892. mmx_deps="x86"
  893. mmx2_deps="mmx"
  894. neon_deps="arm"
  895. ppc4xx_deps="ppc"
  896. sse_deps="mmx"
  897. ssse3_deps="sse"
  898. vis_deps="sparc"
  899. # common features
  900. oldscaler_deps="!swscale"
  901. # decoders / encoders
  902. aac_decoder_select="fft mdct"
  903. ac3_decoder_deps="gpl"
  904. ac3_decoder_select="fft mdct"
  905. atrac3_decoder_select="fft mdct"
  906. cavs_decoder_select="golomb"
  907. cook_decoder_select="fft mdct"
  908. cscd_decoder_suggest="zlib"
  909. dca_decoder_select="fft mdct"
  910. dnxhd_encoder_select="aandct"
  911. dxa_decoder_select="zlib"
  912. eac3_decoder_deps="gpl"
  913. eac3_decoder_select="fft mdct"
  914. eatgq_decoder_select="aandct"
  915. eatqi_decoder_select="aandct"
  916. ffv1_decoder_select="golomb"
  917. flac_decoder_select="golomb"
  918. flac_encoder_select="golomb"
  919. flashsv_decoder_select="zlib"
  920. flashsv_encoder_select="zlib"
  921. flv_encoder_select="aandct"
  922. h261_encoder_select="aandct"
  923. h263_encoder_select="aandct"
  924. h263p_encoder_select="aandct"
  925. h264_decoder_select="golomb"
  926. h264_vdpau_decoder_deps="vdpau"
  927. imc_decoder_select="fft mdct"
  928. jpegls_decoder_select="golomb"
  929. jpegls_encoder_select="golomb"
  930. ljpeg_encoder_select="aandct"
  931. loco_decoder_select="golomb"
  932. mjpeg_encoder_select="aandct"
  933. mpeg1video_encoder_select="aandct"
  934. mpeg2video_encoder_select="aandct"
  935. mpeg4_encoder_select="aandct"
  936. mpeg_vdpau_decoder_deps="vdpau"
  937. mpeg1_vdpau_decoder_deps="vdpau"
  938. mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
  939. msmpeg4v1_encoder_select="aandct"
  940. msmpeg4v2_encoder_select="aandct"
  941. msmpeg4v3_encoder_select="aandct"
  942. nellymoser_decoder_select="fft mdct"
  943. nellymoser_encoder_select="fft mdct"
  944. png_decoder_select="zlib"
  945. png_encoder_select="zlib"
  946. qdm2_decoder_select="fft mdct rdft"
  947. rv10_encoder_select="aandct"
  948. rv20_encoder_select="aandct"
  949. rv30_decoder_select="golomb"
  950. rv40_decoder_select="golomb"
  951. shorten_decoder_select="golomb"
  952. sonic_decoder_select="golomb"
  953. sonic_encoder_select="golomb"
  954. sonic_ls_encoder_select="golomb"
  955. svq3_decoder_select="golomb"
  956. svq3_decoder_suggest="zlib"
  957. tiff_decoder_suggest="zlib"
  958. tiff_encoder_suggest="zlib"
  959. tscc_decoder_select="zlib"
  960. vc1_vdpau_decoder_deps="vdpau"
  961. vorbis_decoder_select="fft mdct"
  962. vorbis_encoder_select="fft mdct"
  963. wmav1_decoder_select="fft mdct"
  964. wmav1_encoder_select="fft mdct"
  965. wmav2_decoder_select="fft mdct"
  966. wmav2_encoder_select="fft mdct"
  967. wmv1_encoder_select="aandct"
  968. wmv2_encoder_select="aandct"
  969. wmv3_vdpau_decoder_deps="vdpau"
  970. zlib_decoder_select="zlib"
  971. zlib_encoder_select="zlib"
  972. zmbv_decoder_select="zlib"
  973. zmbv_encoder_select="zlib"
  974. # external libraries
  975. libamr_nb_decoder_deps="libamr_nb"
  976. libamr_nb_encoder_deps="libamr_nb"
  977. libamr_wb_decoder_deps="libamr_wb"
  978. libamr_wb_encoder_deps="libamr_wb"
  979. libdirac_decoder_deps="libdirac !libschroedinger"
  980. libdirac_encoder_deps="libdirac"
  981. libfaac_encoder_deps="libfaac"
  982. libfaad_decoder_deps="libfaad"
  983. libfaadbin_decoder_extralibs='$ldl'
  984. libgsm_decoder_deps="libgsm"
  985. libgsm_encoder_deps="libgsm"
  986. libgsm_ms_decoder_deps="libgsm"
  987. libgsm_ms_encoder_deps="libgsm"
  988. libmp3lame_encoder_deps="libmp3lame"
  989. libopenjpeg_decoder_deps="libopenjpeg"
  990. libschroedinger_decoder_deps="libschroedinger"
  991. libschroedinger_encoder_deps="libschroedinger"
  992. libspeex_decoder_deps="libspeex"
  993. libtheora_encoder_deps="libtheora"
  994. libvorbis_encoder_deps="libvorbis"
  995. libx264_encoder_deps="libx264"
  996. libxvid_encoder_deps="libxvid"
  997. mpeg4aac_decoder_deps="libfaad"
  998. vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  999. # demuxers / muxers
  1000. ac3_demuxer_deps="ac3_parser"
  1001. alsa_demuxer_deps="alsa_asoundlib_h snd_pcm_htimestamp"
  1002. alsa_demuxer_extralibs="-lasound"
  1003. alsa_muxer_deps="alsa_asoundlib_h"
  1004. alsa_muxer_extralibs="-lasound"
  1005. audio_beos_demuxer_deps="audio_beos"
  1006. audio_beos_demuxer_extralibs="-lmedia -lbe"
  1007. audio_beos_muxer_deps="audio_beos"
  1008. audio_beos_muxer_extralibs="-lmedia -lbe"
  1009. avisynth_demuxer_deps="avisynth"
  1010. bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  1011. dirac_demuxer_deps="dirac_parser"
  1012. dv1394_demuxer_deps="dv1394 dv_demuxer"
  1013. libdc1394_demuxer_deps="libdc1394"
  1014. libnut_demuxer_deps="libnut"
  1015. libnut_muxer_deps="libnut"
  1016. matroska_demuxer_suggest="zlib bzlib"
  1017. mov_demuxer_suggest="zlib"
  1018. mp3_demuxer_deps="mpegaudio_parser"
  1019. oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
  1020. oss_muxer_deps_any="soundcard_h sys_soundcard_h"
  1021. redir_demuxer_deps="network"
  1022. rtp_muxer_deps="network rtp_protocol"
  1023. rtsp_demuxer_deps="sdp_demuxer"
  1024. sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
  1025. v4l_demuxer_deps="linux_videodev_h"
  1026. v4l2_demuxer_deps_any="linux_videodev2_h sys_videoio_h"
  1027. vfwcap_demuxer_deps="capCreateCaptureWindow"
  1028. vfwcap_demuxer_extralibs="-lvfw32"
  1029. x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
  1030. x11_grab_device_demuxer_extralibs="-lX11 -lXext"
  1031. # protocols
  1032. gopher_protocol_deps="network"
  1033. http_protocol_deps="network"
  1034. rtp_protocol_deps="udp_protocol"
  1035. tcp_protocol_deps="network"
  1036. udp_protocol_deps="network"
  1037. # filters
  1038. movie_filter_deps="avfilter_lavf"
  1039. # programs
  1040. ffplay_deps="sdl"
  1041. ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
  1042. ffserver_extralibs='$ldl'
  1043. vhook_extralibs='$ldl'
  1044. # default parameters
  1045. logfile="config.err"
  1046. # installation paths
  1047. prefix_default="/usr/local"
  1048. bindir_default='${prefix}/bin'
  1049. datadir_default='${prefix}/share/ffmpeg'
  1050. incdir_default='${prefix}/include'
  1051. libdir_default='${prefix}/lib'
  1052. mandir_default='${prefix}/share/man'
  1053. shlibdir_default="$libdir_default"
  1054. # toolchain
  1055. ar="ar"
  1056. cc_default="gcc"
  1057. host_cc_default="gcc"
  1058. ln_s="ln -sf"
  1059. nm_default="nm"
  1060. objformat="elf"
  1061. ranlib="ranlib"
  1062. strip="strip"
  1063. yasmexe="yasm"
  1064. # machine
  1065. arch=`uname -m`
  1066. cpu="generic"
  1067. # OS
  1068. target_os=$(tolower $(uname -s))
  1069. # configurable options
  1070. enable debug
  1071. enable ffmpeg
  1072. enable ffplay
  1073. enable ffserver
  1074. enable ipv6
  1075. enable mpegaudio_hp
  1076. enable network
  1077. enable oldscaler
  1078. enable optimizations
  1079. enable protocols
  1080. enable static
  1081. enable stripping
  1082. vhook="default"
  1083. # build settings
  1084. add_cflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
  1085. SHFLAGS='-shared -Wl,-soname,$$(@F)'
  1086. VHOOKSHFLAGS='$(SHFLAGS)'
  1087. FFSERVERLDFLAGS=-Wl,-E
  1088. LIBPREF="lib"
  1089. LIBSUF=".a"
  1090. FULLNAME='$(NAME)$(BUILDSUF)'
  1091. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  1092. SLIBPREF="lib"
  1093. SLIBSUF=".so"
  1094. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  1095. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  1096. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  1097. LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  1098. host_cflags='-O3 -g -Wall'
  1099. host_libs='-lm'
  1100. target_path='.'
  1101. # gcc stupidly only outputs the basename of targets with -MM, but we need the
  1102. # full relative path for objects in subdirectories for non-recursive Make.
  1103. DEPEND_CMD='$(CC) $(CFLAGS) -MM $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
  1104. # find source path
  1105. source_path="`dirname \"$0\"`"
  1106. enable source_path_used
  1107. if test -z "$source_path" -o "$source_path" = "." ; then
  1108. source_path="`pwd`"
  1109. disable source_path_used
  1110. else
  1111. source_path="`cd \"$source_path\"; pwd`"
  1112. echo "$source_path" | grep -q '[[:blank:]]' &&
  1113. die "Out of tree builds are impossible with whitespace in source path."
  1114. fi
  1115. FFMPEG_CONFIGURATION="$@"
  1116. find_things(){
  1117. thing=$1
  1118. pattern=$2
  1119. file=$source_path/$3
  1120. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  1121. }
  1122. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  1123. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  1124. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  1125. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  1126. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  1127. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  1128. OUTDEV_LIST=$(find_things muxer _MUX libavdevice/alldevices.c)
  1129. INDEV_LIST=$(find_things demuxer DEMUX libavdevice/alldevices.c)
  1130. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  1131. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  1132. enable $ARCH_EXT_LIST \
  1133. $DECODER_LIST \
  1134. $ENCODER_LIST \
  1135. $PARSER_LIST \
  1136. $BSF_LIST \
  1137. $DEMUXER_LIST \
  1138. $MUXER_LIST \
  1139. $FILTER_LIST \
  1140. $PROTOCOL_LIST \
  1141. $INDEV_LIST \
  1142. $OUTDEV_LIST \
  1143. die_unknown(){
  1144. echo "Unknown option \"$1\"."
  1145. echo "See $0 --help for available options."
  1146. exit 1
  1147. }
  1148. show_list() {
  1149. suffix=_$1
  1150. shift
  1151. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
  1152. exit 0
  1153. }
  1154. for opt do
  1155. optval="${opt#*=}"
  1156. case "$opt" in
  1157. --extra-cflags=*) add_cflags $optval
  1158. ;;
  1159. --extra-ldflags=*) add_ldflags $optval
  1160. ;;
  1161. --extra-libs=*) add_extralibs $optval
  1162. ;;
  1163. --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
  1164. ;;
  1165. --enable-debug=*) debuglevel="$optval"
  1166. ;;
  1167. --enable-*=*|--disable-*=*)
  1168. eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
  1169. case "$thing" in
  1170. encoder|decoder|muxer|demuxer|parser|bsf|protocol|filter) $action ${optval}_${thing} ;;
  1171. *) die_unknown "$opt" ;;
  1172. esac
  1173. ;;
  1174. --enable-?*|--disable-?*)
  1175. eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
  1176. if is_in $option $COMPONENT_LIST; then
  1177. eval $action \$$(toupper ${option%s})_LIST
  1178. elif is_in $option $CMDLINE_SELECT; then
  1179. $action $option
  1180. else
  1181. die_unknown $opt
  1182. fi
  1183. ;;
  1184. --list-*)
  1185. NAME="${opt#--list-}"
  1186. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  1187. NAME=${NAME%s}
  1188. eval show_list $NAME \$$(toupper $NAME)_LIST
  1189. ;;
  1190. --help|-h) show_help
  1191. ;;
  1192. *)
  1193. optname="${opt%%=*}"
  1194. optname="${optname#--}"
  1195. optname=$(echo "$optname" | sed 's/-/_/g')
  1196. is_in $optname $CMDLINE_SET || die_unknown $opt
  1197. eval $optname='$optval'
  1198. ;;
  1199. esac
  1200. done
  1201. disabled logging && logfile=/dev/null
  1202. echo "# $0 $@" > $logfile
  1203. set >> $logfile
  1204. test -n "$cross_prefix" && enable cross_compile
  1205. ar="${cross_prefix}${ar}"
  1206. cc_default="${cross_prefix}${cc_default}"
  1207. nm_default="${cross_prefix}${nm_default}"
  1208. ranlib="${cross_prefix}${ranlib}"
  1209. strip="${cross_prefix}${strip}"
  1210. sysinclude_default="${sysroot}/usr/include"
  1211. set_default cc nm sysinclude
  1212. enabled cross_compile || host_cc_default=$cc
  1213. set_default host_cc
  1214. case $target_os in
  1215. mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) EXESUF=.exe ;;
  1216. esac
  1217. # set temporary file name
  1218. : ${TMPDIR:=$TEMPDIR}
  1219. : ${TMPDIR:=$TMP}
  1220. : ${TMPDIR:=/tmp}
  1221. TMPC="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
  1222. TMPE="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
  1223. TMPH="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
  1224. TMPO="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
  1225. TMPS="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
  1226. TMPSH="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
  1227. # make sure we can execute files in $TMPDIR
  1228. cat > $TMPSH 2>> $logfile <<EOF
  1229. #! /bin/sh
  1230. EOF
  1231. chmod +x $TMPSH >> $logfile 2>&1
  1232. if ! $TMPSH >> $logfile 2>&1; then
  1233. cat <<EOF
  1234. Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
  1235. variable to another directory and make sure that it is not mounted noexec.
  1236. EOF
  1237. die "Sanity test failed."
  1238. fi
  1239. rm $TMPSH
  1240. if $cc --version 2>/dev/null | grep -qi gcc; then
  1241. cc_type=gcc
  1242. elif $cc --version 2>/dev/null | grep -q Intel; then
  1243. cc_type=icc
  1244. elif $cc -v 2>&1 | grep -q xlc; then
  1245. cc_type=xlc
  1246. elif $cc -V 2>/dev/null | grep -q Compaq; then
  1247. cc_type=ccc
  1248. DEPEND_CMD='$(CC) $(CFLAGS) -M $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
  1249. add_ldflags -Wl,-z,now # calls to libots crash without this
  1250. fi
  1251. test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
  1252. if test -n "$sysroot"; then
  1253. case "$cc_type" in
  1254. gcc)
  1255. add_cflags --sysroot="$sysroot"
  1256. add_ldflags --sysroot="$sysroot"
  1257. ;;
  1258. esac
  1259. fi
  1260. # compiler sanity check
  1261. check_exec <<EOF
  1262. int main(void){ return 0; }
  1263. EOF
  1264. if test "$?" != 0; then
  1265. echo "$cc is unable to create an executable file."
  1266. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1267. echo "If $cc is a cross-compiler, use the --enable-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. check_cflags -std=c99
  1273. case "$arch" in
  1274. alpha)
  1275. arch="alpha"
  1276. enable fast_64bit
  1277. check_cflags -mieee
  1278. ;;
  1279. arm|armv[4567]*l)
  1280. arch="arm"
  1281. ;;
  1282. avr32)
  1283. ;;
  1284. bfin)
  1285. arch="bfin"
  1286. ;;
  1287. ia64)
  1288. arch="ia64"
  1289. enable fast_64bit
  1290. ;;
  1291. m68k)
  1292. arch="m68k"
  1293. ;;
  1294. mips|mipsel|IP*)
  1295. arch="mips"
  1296. ;;
  1297. mips64)
  1298. arch="mips"
  1299. enable fast_64bit
  1300. ;;
  1301. parisc|hppa)
  1302. arch="parisc"
  1303. ;;
  1304. parisc64|hppa64)
  1305. arch="parisc"
  1306. enable fast_64bit
  1307. ;;
  1308. "Power Macintosh"|ppc|powerpc)
  1309. arch="ppc"
  1310. enable fast_unaligned
  1311. ;;
  1312. ppc64)
  1313. arch="ppc"
  1314. enable fast_64bit
  1315. enable fast_unaligned
  1316. ;;
  1317. s390|s390x)
  1318. arch="s390"
  1319. ;;
  1320. sh4|sh)
  1321. arch="sh4"
  1322. ;;
  1323. sparc)
  1324. arch="sparc"
  1325. ;;
  1326. sun4u|sparc64)
  1327. arch="sparc"
  1328. subarch="sparc64"
  1329. enable fast_64bit
  1330. ;;
  1331. i386|i486|i586|i686|i86pc|BePC)
  1332. arch="x86"
  1333. subarch="x86_32"
  1334. enable fast_unaligned
  1335. ;;
  1336. x86_64|amd64)
  1337. arch="x86"
  1338. subarch="x86_32"
  1339. enable cmov
  1340. enable fast_cmov
  1341. enable fast_unaligned
  1342. check_cc <<EOF && enable fast_64bit && subarch="x86_64"
  1343. int test[sizeof(char*) - 7];
  1344. EOF
  1345. ;;
  1346. *)
  1347. arch="unknown"
  1348. ;;
  1349. esac
  1350. enable $arch $subarch
  1351. # OS specific
  1352. case $target_os in
  1353. beos|haiku|zeta)
  1354. prefix_default="$HOME/config"
  1355. # helps building libavcodec
  1356. add_cflags -DPIC -fomit-frame-pointer
  1357. # 3 gcc releases known for BeOS, each with ugly bugs
  1358. gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
  1359. case "$gcc_version" in
  1360. 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
  1361. disable mmx
  1362. ;;
  1363. *20010315*) echo "BeBits gcc"
  1364. add_cflags -fno-expensive-optimizations
  1365. ;;
  1366. esac
  1367. SHFLAGS=-nostart
  1368. # enable BeOS things
  1369. enable audio_beos
  1370. # no need for libm, but the inet stuff
  1371. # Check for BONE
  1372. # XXX: actually should check for NOT net_server
  1373. if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
  1374. network_extralibs="-lbind -lsocket"
  1375. else
  1376. enable beos_netserver
  1377. network_extralibs="-lnet"
  1378. fi ;;
  1379. sunos)
  1380. FFSERVERLDFLAGS=""
  1381. SHFLAGS='-shared -Wl,-h,$$(@F)'
  1382. network_extralibs="-lsocket -lnsl"
  1383. add_cflags -D__EXTENSIONS__
  1384. ;;
  1385. netbsd)
  1386. oss_demuxer_extralibs="-lossaudio"
  1387. oss_muxer_extralibs="-lossaudio"
  1388. ;;
  1389. openbsd)
  1390. disable need_memalign
  1391. LIBOBJFLAGS='$(PIC)'
  1392. SHFLAGS='-shared'
  1393. oss_demuxer_extralibs="-lossaudio"
  1394. oss_muxer_extralibs="-lossaudio"
  1395. ;;
  1396. freebsd)
  1397. disable need_memalign
  1398. ;;
  1399. bsd/os)
  1400. osextralibs="-lpoll -lgnugetopt"
  1401. strip="strip -d"
  1402. ;;
  1403. darwin)
  1404. disable need_memalign
  1405. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
  1406. VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$$(@F)'
  1407. strip="strip -x"
  1408. FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
  1409. SLIBSUF=".dylib"
  1410. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  1411. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  1412. FFSERVERLDFLAGS=-Wl,-bind_at_load
  1413. objformat="macho"
  1414. enabled x86_64 && objformat="macho64"
  1415. ;;
  1416. mingw32*)
  1417. target_os=mingw32
  1418. LIBTARGET=i386
  1419. if enabled x86_64; then
  1420. disable need_memalign
  1421. LIBTARGET=x64
  1422. fi
  1423. shlibdir_default="$bindir_default"
  1424. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1425. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1426. if enabled swscale; then
  1427. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1428. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1429. fi
  1430. disable ffserver
  1431. SLIBPREF=""
  1432. SLIBSUF=".dll"
  1433. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1434. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1435. SLIB_EXTRA_CMD='-lib /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
  1436. SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
  1437. install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"'
  1438. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  1439. SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
  1440. objformat="win32"
  1441. enable dos_paths
  1442. if ! enabled x86_64; then
  1443. check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
  1444. die "ERROR: MinGW runtime version must be >= 3.15."
  1445. enabled_any avisynth vfwcap_demuxer &&
  1446. { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
  1447. die "ERROR: avisynth and vfwcap_demuxer require w32api version 3.13 or later."; }
  1448. fi
  1449. ;;
  1450. cygwin*)
  1451. target_os=cygwin
  1452. shlibdir_default="$bindir_default"
  1453. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1454. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1455. if enabled swscale; then
  1456. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1457. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1458. fi
  1459. SLIBPREF="cyg"
  1460. SLIBSUF=".dll"
  1461. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1462. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1463. SHFLAGS='-shared -Wl,--enable-auto-image-base'
  1464. objformat="win32"
  1465. enable dos_paths
  1466. ;;
  1467. *-dos|freedos|opendos)
  1468. disable ffplay ffserver vhook
  1469. disable $INDEV_LIST $OUTDEV_LIST
  1470. network_extralibs="-lsocket"
  1471. objformat="coff"
  1472. enable dos_paths
  1473. ;;
  1474. linux)
  1475. enable dv1394
  1476. ;;
  1477. irix*)
  1478. target_os=irix
  1479. ranlib="echo ignoring ranlib"
  1480. ;;
  1481. os/2*)
  1482. strip="lxlite"
  1483. ln_s="cp -f"
  1484. FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
  1485. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  1486. FFSERVERLDFLAGS=""
  1487. LIBSUF="_s.a"
  1488. SLIBPREF=""
  1489. SLIBSUF=".dll"
  1490. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1491. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  1492. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  1493. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  1494. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  1495. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  1496. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  1497. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  1498. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  1499. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  1500. SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
  1501. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
  1502. disable vhook
  1503. enable dos_paths
  1504. ;;
  1505. interix)
  1506. disable vhook
  1507. ;;
  1508. *)
  1509. die "Unknown OS '$target_os'."
  1510. ;;
  1511. esac
  1512. set_default $PATHS_LIST
  1513. add_extralibs $osextralibs
  1514. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1515. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1516. # we need to build at least one lib type
  1517. if ! enabled_any static shared; then
  1518. cat <<EOF
  1519. At least one library type must be built.
  1520. Specify --enable-static to build the static libraries or --enable-shared to
  1521. build the shared libraries as well. To only build the shared libraries specify
  1522. --disable-static in addition to --enable-shared.
  1523. EOF
  1524. exit 1;
  1525. fi
  1526. disabled static && LIBNAME=""
  1527. if enabled_any libfaad libfaadbin ; then
  1528. if check_header faad.h; then
  1529. check_cc <<EOF
  1530. #include <faad.h>
  1531. #ifndef FAAD2_VERSION
  1532. ok faad1
  1533. #endif
  1534. int main(void) { return 0; }
  1535. EOF
  1536. test $? = 0 && enable libfaad2
  1537. else
  1538. die "FAAD test failed."
  1539. fi
  1540. fi
  1541. if ! enabled gpl; then
  1542. die_gpl_disabled(){
  1543. name=$1
  1544. shift
  1545. enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
  1546. }
  1547. die_gpl_disabled "The Postprocessing code" postproc
  1548. die_gpl_disabled "libx264" libx264
  1549. die_gpl_disabled "libxvidcore" libxvid
  1550. die_gpl_disabled "FAAD2" libfaad2
  1551. die_gpl_disabled "The X11 grabber" x11grab
  1552. die_gpl_disabled "The software scaler" swscale
  1553. fi
  1554. if ! enabled nonfree && enabled_any libamr_nb libamr_wb; then
  1555. die "libamr is nonfree and --enable-nonfree is not specified."
  1556. fi
  1557. check_deps $ARCH_EXT_LIST
  1558. test -z "$need_memalign" && need_memalign="$mmx"
  1559. #Darwin CC versions
  1560. if test $target_os = darwin; then
  1561. if enabled xlc; then
  1562. add_cflags -qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto
  1563. else
  1564. add_cflags -pipe
  1565. check_cflags -force_cpusubtype_ALL
  1566. check_cflags -Wno-sign-compare
  1567. enabled shared || check_cflags -mdynamic-no-pic
  1568. fi
  1569. fi
  1570. disabled optimizations || check_cflags -fomit-frame-pointer
  1571. # Add processor-specific flags
  1572. if test $cpu != "generic"; then
  1573. warn_altivec(){
  1574. $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
  1575. }
  1576. case $cpu in
  1577. 601|ppc601|PowerPC601)
  1578. add_cflags -mcpu=601
  1579. warn_altivec enabled PPC601
  1580. ;;
  1581. 603*|ppc603*|PowerPC603*)
  1582. add_cflags -mcpu=603
  1583. warn_altivec enabled PPC603
  1584. ;;
  1585. 604*|ppc604*|PowerPC604*)
  1586. add_cflags -mcpu=604
  1587. warn_altivec enabled PPC604
  1588. ;;
  1589. G3|g3|75*|ppc75*|PowerPC75*)
  1590. add_cflags -mcpu=750 -mpowerpc-gfxopt
  1591. warn_altivec enabled PPC75x
  1592. ;;
  1593. G4|g4|745*|ppc745*|PowerPC745*)
  1594. add_cflags -mcpu=7450 -mpowerpc-gfxopt
  1595. warn_altivec disabled PPC745x
  1596. ;;
  1597. 74*|ppc74*|PowerPC74*)
  1598. add_cflags -mcpu=7400 -mpowerpc-gfxopt
  1599. warn_altivec disabled PPC74xx
  1600. ;;
  1601. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1602. add_cflags -mcpu=970 -mpowerpc-gfxopt -mpowerpc64
  1603. warn_altivec disabled PPC970
  1604. enable ppc64
  1605. ;;
  1606. Cell|CELL|cell)
  1607. add_cflags -mcpu=cell
  1608. warn_altivec disabled Cell
  1609. enable ppc64
  1610. ;;
  1611. # targets that do NOT support conditional mov (cmov)
  1612. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1613. add_cflags -march=$cpu
  1614. disable cmov
  1615. ;;
  1616. # targets that do support conditional mov (cmov)
  1617. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1618. add_cflags -march=$cpu
  1619. enable cmov
  1620. enable fast_cmov
  1621. ;;
  1622. # targets that do support conditional mov but on which it's slow
  1623. pentium4|pentium4m|prescott|nocona)
  1624. add_cflags -march=$cpu
  1625. enable cmov
  1626. disable fast_cmov
  1627. ;;
  1628. sparc64)
  1629. add_cflags -mcpu=v9
  1630. ;;
  1631. arm11*|cortex*)
  1632. add_cflags -mcpu=$cpu
  1633. enable fast_unaligned
  1634. ;;
  1635. armv*)
  1636. add_cflags -march=$cpu
  1637. ;;
  1638. arm*)
  1639. add_cflags -mcpu=$cpu
  1640. ;;
  1641. ev4|ev45|ev5|ev56|pca56|ev6|ev67)
  1642. enabled ccc && add_cflags -arch $cpu || add_cflags -mcpu=$cpu
  1643. ;;
  1644. *)
  1645. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1646. ;;
  1647. esac
  1648. fi
  1649. check_cc <<EOF || die "Symbol mangling check failed."
  1650. int ff_extern;
  1651. EOF
  1652. sym=$($nm -P -g $TMPO | grep ff_extern)
  1653. extern_prefix=${sym%%ff_extern*}
  1654. check_asm inline_asm '""'
  1655. if enabled x86; then
  1656. # check whether EBP is available on x86
  1657. # As 'i' is stored on the stack, this program will crash
  1658. # if the base pointer is used to access it because the
  1659. # base pointer is cleared in the inline assembly code.
  1660. check_exec_crash <<EOF && enable ebp_available
  1661. volatile int i=0;
  1662. __asm__ volatile (
  1663. "xorl %%ebp, %%ebp"
  1664. ::: "%ebp");
  1665. return i;
  1666. EOF
  1667. # check wether EBX is available on x86
  1668. check_asm ebx_available '"":::"%ebx"'
  1669. # check whether more than 10 operands are supported
  1670. check_cc <<EOF && enable ten_operands
  1671. int main(void) {
  1672. int x=0;
  1673. __asm__ volatile(
  1674. ""
  1675. :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
  1676. );
  1677. return 0;
  1678. }
  1679. EOF
  1680. # check whether binutils is new enough to compile SSSE3/MMX2
  1681. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  1682. enabled mmx2 && check_asm mmx2 '"movss %xmm0, %xmm0"'
  1683. check_asm bswap '"bswap %%eax" ::: "%eax"'
  1684. YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
  1685. enabled x86_64 && append YASMFLAGS "-m amd64"
  1686. enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
  1687. case "$objformat" in
  1688. elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
  1689. macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
  1690. *) append YASMFLAGS "-DPREFIX" ;;
  1691. esac
  1692. disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
  1693. fi
  1694. # check for assembler specific support
  1695. enabled ppc && check_asm dcbzl '"dcbzl 0, 1"'
  1696. enabled ppc && check_asm ppc4xx '"maclhw r10, r11, r12"'
  1697. # check for SIMD availability
  1698. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1699. if enabled altivec; then
  1700. check_cflags -maltivec -mabi=altivec &&
  1701. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  1702. check_cflags -faltivec
  1703. # check if our compiler supports Motorola AltiVec C API
  1704. check_cc <<EOF || disable altivec
  1705. $inc_altivec_h
  1706. int main(void) {
  1707. vector signed int v1, v2, v3;
  1708. v1 = vec_add(v2,v3);
  1709. return 0;
  1710. }
  1711. EOF
  1712. # check if our compiler supports braces for vector declarations
  1713. check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
  1714. $inc_altivec_h
  1715. int main (void) { (vector int) {1}; return 0; }
  1716. EOF
  1717. fi
  1718. # We have to check if pld is a nop and disable it.
  1719. enabled arm && check_asm pld '"pld [r0]"'
  1720. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  1721. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  1722. enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
  1723. enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
  1724. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  1725. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  1726. enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
  1727. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
  1728. enabled vis && add_cflags -mcpu=ultrasparc -mtune=ultrasparc
  1729. # ---
  1730. # big/little-endian test
  1731. check_cc <<EOF || die "endian test failed"
  1732. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  1733. EOF
  1734. od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  1735. # ---
  1736. # check availability of some header files
  1737. if check_func dlopen; then
  1738. ldl=
  1739. elif check_func dlopen -ldl; then
  1740. ldl=-ldl
  1741. fi
  1742. # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
  1743. check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
  1744. check_func fork
  1745. check_func gethrtime
  1746. check_func getrusage
  1747. check_func inet_aton $network_extralibs
  1748. check_func memalign
  1749. check_func mkstemp
  1750. check_func posix_memalign
  1751. check_func_headers io.h setmode
  1752. check_func_headers windows.h GetProcessTimes
  1753. check_header conio.h
  1754. check_header dlfcn.h
  1755. check_header malloc.h
  1756. check_header poll.h
  1757. check_header sys/mman.h
  1758. check_header sys/resource.h
  1759. check_header sys/select.h
  1760. check_header termios.h
  1761. check_header vdpau/vdpau.h
  1762. check_header vdpau/vdpau_x11.h
  1763. check_header X11/extensions/XvMClib.h
  1764. if ! enabled_any memalign memalign_hack posix_memalign && enabled need_memalign ; then
  1765. die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
  1766. fi
  1767. disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
  1768. disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  1769. # check for some common methods of building with pthread support
  1770. # do this before the optional library checks as some of them require pthreads
  1771. if enabled pthreads; then
  1772. if check_func pthread_create; then
  1773. :
  1774. elif check_func pthread_create -pthread; then
  1775. add_cflags -pthread
  1776. add_extralibs -pthread
  1777. elif check_func pthread_create -pthreads; then
  1778. add_cflags -pthreads
  1779. add_extralibs -pthreads
  1780. elif check_func pthread_create -lpthreadGC2; then
  1781. add_extralibs -lpthreadGC2
  1782. elif ! check_lib pthread.h pthread_create -lpthread; then
  1783. die "ERROR: can't find pthreads library"
  1784. fi
  1785. fi
  1786. for thread in $THREADS_LIST; do
  1787. if enabled $thread; then
  1788. test -n "$thread_type" &&
  1789. die "ERROR: Only one thread type must be selected." ||
  1790. thread_type="$thread"
  1791. fi
  1792. done
  1793. check_lib math.h sin -lm
  1794. # test for C99 functions in math.h
  1795. for func in llrint lrint lrintf round roundf truncf; do
  1796. check_exec <<EOF && enable $func || disable $func
  1797. #include <math.h>
  1798. int main(void) { return ($func(3.999f) > 0)?0:1; }
  1799. EOF
  1800. done
  1801. # these are off by default, so fail if requested and not available
  1802. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  1803. enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
  1804. enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
  1805. enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
  1806. require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init -ldirac_decoder &&
  1807. require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init -ldirac_encoder
  1808. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  1809. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  1810. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1811. enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame -lm
  1812. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1813. enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
  1814. enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
  1815. require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
  1816. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  1817. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  1818. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  1819. enabled libx264 && require libx264 x264.h x264_encoder_open -lx264 -lm &&
  1820. { check_cpp_condition x264.h "X264_BUILD >= 65" ||
  1821. die "ERROR: libx264 version must be >= 0.65."; }
  1822. enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
  1823. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1824. # libdc1394 check
  1825. if enabled libdc1394; then
  1826. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  1827. enable libdc1394_2; } ||
  1828. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  1829. enable libdc1394_1; } ||
  1830. die "ERROR: No version of libdc1394 found "
  1831. fi
  1832. _restrict=
  1833. for restrict_keyword in restrict __restrict__ __restrict; do
  1834. check_cc <<EOF && _restrict=$restrict_keyword && break
  1835. void foo(char * $restrict_keyword p);
  1836. EOF
  1837. done
  1838. test "$vhook" = "default" && vhook="$dlopen"
  1839. if test "$target_os" = cygwin -o "$target_os" = mingw32 && enabled_all static vhook ; then
  1840. disable vhook
  1841. echo
  1842. echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
  1843. echo "Patches welcome."
  1844. echo
  1845. fi
  1846. if enabled vhook; then
  1847. check_ldflags -rdynamic
  1848. check_ldflags -export-dynamic
  1849. fi
  1850. check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
  1851. check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
  1852. ##########################################
  1853. # SDL check
  1854. disable sdl_too_old
  1855. disable sdl
  1856. SDL_CONFIG="${cross_prefix}sdl-config"
  1857. if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
  1858. sdl_cflags=`"${SDL_CONFIG}" --cflags`
  1859. temp_cflags $sdl_cflags
  1860. temp_extralibs `"${SDL_CONFIG}" --libs`
  1861. if check_lib2 SDL.h SDL_Init; then
  1862. _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
  1863. if test "$_sdlversion" -lt 121 ; then
  1864. enable sdl_too_old
  1865. else
  1866. enable sdl
  1867. check_cc $sdl_cflags <<EOF && enable sdl_video_size
  1868. #include <SDL.h>
  1869. int main(int argc, char **argv){
  1870. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1871. int w = vi->current_w;
  1872. return 0;
  1873. }
  1874. EOF
  1875. fi
  1876. fi
  1877. restore_flags
  1878. fi
  1879. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  1880. ##########################################
  1881. # Network check
  1882. if enabled network; then
  1883. check_type "sys/types.h sys/socket.h" socklen_t
  1884. # Prefer arpa/inet.h over winsock2
  1885. if check_header arpa/inet.h ; then
  1886. check_func closesocket
  1887. elif check_header winsock2.h ; then
  1888. network_extralibs="-lws2_32"
  1889. check_type ws2tcpip.h socklen_t
  1890. check_func_headers winsock2.h closesocket
  1891. fi
  1892. fi
  1893. ##########################################
  1894. # IPv6 check
  1895. enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
  1896. #include <sys/types.h>
  1897. #include <sys/socket.h>
  1898. #include <netinet/in.h>
  1899. #include <netdb.h>
  1900. int main(void) {
  1901. struct sockaddr_storage saddr;
  1902. struct ipv6_mreq mreq6;
  1903. getaddrinfo(0,0,0,0);
  1904. getnameinfo(0,0,0,0,0,0,0);
  1905. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1906. }
  1907. EOF
  1908. check_header linux/videodev.h
  1909. check_header linux/videodev2.h
  1910. check_header sys/videoio.h
  1911. check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
  1912. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1913. { check_header dev/bktr/ioctl_meteor.h &&
  1914. check_header dev/bktr/ioctl_bt848.h; } ||
  1915. { check_header machine/ioctl_meteor.h &&
  1916. check_header machine/ioctl_bt848.h; } ||
  1917. { check_header dev/video/meteor/ioctl_meteor.h &&
  1918. check_header dev/video/bktr/ioctl_bt848.h; } ||
  1919. check_header dev/ic/bt8xx.h
  1920. check_header sys/soundcard.h
  1921. check_header soundcard.h
  1922. check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
  1923. # deal with the X11 frame grabber
  1924. enabled x11grab &&
  1925. check_header X11/Xlib.h &&
  1926. check_header X11/extensions/XShm.h &&
  1927. check_func XOpenDisplay -lX11 &&
  1928. check_func XShmCreateImage -lX11 -lXext
  1929. enabled debug && add_cflags -g"$debuglevel"
  1930. # add some useful compiler flags if supported
  1931. check_cflags -Wdeclaration-after-statement
  1932. check_cflags -Wall
  1933. check_cflags -Wno-switch
  1934. check_cflags -Wdisabled-optimization
  1935. check_cflags -Wpointer-arith
  1936. check_cflags -Wredundant-decls
  1937. check_cflags -Wno-pointer-sign
  1938. check_cflags -Wcast-qual
  1939. check_cflags -Wwrite-strings
  1940. check_cflags -Wtype-limits
  1941. check_cflags -Wundef
  1942. enabled extra_warnings && check_cflags -Winline
  1943. # add some linker flags
  1944. check_ldflags -Wl,--warn-common
  1945. check_ldflags -Wl,--as-needed
  1946. check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
  1947. check_ldflags -Wl,-Bsymbolic
  1948. if enabled small; then
  1949. check_cflags -Os # not all compilers support -Os
  1950. optimizations="small"
  1951. elif enabled optimizations; then
  1952. if enabled xlc; then
  1953. add_cflags -O5
  1954. add_ldflags -O5
  1955. elif enabled ccc; then
  1956. add_cflags -fast
  1957. else
  1958. add_cflags -O3
  1959. fi
  1960. fi
  1961. check_cflags -fno-math-errno
  1962. check_cflags -fno-signed-zeros
  1963. # add some flags for Intel C Compiler
  1964. if enabled icc; then
  1965. # Just warnings, no remarks
  1966. check_cflags -w1
  1967. # -wd: Disable following warnings
  1968. # 144, 167, 556: -Wno-pointer-sign
  1969. # 10006: ignoring unknown option -fno-signed-zeros
  1970. # 10156: ignoring option '-W'; no argument required
  1971. check_cflags -wd144,167,556,10006,10156
  1972. # 11030: Warning unknown option --as-needed
  1973. # 10156: ignoring option '-export'; no argument required
  1974. check_ldflags -wd10156,11030
  1975. # Allow to compile with optimizations
  1976. check_ldflags -march=$cpu
  1977. elif enabled ccc; then
  1978. # disable some annoying warnings
  1979. add_cflags -msg_disable cvtu32to64
  1980. add_cflags -msg_disable embedcomment
  1981. add_cflags -msg_disable needconstext
  1982. add_cflags -msg_disable nomainieee
  1983. add_cflags -msg_disable ptrmismatch1
  1984. add_cflags -msg_disable unreachcode
  1985. fi
  1986. # PIC flags for shared library objects where they are needed
  1987. if enabled shared; then
  1988. # LIBOBJFLAGS may have already been set in the OS configuration
  1989. if test -z "$LIBOBJFLAGS" ; then
  1990. case "${subarch-$arch}" in
  1991. x86_64|ia64|alpha|sparc*|power*|parisc*|mips*) LIBOBJFLAGS='$(PIC)' ;;
  1992. esac
  1993. fi
  1994. fi
  1995. if enabled gprof; then
  1996. add_cflags -p
  1997. add_ldflags -p
  1998. fi
  1999. VHOOKCFLAGS="-fPIC"
  2000. # Find out if the .align argument is a power of two or not.
  2001. check_asm asmalign_pot '".align 3"'
  2002. enabled_any $DECODER_LIST && enable decoders
  2003. enabled_any $ENCODER_LIST && enable encoders
  2004. enabled_any $BSF_LIST && enable bsfs
  2005. enabled_any $DEMUXER_LIST && enable demuxers
  2006. enabled_any $MUXER_LIST && enable muxers
  2007. enabled_any $FILTER_LIST && enable filters
  2008. enabled_any $INDEV_LIST && enable demuxers
  2009. enabled_any $OUTDEV_LIST && enable muxers
  2010. enabled_any $PROTOCOL_LIST && enable protocols
  2011. enabled_any $THREADS_LIST && enable threads
  2012. check_deps $CONFIG_LIST \
  2013. $CONFIG_EXTRA \
  2014. $HAVE_LIST \
  2015. $DECODER_LIST \
  2016. $ENCODER_LIST \
  2017. $PARSER_LIST \
  2018. $BSF_LIST \
  2019. $DEMUXER_LIST \
  2020. $MUXER_LIST \
  2021. $FILTER_LIST \
  2022. $INDEV_LIST \
  2023. $OUTDEV_LIST \
  2024. $PROTOCOL_LIST \
  2025. echo "install prefix $prefix"
  2026. echo "source path $source_path"
  2027. echo "C compiler $cc"
  2028. echo ".align is power-of-two $asmalign_pot"
  2029. echo "ARCH $arch ($cpu)"
  2030. if test "$build_suffix" != ""; then
  2031. echo "build suffix $build_suffix"
  2032. fi
  2033. if test "$extra_version" != ""; then
  2034. echo "version string suffix $extra_version"
  2035. fi
  2036. echo "big-endian ${bigendian-no}"
  2037. if enabled x86; then
  2038. echo "yasm ${yasm-no}"
  2039. echo "MMX enabled ${mmx-no}"
  2040. echo "MMX2 enabled ${mmx2-no}"
  2041. echo "3DNow! enabled ${amd3dnow-no}"
  2042. echo "3DNow! extended enabled ${amd3dnowext-no}"
  2043. echo "SSE enabled ${sse-no}"
  2044. echo "SSSE3 enabled ${ssse3-no}"
  2045. echo "CMOV enabled ${cmov-no}"
  2046. echo "CMOV is fast ${fast_cmov-no}"
  2047. echo "EBX available ${ebx_available-no}"
  2048. echo "EBP available ${ebp_available-no}"
  2049. echo "10 operands supported ${ten_operands-no}"
  2050. fi
  2051. if enabled arm; then
  2052. echo "ARMv5TE enabled ${armv5te-no}"
  2053. echo "ARMv6 enabled ${armv6-no}"
  2054. echo "ARMv6T2 enabled ${armv6t2-no}"
  2055. echo "ARM VFP enabled ${armvfp-no}"
  2056. echo "IWMMXT enabled ${iwmmxt-no}"
  2057. echo "NEON enabled ${neon-no}"
  2058. fi
  2059. if enabled mips; then
  2060. echo "MMI enabled ${mmi-no}"
  2061. fi
  2062. if enabled ppc; then
  2063. echo "AltiVec enabled ${altivec-no}"
  2064. echo "PPC 4xx optimizations ${ppc4xx-no}"
  2065. echo "dcbzl available ${dcbzl-no}"
  2066. echo "performance report ${powerpc_perf-no}"
  2067. fi
  2068. if enabled sparc; then
  2069. echo "VIS enabled ${vis-no}"
  2070. fi
  2071. echo "gprof enabled ${gprof-no}"
  2072. echo "debug symbols ${debug-no}"
  2073. echo "strip symbols ${stripping-no}"
  2074. echo "optimizations ${optimizations-no}"
  2075. echo "static ${static-no}"
  2076. echo "shared ${shared-no}"
  2077. echo "postprocessing support ${postproc-no}"
  2078. echo "software scaler enabled ${swscale-no}"
  2079. echo "new filter support ${avfilter-no}"
  2080. echo "filters using lavformat ${avfilter_lavf-no}"
  2081. echo "video hooking ${vhook-no}"
  2082. if enabled vhook; then
  2083. echo "Imlib2 support ${imlib2-no}"
  2084. echo "FreeType support ${freetype2-no}"
  2085. fi
  2086. echo "network support ${network-no}"
  2087. if enabled network; then
  2088. echo "IPv6 support ${ipv6-no}"
  2089. fi
  2090. echo "threading support ${thread_type-no}"
  2091. echo "SDL support ${sdl-no}"
  2092. if enabled sdl_too_old; then
  2093. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  2094. fi
  2095. echo "Sun medialib support ${mlib-no}"
  2096. echo "AVISynth enabled ${avisynth-no}"
  2097. echo "libamr-nb support ${libamr_nb-no}"
  2098. echo "libamr-wb support ${libamr_wb-no}"
  2099. echo "libdc1394 support ${libdc1394-no}"
  2100. echo "libdirac enabled ${libdirac-no}"
  2101. echo "libfaac enabled ${libfaac-no}"
  2102. echo "libfaad enabled ${libfaad-no}"
  2103. echo "libfaad dlopened ${libfaadbin-no}"
  2104. echo "libgsm enabled ${libgsm-no}"
  2105. echo "libmp3lame enabled ${libmp3lame-no}"
  2106. echo "libnut enabled ${libnut-no}"
  2107. echo "libopenjpeg enabled ${libopenjpeg-no}"
  2108. echo "libschroedinger enabled ${libschroedinger-no}"
  2109. echo "libspeex enabled ${libspeex-no}"
  2110. echo "libtheora enabled ${libtheora-no}"
  2111. echo "libvorbis enabled ${libvorbis-no}"
  2112. echo "libx264 enabled ${libx264-no}"
  2113. echo "libxvid enabled ${libxvid-no}"
  2114. echo "vdpau enabled ${vdpau-no}"
  2115. echo "zlib enabled ${zlib-no}"
  2116. echo "bzlib enabled ${bzlib-no}"
  2117. echo
  2118. for type in decoder encoder parser demuxer muxer protocol filter bsf indev outdev; do
  2119. echo "Enabled ${type}s:"
  2120. eval list=\$$(toupper $type)_LIST
  2121. for part in $list; do
  2122. enabled $part && echo ${part%_*}
  2123. done | sort | pr -3 -t
  2124. echo
  2125. done
  2126. license="LGPL"
  2127. if enabled nonfree; then
  2128. license="unredistributable"
  2129. elif enabled gpl; then
  2130. license="GPL"
  2131. fi
  2132. echo "License: $license"
  2133. echo "Creating config.mak and config.h..."
  2134. echo "# Automatically generated by configure - do not modify!" > config.mak
  2135. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  2136. echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
  2137. echo "#define FFMPEG_CONFIG_H" >> $TMPH
  2138. echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
  2139. echo "#define FFMPEG_DATADIR \"$(eval c_escape $datadir)\"" >> $TMPH
  2140. echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
  2141. echo "prefix=$prefix" >> config.mak
  2142. echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
  2143. echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
  2144. echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
  2145. echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
  2146. echo "DATADIR=\$(DESTDIR)$datadir" >> config.mak
  2147. echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
  2148. echo "CC=$cc" >> config.mak
  2149. echo "YASM=$yasmexe" >> config.mak
  2150. echo "AR=$ar" >> config.mak
  2151. echo "RANLIB=$ranlib" >> config.mak
  2152. echo "LN_S=$ln_s" >> config.mak
  2153. enabled stripping &&
  2154. echo "STRIP=$strip" >> config.mak ||
  2155. echo "STRIP=echo ignoring strip" >> config.mak
  2156. echo "OPTFLAGS=$CFLAGS" >> config.mak
  2157. echo "VHOOKCFLAGS=$VHOOKCFLAGS" >> config.mak
  2158. echo "LDFLAGS=$LDFLAGS" >> config.mak
  2159. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  2160. echo "SHFLAGS=$SHFLAGS" >> config.mak
  2161. echo "YASMFLAGS=$YASMFLAGS" >> config.mak
  2162. echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
  2163. echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
  2164. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  2165. echo "BUILD_STATIC=$static" >> config.mak
  2166. echo "BUILDSUF=$build_suffix" >> config.mak
  2167. echo "FULLNAME=$FULLNAME" >> config.mak
  2168. echo "LIBPREF=$LIBPREF" >> config.mak
  2169. echo "LIBSUF=$LIBSUF" >> config.mak
  2170. echo "LIBNAME=$LIBNAME" >> config.mak
  2171. echo "SLIBPREF=$SLIBPREF" >> config.mak
  2172. echo "SLIBSUF=$SLIBSUF" >> config.mak
  2173. echo "EXESUF=$EXESUF" >> config.mak
  2174. echo "EXTRA_VERSION=$extra_version" >> config.mak
  2175. echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
  2176. echo "HOSTCC=$host_cc" >> config.mak
  2177. echo "HOSTCFLAGS=$host_cflags" >> config.mak
  2178. echo "HOSTLDFLAGS=$host_ldflags" >> config.mak
  2179. echo "HOSTLIBS=$host_libs" >> config.mak
  2180. echo "TARGET_EXEC=$target_exec" >> config.mak
  2181. echo "TARGET_PATH=$target_path" >> config.mak
  2182. if enabled bigendian; then
  2183. echo "WORDS_BIGENDIAN=yes" >> config.mak
  2184. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  2185. fi
  2186. if enabled sdl; then
  2187. echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
  2188. echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
  2189. fi
  2190. if enabled texi2html; then
  2191. echo "BUILD_DOC=yes" >> config.mak
  2192. fi
  2193. get_version(){
  2194. name=$1
  2195. file=$source_path/$2
  2196. eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
  2197. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  2198. lcname=$(tolower $name)
  2199. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  2200. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  2201. }
  2202. get_version LIBSWSCALE libswscale/swscale.h
  2203. get_version LIBPOSTPROC libpostproc/postprocess.h
  2204. get_version LIBAVCODEC libavcodec/avcodec.h
  2205. get_version LIBAVDEVICE libavdevice/avdevice.h
  2206. get_version LIBAVFORMAT libavformat/avformat.h
  2207. get_version LIBAVUTIL libavutil/avutil.h
  2208. get_version LIBAVFILTER libavfilter/avfilter.h
  2209. if enabled shared; then
  2210. echo "BUILD_SHARED=yes" >> config.mak
  2211. echo "PIC=-fPIC -DPIC" >> config.mak
  2212. echo "LIBTARGET=${LIBTARGET}" >> config.mak
  2213. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  2214. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  2215. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  2216. echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
  2217. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  2218. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  2219. echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
  2220. fi
  2221. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  2222. echo "EXTRALIBS=$extralibs" >> config.mak
  2223. echo "ARCH=$arch" >> config.mak
  2224. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  2225. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  2226. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  2227. $CONFIG_EXTRA \
  2228. $DECODER_LIST \
  2229. $ENCODER_LIST \
  2230. $PARSER_LIST \
  2231. $BSF_LIST \
  2232. $DEMUXER_LIST \
  2233. $MUXER_LIST \
  2234. $FILTER_LIST \
  2235. $PROTOCOL_LIST \
  2236. $INDEV_LIST \
  2237. $OUTDEV_LIST \
  2238. echo "#define restrict $_restrict" >> $TMPH
  2239. if enabled small; then
  2240. echo "#define av_always_inline" >> $TMPH
  2241. fi
  2242. echo "SRC_PATH=\"$source_path\"" >> config.mak
  2243. echo "SRC_PATH_BARE=$source_path" >> config.mak
  2244. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  2245. # Apparently it's not possible to portably echo a backslash.
  2246. enabled asmalign_pot &&
  2247. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
  2248. printf '#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\\n\\t"\n' >> $TMPH
  2249. echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
  2250. echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
  2251. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  2252. cmp -s $TMPH config.h &&
  2253. echo "config.h is unchanged" ||
  2254. mv -f $TMPH config.h
  2255. rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
  2256. # build tree in object directory if source path is different from current one
  2257. if enabled source_path_used; then
  2258. DIRS="\
  2259. doc \
  2260. libavcodec \
  2261. libavcodec/alpha \
  2262. libavcodec/arm \
  2263. libavcodec/bfin \
  2264. libavcodec/mlib \
  2265. libavcodec/ppc \
  2266. libavcodec/sh4 \
  2267. libavcodec/sparc \
  2268. libavcodec/x86 \
  2269. libavdevice \
  2270. libavfilter \
  2271. libavformat \
  2272. libavutil \
  2273. libpostproc \
  2274. libswscale \
  2275. tests \
  2276. tools \
  2277. vhook \
  2278. "
  2279. FILES="\
  2280. Makefile \
  2281. common.mak \
  2282. subdir.mak \
  2283. doc/texi2pod.pl \
  2284. libavcodec/Makefile \
  2285. libavdevice/Makefile \
  2286. libavfilter/Makefile \
  2287. libavformat/Makefile \
  2288. libavutil/Makefile \
  2289. libpostproc/Makefile \
  2290. libswscale/Makefile \
  2291. "
  2292. for dir in $DIRS ; do
  2293. mkdir -p $dir
  2294. done
  2295. for f in $FILES ; do
  2296. $ln_s "$source_path/$f" $f
  2297. done
  2298. fi
  2299. # build pkg-config files
  2300. pkgconfig_generate(){
  2301. name=$1
  2302. shortname=${name#lib}${build_suffix}
  2303. comment=$2
  2304. version=$3
  2305. libs=$4
  2306. requires=$5
  2307. cat <<EOF > $name/$name.pc
  2308. prefix=$prefix
  2309. exec_prefix=\${prefix}
  2310. libdir=$libdir
  2311. includedir=$incdir
  2312. Name: $name
  2313. Description: $comment
  2314. Version: $version
  2315. Requires: $(disabled shared && echo $requires)
  2316. Requires.private: $(enabled shared && echo $requires)
  2317. Conflicts:
  2318. Libs: -L\${libdir} -l${shortname} $(disabled shared && echo $libs)
  2319. Libs.private: $(enabled shared && echo $libs)
  2320. Cflags: -I\${includedir}
  2321. EOF
  2322. cat <<EOF > $name/$name-uninstalled.pc
  2323. prefix=
  2324. exec_prefix=
  2325. libdir=\${pcfiledir}
  2326. includedir=${source_path}
  2327. Name: $name
  2328. Description: $comment
  2329. Version: $version
  2330. Requires: $requires
  2331. Conflicts:
  2332. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  2333. Cflags: -I\${includedir}
  2334. EOF
  2335. }
  2336. pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
  2337. pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  2338. pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
  2339. pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
  2340. enabled avfilter &&
  2341. pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  2342. enabled postproc &&
  2343. pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
  2344. if enabled swscale; then
  2345. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
  2346. else
  2347. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavcodec = $LIBAVCODEC_VERSION"
  2348. apply libswscale/libswscale.pc sed s/^Libs:.*$/Libs:/
  2349. fi