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.

2863 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. redir_demuxer_deps="network"
  1104. rtp_muxer_deps="network rtp_protocol"
  1105. rtsp_demuxer_deps="sdp_demuxer"
  1106. sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
  1107. tg2_muxer_select="mov_muxer"
  1108. tgp_muxer_select="mov_muxer"
  1109. w64_demuxer_deps="wav_demuxer"
  1110. # indevs / outdevs
  1111. alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
  1112. alsa_indev_extralibs="-lasound"
  1113. alsa_outdev_deps="alsa_asoundlib_h"
  1114. alsa_outdev_extralibs="-lasound"
  1115. audio_beos_indev_deps="audio_beos"
  1116. audio_beos_indev_extralibs="-lmedia -lbe"
  1117. audio_beos_outdev_deps="audio_beos"
  1118. audio_beos_outdev_extralibs="-lmedia -lbe"
  1119. bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  1120. dv1394_indev_deps="dv1394 dv_demuxer"
  1121. jack_indev_deps="jack_jack_h"
  1122. jack_indev_extralibs="-ljack"
  1123. libdc1394_indev_deps="libdc1394"
  1124. oss_indev_deps_any="soundcard_h sys_soundcard_h"
  1125. oss_outdev_deps_any="soundcard_h sys_soundcard_h"
  1126. v4l_indev_deps="linux_videodev_h"
  1127. v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
  1128. vfwcap_indev_deps="capCreateCaptureWindow"
  1129. vfwcap_indev_extralibs="-lvfw32"
  1130. x11_grab_device_indev_deps="x11grab XShmCreateImage"
  1131. x11_grab_device_indev_extralibs="-lX11 -lXext"
  1132. # protocols
  1133. gopher_protocol_deps="network"
  1134. http_protocol_deps="network"
  1135. rtmp_protocol_deps="tcp_protocol"
  1136. rtp_protocol_deps="udp_protocol"
  1137. tcp_protocol_deps="network"
  1138. udp_protocol_deps="network"
  1139. # filters
  1140. movie_filter_deps="avfilter_lavf"
  1141. # programs
  1142. ffplay_deps="sdl"
  1143. ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
  1144. ffserver_extralibs='$ldl'
  1145. # default parameters
  1146. logfile="config.err"
  1147. # installation paths
  1148. prefix_default="/usr/local"
  1149. bindir_default='${prefix}/bin'
  1150. datadir_default='${prefix}/share/ffmpeg'
  1151. incdir_default='${prefix}/include'
  1152. libdir_default='${prefix}/lib'
  1153. mandir_default='${prefix}/share/man'
  1154. shlibdir_default="$libdir_default"
  1155. # toolchain
  1156. ar="ar"
  1157. cc_default="gcc"
  1158. cc_version=\"unknown\"
  1159. host_cc_default="gcc"
  1160. ln_s="ln -sf"
  1161. nm_default="nm"
  1162. objformat="elf"
  1163. ranlib="ranlib"
  1164. strip="strip"
  1165. yasmexe="yasm"
  1166. # machine
  1167. arch=$(uname -m)
  1168. cpu="generic"
  1169. # OS
  1170. target_os=$(tolower $(uname -s))
  1171. host_os=$target_os
  1172. # configurable options
  1173. enable debug
  1174. enable fastdiv
  1175. enable ffmpeg
  1176. enable ffplay
  1177. enable ffserver
  1178. enable ipv6
  1179. enable mpegaudio_hp
  1180. enable network
  1181. enable optimizations
  1182. enable protocols
  1183. enable static
  1184. enable stripping
  1185. enable swscale_alpha
  1186. # build settings
  1187. SHFLAGS='-shared -Wl,-soname,$$(@F)'
  1188. FFSERVERLDFLAGS=-Wl,-E
  1189. LIBPREF="lib"
  1190. LIBSUF=".a"
  1191. FULLNAME='$(NAME)$(BUILDSUF)'
  1192. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  1193. SLIBPREF="lib"
  1194. SLIBSUF=".so"
  1195. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  1196. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  1197. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  1198. LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  1199. CC_O='-o $@'
  1200. host_cflags='-O3 -g -Wall'
  1201. host_libs='-lm'
  1202. target_path='.'
  1203. # gcc stupidly only outputs the basename of targets with -MM, but we need the
  1204. # full relative path for objects in subdirectories for non-recursive Make.
  1205. DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
  1206. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
  1207. # find source path
  1208. source_path="$(dirname "$0")"
  1209. enable source_path_used
  1210. if test -f configure; then
  1211. source_path="$(pwd)"
  1212. disable source_path_used
  1213. else
  1214. source_path="$(cd "$source_path"; pwd)"
  1215. echo "$source_path" | grep -q '[[:blank:]]' &&
  1216. die "Out of tree builds are impossible with whitespace in source path."
  1217. test -e "$source_path/config.h" &&
  1218. die "Out of tree builds are impossible with config.h in source dir."
  1219. fi
  1220. for v in "$@"; do
  1221. r=${v#*=}
  1222. l=${v%"$r"}
  1223. r=$(sh_quote "$r")
  1224. FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
  1225. done
  1226. find_things(){
  1227. thing=$1
  1228. pattern=$2
  1229. file=$source_path/$3
  1230. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  1231. }
  1232. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  1233. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  1234. HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
  1235. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  1236. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  1237. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  1238. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  1239. OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
  1240. INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
  1241. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  1242. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  1243. enable $ARCH_EXT_LIST \
  1244. $DECODER_LIST \
  1245. $ENCODER_LIST \
  1246. $HWACCEL_LIST \
  1247. $PARSER_LIST \
  1248. $BSF_LIST \
  1249. $DEMUXER_LIST \
  1250. $MUXER_LIST \
  1251. $FILTER_LIST \
  1252. $PROTOCOL_LIST \
  1253. $INDEV_LIST \
  1254. $OUTDEV_LIST \
  1255. die_unknown(){
  1256. echo "Unknown option \"$1\"."
  1257. echo "See $0 --help for available options."
  1258. exit 1
  1259. }
  1260. show_list() {
  1261. suffix=_$1
  1262. shift
  1263. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
  1264. exit 0
  1265. }
  1266. for opt do
  1267. optval="${opt#*=}"
  1268. case "$opt" in
  1269. --extra-ldflags=*) add_ldflags $optval
  1270. ;;
  1271. --extra-libs=*) add_extralibs $optval
  1272. ;;
  1273. --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
  1274. ;;
  1275. --enable-debug=*) debuglevel="$optval"
  1276. ;;
  1277. --enable-*=*|--disable-*=*)
  1278. eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
  1279. is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
  1280. eval list=\$$(toupper $thing)_LIST
  1281. name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
  1282. $action $(filter "$name" $list)
  1283. ;;
  1284. --enable-?*|--disable-?*)
  1285. eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
  1286. if is_in $option $COMPONENT_LIST; then
  1287. test $action = disable && action=unset
  1288. eval $action \$$(toupper ${option%s})_LIST
  1289. elif is_in $option $CMDLINE_SELECT; then
  1290. $action $option
  1291. else
  1292. die_unknown $opt
  1293. fi
  1294. ;;
  1295. --list-*)
  1296. NAME="${opt#--list-}"
  1297. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  1298. NAME=${NAME%s}
  1299. eval show_list $NAME \$$(toupper $NAME)_LIST
  1300. ;;
  1301. --help|-h) show_help
  1302. ;;
  1303. *)
  1304. optname="${opt%%=*}"
  1305. optname="${optname#--}"
  1306. optname=$(echo "$optname" | sed 's/-/_/g')
  1307. if is_in $optname $CMDLINE_SET; then
  1308. eval $optname='$optval'
  1309. elif is_in $optname $CMDLINE_APPEND; then
  1310. append $optname "$optval"
  1311. else
  1312. die_unknown $opt
  1313. fi
  1314. ;;
  1315. esac
  1316. done
  1317. disabled logging && logfile=/dev/null
  1318. echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
  1319. set >> $logfile
  1320. test -n "$cross_prefix" && enable cross_compile
  1321. ar="${cross_prefix}${ar}"
  1322. cc_default="${cross_prefix}${cc_default}"
  1323. nm_default="${cross_prefix}${nm_default}"
  1324. ranlib="${cross_prefix}${ranlib}"
  1325. strip="${cross_prefix}${strip}"
  1326. sysinclude_default="${sysroot}/usr/include"
  1327. set_default cc nm sysinclude
  1328. enabled cross_compile || host_cc_default=$cc
  1329. set_default host_cc
  1330. exesuf() {
  1331. case $1 in
  1332. mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
  1333. esac
  1334. }
  1335. EXESUF=$(exesuf $target_os)
  1336. HOSTEXESUF=$(exesuf $host_os)
  1337. # set temporary file name
  1338. : ${TMPDIR:=$TEMPDIR}
  1339. : ${TMPDIR:=$TMP}
  1340. : ${TMPDIR:=/tmp}
  1341. if ! check_cmd type mktemp; then
  1342. # simple replacement for missing mktemp
  1343. # NOT SAFE FOR GENERAL USE
  1344. mktemp(){
  1345. echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
  1346. }
  1347. fi
  1348. tmpfile(){
  1349. tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
  1350. (set -C; exec > $tmp) 2>/dev/null ||
  1351. die "Unable to create temporary file in $TMPDIR."
  1352. append TMPFILES $tmp
  1353. eval $1=$tmp
  1354. }
  1355. trap 'rm -f -- $TMPFILES' EXIT
  1356. trap exit HUP INT TERM
  1357. tmpfile TMPC .c
  1358. tmpfile TMPE $EXESUF
  1359. tmpfile TMPH .h
  1360. tmpfile TMPO .o
  1361. tmpfile TMPS .S
  1362. tmpfile TMPSH .sh
  1363. unset -f mktemp
  1364. # make sure we can execute files in $TMPDIR
  1365. cat > $TMPSH 2>> $logfile <<EOF
  1366. #! /bin/sh
  1367. EOF
  1368. chmod +x $TMPSH >> $logfile 2>&1
  1369. if ! $TMPSH >> $logfile 2>&1; then
  1370. cat <<EOF
  1371. Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
  1372. variable to another directory and make sure that it is not mounted noexec.
  1373. EOF
  1374. die "Sanity test failed."
  1375. fi
  1376. filter_cflags=echo
  1377. filter_cppflags=echo
  1378. filter_asflags=echo
  1379. if $cc -v 2>&1 | grep -qi ^gcc; then
  1380. cc_type=gcc
  1381. cc_version=__VERSION__
  1382. if ! $cc -dumpversion | grep -q '^2\.'; then
  1383. CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1384. AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1385. fi
  1386. elif $cc --version 2>/dev/null | grep -q Intel; then
  1387. cc_type=icc
  1388. cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
  1389. CC_DEPFLAGS='-MMD'
  1390. AS_DEPFLAGS='-MMD'
  1391. elif $cc -v 2>&1 | grep -q xlc; then
  1392. cc_type=xlc
  1393. cc_version="AV_STRINGIFY(__IBMC__)"
  1394. elif $cc -V 2>/dev/null | grep -q Compaq; then
  1395. cc_type=ccc
  1396. cc_version="AV_STRINGIFY(__DECC_VER)"
  1397. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
  1398. debuglevel=3
  1399. add_ldflags -Wl,-z,now # calls to libots crash without this
  1400. elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
  1401. test -d "$sysroot" || die "No valid sysroot specified."
  1402. cc_type=armcc
  1403. cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
  1404. armcc_conf="$PWD/armcc.conf"
  1405. $cc --arm_linux_configure \
  1406. --arm_linux_config_file="$armcc_conf" \
  1407. --configure_sysroot="$sysroot" \
  1408. --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
  1409. die "Error creating armcc configuration file."
  1410. cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
  1411. as_default="${cross_prefix}gcc"
  1412. CC_DEPFLAGS='-MMD'
  1413. AS_DEPFLAGS='-MMD'
  1414. elif $cc -version 2>/dev/null | grep -q TMS470; then
  1415. cc_type=tms470
  1416. cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
  1417. cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
  1418. CC_O='-fr=$(@D)'
  1419. as_default="${cross_prefix}gcc"
  1420. ld_default="${cross_prefix}gcc"
  1421. TMPO=$(basename $TMPC .c).o
  1422. append TMPFILES $TMPO
  1423. add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
  1424. CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
  1425. AS_DEPFLAGS='-MMD'
  1426. filter_cflags=tms470_flags
  1427. tms470_flags(){
  1428. for flag; do
  1429. case $flag in
  1430. -march=*|-mcpu=*)
  1431. case "${flag#*=}" in
  1432. armv7-a|cortex-a*) echo -mv=7a8 ;;
  1433. armv7-r|cortex-r*) echo -mv=7r4 ;;
  1434. armv7-m|cortex-m*) echo -mv=7m3 ;;
  1435. armv6*|arm11*) echo -mv=6 ;;
  1436. armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
  1437. echo -mv=5e ;;
  1438. armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
  1439. esac
  1440. ;;
  1441. -mfpu=neon) echo --float_support=vfpv3 --neon ;;
  1442. -mfpu=vfp) echo --float_support=vfpv2 ;;
  1443. -msoft-float) echo --float_support=vfplib ;;
  1444. -Os) echo -O3 -mf=2 ;;
  1445. -O[0-3]) echo $flag -mf=5 ;;
  1446. -g) echo -g -mn ;;
  1447. esac
  1448. done
  1449. }
  1450. elif $cc -v 2>&1 | grep -q clang; then
  1451. cc_type=clang
  1452. cc_version=__VERSION__
  1453. CC_DEPFLAGS='-MMD'
  1454. AS_DEPFLAGS='-MMD'
  1455. fi
  1456. test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
  1457. : ${as_default:=$cc}
  1458. : ${dep_cc_default:=$cc}
  1459. : ${ld_default:=$cc}
  1460. set_default as dep_cc ld
  1461. test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
  1462. test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
  1463. add_cflags $extra_cflags
  1464. add_asflags $extra_cflags
  1465. if test -n "$sysroot"; then
  1466. case "$cc_type" in
  1467. gcc)
  1468. add_cppflags --sysroot="$sysroot"
  1469. add_ldflags --sysroot="$sysroot"
  1470. ;;
  1471. tms470)
  1472. add_cppflags -I"$sysinclude"
  1473. add_ldflags --sysroot="$sysroot"
  1474. ;;
  1475. clang)
  1476. add_cppflags -isysroot="$sysroot"
  1477. add_ldflags -isysroot="$sysroot"
  1478. ;;
  1479. esac
  1480. fi
  1481. if test "$cpu" = host; then
  1482. enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
  1483. case "$cc_type" in
  1484. gcc)
  1485. check_native(){
  1486. $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
  1487. awk "/$1=/{ match(\$0, /$1=(\\w+)/, a);print a[1];exit }" $TMPE
  1488. }
  1489. cpu=$(check_native -march || check_native -mcpu)
  1490. ;;
  1491. esac
  1492. test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
  1493. fi
  1494. # Add processor-specific flags
  1495. case $cpu in
  1496. 601|ppc601|PowerPC601)
  1497. cpuflags="-mcpu=601"
  1498. ;;
  1499. 603*|ppc603*|PowerPC603*)
  1500. cpuflags="-mcpu=603"
  1501. ;;
  1502. 604*|ppc604*|PowerPC604*)
  1503. cpuflags="-mcpu=604"
  1504. ;;
  1505. G3|g3|75*|ppc75*|PowerPC75*)
  1506. cpuflags="-mcpu=750 -mpowerpc-gfxopt"
  1507. ;;
  1508. G4|g4|745*|ppc745*|PowerPC745*)
  1509. cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
  1510. ;;
  1511. 74*|ppc74*|PowerPC74*)
  1512. cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
  1513. ;;
  1514. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1515. cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1516. ;;
  1517. Cell|CELL|cell)
  1518. cpuflags="-mcpu=cell"
  1519. enable ldbrx
  1520. ;;
  1521. # targets that do NOT support conditional mov (cmov)
  1522. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1523. cpuflags="-march=$cpu"
  1524. disable cmov
  1525. ;;
  1526. # targets that do support conditional mov (cmov)
  1527. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1528. cpuflags="-march=$cpu"
  1529. enable cmov
  1530. enable fast_cmov
  1531. ;;
  1532. # targets that do support conditional mov but on which it's slow
  1533. pentium4|pentium4m|prescott|nocona)
  1534. cpuflags="-march=$cpu"
  1535. enable cmov
  1536. disable fast_cmov
  1537. ;;
  1538. sparc64)
  1539. cpuflags="-mcpu=v9"
  1540. ;;
  1541. arm11*|cortex*)
  1542. cpuflags="-mcpu=$cpu"
  1543. enable fast_unaligned
  1544. ;;
  1545. armv[67]*)
  1546. cpuflags="-march=$cpu"
  1547. enable fast_unaligned
  1548. ;;
  1549. armv*)
  1550. cpuflags="-march=$cpu"
  1551. ;;
  1552. arm*)
  1553. cpuflags="-mcpu=$cpu"
  1554. ;;
  1555. ev4|ev45|ev5|ev56|pca56|ev6|ev67)
  1556. enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
  1557. ;;
  1558. bf*)
  1559. cpuflags="-mcpu=$cpu"
  1560. ;;
  1561. mips*|[45]k*|[237]4k*|m4k|r*000|loongson2[ef])
  1562. cpuflags="-march=$cpu"
  1563. ;;
  1564. ap7[02]0[0-2])
  1565. subarch="avr32_ap"
  1566. cpuflags="-mpart=$cpu"
  1567. ;;
  1568. ap)
  1569. subarch="avr32_ap"
  1570. cpuflags="-march=$cpu"
  1571. ;;
  1572. uc3[ab]*)
  1573. subarch="avr32_uc"
  1574. cpuflags="-mcpu=$cpu"
  1575. ;;
  1576. uc)
  1577. subarch="avr32_uc"
  1578. cpuflags="-march=$cpu"
  1579. ;;
  1580. generic)
  1581. ;;
  1582. *)
  1583. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1584. ;;
  1585. esac
  1586. add_cflags $cpuflags
  1587. add_asflags $cpuflags
  1588. # compiler sanity check
  1589. check_exec <<EOF
  1590. int main(void){ return 0; }
  1591. EOF
  1592. if test "$?" != 0; then
  1593. echo "$cc is unable to create an executable file."
  1594. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1595. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  1596. echo "Only do this if you know what cross compiling means."
  1597. fi
  1598. die "C compiler test failed."
  1599. fi
  1600. add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
  1601. check_cflags -std=c99
  1602. check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
  1603. #include <stdlib.h>
  1604. EOF
  1605. check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
  1606. #include <stdlib.h>
  1607. EOF
  1608. case "$arch" in
  1609. alpha)
  1610. arch="alpha"
  1611. enable fast_64bit
  1612. check_cflags -mieee
  1613. spic=$shared
  1614. ;;
  1615. arm|armv[4567]*l)
  1616. arch="arm"
  1617. ;;
  1618. avr32)
  1619. ;;
  1620. bfin)
  1621. arch="bfin"
  1622. ;;
  1623. ia64)
  1624. arch="ia64"
  1625. enable fast_64bit
  1626. spic=$shared
  1627. ;;
  1628. m68k)
  1629. arch="m68k"
  1630. ;;
  1631. mips|mipsel|IP*)
  1632. arch="mips"
  1633. spic=$shared
  1634. ;;
  1635. mips64)
  1636. arch="mips"
  1637. subarch="mips64"
  1638. enable fast_64bit
  1639. spic=$shared
  1640. ;;
  1641. parisc|hppa)
  1642. arch="parisc"
  1643. spic=$shared
  1644. ;;
  1645. parisc64|hppa64)
  1646. arch="parisc"
  1647. enable fast_64bit
  1648. spic=$shared
  1649. ;;
  1650. "Power Macintosh"|ppc|powerpc)
  1651. arch="ppc"
  1652. enable fast_unaligned
  1653. ;;
  1654. ppc64)
  1655. arch="ppc"
  1656. subarch="ppc64"
  1657. enable fast_64bit
  1658. enable fast_unaligned
  1659. ;;
  1660. s390|s390x)
  1661. arch="s390"
  1662. ;;
  1663. sh4|sh)
  1664. arch="sh4"
  1665. ;;
  1666. sparc)
  1667. arch="sparc"
  1668. spic=$shared
  1669. ;;
  1670. sun4u|sparc64)
  1671. arch="sparc"
  1672. subarch="sparc64"
  1673. enable fast_64bit
  1674. spic=$shared
  1675. ;;
  1676. i386|i486|i586|i686|i86pc|BePC|x86_64|amd64)
  1677. arch="x86"
  1678. subarch="x86_32"
  1679. enable fast_unaligned
  1680. check_cc <<EOF && enable fast_64bit && subarch="x86_64" && spic=$shared
  1681. int test[sizeof(char*) - 7];
  1682. EOF
  1683. if test "$subarch" = "x86_64"; then
  1684. enable cmov
  1685. enable fast_cmov
  1686. fi
  1687. ;;
  1688. *)
  1689. arch="unknown"
  1690. ;;
  1691. esac
  1692. enable $arch $subarch
  1693. enabled spic && enable pic
  1694. # OS specific
  1695. case $target_os in
  1696. beos|haiku|zeta)
  1697. prefix_default="$HOME/config"
  1698. # helps building libavcodec
  1699. add_cppflags -DPIC
  1700. add_cflags -fomit-frame-pointer
  1701. # 3 gcc releases known for BeOS, each with ugly bugs
  1702. gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
  1703. case "$gcc_version" in
  1704. 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
  1705. disable mmx
  1706. ;;
  1707. *20010315*) echo "BeBits gcc"
  1708. add_cflags -fno-expensive-optimizations
  1709. ;;
  1710. esac
  1711. SHFLAGS=-nostart
  1712. # enable BeOS things
  1713. enable audio_beos
  1714. # no need for libm, but the inet stuff
  1715. # Check for BONE
  1716. # XXX: actually should check for NOT net_server
  1717. if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
  1718. network_extralibs="-lbind -lsocket"
  1719. else
  1720. enable beos_netserver
  1721. network_extralibs="-lnet"
  1722. fi ;;
  1723. sunos)
  1724. FFSERVERLDFLAGS=""
  1725. SHFLAGS='-shared -Wl,-h,$$(@F)'
  1726. network_extralibs="-lsocket -lnsl"
  1727. add_cppflags -D__EXTENSIONS__
  1728. ;;
  1729. netbsd)
  1730. oss_indev_extralibs="-lossaudio"
  1731. oss_outdev_extralibs="-lossaudio"
  1732. ;;
  1733. openbsd)
  1734. enable malloc_aligned
  1735. enable pic
  1736. SHFLAGS='-shared'
  1737. oss_indev_extralibs="-lossaudio"
  1738. oss_outdev_extralibs="-lossaudio"
  1739. ;;
  1740. freebsd|dragonfly)
  1741. enable malloc_aligned
  1742. ;;
  1743. bsd/os)
  1744. osextralibs="-lpoll -lgnugetopt"
  1745. strip="strip -d"
  1746. ;;
  1747. darwin)
  1748. enable malloc_aligned
  1749. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
  1750. strip="strip -x"
  1751. FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
  1752. SLIBSUF=".dylib"
  1753. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  1754. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  1755. FFSERVERLDFLAGS=-Wl,-bind_at_load
  1756. objformat="macho"
  1757. enabled x86_64 && objformat="macho64"
  1758. enabled_any pic shared ||
  1759. { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
  1760. ;;
  1761. mingw32*)
  1762. if test $target_os = "mingw32ce"; then
  1763. disable network
  1764. else
  1765. target_os=mingw32
  1766. fi
  1767. LIBTARGET=i386
  1768. if enabled x86_64; then
  1769. enable malloc_aligned
  1770. LIBTARGET=x64
  1771. elif enabled arm; then
  1772. LIBTARGET=arm
  1773. fi
  1774. shlibdir_default="$bindir_default"
  1775. disable ffserver
  1776. SLIBPREF=""
  1777. SLIBSUF=".dll"
  1778. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1779. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1780. SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
  1781. SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
  1782. install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
  1783. install -d "$(LIBDIR)"; \
  1784. install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"'
  1785. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  1786. 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'
  1787. objformat="win32"
  1788. enable dos_paths
  1789. check_cflags -fno-common
  1790. if ! enabled x86_64; then
  1791. check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
  1792. die "ERROR: MinGW runtime version must be >= 3.15."
  1793. enabled_any avisynth vfwcap_indev &&
  1794. { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
  1795. die "ERROR: avisynth and vfwcap_indev require w32api version 3.13 or later."; }
  1796. fi
  1797. ;;
  1798. cygwin*)
  1799. target_os=cygwin
  1800. shlibdir_default="$bindir_default"
  1801. SLIBPREF="cyg"
  1802. SLIBSUF=".dll"
  1803. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1804. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1805. SHFLAGS='-shared -Wl,--enable-auto-image-base'
  1806. objformat="win32"
  1807. enable dos_paths
  1808. check_cflags -fno-common
  1809. ;;
  1810. *-dos|freedos|opendos)
  1811. disable ffplay ffserver
  1812. disable $INDEV_LIST $OUTDEV_LIST
  1813. network_extralibs="-lsocket"
  1814. objformat="coff"
  1815. enable dos_paths
  1816. ;;
  1817. linux)
  1818. enable dv1394
  1819. ;;
  1820. irix*)
  1821. target_os=irix
  1822. ranlib="echo ignoring ranlib"
  1823. ;;
  1824. os/2*)
  1825. strip="lxlite"
  1826. ln_s="cp -f"
  1827. FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
  1828. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  1829. FFSERVERLDFLAGS=""
  1830. LIBSUF="_s.a"
  1831. SLIBPREF=""
  1832. SLIBSUF=".dll"
  1833. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1834. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  1835. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  1836. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  1837. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  1838. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  1839. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  1840. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  1841. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  1842. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  1843. SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
  1844. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
  1845. enable dos_paths
  1846. ;;
  1847. gnu/kfreebsd)
  1848. ;;
  1849. gnu)
  1850. ;;
  1851. *)
  1852. die "Unknown OS '$target_os'."
  1853. ;;
  1854. esac
  1855. set_default $PATHS_LIST
  1856. add_extralibs $osextralibs
  1857. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1858. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1859. # we need to build at least one lib type
  1860. if ! enabled_any static shared; then
  1861. cat <<EOF
  1862. At least one library type must be built.
  1863. Specify --enable-static to build the static libraries or --enable-shared to
  1864. build the shared libraries as well. To only build the shared libraries specify
  1865. --disable-static in addition to --enable-shared.
  1866. EOF
  1867. exit 1;
  1868. fi
  1869. disabled static && LIBNAME=""
  1870. if enabled_any libfaad libfaadbin ; then
  1871. if check_header faad.h; then
  1872. check_cc <<EOF
  1873. #include <faad.h>
  1874. #ifndef FAAD2_VERSION
  1875. ok faad1
  1876. #endif
  1877. int main(void) { return 0; }
  1878. EOF
  1879. test $? = 0 && enable libfaad2
  1880. else
  1881. die "FAAD test failed."
  1882. fi
  1883. fi
  1884. die_license_disabled() {
  1885. enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
  1886. }
  1887. die_license_disabled gpl libfaad2
  1888. die_license_disabled gpl libx264
  1889. die_license_disabled gpl libxvid
  1890. die_license_disabled gpl postproc
  1891. die_license_disabled gpl x11grab
  1892. die_license_disabled nonfree libfaac
  1893. die_license_disabled version3 libopencore_amrnb
  1894. die_license_disabled version3 libopencore_amrwb
  1895. enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
  1896. check_deps $ARCH_EXT_LIST
  1897. disabled optimizations || check_cflags -fomit-frame-pointer
  1898. enable_pic() {
  1899. enable pic
  1900. add_cppflags -DPIC
  1901. add_cflags -fPIC
  1902. add_asflags -fPIC
  1903. }
  1904. enabled pic && enable_pic
  1905. check_cc <<EOF || die "Symbol mangling check failed."
  1906. int ff_extern;
  1907. EOF
  1908. sym=$($nm -P -g $TMPO | grep ff_extern)
  1909. extern_prefix=${sym%%ff_extern*}
  1910. check_cc <<EOF && enable inline_asm
  1911. void foo(void) { __asm__ volatile ("" ::); }
  1912. EOF
  1913. _restrict=
  1914. for restrict_keyword in restrict __restrict__ __restrict; do
  1915. check_cc <<EOF && _restrict=$restrict_keyword && break
  1916. void foo(char * $restrict_keyword p);
  1917. EOF
  1918. done
  1919. check_cc <<EOF && enable attribute_packed
  1920. struct { int x; } __attribute__((packed)) x;
  1921. EOF
  1922. check_cc <<EOF || die "endian test failed"
  1923. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  1924. EOF
  1925. od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  1926. if enabled arm; then
  1927. check_cflags -marm
  1928. check_ld <<EOF && enable vfp_args
  1929. __asm__ (".eabi_attribute 28, 1");
  1930. int main(void) { return 0; }
  1931. EOF
  1932. # We have to check if pld is a nop and disable it.
  1933. check_asm pld '"pld [r0]"'
  1934. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  1935. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  1936. enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
  1937. enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
  1938. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  1939. enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
  1940. enabled_all armv6t2 shared !pic && enable_pic
  1941. elif enabled mips; then
  1942. check_asm loongson '"dmult.g $1, $2, $3"'
  1943. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  1944. elif enabled ppc; then
  1945. check_asm dcbzl '"dcbzl 0, 1"'
  1946. check_asm ppc4xx '"maclhw r10, r11, r12"'
  1947. check_asm xform_asm '"lwzx 0, %y0" :: "Z"(*(int*)0)'
  1948. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1949. if enabled altivec; then
  1950. check_cflags -maltivec -mabi=altivec &&
  1951. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  1952. check_cflags -faltivec
  1953. # check if our compiler supports Motorola AltiVec C API
  1954. check_cc <<EOF || disable altivec
  1955. $inc_altivec_h
  1956. int main(void) {
  1957. vector signed int v1, v2, v3;
  1958. v1 = vec_add(v2,v3);
  1959. return 0;
  1960. }
  1961. EOF
  1962. # check if our compiler supports braces for vector declarations
  1963. check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
  1964. $inc_altivec_h
  1965. int main (void) { (vector int) {1}; return 0; }
  1966. EOF
  1967. fi
  1968. elif enabled sparc; then
  1969. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
  1970. add_cflags -mcpu=ultrasparc -mtune=ultrasparc
  1971. elif enabled x86; then
  1972. # check whether EBP is available on x86
  1973. # As 'i' is stored on the stack, this program will crash
  1974. # if the base pointer is used to access it because the
  1975. # base pointer is cleared in the inline assembly code.
  1976. check_exec_crash <<EOF && enable ebp_available
  1977. volatile int i=0;
  1978. __asm__ volatile (
  1979. "xorl %%ebp, %%ebp"
  1980. ::: "%ebp");
  1981. return i;
  1982. EOF
  1983. # check whether EBX is available on x86
  1984. check_asm ebx_available '""::"b"(0)' &&
  1985. check_asm ebx_available '"":::"%ebx"'
  1986. # check whether more than 10 operands are supported
  1987. check_cc <<EOF && enable ten_operands
  1988. int main(void) {
  1989. int x=0;
  1990. __asm__ volatile(
  1991. ""
  1992. :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
  1993. );
  1994. return 0;
  1995. }
  1996. EOF
  1997. # check whether binutils is new enough to compile SSSE3/MMX2
  1998. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  1999. enabled mmx2 && check_asm mmx2 '"pmaxub %mm0, %mm1"'
  2000. check_asm bswap '"bswap %%eax" ::: "%eax"'
  2001. YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
  2002. enabled x86_64 && append YASMFLAGS "-m amd64"
  2003. enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
  2004. case "$objformat" in
  2005. elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
  2006. macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
  2007. *) append YASMFLAGS "-DPREFIX" ;;
  2008. esac
  2009. disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
  2010. fi
  2011. if check_func dlopen; then
  2012. ldl=
  2013. elif check_func dlopen -ldl; then
  2014. ldl=-ldl
  2015. fi
  2016. # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
  2017. check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
  2018. check_func fork
  2019. check_func gethrtime
  2020. check_func getrusage
  2021. check_func inet_aton $network_extralibs
  2022. check_func isatty
  2023. check_func memalign
  2024. check_func mkstemp
  2025. check_func posix_memalign
  2026. check_func_headers io.h setmode
  2027. check_func_headers lzo/lzo1x.h lzo1x_999_compress
  2028. check_func_headers windows.h GetProcessTimes
  2029. check_func_headers windows.h VirtualAlloc
  2030. check_header conio.h
  2031. check_header dlfcn.h
  2032. check_header malloc.h
  2033. check_header poll.h
  2034. check_header sys/mman.h
  2035. check_header sys/resource.h
  2036. check_header sys/select.h
  2037. check_header termios.h
  2038. check_header vdpau/vdpau.h
  2039. check_header vdpau/vdpau_x11.h
  2040. check_header X11/extensions/XvMClib.h
  2041. if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
  2042. enabled_any $need_memalign ; then
  2043. die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
  2044. fi
  2045. disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
  2046. disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  2047. # check for some common methods of building with pthread support
  2048. # do this before the optional library checks as some of them require pthreads
  2049. if enabled pthreads; then
  2050. if check_func pthread_create; then
  2051. :
  2052. elif check_func pthread_create -pthread; then
  2053. add_cflags -pthread
  2054. add_extralibs -pthread
  2055. elif check_func pthread_create -pthreads; then
  2056. add_cflags -pthreads
  2057. add_extralibs -pthreads
  2058. elif check_func pthread_create -lpthreadGC2; then
  2059. add_extralibs -lpthreadGC2
  2060. elif ! check_lib pthread.h pthread_create -lpthread; then
  2061. die "ERROR: can't find pthreads library"
  2062. fi
  2063. fi
  2064. for thread in $THREADS_LIST; do
  2065. if enabled $thread; then
  2066. test -n "$thread_type" &&
  2067. die "ERROR: Only one thread type must be selected." ||
  2068. thread_type="$thread"
  2069. fi
  2070. done
  2071. check_lib math.h sin -lm
  2072. check_lib va/va.h vaInitialize -lva
  2073. check_func llrint
  2074. check_func log2
  2075. check_func lrint
  2076. check_func lrintf
  2077. check_func round
  2078. check_func roundf
  2079. check_func truncf
  2080. # these are off by default, so fail if requested and not available
  2081. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  2082. enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
  2083. require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
  2084. require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
  2085. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  2086. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  2087. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  2088. enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame -lm
  2089. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  2090. enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
  2091. enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
  2092. enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
  2093. enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
  2094. require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
  2095. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  2096. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  2097. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  2098. enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 -lm &&
  2099. { check_cpp_condition x264.h "X264_BUILD >= 78" ||
  2100. die "ERROR: libx264 version must be >= 0.78."; }
  2101. enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
  2102. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  2103. # libdc1394 check
  2104. if enabled libdc1394; then
  2105. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  2106. enable libdc1394_2; } ||
  2107. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  2108. enable libdc1394_1; } ||
  2109. die "ERROR: No version of libdc1394 found "
  2110. fi
  2111. disable sdl_too_old
  2112. disable sdl
  2113. SDL_CONFIG="${cross_prefix}sdl-config"
  2114. if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
  2115. sdl_cflags=$("${SDL_CONFIG}" --cflags)
  2116. temp_cflags $sdl_cflags
  2117. temp_extralibs $("${SDL_CONFIG}" --libs)
  2118. if check_lib2 SDL.h SDL_Init; then
  2119. _sdlversion=$("${SDL_CONFIG}" --version | sed 's/[^0-9]//g')
  2120. if test "$_sdlversion" -lt 121 ; then
  2121. enable sdl_too_old
  2122. else
  2123. enable sdl
  2124. check_cc $sdl_cflags <<EOF && enable sdl_video_size
  2125. #include <SDL.h>
  2126. int main(int argc, char **argv){
  2127. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  2128. int w = vi->current_w;
  2129. return 0;
  2130. }
  2131. EOF
  2132. fi
  2133. fi
  2134. restore_flags
  2135. fi
  2136. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  2137. if enabled network; then
  2138. check_type "sys/types.h sys/socket.h" socklen_t
  2139. # Prefer arpa/inet.h over winsock2
  2140. if check_header arpa/inet.h ; then
  2141. check_func closesocket
  2142. elif check_header winsock2.h ; then
  2143. check_func_headers winsock2.h closesocket -lws2 && \
  2144. network_extralibs="-lws2" || \
  2145. { check_func_headers winsock2.h closesocket -lws2_32 && \
  2146. network_extralibs="-lws2_32"; }
  2147. check_type ws2tcpip.h socklen_t
  2148. else
  2149. disable network
  2150. fi
  2151. fi
  2152. enabled_all network ipv6 && check_ld <<EOF || disable ipv6
  2153. #include <sys/types.h>
  2154. #include <sys/socket.h>
  2155. #include <netinet/in.h>
  2156. #include <netdb.h>
  2157. int main(void) {
  2158. struct sockaddr_storage saddr;
  2159. struct ipv6_mreq mreq6;
  2160. getaddrinfo(0,0,0,0);
  2161. getnameinfo(0,0,0,0,0,0,0);
  2162. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  2163. }
  2164. EOF
  2165. check_header linux/videodev.h
  2166. check_header linux/videodev2.h
  2167. check_header sys/videoio.h
  2168. check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
  2169. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  2170. { check_header dev/bktr/ioctl_meteor.h &&
  2171. check_header dev/bktr/ioctl_bt848.h; } ||
  2172. { check_header machine/ioctl_meteor.h &&
  2173. check_header machine/ioctl_bt848.h; } ||
  2174. { check_header dev/video/meteor/ioctl_meteor.h &&
  2175. check_header dev/video/bktr/ioctl_bt848.h; } ||
  2176. check_header dev/ic/bt8xx.h
  2177. check_header sys/soundcard.h
  2178. check_header soundcard.h
  2179. enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
  2180. enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
  2181. enabled x11grab &&
  2182. check_header X11/Xlib.h &&
  2183. check_header X11/extensions/XShm.h &&
  2184. check_func XOpenDisplay -lX11 &&
  2185. check_func XShmCreateImage -lX11 -lXext
  2186. enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
  2187. # add some useful compiler flags if supported
  2188. check_cflags -Wdeclaration-after-statement
  2189. check_cflags -Wall
  2190. check_cflags -Wno-switch
  2191. check_cflags -Wdisabled-optimization
  2192. check_cflags -Wpointer-arith
  2193. check_cflags -Wredundant-decls
  2194. check_cflags -Wno-pointer-sign
  2195. check_cflags -Wcast-qual
  2196. check_cflags -Wwrite-strings
  2197. check_cflags -Wtype-limits
  2198. check_cflags -Wundef
  2199. enabled extra_warnings && check_cflags -Winline
  2200. # add some linker flags
  2201. check_ldflags -Wl,--warn-common
  2202. check_ldflags -Wl,--as-needed
  2203. 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'
  2204. check_ldflags -Wl,-Bsymbolic
  2205. if enabled small; then
  2206. check_cflags -Os # not all compilers support -Os
  2207. optimizations="small"
  2208. elif enabled optimizations; then
  2209. if enabled xlc; then
  2210. add_cflags -O5
  2211. add_ldflags -O5
  2212. elif enabled ccc; then
  2213. add_cflags -fast
  2214. else
  2215. add_cflags -O3
  2216. fi
  2217. fi
  2218. check_cflags -fno-math-errno
  2219. check_cflags -fno-signed-zeros
  2220. if enabled icc; then
  2221. # Just warnings, no remarks
  2222. check_cflags -w1
  2223. # -wd: Disable following warnings
  2224. # 144, 167, 556: -Wno-pointer-sign
  2225. # 10006: ignoring unknown option -fno-signed-zeros
  2226. # 10156: ignoring option '-W'; no argument required
  2227. check_cflags -wd144,167,556,10006,10156
  2228. # 11030: Warning unknown option --as-needed
  2229. # 10156: ignoring option '-export'; no argument required
  2230. check_ldflags -wd10156,11030
  2231. # Allow to compile with optimizations
  2232. check_ldflags -march=$cpu
  2233. # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
  2234. enable ebp_available
  2235. elif enabled ccc; then
  2236. # disable some annoying warnings
  2237. add_cflags -msg_disable cvtu32to64
  2238. add_cflags -msg_disable embedcomment
  2239. add_cflags -msg_disable needconstext
  2240. add_cflags -msg_disable nomainieee
  2241. add_cflags -msg_disable ptrmismatch1
  2242. add_cflags -msg_disable unreachcode
  2243. elif enabled gcc; then
  2244. check_cflags -fno-tree-vectorize
  2245. elif enabled clang; then
  2246. check_cflags -Qunused-arguments
  2247. fi
  2248. if enabled gprof; then
  2249. add_cflags -p
  2250. add_ldflags -p
  2251. fi
  2252. # Find out if the .align argument is a power of two or not.
  2253. check_asm asmalign_pot '".align 3"'
  2254. enabled_any $DECODER_LIST && enable decoders
  2255. enabled_any $ENCODER_LIST && enable encoders
  2256. enabled_any $HWACCEL_LIST && enable hwaccels
  2257. enabled_any $BSF_LIST && enable bsfs
  2258. enabled_any $DEMUXER_LIST && enable demuxers
  2259. enabled_any $MUXER_LIST && enable muxers
  2260. enabled_any $FILTER_LIST && enable filters
  2261. enabled_any $INDEV_LIST && enable indevs
  2262. enabled_any $OUTDEV_LIST && enable outdevs
  2263. enabled_any $PROTOCOL_LIST && enable protocols
  2264. enabled_any $THREADS_LIST && enable threads
  2265. check_deps $CONFIG_LIST \
  2266. $CONFIG_EXTRA \
  2267. $HAVE_LIST \
  2268. $DECODER_LIST \
  2269. $ENCODER_LIST \
  2270. $HWACCEL_LIST \
  2271. $PARSER_LIST \
  2272. $BSF_LIST \
  2273. $DEMUXER_LIST \
  2274. $MUXER_LIST \
  2275. $FILTER_LIST \
  2276. $INDEV_LIST \
  2277. $OUTDEV_LIST \
  2278. $PROTOCOL_LIST \
  2279. echo "install prefix $prefix"
  2280. echo "source path $source_path"
  2281. echo "C compiler $cc"
  2282. echo ".align is power-of-two $asmalign_pot"
  2283. echo "ARCH $arch ($cpu)"
  2284. if test "$build_suffix" != ""; then
  2285. echo "build suffix $build_suffix"
  2286. fi
  2287. if test "$extra_version" != ""; then
  2288. echo "version string suffix $extra_version"
  2289. fi
  2290. echo "big-endian ${bigendian-no}"
  2291. echo "runtime cpu detection ${runtime_cpudetect-no}"
  2292. if enabled x86; then
  2293. echo "yasm ${yasm-no}"
  2294. echo "MMX enabled ${mmx-no}"
  2295. echo "MMX2 enabled ${mmx2-no}"
  2296. echo "3DNow! enabled ${amd3dnow-no}"
  2297. echo "3DNow! extended enabled ${amd3dnowext-no}"
  2298. echo "SSE enabled ${sse-no}"
  2299. echo "SSSE3 enabled ${ssse3-no}"
  2300. echo "CMOV enabled ${cmov-no}"
  2301. echo "CMOV is fast ${fast_cmov-no}"
  2302. echo "EBX available ${ebx_available-no}"
  2303. echo "EBP available ${ebp_available-no}"
  2304. echo "10 operands supported ${ten_operands-no}"
  2305. fi
  2306. if enabled arm; then
  2307. echo "ARMv5TE enabled ${armv5te-no}"
  2308. echo "ARMv6 enabled ${armv6-no}"
  2309. echo "ARMv6T2 enabled ${armv6t2-no}"
  2310. echo "ARM VFP enabled ${armvfp-no}"
  2311. echo "IWMMXT enabled ${iwmmxt-no}"
  2312. echo "NEON enabled ${neon-no}"
  2313. fi
  2314. if enabled mips; then
  2315. echo "MMI enabled ${mmi-no}"
  2316. fi
  2317. if enabled ppc; then
  2318. echo "AltiVec enabled ${altivec-no}"
  2319. echo "PPC 4xx optimizations ${ppc4xx-no}"
  2320. echo "dcbzl available ${dcbzl-no}"
  2321. echo "performance report ${powerpc_perf-no}"
  2322. fi
  2323. if enabled sparc; then
  2324. echo "VIS enabled ${vis-no}"
  2325. fi
  2326. echo "gprof enabled ${gprof-no}"
  2327. echo "debug symbols ${debug-no}"
  2328. echo "strip symbols ${stripping-no}"
  2329. echo "optimizations ${optimizations-no}"
  2330. echo "static ${static-no}"
  2331. echo "shared ${shared-no}"
  2332. echo "postprocessing support ${postproc-no}"
  2333. echo "new filter support ${avfilter-no}"
  2334. echo "filters using lavformat ${avfilter_lavf-no}"
  2335. echo "network support ${network-no}"
  2336. if enabled network; then
  2337. echo "IPv6 support ${ipv6-no}"
  2338. fi
  2339. echo "threading support ${thread_type-no}"
  2340. echo "SDL support ${sdl-no}"
  2341. if enabled sdl_too_old; then
  2342. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  2343. fi
  2344. echo "Sun medialib support ${mlib-no}"
  2345. echo "AVISynth enabled ${avisynth-no}"
  2346. echo "libdc1394 support ${libdc1394-no}"
  2347. echo "libdirac enabled ${libdirac-no}"
  2348. echo "libfaac enabled ${libfaac-no}"
  2349. echo "libfaad enabled ${libfaad-no}"
  2350. echo "libfaad dlopened ${libfaadbin-no}"
  2351. echo "libgsm enabled ${libgsm-no}"
  2352. echo "libmp3lame enabled ${libmp3lame-no}"
  2353. echo "libnut enabled ${libnut-no}"
  2354. echo "libopencore-amrnb support ${libopencore_amrnb-no}"
  2355. echo "libopencore-amrwb support ${libopencore_amrwb-no}"
  2356. echo "libopenjpeg enabled ${libopenjpeg-no}"
  2357. echo "libschroedinger enabled ${libschroedinger-no}"
  2358. echo "libspeex enabled ${libspeex-no}"
  2359. echo "libtheora enabled ${libtheora-no}"
  2360. echo "libvorbis enabled ${libvorbis-no}"
  2361. echo "libx264 enabled ${libx264-no}"
  2362. echo "libxvid enabled ${libxvid-no}"
  2363. echo "zlib enabled ${zlib-no}"
  2364. echo "bzlib enabled ${bzlib-no}"
  2365. echo
  2366. for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
  2367. echo "Enabled ${type}s:"
  2368. eval list=\$$(toupper $type)_LIST
  2369. for part in $list; do
  2370. enabled $part && echo ${part%_*}
  2371. done | sort | pr -3 -t
  2372. echo
  2373. done
  2374. license="LGPL version 2.1 or later"
  2375. if enabled nonfree; then
  2376. license="nonfree and unredistributable"
  2377. elif enabled gplv3; then
  2378. license="GPL version 3 or later"
  2379. elif enabled lgplv3; then
  2380. license="LGPL version 3 or later"
  2381. elif enabled gpl; then
  2382. license="GPL version 2 or later"
  2383. fi
  2384. echo "License: $license"
  2385. echo "Creating config.mak and config.h..."
  2386. echo "# Automatically generated by configure - do not modify!" > config.mak
  2387. echo "ifndef FFMPEG_CONFIG_MAK" >> config.mak
  2388. echo "FFMPEG_CONFIG_MAK=1" >> config.mak
  2389. echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
  2390. echo "prefix=$prefix" >> config.mak
  2391. echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
  2392. echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
  2393. echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
  2394. echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
  2395. echo "DATADIR=\$(DESTDIR)$datadir" >> config.mak
  2396. echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
  2397. echo "SRC_PATH=\"$source_path\"" >> config.mak
  2398. echo "SRC_PATH_BARE=$source_path" >> config.mak
  2399. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  2400. echo "CC=$cc" >> config.mak
  2401. echo "AS=$as" >> config.mak
  2402. echo "LD=$ld" >> config.mak
  2403. echo "DEPCC=$dep_cc" >> config.mak
  2404. echo "YASM=$yasmexe" >> config.mak
  2405. echo "AR=$ar" >> config.mak
  2406. echo "RANLIB=$ranlib" >> config.mak
  2407. echo "LN_S=$ln_s" >> config.mak
  2408. enabled stripping &&
  2409. echo "STRIP=$strip" >> config.mak ||
  2410. echo "STRIP=echo ignoring strip" >> config.mak
  2411. echo "CPPFLAGS=$CPPFLAGS" >> config.mak
  2412. echo "CFLAGS=$CFLAGS" >> config.mak
  2413. echo "ASFLAGS=$ASFLAGS" >> config.mak
  2414. echo "CC_O=$CC_O" >> config.mak
  2415. echo "LDFLAGS=$LDFLAGS" >> config.mak
  2416. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  2417. echo "SHFLAGS=$SHFLAGS" >> config.mak
  2418. echo "YASMFLAGS=$YASMFLAGS" >> config.mak
  2419. echo "BUILDSUF=$build_suffix" >> config.mak
  2420. echo "FULLNAME=$FULLNAME" >> config.mak
  2421. echo "LIBPREF=$LIBPREF" >> config.mak
  2422. echo "LIBSUF=$LIBSUF" >> config.mak
  2423. echo "LIBNAME=$LIBNAME" >> config.mak
  2424. echo "SLIBPREF=$SLIBPREF" >> config.mak
  2425. echo "SLIBSUF=$SLIBSUF" >> config.mak
  2426. echo "EXESUF=$EXESUF" >> config.mak
  2427. echo "EXTRA_VERSION=$extra_version" >> config.mak
  2428. echo "DEPFLAGS=$DEPFLAGS" >> config.mak
  2429. echo "CCDEP=$CCDEP" >> config.mak
  2430. echo "ASDEP=$ASDEP" >> config.mak
  2431. echo "CC_DEPFLAGS=$CC_DEPFLAGS" >> config.mak
  2432. echo "AS_DEPFLAGS=$AS_DEPFLAGS" >> config.mak
  2433. echo "HOSTCC=$host_cc" >> config.mak
  2434. echo "HOSTCFLAGS=$host_cflags" >> config.mak
  2435. echo "HOSTEXESUF=$HOSTEXESUF" >> config.mak
  2436. echo "HOSTLDFLAGS=$host_ldflags" >> config.mak
  2437. echo "HOSTLIBS=$host_libs" >> config.mak
  2438. echo "TARGET_EXEC=$target_exec" >> config.mak
  2439. echo "TARGET_PATH=$target_path" >> config.mak
  2440. if enabled sdl; then
  2441. echo "SDL_LIBS=$("${SDL_CONFIG}" --libs)" >> config.mak
  2442. echo "SDL_CFLAGS=$("${SDL_CONFIG}" --cflags)" >> config.mak
  2443. fi
  2444. if enabled texi2html; then
  2445. echo "BUILD_DOC=yes" >> config.mak
  2446. fi
  2447. get_version(){
  2448. name=$1
  2449. file=$source_path/$2
  2450. eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
  2451. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  2452. lcname=$(tolower $name)
  2453. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  2454. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  2455. }
  2456. get_version LIBSWSCALE libswscale/swscale.h
  2457. get_version LIBPOSTPROC libpostproc/postprocess.h
  2458. get_version LIBAVCODEC libavcodec/avcodec.h
  2459. get_version LIBAVDEVICE libavdevice/avdevice.h
  2460. get_version LIBAVFORMAT libavformat/avformat.h
  2461. get_version LIBAVUTIL libavutil/avutil.h
  2462. get_version LIBAVFILTER libavfilter/avfilter.h
  2463. if enabled shared; then
  2464. echo "LIBTARGET=${LIBTARGET}" >> config.mak
  2465. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  2466. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  2467. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  2468. echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
  2469. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  2470. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  2471. echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
  2472. fi
  2473. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  2474. echo "EXTRALIBS=$extralibs" >> config.mak
  2475. echo "ARCH=$arch" >> config.mak
  2476. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  2477. echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
  2478. echo "#define FFMPEG_CONFIG_H" >> $TMPH
  2479. echo "#define FFMPEG_CONFIGURATION \"$(c_escape $FFMPEG_CONFIGURATION)\"" >> $TMPH
  2480. echo "#define FFMPEG_DATADIR \"$(eval c_escape $datadir)\"" >> $TMPH
  2481. echo "#define CC_TYPE \"$cc_type\"" >> $TMPH
  2482. echo "#define CC_VERSION $cc_version" >> $TMPH
  2483. echo "#define restrict $_restrict" >> $TMPH
  2484. if enabled small || disabled optimizations; then
  2485. echo "#define av_always_inline" >> $TMPH
  2486. fi
  2487. # Apparently it's not possible to portably echo a backslash.
  2488. enabled asmalign_pot &&
  2489. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
  2490. printf '#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\\n\\t"\n' >> $TMPH
  2491. echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
  2492. echo "#define EXTERN_ASM ${extern_prefix}" >> $TMPH
  2493. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  2494. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  2495. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  2496. $CONFIG_EXTRA \
  2497. $DECODER_LIST \
  2498. $ENCODER_LIST \
  2499. $HWACCEL_LIST \
  2500. $PARSER_LIST \
  2501. $BSF_LIST \
  2502. $DEMUXER_LIST \
  2503. $MUXER_LIST \
  2504. $FILTER_LIST \
  2505. $PROTOCOL_LIST \
  2506. $INDEV_LIST \
  2507. $OUTDEV_LIST \
  2508. echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
  2509. echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
  2510. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  2511. cmp -s $TMPH config.h &&
  2512. echo "config.h is unchanged" ||
  2513. mv -f $TMPH config.h
  2514. # build tree in object directory if source path is different from current one
  2515. if enabled source_path_used; then
  2516. DIRS="
  2517. doc
  2518. libavcodec
  2519. libavcodec/$arch
  2520. libavdevice
  2521. libavfilter
  2522. libavformat
  2523. libavutil
  2524. libavutil/$arch
  2525. libpostproc
  2526. libswscale
  2527. libswscale/$arch
  2528. tests
  2529. tools
  2530. "
  2531. FILES="
  2532. Makefile
  2533. common.mak
  2534. subdir.mak
  2535. doc/texi2pod.pl
  2536. libavcodec/Makefile
  2537. libavdevice/Makefile
  2538. libavfilter/Makefile
  2539. libavformat/Makefile
  2540. libavutil/Makefile
  2541. libpostproc/Makefile
  2542. libswscale/Makefile
  2543. "
  2544. for dir in $DIRS ; do
  2545. mkdir -p $dir
  2546. done
  2547. for f in $FILES ; do
  2548. $ln_s "$source_path/$f" $f
  2549. done
  2550. fi
  2551. # build pkg-config files
  2552. pkgconfig_generate(){
  2553. name=$1
  2554. shortname=${name#lib}${build_suffix}
  2555. comment=$2
  2556. version=$3
  2557. libs=$4
  2558. requires=$5
  2559. cat <<EOF > $name/$name.pc
  2560. prefix=$prefix
  2561. exec_prefix=\${prefix}
  2562. libdir=$libdir
  2563. includedir=$incdir
  2564. Name: $name
  2565. Description: $comment
  2566. Version: $version
  2567. Requires: $(enabled shared || echo $requires)
  2568. Requires.private: $(enabled shared && echo $requires)
  2569. Conflicts:
  2570. Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
  2571. Libs.private: $(enabled shared && echo $libs)
  2572. Cflags: -I\${includedir}
  2573. EOF
  2574. cat <<EOF > $name/$name-uninstalled.pc
  2575. prefix=
  2576. exec_prefix=
  2577. libdir=\${pcfiledir}
  2578. includedir=${source_path}
  2579. Name: $name
  2580. Description: $comment
  2581. Version: $version
  2582. Requires: $requires
  2583. Conflicts:
  2584. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  2585. Cflags: -I\${includedir}
  2586. EOF
  2587. }
  2588. pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
  2589. pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  2590. pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
  2591. pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
  2592. enabled avfilter &&
  2593. pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  2594. enabled postproc &&
  2595. pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
  2596. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"