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.

4599 lines
136KB

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