]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* all: Sanitize include file order for source files.
authorPaul Smith <psmith@gnu.org>
Thu, 21 Aug 2025 20:51:36 +0000 (16:51 -0400)
committerPaul Smith <psmith@gnu.org>
Thu, 21 Aug 2025 20:51:36 +0000 (16:51 -0400)
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

23 files changed:
src/ar.c
src/commands.c
src/default.c
src/dir.c
src/expand.c
src/file.c
src/function.c
src/guile.c
src/hash.c
src/implicit.c
src/job.c
src/loadapi.c
src/main.c
src/misc.c
src/output.c
src/read.c
src/remake.c
src/remote-cstms.c
src/remote-stub.c
src/rule.c
src/variable.c
src/vpath.c
src/warning.c

index 289235eb4cdd03bd91dcee2cbf46e5ecffb17241..05fc49adbcffb79da68bfeb51d1efdedea029b2d 100644 (file)
--- a/src/ar.c
+++ b/src/ar.c
@@ -19,11 +19,12 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #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.
index 343c1cb5afe699f5c5357348ff144e2964dd1620..dca91b80e06cffeaeec971a3b7ad848966cfd483 100644 (file)
@@ -15,17 +15,20 @@ You should have received a copy of the GNU General Public License along with
 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
index c731817e19e94dcfa50fa0ade27496977288af04..157697dc6e07321f961b5e73503da8372e0f3fbd 100644 (file)
@@ -18,12 +18,12 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #include <assert.h>
 
-#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).  */
index a805a37701cb9200eab3339e9a0e009a54784ca0..d84003592a55b8ad78b1b1c456245c637ea4d913 100644 (file)
--- 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 <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 @@ 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 */
-\f
+
 #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 @@ 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)
index 253a588ec5b3cf2abddd4f1685a2cc448cedf4d2..3b5a010da4195b97b6e2ac8385c23ee4630792cc 100644 (file)
@@ -22,8 +22,8 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 #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
index 6f816c8adf04ad8ebf12237d0e96bf4a11908855..9120ac7adbe485ee74eba92d855ecfdade314f0c 100644 (file)
@@ -18,15 +18,15 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #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
index b4c38052dd2b32d074c1c0cfc88feb406df7d33e..16532f2a4486510a82a4645add7958cae213e15e 100644 (file)
@@ -15,13 +15,14 @@ You should have received a copy of the GNU General Public License along with
 this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #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
index 0b1be48ec09f67311169b43b510fc6a444482f3a..ba4251d2d2922388c1add5e05dca6afabc6282e3 100644 (file)
@@ -20,13 +20,13 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #include "gnumake.h"
 
+#include <libguile.h>
+
 #include "debug.h"
-#include "filedef.h"
 #include "dep.h"
+#include "filedef.h"
 #include "variable.h"
 
-#include <libguile.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 (*) ()
index 41e16895d0674249d29c42ac562aae7146b1fbb7..a118552a969d56d567e41885d271545de5ca9751 100644 (file)
@@ -15,7 +15,9 @@ You should have received a copy of the GNU General Public License along with
 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)))
index 134e3fef08d4ebff3456b99221448aac81e997b6..0b8f1a44bb333dcfe0ea3267722505193df8c81e 100644 (file)
@@ -15,15 +15,17 @@ You should have received a copy of the GNU General Public License along with
 this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #include "makeint.h"
-#include "filedef.h"
-#include "rule.h"
-#include "dep.h"
+
+#include <assert.h>
+
+#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 <assert.h>
+#include "variable.h"
 
 static int pattern_search (struct file *file, int archive,
                            unsigned int depth, unsigned int recursions,
index e54a9340ca85ecde16b8942e62cc3cfc835d9dc0..bbed6499cc89848d2d27a23686896cf8aa05a948 100644 (file)
--- a/src/job.c
+++ b/src/job.c
@@ -16,6 +16,8 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #include "makeint.h"
 
+#include "job.h"
+
 #include <assert.h>
 #include <string.h>
 
@@ -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.
index e48d05b83b968ecd65268368e918ff212f9d1606..5b146b371e035ba6288bbe8e47fccfe5900d4aea 100644 (file)
@@ -16,9 +16,9 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #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 *
index 6a129768093c24b42000a500ade9dcde20e8ce1e..e522492a5351c45a9ff9cdc7ab2bea0adc6d2e17 100644 (file)
@@ -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);
index b36248f0d07495208f8553504215fc277dadfc65..470d3397c7f9b1951d299f72906e0acead8a6bcf 100644 (file)
@@ -15,10 +15,6 @@ You should have received a copy of the GNU General Public License along with
 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 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 # 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)
 {
index b7735ec4460cd1267a5f32558c8ee04658217761..0819ff7476222b7450a743ba458bfeb3ee6ad6a7 100644 (file)
@@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with
 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 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 # include "sub_proc.h"
 #endif
 
+#include "os.h"
+
 struct output *output_context = NULL;
 unsigned int stdio_traced = 0;
 
index 2e30ce176fceb593da919eb9efa8d3d07d2d39e8..6173b7c2a64062fe84545453d7119462a0f7e6d4 100644 (file)
@@ -27,15 +27,15 @@ struct passwd *getpwnam (char *name);
 # 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
index 9d7ae8fdbb5b30380911ed90182197e88f5c4af6..cfbde9d5996b0f07135ddf438973e03acd51935f 100644 (file)
@@ -15,13 +15,6 @@ You should have received a copy of the GNU General Public License along with
 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 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 #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
index 9f15a3b01bf25bd74f217252678c97b1fcdc40fc..903ceee71c01dbb521b4d98ad77ba53979e92428 100644 (file)
@@ -20,11 +20,6 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #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 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #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.
index abec915a23c4923d61003ab14215a3df2dc64339..91ffa6f963e6f3c495e9bf74f8b76d37c2f04ebb 100644 (file)
@@ -15,9 +15,10 @@ You should have received a copy of the GNU General Public License along with
 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;
index d6bad4726fbd0b8258144f75df513aa697aa6423..c6b1eb5cbc27515d6d01a32ca0b23f4019a4b9c6 100644 (file)
@@ -16,14 +16,15 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #include "makeint.h"
 
+#include "rule.h"
+
 #include <assert.h>
 
-#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);
 \f
index af3d6a407f9ce8c2e5d7fb32534c9f4606d730aa..d13ba9ae188c5b312d5fa17135c452d11290943f 100644 (file)
@@ -16,20 +16,21 @@ this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #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().  */
index bd2055ec24f3738d355b00a4a6c565c523884762..8f05436cb22f4128fc52f9febfd354531aa7aa51 100644 (file)
@@ -15,11 +15,12 @@ You should have received a copy of the GNU General Public License along with
 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.  */
index ffb3ff384a31f16bd740b696629e606ef95807de..7372e5d583a4d04d757729bc9be777e4bcbe7650 100644 (file)
@@ -15,7 +15,9 @@ You should have received a copy of the GNU General Public License along with
 this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #include "makeint.h"
+
 #include "warning.h"
+
 #include "variable.h"
 
 /* Current action for each warning.  */