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.

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