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.

2717 lines
78KB

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