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.

3261 lines
95KB

  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. mmst_protocol_deps="network"
  1255. rtmp_protocol_select="tcp_protocol"
  1256. rtp_protocol_select="udp_protocol"
  1257. tcp_protocol_deps="network"
  1258. udp_protocol_deps="network"
  1259. # libraries
  1260. avdevice_deps="avcodec avformat"
  1261. avformat_deps="avcodec"
  1262. # programs
  1263. ffmpeg_deps="avcodec avformat swscale"
  1264. ffmpeg_select="buffer_filter"
  1265. ffplay_deps="avcodec avformat swscale sdl"
  1266. ffplay_select="rdft"
  1267. ffprobe_deps="avcodec avformat"
  1268. ffserver_deps="avformat ffm_muxer rtp_protocol rtsp_demuxer"
  1269. ffserver_extralibs='$ldl'
  1270. doc_deps="texi2html"
  1271. # tests
  1272. test_deps(){
  1273. suf1=$1
  1274. suf2=$2
  1275. shift 2
  1276. for v; do
  1277. dep=${v%=*}
  1278. tests=${v#*=}
  1279. for name in ${tests}; do
  1280. eval ${name}_test_deps="'${dep}$suf1 ${dep}$suf2'"
  1281. done
  1282. done
  1283. }
  1284. set_ne_test_deps(){
  1285. eval ${1}_be_test_deps="bigendian"
  1286. eval ${1}_le_test_deps="!bigendian"
  1287. }
  1288. test_deps _encoder _decoder \
  1289. ac3 \
  1290. adpcm_g726=g726 \
  1291. adpcm_ima_qt \
  1292. adpcm_ima_wav \
  1293. adpcm_ms \
  1294. adpcm_swf \
  1295. adpcm_yamaha=adpcm_yam \
  1296. alac \
  1297. asv1 \
  1298. asv2 \
  1299. bmp \
  1300. dnxhd="hdxhd_1080i dnxhd_720p dnxhd_720p_rd" \
  1301. dvvideo="dv dv50" \
  1302. ffv1 \
  1303. flac \
  1304. flashsv \
  1305. flv \
  1306. gif \
  1307. h261 \
  1308. h263="h263 h263p" \
  1309. huffyuv \
  1310. jpegls \
  1311. mjpeg="jpg mjpeg ljpeg" \
  1312. mp2 \
  1313. mpeg1video="mpeg mpeg1b" \
  1314. mpeg2video="mpeg2 mpeg2thread" \
  1315. mpeg4="mpeg4 mpeg4adv mpeg4nr mpeg4thread error rc" \
  1316. msmpeg4v3=msmpeg4 \
  1317. msmpeg4v2 \
  1318. pbm=pbmpipe \
  1319. pcx \
  1320. pgm="pgm pgmpipe" \
  1321. ppm="ppm ppmpipe" \
  1322. rawvideo="rgb yuv" \
  1323. roq \
  1324. rv10 \
  1325. rv20 \
  1326. sgi \
  1327. snow="snow snowll" \
  1328. svq1 \
  1329. targa=tga \
  1330. tiff \
  1331. wmav1 \
  1332. wmav2 \
  1333. wmv1 \
  1334. wmv2 \
  1335. test_deps _muxer _demuxer \
  1336. aiff \
  1337. pcm_alaw=alaw \
  1338. asf \
  1339. au \
  1340. avi \
  1341. dv=dv_fmt \
  1342. ffm \
  1343. flv=flv_fmt \
  1344. gxf \
  1345. matroska=mkv \
  1346. mmf \
  1347. mov \
  1348. pcm_mulaw=mulaw \
  1349. mxf \
  1350. nut \
  1351. ogg \
  1352. rawvideo=pixfmt \
  1353. rm \
  1354. swf \
  1355. mpegts=ts \
  1356. voc \
  1357. wav \
  1358. yuv4mpegpipe=yuv4mpeg \
  1359. mpg_test_deps="mpeg1system_muxer mpegps_demuxer"
  1360. set_ne_test_deps pixdesc
  1361. set_ne_test_deps pixfmts_crop
  1362. set_ne_test_deps pixfmts_hflip
  1363. set_ne_test_deps pixfmts_null
  1364. set_ne_test_deps pixfmts_pad
  1365. set_ne_test_deps pixfmts_scale
  1366. set_ne_test_deps pixfmts_vflip
  1367. # default parameters
  1368. logfile="config.log"
  1369. # installation paths
  1370. prefix_default="/usr/local"
  1371. bindir_default='${prefix}/bin'
  1372. datadir_default='${prefix}/share/ffmpeg'
  1373. incdir_default='${prefix}/include'
  1374. libdir_default='${prefix}/lib'
  1375. mandir_default='${prefix}/share/man'
  1376. shlibdir_default="$libdir_default"
  1377. # toolchain
  1378. ar_default="ar"
  1379. cc_default="gcc"
  1380. cc_version=\"unknown\"
  1381. host_cc_default="gcc"
  1382. ln_s="ln -sf"
  1383. nm_default="nm"
  1384. objformat="elf"
  1385. ranlib="ranlib"
  1386. strip_default="strip"
  1387. yasmexe="yasm"
  1388. nogas=":"
  1389. nm_opts='-g'
  1390. # machine
  1391. arch_default=$(uname -m)
  1392. cpu="generic"
  1393. # OS
  1394. target_os_default=$(tolower $(uname -s))
  1395. host_os=$target_os_default
  1396. # configurable options
  1397. enable avcodec
  1398. enable avcore
  1399. enable avdevice
  1400. enable avfilter
  1401. enable avformat
  1402. enable avutil
  1403. enable asm
  1404. enable debug
  1405. enable doc
  1406. enable fastdiv
  1407. enable ffmpeg
  1408. enable ffplay
  1409. enable ffprobe
  1410. enable ffserver
  1411. enable mpegaudio_hp
  1412. enable network
  1413. enable optimizations
  1414. enable protocols
  1415. enable static
  1416. enable stripping
  1417. enable swscale
  1418. enable swscale_alpha
  1419. # build settings
  1420. SHFLAGS='-shared -Wl,-soname,$$(@F)'
  1421. FFSERVERLDFLAGS=-Wl,-E
  1422. LIBPREF="lib"
  1423. LIBSUF=".a"
  1424. FULLNAME='$(NAME)$(BUILDSUF)'
  1425. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  1426. SLIBPREF="lib"
  1427. SLIBSUF=".so"
  1428. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  1429. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  1430. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  1431. LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  1432. CC_O='-o $@'
  1433. host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall'
  1434. host_libs='-lm'
  1435. target_path='$(CURDIR)'
  1436. # since the object filename is not given with the -MM flag, the compiler
  1437. # is only able to print the basename, and we must add the path ourselves
  1438. DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
  1439. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
  1440. # find source path
  1441. source_path="$(dirname "$0")"
  1442. enable source_path_used
  1443. if test -f configure; then
  1444. source_path="$(pwd)"
  1445. disable source_path_used
  1446. else
  1447. source_path="$(cd "$source_path"; pwd)"
  1448. echo "$source_path" | grep -q '[[:blank:]]' &&
  1449. die "Out of tree builds are impossible with whitespace in source path."
  1450. test -e "$source_path/config.h" &&
  1451. die "Out of tree builds are impossible with config.h in source dir."
  1452. fi
  1453. for v in "$@"; do
  1454. r=${v#*=}
  1455. l=${v%"$r"}
  1456. r=$(sh_quote "$r")
  1457. FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
  1458. done
  1459. find_things(){
  1460. thing=$1
  1461. pattern=$2
  1462. file=$source_path/$3
  1463. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  1464. }
  1465. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  1466. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  1467. HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
  1468. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  1469. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  1470. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  1471. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  1472. OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
  1473. INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
  1474. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  1475. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  1476. find_tests(){
  1477. map "echo ${2}\${v}_test" $(ls "$source_path"/tests/ref/$1 | grep -v '[^-a-z0-9_]')
  1478. }
  1479. ACODEC_TESTS=$(find_tests acodec)
  1480. VCODEC_TESTS=$(find_tests vsynth1)
  1481. LAVF_TESTS=$(find_tests lavf)
  1482. LAVFI_TESTS=$(find_tests lavfi)
  1483. SEEK_TESTS=$(find_tests seek seek_)
  1484. pcm_test_deps=$(map 'echo ${v%_*}_decoder $v' $(filter pcm_* $ENCODER_LIST))
  1485. for n in $COMPONENT_LIST; do
  1486. v=$(toupper ${n%s})_LIST
  1487. eval enable \$$v
  1488. eval ${n}_if_any="\$$v"
  1489. done
  1490. enable $ARCH_EXT_LIST $ACODEC_TESTS $VCODEC_TESTS $LAVF_TESTS $LAVFI_TESTS $SEEK_TESTS
  1491. die_unknown(){
  1492. echo "Unknown option \"$1\"."
  1493. echo "See $0 --help for available options."
  1494. exit 1
  1495. }
  1496. show_list() {
  1497. suffix=_$1
  1498. shift
  1499. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
  1500. exit 0
  1501. }
  1502. for opt do
  1503. optval="${opt#*=}"
  1504. case "$opt" in
  1505. --extra-ldflags=*) add_ldflags $optval
  1506. ;;
  1507. --extra-libs=*) add_extralibs $optval
  1508. ;;
  1509. --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
  1510. ;;
  1511. --enable-debug=*) debuglevel="$optval"
  1512. ;;
  1513. --disable-everything)
  1514. map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
  1515. ;;
  1516. --enable-*=*|--disable-*=*)
  1517. eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
  1518. is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
  1519. eval list=\$$(toupper $thing)_LIST
  1520. name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
  1521. $action $(filter "$name" $list)
  1522. ;;
  1523. --enable-?*|--disable-?*)
  1524. eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
  1525. if is_in $option $COMPONENT_LIST; then
  1526. test $action = disable && action=unset
  1527. eval $action \$$(toupper ${option%s})_LIST
  1528. elif is_in $option $CMDLINE_SELECT; then
  1529. $action $option
  1530. else
  1531. die_unknown $opt
  1532. fi
  1533. ;;
  1534. --list-*)
  1535. NAME="${opt#--list-}"
  1536. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  1537. NAME=${NAME%s}
  1538. eval show_list $NAME \$$(toupper $NAME)_LIST
  1539. ;;
  1540. --help|-h) show_help
  1541. ;;
  1542. *)
  1543. optname="${opt%%=*}"
  1544. optname="${optname#--}"
  1545. optname=$(echo "$optname" | sed 's/-/_/g')
  1546. if is_in $optname $CMDLINE_SET; then
  1547. eval $optname='$optval'
  1548. elif is_in $optname $CMDLINE_APPEND; then
  1549. append $optname "$optval"
  1550. else
  1551. die_unknown $opt
  1552. fi
  1553. ;;
  1554. esac
  1555. done
  1556. disabled logging && logfile=/dev/null
  1557. echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
  1558. set >> $logfile
  1559. test -n "$cross_prefix" && enable cross_compile
  1560. if enabled cross_compile; then
  1561. test -n "$arch" && test -n "$target_os" ||
  1562. die "Must specify target arch and OS when cross-compiling"
  1563. fi
  1564. set_default arch target_os
  1565. ar_default="${cross_prefix}${ar_default}"
  1566. cc_default="${cross_prefix}${cc_default}"
  1567. nm_default="${cross_prefix}${nm_default}"
  1568. ranlib="${cross_prefix}${ranlib}"
  1569. strip_default="${cross_prefix}${strip_default}"
  1570. sysinclude_default="${sysroot}/usr/include"
  1571. set_default cc nm strip sysinclude
  1572. enabled cross_compile || host_cc_default=$cc
  1573. set_default host_cc
  1574. exesuf() {
  1575. case $1 in
  1576. mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
  1577. esac
  1578. }
  1579. EXESUF=$(exesuf $target_os)
  1580. HOSTEXESUF=$(exesuf $host_os)
  1581. # set temporary file name
  1582. : ${TMPDIR:=$TEMPDIR}
  1583. : ${TMPDIR:=$TMP}
  1584. : ${TMPDIR:=/tmp}
  1585. if ! check_cmd type mktemp; then
  1586. # simple replacement for missing mktemp
  1587. # NOT SAFE FOR GENERAL USE
  1588. mktemp(){
  1589. echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
  1590. }
  1591. fi
  1592. tmpfile(){
  1593. tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
  1594. (set -C; exec > $tmp) 2>/dev/null ||
  1595. die "Unable to create temporary file in $TMPDIR."
  1596. append TMPFILES $tmp
  1597. eval $1=$tmp
  1598. }
  1599. trap 'rm -f -- $TMPFILES' EXIT
  1600. trap exit HUP INT TERM
  1601. tmpfile TMPC .c
  1602. tmpfile TMPE $EXESUF
  1603. tmpfile TMPH .h
  1604. tmpfile TMPO .o
  1605. tmpfile TMPS .S
  1606. tmpfile TMPV .ver
  1607. tmpfile TMPSH .sh
  1608. unset -f mktemp
  1609. # make sure we can execute files in $TMPDIR
  1610. cat > $TMPSH 2>> $logfile <<EOF
  1611. #! /bin/sh
  1612. EOF
  1613. chmod +x $TMPSH >> $logfile 2>&1
  1614. if ! $TMPSH >> $logfile 2>&1; then
  1615. cat <<EOF
  1616. Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
  1617. variable to another directory and make sure that it is not mounted noexec.
  1618. EOF
  1619. die "Sanity test failed."
  1620. fi
  1621. filter_cflags=echo
  1622. filter_cppflags=echo
  1623. filter_asflags=echo
  1624. if $cc -v 2>&1 | grep -qi ^gcc; then
  1625. cc_type=gcc
  1626. cc_version=__VERSION__
  1627. gcc_extra_ver=$(expr "$($cc --version | head -n1)" : '.*\((.*)\)')
  1628. cc_ident="gcc $($cc -dumpversion) $gcc_extra_ver"
  1629. if ! $cc -dumpversion | grep -q '^2\.'; then
  1630. CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1631. AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1632. fi
  1633. speed_cflags='-O3'
  1634. size_cflags='-Os'
  1635. elif $cc --version 2>/dev/null | grep -q Intel; then
  1636. cc_type=icc
  1637. cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
  1638. cc_ident=$($cc --version | head -n1)
  1639. CC_DEPFLAGS='-MMD'
  1640. AS_DEPFLAGS='-MMD'
  1641. speed_cflags='-O3'
  1642. size_cflags='-Os'
  1643. noopt_cflags='-O1'
  1644. elif $cc -v 2>&1 | grep -q xlc; then
  1645. cc_type=xlc
  1646. cc_version="AV_STRINGIFY(__IBMC__)"
  1647. cc_ident=$($cc -qversion 2>/dev/null | head -n1)
  1648. speed_cflags='-O5'
  1649. size_cflags='-O5 -qcompact'
  1650. elif $cc -V 2>/dev/null | grep -q Compaq; then
  1651. cc_type=ccc
  1652. cc_version="AV_STRINGIFY(__DECC_VER)"
  1653. cc_ident=$($cc -V | head -n1 | cut -d' ' -f1-3)
  1654. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
  1655. debuglevel=3
  1656. add_ldflags -Wl,-z,now # calls to libots crash without this
  1657. speed_cflags='-fast'
  1658. size_cflags='-O1'
  1659. elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
  1660. test -d "$sysroot" || die "No valid sysroot specified."
  1661. cc_type=armcc
  1662. cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
  1663. cc_ident=$($cc --vsn | head -n1)
  1664. armcc_conf="$PWD/armcc.conf"
  1665. $cc --arm_linux_configure \
  1666. --arm_linux_config_file="$armcc_conf" \
  1667. --configure_sysroot="$sysroot" \
  1668. --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
  1669. die "Error creating armcc configuration file."
  1670. cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
  1671. as_default="${cross_prefix}gcc"
  1672. CC_DEPFLAGS='-MMD'
  1673. AS_DEPFLAGS='-MMD'
  1674. speed_cflags='-O3'
  1675. size_cflags='-Os'
  1676. elif $cc -version 2>/dev/null | grep -q TMS470; then
  1677. cc_type=tms470
  1678. cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
  1679. cc_ident=$($cc -version | head -n1 | tr -s ' ')
  1680. cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
  1681. CC_O='-fr=$(@D)'
  1682. as_default="${cross_prefix}gcc"
  1683. ld_default="${cross_prefix}gcc"
  1684. TMPO=$(basename $TMPC .c).o
  1685. append TMPFILES $TMPO
  1686. add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
  1687. CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
  1688. AS_DEPFLAGS='-MMD'
  1689. speed_cflags='-O3 -mf=5'
  1690. size_cflags='-O3 -mf=2'
  1691. filter_cflags=tms470_flags
  1692. tms470_flags(){
  1693. for flag; do
  1694. case $flag in
  1695. -march=*|-mcpu=*)
  1696. case "${flag#*=}" in
  1697. armv7-a|cortex-a*) echo -mv=7a8 ;;
  1698. armv7-r|cortex-r*) echo -mv=7r4 ;;
  1699. armv7-m|cortex-m*) echo -mv=7m3 ;;
  1700. armv6*|arm11*) echo -mv=6 ;;
  1701. armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
  1702. echo -mv=5e ;;
  1703. armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
  1704. esac
  1705. ;;
  1706. -mfpu=neon) echo --float_support=vfpv3 --neon ;;
  1707. -mfpu=vfp) echo --float_support=vfpv2 ;;
  1708. -mfpu=vfpv3) echo --float_support=vfpv3 ;;
  1709. -msoft-float) echo --float_support=vfplib ;;
  1710. -O[0-3]|-mf=*) echo $flag ;;
  1711. -g) echo -g -mn ;;
  1712. -pds=*) echo $flag ;;
  1713. esac
  1714. done
  1715. }
  1716. elif $cc -v 2>&1 | grep -q clang; then
  1717. cc_type=clang
  1718. $cc -dM -E $TMPC | grep -q __clang_version__ &&
  1719. cc_version=__clang_version__ || cc_version=__VERSION__
  1720. cc_ident=$($cc --version | head -n1)
  1721. CC_DEPFLAGS='-MMD'
  1722. AS_DEPFLAGS='-MMD'
  1723. speed_cflags='-O3'
  1724. size_cflags='-Os'
  1725. elif $cc -V 2>&1 | grep -q Sun; then
  1726. cc_type=suncc
  1727. cc_version="AV_STRINGIFY(__SUNPRO_C)"
  1728. cc_ident=$($cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
  1729. DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
  1730. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
  1731. speed_cflags='-O5'
  1732. size_cflags='-O5 -xspace'
  1733. filter_cflags=suncc_flags
  1734. suncc_flags(){
  1735. for flag; do
  1736. case $flag in
  1737. -march=*|-mcpu=*)
  1738. case "${flag#*=}" in
  1739. native) echo -xtarget=native ;;
  1740. v9|niagara) echo -xarch=sparc ;;
  1741. ultrasparc) echo -xarch=sparcvis ;;
  1742. ultrasparc3|niagara2) echo -xarch=sparcvis2 ;;
  1743. i586|pentium) echo -xchip=pentium ;;
  1744. i686|pentiumpro|pentium2) echo -xtarget=pentium_pro ;;
  1745. pentium3*|c3-2) echo -xtarget=pentium3 ;;
  1746. pentium-m) echo -xarch=sse2 -xchip=pentium3 ;;
  1747. pentium4*) echo -xtarget=pentium4 ;;
  1748. prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;;
  1749. *-sse3) echo -xarch=sse3 ;;
  1750. core2) echo -xarch=ssse3 -xchip=core2 ;;
  1751. amdfam10|barcelona) echo -xarch=sse4_1 ;;
  1752. athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
  1753. k8|opteron|athlon64|athlon-fx)
  1754. echo -xarch=sse2a ;;
  1755. athlon*) echo -xarch=pentium_proa ;;
  1756. esac
  1757. ;;
  1758. -std=c99) echo -xc99 ;;
  1759. -fomit-frame-pointer) echo -xregs=frameptr ;;
  1760. -fPIC) echo -KPIC -xcode=pic32 ;;
  1761. -W*,*) echo $flag ;;
  1762. -f*-*|-W*) ;;
  1763. *) echo $flag ;;
  1764. esac
  1765. done
  1766. }
  1767. elif $cc -v 2>&1 | grep -q PathScale; then
  1768. cc_type=pathscale
  1769. cc_version=__PATHSCALE__
  1770. cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
  1771. CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1772. AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1773. speed_cflags='-O2'
  1774. size_cflags='-Os'
  1775. fi
  1776. test -n "$cc_type" && enable $cc_type ||
  1777. warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
  1778. : ${as_default:=$cc}
  1779. : ${dep_cc_default:=$cc}
  1780. : ${ld_default:=$cc}
  1781. set_default ar as dep_cc ld
  1782. test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
  1783. test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
  1784. add_cflags $extra_cflags
  1785. add_asflags $extra_cflags
  1786. if test -n "$sysroot"; then
  1787. case "$cc_type" in
  1788. gcc)
  1789. add_cppflags --sysroot="$sysroot"
  1790. add_ldflags --sysroot="$sysroot"
  1791. ;;
  1792. tms470)
  1793. add_cppflags -I"$sysinclude"
  1794. add_ldflags --sysroot="$sysroot"
  1795. ;;
  1796. clang)
  1797. add_cppflags -isysroot "$sysroot"
  1798. add_ldflags -isysroot "$sysroot"
  1799. ;;
  1800. esac
  1801. fi
  1802. if test "$cpu" = host; then
  1803. enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
  1804. case "$cc_type" in
  1805. gcc)
  1806. check_native(){
  1807. $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
  1808. sed -n "/$1=/{
  1809. s/.*$1=\\([^ ]*\\).*/\\1/
  1810. p
  1811. q
  1812. }" $TMPE
  1813. }
  1814. cpu=$(check_native -march || check_native -mcpu)
  1815. ;;
  1816. esac
  1817. test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
  1818. fi
  1819. # Deal with common $arch aliases
  1820. case "$arch" in
  1821. arm*)
  1822. arch="arm"
  1823. ;;
  1824. mips|mipsel|IP*)
  1825. arch="mips"
  1826. ;;
  1827. mips64*)
  1828. arch="mips"
  1829. subarch="mips64"
  1830. ;;
  1831. parisc|hppa)
  1832. arch="parisc"
  1833. ;;
  1834. parisc64|hppa64)
  1835. arch="parisc"
  1836. subarch="parisc64"
  1837. ;;
  1838. "Power Macintosh"|ppc|powerpc)
  1839. arch="ppc"
  1840. ;;
  1841. ppc64|powerpc64)
  1842. arch="ppc"
  1843. subarch="ppc64"
  1844. ;;
  1845. s390|s390x)
  1846. arch="s390"
  1847. ;;
  1848. sh4|sh)
  1849. arch="sh4"
  1850. ;;
  1851. sun4u|sparc64)
  1852. arch="sparc"
  1853. subarch="sparc64"
  1854. ;;
  1855. i[3-6]86|i86pc|BePC|x86_64|amd64)
  1856. arch="x86"
  1857. ;;
  1858. esac
  1859. is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
  1860. enable $arch
  1861. # Add processor-specific flags
  1862. if test "$cpu" = generic; then
  1863. : do nothing
  1864. elif enabled ppc; then
  1865. case $(tolower $cpu) in
  1866. 601|ppc601|powerpc601)
  1867. cpuflags="-mcpu=601"
  1868. disable altivec
  1869. ;;
  1870. 603*|ppc603*|powerpc603*)
  1871. cpuflags="-mcpu=603"
  1872. disable altivec
  1873. ;;
  1874. 604*|ppc604*|powerpc604*)
  1875. cpuflags="-mcpu=604"
  1876. disable altivec
  1877. ;;
  1878. g3|75*|ppc75*|powerpc75*)
  1879. cpuflags="-mcpu=750 -mpowerpc-gfxopt"
  1880. disable altivec
  1881. ;;
  1882. g4|745*|ppc745*|powerpc745*)
  1883. cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
  1884. ;;
  1885. 74*|ppc74*|powerpc74*)
  1886. cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
  1887. ;;
  1888. g5|970|ppc970|powerpc970|power4*)
  1889. cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1890. ;;
  1891. cell)
  1892. cpuflags="-mcpu=cell"
  1893. enable ldbrx
  1894. ;;
  1895. e500v2)
  1896. cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
  1897. disable altivec
  1898. ;;
  1899. e500)
  1900. cpuflags="-mcpu=8540 -mhard-float"
  1901. disable altivec
  1902. ;;
  1903. esac
  1904. elif enabled x86; then
  1905. case $cpu in
  1906. i[345]86|pentium)
  1907. cpuflags="-march=$cpu"
  1908. disable mmx
  1909. ;;
  1910. # targets that do NOT support conditional mov (cmov)
  1911. pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1912. cpuflags="-march=$cpu"
  1913. disable cmov
  1914. ;;
  1915. # targets that do support conditional mov (cmov)
  1916. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2|amdfam10|barcelona)
  1917. cpuflags="-march=$cpu"
  1918. enable cmov
  1919. enable fast_cmov
  1920. ;;
  1921. # targets that do support conditional mov but on which it's slow
  1922. pentium4|pentium4m|prescott|nocona)
  1923. cpuflags="-march=$cpu"
  1924. enable cmov
  1925. disable fast_cmov
  1926. ;;
  1927. esac
  1928. elif enabled sparc; then
  1929. case $cpu in
  1930. niagara)
  1931. cpuflags="-mcpu=$cpu"
  1932. disable vis
  1933. ;;
  1934. sparc64)
  1935. cpuflags="-mcpu=v9"
  1936. ;;
  1937. esac
  1938. elif enabled arm; then
  1939. case $cpu in
  1940. armv*)
  1941. cpuflags="-march=$cpu"
  1942. subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
  1943. ;;
  1944. *)
  1945. cpuflags="-mcpu=$cpu"
  1946. case $cpu in
  1947. cortex-a*) subarch=armv7a ;;
  1948. cortex-r*) subarch=armv7r ;;
  1949. cortex-m*) subarch=armv7m ;;
  1950. arm11*) subarch=armv6 ;;
  1951. arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
  1952. armv4*|arm7*|arm9[24]*) subarch=armv4 ;;
  1953. esac
  1954. ;;
  1955. esac
  1956. elif enabled alpha; then
  1957. enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
  1958. elif enabled bfin; then
  1959. cpuflags="-mcpu=$cpu"
  1960. elif enabled mips; then
  1961. cpuflags="-march=$cpu"
  1962. elif enabled avr32; then
  1963. case $cpu in
  1964. ap7[02]0[0-2])
  1965. subarch="avr32_ap"
  1966. cpuflags="-mpart=$cpu"
  1967. ;;
  1968. ap)
  1969. subarch="avr32_ap"
  1970. cpuflags="-march=$cpu"
  1971. ;;
  1972. uc3[ab]*)
  1973. subarch="avr32_uc"
  1974. cpuflags="-mcpu=$cpu"
  1975. ;;
  1976. uc)
  1977. subarch="avr32_uc"
  1978. cpuflags="-march=$cpu"
  1979. ;;
  1980. esac
  1981. fi
  1982. add_cflags $cpuflags
  1983. add_asflags $cpuflags
  1984. # compiler sanity check
  1985. check_exec <<EOF
  1986. int main(void){ return 0; }
  1987. EOF
  1988. if test "$?" != 0; then
  1989. echo "$cc is unable to create an executable file."
  1990. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1991. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  1992. echo "Only do this if you know what cross compiling means."
  1993. fi
  1994. die "C compiler test failed."
  1995. fi
  1996. add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
  1997. check_cflags -std=c99
  1998. check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
  1999. #include <stdlib.h>
  2000. EOF
  2001. check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
  2002. #include <stdlib.h>
  2003. EOF
  2004. check_host_cflags -std=c99
  2005. case "$arch" in
  2006. alpha|ia64|mips|parisc|sparc)
  2007. spic=$shared
  2008. ;;
  2009. x86)
  2010. subarch="x86_32"
  2011. check_cc <<EOF && subarch="x86_64"
  2012. int test[(int)sizeof(char*) - 7];
  2013. EOF
  2014. if test "$subarch" = "x86_64"; then
  2015. spic=$shared
  2016. fi
  2017. ;;
  2018. esac
  2019. enable $subarch
  2020. enabled spic && enable pic
  2021. # OS specific
  2022. case $target_os in
  2023. haiku)
  2024. prefix_default="/boot/common"
  2025. network_extralibs="-lnetwork"
  2026. ;;
  2027. sunos)
  2028. FFSERVERLDFLAGS=""
  2029. SHFLAGS='-shared -Wl,-h,$$(@F)'
  2030. enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
  2031. network_extralibs="-lsocket -lnsl"
  2032. add_cppflags -D__EXTENSIONS__
  2033. nm_opts='-P -g'
  2034. ;;
  2035. netbsd)
  2036. oss_indev_extralibs="-lossaudio"
  2037. oss_outdev_extralibs="-lossaudio"
  2038. add_cppflags -D_XOPEN_SOURCE=600
  2039. ;;
  2040. openbsd)
  2041. enable malloc_aligned
  2042. # On OpenBSD 4.5. the compiler does not use PIC unless
  2043. # explicitly using -fPIC. FFmpeg builds fine without PIC,
  2044. # however the generated executable will not do anything
  2045. # (simply quits with exit-code 1, no crash, no output).
  2046. # Thus explicitly enable PIC here.
  2047. enable pic
  2048. SHFLAGS='-shared'
  2049. oss_indev_extralibs="-lossaudio"
  2050. oss_outdev_extralibs="-lossaudio"
  2051. ;;
  2052. freebsd|dragonfly)
  2053. enable malloc_aligned
  2054. ;;
  2055. bsd/os)
  2056. add_extralibs -lpoll -lgnugetopt
  2057. strip="strip -d"
  2058. ;;
  2059. darwin)
  2060. enable malloc_aligned
  2061. gas="gas-preprocessor.pl $cc"
  2062. enabled ppc && add_asflags -force_cpusubtype_ALL
  2063. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
  2064. strip="${strip} -x"
  2065. add_ldflags -Wl,-dynamic,-search_paths_first
  2066. SLIBSUF=".dylib"
  2067. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  2068. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  2069. FFSERVERLDFLAGS=-Wl,-bind_at_load
  2070. objformat="macho"
  2071. enabled x86_64 && objformat="macho64"
  2072. enabled_any pic shared ||
  2073. { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
  2074. ;;
  2075. mingw32*)
  2076. if test $target_os = "mingw32ce"; then
  2077. disable network
  2078. else
  2079. target_os=mingw32
  2080. fi
  2081. LIBTARGET=i386
  2082. if enabled x86_64; then
  2083. enable malloc_aligned
  2084. LIBTARGET=x64
  2085. elif enabled arm; then
  2086. LIBTARGET=arm
  2087. fi
  2088. shlibdir_default="$bindir_default"
  2089. disable ffserver
  2090. SLIBPREF=""
  2091. SLIBSUF=".dll"
  2092. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2093. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2094. SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
  2095. SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
  2096. install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"; \
  2097. install -d "$(LIBDIR)"; \
  2098. install -m 644 $(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) "$(LIBDIR)/lib$(SLIBNAME:$(SLIBSUF)=.dll.a)"'
  2099. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  2100. 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'
  2101. objformat="win32"
  2102. enable dos_paths
  2103. check_cflags -fno-common
  2104. check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \
  2105. || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
  2106. die "ERROR: MinGW runtime version must be >= 3.15."
  2107. ;;
  2108. cygwin*)
  2109. target_os=cygwin
  2110. shlibdir_default="$bindir_default"
  2111. SLIBPREF="cyg"
  2112. SLIBSUF=".dll"
  2113. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2114. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2115. SHFLAGS='-shared -Wl,--enable-auto-image-base'
  2116. objformat="win32"
  2117. enable dos_paths
  2118. check_cflags -fno-common
  2119. ;;
  2120. *-dos|freedos|opendos)
  2121. disable ffplay ffserver
  2122. disable $INDEV_LIST $OUTDEV_LIST
  2123. network_extralibs="-lsocket"
  2124. objformat="coff"
  2125. enable dos_paths
  2126. ;;
  2127. linux)
  2128. enable dv1394
  2129. ;;
  2130. irix*)
  2131. target_os=irix
  2132. ranlib="echo ignoring ranlib"
  2133. ;;
  2134. os/2*)
  2135. strip="lxlite"
  2136. ln_s="cp -f"
  2137. add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
  2138. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  2139. FFSERVERLDFLAGS=""
  2140. LIBSUF="_s.a"
  2141. SLIBPREF=""
  2142. SLIBSUF=".dll"
  2143. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  2144. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  2145. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  2146. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  2147. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  2148. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  2149. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  2150. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  2151. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  2152. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  2153. SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
  2154. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
  2155. enable dos_paths
  2156. ;;
  2157. gnu/kfreebsd)
  2158. ;;
  2159. gnu)
  2160. ;;
  2161. none)
  2162. ;;
  2163. *)
  2164. die "Unknown OS '$target_os'."
  2165. ;;
  2166. esac
  2167. check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
  2168. set_default $PATHS_LIST
  2169. # we need to build at least one lib type
  2170. if ! enabled_any static shared; then
  2171. cat <<EOF
  2172. At least one library type must be built.
  2173. Specify --enable-static to build the static libraries or --enable-shared to
  2174. build the shared libraries as well. To only build the shared libraries specify
  2175. --disable-static in addition to --enable-shared.
  2176. EOF
  2177. exit 1;
  2178. fi
  2179. disabled static && LIBNAME=""
  2180. die_license_disabled() {
  2181. enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
  2182. }
  2183. die_license_disabled gpl libx264
  2184. die_license_disabled gpl libxavs
  2185. die_license_disabled gpl libxvid
  2186. die_license_disabled gpl postproc
  2187. die_license_disabled gpl x11grab
  2188. die_license_disabled nonfree libfaac
  2189. die_license_disabled version3 libopencore_amrnb
  2190. die_license_disabled version3 libopencore_amrwb
  2191. enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
  2192. check_deps $ARCH_EXT_LIST
  2193. disabled optimizations || check_cflags -fomit-frame-pointer
  2194. enable_pic() {
  2195. enable pic
  2196. add_cppflags -DPIC
  2197. add_cflags -fPIC
  2198. add_asflags -fPIC
  2199. }
  2200. enabled pic && enable_pic
  2201. check_cc <<EOF || die "Symbol mangling check failed."
  2202. int ff_extern;
  2203. EOF
  2204. sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
  2205. extern_prefix=${sym%%ff_extern*}
  2206. check_cc <<EOF && enable inline_asm
  2207. void foo(void) { __asm__ volatile ("" ::); }
  2208. EOF
  2209. _restrict=
  2210. for restrict_keyword in restrict __restrict__ __restrict; do
  2211. check_cc <<EOF && _restrict=$restrict_keyword && break
  2212. void foo(char * $restrict_keyword p);
  2213. EOF
  2214. done
  2215. check_cc <<EOF && enable attribute_packed
  2216. struct { int x; } __attribute__((packed)) x;
  2217. EOF
  2218. check_cc <<EOF && enable attribute_may_alias
  2219. union { int x; } __attribute__((may_alias)) x;
  2220. EOF
  2221. check_cc <<EOF || die "endian test failed"
  2222. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  2223. EOF
  2224. od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  2225. if enabled alpha; then
  2226. check_cflags -mieee
  2227. elif enabled arm; then
  2228. check_cflags -marm
  2229. nogas=die
  2230. check_ld <<EOF && enable vfp_args
  2231. __asm__ (".eabi_attribute 28, 1");
  2232. int main(void) { return 0; }
  2233. EOF
  2234. # We have to check if pld is a nop and disable it.
  2235. check_asm pld '"pld [r0]"'
  2236. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  2237. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  2238. enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
  2239. enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
  2240. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  2241. enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
  2242. enabled_all armv6t2 shared !pic && enable_pic
  2243. elif enabled mips; then
  2244. check_asm loongson '"dmult.g $1, $2, $3"'
  2245. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  2246. elif enabled ppc; then
  2247. enable local_aligned_8 local_aligned_16
  2248. check_asm dcbzl '"dcbzl 0, %0" :: "r"(0)'
  2249. check_asm ibm_asm '"add 0, 0, 0"'
  2250. check_asm ppc4xx '"maclhw r10, r11, r12"'
  2251. check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
  2252. # AltiVec flags: The FSF version of GCC differs from the Apple version
  2253. if enabled altivec; then
  2254. nogas=warn
  2255. check_cflags -maltivec -mabi=altivec &&
  2256. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  2257. check_cflags -faltivec
  2258. # check if our compiler supports Motorola AltiVec C API
  2259. check_cc <<EOF || disable altivec
  2260. $inc_altivec_h
  2261. int main(void) {
  2262. vector signed int v1, v2, v3;
  2263. v1 = vec_add(v2,v3);
  2264. return 0;
  2265. }
  2266. EOF
  2267. # check if our compiler supports braces for vector declarations
  2268. check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
  2269. $inc_altivec_h
  2270. int main (void) { (vector int) {1}; return 0; }
  2271. EOF
  2272. fi
  2273. elif enabled sparc; then
  2274. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
  2275. add_cflags -mcpu=ultrasparc -mtune=ultrasparc
  2276. elif enabled x86; then
  2277. enable local_aligned_8 local_aligned_16
  2278. # check whether EBP is available on x86
  2279. # As 'i' is stored on the stack, this program will crash
  2280. # if the base pointer is used to access it because the
  2281. # base pointer is cleared in the inline assembly code.
  2282. check_exec_crash <<EOF && enable ebp_available
  2283. volatile int i=0;
  2284. __asm__ volatile (
  2285. "xorl %%ebp, %%ebp"
  2286. ::: "%ebp");
  2287. return i;
  2288. EOF
  2289. # check whether EBX is available on x86
  2290. check_asm ebx_available '""::"b"(0)' &&
  2291. check_asm ebx_available '"":::"%ebx"'
  2292. # check whether more than 10 operands are supported
  2293. check_cc <<EOF && enable ten_operands
  2294. int main(void) {
  2295. int x=0;
  2296. __asm__ volatile(
  2297. ""
  2298. :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
  2299. );
  2300. return 0;
  2301. }
  2302. EOF
  2303. # check whether binutils is new enough to compile SSSE3/MMX2
  2304. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  2305. enabled mmx2 && check_asm mmx2 '"pmaxub %mm0, %mm1"'
  2306. check_asm bswap '"bswap %%eax" ::: "%eax"'
  2307. YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
  2308. enabled x86_64 && append YASMFLAGS "-m amd64"
  2309. enabled pic && append YASMFLAGS "-DPIC"
  2310. test -n "$extern_prefix" && append YASMFLAGS "-DPREFIX"
  2311. case "$objformat" in
  2312. elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
  2313. esac
  2314. if ! disabled yasm; then
  2315. check_yasm "pabsw xmm0, xmm0" && enable yasm ||
  2316. warn "yasm not found, performance will suffer"
  2317. fi
  2318. case "$cpu" in
  2319. athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
  2320. disable fast_clz
  2321. ;;
  2322. esac
  2323. fi
  2324. if enabled asm; then
  2325. as=${gas:=$as}
  2326. check_asm gnu_as '".macro m n\n\\n:.int 0\n.endm\nm x"' ||
  2327. $nogas "GNU assembler not found, install gas-preprocessor"
  2328. fi
  2329. if check_func dlopen; then
  2330. ldl=
  2331. elif check_func dlopen -ldl; then
  2332. ldl=-ldl
  2333. fi
  2334. # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
  2335. check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
  2336. check_func fcntl
  2337. check_func fork
  2338. check_func getaddrinfo $network_extralibs
  2339. check_func gethrtime
  2340. check_func getrusage
  2341. check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
  2342. check_func inet_aton $network_extralibs
  2343. check_func isatty
  2344. check_func ${malloc_prefix}memalign && enable memalign
  2345. check_func mkstemp
  2346. check_func ${malloc_prefix}posix_memalign && enable posix_memalign
  2347. check_func setrlimit
  2348. check_func strerror_r
  2349. check_func_headers io.h setmode
  2350. check_func_headers lzo/lzo1x.h lzo1x_999_compress
  2351. check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
  2352. check_func_headers windows.h GetProcessTimes
  2353. check_func_headers windows.h VirtualAlloc
  2354. check_header conio.h
  2355. check_header dlfcn.h
  2356. check_header dxva2api.h
  2357. check_header malloc.h
  2358. check_header poll.h
  2359. check_header sys/mman.h
  2360. check_header sys/resource.h
  2361. check_header sys/select.h
  2362. check_header termios.h
  2363. check_header vdpau/vdpau.h
  2364. check_header vdpau/vdpau_x11.h
  2365. check_header X11/extensions/XvMClib.h
  2366. check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex
  2367. if ! enabled_any memalign memalign_hack posix_memalign malloc_aligned &&
  2368. enabled_any $need_memalign ; then
  2369. die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
  2370. fi
  2371. disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
  2372. disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  2373. # check for some common methods of building with pthread support
  2374. # do this before the optional library checks as some of them require pthreads
  2375. if ! disabled pthreads && ! enabled w32threads; then
  2376. enable pthreads
  2377. if check_func pthread_create; then
  2378. :
  2379. elif check_func pthread_create -pthread; then
  2380. add_cflags -pthread
  2381. add_extralibs -pthread
  2382. elif check_func pthread_create -pthreads; then
  2383. add_cflags -pthreads
  2384. add_extralibs -pthreads
  2385. elif check_func pthread_create -lpthreadGC2; then
  2386. add_extralibs -lpthreadGC2
  2387. elif ! check_lib pthread.h pthread_create -lpthread; then
  2388. disable pthreads
  2389. fi
  2390. fi
  2391. for thread in $THREADS_LIST; do
  2392. if enabled $thread; then
  2393. test -n "$thread_type" &&
  2394. die "ERROR: Only one thread type must be selected." ||
  2395. thread_type="$thread"
  2396. fi
  2397. done
  2398. check_lib math.h sin -lm
  2399. disabled vaapi || check_lib va/va.h vaInitialize -lva
  2400. check_mathfunc exp2
  2401. check_mathfunc exp2f
  2402. check_mathfunc llrint
  2403. check_mathfunc llrintf
  2404. check_mathfunc log2
  2405. check_mathfunc log2f
  2406. check_mathfunc lrint
  2407. check_mathfunc lrintf
  2408. check_mathfunc round
  2409. check_mathfunc roundf
  2410. check_mathfunc truncf
  2411. # these are off by default, so fail if requested and not available
  2412. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
  2413. enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
  2414. require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
  2415. require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
  2416. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  2417. enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
  2418. enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame
  2419. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  2420. enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
  2421. enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
  2422. enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
  2423. enabled librtmp && { check_lib librtmp/rtmp.h RTMP_Socket $(pkg-config --libs librtmp) ||
  2424. die "ERROR: librtmp not found or RTMP_Socket() missing, librtmp version must be >= 2.2.f"; }
  2425. enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
  2426. require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
  2427. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  2428. enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
  2429. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  2430. enabled libvpx && {
  2431. enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
  2432. die "ERROR: libvpx decoder version must be >=0.9.1"; }
  2433. enabled libvpx_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_enc_init_ver -lvpx ||
  2434. die "ERROR: libvpx encoder version must be >=0.9.1"; } }
  2435. enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
  2436. { check_cpp_condition x264.h "X264_BUILD >= 98" ||
  2437. die "ERROR: libx264 version must be >= 0.98."; }
  2438. enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs
  2439. enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
  2440. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  2441. # libdc1394 check
  2442. if enabled libdc1394; then
  2443. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  2444. enable libdc1394_2; } ||
  2445. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  2446. enable libdc1394_1; } ||
  2447. die "ERROR: No version of libdc1394 found "
  2448. fi
  2449. SDL_CONFIG="${cross_prefix}sdl-config"
  2450. if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
  2451. sdl_cflags=$("${SDL_CONFIG}" --cflags)
  2452. sdl_libs=$("${SDL_CONFIG}" --libs)
  2453. check_func_headers SDL.h SDL_Init $sdl_cflags $sdl_libs &&
  2454. check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
  2455. enable sdl &&
  2456. check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
  2457. fi
  2458. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  2459. if enabled network; then
  2460. check_type "sys/types.h sys/socket.h" socklen_t
  2461. check_type netdb.h "struct addrinfo"
  2462. check_type netinet/in.h "struct ipv6_mreq"
  2463. check_type netinet/in.h "struct sockaddr_in6"
  2464. check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
  2465. check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
  2466. # Prefer arpa/inet.h over winsock2
  2467. if check_header arpa/inet.h ; then
  2468. check_func closesocket
  2469. elif check_header winsock2.h ; then
  2470. check_func_headers winsock2.h closesocket -lws2 && \
  2471. network_extralibs="-lws2" || \
  2472. { check_func_headers winsock2.h closesocket -lws2_32 && \
  2473. network_extralibs="-lws2_32"; }
  2474. check_type ws2tcpip.h socklen_t
  2475. check_type ws2tcpip.h "struct addrinfo"
  2476. check_type ws2tcpip.h "struct ipv6_mreq"
  2477. check_type ws2tcpip.h "struct sockaddr_in6"
  2478. check_type ws2tcpip.h "struct sockaddr_storage"
  2479. check_struct winsock2.h "struct sockaddr" sa_len
  2480. else
  2481. disable network
  2482. fi
  2483. fi
  2484. check_header linux/videodev.h
  2485. check_header linux/videodev2.h
  2486. check_header sys/videoio.h
  2487. check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
  2488. # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
  2489. # w32api 3.12 had it defined wrong
  2490. check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
  2491. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  2492. { check_header dev/bktr/ioctl_meteor.h &&
  2493. check_header dev/bktr/ioctl_bt848.h; } ||
  2494. { check_header machine/ioctl_meteor.h &&
  2495. check_header machine/ioctl_bt848.h; } ||
  2496. { check_header dev/video/meteor/ioctl_meteor.h &&
  2497. check_header dev/video/bktr/ioctl_bt848.h; } ||
  2498. check_header dev/ic/bt8xx.h
  2499. check_header sys/soundcard.h
  2500. check_header soundcard.h
  2501. enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
  2502. enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
  2503. enabled x11grab &&
  2504. check_header X11/Xlib.h &&
  2505. check_header X11/extensions/XShm.h &&
  2506. check_header X11/extensions/Xfixes.h &&
  2507. check_func XOpenDisplay -lX11 &&
  2508. check_func XShmCreateImage -lX11 -lXext &&
  2509. check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
  2510. if ! disabled vdpau && enabled vdpau_vdpau_h; then
  2511. check_cpp_condition \
  2512. vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
  2513. { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
  2514. disable vdpau; }
  2515. fi
  2516. enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
  2517. # add some useful compiler flags if supported
  2518. check_cflags -Wdeclaration-after-statement
  2519. check_cflags -Wall
  2520. check_cflags -Wno-parentheses
  2521. check_cflags -Wno-switch
  2522. check_cflags -Wdisabled-optimization
  2523. check_cflags -Wpointer-arith
  2524. check_cflags -Wredundant-decls
  2525. check_cflags -Wno-pointer-sign
  2526. check_cflags -Wcast-qual
  2527. check_cflags -Wwrite-strings
  2528. check_cflags -Wtype-limits
  2529. check_cflags -Wundef
  2530. check_cflags -Wmissing-prototypes
  2531. enabled extra_warnings && check_cflags -Winline
  2532. # add some linker flags
  2533. check_ldflags -Wl,--warn-common
  2534. check_ldflags -Wl,--as-needed
  2535. 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'
  2536. check_ldflags -Wl,-Bsymbolic
  2537. echo "X{};" > $TMPV
  2538. if test_ldflags -Wl,--version-script,$TMPV; then
  2539. append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
  2540. check_cc <<EOF && enable symver_asm_label
  2541. void ff_foo(void) __asm__ ("av_foo@VERSION");
  2542. void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
  2543. EOF
  2544. check_cc <<EOF && enable symver_gnu_asm
  2545. __asm__(".symver ff_foo,av_foo@VERSION");
  2546. void ff_foo(void) {}
  2547. EOF
  2548. fi
  2549. if enabled small; then
  2550. add_cflags $size_cflags
  2551. optimizations="small"
  2552. elif enabled optimizations; then
  2553. add_cflags $speed_cflags
  2554. else
  2555. add_cflags $noopt_cflags
  2556. fi
  2557. check_cflags -fno-math-errno
  2558. check_cflags -fno-signed-zeros
  2559. if enabled icc; then
  2560. # Just warnings, no remarks
  2561. check_cflags -w1
  2562. # -wd: Disable following warnings
  2563. # 144, 167, 556: -Wno-pointer-sign
  2564. # 10006: ignoring unknown option -fno-signed-zeros
  2565. # 10156: ignoring option '-W'; no argument required
  2566. check_cflags -wd144,167,556,10006,10156
  2567. # 11030: Warning unknown option --as-needed
  2568. # 10156: ignoring option '-export'; no argument required
  2569. check_ldflags -wd10156,11030
  2570. # Allow to compile with optimizations
  2571. check_ldflags -march=$cpu
  2572. # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
  2573. enable ebp_available
  2574. elif enabled ccc; then
  2575. # disable some annoying warnings
  2576. add_cflags -msg_disable cvtu32to64
  2577. add_cflags -msg_disable embedcomment
  2578. add_cflags -msg_disable needconstext
  2579. add_cflags -msg_disable nomainieee
  2580. add_cflags -msg_disable ptrmismatch1
  2581. add_cflags -msg_disable unreachcode
  2582. elif enabled gcc; then
  2583. check_cflags -fno-tree-vectorize
  2584. check_cflags -Werror=implicit-function-declaration
  2585. check_cflags -Werror=missing-prototypes
  2586. elif enabled clang; then
  2587. check_cflags -Qunused-arguments
  2588. elif enabled armcc; then
  2589. # 2523: use of inline assembler is deprecated
  2590. add_cflags -Wrvct,--diag_suppress=2523
  2591. add_cflags -Wrvct,--diag_suppress=1207
  2592. elif enabled tms470; then
  2593. add_cflags -pds=824 -pds=837
  2594. fi
  2595. enabled_any $THREADS_LIST && enable threads
  2596. check_deps $CONFIG_LIST \
  2597. $CONFIG_EXTRA \
  2598. $HAVE_LIST \
  2599. $DECODER_LIST \
  2600. $ENCODER_LIST \
  2601. $HWACCEL_LIST \
  2602. $PARSER_LIST \
  2603. $BSF_LIST \
  2604. $DEMUXER_LIST \
  2605. $MUXER_LIST \
  2606. $FILTER_LIST \
  2607. $INDEV_LIST \
  2608. $OUTDEV_LIST \
  2609. $PROTOCOL_LIST \
  2610. $ACODEC_TESTS \
  2611. $VCODEC_TESTS \
  2612. $LAVF_TESTS \
  2613. $LAVFI_TESTS \
  2614. $SEEK_TESTS \
  2615. enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
  2616. echo "install prefix $prefix"
  2617. echo "source path $source_path"
  2618. echo "C compiler $cc"
  2619. echo "ARCH $arch ($cpu)"
  2620. if test "$build_suffix" != ""; then
  2621. echo "build suffix $build_suffix"
  2622. fi
  2623. if test "$extra_version" != ""; then
  2624. echo "version string suffix $extra_version"
  2625. fi
  2626. echo "big-endian ${bigendian-no}"
  2627. echo "runtime cpu detection ${runtime_cpudetect-no}"
  2628. if enabled x86; then
  2629. echo "yasm ${yasm-no}"
  2630. echo "MMX enabled ${mmx-no}"
  2631. echo "MMX2 enabled ${mmx2-no}"
  2632. echo "3DNow! enabled ${amd3dnow-no}"
  2633. echo "3DNow! extended enabled ${amd3dnowext-no}"
  2634. echo "SSE enabled ${sse-no}"
  2635. echo "SSSE3 enabled ${ssse3-no}"
  2636. echo "CMOV enabled ${cmov-no}"
  2637. echo "CMOV is fast ${fast_cmov-no}"
  2638. echo "EBX available ${ebx_available-no}"
  2639. echo "EBP available ${ebp_available-no}"
  2640. echo "10 operands supported ${ten_operands-no}"
  2641. fi
  2642. if enabled arm; then
  2643. echo "ARMv5TE enabled ${armv5te-no}"
  2644. echo "ARMv6 enabled ${armv6-no}"
  2645. echo "ARMv6T2 enabled ${armv6t2-no}"
  2646. echo "ARM VFP enabled ${armvfp-no}"
  2647. echo "IWMMXT enabled ${iwmmxt-no}"
  2648. echo "NEON enabled ${neon-no}"
  2649. fi
  2650. if enabled mips; then
  2651. echo "MMI enabled ${mmi-no}"
  2652. fi
  2653. if enabled ppc; then
  2654. echo "AltiVec enabled ${altivec-no}"
  2655. echo "PPC 4xx optimizations ${ppc4xx-no}"
  2656. echo "dcbzl available ${dcbzl-no}"
  2657. fi
  2658. if enabled sparc; then
  2659. echo "VIS enabled ${vis-no}"
  2660. fi
  2661. echo "debug symbols ${debug-no}"
  2662. echo "strip symbols ${stripping-no}"
  2663. echo "optimizations ${optimizations-no}"
  2664. echo "static ${static-no}"
  2665. echo "shared ${shared-no}"
  2666. echo "postprocessing support ${postproc-no}"
  2667. echo "new filter support ${avfilter-no}"
  2668. echo "network support ${network-no}"
  2669. echo "threading support ${thread_type-no}"
  2670. echo "SDL support ${sdl-no}"
  2671. echo "Sun medialib support ${mlib-no}"
  2672. echo "AVISynth enabled ${avisynth-no}"
  2673. echo "libdc1394 support ${libdc1394-no}"
  2674. echo "libdirac enabled ${libdirac-no}"
  2675. echo "libfaac enabled ${libfaac-no}"
  2676. echo "libgsm enabled ${libgsm-no}"
  2677. echo "libmp3lame enabled ${libmp3lame-no}"
  2678. echo "libnut enabled ${libnut-no}"
  2679. echo "libopencore-amrnb support ${libopencore_amrnb-no}"
  2680. echo "libopencore-amrwb support ${libopencore_amrwb-no}"
  2681. echo "libopenjpeg enabled ${libopenjpeg-no}"
  2682. echo "librtmp enabled ${librtmp-no}"
  2683. echo "libschroedinger enabled ${libschroedinger-no}"
  2684. echo "libspeex enabled ${libspeex-no}"
  2685. echo "libtheora enabled ${libtheora-no}"
  2686. echo "libvorbis enabled ${libvorbis-no}"
  2687. echo "libvpx enabled ${libvpx-no}"
  2688. echo "libx264 enabled ${libx264-no}"
  2689. echo "libxavs enabled ${libxavs-no}"
  2690. echo "libxvid enabled ${libxvid-no}"
  2691. echo "zlib enabled ${zlib-no}"
  2692. echo "bzlib enabled ${bzlib-no}"
  2693. echo
  2694. for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
  2695. echo "Enabled ${type}s:"
  2696. eval list=\$$(toupper $type)_LIST
  2697. print_enabled '_*' $list | sort | pr -3 -t
  2698. echo
  2699. done
  2700. license="LGPL version 2.1 or later"
  2701. if enabled nonfree; then
  2702. license="nonfree and unredistributable"
  2703. elif enabled gplv3; then
  2704. license="GPL version 3 or later"
  2705. elif enabled lgplv3; then
  2706. license="LGPL version 3 or later"
  2707. elif enabled gpl; then
  2708. license="GPL version 2 or later"
  2709. fi
  2710. echo "License: $license"
  2711. echo "Creating config.mak and config.h..."
  2712. # build tree in object directory if source path is different from current one
  2713. if enabled source_path_used; then
  2714. DIRS="
  2715. doc
  2716. libavcodec
  2717. libavcodec/$arch
  2718. libavcore
  2719. libavdevice
  2720. libavfilter
  2721. libavformat
  2722. libavutil
  2723. libavutil/$arch
  2724. libpostproc
  2725. libswscale
  2726. libswscale/$arch
  2727. tests
  2728. tools
  2729. "
  2730. FILES="
  2731. Makefile
  2732. common.mak
  2733. subdir.mak
  2734. doc/texi2pod.pl
  2735. libavcodec/Makefile
  2736. libavcodec/${arch}/Makefile
  2737. libavcore/Makefile
  2738. libavdevice/Makefile
  2739. libavfilter/Makefile
  2740. libavformat/Makefile
  2741. libavutil/Makefile
  2742. libpostproc/Makefile
  2743. libswscale/Makefile
  2744. "
  2745. map 'mkdir -p $v' $DIRS;
  2746. map 'test -f "$source_path/$v" && $ln_s "$source_path/$v" $v' $FILES
  2747. fi
  2748. enabled stripping || strip="echo skipping strip"
  2749. cat > config.mak <<EOF
  2750. # Automatically generated by configure - do not modify!
  2751. ifndef FFMPEG_CONFIG_MAK
  2752. FFMPEG_CONFIG_MAK=1
  2753. FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION
  2754. prefix=$prefix
  2755. LIBDIR=\$(DESTDIR)$libdir
  2756. SHLIBDIR=\$(DESTDIR)$shlibdir
  2757. INCDIR=\$(DESTDIR)$incdir
  2758. BINDIR=\$(DESTDIR)$bindir
  2759. DATADIR=\$(DESTDIR)$datadir
  2760. MANDIR=\$(DESTDIR)$mandir
  2761. SRC_PATH="$source_path"
  2762. SRC_PATH_BARE=$source_path
  2763. BUILD_ROOT="$PWD"
  2764. CC_IDENT=$cc_ident
  2765. ARCH=$arch
  2766. CC=$cc
  2767. AS=$as
  2768. LD=$ld
  2769. DEPCC=$dep_cc
  2770. YASM=$yasmexe
  2771. YASMDEP=$yasmexe
  2772. AR=$ar
  2773. RANLIB=$ranlib
  2774. CP=cp -p
  2775. LN_S=$ln_s
  2776. STRIP=$strip
  2777. CPPFLAGS=$CPPFLAGS
  2778. CFLAGS=$CFLAGS
  2779. ASFLAGS=$ASFLAGS
  2780. CC_O=$CC_O
  2781. LDFLAGS=$LDFLAGS
  2782. FFSERVERLDFLAGS=$FFSERVERLDFLAGS
  2783. SHFLAGS=$SHFLAGS
  2784. YASMFLAGS=$YASMFLAGS
  2785. BUILDSUF=$build_suffix
  2786. FULLNAME=$FULLNAME
  2787. LIBPREF=$LIBPREF
  2788. LIBSUF=$LIBSUF
  2789. LIBNAME=$LIBNAME
  2790. SLIBPREF=$SLIBPREF
  2791. SLIBSUF=$SLIBSUF
  2792. EXESUF=$EXESUF
  2793. EXTRA_VERSION=$extra_version
  2794. DEPFLAGS=$DEPFLAGS
  2795. CCDEP=$CCDEP
  2796. ASDEP=$ASDEP
  2797. CC_DEPFLAGS=$CC_DEPFLAGS
  2798. AS_DEPFLAGS=$AS_DEPFLAGS
  2799. HOSTCC=$host_cc
  2800. HOSTCFLAGS=$host_cflags
  2801. HOSTEXESUF=$HOSTEXESUF
  2802. HOSTLDFLAGS=$host_ldflags
  2803. HOSTLIBS=$host_libs
  2804. TARGET_EXEC=$target_exec
  2805. TARGET_PATH=$target_path
  2806. SDL_LIBS=$sdl_libs
  2807. SDL_CFLAGS=$sdl_cflags
  2808. LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
  2809. EXTRALIBS=$extralibs
  2810. INSTALL=install
  2811. LIBTARGET=${LIBTARGET}
  2812. SLIBNAME=${SLIBNAME}
  2813. SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
  2814. SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
  2815. SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
  2816. SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
  2817. SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}
  2818. SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}
  2819. SAMPLES=$samples
  2820. EOF
  2821. get_version(){
  2822. name=$1
  2823. file=$source_path/$2
  2824. eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
  2825. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  2826. lcname=$(tolower $name)
  2827. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  2828. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  2829. }
  2830. get_version LIBSWSCALE libswscale/swscale.h
  2831. get_version LIBPOSTPROC libpostproc/postprocess.h
  2832. get_version LIBAVCODEC libavcodec/avcodec.h
  2833. get_version LIBAVCORE libavcore/avcore.h
  2834. get_version LIBAVDEVICE libavdevice/avdevice.h
  2835. get_version LIBAVFORMAT libavformat/avformat.h
  2836. get_version LIBAVUTIL libavutil/avutil.h
  2837. get_version LIBAVFILTER libavfilter/avfilter.h
  2838. cat > $TMPH <<EOF
  2839. /* Automatically generated by configure - do not modify! */
  2840. #ifndef FFMPEG_CONFIG_H
  2841. #define FFMPEG_CONFIG_H
  2842. #define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
  2843. #define FFMPEG_LICENSE "$(c_escape $license)"
  2844. #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
  2845. #define CC_TYPE "$cc_type"
  2846. #define CC_VERSION $cc_version
  2847. #define restrict $_restrict
  2848. #define ASMALIGN(ZEROBITS) ".p2align " #ZEROBITS "\\n\\t"
  2849. #define EXTERN_PREFIX "${extern_prefix}"
  2850. #define EXTERN_ASM ${extern_prefix}
  2851. EOF
  2852. test -n "$malloc_prefix" &&
  2853. echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
  2854. if enabled small || disabled optimizations; then
  2855. echo "#undef av_always_inline" >> $TMPH
  2856. echo "#define av_always_inline" >> $TMPH
  2857. fi
  2858. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  2859. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  2860. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  2861. $CONFIG_EXTRA \
  2862. $DECODER_LIST \
  2863. $ENCODER_LIST \
  2864. $HWACCEL_LIST \
  2865. $PARSER_LIST \
  2866. $BSF_LIST \
  2867. $DEMUXER_LIST \
  2868. $MUXER_LIST \
  2869. $FILTER_LIST \
  2870. $PROTOCOL_LIST \
  2871. $INDEV_LIST \
  2872. $OUTDEV_LIST \
  2873. cat >>config.mak <<EOF
  2874. ACODEC_TESTS=$(print_enabled -n _test $ACODEC_TESTS)
  2875. VCODEC_TESTS=$(print_enabled -n _test $VCODEC_TESTS)
  2876. LAVF_TESTS=$(print_enabled -n _test $LAVF_TESTS)
  2877. LAVFI_TESTS=$(print_enabled -n _test $LAVFI_TESTS)
  2878. SEEK_TESTS=$(print_enabled -n _test $SEEK_TESTS)
  2879. EOF
  2880. echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
  2881. echo "endif # FFMPEG_CONFIG_MAK" >> config.mak
  2882. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  2883. cp_if_changed $TMPH config.h
  2884. touch .config
  2885. cat > $TMPH <<EOF
  2886. /* Generated by ffconf */
  2887. #ifndef AVUTIL_AVCONFIG_H
  2888. #define AVUTIL_AVCONFIG_H
  2889. EOF
  2890. print_config AV_HAVE_ $TMPH /dev/null $HAVE_LIST_PUB
  2891. echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
  2892. cp_if_changed $TMPH libavutil/avconfig.h
  2893. echo "config:$arch:$subarch:$cpu:$target_os:$cc_ident:$FFMPEG_CONFIGURATION" >config.fate
  2894. test -n "$WARNINGS" && printf "\n$WARNINGS"
  2895. # build pkg-config files
  2896. pkgconfig_generate(){
  2897. name=$1
  2898. shortname=${name#lib}${build_suffix}
  2899. comment=$2
  2900. version=$3
  2901. libs=$4
  2902. requires=$5
  2903. enabled ${name#lib} || return 0
  2904. cat <<EOF > $name/$name.pc
  2905. prefix=$prefix
  2906. exec_prefix=\${prefix}
  2907. libdir=$libdir
  2908. includedir=$incdir
  2909. Name: $name
  2910. Description: $comment
  2911. Version: $version
  2912. Requires: $(enabled shared || echo $requires)
  2913. Requires.private: $(enabled shared && echo $requires)
  2914. Conflicts:
  2915. Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
  2916. Libs.private: $(enabled shared && echo $libs)
  2917. Cflags: -I\${includedir}
  2918. EOF
  2919. cat <<EOF > $name/$name-uninstalled.pc
  2920. prefix=
  2921. exec_prefix=
  2922. libdir=\${pcfiledir}
  2923. includedir=${source_path}
  2924. Name: $name
  2925. Description: $comment
  2926. Version: $version
  2927. Requires: $requires
  2928. Conflicts:
  2929. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  2930. Cflags: -I\${includedir}
  2931. EOF
  2932. }
  2933. pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
  2934. pkgconfig_generate libavcore "FFmpeg multimedia shared core utilities library" "$LIBAVCORE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
  2935. pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavcore = $LIBAVCORE_VERSION"
  2936. pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
  2937. pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
  2938. pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavcore = $LIBAVCORE_VERSION"
  2939. pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
  2940. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"