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.

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