Index: src/Makefile
===================================================================
--- src/Makefile	(revision 284998)
+++ src/Makefile	(working copy)
@@ -7,6 +7,8 @@
 #
 # who       when      what
 # --------  --------  ----------------------------------------------
+# jpritcha  2016/10/01  Added 32bit target which will force 32bit compilation 
+#                       on 64bit OS (Implemented for Linux ONLY)
 # rschmutz  28/01/03  install configure in INTROOT.
 # rschmutz  28/01/03  target expert_release added.
 # rschmutz  15/01/03  Tcl *.s[lo] libraries added to release file.
@@ -93,7 +95,11 @@
 #  the executable that is built is called 'configure'. There is no file
 #  used by the system called 'fposs', meaning that the system-specific 
 #  make action is always executed.
-   
+
+32bit : 
+	export MK32BIT=true ; \
+	make -f Makefile_`uname` ../bin/configure
+
 all : 
 	make -f Makefile_`uname` ../bin/configure
            
Index: src/Makefile_Linux
===================================================================
--- src/Makefile_Linux	(revision 284998)
+++ src/Makefile_Linux	(working copy)
@@ -7,6 +7,9 @@
 #
 # who       when        what
 # --------  ----------  --------------------------------------------------------
+# jpritcha  2016/10/01  Added support for Linux_x86_64
+#                       - Compile and link in 64bit on 64bit OS
+#                       - Force 32bit compilation on 64bit OS with variable MK32BIT = true
 # pbaksai   2014/07/22  CCB-000755: Support for 64 bits.
 #                       - Fixed location of X11 lib.
 #                       - Fixed location of Tcl include and lib.
@@ -92,22 +95,39 @@
 #     is assumed to be the same.
 #   - To compile in a non-VLT system, directories are changed assuming it
 #     compiles from inside the FPOSS package.
+#   - Ubuntu puts TCL inlcude files in /usr/include/tcl<VERSION>
+#     direcctories and i386 libraries in /usr/lib/i386-linux-gnu on
+#     x86_64 OSs
+#     
+#     
 #
 X11_LIB := $(shell (test -f /usr/lib/libX11.so && echo /usr/lib) || \
                    (test -f /usr/lib/libX11.so.6 && echo /usr/lib) || \
+                   (test -n "$$MK32BIT" && test -f /usr/lib/i386-linux-gnu/libX11.so.6 && echo /usr/lib/i386-linux-gnu) || \
                    (test -d /usr/X11R?/lib && eval echo /usr/X11R?/lib) || \
-                   echo ../tcltk/lib)
-TCL_LIB := $(shell (test -d /vlt/$$VLTSW_RELEASE/tcltk/lib && echo /vlt/$$VLTSW_RELEASE/tcltk/lib) || \
-                   (test -n "$$TCLTK_LIB" && echo $$TCLTK_LIB) || \
                    echo "/usr/lib")
-TCL_DIR := $(shell (test -d /vlt/$$VLTSW_RELEASE/tcltk/include && echo /vlt/$$VLTSW_RELEASE/tcltk/include) || \
-                   echo "../tcltk/include" )
-TCL_VERSION := $(shell echo "puts [info tclversion]" | tclsh 2>/dev/null)
+
+## TCL version
+## -----------
+## to control manually use:
+# export TCL_VERSION=8.5
 ifeq "$(TCL_VERSION)" ""
-TCL_VERSION := $(shell (test -n "$$TCLTK_VERSION" && echo $$TCLTK_VERSION) || echo 8.3)
+  TCL_VERSION := $(shell echo "puts [info tclversion]" | tclsh 2>/dev/null)
 endif
+ifeq "$(TCL_VERSION)" ""
+  TCL_VERSION := $(shell (test -n "$$TCLTK_VERSION" && echo $$TCLTK_VERSION) || echo 8.3)
+endif
 TK_VERSION = $(TCL_VERSION)
 
+TCL_LIB := $(shell (test -d /vlt/$$VLTSW_RELEASE/tcltk/lib && echo /vlt/$$VLTSW_RELEASE/tcltk/lib) || \
+                   (test -n "$$TCLTK_LIB" && echo $$TCLTK_LIB) || \
+                   (test -n "$$MK32BIT" && test -f /usr/lib/i386-linux-gnu/libtcl$(TCL_VERSION).so && echo /usr/lib/i386-linux-gnu) || \
+                   echo ../tcltk/lib)
+TCL_DIR := $(shell (test -d /vlt/$$VLTSW_RELEASE/tcltk/include && echo /vlt/$$VLTSW_RELEASE/tcltk/include) || \
+                   (test -f /usr/include/tcl$$TCL_VERSION/tcl.h && echo /usr/include/tcl$$TCL_VERSION ) || \
+                   (test -n "$$TCLTK_DIR" && echo $$TCLTK_DIR) || \
+                   echo "../tcltk/include" )
+
 #*******************************************************************************
 #  Standard C settings. We use gcc with optimise selected and with the maximum
 #  warnings . The DFLAMES_ONLY flag prevents the inclusion of code to support
@@ -114,7 +134,16 @@
 #  the AAO's 2dF and 6dF instruments, limiting support to ESO's FLAMES system.
 
 COPT = -O -m32
-CWARNINGS = -Wall -ansi -DUSE_COMPAT_CONST
+LOPT = -m32
+ifndef MK32BIT
+  ifeq ($(shell uname -i),x86_64)
+    COPT = -O3 -D__linux_x86_64__
+    LOPT =
+  endif
+endif
+CWARNINGS = -Wall -ansi -DUSE_COMPAT_CONST -DUSE_INTERP_RESULT
+## The following is useful for debugging...
+#CWARNINGS = -Wall -ansi -DUSE_COMPAT_CONST -DUSE_INTERP_RESULT -Wno-unused -Wno-deprecated-declarations -Wno-format-security
 CINCLUDES = -I$(TCL_DIR) -I$(SDS_SRC) -I$(DRAMA_SRC) -I$(SLA_SRC) -I$(FPCOL_SRC) -I$(PAFCHK_MODULE)/include -I.
 CFLAGS = -DFLAMES_ONLY -DDRAMA_BUILD $(CWARNINGS) $(COPT) $(CINCLUDES)
 CC = gcc
@@ -148,7 +177,7 @@
            fpcolMdl.o fpcolMdlFit.o fpcolMdlCalModel.o \
            tdFparse.o tdFconvertSds.o \
            configversion.o convertPAF.o sla.o pafchkChecksum.o crc32.o libsds.a \
-           -m32 \
+           $(LOPT) \
            -L$(TCL_LIB) -ltk$(TK_VERSION) -ltcl$(TCL_VERSION) \
            -L$(X11_LIB) -lX11 -lm -ldl
               
Index: src/config_method.c
===================================================================
--- src/config_method.c	(revision 284998)
+++ src/config_method.c	(working copy)
@@ -240,6 +240,10 @@
  *      2nd Oct 2002.  Fixed malloc leaks due to the allocation of Pivot and
  *                     ConeTargets arrays. KS.
  *     21st Dec 2002.  fibreType arg. added to *ColInvPos functions.
+ * 
+ * 
+ * 
+ * jpritcha 2016-10-05 Bug fix at lie 5885
  *
  *  Bugs and limitations:
  *     o  The Oxford algorithm was rather bolted onto this code and in places
@@ -5881,8 +5885,18 @@
                                   *  a low-priority target, we flag it as 
                                   *  having been auto-deallocated.
                                   */
-                                  
-                                 if (!TargetInfo[LTarget].Type == 'S'){
+/*
+ * J.Pritchard, 2016-10-05
+ * Following line corrected on the basis of compiler warning
+ * 
+ * config_method.c: In function ‘ConfigMethodConeAllocate’:
+ * config_method.c:5885:65: warning: comparison of constant ‘83’ with boolean expression is always false [-Wbool-compare]
+ *                                   if (! TargetInfo[LTarget].Type == 'S'){
+ *                                                                  ^
+ * 
+                                 if (!TargetInfo[LTarget].Type = 'S'){
+ */
+                                 if (TargetInfo[LTarget].Type != 'S'){
                                     CONFIG_METHOD_Global.
                                          TargetMatrix[LTarget].TargetPivot=-2;
                                  }
Index: src/configure.c
===================================================================
--- src/configure.c	(revision 284998)
+++ src/configure.c	(working copy)
@@ -5,6 +5,8 @@
 *
 * who       when        what
 * --------  ----------  ----------------------------------------------
+* jpr       2016/10/03  Support for Linux_x86_64 native, cleaned up DEBUG
+*                       from previous devel work for Mac OS X porting
 * jpr/pba   2016/06/22  PPRS-65719: Corrected error in proper motion.
 * jpritcha  2016-04-20  Mac OS X-alizing
 * mpruemm   2009-06-23  Fix a few signed/unsigned mismatches.
@@ -214,11 +216,7 @@
 #ifdef DEBUG
 #undef DEBUG
 #endif
-#if 0
-  #define DEBUG printf
-#else
-  #define DEBUG
-#endif
+#define DEBUG printf
 
 /*  By default, at present, PAF files do not have checksums included. To
  *  enable the writing of checksums change USE_CHECKSUM to a non-zero value.
@@ -3182,7 +3180,12 @@
     short ExpertMode;              /* True if program is in expert mode */
     SdsIdType updateID  = 0;       /* ID for Update time in instrument file */
     StatusType localStatus;        /* Inherited status variable */
+/* Linux x86_64 */
+#if defined(__linux_x86_64__)
+    long modTime;                   /* Instrument file modification time */
+#else
     int modTime;                   /* Instrument file modification time */
+#endif
     unsigned long actlen;          /* Actual length of SDS item */
     struct tm* tmPtr;              /* Used to convert modification time */
     int length;                    /* Number of characters in string */      
@@ -4133,19 +4136,14 @@
            char* CommentPtr = NextChar;
            Key = ConfParseComment (CommentPtr, Keyword, Value, &NextChar);
            if (!Key) break;
-           DEBUG("Keyword = %s = %s\n",Keyword, Value);
            if (!strncmp(Keyword,"PM_RA",5)) {
                *PmRa = atof(Value) * PI / (60.0 * 60.0 * 180.0);
-               DEBUG("PmRa = %f\n",atof(Value));
-               DEBUG("PmRa = %f\n",&PmRa);
                Found = TRUE;
            } else if (!strncmp(Keyword,"PM_DEC",6)) {
                *PmDec = atof(Value) * PI / (60.0 * 60.0 * 180.0);
-               DEBUG("PmDec = %f\n",&PmDec);
                Found = TRUE;
            }
        }
-       DEBUG("PmRa,PmDec = %f,%f\n",&PmRa,&PmDec);
     }
     
     return (Found);
@@ -4638,7 +4636,7 @@
             if (strlen(value) > 0) {
                 if (!strncmp(keyword,"PM_RA",5)) {
                     printf("correcting PM_RA with value %s for %s\n",value,name);
-                    sprintf(value,"%*f",strlen(value),atof(value)/cos(dec));
+                    sprintf(value,"%*f",(int) strlen(value),atof(value)/cos(dec));
                 }
                 fprintf (listing,"%s%s        %s;\n",prefix,keyword,value);
             }
@@ -5791,19 +5789,10 @@
         sprintf(buffer,
             "UT set to %.4d/%.2d/%.2d  %.2d:%.2d:%.2d to put field on meridian",
             iy, im, idd, ihmsf[0], ihmsf[1], ihmsf[2]);
-/*      DEBUG(
-         "UT set to %.4d/%.2d/%.2d  %.2d:%.2d:%.2d to put field on meridian\n",
-            iy,im,idd,ihmsf[0],ihmsf[1],ihmsf[2]);
-            */
     } else {
         sprintf(buffer,
           "UT set to %.4d/%.2d/%.2d %.2d:%.2d:%.2d to put field at HA %f hours",
             iy, im, idd, ihmsf[0], ihmsf[1], ihmsf[2], atof(argv[2]));
-/*
-       DEBUG(
-       "UT set to %.4d/%.2d/%.2d %.2d:%.2d:%.2d to put field at HA %f hours\n",
-             iy,im,idd,ihmsf[0],ihmsf[1],ihmsf[2],atof(argv[2]));
-             */
     }
     ConfMessage(interp, buffer);
 
@@ -6678,7 +6667,9 @@
      */
 
     slaMappa(2000.0, mjd, gmap);
+    /*
     DEBUG("gmap=pal.mappa(2000.0, %18.15e)\n",mjd);
+     */
 
     FpilSetObsWavelength(*Instrument,gwave);
     FpilModelCvtInit(TelModel, mjd, 0.0, gtemp, gpress, ghumid, gwave, gwave,
@@ -6953,8 +6944,11 @@
              
             SdsGet(cid, CMTLEN, i * CMTLEN, comment, &actlen, status);
             if (ConfGetProperMotions (comment,&pmra,&pmdec)) {
-                DEBUG("retruned PMs: %f,%f\n",pmra / PI * (60. * 60. * 180.),pmdec / PI * (60. * 60. * 180.));
+               /*
+		DEBUG("retruned PMs: %f,%f\n",pmra / PI * (60. * 60. * 180.),pmdec / PI * (60. * 60. * 180.));
+		*/
                slaMapqk(ra,dec,pmra/cos(dec),pmdec,0.0,0.0,gmap,&ara,&adec);
+/*
                 DEBUG("numpy.array(pal.mapqk(%18.15e,%18.15e,%18.15e,%18.15e,0.0,0.0,gmap))/pi*180.\n",ra,dec,pmra,pmdec);
                 DEBUG("returned Coords: %s :: %f %f :: %f %f\n",
                        "with" ,
@@ -6963,6 +6957,7 @@
                        ara / PI * 180.,
                        adec / PI * 180.
                        );
+ */
 /*               slaMapqk(ra,dec,pmra/cos(dec),pmdec,0.76813,-22.4,gmap,&ara,&adec);
  *               DEBUG("returned Coords [WITH Px+RV]: %s :: %f %f :: %f %f\n",
  *                      "with" ,
@@ -6974,6 +6969,7 @@
  */
             } else {
                slaMapqkz(ra, dec, gmap, &ara, &adec);
+/*
                 DEBUG("numpy.array(pal.mapqkz(%18.15e,%18.15e,gmap))/pi*180.\n",ra,dec);
                 DEBUG("returned Coords: %s :: %f %f :: %f %f\n",
                        "w/o ",
@@ -6982,6 +6978,7 @@
                        ara / PI * 180.,
                        adec / PI * 180.
                        );
+ */
             }
             FpilModelRd2Xy(TelModel, cra, cdec, ara, adec, mjd, &xf, &yf,
                 status);
Index: src/configure.tcl
===================================================================
--- src/configure.tcl	(revision 284998)
+++ src/configure.tcl	(working copy)
@@ -5,6 +5,8 @@
 #
 # who       when        what
 # --------  ----------  --------------------------------------------------------
+# jpritcha  2016/10/01  Removed spurious debugging terminal output left in after 
+#                       previous update
 # pbaksai   2015/02/07  CCB-000755: Support for 64 bits.
 #                       - Fixed font XLFD names.
 # rschmutz  2004-07-16  PPRS 13423: always pop-up "Argus Settings" panel.
@@ -918,7 +920,7 @@
             exit
         }
         if { $UtDateSpec != "" } {
-            puts "Ut date $UtDateSpec"
+            #puts "UT date $UtDateSpec"
             ApplyUTDate $UtDateSpec
         }
         SetTick OpenFile
@@ -7292,7 +7294,6 @@
     #  have to be passed separately to SetUT.
     
     set UtYear [lindex $UtDateSpec 0]
-    puts $UtYear
     set UtMonth [lindex $UtDateSpec 1]
     set UtDay [lindex $UtDateSpec 2]
     
@@ -8790,7 +8791,7 @@
            puts stderr "Cannot open $ConfigFile - type unknown"
        }
        if { $UtDateSpec != "" } {
-           puts "Ut date $UtDateSpec"
+           #puts "UT date $UtDateSpec"
            ApplyUTDate $UtDateSpec
        }
        DoAllocationBatch [SdsCopy $Cfid]
Index: src/convertPAF.c
===================================================================
--- src/convertPAF.c	(revision 284998)
+++ src/convertPAF.c	(working copy)
@@ -5,6 +5,8 @@
 *
 * who       when      what
 * --------  --------  ----------------------------------------------
+ * jpritcha 2016-10-04  removed no longer useful DEBUG statements
+ *                      added during macOS X version development.
 * jpr/pba   2016/06/22  PPRS-65719: Corrected error in proper motion.
 * rschmutz  03/02/03  ignore trailing spaces before ';'.
 * rschmutz  29/01/03  PPRS 8670: load INS.OSS.CHECKHA in PAF file.
@@ -94,11 +96,6 @@
                                      * hold a full file name and some text */
 static int PAF_CurrentLine;         /* Index of the next line in the file */
 
-#ifdef DEBUG
-#undef DEBUG
-#endif
-#define DEBUG printf
-
 #ifndef FALSE
 #define FALSE 0
 #endif
@@ -877,7 +874,6 @@
    int KeyCount;
    int Key;
    char* StringPtr;
-   char* vstr;
    char ValueString[128];
    
    /*  These define the optional keywords normally encoded into the
@@ -952,9 +948,6 @@
          }
          sprintf (ValueString,"(%s=%s)",Keywords[Key],StringPtr);
          strcat (ObjectDataPtr->CommentString,ValueString);
-          if (!strncmp(PAFKeywords[Key],"PM_RA",5)) {
-              printf("VS=%s\n",ValueString);
-          }
       }
    }
    
Index: src/drama/Ers.h
===================================================================
--- src/drama/Ers.h	(revision 284998)
+++ src/drama/Ers.h	(working copy)
@@ -108,6 +108,10 @@
 #elif defined(__macosx__)
 typedef long int IMPZ_INT4;
 
+/* Linux x86_64 - there may be a better test */
+#elif defined(__linux_x86_64__)
+typedef long int IMPZ_INT4;
+
 /* Linux architectures.  Think this is always 32 bits */
 #elif defined(__linux__)
 typedef int IMPZ_INT4;
Index: src/drama/status.h
===================================================================
--- src/drama/status.h	(revision 284998)
+++ src/drama/status.h	(working copy)
@@ -1,3 +1,8 @@
+/*  status.c                                                 */
+/*  jpr   2016/10/01   Added support for Linux_x86_64.       */
+/*  Jeremy Bailey      1998  Jul 13                          */
+/*                                                           */
+
 #ifndef STATUSINC
 #define STATUSINC
 #ifdef __cplusplus
@@ -85,6 +90,10 @@
 #elif defined(__macosx__)
 typedef long int StatusType;
 
+/* Linux x86_64 - there may be a better test */
+#elif defined(__linux_x86_64__)
+typedef long int StatusType;
+
 /* Linux architectures.  Think this is always 32 bits */
 #elif defined(__linux__)
 typedef int StatusType;
Index: src/sds/arg.c
===================================================================
--- src/sds/arg.c	(revision 284998)
+++ src/sds/arg.c	(working copy)
@@ -3429,9 +3429,14 @@
 /*
  *  Output the line
  */
+/* Linux x86_64 */
+#if defined(__linux_x86_64__)
+    if ((long)(*func))
+            (*func)(client_data,buffer,status);
+#else
     if ((int)(*func))
             (*func)(client_data,buffer,status);
-    
+#endif
 }
 
 
Index: src/sds/sds.c
===================================================================
--- src/sds/sds.c	(revision 284998)
+++ src/sds/sds.c	(working copy)
@@ -1,3 +1,4 @@
+/*  jpr   2016/10/01   Added support for Linux_x86_64.       */
 /* jpr/pba   2016/06/22  PPRS-65719: Added support for Mac OSX. */
 /*                                                  */
 /*            Self-Defining Data System             */
@@ -179,6 +180,13 @@
    static long  local_format[SDS_NCODES] = {0,0,0,LITTLEEND,LITTLEEND,LITTLEEND,
                                    LITTLEEND,LITTLEEND,IEEEBS,IEEEBS,0,LITTLEEND,LITTLEEND};
 
+#elif defined __linux_x86_64__
+
+   /* Linux x84_64  */
+
+   static long  local_format[SDS_NCODES] = {0,0,0,LITTLEEND,LITTLEEND,LITTLEEND,
+                                   LITTLEEND,LITTLEEND,IEEEBS,IEEEBS,0,LITTLEEND,LITTLEEND};
+
 #else
 
    /*  All others - e.g. SPARC, 680x0 etc.  */
Index: src/sds/sds.h
===================================================================
--- src/sds/sds.h	(revision 284998)
+++ src/sds/sds.h	(working copy)
@@ -1,4 +1,5 @@
 /*  SDS Include file                                         */
+/*  jpr   2016/10/01   Added support for Linux_x86_64.       */
 /*  jpr/pba   2016/06/22  PPRS-65719: Added support for Mac OSX. */
 /*  Jeremy Bailey      1998  Jul 13                          */
 /*                                                           */
@@ -62,6 +63,8 @@
 #define   SDS_BIGEND 0
 #elif defined __macosx__
 #define   SDS_BIGEND 0
+#elif defined __linux_x86_64__
+#define   SDS_BIGEND 0
 #else
 #define   SDS_BIGEND 1
 #endif
Index: src/sds/sdsutil.c
===================================================================
--- src/sds/sdsutil.c	(revision 284998)
+++ src/sds/sdsutil.c	(working copy)
@@ -1,3 +1,8 @@
+/*  sdsutil.c                                                */
+/*  jpr   2016/10/01   Added support for Linux_x86_64.       */
+/*  Jeremy Bailey      1998  Jul 13                          */
+/*                                                           */
+
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
@@ -192,7 +197,6 @@
   else
      size = buf[1];
 
-
 /*  Close the file and reopen it  */
 
   fclose(input);
