Combined patches from git.
--- /dev/null
+++ ncbi-tools6-6.1.20170106+dfsg1/.gitignore
@@ -0,0 +1,6 @@
+bin
+build
+include
+lib
+shlib
+*-stamp
--- ncbi-tools6-6.1.20170106+dfsg1.orig/access/ent2api.c
+++ ncbi-tools6-6.1.20170106+dfsg1/access/ent2api.c
@@ -1273,7 +1273,7 @@ NLM_EXTERN CONN EntrezOpenConnection (
     *arg = '\0';
 
   return QUERY_OpenServiceQueryEx
-    (StringHasNoText (e2_service) ? "Entrez2" : e2_service, NULL, 30, arg);
+    (StringHasNoText (e2_service) ? "Entrez2s" : e2_service, NULL, 30, arg);
 }
 
 #ifdef OS_MAC
--- ncbi-tools6-6.1.20170106+dfsg1.orig/api/sqnutil3.c
+++ ncbi-tools6-6.1.20170106+dfsg1/api/sqnutil3.c
@@ -33198,7 +33198,7 @@ ClickableItemPtr LIBCALL ClickableGlobal
        cip->clickable_item_type = item_type;
        cip->description 
           = (CharPtr) MemNew ( sizeof (Char) * (StringLen (fmt) + 15));
-       sprintf (cip->description, fmt);
+       strcpy (cip->description, fmt);
        return cip;
   }
   return NULL;
--- ncbi-tools6-6.1.20170106+dfsg1.orig/connect/ncbi_gnutls.c
+++ ncbi-tools6-6.1.20170106+dfsg1/connect/ncbi_gnutls.c
@@ -585,6 +585,7 @@ static EIO_Status s_GnuTlsInit(FSSLPull
 
     assert(!s_GnuTlsCredAnon);
 
+#if 0
     version = gnutls_check_version(0);
     if (strcasecmp(GNUTLS_VERSION, version) != 0) {
         CORE_LOGF(eLOG_Critical,
@@ -592,6 +593,7 @@ static EIO_Status s_GnuTlsInit(FSSLPull
                    GNUTLS_VERSION, version));
         assert(0);
     }
+#endif
 
     val = ConnNetInfo_GetValue(0, "GNUTLS_LOGLEVEL", buf, sizeof(buf), 0);
     CORE_LOCK_READ;
--- ncbi-tools6-6.1.20170106+dfsg1.orig/connect/ncbi_http_connector.c
+++ ncbi-tools6-6.1.20170106+dfsg1/connect/ncbi_http_connector.c
@@ -240,8 +240,14 @@ static int/*bool*/ x_UnsafeRedirectOK(SH
     if (uuu->unsafe_redir == eDefault) {
         if (!(uuu->flags & fHTTP_UnsafeRedirects)) {
             char val[32];
+            const char* dflt = NULL;
+            if (uuu->net_info->scheme == eURL_Https
+		&&  (strspn(uuu->net_info->host, "0123456789.")
+		     == strlen(uuu->net_info->host))) {
+                dflt = "TRUE";
+            }
             ConnNetInfo_GetValue(0, "HTTP_UNSAFE_REDIRECTS",
-                                 val, sizeof(val), 0);
+                                 val, sizeof(val), dflt);
             uuu->unsafe_redir = ConnNetInfo_Boolean(val) ? eOn : eOff;
         } else
             uuu->unsafe_redir = eOn;
--- ncbi-tools6-6.1.20170106+dfsg1.orig/connect/ncbi_util.c
+++ ncbi-tools6-6.1.20170106+dfsg1/connect/ncbi_util.c
@@ -49,7 +49,9 @@
 #  ifndef NCBI_OS_SOLARIS
 #    include <limits.h>
 #  endif /*!NCBI_OS_SOLARIS*/
-#  ifdef NCBI_OS_LINUX
+#  ifdef __MACH__
+#    include <mach/vm_param.h>
+#  elif defined(NCBI_OS_LINUX)
 #    include <sys/user.h>
 #  endif /*NCBI_OS_LINUX*/
 #  include <pwd.h>
--- ncbi-tools6-6.1.20170106+dfsg1.orig/connect/urlquery.c
+++ ncbi-tools6-6.1.20170106+dfsg1/connect/urlquery.c
@@ -128,7 +128,10 @@ NLM_EXTERN CONN QUERY_OpenUrlQuery (
   }
   if ( host_port ) {
     net_info->port = host_port;
+  } else {
+    net_info->scheme = eURL_Https;
   }
+
   StringNCpy_0 (net_info->path, host_path, sizeof (net_info->path));
   if (StringDoesHaveText (arguments)) {
     StringNCpy_0 (net_info->args, arguments, sizeof (net_info->args));
--- ncbi-tools6-6.1.20170106+dfsg1.orig/corelib/ncbimain.c
+++ ncbi-tools6-6.1.20170106+dfsg1/corelib/ncbimain.c
@@ -67,6 +67,7 @@
 #pragma segment NlmSegA
 #endif
 
+extern Nlm_Int2 Nlm_Main(void) __attribute__((weak));
 
 /*****************************************************************************
 *
@@ -95,7 +96,12 @@ main(int argc, char *argv[])
   /* Initialize connection library's logger, registry and lock */
   CONNECT_Init(0);
 
-  retval = Nlm_Main();
+  if (Nlm_Main) {
+    retval = Nlm_Main();
+  } else {
+    ErrPost(0, 0, "Neither main nor Nlm_Main defined by program.");
+    retval = -1;
+  }
 
   NlmThreadJoinAll();
 
--- ncbi-tools6-6.1.20170106+dfsg1.orig/corelib/ncbitime.c
+++ ncbi-tools6-6.1.20170106+dfsg1/corelib/ncbitime.c
@@ -77,6 +77,7 @@
 #include <ncbi.h>
 #include <ncbithr.h>
 #include <ncbiwin.h>
+#include <stdlib.h>
 
 #ifdef OS_UNIX
 #include <sys/times.h>
@@ -108,8 +109,18 @@ NLM_EXTERN time_t LIBCALL  Nlm_GetSecs (
 *****************************************************************************/
 NLM_EXTERN Nlm_Boolean LIBCALL  Nlm_GetDayTime (Nlm_DayTimePtr dtp)
 {
+  /* This function honors the SOURCE_DATE_EPOCH specificatin
+     (https://reproducible-builds.org/specs/source-date-epoch/) */
+  const char *sde = getenv("SOURCE_DATE_EPOCH");
 #if (defined(SOLARIS_THREADS_AVAIL)  ||  defined(POSIX_THREADS_AVAIL)  ||  defined(WIN32)) && !defined(OS_UNIX_DARWIN)
-  time_t t = time( NULL );
+  time_t t;
+  if (sde) {
+    t = strtoul(sde, NULL, 0);
+    if (t == 0)
+      return FALSE;
+  } else {
+    t = time( NULL );
+  }
 #ifdef WIN32
   static TNlmMutex localtime_lock;
   if (NlmMutexLockEx( &localtime_lock ) != 0)
@@ -125,7 +136,13 @@ NLM_EXTERN Nlm_Boolean LIBCALL  Nlm_GetD
   time_t ltime;
   struct tm *dt;
   Nlm_MemFill ((Nlm_VoidPtr) dtp, 0, sizeof(Nlm_DayTime));
-	time(&ltime);
+  if (sde) {
+    ltime = strtoul(sde, NULL, 0);
+    if (ltime == 0)
+      return FALSE;
+  } else {
+    time(&ltime);
+  }
   if ((dt = localtime (&ltime)) != NULL)
  	{
         Nlm_MemCopy ((Nlm_VoidPtr) dtp, (Nlm_VoidPtr) dt, sizeof (struct tm));
--- ncbi-tools6-6.1.20170106+dfsg1.orig/demo/asndisc.c
+++ ncbi-tools6-6.1.20170106+dfsg1/demo/asndisc.c
@@ -65,6 +65,7 @@
 #include <objmacro.h>
 #include <macroapi.h>
 
+#include <connect/ncbi_gnutls.h>
 
 #define ASNDISC_APP_VER "2.3"
 
@@ -1264,6 +1265,8 @@ Int2 Main (void)
   UseLocalAsnloadDataAndErrMsg ();
   ErrPathReset ();
 
+  SOCK_SetupSSL(NcbiSetupGnuTls);
+
   if (! AllObjLoad ()) {
     Message (MSG_FATAL, "AllObjLoad failed");
     return 1;
--- ncbi-tools6-6.1.20170106+dfsg1.orig/demo/entrez2.c
+++ ncbi-tools6-6.1.20170106+dfsg1/demo/entrez2.c
@@ -61,6 +61,8 @@
 
 #include <entrez2.h>
 
+#include <connect/ncbi_gnutls.h>
+
 #define ENTREZ_APP_VERSION "12.1"
 
 #define MAX_QUERY_FORMS 256
@@ -884,6 +886,8 @@ Int2 Main (void)
   UseLocalAsnloadDataAndErrMsg ();
   ErrPathReset ();
 
+  SOCK_SetupSSL(NcbiSetupGnuTls);
+
   /*--------------------------------*/
   /* Initialize the global settings */
   /*--------------------------------*/
@@ -1026,7 +1030,7 @@ Int2 Main (void)
   /*--------------------------------------*/
 
   if (useNormalServ) {
-    EntrezSetService ("Entrez2");
+    EntrezSetService ("Entrez2s");
   } else if (useTestServ) {
     EntrezSetService ("Entrez2Test");
   } else if (useURL) {
--- ncbi-tools6-6.1.20170106+dfsg1.orig/demo/findspl.c
+++ ncbi-tools6-6.1.20170106+dfsg1/demo/findspl.c
@@ -62,6 +62,8 @@
 #include <accentr.h>
 #include <sequtil.h>
 
+#include <connect/ncbi_gnutls.h>
+
 #define NUMARGS 3
 Args myargs[NUMARGS] = {
         {"Gi number of protein","0","1","99999999",FALSE,'g',ARG_INT,0.0,0,NULL},
@@ -98,6 +100,8 @@ Int2 Main(void)
 	FILE *ofp;
 	FILE *ifp = NULL;
 
+	SOCK_SetupSSL(NcbiSetupGnuTls);
+
 	if ( !GetArgs("findspl", NUMARGS, myargs) ) return 1;
 
 	gi = myargs[0].intvalue;
--- ncbi-tools6-6.1.20170106+dfsg1.orig/demo/gbseqget.c
+++ ncbi-tools6-6.1.20170106+dfsg1/demo/gbseqget.c
@@ -54,6 +54,8 @@
 #include <pmfapi.h>
 #include <asn2gnbp.h>
 
+#include <connect/ncbi_gnutls.h>
+
 static CharPtr ReadALine (
   CharPtr str,
   size_t size,
@@ -417,6 +419,8 @@ Int2 Main (void)
   UseLocalAsnloadDataAndErrMsg ();
   ErrPathReset ();
 
+  SOCK_SetupSSL(NcbiSetupGnuTls);
+
   if (! AllObjLoad ()) {
     Message (MSG_FATAL, "AllObjLoad failed");
     return 1;
--- ncbi-tools6-6.1.20170106+dfsg1.orig/demo/insdseqget.c
+++ ncbi-tools6-6.1.20170106+dfsg1/demo/insdseqget.c
@@ -55,6 +55,8 @@
 #include <pmfapi.h>
 #include <asn2gnbp.h>
 
+#include <connect/ncbi_gnutls.h>
+
 #define INSDSEQGET_APP_VER "1.1"
 
 CharPtr INSDSEQGET_APPLICATION = INSDSEQGET_APP_VER;
@@ -423,6 +425,8 @@ Int2 Main (void)
   UseLocalAsnloadDataAndErrMsg ();
   ErrPathReset ();
 
+  SOCK_SetupSSL(NcbiSetupGnuTls);
+
   if (! AllObjLoad ()) {
     Message (MSG_FATAL, "AllObjLoad failed");
     return 1;
--- ncbi-tools6-6.1.20170106+dfsg1.orig/demo/nps2gps.c
+++ ncbi-tools6-6.1.20170106+dfsg1/demo/nps2gps.c
@@ -50,6 +50,8 @@
 #include <toasn3.h>
 #include <pmfapi.h>
 
+#include <connect/ncbi_gnutls.h>
+
 #define NPS2GPSAPP_VER "3.6"
 
 CharPtr NPS2GPSAPPLICATION = NPS2GPSAPP_VER;
@@ -2439,6 +2441,8 @@ Int2 Main (void)
   UseLocalAsnloadDataAndErrMsg ();
   ErrPathReset ();
 
+  SOCK_SetupSSL(NcbiSetupGnuTls);
+
   if (! AllObjLoad ()) {
     Message (MSG_FATAL, "AllObjLoad failed");
     return 1;
--- ncbi-tools6-6.1.20170106+dfsg1.orig/demo/taxblast_main.c
+++ ncbi-tools6-6.1.20170106+dfsg1/demo/taxblast_main.c
@@ -41,6 +41,8 @@ static char const rcsid[] = "$Id: taxbla
 #include <objgen.h>
 #include <taxblast.h>
 
+#include <connect/ncbi_gnutls.h>
+
 
 #define NUMARG (sizeof(myargs)/sizeof(myargs[0]))
 
@@ -63,6 +65,8 @@ Int2 Main (void)
     FILE *outfile;
     Char ofile[128];
     
+    SOCK_SetupSSL(NcbiSetupGnuTls);
+
     if (!GetArgs("txblast", NUMARG, myargs)) {
         return 1;
     }
--- ncbi-tools6-6.1.20170106+dfsg1.orig/demo/tbl2asn.c
+++ ncbi-tools6-6.1.20170106+dfsg1/demo/tbl2asn.c
@@ -8911,10 +8911,12 @@ Int2 Main (void)
     return 1;
   }
 
+  /*
   if (MoreThanYearOld ()) {
     too_old = TRUE;
     Message (MSG_POST, "This copy of tbl2asn is more than a year old.  Please download the current version.");
   }
+  */
 
   /* process command line arguments */
 
@@ -9668,6 +9670,9 @@ Int2 Main (void)
   }
 
   if (tbl.other_failure) {
+    if (MoreThanYearOld ()) {
+      Message (MSG_POST, "This copy of tbl2asn is more than a year old.  Please try again with the current version.");
+    }
     return 1;
   }
 
--- ncbi-tools6-6.1.20170106+dfsg1.orig/desktop/bspview.c
+++ ncbi-tools6-6.1.20170106+dfsg1/desktop/bspview.c
@@ -2549,13 +2549,13 @@ NLM_EXTERN void Nlm_LaunchWebPage (Char
     }
 #endif
 #ifdef WIN_MOTIF
-  argv [0] = "netscape";
+  argv [0] = "sensible-browser";
   argv [1] = url;
   argv [2] = NULL;
   child = fork();
   if(child == 0) {
-     if (execvp ("netscape", argv) == -1) {
-        Message (MSG_POST, "Unable to launch netscape");
+     if (execvp ("sensible-browser", argv) == -1) {
+        Message (MSG_POST, "Unable to launch browser");
         exit(-1);
     }
   }
--- ncbi-tools6-6.1.20170106+dfsg1.orig/doc/dispatcher.html
+++ ncbi-tools6-6.1.20170106+dfsg1/doc/dispatcher.html
@@ -9,15 +9,15 @@
 -->
   <META NAME="keywords" CONTENT="dispatcher toolkit">
   <META NAME="description" CONTENT="NCBI dispatcher">
-  <link rel="stylesheet" href="http://www.ncbi.nlm.nih.gov/corehtml/ncbi2.css">
+  <link rel="stylesheet" href="ncbi2.css">
 </head>
 
 
-<body bgcolor="#FFFFFF" background="http://www.ncbi.nlm.nih.gov/corehtml/bkgd.gif" text="#000000" link="#CC6600" vlink="#CC6600">
+<body bgcolor="#FFFFFF" background="bkgd.gif" text="#000000" link="#CC6600" vlink="#CC6600">
 <!--  the header   --> 
 <table border="0" width="600" cellspacing="0" cellpadding="0">
   <tr> 
-    <td width="140"><a href="http://www.ncbi.nlm.nih.gov"> <img src="http://www.ncbi.nlm.nih.gov/corehtml/left.GIF" width="130" height="45" border="0"></a></td>
+    <td width="140"><a href="http://www.ncbi.nlm.nih.gov"> <img src="left.gif" width="130" height="45" border="0"></a></td>
     <td width="360" class="head1" valign="BOTTOM"> <span class="H1">Network Configuration</span></td>
     <td width="100" valign="BOTTOM"></td>
   </tr>
@@ -37,7 +37,7 @@
 <table border="0" width="600" cellspacing="0" cellpadding="0">
   <tr valign="TOP"> <!--  left column   --> 
     <td width="125"> 
-   <img src="http://www.ncbi.nlm.nih.gov/corehtml/spacer10.GIF" width="125" height="1" border="0">
+   <img src="spacer10.gif" width="125" height="1" border="0">
    <p>
    <a href="#Switch" class="GUTTER">The Switch</a>
    <p>
@@ -52,7 +52,7 @@
    <a href="#Addendum" class="GUTTER">Additional Info</a>
    </td>
     <!-- extra column to force things over the gif border --> 
-    <td width="15"><img src="http://www.ncbi.nlm.nih.gov/corehtml/spacer10.GIF" width="15" height="1" border="0"> </td>
+    <td width="15"><img src="spacer10.gif" width="15" height="1" border="0"> </td>
     <!-- right content column  --> 
     <td width="460"> 
       <p>&nbsp;</p>
--- ncbi-tools6-6.1.20170106+dfsg1.orig/doc/firewall.html
+++ ncbi-tools6-6.1.20170106+dfsg1/doc/firewall.html
@@ -9,15 +9,15 @@
  <META NAME="keywords" CONTENT="insert your keywords for the search engine">
  <META NAME="description" CONTENT="insert the description to be displayed by the search engine.  Also searched by the search engine.">
 -->
-  <link rel="stylesheet" href="http://www.ncbi.nlm.nih.gov/corehtml/ncbi2.css">
+  <link rel="stylesheet" href="ncbi2.css">
 </head>
 
 
-<body bgcolor="#FFFFFF" background="http://www.ncbi.nlm.nih.gov/corehtml/bkgd.gif" text="#000000" link="#CC6600" vlink="#CC6600">
+<body bgcolor="#FFFFFF" background="bkgd.gif" text="#000000" link="#CC6600" vlink="#CC6600">
 <!--  the header   --> 
 <table border="0" width="600" cellspacing="0" cellpadding="0">
   <tr> 
-    <td width="140"><a href="http://www.ncbi.nlm.nih.gov"> <img src="http://www.ncbi.nlm.nih.gov/corehtml/left.GIF" width="130" height="45" border="0"></a></td>
+    <td width="140"><a href="http://www.ncbi.nlm.nih.gov"> <img src="left.gif" width="130" height="45" border="0"></a></td>
     <td width="360" class="head1" valign="BOTTOM"> <span class="H1">Network Configuration</span></td>
     <td width="100" valign="BOTTOM"></td>
   </tr>
@@ -37,12 +37,12 @@
 <table border="0" width="600" cellspacing="0" cellpadding="0">
   <tr valign="TOP"> <!--  left column   --> 
     <td width="125"> 
-<img src="http://www.ncbi.nlm.nih.gov/corehtml/spacer10.GIF" width="125" height="1" border="0">
+<img src="spacer10.gif" width="125" height="1" border="0">
 
 
    </td>
     <!-- extra column to force things over the gif border --> 
-    <td width="15"><img src="http://www.ncbi.nlm.nih.gov/corehtml/spacer10.GIF" width="15" height="1" border="0"> </td>
+    <td width="15"><img src="spacer10.gif" width="15" height="1" border="0"> </td>
     <!-- right content column  --> 
     <td width="460"> 
       <p>&nbsp;</p>
@@ -133,7 +133,7 @@ in case the public access will eventuall
 
 <p>
 To see what ports are currently on, and their status, as reported within
-NCBI, please refer to the following <a href="fwd_check.cgi">Firewall Daemon Presence
+NCBI, please refer to the following <a href="http://www.ncbi.nlm.nih.gov/IEB/ToolBox/NETWORK/fwd_check.cgi">Firewall Daemon Presence
 Check</a> page.  Ports marked <b>INTERNAL</b> are solely for NCBI own use, and may be
 inaccessible from your site. That, however, does not affect availability of any
 services that NCBI provides through other (open) firewall ports.
@@ -143,7 +143,7 @@ TROUBLESHOOTING:  You can test whether t
 your host just by running simple <tt>telnet</tt> command (available on most
 current systems).  To know which ports, at the moment, you should be trying
 from the list above (see the "Ports to open"), first check their status by visiting
-<a href="fwd_check.cgi">Firewall Daemon Presence Check</a> link, then select any
+<a href="http://www.ncbi.nlm.nih.gov/IEB/ToolBox/NETWORK/fwd_check.cgi">Firewall Daemon Presence Check</a> link, then select any
 up-and-running port and do the following (the example assumes port 5861 has
 been shown in operational state):
 <pre>
@@ -175,7 +175,7 @@ functions of NCBI dispatching facilities
 
 <p>
 There is also an auxiliary automated UNIX shell script
-<a href="fwd_check.sh">fwd_check.sh</a> to check all of
+<a href="../libncbi6/examples/fwd_check.sh">fwd_check.sh</a> to check all of
 the preset ports, and it is kept in-sync with currently
 configured open ports (so remember to refresh your download
 prior to actual use).
--- ncbi-tools6-6.1.20170106+dfsg1.orig/doc/fwd_check.sh
+++ ncbi-tools6-6.1.20170106+dfsg1/doc/fwd_check.sh
@@ -8,7 +8,7 @@
 delay_sec="$1"
 delay_sec=${delay_sec:="10"}
 netcat="`which nc 2>/dev/null`"
-temp="/tmp/`basename $0`.$$.tmp"
+temp=`mktemp`
 helper="./fwd_failure_helper.exe"
 test -z "$netcat"  &&  netcat="`whereis nc | sed 's/^[^:]*://;s/ //g'`"
 test -z "$HTTP_NCBI_EXTERNAL"  &&  HTTP_CAF_EXTERNAL="$HTTP_NCBI_EXTERNAL"
--- ncbi-tools6-6.1.20170106+dfsg1.orig/doc/man/cleanasn.1
+++ ncbi-tools6-6.1.20170106+dfsg1/doc/man/cleanasn.1
@@ -1,4 +1,4 @@
-.TH CLEANASN 1 2016-09-01 NCBI "NCBI Tools User's Manual"
+.TH CLEANASN 1 2017-01-09 NCBI "NCBI Tools User's Manual"
 .SH NAME
 cleanasn \- clean up irregularities in NCBI ASN.1 objects
 .SH SYNOPSIS
@@ -75,6 +75,10 @@ Exclude nuc\-prot sets
 Only segmented sequences
 .IP w
 Exclude segmented sequences
+.IP x
+Only segmented proteins
+.IP y
+Exclude segmented proteins
 .PD
 .RE
 .TP
@@ -86,6 +90,8 @@ Sequence operations, per the flags in st
 Compress
 .IP d
 Decompress
+.IP l
+Recalculated segmented sequence length
 .IP v
 Virtual gaps inside segmented sequence
 .IP s
--- /dev/null
+++ ncbi-tools6-6.1.20170106+dfsg1/doc/man/taxblast.1
@@ -0,0 +1,31 @@
+.TH TAXBLAST 1 2016-12-05 NCBI "NCBI Tools User's Manual"
+.SH NAME
+taxblast \- annotate BLAST output with taxonomic details
+.SH SYNOPSIS
+.B taxblast
+[\|\fB\-\fP\|]
+[\|\fB\-d\fP\ \fIstr\fP\|]
+\fB\-i\fP\ \fIfilename\fP
+[\|\fB\-o\fP\ \fIfilename\fP\|]
+[\|\fB\-p\fP\|]
+.SH DESCRIPTION
+\fBtaxblast\fP annotates BLAST output with taxonomic details.
+.SH OPTIONS
+A summary of options is included below.
+.TP
+\fB\-\fP
+Print usage message
+.TP
+\fB\-d\fP\ \fIstr\fP
+Database used to get SeqAnnot ASN.1 (\fBnr\fP by default)
+.TP
+\fB\-i\fP\ \fIfilename\fP
+Input ASN.1 File (SeqAnnot)
+.TP
+\fB\-o\fP\ \fIfilename\fP
+Output file name (stdout by default)
+.TP
+\fB\-p\fP
+Sequence is DNA
+.SH AUTHOR
+The National Center for Biotechnology Information.
--- ncbi-tools6-6.1.20170106+dfsg1.orig/make/makeall.unx
+++ ncbi-tools6-6.1.20170106+dfsg1/make/makeall.unx
@@ -1,4 +1,4 @@
-#	makefile for asntool and ncbi core routines,
+#	-*- makefile -*- for asntool and ncbi core routines,
 #
 #	$Id: makeall.unx,v 6.321 2016/12/31 22:35:10 ucko Exp $
 #
@@ -234,7 +234,7 @@ SRC20 = drawseq.c dotmatrx.c fea2seg.c f
 	dlgutil1.c dlgutil2.c e2trmlst.c e2docsum.c asn2graphic.c \
 	medview.c bspview.c gbfview.c gphview.c gphdraw.c gxydraw.c gtrdraw.c \
 	seqpanel.c ingengraph.c ingenext.c ingenwin.c macrodlg.c \
-	biosrc.c cdrgn.c import.c pubdesc.c seqsub.c mapgene.c prtgene.c salogif.c
+	biosrc.c cdrgn.c import.c pubdesc.c seqsub.c mapgene.c prtgene.c
 
 SRC45 = ddvclick.c ddvgraph.c ddvopen.c ddvpanel.c
 
@@ -392,7 +392,7 @@ OBJ20 = drawseq.o dotmatrx.o fea2seg.o f
 	dlgutil1.o dlgutil2.o e2trmlst.o e2docsum.o asn2graphic.o \
 	medview.o bspview.o gbfview.o gphview.o gphdraw.o gxydraw.o gtrdraw.o \
 	seqpanel.o ingengraph.o ingenext.o ingenwin.o macrodlg.o \
-	biosrc.o cdrgn.o import.o pubdesc.o seqsub.o mapgene.o prtgene.o salogif.o
+	biosrc.o cdrgn.o import.o pubdesc.o seqsub.o mapgene.o prtgene.o
 
 OBJ45 = ddvclick.o ddvgraph.o ddvopen.o ddvpanel.o
 
@@ -491,14 +491,14 @@ ln-if-absent:	../make/ln-if-absent
 nocopy : sources $(THR_OBJ) $(LIB1) $(LIBTLS) $(LIB2) $(LIB3) $(DLIB4) $(DLIB400) \
 	$(LIB5) $(DLIB20) $(DLIB45) $(LIB22) $(LIB23) $(LIBCOMPADJ) \
 	$(DLIB28) $(DLIB30) $(DLIB3000) \
-	$(DLIB34) $(DLIB37) $(DLIB38) $(LIB50) $(LIB60) $(LIB61) $(NCBI_SHLIBS)
+	$(DLIB34) $(DLIB37) $(DLIB38) $(LIB60) $(LIB61) $(NCBI_SHLIBS)
 
 sources : $(SRCALL)
 
 ## To clean out the directory without removing make
 ##
 clean :
-	-rm -f *.[acho]
+	-rm -f *.[acho] *.glo
 
 .NO_PARALLEL:	copy $(ULIB4) $(ULIB30)
 
@@ -656,10 +656,12 @@ shlib.sol :
 	cd ../shlib; make -f $(MAKESHLIB) `ls *.a | sed "s/\.a/.so/"` NCBI_OTHERLIBS=$(OTHERLIBS)
 	rm -f ../shlib/*.a
 
-#
-# Linux shared libs are built the same in the same manner as for SGI
-#
-shlib.lnx : shlib.sgi
+shlib.lnx :
+	-mkdir ../shlib
+	-rm -f ../shlib/*.a
+	ln $(NCBI_LIBDIR)/*.a ../shlib
+	cd ../shlib; make -f $(MAKESHLIB) `ls *.a | sed "s/\.a/.so.$(NCBI_VERSION_MAJOR)/"` SH1="$(CC) -o" SH2="-shared *.o"
+	rm -f ../shlib/*.a
 
 shlib.sgi :
 	-mkdir ../shlib
@@ -792,7 +794,7 @@ copy :
 	cp -fp ../algo/blast/core/*.h ../include/algo/blast/core
 	- mkdir -p ../include/algo/blast/composition_adjustment
 	$(SRCCOPY) ../algo/blast/composition_adjustment/*.c .
-	$(SRCCOPY) ../algo/blast/composition_adjustment/*.h ../include
+#	$(SRCCOPY) ../algo/blast/composition_adjustment/*.h ../include
 	cp -fp ../algo/blast/composition_adjustment/*.h \
 		../include/algo/blast/composition_adjustment
 	- mkdir -p ../include/algo/blast/api
--- ncbi-tools6-6.1.20170106+dfsg1.orig/make/makedemo.unx
+++ ncbi-tools6-6.1.20170106+dfsg1/make/makedemo.unx
@@ -1,4 +1,4 @@
-#	makefile for demo programs
+#	-*- makefile -*- for demo programs
 #
 #	$Id: makedemo.unx,v 6.96 2016/08/31 19:05:26 ucko Exp $
 #
@@ -228,7 +228,8 @@ cdscan : cdscan.c
 # findspl
 
 findspl : findspl.c
-	$(CC) -o findspl $(LDFLAGS) findspl.c $(ENTREZLIBS) $(LIB2) $(LIB1) $(OTHERLIBS)
+	$(CC) -o findspl $(LDFLAGS) findspl.c $(ENTREZLIBS) $(LIB2) $(LIB1) \
+	    $(LIBTLS) $(OTHERLIBS)
 
 # errhdr
 
--- ncbi-tools6-6.1.20170106+dfsg1.orig/make/makenet.unx
+++ ncbi-tools6-6.1.20170106+dfsg1/make/makenet.unx
@@ -1,4 +1,4 @@
-#   makefile for network demo programs and network entrez
+#   -*- makefile -*- for network demo programs and network entrez
 #
 #	$Id: makenet.unx,v 6.261 2016/08/25 15:37:04 ucko Exp $
 #   test, ignore
@@ -330,6 +330,8 @@ OBJ46 = id2.o id2sgen.o
 
 # objects & sources needed for versions of network demo programs
 
+OBJCN3D =       cn3dmain.o
+
 OBJDDV = ddvmain.o
 
 OBJUDV = udvmain.o
@@ -445,10 +447,12 @@ shlib.sol :
 	cd ../shlib; make -f $(MAKESHLIB) `ls *.a | sed "s/\.a/.so/"` NCBI_OTHERLIBS=$(OTHERLIBS)
 	rm -f ../shlib/*.a
 
-#
-# Linux shared libs are built the same in the same manner as for SGI
-#
-shlib.lnx : shlib.sgi
+shlib.lnx :
+	-mkdir ../shlib
+	-rm -f ../shlib/*.a
+	ln $(NCBI_LIBDIR)/*.a ../shlib
+	cd ../shlib; make -f $(MAKESHLIB) `ls *.a | sed "s/\.a/.so.$(NCBI_VERSION_MAJOR)/"` SH1="$(CC) -o" SH2="-shared *.o"
+	rm -f ../shlib/*.a
 
 shlib.sgi :
 	-mkdir ../shlib
@@ -518,7 +522,7 @@ copy :
 	$(SRCCOPY) ../network/vibnet/*.h ../include
 	$(SRCCOPY) ../cdromlib/*.h ../include
 	-$(SRCCOPY) ../network/wwwblast/Src/*.c .
-	-$(SRCCOPY) ../network/wwwblast/Src/*.h ../include
+#	-$(SRCCOPY) ../network/wwwblast/Src/*.h ../include
 	$(SRCCOPY) ../cdromlib/accentr.c .
 	$(SRCCOPY) ../cdromlib/accutils.c .
 	-$(SRCCOPY) ../sequin/*.* .
@@ -952,6 +956,11 @@ accvdb.o : accvdb.c
 ##
 
 
+Cn3D : $(OBJCN3D) $(BENTREZLIBS) netentcf $(BLIB36)
+	$(CC) -o Cn3D $(LDFLAGS) $(OBJCN3D) $(LIB31) $(LIB3000) $(LIB20) \
+		$(LIB45) $(LIB22) $(LIB8) $(LIB7) \
+		$(LIB400) $(LIB2) $(LIB1) $(VIBLIBS) $(OGLLIBS)
+
 ddv    : $(OBJDDV)
 	$(CC) -o ddv $(LDFLAGS) $(OBJDDV) $(LIB41) $(LIB31) $(LIB20) $(LIB61) $(LIB60) $(LIB22) $(LIB45) \
 	$(LIB8) $(LIB7) $(NETCLILIB) $(LIB3) $(LIB4) $(LIB23) \
@@ -1097,8 +1106,8 @@ asnval_dbx_psf.o :	asnval.c
 # asndisc program (asndisc)
 asndisc :	asndisc.c
 	$(CC) -g -o asndisc $(LDFLAGS) asndisc.c $(THREAD_OBJ) $(LIB41) \
-		$(NETCLILIB) $(LIB23) $(LIBCOMPADJ) $(LIB2) $(LIB1) \
-		$(OTHERLIBS) $(THREAD_OTHERLIBS)
+		$(NETCLILIB) $(LIB23) $(LIBCOMPADJ) $(LIB2) $(LIBTLS) $(LIB1) \
+		$(GNUTLS_LIBS) $(OTHERLIBS) $(THREAD_OTHERLIBS)
 
 # asndisc_psf, uses PUBSEQBioseqFetchEnable instead of PubSeqFetchEnable
 # should be used only internally within NCBI.
@@ -1150,17 +1159,19 @@ diffshift :	diffshift.c
 # gbseqget program (gbseqget)
 gbseqget :	gbseqget.c
 	$(CC) -g -o gbseqget $(LDFLAGS) gbseqget.c $(LIB41) $(NETCLILIB) \
-		$(LIB23) $(LIBCOMPADJ) $(LIB2) $(LIB1) $(OTHERLIBS)
+		$(LIB23) $(LIBCOMPADJ) $(LIB2) $(LIBTLS) $(LIB1) \
+		$(GNUTLS_LIBS) $(OTHERLIBS)
 
 # insdseqget program (insdseqget)
 insdseqget :	insdseqget.c
 	$(CC) -g -o insdseqget $(LDFLAGS) insdseqget.c $(LIB41) $(NETCLILIB) \
-		$(LIB23) $(LIBCOMPADJ) $(LIB2) $(LIB1) $(OTHERLIBS)
+		$(LIB23) $(LIBCOMPADJ) $(LIB2) $(LIBTLS) $(LIB1) \
+		$(GNUTLS_LIBS) $(OTHERLIBS)
 
 # nps2gps program (nps2gps)
 nps2gps :	nps2gps.c
 	$(CC) -g -o nps2gps $(LDFLAGS) nps2gps.c $(LIB23) $(LIBCOMPADJ) \
-		$(LIB2) $(LIB1) $(OTHERLIBS)
+		$(LIB2) $(LIBTLS) $(LIB1) $(GNUTLS_LIBS) $(OTHERLIBS)
 
 # trna2sap program (trna2sap)
 trna2sap :	trna2sap.c
@@ -1181,7 +1192,8 @@ testent2 :	testent2.c
 entrez2 :	entrez2.c
 	$(CC) -g -o entrez2 $(LDFLAGS) entrez2.c $(LIB41) $(LIB6) $(LIB20) \
 		$(LIB61) $(LIB60) $(LIB22) $(LIB23) $(LIBCOMPADJ) \
-		$(LIB2) $(LIB4) $(LIB1) $(VIBLIBS) $(OTHERLIBS)
+		$(LIB2) $(LIB4) $(LIBTLS) $(LIB1) \
+		$(GNUTLS_LIBS) $(VIBLIBS) $(OTHERLIBS)
 	$(VIB_POST_LINK) entrez2
 
 # demo program (spidey)
@@ -1285,7 +1297,7 @@ bl2seq : bl2seq.c
 taxblast: taxblast_main.c $(BLIB41) $(BLIB40)
 	$(CC) -g -o taxblast $(LDFLAGS) taxblast_main.c \
 		$(LIB61) $(LIB60) $(LIB36) $(LIB41) $(LIB40) $(LIB23) $(LIBCOMPADJ) \
-		$(NETCLILIB) $(LIB2) $(LIB1) $(OTHERLIBS)
+		$(NETCLILIB) $(LIB2) $(LIBTLS) $(LIB1) $(GNUTLS_LIBS) $(OTHERLIBS)
 
 # test client for the suggest network service
 suggcli: suggcli.c $(BNETCLILIB) $(BLIB24)
--- ncbi-tools6-6.1.20170106+dfsg1.orig/make/makeshlb.unx
+++ ncbi-tools6-6.1.20170106+dfsg1/make/makeshlb.unx
@@ -1,4 +1,4 @@
-#
+# -*- makefile -*-
 #
 #	$Id: makeshlb.unx,v 6.1 1999/03/18 17:31:11 beloslyu Exp $
 #
@@ -12,7 +12,115 @@ SH1 = ld -G -o
 SH2 = `lorder *.o | tsort` $(NCBI_OTHERLIBS)
 
 %.so: %.a
-	rm -f *.o __*
+	rm -f *.o *.glo __*
 	ar x $<
+	case $< in \
+	    *OGL.a) for f in *.glo; do mv $$f `basename $$f .glo`.o; done ;; \
+	esac
 	$(SH1) $@ $(SH2)
 	rm -f *.o __*
+
+so=so.$(NCBI_VERSION_SHLIB)
+
+%.$(so): %.a
+	$(CC) -shared -Wl,-soname=$*.so.$(NCBI_VERSION_MAJOR) -o $@ \
+	    -Wl,--whole-archive $< -Wl,--no-whole-archive $(LDFLAGS) \
+	    $($*_deps) $($*_sysdeps)
+
+%.so.$(NCBI_VERSION_MAJOR): %.$(so)
+	ln -s $< $@
+	ln -s $< $*.so
+
+# Make libncbiCacc and libncbiacc pointers to libncbiNacc, since it's
+# the most useful variant in the usual (net-only) case.  Do the same
+# for libnetentr, and link the static version into libncbiNacc.so, due
+# to a circular dependency.
+libnetentr.$(so) libncbiCacc.$(so) libncbiacc.$(so):
+	ln -s libncbiNacc.$(so) $@
+
+# Standardize on the OpenGL-enabled versions of Vibrant, since there's
+# no longer any real penalty in doing so.
+libvibrant.$(so):
+	ln -s libvibrantOGL.$(so) $@
+libncbicn3d.$(so):
+	ln -s libncbicn3dOGL.$(so) $@
+
+libblast_deps       = libblastcompadj.$(so) libncbi.$(so)
+libblast_sysdeps    = -lm
+libblastapi_deps    = libblast.$(so) libncbitool.$(so) libncbiobj.$(so) \
+                      libncbi.$(so)
+libblastapi_sysdeps = -lm
+libblastcompadj_sysdeps = -lm
+libconnssl_deps     = libncbi.$(so)
+libconnssl_sysdeps  = -lgnutls
+libncbi_sysdeps     = -lm
+# libncbiCacc_deps    = libncbicdr.$(so) libnetentr.a libnetcli.$(so)
+libncbiNacc_deps    = libncbicdr.$(so) libnetentr.a libnetcli.$(so) \
+                      libncbiobj.$(so) libncbi.$(so)
+libncbiNacc_sysdeps = -lm
+# libncbiacc_deps     = libncbicdr.$(so)
+libncbicdr_deps     = libncbiobj.$(so) libncbi.$(so)
+libncbiid1_deps     = libncbiobj.$(so) libnetcli.$(so) libncbi.$(so)
+libncbimla_deps     = libncbiobj.$(so) libnetcli.$(so) libncbi.$(so)
+libncbimmdb_deps    = libncbiid1.$(so) libncbitool.$(so) libncbiobj.$(so) \
+                      libncbi.$(so)
+libncbimmdb_sysdeps = -lm
+libncbiobj_deps     = libncbi.$(so)
+libncbiobj_sysdeps  = -lm
+libncbitool_deps    = libblastcompadj.$(so) libncbiobj.$(so) libncbi.$(so)
+libncbitool_sysdeps = -lm
+libncbitxc2_deps    = libncbitool.$(so) libnetcli.$(so) libncbiobj.$(so) \
+                      libncbi.$(so)
+libncbitxc2_sysdeps = -lm
+libnetblast_deps    = libncbitool.$(so) libnetcli.$(so) libncbiobj.$(so) \
+                      libncbi.$(so)
+libnetcli_deps      = libncbi.$(so)
+# libnetentr_deps     = libncbiacc.$(so) libnetcli.$(so)
+libvibgif_deps      = libncbi.$(so)
+libvibgif_sysdeps   = -lm
+
+libddvlib_deps        = libncbidesk.$(so) libvibrantOGL.$(so) \
+                        libncbitool.$(so) libncbiobj.$(so) libncbi.$(so)
+libncbicn3d_deps      = libncbiNacc.$(so) libddvlib.$(so) libncbidesk.$(so) \
+                        libncbimmdb.$(so) libncbitool.$(so) libncbiobj.$(so) \
+                        libncbi.$(so)
+libncbicn3dOGL_deps   = $(libncbicn3d_deps) libvibrantOGL.$(so)
+libncbicn3dOGL_sysdeps = -lm
+libncbidesk_deps      = libblastapi.$(so) libncbimmdb.$(so) libncbitool.$(so) \
+                        libvibrantOGL.$(so) libncbiobj.$(so) libncbi.$(so)
+libncbidesk_sysdeps   = -lm
+libvibnet_deps        = libncbiNacc.$(so) libncbidesk.$(so) libncbimmdb.$(so) \
+                        libvibrantOGL.$(so) libncbitool.$(so) \
+                        libncbicdr.$(so) libncbiobj.$(so) libncbi.$(so)
+# libvibrant_deps     = libncbi.$(so)
+# libvibrant_sysdeps  = $(VIBLIBS)
+# for ddvcolor stuff
+libvibrantOGL_deps    = libncbiobj.$(so) libncbi.$(so)
+libvibrantOGL_sysdeps = $(OGLLIBS) $(VIBLIBS) -lm
+
+# XXX - is there a way to express these programmatically?
+libblast.$(so):    $(libblast_deps)
+libblastapi.$(so): $(libblastapi_deps)
+libconnssl.$(so):  $(libconnssl_deps)
+# libncbiCacc.$(so): $(libncbiCacc_deps)
+libncbiNacc.$(so): $(libncbiNacc_deps)
+# libncbiacc.$(so):  $(libncbiacc_deps)
+libncbicdr.$(so):  $(libncbicdr_deps)
+libncbiid1.$(so):  $(libncbiid1_deps)
+libncbimla.$(so):  $(libncbimla_deps)
+libncbimmdb.$(so): $(libncbimmdb_deps)
+libncbiobj.$(so):  $(libncbiobj_deps)
+libncbitool.$(so): $(libncbitool_deps)
+libncbitxc2.$(so): $(libncbitxc2_deps)
+libnetblast.$(so): $(libnetblast_deps)
+libnetcli.$(so):   $(libnetcli_deps)
+# libnetentr.$(so): $(libnetentr_deps)
+
+libddvlib.$(so):      $(libddvlib_deps)
+# libncbicn3d.$(so):  $(libncbicn3d_deps)
+libncbicn3dOGL.$(so): $(libncbicn3dOGL_deps)
+libncbidesk.$(so):    $(libncbidesk_deps)
+libvibgif.$(so):      $(libvibgif_deps)
+libvibnet.$(so):      $(libvibnet_deps)
+# libvibrant.$(so):   $(libvibrant_deps)
+libvibrantOGL.$(so):  $(libvibrantOGL_deps)
--- ncbi-tools6-6.1.20170106+dfsg1.orig/tools/readdb.c
+++ ncbi-tools6-6.1.20170106+dfsg1/tools/readdb.c
@@ -10167,7 +10167,10 @@ static    Int2    FDBFinish (FormatDBPtr
             return 1;
     
     MemSet(dateTime, 0, DATETIME_LENGTH);
-    Nlm_DayTimeStr(dateTime, TRUE, TRUE);
+    /* SOURCE_DATE_EPOCH specification: "If the value is malformed, the
+       build process SHOULD exit with a non-zero error code." */
+    if (!Nlm_DayTimeStr(dateTime, TRUE, TRUE))
+      return 1;
 
     /* write db_title and date-time stamp eigth bytes aligned */
     tmp = title_len + StringLen(dateTime);
--- ncbi-tools6-6.1.20170106+dfsg1.orig/vibrant/netscape.c
+++ ncbi-tools6-6.1.20170106+dfsg1/vibrant/netscape.c
@@ -548,9 +548,8 @@ static Boolean NS_LoadNetscape(const cha
     }
 
     /* ---------- child process ------------ */
-    if (execlp("netscape", "netscape", url, NULL) < 0  &&
-        execl(NETSCAPE_PATH, NETSCAPE_PATH, url, NULL) < 0) {
-        Message(MSG_ERROR, "Failure to open URL in netscape window");
+    if (execlp("sensible-browser", "sensible-browser", url, NULL) < 0) {
+        Message(MSG_ERROR, "Failure to open URL in browser window");
         exit(1);
     }
 
--- ncbi-tools6-6.1.20170106+dfsg1.orig/vibrant/shim3d.c
+++ ncbi-tools6-6.1.20170106+dfsg1/vibrant/shim3d.c
@@ -321,6 +321,7 @@
 
 #ifdef _PNG
 #include <png.h> /* must go berore ncbi headers */
+#include <zlib.h>
 #ifndef png_jmpbuf
 #define png_jmpbuf(x) ((x)->jmpbuf)
 #endif
@@ -339,7 +340,8 @@ NLM_EXTERN void LIBCALL Nlm_HeapSort PRO
 #include <ddvcolor.h>
 
 #if defined(_OPENGL) && defined(_PNG)
-TOGL_Data *Cn3D_GetCurrentOGLData(void); /* in cn3dxprt.c */
+/* In cn3dxprt.c; declared weak here to avoid dependency loops. */
+extern TOGL_Data *Cn3D_GetCurrentOGLData(void) __attribute__((weak));
 #endif
 
 
@@ -2939,7 +2941,15 @@ void Nlm_SaveImagePNG(Nlm_Char *fname)
     png_structp png_ptr = NULL;
     png_infop info_ptr = NULL;
     Nlm_Boolean doInterlacing = TRUE;
-    TOGL_Data *OGL_Data = (TOGL_Data *)(Cn3D_GetCurrentOGLData());
+    TOGL_Data *OGL_Data;
+    
+    if (!Cn3D_GetCurrentOGLData) {
+      Message(MSG_ERROR, "PNG output unavailable; "
+	      "please relink application with -lncbicn3d.");
+      return;
+    }
+    
+    OGL_Data = (TOGL_Data *)(Cn3D_GetCurrentOGLData());
 
 #if defined(WIN_MOTIF)
     GLint glSize;
@@ -3720,4 +3730,3 @@ void Nlm_AddHalfWorm3D(Nlm_Picture3D pic
     if (fblock)
         MemFree(fblock);
 }
-
--- ncbi-tools6-6.1.20170106+dfsg1.orig/vibrant/vibmain.c
+++ ncbi-tools6-6.1.20170106+dfsg1/vibrant/vibmain.c
@@ -44,6 +44,21 @@
 
 
 
+extern Nlm_Int2 Nlm_Main(void) __attribute__((weak));
+
+static Nlm_Int2 s_CallNlmMain(void)
+{
+  if (Nlm_Main) {
+    return Nlm_Main();
+  } else {
+    ErrPost(0, 0, "Neither main nor Nlm_Main defined by program.");
+    return -1;
+  }
+}
+
+#define Nlm_Main s_CallNlmMain
+
+
 #ifdef WIN_MAC
 #ifdef OS_UNIX_DARWIN
 int main (int argc, char *argv[]) 
--- ncbi-tools6-6.1.20170106+dfsg1.orig/vibrant/vibwndws.c
+++ ncbi-tools6-6.1.20170106+dfsg1/vibrant/vibwndws.c
@@ -6818,7 +6818,7 @@ extern void Nlm_VibMainPrelude (int argc
   Nlm_InitPrompt ();
   Nlm_InitSlate ();
   Nlm_InitTexts ();
-  if (! Nlm_SetupWindows ()) return;
+  if (! Nlm_SetupWindows ()) exit(1);
   Nlm_RegisterWindows ();
   Nlm_RegisterTexts ();
   Nlm_RegisterSlates ();
