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.

3960 lines
115KB

  1. #!/bin/sh
  2. #
  3. # Libav configure script
  4. #
  5. # Copyright (c) 2000-2002 Fabrice Bellard
  6. # Copyright (c) 2005-2008 Diego Biurrun
  7. # Copyright (c) 2005-2008 Mans Rullgard
  8. #
  9. # Prevent locale nonsense from breaking basic text processing.
  10. LC_ALL=C
  11. export LC_ALL
  12. # make sure we are running under a compatible shell
  13. # try to make this part work with most shells
  14. try_exec(){
  15. echo "Trying shell $1"
  16. type "$1" > /dev/null 2>&1 && exec "$@"
  17. }
  18. unset foo
  19. (: ${foo%%bar}) 2> /dev/null
  20. E1="$?"
  21. (: ${foo?}) 2> /dev/null
  22. E2="$?"
  23. if test "$E1" != 0 || test "$E2" = 0; then
  24. echo "Broken shell detected. Trying alternatives."
  25. export FF_CONF_EXEC
  26. if test "0$FF_CONF_EXEC" -lt 1; then
  27. FF_CONF_EXEC=1
  28. try_exec bash "$0" "$@"
  29. fi
  30. if test "0$FF_CONF_EXEC" -lt 2; then
  31. FF_CONF_EXEC=2
  32. try_exec ksh "$0" "$@"
  33. fi
  34. if test "0$FF_CONF_EXEC" -lt 3; then
  35. FF_CONF_EXEC=3
  36. try_exec /usr/xpg4/bin/sh "$0" "$@"
  37. fi
  38. echo "No compatible shell script interpreter found."
  39. echo "This configure script requires a POSIX-compatible shell"
  40. echo "such as bash or ksh."
  41. echo "THIS IS NOT A BUG IN LIBAV, DO NOT REPORT IT AS SUCH."
  42. echo "Instead, install a working POSIX-compatible shell."
  43. echo "Disabling this configure test will create a broken Libav."
  44. if test "$BASH_VERSION" = '2.04.0(1)-release'; then
  45. echo "This bash version ($BASH_VERSION) is broken on your platform."
  46. echo "Upgrade to a later version if available."
  47. fi
  48. exit 1
  49. fi
  50. test -d /usr/xpg4/bin && PATH=/usr/xpg4/bin:$PATH
  51. show_help(){
  52. cat <<EOF
  53. Usage: configure [options]
  54. Options: [defaults in brackets after descriptions]
  55. Help options:
  56. --help print this message
  57. --list-decoders show all available decoders
  58. --list-encoders show all available encoders
  59. --list-hwaccels show all available hardware accelerators
  60. --list-demuxers show all available demuxers
  61. --list-muxers show all available muxers
  62. --list-parsers show all available parsers
  63. --list-protocols show all available protocols
  64. --list-bsfs show all available bitstream filters
  65. --list-indevs show all available input devices
  66. --list-outdevs show all available output devices
  67. --list-filters show all available filters
  68. Standard options:
  69. --logfile=FILE log tests and output to FILE [config.log]
  70. --disable-logging do not log configure debug information
  71. --prefix=PREFIX install in PREFIX [$prefix]
  72. --bindir=DIR install binaries in DIR [PREFIX/bin]
  73. --datadir=DIR install data files in DIR [PREFIX/share/avconv]
  74. --libdir=DIR install libs in DIR [PREFIX/lib]
  75. --shlibdir=DIR install shared libs in DIR [PREFIX/lib]
  76. --incdir=DIR install includes in DIR [PREFIX/include]
  77. --mandir=DIR install man page in DIR [PREFIX/share/man]
  78. Licensing options:
  79. --enable-gpl allow use of GPL code, the resulting libs
  80. and binaries will be under GPL [no]
  81. --enable-version3 upgrade (L)GPL to version 3 [no]
  82. --enable-nonfree allow use of nonfree code, the resulting libs
  83. and binaries will be unredistributable [no]
  84. Configuration options:
  85. --disable-static do not build static libraries [no]
  86. --enable-shared build shared libraries [no]
  87. --enable-small optimize for size instead of speed
  88. --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
  89. --enable-gray enable full grayscale support (slower color)
  90. --disable-swscale-alpha disable alpha channel support in swscale
  91. Program options:
  92. --disable-programs do not build command line programs
  93. --disable-avconv disable avconv build
  94. --disable-avplay disable avplay build
  95. --disable-avprobe disable avprobe build
  96. --disable-avserver disable avserver build
  97. Component options:
  98. --disable-doc do not build documentation
  99. --disable-avdevice disable libavdevice build
  100. --disable-avcodec disable libavcodec build
  101. --disable-avformat disable libavformat build
  102. --disable-avutil disable libavutil build
  103. --disable-swscale disable libswscale build
  104. --disable-avfilter disable video filter support [no]
  105. --disable-avresample disable libavresample build [no]
  106. --disable-pthreads disable pthreads [auto]
  107. --disable-w32threads disable Win32 threads [auto]
  108. --enable-x11grab enable X11 grabbing [no]
  109. --disable-network disable network support [no]
  110. --disable-dct disable DCT code
  111. --disable-dwt disable DWT code
  112. --disable-lsp disable LSP code
  113. --disable-lzo disable LZO decoder code
  114. --disable-mdct disable MDCT code
  115. --disable-rdft disable RDFT code
  116. --disable-fft disable FFT code
  117. --enable-dxva2 enable DXVA2 code
  118. --enable-vaapi enable VAAPI code
  119. --enable-vda enable VDA code
  120. --enable-vdpau enable VDPAU code
  121. Individual component options:
  122. --disable-everything disable all components listed below
  123. --disable-encoder=NAME disable encoder NAME
  124. --enable-encoder=NAME enable encoder NAME
  125. --disable-encoders disable all encoders
  126. --disable-decoder=NAME disable decoder NAME
  127. --enable-decoder=NAME enable decoder NAME
  128. --disable-decoders disable all decoders
  129. --disable-hwaccel=NAME disable hwaccel NAME
  130. --enable-hwaccel=NAME enable hwaccel NAME
  131. --disable-hwaccels disable all hwaccels
  132. --disable-muxer=NAME disable muxer NAME
  133. --enable-muxer=NAME enable muxer NAME
  134. --disable-muxers disable all muxers
  135. --disable-demuxer=NAME disable demuxer NAME
  136. --enable-demuxer=NAME enable demuxer NAME
  137. --disable-demuxers disable all demuxers
  138. --enable-parser=NAME enable parser NAME
  139. --disable-parser=NAME disable parser NAME
  140. --disable-parsers disable all parsers
  141. --enable-bsf=NAME enable bitstream filter NAME
  142. --disable-bsf=NAME disable bitstream filter NAME
  143. --disable-bsfs disable all bitstream filters
  144. --enable-protocol=NAME enable protocol NAME
  145. --disable-protocol=NAME disable protocol NAME
  146. --disable-protocols disable all protocols
  147. --enable-indev=NAME enable input device NAME
  148. --disable-indev=NAME disable input device NAME
  149. --disable-indevs disable input devices
  150. --enable-outdev=NAME enable output device NAME
  151. --disable-outdev=NAME disable output device NAME
  152. --disable-outdevs disable output devices
  153. --disable-devices disable all devices
  154. --enable-filter=NAME enable filter NAME
  155. --disable-filter=NAME disable filter NAME
  156. --disable-filters disable all filters
  157. External library support:
  158. --enable-avisynth enable reading of AVISynth script files [no]
  159. --enable-bzlib enable bzlib [autodetect]
  160. --enable-frei0r enable frei0r video filtering
  161. --enable-gnutls enable gnutls [no]
  162. --enable-libcdio enable audio CD grabbing with libcdio
  163. --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
  164. and libraw1394 [no]
  165. --enable-libfaac enable AAC encoding via libfaac [no]
  166. --enable-libfdk-aac enable AAC encoding via libfdk-aac [no]
  167. --enable-libfreetype enable libfreetype [no]
  168. --enable-libgsm enable GSM de/encoding via libgsm [no]
  169. --enable-libilbc enable iLBC de/encoding via libilbc [no]
  170. --enable-libmp3lame enable MP3 encoding via libmp3lame [no]
  171. --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
  172. --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
  173. --enable-libopencv enable video filtering via libopencv [no]
  174. --enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no]
  175. --enable-libopus enable Opus decoding via libopus [no]
  176. --enable-libpulse enable Pulseaudio input via libpulse [no]
  177. --enable-librtmp enable RTMP[E] support via librtmp [no]
  178. --enable-libschroedinger enable Dirac de/encoding via libschroedinger [no]
  179. --enable-libspeex enable Speex de/encoding via libspeex [no]
  180. --enable-libtheora enable Theora encoding via libtheora [no]
  181. --enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no]
  182. --enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no]
  183. --enable-libvorbis enable Vorbis encoding via libvorbis [no]
  184. --enable-libvpx enable VP8 de/encoding via libvpx [no]
  185. --enable-libx264 enable H.264 encoding via x264 [no]
  186. --enable-libxavs enable AVS encoding via xavs [no]
  187. --enable-libxvid enable Xvid encoding via xvidcore,
  188. native MPEG-4/Xvid encoder exists [no]
  189. --enable-openssl enable openssl [no]
  190. --enable-zlib enable zlib [autodetect]
  191. Advanced options (experts only):
  192. --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]
  193. --enable-cross-compile assume a cross-compiler is used
  194. --sysroot=PATH root of cross-build tree
  195. --sysinclude=PATH location of cross-build system headers
  196. --target-os=OS compiler targets OS [$target_os]
  197. --target-exec=CMD command to run executables on target
  198. --target-path=DIR path to view of build directory on target
  199. --toolchain=NAME set tool defaults according to NAME
  200. --nm=NM use nm tool
  201. --ar=AR use archive tool AR [$ar_default]
  202. --as=AS use assembler AS [$as_default]
  203. --cc=CC use C compiler CC [$cc_default]
  204. --dep-cc=DEPCC use dependency generator DEPCC [$cc_default]
  205. --ld=LD use linker LD
  206. --host-cc=HOSTCC use host C compiler HOSTCC
  207. --host-cflags=HCFLAGS use HCFLAGS when compiling for host
  208. --host-ld=HOSTLD use host linker HOSTLD
  209. --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
  210. --host-libs=HLIBS use libs HLIBS when linking for host
  211. --host-os=OS compiler host OS [$target_os]
  212. --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
  213. --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
  214. --extra-libs=ELIBS add ELIBS [$ELIBS]
  215. --extra-version=STRING version string suffix []
  216. --optflags=OPTFLAGS override optimization-related compiler flags
  217. --build-suffix=SUFFIX library name suffix []
  218. --malloc-prefix=PREFIX prefix malloc and related names with PREFIX
  219. --arch=ARCH select architecture [$arch]
  220. --cpu=CPU select the minimum required CPU (affects
  221. instruction selection, may crash on older CPUs)
  222. --enable-pic build position-independent code
  223. --enable-sram allow use of on-chip SRAM
  224. --enable-thumb compile for Thumb instruction set
  225. --disable-symver disable symbol versioning
  226. --enable-hardcoded-tables use hardcoded tables instead of runtime generation
  227. --disable-safe-bitstream-reader
  228. disable buffer boundary checking in bitreaders
  229. (faster, but may crash)
  230. --enable-memalign-hack emulate memalign, interferes with memory debuggers
  231. --enable-lto use link-time optimization
  232. Optimization options (experts only):
  233. --disable-asm disable all assembler optimizations
  234. --disable-altivec disable AltiVec optimizations
  235. --disable-amd3dnow disable 3DNow! optimizations
  236. --disable-amd3dnowext disable 3DNow! extended optimizations
  237. --disable-mmx disable MMX optimizations
  238. --disable-mmxext disable MMXEXT optimizations
  239. --disable-sse disable SSE optimizations
  240. --disable-sse2 disable SSE2 optimizations
  241. --disable-sse3 disable SSE3 optimizations
  242. --disable-ssse3 disable SSSE3 optimizations
  243. --disable-sse4 disable SSE4 optimizations
  244. --disable-sse42 disable SSE4.2 optimizations
  245. --disable-avx disable AVX optimizations
  246. --disable-fma4 disable FMA4 optimizations
  247. --disable-armv5te disable armv5te optimizations
  248. --disable-armv6 disable armv6 optimizations
  249. --disable-armv6t2 disable armv6t2 optimizations
  250. --disable-armvfp disable ARM VFP optimizations
  251. --disable-neon disable NEON optimizations
  252. --disable-vis disable VIS optimizations
  253. --disable-inline-asm disable use of inline assembler
  254. --disable-yasm disable use of yasm assembler
  255. Developer options (useful when working on Libav itself):
  256. --disable-debug disable debugging symbols
  257. --enable-debug=LEVEL set the debug level [$debuglevel]
  258. --disable-optimizations disable compiler optimizations
  259. --enable-extra-warnings enable more compiler warnings
  260. --samples=PATH location of test samples for FATE, if not set use
  261. \$LIBAV_SAMPLES at make invocation time.
  262. --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
  263. should be used only for debugging purposes)
  264. --enable-random randomly enable/disable components
  265. --disable-random
  266. --enable-random=LIST randomly enable/disable specific components or
  267. --disable-random=LIST component groups. LIST is a comma-separated list
  268. of NAME[:PROB] entries where NAME is a component
  269. (group) and PROB the probability associated with
  270. NAME (default 0.5).
  271. --random-seed=VALUE seed value for --enable/disable-random
  272. NOTE: Object files are built at the place where configure is launched.
  273. EOF
  274. exit 0
  275. }
  276. quotes='""'
  277. log(){
  278. echo "$@" >> $logfile
  279. }
  280. log_file(){
  281. log BEGIN $1
  282. pr -n -t $1 >> $logfile
  283. log END $1
  284. }
  285. echolog(){
  286. log "$@"
  287. echo "$@"
  288. }
  289. warn(){
  290. log "WARNING: $*"
  291. WARNINGS="${WARNINGS}WARNING: $*\n"
  292. }
  293. die(){
  294. echolog "$@"
  295. cat <<EOF
  296. If you think configure made a mistake, make sure you are using the latest
  297. version from Git. If the latest version fails, report the problem to the
  298. libav-user@libav.org mailing list or IRC #libav on irc.freenode.net.
  299. EOF
  300. if disabled logging; then
  301. cat <<EOF
  302. Rerun configure with logging enabled (do not use --disable-logging), and
  303. include the log this produces with your report.
  304. EOF
  305. else
  306. cat <<EOF
  307. Include the log file "$logfile" produced by configure as this will help
  308. solving the problem.
  309. EOF
  310. fi
  311. exit 1
  312. }
  313. # Avoid locale weirdness, besides we really just want to translate ASCII.
  314. toupper(){
  315. echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  316. }
  317. tolower(){
  318. echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
  319. }
  320. c_escape(){
  321. echo "$*" | sed 's/["\\]/\\\0/g'
  322. }
  323. sh_quote(){
  324. v=$(echo "$1" | sed "s/'/'\\\\''/g")
  325. test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
  326. echo "$v"
  327. }
  328. cleanws(){
  329. echo "$@" | sed 's/^ *//;s/ */ /g;s/ *$//'
  330. }
  331. filter(){
  332. pat=$1
  333. shift
  334. for v; do
  335. eval "case $v in $pat) echo $v ;; esac"
  336. done
  337. }
  338. filter_out(){
  339. pat=$1
  340. shift
  341. for v; do
  342. eval "case $v in $pat) ;; *) echo $v ;; esac"
  343. done
  344. }
  345. map(){
  346. m=$1
  347. shift
  348. for v; do eval $m; done
  349. }
  350. add_suffix(){
  351. suffix=$1
  352. shift
  353. for v; do echo ${v}${suffix}; done
  354. }
  355. set_all(){
  356. value=$1
  357. shift
  358. for var in $*; do
  359. eval $var=$value
  360. done
  361. }
  362. set_weak(){
  363. value=$1
  364. shift
  365. for var; do
  366. eval : \${$var:=$value}
  367. done
  368. }
  369. set_safe(){
  370. var=$1
  371. shift
  372. eval $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')='$*'
  373. }
  374. get_safe(){
  375. eval echo \$$(echo "$1" | sed 's/[^A-Za-z0-9_]/_/g')
  376. }
  377. pushvar(){
  378. for var in $*; do
  379. eval level=\${${var}_level:=0}
  380. eval ${var}_${level}="\$$var"
  381. eval ${var}_level=$(($level+1))
  382. done
  383. }
  384. popvar(){
  385. for var in $*; do
  386. eval level=\${${var}_level:-0}
  387. test $level = 0 && continue
  388. eval level=$(($level-1))
  389. eval $var="\${${var}_${level}}"
  390. eval ${var}_level=$level
  391. eval unset ${var}_${level}
  392. done
  393. }
  394. enable(){
  395. set_all yes $*
  396. }
  397. disable(){
  398. set_all no $*
  399. }
  400. enable_weak(){
  401. set_weak yes $*
  402. }
  403. disable_weak(){
  404. set_weak no $*
  405. }
  406. enable_safe(){
  407. for var; do
  408. enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
  409. done
  410. }
  411. disable_safe(){
  412. for var; do
  413. disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
  414. done
  415. }
  416. do_enable_deep(){
  417. for var; do
  418. enabled $var && continue
  419. eval sel="\$${var}_select"
  420. eval sgs="\$${var}_suggest"
  421. pushvar var sgs
  422. enable_deep $sel
  423. popvar sgs
  424. enable_deep_weak $sgs
  425. popvar var
  426. done
  427. }
  428. enable_deep(){
  429. do_enable_deep $*
  430. enable $*
  431. }
  432. enable_deep_weak(){
  433. do_enable_deep $*
  434. enable_weak $*
  435. }
  436. enabled(){
  437. test "${1#!}" = "$1" && op== || op=!=
  438. eval test "x\$${1#!}" $op "xyes"
  439. }
  440. disabled(){
  441. test "${1#!}" = "$1" && op== || op=!=
  442. eval test "x\$${1#!}" $op "xno"
  443. }
  444. enabled_all(){
  445. for opt; do
  446. enabled $opt || return 1
  447. done
  448. }
  449. disabled_all(){
  450. for opt; do
  451. disabled $opt || return 1
  452. done
  453. }
  454. enabled_any(){
  455. for opt; do
  456. enabled $opt && return 0
  457. done
  458. }
  459. disabled_any(){
  460. for opt; do
  461. disabled $opt && return 0
  462. done
  463. return 1
  464. }
  465. set_default(){
  466. for opt; do
  467. eval : \${$opt:=\$${opt}_default}
  468. done
  469. }
  470. is_in(){
  471. value=$1
  472. shift
  473. for var in $*; do
  474. [ $var = $value ] && return 0
  475. done
  476. return 1
  477. }
  478. check_deps(){
  479. for cfg; do
  480. cfg="${cfg#!}"
  481. enabled ${cfg}_checking && die "Circular dependency for $cfg."
  482. disabled ${cfg}_checking && continue
  483. enable ${cfg}_checking
  484. eval dep_all="\$${cfg}_deps"
  485. eval dep_any="\$${cfg}_deps_any"
  486. eval dep_sel="\$${cfg}_select"
  487. eval dep_sgs="\$${cfg}_suggest"
  488. eval dep_ifa="\$${cfg}_if"
  489. eval dep_ifn="\$${cfg}_if_any"
  490. pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
  491. check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
  492. popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
  493. [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
  494. [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
  495. enabled_all $dep_all || disable $cfg
  496. enabled_any $dep_any || disable $cfg
  497. disabled_any $dep_sel && disable $cfg
  498. if enabled $cfg; then
  499. eval dep_extralibs="\$${cfg}_extralibs"
  500. test -n "$dep_extralibs" && add_extralibs $dep_extralibs
  501. enable_deep $dep_sel
  502. enable_deep_weak $dep_sgs
  503. fi
  504. disable ${cfg}_checking
  505. done
  506. }
  507. print_config(){
  508. pfx=$1
  509. files=$2
  510. shift 2
  511. map 'eval echo "$v \${$v:-no}"' "$@" |
  512. awk "BEGIN { split(\"$files\", files) }
  513. {
  514. c = \"$pfx\" toupper(\$1);
  515. v = \$2;
  516. sub(/yes/, 1, v);
  517. sub(/no/, 0, v);
  518. for (f in files) {
  519. file = files[f];
  520. if (file ~ /\\.h\$/) {
  521. printf(\"#define %s %d\\n\", c, v) >>file;
  522. } else if (file ~ /\\.asm\$/) {
  523. printf(\"%%define %s %d\\n\", c, v) >>file;
  524. } else if (file ~ /\\.mak\$/) {
  525. n = -v ? \"\" : \"!\";
  526. printf(\"%s%s=yes\\n\", n, c) >>file;
  527. }
  528. }
  529. }"
  530. }
  531. print_enabled(){
  532. suf=$1
  533. shift
  534. for v; do
  535. enabled $v && printf "%s\n" ${v%$suf};
  536. done
  537. }
  538. append(){
  539. var=$1
  540. shift
  541. eval "$var=\"\$$var $*\""
  542. }
  543. prepend(){
  544. var=$1
  545. shift
  546. eval "$var=\"$* \$$var\""
  547. }
  548. add_cppflags(){
  549. append CPPFLAGS "$@"
  550. }
  551. add_cflags(){
  552. append CFLAGS $($cflags_filter "$@")
  553. }
  554. add_asflags(){
  555. append ASFLAGS $($asflags_filter "$@")
  556. }
  557. add_ldflags(){
  558. append LDFLAGS $($ldflags_filter "$@")
  559. }
  560. add_extralibs(){
  561. prepend extralibs $($ldflags_filter "$@")
  562. }
  563. add_host_cflags(){
  564. append host_cflags $($host_cflags_filter "$@")
  565. }
  566. add_host_ldflags(){
  567. append host_ldflags $($host_ldflags_filter "$@")
  568. }
  569. add_compat(){
  570. append compat_objs $1
  571. shift
  572. map 'add_cppflags -D$v' "$@"
  573. }
  574. check_cmd(){
  575. log "$@"
  576. "$@" >> $logfile 2>&1
  577. }
  578. cc_o(){
  579. eval printf '%s\\n' $CC_O
  580. }
  581. cc_e(){
  582. eval printf '%s\\n' $CC_E
  583. }
  584. check_cc(){
  585. log check_cc "$@"
  586. cat > $TMPC
  587. log_file $TMPC
  588. check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
  589. }
  590. check_cpp(){
  591. log check_cpp "$@"
  592. cat > $TMPC
  593. log_file $TMPC
  594. check_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
  595. }
  596. as_o(){
  597. eval printf '%s\\n' $AS_O
  598. }
  599. check_as(){
  600. log check_as "$@"
  601. cat > $TMPC
  602. log_file $TMPC
  603. check_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPC
  604. }
  605. check_inline_asm(){
  606. log check_inline_asm "$@"
  607. name="$1"
  608. code="$2"
  609. shift 2
  610. disable $name
  611. check_as "$@" <<EOF && enable $name
  612. void foo(void){ __asm__ volatile($code); }
  613. EOF
  614. }
  615. check_yasm(){
  616. log check_yasm "$@"
  617. echo "$1" > $TMPS
  618. log_file $TMPS
  619. shift 1
  620. check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
  621. }
  622. ld_o(){
  623. eval printf '%s\\n' $LD_O
  624. }
  625. check_ld(){
  626. log check_ld "$@"
  627. flags=$(filter_out '-l*' "$@")
  628. libs=$(filter '-l*' "$@")
  629. check_cc $($cflags_filter $flags) || return
  630. flags=$($ldflags_filter $flags)
  631. libs=$($ldflags_filter $libs)
  632. check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
  633. }
  634. check_code(){
  635. log check_code "$@"
  636. check=$1
  637. headers=$2
  638. code=$3
  639. shift 3
  640. {
  641. for hdr in $headers; do
  642. echo "#include <$hdr>"
  643. done
  644. echo "int main(void) { $code; return 0; }"
  645. } | check_$check "$@"
  646. }
  647. check_cppflags(){
  648. log check_cppflags "$@"
  649. check_cc "$@" <<EOF && append CPPFLAGS "$@"
  650. int x;
  651. EOF
  652. }
  653. check_cflags(){
  654. log check_cflags "$@"
  655. set -- $($cflags_filter "$@")
  656. check_cc "$@" <<EOF && append CFLAGS "$@"
  657. int x;
  658. EOF
  659. }
  660. test_ldflags(){
  661. log test_ldflags "$@"
  662. check_ld "$@" <<EOF
  663. int main(void){ return 0; }
  664. EOF
  665. }
  666. check_ldflags(){
  667. log check_ldflags "$@"
  668. test_ldflags "$@" && add_ldflags "$@"
  669. }
  670. check_header(){
  671. log check_header "$@"
  672. header=$1
  673. shift
  674. disable_safe $header
  675. check_cpp "$@" <<EOF && enable_safe $header
  676. #include <$header>
  677. int x;
  678. EOF
  679. }
  680. check_func(){
  681. log check_func "$@"
  682. func=$1
  683. shift
  684. disable $func
  685. check_ld "$@" <<EOF && enable $func
  686. extern int $func();
  687. int main(void){ $func(); }
  688. EOF
  689. }
  690. check_mathfunc(){
  691. log check_mathfunc "$@"
  692. func=$1
  693. narg=$2
  694. shift 2
  695. test $narg = 2 && args="f, g" || args="f"
  696. disable $func
  697. check_ld "$@" <<EOF && enable $func
  698. #include <math.h>
  699. float foo(float f, float g) { return $func($args); }
  700. int main(void){ return 0; }
  701. EOF
  702. }
  703. check_func_headers(){
  704. log check_func_headers "$@"
  705. headers=$1
  706. funcs=$2
  707. shift 2
  708. {
  709. for hdr in $headers; do
  710. echo "#include <$hdr>"
  711. done
  712. for func in $funcs; do
  713. echo "long check_$func(void) { return (long) $func; }"
  714. done
  715. echo "int main(void) { return 0; }"
  716. } | check_ld "$@" && enable $funcs && enable_safe $headers
  717. }
  718. check_cpp_condition(){
  719. log check_cpp_condition "$@"
  720. header=$1
  721. condition=$2
  722. shift 2
  723. check_cpp "$@" <<EOF
  724. #include <$header>
  725. #if !($condition)
  726. #error "unsatisfied condition: $condition"
  727. #endif
  728. EOF
  729. }
  730. check_lib(){
  731. log check_lib "$@"
  732. header="$1"
  733. func="$2"
  734. shift 2
  735. check_header $header && check_func $func "$@" && add_extralibs "$@"
  736. }
  737. check_lib2(){
  738. log check_lib2 "$@"
  739. headers="$1"
  740. funcs="$2"
  741. shift 2
  742. check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
  743. }
  744. check_pkg_config(){
  745. log check_pkg_config "$@"
  746. pkg="$1"
  747. headers="$2"
  748. funcs="$3"
  749. shift 3
  750. $pkg_config --exists $pkg || return
  751. pkg_cflags=$($pkg_config --cflags $pkg)
  752. pkg_libs=$($pkg_config --libs $pkg)
  753. check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
  754. set_safe ${pkg}_cflags $pkg_cflags &&
  755. set_safe ${pkg}_libs $pkg_libs
  756. }
  757. check_exec(){
  758. check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
  759. }
  760. check_exec_crash(){
  761. code=$(cat)
  762. # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
  763. # are safe but may not be available everywhere. Thus we use
  764. # raise(SIGTERM) instead. The check is run in a subshell so we
  765. # can redirect the "Terminated" message from the shell. SIGBUS
  766. # is not defined by standard C so it is used conditionally.
  767. (check_exec "$@") >> $logfile 2>&1 <<EOF
  768. #include <signal.h>
  769. static void sighandler(int sig){
  770. raise(SIGTERM);
  771. }
  772. int foo(void){
  773. $code
  774. }
  775. int main(void){
  776. signal(SIGILL, sighandler);
  777. signal(SIGFPE, sighandler);
  778. signal(SIGSEGV, sighandler);
  779. #ifdef SIGBUS
  780. signal(SIGBUS, sighandler);
  781. #endif
  782. foo();
  783. }
  784. EOF
  785. }
  786. check_type(){
  787. log check_type "$@"
  788. headers=$1
  789. type=$2
  790. shift 2
  791. disable_safe "$type"
  792. check_code cc "$headers" "$type v" "$@" && enable_safe "$type"
  793. }
  794. check_struct(){
  795. log check_type "$@"
  796. headers=$1
  797. struct=$2
  798. member=$3
  799. shift 3
  800. disable_safe "${struct}_${member}"
  801. check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
  802. enable_safe "${struct}_${member}"
  803. }
  804. require(){
  805. name="$1"
  806. header="$2"
  807. func="$3"
  808. shift 3
  809. check_lib $header $func "$@" || die "ERROR: $name not found"
  810. }
  811. require2(){
  812. name="$1"
  813. headers="$2"
  814. func="$3"
  815. shift 3
  816. check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
  817. }
  818. require_pkg_config(){
  819. pkg="$1"
  820. check_pkg_config "$@" || die "ERROR: $pkg not found"
  821. add_cflags $(get_safe ${pkg}_cflags)
  822. add_extralibs $(get_safe ${pkg}_libs)
  823. }
  824. hostcc_o(){
  825. eval printf '%s\\n' $HOSTCC_O
  826. }
  827. check_host_cc(){
  828. log check_host_cc "$@"
  829. cat > $TMPC
  830. log_file $TMPC
  831. check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
  832. }
  833. check_host_cflags(){
  834. log check_host_cflags "$@"
  835. set -- $($host_cflags_filter "$@")
  836. check_host_cc "$@" <<EOF && append host_cflags "$@"
  837. int x;
  838. EOF
  839. }
  840. apply(){
  841. file=$1
  842. shift
  843. "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
  844. }
  845. cp_if_changed(){
  846. cmp -s "$1" "$2" && echo "$2 is unchanged" && return
  847. mkdir -p "$(dirname $2)"
  848. $cp_f "$1" "$2"
  849. }
  850. # CONFIG_LIST contains configurable options, while HAVE_LIST is for
  851. # system-dependent things.
  852. COMPONENT_LIST="
  853. bsfs
  854. decoders
  855. demuxers
  856. encoders
  857. filters
  858. hwaccels
  859. indevs
  860. muxers
  861. outdevs
  862. parsers
  863. protocols
  864. "
  865. LIBRARY_LIST="
  866. avcodec
  867. avdevice
  868. avfilter
  869. avformat
  870. avresample
  871. avutil
  872. swscale
  873. "
  874. PROGRAM_LIST="
  875. avconv
  876. avplay
  877. avprobe
  878. avserver
  879. "
  880. CONFIG_LIST="
  881. $COMPONENT_LIST
  882. $LIBRARY_LIST
  883. $PROGRAM_LIST
  884. avisynth
  885. bzlib
  886. dct
  887. doc
  888. dwt
  889. dxva2
  890. fft
  891. frei0r
  892. gnutls
  893. gpl
  894. gray
  895. hardcoded_tables
  896. libcdio
  897. libdc1394
  898. libfaac
  899. libfdk_aac
  900. libfreetype
  901. libgsm
  902. libilbc
  903. libmp3lame
  904. libopencore_amrnb
  905. libopencore_amrwb
  906. libopencv
  907. libopenjpeg
  908. libopus
  909. libpulse
  910. librtmp
  911. libschroedinger
  912. libspeex
  913. libtheora
  914. libvo_aacenc
  915. libvo_amrwbenc
  916. libvorbis
  917. libvpx
  918. libx264
  919. libxavs
  920. libxvid
  921. lsp
  922. lzo
  923. mdct
  924. memalign_hack
  925. network
  926. nonfree
  927. openssl
  928. pic
  929. rdft
  930. runtime_cpudetect
  931. safe_bitstream_reader
  932. shared
  933. small
  934. sram
  935. static
  936. swscale_alpha
  937. thumb
  938. vaapi
  939. vda
  940. vdpau
  941. version3
  942. xmm_clobber_test
  943. x11grab
  944. zlib
  945. "
  946. THREADS_LIST='
  947. pthreads
  948. w32threads
  949. '
  950. ARCH_LIST='
  951. aarch64
  952. alpha
  953. arm
  954. avr32
  955. avr32_ap
  956. avr32_uc
  957. bfin
  958. ia64
  959. m68k
  960. mips
  961. mips64
  962. parisc
  963. ppc
  964. ppc64
  965. s390
  966. sh4
  967. sparc
  968. sparc64
  969. tilegx
  970. tilepro
  971. tomi
  972. x86
  973. x86_32
  974. x86_64
  975. '
  976. ARCH_EXT_LIST_X86='
  977. amd3dnow
  978. amd3dnowext
  979. avx
  980. fma4
  981. mmx
  982. mmxext
  983. sse
  984. sse2
  985. sse3
  986. sse4
  987. sse42
  988. ssse3
  989. '
  990. ARCH_EXT_LIST="
  991. $ARCH_EXT_LIST_X86
  992. altivec
  993. armv5te
  994. armv6
  995. armv6t2
  996. armvfp
  997. neon
  998. ppc4xx
  999. vfpv3
  1000. vis
  1001. "
  1002. HAVE_LIST_CMDLINE='
  1003. inline_asm
  1004. symver
  1005. yasm
  1006. '
  1007. HAVE_LIST_PUB='
  1008. bigendian
  1009. fast_unaligned
  1010. '
  1011. MATH_FUNCS="
  1012. atanf
  1013. atan2f
  1014. cbrtf
  1015. cosf
  1016. exp2
  1017. exp2f
  1018. expf
  1019. isinf
  1020. isnan
  1021. ldexpf
  1022. llrint
  1023. llrintf
  1024. log2
  1025. log2f
  1026. log10f
  1027. lrint
  1028. lrintf
  1029. powf
  1030. rint
  1031. round
  1032. roundf
  1033. sinf
  1034. trunc
  1035. truncf
  1036. "
  1037. HAVE_LIST="
  1038. $ARCH_EXT_LIST
  1039. $(add_suffix _external $ARCH_EXT_LIST)
  1040. $(add_suffix _inline $ARCH_EXT_LIST)
  1041. $HAVE_LIST_CMDLINE
  1042. $HAVE_LIST_PUB
  1043. $THREADS_LIST
  1044. $MATH_FUNCS
  1045. aligned_malloc
  1046. aligned_stack
  1047. alsa_asoundlib_h
  1048. altivec_h
  1049. arpa_inet_h
  1050. asm_mod_q
  1051. asm_mod_y
  1052. attribute_may_alias
  1053. attribute_packed
  1054. closesocket
  1055. cmov
  1056. CommandLineToArgvW
  1057. cpunop
  1058. CryptGenRandom
  1059. dcbzl
  1060. dev_bktr_ioctl_bt848_h
  1061. dev_bktr_ioctl_meteor_h
  1062. dev_ic_bt8xx_h
  1063. dev_video_bktr_ioctl_bt848_h
  1064. dev_video_meteor_ioctl_meteor_h
  1065. direct_h
  1066. dlfcn_h
  1067. dlopen
  1068. dos_paths
  1069. dxva_h
  1070. ebp_available
  1071. ebx_available
  1072. fast_64bit
  1073. fast_clz
  1074. fast_cmov
  1075. fcntl
  1076. fork
  1077. getaddrinfo
  1078. gethrtime
  1079. getopt
  1080. GetProcessAffinityMask
  1081. GetProcessMemoryInfo
  1082. GetProcessTimes
  1083. GetSystemTimeAsFileTime
  1084. getrusage
  1085. getservbyport
  1086. gettimeofday
  1087. gnu_as
  1088. ibm_asm
  1089. inet_aton
  1090. io_h
  1091. isatty
  1092. jack_port_get_latency_range
  1093. ldbrx
  1094. libdc1394_1
  1095. libdc1394_2
  1096. local_aligned_16
  1097. local_aligned_8
  1098. localtime_r
  1099. loongson
  1100. machine_ioctl_bt848_h
  1101. machine_ioctl_meteor_h
  1102. malloc_h
  1103. MapViewOfFile
  1104. memalign
  1105. mkstemp
  1106. mm_empty
  1107. mmap
  1108. mprotect
  1109. msvcrt
  1110. nanosleep
  1111. poll_h
  1112. posix_memalign
  1113. rdtsc
  1114. sched_getaffinity
  1115. sdl
  1116. sdl_video_size
  1117. setmode
  1118. setrlimit
  1119. Sleep
  1120. sndio_h
  1121. socklen_t
  1122. soundcard_h
  1123. strerror_r
  1124. strptime
  1125. strtok_r
  1126. struct_addrinfo
  1127. struct_group_source_req
  1128. struct_ip_mreq_source
  1129. struct_ipv6_mreq
  1130. struct_pollfd
  1131. struct_rusage_ru_maxrss
  1132. struct_sockaddr_in6
  1133. struct_sockaddr_sa_len
  1134. struct_sockaddr_storage
  1135. struct_v4l2_frmivalenum_discrete
  1136. symver_asm_label
  1137. symver_gnu_asm
  1138. sysconf
  1139. sysctl
  1140. sys_mman_h
  1141. sys_param_h
  1142. sys_resource_h
  1143. sys_select_h
  1144. sys_soundcard_h
  1145. sys_time_h
  1146. sys_videoio_h
  1147. threads
  1148. unistd_h
  1149. usleep
  1150. vfp_args
  1151. VirtualAlloc
  1152. windows_h
  1153. winsock2_h
  1154. xform_asm
  1155. xmm_clobbers
  1156. "
  1157. # options emitted with CONFIG_ prefix but not available on command line
  1158. CONFIG_EXTRA="
  1159. aandcttables
  1160. ac3dsp
  1161. error_resilience
  1162. gcrypt
  1163. golomb
  1164. gplv3
  1165. h264chroma
  1166. h264dsp
  1167. h264pred
  1168. h264qpel
  1169. huffman
  1170. lgplv3
  1171. lpc
  1172. mpegaudio
  1173. mpegaudiodsp
  1174. mpegvideo
  1175. mpegvideoenc
  1176. nettle
  1177. rangecoder
  1178. rtpdec
  1179. sinewin
  1180. vp3dsp
  1181. "
  1182. CMDLINE_SELECT="
  1183. $ARCH_EXT_LIST
  1184. $CONFIG_LIST
  1185. $HAVE_LIST_CMDLINE
  1186. $THREADS_LIST
  1187. asm
  1188. cross_compile
  1189. debug
  1190. extra_warnings
  1191. logging
  1192. lto
  1193. optimizations
  1194. "
  1195. PATHS_LIST='
  1196. bindir
  1197. datadir
  1198. incdir
  1199. libdir
  1200. mandir
  1201. prefix
  1202. shlibdir
  1203. '
  1204. CMDLINE_SET="
  1205. $PATHS_LIST
  1206. ar
  1207. arch
  1208. as
  1209. build_suffix
  1210. cc
  1211. cpu
  1212. cross_prefix
  1213. dep_cc
  1214. extra_version
  1215. host_cc
  1216. host_cflags
  1217. host_ld
  1218. host_ldflags
  1219. host_libs
  1220. host_os
  1221. ld
  1222. logfile
  1223. malloc_prefix
  1224. nm
  1225. optflags
  1226. pkg_config
  1227. random_seed
  1228. samples
  1229. sysinclude
  1230. sysroot
  1231. target_exec
  1232. target_os
  1233. target_path
  1234. toolchain
  1235. "
  1236. CMDLINE_APPEND="
  1237. extra_cflags
  1238. "
  1239. # code dependency declarations
  1240. # architecture extensions
  1241. armv5te_deps="arm"
  1242. armv6_deps="arm"
  1243. armv6t2_deps="arm"
  1244. armvfp_deps="arm"
  1245. neon_deps="arm"
  1246. vfpv3_deps="armvfp"
  1247. altivec_deps="ppc"
  1248. ppc4xx_deps="ppc"
  1249. vis_deps="sparc"
  1250. x86_64_suggest="cmov fast_cmov"
  1251. amd3dnow_deps="mmx"
  1252. amd3dnowext_deps="amd3dnow"
  1253. mmx_deps="x86"
  1254. mmxext_deps="mmx"
  1255. sse_deps="mmxext"
  1256. sse2_deps="sse"
  1257. sse3_deps="sse2"
  1258. ssse3_deps="sse3"
  1259. sse4_deps="ssse3"
  1260. sse42_deps="sse4"
  1261. avx_deps="sse42"
  1262. fma4_deps="avx"
  1263. mmx_external_deps="yasm"
  1264. mmx_inline_deps="inline_asm"
  1265. mmx_suggest="mmx_external mmx_inline"
  1266. for ext in $(filter_out mmx $ARCH_EXT_LIST_X86); do
  1267. eval dep=\$${ext}_deps
  1268. eval ${ext}_external_deps='"${dep}_external"'
  1269. eval ${ext}_inline_deps='"${dep}_inline"'
  1270. eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
  1271. done
  1272. aligned_stack_if_any="ppc x86"
  1273. fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
  1274. fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
  1275. fast_unaligned_if_any="armv6 ppc x86"
  1276. inline_asm_deps="!tms470"
  1277. need_memalign="altivec neon sse"
  1278. symver_if_any="symver_asm_label symver_gnu_asm"
  1279. log2_deps="!msvcrt"
  1280. # subsystems
  1281. dct_select="rdft"
  1282. mdct_select="fft"
  1283. rdft_select="fft"
  1284. mpegaudio_select="mpegaudiodsp"
  1285. mpegaudiodsp_select="dct"
  1286. mpegvideoenc_select="mpegvideo"
  1287. # decoders / encoders / hardware accelerators
  1288. aac_decoder_select="mdct sinewin"
  1289. aac_encoder_select="mdct sinewin"
  1290. aac_latm_decoder_select="aac_decoder aac_latm_parser"
  1291. ac3_decoder_select="mdct ac3dsp ac3_parser"
  1292. ac3_encoder_select="mdct ac3dsp"
  1293. ac3_fixed_encoder_select="mdct ac3dsp"
  1294. alac_encoder_select="lpc"
  1295. amrnb_decoder_select="lsp"
  1296. amrwb_decoder_select="lsp"
  1297. atrac1_decoder_select="mdct sinewin"
  1298. atrac3_decoder_select="mdct"
  1299. binkaudio_dct_decoder_select="mdct rdft dct sinewin"
  1300. binkaudio_rdft_decoder_select="mdct rdft sinewin"
  1301. cavs_decoder_select="golomb mpegvideo"
  1302. comfortnoise_encoder_select="lpc"
  1303. cook_decoder_select="mdct sinewin"
  1304. cscd_decoder_select="lzo"
  1305. cscd_decoder_suggest="zlib"
  1306. dca_decoder_select="mdct"
  1307. dnxhd_encoder_select="aandcttables mpegvideoenc"
  1308. dxa_decoder_select="zlib"
  1309. eac3_decoder_select="ac3_decoder"
  1310. eac3_encoder_select="ac3_encoder"
  1311. eamad_decoder_select="aandcttables error_resilience mpegvideo"
  1312. eatgq_decoder_select="aandcttables"
  1313. eatqi_decoder_select="aandcttables error_resilience mpegvideo"
  1314. ffv1_decoder_select="golomb rangecoder"
  1315. ffv1_encoder_select="rangecoder"
  1316. ffvhuff_encoder_select="huffman"
  1317. flac_decoder_select="golomb"
  1318. flac_encoder_select="golomb lpc"
  1319. flashsv_decoder_select="zlib"
  1320. flashsv_encoder_select="zlib"
  1321. flashsv2_decoder_select="zlib"
  1322. flv_decoder_select="h263_decoder"
  1323. flv_encoder_select="h263_encoder"
  1324. fraps_decoder_select="huffman"
  1325. h261_decoder_select="error_resilience mpegvideo"
  1326. h261_encoder_select="aandcttables mpegvideoenc"
  1327. h263_decoder_select="error_resilience h263_parser mpegvideo"
  1328. h263_encoder_select="aandcttables error_resilience mpegvideoenc"
  1329. h263_vaapi_hwaccel_select="vaapi h263_decoder"
  1330. h263i_decoder_select="h263_decoder"
  1331. h263p_encoder_select="h263_encoder"
  1332. h264_decoder_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
  1333. h264_dxva2_hwaccel_deps="dxva2api_h"
  1334. h264_dxva2_hwaccel_select="dxva2 h264_decoder"
  1335. h264_vaapi_hwaccel_select="vaapi h264_decoder"
  1336. h264_vda_hwaccel_select="vda h264_decoder"
  1337. h264_vdpau_decoder_select="vdpau h264_decoder"
  1338. huffyuv_encoder_select="huffman"
  1339. iac_decoder_select="fft mdct sinewin"
  1340. imc_decoder_select="fft mdct sinewin"
  1341. jpegls_decoder_select="golomb"
  1342. jpegls_encoder_select="golomb"
  1343. ljpeg_encoder_select="aandcttables mpegvideoenc"
  1344. loco_decoder_select="golomb"
  1345. mdec_decoder_select="error_resilience mpegvideo"
  1346. mjpeg_encoder_select="aandcttables mpegvideoenc"
  1347. mlp_decoder_select="mlp_parser"
  1348. mp1_decoder_select="mpegaudio"
  1349. mp1float_decoder_select="mpegaudio"
  1350. mp2_decoder_select="mpegaudio"
  1351. mp2float_decoder_select="mpegaudio"
  1352. mp3_decoder_select="mpegaudio"
  1353. mp3adu_decoder_select="mpegaudio"
  1354. mp3adufloat_decoder_select="mpegaudio"
  1355. mp3float_decoder_select="mpegaudio"
  1356. mp3on4_decoder_select="mpegaudio"
  1357. mp3on4float_decoder_select="mpegaudio"
  1358. mpc7_decoder_select="mpegaudiodsp"
  1359. mpc8_decoder_select="mpegaudiodsp"
  1360. mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
  1361. mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
  1362. mpeg_xvmc_decoder_select="mpegvideo_decoder"
  1363. mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
  1364. mpeg1video_decoder_select="error_resilience mpegvideo"
  1365. mpeg1video_encoder_select="aandcttables error_resilience mpegvideoenc"
  1366. mpeg2_dxva2_hwaccel_deps="dxva2api_h"
  1367. mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder"
  1368. mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
  1369. mpeg2video_decoder_select="error_resilience mpegvideo"
  1370. mpeg2video_encoder_select="aandcttables error_resilience mpegvideoenc"
  1371. mpeg4_decoder_select="h263_decoder mpeg4video_parser"
  1372. mpeg4_encoder_select="h263_encoder"
  1373. mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
  1374. mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
  1375. msmpeg4v1_decoder_select="h263_decoder"
  1376. msmpeg4v1_encoder_select="h263_encoder"
  1377. msmpeg4v2_decoder_select="h263_decoder"
  1378. msmpeg4v2_encoder_select="h263_encoder"
  1379. msmpeg4v3_decoder_select="h263_decoder"
  1380. msmpeg4v3_encoder_select="h263_encoder"
  1381. mss2_decoder_select="vc1_decoder"
  1382. nellymoser_decoder_select="mdct sinewin"
  1383. nellymoser_encoder_select="mdct sinewin"
  1384. nuv_decoder_select="lzo"
  1385. png_decoder_select="zlib"
  1386. png_encoder_select="zlib"
  1387. qcelp_decoder_select="lsp"
  1388. qdm2_decoder_select="mdct rdft mpegaudiodsp"
  1389. ra_144_encoder_select="lpc"
  1390. ralf_decoder_select="golomb"
  1391. rv10_decoder_select="h263_decoder"
  1392. rv10_encoder_select="h263_encoder"
  1393. rv20_decoder_select="h263_decoder"
  1394. rv20_encoder_select="h263_encoder"
  1395. rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo"
  1396. rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo"
  1397. shorten_decoder_select="golomb"
  1398. sipr_decoder_select="lsp"
  1399. snow_decoder_select="dwt rangecoder"
  1400. snow_encoder_select="aandcttables dwt error_resilience mpegvideoenc rangecoder"
  1401. svq1_decoder_select="error_resilience mpegvideo"
  1402. svq1_encoder_select="aandcttables error_resilience mpegvideoenc"
  1403. svq3_decoder_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
  1404. svq3_decoder_suggest="zlib"
  1405. theora_decoder_select="vp3_decoder"
  1406. tiff_decoder_suggest="zlib"
  1407. tiff_encoder_suggest="zlib"
  1408. truehd_decoder_select="mlp_decoder"
  1409. tscc_decoder_select="zlib"
  1410. twinvq_decoder_select="mdct lsp sinewin"
  1411. utvideo_encoder_select="huffman"
  1412. vc1_decoder_select="h263_decoder h264chroma h264qpel"
  1413. vc1_dxva2_hwaccel_deps="dxva2api_h"
  1414. vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
  1415. vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
  1416. vc1_vdpau_decoder_select="vdpau vc1_decoder"
  1417. vc1image_decoder_select="vc1_decoder"
  1418. vorbis_decoder_select="mdct"
  1419. vorbis_encoder_select="mdct"
  1420. vp3_decoder_select="vp3dsp"
  1421. vp5_decoder_select="vp3dsp"
  1422. vp6_decoder_select="huffman vp3dsp"
  1423. vp6a_decoder_select="vp6_decoder"
  1424. vp6f_decoder_select="vp6_decoder"
  1425. vp8_decoder_select="h264pred h264qpel"
  1426. wmapro_decoder_select="mdct sinewin"
  1427. wmav1_decoder_select="mdct sinewin"
  1428. wmav1_encoder_select="mdct sinewin"
  1429. wmav2_decoder_select="mdct sinewin"
  1430. wmav2_encoder_select="mdct sinewin"
  1431. wmavoice_decoder_select="lsp rdft dct mdct sinewin"
  1432. wmv1_decoder_select="h263_decoder"
  1433. wmv1_encoder_select="h263_encoder"
  1434. wmv2_decoder_select="h263_decoder"
  1435. wmv2_encoder_select="h263_encoder"
  1436. wmv3_decoder_select="vc1_decoder"
  1437. wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
  1438. wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
  1439. wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
  1440. wmv3image_decoder_select="wmv3_decoder"
  1441. zerocodec_decoder_select="zlib"
  1442. zlib_decoder_select="zlib"
  1443. zlib_encoder_select="zlib"
  1444. zmbv_decoder_select="zlib"
  1445. zmbv_encoder_select="zlib"
  1446. vaapi_deps="va_va_h"
  1447. vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
  1448. vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  1449. # parsers
  1450. h264_parser_select="error_resilience golomb h264dsp h264pred mpegvideo"
  1451. mpeg4video_parser_select="error_resilience mpegvideo"
  1452. mpegvideo_parser_select="error_resilience mpegvideo"
  1453. vc1_parser_select="error_resilience mpegvideo"
  1454. # external libraries
  1455. libfaac_encoder_deps="libfaac"
  1456. libfdk_aac_encoder_deps="libfdk_aac"
  1457. libgsm_decoder_deps="libgsm"
  1458. libgsm_encoder_deps="libgsm"
  1459. libgsm_ms_decoder_deps="libgsm"
  1460. libgsm_ms_encoder_deps="libgsm"
  1461. libilbc_decoder_deps="libilbc"
  1462. libilbc_encoder_deps="libilbc"
  1463. libmp3lame_encoder_deps="libmp3lame"
  1464. libopencore_amrnb_decoder_deps="libopencore_amrnb"
  1465. libopencore_amrnb_encoder_deps="libopencore_amrnb"
  1466. libopencore_amrwb_decoder_deps="libopencore_amrwb"
  1467. libopenjpeg_decoder_deps="libopenjpeg"
  1468. libopenjpeg_encoder_deps="libopenjpeg"
  1469. libopus_decoder_deps="libopus"
  1470. libopus_encoder_deps="libopus"
  1471. libschroedinger_decoder_deps="libschroedinger"
  1472. libschroedinger_encoder_deps="libschroedinger"
  1473. libspeex_decoder_deps="libspeex"
  1474. libspeex_encoder_deps="libspeex"
  1475. libtheora_encoder_deps="libtheora"
  1476. libvo_aacenc_encoder_deps="libvo_aacenc"
  1477. libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
  1478. libvorbis_encoder_deps="libvorbis"
  1479. libvpx_decoder_deps="libvpx"
  1480. libvpx_encoder_deps="libvpx"
  1481. libx264_encoder_deps="libx264"
  1482. libxavs_encoder_deps="libxavs"
  1483. libxvid_encoder_deps="libxvid"
  1484. # demuxers / muxers
  1485. ac3_demuxer_select="ac3_parser"
  1486. asf_stream_muxer_select="asf_muxer"
  1487. avisynth_demuxer_deps="avisynth"
  1488. dirac_demuxer_select="dirac_parser"
  1489. eac3_demuxer_select="ac3_parser"
  1490. flac_demuxer_select="flac_parser"
  1491. ipod_muxer_select="mov_muxer"
  1492. matroska_audio_muxer_select="matroska_muxer"
  1493. matroska_demuxer_suggest="bzlib lzo zlib"
  1494. mov_demuxer_suggest="zlib"
  1495. mp3_demuxer_select="mpegaudio_parser"
  1496. mp4_muxer_select="mov_muxer"
  1497. mpegts_muxer_select="adts_muxer latm_muxer mpegvideo"
  1498. mpegtsraw_demuxer_select="mpegts_demuxer"
  1499. mxf_d10_muxer_select="mxf_muxer"
  1500. ogg_demuxer_select="golomb"
  1501. psp_muxer_select="mov_muxer"
  1502. rtp_demuxer_select="sdp_demuxer"
  1503. rtp_muxer_select="mpegvideo"
  1504. rtpdec_select="asf_demuxer rm_demuxer rtp_protocol mpegts_demuxer mov_demuxer"
  1505. rtsp_demuxer_select="http_protocol rtpdec"
  1506. rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol"
  1507. sap_demuxer_select="sdp_demuxer"
  1508. sap_muxer_select="rtp_muxer rtp_protocol"
  1509. sdp_demuxer_select="rtpdec"
  1510. smoothstreaming_muxer_select="ismv_muxer"
  1511. spdif_muxer_select="aac_parser"
  1512. tg2_muxer_select="mov_muxer"
  1513. tgp_muxer_select="mov_muxer"
  1514. w64_demuxer_deps="wav_demuxer"
  1515. # indevs / outdevs
  1516. alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
  1517. alsa_outdev_deps="alsa_asoundlib_h"
  1518. bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  1519. dv1394_indev_deps="dv1394 dv_demuxer"
  1520. fbdev_indev_deps="linux_fb_h"
  1521. jack_indev_deps="jack_jack_h"
  1522. libcdio_indev_deps="libcdio"
  1523. libdc1394_indev_deps="libdc1394"
  1524. oss_indev_deps_any="soundcard_h sys_soundcard_h"
  1525. oss_outdev_deps_any="soundcard_h sys_soundcard_h"
  1526. pulse_indev_deps="libpulse"
  1527. sndio_indev_deps="sndio_h"
  1528. sndio_outdev_deps="sndio_h"
  1529. v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
  1530. vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
  1531. vfwcap_indev_extralibs="-lavicap32"
  1532. x11grab_indev_deps="x11grab XShmCreateImage"
  1533. # protocols
  1534. ffrtmpcrypt_protocol_deps="!librtmp_protocol"
  1535. ffrtmpcrypt_protocol_deps_any="gcrypt nettle openssl"
  1536. ffrtmpcrypt_protocol_select="tcp_protocol"
  1537. ffrtmphttp_protocol_deps="!librtmp_protocol"
  1538. ffrtmphttp_protocol_select="http_protocol"
  1539. gopher_protocol_deps="network"
  1540. httpproxy_protocol_deps="network"
  1541. httpproxy_protocol_select="tcp_protocol"
  1542. http_protocol_deps="network"
  1543. http_protocol_select="tcp_protocol"
  1544. https_protocol_select="tls_protocol"
  1545. librtmp_protocol_deps="librtmp"
  1546. librtmpe_protocol_deps="librtmp"
  1547. librtmps_protocol_deps="librtmp"
  1548. librtmpt_protocol_deps="librtmp"
  1549. librtmpte_protocol_deps="librtmp"
  1550. mmsh_protocol_select="http_protocol"
  1551. mmst_protocol_deps="network"
  1552. rtmp_protocol_deps="!librtmp_protocol"
  1553. rtmp_protocol_select="tcp_protocol"
  1554. rtmpe_protocol_select="ffrtmpcrypt_protocol"
  1555. rtmps_protocol_deps="!librtmp_protocol"
  1556. rtmps_protocol_select="tls_protocol"
  1557. rtmpt_protocol_select="ffrtmphttp_protocol"
  1558. rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
  1559. rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
  1560. rtp_protocol_select="udp_protocol"
  1561. sctp_protocol_deps="network struct_sctp_event_subscribe"
  1562. tcp_protocol_deps="network"
  1563. tls_protocol_deps_any="openssl gnutls"
  1564. tls_protocol_select="tcp_protocol"
  1565. udp_protocol_deps="network"
  1566. # filters
  1567. blackframe_filter_deps="gpl"
  1568. boxblur_filter_deps="gpl"
  1569. cropdetect_filter_deps="gpl"
  1570. delogo_filter_deps="gpl"
  1571. drawtext_filter_deps="libfreetype"
  1572. frei0r_filter_deps="frei0r dlopen strtok_r"
  1573. frei0r_filter_extralibs='$ldl'
  1574. frei0r_src_filter_deps="frei0r dlopen strtok_r"
  1575. frei0r_src_filter_extralibs='$ldl'
  1576. hqdn3d_filter_deps="gpl"
  1577. resample_filter_deps="avresample"
  1578. ocv_filter_deps="libopencv"
  1579. scale_filter_deps="swscale"
  1580. yadif_filter_deps="gpl"
  1581. # libraries
  1582. avcodec_deps="avutil"
  1583. avdevice_deps="avutil avcodec avformat"
  1584. avfilter_deps="avutil"
  1585. avformat_deps="avutil avcodec"
  1586. avresample_deps="avutil"
  1587. swscale_deps="avutil"
  1588. # programs
  1589. avconv_deps="avcodec avfilter avformat avresample swscale"
  1590. avconv_select="aformat_filter asyncts_filter
  1591. format_filter fps_filter scale_filter setpts_filter"
  1592. avplay_deps="avcodec avformat swscale sdl"
  1593. avplay_select="rdft"
  1594. avprobe_deps="avcodec avformat"
  1595. avserver_deps="avformat ffm_muxer fork rtp_protocol rtsp_demuxer !shared"
  1596. avserver_extralibs='$ldl'
  1597. doc_deps="texi2html"
  1598. # default parameters
  1599. logfile="config.log"
  1600. # installation paths
  1601. prefix_default="/usr/local"
  1602. bindir_default='${prefix}/bin'
  1603. datadir_default='${prefix}/share/avconv'
  1604. incdir_default='${prefix}/include'
  1605. libdir_default='${prefix}/lib'
  1606. mandir_default='${prefix}/share/man'
  1607. shlibdir_default="$libdir_default"
  1608. # toolchain
  1609. ar_default="ar"
  1610. cc_default="gcc"
  1611. host_cc_default="gcc"
  1612. cp_f="cp -f"
  1613. ln_s="ln -sf"
  1614. nm_default="nm -g"
  1615. objformat="elf"
  1616. pkg_config_default=pkg-config
  1617. ranlib="ranlib"
  1618. yasmexe="yasm"
  1619. nogas=":"
  1620. # machine
  1621. arch_default=$(uname -m)
  1622. cpu="generic"
  1623. # OS
  1624. target_os_default=$(tolower $(uname -s))
  1625. host_os=$target_os_default
  1626. # configurable options
  1627. enable $LIBRARY_LIST $PROGRAM_LIST
  1628. enable asm
  1629. enable debug
  1630. enable doc
  1631. enable network
  1632. enable optimizations
  1633. enable safe_bitstream_reader
  1634. enable static
  1635. enable swscale_alpha
  1636. # build settings
  1637. SHFLAGS='-shared -Wl,-soname,$$(@F)'
  1638. AVSERVERLDFLAGS=-Wl,-E
  1639. LIBPREF="lib"
  1640. LIBSUF=".a"
  1641. FULLNAME='$(NAME)$(BUILDSUF)'
  1642. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  1643. SLIBPREF="lib"
  1644. SLIBSUF=".so"
  1645. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  1646. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  1647. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  1648. LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  1649. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
  1650. SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
  1651. asflags_filter=echo
  1652. cflags_filter=echo
  1653. ldflags_filter=echo
  1654. AS_C='-c'
  1655. AS_O='-o $@'
  1656. CC_C='-c'
  1657. CC_E='-E -o $@'
  1658. CC_O='-o $@'
  1659. LD_O='-o $@'
  1660. LD_LIB='-l%'
  1661. LD_PATH='-L'
  1662. HOSTCC_C='-c'
  1663. HOSTCC_O='-o $@'
  1664. HOSTLD_O='-o $@'
  1665. host_cflags='-D_ISOC99_SOURCE -D_XOPEN_SOURCE=600 -O3 -g'
  1666. host_libs='-lm'
  1667. host_cflags_filter=echo
  1668. host_ldflags_filter=echo
  1669. target_path='$(CURDIR)'
  1670. # since the object filename is not given with the -MM flag, the compiler
  1671. # is only able to print the basename, and we must add the path ourselves
  1672. DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
  1673. DEPFLAGS='-MM'
  1674. # find source path
  1675. if test -f configure; then
  1676. source_path=.
  1677. else
  1678. source_path=$(cd $(dirname "$0"); pwd)
  1679. echo "$source_path" | grep -q '[[:blank:]]' &&
  1680. die "Out of tree builds are impossible with whitespace in source path."
  1681. test -e "$source_path/config.h" &&
  1682. die "Out of tree builds are impossible with config.h in source dir."
  1683. fi
  1684. for v in "$@"; do
  1685. r=${v#*=}
  1686. l=${v%"$r"}
  1687. r=$(sh_quote "$r")
  1688. LIBAV_CONFIGURATION="${LIBAV_CONFIGURATION# } ${l}${r}"
  1689. done
  1690. find_things(){
  1691. thing=$1
  1692. pattern=$2
  1693. file=$source_path/$3
  1694. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  1695. }
  1696. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  1697. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  1698. HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
  1699. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  1700. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  1701. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  1702. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  1703. OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
  1704. INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
  1705. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  1706. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  1707. ALL_COMPONENTS="
  1708. $BSF_LIST
  1709. $DECODER_LIST
  1710. $DEMUXER_LIST
  1711. $ENCODER_LIST
  1712. $FILTER_LIST
  1713. $HWACCEL_LIST
  1714. $INDEV_LIST
  1715. $MUXER_LIST
  1716. $OUTDEV_LIST
  1717. $PARSER_LIST
  1718. $PROTOCOL_LIST
  1719. "
  1720. for n in $COMPONENT_LIST; do
  1721. v=$(toupper ${n%s})_LIST
  1722. eval enable \$$v
  1723. eval ${n}_if_any="\$$v"
  1724. done
  1725. disable snow_decoder snow_encoder
  1726. enable $ARCH_EXT_LIST
  1727. die_unknown(){
  1728. echo "Unknown option \"$1\"."
  1729. echo "See $0 --help for available options."
  1730. exit 1
  1731. }
  1732. show_list() {
  1733. suffix=_$1
  1734. shift
  1735. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
  1736. exit 0
  1737. }
  1738. rand_list(){
  1739. IFS=', '
  1740. set -- $*
  1741. unset IFS
  1742. for thing; do
  1743. comp=${thing%:*}
  1744. prob=${thing#$comp}
  1745. prob=${prob#:}
  1746. is_in ${comp} $COMPONENT_LIST && eval comp=\$$(toupper ${comp%s})_LIST
  1747. echo "prob ${prob:-0.5}"
  1748. printf '%s\n' $comp
  1749. done
  1750. }
  1751. do_random(){
  1752. action=$1
  1753. shift
  1754. random_seed=$(awk "BEGIN { srand($random_seed); print srand() }")
  1755. $action $(rand_list "$@" | awk "BEGIN { srand($random_seed) } \$1 == \"prob\" { prob = \$2; next } rand() < prob { print }")
  1756. }
  1757. for opt do
  1758. optval="${opt#*=}"
  1759. case "$opt" in
  1760. --extra-ldflags=*) add_ldflags $optval
  1761. ;;
  1762. --extra-libs=*) add_extralibs $optval
  1763. ;;
  1764. --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
  1765. ;;
  1766. --enable-debug=*) debuglevel="$optval"
  1767. ;;
  1768. --disable-programs)
  1769. disable $PROGRAM_LIST
  1770. ;;
  1771. --disable-everything)
  1772. map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
  1773. ;;
  1774. --enable-random|--disable-random)
  1775. action=${opt%%-random}
  1776. do_random ${action#--} $COMPONENT_LIST
  1777. ;;
  1778. --enable-random=*|--disable-random=*)
  1779. action=${opt%%-random=*}
  1780. do_random ${action#--} $optval
  1781. ;;
  1782. --enable-*=*|--disable-*=*)
  1783. eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
  1784. is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
  1785. eval list=\$$(toupper $thing)_LIST
  1786. name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
  1787. $action $(filter "$name" $list)
  1788. ;;
  1789. --enable-?*|--disable-?*)
  1790. eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
  1791. if is_in $option $COMPONENT_LIST; then
  1792. test $action = disable && action=unset
  1793. eval $action \$$(toupper ${option%s})_LIST
  1794. elif is_in $option $CMDLINE_SELECT; then
  1795. $action $option
  1796. else
  1797. die_unknown $opt
  1798. fi
  1799. ;;
  1800. --list-*)
  1801. NAME="${opt#--list-}"
  1802. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  1803. NAME=${NAME%s}
  1804. eval show_list $NAME \$$(toupper $NAME)_LIST
  1805. ;;
  1806. --help|-h) show_help
  1807. ;;
  1808. *)
  1809. optname="${opt%%=*}"
  1810. optname="${optname#--}"
  1811. optname=$(echo "$optname" | sed 's/-/_/g')
  1812. if is_in $optname $CMDLINE_SET; then
  1813. eval $optname='$optval'
  1814. elif is_in $optname $CMDLINE_APPEND; then
  1815. append $optname "$optval"
  1816. else
  1817. die_unknown $opt
  1818. fi
  1819. ;;
  1820. esac
  1821. done
  1822. disabled logging && logfile=/dev/null
  1823. echo "# $0 $LIBAV_CONFIGURATION" > $logfile
  1824. set >> $logfile
  1825. test -n "$cross_prefix" && enable cross_compile
  1826. if enabled cross_compile; then
  1827. test -n "$arch" && test -n "$target_os" ||
  1828. die "Must specify target arch and OS when cross-compiling"
  1829. fi
  1830. ar_default="${cross_prefix}${ar_default}"
  1831. cc_default="${cross_prefix}${cc_default}"
  1832. nm_default="${cross_prefix}${nm_default}"
  1833. pkg_config_default="${cross_prefix}${pkg_config_default}"
  1834. ranlib="${cross_prefix}${ranlib}"
  1835. sysinclude_default="${sysroot}/usr/include"
  1836. case "$toolchain" in
  1837. clang-asan)
  1838. cc_default="clang"
  1839. add_cflags -faddress-sanitizer
  1840. add_ldflags -faddress-sanitizer
  1841. ;;
  1842. clang-tsan)
  1843. cc_default="clang"
  1844. add_cflags -fthread-sanitizer
  1845. add_ldflags -fthread-sanitizer
  1846. ;;
  1847. msvc)
  1848. cc_default="c99wrap cl"
  1849. ld_default="c99wrap link"
  1850. nm_default="dumpbin -symbols"
  1851. ar_default="lib"
  1852. target_os_default="win32"
  1853. ;;
  1854. ?*)
  1855. die "Unknown toolchain $toolchain"
  1856. ;;
  1857. esac
  1858. set_default arch cc pkg_config sysinclude target_os
  1859. enabled cross_compile || host_cc_default=$cc
  1860. set_default host_cc
  1861. if ! $pkg_config --version >/dev/null 2>&1; then
  1862. warn "$pkg_config not found, library detection may fail."
  1863. pkg_config=false
  1864. fi
  1865. exesuf() {
  1866. case $1 in
  1867. mingw32*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
  1868. esac
  1869. }
  1870. EXESUF=$(exesuf $target_os)
  1871. HOSTEXESUF=$(exesuf $host_os)
  1872. # set temporary file name
  1873. : ${TMPDIR:=$TEMPDIR}
  1874. : ${TMPDIR:=$TMP}
  1875. : ${TMPDIR:=/tmp}
  1876. if ! check_cmd mktemp -u XXXXXX; then
  1877. # simple replacement for missing mktemp
  1878. # NOT SAFE FOR GENERAL USE
  1879. mktemp(){
  1880. echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
  1881. }
  1882. fi
  1883. tmpfile(){
  1884. tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
  1885. (set -C; exec > $tmp) 2>/dev/null ||
  1886. die "Unable to create temporary file in $TMPDIR."
  1887. append TMPFILES $tmp
  1888. eval $1=$tmp
  1889. }
  1890. trap 'rm -f -- $TMPFILES' EXIT
  1891. tmpfile TMPASM .asm
  1892. tmpfile TMPC .c
  1893. tmpfile TMPE $EXESUF
  1894. tmpfile TMPH .h
  1895. tmpfile TMPO .o
  1896. tmpfile TMPS .S
  1897. tmpfile TMPSH .sh
  1898. tmpfile TMPV .ver
  1899. unset -f mktemp
  1900. chmod +x $TMPE
  1901. # make sure we can execute files in $TMPDIR
  1902. cat > $TMPSH 2>> $logfile <<EOF
  1903. #! /bin/sh
  1904. EOF
  1905. chmod +x $TMPSH >> $logfile 2>&1
  1906. if ! $TMPSH >> $logfile 2>&1; then
  1907. cat <<EOF
  1908. Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
  1909. variable to another directory and make sure that it is not mounted noexec.
  1910. EOF
  1911. die "Sanity test failed."
  1912. fi
  1913. ccc_flags(){
  1914. for flag; do
  1915. case $flag in
  1916. -std=c99) echo -c99 ;;
  1917. -mcpu=*) echo -arch ${flag#*=} ;;
  1918. -mieee) echo -ieee ;;
  1919. -O*|-fast) echo $flag ;;
  1920. -fno-math-errno) echo -assume nomath_errno ;;
  1921. -g) echo -g3 ;;
  1922. -Wall) echo -msg_enable level2 ;;
  1923. -Wno-pointer-sign) echo -msg_disable ptrmismatch1 ;;
  1924. -Wl,*) echo $flag ;;
  1925. -f*|-W*) ;;
  1926. *) echo $flag ;;
  1927. esac
  1928. done
  1929. }
  1930. msvc_flags(){
  1931. for flag; do
  1932. case $flag in
  1933. -fomit-frame-pointer) echo -Oy ;;
  1934. -g) echo -Z7 ;;
  1935. -Wall) echo -W4 -wd4244 -wd4127 -wd4018 -wd4389 \
  1936. -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
  1937. -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
  1938. -wd4996 -wd4273 ;;
  1939. -std=c99) ;;
  1940. -fno-math-errno) ;;
  1941. -fno-common) ;;
  1942. -fno-signed-zeros) ;;
  1943. -lz) echo zlib.lib ;;
  1944. -lavifil32) echo vfw32.lib ;;
  1945. -lavicap32) echo vfw32.lib user32.lib ;;
  1946. -l*) echo ${flag#-l}.lib ;;
  1947. *) echo $flag ;;
  1948. esac
  1949. done
  1950. }
  1951. pgi_flags(){
  1952. for flag; do
  1953. case $flag in
  1954. -flto) echo -Mipa=fast,libopt,libinline,vestigial ;;
  1955. -fomit-frame-pointer) echo -Mnoframe ;;
  1956. -g) echo -gopt ;;
  1957. *) echo $flag ;;
  1958. esac
  1959. done
  1960. }
  1961. suncc_flags(){
  1962. for flag; do
  1963. case $flag in
  1964. -march=*|-mcpu=*)
  1965. case "${flag#*=}" in
  1966. native) echo -xtarget=native ;;
  1967. v9|niagara) echo -xarch=sparc ;;
  1968. ultrasparc) echo -xarch=sparcvis ;;
  1969. ultrasparc3|niagara2) echo -xarch=sparcvis2 ;;
  1970. i586|pentium) echo -xchip=pentium ;;
  1971. i686|pentiumpro|pentium2) echo -xtarget=pentium_pro ;;
  1972. pentium3*|c3-2) echo -xtarget=pentium3 ;;
  1973. pentium-m) echo -xarch=sse2 -xchip=pentium3 ;;
  1974. pentium4*) echo -xtarget=pentium4 ;;
  1975. prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;;
  1976. *-sse3) echo -xarch=sse3 ;;
  1977. core2) echo -xarch=ssse3 -xchip=core2 ;;
  1978. corei7) echo -xarch=sse4_2 -xchip=nehalem ;;
  1979. corei7-avx) echo -xarch=avx -xchip=sandybridge ;;
  1980. amdfam10|barcelona|bdver*) echo -xarch=sse4_1 ;;
  1981. athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
  1982. k8|opteron|athlon64|athlon-fx)
  1983. echo -xarch=sse2a ;;
  1984. athlon*) echo -xarch=pentium_proa ;;
  1985. esac
  1986. ;;
  1987. -std=c99) echo -xc99 ;;
  1988. -fomit-frame-pointer) echo -xregs=frameptr ;;
  1989. -fPIC) echo -KPIC -xcode=pic32 ;;
  1990. -W*,*) echo $flag ;;
  1991. -f*-*|-W*) ;;
  1992. *) echo $flag ;;
  1993. esac
  1994. done
  1995. }
  1996. tms470_flags(){
  1997. for flag; do
  1998. case $flag in
  1999. -march=*|-mcpu=*)
  2000. case "${flag#*=}" in
  2001. armv7-a|cortex-a*) echo -mv=7a8 ;;
  2002. armv7-r|cortex-r*) echo -mv=7r4 ;;
  2003. armv7-m|cortex-m*) echo -mv=7m3 ;;
  2004. armv6*|arm11*) echo -mv=6 ;;
  2005. armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
  2006. echo -mv=5e ;;
  2007. armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
  2008. esac
  2009. ;;
  2010. -mfpu=neon) echo --float_support=vfpv3 --neon ;;
  2011. -mfpu=vfp) echo --float_support=vfpv2 ;;
  2012. -mfpu=vfpv3) echo --float_support=vfpv3 ;;
  2013. -mfpu=vfpv3-d16) echo --float_support=vfpv3d16 ;;
  2014. -msoft-float) echo --float_support=vfplib ;;
  2015. -O[0-3]|-mf=*) echo $flag ;;
  2016. -g) echo -g -mn ;;
  2017. -pds=*) echo $flag ;;
  2018. -D*|-I*) echo $flag ;;
  2019. --gcc|--abi=*) echo $flag ;;
  2020. -me) echo $flag ;;
  2021. esac
  2022. done
  2023. }
  2024. probe_cc(){
  2025. pfx=$1
  2026. _cc=$2
  2027. unset _type _ident _cc_c _cc_e _cc_o _flags _cflags
  2028. unset _ld_o _ldflags _ld_lib _ld_path
  2029. unset _depflags _DEPCMD _DEPFLAGS
  2030. _flags_filter=echo
  2031. if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
  2032. _type=llvm_gcc
  2033. gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)')
  2034. _ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver"
  2035. _depflags='-MMD -MF $(@:.o=.d) -MT $@'
  2036. _cflags_speed='-O3'
  2037. _cflags_size='-Os'
  2038. elif $_cc -v 2>&1 | grep -qi ^gcc; then
  2039. _type=gcc
  2040. gcc_version=$($_cc --version | head -n1)
  2041. gcc_basever=$($_cc -dumpversion)
  2042. gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
  2043. gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
  2044. _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
  2045. if ! $_cc -dumpversion | grep -q '^2\.'; then
  2046. _depflags='-MMD -MF $(@:.o=.d) -MT $@'
  2047. fi
  2048. _cflags_speed='-O3'
  2049. _cflags_size='-Os'
  2050. elif $_cc --version 2>/dev/null | grep -q Intel; then
  2051. _type=icc
  2052. _ident=$($_cc --version | head -n1)
  2053. _depflags='-MMD'
  2054. _cflags_speed='-O3'
  2055. _cflags_size='-Os'
  2056. _cflags_noopt='-O1'
  2057. elif $_cc -v 2>&1 | grep -q xlc; then
  2058. _type=xlc
  2059. _ident=$($_cc -qversion 2>/dev/null | head -n1)
  2060. _cflags_speed='-O5'
  2061. _cflags_size='-O5 -qcompact'
  2062. elif $_cc -V 2>/dev/null | grep -q Compaq; then
  2063. _type=ccc
  2064. _ident=$($_cc -V | head -n1 | cut -d' ' -f1-3)
  2065. _DEPFLAGS='-M'
  2066. _cflags_speed='-fast'
  2067. _cflags_size='-O1'
  2068. _flags_filter=ccc_flags
  2069. elif $_cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
  2070. test -d "$sysroot" || die "No valid sysroot specified."
  2071. _type=armcc
  2072. _ident=$($_cc --vsn | head -n1)
  2073. armcc_conf="$PWD/armcc.conf"
  2074. $_cc --arm_linux_configure \
  2075. --arm_linux_config_file="$armcc_conf" \
  2076. --configure_sysroot="$sysroot" \
  2077. --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
  2078. die "Error creating armcc configuration file."
  2079. $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
  2080. _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
  2081. as_default="${cross_prefix}gcc"
  2082. _depflags='-MMD'
  2083. _cflags_speed='-O3'
  2084. _cflags_size='-Os'
  2085. elif $_cc -version 2>/dev/null | grep -Eq 'TMS470|TI ARM'; then
  2086. _type=tms470
  2087. _ident=$($_cc -version | head -n1 | tr -s ' ')
  2088. _flags='--gcc --abi=eabi -me'
  2089. _cc_e='-ppl -fe=$@'
  2090. _cc_o='-fe=$@'
  2091. _depflags='-ppa -ppd=$(@:.o=.d)'
  2092. _cflags_speed='-O3 -mf=5'
  2093. _cflags_size='-O3 -mf=2'
  2094. _flags_filter=tms470_flags
  2095. elif $_cc -v 2>&1 | grep -q clang; then
  2096. _type=clang
  2097. _ident=$($_cc --version | head -n1)
  2098. _depflags='-MMD'
  2099. _cflags_speed='-O3'
  2100. _cflags_size='-Os'
  2101. elif $_cc -V 2>&1 | grep -q Sun; then
  2102. _type=suncc
  2103. _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
  2104. _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
  2105. _DEPFLAGS='-xM1 -xc99'
  2106. _ldflags='-std=c99'
  2107. _cflags_speed='-O5'
  2108. _cflags_size='-O5 -xspace'
  2109. _flags_filter=suncc_flags
  2110. elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
  2111. _type=pathscale
  2112. _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
  2113. _depflags='-MMD -MF $(@:.o=.d) -MT $@'
  2114. _cflags_speed='-O2'
  2115. _cflags_size='-Os'
  2116. _flags_filter='filter_out -Wdisabled-optimization'
  2117. elif $_cc -v 2>&1 | grep -q Open64; then
  2118. _type=open64
  2119. _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
  2120. _depflags='-MMD -MF $(@:.o=.d) -MT $@'
  2121. _cflags_speed='-O2'
  2122. _cflags_size='-Os'
  2123. _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
  2124. elif $_cc -V 2>&1 | grep -q Portland; then
  2125. _type=pgi
  2126. _ident="PGI $($_cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')"
  2127. opt_common='-alias=ansi -Mdse -Mlre -Mpre'
  2128. _cflags_speed="-O3 -Mautoinline -Munroll=c:4 $opt_common"
  2129. _cflags_size="-O2 -Munroll=c:1 $opt_common"
  2130. _cflags_noopt="-O1"
  2131. _flags_filter=pgi_flags
  2132. elif $_cc 2>&1 | grep -q Microsoft; then
  2133. _type=msvc
  2134. _ident=$($cc 2>&1 | head -n1)
  2135. _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
  2136. _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
  2137. _cflags_speed="-O2"
  2138. _cflags_size="-O1"
  2139. # Nonstandard output options, to avoid msys path conversion issues, relies on wrapper to remap it
  2140. if $_cc 2>&1 | grep -q Linker; then
  2141. _ld_o='-out $@'
  2142. else
  2143. _ld_o='-Fe$@'
  2144. fi
  2145. _cc_o='-Fo $@'
  2146. _cc_e='-P -Fi $@'
  2147. _flags_filter=msvc_flags
  2148. _ld_lib='lib%.a'
  2149. _ld_path='-libpath:'
  2150. _flags='-nologo'
  2151. _cflags='-D_USE_MATH_DEFINES -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64'
  2152. if [ $pfx = hostcc ]; then
  2153. append _cflags -Dsnprintf=_snprintf
  2154. fi
  2155. fi
  2156. eval ${pfx}_type=\$_type
  2157. eval ${pfx}_ident=\$_ident
  2158. }
  2159. set_ccvars(){
  2160. eval ${1}_C=\${_cc_c-\${${1}_C}}
  2161. eval ${1}_E=\${_cc_e-\${${1}_E}}
  2162. eval ${1}_O=\${_cc_o-\${${1}_O}}
  2163. if [ -n "$_depflags" ]; then
  2164. eval ${1}_DEPFLAGS=\$_depflags
  2165. else
  2166. eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
  2167. eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
  2168. eval DEP${1}FLAGS=\$_flags
  2169. fi
  2170. }
  2171. probe_cc cc "$cc"
  2172. cflags_filter=$_flags_filter
  2173. cflags_speed=$_cflags_speed
  2174. cflags_size=$_cflags_size
  2175. cflags_noopt=$_cflags_noopt
  2176. add_cflags $_flags $_cflags
  2177. cc_ldflags=$_ldflags
  2178. set_ccvars CC
  2179. probe_cc hostcc "$host_cc"
  2180. host_cflags_filter=$_flags_filter
  2181. add_host_cflags $_flags $_cflags
  2182. set_ccvars HOSTCC
  2183. test -n "$cc_type" && enable $cc_type ||
  2184. warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
  2185. : ${as_default:=$cc}
  2186. : ${dep_cc_default:=$cc}
  2187. : ${ld_default:=$cc}
  2188. : ${host_ld_default:=$host_cc}
  2189. set_default ar as dep_cc ld host_ld
  2190. probe_cc as "$as"
  2191. asflags_filter=$_flags_filter
  2192. add_asflags $_flags $_cflags
  2193. set_ccvars AS
  2194. probe_cc ld "$ld"
  2195. ldflags_filter=$_flags_filter
  2196. add_ldflags $_flags $_ldflags
  2197. test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
  2198. LD_O=${_ld_o-$LD_O}
  2199. LD_LIB=${_ld_lib-$LD_LIB}
  2200. LD_PATH=${_ld_path-$LD_PATH}
  2201. probe_cc hostld "$host_ld"
  2202. host_ldflags_filter=$_flags_filter
  2203. add_host_ldflags $_flags $_ldflags
  2204. HOSTLD_O=${_ld_o-$HOSTLD_O}
  2205. if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
  2206. probe_cc depcc "$dep_cc"
  2207. CCDEP=${_DEPCMD:-$DEPCMD}
  2208. CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
  2209. DEPCCFLAGS=$_flags
  2210. fi
  2211. if $ar 2>&1 | grep -q Microsoft; then
  2212. arflags="-nologo"
  2213. ar_o='-out:$@'
  2214. elif $ar 2>&1 | grep -q 'Texas Instruments'; then
  2215. arflags="rq"
  2216. ar_o='$@'
  2217. else
  2218. arflags="rc"
  2219. ar_o='$@'
  2220. fi
  2221. add_cflags $extra_cflags
  2222. add_asflags $extra_cflags
  2223. if test -n "$sysroot"; then
  2224. case "$cc_type" in
  2225. gcc|llvm_gcc|clang)
  2226. add_cppflags --sysroot="$sysroot"
  2227. add_ldflags --sysroot="$sysroot"
  2228. ;;
  2229. tms470)
  2230. add_cppflags -I"$sysinclude"
  2231. add_ldflags --sysroot="$sysroot"
  2232. ;;
  2233. esac
  2234. fi
  2235. if test "$cpu" = host; then
  2236. enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
  2237. case "$cc_type" in
  2238. gcc|llvm_gcc)
  2239. check_native(){
  2240. $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
  2241. sed -n "/cc1.*$1=/{
  2242. s/.*$1=\\([^ ]*\\).*/\\1/
  2243. p
  2244. q
  2245. }" $TMPE
  2246. }
  2247. cpu=$(check_native -march || check_native -mcpu)
  2248. ;;
  2249. esac
  2250. test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
  2251. fi
  2252. # Deal with common $arch aliases
  2253. case "$arch" in
  2254. aarch64|arm64)
  2255. arch="aarch64"
  2256. ;;
  2257. arm*)
  2258. arch="arm"
  2259. ;;
  2260. mips*|IP*)
  2261. arch="mips"
  2262. ;;
  2263. parisc*|hppa*)
  2264. arch="parisc"
  2265. ;;
  2266. "Power Macintosh"|ppc*|powerpc*)
  2267. arch="ppc"
  2268. ;;
  2269. s390|s390x)
  2270. arch="s390"
  2271. ;;
  2272. sh4|sh)
  2273. arch="sh4"
  2274. ;;
  2275. sun4u|sparc*)
  2276. arch="sparc"
  2277. ;;
  2278. tilegx|tile-gx)
  2279. arch="tilegx"
  2280. ;;
  2281. i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64)
  2282. arch="x86"
  2283. ;;
  2284. esac
  2285. is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
  2286. enable $arch
  2287. # Add processor-specific flags
  2288. if test "$cpu" = generic; then
  2289. : do nothing
  2290. elif enabled aarch64; then
  2291. case $cpu in
  2292. armv*)
  2293. cpuflags="-march=$cpu"
  2294. ;;
  2295. *)
  2296. cpuflags="-mcpu=$cpu"
  2297. ;;
  2298. esac
  2299. elif enabled alpha; then
  2300. cpuflags="-mcpu=$cpu"
  2301. elif enabled arm; then
  2302. case $cpu in
  2303. armv*)
  2304. cpuflags="-march=$cpu"
  2305. subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
  2306. ;;
  2307. *)
  2308. cpuflags="-mcpu=$cpu"
  2309. case $cpu in
  2310. cortex-a*) subarch=armv7a ;;
  2311. cortex-r*) subarch=armv7r ;;
  2312. cortex-m*) enable thumb; subarch=armv7m ;;
  2313. arm11*) subarch=armv6 ;;
  2314. arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
  2315. armv4*|arm7*|arm9[24]*) subarch=armv4 ;;
  2316. esac
  2317. ;;
  2318. esac
  2319. elif enabled avr32; then
  2320. case $cpu in
  2321. ap7[02]0[0-2])
  2322. subarch="avr32_ap"
  2323. cpuflags="-mpart=$cpu"
  2324. ;;
  2325. ap)
  2326. subarch="avr32_ap"
  2327. cpuflags="-march=$cpu"
  2328. ;;
  2329. uc3[ab]*)
  2330. subarch="avr32_uc"
  2331. cpuflags="-mcpu=$cpu"
  2332. ;;
  2333. uc)
  2334. subarch="avr32_uc"
  2335. cpuflags="-march=$cpu"
  2336. ;;
  2337. esac
  2338. elif enabled bfin; then
  2339. cpuflags="-mcpu=$cpu"
  2340. elif enabled mips; then
  2341. cpuflags="-march=$cpu"
  2342. elif enabled ppc; then
  2343. case $(tolower $cpu) in
  2344. 601|ppc601|powerpc601)
  2345. cpuflags="-mcpu=601"
  2346. disable altivec
  2347. ;;
  2348. 603*|ppc603*|powerpc603*)
  2349. cpuflags="-mcpu=603"
  2350. disable altivec
  2351. ;;
  2352. 604*|ppc604*|powerpc604*)
  2353. cpuflags="-mcpu=604"
  2354. disable altivec
  2355. ;;
  2356. g3|75*|ppc75*|powerpc75*)
  2357. cpuflags="-mcpu=750"
  2358. disable altivec
  2359. ;;
  2360. g4|745*|ppc745*|powerpc745*)
  2361. cpuflags="-mcpu=7450"
  2362. ;;
  2363. 74*|ppc74*|powerpc74*)
  2364. cpuflags="-mcpu=7400"
  2365. ;;
  2366. g5|970|ppc970|powerpc970)
  2367. cpuflags="-mcpu=970"
  2368. ;;
  2369. power[3-7]*)
  2370. cpuflags="-mcpu=$cpu"
  2371. ;;
  2372. cell)
  2373. cpuflags="-mcpu=cell"
  2374. enable ldbrx
  2375. ;;
  2376. e500mc)
  2377. cpuflags="-mcpu=e500mc"
  2378. disable altivec
  2379. ;;
  2380. e500v2)
  2381. cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
  2382. disable altivec
  2383. ;;
  2384. e500)
  2385. cpuflags="-mcpu=8540 -mhard-float"
  2386. disable altivec
  2387. ;;
  2388. esac
  2389. elif enabled sparc; then
  2390. case $cpu in
  2391. cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
  2392. cpuflags="-mcpu=$cpu"
  2393. disable vis
  2394. ;;
  2395. ultrasparc*|niagara[234])
  2396. cpuflags="-mcpu=$cpu"
  2397. ;;
  2398. esac
  2399. elif enabled x86; then
  2400. case $cpu in
  2401. i[345]86|pentium)
  2402. cpuflags="-march=$cpu"
  2403. disable mmx
  2404. ;;
  2405. # targets that do NOT support conditional mov (cmov)
  2406. pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  2407. cpuflags="-march=$cpu"
  2408. disable cmov
  2409. ;;
  2410. # targets that do support conditional mov (cmov)
  2411. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|corei7*|amdfam10|barcelona|atom|bdver*)
  2412. cpuflags="-march=$cpu"
  2413. enable cmov
  2414. enable fast_cmov
  2415. ;;
  2416. # targets that do support conditional mov but on which it's slow
  2417. pentium4|pentium4m|prescott|nocona)
  2418. cpuflags="-march=$cpu"
  2419. enable cmov
  2420. disable fast_cmov
  2421. ;;
  2422. esac
  2423. fi
  2424. add_cflags $cpuflags
  2425. add_asflags $cpuflags
  2426. # compiler sanity check
  2427. check_exec <<EOF
  2428. int main(void){ return 0; }
  2429. EOF
  2430. if test "$?" != 0; then
  2431. echo "$cc is unable to create an executable file."
  2432. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  2433. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  2434. echo "Only do this if you know what cross compiling means."
  2435. fi
  2436. die "C compiler test failed."
  2437. fi
  2438. add_cppflags -D_ISOC99_SOURCE
  2439. check_cflags -std=c99
  2440. check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
  2441. #include <stdlib.h>
  2442. EOF
  2443. check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
  2444. #include <stdlib.h>
  2445. EOF
  2446. check_host_cflags -std=c99
  2447. check_host_cflags -Wall
  2448. check_64bit(){
  2449. arch32=$1
  2450. arch64=$2
  2451. expr=$3
  2452. check_code cc "" "int test[2*($expr) - 1]" &&
  2453. subarch=$arch64 || subarch=$arch32
  2454. }
  2455. case "$arch" in
  2456. alpha|ia64)
  2457. spic=$shared
  2458. ;;
  2459. mips)
  2460. check_64bit mips mips64 '_MIPS_SIM > 1'
  2461. spic=$shared
  2462. ;;
  2463. parisc)
  2464. check_64bit parisc parisc64 'sizeof(void *) > 4'
  2465. spic=$shared
  2466. ;;
  2467. ppc)
  2468. check_64bit ppc ppc64 'sizeof(void *) > 4'
  2469. ;;
  2470. sparc)
  2471. check_64bit sparc sparc64 'sizeof(void *) > 4'
  2472. spic=$shared
  2473. ;;
  2474. x86)
  2475. check_64bit x86_32 x86_64 'sizeof(void *) > 4'
  2476. if test "$subarch" = "x86_64"; then
  2477. spic=$shared
  2478. fi
  2479. ;;
  2480. esac
  2481. enable $subarch
  2482. enabled spic && enable pic
  2483. # OS specific
  2484. case $target_os in
  2485. haiku)
  2486. prefix_default="/boot/common"
  2487. network_extralibs="-lnetwork"
  2488. host_libs=
  2489. ;;
  2490. sunos)
  2491. AVSERVERLDFLAGS=""
  2492. SHFLAGS='-shared -Wl,-h,$$(@F)'
  2493. enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
  2494. network_extralibs="-lsocket -lnsl"
  2495. add_cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
  2496. # When using suncc to build, the Solaris linker will mark
  2497. # an executable with each instruction set encountered by
  2498. # the Solaris assembler. As our libraries contain their own
  2499. # guards for processor-specific code, instead suppress
  2500. # generation of the HWCAPS ELF section on Solaris x86 only.
  2501. enabled_all suncc x86 && echo "hwcap_1 = OVERRIDE;" > mapfile && add_ldflags -Wl,-M,mapfile
  2502. nm_default='nm -P -g'
  2503. ;;
  2504. netbsd)
  2505. disable symver
  2506. oss_indev_extralibs="-lossaudio"
  2507. oss_outdev_extralibs="-lossaudio"
  2508. ;;
  2509. openbsd|bitrig)
  2510. # On OpenBSD 4.5. the compiler does not use PIC unless
  2511. # explicitly using -fPIC. Libav builds fine without PIC,
  2512. # however the generated executable will not do anything
  2513. # (simply quits with exit-code 1, no crash, no output).
  2514. # Thus explicitly enable PIC here.
  2515. enable pic
  2516. disable symver
  2517. SHFLAGS='-shared'
  2518. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBVERSION)'
  2519. SLIB_INSTALL_LINKS=
  2520. oss_indev_extralibs="-lossaudio"
  2521. oss_outdev_extralibs="-lossaudio"
  2522. ;;
  2523. dragonfly)
  2524. disable symver
  2525. ;;
  2526. freebsd)
  2527. ;;
  2528. bsd/os)
  2529. add_extralibs -lpoll -lgnugetopt
  2530. ;;
  2531. darwin)
  2532. gas="gas-preprocessor.pl $cc"
  2533. enabled ppc && add_asflags -force_cpusubtype_ALL
  2534. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
  2535. enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
  2536. add_ldflags -Wl,-dynamic,-search_paths_first
  2537. SLIBSUF=".dylib"
  2538. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  2539. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  2540. AVSERVERLDFLAGS=-Wl,-bind_at_load
  2541. objformat="macho"
  2542. enabled x86_64 && objformat="macho64"
  2543. enabled_any pic shared ||
  2544. { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
  2545. ;;
  2546. mingw32*)
  2547. if test $target_os = "mingw32ce"; then
  2548. disable network
  2549. else
  2550. target_os=mingw32
  2551. fi
  2552. LIBTARGET=i386
  2553. if enabled x86_64; then
  2554. LIBTARGET="i386:x86-64"
  2555. elif enabled arm; then
  2556. LIBTARGET=arm-wince
  2557. fi
  2558. shlibdir_default="$bindir_default"
  2559. SLIBPREF=""
  2560. SLIBSUF=".dll"
  2561. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2562. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2563. SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
  2564. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
  2565. SLIB_INSTALL_LINKS=
  2566. SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
  2567. SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
  2568. 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'
  2569. objformat="win32"
  2570. dlltool="${cross_prefix}dlltool"
  2571. ranlib=:
  2572. enable dos_paths
  2573. add_cppflags -U__STRICT_ANSI__
  2574. ;;
  2575. win32|win64)
  2576. if enabled shared; then
  2577. # Link to the import library instead of the normal static library
  2578. # for shared libs.
  2579. LD_LIB='%.lib'
  2580. # Cannot build shared and static libraries at the same time with
  2581. # MSVC.
  2582. disable static
  2583. fi
  2584. shlibdir_default="$bindir_default"
  2585. SLIBPREF=""
  2586. SLIBSUF=".dll"
  2587. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2588. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2589. SLIB_CREATE_DEF_CMD='makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
  2590. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
  2591. SLIB_INSTALL_LINKS=
  2592. SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
  2593. SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
  2594. SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
  2595. objformat="win32"
  2596. ranlib=:
  2597. enable dos_paths
  2598. ;;
  2599. cygwin*)
  2600. target_os=cygwin
  2601. shlibdir_default="$bindir_default"
  2602. SLIBPREF="cyg"
  2603. SLIBSUF=".dll"
  2604. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2605. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2606. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
  2607. SLIB_INSTALL_LINKS=
  2608. SLIB_INSTALL_EXTRA_LIB='lib$(FULLNAME).dll.a'
  2609. SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a'
  2610. objformat="win32"
  2611. enable dos_paths
  2612. ;;
  2613. *-dos|freedos|opendos)
  2614. network_extralibs="-lsocket"
  2615. objformat="coff"
  2616. enable dos_paths
  2617. add_cppflags -U__STRICT_ANSI__
  2618. ;;
  2619. linux)
  2620. enable dv1394
  2621. ;;
  2622. irix*)
  2623. target_os=irix
  2624. ranlib="echo ignoring ranlib"
  2625. ;;
  2626. os/2*)
  2627. ln_s="cp -f"
  2628. objformat="aout"
  2629. add_cppflags -D_GNU_SOURCE
  2630. add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
  2631. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  2632. AVSERVERLDFLAGS=""
  2633. LIBSUF="_s.a"
  2634. SLIBPREF=""
  2635. SLIBSUF=".dll"
  2636. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  2637. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  2638. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  2639. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  2640. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  2641. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  2642. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  2643. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  2644. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  2645. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  2646. SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
  2647. enable dos_paths
  2648. ;;
  2649. gnu/kfreebsd)
  2650. add_cppflags -D_BSD_SOURCE
  2651. ;;
  2652. gnu)
  2653. ;;
  2654. qnx)
  2655. add_cppflags -D_QNX_SOURCE
  2656. network_extralibs="-lsocket"
  2657. ;;
  2658. symbian)
  2659. SLIBSUF=".dll"
  2660. enable dos_paths
  2661. add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
  2662. add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
  2663. add_ldflags -Wl,--target1-abs,--no-undefined \
  2664. -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
  2665. -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
  2666. add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
  2667. -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
  2668. -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
  2669. ;;
  2670. osf1)
  2671. add_cppflags -D_OSF_SOURCE -D_POSIX_PII -D_REENTRANT
  2672. AVSERVERLDFLAGS=
  2673. ;;
  2674. minix)
  2675. ;;
  2676. plan9)
  2677. add_cppflags -D_C99_SNPRINTF_EXTENSION \
  2678. -D_REENTRANT_SOURCE \
  2679. -D_RESEARCH_SOURCE \
  2680. -DFD_SETSIZE=96 \
  2681. -DHAVE_SOCK_OPTS
  2682. add_compat strtod.o strtod=avpriv_strtod
  2683. network_extralibs='-lbsd'
  2684. exeobjs=compat/plan9/main.o
  2685. disable avserver
  2686. ln_s='ln -s -f'
  2687. cp_f='cp'
  2688. ;;
  2689. none)
  2690. ;;
  2691. *)
  2692. die "Unknown OS '$target_os'."
  2693. ;;
  2694. esac
  2695. # determine libc flavour
  2696. if check_cpp_condition features.h "defined __UCLIBC__"; then
  2697. libc_type=uclibc
  2698. add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
  2699. elif check_cpp_condition features.h "defined __GLIBC__"; then
  2700. libc_type=glibc
  2701. add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
  2702. elif check_header _mingw.h; then
  2703. libc_type=mingw
  2704. check_cpp_condition _mingw.h \
  2705. "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) || \
  2706. (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
  2707. die "ERROR: MinGW runtime version must be >= 3.15."
  2708. elif check_cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
  2709. libc_type=newlib
  2710. add_cppflags -U__STRICT_ANSI__
  2711. elif check_func_headers stdlib.h _get_doserrno; then
  2712. libc_type=msvcrt
  2713. add_compat strtod.o strtod=avpriv_strtod
  2714. add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf \
  2715. _snprintf=avpriv_snprintf \
  2716. vsnprintf=avpriv_vsnprintf
  2717. elif check_cpp_condition stddef.h "defined __KLIBC__"; then
  2718. libc_type=klibc
  2719. fi
  2720. test -n "$libc_type" && enable $libc_type
  2721. # hacks for compiler/libc/os combinations
  2722. if enabled_all tms470 glibc; then
  2723. CPPFLAGS="-I${source_path}/compat/tms470 ${CPPFLAGS}"
  2724. add_cppflags -D__USER_LABEL_PREFIX__=
  2725. add_cppflags -D__builtin_memset=memset
  2726. add_cppflags -D__gnuc_va_list=va_list -D_VA_LIST_DEFINED
  2727. add_cflags -pds=48 # incompatible redefinition of macro
  2728. fi
  2729. if enabled_all ccc glibc; then
  2730. add_ldflags -Wl,-z,now # calls to libots crash without this
  2731. fi
  2732. esc(){
  2733. echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
  2734. }
  2735. echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $LIBAV_CONFIGURATION)" >config.fate
  2736. check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
  2737. set_default $PATHS_LIST
  2738. set_default nm
  2739. # we need to build at least one lib type
  2740. if ! enabled_any static shared; then
  2741. cat <<EOF
  2742. At least one library type must be built.
  2743. Specify --enable-static to build the static libraries or --enable-shared to
  2744. build the shared libraries as well. To only build the shared libraries specify
  2745. --disable-static in addition to --enable-shared.
  2746. EOF
  2747. exit 1;
  2748. fi
  2749. die_license_disabled() {
  2750. enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
  2751. }
  2752. die_license_disabled gpl libcdio
  2753. die_license_disabled gpl libx264
  2754. die_license_disabled gpl libxavs
  2755. die_license_disabled gpl libxvid
  2756. die_license_disabled gpl x11grab
  2757. die_license_disabled nonfree libfaac
  2758. die_license_disabled nonfree libfdk_aac
  2759. die_license_disabled nonfree openssl
  2760. die_license_disabled version3 libopencore_amrnb
  2761. die_license_disabled version3 libopencore_amrwb
  2762. die_license_disabled version3 libvo_aacenc
  2763. die_license_disabled version3 libvo_amrwbenc
  2764. enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
  2765. disabled optimizations || check_cflags -fomit-frame-pointer
  2766. enable_pic() {
  2767. enable pic
  2768. add_cppflags -DPIC
  2769. add_cflags -fPIC
  2770. add_asflags -fPIC
  2771. }
  2772. enabled pic && enable_pic
  2773. check_cc <<EOF || die "Symbol mangling check failed."
  2774. int ff_extern;
  2775. EOF
  2776. sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
  2777. extern_prefix=${sym%%ff_extern*}
  2778. check_cc <<EOF && enable_weak inline_asm
  2779. void foo(void) { __asm__ volatile ("" ::); }
  2780. EOF
  2781. _restrict=
  2782. for restrict_keyword in restrict __restrict__ __restrict; do
  2783. check_cc <<EOF && _restrict=$restrict_keyword && break
  2784. void foo(char * $restrict_keyword p);
  2785. EOF
  2786. done
  2787. check_cc <<EOF && enable attribute_packed
  2788. struct { int x; } __attribute__((packed)) x;
  2789. EOF
  2790. check_cc <<EOF && enable attribute_may_alias
  2791. union { int x; } __attribute__((may_alias)) x;
  2792. EOF
  2793. check_cc <<EOF || die "endian test failed"
  2794. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  2795. EOF
  2796. od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  2797. if enabled alpha; then
  2798. check_cflags -mieee
  2799. elif enabled arm; then
  2800. enabled thumb && check_cflags -mthumb || check_cflags -marm
  2801. nogas=die
  2802. if check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
  2803. enable vfp_args
  2804. elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then
  2805. case "${cross_prefix:-$cc}" in
  2806. *hardfloat*) enable vfp_args; fpabi=vfp ;;
  2807. *) check_ld <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
  2808. __asm__ (".eabi_attribute 28, 1");
  2809. int main(void) { return 0; }
  2810. EOF
  2811. esac
  2812. warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
  2813. fi
  2814. enabled armv5te && check_inline_asm armv5te '"qadd r0, r0, r0"'
  2815. enabled armv6 && check_inline_asm armv6 '"sadd16 r0, r0, r0"'
  2816. enabled armv6t2 && check_inline_asm armv6t2 '"movt r0, #0"'
  2817. enabled armvfp && check_inline_asm armvfp '"fadds s0, s0, s0"'
  2818. enabled neon && check_inline_asm neon '"vadd.i16 q0, q0, q0"'
  2819. enabled vfpv3 && check_inline_asm vfpv3 '"vmov.f32 s0, #1.0"'
  2820. check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
  2821. check_inline_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)'
  2822. enabled_all armv6t2 shared !pic && enable_pic
  2823. elif enabled mips; then
  2824. check_inline_asm loongson '"dmult.g $1, $2, $3"'
  2825. elif enabled parisc; then
  2826. if enabled gcc; then
  2827. case $($cc -dumpversion) in
  2828. 4.[3-8].*) check_cflags -fno-optimize-sibling-calls ;;
  2829. esac
  2830. fi
  2831. elif enabled ppc; then
  2832. enable local_aligned_8 local_aligned_16
  2833. check_inline_asm dcbzl '"dcbzl 0, %0" :: "r"(0)'
  2834. check_inline_asm ibm_asm '"add 0, 0, 0"'
  2835. check_inline_asm ppc4xx '"maclhw r10, r11, r12"'
  2836. check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
  2837. # AltiVec flags: The FSF version of GCC differs from the Apple version
  2838. if enabled altivec; then
  2839. nogas=warn
  2840. check_cflags -maltivec -mabi=altivec &&
  2841. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  2842. check_cflags -faltivec
  2843. # check if our compiler supports Motorola AltiVec C API
  2844. check_cc <<EOF || disable altivec
  2845. $inc_altivec_h
  2846. int main(void) {
  2847. vector signed int v1 = (vector signed int) { 0 };
  2848. vector signed int v2 = (vector signed int) { 1 };
  2849. v1 = vec_add(v1, v2);
  2850. return 0;
  2851. }
  2852. EOF
  2853. enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
  2854. fi
  2855. elif enabled sparc; then
  2856. enabled vis && check_inline_asm vis '"pdist %f0, %f0, %f0"'
  2857. elif enabled x86; then
  2858. check_code ld intrin.h "__rdtsc()" && enable rdtsc
  2859. check_code ld mmintrin.h "_mm_empty()" && enable mm_empty
  2860. enable local_aligned_8 local_aligned_16
  2861. # check whether EBP is available on x86
  2862. # As 'i' is stored on the stack, this program will crash
  2863. # if the base pointer is used to access it because the
  2864. # base pointer is cleared in the inline assembly code.
  2865. check_exec_crash <<EOF && enable ebp_available
  2866. volatile int i=0;
  2867. __asm__ volatile ("xorl %%ebp, %%ebp" ::: "%ebp");
  2868. return i;
  2869. EOF
  2870. # check whether EBX is available on x86
  2871. check_inline_asm ebx_available '""::"b"(0)' &&
  2872. check_inline_asm ebx_available '"":::"%ebx"'
  2873. # check whether xmm clobbers are supported
  2874. check_inline_asm xmm_clobbers '"":::"%xmm0"'
  2875. # check whether binutils is new enough to compile SSSE3/MMXEXT
  2876. enabled ssse3 && check_inline_asm ssse3_inline '"pabsw %xmm0, %xmm0"'
  2877. enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'
  2878. if ! disabled_any asm mmx yasm; then
  2879. if check_cmd $yasmexe --version; then
  2880. enabled x86_64 && yasm_extra="-m amd64"
  2881. yasm_debug="-g dwarf2"
  2882. elif check_cmd nasm -v; then
  2883. yasmexe=nasm
  2884. yasm_debug="-g -F dwarf"
  2885. enabled x86_64 && test "$objformat" = elf && objformat=elf64
  2886. fi
  2887. YASMFLAGS="-f $objformat $yasm_extra"
  2888. enabled pic && append YASMFLAGS "-DPIC"
  2889. test -n "$extern_prefix" && append YASMFLAGS "-DPREFIX"
  2890. case "$objformat" in
  2891. elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
  2892. esac
  2893. check_yasm "vextractf128 xmm0, ymm0, 0" && enable yasm ||
  2894. die "yasm not found, use --disable-yasm for a crippled build"
  2895. check_yasm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
  2896. check_yasm "CPU amdnop" && enable cpunop
  2897. fi
  2898. case "$cpu" in
  2899. athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
  2900. disable fast_clz
  2901. ;;
  2902. esac
  2903. fi
  2904. if enabled asm; then
  2905. as=${gas:=$as}
  2906. check_inline_asm gnu_as '".macro m n\n\\n:.int 0\n.endm\nm x"' ||
  2907. $nogas "GNU assembler not found, install gas-preprocessor"
  2908. fi
  2909. check_ldflags -Wl,--as-needed
  2910. if check_func dlopen; then
  2911. ldl=
  2912. elif check_func dlopen -ldl; then
  2913. ldl=-ldl
  2914. fi
  2915. if enabled network; then
  2916. check_type "sys/types.h sys/socket.h" socklen_t
  2917. check_type netdb.h "struct addrinfo"
  2918. check_type netinet/in.h "struct group_source_req" -D_BSD_SOURCE
  2919. check_type netinet/in.h "struct ip_mreq_source" -D_BSD_SOURCE
  2920. check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
  2921. check_type netinet/in.h "struct sockaddr_in6"
  2922. check_type poll.h "struct pollfd"
  2923. check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
  2924. check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
  2925. check_type netinet/sctp.h "struct sctp_event_subscribe"
  2926. check_func getaddrinfo $network_extralibs
  2927. check_func getservbyport $network_extralibs
  2928. # Prefer arpa/inet.h over winsock2
  2929. if check_header arpa/inet.h ; then
  2930. check_func closesocket
  2931. elif check_header winsock2.h ; then
  2932. check_func_headers winsock2.h closesocket -lws2 &&
  2933. network_extralibs="-lws2" ||
  2934. { check_func_headers winsock2.h closesocket -lws2_32 &&
  2935. network_extralibs="-lws2_32"; }
  2936. check_func_headers ws2tcpip.h getaddrinfo $network_extralibs
  2937. check_type ws2tcpip.h socklen_t
  2938. check_type ws2tcpip.h "struct addrinfo"
  2939. check_type ws2tcpip.h "struct group_source_req"
  2940. check_type ws2tcpip.h "struct ip_mreq_source"
  2941. check_type ws2tcpip.h "struct ipv6_mreq"
  2942. check_type winsock2.h "struct pollfd"
  2943. check_type ws2tcpip.h "struct sockaddr_in6"
  2944. check_type ws2tcpip.h "struct sockaddr_storage"
  2945. check_struct winsock2.h "struct sockaddr" sa_len
  2946. else
  2947. disable network
  2948. fi
  2949. fi
  2950. # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
  2951. check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
  2952. check_func fcntl
  2953. check_func fork
  2954. check_func gethrtime
  2955. check_func getopt
  2956. check_func getrusage
  2957. check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
  2958. check_func gettimeofday
  2959. check_func inet_aton $network_extralibs
  2960. check_func isatty
  2961. check_func localtime_r
  2962. check_func ${malloc_prefix}memalign && enable memalign
  2963. check_func mkstemp
  2964. check_func mmap
  2965. check_func mprotect
  2966. check_func ${malloc_prefix}posix_memalign && enable posix_memalign
  2967. check_func_headers malloc.h _aligned_malloc && enable aligned_malloc
  2968. check_func setrlimit
  2969. check_func strerror_r
  2970. check_func strptime
  2971. check_func strtok_r
  2972. check_func sched_getaffinity
  2973. check_func sysconf
  2974. check_func sysctl
  2975. check_func usleep
  2976. check_func_headers io.h setmode
  2977. check_lib2 "windows.h shellapi.h" CommandLineToArgvW -lshell32
  2978. check_lib2 "windows.h wincrypt.h" CryptGenRandom -ladvapi32
  2979. check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
  2980. check_func_headers windows.h GetProcessAffinityMask
  2981. check_func_headers windows.h GetProcessTimes
  2982. check_func_headers windows.h GetSystemTimeAsFileTime
  2983. check_func_headers windows.h MapViewOfFile
  2984. check_func_headers windows.h Sleep
  2985. check_func_headers windows.h VirtualAlloc
  2986. check_header direct.h
  2987. check_header dlfcn.h
  2988. check_header dxva.h
  2989. check_header dxva2api.h
  2990. check_header io.h
  2991. check_header malloc.h
  2992. check_header poll.h
  2993. check_header sys/mman.h
  2994. check_header sys/param.h
  2995. check_header sys/resource.h
  2996. check_header sys/select.h
  2997. check_header sys/time.h
  2998. check_header unistd.h
  2999. check_header vdpau/vdpau.h
  3000. check_header vdpau/vdpau_x11.h
  3001. check_header windows.h
  3002. check_header X11/extensions/XvMClib.h
  3003. disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
  3004. disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  3005. if ! disabled w32threads && ! enabled pthreads; then
  3006. check_func _beginthreadex && enable w32threads
  3007. fi
  3008. # check for some common methods of building with pthread support
  3009. # do this before the optional library checks as some of them require pthreads
  3010. if ! disabled pthreads && ! enabled w32threads; then
  3011. enable pthreads
  3012. if check_func pthread_create; then
  3013. :
  3014. elif check_func pthread_create -pthread; then
  3015. add_cflags -pthread
  3016. add_extralibs -pthread
  3017. elif check_func pthread_create -pthreads; then
  3018. add_cflags -pthreads
  3019. add_extralibs -pthreads
  3020. elif check_func pthread_create -lpthreadGC2; then
  3021. add_extralibs -lpthreadGC2
  3022. elif ! check_lib pthread.h pthread_create -lpthread; then
  3023. disable pthreads
  3024. fi
  3025. fi
  3026. for thread in $THREADS_LIST; do
  3027. if enabled $thread; then
  3028. test -n "$thread_type" &&
  3029. die "ERROR: Only one thread type must be selected." ||
  3030. thread_type="$thread"
  3031. fi
  3032. done
  3033. check_lib math.h sin -lm && LIBM="-lm"
  3034. enabled vaapi && require vaapi va/va.h vaInitialize -lva
  3035. atan2f_args=2
  3036. ldexpf_args=2
  3037. powf_args=2
  3038. for func in $MATH_FUNCS; do
  3039. eval check_mathfunc $func \${${func}_args:-1}
  3040. done
  3041. # these are off by default, so fail if requested and not available
  3042. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
  3043. enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
  3044. enabled gnutls && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
  3045. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  3046. enabled libfdk_aac && require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac
  3047. enabled libfreetype && require_pkg_config freetype2 "ft2build.h freetype/freetype.h" FT_Init_FreeType
  3048. enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
  3049. enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
  3050. enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
  3051. enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
  3052. enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
  3053. enabled libopencv && require_pkg_config opencv opencv/cv.h cvCreateImageHeader
  3054. enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
  3055. enabled libopus && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
  3056. enabled libpulse && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new
  3057. enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
  3058. enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
  3059. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  3060. enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
  3061. enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
  3062. enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
  3063. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  3064. enabled libvpx && {
  3065. enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
  3066. die "ERROR: libvpx decoder version must be >=0.9.1"; }
  3067. enabled libvpx_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VPX_CQ" -lvpx ||
  3068. die "ERROR: libvpx encoder version must be >=0.9.6"; } }
  3069. enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
  3070. { check_cpp_condition x264.h "X264_BUILD >= 118" ||
  3071. die "ERROR: libx264 version must be >= 0.118."; }
  3072. enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs
  3073. enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
  3074. enabled openssl && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
  3075. check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
  3076. check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
  3077. die "ERROR: openssl not found"; }
  3078. if enabled gnutls; then
  3079. { check_lib nettle/bignum.h nettle_mpz_get_str_256 -lnettle -lhogweed -lgmp && enable nettle; } ||
  3080. { check_lib gcrypt.h gcry_mpi_new -lgcrypt && enable gcrypt; }
  3081. fi
  3082. # libdc1394 check
  3083. if enabled libdc1394; then
  3084. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  3085. enable libdc1394_2; } ||
  3086. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  3087. enable libdc1394_1; } ||
  3088. die "ERROR: No version of libdc1394 found "
  3089. fi
  3090. if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
  3091. check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
  3092. enable sdl &&
  3093. check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
  3094. fi
  3095. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  3096. check_header linux/fb.h
  3097. check_header linux/videodev2.h
  3098. check_struct linux/videodev2.h "struct v4l2_frmivalenum" discrete
  3099. check_header sys/videoio.h
  3100. check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
  3101. # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
  3102. # w32api 3.12 had it defined wrong
  3103. check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
  3104. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  3105. { check_header dev/bktr/ioctl_meteor.h &&
  3106. check_header dev/bktr/ioctl_bt848.h; } ||
  3107. { check_header machine/ioctl_meteor.h &&
  3108. check_header machine/ioctl_bt848.h; } ||
  3109. { check_header dev/video/meteor/ioctl_meteor.h &&
  3110. check_header dev/video/bktr/ioctl_bt848.h; } ||
  3111. check_header dev/ic/bt8xx.h
  3112. check_header sndio.h
  3113. check_header sys/soundcard.h
  3114. check_header soundcard.h
  3115. enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
  3116. enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack &&
  3117. check_func jack_port_get_latency_range -ljack
  3118. enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
  3119. enabled libcdio &&
  3120. check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio
  3121. enabled x11grab &&
  3122. require X11 X11/Xlib.h XOpenDisplay -lX11 &&
  3123. require Xext X11/extensions/XShm.h XShmCreateImage -lXext &&
  3124. require Xfixes X11/extensions/Xfixes.h XFixesGetCursorImage -lXfixes
  3125. # check for VDA header
  3126. if ! disabled vda && check_header VideoDecodeAcceleration/VDADecoder.h; then
  3127. enable vda && add_extralibs -framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore
  3128. fi
  3129. if ! disabled vdpau && enabled vdpau_vdpau_h; then
  3130. check_cpp_condition vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
  3131. { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." && disable vdpau; }
  3132. fi
  3133. enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
  3134. # add some useful compiler flags if supported
  3135. check_cflags -Wdeclaration-after-statement
  3136. check_cflags -Wall
  3137. check_cflags -Wno-parentheses
  3138. check_cflags -Wno-switch
  3139. check_cflags -Wno-format-zero-length
  3140. check_cflags -Wdisabled-optimization
  3141. check_cflags -Wpointer-arith
  3142. check_cflags -Wredundant-decls
  3143. check_cflags -Wno-pointer-sign
  3144. check_cflags -Wcast-qual
  3145. check_cflags -Wwrite-strings
  3146. check_cflags -Wtype-limits
  3147. check_cflags -Wundef
  3148. check_cflags -Wmissing-prototypes
  3149. check_cflags -Wstrict-prototypes
  3150. enabled extra_warnings && check_cflags -Winline
  3151. # add some linker flags
  3152. check_ldflags -Wl,--warn-common
  3153. check_ldflags -Wl,-rpath-link=libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
  3154. test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
  3155. enabled xmm_clobber_test &&
  3156. check_ldflags -Wl,--wrap,avcodec_open2 \
  3157. -Wl,--wrap,avcodec_decode_audio4 \
  3158. -Wl,--wrap,avcodec_decode_video2 \
  3159. -Wl,--wrap,avcodec_decode_subtitle2 \
  3160. -Wl,--wrap,avcodec_encode_audio2 \
  3161. -Wl,--wrap,avcodec_encode_video \
  3162. -Wl,--wrap,avcodec_encode_subtitle \
  3163. -Wl,--wrap,sws_scale ||
  3164. disable xmm_clobber_test
  3165. echo "X{};" > $TMPV
  3166. if test_ldflags -Wl,--version-script,$TMPV; then
  3167. append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
  3168. check_cc <<EOF && enable symver_asm_label
  3169. void ff_foo(void) __asm__ ("av_foo@VERSION");
  3170. void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
  3171. EOF
  3172. check_cc <<EOF && enable symver_gnu_asm
  3173. __asm__(".symver ff_foo,av_foo@VERSION");
  3174. void ff_foo(void) {}
  3175. EOF
  3176. fi
  3177. if [ -z "$optflags" ]; then
  3178. if enabled small; then
  3179. optflags=$cflags_size
  3180. elif enabled optimizations; then
  3181. optflags=$cflags_speed
  3182. else
  3183. optflags=$cflags_noopt
  3184. fi
  3185. fi
  3186. check_optflags(){
  3187. check_cflags "$@"
  3188. enabled lto && check_ldflags "$@"
  3189. }
  3190. if enabled lto; then
  3191. test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
  3192. check_cflags -flto
  3193. check_ldflags -flto $cpuflags
  3194. fi
  3195. check_optflags $optflags
  3196. check_optflags -fno-math-errno
  3197. check_optflags -fno-signed-zeros
  3198. if enabled icc; then
  3199. # Just warnings, no remarks
  3200. check_cflags -w1
  3201. # -wd: Disable following warnings
  3202. # 144, 167, 556: -Wno-pointer-sign
  3203. # 1292: attribute "foo" ignored
  3204. # 1419: external declaration in primary source file
  3205. # 10006: ignoring unknown option -fno-signed-zeros
  3206. # 10148: ignoring unknown option -Wno-parentheses
  3207. # 10156: ignoring option '-W'; no argument required
  3208. check_cflags -wd144,167,556,1292,1419,10006,10148,10156
  3209. # 11030: Warning unknown option --as-needed
  3210. # 10156: ignoring option '-export'; no argument required
  3211. check_ldflags -wd10156,11030
  3212. # Allow to compile with optimizations
  3213. check_ldflags -march=$cpu
  3214. # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
  3215. enable ebp_available
  3216. if enabled x86_32; then
  3217. icc_version=$($cc -dumpversion)
  3218. test ${icc_version%%.*} -ge 11 &&
  3219. check_cflags -falign-stack=maintain-16-byte ||
  3220. disable aligned_stack
  3221. fi
  3222. elif enabled ccc; then
  3223. # disable some annoying warnings
  3224. add_cflags -msg_disable bitnotint
  3225. add_cflags -msg_disable mixfuncvoid
  3226. add_cflags -msg_disable nonstandcast
  3227. add_cflags -msg_disable unsupieee
  3228. elif enabled gcc; then
  3229. check_optflags -fno-tree-vectorize
  3230. check_cflags -Werror=implicit-function-declaration
  3231. check_cflags -Werror=missing-prototypes
  3232. check_cflags -Werror=declaration-after-statement
  3233. check_cflags -Werror=vla
  3234. elif enabled llvm_gcc; then
  3235. check_cflags -mllvm -stack-alignment=16
  3236. elif enabled clang; then
  3237. check_cflags -mllvm -stack-alignment=16
  3238. check_cflags -Qunused-arguments
  3239. check_cflags -Werror=implicit-function-declaration
  3240. check_cflags -Werror=missing-prototypes
  3241. elif enabled armcc; then
  3242. # 2523: use of inline assembler is deprecated
  3243. add_cflags -W${armcc_opt},--diag_suppress=2523
  3244. add_cflags -W${armcc_opt},--diag_suppress=1207
  3245. add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
  3246. add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
  3247. add_cflags -W${armcc_opt},--diag_suppress=167 # pointer sign
  3248. add_cflags -W${armcc_opt},--diag_suppress=513 # pointer sign
  3249. elif enabled tms470; then
  3250. add_cflags -pds=824 -pds=837
  3251. elif enabled pathscale; then
  3252. add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
  3253. elif enabled msvc; then
  3254. enabled x86_32 && disable aligned_stack
  3255. fi
  3256. case $target_os in
  3257. osf1)
  3258. enabled ccc && add_ldflags '-Wl,-expect_unresolved,*'
  3259. ;;
  3260. plan9)
  3261. add_cppflags -Dmain=plan9_main
  3262. ;;
  3263. esac
  3264. enabled_any $THREADS_LIST && enable threads
  3265. enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
  3266. check_deps $CONFIG_LIST \
  3267. $CONFIG_EXTRA \
  3268. $HAVE_LIST \
  3269. $ALL_COMPONENTS \
  3270. ! enabled_any memalign posix_memalign aligned_malloc &&
  3271. enabled_any $need_memalign && enable memalign_hack
  3272. echo "install prefix $prefix"
  3273. echo "source path $source_path"
  3274. echo "C compiler $cc"
  3275. echo "ARCH $arch ($cpu)"
  3276. if test "$build_suffix" != ""; then
  3277. echo "build suffix $build_suffix"
  3278. fi
  3279. if test "$extra_version" != ""; then
  3280. echo "version string suffix $extra_version"
  3281. fi
  3282. echo "big-endian ${bigendian-no}"
  3283. echo "runtime cpu detection ${runtime_cpudetect-no}"
  3284. if enabled x86; then
  3285. echo "${yasmexe} ${yasm-no}"
  3286. echo "MMX enabled ${mmx-no}"
  3287. echo "MMXEXT enabled ${mmxext-no}"
  3288. echo "3DNow! enabled ${amd3dnow-no}"
  3289. echo "3DNow! extended enabled ${amd3dnowext-no}"
  3290. echo "SSE enabled ${sse-no}"
  3291. echo "SSSE3 enabled ${ssse3-no}"
  3292. echo "AVX enabled ${avx-no}"
  3293. echo "FMA4 enabled ${fma4-no}"
  3294. echo "CMOV enabled ${cmov-no}"
  3295. echo "CMOV is fast ${fast_cmov-no}"
  3296. echo "EBX available ${ebx_available-no}"
  3297. echo "EBP available ${ebp_available-no}"
  3298. fi
  3299. if enabled arm; then
  3300. echo "ARMv5TE enabled ${armv5te-no}"
  3301. echo "ARMv6 enabled ${armv6-no}"
  3302. echo "ARMv6T2 enabled ${armv6t2-no}"
  3303. echo "ARM VFP enabled ${armvfp-no}"
  3304. echo "NEON enabled ${neon-no}"
  3305. fi
  3306. if enabled ppc; then
  3307. echo "AltiVec enabled ${altivec-no}"
  3308. echo "PPC 4xx optimizations ${ppc4xx-no}"
  3309. echo "dcbzl available ${dcbzl-no}"
  3310. fi
  3311. if enabled sparc; then
  3312. echo "VIS enabled ${vis-no}"
  3313. fi
  3314. echo "debug symbols ${debug-no}"
  3315. echo "optimize for size ${small-no}"
  3316. echo "optimizations ${optimizations-no}"
  3317. echo "static ${static-no}"
  3318. echo "shared ${shared-no}"
  3319. echo "new filter support ${avfilter-no}"
  3320. echo "network support ${network-no}"
  3321. echo "threading support ${thread_type-no}"
  3322. echo "safe bitstream reader ${safe_bitstream_reader-no}"
  3323. echo "SDL support ${sdl-no}"
  3324. echo "libdxva2 enabled ${dxva2-no}"
  3325. echo "libva enabled ${vaapi-no}"
  3326. echo "libvdpau enabled ${vdpau-no}"
  3327. echo "AVISynth enabled ${avisynth-no}"
  3328. echo "frei0r enabled ${frei0r-no}"
  3329. echo "gnutls enabled ${gnutls-no}"
  3330. echo "libcdio support ${libcdio-no}"
  3331. echo "libdc1394 support ${libdc1394-no}"
  3332. echo "libfaac enabled ${libfaac-no}"
  3333. echo "libfdk-aac enabled ${libfdk_aac-no}"
  3334. echo "libgsm enabled ${libgsm-no}"
  3335. echo "libilbc enabled ${libilbc-no}"
  3336. echo "libmp3lame enabled ${libmp3lame-no}"
  3337. echo "libopencore-amrnb support ${libopencore_amrnb-no}"
  3338. echo "libopencore-amrwb support ${libopencore_amrwb-no}"
  3339. echo "libopencv support ${libopencv-no}"
  3340. echo "libopenjpeg enabled ${libopenjpeg-no}"
  3341. echo "libopus enabled ${libopus-no}"
  3342. echo "libpulse enabled ${libpulse-no}"
  3343. echo "librtmp enabled ${librtmp-no}"
  3344. echo "libschroedinger enabled ${libschroedinger-no}"
  3345. echo "libspeex enabled ${libspeex-no}"
  3346. echo "libtheora enabled ${libtheora-no}"
  3347. echo "libvo-aacenc support ${libvo_aacenc-no}"
  3348. echo "libvo-amrwbenc support ${libvo_amrwbenc-no}"
  3349. echo "libvorbis enabled ${libvorbis-no}"
  3350. echo "libvpx enabled ${libvpx-no}"
  3351. echo "libx264 enabled ${libx264-no}"
  3352. echo "libxavs enabled ${libxavs-no}"
  3353. echo "libxvid enabled ${libxvid-no}"
  3354. echo "openssl enabled ${openssl-no}"
  3355. echo "zlib enabled ${zlib-no}"
  3356. echo "bzlib enabled ${bzlib-no}"
  3357. test -n "$random_seed" &&
  3358. echo "random seed ${random_seed}"
  3359. echo
  3360. for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
  3361. echo "Enabled ${type}s:"
  3362. eval list=\$$(toupper $type)_LIST
  3363. print_enabled '_*' $list | sort | pr -r -3 -t
  3364. echo
  3365. done
  3366. license="LGPL version 2.1 or later"
  3367. if enabled nonfree; then
  3368. license="nonfree and unredistributable"
  3369. elif enabled gplv3; then
  3370. license="GPL version 3 or later"
  3371. elif enabled lgplv3; then
  3372. license="LGPL version 3 or later"
  3373. elif enabled gpl; then
  3374. license="GPL version 2 or later"
  3375. fi
  3376. echo "License: $license"
  3377. echo "Creating config.mak and config.h..."
  3378. test -e Makefile || $ln_s "$source_path/Makefile" .
  3379. config_files="$TMPH config.mak"
  3380. cat > config.mak <<EOF
  3381. # Automatically generated by configure - do not modify!
  3382. LIBAV_CONFIGURATION=$LIBAV_CONFIGURATION
  3383. prefix=$prefix
  3384. LIBDIR=\$(DESTDIR)$libdir
  3385. SHLIBDIR=\$(DESTDIR)$shlibdir
  3386. INCDIR=\$(DESTDIR)$incdir
  3387. BINDIR=\$(DESTDIR)$bindir
  3388. DATADIR=\$(DESTDIR)$datadir
  3389. MANDIR=\$(DESTDIR)$mandir
  3390. SRC_PATH=$source_path
  3391. CC_IDENT=$cc_ident
  3392. ARCH=$arch
  3393. CC=$cc
  3394. AS=$as
  3395. LD=$ld
  3396. DEPCC=$dep_cc
  3397. DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS)
  3398. DEPAS=$as
  3399. DEPASFLAGS=$DEPASFLAGS \$(CPPFLAGS)
  3400. YASM=$yasmexe
  3401. DEPYASM=$yasmexe
  3402. AR=$ar
  3403. ARFLAGS=$arflags
  3404. AR_O=$ar_o
  3405. RANLIB=$ranlib
  3406. LN_S=$ln_s
  3407. CPPFLAGS=$CPPFLAGS
  3408. CFLAGS=$CFLAGS
  3409. ASFLAGS=$ASFLAGS
  3410. AS_C=$AS_C
  3411. AS_O=$AS_O
  3412. CC_C=$CC_C
  3413. CC_E=$CC_E
  3414. CC_O=$CC_O
  3415. LD_O=$LD_O
  3416. LD_LIB=$LD_LIB
  3417. LD_PATH=$LD_PATH
  3418. DLLTOOL=$dlltool
  3419. LDFLAGS=$LDFLAGS
  3420. LDFLAGS-avserver=$AVSERVERLDFLAGS
  3421. SHFLAGS=$SHFLAGS
  3422. YASMFLAGS=$YASMFLAGS
  3423. BUILDSUF=$build_suffix
  3424. FULLNAME=$FULLNAME
  3425. LIBPREF=$LIBPREF
  3426. LIBSUF=$LIBSUF
  3427. LIBNAME=$LIBNAME
  3428. SLIBPREF=$SLIBPREF
  3429. SLIBSUF=$SLIBSUF
  3430. EXESUF=$EXESUF
  3431. EXTRA_VERSION=$extra_version
  3432. CCDEP=$CCDEP
  3433. CCDEP_FLAGS=$CCDEP_FLAGS
  3434. ASDEP=$ASDEP
  3435. ASDEP_FLAGS=$ASDEP_FLAGS
  3436. CC_DEPFLAGS=$CC_DEPFLAGS
  3437. AS_DEPFLAGS=$AS_DEPFLAGS
  3438. HOSTCC=$host_cc
  3439. HOSTLD=$host_ld
  3440. HOSTCFLAGS=$host_cflags
  3441. HOSTEXESUF=$HOSTEXESUF
  3442. HOSTLDFLAGS=$host_ldflags
  3443. HOSTLIBS=$host_libs
  3444. DEPHOSTCC=$host_cc
  3445. DEPHOSTCCFLAGS=$DEPHOSTCCFLAGS \$(HOSTCCFLAGS)
  3446. HOSTCCDEP=$HOSTCCDEP
  3447. HOSTCCDEP_FLAGS=$HOSTCCDEP_FLAGS
  3448. HOSTCC_DEPFLAGS=$HOSTCC_DEPFLAGS
  3449. HOSTCC_C=$HOSTCC_C
  3450. HOSTCC_O=$HOSTCC_O
  3451. HOSTLD_O=$HOSTLD_O
  3452. TARGET_EXEC=$target_exec
  3453. TARGET_PATH=$target_path
  3454. LIBS-avplay=$sdl_libs
  3455. CFLAGS-avplay=$sdl_cflags
  3456. ZLIB=$($ldflags_filter -lz)
  3457. LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
  3458. EXTRALIBS=$extralibs
  3459. COMPAT_OBJS=$compat_objs
  3460. EXEOBJS=$exeobjs
  3461. INSTALL=install
  3462. LIBTARGET=${LIBTARGET}
  3463. SLIBNAME=${SLIBNAME}
  3464. SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
  3465. SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
  3466. SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
  3467. SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
  3468. SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
  3469. SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
  3470. SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
  3471. SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
  3472. SAMPLES:=${samples:-\$(LIBAV_SAMPLES)}
  3473. EOF
  3474. get_version(){
  3475. lcname=lib${1}
  3476. name=$(toupper $lcname)
  3477. file=$source_path/$lcname/version.h
  3478. eval $(awk "/#define ${name}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file")
  3479. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  3480. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  3481. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  3482. }
  3483. map 'get_version $v' $LIBRARY_LIST
  3484. cat > $TMPH <<EOF
  3485. /* Automatically generated by configure - do not modify! */
  3486. #ifndef LIBAV_CONFIG_H
  3487. #define LIBAV_CONFIG_H
  3488. #define LIBAV_CONFIGURATION "$(c_escape $LIBAV_CONFIGURATION)"
  3489. #define LIBAV_LICENSE "$(c_escape $license)"
  3490. #define AVCONV_DATADIR "$(eval c_escape $datadir)"
  3491. #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
  3492. #define restrict $_restrict
  3493. #define EXTERN_PREFIX "${extern_prefix}"
  3494. #define EXTERN_ASM ${extern_prefix}
  3495. #define SLIBSUF "$SLIBSUF"
  3496. EOF
  3497. test -n "$malloc_prefix" &&
  3498. echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
  3499. if enabled yasm; then
  3500. append config_files $TMPASM
  3501. printf '' >$TMPASM
  3502. fi
  3503. print_config ARCH_ "$config_files" $ARCH_LIST
  3504. print_config HAVE_ "$config_files" $HAVE_LIST
  3505. print_config CONFIG_ "$config_files" $CONFIG_LIST \
  3506. $CONFIG_EXTRA \
  3507. $ALL_COMPONENTS \
  3508. echo "#endif /* LIBAV_CONFIG_H */" >> $TMPH
  3509. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  3510. cp_if_changed $TMPH config.h
  3511. touch .config
  3512. enabled yasm && cp_if_changed $TMPASM config.asm
  3513. cat > $TMPH <<EOF
  3514. /* Generated by ffconf */
  3515. #ifndef AVUTIL_AVCONFIG_H
  3516. #define AVUTIL_AVCONFIG_H
  3517. EOF
  3518. print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
  3519. echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
  3520. cp_if_changed $TMPH libavutil/avconfig.h
  3521. test -n "$WARNINGS" && printf "\n$WARNINGS"
  3522. # build pkg-config files
  3523. pkgconfig_generate(){
  3524. name=$1
  3525. shortname=${name#lib}${build_suffix}
  3526. comment=$2
  3527. version=$3
  3528. libs=$4
  3529. requires=$5
  3530. enabled ${name#lib} || return 0
  3531. mkdir -p $name
  3532. cat <<EOF > $name/$name.pc
  3533. prefix=$prefix
  3534. exec_prefix=\${prefix}
  3535. libdir=$libdir
  3536. includedir=$incdir
  3537. Name: $name
  3538. Description: $comment
  3539. Version: $version
  3540. Requires: $(enabled shared || echo $requires)
  3541. Requires.private: $(enabled shared && echo $requires)
  3542. Conflicts:
  3543. Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
  3544. Libs.private: $(enabled shared && echo $libs)
  3545. Cflags: -I\${includedir}
  3546. EOF
  3547. cat <<EOF > $name/$name-uninstalled.pc
  3548. prefix=
  3549. exec_prefix=
  3550. libdir=\${pcfiledir}
  3551. includedir=${source_path}
  3552. Name: $name
  3553. Description: $comment
  3554. Version: $version
  3555. Requires: $requires
  3556. Conflicts:
  3557. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  3558. Cflags: -I\${includedir}
  3559. EOF
  3560. }
  3561. pkgconfig_generate libavutil "Libav utility library" "$LIBAVUTIL_VERSION" "$LIBM"
  3562. pkgconfig_generate libavcodec "Libav codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  3563. pkgconfig_generate libavformat "Libav container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
  3564. pkgconfig_generate libavdevice "Libav device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
  3565. pkgconfig_generate libavfilter "Libav video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  3566. pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  3567. pkgconfig_generate libswscale "Libav image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION"