--- buildtools/Makefile
+++ buildtools/Makefile
@@ -33,10 +33,10 @@
 	        -o $@ $<
 
 typegen.o endiangen.o:%.o:%.c
-	$(CC_FOR_BUILD) -c -o $@ $<
+	$(CC_FOR_BUILD) $(CFLAGS) -c -o $@ $<
 
 $(PROGS):%:%.o
-	$(LD_FOR_BUILD) -o $@ $<
+	$(LD_FOR_BUILD) $(LDFLAGS) -o $@ $<
 
 clean: cleanlocal
 .PHONY: cleanlocal
--- converter/other/fiasco/codec/coeff.c
+++ converter/other/fiasco/codec/coeff.c
@@ -14,6 +14,7 @@
  *  $State: Exp $
  */
 
+#include <string.h>
 #include "config.h"
 
 #include "types.h"
--- converter/other/fiasco/codec/dfiasco.c
+++ converter/other/fiasco/codec/dfiasco.c
@@ -14,6 +14,9 @@
  *  $State: Exp $
  */
 
+#include <string.h>
+#include <stdlib.h>
+
 #include "config.h"
 
 #include "types.h"
--- converter/other/fiasco/input/basis.c
+++ converter/other/fiasco/input/basis.c
@@ -14,6 +14,7 @@
  *  $State: Exp $
  */
 
+#include <string.h>
 #include "config.h"
 
 #include "types.h"
--- converter/other/jpegtopnm.c
+++ converter/other/jpegtopnm.c
@@ -511,6 +511,7 @@
         pm_error("Input JPEG image has 'unknown' color space "
                  "(JCS_UNKNOWN).\n"
                  "We cannot interpret this image.");
+        *output_type_p = PPM_TYPE; /* not reached */
         break;
     case JCS_GRAYSCALE:
         *output_type_p = PGM_TYPE;
@@ -538,6 +539,7 @@
     default:
         pm_error("Internal error: unknown color space code %d passed "
                  "to set_color_spaces().", jpeg_color_space);
+        *output_type_p = PPM_TYPE; /* not reached */
     }
     pm_message("WRITING %s FILE", 
                *output_type_p == PPM_TYPE ? "PPM" : "PGM");
--- converter/other/pamtopfm.c
+++ converter/other/pamtopfm.c
@@ -239,6 +239,7 @@
               enum endian        const endian) {
     
     struct pfmHeader pfmHeader;
+    memset(&pfmHeader, 0, sizeof(pfmHeader));
     
     pfmHeader.width  = pamP->width;
     pfmHeader.height = pamP->height;
--- converter/other/pamtouil.c
+++ converter/other/pamtouil.c
@@ -377,11 +377,15 @@
     int i;
 
     for (i = 0; i < ncolors; ++i) {
-        cixel_map const cmapEntry = cmap[i];
-        if (cmapEntry.uilname)
+        cixel_map cmapEntry = cmap[i];
+        if (cmapEntry.uilname) {
             freeString(cmapEntry.uilname);
-        if (cmapEntry.rgbname)
+	    cmapEntry.uilname = NULL;
+	}
+        if (cmapEntry.rgbname) {
             freeString(cmapEntry.uilname);
+	    cmapEntry.rgbname = NULL;
+	}
     }
 }
 
--- converter/other/pgmtopbm.c
+++ converter/other/pgmtopbm.c
@@ -549,6 +549,8 @@
     converter.cols = cols;
     converter.convertRow = &dither8ConvertRow;
     converter.destroy = NULL;
+    converter.stateP = NULL;
+    converter.maxval = 0;
 
     /* Scale dither matrix. */
     for (row = 0; row < 16; ++row) {
@@ -621,6 +623,7 @@
     converter.cols = cols;
     converter.convertRow = &clusterConvertRow;
     converter.destroy = &clusterDestroy;
+    converter.maxval = 0;
 
     MALLOCVAR_NOFAIL(stateP);
 
--- converter/other/pnmtofits.c
+++ converter/other/pnmtofits.c
@@ -122,13 +122,13 @@
     	sprintf( card, "NAXIS3  =                    3                                                  " );
     	write_card( card ); ++i;
 	}
-    sprintf( card, "BSCALE  =         %E                                                   ", bscale );
+    sprintf( card, "BSCALE  =         %E                                                  ", bscale ); /* %E is 12 chars */
     write_card( card ); ++i;
-    sprintf( card, "BZERO   =         %E                                                   ", fits_bzero );
+    sprintf( card, "BZERO   =         %E                                                  ", fits_bzero );
     write_card( card ); ++i;
-    sprintf( card, "DATAMAX =         %E                                                   ", datamax );
+    sprintf( card, "DATAMAX =         %E                                                  ", datamax );
     write_card( card ); ++i;
-    sprintf( card, "DATAMIN =         %E                                                   ", datamin );
+    sprintf( card, "DATAMIN =         %E                                                  ", datamin );
     write_card( card ); ++i;
     sprintf( card, "HISTORY Created by pnmtofits.                                                   " );
     write_card( card ); ++i;
--- converter/other/pnmtopng.c
+++ converter/other/pnmtopng.c
@@ -145,6 +145,7 @@
     retval.green = PPM_GETG(scaled);
     retval.blue  = PPM_GETB(scaled);
     retval.gray  = PNM_GET1(scaled);
+    retval.index = 0;
 
     return retval;
 }
--- converter/other/rletopnm.c
+++ converter/other/rletopnm.c
@@ -100,7 +100,7 @@
     optStruct3 opt;
     unsigned int option_def_index;
 
-    unsigned int alphaoutSpec;
+    unsigned int alphaoutSpec = 0;
 
     option_def_index = 0;   /* incremented by OPTENT3 */
     OPTENT3('h', "headerdump", OPT_FLAG,   
--- converter/ppm/ximtoppm.c
+++ converter/ppm/ximtoppm.c
@@ -50,7 +50,7 @@
 
     unsigned int option_def_index;
 
-    unsigned int alphaoutSpec;
+    unsigned int alphaoutSpec = 0;
 
     option_def_index = 0;   /* incremented by OPTENT3 */
     OPTENT3(0,   "alphaout",   OPT_STRING, 
--- editor/pamenlarge.c
+++ editor/pamenlarge.c
@@ -52,7 +52,7 @@
    Create a tuple *outTupleRowP which is actually a row of pointers into
    inTupleRow[], so as to map input pixels to output pixels by stretching.
 -----------------------------------------------------------------------------*/
-    tuple * const newtuplerow;
+    tuple * newtuplerow;
     int col;
 
     MALLOCARRAY_NOFAIL(newtuplerow, outpamP->width);
--- lib/pm.h
+++ lib/pm.h
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <sys/stat.h>
+#include <string.h>
 
 #ifdef VMS
 #include <perror.h>
--- lib/util/wordaccess.h
+++ lib/util/wordaccess.h
@@ -76,6 +76,7 @@
     return *((wordint *)bytes);
 }
 
+static __inline__ void
 wordintToBytes(wordintBytes * const bytesP,
                wordint        const wordInt) {
     
--- urt/rle.h
+++ urt/rle.h
@@ -36,6 +36,7 @@
 #include "rle_config.h"		/* Configuration parameters. */
 
 #include <stdio.h>		/* Declare FILE. */
+#include <string.h>
 
 #ifdef c_plusplus
 #define USE_PROTOTYPES
