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.

2732 lines
79KB

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