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.

2842 lines
81KB

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