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.

3118 lines
87KB

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