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.

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