1#############################################################################
2#  $Id: configure.ac 634642 2021-07-15 17:55:50Z ivanov $
3#  Derived from configure.in version 1.173.
4# ==========================================================================
5#
6#                            PUBLIC DOMAIN NOTICE
7#               National Center for Biotechnology Information
8#
9#  This software/database is a "United States Government Work" under the
10#  terms of the United States Copyright Act.  It was written as part of
11#  the author's official duties as a United States Government employee and
12#  thus cannot be copyrighted.  This software/database is freely available
13#  to the public for use. The National Library of Medicine and the U.S.
14#  Government have not placed any restriction on its use or reproduction.
15#
16#  Although all reasonable efforts have been taken to ensure the accuracy
17#  and reliability of the software and data, the NLM and the U.S.
18#  Government do not and cannot warrant the performance or results that
19#  may be obtained by using this software or data. The NLM and the U.S.
20#  Government disclaim all warranties, express or implied, including
21#  warranties of performance, merchantability or fitness for any particular
22#  purpose.
23#
24#  Please cite the author in any work or product based on this material.
25#
26# ==========================================================================
27#
28# Authors:  Denis Vakatov, Aaron Ucko
29#
30# File Description:
31#   Setup NCBI C++ Toolkit build tree - tuned for your platform, compiler, etc.
32#   USAGE:
33#    1) Process this file with "autoconf" to produce a "configure" script.
34#    2) Run the resultant "configure" script to produce:
35#      a) "<builddir>/inc/ncbiconf_unix.h"
36#      b) "<builddir>/build/Makefile.mk"
37#      c) other Makefile's and scripts in "<builddir>/build" and below
38#
39#############################################################################
40
41AC_PREREQ(2.69)
42
43dnl Early setup, most crucially for locking.  The diversion magic lets
44dnl this occur before AC_INIT, which already interferes with other
45dnl configure processes.
46
47AC_DIVERT_PUSH(INIT_PREPARE)
48
49# Check --with-3psw=.../--without-3psw early because a lot hinges on it
50orig_NCBI=$NCBI
51case "$with_3psw" in
52   '' | yes | [[\$/][Nn]*:[SsLl]*] | [[Nn]*:[SsLl]*] )
53      ncbi_favor_std_packages=no
54      ;;
55   [[SsLl]]*:* )
56      ncbi_favor_std_packages=yes
57      ;;
58   [[SsLl]]* )
59      AS_UNSET(NCBI)
60      ;;
61   no )
62      if test "${with_ncbi_c-no}" != "no"; then
63         AC_MSG_ERROR([incompatible options: --with-ncbi-c but --without-3psw])
64      else
65         with_ncbi_c=no
66      fi
67      if test "${with_aws_sdk-no}" != "no"; then
68         AC_MSG_ERROR([incompatible options: --with-aws-sdk but --without-3psw])
69      else
70         with_aws_sdk=no
71      fi
72      if test "${with_apache_arrow-no}" != "no"; then
73         AC_MSG_ERROR([incompatible options: --with-apache-arrow but --without-3psw])
74      else
75         with_apache_arrow=no
76      fi
77      m4_foreach(X, [sss, sssutils, sssdb, vdb, ngs, libunwind,
78                     z, bz2, lzo, zstd, pcre, mbedtls,
79                     gmp, gcrypt, nettle, gnutls, openssl, krb5, boost, lmdb,
80                     sybase, ftds, mysql, opengl, mesa, glut, glew, gl2ps,
81                     wxwidgets, freetype, ftgl, fastcgi, bdb, orbacus, odbc,
82                     python, perl, jni, sqlite3, mimetic, sge, icu, sp, expat,
83                     sablot, libxml, libxslt, libexslt, xerces, xalan, zorba,
84                     oechem, muparser, hdf5, gif, jpeg, png, tiff, xpm, magic,
85                     curl, gsoap, avro, cereal, sasl2,
86                     mongodb, mongodb3, leveldb, gmock, lapack,
87                     libuv, libssh2, cassandra, nghttp2, h2o, influxdb,
88                     libxlsxwriter, protobuf, grpc, msgsl, hiredis,
89                     librdkafka, cppkafka],
90        [if test "${[with_]X-no}" != "no"; then
91            AC_MSG_ERROR([incompatible options: --with-]X[ but --without-3psw])
92         else
93            [with_]X=no
94         fi
95        ])
96      AS_UNSET(NCBI)
97      ;;
98   * )
99      AC_MSG_ERROR([Unsupported option --with-3psw=$with_3psw])
100      ;;
101esac
102
103if $srcdir/scripts/common/impl/get_lock.sh configure $$; then
104    ac_clean_files=configure.lock
105else
106    exit 1
107fi
108# reconfigure.sh expects config.cache to exist; unconditionally clobber
109# any command-line setting.
110cache_file=config.cache
111if test -z "$CONFIG_SITE" -a -r $srcdir/src/build-system/config.site; then
112    CONFIG_SITE=$srcdir/src/build-system/config.site
113fi
114AC_DIVERT_POP
115
116AC_INIT([ncbi-tools++],[0.0],[cpp-core@ncbi.nlm.nih.gov])
117AC_CONFIG_SRCDIR(src/build-system/Makefile.mk.in)
118
119
120
121#############################################################################
122
123
124#### Describe all "--with-*" arguments -- for the usage printout on "--help"
125
126## Title
127AC_ARG_WITH(_,
128   [===============================================================================])
129AC_ARG_WITH(_,
130   [=============== NCBI C++ Toolkit specific configuration flags =================])
131AC_ARG_WITH(_,
132   [===============================================================================])
133
134## Code generation
135AC_ARG_WITH(debug,
136   [ --without-debug         build non-debug versions of libs and apps])
137AC_ARG_WITH(max-debug,
138   [ --with-max-debug        enable extra runtime checks (esp. of STL usage)])
139AC_ARG_WITH(max-debug,
140   [ --with-max-debug=thread ... including via GCC's thread sanitizer])
141AC_ARG_WITH(symbols,
142   [ --with-symbols          retain debugging symbols in non-debug mode])
143AC_ARG_WITH(optimization,
144   [ --without-optimization  turn off optimization flags in non-debug mode])
145AC_ARG_WITH(sse42,
146   [ --without-sse42         don't enable SSE 4.2 when optimizing])
147AC_ARG_WITH(profiling,
148   [ --with-profiling        build profiled versions of libs and apps])
149AC_ARG_WITH(code-coverage,
150   [ --with-code-coverage    track which code blocks have been exercised])
151AC_ARG_WITH(tcheck,
152   [ --with-tcheck(=DIR)     build for Intel Thread Checker (in DIR)])
153AC_ARG_WITH(dll,
154   [ --with-dll              build all libraries as DLLs])
155AC_ARG_WITH(static,
156   [ --with-static           build all libraries statically even if --with-dll])
157AC_ARG_WITH(static-exe,
158   [ --with-static-exe       build all executables as statically as possible])
159AC_ARG_WITH(plugin-auto-load,
160   [ --with-plugin-auto-load always enable the plugin manager by default])
161AC_ARG_WITH(bundles,
162   [ --with-bundles          build bundles in addition to dylibs on Mac OS X])
163AC_ARG_WITH(bin-release,
164   [ --with-bin-release      build executables suitable for public release])
165AC_ARG_WITH(mt,
166   [ --without-mt            support only single-threaded operation])
167AC_ARG_WITH(openmp,
168   [ --with-openmp           enable OpenMP extensions for all projects])
169AC_ARG_WITH(64,
170   [ --with-64               compile to 64-bit code])
171AC_ARG_WITH(exe,
172   [ --without-exe           do not build executables])
173AC_ARG_WITH(runpath,
174   [ --with-runpath=PATH     specify the usual runtime path to DLLs])
175AC_ARG_WITH(relative-runpath,
176   [ --with-relative-runpath=P specify an executable-relative DLL search path])
177AC_ARG_WITH(hard-runpath,
178   [ --with-hard-runpath     hard-code runtime path, ignoring LD_LIBRARY_PATH])
179AC_ARG_WITH(lfs,
180   [ --with-lfs              enable large file support to the extent possible])
181AC_ARG_WITH(limited-linker,
182   [ --with-limited-linker   don't attempt to build especially large projects])
183AC_ARG_WITH(experimental,
184   [ --with-experimental=... enable named experimental feature(s): Int{4,8}GI,StrictGI,PSGLoader,BM64])
185AC_ARG_WITH(skew-guard,
186   [ --with-skew-guard       catch incomplete rebuilds])
187
188## Scripts, make features, and directory naming
189AC_ARG_WITH(extra-action,
190   [ --with-extra-action=    script to call after the configuration is complete])
191AC_ARG_WITH(autodep,
192   [ --with-autodep          automatic generation of dependencies (GNU make)])
193AC_ARG_WITH(build-root,
194   [ --with-build-root=DIR   specify a non-default build directory name])
195AC_ARG_WITH(fake-root,
196   [ --with-fake-root=DIR    appear to have been built under DIR])
197AC_ARG_WITH(suffix,
198   [ --without-suffix        no Release/Debug, MT or DLL sfx in the build dir name])
199AC_ARG_WITH(hostspec,
200   [ --with-hostspec         add full host specs to the build dir name])
201AC_ARG_WITH(version,
202   [ --without-version       don't always include the cplr ver in the bd name])
203AC_ARG_WITH(build-root-sfx,
204   [ --with-build-root-sfx=X add a user-specified suffix to the build dir name])
205AC_ARG_WITH(execopy,
206   [ --without-execopy       do not copy built executables to the BIN area])
207AC_ARG_WITH(bincopy,
208   [ --with-bincopy          populate lib and bin with copies, not hard links])
209AC_ARG_WITH(lib-rebuilds,
210   [ --with-lib-rebuilds     ensure that apps use up-to-date libraries])
211AC_ARG_WITH(lib-rebuilds,
212   [ --with-lib-rebuilds=ask ask whether to update each app's libraries])dnl'
213AC_ARG_WITH(deactivation,
214   [ --without-deactivation  keep old copies of libraries that no longer build])
215AC_ARG_WITH(makefile-auto-update,
216   [ --without-makefile-auto-update  do not auto-update generated makefiles])
217AC_ARG_WITH(projects,
218   [ --with-projects=FILE    build projects listed in FILE by default])
219AC_ARG_WITH(flat-makefile,
220   [ --without-flat-makefile do not generate an all-encompassing flat makefile])
221AC_ARG_WITH(configure-dialog,
222   [ --with-configure-dialog allow interactive flat makefile project selection])
223AC_ARG_WITH(saved-settings,
224   [ --with-saved-settings=F load configuration settings from the file F])
225AC_ARG_WITH(check,
226   [ --with-check            run test suite after the build])
227AC_ARG_WITH(check-tools,
228   [ --with-check-tools=...  use the specified tools for testing])
229AC_ARG_WITH(ncbi-public,
230   [ --with-ncbi-public      ensure compatibility for all in-house platforms])
231AC_ARG_WITH(strip,
232   [ --with-strip            strip binaries at build time])
233AC_ARG_WITH(pch,
234   [ --with-pch              use precompiled headers if possible])
235AC_ARG_WITH(caution,
236   [ --with-caution          cancel configuration unconditionally when in doubt])
237AC_ARG_WITH(caution,
238   [ --without-caution       proceed without asking when in doubt])
239AC_ARG_WITH(ccache,
240   [ --without-ccache        do not automatically use ccache if available])
241AC_ARG_WITH(distcc,
242   [ --without-distcc        do not automatically use distcc if available])
243
244## NCBI packages
245AC_ARG_WITH(ncbi-c,
246   [ --with-ncbi-c=DIR       use NCBI C Toolkit installation in DIR])
247AC_ARG_WITH(ncbi-c,
248   [ --without-ncbi-c        do not use NCBI C Toolkit])
249AC_ARG_WITH(sss,
250   [ --with-sss=DIR          use NCBI SSS installation in DIR])
251AC_ARG_WITH(sss,
252   [ --without-sss           do not use NCBI SSS libraries])
253AC_ARG_WITH(sssutils,
254   [ --without-utils         do not use NCBI SSS UTIL library])
255AC_ARG_WITH(sssdb,
256   [ --without-sssdb         do not use NCBI SSS DB library])
257AC_ARG_WITH(included-sss,
258   [ --with-included-sss     use the in-tree copy of SSS])
259AC_ARG_WITH(vdb,
260   [ --with-vdb=DIR          use NCBI SRA/VDB Toolkit installation in DIR])
261AC_ARG_WITH(vdb,
262   [ --without-vdb           do not use the NCBI SRA/VDB Toolkit])
263AC_ARG_WITH(downloaded-vdb,
264   [ --with-downloaded-vdb   download and build SRA/VDB from GitHub])
265AC_ARG_WITH(static-vdb,
266   [ --with-static-vdb       always link statically against SRA/VDB])
267AC_ARG_WITH(ngs,
268   [ --with-ngs=DIR          use NCBI NGS SDK installation in DIR])
269AC_ARG_WITH(ngs,
270   [ --without-ngs           do not use the NCBI NGS SDK])
271
272## Third-party and system packages
273AC_ARG_WITH(libunwind,
274   [ --with-libunwind(=DIR)  use libunwind (in DIR)])
275AC_ARG_WITH(libdw,
276   [ --with-libdw=DIR        use elfutils libdw installation in DIR])
277AC_ARG_WITH(libdw,
278   [ --without-libdw         do not use elfutils libdw])
279AC_ARG_WITH(backward-cpp,
280   [ --with-backward-cpp=DIR use backward-cpp installation in DIR])
281AC_ARG_WITH(backward-cpp,
282   [ --without-backward-cpp  do not use backward-cpp])
283AC_ARG_WITH(backward-cpp-sig,
284   [ --with-backward-cpp-sig  allow backward-cpp to also handle signals])
285AC_ARG_WITH(z,
286   [ --with-z=DIR            use zlib installation in DIR])
287AC_ARG_WITH(z,
288   [ --without-z             use internal copy of zlib])
289AC_ARG_WITH(bz2,
290   [ --with-bz2=DIR          use bzlib installation in DIR])
291AC_ARG_WITH(bz2,
292   [ --without-bz2           use internal copy of bzlib])
293AC_ARG_WITH(lzo,
294   [ --with-lzo=DIR          use LZO installation in DIR (requires 2.x or up)])
295AC_ARG_WITH(lzo,
296   [ --without-lzo           do not use LZO])
297AC_ARG_WITH(zstd,
298   [ --with-zstd=DIR         use Zstandard installation in DIR])
299AC_ARG_WITH(zstd,
300   [ --without-zstd          do not use Zstandard])
301AC_ARG_WITH(pcre,
302   [ --with-pcre=DIR         use PCRE installation in DIR])
303AC_ARG_WITH(pcre,
304   [ --without-pcre          use internal copy of PCRE])
305AC_ARG_WITH(mbedtls,
306   [ --with-mbedtls(=DIR)    use external mbedTLS installation (in DIR)])
307AC_ARG_WITH(gmp,
308   [ --with-gmp=DIR          use GMP installation in DIR])
309AC_ARG_WITH(gmp,
310   [ --without-gmp           do not use GMP])
311AC_ARG_WITH(gcrypt,
312   [ --with-gcrypt=DIR       use gcrypt installation in DIR])
313AC_ARG_WITH(gcrypt,
314   [ --without-gcrypt        do not use gcrypt])
315AC_ARG_WITH(nettle,
316   [ --with-nettle=DIR       use Nettle installation in DIR])
317AC_ARG_WITH(nettle,
318   [ --without-nettle        do not use Nettle])
319AC_ARG_WITH(gnutls,
320   [ --with-gnutls=DIR       use GNUTLS installation in DIR])
321AC_ARG_WITH(static-gnutls,
322   [ --with-static-gnutls    link GNUTLS statically if possible])
323AC_ARG_WITH(openssl,
324   [ --with-openssl=DIR      use OpenSSL installation in DIR])
325AC_ARG_WITH(openssl,
326   [ --without-openssl       do not use OpenSSL])
327AC_ARG_WITH(krb5,
328   [ --with-krb5=DIR         use Kerberos 5 installation in DIR])
329AC_ARG_WITH(krb5,
330   [ --without-krb5          do not use Kerberos 5])
331AC_ARG_WITH(sybase,
332   [ --without-sybase        do not use SYBASE libraries])
333AC_ARG_WITH(sybase-local,
334   [ --with-sybase-local=DIR use local SYBASE install (DIR is optional)])
335AC_ARG_WITH(sybase-new,
336   [ --with-sybase-new       use newer SYBASE install (12.5 rather than 12.0)])
337AC_ARG_WITH(ftds,
338   [ --without-ftds          do not use FreeTDS libraries])
339AC_ARG_WITH(ftds,
340   [ --with-ftds=DIR         use FreeTDS installation in DIR])
341AC_ARG_WITH(ftds-renamed,
342   [ --without-ftds-renamed  do not rename Sybase DBLIB symbols in built-in FTDS])
343AC_ARG_WITH(mysql,
344   [ --without-mysql         do not use MySQL])
345AC_ARG_WITH(mysql,
346   [ --with-mysql=DIR        use MySQL installation in DIR])
347AC_ARG_WITH(opengl,
348   [ --without-opengl        do not use OpenGL])
349AC_ARG_WITH(opengl,
350   [ --with-opengl=DIR       use OpenGL installation in DIR])
351AC_ARG_WITH(mesa,
352   [ --without-mesa          do not use MESA off-screen OpenGL])
353AC_ARG_WITH(mesa,
354   [ --with-mesa=DIR         use MESA installation in DIR])
355AC_ARG_WITH(glut,
356   [ --without-glut          do not use GLUT])
357AC_ARG_WITH(glut,
358   [ --with-glut=DIR         use GLUT installation in DIR])
359AC_ARG_WITH(glew,
360   [ --without-glew          do not use GLEW])
361AC_ARG_WITH(glew,
362   [ --with-glew=DIR         use GLEW installation in DIR])
363AC_ARG_WITH(glew-mx,
364   [ --with-glew-mx          insist on a multi-context-ready GLEW installation])
365AC_ARG_WITH(gl2ps,
366   [ --without-gl2ps         do not use GL2PS])
367AC_ARG_WITH(gl2ps,
368   [ --with-gl2ps=DIR        use GL2PS installation in DIR])
369AC_ARG_WITH(wxwidgets,
370   [ --without-wxwidgets     do not use wxWidgets (2.6+)])
371AC_ARG_WITH(wxwidgets,
372   [ --with-wxwidgets=DIR    use wxWidgets installation in DIR])
373AC_ARG_WITH(wxwidgets-ucs,
374   [ --with-wxwidgets-ucs    use Unicode builds of wxWidgets])
375AC_ARG_WITH(wxwidgets-ucs,
376   [ --without-wxwidgets-ucs do not use Unicode builds of wxWidgets])
377AC_ARG_WITH(freetype,
378   [ --without-freetype      do not use FreeType])
379AC_ARG_WITH(freetype,
380   [ --with-freetype=DIR     use FreeType installation in DIR])
381AC_ARG_WITH(ftgl,
382   [ --without-ftgl          do not use FTGL])
383AC_ARG_WITH(ftgl,
384   [ --with-ftgl=DIR         use FTGL installation in DIR])
385AC_ARG_WITH(fastcgi,
386   [ --without-fastcgi       do not use Fast-CGI library])
387AC_ARG_WITH(fastcgi,
388   [ --with-fastcgi=VERSION  use Fast-CGI installation in \$NCBI/fcgi-VERSION])
389AC_ARG_WITH(fastcgi,
390   [ --with-fastcgi=DIR      use Fast-CGI installation in DIR])
391AC_ARG_WITH(bdb,
392   [ --without-bdb           do not use Berkeley DB library])
393AC_ARG_WITH(bdb,
394   [ --with-bdb=VERSION      use DB installation in \$NCBI/BerkeleyDB-VERSION])
395AC_ARG_WITH(bdb,
396   [ --with-bdb=DIR          use Berkeley DB installation in DIR])
397AC_ARG_WITH(sp,
398   [ --without-sp            do not use SP libraries])
399AC_ARG_WITH(orbacus,
400   [ --without-orbacus       do not use ORBacus CORBA libraries])
401AC_ARG_WITH(orbacus,
402   [ --with-orbacus=DIR      use ORBacus installation in DIR])
403AC_ARG_WITH(odbc,
404   [ --with-odbc=DIR         use ODBC installation in DIR])
405AC_ARG_WITH(python,
406   [ --with-python=DIR       use Python installation in DIR])
407AC_ARG_WITH(python,
408   [ --without-python        do not use Python])
409AC_ARG_WITH(perl,
410   [ --with-perl=DIR         use Perl installation in DIR])
411AC_ARG_WITH(perl,
412   [ --without-perl          do not use Perl])
413AC_ARG_WITH(jni,
414   [ --with-jni(=JDK-DIR)    build Java bindings (against the JDK in JDK-DIR)])
415AC_ARG_WITH(boost,
416   [ --with-boost=DIR        use Boost installation in DIR])
417AC_ARG_WITH(boost,
418   [ --without-boost         do not use Boost])
419AC_ARG_WITH(boost-tag,
420   [ --with-boost-tag=TAG    use TAG as the tag appended to Boost library names])
421AC_ARG_WITH(boost-tag,
422   [ --without-boost-tag     use untagged Boost library names])
423AC_ARG_WITH(sqlite3,
424   [ --with-sqlite3=DIR      use SQLite 3.x installation in DIR])
425AC_ARG_WITH(sqlite3,
426   [ --without-sqlite3       do not use SQLite 3.x])
427AC_ARG_WITH(icu,
428   [ --with-icu=DIR          use ICU installation in DIR])
429AC_ARG_WITH(icu,
430   [ --without-icu           do not use ICU])
431AC_ARG_WITH(expat,
432   [ --with-expat=DIR        use Expat installation in DIR])
433AC_ARG_WITH(expat,
434   [ --without-expat         do not use Expat])
435AC_ARG_WITH(sablot,
436   [ --with-sablot=DIR       use Sablotron installation in DIR])
437AC_ARG_WITH(sablot,
438   [ --without-sablot        do not use Sablotron])
439AC_ARG_WITH(libxml,
440   [ --with-libxml=DIR       use libxml2 installation in DIR])
441AC_ARG_WITH(libxml,
442   [ --without-libxml        do not use libxml2])
443AC_ARG_WITH(libxslt,
444   [ --with-libxslt=DIR      use libxslt installation in DIR])
445AC_ARG_WITH(libxslt,
446   [ --without-libxslt       do not use libxslt])
447AC_ARG_WITH(libexslt,
448   [ --with-libexslt=DIR     use libexslt installation in DIR])
449AC_ARG_WITH(libexslt,
450   [ --without-libexslt      do not use libexslt])
451AC_ARG_WITH(xerces,
452   [ --with-xerces=DIR       use Xerces-C++ installation in DIR])
453AC_ARG_WITH(xerces,
454   [ --without-xerces        do not use Xerces-C++])
455AC_ARG_WITH(xalan,
456   [ --with-xalan=DIR        use Xalan-C++ installation in DIR])
457AC_ARG_WITH(xalan,
458   [ --without-xalan         do not use Xalan-C++])
459AC_ARG_WITH(zorba,
460   [ --with-zorba=DIR        use Zorba installation in DIR])
461AC_ARG_WITH(zorba,
462   [ --without-zorba         do not use Zorba])
463AC_ARG_WITH(oechem,
464   [ --with-oechem=DIR       use OpenEye OEChem installation in DIR])
465AC_ARG_WITH(oechem,
466   [ --without-oechem        do not use OEChem])
467AC_ARG_WITH(sge,
468   [ --with-sge=DIR          use Sun/Univa Grid Engine installation in DIR])
469AC_ARG_WITH(sge,
470   [ --without-sge           do not use Sun/Univa Grid Engine])
471AC_ARG_WITH(muparser,
472   [ --with-muparser=DIR     use muParser installation in DIR])
473AC_ARG_WITH(muparser,
474   [ --without-muparser      do not use muParser])
475AC_ARG_WITH(hdf5,
476   [ --with-hdf5=DIR         use HDF5 installation in DIR])
477AC_ARG_WITH(hdf5,
478   [ --without-hdf5          do not use HDF5])
479AC_ARG_WITH(gif,
480   [ --with-gif=DIR          use lib(un)gif installation in DIR])
481AC_ARG_WITH(gif,
482   [ --without-gif           do not use lib(un)gif])
483AC_ARG_WITH(jpeg,
484   [ --with-jpeg=DIR         use libjpeg installation in DIR])
485AC_ARG_WITH(jpeg,
486   [ --without-jpeg          do not use libjpeg])
487AC_ARG_WITH(png,
488   [ --with-png=DIR          use libpng installation in DIR])
489AC_ARG_WITH(png,
490   [ --without-png           do not use libpng])
491AC_ARG_WITH(tiff,
492   [ --with-tiff=DIR         use libtiff installation in DIR])
493AC_ARG_WITH(tiff,
494   [ --without-tiff          do not use libtiff])
495AC_ARG_WITH(xpm,
496   [ --with-xpm=DIR          use libXpm installation in DIR])
497AC_ARG_WITH(xpm,
498   [ --without-xpm           do not use libXpm])
499AC_ARG_WITH(magic,
500   [ --with-magic=DIR        use libmagic installation in DIR])
501AC_ARG_WITH(magic,
502   [ --without-magic         do not use libmagic])
503AC_ARG_WITH(curl,
504   [ --with-curl=DIR         use libcurl installation in DIR])
505AC_ARG_WITH(curl,
506   [ --without-curl          do not use libcurl])
507AC_ARG_WITH(mimetic,
508   [ --with-mimetic=DIR      use libmimetic installation in DIR])
509AC_ARG_WITH(mimetic,
510   [ --without-mimetic       do not use libmimetic])
511AC_ARG_WITH(gsoap,
512   [ --with-gsoap=DIR        use gSOAP++ installation in DIR])
513AC_ARG_WITH(gsoap,
514   [ --without-gsoap         do not use gSOAP++])
515AC_ARG_WITH(avro,
516   [ --with-avro=DIR         use Apache Avro installation in DIR])
517AC_ARG_WITH(avro,
518   [ --without-avro          do not use Apache Avro])
519AC_ARG_WITH(cereal,
520   [ --with-cereal=DIR       use USC Cereal installation in DIR])
521AC_ARG_WITH(cereal,
522   [ --without-cereal        do not use USC Cereal])
523AC_ARG_WITH(sasl2,
524   [ --with-sasl2=DIR        use SASL 2 installation in DIR])
525AC_ARG_WITH(sasl2,
526   [ --without-sasl2         do not use SASL 2])
527AC_ARG_WITH(mongodb,
528   [ --with-mongodb=DIR      use legacy MongoDB installation in DIR])
529AC_ARG_WITH(mongodb,
530   [ --without-mongodb       do not use legacy MongoDB])
531AC_ARG_WITH(mongodb3,
532   [ --with-mongodb3=DIR     use MongoDB 3 installation in DIR])
533AC_ARG_WITH(mongodb3,
534   [ --without-mongodb3      do not use MongoDB 3])
535AC_ARG_WITH(leveldb,
536   [ --with-leveldb=DIR      use LevelDB installation in DIR])
537AC_ARG_WITH(leveldb,
538   [ --without-leveldb       do not use LevelDB])
539AC_ARG_WITH(gmock,
540   [ --with-gmock=DIR        use Google Mock installation in DIR])
541AC_ARG_WITH(gmock,
542   [ --without-gmock         do not use Google Mock])
543AC_ARG_WITH(lapack,
544   [ --with-lapack=DIR       use LAPACK installation in DIR])
545AC_ARG_WITH(lapack,
546   [ --without-lapack        do not use LAPACK])
547AC_ARG_WITH(lmdb,
548   [ --with-lmdb=DIR         use LMDB installation in DIR])
549AC_ARG_WITH(lmdb,
550   [ --without-lmdb          use internal copy of LMDB])
551AC_ARG_WITH(libuv,
552   [ --with-libuv=DIR        use libuv installation in DIR])
553AC_ARG_WITH(libuv,
554   [ --without-libuv         do not use libuv])
555AC_ARG_WITH(libssh2,
556   [ --with-libssh2=DIR      use libssh2 installation in DIR])
557AC_ARG_WITH(libssh2,
558   [ --without-libssh2       do not use libssh2])
559AC_ARG_WITH(cassandra,
560   [ --with-cassandra=DIR    use Datastax Cassandra driver installation in DIR])
561AC_ARG_WITH(cassandra,
562   [ --without-cassandra     do not use Datastax Cassandra driver])
563AC_ARG_WITH(nghttp2,
564   [ --with-nghttp2=DIR      use nghttp2 installation in DIR])
565AC_ARG_WITH(nghttp2,
566   [ --without-nghttp2       do not use nghttp2])
567AC_ARG_WITH(h2o,
568   [ --with-h2o=DIR          use h2o installation in DIR])
569AC_ARG_WITH(h2o,
570   [ --without-h2o           do not use h2o])
571AC_ARG_WITH(influxdb,
572   [ --with-influxdb=DIR     use influxdb-cpp installation in DIR])
573AC_ARG_WITH(influxdb,
574   [ --without-influxdb      do not use influxdb-cpp])
575AC_ARG_WITH(libxlsxwriter,
576   [ --with-libxlsxwriter=DIR use libxlsxwriter installation in DIR])
577AC_ARG_WITH(libxlsxwriter,
578   [ --without-libxlsxwriter do not use libxlsxwriter])
579AC_ARG_WITH(protobuf,
580   [ --with-protobuf=DIR     use protocol buffers installation in DIR])
581AC_ARG_WITH(protobuf,
582   [ --without-protobuf      do not use protocol buffers])
583AC_ARG_WITH(grpc,
584   [ --with-grpc=DIR         use GRPC (and protobuf) installation in DIR])
585AC_ARG_WITH(grpc,
586   [ --without-grpc          do not use GRPC])
587AC_ARG_WITH(msgsl,
588   [ --with-msgsl=DIR        use Guideline Support Library installation in DIR])
589AC_ARG_WITH(msgsl,
590   [ --without-msgsl         do not use the Guideline Support Library])
591AC_ARG_WITH(aws-sdk,
592   [ --with-aws-sdk=DIR      use Amazon Web Services SDK installation in DIR])
593AC_ARG_WITH(aws-sdk,
594   [ --without-aws-sdk       do not use the Amazon Web Services SDK])
595AC_ARG_WITH(hiredis,
596   [ --with-hiredis=DIR      use Hiredis installation in DIR])
597AC_ARG_WITH(hiredis,
598   [ --without-hiredis       do not use Hiredis])
599AC_ARG_WITH(apache-arrow,
600   [ --with-apache-arrow=DIR use Apache Arrow installation in DIR])
601AC_ARG_WITH(apache-arrow,
602   [ --without-apache-arrow  do not use Apache Arrow])
603AC_ARG_WITH(librdkafka,
604   [ --with-librdkafka=DIR   use librdkafka installation in DIR])
605AC_ARG_WITH(librdkafka,
606   [ --without-librdkafka    do not use librdkafka])
607AC_ARG_WITH(cppkafka,
608   [ --with-cppkafka=DIR     use cppkafka installation in DIR])
609AC_ARG_WITH(cppkafka,
610   [ --without-cppkafka      do not use cppkafka])
611AC_ARG_WITH(3psw,
612   [ --with-3psw=std:netopt  favor standard (system) builds of the above pkgs.])
613AC_ARG_WITH(3psw,
614   [ --without-3psw          do not use any of the above packages])
615
616## Optional projects
617AC_ARG_WITH(local-lbsm,
618   [ --without-local-lbsm    turn off support for IPC with locally running LBSMD])
619AC_ARG_WITH(ncbi-crypt,
620   [ --without-ncbi-crypt    use a dummy stubbed-out version of ncbi_crypt])
621AC_ARG_WITH(connext,
622   [ --without-connext       do not build non-public CONNECT library extensions])
623dnl AC_ARG_WITH(serial,
624dnl    [ --without-serial        do not build the serialization library and tools])
625dnl AC_ARG_WITH(objects,
626dnl    [ --without-objects       do not generate/build serializeable objects from ASNs])
627dnl AC_ARG_WITH(dbapi,
628dnl    [ --without-dbapi         do not build database connectivity libraries])
629AC_ARG_WITH(app,
630   [ --without-app           do not build standalone applications like ID1_FETCH])
631AC_ARG_WITH(ctools,
632   [ --without-ctools        do not build NCBI C Toolkit based projects])
633AC_ARG_WITH(gui,
634   [ --without-gui           do not build most graphical projects])
635dnl AC_ARG_WITH(algo,
636dnl    [ --without-algo          do not build CPU-intensive algorithms])
637AC_ARG_WITH(internal,
638   [ --with-internal         always try to build internal projects])
639AC_ARG_WITH(internal,
640   [ --without-internal      never build internal projects])
641AC_ARG_WITH(gbench,
642   [ --with-gbench           ensure that Genome Workbench can be built])
643AC_ARG_WITH(gbench,
644   [ --without-gbench        do not build Genome Workbench])
645
646## Manuals
647AC_ARG_WITH(manuals,
648   [***** See also HTML documentation in ./doc/index.html *****])
649
650
651AC_DIVERT_PUSH(PARSE_ARGS)
652dnl As of Autoconf 2.60, this needs to run too early for config.log,
653dnl to which AC_MSG_ERROR normally copies its output, to be available.
654m4_rename([AS_MESSAGE_LOG_FD], [NCBI_ORIG_ASMLFD])
655m4_define([AS_MESSAGE_LOG_FD], [])
656#### Check the passed arguments against the list of available ones
657x_with_list="\
658debug max-debug max-debug=thread symbols optimization sse42 \
659profiling code-coverage tcheck dll static static-exe \
660plugin-auto-load bundles bin-release mt 64 exe runpath hard-runpath \
661lfs limited-linker skew-guard openmp \
662autodep suffix hostspec version execopy bincopy lib-rebuilds lib-rebuilds=ask \
663deactivation makefile-auto-update projects flat-makefile configure-dialog \
664check ncbi-public strip pch caution ccache distcc \
665ncbi-c wxwidgets wxwidgets-ucs fastcgi sss sssdb sssutils included-sss \
666geo included-geo vdb downloaded-vdb static-vdb ngs libunwind libdw \
667backward-cpp backward-cpp-sig \
668z bz2 lzo zstd pcre mbedtls \
669gmp gcrypt nettle gnutls static-gnutls openssl krb5 \
670sybase sybase-local sybase-new ftds mysql \
671orbacus freetype ftgl opengl mesa glut glew glew-mx gl2ps \
672bdb python perl jni sqlite3 icu boost boost-tag \
673sp expat sablot libxml libxslt libexslt xerces xalan zorba \
674oechem sge muparser hdf5 \
675gif jpeg tiff png xpm \
676magic curl mimetic gsoap avro cereal sasl2 \
677mongodb mongodb3 leveldb gmock lapack lmdb \
678libuv libssh2 cassandra nghttp2 h2o influxdb \
679libxlsxwriter protobuf grpc msgsl aws-sdk hiredis \
680apache-arrow librdkafka cppkafka \
6813psw local-lbsm ncbi-crypt connext \
682serial objects dbapi app ctools gui algo internal gbench"
683
684changequote(, )dnl
685x_with_list=`echo "$x_with_list" | sed 's/\([^ ][^ ]*\)/--with-\1 --without-\1/g'`
686changequote([, ])dnl
687
688
689for x_arg in "$@" ; do
690   if test -z "$x_arg" ; then
691      continue
692   fi
693
694   x_okay=
695   for x_desc in $x_with_list ; do
696      if test "$x_arg" = "$x_desc" ; then
697         x_okay="okay"
698         break
699      fi
700   done
701   if test "$x_okay" = "okay" ; then
702      continue
703   fi
704
705   case "$x_arg" in
706      --with-extra-action= | --exec-prefix= | --with-projects= | --srcdir= \
707      | --cache-file= | --build= | --host= | --target= | --with-runpath= \
708      | --with-relative-runpath= | --x-includes= | --x-libraries= )
709      AC_MSG_ERROR([$x_arg:  requires value;  use --help to show usage])
710      ;;
711
712      --with-projects=* | --with-saved-settings=* )
713      # Confirm that the specified file exists and is readable.
714      file=`echo $x_arg | sed -e 's/^[[^=]]*=//'`
715      case "$file" in
716         /* ) ;;
717         *  ) file=$srcdir/$file ;;
718      esac
719      if test -f "$file"; then
720         if test -r "$file"; then
721            :
722         else
723            AC_MSG_ERROR([$x_arg:  requires a readable file; use --help to show usage])
724         fi
725      else
726         AC_MSG_ERROR([$x_arg:  requires a (readable) file; use --help to show usage])
727      fi
728      ;;
729
730      --with-vdb=rc ) ;;
731
732      --srcdir=* | --x-includes=* | --x-libraries=* | --with-tcheck=* \
733      | --with-ncbi-c=* | --with-sss=* | --with-vdb=* | --with-ngs=* \
734      | --with-libunwind=* | --with-libdw=* | --with-backward-cpp=* \
735      | --with-z=* | --with-bz2=* | --with-lzo=* | --with-zstd=* \
736      | --with-pcre=* | --with-mbedtls=* \
737      | --with-gmp=* | --with-gcrypt=* | --with-nettle=* \
738      | --with-gnutls=* | --with-openssl=* | --with-krb5=* \
739      | --with-sybase-local=* | --with-ftds=*/* | --with-mysql=* \
740      | --with-opengl=* | --with-mesa=* | --with-glut=* | --with-glew=* \
741      | --with-gl2ps=* \
742      | --with-wxwidgets=* | --with-freetype=* | --with-ftgl=* \
743      | --with-fastcgi=*/* | --with-bdb=*/* | --with-orbacus=* \
744      | --with-odbc=* | --with-python=* | --with-perl=* | --with-jni=* \
745      | --with-boost=* | --with-sqlite3=* | --with-icu=* | --with-expat=* \
746      | --with-sablot=* | --with-libxml=* | --with-libxslt=* | --with-exslt=* \
747      | --with-xerces=* | --with-xalan=* | --with-zorba=* | --with-oechem=* \
748      | --with-sge=* | --with-muparser=* | --with-hdf5=* | --with-gif=* \
749      | --with-jpeg=* | --with-png=* | --with-tiff=* | --with-xpm=* \
750      | --with-magic=* | --with-curl=* | --with-mimetic=* | --with-gsoap=* \
751      | --with-avro=* | --with-cereal=* | --with-sasl2=* \
752      | --with-mongodb=* | --with-mongodb3=* | --with-leveldb=* \
753      | --with-gmock=* | --with-lapack=* | --with-lmdb=* | --with-libuv=* \
754      | --with-libssh2=* | --with-cassandra=* | --with-nghttp2=* \
755      | --with-h2o=* | --with-influxdb=* | --with-libxlsxwriter=* \
756      | --with-protobuf=* | --with-grpc=* | --with-msgsl=* | --with-aws-sdk=* \
757      | --with-hiredis=* | --with-librdkafka=* | --with-cppkafka=* )
758      # Confirm that the specified directory exists and is readable.
759      dir=`echo $x_arg | sed -e 's/^[[^=]]*=//'`
760      case "$x_arg" in
761         --srcdir=* | --*=/* ) ;;
762         *  ) dir=$srcdir/$dir ;;
763      esac
764      if test -d "$dir"; then
765         if test -r "$dir"; then
766            :
767         else
768            AC_MSG_ERROR([$x_arg:  requires a readable directory; use --help to show usage])
769         fi
770      else
771         AC_MSG_ERROR([$x_arg:  requires a (readable) directory; use --help to show usage])
772      fi
773      ;;
774
775      [[A-Z]*=*] | -h | --help | --help=* | -V | --version | -q | --quiet \
776      | --silent | --cache-file=* | -C | --config-cache | -n | --no-create \
777      | --no-recursion | --prefix=* | --exec-prefix=* | --bindir=* \
778      | --libdir=* | --includedir=* | --build=* | --host=* | --target=* \
779      | --mandir=* | --infodir=* | --docdir=* | --htmldir=* \
780      | --datadir=* | --sysconfdir=* | --localstatedir=* \
781      | --with-runpath=* | --with-relative-runpath=* \
782      | --with-experimental=* | --with-extra-action=* | --with-build-root=* \
783      | --with-fake-root=* | --with-build-root-sfx=* | --with-check=* \
784      | --with-check-tools=* | --with-ftds=[[0-9]]* | --with-fastcgi=[[0-9]]* \
785      | --with-bdb=[[1-9]]* | --with-boost-tag=* | --with-3psw=* )
786      ;;
787
788      * )
789      AC_MSG_ERROR([$x_arg:  unknown option;  use --help to show usage])
790      ;;
791   esac
792done
793m4_undefine([AS_MESSAGE_LOG_FD])
794m4_rename([NCBI_ORIG_ASMLFD], [AS_MESSAGE_LOG_FD])
795AC_DIVERT_POP
796
797
798if test "$with_gbench" = "yes" ; then
799   m4_foreach(OPT, [dll,mt,gui,exe,serial,objects,algo,glew,wxwidgets,ftgl,sqlite3,bdb,boost,xslt],
800     [if test "$[with_]OPT" = "no"; then
801         AC_MSG_ERROR([incompatible options: --without-]OPT[ but --with-gbench])
802      else
803         : ${[with_]OPT:=yes}
804      fi
805     ])
806   : ${with_projects=scripts/projects/ncbi_gbench.lst}
807elif test "$with_jni" = "yes" ; then
808   m4_foreach(OPT, [dll,mt],
809     [if test "$[with_]OPT" = "no"; then
810         AC_MSG_ERROR([incompatible options: --without-]OPT[ but --with-jni])
811      else
812         [with_]OPT=yes
813      fi
814     ])
815   : ${with_exe=no}
816fi
817
818if test "$with_bin_release" = "yes" ; then
819   # Default some other options accordingly
820   : ${with_ncbi_public=yes}
821   : ${with_local_lbsm=no}
822   : ${with_ncbi_crypt=no}
823   : ${with_connext=no}
824   : ${with_libdw=no}
825   : ${with_pcre=no} # Too much variation across distributions.
826   : ${with_sse42=no}
827   AC_DEFINE(NCBI_BIN_RELEASE, 1,
828             [Define to 1 when building binaries for public release.])
829fi
830
831if test "$with_debug" = no; then
832    : ${with_symbols=no}
833    : ${with_optimization=yes}
834    if test "${with_max_debug-no}" != no; then
835       AC_MSG_ERROR([incompatible options: --without-debug but --with-max-debug])
836    fi
837else
838    : ${with_symbols=yes}
839    : ${with_optimization=no}
840fi
841
842if test "$with_openmp" = yes; then
843   if test "$with_mt" = no; then
844      AC_MSG_ERROR([incompatible options: --without-mt but --with-openmp])
845   fi
846   : ${with_mt=yes}
847fi
848
849case "$with_downloaded_vdb:$with_vdb" in
850   yes:no )
851      AC_MSG_ERROR([incompatible options: --without-vdb but
852                    --with-downloaded-vdb])
853      ;;
854   yes: )
855      with_vdb=yes
856      ;;
857esac
858
859case "$with_static_vdb:$with_vdb" in
860   yes:no )
861      AC_MSG_ERROR([incompatible options: --without-vdb but --with-static-vdb])
862      ;;
863   yes: )
864      with_vdb=yes
865      ;;
866   :* )
867      with_static_vdb=$with_bin_release
868      ;;
869esac
870
871case "$with_static_gnutls:$with_gnutls" in
872   yes:no )
873      AC_MSG_ERROR([incompatible options: --without-gnutls but --with-static-gnutls])
874      ;;
875   yes: )
876      with_gnutls=yes
877      ;;
878   :yes )
879      with_static_gnutls=$with_bin_release
880      ;;
881esac
882
883m4_foreach(OPT, [serial,objects,dbapi,algo],
884   [if test -n "[$with_]OPT"; then
885       AC_MSG_WARN([--with(out)-]OPT[ is deprecated])
886       AC_MSG_WARN([please simply pass an appropriate project list])
887    fi
888   ])
889
890#### Check for special options
891if test "$with_extra_action" = "yes" ; then
892   AC_MSG_ERROR([--with-extra-action must have a value after =])
893fi
894if test "$with_extra_action" = "no" ; then
895   AC_MSG_ERROR([--without-extra-action is not allowed])
896fi
897
898case "$with_projects" in
899 ""|yes)
900     if test -r projects; then
901        AC_MSG_NOTICE([using default projects file "projects".])
902        with_projects=projects
903        AC_SUBST(PROJECTS, "\$(top_srcdir)/projects")
904     else
905        AC_SUBST(PROJECTS, "")
906        if test -f projects; then
907           AC_MSG_WARN([default projects file "projects" is unreadable.])
908        elif test -h projects; then
909           AC_MSG_WARN([default projects file "projects" is a dangling link.])
910        fi
911     fi
912     ;;
913 no) with_projects="" ;  AC_SUBST(PROJECTS, "") ;;
914 /*) AC_SUBST(PROJECTS, $with_projects) ;;
915 * ) AC_SUBST(PROJECTS, "\$(top_srcdir)/$with_projects") ;;
916esac
917
918if test -n "$with_projects"; then
919   case "$with_projects" in
920      /* ) abs_projects=$with_projects         ;;
921      yes) abs_projects=$srcdir/projects       ;;
922      *  ) abs_projects=$srcdir/$with_projects ;;
923   esac
924   test -r "$abs_projects"  ||  \
925      AC_MSG_ERROR([unable to read requested projects file "$abs_projects".])
926fi
927
928# Check for custom optimization flags before potentially going with defaults.
929skip_fast_flags=no
930if test -z "${DEF_FAST_FLAGS}${FAST_CXXFLAGS}"; then
931   case " $CFLAGS $CXXFLAGS" in
932      *\ -O* | *\ -xO* ) skip_fast_flags=yes ;;
933   esac
934fi
935# Generally save any originally specified flags.
936USER_CFLAGS=$CFLAGS
937USER_CXXFLAGS=$CXXFLAGS
938USER_LDFLAGS=$LDFLAGS
939
940with_experimental="$with_experimental PSGLoader"
941
942if test -n "$with_experimental"; then
943   NCBI_C_PATH_TAGS="/ncbi.gi64 .gi64"
944   want_gi32=no
945   want_gi64=no
946   for x in `echo $with_experimental | tr , ' '`; do
947      case "$x" in
948         ChaosMonkey )
949            AC_DEFINE(NCBI_MONKEY, 1,
950               [Define to 1 to enable "ChaosMonkey" failure testing.])
951            NCBI_FEATURE(ChaosMonkey)
952            ;;
953         Int4GI )
954            AC_DEFINE(NCBI_INT4_GI, 1,
955               [Define to 1 to use a simple 32-bit type for GI numbers.])
956            NCBI_C_PATH_TAGS=
957            NCBI_FEATURE(Int4GI)
958            want_gi32=yes
959            ;;
960         Int8GI )
961            AC_DEFINE(NCBI_INT8_GI, 1,
962               [Define to 1 to use a simple 64-bit type for GI numbers.])
963            NCBI_FEATURE(Int8GI)
964            want_gi64=yes
965            ;;
966         StrictGI )
967            AC_DEFINE(NCBI_STRICT_GI, 1,
968               [Define to 1 to use a strict 64-bit type for GI numbers.])
969            NCBI_FEATURE(Int8GI)
970            NCBI_FEATURE(StrictGI)
971            want_gi64=yes
972            ;;
973         PSGLoader )
974            AC_DEFINE(HAVE_PSG_LOADER, 1,
975               [Define to 1 to let the GenBank data loader use PubSeq Gateway.])
976            NCBI_FEATURE(PSGLoader)
977            ;;
978         BM64 )
979            AC_DEFINE(BM64ADDR, 1, [Define to 1 to use 64-bit bitset indices.])
980            NCBI_FEATURE(BM64)
981            ;;
982         * )
983            AC_MSG_ERROR([unrecognized experimental feature "$x".])
984            ;;
985      esac
986   done
987   if test "$want_gi32:$want_gi64" = "yes:yes"; then
988      AC_MSG_ERROR([Incompatible experimental features Int8GI (and/or StrictGI) and Int4GI.])
989   fi
990fi
991
992#### Always define this
993AC_DEFINE(NCBI_CXX_TOOLKIT, 1, [This is the NCBI C++ Toolkit.])
994
995AC_MSG_CHECKING([TeamCity build number])
996if test -n "$TEAMCITY_VERSION" -a -n "$BUILD_NUMBER"; then
997   AC_MSG_RESULT($BUILD_NUMBER)
998   NCBI_TEAMCITY_BUILD_NUMBER=$BUILD_NUMBER
999   NCBI_TEAMCITY_PROJECT_NAME=$TEAMCITY_PROJECT_NAME
1000   NCBI_TEAMCITY_BUILDCONF_NAME=$TEAMCITY_BUILDCONF_NAME
1001   NCBI_TEAMCITY_BUILD_ID=`sed -ne 's/^teamcity\.build\.id=//p' \
1002                           $TEAMCITY_BUILD_PROPERTIES_FILE`
1003else
1004   AC_MSG_RESULT(none)
1005   NCBI_TEAMCITY_BUILD_NUMBER=0
1006fi
1007
1008AC_MSG_CHECKING([Subversion revision])
1009svnrev=`svn info "$srcdir" 2>/dev/null | sed -ne 's/^Revision: //p'`
1010if test -n "$svnrev"; then
1011   AC_MSG_RESULT($svnrev)
1012   NCBI_SUBVERSION_REVISION=$svnrev
1013elif test -n "$NCBI_SUBVERSION_REVISION"; then
1014   AC_MSG_RESULT($NCBI_SUBVERSION_REVISION)
1015else
1016   AC_MSG_RESULT(unknown)
1017   NCBI_SUBVERSION_REVISION=0
1018fi
1019
1020AC_MSG_CHECKING([NCBI stable components' version])
1021scver=`svn info "$srcdir/src/build-system" 2>/dev/null |
1022 sed -ne ['s,^URL: .*/production/components/[^/]*/\([1-9][0-9]*\)\..*,\1,p']`
1023if test -n "$scver"; then
1024   AC_MSG_RESULT($scver)
1025   NCBI_SC_VERSION=$scver
1026elif test -n "$NCBI_SC_VERSION"; then
1027   AC_MSG_RESULT($NCBI_SC_VERSION)
1028else
1029   AC_MSG_RESULT(unknown)
1030   NCBI_SC_VERSION=0
1031fi
1032
1033AC_DEFINE(HAVE_COMMON_NCBI_BUILD_VER_H, 1,
1034   [Define to 1 if you have the <common/ncbi_build_ver.h> header file.])
1035
1036#### Get the running host's properties
1037AC_CONFIG_AUX_DIR(src/build-system)
1038AC_CANONICAL_HOST
1039AC_DEFINE_UNQUOTED(HOST,        "$host",        [Full GNU-style system type])
1040AC_DEFINE_UNQUOTED(HOST_CPU,    "$host_cpu",    [CPU type only])
1041AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor", [System vendor only])
1042AC_DEFINE_UNQUOTED(HOST_OS,     "$host_os",     [System OS only])
1043
1044
1045#### Make some provisions for traditional operation
1046AC_PROG_INSTALL
1047
1048#### Help ICC get off the ground ASAP.
1049case "/$CXX" in
1050   */icpc )
1051      if test -d /opt/ncbi/gcc -o -d /usr/local/gcc; then
1052         case "`$CXX -dumpversion`:$host_cpu" in
1053            *:i?86)           v=4.4.5 ;;
1054            ?.* | 1[[01]].* ) v=4.0.1 ;;
1055            1[[23]].*)        v=4.4.2 ;;
1056            1[[456]].*)       v=4.9.3 ;;
1057            17.*) v=7.3.0; CPPFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0 $CPPFLAGS" ;;
1058            *)                v=7.3.0 ;;
1059         esac
1060         for gcc in /opt/ncbi/gcc/$v/bin/gcc /usr/local/gcc/$v/bin/gcc; do
1061            if test -x $gcc; then
1062               CC="$CC -gcc-name=$gcc"
1063               CXX="$CXX -gcc-name=$gcc"
1064               case $gcc in
1065                  /opt/* )
1066                     LDFLAGS="-Wl,-rpath,/opt/ncbi/gcc/$v/lib64 $LDFLAGS"
1067                     ;;
1068                  /usr/* )
1069                     LDFLAGS="-Wl,-rpath,/usr/lib64/gcc-$v $LDFLAGS"
1070                     ;;
1071               esac
1072               break
1073            fi
1074         done
1075      fi
1076      ;;
1077   */icpx )
1078      case "$host_cpu" in
1079         i?86   ) intel_cpu_name=ia32      ;;
1080         x86_64 ) intel_cpu_name=intel64   ;;
1081         *      ) intel_cpu_name=$host_cpu ;;
1082      esac
1083
1084      set $CXX
1085      x_CXX="`type $1 | sed 's/.* \([^ ]*\)$/\1/'`"
1086      if test ! -x "$x_CXX" ; then
1087         x_CXX="`which $1 2>/dev/null`"
1088      fi
1089
1090      compiler_root=${x_CXX%/bin/*}
1091      icc_libdir=$compiler_root/compiler/lib/$intel_cpu_name
1092      LDFLAGS="-L$icc_libdir -Wl,-rpath,$icc_libdir -lintlc $LDFLAGS"
1093      ;;
1094esac
1095
1096#### Don't let Clang pick up old (pre-C++14) system standard
1097#### library installations on Linux.
1098case "$host_os:/$CXX" in
1099   linux*:*/clang* | */icpx )
1100      case "`$CXX --version`" in
1101         *version\ 3.* )
1102            gccver=5.3.0
1103            CPPFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0 $CPPFLAGS"
1104            ;;
1105         * )
1106            gccver=7.3.0
1107            ;;
1108      esac
1109      gccdir=/opt/ncbi/gcc/$gccver
1110      if test -d $gccdir; then
1111         # CPPFLAGS="--gcc-toolchain=$gccdir $CPPFLAGS"
1112         # LDFLAGS="--gcc-toolchain=$gccdir $LDFLAGS"
1113         for d in `$gccdir/bin/g++ -v -E -x c++ $ARCH_CFLAGS $ARCH_CPPFLAGS - \
1114                   </dev/null 2>&1 | fgrep 'include/c++' | tac`; do
1115            NCBI_FIX_DIR(d)
1116            # We don't use a dedicated CXXCPPFLAGS variable, but sticking
1117            # with -isystem rather than -cxx-isystem avoids spurious
1118            # warnings when also using ccache or distcc, and should still
1119            # be safe in practice.  (The three libstdc++ headers that have
1120            # the same names as system headers all arrange to include
1121            # those headers via #include_next, and to conditionalize any
1122            # C++ declarations on compiling as actual C++.)
1123            CPPFLAGS="-isystem $d $CPPFLAGS"
1124         done
1125         CPPFLAGS="-nostdinc++ $CPPFLAGS"
1126         libstdcxx=`$gccdir/bin/g++ --print-file-name=libstdc++.a`
1127         d=`dirname $libstdcxx`
1128         NCBI_FIX_DIR(d)
1129         LDFLAGS="-L$d -Wl,-rpath,$d $LDFLAGS"
1130         crtbegin=`$gccdir/bin/g++ --print-file-name=crtbegin.o`
1131         d=`dirname $crtbegin`
1132         NCBI_FIX_DIR(d)
1133         LDFLAGS="-L$d -B$d $LDFLAGS"
1134      fi
1135      ;;
1136esac
1137
1138#### C and C++ compilers
1139AC_LANG(C++)
1140AC_PROG_CC
1141ac_build_objext=$ac_objext
1142AS_UNSET([ac_cv_c_compiler_gnu])
1143AX_PROG_CC_FOR_BUILD
1144AC_PROG_CXX
1145
1146
1147#### Detect Insure++, and attempt to find the real compiler.
1148case "$CXX" in
1149   insure* | */insure*)
1150      psrcdump=`echo "$CXX" | sed -e 's/insure.*/psrcdump/'`
1151      real_CXX=`$psrcdump -t insure++ | sed -ne 's/^Compiler \(.*\)/\1/p'`
1152      real_dir=`$psrcdump -t insure++ | sed -ne 's/^Compilerinstalldir \(.*\)/\1/p'`
1153      test -n "$real_dir" && test -x "$real_dir/$real_CXX" && \
1154        real_CXX="$real_dir/$real_CXX"
1155      case "$real_CXX" in
1156          *gcc* ) LIBS="$LIBS -lstdc++"
1157      esac
1158      ;;
1159   *)
1160      real_CXX=$CXX
1161      ;;
1162esac
1163
1164
1165#### Detect KCC compiler
1166if test "$GCC" != "yes" ; then
1167   touch kcc_test.cpp
1168   kcc_ver="`$real_CXX -V -c kcc_test.cpp 2>&1 | grep '^KAI '`"
1169   kcc_license="`$real_CXX -V -c kcc_test.cpp 2>&1 | grep -v '^KAI '`"
1170   rm -f kcc_test.cpp kcc_test.o
1171   case "$kcc_ver" in
1172      KAI* )  KCC="yes" ;;
1173   esac
1174fi
1175
1176
1177#### Detect ICC compiler (newer versions of which configure can mis-ID as GCC)
1178if test "$KCC" != "yes"; then
1179   icc_ver="`$real_CXX -V 2>&1 | grep '^Intel(R) '`"
1180   icc_license="`$real_CXX -c 2>&1 | grep '^icc: NOTE: The evaluation period for this product ends on '`"
1181   case "$icc_ver" in
1182      Intel*C*Compiler* )  ICC="yes"; GCC="no" ;;
1183   esac
1184fi
1185
1186
1187#### Detect Clang compiler (which also masquerades as GCC)
1188if test "$KCC" != "yes"  -a  "$ICC" != yes; then
1189   clang_ver="`$real_CXX -v 2>&1 | grep clang | grep ' version '`"
1190   if test -n "$clang_ver"; then
1191      Clang=yes
1192      GCC=no
1193   fi
1194fi
1195
1196
1197#### Detect IBM VisualAge compiler
1198if test "$GCC" != "yes"  -a  "$KCC" != "yes"  -a  "$ICC" != "yes" \
1199  -a  "$Clang" != "yes" ; then
1200   vac_ver="`$real_CXX -qversion 2>&1`"
1201   case "$vac_ver" in
1202      *AIX* ) VAC="yes" ;;
1203   esac
1204fi
1205
1206
1207#### Detect Compaq compiler
1208if test "$GCC" != "yes"  -a  "$KCC" != "yes"  -a  "$ICC" != "yes" \
1209  -a  "$Clang" != "yes"  -a  "$VAC" != "yes"; then
1210   ccc_ver="`$real_CXX -V 2>&1 | grep '^Compaq C++ V'`"
1211   case "$ccc_ver" in
1212      *Compaq* ) CCC="yes" ;;
1213   esac
1214fi
1215
1216
1217#### Detect Cray compiler
1218if test "$GCC" != "yes"  -a  "$KCC" != "yes"  -a  "$ICC" != "yes" \
1219  -a  "$Clang" != "yes"  -a  "$VAC" != "yes" -a  "$CCC" != "yes"; then
1220   cce_ver="`$real_CXX -V 2>&1 | grep '^Cray'`"
1221   case "$cce_ver" in
1222      *Cray* ) CCE="yes" ;;
1223   esac
1224fi
1225
1226
1227#### Detect supported compilers
1228compiler=
1229compiler_ver=
1230ncbi_compiler="UNKNOWN"
1231ncbi_compiler_ver="0"
1232
1233if test "$GCC" = "yes" ; then
1234   compiler_ver="`$real_CXX -dumpfullversion 2>/dev/null \
1235       || $real_CXX -dumpversion 2>&1`"
1236   case "$compiler_ver" in
1237     *.*.* ) ;;
1238     * )
1239       fullversion="`$real_CXX --version | \
1240           sed -ne '1s/.*) \([[1-9]][[0-9.]]*\).*/\1/p'`"
1241       case "$fullversion" in
1242         "$compiler_ver".* ) compiler_ver=$fullversion ;;
1243       esac
1244       ;;
1245   esac
1246   compiler="GCC"
1247   ncbi_compiler="GCC"
1248   ncbi_compiler_ver="$compiler_ver"
1249   NCBI_FEATURE(GCC)
1250elif test "$KCC" = "yes" ; then
1251   compiler_ver="$kcc_ver"
1252   compiler="KCC"
1253   ncbi_compiler="KCC"
1254   ncbi_compiler_ver="`echo $kcc_ver | sed 's%^KAI .*C[[+]][[+]] \([[0-9.]]*\).*%\1%'`"
1255   NCBI_FEATURE(KCC)
1256elif test "$ICC" = "yes" ; then
1257   compiler_ver="$icc_ver"
1258   compiler="ICC"
1259   ncbi_compiler="ICC"
1260   ncbi_compiler_ver="`echo $icc_ver | sed 's%.*Version \([[0-9.]]*\).*%\1%'`"
1261   NCBI_FEATURE(ICC)
1262elif test "$Clang" = "yes" ; then
1263   compiler_ver="$clang_ver"
1264   case "$compiler_ver" in
1265      *Apple* )
1266         compiler=AppleClang
1267         ncbi_compiler=APPLE_CLANG
1268         NCBI_FEATURE(AppleClang)
1269         ;;
1270      * )
1271         compiler=LLVMClang
1272         ncbi_compiler=LLVM_CLANG
1273         NCBI_FEATURE(LLVMClang)
1274         ;;
1275   esac
1276   ncbi_compiler_ver="`echo $clang_ver | sed 's%.*version \([[0-9.]]*\).*%\1%'`"
1277   NCBI_FEATURE(Clang)
1278elif test "$VAC" = "yes" ; then
1279   compiler_ver="$vac_ver"
1280   compiler="VisualAge"
1281   ncbi_compiler="VISUALAGE"
1282   ncbi_compiler_ver="`echo $vac_ver | sed 's%.*[[Vv]]ersion:* 0*\([[0-9.]]*\).*%\1%'`"
1283   NCBI_FEATURE(VisualAge)
1284elif test "$CCC" = "yes" ; then
1285   compiler_ver="$ccc_ver"
1286   compiler=Compaq
1287   ncbi_compiler="COMPAQ"
1288   ncbi_compiler_ver="`echo $ccc_ver | sed 's%.*C[[+]][[+]] V\([[0-9.]]*\).*%\1%'`"
1289   NCBI_FEATURE(CompaqCompiler)
1290elif test "$CCE" = "yes" ; then
1291   compiler_ver="$cce_ver"
1292   compiler="Cray"
1293   ncbi_compiler="CRAY"
1294   ncbi_compiler_ver="`echo $cce_ver | sed 's%.*Version \([[0-9.]]*\).*%\1%'`"
1295   NCBI_FEATURE(Cray)
1296else
1297   case "$host_os" in
1298    solaris* )
1299      compiler_ver="`$real_CXX -V 2>&1`"
1300      case "$compiler_ver" in
1301        *WorkShop*Compilers*5\.0 )
1302          compiler="WorkShop5"
1303          ncbi_compiler="WORKSHOP"
1304          ncbi_compiler_ver="5.0" ;;
1305        *Sun*WorkShop*6*5\.1* )
1306          compiler="WorkShop51"
1307          ncbi_compiler="WORKSHOP"
1308          ncbi_compiler_ver="5.1" ;;
1309        *Sun*WorkShop*6*5\.2* )
1310          compiler="WorkShop52"
1311          ncbi_compiler="WORKSHOP"
1312          ncbi_compiler_ver="5.2" ;;
1313        *Sun*WorkShop*6*5\.3* )
1314          compiler="WorkShop53"
1315          ncbi_compiler="WORKSHOP"
1316          ncbi_compiler_ver="5.3" ;;
1317        *Forte*7*5\.4* )
1318          compiler="WorkShop54"
1319          ncbi_compiler="WORKSHOP"
1320          ncbi_compiler_ver="5.4" ;;
1321        *Sun*C*5\.5* )
1322          compiler="WorkShop55"
1323          ncbi_compiler="WORKSHOP"
1324          ncbi_compiler_ver="5.5" ;;
1325        *Sun*C*5\.8* )
1326          compiler="WorkShop58"
1327          ncbi_compiler="WORKSHOP"
1328          ncbi_compiler_ver="5.8" ;;
1329        *Sun*C*5\.9* )
1330          compiler="WorkShop59"
1331          ncbi_compiler="WORKSHOP"
1332          ncbi_compiler_ver="5.9" ;;
1333        *Sun*C*5\.10* )
1334          compiler="WorkShop510"
1335          ncbi_compiler="WORKSHOP"
1336          ncbi_compiler_ver="5.10" ;;
1337        *Sun*C*5\.11* )
1338          compiler="WorkShop511"
1339          ncbi_compiler="WORKSHOP"
1340          ncbi_compiler_ver="5.11" ;;
1341      esac
1342      NCBI_FEATURE(WorkShop)
1343      ;;
1344
1345    irix* )
1346      compiler_ver="`$real_CXX -version 2>&1`"
1347      case "$compiler_ver" in
1348        MIPSpro*Compilers:*Version*7\.3* )
1349          compiler="MIPSpro73"
1350          ncbi_compiler="MIPSPRO"
1351          ncbi_compiler_ver="7.3"
1352          NCBI_FEATURE(MIPSpro)
1353          ;;
1354      esac
1355      ;;
1356
1357    cygwin* )
1358      case "$real_CXX" in
1359        *cl\.exe* | cl)
1360          compiler="MSVC"
1361          ncbi_compiler="MSVC"
1362          ncbi_compiler_ver="6.0"
1363          NCBI_FEATURE(MSVC)
1364          ;;
1365      esac
1366      ;;
1367   esac
1368fi
1369
1370changequote(, )dnl
1371#ncbi_compiler_ver="`echo $ncbi_compiler_ver | sed 's%\([0-9]\)\.\([0-9]\)\.\([0-9]\).*%\1\2\3%; s%\([0-9]\)\.\([0-9][0-9]*\).*%\1\2%; s%^\([0-9][0-9]\)$%\10%; s%^\([0-9]\)$%\100%'`"
1372case "$compiler:$ncbi_compiler_ver" in
1373    WorkShop*:?.?? )   ncbi_compiler_sed='s/\([0-9]\)\.\([0-9][0-9]\)/\1\20/' ;;
1374    WorkShop*:[6-9].?) ncbi_compiler_sed='s/\([0-9]\)\.\([0-9\)/\10\20/' ;;
1375    [GI]CC:??.? ) ncbi_compiler_sed='s/\([0-9][0-9]\)\.\([0-9]\)/\1\20/' ;;
1376    GCC:??.?.? | ICC:??.?.? | ICC:??.?.?.* | *Clang:??.?.? )
1377       ncbi_compiler_sed='s/\([0-9][0-9]\)\.\([0-9]\)\.\([0-9]\).*/\1\2\3/' ;;
1378    GCC:?? )    ncbi_compiler_sed='s/\([0-9][0-9]\)/\100/' ;;
1379    ICC:20??.?.? | ICC:20??.?.?.* )
1380       ncbi_compiler_sed='s/20\([0-9][0-9]\)\.\([0-9]\)\.\([0-9]\).*/\1\2\3/' ;;
1381    *:?.?.?)    ncbi_compiler_sed='s/\([0-9]\)\.\([0-9]\)\.\([0-9]\)/\1\2\3/' ;;
1382    *:?.??*)    ncbi_compiler_sed='s/\([0-9]\)\.\([0-9][0-9]\).*/\1\2/' ;;
1383    *:?.?)      ncbi_compiler_sed='s/\([0-9]\).\([0-9]\)/\1\20/' ;;
1384    *:?)        ncbi_compiler_sed='s/\([0-9]\)/\100/' ;;
1385changequote([, ])dnl
1386    *)    AC_MSG_ERROR([Do not know how to parse $compiler version number $ncbi_compiler_ver]) ;;
1387esac
1388ncbi_compiler_ver=`echo $ncbi_compiler_ver | sed "$ncbi_compiler_sed"`
1389compiler_version=$ncbi_compiler_ver
1390
1391# Possible values of NCBI_COMPILER_$ncbi_compiler, since acconfig.h is obsolete
1392if false; then
1393   AC_DEFINE(NCBI_COMPILER_GCC,       1, [Compiler name])
1394   AC_DEFINE(NCBI_COMPILER_KCC,       1, [Compiler name])
1395   AC_DEFINE(NCBI_COMPILER_ICC,       1, [Compiler name])
1396   AC_DEFINE(NCBI_COMPILER_APPLE_CLANG,1,[Compiler name])
1397   AC_DEFINE(NCBI_COMPILER_LLVM_CLANG,1, [Compiler name])
1398   AC_DEFINE(NCBI_COMPILER_WORKSHOP,  1, [Compiler name])
1399   AC_DEFINE(NCBI_COMPILER_MIPSPRO,   1, [Compiler name])
1400   AC_DEFINE(NCBI_COMPILER_VISUALAGE, 1, [Compiler name])
1401   AC_DEFINE(NCBI_COMPILER_COMPAQ,    1, [Compiler name])
1402   AC_DEFINE(NCBI_COMPILER_CRAY,      1, [Compiler name])
1403   AC_DEFINE(NCBI_COMPILER_MSVC,      1, [Compiler name])
1404   AC_DEFINE(NCBI_COMPILER_UNKNOWN,   1, [Compiler name])
1405fi
1406
1407AC_DEFINE_UNQUOTED(NCBI_COMPILER, "$ncbi_compiler", [Compiler name])
1408AC_DEFINE_UNQUOTED(NCBI_COMPILER_$ncbi_compiler, 1, [Compiler name])
1409AC_DEFINE_UNQUOTED(NCBI_COMPILER_VERSION, $ncbi_compiler_ver,
1410                   [Compiler version as three- or four-digit integer])
1411
1412
1413#### Additional check for pre-defined compilers
1414case "$compiler:$compiler_version" in
1415  MSVC:* )
1416    if test -z "$NCBI_COMPILER" ; then
1417       echo
1418       echo "Compiler \"${compiler}\" requires a special tuning, so you"
1419       echo "better use a special shell script located in \"compilers/*.sh\"!"
1420       NCBI_CAUTION([Do you still want to proceed (at your own risk)?])
1421       echo
1422    fi ;;
1423esac
1424
1425
1426#### Use full path to the compiler, if possible
1427changequote(, )dnl
1428
1429set $CC
1430x_CC="`type $1 | sed 's/.* \([^ ]*\)$/\1/'`"
1431if test ! -x "$x_CC" ; then
1432  x_CC="`which $1  2>/dev/null`"
1433fi
1434
1435if test -x "$x_CC" ; then
1436  shift
1437  CC="$x_CC $*"
1438  echo "adjusted C   compiler: $CC"
1439fi
1440CC_PATH="`dirname $x_CC`"
1441x_CC=
1442
1443set $CXX
1444x_CXX="`type $1 | sed 's/.* \([^ ]*\)$/\1/'`"
1445if test ! -x "$x_CXX" ; then
1446  x_CXX="`which $1  2>/dev/null`"
1447fi
1448
1449if test -x "$x_CXX" ; then
1450  shift
1451  CXX="$x_CXX $*"
1452  echo "adjusted C++ compiler: $CXX"
1453fi
1454CXX_PATH="`dirname $x_CXX`"
1455
1456if test "$with_static_exe" = "yes"; then
1457   C_LINK='$(top_srcdir)/scripts/common/impl/favor-static $(CC)'
1458   LINK='$(top_srcdir)/scripts/common/impl/favor-static $(CXX)'
1459else
1460   C_LINK='$(CC)'
1461   LINK='$(CXX)'
1462fi
1463
1464### Which of these is better?
1465#compiler_root=`dirname CXX_PATH`
1466compiler_root=`echo $x_CXX | sed -ne 's:\(.*\)[/\\]bin[/\\].*:\1:p'`
1467x_CXX=
1468
1469changequote([, ])dnl
1470
1471
1472#### Multi-Thread safety
1473# Historically off by default; respect that when reconfiguring old builds.
1474if test -z "$with_mt" -a -f "$NCBI_OLD_STATUS_DIR/-MT.enabled"; then
1475    with_mt=no
1476fi
1477
1478if test "$with_mt" != "no" ; then
1479   with_mt=yes
1480   case "$host_os:$compiler" in
1481    darwin* | irix* | cygwin* | *:Cray ) ;;
1482    solaris*:WorkShop*       )  : ${MT_FLAG:="-mt"} ;;
1483    solaris*:GCC             )  : ${MT_FLAG:="-pthreads"} ;;
1484    *:KCC                    )  : ${MT_FLAG:="--thread_safe"} ;;
1485    *:Compaq | *:GCC | *:ICC | *Clang )
1486                                : ${MT_FLAG:="-pthread"} ;;
1487    *:VisualAge              )  : ${MT_FLAG:="-qthreaded"} ;;
1488    * )
1489       msg="Do not know how to build MT-safe with compiler $CXX $compiler_ver"
1490       case "$with_mt" in
1491          yes ) AC_MSG_ERROR([$msg]) ;;
1492          ''  ) AC_MSG_WARN([$msg]); with_mt=no ;;
1493       esac
1494       ;;
1495   esac
1496fi
1497
1498case "$host_os:$compiler" in
1499  solaris2.10:GCC ) : ${THREAD_LIBS:="-lposix4"} ;;
1500  solaris*        ) : ${THREAD_LIBS:="-lpthread -lposix4"} ;;
1501  freebsd*        ) : ${THREAD_LIBS:="-pthread"} ;; # for LMDB in ST builds
1502  *               ) : ${THREAD_LIBS:="-lpthread"} ;;
1503esac
1504
1505if test "$with_mt" != "no" ; then
1506   CPPFLAGS="$CPPFLAGS -D_MT -D_REENTRANT -D_THREAD_SAFE"
1507   LIBS="$LIBS $THREAD_LIBS"
1508   case "$host_os:$compiler" in
1509     solaris2.??:* | solaris*:GCC | *:Compaq | irix* | aix* | darwin* | cygwin*)
1510        NCBIATOMIC_LIB=
1511        ;;
1512     *:GCC | *:ICC | *Clang | linux*:KCC )
1513        case "$host_cpu" in
1514           i?86 | powerpc* | ppc* | x86_64 | sparc* | aarch64 )
1515              NCBIATOMIC_LIB=
1516              ;;
1517           * ) NCBIATOMIC_LIB=xncbi ;;
1518        esac
1519        ;;
1520     *:WorkShop* | solaris*:KCC )
1521        NCBIATOMIC_LIB=xncbi
1522        ncbicntr="ncbicntr_workshop ncbiatomic_workshop"
1523        ;;
1524     * ) NCBIATOMIC_LIB=xncbi ;;
1525   esac
1526   case "$compiler" in
1527      GCC | LLVMClang ) # Not yet AppleClang, as of version 11.
1528         : ${OPENMP_FLAGS=-fopenmp}
1529         ;;
1530      ICC )
1531         : ${OPENMP_FLAGS=-qopenmp -qopenmp-link=static}
1532         ;;
1533      WorkShop* )
1534         : ${OPENMP_FLAGS=-xopenmp=parallel}
1535         ;;
1536   esac
1537   if test "$with_openmp" = yes; then
1538      MT_FLAG="$MT_FLAG $OPENMP_FLAGS"
1539      OPENMP_FLAGS=
1540   fi
1541   mt_sfx="MT"
1542   NCBI_FEATURE(MT)
1543else
1544   CPPFLAGS="$CPPFLAGS -DNCBI_WITHOUT_MT"
1545   MT_FLAG=
1546   NCBIATOMIC_LIB=
1547   OPENMP_FLAGS=
1548   mt_sfx=""
1549fi
1550MT_SFX="${mt_sfx}"
1551AC_SUBST(MT_SFX)
1552
1553CFLAGS="$MT_FLAG $CFLAGS"
1554CXXFLAGS="$MT_FLAG $CXXFLAGS"
1555LDFLAGS="$MT_FLAG $LDFLAGS"
1556
1557APP_LDFLAGS=
1558DLL_LDFLAGS=
1559
1560#### Provide default environment setup for known platforms/compilers
1561DEPFLAGS="-M"
1562DEPFLAGS_POST="" # Needed for VisualAge
1563OBJCXX_CXXFLAGS=
1564OBJCXX_LIBS=
1565case "$host_os:$compiler:$compiler_version" in
1566 solaris2\.6:GCC:* )
1567   echo "GCC compiler is not supported for:  $host"
1568   compiler=
1569   ;;
1570
1571 solaris*:GCC:* )
1572   STRIP="@:"
1573   ;;
1574
1575 linux*:ICC:??? | linux*:ICC:1??? )
1576   # -we70: "incomplete type is not allowed" should be an error, not a warning!
1577   # -wd2651: Suppress spurious "attribute does not apply to any entity"
1578   #          when deprecating enum values (via NCBI_STD_DEPRECATED).
1579   CFLAGS="-we70 $CFLAGS"
1580   CXXFLAGS="-we70 -wd2651 $CXXFLAGS"
1581   MATH_LIBS=-Wl,-lm # avoid static libimf in shared libs
1582   ;;
1583
1584 linux*:GCC:* )
1585    if test -r $srcdir/src/build-system/config.site.ncbi && test -d "$NCBI"
1586    then
1587       case "$compiler_version" in
1588          5?? ) CPPFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0 $CPPFLAGS" ;;
1589       esac
1590    fi
1591    ;;
1592
1593 irix*:GCC:* )
1594   if test "$with_debug" != "no" ; then
1595      LDFLAGS="-LD_LAYOUT:lgot_buffer=32 $LDFLAGS"
1596   fi
1597   ;;
1598
1599 solaris*:WorkShop* )
1600   CPPFLAGS="-D__EXTENSIONS__ $CPPFLAGS"
1601   CXXFLAGS="+w +w2 $CXXFLAGS"
1602   DEPFLAGS="-xM1"
1603   LDFLAGS="-xildoff $LDFLAGS"
1604   AR=${AR:="$CXX $MT_FLAG -xar -o"}
1605   STRIP="@:"
1606   if test "$with_symbols" = "no" -a "$with_profiling" != "yes" \
1607      -a "$with_strip" = "yes" ; then
1608      LDFLAGS="-s $LDFLAGS"
1609   fi
1610   # Recent versions default to DWARF, yielding much larger executables in
1611   # debug configurations; insist on STABS when the choice exists, even for
1612   # versions that already default to it.
1613   case "$with_symbols:$compiler" in
1614      no:* | *:WorkShop5[[0-4]] ) ;;
1615      * )
1616         CFLAGS="-xdebugformat=stabs $CFLAGS"
1617         CXXFLAGS="-xdebugformat=stabs $CXXFLAGS"
1618         ;;
1619   esac
1620   CXX_FILTER="2>&1 | \$(top_srcdir)/compilers/unix/cxx_filter.WorkShop.sh"
1621   LINK_FILTER="$CXX_FILTER"
1622   AR_FILTER="$CXX_FILTER"
1623   serial_ws50_rtti_kludge="rtti"
1624   ;;
1625
1626 irix*:MIPSpro73:* )
1627   COMMON_FLAGS="-fullwarn -brief_diagnostics -use_readonly_const -G0 -rdata_shared"
1628   # Warnings we disable (messages courtesy of "gettxt cc.cat.m:N")
1629   # 1107: A signed bit field has a length of 1 bit.
1630   # 1169: External/internal linkage conflicts with a previous declaration.
1631   # 1209: The controlling expression is constant. [while (0) et al.]
1632   # 1424: The %n1 is not used in declaring the argument types of %n2.
1633   # 1429: The type "long long" is nonstandard.
1634   # 1460: Function %n is redeclared "inline" after being called.
1635   # 1521: A nonstandard preprocessing directive is used.
1636   CFLAGS="$COMMON_FLAGS -woff 1209 $CFLAGS"
1637   CXXFLAGS="$COMMON_FLAGS -ansiW -ptused -FE:eliminate_duplicate_inline_copies -FE:template_in_elf_section -no_auto_include -LANG:std -LANG:ansi-for-init-scope -woff 1460,1521,1429,1169,1209,1107,1424 $CXXFLAGS"
1638   : ${CXXCPP:="$CXX -E -LANG:std"}
1639   LDFLAGS="-LANG:std -G0 -FE:eliminate_duplicate_inline_copies -FE:template_in_elf_section $LDFLAGS"
1640   CPPFLAGS="-D__LONGLONG $CPPFLAGS"
1641   CXX_FILTER="2>&1 | \$(top_srcdir)/compilers/unix/cxx_filter.$compiler.sh"
1642   ;;
1643
1644 cygwin*:GCC:* )
1645   CPPFLAGS="-D_GLIBCXX_USE_C99 $CPPFLAGS"
1646   with_dll="no"
1647   # : ${NETWORK_LIBS:="-lws2_32"}
1648   CONF_exe_ext=".exe"
1649   ;;
1650
1651 cygwin*:MSVC:* )
1652   with_dll="no"
1653   CFLAGS="/W4 /Od /Zi /DEBUG /D_DEBUG"
1654   CXXFLAGS="/W4 /Od /Zi /DEBUG /D_DEBUG"
1655   CPPFLAGS="/nologo $CPPFLAGS"
1656   LDFLAGS="/DEBUG"
1657   AR="lib.exe"
1658   RANLIB=":"
1659   STRIP="@:"
1660   CONF_obj_ext=".obj"
1661   CONF_lib_ext=".lib"
1662   CONF_dll_ext=".dll"
1663   CONF_lib_l_ext=".lib"
1664   CONF_lib_pre=" "
1665   CONF_lib_l_pre=" "
1666   CONF_exe_ext=".exe"
1667   CONF_f_compile="/c "
1668   CONF_f_outobj="/Fo"
1669   CONF_f_outlib="/OUT:"
1670   CONF_f_libpath="/LIBPATH:"
1671   CONF_f_outexe="/OUT:"
1672   script_shell=""
1673   make_shell=""
1674   ;;
1675
1676 *:VisualAge:* )
1677   # 1506-1108 (I) The use of keyword '__attribute__' is non-portable.
1678   CFLAGS="-qlanglvl=extc99 -qsuppress=1506-1108 $CFLAGS"
1679   # 1540-1663 (W) Incorrect assignment of a restrict qualified pointer.
1680   CXXFLAGS="-qrtti=all -qsuppress=1540-1663 $CXXFLAGS"
1681   DEPFLAGS="-E -M"
1682   DEPFLAGS_POST='>/dev/null 2>&1; (cat $*.u; rm -f $*.u)'
1683   ;;
1684
1685 *:Compaq:* )
1686   CPPFLAGS="-D__USE_STD_IOSTREAM $CPPFLAGS"
1687   CXXFLAGS="-tweak -nocompress -distinguish_nested_enums $CXXFLAGS"
1688   DEPFLAGS="$DEPFLAGS -distinguish_nested_enums"
1689   case "$host_os" in
1690      osf*)
1691        # Suppress link warnings; otherwise, we get "weak symbol multiply
1692        # defined" all over the place.
1693        LDFLAGS="-Wl,-S $LDFLAGS"
1694        # The linker sometimes needs a LOT of memory.
1695        LINK="ulimit -d \`ulimit -H -d\` && $LINK"
1696        ;;
1697   esac
1698   ;;
1699
1700 darwin*:GCC:* | darwin*:*Clang:* )
1701   case `uname -m` in
1702      *64 ) : ${with_64=yes} ;;
1703      *   ) : ${with_64=no}  ;;
1704   esac
1705   # Per <http://fink.sourceforge.net/doc/porting/shared.php>, it was
1706   # historically necessary to build plugins as Mach-O bundles rather than
1707   # dynamic libraries.  That's not such a big deal on modern Mac OS X
1708   # versions, so the Toolkit now defaults to building only the latter.
1709   CONF_dll_ext=".dylib"
1710   if test "$with_bundles" = yes; then
1711      CONF_loadable_ext=".so"
1712   else
1713      CONF_loadable_ext=".dylib"
1714   fi
1715   if test "$compiler" = AppleClang \
1716      ||  ("$compiler" = GCC  &&  $CXX -v 2>&1 | grep -q Apple) ; then
1717      CFLAGS="-fpascal-strings $CFLAGS"
1718      CXXFLAGS="-fpascal-strings $CXXFLAGS"
1719      if test "$compiler" = AppleClang; then
1720         try_old_sdks=no
1721      else
1722         try_old_sdks=$with_ncbi_public
1723         CXXFLAGS="-fno-permissive $CXXFLAGS"
1724      fi
1725      # -flat_namespace is necessary for proper handling of shared libraries
1726      # that don't themselves link against all their dependencies.
1727      LDFLAGS="-flat_namespace -headerpad_max_install_names $LDFLAGS"
1728
1729      if test "$try_old_sdks" = yes; then
1730         sdks='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk'
1731         case "$host_os" in
1732            darwin?.* | darwin10.* ) # Mac OS X 10.6.x or older
1733               TARGET='-mmacosx-version-min=10.5'
1734               sdks="/Developer/SDKs/MacOSX10.6.sdk"
1735               ;;
1736            * )
1737               TARGET='-mmacosx-version-min=10.7'
1738               ;;
1739         esac
1740         for sdk in $sdks; do
1741            if test -d "$sdk"; then
1742               TARGET="-isysroot $sdk $TARGET"
1743               break
1744            fi
1745         done
1746         CC="$CC $TARGET"
1747         CXX="$CXX $TARGET"
1748      fi
1749   else
1750      LDFLAGS="-Wl,-flat_namespace -Wl,-headerpad_max_install_names $LDFLAGS"
1751   fi
1752   if test -f /usr/include/dlfcn.h; then
1753      # may be able to do without /sw, so ignore it by default
1754      :
1755   elif test -f /sw/include/dlfcn.h; then
1756      CPPFLAGS="-I/sw/include $CPPFLAGS"
1757      LDFLAGS="-L/sw/lib $LDFLAGS"
1758   else
1759      AC_MSG_WARN([No dlfcn.h in /usr/include or /sw/include.])
1760   fi
1761   case "$CPPFLAGS $LIBS" in
1762      *sw/*) ;;
1763      *)
1764         if test -d "$orig_NCBI/safe-sw"; then
1765             CPPFLAGS="-I$orig_NCBI/safe-sw/include $CPPFLAGS"
1766             LDFLAGS="-L$orig_NCBI/safe-sw/lib $LDFLAGS"
1767         fi
1768         ;;
1769   esac
1770   : ${with_x=${with_xpm-no}}
1771
1772   # CPPFLAGS="-F/System/Library/Frameworks/CoreServices.framework/Frameworks $CPPFLAGS"
1773   LIBS="-Wl,-framework,ApplicationServices $LIBS"
1774
1775   OBJCXX_CXXFLAGS='-x objective-c++'
1776   OBJCXX_LIBS='-lobjc'
1777   FOUNDATION_LIBS='-framework Foundation'
1778
1779   # New in macOS 10.12; don't attempt to use on older versions
1780   ac_cv_func_clock_gettime=no
1781   ac_cv_search_clock_gettime=no
1782   ;;
1783esac
1784
1785
1786#### Set makefile variables for platform-specific includes
1787changequote(, )dnl
1788COMPILER=`echo $ncbi_compiler | tr '[A-Z]' '[a-z]'`
1789OSTYPE=`echo $host_os | sed -e 's/[0-9.]*$//; s/-gnu[^-]*$//; y/A-Z/a-z/'`
1790changequote([, ])dnl
1791
1792
1793#### Check if the compiler matches one of supported compilers on this platform
1794if test -z "$compiler" ; then
1795   cat <<EOF
1796
1797  Compiler $CXX $compiler_ver is not fully supported.
1798  Consult doc/config.html\#ref_Compilers for the list of
1799  fully supported platforms/compilers.
1800EOF
1801   NCBI_CAUTION([Do you still want to proceed (at your own risk)?])
1802   echo
1803   compiler="UNKNOWN"
1804fi
1805
1806
1807C_LIBS=$LIBS
1808
1809
1810ARCH_CPPFLAGS=
1811#### architecture settings, and extra C++ LIBS
1812if test "$with_64" = "yes" ; then
1813   bit64_sfx="64"
1814   case "$host:$compiler" in
1815    sparc-sun-solaris*:WorkShop5 | sparc-sun-solaris*:KCC )
1816      ARCH_CFLAGS="-xtarget=ultra -xarch=v9"
1817      ;;
1818    sparc-sun-solaris*:WorkShop51 )
1819      ARCH_CFLAGS="-xtarget=ultra -xarch=v9"
1820      LIBS="-Bstatic -L$CXX_PATH/../lib -lCstd -lCrun -Bdynamic $LIBS -lc"
1821      ;;
1822    *solaris*:WorkShop59 | *solaris*:WorkShop51? )
1823      ARCH_CFLAGS="-m64"
1824      LIBS="-lCstd -lCrun $LIBS -lc"
1825      ;;
1826changequote(, )dnl
1827    *solaris*:WorkShop5* )
1828      ARCH_CFLAGS="-xtarget=generic64"
1829      # Redundant for programs, but necessary for dlopen-able shared libs,
1830      # at least in the x86 ReleaseMT configuration.
1831      LIBS="-lCstd -lCrun $LIBS -lc"
1832      ;;
1833changequote([, ])dnl
1834    mips*:GCC )
1835      ARCH_CFLAGS="-mips64"
1836      ;;
1837    *:GCC | *Clang )
1838      # May not work prior to GCC 3.1.
1839      ARCH_CFLAGS="-m64"
1840      case $host_os in darwin*) ARCH_CPPFLAGS="-m64" ;; esac
1841      ;;
1842
1843    mips-sgi-irix*:MIPSpro73 )
1844      ARCH_CFLAGS="-64"
1845      CPPFLAGS="$ARCH_CFLAGS $CPPFLAGS"
1846      AR=${AR:="$CXX $ARCH_CFLAGS -ar -WR,-v -o"}
1847      ;;
1848    mips-sgi-irix*:KCC )
1849      ARCH_CFLAGS="-64"
1850      ;;
1851    * )
1852      AC_MSG_ERROR([Do not know how to compile 64-bit with compiler $CXX $compiler_ver $host:$compiler])
1853      ;;
1854   esac
1855else
1856   bit64_sfx=
1857   ARCH_CFLAGS=
1858   if test "$with_64" = "no" ; then
1859      case "$host:$compiler" in
1860       *solaris*:WorkShop* | *solaris*:KCC )
1861         ARCH_CFLAGS="-xtarget=generic"
1862         ;;
1863       mips*:GCC )
1864         ARCH_CFLAGS="-mipsn32"
1865         ;;
1866       *:GCC | *Clang )
1867         # May not work prior to GCC 3.1.
1868         ARCH_CFLAGS="-m32"
1869         case $host_os in darwin*) ARCH_CPPFLAGS="-m32" ;; esac
1870         ;;
1871
1872       mips-sgi-irix*:MIPSpro73 )
1873         ARCH_CFLAGS="-n32"
1874         CPPFLAGS="$ARCH_CFLAGS $CPPFLAGS"
1875         AR=${AR:="$CXX $ARCH_CFLAGS -ar -WR,-v -o"}
1876         ;;
1877       mips-sgi-irix*:KCC )
1878         ARCH_CFLAGS="-n32"
1879         ;;
1880       * )
1881         # Just a warning, since 32-bit mode is typically the default anyway...
1882         AC_MSG_WARN([Do not know how to compile 32-bit with compiler $CXX $compiler_ver $host:$compiler])
1883         ;;
1884      esac
1885   fi
1886   case "$host:$compiler" in
1887    *solaris*:WorkShop5 )
1888      LIBS="-Bstatic -L$CXX_PATH/../SC5.0/lib -lm -Bdynamic $LIBS"
1889      MATH_LIBS=" "
1890      ;;
1891    *solaris*:WorkShop51 )
1892      LIBS="-Bstatic -L$CXX_PATH/../lib -lCstd -lCrun -lm -Bdynamic $LIBS -lc"
1893      MATH_LIBS=" "
1894      ;;
1895    sparc-sun-solaris*:WorkShop54 )
1896      # Using this (still very conservative) non-generic XARCH flavor allows
1897      # compiler to use the extended instruction set which reportedly speeds
1898      # up the locking of at least some STL classes by allowing them to use
1899      # atomic increment instead of mutex;  also seems to fix something that
1900      # caused misterios basic_string<> related crashes in the
1901      # WorkShop54 -xarch=v8 -mt configuration).
1902      ARCH_CFLAGS="-xarch=v8plus"
1903      LIBS="-lCstd $LIBS -lCrun -lc"
1904      ;;
1905changequote(, )dnl
1906    *solaris*:WorkShop5* )
1907      # MATH_LIBS=" "
1908      # Redundant for programs, but necessary for dlopen-able shared libs,
1909      # at least in the x86 ReleaseMT configuration.
1910      LIBS="-lCstd $LIBS -lCrun -lc"
1911      ;;
1912changequote([, ])dnl
1913    *irix*:MIPSpro73 | *irix*:KCC )
1914      ARCH_CFLAGS="-n32"
1915      ;;
1916   esac
1917fi
1918
1919case "$host_os:$host_cpu" in
1920   linux*:alpha*)
1921      ARCH_CFLAGS="-mieee $ARCH_CFLAGS"
1922      ;;
1923esac
1924
1925CPPFLAGS="$ARCH_CPPFLAGS $CPPFLAGS"
1926CFLAGS="$ARCH_CFLAGS $CFLAGS"
1927CXXFLAGS="$ARCH_CFLAGS $CXXFLAGS"
1928LDFLAGS="$ARCH_CFLAGS $LDFLAGS"
1929
1930: ${MATH_LIBS:="-lm"}
1931
1932### Math lib to be always linked in
1933LIBS="$MATH_LIBS $LIBS"
1934C_LIBS="$MATH_LIBS $C_LIBS"
1935
1936### Should go before any test compiler runs
1937AC_LANG_PUSH(C)
1938AC_GNU_SOURCE
1939AC_LANG_POP(C)
1940
1941if test -n "$with_64"; then
1942   AC_CACHE_CHECK([whether this system supports --with(out)-64],
1943      ncbi_cv_sys_with64_ok,
1944      [AC_LINK_IFELSE([
1945          AC_LANG_PROGRAM([@%:@include <string>],
1946                          [std::string* sp = new std::string("foo");])],
1947          ncbi_cv_sys_with64_ok=yes, ncbi_cv_sys_with64_ok=no)])
1948   if test "$ncbi_cv_sys_with64_ok" = no; then
1949      AC_MSG_ERROR([cannot continue; please try different options])
1950   fi
1951fi
1952
1953case "$host_os:$compiler" in
1954   darwin*:GCC | darwin*Clang )
1955      AC_CACHE_CHECK([whether $CC supports -Wl,-rpath],
1956         ncbi_cv_prog_cc_wl_rpath,
1957         [orig_LDFLAGS=$LDFLAGS
1958          LDFLAGS="-Wl,-rpath,. $LDFLAGS"
1959          AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
1960             [ncbi_cv_prog_cc_wl_rpath=yes], [ncbi_cv_prog_cc_wl_rpath=no])
1961          LDFLAGS=$orig_LDFLAGS])
1962      ;;
1963   cygwin* )
1964      ;;
1965   *:GCC | *:ICC | *Clang )
1966      AC_CACHE_CHECK([whether $CC has an option to export all symbols],
1967         ncbi_cv_prog_cc_export_all,
1968         [orig_LDFLAGS=$LDFLAGS
1969          ncbi_cv_prog_cc_export_all=no
1970          for x in -Wl,--export-all-symbols -Wl,-export-dynamic -rdynamic \
1971                   -Wl,-E; do
1972             LDFLAGS="$x $orig_LDFLAGS"
1973             AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
1974                [ncbi_cv_prog_cc_export_all=$x])
1975             test "x$ncbi_cv_prog_cc_export_all" = "xno"  ||  break
1976          done
1977          LDFLAGS=$orig_LDFLAGS])
1978      test "$ncbi_cv_prog_cc_export_all" = no  || \
1979         LDFLAGS="$ncbi_cv_prog_cc_export_all $LDFLAGS"
1980      AC_CACHE_CHECK([whether $CC supports -Wl,--{en,dis}able-new-dtags],
1981         ncbi_cv_prog_cc_new_dtags,
1982         [orig_LDFLAGS=$LDFLAGS
1983          LDFLAGS="-Wl,--enable-new-dtags $LDFLAGS"
1984          AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
1985             [ncbi_cv_prog_cc_new_dtags=yes], [ncbi_cv_prog_cc_new_dtags=no])
1986          LDFLAGS=$orig_LDFLAGS])
1987      if test "$ncbi_cv_prog_cc_new_dtags" = yes; then
1988          if test "$with_hard_runpath" = yes; then
1989             LDFLAGS="-Wl,--disable-new-dtags $LDFLAGS"
1990          else
1991             LDFLAGS="-Wl,--enable-new-dtags $LDFLAGS"
1992          fi
1993      fi
1994      ;;
1995esac
1996
1997AC_CACHE_CHECK([whether $CC has an option to discard unneeded shared libraries],
1998   ncbi_cv_prog_cc_as_needed,
1999   [orig_LDFLAGS=$LDFLAGS
2000    ncbi_cv_prog_cc_as_needed=no
2001    for x in -Wl,--as-needed; do
2002       LDFLAGS="$orig_LDFLAGS $x"
2003       AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
2004          [ncbi_cv_prog_cc_as_needed=$x])
2005       test "x$ncbi_cv_prog_cc_as_needed" = "xno"  ||  break
2006    done
2007    LDFLAGS=$orig_LDFLAGS])
2008case "$ncbi_cv_prog_cc_as_needed" in
2009   -Wl,--as-needed )
2010      AS_NEEDED=-Wl,--as-needed
2011      NO_AS_NEEDED=-Wl,--no-as-needed
2012      ;;
2013   no )
2014      AS_NEEDED=
2015      NO_AS_NEEDED=
2016      ;;
2017esac
2018
2019AC_CACHE_CHECK([whether $CC has an option to link in whole static archives],
2020   ncbi_cv_prog_cc_whole_archive,
2021   [orig_LDFLAGS=$LDFLAGS
2022    ncbi_cv_prog_cc_whole_archive=no
2023    for x in -Wl,--whole-archive; do
2024       LDFLAGS="$orig_LDFLAGS $x `echo $x | sed -e 's/--/--no-/'`"
2025       AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
2026          [ncbi_cv_prog_cc_whole_archive=$x])
2027       test "x$ncbi_cv_prog_cc_whole_archive" = "xno"  ||  break
2028    done
2029    LDFLAGS=$orig_LDFLAGS])
2030case "$ncbi_cv_prog_cc_whole_archive" in
2031   -Wl,--whole-archive )
2032      WHOLE_ARCHIVE=-Wl,--whole-archive
2033      NO_WHOLE_ARCHIVE=-Wl,--no-whole-archive
2034      ;;
2035   no )
2036      WHOLE_ARCHIVE=
2037      NO_WHOLE_ARCHIVE=
2038      ;;
2039esac
2040
2041case "$compiler" in
2042 *Clang)
2043   CFLAGS="$CFLAGS -Wno-deprecated-register"
2044   CXXFLAGS="$CXXFLAGS -Wno-deprecated-register"
2045
2046   case "$host_os:$CXX" in
2047      darwin[[0-9]].*:/usr/bin/* | darwin1[[0-2]].*:/usr/bin/* )
2048         ncbi_cv_prog_cxx_stdlib_libcxx=no
2049         ;;
2050   esac
2051
2052   AC_CACHE_CHECK([whether $CXX supports -stdlib=libc++],
2053      ncbi_cv_prog_cxx_stdlib_libcxx,
2054      [orig_CXX=$CXX
2055       CXX="$orig_CXX -stdlib=libc++"
2056       AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@include <stdexcept>],
2057             [std::logic_error le("Inconceivable!");])],
2058          [ncbi_cv_prog_cxx_stdlib_libcxx=yes],
2059          [ncbi_cv_prog_cxx_stdlib_libcxx=no])
2060       CXX=$orig_CXX])
2061   test "$ncbi_cv_prog_cxx_stdlib_libcxx" = no  ||  CXX="$CXX -stdlib=libc++"
2062   ;;
2063 *)
2064   ncbi_cv_prog_cxx_stdlib_libcxx=no
2065   ;;
2066esac
2067
2068AC_CHECK_DECL([_LIBCPP_VERSION], [], [], [@%:@include <iosfwd>])
2069
2070AC_CACHE_CHECK([how to enable C++ '14 features in $CXX],
2071   ncbi_cv_prog_cxx_14,
2072   [orig_CXX=$CXX
2073    ncbi_cv_prog_cxx_14=no
2074    for x in -std=gnu++14 ''; do
2075       CXX="$orig_CXX $x"
2076       AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@include <list>],
2077          [std::list<int> l; auto it = std::cbegin(l);])],
2078          [ncbi_cv_prog_cxx_14=$x])
2079          test "x$ncbi_cv_prog_cxx_14" = "xno"  ||  break
2080       done
2081       CXX=$orig_CXX])
2082if test "$ncbi_cv_prog_cxx_14" = no; then
2083   AC_MSG_ERROR([Please upgrade to a compiler supporting C++ '14, such as GCC 5 or newer.])
2084else
2085   CXX="$CXX $ncbi_cv_prog_cxx_14"
2086fi
2087
2088AC_LANG_PUSH(C)
2089AC_CACHE_CHECK([how to enable C '11 or at least '99 features in $CC],
2090   ncbi_cv_prog_c_99,
2091   [orig_CC=$CC
2092    ncbi_cv_prog_c_99=no
2093    for x in -xc99=all "-std=gnu11 -fgnu89-inline" \
2094             "-std=gnu1x -fgnu89-inline" \
2095             "-std=gnu99 -fgnu89-inline" \
2096             "-std=gnu9x -fgnu89-inline"; do
2097       CC="$orig_CC $x"
2098       AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
2099          [ncbi_cv_prog_c_99=$x])
2100          test "x$ncbi_cv_prog_c_99" = "xno"  ||  break
2101       done
2102       CC=$orig_CC])
2103
2104if test "$host_cpu" != x86_64; then
2105   : ${with_sse42=no}
2106fi
2107
2108if test "${with_sse42-$with_optimization}" = yes; then
2109   orig_CC=$CC
2110   AC_CACHE_CHECK([whether $CC supports -msse4.2],
2111      ncbi_cv_prog_c_sse42,
2112      [orig_CC=$CC
2113       CC="$CC -msse4.2"
2114       AC_LINK_IFELSE(
2115          [AC_LANG_PROGRAM(
2116              [@%:@include <smmintrin.h>],
2117              [__m128i v;  _mm_cmpgt_epi64(v, v);])],
2118          [ncbi_cv_prog_c_sse42=yes],
2119          [ncbi_cv_prog_c_sse42=no])])
2120   if test $ncbi_cv_prog_c_sse42 = yes; then
2121      CC="$orig_CC -msse4.2"
2122      orig_CC=$CC
2123   elif test "$with_sse42" = yes; then
2124      AC_MSG_ERROR([SSE 4.2 support explicitly requested but unavailable.])
2125   else
2126      CC=$orig_CC
2127   fi
2128fi
2129AC_LANG_POP(C)
2130test "$ncbi_cv_prog_c_99" = no  ||  CC="$CC $ncbi_cv_prog_c_99"
2131
2132if test "${with_sse42-$with_optimization}" = yes; then
2133   orig_CXX=$CXX
2134   AC_CACHE_CHECK([whether $CXX supports -msse4.2],
2135      ncbi_cv_prog_cxx_sse42,
2136      [CXX="$CXX -msse4.2"
2137       AC_LINK_IFELSE(
2138          [AC_LANG_PROGRAM(
2139              [@%:@include <smmintrin.h>],
2140              [__m128i v;  _mm_cmpgt_epi64(v, v);])],
2141          [ncbi_cv_prog_cxx_sse42=yes],
2142          [ncbi_cv_prog_cxx_sse42=no])])
2143   if test $ncbi_cv_prog_cxx_sse42 = yes; then
2144      CXX="$orig_CXX -msse4.2"
2145      orig_CXX=$CXX
2146   elif test "$with_sse42" = yes; then
2147      AC_MSG_ERROR([SSE 4.2 support explicitly requested but unavailable.])
2148   else
2149      CXX=$orig_CXX
2150   fi
2151fi
2152
2153case "$host_os:$compiler" in
2154 solaris*:GCC )
2155   # On Solaris, GCC defaults to setting _XOPEN_SOURCE (to 500) only
2156   # in C++ mode.  Set it for C code as well to ensure consistent
2157   # header behavior, taking care to match the C standard version
2158   # (as enforced by <sys/feature_tests.h>).
2159   case "$ncbi_cv_prog_c_99" in
2160      no) CC="$CC -D_XOPEN_SOURCE=500" ;;
2161      *)  CC="$CC -D_XOPEN_SOURCE=600" ;;
2162   esac
2163   ;;
2164esac
2165
2166
2167### large file support (switch to AC_SYS_LARGEFILE?)
2168case "$host_os:$compiler:$compiler_version" in
2169    cygwin* ) with_lfs=no ;;
2170    *:GCC:* | *:ICC:* | *Clang:* ) : ${with_lfs=yes} ;;
2171esac
2172
2173if test "$with_lfs" = "yes" ; then
2174   LFSFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
2175   # Modern BSD-based systems (including Mac OS X) already use a 64-bit
2176   # off_t, but don't necessarily provide explicit ...64 variants of all
2177   # relevant functions.
2178   case "$host_os" in
2179      *bsd* | darwin* ) ;;
2180      * ) LFSFLAGS="$LFSFLAGS -D_LARGEFILE64_SOURCE" ;;
2181   esac
2182   CPPFLAGS="$LFSFLAGS $CPPFLAGS"
2183fi
2184
2185tabchar='	'
2186wschars=" $tabchar"
2187wsrx="[[$wschars]]"
2188
2189#### Flags to enable (potentially unsafe) extra optimization.
2190if test "$skip_fast_flags" = no -a -z "$DEF_FAST_FLAGS" ; then
2191   case "$compiler:$compiler_version" in
2192      GCC:* | *Clang:* )
2193        DEF_FAST_FLAGS="-O3 -finline-functions -fstrict-aliasing"
2194        # DEF_FAST_FLAGS="$DEF_FAST_FLAGS -ffast-math" ;;
2195        if test "$with_profiling" != "yes"; then
2196           # incompatible with -pg
2197           DEF_FAST_FLAGS="$DEF_FAST_FLAGS -fomit-frame-pointer"
2198        fi
2199        ;;
2200      WorkShop5[[89]]* | WorkShop510 )
2201        # Limit optimization to -xO2 (-O now maps to -xO3) due to compiler bugs.
2202        subst="s/[$wsrx]-x*O[[1-9]]*//g"
2203        CFLAGS="`  echo \" $CFLAGS\"   | sed -e \"$subst\"` -xO2"
2204        CXXFLAGS="`echo \" $CXXFLAGS\" | sed -e \"$subst\"` -xO2"
2205        LDFLAGS="` echo \" $LDFLAGS\"  | sed -e \"$subst\"` -xO2"
2206        DEF_FAST_FLAGS="-xO2"
2207        ;;
2208      WorkShop* )
2209        DEF_FAST_FLAGS="-fast"
2210        case "$with_ncbi_public:$host_cpu" in
2211           yes:sparc* )
2212              DEF_FAST_FLAGS="$DEF_FAST_FLAGS -xtarget=ultra"
2213              ;;
2214           *:i?86)
2215              case "$compiler_ver" in
2216                *5.[[0-4]]*)
2217                  # Work around a WorkShop standard library bug.
2218                  DEF_FAST_FLAGS="$DEF_FAST_FLAGS -D_RWSTD_NO_TEST_AND_SET"
2219                  ;;
2220              esac
2221              ;;
2222        esac
2223        # (Re)include ARCH_CFLAGS here because -fast implies -xtarget=native.
2224        DEF_FAST_FLAGS="$DEF_FAST_FLAGS $ARCH_CFLAGS"
2225        ;;
2226      KCC:* )
2227        DEF_FAST_FLAGS="+K3"
2228        case "$host_os" in
2229           solaris* )  DEF_FAST_FLAGS="$DEF_FAST_FLAGS -fast $ARCH_CFLAGS" ;;
2230        esac
2231        ;;
2232      ICC:??? | ICC:1??? )
2233        # Core 2; ICC 11 goes up to SSE4.2 (i7), ICC 12 up to CORE-AVX-I
2234        DEF_FAST_FLAGS="-O3 -axSSSE3 -ip"
2235        ;;
2236      ICC:* )
2237        DEF_FAST_FLAGS="-O3 -ffp-model=fast -march=corei7" # -ipo
2238        ;;
2239      MIPSpro* )
2240        # -Ofast would be preferable, but runs into resource limits when
2241        # building libxblast.so. :-/
2242        DEF_FAST_FLAGS="-O2"
2243        ;;
2244      Compaq:* )
2245        DEF_FAST_FLAGS="-fast"
2246        ;;
2247      * )
2248        DEF_FAST_FLAGS="-O"
2249        ;;
2250   esac
2251fi
2252
2253: ${FAST_CFLAGS="$DEF_FAST_FLAGS"}
2254: ${FAST_CXXFLAGS="$DEF_FAST_FLAGS"}
2255: ${FAST_LDFLAGS="$DEF_FAST_FLAGS"}
2256
2257
2258#### DLLs
2259
2260# Generate position-independent code (PIC)
2261if test -z "$CFLAGS_DLL"  -a  -z "$CXXFLAGS_DLL" ; then
2262   case "$host_os:$compiler" in
2263    darwin*:GCC | darwin*Clang )
2264      CFLAGS_DLL="-fno-common"
2265      CXXFLAGS_DLL="-fno-common"
2266      ;;
2267    *:GCC | *Clang | linux* )
2268      CFLAGS_DLL="-fPIC"
2269      CXXFLAGS_DLL="-fPIC"
2270      ;;
2271    solaris*:WorkShop* | irix*:MIPSpro73 | \
2272    solaris*:KCC | irix*:KCC )
2273      CFLAGS_DLL="-KPIC"
2274      CXXFLAGS_DLL="-KPIC"
2275      ;;
2276   esac
2277fi
2278
2279# Flag for setting the runtime library search path
2280if test -z "$CONF_f_runpath" ; then
2281   case "$host_os:$compiler" in
2282    solaris* )
2283      CONF_f_runpath="-R"
2284      ;;
2285    linux*:[[GI]]CC | linux*Clang | *bsd*:GCC | *bsd*Clang | cygwin*:GCC \
2286    | osf*:GCC )
2287      CONF_f_runpath="-Wl,-rpath,"
2288      ;;
2289    irix*:* | linux*:KCC | *:Compaq )
2290      CONF_f_runpath="-rpath "
2291      ;;
2292    darwin* )
2293      test "$ncbi_cv_prog_cc_wl_rpath" = no  ||  CONF_f_runpath="-Wl,-rpath,"
2294      ;;
2295   esac
2296fi
2297case "$host_os:$ncbi_cv_prog_cc_wl_rpath" in
2298    linux*|solaris* )
2299        origin="'\$\$ORIGIN'"
2300        RUNPATH_ORIGIN="$CONF_f_runpath$origin"
2301        ;;
2302    darwin*:yes )
2303        origin='@executable_path'
2304        RUNPATH_ORIGIN="$CONF_f_runpath$origin"
2305        ;;
2306    * )
2307        origin=
2308        RUNPATH_ORIGIN="-DNCBI_RPO_SUFFIX_EATER="
2309        ;;
2310esac
2311
2312AC_PATH_PROG(DPKG_ARCHITECTURE, dpkg-architecture)
2313if test -x "$DPKG_ARCHITECTURE" \
2314    &&  $DPKG_ARCHITECTURE -qDEB_HOST_MULTIARCH >/dev/null 2>&1; then
2315   multiarch=`$DPKG_ARCHITECTURE -qDEB_HOST_MULTIARCH`
2316else
2317   multiarch=`echo $host | sed -e 's/-unknown-/-/; [s/^i[3-9]86-/^i\[3-9\]86/]'`
2318fi
2319
2320case "$compiler:$compiler_version:$with_bin_release:$ncbi_cv_prog_cxx_stdlib_libcxx" in
2321  GCC:*:yes:no | *Clang:*:yes:no )
2322    libstdcxx=`$CXX $LDFLAGS -print-file-name=libstdc++.a`
2323    case "$host_os:$libstdcxx" in
2324       cygwin*:/*)
2325          LDFLAGS="$LDFLAGS -Wl,--allow-multiple-definition"
2326          LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc"
2327          ;;
2328       *:/*)
2329          # LIBS="$libstdcxx $LIBS"
2330          # LINK=$C_LINK
2331          LDFLAGS="$LDFLAGS -static-libstdc++"
2332          ;;
2333       *)
2334          AC_MSG_ERROR([Unable to find static libstdc++ requested by --with-bin-release.])
2335          ;;
2336    esac
2337    ;;
2338  GCC:* | *Clang:*:*:* )
2339    # Need to specify runpath for compiler-provided libraries
2340    major=6 # true for all supported versions at present
2341    found=false
2342    for f in libstdc++.so.$major libgcc_s.so.1 libstdc++.a; do
2343        path=`$CXX $LDFLAGS -print-file-name=$f`
2344        dir=`dirname "$path"`
2345        abs_dir=`cd "$dir" && pwd`
2346        case "$dir:$abs_dir" in
2347            *:/lib | *:/lib64 | *:/usr/lib | *:/usr/lib32 | *:/usr/lib64 \
2348            | *:/usr/lib/$multiarch )
2349               # no rpath needed
2350               break
2351               ;;
2352            /* )
2353               found=true
2354               break
2355               ;;
2356        esac
2357    done
2358    if test "$found" = "true" -a -n "$CONF_f_runpath"; then
2359        LDFLAGS="$CONF_f_runpath$dir $LDFLAGS"
2360        case "$host_os" in
2361           osf*)
2362              # the linker doesn't merge -rpath flags...
2363              CONF_f_runpath="$CONF_f_runpath$dir:"
2364              ;;
2365           solaris*)
2366              # avoid interference from possible older versions in /usr/sfw.
2367              LDFLAGS="-L$dir $LDFLAGS"
2368              ;;
2369        esac
2370    fi
2371    ;;
2372  ICC:6?? )
2373    # Seems to use libcxa.so.1 even without -i_dynamic...
2374    LDFLAGS="$CONF_f_runpath$compiler_root/lib $LDFLAGS"
2375    ;;
2376  ICC:7?? )
2377    # Favor the static version, as libcxa.so.3 isn't exactly common....
2378    # (Undocumented, and unavailable at all in older versions. :-/)
2379    LDFLAGS="-static-libcxa $LDFLAGS"
2380    ;;
2381  ICC:8?? )
2382    # In principle, these settings should work, and avoid the need to
2383    # depend on Intel's libraries at runtime.
2384    #  APP_LDFLAGS="-static-libcxa $APP_LDFLAGS"
2385    #  DLL_LDFLAGS="-nodefaultlibs $DLL_LDFLAGS"
2386    # In practice, they can break applications that use plugins. :-/
2387    LDFLAGS="$CONF_f_runpath$compiler_root/lib $LDFLAGS"
2388    ;;
2389  ICC:9?? )
2390    # -i-static moved from common LDFLAGS to accommodate those few
2391    # DLLs (plugins for external programs such as Python) that need to
2392    # link ICC's libraries dynamically.
2393    APP_LDFLAGS="-i-static $APP_LDFLAGS"
2394    DLL_LDFLAGS="-i-static -nodefaultlibs $DLL_LDFLAGS"
2395    # Running icpc on a bunch of object files doesn't always ensure that
2396    # the C++ standard library is actually linked in, and we shouldn't
2397    # rely on help from wrapper scripts.
2398    LINK="$LINK -Kc++"
2399    ;;
2400  ICC:1???:* )
2401    case "$host_cpu" in
2402       i?86   ) intel_cpu_name=ia32      ;;
2403       x86_64 ) intel_cpu_name=intel64   ;;
2404       *      ) intel_cpu_name=$host_cpu ;;
2405    esac
2406    LDFLAGS="$CONF_f_runpath$compiler_root/lib/$intel_cpu_name $LDFLAGS"
2407    # Suppress "warning #10237: -lcilkrts linked in dynamically, static
2408    # library not available" which is not a problem in practice due to
2409    # as-needed linkage.
2410    APP_LDFLAGS="-static-intel -diag-disable 10237 $APP_LDFLAGS"
2411    DLL_LDFLAGS="-static-intel -diag-disable 10237 -nodefaultlibs $DLL_LDFLAGS"
2412    # Redundant for apps, but necessary for plugins to be adequately
2413    # self-contained, at least on 32-bit Linux.
2414    if test "$with_bin_release" = "yes"; then
2415       LDFLAGS="$LDFLAGS -static-libstdc++"
2416    elif test "$with_dll" != "no"; then
2417       LIBS="$LIBS -lstdc++ -lgcc_s"
2418    fi
2419    LINK="$LINK -Kc++"
2420    # Defining _GCC_NEXT_LIMITS_H ensures that <limits.h> chaining doesn't
2421    # stop short, as can otherwise happen. :-/
2422    CPPFLAGS="$CPPFLAGS -D_GCC_NEXT_LIMITS_H"
2423    ;;
2424   ICC:* )
2425    CPPFLAGS="$CPPFLAGS -D_GCC_NEXT_LIMITS_H"
2426    CFLAGS="$CFLAGS -ffp-model=precise"
2427    CXXFLAGS="$CXXFLAGS -ffp-model=precise"
2428    ;;
2429esac
2430
2431# DLLs and profiling don't mix on all platforms
2432if test "$with_profiling" = "yes" ; then
2433   case "$host_os" in
2434      linux*) # any others?
2435         case "$with_dll" in
2436            yes) AC_MSG_ERROR([This platform does not support DLL profiling.])
2437                 ;;
2438            no) ;;
2439            *) with_dll=no ;;
2440         esac
2441      ;;
2442   esac
2443fi
2444
2445# Whether to build DLLs or static (and whether by default, or forcibly)
2446LIB_OR_DLL="lib"
2447if test "$with_dll" = "yes" ; then
2448   case "$host_os:$compiler" in
2449    linux*:GCC | linux*Clang | irix* | solaris*:WorkShop* | linux*:ICC \
2450    | solaris*:GCC | osf* | darwin*:GCC | darwin*Clang | freebsd*:GCC \
2451    | freebsd*Clang | *:KCC )
2452      ;;
2453    * )
2454      echo
2455      echo "DLLs may not be buildable by $CXX $compiler_ver on $host!"
2456      NCBI_CAUTION([Do you still want to try build DLLs (at your own risk)?])
2457      echo
2458      ;;
2459   esac
2460fi
2461
2462case "$with_dll:$with_static" in
2463   yes:yes) LIB_OR_DLL="both"; dll_sfx="DLL+static" ;;
2464   yes:*)   LIB_OR_DLL="dll";  dll_sfx="DLL" ;;
2465   *:no)    AC_MSG_ERROR([--without-static requires --with-dll]) ;;
2466   *)       LIB_OR_DLL="lib";  dll_sfx=""  ;;
2467esac
2468
2469DLL=
2470DLL_LIB_SETTING='$(DLL_DLIB)'
2471IF_WITH_DLL=
2472UNLESS_WITH_DLL='# '
2473STATIC="-static"
2474USUAL_AND_DLL=both
2475USUAL_AND_LIB=both
2476
2477case "$LIB_OR_DLL" in
2478   dll)
2479       STATIC=
2480       USUAL_AND_DLL=dll
2481       ;;
2482   lib)
2483       DLL=-dll
2484       DLL_LIB_SETTING='$(DLL_LIB)'
2485       IF_WITH_DLL='# '
2486       UNLESS_WITH_DLL=
2487       USUAL_AND_LIB=lib
2488       ;;
2489esac
2490
2491AC_SUBST(DLL)
2492AC_SUBST(DLL_LIB_SETTING)
2493AC_SUBST(IF_WITH_DLL)
2494AC_SUBST(UNLESS_WITH_DLL)
2495AC_SUBST(STATIC)
2496AC_SUBST(USUAL_AND_DLL)
2497AC_SUBST(USUAL_AND_LIB)
2498
2499
2500#### GNU compiler::  common flags and definitions
2501if test "$compiler" = "GCC" ; then
2502   CFLAGS="-Wall -Wno-format-y2k $CFLAGS"
2503   CXXFLAGS="-Wall -Wno-format-y2k $CXXFLAGS"
2504   case "$host_os" in
2505      solaris* )  CPPFLAGS="-D__EXTENSIONS__ $CPPFLAGS" ;;
2506      irix*    )  CXXFLAGS="$CXXFLAGS -D_LANGUAGE_C_PLUS_PLUS" ;;
2507   esac
2508   # orig_CFLAGS=$CFLAGS
2509   # orig_CXXFLAGS=$CXXFLAGS
2510   # flag=-fno-merge-debug-strs
2511   # CFLAGS="$flag $CFLAGS"
2512   # CXXFLAGS="$flag $CXXFLAGS"
2513   # AC_CACHE_CHECK([whether GCC supports $flag], ncbi_cv_prog_gcc_nomerge,
2514   #    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],
2515   #                       ncbi_cv_prog_gcc_nomerge=yes,
2516   #                       ncbi_cv_prog_gcc_nomerge=no)])
2517   # if test "$ncbi_cv_prog_gcc_nomerge" = no; then
2518   #    CFLAGS=$orig_CFLAGS
2519   #    CXXFLAGS=$orig_CXXFLAGS
2520   # fi
2521fi
2522
2523
2524#### Clang compiler::  common flags and definitions
2525case "$compiler" in
2526   *Clang )
2527      CFLAGS="-Wall -Wno-format-y2k $CFLAGS"
2528      CXXFLAGS="-Wall -Wno-format-y2k $CXXFLAGS"
2529      ;;
2530esac
2531
2532
2533#### KAI compiler::  common flags and definitions
2534if test "$compiler" = "KCC" ; then
2535   AR=${AR:="$CXX $MT_FLAG -o"}
2536   CFLAGS="--display_error_number --c $CFLAGS"
2537   CXXFLAGS="--display_error_number --one_instantiation_per_object $CXXFLAGS"
2538   case "$host_os" in
2539      solaris* )  CPPFLAGS="-D__EXTENSIONS__ -D__STDC__=0 $CPPFLAGS" ;;
2540   esac
2541fi
2542
2543
2544#### Intel compiler::  common flags and definitions
2545if test "$compiler" = "ICC" ; then
2546   if test -n "$icc_license" ; then
2547      icc_CC="$CC"
2548      icc_CXX="$CXX"
2549      CC="./compilers/unix/cxx_filter.ICC.sh $CC"
2550      CXX="./compilers/unix/cxx_filter.ICC.sh $CXX"
2551   fi
2552fi
2553
2554
2555#### How to ensure that the compiler will account for potential aliasing
2556case "$compiler" in
2557   GCC | *Clang ) NO_STRICT_ALIASING=-fno-strict-aliasing ;;
2558   ICC ) NO_STRICT_ALIASING='-falias -ffnalias' ;;
2559   WorkShop* ) NO_STRICT_ALIASING='-xalias_level=any' ;;
2560   * ) NO_STRICT_ALIASING=
2561esac
2562
2563dnl Autoconf 2.62+ has an AC_PATH_PROGS_FEATURE_CHECK macro that could
2564dnl also be useful.
2565AX_CHECK_GNU_MAKE
2566AC_PATH_PROG(AWK, ${ac_cv_prog_AWK-awk})
2567AC_PATH_PROG(MAKE, ${ax_cv_gnu_make_command-make})
2568export MAKE
2569
2570#### Automatic generation of dependencies for/by the "make" utility
2571case "$host_os" in
2572   solaris* )  KeepStateTarget=".KEEP_STATE:" ;;
2573esac
2574
2575if test "$with_autodep" = "yes" ; then
2576   Rules="rules_with_autodep"
2577elif test "$with_autodep" = "no" ; then
2578   Rules="rules"
2579elif $MAKE --version 2>/dev/null | grep 'GNU Make' >/dev/null ; then
2580   Rules="rules_with_autodep"
2581else
2582   Rules="rules"
2583fi
2584
2585
2586### Support for precompiled headers
2587GCCPCH="#"
2588if test "$with_pch" = "yes"; then
2589   case "$compiler" in
2590      GCC | *Clang ) ;;
2591      * ) ncbi_cv_cxx_pch=no ;;
2592   esac
2593   AC_CACHE_CHECK([whether $CXX supports precompiled headers], ncbi_cv_cxx_pch,
2594      [echo '@%:@include <iostream>' > conftest.hpp
2595       echo $CXX $CPPFLAGS $CXXFLAGS -xc++-header -c conftest.hpp >&AS_MESSAGE_LOG_FD
2596       if $CXX $CPPFLAGS $CXXFLAGS -xc++-header -c conftest.hpp >&AS_MESSAGE_LOG_FD 2>&1 \
2597         &&  test -f conftest.hpp.gch; then
2598          ncbi_cv_cxx_pch=yes
2599       else
2600          ncbi_cv_cxx_pch=no
2601       fi])
2602   if test "$ncbi_cv_cxx_pch" = "yes"; then
2603      if test "$Rules" = "rules"; then
2604         AC_MSG_WARN([Your version of make does not fully support PCH-related dependencies.])
2605      fi
2606      CXXFLAGS="-DNCBI_USE_PCH $CXXFLAGS"
2607      GCCPCH=""
2608   fi
2609fi
2610
2611
2612#### Tools
2613AC_PROG_LN_S
2614case "$LN_S" in
2615    /*) ;;
2616    * ) LN_S=/bin/$LN_S ;;
2617esac
2618
2619AC_PROG_RANLIB
2620AC_CHECK_PROG(AR, ar, ar cr, ErrorCannotFind_AR)
2621if test "x$RANLIB" != "x:"; then
2622   AC_CACHE_CHECK([ranlib's effectiveness], ncbi_cv_prog_ranlib_effect,
2623      [AC_LANG_CONFTEST([AC_LANG_SOURCE([[int libfunc(void) { return 0; }]])])
2624       echo $CXX $CPPFLAGS $CXXFLAGS -c conftest.$ac_ext >&AS_MESSAGE_LOG_FD
2625       $CXX $CPPFLAGS $CXXFLAGS -c conftest.$ac_ext >&AS_MESSAGE_LOG_FD 2>&1
2626       echo $AR conftest.a conftest.o >&AS_MESSAGE_LOG_FD
2627       $AR conftest.a conftest.o >&AS_MESSAGE_LOG_FD 2>&1
2628       save_LIBS=$LIBS
2629       LIBS="conftest.a $LIBS"
2630       AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int libfunc(void);]],
2631                                       [[return libfunc();]])],
2632                      [ok_without=true], [ok_without=false])
2633       echo $RANLIB conftest.a >&AS_MESSAGE_LOG_FD
2634       $RANLIB conftest.a >&AS_MESSAGE_LOG_FD
2635       AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int libfunc(void);]],
2636                                       [[return libfunc();]])],
2637                      [ok_with=true], [ok_with=false])
2638       LIBS=$save_LIBS
2639       case $ok_with:$ok_without in
2640          true:false)  ncbi_cv_prog_ranlib_effect=positive ;;
2641          false:true)  ncbi_cv_prog_ranlib_effect=negative ;;
2642          true:true)   ncbi_cv_prog_ranlib_effect=neutral  ;;
2643          false:false) ncbi_cv_prog_ranlib_effect=unknown  ;;
2644       esac
2645      ])
2646   case "$ncbi_cv_prog_ranlib_effect" in
2647      negative) RANLIB=: ;;
2648      unknown)
2649        AC_MSG_WARN([Failed to make a working library with or without ranlib.])
2650        ;;
2651   esac
2652fi
2653if test "$with_strip" = yes; then
2654   AC_CHECK_PROG(STRIP, strip, strip, @:)
2655   AC_CACHE_CHECK([whether strip loses runtime type information],
2656      ncbi_cv_strip_loses_rtti,
2657      [if test "$cross_compiling" = yes; then
2658          case "$host_os" in
2659             darwin* ) ncbi_cv_strip_loses_rtti=yes ;;
2660             # No problems observed elsewhere so far.
2661             *       ) ncbi_cv_strip_loses_rtti=no  ;;
2662          esac
2663       else
2664          AC_LANG_CONFTEST([AC_LANG_PROGRAM(
2665                               [[@%:@include <iostream>
2666                                 @%:@include <typeinfo>
2667                                 struct SomeStruct { };]],
2668                               [[std::cout << typeid(SomeStruct).name();]])])
2669          echo $CXX $CPPFLAGS $CXXFLAGS $LDFLAGS -o conftest$ac_exeext \
2670             conftest.$ac_ext >&AS_MESSAGE_LOG_FD
2671          $CXX $CPPFLAGS $CXXFLAGS $LDFLAGS -o conftest$ac_exeext \
2672             conftest.$ac_ext >&AS_MESSAGE_LOG_FD 2>&1
2673          $STRIP conftest$ac_exeext
2674          if (ulimit -c 0; ./conftest$ac_exeext) >/dev/null 2>&1; then
2675             ncbi_cv_strip_loses_rtti=no
2676          else
2677             ncbi_cv_strip_loses_rtti=yes
2678          fi
2679          rm -rf conftest*
2680       fi])
2681   if test "$ncbi_cv_strip_loses_rtti" = "yes"; then
2682      NCBI_CAUTION([Do you still want to proceed (at your own risk)?])
2683   fi
2684else
2685   STRIP=@:
2686fi
2687
2688
2689# When using ccache and distcc together, ccache needs to be primary,
2690# so look for distcc(.sh) first.
2691
2692if test -x $orig_NCBI/bin/distcc.sh ; then
2693   : ${DISTCC=$orig_NCBI/bin/distcc.sh}
2694   : ${with_distcc=yes}
2695fi
2696
2697if test "$with_distcc" = "yes" ; then
2698   AC_PATH_PROG(DISTCC, distcc, distcc, [])
2699   if test -n "$DISTCC" ; then
2700      # Test distcc reasonably thoroughly to avoid possible gotchas.
2701      cat > distcctest.c << EOF
2702@%:@include <stddef.h>
2703@%:@if !defined(__GNUC__)  &&  !defined(offsetof)
2704@%:@  define offsetof(T, F) ((size_t)((char*) &(((T*) 0)->F) - (char*) 0))
2705@%:@endif
2706struct S { int x; };
2707int f() { return offsetof(struct S, x); }
2708EOF
2709      DISTCC_FALLBACK=0
2710      export DISTCC_FALLBACK
2711      AC_CACHE_CHECK([whether any distcc servers are available],
2712         ncbi_cv_prog_distcc_servers,
2713         [$DISTCC $CC -c distcctest.c 2>&AS_MESSAGE_LOG_FD
2714          case $? in
2715            # 102: bind failed
2716            # 103: connect failed
2717            # 106: bad hostspec
2718            # 107: I/O error
2719            # 109: protocol error
2720            # 113: access denied
2721            # 116: no hosts defined
2722            102 | 103 | 106 | 107 | 109 | 113 | 116 )
2723             ncbi_cv_prog_distcc_servers=no ;;
2724            * )
2725             ncbi_cv_prog_distcc_servers=yes ;;
2726          esac])
2727      if test "$ncbi_cv_prog_distcc_servers" = no; then
2728         AS_UNSET(DISTCC)
2729      fi
2730      if test -n "$DISTCC" ; then
2731         AC_CACHE_CHECK([whether $DISTCC is compatible with $CC],
2732            ncbi_cv_prog_distcc_vs_cc,
2733            [if $DISTCC $CC -c distcctest.c 2>&AS_MESSAGE_LOG_FD ; then
2734                ncbi_cv_prog_distcc_vs_cc=yes
2735             else
2736                ncbi_cv_prog_distcc_vs_cc=no
2737             fi])
2738         if test "$ncbi_cv_prog_distcc_vs_cc" = yes; then
2739            CC_WRAPPER="$DISTCC $CC_WRAPPER"
2740         else
2741            AS_UNSET(DISTCC)
2742         fi
2743      fi
2744      if test -n "$DISTCC" ; then
2745         AC_CACHE_CHECK([whether $DISTCC is compatible with $CXX],
2746            ncbi_cv_prog_distcc_vs_cxx,
2747            [mv distcctest.c distcctest.cpp
2748             if $DISTCC $CXX -c distcctest.cpp 2>&AS_MESSAGE_LOG_FD ; then
2749                ncbi_cv_prog_distcc_vs_cxx=yes
2750             else
2751                ncbi_cv_prog_distcc_vs_cxx=no
2752             fi])
2753         if test "$ncbi_cv_prog_distcc_vs_cxx" = yes; then
2754            CXX_WRAPPER="$DISTCC $CXX_WRAPPER"
2755         else
2756            AS_UNSET(DISTCC)
2757         fi
2758      fi
2759      rm -f distcctest.*
2760   elif test "$with_distcc" = "yes" ; then
2761      AC_MSG_WARN([distcc explicitly requested, but not found in PATH.])
2762   fi
2763   AS_UNSET(DISTCC_FALLBACK)
2764fi
2765
2766if test -z "$with_ccache"  -a  -n "$DISTCC"  -a  -z "$CCACHE_DIR" ; then
2767   # Using CCACHE together with DISTCC causes problems when the involved DISTCC
2768   # servers share the same home dir, as in that case the caches from
2769   # different servers can mix up rather badly, corrupting each other.
2770   # On the other hand, most NCBI accounts have $CCACHE_DIR automatically set
2771   # to a non-shared, per-machine location (such as "/tmp/.ccache-username").
2772   with_ccache="no"
2773fi
2774
2775if test "$with_ccache" != "no"; then
2776   AC_PATH_PROG(CCACHE, ccache)
2777   if test -n "$CCACHE" ; then
2778      if test -n "$CC_WRAPPER"; then
2779         CC_WRAPPER="CCACHE_PREFIX=$CC_WRAPPER $CCACHE"
2780      else
2781         CC_WRAPPER=$CCACHE
2782      fi
2783      if test -n "$CXX_WRAPPER"; then
2784         CXX_WRAPPER="CCACHE_PREFIX=$CXX_WRAPPER $CCACHE"
2785      else
2786         CXX_WRAPPER=$CCACHE
2787      fi
2788   elif test "$with_ccache" = "yes"; then
2789      AC_MSG_WARN([ccache explicitly requested, but not found in PATH.])
2790   fi
2791fi
2792
2793# Note the path, since syntax is version-specific....
2794AC_PATH_PROG(TAIL, tail)
2795AC_MSG_CHECKING([whether $TAIL accepts modern syntax (-n N)])
2796if $TAIL -n 1 config.log >/dev/null 2>&1; then
2797   TAIL_N="$TAIL -n "
2798   AC_MSG_RESULT(yes)
2799else
2800   TAIL_N="$TAIL -"
2801   AC_MSG_RESULT(no)
2802fi
2803
2804AC_PATH_PROG(BASENAME, basename)
2805AC_PATH_PROG(SED, sed)
2806AC_PATH_PROG(TOUCH, touch, [], /bin:/usr/bin:$PATH)
2807dnl AC_PATH_PROG(GREP, grep)
2808AC_PROG_EGREP
2809AC_MSG_CHECKING([how to run $EGREP quietly])
2810if test -z "`echo foo | $EGREP -q fo+ 2>>config.log || echo $?`"; then
2811   EGREP_Q="$EGREP -q"
2812elif test -z "`echo foo | $EGREP -s fo+ 2>>config.log || echo $?`"; then
2813   EGREP_Q="$EGREP -s"
2814else
2815   EGREP_Q=">/dev/null $EGREP"
2816fi
2817AC_MSG_RESULT($EGREP_Q)
2818
2819AC_CHECK_PROG(VALGRIND_PATH, valgrind, valgrind)
2820
2821AC_PATH_PROG(LDD, ldd, [], /bin:/usr/bin:$PATH)
2822if test -n "$LDD"; then
2823   AC_MSG_CHECKING([whether $LDD accepts -r])
2824   if $LDD -r /bin/ls >/dev/null 2>&1; then
2825      AC_MSG_RESULT(yes)
2826      LDD_R="$LDD -r"
2827   else
2828      AC_MSG_RESULT(no)
2829   fi
2830fi
2831
2832AC_PATH_PROG(UUIDGEN, uuidgen)
2833AC_PATH_PROG(CD_REPORTER, cd_reporter, [],
2834   [/am/ncbiapdata/bin:/Volumes/ncbiapdata/bin:$PATH])
2835
2836#### Check if "${build_root}" is defined;  provide a default one
2837if test -n "${with_build_root}" ; then
2838   build_root=${with_build_root}
2839fi
2840
2841signature_compiler=$compiler
2842case "$compiler" in
2843   GCC )
2844      if $CXX -v 2>&1 | $EGREP_Q 'LLVM'; then
2845         signature_compiler=LLVMGCC
2846      fi
2847      ;;
2848   *Clang )
2849      signature_compiler=Clang
2850      ;;
2851esac
2852
2853### Possibly add the version to the build directory name, but preseve
2854### the original default when reconfiguring.
2855if test -z "${with_version}" -a -n "${ncbi_cv_sys_xdir_ln}"; then
2856   with_version=${ncbi_cv_with_version:-no}
2857fi
2858if test -z "${build_root}" ; then
2859   build_root="${srcdir}/${signature_compiler}"
2860   case "$signature_compiler:$with_version" in
2861      *[[0-9]]:* | *:no) ;;
2862      *) build_root=${build_root}${compiler_version} ;;
2863   esac
2864   ncbi_cv_with_version=${with_version:-yes}
2865else
2866   : ${with_suffix:="no"}
2867fi
2868
2869
2870#### Release/Debug
2871case "${with_debug}:${with_optimization}" in
2872   no:*)
2873      release_debug=Release
2874      DEBUG_SFX=Release
2875      D_SFX=
2876      ;;
2877   yes:yes | :yes)
2878      release_debug=DebugOpt
2879      DEBUG_SFX=Debug
2880      D_SFX=d
2881      ;;
2882   *)
2883      release_debug=Debug
2884      DEBUG_SFX=Debug
2885      D_SFX=d
2886      ;;
2887esac
2888
2889if test "${with_max_debug-no}" != "no"; then
2890   case "$NCBI_OLD_STATUS_DIR" in
2891      *MaxDebug* ) max_tag=Max ;;
2892      *Debug*    )             ;;
2893      *          ) max_tag=Max ;;
2894   esac
2895fi
2896
2897
2898#### Profiling; try to turn on both function weight and basic-block counting
2899if test "$with_profiling" = "yes" ; then
2900   prof_sfx="Prof"
2901   case "$compiler" in
2902      Compaq)    PFFLAGS="-pg" ;;
2903      GCC)       PFFLAGS="-pg" ;;
2904      ICC)       PFFLAGS="-p" ;;
2905      *Clang)    PFFLAGS="-pg" ;;
2906      KCC)       PFFLAGS="-pg" ;;
2907      MIPSpro73) PFFLAGS="" ;; # pixie(1) adds info at runtime
2908      MSVC)      PFFLAGS="/PROFILE" ;;
2909      VisualAge) PFFLAGS="-pg" ;;
2910      WorkShop*) PFFLAGS="-pg -xprofile=tcov" ;;
2911      *)         PFFLAGS="-p" ;; # Fairly standard; shouldn't rely on -pg
2912   esac
2913   CFLAGS="$CFLAGS $PFFLAGS"
2914   CXXFLAGS="$CXXFLAGS $PFFLAGS"
2915   LDFLAGS="$LDFLAGS $PFFLAGS"
2916   STRIP="@:" # Stripping may lose profiling info
2917else
2918   prof_sfx=
2919fi
2920
2921
2922#### Code coverage
2923if test "$with_code_coverage" = "yes"; then
2924   case "$compiler" in
2925      GCC | *Clang )
2926         COVFLAGS="--coverage"
2927         ;;
2928      * )
2929         AC_MSG_ERROR([--with-code-coverage not implemented for $compiler])
2930         ;;
2931   esac
2932   CFLAGS="$CFLAGS $COVFLAGS"
2933   CXXFLAGS="$CXXFLAGS $COVFLAGS"
2934   LDFLAGS="$LDFLAGS $COVFLAGS"
2935fi
2936
2937
2938#### Determine whether this is implicitly a 64-bit platform
2939AC_TYPE_SIZE_T
2940AC_CHECK_SIZEOF(size_t)
2941ac_cv_sizeof_size_t=`echo "$ac_cv_sizeof_size_t" | tr -d '\r'`
2942NCBI_PLATFORM_BITS=`expr 8 \* $ac_cv_sizeof_size_t`
2943AC_DEFINE_UNQUOTED(NCBI_PLATFORM_BITS, $NCBI_PLATFORM_BITS,
2944                   [Define to the architecture size.])
2945if test $NCBI_PLATFORM_BITS -eq 64; then
2946   bit64_sfx=64
2947fi
2948
2949if test "$bit64_sfx" = 64 -o "$with_lfs" = "yes"; then
2950   NCBI_FEATURE(LFS)
2951fi
2952
2953
2954### Intel Thread Checker
2955if test "${with_tcheck=no}" != "no" ; then
2956   if test "${release_debug}${mt_sfx}" != "DebugMT" ; then
2957      AC_MSG_WARN([--with-tcheck is most likely to be effective in DebugMT builds.])
2958   fi
2959   if test "$compiler" = "ICC"; then
2960      case "$bit64_sfx" in
2961        64) tcbin=bin/32e ;;
2962        * ) tcbin=bin/32  ;;
2963      esac
2964      if test "$with_tcheck" != yes; then
2965         TCHECK_BIN=$with_tcheck/$tcbin
2966      fi
2967      AC_PATH_PROG(TCHECK_CL, tcheck_cl, [], $TCHECK_BIN:$PATH:$TCHECK_FALLBACK)
2968      if test -n "$TCHECK_CL"; then
2969         CFLAGS="$CFLAGS -tcheck -O0"
2970         CXXFLAGS="$CXXFLAGS -tcheck -O0"
2971         LDFLAGS="$LDFLAGS -tcheck -O0 -L`dirname $TCHECK_CL`"
2972      fi
2973   fi
2974   CPPFLAGS="$CPPFLAGS -DNCBI_TCHECK"
2975fi
2976
2977
2978#### Add "Release"/"Debug", "MT", "DLL", "64", "_p" suffixes to "${build_root}"
2979if test "$with_suffix" != "no" ; then
2980   build_root="${build_root}-${max_tag}${release_debug}${mt_sfx}${dll_sfx}${bit64_sfx}${prof_sfx}"
2981fi
2982
2983
2984#### Add full host specs to "${build_root}"
2985if test "$with_hostspec" = "yes" ; then
2986   build_root="${build_root}--${host}"
2987fi
2988
2989if test -n "$with_build_root_sfx" ; then
2990   build_root=$build_root$with_build_root_sfx
2991fi
2992
2993case "$host_os" in
2994   linux*)
2995      kver=`uname -r | sed -e 's/-.*//'`
2996      libcver=`ldd --version | awk 'NR == 1 { print $NF }'`
2997      verbose_host=$host_cpu-$host_vendor-linux$kver-gnu$libcver
2998      ;;
2999   *) verbose_host=$host ;;
3000esac
3001
3002#### Overall configuration mode summary
3003signature_hostname=`(hostname || uname -n) 2>/dev/null \
3004    | sed 's/\..*//; s/-/_/g; 1q'`
3005signature="${signature_compiler}_${compiler_version}-${release_debug}${mt_sfx}${dll_sfx}${bit64_sfx}${prof_sfx}--${verbose_host}-${signature_hostname}"
3006AC_DEFINE_UNQUOTED(NCBI_SIGNATURE, "$signature",
3007   [Build signature: compiler-name '_' compiler-version '-' configuration
3008   '--' platform-name '-' hostname])
3009
3010
3011#### Check if there is "${build_root}" dir
3012test -d "${build_root}"  ||  mkdir -p "${build_root}"
3013test -d "${build_root}"  ||  AC_MSG_ERROR([Couldn't create ${build_root}])
3014
3015#### Try to find a version of pwd that yields /net paths.
3016AC_PATH_PROG(AMQ, amq, [], $PATH:/usr/sbin:/sbin)
3017case "$AMQ" in
3018   */amq)
3019      AC_CACHE_CHECK([whether $AMQ -w works], ncbi_cv_prog_amq_w,
3020      [if $AMQ -w >/dev/null 2>&1; then
3021          ncbi_cv_prog_amq_w=yes
3022       else
3023          ncbi_cv_prog_amq_w=no
3024       fi])
3025      if test "$ncbi_cv_prog_amq_w" = yes; then
3026         smart_pwd="$AMQ -w"
3027      else
3028         smart_pwd=pwd
3029      fi
3030      ;;
3031   *)
3032      smart_pwd=pwd
3033      ;;
3034esac
3035
3036#### Make "build_root" absolute
3037case "${build_root}" in
3038   /* ) ;;
3039   . )
3040      CDPATH=
3041      if test "${PWD}" != "" && test "`(cd ${PWD} ; sh -c pwd)`" = "`pwd`"  ;
3042      then
3043         build_root="$PWD"
3044      else
3045         NCBI_FIX_DIR(build_root)
3046      fi
3047   ;;
3048   *  ) NCBI_FIX_DIR(build_root) ;;
3049esac
3050if test -n "$with_fake_root"; then
3051   build_root=$with_fake_root/`basename $build_root`
3052fi
3053
3054
3055#### Set runpath (may depend on build root)
3056if test -n "$with_relative_runpath"; then
3057   if test "$with_runpath" = "no"; then
3058      AC_MSG_ERROR([incompatible options: --without-runpath and --with-relative-runpath=$with_relative_runpath])
3059   elif test -z "$origin"; then
3060      AC_MSG_ERROR([Do not know how to specify relative runpaths on $host])
3061   else
3062      rp=`echo "$origin/$with_relative_runpath" | \
3063          sed "s,:,:$origin/,g; s,/.:,:,g; s,/.\$,,"`
3064      with_runpath="$rp${with_runpath+:$with_runpath}"
3065   fi
3066fi
3067
3068if test -z "$with_runpath"; then
3069   # Don't allow libdir values containing variable expansions,
3070   # including in particular the default "${exec_prefix}/lib"
3071   if test -n "$libdir"  &&  expr "$libdir" : '[[^$]]*$' >/dev/null; then
3072      with_runpath=$libdir
3073   elif test -n "$exec_prefix"  -a  "$exec_prefix" != "NONE" ; then
3074      with_runpath=$exec_prefix/lib
3075   elif test -n "$prefix"  -a  "$prefix" != "NONE" ; then
3076      with_runpath=$prefix/lib
3077   fi
3078fi
3079
3080if   test "$with_runpath" = "no" ; then
3081   runpath=
3082   pure_runpath=
3083elif test -n "$with_runpath"  -a  "$with_runpath" != "yes" ; then
3084   root_base=`basename $build_root`
3085   pure_runpath=`echo "${with_runpath}" | sed -e "s/{}/$root_base/g"`
3086   runpath="${CONF_f_runpath}${pure_runpath}"
3087   case "$host_os:$compiler" in
3088    darwin* )
3089      # Needed for a few gui projects, including gbench_plugin_scan;
3090      # harmless elsewhere, since it only affects projects that indirectly
3091      # need one of these libraries.  (There seems to be no general
3092      # equivalent of -rpath-link.)
3093      for l in dbapi_driver gui_utils ncbi_xloader_genbank ncbi_xreader \
3094               ncbi_xreader_id1 ncbi_xreader_pubseqos; do
3095         ll=lib$l.dylib
3096         LDFLAGS="$LDFLAGS -dylib_file ${pure_runpath}/$ll:\$(libdir)/$ll"
3097      done
3098      ;;
3099    *:GCC )
3100      if `$CXX -print-prog-name=ld` --version 2>&1 | grep GNU >/dev/null; then
3101         runpath="$runpath -Wl,-rpath-link,\$(libdir)"
3102      fi
3103      ;;
3104    *:ICC )
3105      runpath="$runpath -Wl,-rpath-link,\$(libdir)"
3106      ;;
3107   esac
3108elif test "$with_runpath" = "yes"  -o  "$with_dll" != "no" ; then
3109   runpath="${CONF_f_runpath}\$(libdir)"
3110   pure_runpath='${build_root}/lib'
3111else
3112   runpath=
3113   pure_runpath=
3114fi
3115if test -z "$CONF_f_runpath" ; then
3116   # Drop the linker flag (since passing directory names doesn't work
3117   # so well), but keep pure_runpath for other uses.
3118   runpath=
3119fi
3120
3121
3122#### Linker command-line to build DLL (may depend on runpath)
3123has_dll_loadable="@# "
3124ALLOW_UNDEF=
3125FORBID_UNDEF=
3126case "$compiler" in
3127 GCC | ICC | *Clang)
3128   LINK_DLL="$LINK $ARCH_CFLAGS -shared -o" # possibly overridden below
3129   case "$host_os" in
3130      solaris* )
3131        # See http://realm.progsoc.uts.edu.au/~subtle/solaris28_link.html
3132        LINK_DLL="$LINK $ARCH_CFLAGS -shared -mimpure-text -o"
3133        FORBID_UNDEF="-Wl,-z,defs"
3134        ;;
3135      darwin* )
3136        # Per <http://fink.sourceforge.net/doc/porting/shared.php>, it was
3137        # historically necessary to build plugins as Mach-O bundles rather than
3138        # dynamic libraries.  That's not such a big deal on modern Mac OS X
3139        # versions, so the Toolkit now defaults to building only the latter.
3140        if test "$with_bundles" = yes; then
3141           has_dll_loadable=""
3142           AC_DEFINE(NCBI_USE_BUNDLES, 1,
3143              [Define to 1 if building plugins as bundles, as Mac OS X
3144               traditionally required.])
3145        fi
3146        if $CXX -v 2>&1 | egrep -q 'Apple|clang'; then
3147           LINK_DLL="$LINK $ARCH_CFLAGS -dynamiclib -install_name ${pure_runpath%%:*}/\$(XDLL) -o"
3148           LINK_LOADABLE="$LINK $ARCH_CFLAGS -bundle -o"
3149           ALLOW_UNDEF='-undefined suppress'
3150           FORBID_UNDEF='-undefined error'
3151        else
3152           LINK_DLL="$LINK $ARCH_CFLAGS -nostartfiles -Wl,-dynamic -Wl,-dylib -Wl,-install_name,${pure_runpath%%:*}/\$(XDLL) -o"
3153           LINK_LOADABLE="$LINK $ARCH_CFLAGS -nostartfiles -Wl,-dynamic -Wl,-bundle -Wl,-read_only_relocs,warning -lbundle1.o -o"
3154           ALLOW_UNDEF='-Wl,-undefined,suppress'
3155           FORBID_UNDEF='-Wl,-undefined,error'
3156        fi
3157        ;;
3158      linux* | *gnu* ) # | *bsd*
3159        case "$compiler:$compiler_version" in
3160           ICC:* )
3161             ncbi_cv_prog_cc_wl_no_asu=no
3162             LIBS="$LIBS -lc"
3163             C_LIBS="$C_LIBS -lc"
3164             ;;
3165           * )
3166             FORBID_UNDEF='-Wl,--no-undefined'
3167             ;;
3168        esac
3169        ;;
3170      irix* )
3171        FORBID_UNDEF='-Wl,-no_unresolved'
3172        ;;
3173      osf* )
3174        ALLOW_UNDEF='-Wl,-expect_unresolved,\*'
3175        FORBID_UNDEF='-Wl,-error_unresolved'
3176        ;;
3177   esac
3178   AC_CACHE_CHECK([whether $CC supports -Wl,--no-allow-shlib-undefined],
3179      ncbi_cv_prog_cc_wl_no_asu,
3180      [orig_LDFLAGS=$LDFLAGS
3181       LDFLAGS="$CXXFLAGS_DLL -shared -Wl,--no-allow-shlib-undefined $LDFLAGS"
3182       AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
3183          [ncbi_cv_prog_cc_wl_no_asu=yes], [ncbi_cv_prog_cc_wl_no_asu=no])
3184       LDFLAGS=$orig_LDFLAGS])
3185   if test "$ncbi_cv_prog_cc_wl_no_asu" = yes; then
3186      FORBID_UNDEF="$FORBID_UNDEF -Wl,--no-allow-shlib-undefined"
3187   fi
3188  ;;
3189 MIPSpro73 )
3190   LINK_DLL="$LINK $ARCH_CFLAGS -shared -o"
3191   FORBID_UNDEF="-no_unresolved"
3192   ;;
3193 Compaq )
3194   LINK_DLL="$LINK $ARCH_CFLAGS -shared -o"
3195   ALLOW_UNDEF='-expect_unresolved \*'
3196   FORBID_UNDEF='-error_unresolved'
3197   ;;
3198 WorkShop* )
3199   LINK_DLL="$LINK $ARCH_CFLAGS $MT_FLAG -G -h \$(XDLL) -o"
3200   FORBID_UNDEF="-z defs"
3201   ;;
3202 KCC )
3203   LINK_DLL="$LINK $ARCH_CFLAGS $MT_FLAG --soname \$(XDLL) -o"
3204   FORBID_UNDEF="-z defs"
3205   ;;
3206 VisualAge )
3207   # NOTE: --without-dll still recommended, as the linker doesn't seem
3208   # to support building shared libraries with undefined symbols.
3209   LINK_DLL="$LINK $ARCH_CFLAGS $MT_FLAG -qmkshrobj -o"
3210   # ALLOW_UNDEF="???"
3211   ;;
3212 * )
3213   if test "$with_dll" = "yes"  &&  test -z "$LINK_DLL" ; then
3214      AC_MSG_ERROR([Do not know how to build DLLs with compiler $CXX $compiler_ver])
3215   elif test -z "$LINK_DLL"; then
3216      with_dll=no
3217   fi
3218   ;;
3219esac
3220
3221if test "$with_dll" = "no"; then # no DLLs whatsoever!
3222   DLL=
3223   FORCE_STATIC_LIB="LIB_OR_DLL = lib"
3224   APP_LIB_SETTING='$(STATIC_LIB)'
3225   APP_LIBS_SETTING='$(STATIC_LIBS)'
3226   if test "$with_bin_release" = "yes"; then
3227      CFLAGS="$CFLAGS $CFLAGS_DLL"
3228      CFLAGS_DLL=
3229      CXXFLAGS="$CXXFLAGS $CXXFLAGS_DLL"
3230      CXXFLAGS_DLL=
3231   fi
3232else
3233   FORCE_STATIC_LIB=
3234   APP_LIB_SETTING='$(LIB)'
3235   APP_LIBS_SETTING='$(LIBS)'
3236   NCBI_FEATURE(DLL)
3237   # Some shared libraries end up containing static libraries, so make
3238   # sure to use DLL flags for both, as such inclusion can otherwise
3239   # result in linker errors.
3240   DLL_LDFLAGS="$DLL_LDFLAGS $CXXFLAGS_DLL"
3241   CFLAGS="$CFLAGS $CFLAGS_DLL"
3242   CFLAGS_DLL=
3243   CXXFLAGS="$CXXFLAGS $CXXFLAGS_DLL"
3244   CXXFLAGS_DLL=
3245   AC_DEFINE(NCBI_DLL_SUPPORT, 1,
3246     [Define to 1 if building dynamic libraries at all
3247      (albeit not necessarily by default).])
3248   if test "$with_dll" = "yes"; then
3249      NCBI_FEATURE(DLL_BUILD)
3250      AC_DEFINE(NCBI_DLL_BUILD, 1,
3251                [Define to 1 if building dynamic libraries by default.])
3252      : ${with_plugin_auto_load=yes}
3253   fi
3254fi
3255
3256if test "$with_plugin_auto_load" = yes; then
3257   AC_DEFINE(NCBI_PLUGIN_AUTO_LOAD, 1,
3258             [Define to 1 if the plugin manager should load DLLs by default.])
3259fi
3260
3261# Make sure we have commands for both C and C++ preprocessors
3262AC_PROG_CPP
3263dnl AC_PROG_CXXCPP
3264
3265
3266#### Make "srcdir" absolute
3267case "${srcdir}" in
3268   /* ) ;;
3269   . )
3270      CDPATH=
3271      if test "${PWD}" != "" && test "`(cd ${PWD} ; sh -c pwd)`" = "`pwd`"  ;
3272      then
3273        srcdir="$PWD"
3274      else
3275        NCBI_FIX_DIR(srcdir)
3276      fi
3277   ;;
3278   * ) NCBI_FIX_DIR(srcdir) ;;
3279esac
3280real_srcdir=$srcdir
3281if test -n "$with_fake_root"; then
3282   srcdir=$build_root/..
3283fi
3284
3285
3286#### Ensure that all explicitly requested subtrees actually exist
3287NCBI_CHECK_SUBTREE(algo)
3288dnl NCBI_CHECK_SUBTREE(app)
3289if test "$with_app" = "no" ; then
3290   NoConfProjects="$NoConfProjects app"
3291fi
3292
3293if test ! -f ${real_srcdir}/src/app/Makefile.in ; then
3294   if test "${with_app-no}" != "no" ; then
3295      AC_MSG_ERROR([--with-app:  APP sources are missing])
3296   fi
3297   with_app="no"
3298fi
3299
3300dnl NCBI_CHECK_SUBTREE(bdb) # deferred until end, as --with-bdb does double duty
3301dnl NCBI_CHECK_SUBTREE(cgi) # --without-cgi deliberately unavailable for now
3302if test -f ${real_srcdir}/src/cgi/Makefile.in  -a \
3303        -d ${real_srcdir}/include/cgi; then
3304   NCBI_PROJECT(cgi)
3305else
3306   AC_MSG_WARN([CGI tree missing; some projects may fail to build.])
3307fi
3308
3309NCBI_CHECK_SUBTREE(ctools)
3310NCBI_CHECK_SUBTREE(dbapi)
3311NCBI_CHECK_SUBTREE(gui)
3312NCBI_CHECK_SUBTREE(objects)
3313NCBI_CHECK_SUBTREE(serial)
3314
3315
3316#### Source, include, and build directories
3317ncbiconf="$build_root/inc/ncbiconf_unix.h"
3318ncbiconf_old="$build_root/inc/ncbiconf.h"
3319if test -f "$ncbiconf_old" -a ! -f "$ncbiconf"; then
3320   mv "$ncbiconf_old" "$ncbiconf"
3321fi
3322if test "$build_root" = "$srcdir" ; then
3323   builddir="$srcdir/src"
3324else
3325   builddir="$build_root/build"
3326fi
3327status_dir="$build_root/status"
3328
3329
3330#### Create build directories
3331mkdir -p "$builddir" "$build_root/lib" "$build_root/bin"
3332
3333
3334#### Check if the target directory already has a configured system in it
3335if test "$no_create" != "yes"  -a  -f "${ncbiconf}" ; then
3336   echo
3337   echo "There is already a built \"${ncbiconf}\"!"
3338   NCBI_CAUTION([Do you want to re-configure in \"${builddir}\" (at your own risk)?])
3339   echo
3340fi
3341
3342
3343#### Use right command shell in scripts and makefiles
3344script_shell="#! ${CONFIG_SHELL:=/bin/sh}"
3345make_shell="SHELL=${CONFIG_SHELL:=/bin/sh}"
3346
3347
3348#### Turn on compilation warnings and adjust
3349#### some compiler-specific flags and features
3350
3351if test "$CONF_obj_ext"   = " " ;  then obj_ext="" ; else obj_ext="${CONF_obj_ext:=.o}" ; fi
3352if test "$CONF_lib_pre"   = " " ;  then lib_pre="" ; else lib_pre="${CONF_lib_pre:=lib}" ; fi
3353if test "$CONF_lib_l_pre" = " " ;  then lib_l_pre="" ; else lib_l_pre="${CONF_lib_l_pre:=-l}" ; fi
3354if test "$CONF_lib_ext"   = " " ;  then lib_ext="" ; else lib_ext="${CONF_lib_ext:=.a}" ; fi
3355if test "$CONF_dll_ext"   = " " ;  then dll_ext="" ; else dll_ext="${CONF_dll_ext:=.so}" ; fi
3356if test "$CONF_loadable_ext"  = " " ;  then loadable_ext="" ; else loadable_ext="${CONF_loadable_ext:=.so}" ; fi
3357if test "$CONF_lib_l_ext" = " " ;  then lib_l_ext="" ; else lib_l_ext="${CONF_lib_l_ext}" ; fi
3358if test "$CONF_exe_ext"   = " " ;  then exe_ext="" ; else exe_ext="${CONF_exe_ext}" ; fi
3359if test "$CONF_f_compile" = " " ;  then f_compile="" ; else f_compile="${CONF_f_compile:=-c }" ; fi
3360if test "$CONF_f_outobj"  = " " ;  then f_outobj="" ; else f_outobj="${CONF_f_outobj:=-o }" ; fi
3361if test "$CONF_f_outlib"  = " " ;  then f_outlib="" ; else f_outlib="${CONF_f_outlib}" ; fi
3362if test "$CONF_f_libpath" = " " ;  then f_libpath="" ; else f_libpath="${CONF_f_libpath:=-L}" ; fi
3363if test "$CONF_f_runpath" = " " ;  then f_runpath="" ; else f_runpath="${CONF_f_runpath:=$CONF_f_libpath}" ; fi
3364if test "$CONF_f_outexe"  = " " ;  then f_outexe="" ; else f_outexe="${CONF_f_outexe:=-o }" ; fi
3365
3366
3367BINCOPY="/bin/cp -p"
3368MAC_BINCOPY="/Developer/Tools/CpMac -p"
3369if test "$with_bincopy" != "yes"; then
3370   AC_CACHE_CHECK([whether cross-directory hard links work],
3371      ncbi_cv_sys_xdir_ln,
3372      [mkdir conftestdir
3373       touch conftestdir/conftestfile
3374       if ln -f conftestdir/conftestfile .; then
3375          ncbi_cv_sys_xdir_ln=yes
3376       else
3377          ncbi_cv_sys_xdir_ln=no
3378       fi
3379       rm -rf conftestdir conftestfile])
3380   if test "$ncbi_cv_sys_xdir_ln" = "yes"; then
3381      BINCOPY="/bin/ln -f"
3382      MAC_BINCOPY="\$(top_srcdir)/scripts/common/impl/ln_mac.sh"
3383   fi
3384fi
3385ifdiff="${CONFIG_SHELL} \$(top_srcdir)/scripts/common/impl/if_diff.sh"
3386if test "$OSTYPE" = "darwin" -a -x /Developer/Tools/CpMac; then
3387   BINCOPY="$ifdiff \"$MAC_BINCOPY\""
3388else
3389   BINCOPY="$ifdiff \"$BINCOPY\""
3390fi
3391
3392
3393#### Manage the debug-vs.-optimization flags ("--with(out)-(max-)debug",
3394#### "--with(out)-symbols", "--with(out)-optimization")
3395asan_sfx=''
3396if test "$compiler" != "MSVC" ; then
3397   if test "$with_debug" = "no" -o "$with_tcheck" != "no"; then
3398      CPPFLAGS="-DNDEBUG $CPPFLAGS"
3399   else
3400      CPPFLAGS="-D_DEBUG $CPPFLAGS"
3401   fi
3402
3403   if test "${with_max_debug-no}" != "no"; then
3404      case "$compiler:$with_max_debug" in
3405         GCC:thread | *Clang:thread ) sanitize=-fsanitize=thread ;;
3406         GCC:yes | *Clang:yes ) sanitize=-fsanitize=address; asan_sfx=ASan ;;
3407         *:yes ) ;;
3408         * )
3409            AC_MSG_ERROR([--with-max-debug=$with_max_debug unimplemented for compiler $compiler])
3410            ;;
3411      esac
3412      case "$compiler" in
3413         GCC | *Clang )
3414            CPPFLAGS="-D_GLIBCXX_DEBUG $CPPFLAGS"
3415            CFLAGS="-fstack-check $sanitize $CFLAGS"
3416            CXXFLAGS="-fstack-check $sanitize $CXXFLAGS"
3417            LDFLAGS="$sanitize $LDFLAGS"
3418            ;;
3419         ICC )
3420            CPPFLAGS="-D_GLIBCXX_DEBUG $CPPFLAGS"
3421            CFLAGS="-debug all -fstack-security-check -ftrapuv $CFLAGS"
3422            CXXFLAGS="-debug all -fstack-security-check -ftrapuv $CXXFLAGS"
3423            ;;
3424         WorkShop* )
3425            CFLAGS="-xcheck=%all $CFLAGS"
3426            CXXFLAGS="-xcheck=%all $CXXFLAGS"
3427            ;;
3428      esac
3429      NCBI_FEATURE(MaxDebug)
3430   fi
3431changequote(, )dnl
3432   dbgrx1="$wsrx-g[^cx$wschars]*$wsrx"
3433   dbgrx2="$wsrx-gx*coff[0-9+]*$wsrx"
3434   optrx="$wsrx-x*O[0-9s]*$wsrx"
3435   NDEB_CFLAGS=`  echo " $CFLAGS "   | sed "s/$dbgrx1/ /g; s/$dbgrx2/ /g"`
3436   NDEB_CXXFLAGS=`echo " $CXXFLAGS " | sed "s/$dbgrx1/ /g; s/$dbgrx2/ /g"`
3437   NDEB_LDFLAGS=` echo " $LDFLAGS "  | sed "s/$dbgrx1/ /g; s/$dbgrx2/ /g"`
3438   if test "$with_symbols" = "no" ; then
3439      CFLAGS=$NDEB_CFLAGS
3440      CXXFLAGS=$NDEB_CXXFLAGS
3441      LDFLAGS=$NDEB_LDFLAGS
3442   else
3443      echo " $CFLAGS "  | $EGREP_Q "$dbgrx1|$dbgrx2" || CFLAGS="$CFLAGS -g"
3444      echo " $CXXFLAGS "| $EGREP_Q "$dbgrx1|$dbgrx2" || CXXFLAGS="$CXXFLAGS -g"
3445      echo " $LDFLAGS " | $EGREP_Q "$dbgrx1|$dbgrx2" || LDFLAGS="$LDFLAGS -g"
3446      STRIP="@:"
3447      case "$compiler:$compiler_version" in
3448         GCC:* )
3449            # GCC 4.8 defaults to DWARF 4, which Totalview for one
3450            # can't handle; roll back to version 3 by default.
3451            echo " $USER_CFLAGS " | $EGREP_Q "$dbgrx1|$dbgrx2" || \
3452               CFLAGS="$NDEB_CFLAGS -gdwarf-3"
3453            echo " $USER_CXXFLAGS " | $EGREP_Q "$dbgrx1|$dbgrx2" || \
3454               CXXFLAGS="$NDEB_CXXFLAGS -gdwarf-3"
3455            echo " $USER_LDFLAGS " | $EGREP_Q "$dbgrx1|$dbgrx2" || \
3456               LDFLAGS="$NDEB_LDFLAGS -gdwarf-3"
3457            ;;
3458      esac
3459   fi
3460
3461   NOPT_CFLAGS=`  echo " $CFLAGS "    | sed "s/$optrx/ /g"`
3462   NOPT_CXXFLAGS=`echo " $CXXFLAGS "  | sed "s/$optrx/ /g"`
3463   NOPT_LDFLAGS=` echo " $LDFLAGS "   | sed "s/$optrx/ /g"`
3464   if test "${with_tcheck-no}" != "no"; then
3465      # Suppress warnings when building with ICC.
3466      NOPT_CFLAGS="$NOPT_CFLAGS -O0"
3467      NOPT_CXXFLAGS="$NOPT_CXXFLAGS -O0"
3468      NOPT_LDFLAGS="$NOPT_LDFLAGS -O0"
3469   fi
3470   if test "$with_optimization" = "no" ; then
3471      CFLAGS="$NOPT_CFLAGS"
3472      CXXFLAGS="$NOPT_CXXFLAGS"
3473      LDFLAGS="$NOPT_LDFLAGS"
3474      FAST_CFLAGS="$CFLAGS"
3475      FAST_CXXFLAGS="$CXXFLAGS"
3476      FAST_LDFLAGS="$LDFLAGS"
3477   else
3478      if test "$GCC" = yes; then
3479         defoptim=-O2
3480      else
3481         defoptim=-O
3482      fi
3483      if echo " $CFLAGS "   | grep -v "$optrx" >/dev/null ; then
3484         CFLAGS="$CFLAGS $defoptim" ; fi
3485      if echo " $CXXFLAGS " | grep -v "$optrx" >/dev/null ; then
3486         CXXFLAGS="$CXXFLAGS $defoptim" ; fi
3487      if echo " $LDFLAGS "  | grep -v "$optrx" >/dev/null ; then
3488         LDFLAGS="$LDFLAGS $defoptim" ; fi
3489      if test "$skip_fast_flags" = yes ; then
3490         FAST_CFLAGS="$CFLAGS"
3491         FAST_CXXFLAGS="$CXXFLAGS"
3492         FAST_LDFLAGS="$LDFLAGS"
3493      else
3494         case "$compiler:$compiler_version" in
3495            ICC:[2-9]??? )
3496               NOPT_CFLAGS=`echo " $NOPT_CFLAGS" \
3497                            | sed -e 's/ -ffp-model=[^ ]*//'`
3498               NOPT_CXXFLAGS=`echo " $NOPT_CXXFLAGS" \
3499                              | sed -e 's/ -ffp-model=[^ ]*//'`
3500               # NOPT_LDFLAGS="$NOPT_LDFLAGS -fuse-ld=lld"
3501               ;;
3502         esac
3503         FAST_CFLAGS="$NOPT_CFLAGS $FAST_CFLAGS"
3504         FAST_CXXFLAGS="$NOPT_CXXFLAGS $FAST_CXXFLAGS"
3505         FAST_LDFLAGS="$NOPT_LDFLAGS $FAST_LDFLAGS"
3506      fi
3507   fi
3508changequote([, ])dnl
3509fi
3510
3511
3512
3513### ------------------------------------------------------------------
3514### ------------------------------------------------------------------
3515
3516### Check for header files.
3517AC_CHECK_HEADERS(iostream  iostream.h)
3518AC_CHECK_HEADERS(fstream   fstream.h)
3519AC_CHECK_HEADERS(strstream strstream.h strstrea.h)
3520
3521AC_CHECK_HEADERS(inttypes.h limits limits.h)
3522
3523### Check for the platform (very roughly)
3524AC_CHECK_HEADERS(unistd.h,  x_have_unistd="yes")
3525AC_CHECK_HEADERS(windows.h, x_have_windows="yes")
3526
3527if test "$x_have_windows" = "yes" -a "x$host_os" != "xcygwin32" -a "x$host_os" != "xcygwin"; then
3528   AC_DEFINE(NCBI_OS_MSWIN, 1, [Define to 1 on Windows.])
3529   AC_DEFINE(NCBI_OS, "MSWIN", [Operating system name])
3530   NCBI_FEATURE(MSWin)
3531elif test "$x_have_unistd" = "yes" ; then
3532   AC_DEFINE(NCBI_OS_UNIX, 1,  [Define to 1 on Unix.])
3533   AC_DEFINE(NCBI_OS, "UNIX",  [Operating system name])
3534
3535   UNIX_SRC='$(UNIX_SRC)'
3536   UNIX_USR_PROJ='$(UNIX_USR_PROJ)'
3537   NCBI_FEATURE(unix)
3538   NCBI_FEATURE(WinMain) # to accommodate a PTB-specific (ab)use of REQUIRES
3539
3540   # Extra defines for variants we care about
3541   case "$OSTYPE" in
3542     aix)
3543        AC_DEFINE(NCBI_OS_AIX,     1, [Define to 1 on AIX.])
3544        NCBI_FEATURE(AIX)
3545        ;;
3546     *bsd)
3547        AC_DEFINE(NCBI_OS_BSD,     1, [Define to 1 on *BSD.])
3548        NCBI_FEATURE(BSD)
3549        ;;
3550     cygwin)
3551        AC_DEFINE(NCBI_OS_CYGWIN,  1, [Define to 1 on Cygwin.])
3552        NCBI_FEATURE(Cygwin)
3553        if test "$with_mt" = yes; then NCBI_FEATURE(CygwinMT); fi
3554        ;;
3555     darwin)
3556        AC_DEFINE(NCBI_OS_DARWIN,  1, [Define to 1 on Mac OS X.])
3557        NCBI_FEATURE(Darwin)
3558        if false; then NCBI_FEATURE(XCODE); fi
3559        ;;
3560     irix)
3561        AC_DEFINE(NCBI_OS_IRIX,    1, [Define to 1 on IRIX.])
3562        NCBI_FEATURE(IRIX)
3563        ;;
3564     linux)
3565        AC_DEFINE(NCBI_OS_LINUX,   1, [Define to 1 on Linux.])
3566        NCBI_FEATURE(Linux)
3567        ;;
3568     osf)
3569        AC_DEFINE(NCBI_OS_OSF1,    1, [Define to 1 on Tru64 Unix.])
3570        NCBI_FEATURE(OSF)
3571        ;;
3572     solaris)
3573        AC_DEFINE(NCBI_OS_SOLARIS, 1, [Define to 1 on Solaris.])
3574        NCBI_FEATURE(Solaris)
3575        ;;
3576   esac
3577else
3578dnl Classic Mac OS, no longer supported; the following line is
3579dnl commented out to avoid cluttering config.h.in.
3580dnl AC_DEFINE(NCBI_OS_MAC, 1, [Define to 1 on MacOS.])
3581   AC_DEFINE(NCBI_OS, "MAC", [Operating system name])
3582   NCBI_FEATURE(MacOS)
3583fi
3584
3585case "$host_os" in
3586   cygwin* | osf* )
3587      AC_DEFINE(NETDB_REENTRANT, 1,
3588                [Define to 1 if the BSD-style netdb interface is reentrant.])
3589      ;;
3590esac
3591
3592# AC_CHECK_TYPES is insufficient, as linking may still fail :-/
3593AC_CACHE_CHECK([for wstring], ac_cv_type_wstring_linkable,
3594   [AC_LINK_IFELSE([AC_LANG_PROGRAM(
3595       [[@%:@include <string>
3596         using std::wstring;]],
3597       [[wstring ws, ws2; ws.find_first_of(ws2);]])],
3598       [ac_cv_type_wstring_linkable=yes], [ac_cv_type_wstring_linkable=no])])
3599if test "$ac_cv_type_wstring_linkable" = "yes"; then
3600   AC_DEFINE(HAVE_WSTRING, 1,
3601      [Define to 1 if the system has the type `wstring'.])
3602fi
3603
3604AC_CHECK_TYPES(socklen_t,,,[@%:@include <sys/types.h>
3605@%:@include <sys/socket.h>])
3606AC_CHECK_HEADERS(atomic.h cpuid.h dlfcn.h ieeefp.h poll.h sys/epoll.h \
3607                 sys/mount.h sys/sockio.h sys/statvfs.h sys/sysinfo.h \
3608                 sys/sysmacros.h sys/vfs.h x86intrin.h)
3609case "$host_os" in
3610   cygwin*) AC_CHECK_HEADERS(winternl.h) ;;
3611esac
3612# for FreeTDS
3613AC_CHECK_HEADERS(alloca.h arpa/inet.h dirent.h errno.h fcntl.h getopt.h \
3614                 langinfo.h libgen.h locale.h malloc.h net/inet/in.h netdb.h \
3615                 netinet/in.h netinet/tcp.h paths.h select.h signal.h \
3616                 stdbool.h stddef.h sys/eventfd.h sys/file.h sys/ioctl.h \
3617                 sys/param.h sys/resource.h sys/select.h sys/socket.h \
3618                 sys/time.h sys/wait.h valgrind/memcheck.h wchar.h)
3619AC_HEADER_TIME
3620
3621AC_CHECK_HEADERS(cxxabi.h)
3622if test "$ac_cv_header_cxxabi_h" = "yes"; then
3623   AC_CHECK_DECL(abi::__cxa_demangle,
3624      [AC_DEFINE(HAVE_CXA_DEMANGLE, 1,
3625        [Define to 1 if `abi::__cxa_demangle' is available from <cxxabi.h>.])],
3626      [], [[@%:@include <cxxabi.h>]])
3627fi
3628
3629orig_CFLAGS=$CFLAGS
3630CFLAGS="$CFLAGS $OPENMP_FLAGS"
3631AC_CHECK_HEADER(omp.h)
3632if test "$ac_cv_header_omp_h" = no; then
3633   if test "$with_openmp" = yes; then
3634      AC_MSG_ERROR([--with-openmp explicitly specified, but unavailable with $CC.])
3635   else
3636      OPENMP_FLAGS=
3637   fi
3638fi
3639CFLAGS=$orig_CFLAGS
3640dnl case $compiler:$host_os in
3641dnl    LLVMClang:linux* )
3642dnl       AC_CACHE_CHECK([whether $CC needs GCC's omp.h],
3643dnl          ncbi_cv_cc_lacks_omp_h,
3644dnl          [AC_COMPILE_IFELSE(
3645dnl             [AC_LANG_PROGRAM([@%:@include <omp.h>], [])],
3646dnl             ncbi_cv_cc_lacks_omp_h=no, ncbi_cv_cc_lacks_omp_h=yes)])
3647dnl       if test "$ncbi_cv_cc_lacks_omp_h" = yes; then
3648dnl          d=$(echo '@%:@include <omp.h>' | "$gccdir"/bin/gcc -E -M - | \
3649dnl              sed -ne 's, \([[^ ]]*\)/omp\.h,\1,p')
3650dnl          CPPFLAGS="-idirafter $d $CPPFLAGS"
3651dnl          $LN_S "$("$gccdir"/bin/gcc -print-file-name=libgomp.so)" \
3652dnl             "$build_root"/lib/libomp.so
3653dnl       fi
3654dnl       ;;
3655dnl esac
3656
3657## gethostbyname_r() -- 2 different variants: 5-arg (Solaris), 6-arg (Linux).
3658
3659AC_CACHE_CHECK([for gethostbyname_r], ncbi_cv_func_gethostbyname_r,
3660   [ncbi_cv_func_gethostbyname_r="no"
3661    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3662       [[@%:@include <netdb.h>]],
3663       [[
3664         void*           dummy = (void*) &gethostbyname_r;
3665         char            buf[1024];
3666         int             err;
3667         struct hostent* hp = 0;
3668         hp = gethostbyname_r("", hp, buf, sizeof(buf), &err);
3669       ]])],
3670       [
3671         ncbi_cv_func_gethostbyname_r="5"
3672       ]
3673    )
3674    if test "$ncbi_cv_func_gethostbyname_r" = "no" ; then
3675    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3676       [[@%:@include <netdb.h>]],
3677       [[
3678         void*           dummy = (void*) &gethostbyname_r;
3679         char            buf[1024];
3680         int             err;
3681         struct hostent* hp = 0;
3682         err = gethostbyname_r("", hp, buf, sizeof(buf), &hp, &err);
3683       ]])],
3684       [
3685         ncbi_cv_func_gethostbyname_r="6"
3686       ]
3687    )
3688    fi])
3689
3690if test "$ncbi_cv_func_gethostbyname_r" != "no" ; then
3691   AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYNAME_R, $ncbi_cv_func_gethostbyname_r,
3692    [If you have the `gethostbyname_r' function, define to the number of
3693     arguments it takes (normally 5 or 6).])
3694fi
3695
3696
3697## gethostbyaddr_r() -- 2 different variants: 7-arg (Solaris), 8-arg (Linux).
3698
3699AC_CACHE_CHECK([for gethostbyaddr_r], ncbi_cv_func_gethostbyaddr_r,
3700   [ncbi_cv_func_gethostbyaddr_r="no"
3701    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3702       [[
3703         @%:@include <netdb.h>
3704         @%:@include <sys/types.h>
3705         @%:@include <sys/socket.h>
3706       ]],
3707       [[
3708         void* dummy = (void*) &gethostbyaddr_r;
3709         char            buf[1024];
3710         int             err;
3711         unsigned int    host;
3712         struct hostent* hp = 0;
3713         hp = gethostbyaddr_r((char *) &host, sizeof(host), AF_INET,
3714                              hp, buf, sizeof(buf), &err);
3715       ]])],
3716       [
3717         ncbi_cv_func_gethostbyaddr_r="7"
3718       ]
3719    )
3720    if test "$ncbi_cv_func_gethostbyaddr_r" = "no" ; then
3721    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3722       [[
3723         @%:@include <netdb.h>
3724         @%:@include <sys/types.h>
3725         @%:@include <sys/socket.h>
3726       ]],
3727       [[
3728         void* dummy = (void*) &gethostbyaddr_r;
3729         char            buf[1024];
3730         int             err;
3731         unsigned int    host;
3732         struct hostent* hp = 0;
3733         int res = gethostbyaddr_r((char *) &host, sizeof(host), AF_INET,
3734                                   hp, buf, sizeof(buf), &hp, &err);
3735       ]])],
3736       [
3737         ncbi_cv_func_gethostbyaddr_r="8"
3738       ]
3739    )
3740    fi])
3741
3742if test "$ncbi_cv_func_gethostbyaddr_r" != "no" ; then
3743   AC_DEFINE_UNQUOTED(HAVE_GETHOSTBYADDR_R, $ncbi_cv_func_gethostbyaddr_r,
3744    [If you have the `gethostbyaddr_r' function, define to the number of
3745     arguments it takes (normally 7 or 8).])
3746fi
3747
3748
3749## getservbyname_r() -- 2 different variants: 5-arg (Solaris), 6-arg (Linux).
3750
3751AC_CACHE_CHECK([for getservbyname_r], ncbi_cv_func_getservbyname_r,
3752   [ncbi_cv_func_getservbyname_r="no"
3753    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3754       [[@%:@include <netdb.h>]],
3755       [[
3756         void*           dummy = (void*) &getservbyname_r;
3757         char            buf[1024];
3758         int             err;
3759         struct servent* sp = 0;
3760         sp = getservbyname_r("", "", sp, buf, sizeof(buf));
3761       ]])],
3762       [
3763         ncbi_cv_func_getservbyname_r="5"
3764       ]
3765    )
3766    if test "$ncbi_cv_func_getservbyname_r" = "no" ; then
3767    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3768       [[@%:@include <netdb.h>]],
3769       [[
3770         void*           dummy = (void*) &getservbyname_r;
3771         char            buf[1024];
3772         int             err;
3773         struct servent* sp = 0;
3774         err = getservbyname_r("", "", sp, buf, sizeof(buf), &sp);
3775       ]])],
3776       [
3777         ncbi_cv_func_getservbyname_r="6"
3778       ]
3779    )
3780    fi])
3781
3782if test "$ncbi_cv_func_getservbyname_r" != "no" ; then
3783   AC_DEFINE_UNQUOTED(HAVE_GETSERVBYNAME_R, $ncbi_cv_func_getservbyname_r,
3784    [If you have the `getservbyname_r' function, define to the number of
3785     arguments it takes (normally 5 or 6).])
3786fi
3787
3788## getpwuid_r() -- 2 major variants: 4-arg, 5-arg (POSIX).
3789## (Alternate 4-arg interface ignored due to rarity.)
3790
3791AC_CACHE_CHECK([for getpwuid_r], ncbi_cv_func_getpwuid_r,
3792   [ncbi_cv_func_getpwuid_r="no"
3793    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3794       [[@%:@include <unistd.h>
3795         @%:@include <pwd.h>]],
3796       [[struct passwd bpw;
3797         char buf[1024];
3798         char *dir = getpwuid_r(getuid(), &bpw, buf, sizeof(buf))->pw_dir;
3799       ]])],
3800       [ncbi_cv_func_getpwuid_r=4])
3801    if test "$ncbi_cv_func_getpwuid_r" = "no" ; then
3802    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3803       [[@%:@include <unistd.h>
3804         @%:@include <pwd.h>]],
3805       [[struct passwd *pw, bpw;
3806         char buf[1024];
3807         getpwuid_r(getuid(), &bpw, buf, sizeof(buf), &pw);
3808       ]])],
3809       [ncbi_cv_func_getpwuid_r=5])
3810    fi])
3811
3812if test "$ncbi_cv_func_getpwuid_r" != "no" ; then
3813   AC_DEFINE_UNQUOTED(NCBI_HAVE_GETPWUID_R, $ncbi_cv_func_getpwuid_r,
3814    [If you have the `getpwuid_r' function, define to the number of
3815     arguments it takes (normally 4 or 5).])
3816fi
3817
3818# Perform a full-fledged check in C++ to be sure of an actual declaration.
3819# Accommodate the old Solaris interface that returns char* rather than int. :-/
3820AC_CACHE_CHECK([for getlogin_r], ncbi_cv_func_getlogin_r,
3821   [ncbi_cv_func_getlogin_r="no"
3822    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3823       [[@%:@include <unistd.h>]],
3824       [[char buf[64]; /* return */ getlogin_r(buf, 64);]])],
3825       [ncbi_cv_func_getlogin_r=yes], [ncbi_cv_func_getlogin_r=no])])
3826if test $ncbi_cv_func_getlogin_r = yes; then
3827   AC_DEFINE(HAVE_GETLOGIN_R, 1,
3828      [Define to 1 if you have the `getlogin_r' function])
3829fi
3830
3831AC_LANG_PUSH(C)
3832# some of these can lose in C++ due to the way autoconf works
3833AC_CHECK_FUNCS(localtime_r pthread_setconcurrency pthread_atfork)
3834if test "$ac_cv_func_localtime_r" = "yes" ; then
3835   AC_CACHE_CHECK(return type of localtime_r, ac_cv_func_which_localtime_r,
3836      [AC_COMPILE_IFELSE(
3837          [AC_LANG_PROGRAM(
3838             [[@%:@include <unistd.h>
3839               @%:@include <time.h>]],
3840             [[struct tm mytm;
3841               time_t t;
3842               int y = localtime_r(&t, &mytm)->tm_year;]])],
3843          ac_cv_func_which_localtime_r=struct,
3844          ac_cv_func_which_localtime_r=int)])
3845   if test $ac_cv_func_which_localtime_r = struct; then
3846      AC_DEFINE(HAVE_FUNC_LOCALTIME_R_TM, 1,
3847         [Define to 1 if your localtime_r returns a struct tm*.])
3848   else
3849     AC_DEFINE(HAVE_FUNC_LOCALTIME_R_INT, 1,
3850        [Define to 1 if your localtime_r returns a int.])
3851   fi
3852fi
3853
3854AC_CACHE_CHECK([whether pthread mutexes are available],
3855   ncbi_cv_func_pthread_mutex,
3856   [AC_LINK_IFELSE([AC_LANG_PROGRAM(
3857       [[@%:@include <pthread.h>
3858         pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;]],
3859       [[pthread_mutex_lock(&mutex); pthread_mutex_unlock(&mutex);]])],
3860      [ncbi_cv_func_pthread_mutex=yes], [ncbi_cv_func_pthread_mutex=no])])
3861if test $ncbi_cv_func_pthread_mutex=yes; then
3862   AC_DEFINE(HAVE_PTHREAD_MUTEX, 1,
3863      [Define to 1 if pthread mutexes are available.])
3864fi
3865
3866
3867### Check for other standard library functions
3868
3869AC_FUNC_VPRINTF
3870AC_CHECK_FUNCS(alarm asprintf atoll basename dbopen daemon euidaccess eventfd \
3871               fseeko fstat getgrouplist gethrtime getopt getpagesize getpass \
3872               getpassphrase getpwuid getrusage gettimeofday getuid lchown \
3873               lutimes malloc_options memrchr nl_langinfo poll putenv \
3874               readpassphrase readv select setenv setitimer setrlimit \
3875               snprintf statfs statvfs strcasecmp strdup strlcat strlcpy \
3876               strndup strnlen strsep strtok_r sysmp timegm usleep utimes \
3877               vasprintf vsnprintf writev)
3878AC_LANG_POP(C)
3879
3880AC_TYPE_SIGNAL
3881test "$ac_cv_func_select" = yes  ||  ncbi_cv_func_select_updates_timeout=no
3882AC_CACHE_CHECK([whether select updates the timeout when interrupted],
3883               ncbi_cv_func_select_updates_timeout,
3884   [AC_RUN_IFELSE([AC_LANG_PROGRAM(
3885       [[@%:@include <signal.h>
3886         @%:@include <sys/types.h>
3887         @%:@ifdef HAVE_SYS_SELECT_H
3888         @%:@  include <sys/select.h>
3889         @%:@endif
3890         @%:@ifdef HAVE_SYS_TIME_H
3891         @%:@  include <sys/time.h>
3892         @%:@endif
3893         @%:@ifdef HAVE_UNISTD_H
3894         @%:@  include <unistd.h>
3895         @%:@endif
3896         RETSIGTYPE handler(int sig) { alarm(0); }]],
3897       [[struct timeval timeout = { 5, 0 };
3898         signal(SIGALRM, &handler);
3899         alarm(1);
3900         select(0, NULL, NULL, NULL, &timeout);
3901         return timeout.tv_sec == 5;]])],
3902       [ncbi_cv_func_select_updates_timeout=yes],
3903       [ncbi_cv_func_select_updates_timeout=no],
3904       [case "$host_os" in
3905          linux) ncbi_cv_func_select_updates_timeout=yes ;;
3906          *) ncbi_cv_func_select_updates_timeout=no ;;
3907        esac])])
3908if test "$ncbi_cv_func_select_updates_timeout" = yes; then
3909   AC_DEFINE(SELECT_UPDATES_TIMEOUT, 1,
3910      [Define to 1 if the `select' function updates its timeout when
3911       interrupted by a signal.])
3912fi
3913
3914# We want the program to return 0, which is *false* in C.  Also, since
3915# use of lowercase seems to be customary if not universal, the default
3916# is yes when cross-compiling; anyone cross-compiling for exceptional
3917# platforms can set ncbi_cv_func_strcasecmp_lc=no in config.site.
3918if test "$ac_cv_func_strcasecmp" = yes; then
3919   AC_CACHE_CHECK([whether strcasecmp treats letters as lowercase],
3920                  ncbi_cv_func_strcasecmp_lc,
3921      [AC_RUN_IFELSE([AC_LANG_PROGRAM(
3922          [[@%:@include <string.h>]],
3923          [[return strcasecmp("A", "_") <= 0;]])],
3924          [ncbi_cv_func_strcasecmp_lc=yes], [ncbi_cv_func_strcasecmp_lc=no],
3925          [ncbi_cv_func_strcasecmp_lc=yes])])
3926   if test "$ncbi_cv_func_strcasecmp_lc" = yes; then
3927      AC_DEFINE(HAVE_STRCASECMP_LC, 1,
3928                [Define to 1 if strcasecmp treats letters as lowercase.])
3929   fi
3930fi
3931
3932AC_CACHE_CHECK([for Linux-like sysinfo with 1 arg], ncbi_cv_func_sysinfo_1,
3933   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3934       [[@%:@include <sys/sysinfo.h>]],
3935       [[
3936         void* dummy = (void*) &sysinfo;
3937         struct sysinfo* info = 0;
3938         int retval = sysinfo(info);
3939       ]])], [ncbi_cv_func_sysinfo_1=yes], [ncbi_cv_func_sysinfo_1=no])])
3940
3941if test "$ncbi_cv_func_sysinfo_1" = yes; then
3942   AC_DEFINE(HAVE_SYSINFO_1, 1,
3943             [Define to 1 if Linux-like 1-arg sysinfo exists.])
3944fi
3945
3946dnl Too much overkill, and now wants getloadavg.c to exist.
3947dnl AC_FUNC_GETLOADAVG
3948AC_CHECK_FUNCS(getloadavg)
3949
3950## readdir_r() -- 2 different variants: 2-arg (trad. Solaris), 3-arg (POSIX).
3951
3952AC_CACHE_CHECK([for readdir_r], ncbi_cv_func_readdir_r,
3953   [ncbi_cv_func_readdir_r="no"
3954    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3955       [[@%:@include <dirent.h>]],
3956       [[DIR* dir; struct dirent* entry; readdir_r(dir, entry, &entry);]])],
3957       [ncbi_cv_func_readdir_r=3])
3958    if test "$ncbi_cv_func_readdir_r" = "no" ; then
3959    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3960       [[@%:@include <dirent.h>]],
3961       [[DIR* dir; struct dirent* entry; readdir_r(dir, entry);]])],
3962       [ncbi_cv_func_readdir_r=2])
3963    fi])
3964
3965if test "$ncbi_cv_func_readdir_r" != "no" ; then
3966   AC_DEFINE_UNQUOTED(NCBI_HAVE_READDIR_R, $ncbi_cv_func_readdir_r,
3967    [If you have the `readdir_r' function, define to the number of
3968     arguments it takes (normally 2 or 3).])
3969fi
3970
3971AC_CACHE_CHECK([whether stdio supports locking], ncbi_cv_c_stdio_locked,
3972   [AC_LINK_IFELSE([AC_LANG_PROGRAM(
3973      [[@%:@include <stdio.h>]],
3974      [[int c;
3975        flockfile(stdin);
3976        c = getc_unlocked(stdin);
3977        funlockfile(stdin);]])],
3978      [ncbi_cv_c_stdio_locked=yes], [ncbi_cv_c_stdio_locked=no])])
3979if test "$ncbi_cv_c_stdio_locked" = yes; then
3980   AC_DEFINE(NCBI_HAVE_STDIO_LOCKED, 1,
3981      [Define to 1 if stdio supports locking.])
3982fi
3983
3984### Check for typedefs, structures, and compiler features.
3985AC_C_CONST
3986
3987### Check for C standard types and sizes
3988AC_C_BIGENDIAN
3989AC_C_CHAR_UNSIGNED
3990AC_CHECK_SIZEOF(char)
3991AC_CHECK_SIZEOF(double)
3992AC_CHECK_SIZEOF(float)
3993AC_CHECK_SIZEOF(int)
3994AC_CHECK_SIZEOF(long)
3995AC_CHECK_SIZEOF(long double)
3996AC_CHECK_SIZEOF(long long)
3997AC_CHECK_SIZEOF(short)
3998AC_CHECK_SIZEOF(void*)
3999AC_CHECK_SIZEOF(wchar_t, [], [@%:@include <wchar.h>])
4000AC_CHECK_SIZEOF(__int64)
4001AC_CHECK_TYPES([intptr_t, uintptr_t])
4002
4003AC_CHECK_MEMBER(struct sockaddr_in.sin_len,
4004   [AC_DEFINE(HAVE_SIN_LEN, 1,
4005      [Define to 1 if `sin_len' is a member of `struct sockaddr_in'.])],
4006   [], [@%:@include <sys/types.h>
4007        @%:@include <netinet/in.h>])
4008
4009AC_CHECK_MEMBERS([struct tm.tm_zone, struct tm.__tm_zone], [], [],
4010   [@%:@include <time.h>])
4011
4012
4013AC_CACHE_CHECK([whether function prototypes can use throw(...)],
4014   ncbi_cv_cxx_throw_spec,
4015   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4016       [[template <class T> inline int test_throw_spec(const T&) throw() {
4017          return 0;
4018       }]],
4019       [[return test_throw_spec(123);]])],
4020       [ncbi_cv_cxx_throw_spec=yes], [ncbi_cv_cxx_throw_spec=no])])
4021if test "$ncbi_cv_cxx_throw_spec" = yes; then
4022   AC_DEFINE(NCBI_USE_THROW_SPEC, 1,
4023             [Define to 1 if prototypes can use exception specifications.])
4024fi
4025
4026
4027AC_CACHE_CHECK([for ios(_base)::register_callback],
4028   ncbi_cv_func_ios_register_callback,
4029   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4030       [[@%:@include <iostream>]],
4031       [[std::cout.register_callback(0, std::ios::erase_event);]])],
4032       [ncbi_cv_func_ios_register_callback=yes],
4033       [ncbi_cv_func_ios_register_callback=no])])
4034if test "$ncbi_cv_func_ios_register_callback" = yes; then
4035   AC_DEFINE(HAVE_IOS_REGISTER_CALLBACK, 1,
4036             [Define to 1 if you have `ios(_base)::register_callback'.])
4037fi
4038
4039
4040AC_CACHE_CHECK([for SysV semaphores], ncbi_cv_sys_semaphores,
4041   AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@include <sys/types.h>
4042@%:@include <sys/sem.h>],
4043      [struct sembuf buf; int id = semget(0x1234, 0, IPC_CREAT);
4044       buf.sem_op = SEM_UNDO;])],
4045      [ncbi_cv_sys_semaphores=yes], [ncbi_cv_sys_semaphores=no]))
4046if test "$ncbi_cv_sys_semaphores" = yes; then
4047   AC_DEFINE(HAVE_SYSV_SEMAPHORES, 1,
4048             [Define to 1 if you have SysV semaphores.])
4049fi
4050
4051AC_CHECK_TYPE([union semun],
4052   AC_DEFINE(HAVE_SEMUN, 1, [Define to 1 if you have `union semun'.]),
4053   [], [@%:@include <sys/types.h>
4054@%:@include <sys/sem.h>])
4055
4056
4057AC_CACHE_CHECK([which way the stack grows], ncbi_cv_sys_stack_dir,
4058   [AC_RUN_IFELSE([AC_LANG_PROGRAM(
4059        [[ int f(int* p) { int i; return (&i < p) ? 1 : 0; } ]],
4060        [[ int p; return f(&p); ]])],
4061        [ncbi_cv_sys_stack_dir=up], [ncbi_cv_sys_stack_dir=down],
4062        [ncbi_cv_sys_stack_dir="unknown (cross-compiling)"])])
4063case "$ncbi_cv_sys_stack_dir" in
4064 up)   AC_DEFINE(STACK_GROWS_UP,   1, [Define to 1 if the stack grows up.])  ;;
4065 down) AC_DEFINE(STACK_GROWS_DOWN, 1, [Define to 1 if the stack grows down.]);;
4066esac
4067
4068AC_LANG_PUSH(C)
4069
4070AC_CACHE_CHECK([whether the preprocessor supports C99-style variadic macros],
4071   ncbi_cv_cpp_std_varargs,
4072   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4073       [[@%:@define foo(...) 1
4074         @%:@if foo(x,y,z) != 1
4075         @%:@error failed
4076         @%:@endif]], [])],
4077       [ncbi_cv_cpp_std_varargs=yes], [ncbi_cv_cpp_std_varargs=no])])
4078if test "$ncbi_cv_cpp_std_varargs" = yes; then
4079   AC_DEFINE(HAVE_CPP_STD_VARARGS, 1,
4080      [Define to 1 if the preprocessor supports C99-style variadic macros.])
4081fi
4082
4083AC_CACHE_CHECK([whether the preprocessor supports GNU-style variadic macros],
4084   ncbi_cv_cpp_gnu_varargs,
4085   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4086       [[@%:@define foo(args...) 1
4087         @%:@if foo(x,y,z) != 1
4088         @%:@error failed
4089         @%:@endif]], [])],
4090       [ncbi_cv_cpp_gnu_varargs=yes], [ncbi_cv_cpp_gnu_varargs=no])])
4091if test "$ncbi_cv_cpp_gnu_varargs" = yes; then
4092   AC_DEFINE(HAVE_CPP_GNU_VARARGS, 1,
4093      [Define to 1 if the preprocessor supports GNU-style variadic macros.])
4094fi
4095
4096AC_LANG_POP(C)
4097
4098# Avoid using unsupported (and noisily ignored) attributes.
4099case "$compiler:$compiler_version" in
4100   VisualAge:* | WorkShop* )
4101      ncbi_cv_c_forceinline=inline
4102      ;;
4103esac
4104
4105AC_LANG_PUSH(C)
4106AC_CACHE_CHECK([how to force inlining],
4107   ncbi_cv_c_forceinline,
4108   [ncbi_cv_c_forceinline=no
4109    for fi in __always_inline "inline __attribute__((always_inline))" \
4110       forceinline __forceinline__ __forceinline inline __inline__; do
4111       test "$ncbi_cv_c_forceinline" = "no" || break
4112       AC_COMPILE_IFELSE([AC_LANG_SOURCE([$fi int f(void) { return 0; }])],
4113          [ncbi_cv_c_forceinline=$fi], [])
4114    done])
4115forceinline=$ncbi_cv_c_forceinline
4116test "$forceinline" = "no"  &&  forceinline=""
4117AC_DEFINE_UNQUOTED(NCBI_FORCEINLINE, $forceinline,
4118   [Define to whatever syntax your compiler supports for marking functions
4119    as to be inlined even if they might not otherwise be.])
4120
4121case "$compiler:$compiler_version $CFLAGS $CXXFLAGS" in
4122   GCC:*\ *\ -fvisibility* | ICC:*\ -fvisibility* | *Clang:*\ -fvisibility*) ;;
4123   * ) ncbi_cv_c_attribute_visibility_default=unnecessary ;;
4124esac
4125
4126AC_CACHE_CHECK([whether $CC supports __attribute__((visibility("default")))],
4127   ncbi_cv_c_attribute_visibility_default,
4128   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4129       [[__attribute__((visibility("default"))) void f(void); void f(void) {}]],
4130       [[f();]])],
4131      [ncbi_cv_c_attribute_visibility_default=yes],
4132      [ncbi_cv_c_attribute_visibility_default=no])])
4133if test $ncbi_cv_c_attribute_visibility_default = yes; then
4134   AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY_DEFAULT, 1,
4135      [Define to 1 if your compiler supports __attribute__((visibility("default")))])
4136fi
4137
4138AC_CACHE_CHECK([whether the C compiler supports C99 restrict],
4139   ncbi_cv_c_restrict,
4140   [ncbi_cv_c_restrict=no
4141    for restrict in __restrict__ __restrict restrict; do
4142       test "$ncbi_cv_c_restrict" = "no" || break
4143       AC_COMPILE_IFELSE([AC_LANG_SOURCE([void f(int * $restrict p);])],
4144          [ncbi_cv_c_restrict=$restrict], [])
4145    done])
4146restrict=$ncbi_cv_c_restrict
4147test "$restrict" = "no"  &&  restrict=""
4148AC_DEFINE_UNQUOTED(NCBI_RESTRICT_C, $restrict,
4149   [Define to whatever syntax, if any, your C compiler supports for marking
4150    pointers as restricted in the C99 sense.])
4151if test -n "$restrict"; then
4152   AC_DEFINE(HAVE_RESTRICT_C, 1,
4153      [Define to 1 if your C compiler supports some variant of the C99
4154       `restrict' keyword.])
4155fi
4156AC_LANG_POP(C)
4157
4158AC_CACHE_CHECK([whether the C++ compiler supports C99 restrict],
4159   ncbi_cv_cxx_restrict,
4160   [ncbi_cv_cxx_restrict=no
4161    for restrict in __restrict__ __restrict restrict; do
4162       test "$ncbi_cv_cxx_restrict" = "no" || break
4163       AC_COMPILE_IFELSE([AC_LANG_SOURCE([void f(int * $restrict p);])],
4164          [ncbi_cv_cxx_restrict=$restrict], [])
4165    done])
4166restrict=$ncbi_cv_cxx_restrict
4167test "$restrict" = "no"  &&  restrict=""
4168AC_DEFINE_UNQUOTED(NCBI_RESTRICT_CXX, $restrict,
4169   [Define to whatever syntax, if any, your C++ compiler supports for marking
4170    pointers as restricted in the C99 sense.])
4171if test -n "$restrict"; then
4172   AC_DEFINE(HAVE_RESTRICT_CXX, 1,
4173      [Define to 1 if your C++ compiler supports some variant of the C99
4174       `restrict' keyword.])
4175fi
4176
4177AC_CACHE_CHECK([syntax for declaring thread-local variables],
4178   ncbi_cv_c_tls_var,
4179   [ncbi_cv_c_tls_var=none
4180    for tls_var in __thread '__declspec(thread)' _Thread_local; do
4181       test "$ncbi_cv_c_tls_var" = "none" || break
4182       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$tls_var int i;],
4183          [static $tls_var int j;])],
4184          [ncbi_cv_c_tls_var=$tls_var], [])
4185    done])
4186tls_var=$ncbi_cv_c_tls_var
4187if test "$tls_var" != "none"; then
4188   AC_DEFINE_UNQUOTED(NCBI_TLS_VAR, $tls_var,
4189      [Define to whatever syntax your compiler supports for declaring
4190       thread-local variables, or leave undefined if it doesn't.])
4191fi
4192
4193# for FreeTDS
4194AC_CACHE_CHECK([whether FIONBIO requires BSD_COMP to be defined],
4195   ncbi_cv_decl_fionbio_needs_bsd_comp,
4196   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4197       [[ @%:@include <sys/types.h>
4198          @%:@include <sys/ioctl.h> ]],
4199       [[ int request = FIONBIO; ]])],
4200       [ncbi_cv_decl_fionbio_needs_bsd_comp=no],
4201       [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4202           [[ @%:@define BSD_COMP 1
4203              @%:@include <sys/types.h>
4204              @%:@include <sys/ioctl.h> ]],
4205           [[ int request = FIONBIO; ]])],
4206           [ncbi_cv_decl_fionbio_needs_bsd_comp=yes],
4207           [ncbi_cv_decl_fionbio_needs_bsd_comp="never defined at all"])])])
4208if test "$ncbi_cv_decl_fionbio_needs_bsd_comp" = yes; then
4209   AC_DEFINE(BSD_COMP, 1,
4210             [Define to 1 if necessary to get FIONBIO (e.g., on Solaris)])
4211fi
4212
4213AC_CACHE_CHECK([whether INADDR_NONE is defined], ncbi_cv_decl_inaddr_none,
4214   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4215       [[
4216         @%:@ifdef HAVE_SYS_TYPES_H
4217         @%:@include <sys/types.h>
4218         @%:@endif
4219         @%:@ifdef HAVE_SYS_SOCKET_H
4220         @%:@include <sys/socket.h>
4221         @%:@endif
4222         @%:@ifdef HAVE_NETINET_IN_H
4223         @%:@include <netinet/in.h>
4224         @%:@endif
4225         @%:@ifdef HAVE_ARPA_INET_H
4226         @%:@include <arpa/inet.h>
4227         @%:@endif
4228       ]],
4229       [[ unsigned long addr = INADDR_NONE; ]])],
4230       [ncbi_cv_decl_inaddr_none=yes], [ncbi_cv_decl_inaddr_none=no])])
4231if test "$ncbi_cv_decl_inaddr_none" != yes; then
4232   AC_DEFINE(INADDR_NONE, 0xffffffff,
4233             [Define to 0xffffffff if your operating system doesn't.])
4234fi
4235
4236AC_CACHE_CHECK([whether unaligned reads are permissible],
4237               ncbi_cv_sys_unaligned_reads,
4238   [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ @%:@include <stdio.h> ]],
4239       [[ unsigned int a[2] = { 0x01234567, 0x89abcdef };
4240          fprintf(stderr, "%x\n", *(unsigned int*)((char*)a + 1)); ]])],
4241       [ncbi_cv_sys_unaligned_reads=yes],
4242       [ncbi_cv_sys_unaligned_reads=no],
4243       [case "$host_cpu" in
4244          i?86|x86_64|powerpc*|ppc*) ncbi_cv_sys_unaligned_reads=yes ;;
4245          *)                         ncbi_cv_sys_unaligned_reads=no  ;;
4246        esac])])
4247if test "$ncbi_cv_sys_unaligned_reads" = yes; then
4248   AC_DEFINE(HAVE_UNALIGNED_READS, 1,
4249             [Define to 1 if your system permits reading integers from
4250              unaligned addresses.])
4251fi
4252
4253AC_LANG_PUSH(C)
4254orig_CFLAGS=$CFLAGS
4255
4256AC_CACHE_CHECK([whether $CC supports SIMD vector arithmetic],
4257               ncbi_cv_cc_vector_math,
4258   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4259         [typedef int TVector __attribute__((vector_size(16)));
4260          TVector f(TVector v1, TVector v2) { return v1 ^ v2; }],
4261         [TVector v1, v2, v3;  v3 = f(v1, v2);])],
4262      [ncbi_cv_cc_vector_math=yes], [ncbi_cv_cc_vector_math=no])])
4263if test "$ncbi_cv_cc_vector_math" = yes; then
4264   AC_DEFINE(HAVE_VECTOR_MATH, 1,
4265      [Define to 1 if your C compiler supports SIMD vector calculations.])
4266fi
4267
4268AC_CACHE_CHECK([whether $CC supports -funsafe-math-optimizations],
4269               ncbi_cv_cc_unsafe_math,
4270   [CFLAGS="$orig_CFLAGS -funsafe-math-optimizations"
4271    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
4272       [ncbi_cv_cc_unsafe_math=yes], [ncbi_cv_cc_unsafe_math=no])])
4273
4274AC_CACHE_CHECK([whether $CC supports -msse4.1], ncbi_cv_cc_sse4_1,
4275   [CFLAGS="$orig_CFLAGS -msse4.1"
4276    AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@include <emmintrin.h>],
4277          [double v __attribute__((__vector_size__(16)));
4278           __builtin_ia32_shufpd(v, v, 1);])],
4279       [ncbi_cv_cc_sse4_1=yes], [ncbi_cv_cc_sse4_1=no])])
4280
4281AC_CACHE_CHECK([whether $CC supports -maes], ncbi_cv_cc_aes,
4282   [CFLAGS="$orig_CFLAGS -maes"
4283    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4284          [@%:@include <wmmintrin.h>
4285           typedef long long TAESVec __attribute__((__vector_size__(16)));
4286           TAESVec f(TAESVec v, TAESVec w) {
4287              return __builtin_ia32_aesdec128(v, w);
4288           }], [])],
4289       [ncbi_cv_cc_aes=yes], [ncbi_cv_cc_aes=no])])
4290
4291case "$compiler:$compiler_version" in
4292 ICC:??? | ICC:1??? )
4293   # Pre-(20)21 ICC noisily ignores this flag, so explicitly blacklist it.
4294   ncbi_cv_cc_fdiagnostics_color_always=no
4295   ;;
4296esac
4297AC_CACHE_CHECK([whether $CC supports -fdiagnostics-color=always],
4298   ncbi_cv_cc_fdiagnostics_color_always,
4299   [CFLAGS="$orig_CFLAGS -fdiagnostics-color=always"
4300    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
4301       [ncbi_cv_cc_fdiagnostics_color_always=yes],
4302       [ncbi_cv_cc_fdiagnostics_color_always=no])])
4303if test $ncbi_cv_cc_fdiagnostics_color_always = yes; then
4304   COLOR_DIAGNOSTICS=-fdiagnostics-color=always
4305else
4306   COLOR_DIAGNOSTICS=
4307fi
4308
4309CFLAGS=$orig_CFLAGS
4310AC_LANG_POP(C)
4311
4312if test $ncbi_cv_cc_unsafe_math = yes; then
4313   UNSAFE_MATH_FLAG=-funsafe-math-optimizations
4314else
4315   UNSAFE_MATH_FLAG=
4316fi
4317
4318if test $ncbi_cv_cc_sse4_1 = yes; then
4319   SSE4_1_FLAG=-msse4.1
4320else
4321   SSE4_1_FLAG=
4322fi
4323
4324if test $ncbi_cv_cc_sse4_1 = yes -a $ncbi_cv_cc_aes = yes; then
4325   AES_FLAG=-maes
4326else
4327   AES_FLAG=
4328fi
4329
4330AC_CACHE_CHECK([whether $CXX supports __builtin_bswap32],
4331   ncbi_cv_cxx_builtin_bswap32,
4332   [AC_LINK_IFELSE([AC_LANG_PROGRAM([],
4333                       [[int i = 0x01234567; return __builtin_bswap32(i);]])],
4334       [ncbi_cv_cxx_builtin_bswap32=yes], [ncbi_cv_cxx_builtin_bswap32=no])])
4335if test $ncbi_cv_cxx_builtin_bswap32 = yes; then
4336   AC_DEFINE(HAVE_BUILTIN_BSWAP, 1,
4337      [Define to 1 if the C++ compiler supports __builtin_bswap32.])
4338fi
4339
4340AC_CACHE_CHECK([whether $CXX supports __builtin_expect],
4341   ncbi_cv_cxx_builtin_expect,
4342   [AC_LINK_IFELSE([AC_LANG_PROGRAM([],
4343                       [[int i = 0;  return __builtin_expect(i, 0);]])],
4344       [ncbi_cv_cxx_builtin_expect=yes], [ncbi_cv_cxx_builtin_expect=no])])
4345if test $ncbi_cv_cxx_builtin_expect = yes; then
4346   AC_DEFINE(HAVE_BUILTIN_EXPECT, 1,
4347      [Define to 1 if the C++ compiler supports __builtin_expect.])
4348fi
4349
4350### Check for the availability of other packages
4351### --------------------------------------------
4352
4353
4354AC_MSG_CHECKING([whether in-house NCBI resources are available])
4355if test -n "$orig_NCBI" -a -f "$orig_NCBI/.ncbirc" \
4356    -a \( -d /am/ncbiapdata/test_data -o -d /Volumes/ncbiapdata/test_data \)
4357then
4358   NCBI_FEATURE(in-house-resources)
4359   AC_MSG_RESULT(yes)
4360else
4361   AC_MSG_RESULT(no)
4362fi
4363
4364### Common-use system and miscellaneous libs
4365if test -z "${NETWORK_LIBS+set}"; then
4366   AC_SEARCH_LIBS(gethostbyname, [nsl],
4367      [test "x$ac_cv_search_gethostbyname" = "xnone required" \
4368       || libnsl=$ac_cv_search_gethostbyname],
4369      [libnsl=])
4370   AC_SEARCH_LIBS(connect, [socket],
4371      [test "x$ac_cv_search_connect" = "xnone required" \
4372       || NETWORK_LIBS="$ac_cv_search_connect $libnsl"],
4373      [NETWORK_LIBS=$libnsl])
4374fi
4375AC_CACHE_CHECK([for res_search in -lresolv], ac_cv_lib_resolv_res_search,
4376   [orig_LIBS=$LIBS
4377    LIBS="-lresolv $NETWORK_LIBS $orig_LIBS"
4378    AC_LINK_IFELSE([AC_LANG_PROGRAM(
4379       [[@%:@include <resolv.h>]],
4380       [[unsigned char ans[256];
4381         int st = res_search("foo.bar", 1, 1, ans, sizeof(ans));]])],
4382       [ac_cv_lib_resolv_res_search=yes], [ac_cv_lib_resolv_res_search=no])
4383    LIBS=$orig_LIBS])
4384if test "$ac_cv_lib_resolv_res_search" = "yes"; then
4385   RESOLVER_LIBS=-lresolv
4386else
4387   RESOLVER_LIBS=
4388fi
4389
4390orig_LIBS=$LIBS
4391LIBS="$NETWORK_LIBS $orig_LIBS"
4392AC_CHECK_FUNCS(inet_ntoa_r)
4393AC_CACHE_CHECK([for getaddrinfo], ac_cv_func_getaddrinfo,
4394   [AC_LINK_IFELSE([AC_LANG_PROGRAM(
4395       [[@%:@include <netdb.h>]],
4396       [[struct addrinfo *p; getaddrinfo("foo", "bar", p, &p);]])],
4397       [ac_cv_func_getaddrinfo=yes], [ac_cv_func_getaddrinfo=no])])
4398test "$ac_cv_func_getaddrinfo" = "yes" && \
4399  AC_DEFINE(HAVE_GETADDRINFO, 1,
4400            [Define to 1 if you have the `getaddrinfo' function.])
4401AC_CACHE_CHECK([for getnameinfo], ac_cv_func_getnameinfo,
4402   [AC_LINK_IFELSE([AC_LANG_PROGRAM(
4403       [[@%:@include <netdb.h>
4404         @%:@include <sys/types.h>
4405         @%:@include <sys/socket.h>]],
4406       [[struct sockaddr p; char buf[256], buf2[256];
4407         getnameinfo(&p, sizeof(p), buf, 256, buf2, 256, 0);]])],
4408       [ac_cv_func_getnameinfo=yes], [ac_cv_func_getnameinfo=no])])
4409test "$ac_cv_func_getnameinfo" = "yes" && \
4410  AC_DEFINE(HAVE_GETNAMEINFO, 1,
4411            [Define to 1 if you have the `getnameinfo' function.])
4412AC_CHECK_FUNCS(freehostent gethostent_r getipnodebyaddr getipnodebyname \
4413               inet_ntop socketpair)
4414LIBS=$orig_LIBS
4415
4416
4417### Save original compiler/linker flags
4418orig_CPPFLAGS="$CPPFLAGS"
4419orig_LDFLAGS="$LDFLAGS"
4420orig_LIBS="$LIBS"
4421
4422
4423### Check for math functions that aren't always available
4424AC_CHECK_FUNCS(erf)
4425
4426NCBI_CHECK_LIBS(KSTAT, kstat, kstat_open)
4427NCBI_CHECK_LIBS(RPCSVC, rpcsvc, rstat)
4428AC_LANG_PUSH(C)
4429# Force C for this test because Sun WorkShop otherwise complains about
4430# multiple extern "C" declarations of setkey.
4431NCBI_CHECK_LIBS(CRYPT, crypt crypt_i, setkey)
4432AC_LANG_POP(C)
4433case "$host_os:$compiler" in
4434     linux*:ICC   ) ac_cv_search_dlopen="-ldl" ;;
4435     solaris*:GCC ) ac_cv_search_dlopen="-ldl" ;;
4436     darwin*      ) ac_cv_search_iconv="-liconv" ;;
4437esac
4438# Temporarily drop -fsanitize= flags for this test, as some toolchains count
4439# the support library's indirect use of libdt when building applications
4440# but not when building shared libraries with --no-undefined.
4441orig_CXXFLAGS=$CXXFLAGS
4442orig_LDFLAGS=$LDFLAGS
4443CXXFLAGS=`echo $CXXFLAGS | sed -e 's/[[^ ]]*fsanitize=[[^ ]]*//g'`
4444LDFLAGS=`echo $LDFLAGS | sed -e 's/[[^ ]]*fsanitize=[[^ ]]*//g'`
4445NCBI_CHECK_LIBS(DL, dl, dlopen)
4446CXXFLAGS=$orig_CXXFLAGS
4447LDFLAGS=$orig_LDFLAGS
4448orig_LIBS="$DL_LIBS $orig_LIBS"
4449# Left alone for the sake of anything using $(C_LIBS) in lieu of $(ORIG_LIBS).
4450# DL_LIBS=
4451dnl NCBI_CHECK_LIBS(UUID, uuid, uuid_generate)
4452AC_SEARCH_LIBS(uuid_generate, uuid,
4453   [NCBI_PACKAGE(UUID)
4454    test "x$ac_cv_search_uuid_generate" = "xnone required" || \
4455       UUID_LIBS=$ac_cv_search_uuid_generate])
4456LIBS=$orig_LIBS
4457dnl NCBI_CHECK_LIBS(FUSE, fuse, fuse_loop)
4458AC_SEARCH_LIBS(fuse_loop, fuse, [NCBI_PACKAGE(FUSE)])
4459LIBS=$orig_LIBS
4460# Temporarily drop OpenMP flags for this test, as some toolchains count
4461# its support library's indirect use of librt when building applications
4462# but not when building shared libraries with --no-undefined.
4463orig_CXXFLAGS=$CXXFLAGS
4464orig_LDFLAGS=$LDFLAGS
4465CXXFLAGS=`echo $CXXFLAGS | sed -e 's/[[^ ]]*openmp[[^ ]]*//g'`
4466LDFLAGS=`echo $LDFLAGS | sed -e 's/[[^ ]]*openmp[[^ ]]*//g'`
4467NCBI_CHECK_LIBS(RT, rt posix4, clock_gettime)
4468CXXFLAGS=$orig_CXXFLAGS
4469LDFLAGS=$orig_LDFLAGS
4470NCBI_CHECK_LIBS(DEMANGLE, demangle, cplus_demangle)
4471# Add to (orig_)LIBS if present for the sake of corelib and the
4472# following call to AC_CHECK_FUNCS.
4473if test -n "$DEMANGLE_LIBS$RT_LIBS"; then
4474    LIBS="$DEMANGLE_LIBS $RT_LIBS $LIBS"
4475    orig_LIBS="$DEMANGLE_LIBS $RT_LIBS $orig_LIBS"
4476fi
4477AC_CHECK_FUNCS([clock_gettime nanosleep pthread_cond_timedwait_relative_np \
4478                pthread_condattr_setclock sched_yield])
4479AC_CHECK_DECLS([CLOCK_MONOTONIC, CLOCK_SGI_CYCLE, CLOCK_REALTIME], [], [],
4480   [[@%:@include <time.h>
4481     @%:@ifdef HAVE_SYS_TIME_H
4482     @%:@  include <sys/time.h>
4483     @%:@endif]])
4484
4485dnl NCBI_CHECK_LIBS(ICONV, iconv, iconv)
4486# We need to include <iconv.h>, since some implementations rename the symbols.
4487# This logic adapted from Bruno Haible's iconv.m4.
4488AC_CACHE_CHECK(for library containing iconv, ac_cv_search_iconv, [
4489   ac_cv_search_iconv=no
4490   AC_LINK_IFELSE(
4491      [AC_LANG_PROGRAM(
4492         [[@%:@include <stdlib.h>
4493           @%:@include <iconv.h>]],
4494         [[iconv_t cd = iconv_open("","");
4495           iconv(cd,NULL,NULL,NULL,NULL);
4496           iconv_close(cd);]])],
4497      [ac_cv_search_iconv="none required"])
4498   if test "$ac_cv_search_iconv" != "none required"; then
4499      for l in iconv; do
4500         LIBS="-l$l $orig_LIBS"
4501         AC_LINK_IFELSE(
4502            [AC_LANG_PROGRAM(
4503                [[@%:@include <stdlib.h>
4504                  @%:@include <iconv.h>]],
4505                [[iconv_t cd = iconv_open("","");
4506                  iconv(cd,NULL,NULL,NULL,NULL);
4507                  iconv_close(cd);]])],
4508            [ac_cv_search_iconv=-l$l])
4509         LIBS="$orig_LIBS"
4510      done
4511   fi])
4512if test "x$ac_cv_search_iconv" != xno; then
4513   NCBI_PACKAGE(Iconv)
4514   AC_DEFINE(HAVE_LIBICONV, 1,
4515   [Define to 1 if ICONV is available, either in its own library or as part
4516    of the standard libraries.])
4517   AC_MSG_CHECKING([for iconv declaration])
4518   AC_CACHE_VAL(am_cv_proto_iconv, [
4519      AC_COMPILE_IFELSE([
4520         AC_LANG_SOURCE([
4521@%:@include <stdlib.h>
4522@%:@include <iconv.h>
4523extern
4524@%:@ifdef __cplusplus
4525"C"
4526@%:@endif
4527@%:@if defined(__STDC__) || defined(__cplusplus)
4528size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
4529@%:@else
4530size_t iconv();
4531@%:@endif
4532])], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
4533      am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
4534   am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
4535   AC_MSG_RESULT([$]{ac_t:-
4536       }[$]am_cv_proto_iconv)
4537   AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
4538     [Define as const if the declaration of iconv() needs const.])
4539   if test "x$ac_cv_search_iconv" != "xnone required"; then
4540      ICONV_LIBS=$ac_cv_search_iconv
4541   fi
4542fi
4543
4544
4545### Third-party libraries
4546
4547#### Set compiler prefix (empty for vendor compilers)
4548case "$signature_compiler:$ac_cv_have_decl__LIBCPP_VERSION" in
4549   Clang:no | LLVMGCC:no )
4550      compiler_pfx="GCC-"
4551      : ${gccver=`$CXX -dumpversion`}
4552      compiler_vpfx="GCC`echo $gccver | tr -d .`-"
4553      ;;
4554   Clang:* | *[[GIK]]CC:* )
4555      compiler_pfx="${signature_compiler}-"
4556      compiler_vpfx="${signature_compiler}${compiler_version}-"
4557      ;;
4558esac
4559
4560usr_lib=['[/usr]*/lib/*[amdsprcv]*[23469]*']
4561no_usr_lib="s,-L$usr_lib ,,g; s,-L/usr/lib/$multiarch ,,g"
4562
4563: ${with_libunwind:=no}
4564NCBI_CHECK_THIRD_PARTY_LIB_EX(libunwind, LIBUNWIND, unwind,
4565 [AC_LANG_PROGRAM([@%:@include <libunwind.h>
4566                   @%:@include <stdlib.h>],
4567      [[void *buffer; unw_backtrace(&buffer, 9);]])])
4568LIBS="$LIBUNWIND_LIBS $LIBS"
4569orig_LIBS="$LIBUNWIND_LIBS $orig_LIBS"
4570
4571NCBI_CHECK_THIRD_PARTY_LIB_EX(libdw, LIBDW, dw,
4572 [AC_LANG_PROGRAM([@%:@include <elfutils/libdw.h>],
4573      [[Dwarf* d = dwarf_begin(17, DWARF_C_READ);]])])
4574LIBS="$LIBDW_LIBS $LIBS"
4575orig_LIBS="$LIBDW_LIBS $orig_LIBS"
4576
4577NCBI_CHECK_THIRD_PARTY_LIB_EX(backward_cpp, BACKWARD_CPP, backward,
4578 [AC_LANG_PROGRAM([@%:@ifdef HAVE_LIBUNWIND
4579                   @%:@  define BACKWARD_HAS_UNWIND 1
4580                   @%:@else
4581                   @%:@  define BACKWARD_HAS_BACKTRACE 1
4582                   @%:@endif
4583                   @%:@ifdef HAVE_LIBDW
4584                   @%:@  define BACKWARD_HAS_DW 1
4585                   @%:@endif
4586                   @%:@include <backward.hpp>],
4587      [[backward::StackTrace st; st.load_here(32);]])],
4588 [], [], [$LIBUNWIND_INCLUDE $LIBDW_INCLUDE])
4589
4590
4591if test "$with_backward_cpp_sig" = yes; then
4592   AC_DEFINE(USE_LIBBACKWARD_SIG_HANDLING, 1,
4593             [Define to allow backward-cpp to also handle signals.])
4594fi
4595
4596NCBI_CHECK_THIRD_PARTY_LIB(z,
4597 [AC_LANG_PROGRAM([@%:@include <zlib.h>],
4598      [[gzFile fp; char buf[1024]; int n = gzread(fp, buf, sizeof(buf))]])])
4599if test -z "$Z_LIBS"; then
4600   zlocal=util/compress/zlib
4601   AC_MSG_NOTICE([using local zlib copy in $zlocal])
4602   Z_PATH="<$zlocal>"
4603   Z_INCLUDE="-I\$(includedir)/$zlocal -I\$(includedir0)/$zlocal"
4604   # Z_LIBS="-lz"
4605   Z_LIB="z"
4606   # AC_DEFINE(USE_LOCAL_ZLIB, 1, [Define to 1 if using a local copy of zlib.])
4607   NCBI_PACKAGE(Z)
4608   NCBI_PACKAGE(LocalZ)
4609fi
4610
4611NCBI_CHECK_THIRD_PARTY_LIB(bz2,
4612 [AC_LANG_PROGRAM([@%:@include <bzlib.h>],
4613      [[BZFILE* fp; char buf[1024]; int err;
4614        int n = BZ2_bzRead(&err, fp, buf, sizeof(buf))]])])
4615if test -z "$BZ2_LIBS"; then
4616   bzlocal=util/compress/bzip2
4617   AC_MSG_NOTICE([using local bzlib copy in $bzlocal])
4618   BZ2_PATH="<$bzlocal>"
4619   BZ2_INCLUDE="-I\$(includedir)/$bzlocal -I\$(includedir0)/$bzlocal"
4620   # BZ2_LIBS="-lbz2"
4621   BZ2_LIB="bz2"
4622   AC_DEFINE(USE_LOCAL_BZLIB, 1, [Define to 1 if using a local copy of bzlib.])
4623   NCBI_PACKAGE(BZ2)
4624   NCBI_PACKAGE(LocalBZ2)
4625fi
4626
4627if test -d "$LZO_PATH"; then
4628   NCBI_FIX_DIR(LZO_PATH)
4629fi
4630NCBI_CHECK_THIRD_PARTY_LIB_EX(lzo, LZO, lzo2,
4631 [AC_LANG_PROGRAM([@%:@include <lzo/lzo1x.h>],
4632      [[lzo_uint32 c = lzo_crc32(0, (const unsigned char*)"foo", 3);]])])
4633if test -n "$LZO_LIBS" -a "x$with_bin_release" = xyes \
4634        -a \( -f "$LZO_PATH/lib$bit64_sfx/liblzo2-static.a" \
4635              -o -f "$LZO_PATH/lib/liblzo2-static.a" \); then
4636   LZO_LIBS="$LZO_LIBPATH -llzo2-static"
4637fi
4638
4639if test -d "$ZSTD_PATH"; then
4640   NCBI_FIX_DIR(ZSTD_PATH)
4641fi
4642NCBI_CHECK_THIRD_PARTY_LIB(zstd,
4643 [AC_LANG_PROGRAM([@%:@include <zstd.h>],
4644      [[ZSTD_CCtx* cctx = ZSTD_createCCtx();]])])
4645
4646if test -z "$PCRE_PATH"  &&  pcre-config --version >/dev/null 2>&1; then
4647    p=`pcre-config --prefix`
4648    test "x$p" = "x/usr"  ||  PCRE_PATH=$p
4649fi
4650NCBI_CHECK_THIRD_PARTY_LIB(pcre,
4651 [AC_LANG_PROGRAM([@%:@include <pcre.h>],
4652   [[const char*s[]={"x"}; pcre* p; pcre_extra* x = pcre_study(p, 1, s);]])])
4653if test -z "$PCRE_LIBS"; then
4654   pcrelocal=util/regexp
4655   AC_MSG_NOTICE([using local PCRE copy in $pcrelocal])
4656   PCRE_PATH="<$pcrelocal>"
4657   PCRE_INCLUDE="-I\$(includedir)/$pcrelocal -I\$(includedir0)/$pcrelocal"
4658   # PCRE_LIBS="-lregexp"
4659   # PCREPOSIX_LIBS="-lregexp"
4660   PCRE_LIB="regexp"
4661   AC_DEFINE(USE_LOCAL_PCRE, 1, [Define to 1 if using a local copy of PCRE.])
4662   NCBI_PACKAGE(PCRE)
4663   NCBI_PACKAGE(LocalPCRE)
4664else
4665   PCREPOSIX_LIBS=`echo "$PCRE_LIBS" | sed -e 's/-lpcre/-lpcreposix -lpcre/'`
4666fi
4667
4668## SSL/TLS libraries (and supporting libraries)
4669if test "x${with_mbedtls-no}" != xno; then
4670   case "$with_mbedtls" in
4671      yes ) ;;
4672      *   ) MBEDTLS_PATH=$with_mbedtls ;;
4673   esac
4674   d="$MBEDTLS_PATH/${DEBUG_SFX}${mt_sfx}${bit64_sfx}"
4675   if test -d "$d"; then
4676      MBEDTLS_PATH=$d
4677   fi
4678   if test -d "$MBEDTLS_PATH"; then
4679      NCBI_FIX_DIR(MBEDTLS_PATH)
4680   fi
4681   NCBI_CHECK_THIRD_PARTY_LIB(mbedtls,
4682      [AC_LANG_PROGRAM([@%:@include <mbedtls/ssl.h>],
4683           [[mbedtls_ssl_context ssl; mbedtls_ssl_init(&ssl);]])],
4684      [[-lmbedx509 -lmbedcrypto $Z_LIBS]])
4685   if test -n "$MBEDTLS_LIBS" -a -f "$MBEDTLS_PATH/lib/libmbedtls-static.a" \
4686      -a "x$with_static_mbedtls" = xyes; then
4687      MBEDTLS_LIBS="-L$MBEDTLS_PATH/lib -lmbedtls-static -lmbedx509-static -lmbedcrypto-static $Z_LIBS"
4688   fi
4689fi
4690if test -z "$MBEDTLS_LIBS"; then
4691   mbedtls_local=connect/mbedtls
4692   AC_MSG_NOTICE([using local mbedTLS copy in $mbedtls_local])
4693   MBEDTLS_INCLUDE=""
4694   MBEDTLS_LIBS="$Z_LIBS"
4695   NCBI_PACKAGE(MBEDTLS)
4696fi
4697
4698if test "x$with_gmp" != xno; then
4699   case "$with_gmp" in
4700      yes | '' ) ;;
4701      *        ) GMP_PATH=$with_gmp ;;
4702   esac
4703   for pfx in "$compiler_vpfx" "$compiler_pfx" "" ; do
4704      vpath=$GMP_PATH/$pfx${DEBUG_SFX}${mt_sfx}${bit64_sfx}
4705      if test -d "$vpath" ; then
4706         GMP_PATH=$vpath
4707         break
4708      fi
4709   done
4710   if test -d "$GMP_PATH"; then
4711      NCBI_FIX_DIR(GMP_PATH)
4712   fi
4713   NCBI_CHECK_THIRD_PARTY_LIB(gmp,
4714      [AC_LANG_PROGRAM([@%:@include <gmp.h>],
4715           [[mpz_t x; mpz_init(x);]])])
4716fi
4717if test "$with_gmp" = no; then
4718   AS_UNSET(GMP_INCLUDE)
4719   AS_UNSET(GMP_LIBS)
4720else
4721   NCBI_PACKAGE(GMP)
4722fi
4723
4724case "$with_gcrypt" in
4725   no )       ac_cv_path_LIBGCRYPT_CONFIG=no ;;
4726   yes | '' )                                ;;
4727   * )        GCRYPT_PATH=$with_gcrypt       ;;
4728esac
4729if test -d "$GCRYPT_PATH"; then
4730   NCBI_FIX_DIR(GCRYPT_PATH)
4731fi
4732AC_PATH_PROG(LIBGCRYPT_CONFIG, libgcrypt-config, [], [${GCRYPT_BIN-$GCRYPT_PATH/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}/bin}:$GCRYPT_PATH/bin${bit64_sfx}:$GCRYPT_PATH/bin:$PATH])
4733
4734if test "x$with_gcrypt" != xno; then
4735   if test -x "$LIBGCRYPT_CONFIG"; then
4736      if test -z "$GCRYPT_PATH"; then
4737         p=`libgcrypt-config --prefix`
4738         test "x$p" = "x/usr"  ||  GCRYPT_PATH=$p
4739      fi
4740      NCBI_RPATHIFY_OUTPUT(GCRYPT_LIBPATH,
4741        [$LIBGCRYPT_CONFIG --exec-prefix], [s,^,-L,; s,$,/lib,;])
4742      GCRYPT_INCLUDE=`$LIBGCRYPT_CONFIG --cflags`
4743      GCRYPT_CONFIG_LIBS="`$LIBGCRYPT_CONFIG --libs` $Z_LIBS"
4744   fi
4745else
4746   AS_UNSET(GCRYPT_CONFIG_LIBS)
4747fi
4748NCBI_CHECK_THIRD_PARTY_LIB(gcrypt,
4749 [AC_LANG_PROGRAM([[@%:@include <gcrypt.h>
4750                     @%:@include <pthread.h>
4751                     @%:@include <errno.h>
4752                     GCRY_THREAD_OPTION_PTHREAD_IMPL;]],
4753   [[gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);]])],
4754 $GCRYPT_CONFIG_LIBS)
4755if test "x$with_gcrypt" != xno -a -n "$GCRYPT_CONFIG_LIBS"; then
4756   NCBI_RPATHIFY_OUTPUT(GCRYPT_LIBS, [echo $GCRYPT_CONFIG_LIBS], [$no_usr_lib])
4757fi
4758
4759if test "x$with_nettle" != xno; then
4760   case "$with_nettle" in
4761      yes | '' ) ;;
4762      *        ) NETTLE_PATH=$with_nettle ;;
4763   esac
4764   if test -d "$NETTLE_PATH"; then
4765      NCBI_FIX_DIR(NETTLE_PATH)
4766   fi
4767   if test -d "$NETTLE_PATH/lib$bit64_sfx"; then
4768      NETTLE_LIBDIR=$NETTLE_PATH/lib$bit64_sfx
4769   else
4770      NETTLE_LIBDIR=$NETTLE_PATH/lib
4771   fi
4772   for pfx in "$compiler_vpfx" "$compiler_pfx" "" ; do
4773      vpath=$NETTLE_PATH/$pfx${DEBUG_SFX}${mt_sfx}${bit64_sfx}
4774      if test -d "$vpath" ; then
4775         NETTLE_LIBDIR=$vpath/lib
4776         break
4777      fi
4778   done
4779   if test -d "$NETTLE_LIBDIR"; then
4780      NCBI_FIX_DIR(NETTLE_LIBDIR)
4781      NCBI_RPATHIFY(NETTLE_LIBPATH, $NETTLE_LIBDIR)
4782   fi
4783   NCBI_CHECK_THIRD_PARTY_LIB_EX(nettle, NETTLE, hogweed,
4784      [AC_LANG_PROGRAM([@%:@include <nettle/sexp.h>],
4785           [[struct sexp_iterator it;
4786             sexp_iterator_first(&it, 0, (const uint8_t*) NULL);]])],
4787      [-lnettle], [$GMP_LIBS])
4788fi
4789if test "$with_nettle" = no; then
4790   AS_UNSET(NETTLE_INCLUDE)
4791   AS_UNSET(NETTLE_LIBS)
4792else
4793   NCBI_PACKAGE(NETTLE)
4794fi
4795
4796case "${with_gnutls=no}" in
4797   no  ) ac_cv_path_LIBGNUTLS_CONFIG=no ;;
4798   yes )                                ;;
4799   *   ) GNUTLS_PATH=$with_gnutls       ;;
4800esac
4801if test -d "$GNUTLS_PATH"; then
4802   NCBI_FIX_DIR(GNUTLS_PATH)
4803   gnutls_config_path=${GNUTLS_BIN-$GNUTLS_PATH/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}/bin}:$GNUTLS_PATH/bin${bit64_sfx}:$GNUTLS_PATH/bin
4804else
4805   gnutls_config_path=$PATH
4806fi
4807AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, [], [$gnutls_config_path])
4808
4809if test "x$with_gnutls" != xno; then
4810   if test -x "$LIBGNUTLS_CONFIG"; then
4811      if test -z "$GNUTLS_PATH"; then
4812         p=`$LIBGNUTLS_CONFIG --prefix`
4813         test "x$p" = "x/usr"  ||  GNUTLS_PATH=$p
4814      fi
4815   else
4816      LIBGNUTLS_CONFIG="eval PKG_CONFIG_PATH=\"$GNUTLS_PATH/lib$bit64_sfx/pkgconfig:$GNUTLS_PATH/lib/pkgconfig\" pkg-config gnutls --static"
4817      $LIBGNUTLS_CONFIG --exists >/dev/null 2>&1 ||  LIBGNUTLS_CONFIG=no
4818   fi
4819   case "$LIBGNUTLS_CONFIG" in
4820       eval\ *)
4821           NCBI_RPATHIFY_OUTPUT(GNUTLS_LIBPATH,
4822             [$LIBGNUTLS_CONFIG --libs-only-L])
4823           GNUTLS_CONFIG_LIBS=`$LIBGNUTLS_CONFIG --libs-only-l`
4824           GNUTLS_CONFIG_LIBS="$GNUTLS_LIBPATH $GNUTLS_CONFIG_LIBS $Z_LIBS"
4825           ;;
4826       no)
4827           ;;
4828       *)
4829           NCBI_RPATHIFY_OUTPUT(GNUTLS_LIBPATH,
4830             [$LIBGNUTLS_CONFIG --exec-prefix], [s,^,-L,; s,$,/lib,;])
4831           GNUTLS_CONFIG_LIBS="`$LIBGNUTLS_CONFIG --libs` $Z_LIBS"
4832           ;;
4833   esac
4834
4835   if test "x$LIBGNUTLS_CONFIG" != xno; then
4836      GNUTLS_INCLUDE=`$LIBGNUTLS_CONFIG --cflags`
4837   fi
4838else
4839   AS_UNSET(GNUTLS_CONFIG_LIBS)
4840fi
4841NCBI_CHECK_THIRD_PARTY_LIB(gnutls,
4842 [AC_LANG_PROGRAM([[@%:@include <gnutls/gnutls.h>]],
4843   [[gnutls_session_t s; gnutls_init(&s, GNUTLS_CLIENT);]])],
4844 [$GNUTLS_CONFIG_LIBS], [$GCRYPT_LIBS $NETTLE_LIBS $GMP_LIBS])
4845if test "x$with_gnutls" != xno; then
4846   AC_CHECK_FUNCS([gnutls_certificate_set_verify_function \
4847                   gnutls_record_disable_padding gnutls_rnd])
4848   AC_CHECK_HEADERS([gnutls/abstract.h])
4849   if test -n "$GNUTLS_CONFIG_LIBS"; then
4850      NCBI_RPATHIFY_OUTPUT(GNUTLS_LIBS, [echo $GNUTLS_CONFIG_LIBS],
4851         [$no_usr_lib])
4852   else
4853      GNUTLS_LIBS="$GNUTLS_LIBS $NETTLE_LIBS $GMP_LIBS"
4854   fi
4855   # Conservatively build against gcrypt if available even when gnutls
4856   # uses nettle instead, because gcrypt needs explicit initialization
4857   # to be thread-safe, but gnutls's headers don't indicate which
4858   # underlying crypto library it's actually using.
4859   case "$GNUTLS_INCLUDE" in
4860       *$GCRYPT_INCLUDE* ) ;;
4861       *                 ) GNUTLS_INCLUDE="$GNUTLS_INCLUDE $GCRYPT_INCLUDE" ;;
4862   esac
4863   case "$GNUTLS_LIBS" in
4864       *\ -lgcrypt* ) ;;
4865       *            ) GNUTLS_LIBS="$GNUTLS_LIBS $GCRYPT_LIBS" ;;
4866   esac
4867   if test "$with_static_gnutls" = yes; then
4868      dirs=''
4869      sep=''
4870      static_libs=''
4871      for x in $GNUTLS_LIBS; do
4872         case $x in
4873            -L* ) dirs="$dirs `echo _$x | cut -c4-`" ;;
4874            -l* )
4875                want=lib`echo _$x | cut -c4-`-static.a
4876                for d in $dirs; do
4877                   if test -f $d/$want; then
4878                      x=$x-static
4879                      break
4880                   fi
4881                done
4882                ;;
4883         esac
4884         static_libs=$static_libs$sep$x
4885         sep=' '
4886      done
4887      GNUTLS_LIBS="$static_libs $ICONV_LIBS"
4888   fi
4889fi
4890
4891NCBI_CHECK_THIRD_PARTY_LIB_EX(openssl, OPENSSL, ssl,
4892 [AC_LANG_PROGRAM([[@%:@include <openssl/ssl.h>]],
4893   [[SSL_library_init();]])],
4894 -lcrypto)
4895
4896OPENSSL_STATIC_LIBS=$OPENSSL_LIBS
4897for d in `echo " $OPENSSL_LIBS" | fmt -w 1 | sed -ne 's/^ *-L//p'` \
4898   /usr/local/lib${bit64_sfx} /usr/local/lib /usr/lib${bit64_sfx} /usr/lib; do
4899   if test -f $d/libssl.a -a -f $d/libcrypto.a; then
4900      OPENSSL_STATIC_LIBS="$d/libssl.a $d/libcrypto.a"
4901      break
4902   elif test -f $d/libssl.so -o -f $d/libssl.dylib; then
4903      break
4904   fi
4905done
4906
4907NETWORK_LIBS="$GNUTLS_LIBS $MBEDTLS_LIBS $NETWORK_LIBS"
4908
4909case "$with_krb5" in
4910   no )       ac_cv_path_KRB5_CONFIG=no    ;;
4911   yes | '' ) : ${KRB5_PATH=/usr/kerberos} ;;
4912   * )        KRB5_PATH=$with_krb5         ;;
4913esac
4914AC_PATH_PROG(KRB5_CONFIG, krb5-config, [], [${KRB5_BIN-$KRB5_PATH/bin}:$PATH])
4915
4916if test "x$with_krb5" != xno; then
4917   if test -x "$KRB5_CONFIG"; then
4918      KRB5_PATH=`$KRB5_CONFIG --prefix`
4919      KRB5_INCLUDE=`$KRB5_CONFIG --cflags | \
4920         sed -e 's/$/ /; s,-I/usr/include ,,'`
4921      KRB5_CONFIG_LIBS=`$KRB5_CONFIG --libs gssapi | \
4922         sed -e 's/^/ /; s/ -[[^Ll]][[^ ]]*//g'`
4923   fi
4924else
4925   dnl AS_UNSET(KRB5_CONFIG_LIBS)
4926   KRB5_CONFIG_LIBS=$KRB5_LIBS
4927fi
4928NCBI_CHECK_THIRD_PARTY_LIB_EX(krb5, KRB5, gssapi_krb5,
4929 [AC_LANG_PROGRAM([[@%:@include <time.h>
4930@%:@ifdef HAVE_INTTYPES_H
4931@%:@  include <inttypes.h>
4932@%:@endif
4933extern "C" {
4934@%:@include <gssapi/gssapi_krb5.h>
4935}]],
4936   [[OM_uint32 min_stat;
4937     gss_buffer_desc buf;
4938     gss_release_buffer(&min_stat, &buf);]])],
4939 $KRB5_CONFIG_LIBS)
4940if test "x$with_krb5" != xno; then
4941   AC_CHECK_FUNCS([error_message])
4942   AC_CHECK_HEADERS([com_err.h roken.h])
4943   NCBI_RPATHIFY_OUTPUT(KRB5_LIBS, [echo $KRB5_CONFIG_LIBS], [$no_usr_lib])
4944fi
4945
4946
4947NCBI_CHECK_THIRD_PARTY_LIB(curl,
4948   [AC_LANG_PROGRAM([@%:@include <curl/curl.h>],
4949       [char* v = curl_version();])])
4950
4951
4952## SYBASE libraries
4953
4954NETWORK_PURE_LIBS="$NETWORK_LIBS"
4955if test "$with_sybase" != "no" ; then
4956   resolve_sybase=true
4957   default_pointer=default-${NCBI_PLATFORM_BITS}bit
4958   : ${with_sybase_new:="no"}
4959   case "$host_os" in
4960      linux* )
4961         : ${with_sybase_local:=yes}
4962         ;;
4963      * )
4964         if test -d "$net_sybase_root" ; then
4965            : ${with_sybase_local:=no}
4966         else
4967            : ${with_sybase_local:=yes}
4968         fi
4969         ;;
4970   esac
4971
4972   if test "$with_sybase_local" != "no" ; then
4973      if test "$with_sybase_local" = "yes" ; then
4974         if test -n "$SYBASE_PATH" ; then
4975            with_sybase_local=$SYBASE_PATH
4976         else
4977            if test "$with_sybase_new" = "yes" ; then
4978               with_sybase_local=$local_sybase_root/new
4979            elif test -f "$local_sybase_root/$default_pointer" ; then
4980               with_sybase_local=`cat $local_sybase_root/$default_pointer`
4981               resolve_sybase=false
4982            else
4983               with_sybase_local=$local_sybase_root/current
4984            fi
4985            if test -d "$with_sybase_local$NCBI_PLATFORM_BITS" ; then
4986               with_sybase_local=$with_sybase_local$NCBI_PLATFORM_BITS
4987            fi
4988         fi # default paths
4989      fi # no command-line path
4990      if test -d "$with_sybase_local" ; then
4991         SYBASE_PATH=$with_sybase_local
4992         SYBASE_LCL_PATH=
4993      else
4994         with_sybase_local=no
4995      fi
4996   fi
4997
4998   if test "$with_sybase_local" = "no" ; then
4999      if test "$with_sybase_new" = "yes" ; then
5000         if test -d "$net_sybase_root/new$NCBI_PLATFORM_BITS" ; then
5001            SYBASE_LCL_PATH=$local_sybase_root/new$NCBI_PLATFORM_BITS
5002            SYBASE_PATH=$net_sybase_root/new$NCBI_PLATFORM_BITS
5003         elif test -d "$net_sybase_root/new" ; then
5004            SYBASE_LCL_PATH=$local_sybase_root/new
5005            SYBASE_PATH=$net_sybase_root/new
5006         else
5007            with_sybase_new=no
5008         fi
5009      fi
5010
5011      if test -z "$SYBASE_PATH" ; then
5012         if test -f "$net_sybase_root/$default_pointer" ; then
5013            SYBASE_LCL_PATH=
5014            SYBASE_PATH=`cat $local_sybase_root/$default_pointer`
5015            resolve_sybase=false
5016         elif test -d "$net_sybase_root/current$NCBI_PLATFORM_BITS" ; then
5017            SYBASE_LCL_PATH=$local_sybase_root/current$NCBI_PLATFORM_BITS
5018            SYBASE_PATH=$net_sybase_root/current$NCBI_PLATFORM_BITS
5019         elif test -d "$net_sybase_root/current" ; then
5020            SYBASE_LCL_PATH=$local_sybase_root/current
5021            SYBASE_PATH=$net_sybase_root/current
5022         else
5023            SYBASE_LCL_PATH=
5024            SYBASE_PATH=$SYBASE
5025         fi
5026      fi
5027   fi
5028
5029   # Lock in the version we found, ignoring symlinks further up
5030   case "$SYBASE_PATH" in
5031      */[[1-9]]* ) resolve_sybase=false ;;
5032   esac
5033   if test -d "$SYBASE_PATH"  &&  $resolve_sybase; then
5034      # SYBASE_PATH_=`cd $SYBASE_PATH && /bin/pwd`
5035      SYBASE_PATH_=`ls -ld $SYBASE_PATH | sed -ne 's/.* -> //p'`
5036      case "$SYBASE_PATH_" in
5037         '' ) ;;
5038         /* )
5039            SYBASE_VERSION=`basename $SYBASE_PATH_`
5040            SYBASE_PATH=`dirname $SYBASE_PATH`/$SYBASE_VERSION
5041            test -d "$SYBASE_PATH"  ||  SYBASE_PATH=$SYBASE_PATH_
5042            ;;
5043         * )
5044            orig_parent=`dirname $SYBASE_PATH`
5045            SYBASE_VERSION=`basename $SYBASE_PATH_`
5046            SYBASE_PATH=$orig_parent/$SYBASE_VERSION
5047            test -d "$SYBASE_PATH"  ||  SYBASE_PATH=$orig_parent/$SYBASE_PATH_
5048            ;;
5049      esac
5050   fi
5051
5052   if test -d "$SYBASE_LCL_PATH"  &&  $resolve_sybase ; then
5053      # SYBASE_LCL_PATH_=`cd $SYBASE_LCL_PATH && /bin/pwd`
5054      SYBASE_LCL_PATH_=`ls -ld $SYBASE_LCL_PATH | sed -ne 's/.* -> //p'`
5055      case "$SYBASE_LCL_PATH_" in
5056         '' ) ;;
5057         /* )
5058            SYBASE_LCL_VERSION=`basename $SYBASE_LCL_PATH_`
5059            SYBASE_LCL_PATH=`dirname $SYBASE_LCL_PATH`/$SYBASE_LCL_VERSION
5060            test -d "$SYBASE_LCL_PATH"  ||  SYBASE_LCL_PATH=$SYBASE_LCL_PATH_
5061            ;;
5062         * )
5063            orig_parent=`dirname $SYBASE_LCL_PATH`
5064            SYBASE_LCL_VERSION=`basename $SYBASE_LCL_PATH_`
5065            SYBASE_LCL_PATH=$orig_parent/$SYBASE_LCL_VERSION
5066            test -d "$SYBASE_LCL_PATH"  || \
5067               SYBASE_LCL_PATH=$orig_parent/$SYBASE_LCL_PATH_
5068            ;;
5069      esac
5070   elif test -n "$SYBASE_LCL_PATH" ; then
5071      SYBASE_LCL_PATH=`dirname $SYBASE_LCL_PATH`/$SYBASE_VERSION
5072   fi
5073
5074   if test -n "$SYBASE_VERSION" -a -n "$SYBASE_LCL_VERSION" \
5075        -a "$SYBASE_VERSION" != "$SYBASE_LCL_VERSION" ; then
5076      AC_MSG_WARN([ignoring inconsistent local Sybase symlink: $SYBASE_LCL_VERSION vs. $SYBASE_VERSION])
5077      SYBASE_LCL_PATH=`dirname $SYBASE_LCL_PATH`/$SYBASE_VERSION
5078   fi
5079
5080   if test -n "$SYBASE" ; then
5081      if test -d "$net_sybase_root" -o -d "$local_sybase_root" ; then
5082         case $SYBASE in
5083            $net_sybase_root/* | $local_sybase_root/* ) ;;
5084            * ) AC_MSG_WARN([ignoring non-standard SYBASE setting: $SYBASE]) ;;
5085            # Ignored regardless, but standard values are not so concerning.
5086         esac
5087      fi
5088   fi
5089
5090   if test -f "$SYBASE_PATH/SYBASE.env"; then
5091      ocs=`sed -ne 's:^SYBASE_OCS=:/:p' "$SYBASE_PATH/SYBASE.env"`
5092   else
5093      ocs=
5094   fi
5095   if test -d "$SYBASE_PATH$ocslib$bit64_sfx"; then
5096      SYBASE_LIBPATH="$SYBASE_PATH$ocs/lib$bit64_sfx"
5097   else
5098      SYBASE_LIBPATH="$SYBASE_PATH$ocs/lib"
5099   fi
5100   syb_sfx=$bit64_sfx
5101   if test -f "$SYBASE_LIBPATH/libsybct$syb_sfx.a"; then
5102      syb_pfx=syb
5103   else
5104      syb_pfx=
5105   fi
5106
5107   if test "$with_mt" = "yes" ; then
5108      AC_CACHE_CHECK([for reentrant Sybase libraries], ncbi_cv_lib_sybase_r,
5109         [if test -f "$SYBASE_LIBPATH/lib${syb_pfx}ct_r$bit64_sfx.so"; then
5110             ncbi_cv_lib_sybase_r=yes
5111          else
5112             ncbi_cv_lib_sybase_r=no
5113          fi])
5114      if test $ncbi_cv_lib_sybase_r = yes; then
5115         syb_sfx=_r$bit64_sfx
5116      fi
5117   fi
5118   case "$host_os" in
5119      linux*) sybtcl=-lsybtcl$syb_sfx; sybtli="" ;;
5120      *)      sybtcl=-l${syb_pfx}tcl$syb_sfx; sybtli=-ltli$syb_sfx ;;
5121   esac
5122   test -f "$SYBASE_LIBPATH/libtli.so" || sybtli=
5123
5124   # quick-patch for the bad "tli" lib (Solaris8/Intel specific)
5125   case "$host_os:$host_vendor" in
5126      solaris*:pc )  : ${sybase_sol8pc_patch:="yes"} ;;
5127   esac
5128   if test "$sybase_sol8pc_patch" = "yes" ; then
5129      sybtli="-ltli_orig$syb_sfx -ltli$syb_sfx"
5130      SYBASE_NETWORK_LIBS="-ltli$syb_sfx $NETWORK_LIBS"
5131   else
5132      SYBASE_NETWORK_LIBS="$NETWORK_LIBS"
5133   fi
5134
5135   if test -f "$SYBASE_LIBPATH/libsybunic${bit64_sfx}.a"; then
5136      sybunic=-lsybunic${bit64_sfx}
5137   fi
5138
5139   test -n "$bit64_sfx"  &&  SYBASE_INCLUDE="-DSYB_LP64"
5140   SYBASE_LIBLIST="-l${syb_pfx}blk$syb_sfx -l${syb_pfx}ct$syb_sfx"
5141   SYBASE_LIBLIST="$SYBASE_LIBLIST -l${syb_pfx}cs$syb_sfx $sybtcl"
5142   SYBASE_LIBLIST="$SYBASE_LIBLIST -l${syb_pfx}comn$syb_sfx"
5143   SYBASE_LIBLIST="$SYBASE_LIBLIST -l${syb_pfx}intl$syb_sfx $sybunic"
5144   SYBASE_DLLLIST="$sybtli"
5145
5146   # deduce conf.macro: SYBASE_INCLUDE, SYBASE_LIBS, SYBASE_DLLS, SYBASE_DBLIBS
5147   SYBASE_INCLUDE="-I$SYBASE_PATH$ocs/include $SYBASE_INCLUDE"
5148   if test -z "$SYBASE_LCL_PATH" ; then
5149      NCBI_RPATHIFY(SYBASE_LPATH, $SYBASE_LIBPATH)
5150   else
5151      SYBASE_LCL_LIBPATH="$SYBASE_LCL_PATH$ocs/${sybase_lib}"
5152      NCBI_RPATHIFY(SYBASE_LPATH, $SYBASE_LCL_LIBPATH $SYBASE_LIBPATH)
5153      SYBASE_INCLUDE="-I$SYBASE_LCL_PATH$ocs/include $SYBASE_INCLUDE"
5154   fi
5155   SYBASE_LIBS="$SYBASE_LPATH $SYBASE_LIBLIST"
5156   SYBASE_DBLIBS="$SYBASE_LPATH $SYBASE_DBLIBS"
5157   SYBASE_DLLS="$SYBASE_DLLLIST"
5158
5159   AC_CACHE_CHECK([for Sybase${SYBASE_PATH:+ in $SYBASE_PATH}],
5160      ncbi_cv_lib_sybase,
5161      [CPPFLAGS="$SYBASE_INCLUDE $orig_CPPFLAGS"
5162       LIBS="$SYBASE_LIBS $SYBASE_DLLS $SYBASE_NETWORK_LIBS $orig_LIBS"
5163       AC_LINK_IFELSE([AC_LANG_PROGRAM(
5164          [[@%:@include <ctpublic.h>]],
5165          [[CS_RETCODE i = ct_init(0,0);  i = cs_ctx_global(0,0); ]])],
5166          [ncbi_cv_lib_sybase=yes], [ncbi_cv_lib_sybase=no])])
5167
5168   if test "$ncbi_cv_lib_sybase" = yes; then
5169      NCBI_PACKAGE(Sybase)
5170      AC_DEFINE(HAVE_LIBSYBASE, 1,
5171                [Define to 1 if SYBASE libraries are available.])
5172      if test "$with_mt" = "yes" -a "$ncbi_cv_lib_sybase_r" = "yes"; then
5173         AC_DEFINE(HAVE_SYBASE_REENTRANT, 1,
5174                   [Define to 1 if SYBASE has reentrant libraries.])
5175      fi
5176
5177      SYBASE_DBLIBS="$SYBASE_LPATH -lsybdb${bit64_sfx} $sybunic"
5178      AC_CACHE_CHECK([for Sybase DBLib], ncbi_cv_lib_sybdb,
5179         [CPPFLAGS="$SYBASE_INCLUDE $orig_CPPFLAGS"
5180          LIBS="$SYBASE_DBLIBS $SYBASE_LIBS $SYBASE_DLLS $SYBASE_NETWORK_LIBS $orig_LIBS"
5181          AC_LINK_IFELSE([AC_LANG_PROGRAM(
5182             [[
5183              @%:@include <sybfront.h>
5184              @%:@include <sybdb.h>
5185             ]],
5186             [[
5187              LOGINREC*  x_login     = 0;
5188              DBPROCESS* x_dbproc    = dbopen(x_login, (char*) "SRV_NAME");
5189             ]])],
5190             [ncbi_cv_lib_sybdb=yes], [ncbi_cv_lib_sybdb=no])])
5191      if test "$ncbi_cv_lib_sybdb" = yes; then
5192         NCBI_PACKAGE(DBLib)
5193         AC_DEFINE(HAVE_LIBSYBDB, 1,
5194                   [Define to 1 if SYBASE DBLib is available.])
5195      else
5196         SYBASE_DBLIBS=
5197      fi
5198      # apply the Sybase patch to $NETWORK_LIBS
5199      if test "$sybase_sol8pc_patch" = "yes" ; then
5200         NETWORK_LIBS="$SYBASE_LPATH $SYBASE_NETWORK_LIBS"
5201      fi
5202   else
5203      NCBI_MISSING_PACKAGE(sybase)
5204   fi
5205fi # with_sybase != no?
5206
5207if test "$with_sybase" = no; then
5208   SYBASE_PATH="No_Sybase"
5209   SYBASE_INCLUDE=
5210   SYBASE_LIBS=
5211   SYBASE_DLLS=
5212   SYBASE_DBLIBS=
5213fi
5214
5215SYBASE_LPATH=
5216SYBASE_LCL_LIBPATH=
5217SYBASE_LIBLIST=
5218SYBASE_DLLLIST=
5219SYBASE_LIBPATH=
5220
5221
5222## FreeTDS libraries
5223freetds=
5224if test "$with_ftds" != "no" ; then
5225   ftds_ver=100
5226   try_local=yes
5227   case "$with_ftds" in
5228      95 | 0.95 )
5229         ftds_ver=95
5230         ;;
5231      100 | 1.00 | yes | '' )
5232         ;;
5233      * )
5234         FTDS_PATH=$with_ftds
5235         try_local=no
5236         ;;
5237   esac
5238   : ${FTDS_CTLIBS:="-lct -ltds $NETWORK_LIBS"}
5239   NCBI_RPATHIFY(FTDS_CTLIBS,   $FTDS_PATH/lib,      [ ]$FTDS_CTLIBS)
5240   FTDS_INCLUDE="-I$FTDS_PATH/include"
5241   NCBI_LOCAL_FTDS(95)
5242   NCBI_LOCAL_FTDS(100)
5243   if test -n "$freetds" ; then
5244      FTDS_LIB="\$(FTDS${ftds_ver}_LIB)"
5245      FTDS_LIBS="\$(FTDS${ftds_ver}_LIBS)"
5246      FTDS_INCLUDE="\$(FTDS${ftds_ver}_INCLUDE)"
5247      if test "$with_ftds_renamed" != "no" ; then
5248          AC_DEFINE(NCBI_FTDS_RENAME_SYBDB, 1,
5249                    [Rename DBLIB symbols in FTDS to avoid name clash with Sybase DBLIB.])
5250      fi
5251      AC_MSG_NOTICE([Using bundled FreeTDS (version $ftds_ver) from $FTDS_PATH])
5252   else
5253      FTDS_LIBS="$FTDS_CTLIBS"
5254      AC_CACHE_CHECK([for FreeTDS${FTDS_PATH:+ in $FTDS_PATH}],
5255         ncbi_cv_lib_freetds,
5256         [CPPFLAGS="$FTDS_INCLUDE $orig_CPPFLAGS"
5257          LIBS="$FTDS_LIBS $NETWORK_LIBS $orig_LIBS"
5258          AC_LINK_IFELSE([AC_LANG_PROGRAM(
5259            [[
5260             @%:@include <sybdb.h>
5261             @%:@include <tds.h>
5262            ]],
5263            [[
5264             LOGINREC*  x_login     = 0;
5265             DBPROCESS* x_dbproc    = dbopen(x_login, (char*) "SRV_NAME");
5266             TDSLOGIN*  x_tds_login = 0;
5267             /* TDSSOCKET* x_sock      = tds_connect(x_tds_login); */
5268             tds_set_timeouts(x_tds_login, 0, 0, 0);
5269            ]])],
5270            [ncbi_cv_lib_freetds=yes], [ncbi_cv_lib_freetds=no])])
5271      if test "$ncbi_cv_lib_freetds" = "no"; then
5272         # Don't panic when using partial trees lacking dbapi/driver/ftdsN.
5273         NCBI_MISSING_PACKAGE(ftds)
5274      fi
5275   fi
5276fi
5277if test "$with_ftds" = "no" ; then
5278   FTDS_PATH=
5279   FTDS_INCLUDE=
5280   FTDS_LIBS=
5281   FTDS_LIB=
5282   FTDS95_INCLUDE=
5283   FTDS95_LIBS=
5284   FTDS95_LIB=
5285   FTDS95_CTLIB_INCLUDE=
5286   FTDS95_CTLIB_LIBS=
5287   FTDS95_CTLIB_LIB=
5288   FTDS100_INCLUDE=
5289   FTDS100_LIBS=
5290   FTDS100_LIB=
5291   FTDS100_CTLIB_INCLUDE=
5292   FTDS100_CTLIB_LIBS=
5293   FTDS100_CTLIB_LIB=
5294   freetds=
5295else
5296   AC_DEFINE(HAVE_LIBFTDS, 1,
5297             [Define to 1 if FreeTDS libraries are available.])
5298   NCBI_PACKAGE(FreeTDS)
5299fi
5300AC_SUBST(FTDS95_INCLUDE)
5301AC_SUBST(FTDS95_LIBS)
5302AC_SUBST(FTDS95_LIB)
5303AC_SUBST(FTDS95_CTLIB_INCLUDE)
5304AC_SUBST(FTDS95_CTLIB_LIBS)
5305AC_SUBST(FTDS95_CTLIB_LIB)
5306AC_SUBST(FTDS100_INCLUDE)
5307AC_SUBST(FTDS100_LIBS)
5308AC_SUBST(FTDS100_LIB)
5309AC_SUBST(FTDS100_CTLIB_INCLUDE)
5310AC_SUBST(FTDS100_CTLIB_LIBS)
5311AC_SUBST(FTDS100_CTLIB_LIB)
5312AC_SUBST(FTDS_INCLUDE)
5313AC_SUBST(FTDS_LIBS)
5314AC_SUBST(FTDS_LIB)
5315AC_SUBST(freetds)
5316
5317
5318## MySQL
5319if test "$with_mysql" != "no" ; then
5320   case "$with_mysql" in
5321      yes | "" ) ;;
5322      *        ) MYSQL_PATH=$with_mysql ;;
5323   esac
5324   : ${MYSQL_BINPATH=$MYSQL_PATH/bin}
5325   AC_PATH_PROG(mysql_config, mysql_config, [], [$MYSQL_BINPATH:$PATH])
5326   if test -n "$mysql_config" ; then
5327      : ${MYSQL_BINPATH=`dirname $mysql_config`}
5328      # Kill off single quotes, due to later requoting
5329      : ${MYSQL_INCLUDE=`$mysql_config --include | tr -d \'`}
5330      NCBI_RPATHIFY_OUTPUT_COND(MYSQL_LIBS, $mysql_config --libs${mt_sfx:+_r},
5331         [s/'//g; $no_usr_lib])
5332      AC_CACHE_CHECK([whether MySQL works], ncbi_cv_lib_mysql,
5333         [CPPFLAGS="$MYSQL_INCLUDE $orig_CPPFLAGS"
5334          LIBS="$MYSQL_LIBS $orig_LIBS"
5335          AC_LINK_IFELSE([AC_LANG_PROGRAM(
5336          [[@%:@include <mysql.h>]],
5337          [[MYSQL *p;  p = mysql_init(p);]])],
5338          [ncbi_cv_lib_mysql=yes], [ncbi_cv_lib_mysql=no])])
5339      if test "$ncbi_cv_lib_mysql" = no; then
5340         NCBI_MISSING_PACKAGE(mysql)
5341      fi
5342   else
5343      NCBI_MISSING_PACKAGE(mysql)
5344   fi
5345fi
5346if test "$with_mysql" = "no" ; then
5347   MYSQL_PATH="No_MYSQL"
5348   MYSQL_INCLUDE=
5349   MYSQL_LIBS=
5350else
5351   NCBI_PACKAGE(MySQL)
5352   AC_DEFINE(HAVE_MYSQL, 1, [Define to 1 if MySQL is available.])
5353fi
5354
5355
5356## Berkeley DB library
5357if test "$with_bdb" != "no" ; then
5358   case "$with_bdb" in
5359      yes | "" )
5360         ;;
5361      */*)
5362          BERKELEYDB_PATH=$with_bdb
5363          AS_UNSET(BERKELEYDB_INCLUDE)
5364          AS_UNSET(BERKELEYDB_LIBPATH)
5365          AS_UNSET(BERKELEYDB_LIBS)
5366          ;;
5367      *)
5368          BERKELEYDB_PATH=$NCBI/BerkeleyDB-${with_bdb}
5369          AS_UNSET(BERKELEYDB_INCLUDE)
5370          AS_UNSET(BERKELEYDB_LIBPATH)
5371          AS_UNSET(BERKELEYDB_LIBS)
5372          ;;
5373   esac
5374   if test -d "$BERKELEYDB_PATH"; then
5375      NCBI_FIX_DIR(BERKELEYDB_PATH)
5376      : ${BERKELEYDB_INCLUDE:="-I$BERKELEYDB_PATH/include"}
5377   fi
5378   if test -z "${BERKELEYDB_LIBPATH}"; then
5379      for d in "${compiler_vpfx}${DEBUG_SFX}" "${compiler_pfx}${DEBUG_SFX}" \
5380               "${DEBUG_SFX}" lib; do
5381         for sfx in "$mt_sfx$bit64_sfx" "$bit64_sfx$mt_sfx" "$bit64_sfx" \
5382                    "$mt_sfx" ""; do
5383            BERKELEYDB_LIBPATH=${BERKELEYDB_PATH}/$d$sfx
5384            test -d "${BERKELEYDB_LIBPATH}"  &&  break
5385         done
5386         test -d "${BERKELEYDB_LIBPATH}"  &&  break
5387      done
5388   fi
5389   if test -d "$BERKELEYDB_LIBPATH"; then
5390      NCBI_FIX_DIR(BERKELEYDB_LIBPATH)
5391      NCBI_RPATHIFY_COND(BERKELEYDB_LIBS:, ${BERKELEYDB_LIBPATH}, [ -ldb])
5392   else
5393      : ${BERKELEYDB_LIBS:="-ldb"}
5394   fi
5395   if test -f "${BERKELEYDB_LIBPATH}/libdb-static.a"; then
5396      BERKELEYDB_STATIC_LIBS="-L${BERKELEYDB_LIBPATH} -ldb-static"
5397      if test "x$with_bin_release" = "xyes"; then
5398         BERKELEYDB_LIBS=$BERKELEYDB_STATIC_LIBS
5399      fi
5400   else
5401      BERKELEYDB_STATIC_LIBS=${BERKELEYDB_LIBS}
5402   fi
5403   AC_CACHE_CHECK(
5404      [for Berkeley DB libraries${BERKELEYDB_PATH:+ in $BERKELEYDB_PATH}],
5405      ncbi_cv_lib_berkeley_db,
5406      [CPPFLAGS="$BERKELEYDB_INCLUDE $orig_CPPFLAGS"
5407       LIBS="$BERKELEYDB_LIBS $orig_LIBS"
5408       AC_LINK_IFELSE([AC_LANG_PROGRAM(
5409          [[@%:@include <db.h>
5410            @%:@include <stdlib.h>]],
5411          [[ DB* dbp;  db_create(&dbp, NULL, 0);  dbp->app_private = 0; ]])],
5412          [ncbi_cv_lib_berkeley_db=yes], [ncbi_cv_lib_berkeley_db=no])])
5413   if test "$ncbi_cv_lib_berkeley_db" = "no"; then
5414      NCBI_MISSING_PACKAGE(bdb)
5415   else
5416      AC_CACHE_CHECK([Berkeley DB version (4.3 or newer required)],
5417         ncbi_cv_lib_berkeley_db_version,
5418         [AC_LANG_CONFTEST([AC_LANG_SOURCE([[
5419cat >/dev/null <<_NCBI_EOF
5420@%:@include <db.h>
5421_NCBI_EOF
5422get_DB_VERSION() {
5423    grep '^[^#]' <<_NCBI_EOF
5424DB_VERSION_MAJOR.DB_VERSION_MINOR.DB_VERSION_PATCH
5425_NCBI_EOF
5426}
5427ncbi_cv_lib_berkeley_db_version=\`get_DB_VERSION | tr -cd 0123456789.\`
5428          ]])])
5429          eval "$ac_cpp $BERKELEYDB_INCLUDE conftest.$ac_ext" > conftest.sh \
5430             2>&AS_MESSAGE_LOG_FD
5431          . ./conftest.sh
5432          rm -f conftest*
5433         ])
5434      case "$ncbi_cv_lib_berkeley_db_version" in
5435         1.* | 2.* | 3.* | 4.[[0-2]].* )
5436            AC_MSG_WARN(
5437               [Your Berkeley DB version is too old to use.  (Needed >= 4.3.)])
5438            if test -n "$with_bdb"; then
5439               AC_MSG_ERROR([--with-bdb:  Berkeley DB library is too old])
5440            fi
5441            with_bdb=no
5442            ;;
5443         4.[[3-6]].* | [[5-9]].* | 1[[0-7]].* | 18.[[01]].* ) ;;
5444         * )
5445            AC_MSG_WARN(
5446               [Untested Berkeley DB version; may prove incompatible.])
5447            AC_MSG_WARN(
5448               [If so, please re-run this script with the flag --without-bdb.])
5449            ;;
5450      esac
5451   fi
5452fi
5453if test "$with_bdb" = "no" ; then
5454   BERKELEYDB_PATH="No_BerkeleyDB"
5455   BERKELEYDB_INCLUDE=
5456   BERKELEYDB_LIBS=
5457   BERKELEYDB_STATIC_LIBS=
5458   BERKELEYDB_CXX_LIBS=
5459   BERKELEYDB_CXX_STATIC_LIBS=
5460else
5461   NCBI_PACKAGE(BerkeleyDB)
5462   AC_DEFINE(HAVE_BERKELEY_DB, 1,
5463             [Define to 1 if Berkeley DB libraries are available.])
5464   if test -d "$BERKELEYDB_LIBPATH"; then
5465      NCBI_RPATHIFY_COND(BERKELEYDB_CXX_LIBS:, ${BERKELEYDB_LIBPATH},
5466          [ -ldb_cxx -ldb])
5467   else
5468      : ${BERKELEYDB_CXX_LIBS:="-ldb_cxx -ldb"}
5469   fi
5470   if test -f "${BERKELEYDB_LIBPATH}/libdb_cxx-static.a"; then
5471      BERKELEYDB_CXX_STATIC_LIBS="-L${BERKELEYDB_LIBPATH} -ldb_cxx-static -ldb-static"
5472   else
5473      BERKELEYDB_CXX_STATIC_LIBS=${BERKELEYDB_CXX_LIBS}
5474   fi
5475   AC_CACHE_CHECK([for native Berkeley DB C++ wrappers (optional)],
5476      ncbi_cv_lib_berkeley_db_cxx,
5477      [CPPFLAGS="$BERKELEYDB_INCLUDE $orig_CPPFLAGS"
5478       LIBS="$BERKELEYDB_CXX_LIBS $orig_LIBS"
5479       AC_LINK_IFELSE([AC_LANG_PROGRAM(
5480          [[@%:@include <db_cxx.h>]],
5481          [[DbEnv env(0);  Db db(&env, 0);  db.set_app_private(NULL);]])],
5482          [ncbi_cv_lib_berkeley_db_cxx=yes],
5483          [ncbi_cv_lib_berkeley_db_cxx=no])])
5484   if test "$ncbi_cv_lib_berkeley_db_cxx" = "yes"; then
5485      NCBI_PACKAGE(BerkeleyDB++)
5486      AC_DEFINE(HAVE_BERKELEY_DB_CXX, 1,
5487                [Define to 1 if the Berkeley `db_cxx' library is available.])
5488   else
5489      BERKELEYDB_CXX_LIBS=
5490      BERKELEYDB_CXX_STATIC_LIBS=
5491   fi
5492fi
5493
5494
5495## ODBC
5496case "$with_odbc" in
5497   yes | ""   ) : ${ODBC_PATH:=dbapi/driver/odbc/unix_odbc} ;;
5498   internal | no ) ODBC_PATH=dbapi/driver/odbc/unix_odbc       ;;
5499   *          ) ODBC_PATH=$with_odbc                        ;;
5500esac
5501
5502case "$ODBC_PATH" in
5503 dbapi/* ) ;;
5504 *)
5505   ODBC_INCLUDE="-I$ODBC_PATH/include"
5506   ODBC_LIBPATH="${ODBC_PATH}/lib"
5507   NCBI_RPATHIFY(ODBC_LIBS, ${ODBC_LIBPATH}, [ -lodbc -lodbcinst])
5508   CPPFLAGS="$ODBC_INCLUDE $orig_CPPFLAGS"
5509   LIBS="$ODBC_LIBS $orig_LIBS"
5510   AC_CACHE_CHECK([for ODBC libraries${ODBC_PATH:+ in $ODBC_PATH}],
5511      ncbi_cv_lib_odbc,
5512      [AC_LINK_IFELSE([AC_LANG_PROGRAM(
5513          [[@%:@include <sql.h>]],
5514          [[SQLHDBC hdbc;  SQLCHAR* cp = (SQLCHAR*) "x";
5515            SQLRETURN x = SQLConnect(hdbc, cp, 1, cp, 2, cp, 3);]])],
5516          [ncbi_cv_lib_odbc=yes], [ncbi_cv_lib_odbc=no])])
5517   if test "$ncbi_cv_lib_odbc" = "no"; then
5518      dnl ODBC_PATH=dbapi/driver/odbc/unix_odbc
5519      dnl AC_MSG_WARN([Falling back to internal FreeTDS-specific ODBC implementation.])
5520      NCBI_MISSING_PACKAGE(odbc)
5521   else
5522      # odbcss.h isn't self-contained :-/
5523      AC_CHECK_HEADERS(odbcss.h, [], [], [@%:@include <sql.h>])
5524
5525      AC_CHECK_FUNCS(SQLGetPrivateProfileString)
5526      AC_CHECK_TYPES([SQLLEN, SQLROWOFFSET, SQLROWSETSIZE, SQLSETPOSIROW],,,
5527         [@%:@include <sqltypes.h>])
5528      AC_CHECK_SIZEOF(SQLWCHAR, [], [@%:@include <sqltypes.h>])
5529
5530      AC_CACHE_CHECK([whether SQLColAttribute's last argument is an SQLLEN *],
5531         ncbi_cv_func_sqlcolattribute_sqllen,
5532         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
5533            [[@%:@include <sql.h>
5534              SQLRETURN SQL_API SQLColAttribute
5535                (SQLHSTMT sh, SQLUSMALLINT cn, SQLUSMALLINT fi, SQLPOINTER ca,
5536                 SQLSMALLINT bl, SQLSMALLINT *sl, SQLLEN *na);]],
5537            [[]])],
5538            ncbi_cv_func_sqlcolattribute_sqllen=yes,
5539            ncbi_cv_func_sqlcolattribute_sqllen=no)])
5540      if test $ncbi_cv_func_sqlcolattribute_sqllen = yes; then
5541         AC_DEFINE(NCBI_SQLCOLATTRIBUTE_SQLLEN, 1,
5542            [Define to 1 if SQLColAttribute's last argument is an SQLLEN *])
5543      fi
5544   fi
5545   ;;
5546esac
5547
5548case "$ODBC_PATH" in
5549 dbapi/*)
5550   # ODBC_PATH="No_ODBC"
5551   # Point to a local copy of unixODBC's headers, required by FreeTDS 0.64+.
5552   ODBC_INCLUDE="-I\$(includedir)/$ODBC_PATH -I\$(includedir0)/$ODBC_PATH"
5553   ODBC_LIBS=
5554   dnl AC_DEFINE(HAVE_SQLGETPRIVATEPROFILESTRING, 1)
5555   AC_DEFINE(HAVE_SQLLEN, 1)
5556   if test $NCBI_PLATFORM_BITS -eq 32; then
5557      AC_DEFINE(HAVE_SQLROWOFFSET, 1)
5558      AC_DEFINE(HAVE_SQLROWSETSIZE, 1)
5559   fi
5560   AC_DEFINE(HAVE_SQLSETPOSIROW, 1)
5561   AC_DEFINE(NCBI_SQLCOLATTRIBUTE_SQLLEN, 1)
5562   dnl AC_DEFINE(SIZEOF_SQLWCHAR, 2) # depends on SQL_WCHART_CONVERT
5563   ;;
5564 *)
5565   NCBI_PACKAGE(ODBC)
5566   AC_DEFINE(HAVE_ODBC, 1, [Define to 1 if ODBC libraries are available.])
5567   ;;
5568esac
5569
5570## Python
5571if test "$with_python" != "no" ; then
5572   case "$with_python" in
5573      yes | "" ) ;;
5574      */*      ) PYTHON_PATH=$with_python ;;
5575   esac
5576   NCBI_CHECK_PYTHON()
5577   NCBI_CHECK_PYTHON(2.5)
5578   NCBI_CHECK_PYTHON(2.6)
5579   NCBI_CHECK_PYTHON(2.7)
5580   NCBI_CHECK_PYTHON(3)
5581   if test "$ncbi_cv_lib_python" = "no"; then
5582      if test "$ncbi_cv_lib_python27" = "yes"; then
5583         PYTHON_INCLUDE=$PYTHON27_INCLUDE
5584         PYTHON_LIBS=$PYTHON27_LIBS
5585      elif test "$ncbi_cv_lib_python26" = "yes"; then
5586         PYTHON_INCLUDE=$PYTHON26_INCLUDE
5587         PYTHON_LIBS=$PYTHON26_LIBS
5588      elif test "$ncbi_cv_lib_python25" = "yes"; then
5589         PYTHON_INCLUDE=$PYTHON25_INCLUDE
5590         PYTHON_LIBS=$PYTHON25_LIBS
5591      fi
5592      if test -n "$PYTHON_LIBS"; then
5593         NCBI_PACKAGE(PYTHON)
5594         AC_DEFINE(HAVE_PYTHON, 1)
5595      else
5596         NCBI_MISSING_PACKAGE(python)
5597      fi
5598   fi
5599fi
5600
5601## Perl
5602if test "$with_perl" != "no" ; then
5603   case "$with_perl" in
5604      yes | "" ) ;;
5605      */*      ) PERL_PATH=$with_perl ;;
5606   esac
5607   AC_PATH_PROG(PERL, perl, [], [$PERL_PATH/bin:$PATH])
5608   if test -x "$PERL"; then
5609      PERL_ARCHLIB=`$PERL -MConfig -e 'print \$Config{archlibexp};'`
5610      PERL_FLAGS=`$PERL -MConfig -e 'print join " ", grep /^-[[DI]]/, split /\\s+/, \$Config{cppflags};'`
5611      PERL_INCLUDE="-I$PERL_ARCHLIB/CORE $PERL_FLAGS"
5612      PERL_DEPS=`$PERL -MConfig -e 'print \$Config{libs};'`
5613      NCBI_RPATHIFY(PERL_LIBS, $PERL_ARCHLIB/CORE, [ -lperl $PERL_DEPS])
5614      CPPFLAGS="$PERL_INCLUDE $orig_CPPFLAGS"
5615      LIBS="$PERL_LIBS $orig_LIBS"
5616      AC_CACHE_CHECK([for usable Perl libraries], [ncbi_cv_lib_perl],
5617         [AC_LINK_IFELSE([AC_LANG_PROGRAM(
5618                [[
5619@%:@include <EXTERN.h>
5620@%:@include <perl.h>]],
5621                [[PerlInterpreter* p = perl_alloc();]])],
5622             [ncbi_cv_lib_perl=yes], [ncbi_cv_lib_perl=no])])
5623   fi
5624   if test "$ncbi_cv_lib_perl" = yes; then
5625      NCBI_PACKAGE(PERL)
5626      dnl AC_DEFINE(HAVE_PERL, 1)
5627   else
5628      NCBI_MISSING_PACKAGE(perl)
5629      PERL_INCLUDE=
5630      PERL_LIBS=
5631   fi
5632fi
5633
5634## Java
5635if test "${with_jni-no}" != "no"; then
5636   case "$with_jni:${JAVAC+set}" in
5637      yes: | : )
5638         if test -d "$JAVA_HOME"; then
5639            JAVAC=$JAVA_HOME/bin/javac
5640         else
5641            JAVAC=javac
5642         fi
5643         ;;
5644      * )
5645         JAVAC=$with_jni/bin/javac
5646         ;;
5647   esac
5648   AX_JNI_INCLUDE_DIR
5649   JDK_INCLUDE=''
5650   sep=''
5651   for x in $JNI_INCLUDE_DIRS; do
5652      JDK_INCLUDE=$JDK_INCLUDE$sep-I$x
5653      sep=' '
5654   done
5655   AC_MSG_NOTICE([setting JDK_INCLUDE = $JDK_INCLUDE])
5656   CPPFLAGS="$JDK_INCLUDE $orig_CPPFLAGS"
5657   AC_CHECK_HEADER(jni.h,
5658      [AC_DEFINE(NCBI_JNI, 1,
5659          [Define to 1 if building Java Native Interface bindings.])
5660       NCBI_FEATURE([JDK])
5661       NCBI_FEATURE([Ncbi-JNI])
5662       JDK_PATH=$_JTOPDIR
5663       ncbi_java=ncbi_java],
5664      [JDK_INCLUDE=''
5665       JDK_PATH=''
5666       ncbi_java=''])
5667fi
5668
5669
5670## Boost
5671if test "$with_boost" != "no"; then
5672   if test "${with_boost-yes}" != yes; then
5673      BOOST_PATH=$with_boost
5674   fi
5675   if test -d "$BOOST_PATH"; then
5676      NCBI_FIX_DIR(BOOST_PATH)
5677      : ${BOOST_INCLUDE=-I$BOOST_PATH/include}
5678   fi
5679   BOOST_LIBPATH_=$BOOST_PATH/lib
5680   NCBI_RPATHIFY_COND(BOOST_LIBPATH, $BOOST_LIBPATH_)
5681   if test -d "$BOOST_PATH"; then
5682      boost_path_digits=`basename $BOOST_PATH | sed -e 's/-ncbi[[0-9]]*$//; s/.0$//' | tr -cd 0123456789`
5683   else
5684      boost_path_digits=
5685      BOOST_LIBPATH_=/usr/lib
5686   fi
5687   if test -n "$boost_path_digits"; then
5688      boost_version_digits=`echo $ncbi_cv_lib_boost_version | sed -e 's/.0$//' | tr -cd 0123456789`
5689      if test $boost_path_digits != "$boost_version_digits"; then
5690         # presumably stale, particularly if boost_version WASN'T cached;
5691         # uncache all relevant settings
5692         AS_UNSET(ncbi_cv_lib_boost_version)
5693         AS_UNSET(ncbi_cv_lib_boost_version_num)
5694         AS_UNSET(ncbi_cv_lib_boost_regex)
5695         AS_UNSET(ncbi_cv_lib_boost_spirit)
5696         AS_UNSET(ncbi_cv_lib_boost_system)
5697         AS_UNSET(ncbi_cv_lib_boost_filesystem)
5698         AS_UNSET(ncbi_cv_lib_boost_iostreams)
5699         AS_UNSET(ncbi_cv_lib_boost_program_options)
5700         AS_UNSET(ncbi_cv_lib_boost_serialization)
5701         AS_UNSET(ncbi_cv_lib_boost_test)
5702         AS_UNSET(ncbi_cv_lib_boost_thread)
5703      elif test -z "$ncbi_cv_lib_boost_version_num"; then
5704         AS_UNSET(ncbi_cv_lib_boost_version)
5705      fi
5706   fi
5707      CPPFLAGS=$orig_CPPFLAGS
5708      AC_CACHE_CHECK([Boost version],
5709         ncbi_cv_lib_boost_version,
5710         [AC_LANG_CONFTEST([AC_LANG_SOURCE([[
5711cat >/dev/null <<_NCBI_EOF
5712@%:@include <boost/version.hpp>
5713_NCBI_EOF
5714get_BOOST_VERSION() {
5715    grep '^[^#]' <<_NCBI_EOF
5716BOOST_VERSION
5717_NCBI_EOF
5718}
5719get_BOOST_LIB_VERSION() {
5720    grep '^[^#]' <<_NCBI_EOF
5721BOOST_LIB_VERSION
5722_NCBI_EOF
5723}
5724ncbi_cv_lib_boost_version_num=\`get_BOOST_VERSION\`
5725ncbi_cv_lib_boost_version=\`get_BOOST_LIB_VERSION | tr -d '"'\`
5726          ]])])
5727          _AC_DO([$ac_cpp $BOOST_INCLUDE conftest.$ac_ext]) > conftest.sh
5728          . ./conftest.sh 2>&AS_MESSAGE_LOG_FD
5729          rm -f conftest*
5730         ])
5731      AC_DEFINE_UNQUOTED(NCBI_EXPECTED_BOOST_VERSION,
5732         $ncbi_cv_lib_boost_version_num,
5733         [Define to the expected Boost version, to help catch skew.])
5734   if test -d `echo $BOOST_INCLUDE | sed -e 's/^-I//'`/boost-${ncbi_cv_lib_boost_version}/boost; then
5735      BOOST_INCLUDE=$BOOST_INCLUDE/boost-${ncbi_cv_lib_boost_version}
5736   fi
5737   case "$compiler:$ncbi_compiler_ver" in
5738      MIPSpro*)
5739         BOOST_INCLUDE="$BOOST_INCLUDE $BOOST_INCLUDE/boost/compatibility/cpp_c_headers"
5740         ;;
5741      WorkShop*)
5742         # Boost.Test's macros yield a *lot* of spurious "should not initialize
5743         # a non-const reference with a temporary" warnings, to the point of
5744         # overwhelming the compiler in some cases; turn them off altogether
5745         # when using Boost at all.
5746         BOOST_INCLUDE="$BOOST_INCLUDE -erroff=reftotemp"
5747         ;;
5748      GCC* | *Clang* )
5749         # Some portions of Boost also have a lot of "unused" typedefs
5750         # from concept checking.
5751         BOOST_INCLUDE="$BOOST_INCLUDE -Wno-unused-local-typedefs"
5752         ;;
5753   esac
5754   case "$ncbi_cv_lib_boost_version" in
5755      0_* | 1_[[0-9]] | 1_[[0-9]]_* | 1_[[0-2]][[0-9]] | 1_[[0-2]][[0-9]]_* ) ;;
5756      1_3[[0-4]] | 1_3[[0-4]]_* )
5757         AC_MSG_WARN(
5758            [Your Boost version is too old to use.  (Needed >= 1.35.)])
5759         if test -n "$with_boost"; then
5760            AC_MSG_ERROR([--with-boost:  Boost library is too old])
5761         fi
5762         with_boost=no
5763         ;;
5764      1_3[[5-9]] | 1_3[[5-9]]_* | 1_[[4-6]]* | 1_7[[0-6]] | 1_7[[0-6]]_* ) ;;
5765      '' ) with_boost=no ;;
5766      * )
5767         AC_MSG_WARN(
5768            [Untested Boost version; may prove incompatible.])
5769         AC_MSG_WARN(
5770            [If so, please re-run this script with the flag --without-boost.])
5771         ;;
5772   esac
5773   AC_MSG_CHECKING([for Boost library name tag])
5774   case "$with_boost_tag" in
5775      yes | "" )
5776         case "$host_os:$ncbi_compiler" in
5777            darwin*:GCC) BOOST_TAG="-xgcc" ;;
5778            *:GCC)       BOOST_TAG="-gcc" ;;
5779            *:KCC)       BOOST_TAG="-kcc" ;;
5780            linux*:ICC)  BOOST_TAG="-il"  ;;
5781            *:WORKSHOP)  BOOST_TAG="-sw"  ;;
5782            *:MIPSPRO)   BOOST_TAG="-mp"  ;;
5783            *:VISUALAGE) BOOST_TAG="-xlc" ;;
5784            *:COMPAQ)    BOOST_TAG="-tru" ;;
5785            *:MSVC)      BOOST_TAG="-vc"  ;;
5786            darwin*:*CLANG)
5787               if test "x$ac_cv_have_decl__LIBCPP_VERSION" = xyes; then
5788                  BOOST_TAG="-clang-darwin"
5789               else
5790                  BOOST_TAG="-xgcc"
5791                  boost_comp_vers=`echo $gccver | tr -d . | cut -c1-2`
5792               fi
5793               ;;
5794            *:*CLANG)
5795               if test "x$ac_cv_have_decl__LIBCPP_VERSION" = xyes; then
5796                  BOOST_TAG="-clang"
5797               else
5798                  BOOST_TAG="-gcc"
5799                  boost_comp_vers=`echo $gccver | tr -d . | cut -c1-2`
5800               fi
5801               ;;
5802         esac
5803         case "$BOOST_TAG:$compiler_version" in
5804            -*gcc:???|-il:???|-clang*:??? )
5805               : ${boost_comp_vers=`echo $compiler_version | cut -c1-2`}
5806               boost_comp_major=`echo $compiler_version | cut -c1`
5807               ;;
5808            -*gcc:????|-il:????|-clang*:???? )
5809               : ${boost_comp_vers=`echo $compiler_version | cut -c1-3`}
5810               boost_comp_major=`echo $compiler_version | cut -c1-2`
5811               ;;
5812            * )
5813               boost_comp_vers=''
5814               boost_comp_major=''
5815               ;;
5816         esac
5817         test "$with_mt"    = "yes"  &&  BOOST_MT=-mt
5818         if test "$with_max_debug" = yes; then
5819            BOOST_D="-gd -d"
5820         elif test "$with_debug" = no; then
5821            BOOST_D=
5822         else
5823            BOOST_D=-d
5824         fi
5825         test "$bit64_sfx"  = "64"   &&  BOOST_64=-64
5826         case "$host_cpu" in
5827            i?86 | x86_64 ) BOOST_ARCH=-x$NCBI_PLATFORM_BITS ;;
5828            arm*          ) BOOST_ARCH=-a$NCBI_PLATFORM_BITS ;;
5829            ia64          ) BOOST_ARCH=-i$NCBI_PLATFORM_BITS ;;
5830            sparc*        ) BOOST_ARCH=-s$NCBI_PLATFORM_BITS ;;
5831            mips*         ) BOOST_ARCH=-m$NCBI_PLATFORM_BITS ;;
5832            power* | ppc* ) BOOST_ARCH=-p$NCBI_PLATFORM_BITS ;;
5833            *             ) BOOST_ARCH= ;;
5834         esac
5835         found=no
5836         for base in "$BOOST_TAG$boost_comp_vers" \
5837             "$BOOST_TAG$boost_comp_major" "$BOOST_TAG" ''; do
5838           for bvers in "-$ncbi_cv_lib_boost_version" ''; do
5839             for bvers2 in "$BOOST_ARCH$bvers" "$bvers$BOOST_64" "$bvers"; do
5840               for bmt in "$BOOST_MT" '-mt' ''; do
5841                 for bd in $BOOST_D '' '-d'; do
5842                   bsfx=$bmt$bd$bvers2
5843                   if ls $BOOST_LIBPATH_/libboost*$base$bsfx.* >/dev/null 2>&1;
5844                   then
5845                     found=yes
5846                     break
5847                   else
5848                     for ext in .a .so; do
5849                       name=libboost_system$base$bsfx$ext
5850                       path=`$CXX -B$BOOST_LIBPATH_/ -print-file-name=$name \
5851                             2>/dev/null`
5852                       case "$path" in
5853                         $BOOST_PATH/*/$name ) found=yes; break ;;
5854                       esac
5855                     done
5856                   fi
5857                   test "$found" = yes  &&  break
5858                 done
5859                 test "$found" = yes  &&  break
5860               done
5861               test "$found" = yes  &&  break
5862             done
5863             test "$found" = yes  &&  break
5864           done
5865           test "$found" = yes  &&  break
5866         done
5867
5868         if test "$found" = no; then
5869            base=$BOOST_TAG
5870            cvers=$boost_comp_vers
5871            bvers=-$ncbi_cv_lib_boost_version
5872            bvers2=$BOOST_ARCH$bvers
5873            bmt=$BOOST_MT
5874            bd=${BOOST_D%% *}
5875            bsfx=$cvers$bmt$bd$bvers2
5876         fi
5877
5878         BOOST_TAG=$base$bsfx
5879         AC_MSG_RESULT([$BOOST_TAG (autodetected)])
5880         ;;
5881      no )
5882         BOOST_TAG=""
5883         AC_MSG_RESULT([none (by explicit request)])
5884         ;;
5885      *)
5886         BOOST_TAG=$with_boost_tag
5887         AC_MSG_RESULT([$BOOST_TAG (by explicit request)])
5888         ;;
5889   esac
5890   BOOST_STATIC_TAG=`echo "_$BOOST_TAG-s" \
5891     | sed -e 's/^_//; s/-\(g*d\)-s$/-s\1/; s/-\(g*d-.*\)-s$/-s\1/; s/\(-[[a-z][36][24]].*\)-s$/-s\1/; s/\(-[[1-9]].*\)-s$/-s\1/'`
5892
5893   test "$with_mt" = yes  || \
5894      BOOST_INCLUDE="$BOOST_INCLUDE -DBOOST_DISABLE_THREADS"
5895
5896   BOOST_REGEX_LIBS=-lboost_regex${BOOST_TAG}
5897   if test -f "$BOOST_LIBPATH_/libboost_regex$BOOST_STATIC_TAG.a"; then
5898       BOOST_REGEX_STATIC_LIBS=-lboost_regex$BOOST_STATIC_TAG
5899   else
5900       BOOST_REGEX_STATIC_LIBS=$BOOST_REGEX_LIBS
5901   fi
5902
5903   in_path=${BOOST_PATH:+ in $BOOST_PATH}
5904
5905   AC_CACHE_CHECK([for Boost.Regex$in_path], ncbi_cv_lib_boost_regex,
5906      CPPFLAGS="$BOOST_INCLUDE $orig_CPPFLAGS"
5907      LIBS="$BOOST_LIBPATH $BOOST_REGEX_LIBS $RT_LIBS $orig_LIBS"
5908      [AC_LINK_IFELSE(
5909          [AC_LANG_PROGRAM([[@%:@include <boost/regex.hpp>]],
5910              [[throw boost::regex_error(boost::regex_constants::error_stack);]])],
5911          [ncbi_cv_lib_boost_regex=yes], [ncbi_cv_lib_boost_regex=no])])
5912
5913   AC_CACHE_CHECK([for Boost.Spirit$in_path], ncbi_cv_lib_boost_spirit,
5914      CPPFLAGS="$BOOST_INCLUDE -DBOOST_ERROR_CODE_HEADER_ONLY $orig_CPPFLAGS"
5915      LIBS="$RT_LIBS $orig_LIBS"
5916      [AC_LINK_IFELSE(
5917          [AC_LANG_PROGRAM([[@%:@include <boost/spirit.hpp>
5918                             using namespace boost::spirit;
5919                             struct MyGrammar : public grammar<MyGrammar>
5920                             {
5921                                 template <typename TScanner>
5922                                 struct definition {
5923                                     definition(const MyGrammar&) { }
5924                                     typedef rule<TScanner, parser_context<>,
5925                                                  parser_tag<0> >
5926                                             TRule;
5927                                     TRule my_rule;
5928                                     TRule const & start() const
5929                                         { return my_rule; }
5930                                 };
5931                             };]],
5932              [[MyGrammar g;  parse("123", g);]])],
5933          [ncbi_cv_lib_boost_spirit=yes], [ncbi_cv_lib_boost_spirit=no])])
5934
5935   BOOST_SYSTEM_LIBS=-lboost_system${BOOST_TAG}
5936   if test -f "$BOOST_LIBPATH_/libboost_system$BOOST_STATIC_TAG.a"; then
5937       BOOST_SYSTEM_STATIC_LIBS=-lboost_system$BOOST_STATIC_TAG
5938   else
5939       BOOST_SYSTEM_STATIC_LIBS=$BOOST_SYSTEM_LIBS
5940   fi
5941
5942   AC_CACHE_CHECK([for Boost.System$in_path], ncbi_cv_lib_boost_system,
5943      CPPFLAGS="$BOOST_INCLUDE $orig_CPPFLAGS"
5944      LIBS="$BOOST_LIBPATH $BOOST_SYSTEM_LIBS $RT_LIBS $orig_LIBS"
5945      [AC_LINK_IFELSE(
5946          [AC_LANG_PROGRAM([[@%:@include <boost/system/error_code.hpp>]],
5947              [[const char * s = boost::system::system_category().name();]])],
5948          [ncbi_cv_lib_boost_system=yes],
5949          [ncbi_cv_lib_boost_system=no
5950           BOOST_SYSTEM_LIBS=
5951           BOOST_SYSTEM_STATIC_LIBS=])])
5952
5953   boost_chrono_lib=-lboost_chrono${BOOST_TAG}
5954   if test -f "$BOOST_LIBPATH_/libboost_chrono$BOOST_STATIC_TAG.a"; then
5955       boost_chrono_static_lib=-lboost_chrono$BOOST_STATIC_TAG
5956   else
5957       boost_chrono_static_lib=$boost_chrono_lib
5958   fi
5959   BOOST_CHRONO_LIBS="$boost_chrono_lib $BOOST_CHRONO_LIBS"
5960   BOOST_CHRONO_STATIC_LIBS="$boost_chrono_static_lib $BOOST_SYSTEM_STATIC_LIBS"
5961
5962   AC_CACHE_CHECK([for Boost.Chrono$in_path], ncbi_cv_lib_boost_chrono,
5963      CPPFLAGS="$BOOST_INCLUDE $orig_CPPFLAGS"
5964      LIBS="$BOOST_LIBPATH $BOOST_CHRONO_LIBS $BOOST_SYSTEM_LIBS $RT_LIBS $orig_LIBS"
5965      [AC_LINK_IFELSE(
5966          [AC_LANG_PROGRAM([[@%:@include <boost/chrono.hpp>]],
5967              [[boost::chrono::system_clock::now();]])],
5968          [ncbi_cv_lib_boost_chrono=yes],
5969          [ncbi_cv_lib_boost_chrono=no])])
5970
5971   boost_fs_lib=-lboost_filesystem${BOOST_TAG}
5972   if test -f "$BOOST_LIBPATH_/libboost_filesystem$BOOST_STATIC_TAG.a"; then
5973       boost_fs_static_lib=-lboost_filesystem$BOOST_STATIC_TAG
5974   else
5975       boost_fs_static_lib=$boost_fs_lib
5976   fi
5977   BOOST_FILESYSTEM_LIBS="$boost_fs_lib $BOOST_SYSTEM_LIBS"
5978   BOOST_FILESYSTEM_STATIC_LIBS="$boost_fs_static_lib $BOOST_SYSTEM_STATIC_LIBS"
5979
5980   AC_CACHE_CHECK([for Boost.Filesystem$in_path], ncbi_cv_lib_boost_filesystem,
5981      CPPFLAGS="$BOOST_INCLUDE $orig_CPPFLAGS"
5982      LIBS="$BOOST_LIBPATH $BOOST_FILESYSTEM_LIBS $RT_LIBS $orig_LIBS"
5983      [AC_LINK_IFELSE(
5984          [AC_LANG_PROGRAM([[@%:@include <boost/filesystem.hpp>]],
5985              [[return boost::filesystem::portable_name("foo");]])],
5986          [ncbi_cv_lib_boost_filesystem=yes],
5987          [ncbi_cv_lib_boost_filesystem=no])])
5988
5989   BOOST_IOSTREAMS_LIBS=-lboost_iostreams${BOOST_TAG}
5990   if test -f "$BOOST_LIBPATH_/libboost_iostreams$BOOST_STATIC_TAG.a"; then
5991       BOOST_IOSTREAMS_STATIC_LIBS=-lboost_iostreams$BOOST_STATIC_TAG
5992   else
5993       BOOST_IOSTREAMS_STATIC_LIBS=$BOOST_IOSTREAMS_LIBS
5994   fi
5995
5996   AC_CACHE_CHECK([for Boost.Iostreams$in_path], ncbi_cv_lib_boost_iostreams,
5997      CPPFLAGS="$BOOST_INCLUDE $orig_CPPFLAGS"
5998      LIBS="$BOOST_LIBPATH $BOOST_IOSTREAMS_LIBS $Z_LIBS $BZ2_LIBS $orig_LIBS"
5999      [AC_LINK_IFELSE(
6000          [AC_LANG_PROGRAM([[@%:@include <boost/iostreams/device/file_descriptor.hpp>]],
6001              [[boost::iostreams::file_descriptor fd;]])],
6002          [ncbi_cv_lib_boost_iostreams=yes],
6003          [ncbi_cv_lib_boost_iostreams=no])])
6004
6005   BOOST_PROGRAM_OPTIONS_LIBS=-lboost_program_options${BOOST_TAG}
6006   if test -f "$BOOST_LIBPATH_/libboost_program_options$BOOST_STATIC_TAG.a"; then
6007       BOOST_PROGRAM_OPTIONS_STATIC_LIBS=-lboost_program_options$BOOST_STATIC_TAG
6008   else
6009       BOOST_PROGRAM_OPTIONS_STATIC_LIBS=$BOOST_PROGRAM_OPTIONS_LIBS
6010   fi
6011
6012   AC_CACHE_CHECK([for Boost.Program-Options$in_path],
6013      ncbi_cv_lib_boost_program_options,
6014      CPPFLAGS="$BOOST_INCLUDE $orig_CPPFLAGS"
6015      LIBS="$BOOST_LIBPATH $BOOST_PROGRAM_OPTIONS_LIBS $orig_LIBS"
6016      [AC_LINK_IFELSE(
6017          [AC_LANG_PROGRAM([[@%:@include <boost/program_options.hpp>]],
6018              [[boost::program_options::option_description od;]])],
6019          [ncbi_cv_lib_boost_program_options=yes],
6020          [ncbi_cv_lib_boost_program_options=no])])
6021
6022   BOOST_SERIALIZATION_LIBS=-lboost_serialization${BOOST_TAG}
6023   if test -f "$BOOST_LIBPATH_/libboost_serialization$BOOST_STATIC_TAG.a"; then
6024       BOOST_SERIALIZATION_STATIC_LIBS=-lboost_serialization$BOOST_STATIC_TAG
6025   else
6026       BOOST_SERIALIZATION_STATIC_LIBS=$BOOST_SERIALIZATION_LIBS
6027   fi
6028
6029   AC_CACHE_CHECK([for Boost.Serialization$in_path],
6030      ncbi_cv_lib_boost_serialization,
6031      CPPFLAGS="$BOOST_INCLUDE $orig_CPPFLAGS"
6032      LIBS="$BOOST_LIBPATH $BOOST_SERIALIZATION_LIBS $orig_LIBS"
6033      [AC_LINK_IFELSE(
6034          [AC_LANG_PROGRAM([[@%:@include <boost/archive/text_oarchive.hpp>
6035                             @%:@include <iostream>]],
6036              [[boost::archive::text_oarchive oa(std::cout);]])],
6037          [ncbi_cv_lib_boost_serialization=yes],
6038          [ncbi_cv_lib_boost_serialization=no])])
6039
6040   BOOST_TEST_PEM_LIBS=-lboost_prg_exec_monitor${BOOST_TAG}
6041   if test -f "$BOOST_LIBPATH_/libboost_prg_exec_monitor$BOOST_STATIC_TAG.a"; then
6042       BOOST_TEST_PEM_STATIC_LIBS=-lboost_prg_exec_monitor$BOOST_STATIC_TAG
6043   else
6044       BOOST_TEST_PEM_STATIC_LIBS=$BOOST_TEST_PEM_LIBS
6045   fi
6046
6047   BOOST_TEST_TEM_LIBS=-lboost_test_exec_monitor${BOOST_TAG}
6048   if test -f "$BOOST_LIBPATH_/libboost_test_exec_monitor$BOOST_STATIC_TAG.a"; then
6049       BOOST_TEST_TEM_STATIC_LIBS=-lboost_test_exec_monitor$BOOST_STATIC_TAG
6050   else
6051       BOOST_TEST_TEM_STATIC_LIBS=$BOOST_TEST_TEM_LIBS
6052   fi
6053
6054   BOOST_TEST_UTF_LIBS=-lboost_unit_test_framework${BOOST_TAG}
6055   if test -f "$BOOST_LIBPATH_/libboost_unit_test_framework$BOOST_STATIC_TAG.a"; then
6056       BOOST_TEST_UTF_STATIC_LIBS=-lboost_unit_test_framework$BOOST_STATIC_TAG
6057   else
6058       BOOST_TEST_UTF_STATIC_LIBS=$BOOST_TEST_UTF_LIBS
6059   dnl AC_DEFINE([NCBI_BOOST_TEST_DLL], 1,
6060   dnl   [Define to 1 if unable to locate an appropriate
6061   dnl    libboost_unit_test_framework$BOOST_STATIC_TAG.a.])
6062   fi
6063
6064   BOOST_TEST_PEM_LIBS=$BOOST_TEST_PEM_STATIC_LIBS
6065   BOOST_TEST_TEM_LIBS=$BOOST_TEST_TEM_STATIC_LIBS
6066   BOOST_TEST_UTF_LIBS=$BOOST_TEST_UTF_STATIC_LIBS
6067
6068   AC_CACHE_CHECK([for Boost.Test$in_path], ncbi_cv_lib_boost_test,
6069      CPPFLAGS="$BOOST_INCLUDE $orig_CPPFLAGS"
6070      LIBS="$RT_LIBS $orig_LIBS"
6071      found=
6072      for mode in included external; do
6073        if test "$mode" = external; then
6074          CPPFLAGS="-DNCBI_BOOST_NOT_INCLUDED $CPPFLAGS"
6075          LIBS="$BOOST_LIBPATH $BOOST_TEST_UTF_LIBS $LIBS"
6076        fi
6077        [AC_LINK_IFELSE(
6078           [AC_LANG_SOURCE(
6079              [[@%:@ifdef NCBI_BOOST_NOT_INCLUDED
6080                @%:@  include <boost/test/unit_test.hpp>
6081                @%:@else
6082                @%:@  include <boost/test/included/unit_test.hpp>
6083                @%:@endif
6084                using boost::unit_test::test_suite;
6085                static void s_Test1(void) { BOOST_CHECK(1 == 1); }
6086                test_suite* init_unit_test_suite(int, char*[])
6087                {
6088                    test_suite* test = BOOST_TEST_SUITE("foo");
6089                    test->add(BOOST_TEST_CASE(&s_Test1), 0);
6090                    return test;
6091                }]])],
6092           [found="$found:$mode"])]
6093      done
6094      [case "$found" in
6095        :included:external ) ncbi_cv_lib_boost_test=yes           ;;
6096        :included          ) ncbi_cv_lib_boost_test=included-only ;;
6097        :external          ) ncbi_cv_lib_boost_test=external-only ;;
6098        ''                 ) ncbi_cv_lib_boost_test=no            ;;
6099      esac])
6100
6101   BOOST_THREAD_LIBS="-lboost_thread${BOOST_TAG} $BOOST_SYSTEM_LIBS"
6102   if test -f "$BOOST_LIBPATH_/libboost_thread$BOOST_STATIC_TAG.a"; then
6103       BOOST_THREAD_STATIC_LIBS="-lboost_thread$BOOST_STATIC_TAG $BOOST_SYSTEM_STATIC_LIBS"
6104   else
6105       BOOST_THREAD_STATIC_LIBS=$BOOST_THREAD_LIBS
6106   fi
6107
6108   AC_CACHE_CHECK([for Boost.Thread$in_path], ncbi_cv_lib_boost_thread,
6109      CPPFLAGS="$BOOST_INCLUDE $orig_CPPFLAGS"
6110      LIBS="$BOOST_LIBPATH $BOOST_THREAD_LIBS $RT_LIBS $orig_LIBS"
6111      [AC_LINK_IFELSE(
6112          [AC_LANG_PROGRAM([[@%:@include <boost/thread.hpp>]],
6113              [[boost::mutex m; boost::mutex::scoped_lock l(m);]])],
6114          [ncbi_cv_lib_boost_thread=yes], [ncbi_cv_lib_boost_thread=no])])
6115else
6116   BOOST_INCLUDE=
6117   BOOST_LIBPATH=
6118   BOOST_TAG=
6119   ncbi_cv_lib_boost_chrono=no
6120   ncbi_cv_lib_boost_filesystem=no
6121   ncbi_cv_lib_boost_iostreams=no
6122   ncbi_cv_lib_boost_program_options=no
6123   ncbi_cv_lib_boost_regex=no
6124   ncbi_cv_lib_boost_serialization=no
6125   ncbi_cv_lib_boost_spirit=no
6126   ncbi_cv_lib_boost_system=no
6127   ncbi_cv_lib_boost_test=no
6128   ncbi_cv_lib_boost_thread=no
6129fi
6130
6131if test "$ncbi_cv_lib_boost_chrono" != "no"; then
6132   AC_DEFINE(HAVE_BOOST_CHRONO, 1,
6133             [Define to 1 if the `Boost.Chrono' library is available.])
6134   NCBI_PACKAGE(Boost.Chrono)
6135else
6136   boost_chrono_lib=
6137   boost_chrono_static_lib=
6138   BOOST_CHRONO_LIBS=
6139   BOOST_CHRONO_STATIC_LIBS=
6140fi
6141
6142if test "$ncbi_cv_lib_boost_filesystem" != "no"; then
6143   AC_DEFINE(HAVE_BOOST_FILESYSTEM, 1,
6144             [Define to 1 if the `Boost.Filesystem' library is available.])
6145   NCBI_PACKAGE(Boost.Filesystem)
6146else
6147   boost_fs_lib=
6148   boost_fs_static_lib=
6149   BOOST_FILESYSTEM_LIBS=
6150   BOOST_FILESYSTEM_STATIC_LIBS=
6151fi
6152
6153if test "$ncbi_cv_lib_boost_iostreams" != "no"; then
6154   AC_DEFINE(HAVE_BOOST_IOSTREAMS, 1,
6155             [Define to 1 if the `Boost.Iostreams' library is available.])
6156   NCBI_PACKAGE(Boost.Iostreams)
6157else
6158   BOOST_IOSTREAMS_LIBS=
6159   BOOST_IOSTREAMS_STATIC_LIBS=
6160fi
6161
6162if test "$ncbi_cv_lib_boost_program_options" != "no"; then
6163   AC_DEFINE(HAVE_BOOST_PROGRAM_OPTIONS, 1,
6164             [Define to 1 if the `Boost.Program-Options' library is available.])
6165   NCBI_PACKAGE(Boost.Program-Options)
6166else
6167   BOOST_PROGRAM_OPTIONS_LIBS=
6168   BOOST_PROGRAM_OPTIONS_STATIC_LIBS=
6169fi
6170
6171if test "$ncbi_cv_lib_boost_regex" != "no"; then
6172   AC_DEFINE(HAVE_BOOST_REGEX, 1,
6173             [Define to 1 if the `Boost.Regex' library is available.])
6174   NCBI_PACKAGE(Boost.Regex)
6175else
6176   BOOST_REGEX_LIBS=
6177   BOOST_REGEX_STATIC_LIBS=
6178fi
6179
6180if test "$ncbi_cv_lib_boost_serialization" != "no"; then
6181   AC_DEFINE(HAVE_BOOST_SERIALIZATION, 1,
6182             [Define to 1 if the `Boost.Serialization' library is available.])
6183   NCBI_PACKAGE(Boost.Serialization)
6184else
6185   BOOST_SERIALIZATION_LIBS=
6186   BOOST_SERIALIZATION_STATIC_LIBS=
6187fi
6188
6189if test "$ncbi_cv_lib_boost_spirit" != "no"; then
6190   AC_DEFINE(HAVE_BOOST_SPIRIT, 1,
6191             [Define to 1 if the `Boost.Spirit' headers are available.])
6192   NCBI_PACKAGE(Boost.Spirit)
6193fi
6194
6195if test "$ncbi_cv_lib_boost_system" != "no"; then
6196   AC_DEFINE(HAVE_BOOST_SYSTEM, 1,
6197             [Define to 1 if the `Boost.System' library is available.])
6198   NCBI_PACKAGE(Boost.System)
6199# BOOST_SYSTEM(_STATIC)_LIBS already conditionally cleared above
6200fi
6201
6202if test "$ncbi_cv_lib_boost_test" != "no"; then
6203   AC_DEFINE(HAVE_BOOST_TEST, 1,
6204             [Define to 1 if the `Boost.Test' libraries are available.])
6205   if test "$ncbi_cv_lib_boost_test" != "included-only"; then
6206      NCBI_PACKAGE(Boost.Test)
6207   fi
6208   if test "$ncbi_cv_lib_boost_test" != "external-only"; then
6209      NCBI_PACKAGE(Boost.Test.Included)
6210   fi
6211else
6212   BOOST_TEST_PEM_LIBS=
6213   BOOST_TEST_PEM_STATIC_LIBS=
6214   BOOST_TEST_TEM_LIBS=
6215   BOOST_TEST_TEM_STATIC_LIBS=
6216   BOOST_TEST_UTF_LIBS=
6217   BOOST_TEST_UTF_STATIC_LIBS=
6218fi
6219
6220if test "$ncbi_cv_lib_boost_thread" != "no"; then
6221   AC_DEFINE(HAVE_BOOST_THREAD, 1,
6222             [Define to 1 if the `Boost.Thread' library is available.])
6223   NCBI_PACKAGE(Boost.Thread)
6224else
6225   BOOST_THREAD_LIBS=
6226   BOOST_THREAD_STATIC_LIBS=
6227fi
6228
6229case "$with_boost:$ncbi_cv_lib_boost_test" in
6230   :* | no:* | *:yes | *:included-only ) ;; # no problem
6231   * ) AC_MSG_ERROR([Boost explicitly requested, but Boost.Test.Included unavailable.]) ;;
6232esac
6233
6234
6235## NCBI C Toolkit
6236if test "$with_ncbi_c" != "no" ; then
6237   if test "${with_ncbi_c-yes}" != yes; then
6238      NCBI_C_PATH=$with_ncbi_c
6239   fi
6240   : ${NCBI_C_PATH="$NCBI"}
6241   if test "$ncbi_compiler" = ICC -a -d "$NCBI_C_PATH/ncbi_icc"; then
6242      NCBI_C_PATH=$NCBI_C_PATH/ncbi_icc
6243   fi
6244   if test -n "$NCBI_C_PATH_TAGS"; then
6245      for x in $NCBI_C_PATH_TAGS; do
6246         if test -d "$NCBI_C_PATH$x"; then
6247            NCBI_C_PATH=$NCBI_C_PATH$x
6248            break
6249         fi
6250      done
6251   fi
6252
6253   NCBI_C_INCLUDE="-I$NCBI_C_PATH/include${bit64_sfx}"
6254   if test "$with_debug" = "no" ; then
6255     NCBI_C_LIBPATH="$NCBI_C_PATH/lib${bit64_sfx}"
6256   else
6257     NCBI_C_LIBPATH="$NCBI_C_PATH/altlib${bit64_sfx}"
6258   fi
6259   if test "$with_mt" = "yes" ; then
6260     NCBI_C_LIBPATH="$NCBI_C_LIBPATH $NCBI_C_LIBPATH/ncbithr.o"
6261   fi
6262   if test -n "$NCBI_C_ncbi" ; then
6263     :
6264   elif test "$OSTYPE" = "darwin" ; then
6265     NCBI_C_ncbi="-lncbi -Wl,-framework,AppKit"
6266   else
6267     NCBI_C_ncbi="-lncbi"
6268   fi
6269   NCBI_C_LIBPATH="-L$NCBI_C_LIBPATH"
6270   AC_CACHE_CHECK([for the NCBI C toolkit${NCBI_C_PATH:+ in $NCBI_C_PATH}],
6271      ncbi_cv_lib_ctools,
6272      [CPPFLAGS="$NCBI_C_INCLUDE $orig_CPPFLAGS"
6273       LIBS="$NCBI_C_LIBPATH $NCBI_C_ncbi $NETWORK_LIBS $orig_LIBS"
6274       AC_LINK_IFELSE([AC_LANG_PROGRAM(
6275          [[@%:@include <ncbi.h>]],
6276          [[ Nlm_Boolean b = Nlm_GetArgs("fake", -1, 0); ]])],
6277          [ncbi_cv_lib_ctools=yes], [ncbi_cv_lib_ctools=no])])
6278   if test "$ncbi_cv_lib_ctools" = no; then
6279      NCBI_MISSING_PACKAGE(ncbi-c)
6280   fi
6281fi
6282if test "$with_ncbi_c" = "no" ; then
6283   if test "$with_ctools" = "yes"; then
6284      AC_MSG_ERROR([--with-ctools:  NCBI C Toolkit is missing])
6285   fi
6286   NCBI_C_PATH="No_NCBI_CToolkit"
6287   NCBI_C_INCLUDE=
6288   NCBI_C_LIBPATH=
6289   NCBI_C_ncbi=
6290else
6291   NCBI_PACKAGE(C-Toolkit)
6292   AC_DEFINE(HAVE_NCBI_C, 1, [Define to 1 if the NCBI C toolkit is available.])
6293fi
6294
6295# X11
6296LIBS="$orig_LIBS"
6297CPPFLAGS="$orig_CPPFLAGS"
6298# Look in /usr/X11R6/lib64 if necessary
6299xlib=`ls -d /usr/X11R6/lib$bit64_sfx/libX11.* 2>/dev/null | sed -ne 1p`
6300if test -f "$xlib" -a "${x_libraries-NONE}" = NONE \
6301  -a "${x_includes-NONE}" = NONE; then
6302   base=`basename $xlib`
6303   cmp -s /usr/X11R6/lib/$base $xlib  || \
6304      cmp -s /usr/lib/$base $xlib  || \
6305      cmp -s /usr/lib$bit64_sfx/$base $xlib  || \
6306      x_libraries=/usr/X11R6/lib$bit64_sfx x_includes=/usr/X11R6/include
6307fi
6308AC_PATH_XTRA
6309x_libraries=`echo "$x_libraries" | sed -e "s,^$usr_lib\$,,"`
6310X_LIBS=`echo "$X_LIBS " | sed -e "$no_usr_lib"`
6311AC_CHECK_LIB(Xext, XextCreateExtension, Xext="-lXext", Xext=,
6312   [$X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
6313AC_CHECK_LIB(Xt, XtMainLoop, Xt="-lXt", Xt=,
6314   [$Xext $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
6315AC_CHECK_LIB(Xmu, XmuMakeAtom, Xmu="-lXmu", Xmu=,
6316   [$Xt $Xext $X_PRE_LIBS -lX11 $X_EXTRA_LIBS])
6317LDFLAGS=$orig_LDFLAGS
6318X_ALL_LIBS="$Xmu $Xt $Xext $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
6319
6320## OpenGL
6321if test "$with_opengl" != "no"; then
6322   if test "${with_opengl-yes}" != yes; then
6323      OPENGL_PATH=$with_opengl
6324   fi
6325   if test -d "$OPENGL_PATH"; then
6326      NCBI_FIX_DIR(OPENGL_PATH)
6327   fi
6328   case "$OSTYPE" in
6329      darwin) # Use native interface
6330         OPENGL_LIBS="-framework AGL -framework OpenGL"
6331         # ... and its proprietary successor
6332         OPENGL_LIBS="$OPENGL_LIBS -framework Metal -framework MetalKit"
6333         OPENGL_LIBS="$OPENGL_LIBS -framework QuartzCore"
6334         ;;
6335      # cygwin) ... ;;
6336      *) # Default -- assume X-based
6337         LIBS="$orig_LIBS"
6338         CPPFLAGS="$orig_CPPFLAGS"
6339         LDFLAGS="$orig_LDFLAGS $X_LIBS"
6340         if test -d "$OPENGL_PATH/include/GL"; then
6341            OPENGL_INCLUDE="-I$OPENGL_PATH/include $X_CFLAGS"
6342         else
6343            OPENGL_INCLUDE=$X_CFLAGS
6344         fi
6345         if test -n "$OPENGL_PATH" -a -d "$OPENGL_PATH/lib${bit64_sfx}"; then
6346            NCBI_RPATHIFY(OPENGL_LIBPATH, $OPENGL_PATH/lib${bit64_sfx},
6347                          [ ]$X_LIBS)
6348         elif test -f /usr/lib/mesa/libGL.so; then
6349            NCBI_RPATHIFY(OPENGL_LIBPATH, /usr/lib/mesa, [ ]$X_LIBS)
6350         else
6351            OPENGL_LIBPATH=$X_LIBS
6352         fi
6353         OPENGL_LIBS="$OPENGL_LIBPATH -lGLU -lGL $X_ALL_LIBS"
6354         ;;
6355   esac
6356   case "${OPENGL_PATH}" in
6357      */*) where=" in $OPENGL_PATH" ;;
6358      *  ) where= ;;
6359   esac
6360   AC_CACHE_CHECK([for OpenGL$where], ncbi_cv_lib_opengl,
6361      [CPPFLAGS="$orig_CPPFLAGS $OPENGL_INCLUDE"
6362       LIBS="$OPENGL_LIBS $orig_LIBS"
6363       AC_LINK_IFELSE([AC_LANG_PROGRAM(
6364          [[
6365           @%:@ifdef NCBI_OS_DARWIN
6366           @%:@  include <OpenGL/gl.h>
6367           @%:@else
6368           @%:@  include <GL/gl.h>
6369           @%:@endif
6370          ]],
6371          [[glBegin(0);]])],
6372          [ncbi_cv_lib_opengl=yes], [ncbi_cv_lib_opengl=no])])
6373fi
6374
6375if test "$with_opengl" = "no" -o "$ncbi_cv_lib_opengl" = "no"; then
6376   OPENGL_INCLUDE=
6377   OPENGL_LIBS=
6378   OPENGL_STATIC_LIBS=
6379   OSMESA_INCLUDE=
6380   OSMESA_LIBS=
6381   OSMESA_STATIC_LIBS=
6382   GLUT_INCLUDE=
6383   GLUT_LIBS=
6384   GLEW_INCLUDE=
6385   GLEW_LIBS=
6386   GLEW_STATIC_LIBS=
6387   NCBI_MISSING_PACKAGE(opengl)
6388   NCBI_MISSING_PACKAGE(gl2ps)
6389else
6390   NCBI_PACKAGE(OpenGL)
6391   AC_DEFINE(HAVE_OPENGL, 1, [Define to 1 if you have OpenGL (-lGL).])
6392   if test -f "$OPENGL_PATH/lib${bit64_sfx}/libGLU-static.a"; then
6393      OPENGL_STATIC_LIBS="$OPENGL_LIBPATH -lGLU-static -lGL-static $X_ALL_LIBS"
6394   else
6395      OPENGL_STATIC_LIBS=$OPENGL_LIBS
6396   fi
6397   : ${OSMESA_PATH=$OPENGL_PATH}
6398   if test "$with_mesa" != "no"; then
6399      if test "${with_mesa-yes}" != "yes"; then
6400         OSMESA_PATH=$with_mesa
6401      fi
6402      if test -d "$OSMESA_PATH"; then
6403         OSMESA_INCLUDE=-I$OSMESA_PATH/include
6404         if test "$OSMESA_PATH" != "$OPENGL_PATH"; then
6405            NCBI_RPATHIFY(OSMESA_LDFLAGS, $OSMESA_PATH/lib${bit64_sfx})
6406         fi
6407      fi
6408      LDFLAGS="$orig_LDFLAGS $OSMESA_LDFLAGS $OPENGL_LIBPATH"
6409      AC_CHECK_LIB(OSMesa, OSMesaCreateContext,
6410         [NCBI_PACKAGE(MESA);
6411          OSMESA_LIBS="$OSMESA_LDFLAGS $OPENGL_LIBPATH -lOSMesa -lGLU -lGL $X_ALL_LIBS"
6412          AC_DEFINE(HAVE_LIBOSMESA, 1, [Define to 1 if you have libOSMesa.])],
6413         [OSMESA_LIBS=],
6414         $OPENGL_LIBS)
6415   fi
6416   if test -z "$OSMESA_LIBS"; then
6417      NCBI_MISSING_PACKAGE(mesa)
6418   elif test -f "$OSMESA_PATH/lib${bit64_sfx}/libOSMesa-static.a"; then
6419      OSMESA_STATIC_LIBS="$OSMESA_LDFLAGS $OPENGL_LIBPATH -lOSMesa-static -lGLU-static -lGL-static $X_ALL_LIBS"
6420   else
6421      OSMESA_STATIC_LIBS=$OSMESA_LIBS
6422   fi
6423   if test "$with_glut" != "no"; then
6424      if test "${with_glut-yes}" != "yes"; then
6425         GLUT_PATH=$with_glut
6426      fi
6427      if test -d "GLUT_PATH"; then
6428         GLUT_INCLUDE=-I$GLUT_PATH/include
6429         NCBI_RPATHIFY(GLUT_LDFLAGS, $GLUT_PATH/lib${bit64_sfx})
6430      fi
6431      LDFLAGS="$orig_LDFLAGS $GLUT_LDFLAGS $OPENGL_LIBPATH"
6432      AC_CHECK_LIB(glut, glutInit,
6433         [NCBI_PACKAGE(GLUT);
6434          GLUT_LIBS="$GLUT_LDFLAGS $OPENGL_LIBPATH -lglut -lGLU -lGL $X_ALL_LIBS"
6435          AC_DEFINE(HAVE_LIBGLUT, 1, [Define to 1 if you have libglut.])],
6436         [GLUT_LIBS=],
6437         $OPENGL_LIBS)
6438      if test -z "$GLUT_LIBS"; then
6439         NCBI_MISSING_PACKAGE(glut)
6440      fi
6441   fi
6442   if test "$with_glew" != "no"; then
6443      if test "${with_glew-yes}" != "yes"; then
6444         GLEW_PATH=$with_glew
6445      fi
6446      if test -d "$GLEW_PATH"; then
6447         if test -d "$GLEW_PATH/$compiler_vpfx$DEBUG_SFX$bit64_sfx"; then
6448            GLEW_PATH=$GLEW_PATH/$compiler_vpfx$DEBUG_SFX$bit64_sfx
6449         elif test -d "$GLEW_PATH/$compiler_pfx$DEBUG_SFX$bit64_sfx"; then
6450            GLEW_PATH=$GLEW_PATH/$compiler_pfx$DEBUG_SFX$bit64_sfx
6451         elif test -d "$GLEW_PATH/$DEBUG_SFX$bit64_sfx"; then
6452            GLEW_PATH=$GLEW_PATH/$DEBUG_SFX$bit64_sfx
6453         fi
6454         NCBI_FIX_DIR(GLEW_PATH)
6455         GLEW_LIBDIR=$GLEW_PATH/lib
6456         if test -n "$bit64_sfx" -a -d $GLEW_LIBDIR$bit64_sfx; then
6457            if test -d $GLEW_LIBDIR; then
6458               for x in $GLEW_LIBDIR/libGLEW*; do
6459                  if cmp -s "$x" "$GLEW_LIBDIR$bit64_sfx/`basename \"$x\"`"; then
6460                     :
6461                  else
6462                     GLEW_LIBDIR=$GLEW_LIBDIR$bit64_sfx
6463                     break
6464                  fi
6465               done
6466            else
6467               GLEW_LIBDIR=$GLEW_LIBDIR$bit64_sfx
6468            fi
6469         fi
6470      fi
6471      glew_config="eval PKG_CONFIG_PATH=\"$GLEW_LIBDIR/pkgconfig\" pkg-config"
6472      if pkg-config --version >/dev/null 2>&1; then
6473         if test "$with_glew_mx" != no \
6474           && $glew_config glewmx --exists >/dev/null 2>&1 \
6475           && test -n "`$glew_config glewmx --libs 2>/dev/null`"; then
6476            glew_config="$glew_config glewmx"
6477         elif $glew_config glew --exists >/dev/null 2>&1 \
6478           && test -n "`$glew_config glew --libs 2>/dev/null`"; then
6479            glew_config="$glew_config glew"
6480         else
6481            glew_config=
6482         fi
6483         if test -n "$glew_config"; then
6484            GLEW_INCLUDE=`$glew_config --cflags | sed 's:/GL *$::'`
6485            GLEW_LDFLAGS=`$glew_config --libs-only-L`
6486            glew_libname=`$glew_config --libs-only-l | sed -e 's/-l//'`
6487         fi
6488      fi
6489      if test -z "$glew_libname" -a -d "$GLEW_PATH"; then
6490         GLEW_INCLUDE=-I$GLEW_PATH/include
6491         GLEW_LDFLAGS=-L$GLEW_LIBDIR
6492      fi
6493      LDFLAGS="$orig_LDFLAGS $GLEW_LDFLAGS"
6494      LIBS="$OPENGL_LIBS $orig_LIBS"
6495      NCBI_CHECK_LIBS(GLEW, [$glew_libname GLEWmx GLEW], glewGetExtension)
6496      if test "$ac_cv_search_glewGetExtension" = no; then
6497         GLEW_INCLUDE=
6498         GLEW_LIBS=
6499         NCBI_MISSING_PACKAGE(glew)
6500         NCBI_MISSING_PACKAGE(glew-mx)
6501      else
6502         NCBI_RPATHIFY_OUTPUT_COND(tmp_LIBS, [echo $GLEW_LDFLAGS $GLEW_LIBS])
6503         GLEW_LIBS=$tmp_LIBS
6504         NCBI_PACKAGE(GLEW)
6505         CPPFLAGS="$orig_CPPFLAGS $GLEW_INCLUDE $OPENGL_INCLUDE"
6506         LIBS="$GLEW_LIBS $OPENGL_LIBS $orig_LIBS"
6507         AC_CACHE_CHECK([for GLEW multi-context (MX) support],
6508            ncbi_cv_lib_glew_mx,
6509            [AC_LINK_IFELSE([AC_LANG_PROGRAM(
6510               [[@%:@define GLEW_MX 1
6511                 @%:@include <GL/glew.h>]],
6512               [[glewContextInit(NULL);]])],
6513             [ncbi_cv_lib_glew_mx=yes], [ncbi_cv_lib_glew_mx=no])])
6514          if test $ncbi_cv_lib_glew_mx = yes; then
6515             if test "$with_glew_mx" = no; then
6516                GLEW_INCLUDE=
6517                GLEW_LIBS=
6518                NCBI_MISSING_PACKAGE(glew)
6519             else
6520                GLEW_INCLUDE="$GLEW_INCLUDE -DGLEW_MX"
6521             fi
6522          else
6523             NCBI_MISSING_PACKAGE(glew-mx)
6524          fi
6525          : ${GLEW_STATIC_LIBS=$GLEW_LIBDIR/libGLEW-static.a}
6526          test -f "$GLEW_STATIC_LIBS"  ||  GLEW_STATIC_LIBS=$GLEW_LIBS
6527      fi
6528   fi
6529fi
6530
6531LDFLAGS=$orig_LDFLAGS
6532
6533
6534## wxWidgets
6535# : ${with_wxwidgets_ucs=no}
6536if test "$with_wxwidgets" != "no" ; then
6537   case "$with_wxwidgets" in
6538      yes | "" ) ;;
6539      *        ) WXWIDGETS_PATH=$with_wxwidgets ;;
6540   esac
6541   if test -d "$WXWIDGETS_PATH/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}/lib" \
6542        -a -z "$WXWIDGETS_ARCH_PATH"; then
6543      WXWIDGETS_ARCH_PATH="$WXWIDGETS_PATH/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}"
6544   elif test -d "$WXWIDGETS_PATH/${compiler_pfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}/lib" \
6545        -a -z "$WXWIDGETS_ARCH_PATH"; then
6546      WXWIDGETS_ARCH_PATH="$WXWIDGETS_PATH/${compiler_pfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}"
6547   else
6548      WXWIDGETS_ARCH_PATH="$WXWIDGETS_PATH"
6549   fi
6550   WXWIDGETS_BINPATH=${WXWIDGETS_BINPATH:="$WXWIDGETS_ARCH_PATH/bin"}
6551   WXWIDGETS_LIBPATH=${WXWIDGETS_LIBPATH:="$WXWIDGETS_ARCH_PATH/lib"}
6552   WXWIDGETS_INCLUDE=
6553   AS_UNSET(wxconf)
6554   AC_PATH_PROG(wxconf, wx-config, [], $WXWIDGETS_BINPATH:$PATH)
6555   if test -x "$wxconf"; then
6556      WXWIDGETS_ARCH_PATH=`$wxconf --exec-prefix`
6557      if test -n "$with_wxwidgets_ucs"; then
6558         wxcfflags=--unicode=$with_wxwidgets_ucs
6559      else
6560         wxcfflags=
6561      fi
6562      for x in `"$wxconf" $wxcfflags --libs --static 2>&AS_MESSAGE_LOG_FD`; do
6563         case "$x" in
6564            -L*)
6565                d=`echo $x | sed -e 's/^-L//'`
6566                pcd=$d/pkgconfig
6567                if test -d "$pcd"; then
6568                   PKG_CONFIG_PATH="${PKG_CONFIG_PATH+$PKG_CONFIG_PATH:}$pcd"
6569                fi
6570                ;;
6571         esac
6572      done
6573      export PKG_CONFIG_PATH
6574   else
6575      AS_UNSET(wxconf)
6576   fi
6577   if test -x "$wxconf" \
6578     &&  "$wxconf" $wxcfflags --list 2>/dev/null \
6579       | grep 'Default config is gtk2' >/dev/null; then
6580      gtkconf="pkg-config gtk+-2.0"
6581   elif test -x "$WXWIDGETS_BINPATH/gtk-config"; then
6582      gtkconf=$WXWIDGETS_BINPATH/gtk-config
6583   elif gtk-config --version >/dev/null 2>&1; then
6584      gtkconf=gtk-config
6585   else
6586      # May work without gtk-config (e.g., on Mac OS X)
6587      gtkconf=:
6588   fi
6589   case "$host_os" in
6590      darwin* )
6591         baseflags=""
6592         basesed='s/-isysroot [[^ ]]*//g; s/-arch [[^ ]]*//g'
6593         if test -n "$SYSROOT"; then
6594            deps=`"$wxconf" $wxcfflags --libs --static 2>/dev/null \
6595                  | sed -e 's/.*\.a//'`
6596            libsed="$basesed; s%\$% $deps%"
6597         else
6598            libsed=$basesed
6599         fi
6600         ;;
6601      * )
6602         baseflags=`$gtkconf --cflags 2>/dev/null`
6603         basesed=$no_usr_lib
6604         deps=`$gtkconf --libs 2>/dev/null`
6605         libsed="$basesed; s%\$% $deps%"
6606         ;;
6607   esac
6608   test -x "$wxconf"  &&  case "`"$wxconf" $wxcfflags --version`" in
6609      1.* | 2.[[0-7]].* ) wxlibs=std ;;
6610      *                 ) wxlibs=std,richtext,aui,propgrid ;;
6611   esac
6612   AC_CACHE_CHECK(
6613      [for wxWidgets${WXWIDGETS_ARCH_PATH:+ in $WXWIDGETS_ARCH_PATH}],
6614      ncbi_cv_lib_wxwidgets,
6615      [if test -x "$wxconf" ; then
6616          WXWIDGETS_INCLUDE="`"$wxconf" $wxcfflags --cflags` $baseflags"
6617          NCBI_RPATHIFY_OUTPUT(WXWIDGETS_LIBS,
6618             ["$wxconf" $wxcfflags --libs $wxlibs],
6619             [$libsed; s/ -lm / /g;])
6620
6621          CPPFLAGS="$WXWIDGETS_INCLUDE $orig_CPPFLAGS"
6622          LIBS="$WXWIDGETS_LIBS $orig_LIBS"
6623          AC_LINK_IFELSE([AC_LANG_PROGRAM(
6624             [[@%:@include <wx/combobox.h>
6625               class CMyComboBox : public wxComboBox {};]],
6626             [[CMyComboBox cb; cb.Clear();]])],
6627             [ncbi_cv_lib_wxwidgets=yes], [ncbi_cv_lib_wxwidgets=no])
6628       else
6629          ncbi_cv_lib_wxwidgets=no
6630       fi])
6631   if test "$ncbi_cv_lib_wxwidgets" = "no"; then
6632      NCBI_MISSING_PACKAGE(wxwidgets)
6633   fi
6634fi
6635
6636if test "$with_wxwidgets" = "no" ; then
6637   WXWIDGETS_LIBPATH="No_wxWidgets"
6638   WXWIDGETS_INCLUDE=
6639   WXWIDGETS_LIBS=
6640   WXWIDGETS_STATIC_LIBS=
6641   WXWIDGETS_GL_LIBS=
6642   WXWIDGETS_GL_STATIC_LIBS=
6643   WXWIDGETS_POST_LINK=:
6644else
6645   NCBI_PACKAGE(wxWidgets)
6646   case "`"$wxconf" $wxcfflags --version`" in
6647      1.* | 2.[[0-7]].*) ;;
6648      * ) NCBI_PACKAGE(wx2.8) ;;
6649   esac
6650   # The "yes" may have been cached; get the actual settings again if needed
6651   if test -z "$WXWIDGETS_INCLUDE"; then
6652      WXWIDGETS_INCLUDE="`"$wxconf" $wxcfflags --cflags` $baseflags"
6653   fi
6654   NCBI_RPATHIFY_OUTPUT(WXWIDGETS_LIBS, [$wxconf $wxcfflags --libs $wxlibs],
6655      [$libsed; s/ -lm / /g;])
6656   WXWIDGETS_STATIC_LIBS=`"$wxconf" $wxcfflags --libs $wxlibs --static \
6657      2>/dev/null | sed -e "$basesed; s/ -lm / /g;"`
6658   if test -n "$WXWIDGETS_STATIC_LIBS"; then
6659      # Allow direct use of underlying libraries with strict linkers
6660      WXWIDGETS_LIBS="$WXWIDGETS_LIBS `echo $WXWIDGETS_STATIC_LIBS | sed -e 's/.*\.a *//'`"
6661   else
6662      WXWIDGETS_STATIC_LIBS=$WXWIDGETS_LIBS
6663   fi
6664   WXWIDGETS_GL_LIBS=`"$wxconf" $wxcfflags --libs gl | sed -e "$basesed"`
6665   WXWIDGETS_GL_STATIC_LIBS=`"$wxconf" $wxcfflags --libs gl --static \
6666      2>/dev/null | sed -e "$basesed; s|-lGLU* -lGLU*|$OPENGL_STATIC_LIBS|"`
6667   : ${WXWIDGETS_GL_STATIC_LIBS:=$WXWIDGETS_GL_LIBS}
6668   WXWIDGETS_POST_LINK=`"$wxconf" $wxcfflags --rezflags 2>/dev/null`
6669   test -n "$WXWIDGETS_POST_LINK"  ||  WXWIDGETS_POST_LINK=:
6670   wxpnglib=$WXWIDGETS_ARCH_PATH/lib/libpng.so
6671   defpnglib=${PNG_PATH-/usr}/lib${bit64_sfx}/libpng.so
6672   if test -f $wxpnglib  &&  \
6673       (test ! -f $defpnglib  ||  ! cmp -s $wxpnglib $defpnglib); then
6674      PNG_PATH=$WXWIDGETS_ARCH_PATH
6675      PNG_INCLUDE=$WXWIDGETS_INCLUDE
6676   fi
6677   wxtifflib=$WXWIDGETS_ARCH_PATH/lib/libtiff.so
6678   deftifflib=${TIFF_PATH-/usr}/lib${bit64_sfx}/libtiff.so
6679   if test -f $wxtifflib  &&  \
6680       (test ! -f $deftifflib  ||  ! cmp -s $wxtifflib $deftifflib); then
6681      TIFF_PATH=$WXWIDGETS_ARCH_PATH
6682      TIFF_INCLUDE=$WXWIDGETS_INCLUDE
6683   fi
6684   AC_DEFINE(HAVE_WXWIDGETS, 1, [Define to 1 if wxWidgets is available.])
6685fi
6686
6687
6688## In-house Fast-CGI library
6689if test "$with_fastcgi" != "no" ; then
6690   case "$with_fastcgi" in
6691      yes | "" ) ;;
6692      */*      ) FASTCGI_PATH=$with_fastcgi              ;;
6693      *        ) FASTCGI_PATH=$NCBI/fcgi-${with_fastcgi} ;;
6694   esac
6695   if test -d "$FASTCGI_PATH"; then
6696      NCBI_FIX_DIR(FASTCGI_PATH)
6697   fi
6698   FASTCGI_INCLUDE="-I$FASTCGI_PATH/include${bit64_sfx}"
6699   if test "$with_debug" = "no" ; then
6700      FASTCGI_LIBDIR="$FASTCGI_PATH/lib${bit64_sfx}"
6701   else
6702      FASTCGI_LIBDIR="$FASTCGI_PATH/altlib${bit64_sfx}"
6703   fi
6704   NCBI_RPATHIFY(FASTCGI_LIBS, $FASTCGI_LIBDIR, [ -lfcgi $NETWORK_LIBS])
6705   FASTCGI_OBJS="fcgibuf"
6706   LIBS="$FASTCGI_LIBS $orig_LIBS"
6707   AC_CACHE_CHECK([for FastCGI libraries${FASTCGI_PATH:+ in $FASTCGI_PATH}],
6708      ncbi_cv_lib_fcgi,
6709      [CPPFLAGS="$FASTCGI_INCLUDE $orig_CPPFLAGS"
6710       AC_LINK_IFELSE([AC_LANG_PROGRAM(
6711          [[@%:@include <fcgiapp.h>]],
6712          [[ (void) FCGX_IsCGI(); ]])],
6713          [ncbi_cv_lib_fcgi=yes], [ncbi_cv_lib_fcgi=no])])
6714   if test "$ncbi_cv_lib_fcgi" = "no"; then
6715      NCBI_MISSING_PACKAGE(fastcgi)
6716   fi
6717   AC_CHECK_FUNCS(FCGX_Accept_r)
6718fi
6719if test "$with_fastcgi" = "no" ; then
6720   FASTCGI_PATH="No_FastCgi"
6721   FASTCGI_INCLUDE=
6722   FASTCGI_LIBS=
6723   FASTCGI_OBJS=
6724else
6725   NCBI_PACKAGE(Fast-CGI)
6726   AC_DEFINE(HAVE_LIBFASTCGI, 1,
6727             [Define to 1 if FastCGI libraries are available.])
6728fi
6729
6730
6731## NCBI SSS libraries
6732if test "$with_sybase" = "no" ; then
6733   NCBI_MISSING_PACKAGE(sssdb)
6734fi
6735
6736case "$host_os:$compiler:$compiler_version" in
6737   linux*:GCC:* | linux*:*Clang:* )
6738      : ${with_included_sss=yes}
6739   ;;
6740esac
6741
6742if test "$with_sss" != "no" ; then
6743   local_sss=${real_srcdir}/src/internal/sss
6744   if test "${with_included_sss-no}" = "yes" \
6745       -a -f "$local_sss/utils/sssdebug.hpp" \
6746       -a -f "${local_sss}srv/cli/sssconnection.cpp"; then
6747      with_included_sss=yes
6748      NCBI_SSS_PATH=$local_sss
6749      NCBI_SSS_INCLUDE="\$(incdir)/sss"
6750      NCBI_SSS_LIBPATH="\$(libdir)"
6751      NCBI_PACKAGE(LocalSSS)
6752      if test -f "$local_sss/../msgmail2/asn/msgmail.asn"; then
6753         NCBI_PACKAGE(LocalMSGMAIL2)
6754      fi
6755   else
6756      with_included_sss=no
6757   fi
6758   if test "${with_sss-yes}" = yes; then
6759      NCBI_SSS_PATH=${NCBI_SSS_PATH:="$NCBI/sss/BUILD"}
6760   else
6761      NCBI_SSS_PATH=$with_sss
6762   fi
6763   NCBI_SSS_INCLUDE=${NCBI_SSS_INCLUDE:="$NCBI_SSS_PATH/include"}
6764   if test -z "$NCBI_SSS_LIBPATH" ; then
6765      NCBI_SSS_LIBPATH="${NCBI_SSS_PATH}/lib/${compiler_vpfx}${DEBUG_SFX}${bit64_sfx}"
6766      if test "$with_mt" = "yes" ; then
6767         NCBI_SSS_LIBPATH="${NCBI_SSS_LIBPATH}mt"
6768      fi
6769   fi
6770   AC_MSG_CHECKING(
6771      [for NCBI SSS directories${NCBI_SSS_PATH:+ in $NCBI_SSS_PATH}])
6772   if test "$with_included_sss" = "yes"; then
6773      AC_MSG_RESULT([yes]) # duh
6774   elif test ! -d "${NCBI_SSS_LIBPATH}"  -o  ! -d "${NCBI_SSS_INCLUDE}" ; then
6775      AC_MSG_RESULT([no])
6776      NCBI_MISSING_PACKAGE(sss)
6777   else
6778      AC_MSG_RESULT([yes])
6779   fi
6780fi
6781
6782if test "$with_sss" = "no" ; then
6783   NCBI_MISSING_PACKAGE(sssutils)
6784   NCBI_MISSING_PACKAGE(sssdb)
6785   NCBI_SSS_INCLUDE=
6786   NCBI_SSS_LIBPATH=
6787   LIBSSSUTILS=
6788   LIBSSSDB=
6789else
6790   if test "$with_included_sss" = "yes"; then
6791      NCBI_SSS_LIBPATH= # Not needed
6792      ncbi_cv_lib_sssutils=yes
6793      ncbi_cv_lib_sssdb=yes
6794      sssutils=sssutils
6795   else
6796      NCBI_SSS_LIBPATH="-L${NCBI_SSS_LIBPATH}"
6797   fi
6798   NCBI_SSS_INCLUDE="-I${NCBI_SSS_INCLUDE}"
6799
6800   # SSS UTILS
6801   if test "$with_sssutils" != "no" ; then
6802      LIBSSSUTILS="-lsssutils"
6803      AC_CACHE_CHECK([for the NCBI SSS UTILS library], ncbi_cv_lib_sssutils,
6804         [CPPFLAGS="$NCBI_SSS_INCLUDE $SYBASE_INCLUDE $orig_CPPFLAGS"
6805          LIBS="$NCBI_SSS_LIBPATH $LIBSSSUTILS $SYBASE_LIBS $NETWORK_LIBS $orig_LIBS"
6806          AC_LINK_IFELSE([AC_LANG_PROGRAM(
6807             [[@%:@include <hashtab.hpp>]],
6808             [[ (new C_HashTab(123))->Clear(); ]])],
6809             [ncbi_cv_lib_sssutils=yes], [ncbi_cv_lib_sssutils=no])])
6810      if test "$ncbi_cv_lib_sssutils" = yes; then
6811         AC_DEFINE(HAVE_LIBSSSUTILS, 1,
6812                   [Define to 1 if the NCBI SSS UTILS library is available.])
6813         NCBI_PACKAGE(SSSUTILS)
6814         if test -f "$local_sss/../ncbils2/asn/login.asn" \
6815           -a -n "$GCRYPT_LIBS"; then
6816            if test "$with_included_sss" = yes  || \
6817               grep vformat $NCBI_SSS_INCLUDE/String.hpp >/dev/null 2>&1; then
6818               NCBI_PACKAGE(LocalNCBILS) # temporary compatibility measure
6819               NCBI_PACKAGE(NCBILS2)
6820            fi
6821         fi
6822      else
6823         NCBI_MISSING_PACKAGE(sssutils)
6824         NCBI_MISSING_PACKAGE(sss)
6825         LIBSSSUTILS=""
6826      fi
6827   fi
6828
6829   # SSS DB
6830   if test "$with_sssdb" != "no" ; then
6831      if test "$with_mt" = "yes" ; then
6832         LIBSSSDB="-lsssdb -lssssys"
6833      else
6834         LIBSSSDB="-lsssdb"
6835      fi
6836      AC_CACHE_CHECK([for the NCBI SSS DB library], ncbi_cv_lib_sssdb,
6837         [CPPFLAGS="$NCBI_SSS_INCLUDE $SYBASE_INCLUDE $orig_CPPFLAGS"
6838          LIBS="$NCBI_SSS_LIBPATH $LIBSSSDB $SYBASE_LIBS $NETWORK_LIBS $orig_LIBS"
6839          AC_LINK_IFELSE([AC_LANG_PROGRAM(
6840             [[@%:@include <cslink.hpp>]],
6841             [[ (new CSLink)->connect2server("srv", "user", "pwd", "db"); ]])],
6842             [ncbi_cv_lib_sssdb=yes], [ncbi_cv_lib_sssdb=no])])
6843      if test "$ncbi_cv_lib_sssdb" = "yes"; then
6844         AC_DEFINE(HAVE_LIBSSSDB, 1,
6845                   [Define to 1 if the NCBI SSS DB library is available.])
6846         NCBI_PACKAGE(SSSDB)
6847      else
6848         NCBI_MISSING_PACKAGE(sssdb)
6849         NCBI_MISSING_PACKAGE(sss)
6850         LIBSSSDB=""
6851      fi
6852   fi
6853fi
6854
6855
6856# SP
6857if test "$with_sp" != "no" ; then
6858   if test -n "$SP_INCLUDE"; then
6859      SP_GENERIC="$SP_INCLUDE/../generic"
6860   else
6861      SP_INCLUDE="$SP_PATH/include"
6862      SP_GENERIC="$SP_PATH/generic"
6863   fi
6864   if test -z "$SP_LIBPATH" ; then
6865      SP_LIBPATH="${SP_PATH}/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}"
6866   fi
6867   AC_MSG_CHECKING([for SP directories${SP_PATH:+ in $SP_PATH}])
6868   if test ! -d "${SP_LIBPATH}"  -o  ! -d "${SP_INCLUDE}" ; then
6869      AC_MSG_RESULT([no])
6870      NCBI_MISSING_PACKAGE(sp)
6871   else
6872      AC_MSG_RESULT([yes])
6873   fi
6874fi
6875
6876if test "$with_sp" != "no" ; then
6877   if test -d "$SP_GENERIC"; then
6878      SP_INCLUDE="-I${SP_INCLUDE} -I${SP_GENERIC}"
6879   else
6880      SP_INCLUDE="-I${SP_INCLUDE}"
6881   fi
6882   SP_LIBS="-L$SP_LIBPATH -lsp"
6883   AC_CACHE_CHECK([for the SP SGML library], ncbi_cv_lib_sp,
6884      [CPPFLAGS="$SP_INCLUDE $orig_CPPFLAGS"
6885       LIBS="$SP_LIBS $orig_LIBS"
6886       AC_LINK_IFELSE([AC_LANG_PROGRAM(
6887          [[@%:@include <SGMLApplication.h>]],
6888          [[ SP_API::SGMLApplication app; ]])],
6889          [ncbi_cv_lib_sp=yes], [ncbi_cv_lib_sp=no])])
6890   if test "$ncbi_cv_lib_sp" = "no"; then
6891      NCBI_MISSING_PACKAGE(sp)
6892   fi
6893fi
6894
6895if test "$with_sp" = "no" ; then
6896   SP_INCLUDE=
6897   SP_LIBS=
6898else
6899   NCBI_PACKAGE(SP)
6900   AC_DEFINE(HAVE_LIBSP, 1, [Define to 1 if the SP SGML library is available.])
6901fi
6902
6903
6904## ORBacus CORBA
6905if test "$with_orbacus" != no; then
6906   if test "$with_orbacus" != yes; then
6907       ORBACUS_PATH=$with_orbacus
6908   fi
6909   if test -d "$ORBACUS_PATH"; then
6910      NCBI_FIX_DIR(ORBACUS_PATH)
6911   fi
6912   fullpath=${ORBACUS_PATH}/${DEBUG_SFX}${mt_sfx}${bit64_sfx}
6913   if test -f ${fullpath}/inc/OB/Config.h ; then
6914      : ${ORBACUS_INCLUDE="-I$ORBACUS_PATH/include -I$fullpath/inc"}
6915      NCBI_RPATHIFY_COND(ORBACUS_LIBPATH, $fullpath/lib)
6916   elif test -f ${ORBACUS_PATH}/include/OB/Config.h ; then
6917     : ${ORBACUS_INCLUDE="-I$ORBACUS_PATH/include"}
6918     NCBI_RPATHIFY_COND(ORBACUS_LIBPATH, $ORBACUS_PATH/lib)
6919   fi
6920   case "$host_os:$with_mt" in
6921       linux*:no) LIBJTC="-lJTC -pthread" ;;
6922       *)         LIBJTC="-lJTC"          ;;
6923   esac
6924
6925   case "$with_mt:$ORBACUS_LIBPATH" in
6926      yes:* | *:-L*MT/lib* )
6927         LIBOB="-lOB $LIBJTC"
6928         LIBIMR="-lIMR"
6929         ;;
6930      * )
6931         LIBOB="-lOB"
6932         LIBIMR=
6933         ;;
6934   esac
6935   AC_CACHE_CHECK([for ORBacus${ORBACUS_PATH:+ in $ORBACUS_PATH}],
6936      ncbi_cv_lib_orbacus,
6937      [CPPFLAGS="$ORBACUS_INCLUDE $orig_CPPFLAGS"
6938       LIBS="$ORBACUS_LIBPATH $LIBOB $NETWORK_LIBS $orig_LIBS"
6939       AC_LINK_IFELSE([AC_LANG_PROGRAM(
6940          [[@%:@include <OB/CORBA.h>]],
6941          [[
6942            int c = 0;
6943            char* v[] = { NULL };
6944            CORBA::ORB_var orb = CORBA::ORB_init(c, v);
6945            if (!CORBA::is_nil(orb)) orb->destroy();
6946          ]])],
6947          [ncbi_cv_lib_orbacus=yes], [ncbi_cv_lib_orbacus=no])])
6948   if test "$ncbi_cv_lib_orbacus" = "no"; then
6949      NCBI_MISSING_PACKAGE(orbacus)
6950   fi
6951fi
6952if test "$with_orbacus" = no; then
6953   ORBACUS_PATH=No_ORBacus
6954   ORBACUS_INCLUDE=
6955   ORBACUS_LIBPATH=
6956   LIBOB=
6957   LIBIMR=
6958else
6959   NCBI_PACKAGE(ORBacus)
6960   AC_DEFINE(HAVE_ORBACUS, 1,
6961             [Define to 1 if the ORBacus CORBA package is available.])
6962fi
6963
6964
6965## International Components for Unicode (ICU)
6966if test -z "$ICU_PATH"  &&  icu-config --version >/dev/null 2>&1; then
6967    ICU_PATH=`icu-config --prefix`
6968fi
6969
6970if test "$with_icu" != "no" ; then
6971   case "$with_icu" in
6972      yes | "" ) ;;
6973      *        ) ICU_PATH=$with_icu ;;
6974   esac
6975   if test -d "$ICU_PATH/${compiler_vpfx}${DEBUG_SFX}${bit64_sfx}${mt_sfx}/lib" \
6976        -a -z "$ICU_ARCH_PATH"; then
6977      ICU_ARCH_PATH="$ICU_PATH/${compiler_vpfx}${DEBUG_SFX}${bit64_sfx}${mt_sfx}"
6978   elif test -d "$ICU_PATH/${compiler_pfx}${DEBUG_SFX}${bit64_sfx}${mt_sfx}/lib" \
6979        -a -z "$ICU_ARCH_PATH"; then
6980      ICU_ARCH_PATH="$ICU_PATH/${compiler_pfx}${DEBUG_SFX}${bit64_sfx}${mt_sfx}"
6981   else
6982      ICU_ARCH_PATH="$ICU_PATH"
6983   fi
6984   ICU_BINPATH=${ICU_BINPATH:="$ICU_ARCH_PATH/bin"}
6985   ICU_LIBPATH=${ICU_LIBPATH:="$ICU_ARCH_PATH/lib"}
6986   ICU_INCLUDE=
6987   AC_CACHE_CHECK([for ICU${ICU_ARCH_PATH:+ in $ICU_ARCH_PATH}],
6988      ncbi_cv_lib_icu,
6989      [ICU_CONFIG=`$ICU_BINPATH/icu-config --bindir 2>/dev/null`/icu-config
6990       if test -x "$ICU_CONFIG" ; then
6991          ICU_INCLUDE=`$ICU_CONFIG --cppflags-searchpath`
6992          NCBI_RPATHIFY_OUTPUT(ICU_LIBS, $ICU_CONFIG --ldflags-searchpath)
6993          ICU_LIBS="$ICU_LIBS `$ICU_CONFIG --ldflags-libsonly`"
6994
6995          CPPFLAGS="$ICU_INCLUDE $orig_CPPFLAGS"
6996          LIBS="$ICU_LIBS $orig_LIBS"
6997          AC_LINK_IFELSE([AC_LANG_PROGRAM(
6998            [[@%:@include <unicode/unistr.h>]],
6999            [[int32_t i = UNICODE_STRING_SIMPLE("foo").indexOf('f');]])],
7000            [ncbi_cv_lib_icu=yes], [ncbi_cv_lib_icu=no])
7001       else
7002          ncbi_cv_lib_icu=no
7003       fi])
7004   if test "$ncbi_cv_lib_icu" = "no"; then
7005      NCBI_MISSING_PACKAGE(icu)
7006   fi
7007fi
7008
7009if test "$with_icu" = "no" ; then
7010   ICU_PATH="No_ICU"
7011   ICU_INCLUDE=
7012   ICU_LIBS=
7013   ICU_STATIC_LIBS=
7014else
7015   NCBI_PACKAGE(ICU)
7016   ICU_CONFIG="`$ICU_BINPATH/icu-config --bindir`/icu-config"
7017   # The "yes" may have been cached; get the actual settings again if needed
7018   if test -z "$ICU_INCLUDE"; then
7019      ICU_INCLUDE=`$ICU_CONFIG --cppflags-searchpath`
7020      NCBI_RPATHIFY_OUTPUT(ICU_LIBS, $ICU_CONFIG --ldflags-searchpath)
7021      ICU_LIBS="$ICU_LIBS `$ICU_CONFIG --ldflags-libsonly`"
7022   fi
7023   ICU_SEARCHPATH=`$ICU_CONFIG --ldflags-searchpath | sed -e "$no_usr_lib"`
7024   ICU_STATIC_LIBS=`$ICU_CONFIG --ldflags-libsonly | sed -e 's/-licu/-lsicu/g'`
7025   ICU_STATIC_LIBS="$ICU_SEARCHPATH $ICU_STATIC_LIBS"
7026   AC_DEFINE(HAVE_ICU, 1, [Define to 1 if ICU libraries are available.])
7027fi
7028
7029
7030### XML/XSL libraries
7031NCBI_CHECK_THIRD_PARTY_LIB(expat,
7032 [AC_LANG_PROGRAM([@%:@include <expat.h>],
7033    [XML_Parser parser = XML_ParserCreate("utf-8");])])
7034if test -f "${EXPAT_PATH}/lib${bit64_sfx}/libexpat-static.a"; then
7035   EXPAT_STATIC_LIBS="-L${EXPAT_PATH}/lib${bit64_sfx} -lexpat-static"
7036else
7037   EXPAT_STATIC_LIBS=${EXPAT_LIBS}
7038fi
7039vpath="$SABLOT_PATH/${compiler_vpfx}build"
7040test -d "$vpath"  &&  SABLOT_PATH=$vpath
7041if test -d "$SABLOT_PATH"; then
7042   NCBI_FIX_DIR(SABLOT_PATH)
7043fi
7044NCBI_CHECK_THIRD_PARTY_LIB(sablot,
7045 [AC_LANG_PROGRAM([@%:@include <sablot.h>],
7046    [SDOM_Document* D; int x = SablotParse(NULL, "file:/dev/null", D);])],
7047 $EXPAT_LIBS)
7048if test -f "${SABLOT_PATH}/lib${bit64_sfx}/libsablot-static.a"; then
7049   SABLOT_STATIC_LIBS="-L${SABLOT_PATH}/lib${bit64_sfx} -lsablot-static $EXPAT_STATIC_LIBS"
7050else
7051   SABLOT_STATIC_LIBS=${SABLOT_LIBS}
7052fi
7053
7054# test -d "$LIBXML_PATH" || LIBXML_PATH=`xml2-config --prefix 2>/dev/null`
7055if test "$with_libxml" != "no"; then
7056   case "$with_libxml" in
7057      yes | "" ) ;;
7058      *        ) LIBXML_PATH=$with_libxml ;;
7059   esac
7060   for pfx in "$compiler_vpfx" "$compiler_pfx" "" ; do
7061      vpath=$LIBXML_PATH/$pfx${DEBUG_SFX}${mt_sfx}${bit64_sfx}
7062      if test -d "$vpath" ; then
7063         LIBXML_PATH=$vpath
7064         break
7065      fi
7066   done
7067   if test -d "$LIBXML_PATH"; then
7068      NCBI_FIX_DIR(LIBXML_PATH)
7069      in_path=" in $LIBXML_PATH"
7070      if test -n "$LIBXML_INCLUDE"; then
7071         :
7072      elif test -d "$LIBXML_PATH/include/libxml2/libxml"; then
7073         LIBXML_INCLUDE="-I$LIBXML_PATH/include/libxml2 -I$LIBXML_PATH/include"
7074      elif test -d "$LIBXML_PATH/include/libxml"; then
7075         LIBXML_INCLUDE="-I$LIBXML_PATH/include";
7076      else
7077         case "$host_os" in
7078            darwin* )
7079               LIBXML_INCLUDE="-iwithsysroot $LIBXML_PATH/include/libxml2"
7080               ;;
7081         esac
7082      fi
7083      if test -d "$LIBXML_PATH/lib${bit64_sfx}"; then
7084         LIBXML_LIBPATH_="$LIBXML_PATH/lib${bit64_sfx}"
7085      elif test -d "$LIBXML_PATH/lib"; then
7086         LIBXML_LIBPATH_="$LIBXML_PATH/lib"
7087      fi
7088      NCBI_RPATHIFY_COND(LIBXML_LIBPATH, $LIBXML_LIBPATH_)
7089      LIBXML_LIBS="$LIBXML_LIBPATH -lxml2"
7090   else
7091      case "$host_os" in
7092         darwin* ) LIBXML_INCLUDE="-iwithsysroot /usr/include/libxml2" ;;
7093         *       ) LIBXML_INCLUDE="-I/usr/include/libxml2" ;;
7094      esac
7095      LIBXML_LIBS="-lxml2"
7096      in_path=
7097   fi
7098   LIBXML_LIBS="$LIBXML_LIBS $ICONV_LIBS"
7099   AC_CACHE_CHECK([for libxml2$in_path], ncbi_cv_lib_libxml,
7100      CPPFLAGS="$LIBXML_INCLUDE $orig_CPPFLAGS"
7101      LIBS="$LIBXML_LIBS $orig_LIBS"
7102      [AC_LINK_IFELSE(
7103         [AC_LANG_PROGRAM(
7104             [@%:@include <libxml/parser.h>],
7105             [xmlDocPtr doc = xmlParseFile("foo.xml");])],
7106      [ncbi_cv_lib_libxml=yes], [ncbi_cv_lib_libxml=no])])
7107   if test "$ncbi_cv_lib_libxml" = "no"; then
7108      NCBI_MISSING_PACKAGE(libxml)
7109   fi
7110fi
7111if test "$with_libxml" = "no"; then
7112   LIBXML_PATH="No_LIBXML"
7113   LIBXML_INCLUDE=
7114   LIBXML_LIBPATH_=
7115   LIBXML_LIBS=
7116else
7117   NCBI_PACKAGE(LIBXML)
7118   LIBXML_INCLUDE="$LIBXML_INCLUDE"
7119   AC_DEFINE(HAVE_LIBXML, 1, [Define to 1 if libxml2 is available.])
7120   export LIBXML_LIBPATH
7121fi
7122AC_SUBST(LIBXML_INCLUDE)
7123AC_SUBST(LIBXML_LIBS)
7124
7125if test -f "${LIBXML_LIBPATH_}/libxml2-static.a"; then
7126   LIBXML_STATIC_LIBS="-L${LIBXML_LIBPATH_} -lxml2-static $ICONV_LIBS"
7127   if test "x$with_bin_release" = "xyes"; then
7128      LIBXML_LIBS=$LIBXML_STATIC_LIBS
7129   fi
7130else
7131   LIBXML_STATIC_LIBS=${LIBXML_LIBS}
7132fi
7133
7134: ${LIBXSLT_PATH=$LIBXML_PATH}
7135NCBI_CHECK_THIRD_PARTY_LIB_EX(libxslt, LIBXSLT, xslt,
7136 [AC_LANG_PROGRAM([@%:@include <libxslt/xslt.h>], [xsltInit()])],
7137 [], [$LIBXML_LIBS $Z_LIBS], [$LIBXML_INCLUDE])
7138
7139# XXX - they might be in different directories in some setups
7140if test -f "${LIBXML_LIBPATH_}/libxslt-static.a"; then
7141   LIBXSLT_STATIC_LIBS="-L${LIBXML_LIBPATH_} -lxslt-static"
7142   if test "x$with_bin_release" = "xyes"; then
7143      LIBXSLT_LIBS=$LIBXSLT_STATIC_LIBS
7144   fi
7145else
7146   LIBXSLT_STATIC_LIBS=${LIBXSLT_LIBS}
7147fi
7148
7149AC_PATH_PROG(XSLTPROC, xsltproc, :,
7150   [$LIBXSLT_PATH/bin:`dirname $LIBXML_LIBPATH_ 2>/dev/null`/bin:$PATH])
7151
7152: ${LIBEXSLT_PATH=$LIBXSLT_PATH}
7153if env PKG_CONFIG_PATH=$LIBEXSLT_PATH/lib/pkgconfig pkg-config libexslt --libs \
7154    2>/dev/null | $EGREP_Q gcrypt; then
7155   exslt_autodep=$GCRYPT_LIBS
7156else
7157   exslt_autodep=
7158fi
7159NCBI_CHECK_THIRD_PARTY_LIB_EX(libexslt, LIBEXSLT, exslt,
7160 [AC_LANG_PROGRAM([@%:@include <libexslt/exslt.h>], [exsltRegisterAll()])],
7161 [$exslt_autodep], [$LIBXSLT_LIBS $LIBXML_LIBS $Z_LIBS], [$LIBXSLT_INCLUDE])
7162
7163# XXX - they might be in different directories in some setups
7164if test -f "${LIBXML_LIBPATH_}/libexslt-static.a"; then
7165   LIBEXSLT_STATIC_LIBS="-L${LIBXML_LIBPATH_} -lexslt-static $GCRYPT_LIBS"
7166   if test "x$with_bin_release" = "xyes"; then
7167      LIBEXSLT_LIBS=$LIBEXSLT_STATIC_LIBS
7168   fi
7169else
7170   LIBEXSLT_STATIC_LIBS=${LIBEXSLT_LIBS}
7171fi
7172
7173if test "$with_xerces" != no; then
7174   if test "${with_xerces-yes}" != yes; then
7175      XERCES_PATH=$with_xerces
7176   fi
7177   if test -d "$XERCES_PATH"; then
7178      NCBI_FIX_DIR(XERCES_PATH)
7179   fi
7180   vpath="$XERCES_PATH/${compiler_vpfx}${DEBUG_SFX}${bit64_sfx}${mt_sfx}"
7181   if test -d "$vpath/lib"; then
7182      XERCES_PATH=$vpath
7183      NCBI_FIX_DIR(XERCES_PATH)
7184   elif test -d "$vpath"; then
7185      : ${XERCES_LIBPATH=$vpath}
7186      NCBI_FIX_DIR(XERCES_LIBPATH)
7187   else
7188      vpath="$XERCES_PATH/${compiler_pfx}${DEBUG_SFX}${bit64_sfx}${mt_sfx}"
7189      if test -d "$vpath/lib"; then
7190         XERCES_PATH=$vpath
7191         NCBI_FIX_DIR(XERCES_PATH)
7192      elif test -d "$vpath"; then
7193         XERCES_LIBPATH=$vpath
7194         NCBI_FIX_DIR(XERCES_LIBPATH)
7195      fi
7196   fi
7197   if test -d "$XERCES_PATH"; then
7198      in_path=" in $XERCES_PATH"
7199      : ${XERCES_INCLUDE=-I$XERCES_PATH/include}
7200      : ${XERCES_LIBPATH=$XERCES_PATH/lib}
7201   else
7202      in_path=''
7203   fi
7204   NCBI_RPATHIFY(XERCES_LIBPATH_, $XERCES_LIBPATH)
7205   XERCES_LIBS="$XERCES_LIBPATH_ -lxerces-c"
7206   AC_CACHE_CHECK([for Xerces-C++$in_path], ncbi_cv_lib_xerces_c,
7207      [CPPFLAGS="$XERCES_INCLUDE $orig_CPPFLAGS"
7208       LIBS="$XERCES_LIBS $ICU_LIBS $orig_LIBS"
7209       AC_LINK_IFELSE(
7210          [AC_LANG_PROGRAM([[@%:@include <xercesc/dom/DOM.hpp>]],
7211             [[xercesc::DOMImplementation* impl
7212               = xercesc::DOMImplementationRegistry::getDOMImplementation
7213                 (xercesc::XMLString::transcode("XML 1.0"));]])],
7214          ncbi_cv_lib_xerces_c=yes, ncbi_cv_lib_xerces_c=no)])
7215   if test $ncbi_cv_lib_xerces_c = yes; then
7216      if test -f "$XERCES_LIBPATH/libxerces-c-static.a"; then
7217         XERCES_STATIC_LIBS="-L$XERCES_LIBPATH -lxerces-c-static $CURL_LIBS"
7218      else
7219         XERCES_STATIC_LIBS=$XERCES_LIBS
7220      fi
7221   else
7222      NCBI_MISSING_PACKAGE(xerces)
7223   fi
7224fi
7225if test "$with_xerces" != no; then
7226   NCBI_PACKAGE(Xerces)
7227   AC_DEFINE(HAVE_XERCES, 1, [Define to 1 if Xerces-C++ is available.])
7228else
7229   XERCES_INCLUDE=
7230   XERCES_LIBS=
7231   XERCES_STATIC_LIBS=
7232fi
7233
7234if test "$with_xalan" != no; then
7235   if test "${with_xalan-yes}" != yes; then
7236      XALAN_PATH=$with_xalan
7237   fi
7238   if test -d "$XALAN_PATH"; then
7239      NCBI_FIX_DIR(XALAN_PATH)
7240   fi
7241   vpath="$XALAN_PATH/${compiler_vpfx}${DEBUG_SFX}${bit64_sfx}${mt_sfx}"
7242   if test -d "$vpath/lib"; then
7243      XALAN_PATH=$vpath
7244      NCBI_FIX_DIR(XALAN_PATH)
7245   elif test -d "$vpath"; then
7246      : ${XALAN_LIBPATH=$vpath}
7247      NCBI_FIX_DIR(XALAN_LIBPATH)
7248   else
7249      vpath="$XALAN_PATH/${compiler_pfx}${DEBUG_SFX}${bit64_sfx}${mt_sfx}"
7250      if test -d "$vpath/lib"; then
7251         XALAN_PATH=$vpath
7252         NCBI_FIX_DIR(XALAN_PATH)
7253      elif test -d "$vpath"; then
7254         XALAN_LIBPATH=$vpath
7255         NCBI_FIX_DIR(XALAN_LIBPATH)
7256      fi
7257   fi
7258   if test -d "$XALAN_PATH"; then
7259      in_path=" in $XALAN_PATH"
7260      : ${XALAN_INCLUDE=-I$XALAN_PATH/include}
7261      : ${XALAN_LIBPATH=$XALAN_PATH/lib}
7262   else
7263      in_path=''
7264   fi
7265   NCBI_RPATHIFY(XALAN_LIBPATH_, $XALAN_LIBPATH)
7266   XALAN_LIBS="$XALAN_LIBPATH_ -lxalan-c -lxalanMsg"
7267   AC_CACHE_CHECK([for Xalan-C++$in_path], ncbi_cv_lib_xalan_c,
7268      [CPPFLAGS="$XALAN_INCLUDE $XERCES_INCLUDE $orig_CPPFLAGS"
7269       LIBS="$XALAN_LIBS $XERCES_LIBS $ICU_LIBS $orig_LIBS"
7270       AC_LINK_IFELSE(
7271          [AC_LANG_PROGRAM([[@%:@include <xalanc/XalanTransformer/XalanTransformer.hpp>]],
7272             [[xalanc::XalanTransformer::initialize();]])],
7273          ncbi_cv_lib_xalan_c=yes, ncbi_cv_lib_xalan_c=no)])
7274   if test $ncbi_cv_lib_xalan_c = yes; then
7275      if test -f "$XALAN_LIBPATH/libxalan-c-static.a"; then
7276         XALAN_STATIC_LIBS="-L$XALAN_LIBPATH -lxalan-c-static -lxalanMsg-static"
7277      else
7278         XALAN_STATIC_LIBS=$XALAN_LIBS
7279      fi
7280   else
7281      NCBI_MISSING_PACKAGE(xalan)
7282   fi
7283fi
7284if test "$with_xalan" != no; then
7285   NCBI_PACKAGE(Xalan)
7286   AC_DEFINE(HAVE_XALAN, 1, [Define to 1 if Xalan-C++ is available.])
7287else
7288   XALAN_INCLUDE=
7289   XALAN_LIBS=
7290   XALAN_STATIC_LIBS=
7291fi
7292
7293if test "$with_zorba" != no; then
7294   if test "${with_zorba-yes}" != yes; then
7295      ZORBA_PATH=$with_zorba
7296   fi
7297   if test -d "$ZORBA_PATH"; then
7298      NCBI_FIX_DIR(ZORBA_PATH)
7299   fi
7300   vpath="$ZORBA_PATH/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}"
7301   if test -d "$vpath/lib"; then
7302      ZORBA_PATH=$vpath
7303      NCBI_FIX_DIR(ZORBA_PATH)
7304   elif test -d "$vpath"; then
7305      : ${ZORBA_LIBPATH=$vpath}
7306      NCBI_FIX_DIR(ZORBA_LIBPATH)
7307   else
7308      vpath="$ZORBA_PATH/${compiler_pfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}"
7309      if test -d "$vpath/lib"; then
7310         ZORBA_PATH=$vpath
7311         NCBI_FIX_DIR(ZORBA_PATH)
7312      elif test -d "$vpath"; then
7313         ZORBA_LIBPATH=$vpath
7314         NCBI_FIX_DIR(ZORBA_LIBPATH)
7315      fi
7316   fi
7317   ZORBA_CONFIG="$ZORBA_PATH/bin/zorba-config"
7318   if test -x "$ZORBA_CONFIG"; then
7319      ZORBA_PATH=`$ZORBA_CONFIG --prefix`
7320      : ${ZORBA_INCLUDE=`$ZORBA_CONFIG --cppflags`}
7321   fi
7322   if test -d "$ZORBA_PATH"; then
7323      in_path=" in $ZORBA_PATH"
7324      : ${ZORBA_INCLUDE=-I$ZORBA_PATH/include}
7325      : ${ZORBA_LIBPATH=$ZORBA_PATH/lib}
7326   else
7327      in_path=''
7328   fi
7329   if test -x "$ZORBA_CONFIG"; then
7330      ZORBA_LIBS=`$ZORBA_CONFIG --libs`
7331   else
7332      NCBI_RPATHIFY(ZORBA_LIBPATH_, $ZORBA_LIBPATH)
7333      ZORBA_LIBS="$ZORBA_LIBPATH_ -lzorba_simplestore"
7334   fi
7335   AC_CACHE_CHECK([for Zorba$in_path], ncbi_cv_lib_zorba,
7336      [CPPFLAGS="$ZORBA_INCLUDE $orig_CPPFLAGS"
7337       LIBS="$ZORBA_LIBS $orig_LIBS"
7338       AC_LINK_IFELSE(
7339          [AC_LANG_PROGRAM([[@%:@include <zorba/zorba.h>]],
7340             [[zorba::Version v = zorba::Zorba::version();]])],
7341          ncbi_cv_lib_zorba=yes, ncbi_cv_lib_zorba=no)])
7342   if test $ncbi_cv_lib_zorba = yes; then
7343      if test -x "$ZORBA_CONFIG"; then
7344         ZORBA_STATIC_LIBS=`$ZORBA_CONFIG --static-libs`
7345      elif test -f "$ZORBA_LIBPATH/libzorba_simplestore-static.a"; then
7346         ZORBA_STATIC_LIBS="-L$ZORBA_LIBPATH -lzorba_simplestore-static $XERCES_STATIC_LIBS $ICU_STATIC_LIBS $LIBXSLT_STATIC_LIBS $LIBXML_STATIC_LIBS"
7347      else
7348         ZORBA_STATIC_LIBS=$ZORBA_LIBS
7349      fi
7350   else
7351      NCBI_MISSING_PACKAGE(zorba)
7352   fi
7353fi
7354if test "$with_zorba" != no; then
7355   NCBI_PACKAGE(Zorba)
7356   AC_DEFINE(HAVE_ZORBA, 1, [Define to 1 if Zorba is available.])
7357else
7358   ZORBA_INCLUDE=
7359   ZORBA_LIBS=
7360   ZORBA_STATIC_LIBS=
7361fi
7362
7363### SQLite
7364case "$with_sqlite3" in
7365   yes | '' ) ;;
7366   *        ) SQLITE3_PATH=$with_sqlite3 ;;
7367esac
7368
7369if test -d "$SQLITE3_PATH"; then
7370   NCBI_FIX_DIR(SQLITE3_PATH)
7371fi
7372if test -d "$SQLITE3_PATH/${compiler_pfx}${DEBUG_SFX}${MT_SFX}${bit64_sfx}/lib"; then
7373   SQLITE3_LIBDIR=$SQLITE3_PATH/${compiler_pfx}${DEBUG_SFX}${MT_SFX}${bit64_sfx}/lib
7374elif test -d $SQLITE3_PATH/lib${bit64_sfx}; then
7375   SQLITE3_LIBDIR=$SQLITE3_PATH/lib${bit64_sfx}
7376else
7377   SQLITE3_LIBDIR=$SQLITE3_PATH/lib
7378fi
7379NCBI_RPATHIFY(SQLITE3_LIBPATH, $SQLITE3_LIBDIR)
7380NCBI_CHECK_THIRD_PARTY_LIB(sqlite3,
7381 [AC_LANG_PROGRAM([@%:@include <sqlite3.h>],
7382    [sqlite3_pcache_methods m;
7383     int status = sqlite3_config(SQLITE_CONFIG_GETPCACHE, &m);])])
7384if test -n "$SQLITE3_LIBS"; then
7385   CPPFLAGS="$SQLITE3_INCLUDE $orig_CPPFLAGS"
7386   AC_CHECK_HEADER(sqlite3async.h,
7387      [AC_DEFINE(HAVE_SQLITE3ASYNC_H, 1,
7388          [Define to 1 if you have the <sqlite3async.h> header file.])
7389       NCBI_PACKAGE(SQLITE3ASYNC)])
7390   LIBS="$SQLITE3_LIBS $orig_LIBS"
7391   AC_CHECK_FUNCS(sqlite3_unlock_notify)
7392   SQLITE3_WRAPPER=sqlitewrapp
7393else
7394   SQLITE3_WRAPPER=
7395fi
7396if test -n "$SQLITE3_LIBS" -a -f "$SQLITE3_LIBDIR/libsqlite3-static.a"; then
7397   SQLITE3_STATIC_LIBS="-L$SQLITE3_LIBDIR -lsqlite3-static"
7398   if test "x$with_bin_release" = "xyes"; then
7399      SQLITE3_LIBS=$SQLITE3_STATIC_LIBS
7400   fi
7401else
7402   SQLITE3_STATIC_LIBS=$SQLITE3_LIBS
7403fi
7404
7405
7406# NCBI SRA/VDB
7407VDB_POST_LINK=:
7408VDB_REQ=VDB
7409if test "$with_vdb" != "no" ; then
7410   # CURL?
7411   vdb_deps="$NETWORK_LIBS $BZ2_LIBS $Z_LIBS $DL_LIBS"
7412   # In MT builds, ORIG_LIBS already contains THREAD_LIBS.  However,
7413   # VDB is always threaded, and may need explicit THREAD_LIBS when
7414   # used statically.
7415   if test "$with_mt" = no; then
7416      vdb_deps="$vdb_deps $THREAD_LIBS"
7417   fi
7418   vdb_static_deps="$LIBXML_STATIC_LIBS $vdb_deps"
7419   vdb_deps="$LIBXML_LIBS $vdb_deps"
7420   if test "${with_vdb:-yes}" != "yes" -a -d "$with_vdb"; then
7421      VDB_PATH=$with_vdb
7422   fi
7423   if test -d "$VDB_PATH"; then
7424      : ${with_downloaded_vdb=no}
7425   else
7426      : ${with_downloaded_vdb=$with_vdb}
7427   fi
7428   if test "$with_downloaded_vdb" != "no"; then
7429      AC_MSG_NOTICE([trying to build the NCBI SRA/VDB Toolkit from GitHub.])
7430      VDB_PATH=`$real_srcdir/scripts/common/add_vdb.sh 2>&AS_MESSAGE_LOG_FD`
7431      status=$?
7432      if test $status != 0; then
7433         message="SRA/VDB build failed with status $status"
7434      elif test ! -d "$VDB_PATH"; then
7435         message="SRA/VDB build nominally succeeded, but failed to report where"
7436      else
7437         message=
7438      fi
7439      case "$message:$with_downloaded_vdb" in
7440         :*    ) ;;
7441         *:yes ) AC_MSG_FAILURE([$message]) ;;
7442         *     ) AC_MSG_WARN([$message])  ;;
7443      esac
7444   fi
7445   # if test "$with_included_vdb" != "yes"; then
7446      if test -z "$VDB_PATH"; then
7447         in_path=
7448      else
7449         dnl NCBI_FIX_DIR(VDB_PATH)
7450         vdb_parent=`dirname "$VDB_PATH"`
7451         NCBI_FIX_DIR(vdb_parent)
7452         VDB_PATH=$vdb_parent/`basename "$VDB_PATH"`
7453         in_path=" in $VDB_PATH"
7454         case "$host_os" in
7455            darwin*  ) vdb_os=mac ;;
7456            linux*   ) vdb_os=linux ;;
7457            solaris* ) vdb_os=sun ;;
7458         esac
7459         case "$VDB_PATH" in
7460            */cxx_toolkit/* ) vdb_os_interfaces=$vdb_os/../interfaces ;;
7461            *               ) vdb_os_interfaces= ;;
7462         esac
7463         for x in $vdb_os_interfaces interfaces include; do
7464            if test -d "$VDB_PATH/$x"; then
7465               vdb_inc_root=$VDB_PATH/$x
7466               : ${VDB_INCLUDE="-I$vdb_inc_root"}
7467               break
7468            fi
7469         done
7470         vdb_inc_subdirs=cc/gcc
7471         case "$host_cpu:$bit64_sfx" in
7472            *86*:64 ) vdb_inc_subdirs="cc/gcc/x86_64 $vdb_inc_subdirs" ;;
7473            *86*:*  ) vdb_inc_subdirs="cc/gcc/fat86 $vdb_inc_subdirs" ;;
7474         esac
7475         if test "$ncbi_compiler" = ICC; then
7476            vdb_inc_subdirs="cc/icc $vdb_inc_subdirs"
7477         fi
7478         vdb_inc_subdirs="os/$vdb_os os/unix $vdb_inc_subdirs"
7479         for x in $vdb_inc_subdirs; do
7480            VDB_INCLUDE="$VDB_INCLUDE -I$vdb_inc_root/$x"
7481         done
7482         case "$DEBUG_SFX" in
7483            Debug )
7484               VDB_INCLUDE="$VDB_INCLUDE -D_DEBUGGING"
7485               vdb_mode=debug
7486               ;;
7487            Release )
7488               vdb_mode=release
7489               ;;
7490         esac
7491         case "$host_os:$host_cpu:$bit64_sfx" in
7492            darwin*:*86*:64 ) vdb_libpath=mac/$vdb_mode/x86_64/lib   ;;
7493            darwin*:*86*:* )  vdb_libpath=mac/$vdb_mode/fat86/lib    ;;
7494            linux*:*86*:64 )  vdb_libpath=linux/$vdb_mode/x86_64/lib ;;
7495            * )
7496               if test -n "$with_vdb"; then
7497                  AC_MSG_ERROR([--with-vdb explicitly specified,
7498                                but not supported on this platform.])
7499               fi
7500               ;;
7501         esac
7502         for x in "$vdb_libpath" "lib${bit64_sfx:-32}" lib; do
7503            if test -n "$x" -a -d "$VDB_PATH/$x"; then
7504               : ${VDB_LIBDIR=$VDB_PATH/$x}
7505               break
7506            fi
7507         done
7508      fi
7509      NCBI_RPATHIFY_COND(VDB_LIBS, $VDB_LIBDIR, [ -lncbi-vdb $vdb_deps])
7510      CPPFLAGS="$orig_CPPFLAGS $VDB_INCLUDE"
7511      LIBS="$orig_LIBS $VDB_LIBS"
7512      AC_CACHE_CHECK([for ncbi-vdb$in_path], ncbi_cv_lib_ncbi_vdb,
7513         AC_LINK_IFELSE([
7514            AC_LANG_PROGRAM([@%:@include <sra/sradb.h>],
7515               [const SRAMgr* mgr; SRAMgrMakeRead(&mgr);])],
7516            [ncbi_cv_lib_ncbi_vdb=yes], [ncbi_cv_lib_ncbi_vdb=no]))
7517      if test "$ncbi_cv_lib_ncbi_vdb" = yes; then
7518         NCBI_PACKAGE(VDB)
7519         if test -f "$VDB_LIBDIR/libncbi-vdb-static.a"; then
7520            VDB_STATIC_LIBS="-L$VDB_LIBDIR -lncbi-vdb-static $vdb_static_deps"
7521            if test "$with_static_vdb" = yes; then
7522               VDB_LIBS="-L$VDB_LIBDIR -lncbi-vdb-static $vdb_deps"
7523            fi
7524         else
7525            VDB_STATIC_LIBS=$VDB_LIBS
7526         fi
7527         case "$host_os" in
7528            darwin*)
7529               inst_name=`otool -D $VDB_LIBDIR/libncbi-vdb.dylib 2>/dev/null \
7530                          | grep -v ':$'`
7531               case "$inst_name" in
7532                   @executable_path* )
7533                      major=`echo $inst_name | sed -ne 's,.*/libncbi-vdb\.\([[1-9]][[0-9]]*\).*\.dylib$,\1,p'`
7534                      test -z "$major"  || \
7535                         VDB_POST_LINK="install_name_tool -change $inst_name @rpath/libncbi-vdb.$major.dylib"
7536                      ;;
7537               esac
7538               ;;
7539         esac
7540         AC_DEFINE(HAVE_NCBI_VDB, 1,
7541            [Define to 1 if you have NCBI's SRA/VDB SDK/Toolkit.])
7542         bamread=bamread
7543         sraread=sraread
7544         ncbi_id2proc_snp=ncbi_id2proc_snp
7545         ncbi_id2proc_wgs=ncbi_id2proc_wgs
7546         ncbi_xloader_bam=ncbi_xloader_bam
7547         ncbi_xloader_csra=ncbi_xloader_csra
7548         ncbi_xloader_snp=ncbi_xloader_snp
7549         ncbi_xloader_sra=ncbi_xloader_sra
7550         ncbi_xloader_vdbgraph=ncbi_xloader_vdbgraph
7551         ncbi_xloader_wgs=ncbi_xloader_wgs
7552      else
7553         VDB_INCLUDE=
7554         VDB_LIBS=
7555         VDB_STATIC_LIBS=
7556         bamread=
7557         sraread=
7558         ncbi_id2proc_snp=
7559         ncbi_id2proc_wgs=
7560         ncbi_xloader_bam=
7561         ncbi_xloader_csra=
7562         ncbi_xloader_snp=
7563         ncbi_xloader_sra=
7564         ncbi_xloader_vdbgraph=
7565         ncbi_xloader_wgs=
7566      fi
7567   # else ...
7568   # fi
7569   if test -z "$VDB_LIBS"; then
7570      NCBI_MISSING_PACKAGE(vdb)
7571      NCBI_MISSING_PACKAGE(ngs)
7572   fi
7573else
7574   NCBI_MISSING_PACKAGE(ngs)
7575fi
7576
7577
7578### NCBI NGS SDK
7579if test "$with_ngs" != "no" ; then
7580   if test "${with_ngs:-yes}" != "yes" -a -d "$with_ngs"; then
7581      NGS_PATH=$with_ngs
7582   fi
7583   NGS_INCLUDE="-I$NGS_PATH/include"
7584   case "$host_cpu:$bit64_sfx" in
7585      *86*:64 ) extra_inc="-I$NGS_PATH/include/ngs/unix/x86_64" ;;
7586      *86*:*  ) extra_inc="-I$NGS_PATH/include/ngs/unix/fat86"  ;;
7587      *       ) extra_inc=''                                    ;;
7588   esac
7589   CPPFLAGS="$NGS_PATH/include $extra_inc $VDB_INCLUDE $orig_CPPFLAGS"
7590   for x in "$vdb_libpath" "lib${bit64_sfx:-32}" lib; do
7591      if test -n "$x" -a -d "$NGS_PATH/$x"; then
7592         : ${NGS_LIBDIR=$NGS_PATH/$x}
7593         break
7594      fi
7595   done
7596   NCBI_RPATHIFY(NGS_LIBPATH, [$NGS_LIBDIR])
7597   if test -n "$NGS_PATH"; then
7598      in_path=" in $NGS_PATH"
7599   else
7600      in_path=
7601   fi
7602   AC_CACHE_CHECK([for libncbi-ngs$in_path], ncbi_cv_lib_ncbi_ngs,
7603      AC_LINK_IFELSE([
7604         AC_LANG_PROGRAM([@%:@include <ngs/itf/PileupItf.h>],
7605            [struct NGS_Pileup_v1_vt * p1vt = &ITF_Pileup_vt;])],
7606         [ncbi_cv_lib_ncbi_ngs=yes], [ncbi_cv_lib_ncbi_ngs=no]))
7607   if test $ncbi_cv_lib_ncbi_ngs=yes; then
7608      NGS_C_LIBS=-lncbi-ngs
7609   fi
7610   NCBI_CHECK_THIRD_PARTY_LIB_EX(ngs, NGS, ncbi-ngs-c++,
7611      [AC_LANG_PROGRAM([[@%:@include <ncbi-vdb/NGS.hpp>
7612                          @%:@include <ngs-bam/ngs-bam.hpp>]],
7613           [[ncbi::NGS::setAppVersionString("conftest.0.0.0");
7614             ngs::ReadCollection coll
7615             = NGS_BAM::openReadCollection("foo.bam");]])],
7616      [-lngs-bam-c++ -lngs-adapt-c++ -lngs-c++ $NGS_C_LIBS], $VDB_LIBS,
7617      $extra_inc)
7618   if test -n "$NGS_LIBS"; then
7619      if test -f "$NGS_LIBDIR/libncbi-ngs-c++-static.a"; then
7620         NGS_STATIC_LIBS="-L$NGS_LIBDIR -lncbi-ngs-c++-static"
7621         NGS_STATIC_LIBS="$NGS_STATIC_LIBS -lngs-bam-c++-static"
7622         NGS_STATIC_LIBS="$NGS_STATIC_LIBS -lngs-adapt-c++-static"
7623         NGS_STATIC_LIBS="$NGS_STATIC_LIBS -lngs-c++-static"
7624         if test -n "$NGS_C_LIBS"; then
7625            NGS_STATIC_LIBS="$NGS_STATIC_LIBS $NGS_C_LIBS-static"
7626         fi
7627      else
7628         NGS_STATIC_LIBS=$NGS_LIBS
7629      fi
7630   else
7631      NCBI_MISSING_PACKAGE(ngs)
7632   fi
7633fi
7634
7635
7636### OEChem
7637# somewhat kludgish, as we now wanto to add in oeiupac and oedepict,
7638# which depend on oechem....
7639NCBI_CHECK_THIRD_PARTY_LIB(oechem,
7640 [AC_LANG_PROGRAM([@%:@include <oechem.h>],
7641    [OEChem::OEMol mol; OEChem::OEConfBase* c = mol.GetActive();])],
7642  -loeiupac -loedepict -loechem -loesystem -loeplatform -lz, $NETWORK_LIBS)
7643if test -n "$OECHEM_LIBS"; then
7644   OECHEM_LIBS=`echo $OECHEM_LIBS | sed -e 's/-loechem \(.*-loechem .*\)/\1/'`
7645fi
7646
7647
7648### Sun/Univa Grid Engine
7649case "$with_sge" in
7650   yes | "" ) ;;
7651   *        ) SGE_PATH=$with_sge ;;
7652esac
7653if test -d "$SGE_PATH" -a -z "$SGE_LIBPATH"; then
7654   case "$host:$NCBI_PLATFORM_BITS" in
7655      i?86-*-darwin*      ) SGE_PLATFORMS='darwin-x86'          ;;
7656      i?86-*-linux*       ) SGE_PLATFORMS='lx24-x86 lx-x86'     ;;
7657      i?86-*-solaris*:32  ) SGE_PLATFORMS='sol-x86'             ;;
7658      i?86-*-solaris*:64  ) SGE_PLATFORMS='sol-amd64'           ;;
7659      powerpc-*-darwin*   ) SGE_PLATFORMS='darwin-ppc'          ;;
7660      sparc-*-solaris*:32 ) SGE_PLATFORMS='sol-sparc'           ;;
7661      sparc-*-solaris*:64 ) SGE_PLATFORMS='sol-sparc64'         ;;
7662      x86_64-*-linux*     ) SGE_PLATFORMS='lx24-amd64 lx-amd64' ;;
7663   esac
7664   for x in $SGE_PLATFORMS; do
7665      if test -d "$SGE_PATH/lib/$x"; then
7666         SGE_LIBPATH="$SGE_PATH/lib/$x"
7667         break
7668      fi
7669   done
7670   BASE_SGE_LIBPATH=$SGE_LIBPATH
7671   NCBI_RPATHIFY(SGE_LIBPATH, $SGE_LIBPATH)
7672   # Try to use a dedicated directory without alternate versions of
7673   # system libraries such as OpenSSL.
7674   if test -d "$BASE_SGE_LIBPATH" -a -d "$SGE_PATH/lib/drmaa"; then
7675      SGE_LIBPATH=`echo $SGE_LIBPATH \
7676          | sed -e "s,-L$BASE_SGE_LIBPATH,-L$SGE_PATH/lib/drmaa,g"`
7677   fi
7678fi
7679NCBI_CHECK_THIRD_PARTY_LIB_EX(sge, SGE, drmaa,
7680  [AC_LANG_PROGRAM([[@%:@include <sys/types.h>
7681                     @%:@include <drmaa.h>]],
7682     [[char buf[1024]; drmaa_init("SGE", buf, sizeof(buf));]])])
7683
7684
7685### muParser
7686case "$with_muparser" in
7687   yes | '' ) ;;
7688   *        ) MUPARSER_PATH=$with_muparser ;;
7689esac
7690
7691if test -d "$MUPARSER_PATH"; then
7692   NCBI_FIX_DIR(MUPARSER_PATH)
7693fi
7694if test -d "$MUPARSER_PATH/${compiler_vpfx}${DEBUG_SFX}${bit64_sfx}/lib"; then
7695   MUPARSER_LIBPATH=-L$MUPARSER_PATH/${compiler_vpfx}${DEBUG_SFX}${bit64_sfx}/lib
7696elif test -d "$MUPARSER_PATH/${compiler_pfx}${DEBUG_SFX}${bit64_sfx}/lib"; then
7697   MUPARSER_LIBPATH=-L$MUPARSER_PATH/${compiler_pfx}${DEBUG_SFX}${bit64_sfx}/lib
7698fi
7699
7700NCBI_CHECK_THIRD_PARTY_LIB(muparser,
7701  [AC_LANG_PROGRAM([[@%:@include <muParser.h>]],
7702     [[mu::Parser parser;]])])
7703
7704
7705### hdf5
7706case "$with_hdf5" in
7707   yes | '' ) ;;
7708   *        ) HDF5_PATH=$with_hdf5 ;;
7709esac
7710
7711if test -d "$HDF5_PATH/${compiler_vpfx}${DEBUG_SFX}${bit64_sfx}"; then
7712   HDF5_PATH=$HDF5_PATH/${compiler_vpfx}${DEBUG_SFX}${bit64_sfx}
7713elif test -d "$HDF5_PATH/${compiler_pfx}${DEBUG_SFX}${bit64_sfx}"; then
7714   HDF5_PATH=$HDF5_PATH/${compiler_pfx}${DEBUG_SFX}${bit64_sfx}
7715fi
7716if test -d "$HDF5_PATH"; then
7717   NCBI_FIX_DIR(HDF5_PATH)
7718fi
7719
7720NCBI_CHECK_THIRD_PARTY_LIB_EX(hdf5, HDF5, hdf5_cpp,
7721  [AC_LANG_PROGRAM([[@%:@include <H5Cpp.h>]],
7722     [[H5::H5Library::open();]])],
7723  [-lhdf5])
7724
7725
7726### Image libraries
7727# : ${JPEG_PATH=/usr/sfw}
7728# Grr... jpeglib.h isn't especially well-behaved.
7729NCBI_CHECK_THIRD_PARTY_LIB(jpeg,
7730 [AC_LANG_PROGRAM([@%:@include <sys/types.h>
7731                   @%:@include <stdio.h>
7732                   extern "C" {
7733                   @%:@include <jpeglib.h>
7734                   }],
7735    [struct jpeg_decompress_struct cinfo;
7736     struct jpeg_error_mgr         jerr;
7737     cinfo.err = jpeg_std_error(&jerr);
7738 ])])
7739
7740# : ${PNG_PATH=/usr/sfw}
7741NCBI_CHECK_THIRD_PARTY_LIB(png,
7742 [AC_LANG_PROGRAM([@%:@include <png.h>],
7743    [png_structp png_ptr
7744      = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
7745 ])], $Z_LIBS, [], $Z_INCLUDE)
7746
7747# : ${TIFF_PATH=/usr/sfw}
7748NCBI_CHECK_THIRD_PARTY_LIB(tiff,
7749 [AC_LANG_PROGRAM([@%:@include <tiffio.h>],
7750    [TIFF* tiff = TIFFOpen("foo", "r");])], $Z_LIBS, $JPEG_LIBS)
7751## etc.
7752
7753# Paths?
7754with_ungif=$with_gif
7755NCBI_CHECK_THIRD_PARTY_LIB(gif,
7756 [AC_LANG_PROGRAM([extern "C" {
7757                  @%:@include <gif_lib.h>
7758                  }],
7759    [GifFileType* fp = DGifOpenFileName("foo");])], $X_LIBS -lX11)
7760if test "$with_gif" = "no"; then
7761   NCBI_CHECK_THIRD_PARTY_LIB(ungif,
7762    [AC_LANG_PROGRAM([extern "C" {
7763                     @%:@include <gif_lib.h>
7764                     }],
7765       [GifFileType* fp = DGifOpenFileName("foo");])], $X_LIBS -lX11)
7766else
7767   AC_DEFINE(HAVE_LIBUNGIF, 1, [Define to 1 if libungif is available.])
7768   UNGIF_INCLUDE=$GIF_INCLUDE
7769   UNGIF_LIBS=$GIF_LIBS
7770fi
7771
7772case "$x_libraries" in */*) : ${XPM_PATH=`dirname "$x_libraries"`} ;; esac
7773NCBI_CHECK_THIRD_PARTY_LIB(Xpm,
7774 [AC_LANG_PROGRAM([@%:@include <X11/xpm.h>],
7775    [XpmImage image; XpmInfo info;
7776     XpmReadFileToXpmImage("foo", &image, &info);])], $X_LIBS -lX11, [],
7777    $X_CFLAGS)
7778# The use of X_CFLAGS is probably redundant, but shouldn't hurt.
7779
7780if test "$with_gl2ps" != "no"; then
7781   if test "${with_gl2ps-yes}" != "yes"; then
7782      GL2PS_PATH=$with_gl2ps
7783   fi
7784   if test -d "$GL2PS_PATH"; then
7785      if test -d "$GL2PS_PATH/$compiler_vpfx$DEBUG_SFX$bit64_sfx"; then
7786         GL2PS_PATH=$GL2PS_PATH/$compiler_vpfx$DEBUG_SFX$bit64_sfx
7787      elif test -d "$GL2PS_PATH/$compiler_pfx$DEBUG_SFX$bit64_sfx"; then
7788         GL2PS_PATH=$GL2PS_PATH/$compiler_pfx$DEBUG_SFX$bit64_sfx
7789      elif test -d "$GL2PS_PATH/$DEBUG_SFX$bit64_sfx"; then
7790         GL2PS_PATH=$GL2PS_PATH/$DEBUG_SFX$bit64_sfx
7791      fi
7792      NCBI_FIX_DIR(GL2PS_PATH)
7793   fi
7794   NCBI_CHECK_THIRD_PARTY_LIB(gl2ps,
7795    [AC_LANG_PROGRAM([@%:@include <gl2ps.h>],
7796       [gl2psSpecial(GL2PS_SVG, "foo")])],
7797    [], [$OPENGL_LIBS $PNG_LIBS $Z_LIBS], [$OPENGL_INCLUDE])
7798fi
7799if test -n "$GL2PS_LIBS" -a -f "$GL2PS_PATH/lib/libgl2ps-static.a"; then
7800   GL2PS_STATIC_LIBS="-L$GL2PS_PATH/lib -lgl2ps-static"
7801else
7802   GL2PS_STATIC_LIBS=$GL2PS_LIBS
7803fi
7804
7805## FreeType and FTGL
7806if test "$with_freetype" != "no" ; then
7807   ft2pc="env PKG_CONFIG_PATH=$FREETYPE_PATH/lib/pkgconfig pkg-config freetype2"
7808   if $ft2pc --exists >/dev/null 2>&1; then
7809      freetype_config=$ft2pc
7810      FREETYPE_PATH=`$ft2pc --variable=exec_prefix`
7811   else
7812      : ${FREETYPE_BINPATH=$FREETYPE_PATH/bin}
7813      AC_PATH_PROG(freetype_config, freetype-config, [],
7814                   [$FREETYPE_BINPATH:$PATH])
7815   fi
7816   if test -n "$freetype_config" ; then
7817      : ${FREETYPE_INCLUDE=`$freetype_config --cflags`}
7818      NCBI_RPATHIFY_OUTPUT_COND(FREETYPE_LIBS, $freetype_config --libs,
7819         [$no_usr_lib])
7820      case "$host_os:$bit64_sfx" in
7821         solaris*:64 )
7822            ftprefix=`$freetype_config --exec-prefix`
7823            if test -d "$ftprefix/lib/64"; then
7824               FREETYPE_LIBS=`echo $FREETYPE_LIBS \
7825                   | sed -e "s,$ftprefix/lib ,$ftprefix/lib/64 ,g"`
7826            fi
7827            ;;
7828      esac
7829      AC_CACHE_CHECK([whether FREETYPE_INCLUDE needs doctoring],
7830                     ncbi_cv_lib_freetype_fix_include,
7831         [CPPFLAGS="$FREETYPE_INCLUDE $orig_CPPFLAGS"
7832          AC_COMPILE_IFELSE(
7833             [AC_LANG_PROGRAM(
7834                 [[@%:@include <ft2build.h>]], [])],
7835             [ncbi_cv_lib_freetype_fix_include=no],
7836             [ncbi_cv_lib_freetype_fix_include=yes])])
7837      if test "$ncbi_cv_lib_freetype_fix_include" = yes; then
7838         FREETYPE_INCLUDE=`echo "$FREETYPE_INCLUDE" |\
7839             sed -e 's:\(-I[[^ ]]*\)\(/freetype2\):\1 \1\2:g'`
7840      fi
7841      AC_CACHE_CHECK([whether FreeType works], ncbi_cv_lib_freetype,
7842         [CPPFLAGS="$FREETYPE_INCLUDE $orig_CPPFLAGS"
7843          LIBS="$FREETYPE_LIBS $orig_LIBS"
7844          AC_LINK_IFELSE(
7845             [AC_LANG_PROGRAM(
7846                 [[@%:@include <ft2build.h>
7847                   @%:@include FT_FREETYPE_H]],
7848                 [[FT_Select_Charmap(NULL, ft_encoding_unicode);]])],
7849             [ncbi_cv_lib_freetype=yes], [ncbi_cv_lib_freetype=no])])
7850      if test "$ncbi_cv_lib_freetype" = no; then
7851         NCBI_MISSING_PACKAGE(freetype)
7852      fi
7853   else
7854      NCBI_MISSING_PACKAGE(freetype)
7855   fi
7856fi
7857if test "$with_freetype" = "no" ; then
7858   FREETYPE_PATH="No_FREETYPE"
7859   FREETYPE_INCLUDE=
7860   FREETYPE_LIBS=
7861else
7862   NCBI_PACKAGE(FreeType)
7863   AC_DEFINE(HAVE_FREETYPE, 1, [Define to 1 if FreeType is available.])
7864fi
7865
7866case "$with_ftgl" in
7867   yes | '' ) ;;
7868   *        ) FTGL_PATH=$with_ftgl ;;
7869esac
7870
7871if test -d "$FTGL_PATH"; then
7872   NCBI_FIX_DIR(FTGL_PATH)
7873fi
7874if test -d "$FTGL_PATH/${compiler_vpfx}${DEBUG_SFX}${bit64_sfx}/lib"; then
7875   FTGL_LIBDIR=$FTGL_PATH/${compiler_vpfx}${DEBUG_SFX}${bit64_sfx}/lib
7876elif test -d "$FTGL_PATH/${compiler_pfx}${DEBUG_SFX}${bit64_sfx}/lib"; then
7877   FTGL_LIBDIR=$FTGL_PATH/${compiler_pfx}${DEBUG_SFX}${bit64_sfx}/lib
7878fi
7879NCBI_FIX_DIR(FTGL_LIBDIR)
7880NCBI_RPATHIFY(FTGL_LIBPATH, $FTGL_LIBDIR)
7881
7882NCBI_CHECK_THIRD_PARTY_LIB(ftgl,
7883  [AC_LANG_PROGRAM([[@%:@include <FTGL/ftgl.h>]], [[FTSimpleLayout layout;]])],
7884  [$FREETYPE_LIBS], [], [$FREETYPE_INCLUDE])
7885
7886
7887NCBI_CHECK_THIRD_PARTY_LIB(magic,
7888   [AC_LANG_PROGRAM([@%:@include <magic.h>],
7889       [magic_t m = magic_open(17);])])
7890
7891
7892# Mimetic
7893case "$with_mimetic" in
7894   yes | '' ) ;;
7895   *        ) MIMETIC_PATH=$with_mimetic ;;
7896esac
7897if test -d "$MIMETIC_PATH"; then
7898   NCBI_FIX_DIR(MIMETIC_PATH)
7899fi
7900for d in "$MIMETIC_LIBDIR" \
7901         "$MIMETIC_PATH/${compiler_vpfx}${DEBUG_SFX}${bit64_sfx}/lib" \
7902         "$MIMETIC_PATH/${compiler_pfx}${DEBUG_SFX}${bit64_sfx}/lib" \
7903         "$MIMETIC_PATH/lib${bit64_sfx}" \
7904         "$MIMETIC_PATH/${compiler_vpfx}${DEBUG_SFX}/lib" \
7905         "$MIMETIC_PATH/${compiler_pfx}${DEBUG_SFX}/lib" \
7906         "$MIMETIC_PATH/lib"; do
7907   if test -d "$d"; then
7908      MIMETIC_LIBDIR=$d
7909      break
7910   fi
7911done
7912NCBI_RPATHIFY(MIMETIC_LIBPATH, $MIMETIC_LIBDIR)
7913
7914NCBI_CHECK_THIRD_PARTY_LIB(mimetic,
7915   [AC_LANG_PROGRAM([@%:@include <mimetic/mimetic.h>],
7916       [mimetic::MimeEntity me;])])
7917
7918
7919# gSOAP++
7920case "$with_gsoap" in
7921   yes | '' ) ;;
7922   *        ) GSOAP_PATH=$with_gsoap ;;
7923esac
7924if test -d "$GSOAP_PATH"; then
7925   NCBI_FIX_DIR(GSOAP_PATH)
7926fi
7927for d in "$GSOAP_LIBDIR" \
7928         "$GSOAP_PATH/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}/lib" \
7929         "$GSOAP_PATH/${compiler_pfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}/lib" \
7930         "$GSOAP_PATH/lib${bit64_sfx}" \
7931         "$GSOAP_PATH/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}/lib" \
7932         "$GSOAP_PATH/${compiler_pfx}${DEBUG_SFX}${mt_sfx}/lib" \
7933         "$GSOAP_PATH/lib"; do
7934   if test -d "$d"; then
7935      GSOAP_LIBDIR=$d
7936      NCBI_FIX_DIR(GSOAP_LIBDIR)
7937      break
7938   fi
7939done
7940NCBI_RPATHIFY(GSOAP_LIBPATH, $GSOAP_LIBDIR)
7941
7942: ${GSOAP_BINDIR=`dirname "$GSOAP_LIBDIR"`/bin}
7943AC_PATH_PROG(GSOAP_SOAPCPP2, soapcpp2, [], $GSOAP_BINDIR:$PATH)
7944AC_PATH_PROG(GSOAP_WSDL2H,   wsdl2h,   [], $GSOAP_BINDIR:$PATH)
7945
7946NCBI_CHECK_THIRD_PARTY_LIB_EX(gsoap, GSOAP, gsoapssl++,
7947   [AC_LANG_PROGRAM([@%:@include <stdsoap2.h>
7948        SOAP_FMAC3 const char** SOAP_FMAC4 soap_faultcode(struct soap*)
7949        { return NULL; }
7950        SOAP_FMAC3 const char** SOAP_FMAC4 soap_faultsubcode(struct soap*)
7951        { return NULL; }
7952        SOAP_FMAC3 const char** SOAP_FMAC4 soap_faultstring(struct soap*)
7953        { return NULL; }
7954        SOAP_FMAC3 const char** SOAP_FMAC4 soap_faultdetail(struct soap*)
7955        { return NULL; }
7956        SOAP_FMAC3 const char* SOAP_FMAC4 soap_check_faultsubcode(struct soap*)
7957        { return NULL; }
7958        SOAP_FMAC3 const char* SOAP_FMAC4 soap_check_faultdetail(struct soap*)
7959        { return NULL; }
7960        SOAP_FMAC3 void SOAP_FMAC4 soap_serializeheader(struct soap*) { }
7961        SOAP_FMAC3 int SOAP_FMAC4 soap_putheader(struct soap*) { return 0; }
7962        SOAP_FMAC3 int SOAP_FMAC4 soap_getheader(struct soap*) { return 0; }
7963        SOAP_FMAC3 void SOAP_FMAC4 soap_serializefault(struct soap*) { }
7964        SOAP_FMAC3 int SOAP_FMAC4 soap_putfault(struct soap*) { return 0; }
7965        SOAP_FMAC3 int SOAP_FMAC4 soap_getfault(struct soap*) { return 0; }],
7966       [soap s;])],
7967   $OPENSSL_LIBS $Z_LIBS)
7968
7969
7970# Apache Avro
7971if test "$with_avro" != no; then
7972   case "$with_avro" in
7973      yes | '' ) ;;
7974      *        ) AVRO_PATH=$with_avro ;;
7975   esac
7976   for d in "$AVRO_PATH/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}" \
7977            "$AVRO_PATH/${compiler_pfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}" \
7978            "$AVRO_PATH/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}" \
7979            "$AVRO_PATH/${compiler_pfx}${DEBUG_SFX}${mt_sfx}"; do
7980      if test -d "$d"; then
7981         AVRO_PATH=$d
7982         break
7983      fi
7984   done
7985   if test -d "$AVRO_PATH"; then
7986      NCBI_FIX_DIR(AVRO_PATH)
7987   fi
7988fi
7989NCBI_CHECK_THIRD_PARTY_LIB_EX(avro, AVRO, avrocpp,
7990   [AC_LANG_PROGRAM([@%:@include <avro/Node.hh>],
7991      [avro::Name name("foo");])],
7992   [$BOOST_LIBPATH $BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS $BOOST_PROGRAM_OPTIONS_LIBS $BOOST_IOSTREAMS_LIBS $RT_LIBS $Z_LIBS $BZ2_LIBS],
7993   [],
7994   [$BOOST_INCLUDE])
7995if test -n "$AVRO_LIBS"; then
7996   if test -f "$AVRO_PATH/lib/libavrocpp_s.a"; then
7997      AVRO_STATIC_LIBS="$AVRO_LIBPATH -lavrocpp_s $BOOST_LIBPATH $BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS $BOOST_PROGRAM_OPTIONS_LIBS $BOOST_IOSTREAMS_LIBS $RT_LIBS $Z_LIBS $BZ2_LIBS"
7998   else
7999      AVRO_STATIC_LIBS=$AVRO_LIBS
8000   fi
8001   AC_PATH_PROG(AVROGENCPP, avrogencpp, [], [$AVRO_PATH/bin:$PATH])
8002fi
8003
8004
8005# USC Cereal (header-only)
8006case "$with_cereal" in
8007   yes | no | '' ) ;;
8008   *             ) CEREAL_PATH=$with_cereal ;;
8009esac
8010if test "$with_cereal" != no; then
8011   in_cereal=
8012   if test -d "$CEREAL_PATH"; then
8013      NCBI_FIX_DIR(CEREAL_PATH)
8014      in_cereal=" in $CEREAL_PATH"
8015   fi
8016   CEREAL_INCLUDE=-I$CEREAL_PATH/include
8017   AC_CACHE_CHECK([for USC Cereal$in_cereal], ncbi_cv_lib_cereal,
8018      [CPPFLAGS="$CEREAL_INCLUDE $orig_CPPFLAGS"
8019       AC_COMPILE_IFELSE(
8020          [AC_LANG_PROGRAM([[@%:@include <iostream>
8021                             @%:@include <cereal/archives/binary.hpp>]],
8022                           [[cereal::BinaryOutputArchive
8023                             archive(std::cout);]])],
8024          [ncbi_cv_lib_cereal=yes], [ncbi_cv_lib_cereal=no])])
8025    if test "$ncbi_cv_lib_cereal" = yes; then
8026       NCBI_PACKAGE(Cereal)
8027    else
8028       NCBI_MISSING_PACKAGE(cereal)
8029       CEREAL_INCLUDE=
8030    fi
8031fi
8032
8033
8034# SASL 2
8035NCBI_CHECK_THIRD_PARTY_LIB(sasl2,
8036 [AC_LANG_PROGRAM([[@%:@include <stdlib.h>
8037                    @%:@include <sasl/sasl.h>]],
8038   [[sasl_client_init(NULL);]])])
8039
8040
8041# legacy MongoDB
8042case "$with_mongodb" in
8043   yes | no | '' ) ;;
8044   *             ) MONGODB_PATH=$with_mongodb ;;
8045esac
8046if test -d "$MONGODB_PATH"; then
8047   NCBI_FIX_DIR(MONGODB_PATH)
8048fi
8049if test -d $MONGODB_PATH/lib${bit64_sfx}; then
8050   MONGODB_LIBDIR=$MONGODB_PATH/lib${bit64_sfx}
8051else
8052   MONGODB_LIBDIR=$MONGODB_PATH/lib
8053fi
8054# need Boost rpath
8055NCBI_RPATHIFY(MONGODB_LIBPATH, $MONGODB_LIBDIR)
8056NCBI_CHECK_THIRD_PARTY_LIB_EX(mongodb, MONGODB, mongoclient,
8057   [AC_LANG_PROGRAM([@%:@include <mongo/client/dbclient.h>],
8058      [std::vector<mongo::HostAndPort> v;
8059       mongo::DBClientReplicaSet client("foo", v);
8060       client.connect();])],
8061   [$BOOST_LIBPATH $boost_fs_lib $BOOST_REGEX_LIBS $BOOST_THREAD_LIBS $OPENSSL_LIBS $SASL2_LIBS], [],
8062   [$BOOST_INCLUDE])
8063# MongoDB's own library is normally static, but its supporting Boost
8064# libraries might not be by default.
8065if test -n "$MONGODB_LIBS"; then
8066   MONGODB_STATIC_LIBS="$MONGODB_LIBPATH -lmongoclient $BOOST_LIBPATH $boost_fs_static_lib $BOOST_REGEX_STATIC_LIBS $BOOST_THREAD_STATIC_LIBS $OPENSSL_LIBS $SASL2_LIBS"
8067else
8068   MONGODB_STATIC_LIBS=
8069fi
8070
8071
8072# MongoDB 3.x
8073if test "$with_mongodb3" != no; then
8074   case "$with_mongodb3" in
8075      yes | '' ) ;;
8076      *        ) MONGODB3_PATH=$with_mongodb3 ;;
8077   esac
8078   for d in "$MONGODB3_PATH/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}" \
8079            "$MONGODB3_PATH/${compiler_pfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}" \
8080            "$MONGODB3_PATH/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}" \
8081            "$MONGODB3_PATH/${compiler_pfx}${DEBUG_SFX}${mt_sfx}"; do
8082      if test -d "$d"; then
8083         MONGODB3_PATH=$d
8084         break
8085      fi
8086   done
8087   if test -d "$MONGODB3_PATH"; then
8088      NCBI_FIX_DIR(MONGODB3_PATH)
8089   fi
8090fi
8091if test -d $MONGODB3_PATH/lib${bit64_sfx}; then
8092   MONGODB3_LIBDIR=$MONGODB3_PATH/lib${bit64_sfx}
8093else
8094   MONGODB3_LIBDIR=$MONGODB3_PATH/lib
8095fi
8096m3pc="env PKG_CONFIG_PATH=$MONGODB3_LIBDIR/pkgconfig pkg-config libmongocxx"
8097if $m3pc --exists >/dev/null 2>&1; then
8098   MONGODB3_FULL_INCLUDE=`$m3pc --cflags`
8099   NCBI_RPATHIFY_OUTPUT(MONGODB3_FULL_LIBS, [$m3pc --libs --static],
8100      [$no_usr_lib])
8101fi
8102NCBI_CHECK_THIRD_PARTY_LIB_EX(mongodb3, MONGODB3, mongocxx,
8103   [AC_LANG_PROGRAM([@%:@include <mongocxx/client.hpp>],
8104      [mongocxx::client mongo_client;])],
8105   [], [$MONGODB3_FULL_LIBS],
8106   [$MONGODB3_FULL_INCLUDE $BOOST_INCLUDE])
8107if test -n "$MONGODB3_LIBS"; then
8108   MONGODB3_INCLUDE=$MONGODB3_FULL_INCLUDE
8109   MONGODB3_LIBS=$MONGODB3_FULL_LIBS
8110   if $m3pc-static --exists >/dev/null 2>&1; then
8111      MONGODB3_STATIC_LIBS=`$m3pc-static --libs --static`
8112   elif test -f $MONGODB3_LIBDIR/libmongocxx-static.a; then
8113      MONGODB3_STATIC_LIBS=`echo "$MONGODB3_LIBS" | \
8114        [sed -e 's/-lmongo[^ ]*/&-static/g; s/-lbson[^ ]*/&-static/g' \
8115             -e 's/\(-l[^ ]*-static[^ ]*\)-static/\1/g']`
8116   else
8117      MONGODB3_STATIC_LIBS=$MONGODB3_LIBS
8118   fi
8119fi
8120
8121
8122# LevelDB
8123if test "$with_leveldb" != no; then
8124   case "$with_leveldb" in
8125      yes | '' ) ;;
8126      *        ) LEVELDB_PATH=$with_leveldb ;;
8127   esac
8128   for d in "$LEVELDB_PATH/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}" \
8129            "$LEVELDB_PATH/${compiler_pfx}${DEBUG_SFX}${mt_sfx}${bit64_sfx}" \
8130            "$LEVELDB_PATH/${compiler_vpfx}${DEBUG_SFX}${mt_sfx}" \
8131            "$LEVELDB_PATH/${compiler_pfx}${DEBUG_SFX}${mt_sfx}"; do
8132      if test -d "$d"; then
8133         LEVELDB_PATH=$d
8134         break
8135      fi
8136   done
8137   if test -d "$LEVELDB_PATH"; then
8138      NCBI_FIX_DIR(LEVELDB_PATH)
8139   fi
8140fi
8141if test -d $LEVELDB_PATH/lib${bit64_sfx}; then
8142   LEVELDB_LIBDIR=$LEVELDB_PATH/lib${bit64_sfx}
8143else
8144   LEVELDB_LIBDIR=$LEVELDB_PATH/lib
8145fi
8146NCBI_CHECK_THIRD_PARTY_LIB(leveldb,
8147  [AC_LANG_PROGRAM([[@%:@include <leveldb/db.h>
8148                     using namespace leveldb;]],
8149     [[DB* db; Status status = DB::Open(Options(), "foo", &db);]])])
8150
8151
8152# Google Mock
8153case "$with_gmock" in
8154   yes | no | '' ) ;;
8155   *             ) GMOCK_PATH=$with_gmock ;;
8156esac
8157if test -d "$GMOCK_PATH"; then
8158   NCBI_FIX_DIR(GMOCK_PATH)
8159   for d in "$GMOCK_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$bit64_sfx/lib" \
8160            "$GMOCK_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$bit64_sfx/lib" \
8161            "$GMOCK_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx/lib" \
8162            "$GMOCK_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx/lib" \
8163            "$GMOCK_PATH/lib$bit64_sfx" "$GMOCK_PATH/lib"; do
8164      if test -d "$d"; then
8165         GMOCK_LIBDIR=$d
8166         NCBI_FIX_DIR(GMOCK_LIBDIR)
8167         break
8168      fi
8169   done
8170fi
8171NCBI_RPATHIFY(GMOCK_LIBPATH, $GMOCK_LIBDIR)
8172NCBI_CHECK_THIRD_PARTY_LIB(gmock,
8173   [AC_LANG_PROGRAM([@%:@include <gmock/gmock.h>],
8174      [int    my_argc;
8175       char** my_argv;
8176       testing::InitGoogleMock(&my_argc, my_argv);])],
8177   [-lgtest])
8178if test -n "$GMOCK_LIBS"; then
8179   if test -f "$GMOCK_LIBDIR/libgmock-static.a"; then
8180      GMOCK_STATIC_LIBS="-L$GMOCK_LIBDIR -lgmock-static -lgtest-static"
8181   else
8182      GMOCK_STATIC_LIBS=$GMOCK_LIBS
8183   fi
8184fi
8185
8186
8187# LAPACK
8188CPPFLAGS="-DHAVE_LAPACK_CONFIG_H $orig_CPPFLAGS"
8189case "$with_lapack" in
8190   yes | no | '' ) ;;
8191   *             ) LAPACK_PATH=$with_lapack ;;
8192esac
8193if test -d "$LAPACK_PATH"; then
8194   NCBI_FIX_DIR(LAPACK_PATH)
8195   CPPFLAGS="-I$LAPACK_PATH/include $CPPFLAGS"
8196fi
8197AC_LANG_PUSH(C)
8198AC_CHECK_HEADERS(lapacke.h lapacke/lapacke.h clapack.h Accelerate/Accelerate.h)
8199AC_LANG_POP(C)
8200if test "$ac_cv_header_clapack_h:$ac_cv_header_Accelerate_Accelerate_h" != no:no; then
8201   AC_CHECK_TYPES([__CLPK_integer], [], [],
8202      [[@%:@ifdef HAVE_CLAPACK_H
8203        @%:@  include <clapack.h>
8204        @%:@else
8205        @%:@  include <Accelerate/Accelerate.h>
8206        @%:@endif]])
8207fi
8208
8209NCBI_CHECK_THIRD_PARTY_LIB(lapack,
8210   [AC_LANG_PROGRAM([[extern "C" int dsyev_();]],
8211      [[return dsyev_();]])],
8212   [-lblas])
8213
8214# LMDB
8215NCBI_CHECK_THIRD_PARTY_LIB(lmdb,
8216   [AC_LANG_PROGRAM([[@%:@include <lmdb.h>]],
8217      [[MDB_env *env; return mdb_env_create(&env);]])],
8218   [$THREAD_LIBS])
8219if test -z "$LMDB_LIBS"; then
8220   lmdblocal=util/lmdb
8221   AC_MSG_NOTICE([using local LMDB copy in $lmdblocal])
8222   LMDB_PATH="<$lmdblocal>"
8223   LMDB_INCLUDE="-I\$(includedir)/$lmdblocal -I\$(includedir0)/$lmdblocal"
8224   # In MT builds, ORIG_LIBS already contains THREAD_LIBS.  However,
8225   # LMDB is always threaded, and may need explicit THREAD_LIBS when
8226   # used statically.
8227   LMDB_LIBS="$THREAD_LIBS"
8228   # LMDB_LIBS="-llmdb $THREAD_LIBS"
8229   LMDB_LIB="lmdb"
8230   AC_DEFINE(USE_LOCAL_LMDB, 1, [Define to 1 if using a local copy of LMDB.])
8231   NCBI_PACKAGE(LMDB)
8232   NCBI_PACKAGE(LocalLMDB)
8233fi
8234if test "$with_lmdb" != no -a -f "$LMDB_PATH/lib/liblmdb-static.a"; then
8235    LMDB_STATIC_LIBS="-L$LMDB_PATH/lib -llmdb-static"
8236    if test "x$with_bin_release" = "xyes"; then
8237       LMDB_LIBS=$LMDB_STATIC_LIBS
8238    fi
8239else
8240    LMDB_STATIC_LIBS=$LMDB_LIBS
8241fi
8242
8243# libuv
8244case "$with_libuv" in
8245   yes | no | '' ) ;;
8246   *             ) LIBUV_PATH=$with_libuv ;;
8247esac
8248if test -d "$LIBUV_PATH"; then
8249   NCBI_FIX_DIR(LIBUV_PATH)
8250   for d in "$LIBUV_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$bit64_sfx/lib" \
8251            "$LIBUV_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$bit64_sfx/lib" \
8252            "$LIBUV_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx/lib" \
8253            "$LIBUV_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx/lib" \
8254            "$LIBUV_PATH/lib$bit64_sfx" "$LIBUV_PATH/lib"; do
8255      if test -d "$d"; then
8256         LIBUV_LIBDIR=$d
8257         NCBI_FIX_DIR(LIBUV_LIBDIR)
8258         break
8259      fi
8260   done
8261fi
8262NCBI_RPATHIFY(LIBUV_LIBPATH, $LIBUV_LIBDIR)
8263NCBI_CHECK_THIRD_PARTY_LIB_EX(libuv, LIBUV, uv,
8264   [AC_LANG_PROGRAM([[@%:@include <uv.h>]],
8265      [[uv_mutex_t m; return uv_mutex_init(&m);]])])
8266if test "$with_libuv" != no -a -f "$LIBUV_LIBDIR/libuv-static.a"; then
8267    LIBUV_STATIC_LIBS="-L$LIBUV_LIBDIR -luv-static"
8268    if test "x$with_bin_release" = "xyes"; then
8269       LIBUV_LIBS=$LIBUV_STATIC_LIBS
8270    fi
8271else
8272    LIBUV_STATIC_LIBS=$LIBUV_LIBS
8273fi
8274
8275# libssh2
8276case "$with_libssh2" in
8277   yes | no | '' ) ;;
8278   *             ) LIBSSH2_PATH=$with_libssh2 ;;
8279esac
8280if test -d "$LIBSSH2_PATH"; then
8281   NCBI_FIX_DIR(LIBSSH2_PATH)
8282   for d in "$LIBSSH2_PATH/$compiler_vpfx$DEBUG_SFX$bit64_sfx/lib" \
8283            "$LIBSSH2_PATH/$compiler_pfx$DEBUG_SFX$bit64_sfx/lib" \
8284            "$LIBSSH2_PATH/$compiler_vpfx$DEBUG_SFX/lib" \
8285            "$LIBSSH2_PATH/$compiler_pfx$DEBUG_SFX/lib" \
8286            "$LIBSSH2_PATH/lib$bit64_sfx" "$LIBSSH2_PATH/lib"; do
8287      if test -d "$d"; then
8288         LIBSSH2_LIBDIR=$d
8289         NCBI_FIX_DIR(LIBSSH2_LIBDIR)
8290         break
8291      fi
8292   done
8293fi
8294NCBI_RPATHIFY(LIBSSH2_LIBPATH, $LIBSSH2_LIBDIR)
8295NCBI_CHECK_THIRD_PARTY_LIB_EX(libssh2, LIBSSH2, ssh2,
8296   [AC_LANG_PROGRAM([[@%:@include <libssh2.h>]],
8297      [[return libssh2_init(LIBSSH2_INIT_NO_CRYPTO);]])],
8298   [$OPENSSL_LIBS])
8299if test "$with_libssh2" != no -a -f "$LIBSSH2_LIBDIR/libssh2-static.a"; then
8300    LIBSSH2_STATIC_LIBS="-L$LIBSSH2_LIBDIR -lssh2-static $OPENSSL_LIBS"
8301else
8302    LIBSSH2_STATIC_LIBS=$LIBSSH2_LIBS
8303fi
8304
8305# Datastax Cassandra driver
8306case "$with_cassandra" in
8307   yes | no | '' ) ;;
8308   *             ) CASSANDRA_PATH=$with_cassandra ;;
8309esac
8310if test -d "$CASSANDRA_PATH"; then
8311   NCBI_FIX_DIR(CASSANDRA_PATH)
8312   for d in "$CASSANDRA_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8313            "$CASSANDRA_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8314            "$CASSANDRA_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx" \
8315            "$CASSANDRA_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx"; do
8316      if test -d "$d"; then
8317         CASSANDRA_PATH=$d
8318         NCBI_FIX_DIR(CASSANDRA_PATH)
8319         break
8320      fi
8321   done
8322fi
8323NCBI_CHECK_THIRD_PARTY_LIB(cassandra,
8324   [AC_LANG_PROGRAM([[@%:@include <cassandra.h>]],
8325      [[CassCluster* c = cass_cluster_new();]])],
8326   [$LIBSSH2_LIBS $LIBUV_LIBS])
8327if test "$with_cassandra" != no -a \
8328     -f "$CASSANDRA_PATH/lib/libcassandra_static.a"; then
8329    CASSANDRA_STATIC_LIBS="-L$CASSANDRA_PATH/lib -lcassandra_static $LIBSSH2_STATIC_LIBS $LIBUV_STATIC_LIBS"
8330else
8331    CASSANDRA_STATIC_LIBS=$CASSANDRA_LIBS
8332fi
8333
8334# HTTP/2 libraries
8335case "$with_nghttp2" in
8336   yes | no | '' ) ;;
8337   *             ) NGHTTP2_PATH=$with_nghttp2 ;;
8338esac
8339if test -d "$NGHTTP2_PATH"; then
8340   NCBI_FIX_DIR(NGHTTP2_PATH)
8341   for d in "$NGHTTP2_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8342            "$NGHTTP2_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8343            "$NGHTTP2_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx" \
8344            "$NGHTTP2_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx"; do
8345      if test -d "$d/lib"; then
8346         NGHTTP2_LIBDIR=$d/lib
8347         NCBI_FIX_DIR(NGHTTP2_LIBDIR)
8348         break
8349      fi
8350   done
8351fi
8352NCBI_RPATHIFY(NGHTTP2_LIBPATH, $NGHTTP2_LIBDIR)
8353NCBI_CHECK_THIRD_PARTY_LIB(nghttp2,
8354   [AC_LANG_PROGRAM([[@%:@include <nghttp2/nghttp2.h>]],
8355       [[nghttp2_error_callback cb;
8356         const char* s = nghttp2_http2_strerror(NGHTTP2_ERR_EOF);]])])
8357if test "$with_nghttp2" != no -a \
8358     -f "$NGHTTP2_LIBDIR/libnghttp2-static.a"; then
8359   NGHTTP2_STATIC_LIBS="-L$NGHTTP2_LIBDIR -lnghttp2-static"
8360   if test "x$with_bin_release" = "xyes"; then
8361      NGHTTP2_LIBS=$NGHTTP2_STATIC_LIBS
8362   fi
8363else
8364   NGHTTP2_STATIC_LIBS=$NGHTTP2_LIBS
8365fi
8366
8367case "$with_h2o" in
8368   yes | no | '' ) ;;
8369   *             ) H2O_PATH=$with_h2o ;;
8370esac
8371if test -d "$H2O_PATH"; then
8372   NCBI_FIX_DIR(H2O_PATH)
8373   for d in "$H2O_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8374            "$H2O_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8375            "$H2O_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx" \
8376            "$H2O_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx"; do
8377      if test -d "$d"; then
8378         H2O_PATH=$d
8379         NCBI_FIX_DIR(H2O_PATH)
8380         break
8381      fi
8382   done
8383fi
8384NCBI_CHECK_THIRD_PARTY_LIB(h2o,
8385   [AC_LANG_PROGRAM([[@%:@include <h2o.h>>]],
8386       [[h2o_init_request(NULL, NULL, NULL);]])],
8387   [$LIBUV_LIBS $OPENSSL_LIBS $Z_LIBS], [], [$LIBUV_INCLUDE])
8388if test "$with_h2o" != no -a \
8389     -f "$H2O_PATH/lib/libh2o-static.a"; then
8390    H2O_STATIC_LIBS="-L$H2O_PATH/lib -lh2o-static $LIBUV_STATIC_LIBS $OPENSSL_LIBS $Z_LIBS"
8391else
8392    H2O_STATIC_LIBS=$H2O_LIBS
8393fi
8394
8395case "$with_influxdb" in
8396   yes | '' ) ;;
8397   no       ) ncbi_cv_lib_influxdb=no ;;
8398   *        ) INFLUXDB_PATH=$with_influxdb ;;
8399esac
8400if test -d "$INFLUXDB_PATH"; then
8401   INFLUXDB_INCLUDE=-I$INFLUXDB_PATH/include
8402   in_path=" in $INFLUXDB_PATH"
8403else
8404   in_path=
8405fi
8406CPPFLAGS="$orig_CPPFLAGS $INFLUXDB_INCLUDE"
8407AC_CACHE_CHECK([for influxdb-cpp$in_path],
8408   ncbi_cv_lib_influxdb,
8409   [AC_COMPILE_IFELSE(
8410       [AC_LANG_PROGRAM([[@%:@include <influxdb.hpp>]],
8411           [[auto& b = influxdb_cpp::builder().meas("foo");]])],
8412       ncbi_cv_lib_influxdb=yes, ncbi_cv_lib_influxdb=no)])
8413if test $ncbi_cv_lib_influxdb = yes; then
8414   NCBI_PACKAGE(INFLUXDB)
8415else
8416   INFLUXDB_INCLUDE=
8417   NCBI_MISSING_PACKAGE(influxdb)
8418fi
8419
8420
8421NCBI_CHECK_THIRD_PARTY_LIB_EX(libxlsxwriter, LIBXLSXWRITER, xlsxwriter,
8422   [AC_LANG_PROGRAM([[@%:@include <xlsxwriter.h>]],
8423      [[lxw_workbook* wb = workbook_new("conftest.xlsx");]])],
8424   [], [$Z_LIBS])
8425if test "$with_libxlsxwriter" != no -a \
8426     -f "$LIBXLSXWRITER_PATH/lib/libxlsxwriter-static.a"; then
8427    LIBXLSXWRITER_STATIC_LIBS="-L$LIBXLSXWRITER_PATH/lib -lxlsxwriter-static"
8428else
8429    LIBXLSXWRITER_STATIC_LIBS=$LIBXLSXWRITER_LIBS
8430fi
8431
8432case "$with_grpc" in
8433   yes | no | '' ) ;;
8434   *             ) GRPC_PATH=$with_grpc ;;
8435esac
8436if test -d "$GRPC_PATH"; then
8437   NCBI_FIX_DIR(GRPC_PATH)
8438   for d in "$GRPC_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$bit64_sfx$asan_sfx" \
8439            "$GRPC_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$bit64_sfx$asan_sfx" \
8440            "$GRPC_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$asan_sfx" \
8441            "$GRPC_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$asan_sfx" \
8442            "$GRPC_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8443            "$GRPC_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8444            "$GRPC_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx" \
8445            "$GRPC_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx"; do
8446      if test -d "$d"; then
8447         GRPC_PATH=$d
8448         NCBI_FIX_DIR(GRPC_PATH)
8449         break
8450      fi
8451   done
8452fi
8453
8454: ${PROTOBUF_PATH=$GRPC_PATH}
8455
8456PROTOBUF_SFX=
8457if test -n "$D_SFX"; then
8458   if ls $PROTOBUF_PATH/lib*/libprotobuf$D_SFX.* >/dev/null 2>&1; then
8459      PROTOBUF_SFX=$D_SFX
8460   else
8461      for ext in .a .so .dylib; do
8462         path=`$CXX -B$PROTOBUF_PATH/ -print-file-name=libprotobuf$D_SFX.$ext \
8463               2>/dev/null`
8464         case "$path" in
8465            */* ) PROTOBUF_SFX=$D_SFX; break ;;
8466         esac
8467      done
8468   fi
8469fi
8470NCBI_CHECK_THIRD_PARTY_LIB_EX(protobuf, PROTOBUF, [protobuf$PROTOBUF_SFX],
8471   [AC_LANG_PROGRAM([[@%:@include <google/protobuf/type.pb.h>]],
8472       [[google::protobuf::Type t;]])],
8473   [], [$Z_LIBS])
8474if test -n "$PROTOBUF_LIBS"; then
8475   AC_PATH_PROG(PROTOC, protoc, [], [$PROTOBUF_PATH/bin:$PATH])
8476   if test ! -x "$PROTOC"; then
8477      NCBI_MISSING_PACKAGE(grpc)
8478      NCBI_MISSING_PACKAGE(protobuf)
8479   fi
8480   PROTOBUF_BIN=`dirname $PROTOC`
8481else
8482   NCBI_MISSING_PACKAGE(grpc)
8483fi
8484
8485grpc_pc=pkg-config
8486if test -n "$GRPC_PATH"; then
8487   for d in "$GRPC_PATH/lib$bit64_sfx" "$GRPC_PATH/lib"; do
8488      if test -d "$d/pkgconfig"; then
8489         grpc_pc="env PKG_CONFIG_PATH=$d/pkgconfig pkg-config"
8490         break
8491      fi
8492   done
8493fi
8494if $grpc_pc grpc++ --exists 2>/dev/null; then
8495   GRPC_SED=sed
8496   if test -f "$GRPC_PATH/lib/libboringssl.a"; then
8497      GRPC_SED="sed -e s/-lssl/-lboringssl/g -e s/-lcrypto/-lboringcrypto/g"
8498   fi
8499   if test -f /usr/lib/libssl.dylib -a \
8500             x"`$grpc_pc grpc++ --variable=prefix`" != x/sw; then
8501      GRPC_SED="$GRPC_SED -e s,-L/sw/lib,,"
8502   fi
8503   if test "$GRPC_SED" = sed; then
8504      GRPC_SED=cat
8505   fi
8506   GRPC_CONFIG_LIBS="`$grpc_pc grpc++ grpc --libs | $GRPC_SED`"
8507else
8508   GRPC_CONFIG_LIBS=
8509   if test -n "$GRPC_PATH"; then
8510      in_path=" in $GRPC_PATH"
8511      CPPFLAGS="-I$GRPC_PATH/include $orig_CPPFLAGS"
8512      LIBS="$PROTOBUF_LIBPATH -L$GRPC_PATH/lib$bit64_sfx -L$GRPC_PATH/lib -lcares"
8513      LIBS="$LIBS $orig_LIBS"
8514   else
8515      LIBS="-lcares $orig_LIBS"
8516   fi
8517   AC_MSG_CHECKING([for libcares$in_path])
8518   AC_LINK_IFELSE(
8519      [AC_LANG_PROGRAM([@%:@include <ares.h>], [ares_library_init(0);])],
8520      [CARES_LIBS=-lcares; AC_MSG_RESULT([yes])],
8521      [CARES_LIBS=; AC_MSG_RESULT([no])])
8522
8523   if test -f "$GRPC_PATH/lib/libboringssl.a"; then
8524      GRPC_LDEP="-lboringssl -lboringcrypto"
8525   else
8526      GRPC_LDEP=$OPENSSL_LIBS
8527   fi
8528fi
8529# In MT builds, ORIG_LIBS already contains THREAD_LIBS.  However,
8530# GRPC is always threaded, and may need explicit THREAD_LIBS when
8531# used statically.
8532if test "$with_mt" = no; then
8533   GRPC_LDEP="$GRPC_LDEP $THREAD_LIBS"
8534fi
8535
8536NCBI_CHECK_THIRD_PARTY_LIB_EX(grpc, GRPC, grpc++,
8537   [AC_LANG_PROGRAM([[@%:@include <grpc++/grpc++.h>]],
8538       [[return grpc::Version().size();]])],
8539   [${GRPC_CONFIG_LIBS--lgrpc -lgpr $CARES_LIBS $GRPC_LDEP}],
8540   [$PROTOBUF_LIBS $Z_LIBS], [$PROTOBUF_INCLUDE])
8541if test -n "$GRPC_LIBS"; then
8542   if test -n "$GRPC_CONFIG_LIBS"; then
8543      GRPC_LIBS="$GRPC_CONFIG_LIBS $PROTOBUF_LIBS $GRPC_LDEP"
8544      GRPC_UNSECURE_LIBS="`$grpc_pc grpc++_unsecure grpc_unsecure --libs`"
8545      for x in address_sorting upb cares; do
8546         case " $GRPC_LIBS ::: $GRPC_UNSECURE_LIBS " in
8547            *:::*" -l$x "* ) ;;
8548            *" -l$x "* ) GRPC_UNSECURE_LIBS="$GRPC_UNSECURE_LIBS -l$x" ;;
8549         esac
8550      done
8551      GRPC_UNSECURE_LIBS="$GRPC_UNSECURE_LIBS $PROTOBUF_LIBS $GRPC_LDEP"
8552   else
8553      LDFLAGS="$orig_LDFLAGS $GRPC_LIBPATH"
8554      AC_CHECK_LIB(address_sorting, address_sorting_rfc_6724_sort,
8555         [GRPC_LIBS="$GRPC_LIBS -laddress_sorting"], [])
8556      LDFLAGS=$orig_LDFLAGS
8557      GRPC_UNSECURE_LIBS=`echo $GRPC_LIBS \
8558         | sed -e 's/\(-lgrpc+*\)/\1_unsecure/g'`
8559      GRPC_LIBS="$GRPC_LIBS $GRPC_LDEP"
8560   fi
8561   GRPC_REFLECTION_LIBS="$WHOLE_ARCHIVE $NO_AS_NEEDED $GRPC_LIBPATH"
8562   GRPC_REFLECTION_LIBS="$GRPC_REFLECTION_LIBS -lgrpc++_reflection"
8563   GRPC_REFLECTION_LIBS="$GRPC_REFLECTION_LIBS $NO_WHOLE_ARCHIVE $AS_NEEDED"
8564   AC_PATH_PROG(GRPC_CPP_PLUGIN, grpc_cpp_plugin, [],
8565      [$GRPC_PATH/bin:$PROTOBUF_PATH/bin:$PATH])
8566   if test ! -x "$GRPC_CPP_PLUGIN"; then
8567      NCBI_MISSING_PACKAGE(grpc)
8568   fi
8569   GRPC_BIN=`dirname $GRPC_CPP_PLUGIN`
8570fi
8571
8572case "$with_msgsl" in
8573   yes | '' ) ;;
8574   no       ) ncbi_cv_lib_msgsl=no ;;
8575   *        ) MSGSL_PATH=$with_msgsl ;;
8576esac
8577if test -d "$MSGSL_PATH"; then
8578   MSGSL_INCLUDE=-I$MSGSL_PATH/include
8579   in_path=" in $MSGSL_PATH"
8580else
8581   in_path=
8582fi
8583CPPFLAGS="$orig_CPPFLAGS $MSGSL_INCLUDE"
8584AC_CHECK_HEADERS([gsl/gsl], [NCBI_PACKAGE(MSGSL)],
8585   [MSGSL_INCLUDE=; NCBI_MISSING_PACKAGE(msgsl)])
8586
8587case "$with_aws_sdk" in
8588   yes | no | '' ) ;;
8589   *             ) AWS_SDK_PATH=$with_aws_sdk ;;
8590esac
8591if test -d "$AWS_SDK_PATH"; then
8592   NCBI_FIX_DIR(AWS_SDK_PATH)
8593   for d in "$AWS_SDK_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8594            "$AWS_SDK_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8595            "$AWS_SDK_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx" \
8596            "$AWS_SDK_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx"; do
8597      if test -d "$d"; then
8598         AWS_SDK_PATH=$d
8599         NCBI_FIX_DIR(AWS_SDK_PATH)
8600         break
8601      fi
8602   done
8603fi
8604AWS_SDK_LDEP=
8605AWS_SDK_STATIC_LDEP=
8606for d in "$AWS_SDK_PATH/lib$bit64_sfx" "$AWS_SDK_PATH/lib" \
8607         /usr/lib/$multiarch /usr/lib$bit64_sfx /usr/lib \
8608         /usr/local/lib$bit64_sfx /usr/local/lib; do
8609    if test -f "$d/libaws-cpp-sdk-s3.a"; then
8610       AWS_SDK_LIBDIR=$d
8611       if test -f "$AWS_SDK_LIBDIR/libaws-c-event-stream.a"; then
8612          AWS_SDK_LDEP="-laws-c-event-stream -laws-checksums -laws-c-common"
8613          AWS_SDK_STATIC_LDEP="-laws-c-event-stream-static -laws-checksums-static -laws-c-common-static"
8614       fi
8615       break
8616    fi
8617done
8618NCBI_CHECK_THIRD_PARTY_LIB_EX(aws_sdk, AWS_SDK, aws-cpp-sdk-s3,
8619   [AC_LANG_PROGRAM([[@%:@include <aws/s3/S3Client.h>
8620                      @%:@include <aws/ec2/EC2Client.h>]],
8621       [[Aws::S3::S3Client s3cli;
8622         Aws::EC2::EC2Client ec2cli;]])],
8623   [-laws-cpp-sdk-ec2 -laws-cpp-sdk-core $AWS_SDK_LDEP],
8624   [$CURL_LIBS $OPENSSL_LIBS $Z_LIBS])
8625if test "$with_aws_sdk" != no -a \
8626     -f "$AWS_SDK_LIBDIR/libaws-cpp-sdk-s3-static.a"; then
8627    AWS_SDK_STATIC_LIBS="-L$AWS_SDK_LIBDIR -laws-cpp-sdk-s3-static -laws-cpp-sdk-ec2-static -laws-cpp-sdk-core-static $AWS_SDK_STATIC_LDEP"
8628else
8629    AWS_SDK_STATIC_LIBS=$AWS_SDK_LIBS
8630fi
8631
8632NCBI_CHECK_THIRD_PARTY_LIB(hiredis,
8633   [AC_LANG_PROGRAM([[@%:@include <hiredis/hiredis.h>]],
8634       [[redisReader* r = redisReaderCreate();]])])
8635if test "$with_hiredis" != no \
8636      -a -f "$HIREDIS_PATH/lib/libhiredis-static.a"; then
8637    HIREDIS_STATIC_LIBS="-L$HIREDIS_PATH/lib -lhiredis-static"
8638else
8639    HIREDIS_STATIC_LIBS=$HIREDIS_LIBS
8640fi
8641
8642case "$with_apache_arrow" in
8643   yes | no | '' ) ;;
8644   *             ) APACHE_ARROW_PATH=$with_apache_arrow ;;
8645esac
8646if test -d "$APACHE_ARROW_PATH"; then
8647   NCBI_FIX_DIR(APACHE_ARROW_PATH)
8648   for d in "$APACHE_ARROW_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$bit64_sfx$asan_sfx" \
8649            "$APACHE_ARROW_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$bit64_sfx$asan_sfx" \
8650            "$APACHE_ARROW_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$asan_sfx" \
8651            "$APACHE_ARROW_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$asan_sfx" \
8652            "$APACHE_ARROW_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8653            "$APACHE_ARROW_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8654            "$APACHE_ARROW_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx" \
8655            "$APACHE_ARROW_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx"; do
8656      if test -d "$d"; then
8657         APACHE_ARROW_PATH=$d
8658         NCBI_FIX_DIR(APACHE_ARROW_PATH)
8659         break
8660      fi
8661   done
8662fi
8663
8664NCBI_CHECK_THIRD_PARTY_LIB_EX(apache_arrow, APACHE_ARROW, parquet,
8665  [AC_LANG_PROGRAM([[@%:@include <parquet/api/reader.h>]],
8666     [[parquet::ParquetFileReader pfr;]])],
8667  [-larrow])
8668if test "$with_apache_arrow" != no -a \
8669     -f "$APACHE_ARROW_LIBDIR/libparquet-static.a"; then
8670    APACHE_ARROW_STATIC_LIBS="-L$APACHE_ARROW_LIBDIR -lparquet-static -larrow-static -larrow_bundled_dependencies-static $BZ2_LIBS $Z_LIBS -lzstd"
8671else
8672    APACHE_ARROW_STATIC_LIBS=$APACHE_ARROW_LIBS
8673fi
8674
8675case "$with_librdkafka" in
8676   yes | no | '' ) ;;
8677   *             ) LIBRDKAFKA_PATH=$with_librdkafka ;;
8678esac
8679if test -d "$LIBRDKAFKA_PATH"; then
8680   NCBI_FIX_DIR(LIBRDKAFKA_PATH)
8681   for d in "$LIBRDKAFKA_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8682            "$LIBRDKAFKA_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8683            "$LIBRDKAFKA_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx" \
8684            "$LIBRDKAFKA_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx"; do
8685      if test -d "$d"; then
8686         LIBRDKAFKA_PATH=$d
8687         NCBI_FIX_DIR(LIBRDKAFKA_PATH)
8688         break
8689      fi
8690   done
8691fi
8692
8693NCBI_CHECK_THIRD_PARTY_LIB_EX(librdkafka, LIBRDKAFKA, rdkafka,
8694  [AC_LANG_PROGRAM([[@%:@include <librdkafka/rdkafka.h>]],
8695      [[rd_kafka_conf_t *conf = rd_kafka_conf_new();]])])
8696if test "$with_librdkafka" != no -a \
8697     -f "$LIBRDKAFKA_PATH/lib$bit64_sfx/librdkafka-static.a"; then
8698   LIBRDKAFKA_STATIC_LIBS="-L$LIBRDKAFKA_PATH/lib$bit64_sfx -lrdkafka-static"
8699else
8700   LIBRDKAFKA_STATIC_LIBS=$LIBRDKAFKA_LIBS
8701fi
8702
8703case "$with_cppkafka" in
8704   yes | no | '' ) ;;
8705   *             ) CPPKAFKA_PATH=$with_cppkafka ;;
8706esac
8707if test -d "$CPPKAFKA_PATH"; then
8708   NCBI_FIX_DIR(CPPKAFKA_PATH)
8709   for d in "$CPPKAFKA_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8710            "$CPPKAFKA_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx$bit64_sfx" \
8711            "$CPPKAFKA_PATH/$compiler_vpfx$DEBUG_SFX$mt_sfx" \
8712            "$CPPKAFKA_PATH/$compiler_pfx$DEBUG_SFX$mt_sfx"; do
8713      if test -d "$d"; then
8714         CPPKAFKA_PATH=$d
8715         NCBI_FIX_DIR(CPPKAFKA_PATH)
8716         break
8717      fi
8718   done
8719fi
8720
8721NCBI_CHECK_THIRD_PARTY_LIB(cppkafka,
8722  [AC_LANG_PROGRAM([[@%:@include <cppkafka/configuration.h>]],
8723      [[cppkafka::Configuration cfg; cfg.set("foo", "bar");]])],
8724  [$LIBRDKAFKA_LIBS], [], [$LIBRDKAFKA_INCLUDE])
8725if test "$with_cppkafka" != no -a \
8726     -f "$CPPKAFKA_PATH/lib$bit64_sfx/libcppkafka-static.a"; then
8727   CPPKAFKA_STATIC_LIBS="-L$CPPKAFKA_PATH/lib$bit64_sfx -lcppkafka-static $LIBRDKAFKA_STATIC_LIBS"
8728else
8729   CPPKAFKA_STATIC_LIBS=$CPPKAFKA_LIBS
8730fi
8731
8732### Restore original compiler/linker flags
8733LIBS="$orig_LIBS"
8734CPPFLAGS="$orig_CPPFLAGS"
8735
8736
8737### Optional projects
8738### --------------------------------------------
8739
8740
8741## `local_lbsm' support
8742
8743local_lbsm="ncbi_lbsm ncbi_lbsm_ipc ncbi_lbsmd"
8744
8745## requires semaphores (lacking on older versions of Cygwin and Darwin)
8746if test $ncbi_cv_sys_semaphores = no; then
8747    NCBI_MISSING_PACKAGE(local-lbsm)
8748fi
8749## disable by default even on newer Cygwin, as its semaphores don't
8750## actually work very well
8751test $OSTYPE = cygwin  &&  : ${with_local_lbsm=no}
8752
8753for fff in $local_lbsm ; do
8754   if test ! -f ${real_srcdir}/src/connect/${fff}.c ; then
8755      if test "$with_local_lbsm" = "yes" ; then
8756         AC_MSG_ERROR([--with-local-lbsm:  src/connect/${fff}.c is  missing])
8757      fi
8758      with_local_lbsm="no"
8759      break
8760   fi
8761done
8762
8763if test "$with_local_lbsm" = "no" ; then
8764   local_lbsm="ncbi_lbsmd_stub"
8765else
8766   NCBI_PROJECT(local_lbsm)
8767   AC_DEFINE(HAVE_LOCAL_LBSM, 1,
8768             [Define to 1 if local LBSM support is available.])
8769fi
8770
8771
8772## `connext' support
8773
8774connext="ncbi_dblb ncbi_ifconf ncbi_localnet"
8775
8776for fff in $connext ; do
8777   if test ! -f ${real_srcdir}/src/connect/ext/${fff}.c ; then
8778      if test "$with_connext" = "yes" ; then
8779         AC_MSG_ERROR([--with-connext:  src/connect/ext/${fff}.c is missing])
8780      fi
8781      with_connext="no"
8782      break
8783   fi
8784done
8785
8786if test "$with_connext" = "no"; then
8787   if test "$with_ncbi_crypt" = "yes" ; then
8788      AC_MSG_ERROR([--with-ncbi-crypt specified, but CONNECT extensions are unavailable])
8789   fi
8790   with_ncbi_crypt=no
8791fi
8792
8793if test "$with_connext" = "no" ; then
8794   CONNEXT=
8795   XCONNEXT=
8796else
8797   NCBI_PROJECT(connext)
8798   CONNEXT=connext
8799   XCONNEXT=xconnext
8800   AC_DEFINE(HAVE_LIBCONNEXT, 1,
8801      [Define to 1 if non-public CONNECT extensions are available.])
8802fi
8803
8804
8805## `ncbi_crypt' support
8806
8807ncbi_crypt="ncbi_crypt"
8808
8809for fff in $ncbi_crypt ; do
8810   if test ! -f ${real_srcdir}/src/connect/ext/${fff}.c ; then
8811      if test "$with_ncbi_crypt" = "yes" ; then
8812         AC_MSG_ERROR([--with-ncbi-crypt:  src/connect/ext/${fff}.c is missing])
8813      fi
8814      with_ncbi_crypt="no"
8815      break
8816   fi
8817done
8818
8819if test "$with_ncbi_crypt" = "no" ; then
8820   ncbi_crypt="ncbi_crypt_stub"
8821else
8822   NCBI_PROJECT(ncbi_crypt)
8823   AC_DEFINE(HAVE_NCBI_CRYPT, 1,
8824      [Define to 1 if the real version of ncbi_crypt support is available.])
8825fi
8826
8827
8828## direct PubSeqOS data loaders
8829
8830if test "$with_dbapi" != no -a \
8831   -f ${real_srcdir}/src/objtools/data_loaders/genbank/pubseq/Makefile.ncbi_xreader_pubseqos.lib ; then
8832   AC_DEFINE(HAVE_PUBSEQ_OS, 1,
8833      [Define to 1 if the PUBSEQ service is available.])
8834   NCBI_FEATURE(PubSeqOS)
8835   ncbi_xreader_pubseqos=ncbi_xreader_pubseqos
8836   ncbi_xreader_pubseqos2=ncbi_xreader_pubseqos2
8837   UNLESS_PUBSEQOS=\#
8838else
8839   ncbi_xreader_pubseqos=
8840   ncbi_xreader_pubseqos2=
8841   UNLESS_PUBSEQOS=
8842fi
8843
8844
8845## `serial' projects
8846
8847if test "$with_serial" = "no" ; then
8848   serial=
8849else
8850   NCBI_PROJECT(serial)
8851   serial="serial"
8852fi
8853
8854
8855## `objects' projects
8856
8857if test "$with_objects" = "no"  -o  -z "$serial" ; then
8858   objects=
8859else
8860   NCBI_PROJECT(objects)
8861   objects="objects"
8862fi
8863
8864
8865## `bdb' projects
8866
8867dnl NCBI_CHECK_SUBTREE(bdb)
8868if test "$with_bdb" = "no" ; then
8869   NoConfProjects="$NoConfProjects bdb"
8870fi
8871
8872if test ! -f ${real_srcdir}/src/db/bdb/Makefile.in  -o  \
8873        ! -d ${real_srcdir}/include/db/bdb ; then
8874   if test "${with_bdb-no}" != "no" ; then
8875      AC_MSG_ERROR([--with-]bdb[:  ]BDB[ sources are missing])
8876   fi
8877   with_bdb="no"
8878fi
8879
8880
8881if test "$with_bdb" = "no" ; then
8882   bdb=
8883   BDB_LIB=
8884   BDB_CACHE_LIB=
8885else
8886   NCBI_PROJECT(bdb)
8887   bdb="bdb"
8888   BDB_LIB="bdb"
8889   AC_DEFINE(HAVE_BDB, 1,
8890             [Define to 1 if NCBI C++ API for BerkeleyDB is available.])
8891   bdb_cache="ncbi_xcache_bdb"
8892   BDB_CACHE_LIB="ncbi_xcache_bdb"
8893   AC_DEFINE(HAVE_BDB_CACHE, 1,
8894             [Define to 1 if NCBI C++ API for BerkeleyDB based data cache is available.])
8895fi
8896
8897
8898## `dbapi' projects
8899
8900DBAPI_DRIVER=
8901DBAPI_CTLIB=
8902DBAPI_FTDS=
8903DBAPI_FTDS95=
8904DBAPI_FTDS100=
8905DBAPI_MYSQL=
8906DBAPI_ODBC=
8907if test "$with_dbapi" = "no" ; then
8908   dbapi=
8909else
8910   NCBI_PROJECT(dbapi)
8911   dbapi="dbapi"
8912   DBAPI_DRIVER=dbapi_driver
8913   DBAPI_FTDS=ncbi_xdbapi_ftds
8914   DBAPI_FTDS95=ncbi_xdbapi_ftds95
8915   DBAPI_FTDS100=ncbi_xdbapi_ftds100
8916   test -n "$SYBASE_LIBS"    &&  DBAPI_CTLIB=ncbi_xdbapi_ctlib
8917   test -n "$MYSQL_LIBS"     &&  DBAPI_MYSQL=ncbi_xdbapi_mysql
8918   test -n "$ODBC_LIBS"      &&  DBAPI_ODBC=ncbi_xdbapi_odbc
8919fi
8920
8921
8922## `app' projects
8923
8924if test "$with_app" = "no" ; then
8925   app=
8926else
8927   NCBI_PROJECT(app)
8928   app="app"
8929fi
8930
8931
8932## `ctools' project cluster
8933
8934if test "$with_ctools" != "no" ; then
8935   NCBI_PROJECT(ctools)
8936fi
8937
8938
8939## `gui' projects
8940
8941if test "$with_gui" = "no" ; then
8942   gui=
8943else
8944   NCBI_PROJECT(gui)
8945   gui="gui"
8946fi
8947
8948
8949## `algo' projects
8950
8951if test "$with_algo" = "no" -o -z "$objects" ; then
8952   algo=
8953else
8954   NCBI_PROJECT(algo)
8955   algo="algo"
8956fi
8957
8958
8959## `internal' project cluster
8960
8961if test "$with_internal" = "no"  \
8962    -o  ! -f "${real_srcdir}/src/internal/Makefile.in"; then
8963   NoConfProjects="$NoConfProjects internal"
8964   internal=
8965else
8966   reason=""
8967   sep=
8968   if test ! -d "${real_srcdir}/include/internal"; then
8969     reason="$reason${sep}headers"
8970     sep=", "
8971   fi
8972   if test "$with_sybase" = "no"; then
8973     reason="$reason${sep}Sybase"
8974     sep=", "
8975   fi
8976   if test "$with_ncbi_c" = "no"; then
8977     reason="$reason${sep}C-Toolkit"
8978     sep=", "
8979   fi
8980   if test "$with_sss" = "no"; then
8981     reason="$reason${sep}SSS"
8982     sep=", "
8983   fi
8984   if test -n "$reason" -a "$with_internal" = "yes"; then
8985      if test -z "$with_projects"; then
8986         AC_MSG_ERROR([--with-internal:  Cannot build INTERNAL projects: missing $reason])
8987      else
8988         AC_MSG_WARN([--with-internal:  Cannot build some INTERNAL projects: missing $reason])
8989         OPT_GROUPS="$OPT_GROUPS internal"
8990         internal="internal"
8991      fi
8992   elif test -n "$reason" -a -z "$with_projects"; then
8993      NoConfProjects="$NoConfProjects internal"
8994      internal=
8995   else
8996      OPT_GROUPS="$OPT_GROUPS internal"
8997      internal="internal"
8998   fi
8999fi
9000
9001## Genome Workbench
9002
9003if test "$with_gbench" != "no"  -a  -d "$real_srcdir/src/app/gbench"; then
9004   reason=""
9005   sep=
9006   if test "$with_wxwidgets" = "no"; then
9007     reason="$reason${sep}wxWidgets"
9008     sep=", "
9009   fi
9010   if test ! -d "$real_srcdir/src/gui/packages"; then
9011     reason="$reason${sep}internal packages"
9012     sep=", "
9013   fi
9014   if test "$with_opengl" = "no"; then
9015     reason="$reason${sep}OpenGL"
9016     sep=", "
9017   fi
9018   if test "$with_glew" = "no"; then
9019     reason="$reason${sep}GLEW"
9020     sep=", "
9021   fi
9022   if test "$with_ftgl" = "no"; then
9023     reason="$reason${sep}FTGL"
9024     sep=", "
9025   fi
9026   if test "$with_sqlite3" = "no"; then
9027     reason="$reason${sep}SQLite 3.x"
9028     sep=", "
9029   fi
9030   if test "$with_bdb" = "no"; then
9031     reason="$reason${sep}Berkeley DB"
9032     sep=", "
9033   fi
9034   if test "$ncbi_cv_lib_boost_spirit" != "yes"; then
9035     reason=Boost.Spirit
9036     sep=", "
9037   fi
9038   if test "$with_libxslt" = "no"; then
9039     reason="$reason${sep}libxslt"
9040     sep=", "
9041   fi
9042   if test "$with_mt" = "no"; then
9043     reason="$reason${sep}multithreading"
9044     sep=", "
9045   fi
9046   if test "$with_dll" != "yes"; then
9047     reason="$reason${sep}full-DLL setup"
9048     sep=", "
9049   fi
9050   if test "$with_algo" = "no"; then
9051     reason="$reason${sep}other required subtrees"
9052     sep=","
9053   fi
9054   # Anything else?
9055   if test -n "$reason" -a "$with_gbench" = "yes"; then
9056      AC_MSG_ERROR([--with-gbench:  Cannot build Genome Workbench: missing $reason])
9057   elif test -z "$reason"; then
9058      NCBI_PROJECT(gbench)
9059   fi
9060fi
9061
9062
9063
9064### Miscellanea
9065### --------------------------------------------
9066
9067if test "$with_execopy" = "no" ; then
9068   APP_NOCOPY="BINCOPY=@:"
9069else
9070   APP_NOCOPY=
9071fi
9072
9073if test "$with_exe" = "no" ; then
9074   APP_OR_NULL=null
9075else
9076   APP_OR_NULL=app
9077fi
9078
9079IF_REBUILDING_LIBS="#"
9080IF_REBUILDING_CONDITIONALLY="#"
9081case "$with_lib_rebuilds" in
9082  yes) IF_REBUILDING_LIBS="" ;;
9083  ask) IF_REBUILDING_CONDITIONALLY="" ;;
9084esac
9085
9086case "$with_deactivation" in
9087  no) IF_DEACTIVATING="#" ;;
9088  * ) IF_DEACTIVATING=""  ;;
9089esac
9090
9091case "$with_makefile_auto_update" in
9092  no) configurables_mfname=configurables.null ;;
9093  * ) configurables_mfname=configurables      ;;
9094esac
9095
9096# Run the test suite after the build?
9097
9098if test -n "$with_check"  -a  "$with_check" != "no" ; then
9099   check="check"
9100   if test "$with_check" != "yes" ; then
9101      CHECK_ARG=`echo "$with_check" | sed 's/%/ /g'`
9102   fi
9103   NCBI_FEATURE(check)
9104fi
9105CHECK_TOOLS=$with_check_tools
9106case "$CHECK_TOOLS" in
9107   [*[Vv][Aa][Ll][Gg][Rr][Ii][Nn][Dd]*] ) NCBI_FEATURE(Valgrind) ;;
9108   [*[Hh][Ee][Ll][Gg][Rr][Ii][Nn][Dd]*] ) NCBI_FEATURE(Valgrind) ;;
9109esac
9110CHECK_OS_NAME=
9111: ${CHECK_TIMEOUT_MULT=1}
9112case "$host_os" in
9113   linux* )
9114      if test -x /usr/bin/lsb_release; then
9115         CHECK_OS_NAME=`lsb_release -is | tr A-Z a-z`
9116      elif test -r /etc/SuSE-release; then
9117         CHECK_OS_NAME=suse
9118      elif test -r /etc/redhat-release; then
9119         CHECK_OS_NAME=`cut -d' ' -f1 /etc/redhat-release | tr A-Z a-z`
9120      elif test -d /usr/share/doc/ubuntu-keyring; then
9121         CHECK_OS_NAME=ubuntu
9122      fi
9123      ;;
9124esac
9125
9126if test "${with_limited_linker}" = "yes"; then
9127   NCBI_FEATURE(LimitedLinker)
9128fi
9129
9130if test "${with_skew_guard-$with_ncbi_public}" = "yes"; then
9131    AC_DEFINE(HAVE_NCBI_SKEW_GUARD, 1,
9132       [Define to 1 to catch incomplete rebuilds.])
9133fi
9134
9135FEATURES="$WithFeatures $WithPackages $WithProjects"
9136
9137### Compute Without{Features,Packages,Projects}.  Takes quadratic time,
9138### but that's life.
9139m4_foreach(CATEGORY, [Features,Packages,Projects],
9140  [for x in m4_indir([NCBI_ALL_]CATEGORY); do
9141      case " [$With]CATEGORY " in
9142         *" $x "*) ;;
9143         *) [Without]CATEGORY="[$Without]CATEGORY[$Without]CATEGORY[Sep$x]"
9144            [Without]CATEGORY[Sep]=" "
9145            FEATURES="$FEATURES -$x"
9146          ;;
9147      esac
9148   done
9149  ])
9150# Sort, then consolidate back to a single line
9151FEATURES=`echo $FEATURES | fmt -w1 | sort -dfu`
9152FEATURES=`echo $FEATURES`
9153
9154
9155### Get rid of the KCC "anti-license-warning" filter
9156if test "$KCC" = "yes"  -a  -n "$kcc_license" ; then
9157   CC="$kcc_CC"
9158   CXXCPP="$kcc_CXX -E"
9159   CXX="$kcc_CXX"
9160fi
9161
9162### Get rid of the ICC "anti-license-warning" filter
9163if test "$ICC" = "yes"  -a  -n "$icc_license" ; then
9164   CC="$icc_CC"
9165   CXXCPP="$icc_CXX -E"
9166   CXX="$icc_CXX"
9167fi
9168
9169### Adjust paths to wrapper.*.sh
9170case "$CC"     in compilers/*)     CC="\$(top_srcdir)/$CC"     ;; esac
9171case "$CXX"    in compilers/*)    CXX="\$(top_srcdir)/$CXX"    ;; esac
9172case "$CXXCPP" in compilers/*) CXXCPP="\$(top_srcdir)/$CXXCPP" ;; esac
9173case "$AR"     in compilers/*)     AR="\$(top_srcdir)/$AR"     ;; esac
9174
9175### Get Insure++ to honor the Toolkit's psrc file
9176case "$CC" in
9177   */insure*)
9178      CC="$CC -Zop \$(top_srcdir)/compilers/unix/psrc -D__INSURE__"
9179      CXX="$CXX -Zop \$(top_srcdir)/compilers/unix/psrc -D__INSURE__"
9180      CXXCPP="$CXXCPP -Zop \$(top_srcdir)/compilers/unix/psrc -D__INSURE__"
9181      LINK_DLL=`echo "$LINK_DLL" | sed -e 's:insure:& -Zop \$(top_srcdir)/compilers/unix/psrc:'`
9182   ;;
9183esac
9184
9185
9186#############################################################################
9187### Compose a list of configurables("*.in" -- makefiles, shell scripts, etc.)
9188### in subdirs to configure
9189### Compose their target counterparts
9190### Configure
9191
9192AC_MSG_NOTICE([looking for configurables below $real_srcdir...])
9193tmp_sed="`pwd`/config.tmp.$$"
9194for x in $NoConfProjects dll; do
9195   echo "/^\\.\\/$x/d"
9196done > $tmp_sed
9197cat >>$tmp_sed <<EOF
9198s%^.\\(/build-system.*/Makefile*\\)\\.in\$%$builddir\\1:./src\\1\\.in%
9199s%^.\\(/build-system\\)\\(/.*\\)\\.in\$%$builddir\\2:./src\\1\\2\\.in%
9200s%^.\\(/[[^:]]*\\)\\.in\$%$builddir\\1:./src\\1\\.in%
9201EOF
9202cat $tmp_sed >&AS_MESSAGE_LOG_FD
9203configurables=`cd "${real_srcdir}/src"  &&  find . -name '.svn' -prune -o -name '*.in' -print | sed -f $tmp_sed`
9204rm $tmp_sed
9205
9206if test -z "$configurables" ; then
9207  AC_MSG_ERROR([cannot find any configurables below "${real_srcdir}"!])
9208else
9209  AC_MSG_NOTICE([...done])
9210fi
9211
9212ncbi_runpath=`eval echo "$pure_runpath"`
9213dnl AC_DEFINE_UNQUOTED(NCBI_RUNPATH, "$ncbi_runpath", [NCBI runpath])
9214c_ncbi_runpath=`echo "$ncbi_runpath" | sed -e 's:\\$\\$:\\$:g'`
9215
9216### Template substitutions
9217AC_SUBST(signature)
9218
9219AC_SUBST(build_root)
9220
9221AC_SUBST(top_srcdir)
9222AC_SUBST(srcdir)
9223#AC_SUBST(real_srcdir)
9224AC_SUBST(includedir)
9225AC_SUBST(status_dir)
9226AC_SUBST(builddir)
9227AC_SUBST(runpath)
9228AC_SUBST(ncbi_runpath)
9229AC_SUBST(c_ncbi_runpath)
9230
9231AC_SUBST(CC)
9232AC_SUBST(CPP)
9233AC_SUBST(CXX)
9234AC_SUBST(AR)
9235AC_SUBST(RANLIB)
9236AC_SUBST(STRIP)
9237AC_SUBST(LINK)
9238AC_SUBST(C_LINK)
9239AC_SUBST(TAIL_N)
9240AC_SUBST(EGREP_Q)
9241AC_SUBST(LDD_R)
9242
9243AC_SUBST(CFLAGS)
9244AC_SUBST(FAST_CFLAGS)
9245AC_SUBST(CXXFLAGS)
9246AC_SUBST(FAST_CXXFLAGS)
9247AC_SUBST(OBJCXX_CXXFLAGS)
9248AC_SUBST(CPPFLAGS)
9249AC_SUBST(DEPFLAGS)
9250AC_SUBST(DEPFLAGS_POST)
9251AC_SUBST(LDFLAGS)
9252AC_SUBST(FAST_LDFLAGS)
9253AC_SUBST(APP_LDFLAGS)
9254AC_SUBST(DLL_LDFLAGS)
9255AC_SUBST(LIBS)
9256AC_SUBST(C_LIBS)
9257AC_SUBST(OBJCXX_LIBS)
9258AC_SUBST(FOUNDATION_LIBS)
9259AC_SUBST(GCCPCH)
9260AC_SUBST(RUNPATH_ORIGIN)
9261AC_SUBST(NO_STRICT_ALIASING)
9262
9263AC_SUBST(D_SFX)
9264AC_SUBST(DEBUG_SFX)
9265
9266AC_SUBST(LIB_OR_DLL)
9267AC_SUBST(FORCE_STATIC_LIB)
9268AC_SUBST(APP_LIB_SETTING)
9269AC_SUBST(APP_LIBS_SETTING)
9270AC_SUBST(LINK_DLL)
9271AC_SUBST(has_dll_loadable)
9272AC_SUBST(LINK_LOADABLE)
9273AC_SUBST(CFLAGS_DLL)
9274AC_SUBST(CXXFLAGS_DLL)
9275AC_SUBST(ALLOW_UNDEF)
9276AC_SUBST(FORBID_UNDEF)
9277AC_SUBST(AS_NEEDED)
9278AC_SUBST(NO_AS_NEEDED)
9279AC_SUBST(WHOLE_ARCHIVE)
9280AC_SUBST(NO_WHOLE_ARCHIVE)
9281
9282AC_SUBST(OPT_GROUPS)
9283AC_SUBST(local_lbsm)
9284AC_SUBST(ncbi_crypt)
9285AC_SUBST(CONNEXT)
9286AC_SUBST(XCONNEXT)
9287AC_SUBST(serial)
9288AC_SUBST(bdb)
9289AC_SUBST(dbapi)
9290AC_SUBST(objects)
9291AC_SUBST(gui)
9292AC_SUBST(algo)
9293AC_SUBST(app)
9294AC_SUBST(internal)
9295
9296AC_SUBST(check)
9297AC_SUBST(CHECK_ARG)
9298AC_SUBST(CHECK_TOOLS)
9299AC_SUBST(CHECK_TIMEOUT_MULT)
9300AC_SUBST(CHECK_OS_NAME)
9301AC_SUBST(FEATURES)
9302
9303AC_SUBST(script_shell)
9304AC_SUBST(make_shell)
9305AC_SUBST(obj_ext)
9306AC_SUBST(lib_pre)
9307AC_SUBST(lib_l_pre)
9308AC_SUBST(lib_ext)
9309AC_SUBST(dll_ext)
9310AC_SUBST(loadable_ext)
9311AC_SUBST(lib_l_ext)
9312AC_SUBST(exe_ext)
9313AC_SUBST(f_compile)
9314AC_SUBST(f_outobj)
9315AC_SUBST(f_outlib)
9316AC_SUBST(f_libpath)
9317AC_SUBST(f_runpath)
9318AC_SUBST(f_outexe)
9319
9320AC_SUBST(BDB_LIB)
9321AC_SUBST(BDB_CACHE_LIB)
9322AC_SUBST(SQLITE3_WRAPPER)
9323AC_SUBST(DBAPI_DRIVER)
9324AC_SUBST(DBAPI_CTLIB)
9325AC_SUBST(DBAPI_FTDS)
9326AC_SUBST(DBAPI_FTDS95)
9327AC_SUBST(DBAPI_FTDS100)
9328AC_SUBST(DBAPI_MYSQL)
9329AC_SUBST(DBAPI_ODBC)
9330
9331AC_SUBST(THREAD_LIBS)
9332AC_SUBST(NCBIATOMIC_LIB)
9333AC_SUBST(OPENMP_FLAGS)
9334AC_SUBST(UNSAFE_MATH_FLAG)
9335AC_SUBST(SSE4_1_FLAG)
9336AC_SUBST(AES_FLAG)
9337AC_SUBST(COLOR_DIAGNOSTICS)
9338AC_SUBST(NETWORK_LIBS)
9339AC_SUBST(NETWORK_PURE_LIBS)
9340AC_SUBST(RESOLVER_LIBS)
9341AC_SUBST(MATH_LIBS)
9342AC_SUBST(KSTAT_LIBS)
9343AC_SUBST(RPCSVC_LIBS)
9344AC_SUBST(CRYPT_LIBS)
9345AC_SUBST(DL_LIBS)
9346AC_SUBST(RT_LIBS)
9347AC_SUBST(UUID_LIBS)
9348AC_SUBST(DEMANGLE_LIBS)
9349AC_SUBST(ICONV_LIBS)
9350AC_SUBST(Z_LIB)
9351AC_SUBST(BZ2_LIB)
9352AC_SUBST(PCREPOSIX_LIBS)
9353AC_SUBST(PCRE_LIB)
9354AC_SUBST(OPENSSL_STATIC_LIBS)
9355AC_SUBST(SYBASE_PATH)
9356AC_SUBST(SYBASE_LCL_PATH)
9357AC_SUBST(SYBASE_INCLUDE)
9358AC_SUBST(SYBASE_LIBS)
9359AC_SUBST(SYBASE_DLLS)
9360AC_SUBST(SYBASE_DBLIBS)
9361AC_SUBST(MYSQL_INCLUDE)
9362AC_SUBST(MYSQL_LIBS)
9363AC_SUBST(BERKELEYDB_INCLUDE)
9364AC_SUBST(BERKELEYDB_LIBS)
9365AC_SUBST(BERKELEYDB_STATIC_LIBS)
9366AC_SUBST(BERKELEYDB_CXX_LIBS)
9367AC_SUBST(BERKELEYDB_CXX_STATIC_LIBS)
9368AC_SUBST(ODBC_INCLUDE)
9369AC_SUBST(ODBC_LIBS)
9370AC_SUBST(BOOST_INCLUDE)
9371AC_SUBST(BOOST_LIBPATH)
9372AC_SUBST(BOOST_TAG)
9373AC_SUBST(BOOST_STATIC_TAG)
9374AC_SUBST(BOOST_CHRONO_LIBS)
9375AC_SUBST(BOOST_CHRONO_STATIC_LIBS)
9376AC_SUBST(BOOST_FILESYSTEM_LIBS)
9377AC_SUBST(BOOST_FILESYSTEM_STATIC_LIBS)
9378AC_SUBST(BOOST_IOSTREAMS_LIBS)
9379AC_SUBST(BOOST_IOSTREAMS_STATIC_LIBS)
9380AC_SUBST(BOOST_PROGRAM_OPTIONS_LIBS)
9381AC_SUBST(BOOST_PROGRAM_OPTIONS_STATIC_LIBS)
9382AC_SUBST(BOOST_REGEX_LIBS)
9383AC_SUBST(BOOST_REGEX_STATIC_LIBS)
9384AC_SUBST(BOOST_SERIALIZATION_LIBS)
9385AC_SUBST(BOOST_SERIALIZATION_STATIC_LIBS)
9386AC_SUBST(BOOST_SYSTEM_LIBS)
9387AC_SUBST(BOOST_SYSTEM_STATIC_LIBS)
9388AC_SUBST(BOOST_TEST_PEM_LIBS)
9389AC_SUBST(BOOST_TEST_PEM_STATIC_LIBS)
9390AC_SUBST(BOOST_TEST_TEM_LIBS)
9391AC_SUBST(BOOST_TEST_TEM_STATIC_LIBS)
9392AC_SUBST(BOOST_TEST_UTF_LIBS)
9393AC_SUBST(BOOST_TEST_UTF_STATIC_LIBS)
9394AC_SUBST(BOOST_THREAD_LIBS)
9395AC_SUBST(BOOST_THREAD_STATIC_LIBS)
9396AC_SUBST(NCBI_C_INCLUDE)
9397AC_SUBST(NCBI_C_LIBPATH)
9398AC_SUBST(OPENGL_INCLUDE)
9399AC_SUBST(OPENGL_LIBS)
9400AC_SUBST(OPENGL_STATIC_LIBS)
9401AC_SUBST(OSMESA_INCLUDE)
9402AC_SUBST(OSMESA_LIBS)
9403AC_SUBST(OSMESA_STATIC_LIBS)
9404AC_SUBST(GLUT_INCLUDE)
9405AC_SUBST(GLUT_LIBS)
9406AC_SUBST(GLEW_INCLUDE)
9407AC_SUBST(GLEW_LIBS)
9408AC_SUBST(GLEW_STATIC_LIBS)
9409AC_SUBST(GL2PS_INCLUDE)
9410AC_SUBST(GL2PS_LIBS)
9411AC_SUBST(GL2PS_STATIC_LIBS)
9412AC_SUBST(WXWIDGETS_INCLUDE)
9413AC_SUBST(WXWIDGETS_LIBS)
9414AC_SUBST(WXWIDGETS_STATIC_LIBS)
9415AC_SUBST(WXWIDGETS_GL_LIBS)
9416AC_SUBST(WXWIDGETS_GL_STATIC_LIBS)
9417AC_SUBST(WXWIDGETS_POST_LINK)
9418AC_SUBST(FASTCGI_INCLUDE)
9419AC_SUBST(FASTCGI_LIBS)
9420AC_SUBST(FASTCGI_OBJS)
9421AC_SUBST(NCBI_SSS_INCLUDE)
9422AC_SUBST(NCBI_SSS_LIBPATH)
9423AC_SUBST(LIBSSSUTILS)
9424AC_SUBST(LIBSSSDB)
9425AC_SUBST(sssutils)
9426AC_SUBST(VDB_INCLUDE)
9427AC_SUBST(VDB_LIBS)
9428AC_SUBST(VDB_STATIC_LIBS)
9429AC_SUBST(bamread)
9430AC_SUBST(sraread)
9431AC_SUBST(ncbi_id2proc_snp)
9432AC_SUBST(ncbi_id2proc_wgs)
9433AC_SUBST(ncbi_xloader_bam)
9434AC_SUBST(ncbi_xloader_csra)
9435AC_SUBST(ncbi_xloader_snp)
9436AC_SUBST(ncbi_xloader_sra)
9437AC_SUBST(ncbi_xloader_vdbgraph)
9438AC_SUBST(ncbi_xloader_wgs)
9439AC_SUBST(VDB_REQ)
9440AC_SUBST(VDB_POST_LINK)
9441AC_SUBST(NGS_STATIC_LIBS)
9442AC_SUBST(SP_INCLUDE)
9443AC_SUBST(SP_LIBS)
9444AC_SUBST(ORBACUS_INCLUDE)
9445AC_SUBST(ORBACUS_LIBPATH)
9446AC_SUBST(LIBOB)
9447AC_SUBST(LIBIMR)
9448AC_SUBST(ICU_CONFIG)
9449AC_SUBST(ICU_INCLUDE)
9450AC_SUBST(ICU_LIBS)
9451AC_SUBST(ICU_STATIC_LIBS)
9452AC_SUBST(EXPAT_STATIC_LIBS)
9453AC_SUBST(SABLOT_STATIC_LIBS)
9454AC_SUBST(LIBXML_STATIC_LIBS)
9455AC_SUBST(LIBXSLT_STATIC_LIBS)
9456AC_SUBST(LIBEXSLT_STATIC_LIBS)
9457AC_SUBST(XERCES_INCLUDE)
9458AC_SUBST(XERCES_LIBS)
9459AC_SUBST(XERCES_STATIC_LIBS)
9460AC_SUBST(XALAN_INCLUDE)
9461AC_SUBST(XALAN_LIBS)
9462AC_SUBST(XALAN_STATIC_LIBS)
9463AC_SUBST(ZORBA_INCLUDE)
9464AC_SUBST(ZORBA_LIBS)
9465AC_SUBST(ZORBA_STATIC_LIBS)
9466AC_SUBST(SQLITE3_STATIC_LIBS)
9467AC_SUBST(FREETYPE_INCLUDE)
9468AC_SUBST(FREETYPE_LIBS)
9469AC_SUBST(GSOAP_PATH)
9470AC_SUBST(AVRO_STATIC_LIBS)
9471AC_SUBST(CEREAL_INCLUDE)
9472AC_SUBST(MONGODB_STATIC_LIBS)
9473AC_SUBST(MONGODB3_STATIC_LIBS)
9474AC_SUBST(GMOCK_STATIC_LIBS)
9475AC_SUBST(LMDB_LIB)
9476AC_SUBST(LMDB_STATIC_LIBS)
9477AC_SUBST(LIBUV_STATIC_LIBS)
9478AC_SUBST(LIBSSH2_STATIC_LIBS)
9479AC_SUBST(CASSANDRA_STATIC_LIBS)
9480AC_SUBST(NGHTTP2_STATIC_LIBS)
9481AC_SUBST(H2O_STATIC_LIBS)
9482AC_SUBST(INFLUXDB_INCLUDE)
9483AC_SUBST(LIBXLSXWRITER_STATIC_LIBS)
9484AC_SUBST(PROTOC)
9485AC_SUBST(PROTOBUF_BIN)
9486AC_SUBST(GRPC_UNSECURE_LIBS)
9487AC_SUBST(GRPC_REFLECTION_LIBS)
9488AC_SUBST(GRPC_CPP_PLUGIN)
9489AC_SUBST(GRPC_BIN)
9490AC_SUBST(MSGSL_INCLUDE)
9491AC_SUBST(AWS_SDK_STATIC_LIBS)
9492AC_SUBST(HIREDIS_STATIC_LIBS)
9493AC_SUBST(APACHE_ARROW_STATIC_LIBS)
9494AC_SUBST(LIBRDKAFKA_STATIC_LIBS)
9495AC_SUBST(CPPKAFKA_STATIC_LIBS)
9496AC_SUBST(ncbi_xreader_pubseqos)
9497AC_SUBST(ncbi_xreader_pubseqos2)
9498AC_SUBST(UNLESS_PUBSEQOS)
9499AC_SUBST(PERL)
9500AC_SUBST(PERL_INCLUDE)
9501AC_SUBST(PERL_LIBS)
9502AC_SUBST(JDK_PATH)
9503AC_SUBST(JDK_INCLUDE)
9504AC_SUBST(ncbi_java)
9505
9506AC_SUBST(NCBI_C_ncbi)
9507
9508AC_SUBST(BINCOPY)
9509AC_SUBST(APP_NOCOPY)
9510AC_SUBST(APP_OR_NULL)
9511AC_SUBST(IF_REBUILDING_LIBS)
9512AC_SUBST(IF_REBUILDING_CONDITIONALLY)
9513AC_SUBST(IF_DEACTIVATING)
9514AC_SUBST(configurables_mfname)
9515AC_SUBST(CC_FILTER)
9516AC_SUBST(CXX_FILTER)
9517AC_SUBST(AR_FILTER)
9518AC_SUBST(LINK_FILTER)
9519AC_SUBST(CC_WRAPPER)
9520AC_SUBST(CXX_WRAPPER)
9521AC_SUBST(AR_WRAPPER)
9522AC_SUBST(LINK_WRAPPER)
9523
9524AC_SUBST(KeepStateTarget)
9525AC_SUBST(Rules)
9526AC_SUBST(serial_ws50_rtti_kludge)
9527AC_SUBST(ncbicntr)
9528
9529AC_SUBST(UNIX_SRC)
9530AC_SUBST(UNIX_USR_PROJ)
9531
9532AC_SUBST(compiler)
9533AC_SUBST(compiler_root)
9534AC_SUBST(compiler_version)
9535
9536AC_SUBST(COMPILER)
9537AC_SUBST(OSTYPE)
9538AC_SUBST(NCBI_PLATFORM_BITS)
9539
9540AC_SUBST(NCBI_TEAMCITY_BUILD_NUMBER)
9541AC_SUBST(NCBI_TEAMCITY_PROJECT_NAME)
9542AC_SUBST(NCBI_TEAMCITY_BUILDCONF_NAME)
9543AC_SUBST(NCBI_TEAMCITY_BUILD_ID)
9544AC_SUBST(NCBI_SUBVERSION_REVISION)
9545AC_SUBST(NCBI_SC_VERSION)
9546
9547#############################################################################
9548### Create output files and do some post-configuration
9549
9550## Compose a list of target files
9551changequote(<<, >>)dnl
9552x_configurables=`echo "$configurables" | sed 's/:[^:][^:]*\.in//g'`
9553changequote([, ])dnl
9554
9555## Deploy the target directory tree
9556echo "$x_configurables" | while read x_file ; do
9557   x_dir=`dirname $x_file`
9558   test -d "$x_dir"  ||  mkdir -p "$x_dir"
9559done
9560
9561## Create ncbicfg.c.last if necessary
9562ncbicfg="$builddir/corelib/ncbicfg.c"
9563test -f "$ncbicfg" -a ! -f "$ncbicfg.last" && cp -p "$ncbicfg" "$ncbicfg.last"
9564
9565test -d "$status_dir"  ||  mkdir -p "$status_dir"
9566CONFIG_STATUS=$status_dir/config.status
9567
9568## Configure the compiler/flag-dependent header
9569AC_CONFIG_HEADER(${ncbiconf}:src/build-system/config.h.in)
9570
9571##
9572## Configure makefiles, shell scripts, etc.
9573##
9574AC_CONFIG_FILES($configurables \
9575   $srcdir/./Makefile:src/build-system/Makefile.in.top \
9576   $build_root/inc/common/ncbi_build_ver.h:include/common/ncbi_build_ver.h.in \
9577   $srcdir/include/common/ncbi_revision.h:include/common/ncbi_revision.h.in)
9578
9579AC_CONFIG_COMMANDS([default], [
9580dnl make all shell scripts *.sh be executable
9581find "$build_root/." -name '*.sh' -print | while read x_file ; do
9582   chmod a+x "$x_file"
9583done
9584chmod a+x "$build_root/build/run_with_cd_reporter.py"
9585
9586dnl save cache and log files to the build tree dir "status/"
9587dnl (alongside config.status, which is now directly created there to
9588dnl avoid possible trouble; for that matter, it can be at least as
9589dnl important to avoid having config.log still open for writing during
9590dnl the move).
9591if test -f config.cache -a -f config.log ; then
9592   test -d  "$status_dir"  ||  mkdir -p "$status_dir"
9593   exec AS_MESSAGE_LOG_FD>/dev/null
9594   mv config.cache config.log "$status_dir"/
9595   exec AS_MESSAGE_LOG_FD>>"$status_dir/config.log"
9596fi
9597
9598dnl Update list of enabled packages
9599rm -f "$status_dir"/*.enabled
9600for p in $WithPackages $WithProjects $WithFeatures ; do
9601   touch "$status_dir"/$p.enabled
9602done
9603for p in $WithoutPackages $WithoutProjects $WithoutFeatures ; do
9604   touch "$status_dir"/-$p.enabled
9605done
9606
9607dnl Create dummy .dep files for system installations of (b)zlib.
9608dnl This is a stopgap measure, and fails for installations in non-system dirs.
9609# test -f "$status_dir"/LocalZ.enabled  ||  \
9610#    touch -t 197001010000 $status_dir/.z.dep
9611# test -f "$status_dir"/LocalBZ2.enabled  ||  \
9612#    touch -t 197001010000 $status_dir/.bz2.dep
9613
9614dnl Incorporate any Makefile.*.mk and ncbiconf.*.h files found in the tree.
9615"$srcdir"/scripts/common/impl/supplement_makefile_mk.sh "$real_srcdir" \
9616   "$builddir"
9617find "$srcdir"/src/* -name .svn -prune -o -name 'ncbiconf.*.h' -print \
9618   | while read x; do
9619      echo
9620      echo "/*** Extra macro definitions from $x ***/"
9621      echo
9622      echo "#line 1 \"$x\""
9623      cat "$x"
9624   done > "$build_root/inc/ncbiconf_extra.h"
9625if test -s "$build_root/inc/ncbiconf_extra.h"; then
9626   ncbiconf=$build_root/inc/ncbiconf_unix.h
9627   newconf=$ncbiconf.extra.new
9628   savedconf=$ncbiconf.extra.prev
9629   cat "$ncbiconf" "$build_root/inc/ncbiconf_extra.h" > "$newconf"
9630   $srcdir/scripts/common/impl/report_duplicates.awk \
9631      src="$srcdir/src/build-system/config.h.in" "$newconf"
9632   if test -f "$savedconf"  &&  cmp "$newconf" "$savedconf" >/dev/null; then
9633      echo "$ncbiconf is unchanged"
9634   else
9635      cp -pf "$newconf" "$savedconf"
9636   fi
9637   cp -pf "$savedconf" "$ncbiconf"
9638else
9639   rm -f "$build_root/inc/ncbiconf_extra.h"
9640fi
9641
9642dnl Avoid gratuitous rebuilding
9643for f in "$builddir/corelib/ncbicfg.c" \
9644         "$build_root/inc/common/ncbi_build_ver.h"; do
9645   if test -f "$f.last" && cmp -s "$f.last" "$f"; then
9646      echo "$f" is unchanged
9647      touch -r "$f.last" "$f"
9648   elif test -f "$f"; then
9649      echo "$f" is updated
9650      rm -f "$f.last"
9651      cp -p "$f" "$f.last"
9652   else
9653      echo "$f" is not present
9654   fi
9655done
9656
9657dnl Try to build simple helpers
9658(cd $builddir/build-system/helpers && $MAKE -k)
9659
9660dnl Generated header containing random compile-time values, produced by
9661dnl either project_tree_builder (alongside Makefile.flat) or fallback logic.
9662random_macro="$build_root/inc/ncbi_random_macro.h"
9663rm -f $random_macro
9664
9665dnl Create Makefile.flat if requested
9666if test "$with_configure_dialog" = yes; then
9667   if test "$with_flat_makefile" = no; then
9668      AC_MSG_ERROR([incompatible options: --without-flat-makefile but --with-configure-dialog.])
9669   fi
9670   with_flat_makefile=yes
9671elif test "${with_saved_settings:-no}" != no; then
9672   if test "$with_flat_makefile" = no; then
9673      AC_MSG_ERROR([incompatible options: --without-flat-makefile but --with-saved-settings.])
9674   fi
9675   with_flat_makefile=yes
9676fi
9677if test "$with_flat_makefile" != "no"; then
9678   if test "$with_flat_makefile" = yes; then
9679      cfm_flags=''
9680   else
9681      cfm_flags='-remoteptb'
9682   fi
9683   if test -n "$with_projects"; then
9684      cfm_flags="$cfm_flags -p $with_projects"
9685   fi
9686   if test "$with_configure_dialog" = yes; then
9687      cfm_flags="$cfm_flags -cfg"
9688   fi
9689   if test "${with_saved_settings-no}" != no; then
9690      cfm_flags="$cfm_flags -saved $with_saved_settings"
9691   fi
9692   if $real_srcdir/scripts/common/impl/create_flat_makefile.sh "$build_root" \
9693       -s "$real_srcdir" $cfm_flags  &&  test -f "$builddir/Makefile.flat"; then
9694      build_flat="Alternatively, cd $builddir && $MAKE -f Makefile.flat"
9695   elif test -f "$builddir/Flat.configuration_log" \
9696      -o "$with_flat_makefile" = yes; then
9697      $EGREP_Q 'Error:|already defined' "$builddir/Flat.configuration_log"
9698      AC_MSG_ERROR([flat makefile generation failed.])
9699   fi
9700fi
9701
9702if test ! -f "$random_macro"; then
9703   $real_srcdir/scripts/common/impl/define_random_macros.sh >$random_macro
9704fi
9705
9706dnl execute extra-action
9707if test -n "$with_extra_action" ; then
9708   with_extra_action=`echo "$with_extra_action" | sed "s%{}%$build_root%g"`
9709   echo
9710   echo "executing:  $with_extra_action..."
9711   eval $with_extra_action
9712   exit_code="$?"
9713   if test $exit_code -ne 0 ; then
9714      AC_MSG_WARN([non-zero exit code ($exit_code):  $with_extra_action])
9715   fi
9716   echo
9717fi
9718
9719dnl print out additional configuration options
9720case "$LIB_OR_DLL" in
9721both) DLL_USAGE="LIBRARIES:  build both static and dynamic by default" ;;
9722dll)  DLL_USAGE="LIBRARIES:  build as dynamic by default" ;;
9723lib)
9724   if test "$with_dll" = "no" ; then
9725      DLL_USAGE="LIBRARIES:  build as static only"
9726   else
9727      DLL_USAGE="LIBRARIES:  build as static by default"
9728   fi
9729   ;;
9730esac
9731
9732if test -n "$with_projects"; then
9733    build_proj="To build selected projects (as listed in \"$with_projects\"):
9734  cd $builddir && $MAKE all_p"
9735fi
9736
9737cat << EOCONF
9738===============================================================================
9739NCBI C++ Toolkit documentation:
9740  Online:   http://www.ncbi.nlm.nih.gov/toolkit/doc/book/
9741  Local:    ./doc/public/index.html
9742For the available configuration flags run:  ./configure --help
9743
9744CFLAGS   = $CFLAGS
9745CXXFLAGS = $CXXFLAGS
9746CPPFLAGS = $CPPFLAGS
9747LDFLAGS  = $LDFLAGS
9748
9749$DLL_USAGE
9750FEATURES:   $WithFeatures
9751PACKAGES:
9752  enabled:  $WithPackages
9753  disabled: $WithoutPackages
9754PROJECTS:
9755  enabled:  $WithProjects
9756  disabled: $WithoutProjects
9757
9758Tools / flags / paths:  $builddir/Makefile.mk
9759Configuration  header:  $ncbiconf
9760
9761To build everything:  cd $builddir && $MAKE all_r
9762or simply run $MAKE in the current directory
9763$build_proj
9764$build_flat
9765******* CONFIGURATION SUCCESSFUL *******
9766EOCONF
9767], [
9768PATH="$HOME/bin:/bin:/usr/bin:\$PATH"
9769status_dir='$status_dir'
9770builddir='$builddir'
9771build_root='$build_root'
9772x_configurables='$x_configurables'
9773ncbiconf='$ncbiconf'
9774CFLAGS='$CFLAGS'
9775CXXFLAGS='$CXXFLAGS'
9776CPPFLAGS='$CPPFLAGS'
9777LDFLAGS='$LDFLAGS'
9778LIB_OR_DLL='$LIB_OR_DLL'
9779MAKE='$MAKE'
9780with_dll='$with_dll'
9781WithFeatures='$WithFeatures'
9782WithoutFeatures='$WithoutFeatures'
9783WithPackages='$WithPackages'
9784WithoutPackages='$WithoutPackages'
9785WithProjects='$WithProjects $OPT_GROUPS'
9786WithoutProjects='$WithoutProjects'
9787with_extra_action='$with_extra_action'
9788with_projects='$with_projects'
9789with_flat_makefile='$with_flat_makefile'
9790with_configure_dialog='$with_configure_dialog'
9791with_saved_settings='$with_saved_settings'
9792smart_pwd='$smart_pwd'
9793real_srcdir='$real_srcdir'
9794EGREP_Q='$EGREP_Q'
9795export MAKE PATH
9796])
9797
9798AC_WARNING([*** Please don't forget to update .../src/build-system/NEWS if appropriate! ***])dnl
9799AC_OUTPUT
9800