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.

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