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.

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