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.

2868 lines
82KB

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