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.

3150 lines
88KB

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