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.

4763 lines
140KB

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