Fixes for enhanced GCC warnings.

Move function prototypes into header files and out of .c files.
Use void argument lists for functions that accept no args.
Remove unused macros.  Make private functions static.  Align
types with printf format characters.
diff --git a/ar.c b/ar.c
index 85e91c8..b9c1cf7 100644
--- a/ar.c
+++ b/ar.c
@@ -73,7 +73,7 @@
 ar_member_date_1 (int desc UNUSED, const char *mem, int truncated,
                   long int hdrpos UNUSED, long int datapos UNUSED,
                   long int size UNUSED, long int date,
-                  int uid UNUSED, int gid UNUSED, int mode UNUSED,
+                  int uid UNUSED, int gid UNUSED, unsigned int mode UNUSED,
                   const void *name)
 {
   return ar_name_equal (name, mem, truncated) ? date : 0;
@@ -198,7 +198,7 @@
 ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED,
                long int hdrpos UNUSED, long int datapos UNUSED,
                long int size UNUSED, long int date UNUSED, int uid UNUSED,
-               int gid UNUSED, int mode UNUSED, const void *arg)
+               int gid UNUSED, unsigned int mode UNUSED, const void *arg)
 {
   struct ar_glob_state *state = (struct ar_glob_state *)arg;
 
@@ -224,7 +224,7 @@
 /* Return nonzero if PATTERN contains any metacharacters.
    Metacharacters can be quoted with backslashes if QUOTE is nonzero.  */
 static int
-glob_pattern_p (const char *pattern, int quote)
+ar_glob_pattern_p (const char *pattern, int quote)
 {
   const char *p;
   int opened = 0;
@@ -267,7 +267,7 @@
 #ifdef VMS
   char *vms_member_pattern;
 #endif
-  if (! glob_pattern_p (member_pattern, 1))
+  if (! ar_glob_pattern_p (member_pattern, 1))
     return 0;
 
   /* Scan the archive for matches.
diff --git a/arscan.c b/arscan.c
index d35686d..549fe1e 100644
--- a/arscan.c
+++ b/arscan.c
@@ -547,7 +547,7 @@
         int long_name = 0;
 #endif
         long int eltsize;
-        int eltmode;
+        unsigned int eltmode;
         long int fnval;
         off_t o;
 
@@ -872,7 +872,7 @@
 ar_member_pos (int desc UNUSED, const char *mem, int truncated,
                long int hdrpos, long int datapos UNUSED, long int size UNUSED,
                long int date UNUSED, int uid UNUSED, int gid UNUSED,
-               int mode UNUSED, const void *name)
+               unsigned int mode UNUSED, const void *name)
 {
   if (!ar_name_equal (name, mem, truncated))
     return 0;
@@ -957,7 +957,8 @@
 long int
 describe_member (int desc, const char *name, int truncated,
                  long int hdrpos, long int datapos, long int size,
-                 long int date, int uid, int gid, int mode, const void *arg)
+                 long int date, int uid, int gid, unsigned int mode,
+                 const void *arg)
 {
   extern char *ctime ();
 
diff --git a/commands.c b/commands.c
index 4303b86..124b93e 100644
--- a/commands.c
+++ b/commands.c
@@ -31,8 +31,6 @@
 # define FILE_LIST_SEPARATOR ' '
 #endif
 
-int remote_kill (int id, int sig);
-
 #ifndef HAVE_UNISTD_H
 int getpid ();
 #endif
diff --git a/commands.h b/commands.h
index db95fb2..f7cf064 100644
--- a/commands.h
+++ b/commands.h
@@ -34,6 +34,7 @@
 #define COMMANDS_SILENT         2 /* Silent: @.  */
 #define COMMANDS_NOERROR        4 /* No errors: -.  */
 
+RETSIGTYPE fatal_error_signal (int sig);
 void execute_file_commands (struct file *file);
 void print_commands (const struct commands *cmds);
 void delete_child_targets (struct child *child);
diff --git a/dir.c b/dir.c
index a286d2e..63c82a0 100644
--- a/dir.c
+++ b/dir.c
@@ -1169,8 +1169,6 @@
 
 /* Hooks for globbing.  */
 
-#include <glob.h>
-
 /* Structure describing state of iterating through a directory hash table.  */
 
 struct dirstream
@@ -1263,7 +1261,9 @@
  */
 #if !defined(stat) && !defined(WINDOWS32) || defined(VMS)
 # ifndef VMS
+#  ifndef HAVE_SYS_STAT_H
 int stat (const char *path, struct stat *sbuf);
+#  endif
 # else
     /* We are done with the fake stat.  Go back to the real stat */
 #   ifdef stat
diff --git a/file.c b/file.c
index 2207be4..ae1c285 100644
--- a/file.c
+++ b/file.c
@@ -57,9 +57,6 @@
                           ((struct file const *) y)->hname);
 }
 
-#ifndef FILE_BUCKETS
-#define FILE_BUCKETS    1007
-#endif
 static struct hash_table files;
 
 /* Whether or not .SECONDARY with no prerequisites was given.  */
diff --git a/filedef.h b/filedef.h
index b280fb8..507a027 100644
--- a/filedef.h
+++ b/filedef.h
@@ -103,7 +103,7 @@
   };
 
 
-extern struct file *suffix_file, *default_file;
+extern struct file *default_file;
 
 
 struct file *lookup_file (const char *name);
@@ -117,9 +117,12 @@
 void set_command_state (struct file *file, enum cmd_state state);
 void notice_finished_file (struct file *file);
 void init_hash_files (void);
+void verify_file_data_base (void);
 char *build_target_list (char *old_list);
 void print_prereqs (const struct dep *deps);
 void print_file_data_base (void);
+int try_implicit_rule (struct file *file, unsigned int depth);
+int stemlen_compare (const void *v1, const void *v2);
 
 #if FILE_TIMESTAMP_HI_RES
 # define FILE_TIMESTAMP_STAT_MODTIME(fname, st) \
diff --git a/function.c b/function.c
index b8e69b2..c9fcec2 100644
--- a/function.c
+++ b/function.c
@@ -627,6 +627,7 @@
       else if (is_dir)
 #ifdef VMS
         {
+          extern int vms_report_unix_paths;
           if (vms_report_unix_paths)
             o = variable_buffer_output (o, "./", 2);
           else
@@ -1975,7 +1976,7 @@
 }
 #endif  /* _AMIGA */
 
-char *
+static char *
 func_shell (char *o, char **argv, const char *funcname UNUSED)
 {
   return func_shell_base (o, argv, 1);
@@ -2653,10 +2654,10 @@
     OS (fatal, flocp, _("Function name too long: %s"), name);
   if (min > 255)
     ONS (fatal, flocp,
-         _("Invalid minimum argument count (%d) for function %s"), min, name);
+         _("Invalid minimum argument count (%u) for function %s"), min, name);
   if (max > 255 || (max && max < min))
     ONS (fatal, flocp,
-         _("Invalid maximum argument count (%d) for function %s"), max, name);
+         _("Invalid maximum argument count (%u) for function %s"), max, name);
 
   ent = xmalloc (sizeof (struct function_table_entry));
   ent->name = name;
diff --git a/job.c b/job.c
index 2d2c803..ddac6c4 100644
--- a/job.c
+++ b/job.c
@@ -24,7 +24,6 @@
 #include "commands.h"
 #include "variable.h"
 #include "os.h"
-#include "debug.h"
 
 #include <string.h>
 
@@ -208,14 +207,10 @@
   return pidstring;
 }
 
+#ifndef HAVE_GETLOADAVG
 int getloadavg (double loadavg[], int nelem);
-int start_remote_job (char **argv, char **envp, int stdin_fd, int *is_remote,
-                      int *id_ptr, int *used_stdin);
-int start_remote_job_p (int);
-int remote_status (int *exit_code_ptr, int *signal_ptr, int *coredump_ptr,
-                   int block);
+#endif
 
-RETSIGTYPE child_handler (int);
 static void free_child (struct child *);
 static void start_job_command (struct child *child);
 static int load_too_high (void);
@@ -2285,7 +2280,6 @@
     case ENOEXEC:
       {
         /* The file is not executable.  Try it as a shell script.  */
-        extern char *getenv ();
         const char *shell;
         char **new_argv;
         int argc;
diff --git a/main.c b/main.c
index c812ba4..576f2e9 100644
--- a/main.c
+++ b/main.c
@@ -84,18 +84,6 @@
 }
 #endif
 
-void init_dir (void);
-void remote_setup (void);
-void remote_cleanup (void);
-RETSIGTYPE fatal_error_signal (int sig);
-
-void print_variable_data_base (void);
-void print_dir_data_base (void);
-void print_rule_data_base (void);
-void print_vpath_data_base (void);
-
-void verify_file_data_base (void);
-
 #if defined HAVE_WAITPID || defined HAVE_WAIT3
 # define HAVE_WAIT_NOHANG
 #endif
@@ -645,7 +633,7 @@
    Each element is true if we should stop parsing on that character.  */
 
 static void
-initialize_stopchar_map ()
+initialize_stopchar_map (void)
 {
   int i;
 
@@ -1063,7 +1051,7 @@
 #endif  /* __MSDOS__ */
 
 static void
-reset_jobserver ()
+reset_jobserver (void)
 {
   jobserver_clear ();
   free (jobserver_auth);
@@ -1895,7 +1883,6 @@
 
      If none of these are true, we don't need a signal handler at all.  */
   {
-    RETSIGTYPE child_handler (int sig);
 # if defined SIGCHLD
     bsd_signal (SIGCHLD, child_handler);
 # endif
@@ -3369,7 +3356,7 @@
 /* Print a bunch of information about this and that.  */
 
 static void
-print_data_base ()
+print_data_base (void)
 {
   time_t when = time ((time_t *) 0);
 
diff --git a/makeint.h b/makeint.h
index 0ee5acc..ad0a511 100644
--- a/makeint.h
+++ b/makeint.h
@@ -450,6 +450,8 @@
 extern struct rlimit stack_limit;
 #endif
 
+#include <glob.h>
+
 #define NILF ((gmk_floc *)0)
 
 #define CSTRLEN(_s)           (sizeof (_s)-1)
@@ -518,7 +520,8 @@
 typedef long int (*ar_member_func_t) (int desc, const char *mem, int truncated,
                                       long int hdrpos, long int datapos,
                                       long int size, long int date, int uid,
-                                      int gid, int mode, const void *arg);
+                                      int gid, unsigned int mode,
+                                      const void *arg);
 
 long int ar_scan (const char *archive, ar_member_func_t function, const void *arg);
 int ar_name_equal (const char *name, const char *mem, int truncated);
@@ -532,6 +535,8 @@
 int file_impossible_p (const char *);
 void file_impossible (const char *);
 const char *dir_name (const char *);
+void print_dir_data_base (void);
+void dir_setup_glob (glob_t *);
 void hash_init_directories (void);
 
 void define_default_variables (void);
@@ -554,7 +559,7 @@
 
 char *strip_whitespace (const char **begpp, const char **endpp);
 
-void show_goal_error ();
+void show_goal_error (void);
 
 /* String caching  */
 void strcache_init (void);
@@ -581,16 +586,16 @@
 long int lseek ();
 # endif
 
-#endif  /* Not GNU C library or POSIX.  */
-
-#ifdef  HAVE_GETCWD
-# if !defined(VMS) && !defined(__DECC)
+# ifdef  HAVE_GETCWD
+#  if !defined(VMS) && !defined(__DECC)
 char *getcwd ();
-# endif
-#else
+#  endif
+# else
 char *getwd ();
-# define getcwd(buf, len)       getwd (buf)
-#endif
+#  define getcwd(buf, len)       getwd (buf)
+# endif
+
+#endif  /* Not GNU C library or POSIX.  */
 
 #if !HAVE_STRCASECMP
 # if HAVE_STRICMP
@@ -619,11 +624,12 @@
 #define OUTPUT_SYNC_TARGET  2
 #define OUTPUT_SYNC_RECURSE 3
 
+/* Non-GNU systems may not declare this in unistd.h.  */
+extern char **environ;
+
 extern const gmk_floc *reading_file;
 extern const gmk_floc **expanding_var;
 
-extern char **environ;
-
 extern unsigned short stopchar_map[];
 
 extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
@@ -634,6 +640,8 @@
 extern int not_parallel, second_expansion, clock_skew_detected;
 extern int rebuilding_makefiles, one_shell, output_sync, verify_flag;
 
+extern const char *default_shell;
+
 /* can we run commands via 'sh -c xxx' or must we use batch files? */
 extern int batch_mode_shell;
 
@@ -685,6 +693,17 @@
 
 #endif
 
+void remote_setup (void);
+void remote_cleanup (void);
+int start_remote_job_p (int);
+int start_remote_job (char **, char **, int, int *, int *, int *);
+int remote_status (int *, int *, int *, int);
+void block_remote_children (void);
+void unblock_remote_children (void);
+int remote_kill (int id, int sig);
+void print_variable_data_base (void);
+void print_vpath_data_base (void);
+
 extern char *starting_directory;
 extern unsigned int makelevel;
 extern char *version_string, *remote_description, *make_host;
diff --git a/os.h b/os.h
index ac5350b..c1a19e1 100644
--- a/os.h
+++ b/os.h
@@ -20,7 +20,7 @@
 #ifdef MAKE_JOBSERVER
 
 /* Returns 1 if the jobserver is enabled, else 0.  */
-unsigned int jobserver_enabled ();
+unsigned int jobserver_enabled (void);
 
 /* Called in the master instance to set up the jobserver initially.  */
 unsigned int jobserver_setup (int job_slots);
@@ -29,28 +29,28 @@
 unsigned int jobserver_parse_auth (const char* auth);
 
 /* Returns an allocated buffer used to pass to child instances.  */
-char *jobserver_get_auth ();
+char *jobserver_get_auth (void);
 
 /* Clear this instance's jobserver configuration.  */
-void jobserver_clear ();
+void jobserver_clear (void);
 
 /* Recover all the jobserver tokens and return the number we got.  */
-unsigned int jobserver_acquire_all ();
+unsigned int jobserver_acquire_all (void);
 
 /* Release a jobserver token.  If it fails and is_fatal is 1, fatal.  */
 void jobserver_release (int is_fatal);
 
 /* Notify the jobserver that a child exited.  */
-void jobserver_signal ();
+void jobserver_signal (void);
 
 /* Get ready to start a non-recursive child.  */
-void jobserver_pre_child ();
+void jobserver_pre_child (int);
 
 /* Complete starting a non-recursive child.  */
-void jobserver_post_child ();
+void jobserver_post_child (int);
 
 /* Set up to acquire a new token.  */
-void jobserver_pre_acquire ();
+void jobserver_pre_acquire (void);
 
 /* Wait until we can acquire a jobserver token.
    TIMEOUT is 1 if we have other jobs waiting for the load to go down;
@@ -78,7 +78,7 @@
 
 /* Create a "bad" file descriptor for stdin when parallel jobs are run.  */
 #if !defined(VMD) && !defined(WINDOWS32) && !defined(_AMIGA) && !defined(__MSDOS__)
-int get_bad_stdin ();
+int get_bad_stdin (void);
 #else
 # define get_bad_stdin() (-1)
 #endif
diff --git a/output.c b/output.c
index 475862f..0a0420c 100644
--- a/output.c
+++ b/output.c
@@ -174,7 +174,7 @@
 
 /* Set up the sync handle.  Disables output_sync on error.  */
 static int
-sync_init ()
+sync_init (void)
 {
   int combined_output = 0;
 
@@ -283,7 +283,7 @@
 /* Returns a file descriptor to a temporary file.  The file is automatically
    closed/deleted on exit.  Don't use a FILE* stream.  */
 int
-output_tmpfd ()
+output_tmpfd (void)
 {
   int fd = -1;
   FILE *tfile = tmpfile ();
@@ -558,7 +558,7 @@
 
 /* We're about to generate output: be sure it's set up.  */
 void
-output_start ()
+output_start (void)
 {
 #ifndef NO_OUTPUT_SYNC
   /* If we're syncing output make sure the temporary file is set up.  */
diff --git a/posixos.c b/posixos.c
index 4a88b3c..4a787e4 100644
--- a/posixos.c
+++ b/posixos.c
@@ -45,7 +45,7 @@
 static char token = '+';
 
 static int
-make_job_rfd ()
+make_job_rfd (void)
 {
 #ifdef HAVE_PSELECT
   /* Pretend we succeeded.  */
@@ -117,7 +117,7 @@
 }
 
 char *
-jobserver_get_auth ()
+jobserver_get_auth (void)
 {
   char *auth = xmalloc ((INTSTR_LENGTH * 2) + 2);
   sprintf (auth, "%d,%d", job_fds[0], job_fds[1]);
@@ -125,13 +125,13 @@
 }
 
 unsigned int
-jobserver_enabled ()
+jobserver_enabled (void)
 {
   return job_fds[0] >= 0;
 }
 
 void
-jobserver_clear ()
+jobserver_clear (void)
 {
   if (job_fds[0] >= 0)
     close (job_fds[0]);
@@ -157,7 +157,7 @@
 }
 
 unsigned int
-jobserver_acquire_all ()
+jobserver_acquire_all (void)
 {
   unsigned int tokens = 0;
 
@@ -210,7 +210,7 @@
 }
 
 void
-jobserver_signal ()
+jobserver_signal (void)
 {
   if (job_rfd >= 0)
     {
@@ -220,7 +220,7 @@
 }
 
 void
-jobserver_pre_acquire ()
+jobserver_pre_acquire (void)
 {
   /* Make sure we have a dup'd FD.  */
   if (job_rfd < 0 && job_fds[0] >= 0 && make_job_rfd () < 0)
@@ -402,7 +402,7 @@
 
 /* Create a "bad" file descriptor for stdin when parallel jobs are run.  */
 int
-get_bad_stdin ()
+get_bad_stdin (void)
 {
   static int bad_stdin = -1;
 
diff --git a/read.c b/read.c
index a71eaeb..c6eb5c8 100644
--- a/read.c
+++ b/read.c
@@ -18,8 +18,6 @@
 
 #include <assert.h>
 
-#include <glob.h>
-
 #include "filedef.h"
 #include "dep.h"
 #include "job.h"
@@ -2920,7 +2918,6 @@
 #ifndef VMS
   if (name[1] == '/' || name[1] == '\0')
     {
-      extern char *getenv ();
       char *home_dir;
       int is_variable;
 
@@ -2943,7 +2940,6 @@
 # if !defined(_AMIGA) && !defined(WINDOWS32)
       if (home_dir == 0 || home_dir[0] == '\0')
         {
-          extern char *getlogin ();
           char *logname = getlogin ();
           home_dir = 0;
           if (logname != 0)
@@ -3008,8 +3004,6 @@
         PARSEFS_NOCACHE - Do not add filenames to the strcache (caller frees)
   */
 
-void dir_setup_glob (glob_t *glob);
-
 void *
 parse_file_seq (char **stringp, unsigned int size, int stopmap,
                 const char *prefix, int flags)
diff --git a/remake.c b/remake.c
index c837903..63ee648 100644
--- a/remake.c
+++ b/remake.c
@@ -37,8 +37,6 @@
 #include <io.h>
 #endif
 
-extern int try_implicit_rule (struct file *file, unsigned int depth);
-
 
 /* The test for circular dependencies is based on the 'updating' bit in
    'struct file'.  However, double colon targets have separate 'struct
@@ -269,7 +267,7 @@
    about errors, show an error message the first time.  */
 
 void
-show_goal_error ()
+show_goal_error (void)
 {
   struct goaldep *goal;
 
diff --git a/rule.h b/rule.h
index 72ff2e9..9156b8e 100644
--- a/rule.h
+++ b/rule.h
@@ -55,3 +55,4 @@
 void create_pattern_rule (const char **targets, const char **target_percents,
                           unsigned int num, int terminal, struct dep *deps,
                           struct commands *commands, int override);
+void print_rule_data_base (void);
diff --git a/variable.c b/variable.c
index 9c932d4..26baabd 100644
--- a/variable.c
+++ b/variable.c
@@ -822,7 +822,6 @@
 void
 define_automatic_variables (void)
 {
-  extern const char* default_shell;
   struct variable *v;
   char buf[200];
 
@@ -1049,7 +1048,6 @@
                   /* If this is the SHELL variable and it's not exported,
                      then add the value from our original environment, if
                      the original environment defined a value for SHELL.  */
-                  extern struct variable shell_var;
                   if (streq (v->name, "SHELL") && shell_var.value)
                     {
                       v = &shell_var;
@@ -1136,7 +1134,7 @@
  * result. This removes only ONE newline (if any) at the end, for maximum
  * compatibility with the *BSD makes.  If it fails, returns NULL. */
 
-char *
+static char *
 shell_result (const char *p)
 {
   char *buf;
@@ -1739,7 +1737,7 @@
 
   {
     struct pattern_var *p;
-    int rules = 0;
+    unsigned int rules = 0;
 
     for (p = pattern_vars; p != 0; p = p->next)
       {
diff --git a/variable.h b/variable.h
index 75d4c0b..583a65f 100644
--- a/variable.h
+++ b/variable.h
@@ -110,6 +110,7 @@
 extern char *variable_buffer;
 extern struct variable_set_list *current_variable_set_list;
 extern struct variable *default_goal_var;
+extern struct variable shell_var;
 
 /* expand.c */
 char *variable_buffer_output (char *ptr, const char *string, unsigned int length);
@@ -148,7 +149,6 @@
 void define_automatic_variables (void);
 void initialize_file_variables (struct file *file, int reading);
 void print_file_variables (const struct file *file);
-void print_file_variables (const struct file *file);
 void print_target_variables (const struct file *file);
 void merge_variable_set_lists (struct variable_set_list **to_list,
                                struct variable_set_list *from_list);
diff --git a/vpath.c b/vpath.c
index 2f1dafd..0c7dce3 100644
--- a/vpath.c
+++ b/vpath.c
@@ -52,7 +52,7 @@
    variable.  */
 
 void
-build_vpath_lists ()
+build_vpath_lists (void)
 {
   register struct vpath *new = 0;
   register struct vpath *old, *nexto;