Index: trunk/psLib/configure.ac
===================================================================
--- trunk/psLib/configure.ac	(revision 33955)
+++ trunk/psLib/configure.ac	(revision 34089)
@@ -27,5 +27,5 @@
 AC_SUBST(PSLIB_LT_VERSION,$PSLIB_LT_VERSION)
 
-IPP_STDCFLAGS
+IPP_STDLDFLAGS
 
 dnl ------------------- PERL options ---------------------
@@ -473,7 +473,5 @@
 dnl ------- enable -Werror after all of the probes have run ---------
 IPP_STDOPTS
-
-CFLAGS="${CFLAGS} -Wall -Werror"
-dnl enable POSIX/XSI and C99 compliance
+IPP_STDCFLAGS
 CFLAGS="${CFLAGS=} -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L"
 
Index: trunk/psLib/m4/ipp_stdopts.m4
===================================================================
--- trunk/psLib/m4/ipp_stdopts.m4	(revision 33955)
+++ trunk/psLib/m4/ipp_stdopts.m4	(revision 34089)
@@ -1,5 +1,7 @@
 
+dnl IPP_STDCFLAGS must go *after* external probes (to avoid Werror confusing things)
 AC_DEFUN([IPP_STDCFLAGS],
 [
+    dnl this section currently overrides a user-defined CFLAGS
     AC_ARG_ENABLE(optimize,
       [AS_HELP_STRING(--enable-optimize,enable compiler optimization)],
@@ -12,5 +14,45 @@
       ]
     )
+    dnl this section accepts a user-defined CFLAGS, and sets CFLAGS to the empty string if not present
+    AC_ARG_ENABLE(debug-build,
+      [AS_HELP_STRING(--enable-debug-build,enable debug build: ie disable Werror)],
+      [AC_MSG_RESULT(debug build enabled)
+        if test x"${CFLAGS}" == x; then
+          CFLAGS="-Wall"
+	else
+          CFLAGS="${CFLAGS=} -Wall"
+        fi
+      ],
+      [AC_MSG_RESULT([compile optimization disabled])
+        if test x"${CFLAGS}" == x; then
+          CFLAGS="-Wall -Werror"
+	else
+          CFLAGS="${CFLAGS=} -Wall -Werror"
+        fi
+      ]
+    )
 ])
+
+dnl IPP_STDLDFLAGS must go *before* external probes (so linking is done with --no-as-needed if needed)
+AC_DEFUN([IPP_STDLDFLAGS],
+[
+    dnl this section accepts a user-defined LDFLAGS, and sets LDFLAGS to the empty string if not present
+    AC_ARG_ENABLE(no-as-needed, 
+      [AS_HELP_STRING(--enable-no-as-needed, prevent as-needed option sometimes supplied to gcc such as Ubuntu after 11.11)],
+      [AC_MSG_RESULT(no-as-needed passed to linker) 
+      	if test x"${LDFLAGS}" == x; then
+          LDFLAGS="-Wl,--no-as-needed"
+	else
+          LDFLAGS="${LDFLAGS=} -Wl,--no-as-needed"
+	fi
+      ],
+      [AC_MSG_RESULT(as-needed linker flags accepted) 
+      	if test x"${LDFLAGS}" == x; then
+          LDFLAGS=""
+	fi
+      ]
+    )
+])
+dnl
 
 AC_DEFUN([IPP_STDOPTS],
Index: trunk/psLib/src/astro/psTime.c
===================================================================
--- trunk/psLib/src/astro/psTime.c	(revision 33955)
+++ trunk/psLib/src/astro/psTime.c	(revision 34089)
@@ -223,5 +223,4 @@
 static bool timeInit(const char *fileName)
 {
-    psS32 numLines = 0;
     bool foundTable = false;
     char *tableDir = NULL;
@@ -390,5 +389,5 @@
         if (i < numTables) {
             table = psLookupTableAlloc(fullTableName, (const char*)tableFormat, tablesIndex->data.S32[i]);
-            numLines = psLookupTableRead(table);
+            psLookupTableRead(table);
         } else {
             psError(PS_ERR_BAD_PARAMETER_VALUE, no_problem,
Index: trunk/psLib/src/fits/psFitsTable.c
===================================================================
--- trunk/psLib/src/fits/psFitsTable.c	(revision 33955)
+++ trunk/psLib/src/fits/psFitsTable.c	(revision 34089)
@@ -511,5 +511,5 @@
                 colSpec *spec = psAlloc(sizeof(colSpec)); // Specification for this column
                 // BOOL type is not a valid vector type, so we translate it to U8
-                spec->type = colItem->type == PS_TYPE_BOOL ? PS_TYPE_U8 : colItem->type;
+                spec->type = colItem->type == PS_DATA_BOOL ? PS_DATA_U8 : colItem->type;
                 spec->size = size;
                 if (colItem->type == PS_DATA_VECTOR) {
@@ -526,5 +526,5 @@
                 }
                 if (colItem->type != spec->type &&
-                    colItem->type != PS_TYPE_BOOL && spec->type != PS_TYPE_U8) {
+                    colItem->type != PS_DATA_BOOL && spec->type != PS_DATA_U8) {
                     psWarning("Differing type found for column %s: %x vs %x --- using the first found.\n",
                               colSpecItem->name, colItem->type, spec->type);
Index: trunk/psLib/src/imageops/psImageGeomManip.c
===================================================================
--- trunk/psLib/src/imageops/psImageGeomManip.c	(revision 33955)
+++ trunk/psLib/src/imageops/psImageGeomManip.c	(revision 34089)
@@ -580,5 +580,4 @@
     psS32 outRows;
     psS32 outCols;
-    psS32 elementSize;
     psElemType type;
 
@@ -594,5 +593,5 @@
     outCols = input->numCols;
     type = input->type.type;
-    elementSize = PSELEMTYPE_SIZEOF(type);
+    // XXX unused psS32 elementSize = PSELEMTYPE_SIZEOF(type);
     out = psImageRecycle(out, outCols, outRows, type);
 
Index: trunk/psLib/src/imageops/psImageInterpolate.c
===================================================================
--- trunk/psLib/src/imageops/psImageInterpolate.c	(revision 33955)
+++ trunk/psLib/src/imageops/psImageInterpolate.c	(revision 34089)
@@ -461,4 +461,10 @@
     }
 
+#define INTERPOLATE_CHECK() \
+    if (xMin < 0) { /* XXX warn or error? */ } \
+    if (yMin < 0) { /* XXX warn or error? */ } \
+    if (xMax >= image->numCols) { /* XXX warn or error? */ } \
+    if (yMax >= image->numRows) { /* XXX warn or error? */ } \
+
 // Determine the result of the interpolation after all the math has been done
 static psImageInterpolateStatus interpolateResult(const psImageInterpolation *interp,
@@ -523,4 +529,5 @@
     }
     INTERPOLATE_RANGE();
+    INTERPOLATE_CHECK();
 
     // Get the appropriate kernels
@@ -779,4 +786,5 @@
     }
     INTERPOLATE_RANGE();
+    INTERPOLATE_CHECK();
 
     // Get the appropriate kernels
@@ -989,4 +997,5 @@
     INTERPOLATE_SETUP(x, y);
     xExact = yExact = false;
+    if (xExact && yExact) { /* possible alternative */ }
 
     psF32 xKernel[size], yKernel[size]; // Interpolation kernels
@@ -1038,4 +1047,5 @@
     INTERPOLATE_SETUP(x, y);
     xExact = yExact = false;
+    if (xExact && yExact) { /* possible alternative */ }
 
     psF32 xKernel[size], yKernel[size]; // Interpolation kernels
Index: trunk/psLib/src/imageops/psImageStructManip.c
===================================================================
--- trunk/psLib/src/imageops/psImageStructManip.c	(revision 33955)
+++ trunk/psLib/src/imageops/psImageStructManip.c	(revision 34089)
@@ -212,4 +212,6 @@
     elementSize = PSELEMTYPE_SIZEOF(inDatatype);
 
+    if (0) { fprintf (stderr, "%d elements, %d total memory\n", elements, elements * elementSize); }
+
     output = p_psImageRecycle(file, lineno, func, output, numCols, numRows, type);
     P_PSIMAGE_SET_COL0(output, input->col0);
Index: trunk/psLib/src/math/psMinimizePowell.c
===================================================================
--- trunk/psLib/src/math/psMinimizePowell.c	(revision 33955)
+++ trunk/psLib/src/math/psMinimizePowell.c	(revision 34089)
@@ -367,7 +367,4 @@
     psF32 c = 0.0;
     psF32 n = 0.0;
-    psF32 fa = 0.0;
-    psF32 fb = 0.0;
-    psF32 fc = 0.0;
     psF32 fn = 0.0;
     psF32 mul = 0.0;
@@ -415,8 +412,10 @@
         PS_VECTOR_ADD_MULTIPLE(params, paramMask, line, tmpb, b);
         PS_VECTOR_ADD_MULTIPLE(params, paramMask, line, tmpc, c);
-        fa = func(tmpa, coords);
-        fb = func(tmpb, coords);
-        fc = func(tmpc, coords);
+        psF32 fb = func(tmpb, coords);
+# if (PS_TRACE_ON)
+        psF32 fa = func(tmpa, coords);
+        psF32 fc = func(tmpc, coords);
         psTrace("psLib.math", 6, "LineMin: f(%f %f %f) is (%f %f %f)\n", a, b, c, fa, fb, fc);
+# endif
 
         // We determine which is the biggest segment in [a,b,c] then split
Index: trunk/psLib/src/mathtypes/psVector.c
===================================================================
--- trunk/psLib/src/mathtypes/psVector.c	(revision 33955)
+++ trunk/psLib/src/mathtypes/psVector.c	(revision 34089)
@@ -322,13 +322,9 @@
             PSVECTOR_COPY_SAME_CASE(F32);
             PSVECTOR_COPY_SAME_CASE(F64);
-        default: {
-                char* typeStr;
-                PS_TYPE_NAME(typeStr,type);
-                psError(PS_ERR_BAD_PARAMETER_TYPE, true,
-                        //                        _("Input psVector is an unsupported type (0x%x)."), typeStr);
-                        "Input psVector is an unsupported type.\n");
-                psFree(output);
-                return NULL;
-            }
+	  default: {
+	      psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Input psVector is an unsupported type.\n");
+	      psFree(output);
+	      return NULL;
+	  }
         }
         return output;
Index: trunk/psLib/src/types/psLookupTable.c
===================================================================
--- trunk/psLib/src/types/psLookupTable.c	(revision 33955)
+++ trunk/psLib/src/types/psLookupTable.c	(revision 34089)
@@ -607,5 +607,4 @@
     psU64 loIdx = 0;
     long  numRows = 0;
-    long numCols = 0;
     psF64 out = 0.0;
     psF64 denom = 0.0;
@@ -619,5 +618,4 @@
     values = table->values;
     numRows = table->index->n;
-    numCols = table->values->n;
     valuesVec = (psVector*)values->data[column];
 
Index: trunk/psLib/src/types/psMetadata.c
===================================================================
--- trunk/psLib/src/types/psMetadata.c	(revision 33955)
+++ trunk/psLib/src/types/psMetadata.c	(revision 34089)
@@ -1504,5 +1504,4 @@
               fprintf(fd, "\n");
               break;
-            case PS_DATA_UNKNOWN:
             default:
               fprintf(fd, "<Unsupported type>\n");
Index: trunk/psLib/src/types/psMetadataConfig.c
===================================================================
--- trunk/psLib/src/types/psMetadataConfig.c	(revision 33955)
+++ trunk/psLib/src/types/psMetadataConfig.c	(revision 34089)
@@ -1573,5 +1573,4 @@
             }
             break;
-        case PS_DATA_UNKNOWN:
         default:
             psError(PS_ERR_BAD_PARAMETER_VALUE, true,
Index: trunk/psLib/src/types/psMetadataItemCompare.c
===================================================================
--- trunk/psLib/src/types/psMetadataItemCompare.c	(revision 33955)
+++ trunk/psLib/src/types/psMetadataItemCompare.c	(revision 34089)
@@ -129,10 +129,11 @@
   case PS_TYPE_##COMPARETYPENAME: { \
       TEMPLATETYPE valueC = (TEMPLATETYPE)compare->data.COMPARENAME; \
-      TEMPLATETYPE valueT = (TEMPLATETYPE)template->data.TEMPLATENAME; \
-      /* XXX check the validiy of the type casting? */ \
-      if (valueC != compare->data.COMPARENAME) { \
-          return false; \
-      } \
-      COMPARE_VALUES(valueT, valueC, (template->type == PS_TYPE_F32 || template->type == PS_TYPE_F64)); \
+      TEMPLATETYPE valueT = (TEMPLATETYPE)template->data.TEMPLATENAME;	\
+      /* XXX check the validiy of the type casting? */			\
+      if (valueC != compare->data.COMPARENAME) {			\
+	return false;							\
+      }									\
+      COMPARE_VALUES(valueT, valueC, (template->type == PS_DATA_F32 || template->type == PS_DATA_F64)); \
+      /* COMPARE_VALUES(valueT, valueC, 1);				*/  \
       psAbort("Should never reach here."); \
   }
@@ -277,5 +278,5 @@
                     return false;
                 }
-                double compareValue = compare->type == PS_TYPE_F32 ? compare->data.F32 : compare->data.F64;
+                double compareValue = compare->type == PS_DATA_F32 ? compare->data.F32 : compare->data.F64;
                 COMPARE_VALUES(templateValue, compareValue, true);
             }
Index: trunk/psLib/test/tap/src/tap.c
===================================================================
--- trunk/psLib/test/tap/src/tap.c	(revision 33955)
+++ trunk/psLib/test/tap/src/tap.c	(revision 34089)
@@ -87,5 +87,6 @@
     if(test_name != NULL) {
         va_start(ap, test_name);
-        vasprintf(&local_test_name, test_name, ap);
+        int status = vasprintf(&local_test_name, test_name, ap);
+	if (status) {/* warning? */}
         va_end(ap);
 
@@ -303,5 +304,6 @@
 
     va_start(ap, fmt);
-    asprintf(&skip_msg, fmt, ap);
+    int status = asprintf(&skip_msg, fmt, ap);
+    if (status) {/* warning? */}
     va_end(ap);
 
@@ -328,5 +330,6 @@
 
     va_start(ap, fmt);
-    vasprintf(&todo_msg, fmt, ap);
+    int status = vasprintf(&todo_msg, fmt, ap);
+    if (status) {/* warning? */}
     va_end(ap);
 
