* all: Sanitize include file order for source files. Avoid warnings due to use of unreserved symbols in system headers (primarily on Windows) by using this order of #include in .c files: - First include makeint.h - Next include the header for this .c file (if one exists) - Next include all system header files - Lastly include any other GNU Make headers, in alphabetical order
diff --git a/src/ar.c b/src/ar.c index 289235e..05fc49a 100644 --- a/src/ar.c +++ b/src/ar.c
@@ -19,11 +19,12 @@ #ifndef NO_ARCHIVES -#include "filedef.h" -#include "dep.h" #include <fnmatch.h> #include <intprops.h> +#include "dep.h" +#include "filedef.h" + /* Return nonzero if NAME is an archive-member reference, zero if not. An archive-member reference is a name like 'lib(member)' where member is a non-empty string.
diff --git a/src/commands.c b/src/commands.c index 343c1cb..dca91b8 100644 --- a/src/commands.c +++ b/src/commands.c
@@ -15,17 +15,20 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ #include "makeint.h" -#include "filedef.h" -#include "os.h" -#include "dep.h" -#include "variable.h" -#include "job.h" + #include "commands.h" + #if MK_OS_W32 #include <windows.h> #include "w32err.h" #endif +#include "dep.h" +#include "filedef.h" +#include "job.h" +#include "os.h" +#include "variable.h" + #if MK_OS_VMS # define FILE_LIST_SEPARATOR (vms_comma_separator ? ',' : ' ') #else
diff --git a/src/default.c b/src/default.c index c731817..157697d 100644 --- a/src/default.c +++ b/src/default.c
@@ -18,12 +18,12 @@ #include <assert.h> -#include "filedef.h" -#include "variable.h" -#include "rule.h" -#include "dep.h" -#include "job.h" #include "commands.h" +#include "dep.h" +#include "filedef.h" +#include "job.h" +#include "rule.h" +#include "variable.h" /* Define GCC_IS_NATIVE if gcc is the native development environment on your system (gcc/bison/flex vs cc/yacc/lex). */
diff --git a/src/dir.c b/src/dir.c index a805a37..d840035 100644 --- a/src/dir.c +++ b/src/dir.c
@@ -15,10 +15,6 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ #include "makeint.h" -#include "hash.h" -#include "filedef.h" -#include "dep.h" -#include "debug.h" #ifdef HAVE_DIRENT_H # include <dirent.h> @@ -59,11 +55,21 @@ # define REAL_DIR_ENTRY(dp) (dp->d_ino != 0) # define FAKE_DIR_ENTRY(dp) (dp->d_ino = 1) #endif /* POSIX */ - + #if MK_OS_DOS #include <ctype.h> #include <fcntl.h> +#endif +#include "debug.h" +#include "dep.h" +#include "filedef.h" +#include "hash.h" +#if MK_OS_W32 +#include "pathstuff.h" +#endif + +#if MK_OS_DOS /* If it's MSDOS that doesn't have _USE_LFN, disable LFN support. */ #ifndef _USE_LFN #define _USE_LFN 0 @@ -110,10 +116,6 @@ } #endif /* MK_OS_DOS */ -#if MK_OS_W32 -#include "pathstuff.h" -#endif - #ifdef HAVE_CASE_INSENSITIVE_FS static const char * downcase (const char *filename)
diff --git a/src/expand.c b/src/expand.c index 253a588..3b5a010 100644 --- a/src/expand.c +++ b/src/expand.c
@@ -22,8 +22,8 @@ #include "debug.h" #include "filedef.h" #include "job.h" -#include "variable.h" #include "rule.h" +#include "variable.h" #include "warning.h" /* Initially, any errors reported when expanding strings will be reported
diff --git a/src/file.c b/src/file.c index 6f816c8..9120ac7 100644 --- a/src/file.c +++ b/src/file.c
@@ -18,15 +18,15 @@ #include <assert.h> -#include "filedef.h" -#include "dep.h" -#include "job.h" #include "commands.h" -#include "variable.h" #include "debug.h" +#include "dep.h" +#include "filedef.h" #include "hash.h" -#include "shuffle.h" +#include "job.h" #include "rule.h" +#include "shuffle.h" +#include "variable.h" /* Remember whether snap_deps has been invoked: we need this to be sure we
diff --git a/src/function.c b/src/function.c index b4c3805..16532f2 100644 --- a/src/function.c +++ b/src/function.c
@@ -15,13 +15,14 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ #include "makeint.h" -#include "filedef.h" -#include "variable.h" -#include "dep.h" -#include "job.h" -#include "os.h" + #include "commands.h" #include "debug.h" +#include "dep.h" +#include "filedef.h" +#include "job.h" +#include "os.h" +#include "variable.h" struct function_table_entry
diff --git a/src/guile.c b/src/guile.c index 0b1be48..ba4251d 100644 --- a/src/guile.c +++ b/src/guile.c
@@ -20,13 +20,13 @@ #include "gnumake.h" -#include "debug.h" -#include "filedef.h" -#include "dep.h" -#include "variable.h" - #include <libguile.h> +#include "debug.h" +#include "dep.h" +#include "filedef.h" +#include "variable.h" + /* Pre-2.0 versions of Guile don't have a typedef for gsubr function types. */ #if SCM_MAJOR_VERSION < 2 # define GSUBR_TYPE SCM (*) ()
diff --git a/src/hash.c b/src/hash.c index 41e1689..a118552 100644 --- a/src/hash.c +++ b/src/hash.c
@@ -15,7 +15,9 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ #include "makeint.h" + #include "hash.h" + #include <assert.h> #define CALLOC(t, n) ((t *) xcalloc (sizeof (t) * (n)))
diff --git a/src/implicit.c b/src/implicit.c index 134e3fe..0b8f1a4 100644 --- a/src/implicit.c +++ b/src/implicit.c
@@ -15,16 +15,18 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ #include "makeint.h" -#include "filedef.h" -#include "rule.h" -#include "dep.h" -#include "debug.h" -#include "variable.h" -#include "job.h" /* struct child, used inside commands.h */ -#include "commands.h" /* set_file_variables */ -#include "shuffle.h" + #include <assert.h> +#include "commands.h" /* set_file_variables */ +#include "debug.h" +#include "dep.h" +#include "filedef.h" +#include "job.h" /* struct child, used inside commands.h */ +#include "rule.h" +#include "shuffle.h" +#include "variable.h" + static int pattern_search (struct file *file, int archive, unsigned int depth, unsigned int recursions, int allow_compat_rules);
diff --git a/src/job.c b/src/job.c index e54a934..bbed649 100644 --- a/src/job.c +++ b/src/job.c
@@ -16,6 +16,8 @@ #include "makeint.h" +#include "job.h" + #include <assert.h> #include <string.h> @@ -186,14 +188,13 @@ int getloadavg (double loadavg[], int nelem); #endif -#include "job.h" -#include "debug.h" -#include "filedef.h" #include "commands.h" -#include "variable.h" -#include "os.h" +#include "debug.h" #include "dep.h" +#include "filedef.h" +#include "os.h" #include "shuffle.h" +#include "variable.h" #include "warning.h" /* Different systems have different requirements for pid_t.
diff --git a/src/loadapi.c b/src/loadapi.c index e48d05b..5b146b3 100644 --- a/src/loadapi.c +++ b/src/loadapi.c
@@ -16,9 +16,9 @@ #include "makeint.h" +#include "dep.h" #include "filedef.h" #include "variable.h" -#include "dep.h" /* Allocate a buffer in our context, so we can free it. */ char *
diff --git a/src/main.c b/src/main.c index 6a12976..e522492 100644 --- a/src/main.c +++ b/src/main.c
@@ -82,16 +82,16 @@ double atof (); #endif -#include "os.h" -#include "filedef.h" -#include "dep.h" -#include "variable.h" -#include "job.h" #include "commands.h" -#include "rule.h" #include "debug.h" +#include "dep.h" +#include "filedef.h" #include "getopt.h" +#include "job.h" +#include "os.h" +#include "rule.h" #include "shuffle.h" +#include "variable.h" #include "warning.h" static void clean_jobserver (int status);
diff --git a/src/misc.c b/src/misc.c index b36248f..470d339 100644 --- a/src/misc.c +++ b/src/misc.c
@@ -15,10 +15,6 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ #include "makeint.h" -#include "filedef.h" -#include "dep.h" -#include "os.h" -#include "debug.h" #include <assert.h> #include <stdarg.h> @@ -39,6 +35,11 @@ # include <sys/file.h> #endif +#include "debug.h" +#include "dep.h" +#include "filedef.h" +#include "os.h" + unsigned int make_toui (const char *str, const char **error) {
diff --git a/src/output.c b/src/output.c index b7735ec..0819ff7 100644 --- a/src/output.c +++ b/src/output.c
@@ -15,7 +15,7 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ #include "makeint.h" -#include "os.h" + #include "output.h" /* GNU Make no longer supports pre-ANSI89 environments. */ @@ -40,6 +40,8 @@ # include "sub_proc.h" #endif +#include "os.h" + struct output *output_context = NULL; unsigned int stdio_traced = 0;
diff --git a/src/read.c b/src/read.c index 2e30ce1..6173b7c 100644 --- a/src/read.c +++ b/src/read.c
@@ -27,15 +27,15 @@ # include <pwd.h> #endif -#include "filedef.h" +#include "commands.h" +#include "debug.h" #include "dep.h" +#include "filedef.h" +#include "hash.h" #include "job.h" #include "os.h" -#include "commands.h" -#include "variable.h" #include "rule.h" -#include "debug.h" -#include "hash.h" +#include "variable.h" #include "warning.h" /* A 'struct ebuffer' controls the origin of the makefile we are currently
diff --git a/src/remake.c b/src/remake.c index 9d7ae8f..cfbde9d 100644 --- a/src/remake.c +++ b/src/remake.c
@@ -15,13 +15,6 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ #include "makeint.h" -#include "filedef.h" -#include "job.h" -#include "commands.h" -#include "dep.h" -#include "variable.h" -#include "warning.h" -#include "debug.h" #include <assert.h> @@ -46,6 +39,14 @@ #endif #endif +#include "commands.h" +#include "debug.h" +#include "dep.h" +#include "filedef.h" +#include "job.h" +#include "variable.h" +#include "warning.h" + /* The test for circular dependencies is based on the 'updating' bit in 'struct file'. However, double colon targets have separate 'struct
diff --git a/src/remote-cstms.c b/src/remote-cstms.c index 9f15a3b..903ceee 100644 --- a/src/remote-cstms.c +++ b/src/remote-cstms.c
@@ -20,11 +20,6 @@ #include "makeint.h" -#include "filedef.h" -#include "job.h" -#include "commands.h" -#include "debug.h" - #if HAVE_SYS_TIME_H # include <sys/time.h> #endif @@ -32,6 +27,11 @@ #include "customs.h" +#include "commands.h" +#include "debug.h" +#include "filedef.h" +#include "job.h" + char *remote_description = "Customs"; /* File name of the Customs 'export' client command.
diff --git a/src/remote-stub.c b/src/remote-stub.c index abec915..91ffa6f 100644 --- a/src/remote-stub.c +++ b/src/remote-stub.c
@@ -15,9 +15,10 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ #include "makeint.h" + +#include "commands.h" #include "filedef.h" #include "job.h" -#include "commands.h" char *remote_description = 0;
diff --git a/src/rule.c b/src/rule.c index d6bad47..c6b1eb5 100644 --- a/src/rule.c +++ b/src/rule.c
@@ -16,14 +16,15 @@ #include "makeint.h" +#include "rule.h" + #include <assert.h> -#include "filedef.h" -#include "dep.h" -#include "job.h" #include "commands.h" +#include "dep.h" +#include "filedef.h" +#include "job.h" #include "variable.h" -#include "rule.h" static void freerule (struct rule *rule, struct rule *lastrule);
diff --git a/src/variable.c b/src/variable.c index af3d6a4..d13ba9a 100644 --- a/src/variable.c +++ b/src/variable.c
@@ -16,20 +16,21 @@ #include "makeint.h" +#include "variable.h" + #include <assert.h> -#include "filedef.h" +#include "commands.h" #include "debug.h" #include "dep.h" +#include "filedef.h" +#include "hash.h" #include "job.h" -#include "commands.h" -#include "variable.h" #include "os.h" -#include "rule.h" #if MK_OS_W32 #include "pathstuff.h" #endif -#include "hash.h" +#include "rule.h" #include "warning.h" /* Incremented every time we enter target_environment(). */
diff --git a/src/vpath.c b/src/vpath.c index bd2055e..8f05436 100644 --- a/src/vpath.c +++ b/src/vpath.c
@@ -15,11 +15,12 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ #include "makeint.h" + #include "filedef.h" -#include "variable.h" #if MK_OS_W32 #include "pathstuff.h" #endif +#include "variable.h" /* Structure used to represent a selective VPATH searchpath. */
diff --git a/src/warning.c b/src/warning.c index ffb3ff3..7372e5d 100644 --- a/src/warning.c +++ b/src/warning.c
@@ -15,7 +15,9 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ #include "makeint.h" + #include "warning.h" + #include "variable.h" /* Current action for each warning. */