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.

2886 lines
83KB

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