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.

3207 lines
93KB

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