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.

3263 lines
96KB

  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. cat <<EOF
  52. Usage: configure [options]
  53. Options: [defaults in brackets after descriptions]
  54. Standard options:
  55. --help print this message
  56. --logfile=FILE log tests and output to FILE [config.log]
  57. --disable-logging do not log configure debug information
  58. --prefix=PREFIX install in PREFIX [$prefix]
  59. --bindir=DIR install binaries in DIR [PREFIX/bin]
  60. --datadir=DIR install data files in DIR [PREFIX/share/ffmpeg]
  61. --libdir=DIR install libs in DIR [PREFIX/lib]
  62. --shlibdir=DIR install shared libs in DIR [PREFIX/lib]
  63. --incdir=DIR install includes in DIR [PREFIX/include]
  64. --mandir=DIR install man page in DIR [PREFIX/share/man]
  65. Configuration options:
  66. --disable-static do not build static libraries [no]
  67. --enable-shared build shared libraries [no]
  68. --enable-gpl allow use of GPL code, the resulting libs
  69. and binaries will be under GPL [no]
  70. --enable-version3 upgrade (L)GPL to version 3 [no]
  71. --enable-nonfree allow use of nonfree code, the resulting libs
  72. and binaries will be unredistributable [no]
  73. --disable-doc do not build documentation
  74. --disable-ffmpeg disable ffmpeg build
  75. --disable-ffplay disable ffplay build
  76. --disable-ffprobe disable ffprobe build
  77. --disable-ffserver disable ffserver build
  78. --disable-avdevice disable libavdevice build
  79. --disable-avcodec disable libavcodec build
  80. --disable-avcore disable libavcore build
  81. --disable-avformat disable libavformat build
  82. --disable-swscale disable libswscale build
  83. --enable-postproc enable GPLed postprocessing support [no]
  84. --disable-avfilter disable video filter support [no]
  85. --disable-pthreads disable pthreads [auto]
  86. --enable-w32threads use Win32 threads [no]
  87. --enable-x11grab enable X11 grabbing [no]
  88. --disable-network disable network support [no]
  89. --disable-mpegaudio-hp faster (but less accurate) MPEG audio decoding [no]
  90. --enable-gray enable full grayscale support (slower color)
  91. --disable-swscale-alpha disable alpha channel support in swscale
  92. --disable-fastdiv disable table-based division
  93. --enable-small optimize for size instead of speed
  94. --disable-aandct disable AAN DCT code
  95. --disable-dct disable DCT code
  96. --disable-fft disable FFT code
  97. --disable-golomb disable Golomb code
  98. --disable-huffman disable Huffman code
  99. --disable-lpc disable LPC code
  100. --disable-mdct disable MDCT code
  101. --disable-rdft disable RDFT code
  102. --disable-vaapi disable VAAPI code
  103. --disable-vdpau disable VDPAU code
  104. --disable-dxva2 disable DXVA2 code
  105. --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
  106. --enable-hardcoded-tables use hardcoded tables instead of runtime generation
  107. --enable-memalign-hack emulate memalign, interferes with memory debuggers
  108. --disable-everything disable all components listed below
  109. --disable-encoder=NAME disable encoder NAME
  110. --enable-encoder=NAME enable encoder NAME
  111. --disable-encoders disable all encoders
  112. --disable-decoder=NAME disable decoder NAME
  113. --enable-decoder=NAME enable decoder NAME
  114. --disable-decoders disable all decoders
  115. --disable-hwaccel=NAME disable hwaccel NAME
  116. --enable-hwaccel=NAME enable hwaccel NAME
  117. --disable-hwaccels disable all hwaccels
  118. --disable-muxer=NAME disable muxer NAME
  119. --enable-muxer=NAME enable muxer NAME
  120. --disable-muxers disable all muxers
  121. --disable-demuxer=NAME disable demuxer NAME
  122. --enable-demuxer=NAME enable demuxer NAME
  123. --disable-demuxers disable all demuxers
  124. --enable-parser=NAME enable parser NAME
  125. --disable-parser=NAME disable parser NAME
  126. --disable-parsers disable all parsers
  127. --enable-bsf=NAME enable bitstream filter NAME
  128. --disable-bsf=NAME disable bitstream filter NAME
  129. --disable-bsfs disable all bitstream filters
  130. --enable-protocol=NAME enable protocol NAME
  131. --disable-protocol=NAME disable protocol NAME
  132. --disable-protocols disable all protocols
  133. --disable-indev=NAME disable input device NAME
  134. --disable-outdev=NAME disable output device NAME
  135. --disable-indevs disable input devices
  136. --disable-outdevs disable output devices
  137. --disable-devices disable all devices
  138. --enable-filter=NAME enable filter NAME
  139. --disable-filter=NAME disable filter NAME
  140. --disable-filters disable all filters
  141. --list-decoders show all available decoders
  142. --list-encoders show all available encoders
  143. --list-hwaccels show all available hardware accelerators
  144. --list-muxers show all available muxers
  145. --list-demuxers show all available demuxers
  146. --list-parsers show all available parsers
  147. --list-protocols show all available protocols
  148. --list-bsfs show all available bitstream filters
  149. --list-indevs show all available input devices
  150. --list-outdevs show all available output devices
  151. --list-filters show all available filters
  152. External library support:
  153. --enable-avisynth enable reading of AVISynth script files [no]
  154. --enable-bzlib enable bzlib [autodetect]
  155. --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
  156. --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
  157. --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
  158. and libraw1394 [no]
  159. --enable-libdirac enable Dirac support via libdirac [no]
  160. --enable-libfaac enable FAAC support via libfaac [no]
  161. --enable-libgsm enable GSM support via libgsm [no]
  162. --enable-libmp3lame enable MP3 encoding via libmp3lame [no]
  163. --enable-libnut enable NUT (de)muxing via libnut,
  164. native (de)muxer exists [no]
  165. --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no]
  166. --enable-librtmp enable RTMP[E] support via librtmp [no]
  167. --enable-libschroedinger enable Dirac support via libschroedinger [no]
  168. --enable-libspeex enable Speex decoding via libspeex [no]
  169. --enable-libtheora enable Theora encoding via libtheora [no]
  170. --enable-libvorbis enable Vorbis encoding via libvorbis,
  171. native implementation exists [no]
  172. --enable-libvpx enable VP8 support via libvpx [no]
  173. --enable-libx264 enable H.264 encoding via x264 [no]
  174. --enable-libxavs enable AVS encoding via xavs [no]
  175. --enable-libxvid enable Xvid encoding via xvidcore,
  176. native MPEG-4/Xvid encoder exists [no]
  177. --enable-mlib enable Sun medialib [no]
  178. --enable-zlib enable zlib [autodetect]
  179. Advanced options (experts only):
  180. --source-path=PATH path to source code [$source_path]
  181. --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]
  182. --enable-cross-compile assume a cross-compiler is used
  183. --sysroot=PATH root of cross-build tree
  184. --sysinclude=PATH location of cross-build system headers
  185. --target-os=OS compiler targets OS [$target_os]
  186. --target-exec=CMD command to run executables on target
  187. --target-path=DIR path to view of build directory on target
  188. --nm=NM use nm tool
  189. --ar=AR use archive tool AR [$ar_default]
  190. --as=AS use assembler AS [$as_default]
  191. --cc=CC use C compiler CC [$cc_default]
  192. --ld=LD use linker LD
  193. --host-cc=HOSTCC use host C compiler HOSTCC
  194. --host-cflags=HCFLAGS use HCFLAGS when compiling for host
  195. --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
  196. --host-libs=HLIBS use libs HLIBS when linking for host
  197. --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
  198. --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
  199. --extra-libs=ELIBS add ELIBS [$ELIBS]
  200. --extra-version=STRING version string suffix []
  201. --build-suffix=SUFFIX library name suffix []
  202. --arch=ARCH select architecture [$arch]
  203. --cpu=CPU select the minimum required CPU (affects
  204. instruction selection, may crash on older CPUs)
  205. --disable-asm disable all assembler optimizations
  206. --disable-altivec disable AltiVec optimizations
  207. --disable-amd3dnow disable 3DNow! optimizations
  208. --disable-amd3dnowext disable 3DNow! extended optimizations
  209. --disable-mmx disable MMX optimizations
  210. --disable-mmx2 disable MMX2 optimizations
  211. --disable-sse disable SSE optimizations
  212. --disable-ssse3 disable SSSE3 optimizations
  213. --disable-armv5te disable armv5te optimizations
  214. --disable-armv6 disable armv6 optimizations
  215. --disable-armv6t2 disable armv6t2 optimizations
  216. --disable-armvfp disable ARM VFP optimizations
  217. --disable-iwmmxt disable iwmmxt optimizations
  218. --disable-mmi disable MMI optimizations
  219. --disable-neon disable neon optimizations
  220. --disable-vis disable VIS optimizations
  221. --disable-yasm disable use of yasm assembler
  222. --enable-pic build position-independent code
  223. --malloc-prefix=PFX prefix malloc and related names with PFX
  224. --enable-sram allow use of on-chip SRAM
  225. Developer options (useful when working on FFmpeg itself):
  226. --disable-debug disable debugging symbols
  227. --enable-debug=LEVEL set the debug level [$debuglevel]
  228. --disable-optimizations disable compiler optimizations
  229. --enable-extra-warnings enable more compiler warnings
  230. --disable-stripping disable stripping of executables and shared libraries
  231. --samples=PATH location of test samples for FATE
  232. NOTE: Object files are built at the place where configure is launched.
  233. EOF
  234. exit 0
  235. }
  236. quotes='""'
  237. log(){
  238. echo "$@" >> $logfile
  239. }
  240. log_file(){
  241. log BEGIN $1
  242. pr -n -t $1 >> $logfile
  243. log END $1
  244. }
  245. echolog(){
  246. log "$@"
  247. echo "$@"
  248. }
  249. warn(){
  250. log "WARNING: $*"
  251. WARNINGS="${WARNINGS}WARNING: $*\n"
  252. }
  253. die(){
  254. echolog "$@"
  255. cat <<EOF
  256. If you think configure made a mistake, make sure you are using the latest
  257. version from SVN. If the latest version fails, report the problem to the
  258. ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
  259. EOF
  260. if disabled logging; then
  261. cat <<EOF
  262. Rerun configure with logging enabled (do not use --disable-logging), and
  263. include the log this produces with your report.
  264. EOF
  265. else
  266. cat <<EOF
  267. Include the log file "$logfile" produced by configure as this will help
  268. solving the problem.
  269. EOF
  270. fi
  271. exit 1
  272. }
  273. # Avoid locale weirdness, besides we really just want to translate ASCII.
  274. toupper(){
  275. echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  276. }
  277. tolower(){
  278. echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
  279. }
  280. c_escape(){
  281. echo "$*" | sed 's/["\\]/\\\0/g'
  282. }
  283. sh_quote(){
  284. v=$(echo "$1" | sed "s/'/'\\\\''/g")
  285. test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
  286. echo "$v"
  287. }
  288. filter(){
  289. pat=$1
  290. shift
  291. for v; do
  292. eval "case $v in $pat) echo $v ;; esac"
  293. done
  294. }
  295. map(){
  296. m=$1
  297. shift
  298. for v; do eval $m; done
  299. }
  300. set_all(){
  301. value=$1
  302. shift
  303. for var in $*; do
  304. eval $var=$value
  305. done
  306. }
  307. set_weak(){
  308. value=$1
  309. shift
  310. for var; do
  311. eval : \${$var:=$value}
  312. done
  313. }
  314. pushvar(){
  315. for var in $*; do
  316. eval level=\${${var}_level:=0}
  317. eval ${var}_${level}="\$$var"
  318. eval ${var}_level=$(($level+1))
  319. done
  320. }
  321. popvar(){
  322. for var in $*; do
  323. eval level=\${${var}_level:-0}
  324. test $level = 0 && continue
  325. eval level=$(($level-1))
  326. eval $var="\${${var}_${level}}"
  327. eval ${var}_level=$level
  328. eval unset ${var}_${level}
  329. done
  330. }
  331. enable(){
  332. set_all yes $*
  333. }
  334. disable(){
  335. set_all no $*
  336. }
  337. enable_weak(){
  338. set_weak yes $*
  339. }
  340. disable_weak(){
  341. set_weak no $*
  342. }
  343. enable_safe(){
  344. for var; do
  345. enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
  346. done
  347. }
  348. disable_safe(){
  349. for var; do
  350. disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
  351. done
  352. }
  353. do_enable_deep(){
  354. for var; do
  355. enabled $var && continue
  356. eval sel="\$${var}_select"
  357. eval sgs="\$${var}_suggest"
  358. pushvar var sgs
  359. enable_deep $sel
  360. popvar sgs
  361. enable_deep_weak $sgs
  362. popvar var
  363. done
  364. }
  365. enable_deep(){
  366. do_enable_deep $*
  367. enable $*
  368. }
  369. enable_deep_weak(){
  370. do_enable_deep $*
  371. enable_weak $*
  372. }
  373. enabled(){
  374. test "${1#!}" = "$1" && op== || op=!=
  375. eval test "x\$${1#!}" $op "xyes"
  376. }
  377. disabled(){
  378. test "${1#!}" = "$1" && op== || op=!=
  379. eval test "x\$${1#!}" $op "xno"
  380. }
  381. enabled_all(){
  382. for opt; do
  383. enabled $opt || return 1
  384. done
  385. }
  386. disabled_all(){
  387. for opt; do
  388. disabled $opt || return 1
  389. done
  390. }
  391. enabled_any(){
  392. for opt; do
  393. enabled $opt && return 0
  394. done
  395. }
  396. disabled_any(){
  397. for opt; do
  398. disabled $opt && return 0
  399. done
  400. return 1
  401. }
  402. set_default(){
  403. for opt; do
  404. eval : \${$opt:=\$${opt}_default}
  405. done
  406. }
  407. is_in(){
  408. value=$1
  409. shift
  410. for var in $*; do
  411. [ $var = $value ] && return 0
  412. done
  413. return 1
  414. }
  415. check_deps(){
  416. for cfg; do
  417. cfg="${cfg#!}"
  418. enabled ${cfg}_checking && die "Circular dependency for $cfg."
  419. disabled ${cfg}_checking && continue
  420. enable ${cfg}_checking
  421. eval dep_all="\$${cfg}_deps"
  422. eval dep_any="\$${cfg}_deps_any"
  423. eval dep_sel="\$${cfg}_select"
  424. eval dep_sgs="\$${cfg}_suggest"
  425. eval dep_ifa="\$${cfg}_if"
  426. eval dep_ifn="\$${cfg}_if_any"
  427. pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
  428. check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
  429. popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
  430. [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
  431. [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
  432. enabled_all $dep_all || disable $cfg
  433. enabled_any $dep_any || disable $cfg
  434. disabled_any $dep_sel && disable $cfg
  435. if enabled $cfg; then
  436. eval dep_extralibs="\$${cfg}_extralibs"
  437. test -n "$dep_extralibs" && add_extralibs $dep_extralibs
  438. enable_deep $dep_sel
  439. enable_deep_weak $dep_sgs
  440. fi
  441. disable ${cfg}_checking
  442. done
  443. }
  444. print_config(){
  445. pfx=$1
  446. header=$2
  447. makefile=$3
  448. shift 3
  449. for cfg; do
  450. ucname="$(toupper $cfg)"
  451. if enabled $cfg; then
  452. echo "#define ${pfx}${ucname} 1" >> $header
  453. echo "${pfx}${ucname}=yes" >> $makefile
  454. else
  455. echo "#define ${pfx}${ucname} 0" >> $header
  456. echo "!${pfx}${ucname}=yes" >> $makefile
  457. fi
  458. done
  459. }
  460. print_enabled(){
  461. test "$1" = -n && end=" " && shift || end="\n"
  462. suf=$1
  463. shift
  464. for v; do
  465. enabled $v && printf "%s$end" ${v%$suf};
  466. done
  467. }
  468. append(){
  469. var=$1
  470. shift
  471. eval "$var=\"\$$var $*\""
  472. }
  473. prepend(){
  474. var=$1
  475. shift
  476. eval "$var=\"$* \$$var\""
  477. }
  478. add_cppflags(){
  479. append CPPFLAGS $($filter_cppflags "$@")
  480. }
  481. add_cflags(){
  482. append CFLAGS $($filter_cflags "$@")
  483. }
  484. add_asflags(){
  485. append ASFLAGS $($filter_asflags "$@")
  486. }
  487. add_ldflags(){
  488. append LDFLAGS "$@"
  489. }
  490. add_extralibs(){
  491. prepend extralibs "$@"
  492. }
  493. check_cmd(){
  494. log "$@"
  495. "$@" >> $logfile 2>&1
  496. }
  497. check_cc(){
  498. log check_cc "$@"
  499. cat > $TMPC
  500. log_file $TMPC
  501. check_cmd $cc $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
  502. }
  503. check_cpp(){
  504. log check_cpp "$@"
  505. cat > $TMPC
  506. log_file $TMPC
  507. check_cmd $cc $CPPFLAGS $CFLAGS "$@" -E -o $TMPO $TMPC
  508. }
  509. check_as(){
  510. log check_as "$@"
  511. cat > $TMPC
  512. log_file $TMPC
  513. check_cmd $as $CPPFLAGS $ASFLAGS "$@" -c -o $TMPO $TMPC
  514. }
  515. check_asm(){
  516. log check_asm "$@"
  517. name="$1"
  518. code="$2"
  519. shift 2
  520. disable $name
  521. check_as "$@" <<EOF && enable $name
  522. void foo(void){ __asm__ volatile($code); }
  523. EOF
  524. }
  525. check_yasm(){
  526. log check_yasm "$@"
  527. echo "$1" > $TMPS
  528. log_file $TMPS
  529. shift 1
  530. check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
  531. }
  532. check_ld(){
  533. log check_ld "$@"
  534. flags=''
  535. libs=''
  536. for f; do
  537. test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
  538. done
  539. check_cc $($filter_cflags $flags) || return
  540. check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
  541. }
  542. check_cppflags(){
  543. log check_cppflags "$@"
  544. set -- $($filter_cppflags "$@")
  545. check_cc "$@" <<EOF && append CPPFLAGS "$@"
  546. int x;
  547. EOF
  548. }
  549. check_cflags(){
  550. log check_cflags "$@"
  551. set -- $($filter_cflags "$@")
  552. check_cc "$@" <<EOF && append CFLAGS "$@"
  553. int x;
  554. EOF
  555. }
  556. test_ldflags(){
  557. log test_ldflags "$@"
  558. check_ld "$@" <<EOF
  559. int main(void){ return 0; }
  560. EOF
  561. }
  562. check_ldflags(){
  563. log check_ldflags "$@"
  564. test_ldflags "$@" && add_ldflags "$@"
  565. }
  566. check_header(){
  567. log check_header "$@"
  568. header=$1
  569. shift
  570. disable_safe $header
  571. check_cpp "$@" <<EOF && enable_safe $header
  572. #include <$header>
  573. int x;
  574. EOF
  575. }
  576. check_func(){
  577. log check_func "$@"
  578. func=$1
  579. shift
  580. disable $func
  581. check_ld "$@" <<EOF && enable $func
  582. extern int $func();
  583. int main(void){ $func(); }
  584. EOF
  585. }
  586. check_mathfunc(){
  587. log check_mathfunc "$@"
  588. func=$1
  589. shift
  590. disable $func
  591. check_ld "$@" <<EOF && enable $func
  592. #include <math.h>
  593. float foo(float f) { return $func(f); }
  594. int main(void){ return 0; }
  595. EOF
  596. }
  597. check_func_headers(){
  598. log check_func_headers "$@"
  599. headers=$1
  600. func=$2
  601. shift 2
  602. disable $func
  603. incs=""
  604. for hdr in $headers; do
  605. incs="$incs
  606. #include <$hdr>"
  607. done
  608. check_ld "$@" <<EOF && enable $func && enable_safe $headers
  609. $incs
  610. int main(int argc, char **argv){
  611. return (long) $func;
  612. }
  613. EOF
  614. }
  615. check_cpp_condition(){
  616. log check_cpp_condition "$@"
  617. header=$1
  618. condition=$2
  619. shift 2
  620. check_cpp $($filter_cppflags "$@") <<EOF
  621. #include <$header>
  622. #if !($condition)
  623. #error "unsatisfied condition: $condition"
  624. #endif
  625. EOF
  626. }
  627. check_lib(){
  628. log check_lib "$@"
  629. header="$1"
  630. func="$2"
  631. shift 2
  632. check_header $header && check_func $func "$@" && add_extralibs "$@"
  633. }
  634. check_lib2(){
  635. log check_lib2 "$@"
  636. headers="$1"
  637. func="$2"
  638. shift 2
  639. check_func_headers "$headers" $func "$@" && add_extralibs "$@"
  640. }
  641. check_exec(){
  642. check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
  643. }
  644. check_exec_crash(){
  645. code=$(cat)
  646. # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
  647. # are safe but may not be available everywhere. Thus we use
  648. # raise(SIGTERM) instead. The check is run in a subshell so we
  649. # can redirect the "Terminated" message from the shell. SIGBUS
  650. # is not defined by standard C so it is used conditionally.
  651. (check_exec "$@") >> $logfile 2>&1 <<EOF
  652. #include <signal.h>
  653. static void sighandler(int sig){
  654. raise(SIGTERM);
  655. }
  656. int main(void){
  657. signal(SIGILL, sighandler);
  658. signal(SIGFPE, sighandler);
  659. signal(SIGSEGV, sighandler);
  660. #ifdef SIGBUS
  661. signal(SIGBUS, sighandler);
  662. #endif
  663. { $code }
  664. }
  665. EOF
  666. }
  667. check_type(){
  668. log check_type "$@"
  669. headers=$1
  670. type=$2
  671. shift 2
  672. disable_safe "$type"
  673. incs=""
  674. for hdr in $headers; do
  675. incs="$incs
  676. #include <$hdr>"
  677. done
  678. check_cc "$@" <<EOF && enable_safe "$type"
  679. $incs
  680. $type v;
  681. EOF
  682. }
  683. check_struct(){
  684. log check_type "$@"
  685. headers=$1
  686. struct=$2
  687. member=$3
  688. shift 3
  689. disable_safe "${struct}_${member}"
  690. incs=""
  691. for hdr in $headers; do
  692. incs="$incs
  693. #include <$hdr>"
  694. done
  695. check_cc "$@" <<EOF && enable_safe "${struct}_${member}"
  696. $incs
  697. const void *p = &(($struct *)0)->$member;
  698. EOF
  699. }
  700. require(){
  701. name="$1"
  702. header="$2"
  703. func="$3"
  704. shift 3
  705. check_lib $header $func "$@" || die "ERROR: $name not found"
  706. }
  707. require2(){
  708. name="$1"
  709. headers="$2"
  710. func="$3"
  711. shift 3
  712. check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
  713. }
  714. check_host_cc(){
  715. log check_host_cc "$@"
  716. cat > $TMPC
  717. log_file $TMPC
  718. check_cmd $host_cc $host_cflags "$@" -c -o $TMPO $TMPC
  719. }
  720. check_host_cflags(){
  721. log check_host_cflags "$@"
  722. check_host_cc "$@" <<EOF && append host_cflags "$@"
  723. int x;
  724. EOF
  725. }
  726. apply(){
  727. file=$1
  728. shift
  729. "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
  730. }
  731. cp_if_changed(){
  732. cmp -s "$1" "$2" &&
  733. echo "$2 is unchanged" ||
  734. cp -f "$1" "$2"
  735. }
  736. # CONFIG_LIST contains configurable options, while HAVE_LIST is for
  737. # system-dependent things.
  738. COMPONENT_LIST="
  739. bsfs
  740. decoders
  741. demuxers
  742. encoders
  743. filters
  744. hwaccels
  745. indevs
  746. muxers
  747. outdevs
  748. parsers
  749. protocols
  750. "
  751. CONFIG_LIST="
  752. $COMPONENT_LIST
  753. aandct
  754. avcodec
  755. avcore
  756. avdevice
  757. avfilter
  758. avformat
  759. avisynth
  760. bzlib
  761. dct
  762. doc
  763. dwt
  764. dxva2
  765. fastdiv
  766. ffmpeg
  767. ffplay
  768. ffprobe
  769. ffserver
  770. fft
  771. golomb
  772. gpl
  773. gray
  774. h264dsp
  775. h264pred
  776. hardcoded_tables
  777. huffman
  778. libdc1394
  779. libdirac
  780. libfaac
  781. libgsm
  782. libmp3lame
  783. libnut
  784. libopencore_amrnb
  785. libopencore_amrwb
  786. libopenjpeg
  787. librtmp
  788. libschroedinger
  789. libspeex
  790. libtheora
  791. libvorbis
  792. libvpx
  793. libx264
  794. libxavs
  795. libxvid
  796. lpc
  797. lsp
  798. mdct
  799. memalign_hack
  800. mlib
  801. mpegaudio_hp
  802. network
  803. nonfree
  804. pic
  805. postproc
  806. rdft
  807. runtime_cpudetect
  808. shared
  809. small
  810. sram
  811. static
  812. swscale
  813. swscale_alpha
  814. vaapi
  815. vdpau
  816. version3
  817. x11grab
  818. zlib
  819. "
  820. THREADS_LIST='
  821. pthreads
  822. w32threads
  823. '
  824. ARCH_LIST='
  825. alpha
  826. arm
  827. avr32
  828. avr32_ap
  829. avr32_uc
  830. bfin
  831. ia64
  832. m68k
  833. mips
  834. mips64
  835. parisc
  836. ppc
  837. ppc64
  838. s390
  839. sh4
  840. sparc
  841. sparc64
  842. tomi
  843. x86
  844. x86_32
  845. x86_64
  846. '
  847. ARCH_EXT_LIST='
  848. altivec
  849. amd3dnow
  850. amd3dnowext
  851. armv5te
  852. armv6
  853. armv6t2
  854. armvfp
  855. iwmmxt
  856. mmi
  857. mmx
  858. mmx2
  859. neon
  860. ppc4xx
  861. sse
  862. ssse3
  863. vis
  864. '
  865. HAVE_LIST_PUB='
  866. bigendian
  867. fast_unaligned
  868. '
  869. HAVE_LIST="
  870. $ARCH_EXT_LIST
  871. $HAVE_LIST_PUB
  872. $THREADS_LIST
  873. alsa_asoundlib_h
  874. altivec_h
  875. arpa_inet_h
  876. attribute_may_alias
  877. attribute_packed
  878. bswap
  879. closesocket
  880. cmov
  881. conio_h
  882. dcbzl
  883. dev_bktr_ioctl_bt848_h
  884. dev_bktr_ioctl_meteor_h
  885. dev_ic_bt8xx_h
  886. dev_video_meteor_ioctl_meteor_h
  887. dev_video_bktr_ioctl_bt848_h
  888. dlfcn_h
  889. dlopen
  890. dos_paths
  891. ebp_available
  892. ebx_available
  893. exp2
  894. exp2f
  895. fast_64bit
  896. fast_clz
  897. fast_cmov
  898. fcntl
  899. fork
  900. getaddrinfo
  901. gethrtime
  902. GetProcessMemoryInfo
  903. GetProcessTimes
  904. getrusage
  905. gnu_as
  906. struct_rusage_ru_maxrss
  907. ibm_asm
  908. inet_aton
  909. inline_asm
  910. isatty
  911. ldbrx
  912. libdc1394_1
  913. libdc1394_2
  914. llrint
  915. llrintf
  916. local_aligned_16
  917. local_aligned_8
  918. log2
  919. log2f
  920. loongson
  921. lrint
  922. lrintf
  923. lzo1x_999_compress
  924. machine_ioctl_bt848_h
  925. machine_ioctl_meteor_h
  926. malloc_h
  927. memalign
  928. mkstemp
  929. pld
  930. posix_memalign
  931. round
  932. roundf
  933. sdl
  934. sdl_video_size
  935. setmode
  936. socklen_t
  937. soundcard_h
  938. poll_h
  939. setrlimit
  940. strerror_r
  941. struct_addrinfo
  942. struct_ipv6_mreq
  943. struct_sockaddr_in6
  944. struct_sockaddr_sa_len
  945. struct_sockaddr_storage
  946. symver
  947. symver_gnu_asm
  948. symver_asm_label
  949. sys_mman_h
  950. sys_resource_h
  951. sys_select_h
  952. sys_soundcard_h
  953. sys_videoio_h
  954. ten_operands
  955. termios_h
  956. threads
  957. truncf
  958. vfp_args
  959. VirtualAlloc
  960. winsock2_h
  961. xform_asm
  962. yasm
  963. "
  964. # options emitted with CONFIG_ prefix but not available on command line
  965. CONFIG_EXTRA="
  966. avutil
  967. gplv3
  968. lgplv3
  969. "
  970. CMDLINE_SELECT="
  971. $ARCH_EXT_LIST
  972. $CONFIG_LIST
  973. $THREADS_LIST
  974. asm
  975. cross_compile
  976. debug
  977. extra_warnings
  978. logging
  979. optimizations
  980. stripping
  981. yasm
  982. "
  983. PATHS_LIST='
  984. bindir
  985. datadir
  986. incdir
  987. libdir
  988. mandir
  989. prefix
  990. shlibdir
  991. '
  992. CMDLINE_SET="
  993. $PATHS_LIST
  994. ar
  995. arch
  996. as
  997. build_suffix
  998. cc
  999. cpu
  1000. cross_prefix
  1001. dep_cc
  1002. extra_version
  1003. host_cc
  1004. host_cflags
  1005. host_ldflags
  1006. host_libs
  1007. host_os
  1008. ld
  1009. logfile
  1010. malloc_prefix
  1011. nm
  1012. samples
  1013. source_path
  1014. strip
  1015. sysinclude
  1016. sysroot
  1017. target_exec
  1018. target_os
  1019. target_path
  1020. "
  1021. CMDLINE_APPEND="
  1022. extra_cflags
  1023. "
  1024. # code dependency declarations
  1025. # architecture extensions
  1026. armv5te_deps="arm"
  1027. armv6_deps="arm"
  1028. armv6t2_deps="arm"
  1029. armvfp_deps="arm"
  1030. iwmmxt_deps="arm"
  1031. neon_deps="arm"
  1032. mmi_deps="mips"
  1033. altivec_deps="ppc"
  1034. ppc4xx_deps="ppc"
  1035. vis_deps="sparc"
  1036. x86_64_suggest="cmov fast_cmov"
  1037. amd3dnow_deps="mmx"
  1038. amd3dnowext_deps="amd3dnow"
  1039. mmx_deps="x86"
  1040. mmx2_deps="mmx"
  1041. sse_deps="mmx"
  1042. ssse3_deps="sse"
  1043. fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
  1044. fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
  1045. fast_unaligned_if_any="armv6 ppc x86"
  1046. need_memalign="altivec neon sse"
  1047. inline_asm_deps="!tms470"
  1048. symver_if_any="symver_asm_label symver_gnu_asm"
  1049. # subsystems
  1050. dct_select="rdft"
  1051. mdct_select="fft"
  1052. rdft_select="fft"
  1053. # decoders / encoders / hardware accelerators
  1054. aac_decoder_select="mdct rdft"
  1055. aac_encoder_select="mdct"
  1056. ac3_decoder_select="mdct ac3_parser"
  1057. alac_encoder_select="lpc"
  1058. amrnb_decoder_select="lsp"
  1059. atrac1_decoder_select="mdct"
  1060. atrac3_decoder_select="mdct"
  1061. binkaudio_dct_decoder_select="mdct rdft dct"
  1062. binkaudio_rdft_decoder_select="mdct rdft"
  1063. cavs_decoder_select="golomb"
  1064. cook_decoder_select="mdct"
  1065. cscd_decoder_suggest="zlib"
  1066. dca_decoder_select="mdct"
  1067. dnxhd_encoder_select="aandct"
  1068. dxa_decoder_select="zlib"
  1069. eac3_decoder_select="ac3_decoder"
  1070. eamad_decoder_select="aandct"
  1071. eatgq_decoder_select="aandct"
  1072. eatqi_decoder_select="aandct"
  1073. ffv1_decoder_select="golomb"
  1074. flac_decoder_select="golomb"
  1075. flac_encoder_select="golomb lpc"
  1076. flashsv_decoder_select="zlib"
  1077. flashsv_encoder_select="zlib"
  1078. flv_decoder_select="h263_decoder"
  1079. flv_encoder_select="h263_encoder"
  1080. fraps_decoder_select="huffman"
  1081. h261_encoder_select="aandct"
  1082. h263_decoder_select="h263_parser"
  1083. h263_encoder_select="aandct"
  1084. h263_vaapi_hwaccel_select="vaapi h263_decoder"
  1085. h263i_decoder_select="h263_decoder"
  1086. h263p_encoder_select="h263_encoder"
  1087. h264_decoder_select="golomb h264dsp h264pred"
  1088. h264_dxva2_hwaccel_deps="dxva2api_h"
  1089. h264_dxva2_hwaccel_select="dxva2 h264_decoder"
  1090. h264_vaapi_hwaccel_select="vaapi"
  1091. h264_vdpau_decoder_select="vdpau h264_decoder"
  1092. imc_decoder_select="fft mdct"
  1093. jpegls_decoder_select="golomb"
  1094. jpegls_encoder_select="golomb"
  1095. ljpeg_encoder_select="aandct"
  1096. loco_decoder_select="golomb"
  1097. mjpeg_encoder_select="aandct"
  1098. mlp_decoder_select="mlp_parser"
  1099. mp1float_decoder_select="dct"
  1100. mp2float_decoder_select="dct"
  1101. mp3adufloat_decoder_select="dct"
  1102. mp3float_decoder_select="dct"
  1103. mp3on4float_decoder_select="dct"
  1104. mpeg1video_encoder_select="aandct"
  1105. mpeg2video_encoder_select="aandct"
  1106. mpeg4_decoder_select="h263_decoder mpeg4video_parser"
  1107. mpeg4_encoder_select="h263_encoder"
  1108. mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
  1109. mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
  1110. mpeg2_dxva2_hwaccel_deps="dxva2api_h"
  1111. mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder"
  1112. mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
  1113. mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
  1114. mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
  1115. mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
  1116. mpeg_xvmc_decoder_select="mpegvideo_decoder"
  1117. msmpeg4v1_decoder_select="h263_decoder"
  1118. msmpeg4v1_encoder_select="h263_encoder"
  1119. msmpeg4v2_decoder_select="h263_decoder"
  1120. msmpeg4v2_encoder_select="h263_encoder"
  1121. msmpeg4v3_decoder_select="h263_decoder"
  1122. msmpeg4v3_encoder_select="h263_encoder"
  1123. nellymoser_decoder_select="mdct"
  1124. nellymoser_encoder_select="mdct"
  1125. png_decoder_select="zlib"
  1126. png_encoder_select="zlib"
  1127. qcelp_decoder_select="lsp"
  1128. qdm2_decoder_select="mdct rdft"
  1129. ra_144_encoder_select="lpc"
  1130. rv10_decoder_select="h263_decoder"
  1131. rv10_encoder_select="h263_encoder"
  1132. rv20_decoder_select="h263_decoder"
  1133. rv20_encoder_select="h263_encoder"
  1134. rv30_decoder_select="golomb h264pred"
  1135. rv40_decoder_select="golomb h264pred"
  1136. shorten_decoder_select="golomb"
  1137. sipr_decoder_select="lsp"
  1138. snow_decoder_select="dwt"
  1139. snow_encoder_select="aandct dwt"
  1140. sonic_decoder_select="golomb"
  1141. sonic_encoder_select="golomb"
  1142. sonic_ls_encoder_select="golomb"
  1143. svq1_encoder_select="aandct"
  1144. svq3_decoder_select="golomb h264dsp h264pred"
  1145. svq3_decoder_suggest="zlib"
  1146. theora_decoder_select="vp3_decoder"
  1147. tiff_decoder_suggest="zlib"
  1148. tiff_encoder_suggest="zlib"
  1149. truehd_decoder_select="mlp_decoder"
  1150. tscc_decoder_select="zlib"
  1151. twinvq_decoder_select="mdct lsp"
  1152. vc1_decoder_select="h263_decoder"
  1153. vc1_dxva2_hwaccel_deps="dxva2api_h DXVA_PictureParameters_wDecodedPictureIndex"
  1154. vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
  1155. vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
  1156. vc1_vdpau_decoder_select="vdpau vc1_decoder"
  1157. vorbis_decoder_select="mdct"
  1158. vorbis_encoder_select="mdct"
  1159. vp6_decoder_select="huffman"
  1160. vp6a_decoder_select="vp6_decoder"
  1161. vp6f_decoder_select="vp6_decoder"
  1162. vp8_decoder_select="h264pred"
  1163. wmapro_decoder_select="mdct"
  1164. wmav1_decoder_select="mdct"
  1165. wmav1_encoder_select="mdct"
  1166. wmav2_decoder_select="mdct"
  1167. wmav2_encoder_select="mdct"
  1168. wmavoice_decoder_select="lsp rdft dct mdct"
  1169. wmv1_decoder_select="h263_decoder"
  1170. wmv1_encoder_select="h263_encoder"
  1171. wmv2_decoder_select="h263_decoder"
  1172. wmv2_encoder_select="h263_encoder"
  1173. wmv3_decoder_select="vc1_decoder"
  1174. wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
  1175. wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
  1176. wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
  1177. zlib_decoder_select="zlib"
  1178. zlib_encoder_select="zlib"
  1179. zmbv_decoder_select="zlib"
  1180. zmbv_encoder_select="zlib"
  1181. vaapi_deps="va_va_h"
  1182. vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  1183. # parsers
  1184. h264_parser_select="golomb h264dsp h264pred"
  1185. # external libraries
  1186. libdirac_decoder_deps="libdirac !libschroedinger"
  1187. libdirac_encoder_deps="libdirac"
  1188. libfaac_encoder_deps="libfaac"
  1189. libgsm_decoder_deps="libgsm"
  1190. libgsm_encoder_deps="libgsm"
  1191. libgsm_ms_decoder_deps="libgsm"
  1192. libgsm_ms_encoder_deps="libgsm"
  1193. libmp3lame_encoder_deps="libmp3lame"
  1194. libopencore_amrnb_decoder_deps="libopencore_amrnb"
  1195. libopencore_amrnb_encoder_deps="libopencore_amrnb"
  1196. libopencore_amrwb_decoder_deps="libopencore_amrwb"
  1197. libopenjpeg_decoder_deps="libopenjpeg"
  1198. libschroedinger_decoder_deps="libschroedinger"
  1199. libschroedinger_encoder_deps="libschroedinger"
  1200. libspeex_decoder_deps="libspeex"
  1201. libtheora_encoder_deps="libtheora"
  1202. libvorbis_encoder_deps="libvorbis"
  1203. libvpx_decoder_deps="libvpx"
  1204. libvpx_encoder_deps="libvpx"
  1205. libx264_encoder_deps="libx264"
  1206. libxavs_encoder_deps="libxavs"
  1207. libxvid_encoder_deps="libxvid"
  1208. # demuxers / muxers
  1209. ac3_demuxer_deps="ac3_parser"
  1210. asf_stream_muxer_select="asf_muxer"
  1211. avisynth_demuxer_deps="avisynth"
  1212. dirac_demuxer_deps="dirac_parser"
  1213. eac3_demuxer_select="ac3_parser"
  1214. ipod_muxer_select="mov_muxer"
  1215. libnut_demuxer_deps="libnut"
  1216. libnut_muxer_deps="libnut"
  1217. matroska_audio_muxer_select="matroska_muxer"
  1218. matroska_demuxer_suggest="zlib bzlib"
  1219. mov_demuxer_suggest="zlib"
  1220. mp3_demuxer_deps="mpegaudio_parser"
  1221. mp4_muxer_select="mov_muxer"
  1222. mpegtsraw_demuxer_select="mpegts_demuxer"
  1223. mxf_d10_muxer_select="mxf_muxer"
  1224. ogg_demuxer_select="golomb"
  1225. psp_muxer_select="mov_muxer"
  1226. rtsp_demuxer_deps="sdp_demuxer"
  1227. rtsp_muxer_deps="sdp_demuxer"
  1228. rtsp_muxer_select="rtp_muxer"
  1229. sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
  1230. sdp_demuxer_select="asf_demuxer rm_demuxer"
  1231. spdif_muxer_select="aac_parser"
  1232. tg2_muxer_select="mov_muxer"
  1233. tgp_muxer_select="mov_muxer"
  1234. w64_demuxer_deps="wav_demuxer"
  1235. # indevs / outdevs
  1236. alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
  1237. alsa_outdev_deps="alsa_asoundlib_h"
  1238. bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  1239. dv1394_indev_deps="dv1394 dv_demuxer"
  1240. jack_indev_deps="jack_jack_h"
  1241. libdc1394_indev_deps="libdc1394"
  1242. oss_indev_deps_any="soundcard_h sys_soundcard_h"
  1243. oss_outdev_deps_any="soundcard_h sys_soundcard_h"
  1244. v4l_indev_deps="linux_videodev_h"
  1245. v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
  1246. vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
  1247. vfwcap_indev_extralibs="-lavicap32"
  1248. x11_grab_device_indev_deps="x11grab XShmCreateImage"
  1249. x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
  1250. # protocols
  1251. gopher_protocol_deps="network"
  1252. http_protocol_deps="network"
  1253. http_protocol_select="tcp_protocol"
  1254. mmsh_protocol_select="http_protocol"
  1255. mmst_protocol_deps="network"
  1256. rtmp_protocol_select="tcp_protocol"
  1257. rtp_protocol_select="udp_protocol"
  1258. tcp_protocol_deps="network"
  1259. udp_protocol_deps="network"
  1260. # libraries
  1261. avdevice_deps="avcodec avformat"
  1262. avformat_deps="avcodec"
  1263. # programs
  1264. ffmpeg_deps="avcodec avformat swscale"
  1265. ffmpeg_select="buffer_filter"
  1266. ffplay_deps="avcodec avformat swscale sdl"
  1267. ffplay_select="rdft"
  1268. ffprobe_deps="avcodec avformat"
  1269. ffserver_deps="avformat ffm_muxer rtp_protocol rtsp_demuxer"
  1270. ffserver_extralibs='$ldl'
  1271. doc_deps="texi2html"
  1272. # tests
  1273. test_deps(){
  1274. suf1=$1
  1275. suf2=$2
  1276. shift 2
  1277. for v; do
  1278. dep=${v%=*}
  1279. tests=${v#*=}
  1280. for name in ${tests}; do
  1281. eval ${name}_test_deps="'${dep}$suf1 ${dep}$suf2'"
  1282. done
  1283. done
  1284. }
  1285. set_ne_test_deps(){
  1286. eval ${1}_be_test_deps="bigendian"
  1287. eval ${1}_le_test_deps="!bigendian"
  1288. }
  1289. test_deps _encoder _decoder \
  1290. ac3 \
  1291. adpcm_g726=g726 \
  1292. adpcm_ima_qt \
  1293. adpcm_ima_wav \
  1294. adpcm_ms \
  1295. adpcm_swf \
  1296. adpcm_yamaha=adpcm_yam \
  1297. alac \
  1298. asv1 \
  1299. asv2 \
  1300. bmp \
  1301. dnxhd="dnxhd_1080i dnxhd_720p dnxhd_720p_rd" \
  1302. dvvideo="dv dv50" \
  1303. ffv1 \
  1304. flac \
  1305. flashsv \
  1306. flv \
  1307. gif \
  1308. h261 \
  1309. h263="h263 h263p" \
  1310. huffyuv \
  1311. jpegls \
  1312. mjpeg="jpg mjpeg ljpeg" \
  1313. mp2 \
  1314. mpeg1video="mpeg mpeg1b" \
  1315. mpeg2video="mpeg2 mpeg2thread" \
  1316. mpeg4="mpeg4 mpeg4adv mpeg4nr mpeg4thread error rc" \
  1317. msmpeg4v3=msmpeg4 \
  1318. msmpeg4v2 \
  1319. pbm=pbmpipe \
  1320. pcx \
  1321. pgm="pgm pgmpipe" \
  1322. ppm="ppm ppmpipe" \
  1323. rawvideo="rgb yuv" \
  1324. roq \
  1325. rv10 \
  1326. rv20 \
  1327. sgi \
  1328. snow="snow snowll" \
  1329. svq1 \
  1330. targa=tga \
  1331. tiff \
  1332. wmav1 \
  1333. wmav2 \
  1334. wmv1 \
  1335. wmv2 \
  1336. test_deps _muxer _demuxer \
  1337. aiff \
  1338. pcm_alaw=alaw \
  1339. asf \
  1340. au \
  1341. avi \
  1342. dv=dv_fmt \
  1343. ffm \
  1344. flv=flv_fmt \
  1345. gxf \
  1346. matroska=mkv \
  1347. mmf \
  1348. mov \
  1349. pcm_mulaw=mulaw \
  1350. mxf \
  1351. nut \
  1352. ogg \
  1353. rawvideo=pixfmt \
  1354. rm \
  1355. swf \
  1356. mpegts=ts \
  1357. voc \
  1358. wav \
  1359. yuv4mpegpipe=yuv4mpeg \
  1360. mpg_test_deps="mpeg1system_muxer mpegps_demuxer"
  1361. set_ne_test_deps pixdesc
  1362. set_ne_test_deps pixfmts_crop
  1363. set_ne_test_deps pixfmts_hflip
  1364. set_ne_test_deps pixfmts_null
  1365. set_ne_test_deps pixfmts_pad
  1366. set_ne_test_deps pixfmts_scale
  1367. set_ne_test_deps pixfmts_vflip
  1368. # default parameters
  1369. logfile="config.log"
  1370. # installation paths
  1371. prefix_default="/usr/local"
  1372. bindir_default='${prefix}/bin'
  1373. datadir_default='${prefix}/share/ffmpeg'
  1374. incdir_default='${prefix}/include'
  1375. libdir_default='${prefix}/lib'
  1376. mandir_default='${prefix}/share/man'
  1377. shlibdir_default="$libdir_default"
  1378. # toolchain
  1379. ar_default="ar"
  1380. cc_default="gcc"
  1381. cc_version=\"unknown\"
  1382. host_cc_default="gcc"
  1383. ln_s="ln -sf"
  1384. nm_default="nm"
  1385. objformat="elf"
  1386. ranlib="ranlib"
  1387. strip_default="strip"
  1388. yasmexe="yasm"
  1389. nogas=":"
  1390. nm_opts='-g'
  1391. # machine
  1392. arch_default=$(uname -m)
  1393. cpu="generic"
  1394. # OS
  1395. target_os_default=$(tolower $(uname -s))
  1396. host_os=$target_os_default
  1397. # configurable options
  1398. enable avcodec
  1399. enable avcore
  1400. enable avdevice
  1401. enable avfilter
  1402. enable avformat
  1403. enable avutil
  1404. enable asm
  1405. enable debug
  1406. enable doc
  1407. enable fastdiv
  1408. enable ffmpeg
  1409. enable ffplay
  1410. enable ffprobe
  1411. enable ffserver
  1412. enable mpegaudio_hp
  1413. enable network
  1414. enable optimizations
  1415. enable protocols
  1416. enable static
  1417. enable stripping
  1418. enable swscale
  1419. enable swscale_alpha
  1420. # build settings
  1421. SHFLAGS='-shared -Wl,-soname,$$(@F)'
  1422. FFSERVERLDFLAGS=-Wl,-E
  1423. LIBPREF="lib"
  1424. LIBSUF=".a"
  1425. FULLNAME='$(NAME)$(BUILDSUF)'
  1426. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  1427. SLIBPREF="lib"
  1428. SLIBSUF=".so"
  1429. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  1430. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  1431. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  1432. LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  1433. CC_O='-o $@'
  1434. host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
  1435. host_libs='-lm'
  1436. target_path='$(CURDIR)'
  1437. # since the object filename is not given with the -MM flag, the compiler
  1438. # is only able to print the basename, and we must add the path ourselves
  1439. DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
  1440. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
  1441. # find source path
  1442. source_path="$(dirname "$0")"
  1443. enable source_path_used
  1444. if test -f configure; then
  1445. source_path="$(pwd)"
  1446. disable source_path_used
  1447. else
  1448. source_path="$(cd "$source_path"; pwd)"
  1449. echo "$source_path" | grep -q '[[:blank:]]' &&
  1450. die "Out of tree builds are impossible with whitespace in source path."
  1451. test -e "$source_path/config.h" &&
  1452. die "Out of tree builds are impossible with config.h in source dir."
  1453. fi
  1454. for v in "$@"; do
  1455. r=${v#*=}
  1456. l=${v%"$r"}
  1457. r=$(sh_quote "$r")
  1458. FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
  1459. done
  1460. find_things(){
  1461. thing=$1
  1462. pattern=$2
  1463. file=$source_path/$3
  1464. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  1465. }
  1466. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  1467. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  1468. HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
  1469. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  1470. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  1471. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  1472. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  1473. OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
  1474. INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
  1475. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  1476. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  1477. find_tests(){
  1478. map "echo ${2}\${v}_test" $(ls "$source_path"/tests/ref/$1 | grep -v '[^-a-z0-9_]')
  1479. }
  1480. ACODEC_TESTS=$(find_tests acodec)
  1481. VCODEC_TESTS=$(find_tests vsynth1)
  1482. LAVF_TESTS=$(find_tests lavf)
  1483. LAVFI_TESTS=$(find_tests lavfi)
  1484. SEEK_TESTS=$(find_tests seek seek_)
  1485. pcm_test_deps=$(map 'echo ${v%_*}_decoder $v' $(filter pcm_* $ENCODER_LIST))
  1486. for n in $COMPONENT_LIST; do
  1487. v=$(toupper ${n%s})_LIST
  1488. eval enable \$$v
  1489. eval ${n}_if_any="\$$v"
  1490. done
  1491. enable $ARCH_EXT_LIST $ACODEC_TESTS $VCODEC_TESTS $LAVF_TESTS $LAVFI_TESTS $SEEK_TESTS
  1492. die_unknown(){
  1493. echo "Unknown option \"$1\"."
  1494. echo "See $0 --help for available options."
  1495. exit 1
  1496. }
  1497. show_list() {
  1498. suffix=_$1
  1499. shift
  1500. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
  1501. exit 0
  1502. }
  1503. for opt do
  1504. optval="${opt#*=}"
  1505. case "$opt" in
  1506. --extra-ldflags=*) add_ldflags $optval
  1507. ;;
  1508. --extra-libs=*) add_extralibs $optval
  1509. ;;
  1510. --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
  1511. ;;
  1512. --enable-debug=*) debuglevel="$optval"
  1513. ;;
  1514. --disable-everything)
  1515. map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
  1516. ;;
  1517. --enable-*=*|--disable-*=*)
  1518. eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
  1519. is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
  1520. eval list=\$$(toupper $thing)_LIST
  1521. name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
  1522. $action $(filter "$name" $list)
  1523. ;;
  1524. --enable-?*|--disable-?*)
  1525. eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
  1526. if is_in $option $COMPONENT_LIST; then
  1527. test $action = disable && action=unset
  1528. eval $action \$$(toupper ${option%s})_LIST
  1529. elif is_in $option $CMDLINE_SELECT; then
  1530. $action $option
  1531. else
  1532. die_unknown $opt
  1533. fi
  1534. ;;
  1535. --list-*)
  1536. NAME="${opt#--list-}"
  1537. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  1538. NAME=${NAME%s}
  1539. eval show_list $NAME \$$(toupper $NAME)_LIST
  1540. ;;
  1541. --help|-h) show_help
  1542. ;;
  1543. *)
  1544. optname="${opt%%=*}"
  1545. optname="${optname#--}"
  1546. optname=$(echo "$optname" | sed 's/-/_/g')
  1547. if is_in $optname $CMDLINE_SET; then
  1548. eval $optname='$optval'
  1549. elif is_in $optname $CMDLINE_APPEND; then
  1550. append $optname "$optval"
  1551. else
  1552. die_unknown $opt
  1553. fi
  1554. ;;
  1555. esac
  1556. done
  1557. disabled logging && logfile=/dev/null
  1558. echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
  1559. set >> $logfile
  1560. test -n "$cross_prefix" && enable cross_compile
  1561. if enabled cross_compile; then
  1562. test -n "$arch" && test -n "$target_os" ||
  1563. die "Must specify target arch and OS when cross-compiling"
  1564. fi
  1565. set_default arch target_os
  1566. ar_default="${cross_prefix}${ar_default}"
  1567. cc_default="${cross_prefix}${cc_default}"
  1568. nm_default="${cross_prefix}${nm_default}"
  1569. ranlib="${cross_prefix}${ranlib}"
  1570. strip_default="${cross_prefix}${strip_default}"
  1571. sysinclude_default="${sysroot}/usr/include"
  1572. set_default cc nm strip sysinclude
  1573. enabled cross_compile || host_cc_default=$cc
  1574. set_default host_cc
  1575. exesuf() {
  1576. case $1 in
  1577. mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
  1578. esac
  1579. }
  1580. EXESUF=$(exesuf $target_os)
  1581. HOSTEXESUF=$(exesuf $host_os)
  1582. # set temporary file name
  1583. : ${TMPDIR:=$TEMPDIR}
  1584. : ${TMPDIR:=$TMP}
  1585. : ${TMPDIR:=/tmp}
  1586. if ! check_cmd type mktemp; then
  1587. # simple replacement for missing mktemp
  1588. # NOT SAFE FOR GENERAL USE
  1589. mktemp(){
  1590. echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
  1591. }
  1592. fi
  1593. tmpfile(){
  1594. tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
  1595. (set -C; exec > $tmp) 2>/dev/null ||
  1596. die "Unable to create temporary file in $TMPDIR."
  1597. append TMPFILES $tmp
  1598. eval $1=$tmp
  1599. }
  1600. trap 'rm -f -- $TMPFILES' EXIT
  1601. trap exit HUP INT TERM
  1602. tmpfile TMPC .c
  1603. tmpfile TMPE $EXESUF
  1604. tmpfile TMPH .h
  1605. tmpfile TMPO .o
  1606. tmpfile TMPS .S
  1607. tmpfile TMPV .ver
  1608. tmpfile TMPSH .sh
  1609. unset -f mktemp
  1610. # make sure we can execute files in $TMPDIR
  1611. cat > $TMPSH 2>> $logfile <<EOF
  1612. #! /bin/sh
  1613. EOF
  1614. chmod +x $TMPSH >> $logfile 2>&1
  1615. if ! $TMPSH >> $logfile 2>&1; then
  1616. cat <<EOF
  1617. Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
  1618. variable to another directory and make sure that it is not mounted noexec.
  1619. EOF
  1620. die "Sanity test failed."
  1621. fi
  1622. filter_cflags=echo
  1623. filter_cppflags=echo
  1624. filter_asflags=echo
  1625. if $cc -v 2>&1 | grep -qi ^gcc; then
  1626. cc_type=gcc
  1627. cc_version=__VERSION__
  1628. gcc_extra_ver=$(expr "$($cc --version | head -n1)" : '.*\((.*)\)')
  1629. cc_ident="gcc $($cc -dumpversion) $gcc_extra_ver"
  1630. if ! $cc -dumpversion | grep -q '^2\.'; then
  1631. CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1632. AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1633. fi
  1634. speed_cflags='-O3'
  1635. size_cflags='-Os'
  1636. elif $cc --version 2>/dev/null | grep -q Intel; then
  1637. cc_type=icc
  1638. cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
  1639. cc_ident=$($cc --version | head -n1)
  1640. CC_DEPFLAGS='-MMD'
  1641. AS_DEPFLAGS='-MMD'
  1642. speed_cflags='-O3'
  1643. size_cflags='-Os'
  1644. noopt_cflags='-O1'
  1645. elif $cc -v 2>&1 | grep -q xlc; then
  1646. cc_type=xlc
  1647. cc_version="AV_STRINGIFY(__IBMC__)"
  1648. cc_ident=$($cc -qversion 2>/dev/null | head -n1)
  1649. speed_cflags='-O5'
  1650. size_cflags='-O5 -qcompact'
  1651. elif $cc -V 2>/dev/null | grep -q Compaq; then
  1652. cc_type=ccc
  1653. cc_version="AV_STRINGIFY(__DECC_VER)"
  1654. cc_ident=$($cc -V | head -n1 | cut -d' ' -f1-3)
  1655. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
  1656. debuglevel=3
  1657. add_ldflags -Wl,-z,now # calls to libots crash without this
  1658. speed_cflags='-fast'
  1659. size_cflags='-O1'
  1660. elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
  1661. test -d "$sysroot" || die "No valid sysroot specified."
  1662. cc_type=armcc
  1663. cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
  1664. cc_ident=$($cc --vsn | head -n1)
  1665. armcc_conf="$PWD/armcc.conf"
  1666. $cc --arm_linux_configure \
  1667. --arm_linux_config_file="$armcc_conf" \
  1668. --configure_sysroot="$sysroot" \
  1669. --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
  1670. die "Error creating armcc configuration file."
  1671. $cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
  1672. cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
  1673. as_default="${cross_prefix}gcc"
  1674. CC_DEPFLAGS='-MMD'
  1675. AS_DEPFLAGS='-MMD'
  1676. speed_cflags='-O3'
  1677. size_cflags='-Os'
  1678. elif $cc -version 2>/dev/null | grep -q TMS470; then
  1679. cc_type=tms470
  1680. cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
  1681. cc_ident=$($cc -version | head -n1 | tr -s ' ')
  1682. cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
  1683. CC_O='-fr=$(@D)'
  1684. as_default="${cross_prefix}gcc"
  1685. ld_default="${cross_prefix}gcc"
  1686. TMPO=$(basename $TMPC .c).o
  1687. append TMPFILES $TMPO
  1688. add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
  1689. CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
  1690. AS_DEPFLAGS='-MMD'
  1691. speed_cflags='-O3 -mf=5'
  1692. size_cflags='-O3 -mf=2'
  1693. filter_cflags=tms470_flags
  1694. tms470_flags(){
  1695. for flag; do
  1696. case $flag in
  1697. -march=*|-mcpu=*)
  1698. case "${flag#*=}" in
  1699. armv7-a|cortex-a*) echo -mv=7a8 ;;
  1700. armv7-r|cortex-r*) echo -mv=7r4 ;;
  1701. armv7-m|cortex-m*) echo -mv=7m3 ;;
  1702. armv6*|arm11*) echo -mv=6 ;;
  1703. armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
  1704. echo -mv=5e ;;
  1705. armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
  1706. esac
  1707. ;;
  1708. -mfpu=neon) echo --float_support=vfpv3 --neon ;;
  1709. -mfpu=vfp) echo --float_support=vfpv2 ;;
  1710. -mfpu=vfpv3) echo --float_support=vfpv3 ;;
  1711. -msoft-float) echo --float_support=vfplib ;;
  1712. -O[0-3]|-mf=*) echo $flag ;;
  1713. -g) echo -g -mn ;;
  1714. -pds=*) echo $flag ;;
  1715. esac
  1716. done
  1717. }
  1718. elif $cc -v 2>&1 | grep -q clang; then
  1719. cc_type=clang
  1720. $cc -dM -E $TMPC | grep -q __clang_version__ &&
  1721. cc_version=__clang_version__ || cc_version=__VERSION__
  1722. cc_ident=$($cc --version | head -n1)
  1723. CC_DEPFLAGS='-MMD'
  1724. AS_DEPFLAGS='-MMD'
  1725. speed_cflags='-O3'
  1726. size_cflags='-Os'
  1727. elif $cc -V 2>&1 | grep -q Sun; then
  1728. cc_type=suncc
  1729. cc_version="AV_STRINGIFY(__SUNPRO_C)"
  1730. cc_ident=$($cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
  1731. DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
  1732. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
  1733. speed_cflags='-O5'
  1734. size_cflags='-O5 -xspace'
  1735. filter_cflags=suncc_flags
  1736. suncc_flags(){
  1737. for flag; do
  1738. case $flag in
  1739. -march=*|-mcpu=*)
  1740. case "${flag#*=}" in
  1741. native) echo -xtarget=native ;;
  1742. v9|niagara) echo -xarch=sparc ;;
  1743. ultrasparc) echo -xarch=sparcvis ;;
  1744. ultrasparc3|niagara2) echo -xarch=sparcvis2 ;;
  1745. i586|pentium) echo -xchip=pentium ;;
  1746. i686|pentiumpro|pentium2) echo -xtarget=pentium_pro ;;
  1747. pentium3*|c3-2) echo -xtarget=pentium3 ;;
  1748. pentium-m) echo -xarch=sse2 -xchip=pentium3 ;;
  1749. pentium4*) echo -xtarget=pentium4 ;;
  1750. prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;;
  1751. *-sse3) echo -xarch=sse3 ;;
  1752. core2) echo -xarch=ssse3 -xchip=core2 ;;
  1753. amdfam10|barcelona) echo -xarch=sse4_1 ;;
  1754. athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
  1755. k8|opteron|athlon64|athlon-fx)
  1756. echo -xarch=sse2a ;;
  1757. athlon*) echo -xarch=pentium_proa ;;
  1758. esac
  1759. ;;
  1760. -std=c99) echo -xc99 ;;
  1761. -fomit-frame-pointer) echo -xregs=frameptr ;;
  1762. -fPIC) echo -KPIC -xcode=pic32 ;;
  1763. -W*,*) echo $flag ;;
  1764. -f*-*|-W*) ;;
  1765. *) echo $flag ;;
  1766. esac
  1767. done
  1768. }
  1769. elif $cc -v 2>&1 | grep -q PathScale; then
  1770. cc_type=pathscale
  1771. cc_version=__PATHSCALE__
  1772. cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
  1773. CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1774. AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1775. speed_cflags='-O2'
  1776. size_cflags='-Os'
  1777. fi
  1778. test -n "$cc_type" && enable $cc_type ||
  1779. warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
  1780. : ${as_default:=$cc}
  1781. : ${dep_cc_default:=$cc}
  1782. : ${ld_default:=$cc}
  1783. set_default ar as dep_cc ld
  1784. test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
  1785. test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
  1786. add_cflags $extra_cflags
  1787. add_asflags $extra_cflags
  1788. if test -n "$sysroot"; then
  1789. case "$cc_type" in
  1790. gcc)
  1791. add_cppflags --sysroot="$sysroot"
  1792. add_ldflags --sysroot="$sysroot"
  1793. ;;
  1794. tms470)
  1795. add_cppflags -I"$sysinclude"
  1796. add_ldflags --sysroot="$sysroot"
  1797. ;;
  1798. clang)
  1799. add_cppflags -isysroot "$sysroot"
  1800. add_ldflags -isysroot "$sysroot"
  1801. ;;
  1802. esac
  1803. fi
  1804. if test "$cpu" = host; then
  1805. enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
  1806. case "$cc_type" in
  1807. gcc)
  1808. check_native(){
  1809. $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
  1810. sed -n "/$1=/{
  1811. s/.*$1=\\([^ ]*\\).*/\\1/
  1812. p
  1813. q
  1814. }" $TMPE
  1815. }
  1816. cpu=$(check_native -march || check_native -mcpu)
  1817. ;;
  1818. esac
  1819. test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
  1820. fi
  1821. # Deal with common $arch aliases
  1822. case "$arch" in
  1823. arm*)
  1824. arch="arm"
  1825. ;;
  1826. mips|mipsel|IP*)
  1827. arch="mips"
  1828. ;;
  1829. mips64*)
  1830. arch="mips"
  1831. subarch="mips64"
  1832. ;;
  1833. parisc|hppa)
  1834. arch="parisc"
  1835. ;;
  1836. parisc64|hppa64)
  1837. arch="parisc"
  1838. subarch="parisc64"
  1839. ;;
  1840. "Power Macintosh"|ppc|powerpc)
  1841. arch="ppc"
  1842. ;;
  1843. ppc64|powerpc64)
  1844. arch="ppc"
  1845. subarch="ppc64"
  1846. ;;
  1847. s390|s390x)
  1848. arch="s390"
  1849. ;;
  1850. sh4|sh)
  1851. arch="sh4"
  1852. ;;
  1853. sun4u|sparc64)
  1854. arch="sparc"
  1855. subarch="sparc64"
  1856. ;;
  1857. i[3-6]86|i86pc|BePC|x86_64|amd64)
  1858. arch="x86"
  1859. ;;
  1860. esac
  1861. is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
  1862. enable $arch
  1863. # Add processor-specific flags
  1864. if test "$cpu" = generic; then
  1865. : do nothing
  1866. elif enabled ppc; then
  1867. case $(tolower $cpu) in
  1868. 601|ppc601|powerpc601)
  1869. cpuflags="-mcpu=601"
  1870. disable altivec
  1871. ;;
  1872. 603*|ppc603*|powerpc603*)
  1873. cpuflags="-mcpu=603"
  1874. disable altivec
  1875. ;;
  1876. 604*|ppc604*|powerpc604*)
  1877. cpuflags="-mcpu=604"
  1878. disable altivec
  1879. ;;
  1880. g3|75*|ppc75*|powerpc75*)
  1881. cpuflags="-mcpu=750 -mpowerpc-gfxopt"
  1882. disable altivec
  1883. ;;
  1884. g4|745*|ppc745*|powerpc745*)
  1885. cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
  1886. ;;
  1887. 74*|ppc74*|powerpc74*)
  1888. cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
  1889. ;;
  1890. g5|970|ppc970|powerpc970|power4*)
  1891. cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1892. ;;
  1893. cell)
  1894. cpuflags="-mcpu=cell"
  1895. enable ldbrx
  1896. ;;
  1897. e500v2)
  1898. cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
  1899. disable altivec
  1900. ;;
  1901. e500)
  1902. cpuflags="-mcpu=8540 -mhard-float"
  1903. disable altivec
  1904. ;;
  1905. esac
  1906. elif enabled x86; then
  1907. case $cpu in
  1908. i[345]86|pentium)
  1909. cpuflags="-march=$cpu"
  1910. disable mmx
  1911. ;;
  1912. # targets that do NOT support conditional mov (cmov)
  1913. pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1914. cpuflags="-march=$cpu"
  1915. disable cmov
  1916. ;;
  1917. # targets that do support conditional mov (cmov)
  1918. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10|barcelona|atom)
  1919. cpuflags="-march=$cpu"
  1920. enable cmov
  1921. enable fast_cmov
  1922. ;;
  1923. # targets that do support conditional mov but on which it's slow
  1924. pentium4|pentium4m|prescott|nocona)
  1925. cpuflags="-march=$cpu"
  1926. enable cmov
  1927. disable fast_cmov
  1928. ;;
  1929. esac
  1930. elif enabled sparc; then
  1931. case $cpu in
  1932. niagara)
  1933. cpuflags="-mcpu=$cpu"
  1934. disable vis
  1935. ;;
  1936. sparc64)
  1937. cpuflags="-mcpu=v9"
  1938. ;;
  1939. esac
  1940. elif enabled arm; then
  1941. case $cpu in
  1942. armv*)
  1943. cpuflags="-march=$cpu"
  1944. subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
  1945. ;;
  1946. *)
  1947. cpuflags="-mcpu=$cpu"
  1948. case $cpu in
  1949. cortex-a*) subarch=armv7a ;;
  1950. cortex-r*) subarch=armv7r ;;
  1951. cortex-m*) subarch=armv7m ;;
  1952. arm11*) subarch=armv6 ;;
  1953. arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
  1954. armv4*|arm7*|arm9[24]*) subarch=armv4 ;;
  1955. esac
  1956. ;;
  1957. esac
  1958. elif enabled alpha; then
  1959. enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
  1960. elif enabled bfin; then
  1961. cpuflags="-mcpu=$cpu"
  1962. elif enabled mips; then
  1963. cpuflags="-march=$cpu"
  1964. elif enabled avr32; then
  1965. case $cpu in
  1966. ap7[02]0[0-2])
  1967. subarch="avr32_ap"
  1968. cpuflags="-mpart=$cpu"
  1969. ;;
  1970. ap)
  1971. subarch="avr32_ap"
  1972. cpuflags="-march=$cpu"
  1973. ;;
  1974. uc3[ab]*)
  1975. subarch="avr32_uc"
  1976. cpuflags="-mcpu=$cpu"
  1977. ;;
  1978. uc)
  1979. subarch="avr32_uc"
  1980. cpuflags="-march=$cpu"
  1981. ;;
  1982. esac
  1983. fi
  1984. add_cflags $cpuflags
  1985. add_asflags $cpuflags
  1986. # compiler sanity check
  1987. check_exec <<EOF
  1988. int main(void){ return 0; }
  1989. EOF
  1990. if test "$?" != 0; then
  1991. echo "$cc is unable to create an executable file."
  1992. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1993. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  1994. echo "Only do this if you know what cross compiling means."
  1995. fi
  1996. die "C compiler test failed."
  1997. fi
  1998. add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
  1999. check_cflags -std=c99
  2000. check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
  2001. #include <stdlib.h>
  2002. EOF
  2003. check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
  2004. #include <stdlib.h>
  2005. EOF
  2006. check_host_cflags -std=c99
  2007. case "$arch" in
  2008. alpha|ia64|mips|parisc|sparc)
  2009. spic=$shared
  2010. ;;
  2011. x86)
  2012. subarch="x86_32"
  2013. check_cc <<EOF && subarch="x86_64"
  2014. int test[(int)sizeof(char*) - 7];
  2015. EOF
  2016. if test "$subarch" = "x86_64"; then
  2017. spic=$shared
  2018. fi
  2019. ;;
  2020. esac
  2021. enable $subarch
  2022. enabled spic && enable pic
  2023. # OS specific
  2024. case $target_os in
  2025. haiku)
  2026. prefix_default="/boot/common"
  2027. network_extralibs="-lnetwork"
  2028. ;;
  2029. sunos)
  2030. FFSERVERLDFLAGS=""
  2031. SHFLAGS='-shared -Wl,-h,$$(@F)'
  2032. enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
  2033. network_extralibs="-lsocket -lnsl"
  2034. add_cppflags -D__EXTENSIONS__
  2035. nm_opts='-P -g'
  2036. ;;
  2037. netbsd)
  2038. oss_indev_extralibs="-lossaudio"
  2039. oss_outdev_extralibs="-lossaudio"
  2040. add_cppflags -D_XOPEN_SOURCE=600
  2041. ;;
  2042. openbsd)
  2043. enable malloc_aligned
  2044. # On OpenBSD 4.5. the compiler does not use PIC unless
  2045. # explicitly using -fPIC. FFmpeg builds fine without PIC,
  2046. # however the generated executable will not do anything
  2047. # (simply quits with exit-code 1, no crash, no output).
  2048. # Thus explicitly enable PIC here.
  2049. enable pic
  2050. SHFLAGS='-shared'
  2051. oss_indev_extralibs="-lossaudio"
  2052. oss_outdev_extralibs="-lossaudio"
  2053. ;;
  2054. freebsd|dragonfly)
  2055. enable malloc_aligned
  2056. ;;
  2057. bsd/os)
  2058. add_extralibs -lpoll -lgnugetopt
  2059. strip="strip -d"
  2060. ;;
  2061. darwin)
  2062. enable malloc_aligned
  2063. gas="gas-preprocessor.pl $cc"
  2064. enabled ppc && add_asflags -force_cpusubtype_ALL
  2065. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
  2066. strip="${strip} -x"
  2067. add_ldflags -Wl,-dynamic,-search_paths_first
  2068. SLIBSUF=".dylib"
  2069. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  2070. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  2071. FFSERVERLDFLAGS=-Wl,-bind_at_load
  2072. objformat="macho"
  2073. enabled x86_64 && objformat="macho64"
  2074. enabled_any pic shared ||
  2075. { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
  2076. ;;
  2077. mingw32*)
  2078. if test $target_os = "mingw32ce"; then
  2079. disable network
  2080. else
  2081. target_os=mingw32
  2082. fi
  2083. LIBTARGET=i386
  2084. if enabled x86_64; then
  2085. enable malloc_aligned
  2086. LIBTARGET=x64
  2087. elif enabled arm; then
  2088. LIBTARGET=arm
  2089. fi
  2090. shlibdir_default="$bindir_default"
  2091. disable ffserver
  2092. SLIBPREF=""
  2093. SLIBSUF=".dll"
  2094. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2095. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2096. SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
  2097. SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
  2098. install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
  2099. install -d "$(LIBDIR)"; \
  2100. install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"'
  2101. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  2102. 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'
  2103. objformat="win32"
  2104. enable dos_paths
  2105. check_cflags -fno-common
  2106. check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \
  2107. || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
  2108. die "ERROR: MinGW runtime version must be >= 3.15."
  2109. ;;
  2110. cygwin*)
  2111. target_os=cygwin
  2112. shlibdir_default="$bindir_default"
  2113. SLIBPREF="cyg"
  2114. SLIBSUF=".dll"
  2115. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2116. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2117. SHFLAGS='-shared -Wl,--enable-auto-image-base'
  2118. objformat="win32"
  2119. enable dos_paths
  2120. check_cflags -fno-common
  2121. ;;
  2122. *-dos|freedos|opendos)
  2123. disable ffplay ffserver
  2124. disable $INDEV_LIST $OUTDEV_LIST
  2125. network_extralibs="-lsocket"
  2126. objformat="coff"
  2127. enable dos_paths
  2128. ;;
  2129. linux)
  2130. enable dv1394
  2131. ;;
  2132. irix*)
  2133. target_os=irix
  2134. ranlib="echo ignoring ranlib"
  2135. ;;
  2136. os/2*)
  2137. strip="lxlite"
  2138. ln_s="cp -f"
  2139. add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
  2140. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  2141. FFSERVERLDFLAGS=""
  2142. LIBSUF="_s.a"
  2143. SLIBPREF=""
  2144. SLIBSUF=".dll"
  2145. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  2146. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  2147. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  2148. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  2149. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  2150. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  2151. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  2152. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  2153. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  2154. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  2155. SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
  2156. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
  2157. enable dos_paths
  2158. ;;
  2159. gnu/kfreebsd)
  2160. ;;
  2161. gnu)
  2162. ;;
  2163. none)
  2164. ;;
  2165. *)
  2166. die "Unknown OS '$target_os'."
  2167. ;;
  2168. esac
  2169. echo "config:$arch:$subarch:$cpu:$target_os:$cc_ident:$FFMPEG_CONFIGURATION" >config.fate
  2170. check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
  2171. set_default $PATHS_LIST
  2172. # we need to build at least one lib type
  2173. if ! enabled_any static shared; then
  2174. cat <<EOF
  2175. At least one library type must be built.
  2176. Specify --enable-static to build the static libraries or --enable-shared to
  2177. build the shared libraries as well. To only build the shared libraries specify
  2178. --disable-static in addition to --enable-shared.
  2179. EOF
  2180. exit 1;
  2181. fi
  2182. disabled static && LIBNAME=""
  2183. die_license_disabled() {
  2184. enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
  2185. }
  2186. die_license_disabled gpl libx264
  2187. die_license_disabled gpl libxavs
  2188. die_license_disabled gpl libxvid
  2189. die_license_disabled gpl postproc
  2190. die_license_disabled gpl x11grab
  2191. die_license_disabled nonfree libfaac
  2192. die_license_disabled version3 libopencore_amrnb
  2193. die_license_disabled version3 libopencore_amrwb
  2194. enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
  2195. check_deps $ARCH_EXT_LIST
  2196. disabled optimizations || check_cflags -fomit-frame-pointer
  2197. enable_pic() {
  2198. enable pic
  2199. add_cppflags -DPIC
  2200. add_cflags -fPIC
  2201. add_asflags -fPIC
  2202. }
  2203. enabled pic && enable_pic
  2204. check_cc <<EOF || die "Symbol mangling check failed."
  2205. int ff_extern;
  2206. EOF
  2207. sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
  2208. extern_prefix=${sym%%ff_extern*}
  2209. check_cc <<EOF && enable inline_asm
  2210. void foo(void) { __asm__ volatile ("" ::); }
  2211. EOF
  2212. _restrict=
  2213. for restrict_keyword in restrict __restrict__ __restrict; do
  2214. check_cc <<EOF && _restrict=$restrict_keyword && break
  2215. void foo(char * $restrict_keyword p);
  2216. EOF
  2217. done
  2218. check_cc <<EOF && enable attribute_packed
  2219. struct { int x; } __attribute__((packed)) x;
  2220. EOF
  2221. check_cc <<EOF && enable attribute_may_alias
  2222. union { int x; } __attribute__((may_alias)) x;
  2223. EOF
  2224. check_cc <<EOF || die "endian test failed"
  2225. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  2226. EOF
  2227. od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  2228. if enabled alpha; then
  2229. check_cflags -mieee
  2230. elif enabled arm; then
  2231. check_cflags -marm
  2232. nogas=die
  2233. check_ld <<EOF && enable vfp_args
  2234. __asm__ (".eabi_attribute 28, 1");
  2235. int main(void) { return 0; }
  2236. EOF
  2237. # We have to check if pld is a nop and disable it.
  2238. check_asm pld '"pld [r0]"'
  2239. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  2240. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  2241. enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
  2242. enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
  2243. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  2244. enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
  2245. enabled_all armv6t2 shared !pic && enable_pic
  2246. elif enabled mips; then
  2247. check_asm loongson '"dmult.g $1, $2, $3"'
  2248. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  2249. elif enabled ppc; then
  2250. enable local_aligned_8 local_aligned_16
  2251. check_asm dcbzl '"dcbzl 0, %0" :: "r"(0)'
  2252. check_asm ibm_asm '"add 0, 0, 0"'
  2253. check_asm ppc4xx '"maclhw r10, r11, r12"'
  2254. check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
  2255. # AltiVec flags: The FSF version of GCC differs from the Apple version
  2256. if enabled altivec; then
  2257. nogas=warn
  2258. check_cflags -maltivec -mabi=altivec &&
  2259. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  2260. check_cflags -faltivec
  2261. # check if our compiler supports Motorola AltiVec C API
  2262. check_cc <<EOF || disable altivec
  2263. $inc_altivec_h
  2264. int main(void) {
  2265. vector signed int v1, v2, v3;
  2266. v1 = vec_add(v2,v3);
  2267. return 0;
  2268. }
  2269. EOF
  2270. # check if our compiler supports braces for vector declarations
  2271. check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
  2272. $inc_altivec_h
  2273. int main (void) { (vector int) {1}; return 0; }
  2274. EOF
  2275. fi
  2276. elif enabled sparc; then
  2277. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
  2278. add_cflags -mcpu=ultrasparc -mtune=ultrasparc
  2279. elif enabled x86; then
  2280. enable local_aligned_8 local_aligned_16
  2281. # check whether EBP is available on x86
  2282. # As 'i' is stored on the stack, this program will crash
  2283. # if the base pointer is used to access it because the
  2284. # base pointer is cleared in the inline assembly code.
  2285. check_exec_crash <<EOF && enable ebp_available
  2286. volatile int i=0;
  2287. __asm__ volatile (
  2288. "xorl %%ebp, %%ebp"
  2289. ::: "%ebp");
  2290. return i;
  2291. EOF
  2292. # check whether EBX is available on x86
  2293. check_asm ebx_available '""::"b"(0)' &&
  2294. check_asm ebx_available '"":::"%ebx"'
  2295. # check whether more than 10 operands are supported
  2296. check_cc <<EOF && enable ten_operands
  2297. int main(void) {
  2298. int x=0;
  2299. __asm__ volatile(
  2300. ""
  2301. :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
  2302. );
  2303. return 0;
  2304. }
  2305. EOF
  2306. # check whether binutils is new enough to compile SSSE3/MMX2
  2307. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  2308. enabled mmx2 && check_asm mmx2 '"pmaxub %mm0, %mm1"'
  2309. check_asm bswap '"bswap %%eax" ::: "%eax"'
  2310. YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
  2311. enabled x86_64 && append YASMFLAGS "-m amd64"
  2312. enabled pic && append YASMFLAGS "-DPIC"
  2313. test -n "$extern_prefix" && append YASMFLAGS "-DPREFIX"
  2314. case "$objformat" in
  2315. elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
  2316. esac
  2317. if ! disabled_any asm mmx yasm; then
  2318. check_yasm "pabsw xmm0, xmm0" && enable yasm ||
  2319. die "yasm not found, use --disable-yasm for a crippled build"
  2320. fi
  2321. case "$cpu" in
  2322. athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
  2323. disable fast_clz
  2324. ;;
  2325. esac
  2326. fi
  2327. if enabled asm; then
  2328. as=${gas:=$as}
  2329. check_asm gnu_as '".macro m n\n\\n:.int 0\n.endm\nm x"' ||
  2330. $nogas "GNU assembler not found, install gas-preprocessor"
  2331. fi
  2332. if check_func dlopen; then
  2333. ldl=
  2334. elif check_func dlopen -ldl; then
  2335. ldl=-ldl
  2336. fi
  2337. # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
  2338. check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
  2339. check_func fcntl
  2340. check_func fork
  2341. check_func getaddrinfo $network_extralibs
  2342. check_func gethrtime
  2343. check_func getrusage
  2344. check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
  2345. check_func inet_aton $network_extralibs
  2346. check_func isatty
  2347. check_func ${malloc_prefix}memalign && enable memalign
  2348. check_func mkstemp
  2349. check_func ${malloc_prefix}posix_memalign && enable posix_memalign
  2350. check_func setrlimit
  2351. check_func strerror_r
  2352. check_func_headers io.h setmode
  2353. check_func_headers lzo/lzo1x.h lzo1x_999_compress
  2354. check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
  2355. check_func_headers windows.h GetProcessTimes
  2356. check_func_headers windows.h VirtualAlloc
  2357. check_header conio.h
  2358. check_header dlfcn.h
  2359. check_header dxva2api.h
  2360. check_header malloc.h
  2361. check_header poll.h
  2362. check_header sys/mman.h
  2363. check_header sys/resource.h
  2364. check_header sys/select.h
  2365. check_header termios.h
  2366. check_header vdpau/vdpau.h
  2367. check_header vdpau/vdpau_x11.h
  2368. check_header X11/extensions/XvMClib.h
  2369. check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex
  2370. if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
  2371. enabled_any $need_memalign ; then
  2372. die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
  2373. fi
  2374. disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
  2375. disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  2376. # check for some common methods of building with pthread support
  2377. # do this before the optional library checks as some of them require pthreads
  2378. if ! disabled pthreads && ! enabled w32threads; then
  2379. enable pthreads
  2380. if check_func pthread_create; then
  2381. :
  2382. elif check_func pthread_create -pthread; then
  2383. add_cflags -pthread
  2384. add_extralibs -pthread
  2385. elif check_func pthread_create -pthreads; then
  2386. add_cflags -pthreads
  2387. add_extralibs -pthreads
  2388. elif check_func pthread_create -lpthreadGC2; then
  2389. add_extralibs -lpthreadGC2
  2390. elif ! check_lib pthread.h pthread_create -lpthread; then
  2391. disable pthreads
  2392. fi
  2393. fi
  2394. for thread in $THREADS_LIST; do
  2395. if enabled $thread; then
  2396. test -n "$thread_type" &&
  2397. die "ERROR: Only one thread type must be selected." ||
  2398. thread_type="$thread"
  2399. fi
  2400. done
  2401. check_lib math.h sin -lm
  2402. disabled vaapi || check_lib va/va.h vaInitialize -lva
  2403. check_mathfunc exp2
  2404. check_mathfunc exp2f
  2405. check_mathfunc llrint
  2406. check_mathfunc llrintf
  2407. check_mathfunc log2
  2408. check_mathfunc log2f
  2409. check_mathfunc lrint
  2410. check_mathfunc lrintf
  2411. check_mathfunc round
  2412. check_mathfunc roundf
  2413. check_mathfunc truncf
  2414. # these are off by default, so fail if requested and not available
  2415. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
  2416. enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
  2417. require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
  2418. require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
  2419. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  2420. enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
  2421. enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame
  2422. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  2423. enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
  2424. enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
  2425. enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
  2426. enabled librtmp && { check_lib librtmp/rtmp.h RTMP_Socket $(pkg-config --libs librtmp) ||
  2427. die "ERROR: librtmp not found or RTMP_Socket() missing, librtmp version must be >= 2.2.f"; }
  2428. enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
  2429. require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
  2430. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  2431. enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
  2432. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  2433. enabled libvpx && {
  2434. enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
  2435. die "ERROR: libvpx decoder version must be >=0.9.1"; }
  2436. enabled libvpx_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_enc_init_ver -lvpx ||
  2437. die "ERROR: libvpx encoder version must be >=0.9.1"; } }
  2438. enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
  2439. { check_cpp_condition x264.h "X264_BUILD >= 98" ||
  2440. die "ERROR: libx264 version must be >= 0.98."; }
  2441. enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs
  2442. enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
  2443. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  2444. # libdc1394 check
  2445. if enabled libdc1394; then
  2446. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  2447. enable libdc1394_2; } ||
  2448. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  2449. enable libdc1394_1; } ||
  2450. die "ERROR: No version of libdc1394 found "
  2451. fi
  2452. SDL_CONFIG="${cross_prefix}sdl-config"
  2453. if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
  2454. sdl_cflags=$("${SDL_CONFIG}" --cflags)
  2455. sdl_libs=$("${SDL_CONFIG}" --libs)
  2456. check_func_headers SDL.h SDL_Init $sdl_cflags $sdl_libs &&
  2457. check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
  2458. enable sdl &&
  2459. check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
  2460. fi
  2461. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  2462. if enabled network; then
  2463. check_type "sys/types.h sys/socket.h" socklen_t
  2464. check_type netdb.h "struct addrinfo"
  2465. check_type netinet/in.h "struct ipv6_mreq"
  2466. check_type netinet/in.h "struct sockaddr_in6"
  2467. check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
  2468. check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
  2469. # Prefer arpa/inet.h over winsock2
  2470. if check_header arpa/inet.h ; then
  2471. check_func closesocket
  2472. elif check_header winsock2.h ; then
  2473. check_func_headers winsock2.h closesocket -lws2 && \
  2474. network_extralibs="-lws2" || \
  2475. { check_func_headers winsock2.h closesocket -lws2_32 && \
  2476. network_extralibs="-lws2_32"; }
  2477. check_type ws2tcpip.h socklen_t
  2478. check_type ws2tcpip.h "struct addrinfo"
  2479. check_type ws2tcpip.h "struct ipv6_mreq"
  2480. check_type ws2tcpip.h "struct sockaddr_in6"
  2481. check_type ws2tcpip.h "struct sockaddr_storage"
  2482. check_struct winsock2.h "struct sockaddr" sa_len
  2483. else
  2484. disable network
  2485. fi
  2486. fi
  2487. check_header linux/videodev.h
  2488. check_header linux/videodev2.h
  2489. check_header sys/videoio.h
  2490. check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
  2491. # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
  2492. # w32api 3.12 had it defined wrong
  2493. check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
  2494. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  2495. { check_header dev/bktr/ioctl_meteor.h &&
  2496. check_header dev/bktr/ioctl_bt848.h; } ||
  2497. { check_header machine/ioctl_meteor.h &&
  2498. check_header machine/ioctl_bt848.h; } ||
  2499. { check_header dev/video/meteor/ioctl_meteor.h &&
  2500. check_header dev/video/bktr/ioctl_bt848.h; } ||
  2501. check_header dev/ic/bt8xx.h
  2502. check_header sys/soundcard.h
  2503. check_header soundcard.h
  2504. enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
  2505. enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
  2506. enabled x11grab &&
  2507. check_header X11/Xlib.h &&
  2508. check_header X11/extensions/XShm.h &&
  2509. check_header X11/extensions/Xfixes.h &&
  2510. check_func XOpenDisplay -lX11 &&
  2511. check_func XShmCreateImage -lX11 -lXext &&
  2512. check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
  2513. if ! disabled vdpau && enabled vdpau_vdpau_h; then
  2514. check_cpp_condition \
  2515. vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
  2516. { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
  2517. disable vdpau; }
  2518. fi
  2519. enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
  2520. # add some useful compiler flags if supported
  2521. check_cflags -Wdeclaration-after-statement
  2522. check_cflags -Wall
  2523. check_cflags -Wno-parentheses
  2524. check_cflags -Wno-switch
  2525. check_cflags -Wdisabled-optimization
  2526. check_cflags -Wpointer-arith
  2527. check_cflags -Wredundant-decls
  2528. check_cflags -Wno-pointer-sign
  2529. check_cflags -Wcast-qual
  2530. check_cflags -Wwrite-strings
  2531. check_cflags -Wtype-limits
  2532. check_cflags -Wundef
  2533. check_cflags -Wmissing-prototypes
  2534. enabled extra_warnings && check_cflags -Winline
  2535. # add some linker flags
  2536. check_ldflags -Wl,--warn-common
  2537. check_ldflags -Wl,--as-needed
  2538. 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)/libavcore -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
  2539. check_ldflags -Wl,-Bsymbolic
  2540. echo "X{};" > $TMPV
  2541. if test_ldflags -Wl,--version-script,$TMPV; then
  2542. append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
  2543. check_cc <<EOF && enable symver_asm_label
  2544. void ff_foo(void) __asm__ ("av_foo@VERSION");
  2545. void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
  2546. EOF
  2547. check_cc <<EOF && enable symver_gnu_asm
  2548. __asm__(".symver ff_foo,av_foo@VERSION");
  2549. void ff_foo(void) {}
  2550. EOF
  2551. fi
  2552. if enabled small; then
  2553. add_cflags $size_cflags
  2554. optimizations="small"
  2555. elif enabled optimizations; then
  2556. add_cflags $speed_cflags
  2557. else
  2558. add_cflags $noopt_cflags
  2559. fi
  2560. check_cflags -fno-math-errno
  2561. check_cflags -fno-signed-zeros
  2562. if enabled icc; then
  2563. # Just warnings, no remarks
  2564. check_cflags -w1
  2565. # -wd: Disable following warnings
  2566. # 144, 167, 556: -Wno-pointer-sign
  2567. # 10006: ignoring unknown option -fno-signed-zeros
  2568. # 10156: ignoring option '-W'; no argument required
  2569. check_cflags -wd144,167,556,10006,10156
  2570. # 11030: Warning unknown option --as-needed
  2571. # 10156: ignoring option '-export'; no argument required
  2572. check_ldflags -wd10156,11030
  2573. # Allow to compile with optimizations
  2574. check_ldflags -march=$cpu
  2575. # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
  2576. enable ebp_available
  2577. elif enabled ccc; then
  2578. # disable some annoying warnings
  2579. add_cflags -msg_disable cvtu32to64
  2580. add_cflags -msg_disable embedcomment
  2581. add_cflags -msg_disable needconstext
  2582. add_cflags -msg_disable nomainieee
  2583. add_cflags -msg_disable ptrmismatch1
  2584. add_cflags -msg_disable unreachcode
  2585. elif enabled gcc; then
  2586. check_cflags -fno-tree-vectorize
  2587. check_cflags -Werror=implicit-function-declaration
  2588. check_cflags -Werror=missing-prototypes
  2589. elif enabled clang; then
  2590. check_cflags -Qunused-arguments
  2591. elif enabled armcc; then
  2592. # 2523: use of inline assembler is deprecated
  2593. add_cflags -W${armcc_opt},--diag_suppress=2523
  2594. add_cflags -W${armcc_opt},--diag_suppress=1207
  2595. elif enabled tms470; then
  2596. add_cflags -pds=824 -pds=837
  2597. fi
  2598. enabled_any $THREADS_LIST && enable threads
  2599. check_deps $CONFIG_LIST \
  2600. $CONFIG_EXTRA \
  2601. $HAVE_LIST \
  2602. $DECODER_LIST \
  2603. $ENCODER_LIST \
  2604. $HWACCEL_LIST \
  2605. $PARSER_LIST \
  2606. $BSF_LIST \
  2607. $DEMUXER_LIST \
  2608. $MUXER_LIST \
  2609. $FILTER_LIST \
  2610. $INDEV_LIST \
  2611. $OUTDEV_LIST \
  2612. $PROTOCOL_LIST \
  2613. $ACODEC_TESTS \
  2614. $VCODEC_TESTS \
  2615. $LAVF_TESTS \
  2616. $LAVFI_TESTS \
  2617. $SEEK_TESTS \
  2618. enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
  2619. echo "install prefix $prefix"
  2620. echo "source path $source_path"
  2621. echo "C compiler $cc"
  2622. echo "ARCH $arch ($cpu)"
  2623. if test "$build_suffix" != ""; then
  2624. echo "build suffix $build_suffix"
  2625. fi
  2626. if test "$extra_version" != ""; then
  2627. echo "version string suffix $extra_version"
  2628. fi
  2629. echo "big-endian ${bigendian-no}"
  2630. echo "runtime cpu detection ${runtime_cpudetect-no}"
  2631. if enabled x86; then
  2632. echo "yasm ${yasm-no}"
  2633. echo "MMX enabled ${mmx-no}"
  2634. echo "MMX2 enabled ${mmx2-no}"
  2635. echo "3DNow! enabled ${amd3dnow-no}"
  2636. echo "3DNow! extended enabled ${amd3dnowext-no}"
  2637. echo "SSE enabled ${sse-no}"
  2638. echo "SSSE3 enabled ${ssse3-no}"
  2639. echo "CMOV enabled ${cmov-no}"
  2640. echo "CMOV is fast ${fast_cmov-no}"
  2641. echo "EBX available ${ebx_available-no}"
  2642. echo "EBP available ${ebp_available-no}"
  2643. echo "10 operands supported ${ten_operands-no}"
  2644. fi
  2645. if enabled arm; then
  2646. echo "ARMv5TE enabled ${armv5te-no}"
  2647. echo "ARMv6 enabled ${armv6-no}"
  2648. echo "ARMv6T2 enabled ${armv6t2-no}"
  2649. echo "ARM VFP enabled ${armvfp-no}"
  2650. echo "IWMMXT enabled ${iwmmxt-no}"
  2651. echo "NEON enabled ${neon-no}"
  2652. fi
  2653. if enabled mips; then
  2654. echo "MMI enabled ${mmi-no}"
  2655. fi
  2656. if enabled ppc; then
  2657. echo "AltiVec enabled ${altivec-no}"
  2658. echo "PPC 4xx optimizations ${ppc4xx-no}"
  2659. echo "dcbzl available ${dcbzl-no}"
  2660. fi
  2661. if enabled sparc; then
  2662. echo "VIS enabled ${vis-no}"
  2663. fi
  2664. echo "debug symbols ${debug-no}"
  2665. echo "strip symbols ${stripping-no}"
  2666. echo "optimizations ${optimizations-no}"
  2667. echo "static ${static-no}"
  2668. echo "shared ${shared-no}"
  2669. echo "postprocessing support ${postproc-no}"
  2670. echo "new filter support ${avfilter-no}"
  2671. echo "network support ${network-no}"
  2672. echo "threading support ${thread_type-no}"
  2673. echo "SDL support ${sdl-no}"
  2674. echo "Sun medialib support ${mlib-no}"
  2675. echo "AVISynth enabled ${avisynth-no}"
  2676. echo "libdc1394 support ${libdc1394-no}"
  2677. echo "libdirac enabled ${libdirac-no}"
  2678. echo "libfaac enabled ${libfaac-no}"
  2679. echo "libgsm enabled ${libgsm-no}"
  2680. echo "libmp3lame enabled ${libmp3lame-no}"
  2681. echo "libnut enabled ${libnut-no}"
  2682. echo "libopencore-amrnb support ${libopencore_amrnb-no}"
  2683. echo "libopencore-amrwb support ${libopencore_amrwb-no}"
  2684. echo "libopenjpeg enabled ${libopenjpeg-no}"
  2685. echo "librtmp enabled ${librtmp-no}"
  2686. echo "libschroedinger enabled ${libschroedinger-no}"
  2687. echo "libspeex enabled ${libspeex-no}"
  2688. echo "libtheora enabled ${libtheora-no}"
  2689. echo "libvorbis enabled ${libvorbis-no}"
  2690. echo "libvpx enabled ${libvpx-no}"
  2691. echo "libx264 enabled ${libx264-no}"
  2692. echo "libxavs enabled ${libxavs-no}"
  2693. echo "libxvid enabled ${libxvid-no}"
  2694. echo "zlib enabled ${zlib-no}"
  2695. echo "bzlib enabled ${bzlib-no}"
  2696. echo
  2697. for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
  2698. echo "Enabled ${type}s:"
  2699. eval list=\$$(toupper $type)_LIST
  2700. print_enabled '_*' $list | sort | pr -3 -t
  2701. echo
  2702. done
  2703. license="LGPL version 2.1 or later"
  2704. if enabled nonfree; then
  2705. license="nonfree and unredistributable"
  2706. elif enabled gplv3; then
  2707. license="GPL version 3 or later"
  2708. elif enabled lgplv3; then
  2709. license="LGPL version 3 or later"
  2710. elif enabled gpl; then
  2711. license="GPL version 2 or later"
  2712. fi
  2713. echo "License: $license"
  2714. echo "Creating config.mak and config.h..."
  2715. # build tree in object directory if source path is different from current one
  2716. if enabled source_path_used; then
  2717. DIRS="
  2718. doc
  2719. libavcodec
  2720. libavcodec/$arch
  2721. libavcore
  2722. libavdevice
  2723. libavfilter
  2724. libavformat
  2725. libavutil
  2726. libavutil/$arch
  2727. libpostproc
  2728. libswscale
  2729. libswscale/$arch
  2730. tests
  2731. tools
  2732. "
  2733. FILES="
  2734. Makefile
  2735. common.mak
  2736. subdir.mak
  2737. doc/texi2pod.pl
  2738. libavcodec/Makefile
  2739. libavcodec/${arch}/Makefile
  2740. libavcore/Makefile
  2741. libavdevice/Makefile
  2742. libavfilter/Makefile
  2743. libavformat/Makefile
  2744. libavutil/Makefile
  2745. libpostproc/Makefile
  2746. libswscale/Makefile
  2747. "
  2748. map 'mkdir -p $v' $DIRS;
  2749. map 'test -f "$source_path/$v" && $ln_s "$source_path/$v" $v' $FILES
  2750. fi
  2751. enabled stripping || strip="echo skipping strip"
  2752. cat > config.mak <<EOF
  2753. # Automatically generated by configure - do not modify!
  2754. ifndef FFMPEG_CONFIG_MAK
  2755. FFMPEG_CONFIG_MAK=1
  2756. FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
  2757. prefix=$prefix
  2758. LIBDIR=\$(DESTDIR)$libdir
  2759. SHLIBDIR=\$(DESTDIR)$shlibdir
  2760. INCDIR=\$(DESTDIR)$incdir
  2761. BINDIR=\$(DESTDIR)$bindir
  2762. DATADIR=\$(DESTDIR)$datadir
  2763. MANDIR=\$(DESTDIR)$mandir
  2764. SRC_PATH="$source_path"
  2765. SRC_PATH_BARE=$source_path
  2766. BUILD_ROOT="$PWD"
  2767. CC_IDENT=$cc_ident
  2768. ARCH=$arch
  2769. CC=$cc
  2770. AS=$as
  2771. LD=$ld
  2772. DEPCC=$dep_cc
  2773. YASM=$yasmexe
  2774. YASMDEP=$yasmexe
  2775. AR=$ar
  2776. RANLIB=$ranlib
  2777. CP=cp -p
  2778. LN_S=$ln_s
  2779. STRIP=$strip
  2780. CPPFLAGS=$CPPFLAGS
  2781. CFLAGS=$CFLAGS
  2782. ASFLAGS=$ASFLAGS
  2783. CC_O=$CC_O
  2784. LDFLAGS=$LDFLAGS
  2785. FFSERVERLDFLAGS=$FFSERVERLDFLAGS
  2786. SHFLAGS=$SHFLAGS
  2787. YASMFLAGS=$YASMFLAGS
  2788. BUILDSUF=$build_suffix
  2789. FULLNAME=$FULLNAME
  2790. LIBPREF=$LIBPREF
  2791. LIBSUF=$LIBSUF
  2792. LIBNAME=$LIBNAME
  2793. SLIBPREF=$SLIBPREF
  2794. SLIBSUF=$SLIBSUF
  2795. EXESUF=$EXESUF
  2796. EXTRA_VERSION=$extra_version
  2797. DEPFLAGS=$DEPFLAGS
  2798. CCDEP=$CCDEP
  2799. ASDEP=$ASDEP
  2800. CC_DEPFLAGS=$CC_DEPFLAGS
  2801. AS_DEPFLAGS=$AS_DEPFLAGS
  2802. HOSTCC=$host_cc
  2803. HOSTCFLAGS=$host_cflags
  2804. HOSTEXESUF=$HOSTEXESUF
  2805. HOSTLDFLAGS=$host_ldflags
  2806. HOSTLIBS=$host_libs
  2807. TARGET_EXEC=$target_exec
  2808. TARGET_PATH=$target_path
  2809. SDL_LIBS=$sdl_libs
  2810. SDL_CFLAGS=$sdl_cflags
  2811. LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
  2812. EXTRALIBS=$extralibs
  2813. INSTALL=install
  2814. LIBTARGET=${LIBTARGET}
  2815. SLIBNAME=${SLIBNAME}
  2816. SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
  2817. SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
  2818. SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
  2819. SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
  2820. SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}
  2821. SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}
  2822. SAMPLES=$samples
  2823. EOF
  2824. get_version(){
  2825. name=$1
  2826. file=$source_path/$2
  2827. eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
  2828. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  2829. lcname=$(tolower $name)
  2830. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  2831. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  2832. }
  2833. get_version LIBSWSCALE libswscale/swscale.h
  2834. get_version LIBPOSTPROC libpostproc/postprocess.h
  2835. get_version LIBAVCODEC libavcodec/avcodec.h
  2836. get_version LIBAVCORE libavcore/avcore.h
  2837. get_version LIBAVDEVICE libavdevice/avdevice.h
  2838. get_version LIBAVFORMAT libavformat/avformat.h
  2839. get_version LIBAVUTIL libavutil/avutil.h
  2840. get_version LIBAVFILTER libavfilter/avfilter.h
  2841. cat > $TMPH <<EOF
  2842. /* Automatically generated by configure - do not modify! */
  2843. #ifndef FFMPEG_CONFIG_H
  2844. #define FFMPEG_CONFIG_H
  2845. #define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
  2846. #define FFMPEG_LICENSE "$(c_escape $license)"
  2847. #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
  2848. #define CC_TYPE "$cc_type"
  2849. #define CC_VERSION $cc_version
  2850. #define restrict $_restrict
  2851. #define ASMALIGN(ZEROBITS) ".p2align " #ZEROBITS "\\n\\t"
  2852. #define EXTERN_PREFIX "${extern_prefix}"
  2853. #define EXTERN_ASM ${extern_prefix}
  2854. EOF
  2855. test -n "$malloc_prefix" &&
  2856. echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
  2857. if enabled small || disabled optimizations; then
  2858. echo "#undef av_always_inline" >> $TMPH
  2859. echo "#define av_always_inline" >> $TMPH
  2860. fi
  2861. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  2862. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  2863. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  2864. $CONFIG_EXTRA \
  2865. $DECODER_LIST \
  2866. $ENCODER_LIST \
  2867. $HWACCEL_LIST \
  2868. $PARSER_LIST \
  2869. $BSF_LIST \
  2870. $DEMUXER_LIST \
  2871. $MUXER_LIST \
  2872. $FILTER_LIST \
  2873. $PROTOCOL_LIST \
  2874. $INDEV_LIST \
  2875. $OUTDEV_LIST \
  2876. cat >>config.mak <<EOF
  2877. ACODEC_TESTS=$(print_enabled -n _test $ACODEC_TESTS)
  2878. VCODEC_TESTS=$(print_enabled -n _test $VCODEC_TESTS)
  2879. LAVF_TESTS=$(print_enabled -n _test $LAVF_TESTS)
  2880. LAVFI_TESTS=$(print_enabled -n _test $LAVFI_TESTS)
  2881. SEEK_TESTS=$(print_enabled -n _test $SEEK_TESTS)
  2882. EOF
  2883. echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
  2884. echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
  2885. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  2886. cp_if_changed $TMPH config.h
  2887. touch .config
  2888. cat > $TMPH <<EOF
  2889. /* Generated by ffconf */
  2890. #ifndef AVUTIL_AVCONFIG_H
  2891. #define AVUTIL_AVCONFIG_H
  2892. EOF
  2893. print_config AV_HAVE_ $TMPH /dev/null $HAVE_LIST_PUB
  2894. echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
  2895. cp_if_changed $TMPH libavutil/avconfig.h
  2896. test -n "$WARNINGS" && printf "\n$WARNINGS"
  2897. # build pkg-config files
  2898. pkgconfig_generate(){
  2899. name=$1
  2900. shortname=${name#lib}${build_suffix}
  2901. comment=$2
  2902. version=$3
  2903. libs=$4
  2904. requires=$5
  2905. enabled ${name#lib} || return 0
  2906. cat <<EOF > $name/$name.pc
  2907. prefix=$prefix
  2908. exec_prefix=\${prefix}
  2909. libdir=$libdir
  2910. includedir=$incdir
  2911. Name: $name
  2912. Description: $comment
  2913. Version: $version
  2914. Requires: $(enabled shared || echo $requires)
  2915. Requires.private: $(enabled shared && echo $requires)
  2916. Conflicts:
  2917. Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
  2918. Libs.private: $(enabled shared && echo $libs)
  2919. Cflags: -I\${includedir}
  2920. EOF
  2921. cat <<EOF > $name/$name-uninstalled.pc
  2922. prefix=
  2923. exec_prefix=
  2924. libdir=\${pcfiledir}
  2925. includedir=${source_path}
  2926. Name: $name
  2927. Description: $comment
  2928. Version: $version
  2929. Requires: $requires
  2930. Conflicts:
  2931. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  2932. Cflags: -I\${includedir}
  2933. EOF
  2934. }
  2935. pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
  2936. pkgconfig_generate libavcore "FFmpeg multimedia shared core utilities library" "$LIBAVCORE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
  2937. pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavcore = $LIBAVCORE_VERSION"
  2938. pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
  2939. pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
  2940. pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavcore = $LIBAVCORE_VERSION"
  2941. pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
  2942. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"