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.

3181 lines
89KB

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