From: Paul Smith Date: Thu, 21 Aug 2025 20:51:36 +0000 (-0400) Subject: * all: Sanitize include file order for source files. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cf6e11c2f5f805742eade95d28fb243cf947ef1d;p=thirdparty%2Fmake.git * 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 289235eb..05fc49ad 100644 --- a/src/ar.c +++ b/src/ar.c @@ -19,11 +19,12 @@ this program. If not, see . */ #ifndef NO_ARCHIVES -#include "filedef.h" -#include "dep.h" #include #include +#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 343c1cb5..dca91b80 100644 --- a/src/commands.c +++ b/src/commands.c @@ -15,17 +15,20 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ #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 #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 c731817e..157697dc 100644 --- a/src/default.c +++ b/src/default.c @@ -18,12 +18,12 @@ this program. If not, see . */ #include -#include "filedef.h" -#include "variable.h" -#include "rule.h" +#include "commands.h" #include "dep.h" +#include "filedef.h" #include "job.h" -#include "commands.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 a805a377..d8400359 100644 --- a/src/dir.c +++ b/src/dir.c @@ -15,10 +15,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "makeint.h" -#include "hash.h" -#include "filedef.h" -#include "dep.h" -#include "debug.h" #ifdef HAVE_DIRENT_H # include @@ -59,11 +55,21 @@ const char *vmsify (const char *name, int type); # 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 #include +#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 @@ dosify (const char *filename) } #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 253a588e..3b5a010d 100644 --- a/src/expand.c +++ b/src/expand.c @@ -22,8 +22,8 @@ this program. If not, see . */ #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 6f816c8a..9120ac7a 100644 --- a/src/file.c +++ b/src/file.c @@ -18,15 +18,15 @@ this program. If not, see . */ #include -#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 b4c38052..16532f2a 100644 --- a/src/function.c +++ b/src/function.c @@ -15,13 +15,14 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "makeint.h" -#include "filedef.h" -#include "variable.h" + +#include "commands.h" +#include "debug.h" #include "dep.h" +#include "filedef.h" #include "job.h" #include "os.h" -#include "commands.h" -#include "debug.h" +#include "variable.h" struct function_table_entry diff --git a/src/guile.c b/src/guile.c index 0b1be48e..ba4251d2 100644 --- a/src/guile.c +++ b/src/guile.c @@ -20,13 +20,13 @@ this program. If not, see . */ #include "gnumake.h" +#include + #include "debug.h" -#include "filedef.h" #include "dep.h" +#include "filedef.h" #include "variable.h" -#include - /* 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 41e16895..a118552a 100644 --- a/src/hash.c +++ b/src/hash.c @@ -15,7 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "makeint.h" + #include "hash.h" + #include #define CALLOC(t, n) ((t *) xcalloc (sizeof (t) * (n))) diff --git a/src/implicit.c b/src/implicit.c index 134e3fef..0b8f1a44 100644 --- a/src/implicit.c +++ b/src/implicit.c @@ -15,15 +15,17 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "makeint.h" -#include "filedef.h" -#include "rule.h" -#include "dep.h" + +#include + +#include "commands.h" /* set_file_variables */ #include "debug.h" -#include "variable.h" +#include "dep.h" +#include "filedef.h" #include "job.h" /* struct child, used inside commands.h */ -#include "commands.h" /* set_file_variables */ +#include "rule.h" #include "shuffle.h" -#include +#include "variable.h" static int pattern_search (struct file *file, int archive, unsigned int depth, unsigned int recursions, diff --git a/src/job.c b/src/job.c index e54a9340..bbed6499 100644 --- a/src/job.c +++ b/src/job.c @@ -16,6 +16,8 @@ this program. If not, see . */ #include "makeint.h" +#include "job.h" + #include #include @@ -186,14 +188,13 @@ int getgid (); int getloadavg (double loadavg[], int nelem); #endif -#include "job.h" +#include "commands.h" #include "debug.h" +#include "dep.h" #include "filedef.h" -#include "commands.h" -#include "variable.h" #include "os.h" -#include "dep.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 e48d05b8..5b146b37 100644 --- a/src/loadapi.c +++ b/src/loadapi.c @@ -16,9 +16,9 @@ this program. If not, see . */ #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 6a129768..e522492a 100644 --- a/src/main.c +++ b/src/main.c @@ -82,16 +82,16 @@ void exit (int) NORETURN; 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 b36248f0..470d3397 100644 --- a/src/misc.c +++ b/src/misc.c @@ -15,10 +15,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "makeint.h" -#include "filedef.h" -#include "dep.h" -#include "os.h" -#include "debug.h" #include #include @@ -39,6 +35,11 @@ this program. If not, see . */ # include #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 b7735ec4..0819ff74 100644 --- a/src/output.c +++ b/src/output.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "makeint.h" -#include "os.h" + #include "output.h" /* GNU Make no longer supports pre-ANSI89 environments. */ @@ -40,6 +40,8 @@ this program. If not, see . */ # 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 2e30ce17..6173b7c2 100644 --- a/src/read.c +++ b/src/read.c @@ -27,15 +27,15 @@ struct passwd *getpwnam (char *name); # include #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 9d7ae8fd..cfbde9d5 100644 --- a/src/remake.c +++ b/src/remake.c @@ -15,13 +15,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ #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 @@ -46,6 +39,14 @@ this program. If not, see . */ #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 9f15a3b0..903ceee7 100644 --- a/src/remote-cstms.c +++ b/src/remote-cstms.c @@ -20,11 +20,6 @@ this program. If not, see . */ #include "makeint.h" -#include "filedef.h" -#include "job.h" -#include "commands.h" -#include "debug.h" - #if HAVE_SYS_TIME_H # include #endif @@ -32,6 +27,11 @@ this program. If not, see . */ #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 abec915a..91ffa6f9 100644 --- a/src/remote-stub.c +++ b/src/remote-stub.c @@ -15,9 +15,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ #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 d6bad472..c6b1eb5c 100644 --- a/src/rule.c +++ b/src/rule.c @@ -16,14 +16,15 @@ this program. If not, see . */ #include "makeint.h" +#include "rule.h" + #include -#include "filedef.h" +#include "commands.h" #include "dep.h" +#include "filedef.h" #include "job.h" -#include "commands.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 af3d6a40..d13ba9ae 100644 --- a/src/variable.c +++ b/src/variable.c @@ -16,20 +16,21 @@ this program. If not, see . */ #include "makeint.h" +#include "variable.h" + #include -#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 bd2055ec..8f05436c 100644 --- a/src/vpath.c +++ b/src/vpath.c @@ -15,11 +15,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ #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 ffb3ff38..7372e5d5 100644 --- a/src/warning.c +++ b/src/warning.c @@ -15,7 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "makeint.h" + #include "warning.h" + #include "variable.h" /* Current action for each warning. */