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.

4576 lines
135KB

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