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.

4531 lines
134KB

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