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