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.

2843 lines
81KB

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