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.

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