aboutsummaryrefslogtreecommitdiff
path: root/contrib/bmake/make.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bmake/make.h')
-rw-r--r--contrib/bmake/make.h110
1 files changed, 60 insertions, 50 deletions
diff --git a/contrib/bmake/make.h b/contrib/bmake/make.h
index 9b73b04abb74..86c198cb55f0 100644
--- a/contrib/bmake/make.h
+++ b/contrib/bmake/make.h
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.300 2022/04/18 15:06:27 rillig Exp $ */
+/* $NetBSD: make.h,v 1.329 2024/03/10 02:53:37 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -196,6 +196,13 @@ typedef unsigned char bool;
#endif
/*
+ * IRIX defines OP_NONE in sys/fcntl.h
+ */
+#if defined(OP_NONE)
+# undef OP_NONE
+#endif
+
+/*
* The typical flow of states is:
*
* The direct successful path:
@@ -520,6 +527,7 @@ typedef struct GNode {
const char *fname;
/* Line number where the GNode got defined, 1-based */
unsigned lineno;
+ int exit_status;
} GNode;
/*
@@ -555,6 +563,14 @@ typedef enum CondResult {
CR_ERROR /* Unknown directive or parse error */
} CondResult;
+typedef struct {
+ enum GuardKind {
+ GK_VARIABLE,
+ GK_TARGET
+ } kind;
+ char *name;
+} Guard;
+
/* Names of the variables that are "local" to a specific target. */
#define TARGET "@" /* Target of dependency */
#define OODATE "?" /* All out-of-date sources */
@@ -625,15 +641,6 @@ extern GNode *mainNode;
extern pid_t myPid;
#define MAKEFLAGS ".MAKEFLAGS"
-#define MAKEOVERRIDES ".MAKEOVERRIDES"
-/* prefix when printing the target of a job */
-#define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX"
-#define MAKE_EXPORTED ".MAKE.EXPORTED" /* exported variables */
-#define MAKE_MAKEFILES ".MAKE.MAKEFILES" /* all loaded makefiles */
-#define MAKE_LEVEL ".MAKE.LEVEL" /* recursion level */
-#define MAKE_MAKEFILE_PREFERENCE ".MAKE.MAKEFILE_PREFERENCE"
-#define MAKE_DEPENDFILE ".MAKE.DEPENDFILE" /* .depend */
-#define MAKE_MODE ".MAKE.MODE"
#ifndef MAKE_LEVEL_ENV
# define MAKE_LEVEL_ENV "MAKELEVEL"
#endif
@@ -785,9 +792,16 @@ typedef struct CmdOpts {
*/
StringList create;
+ /*
+ * Randomize the order in which the targets from toBeMade are made,
+ * to catch undeclared dependencies.
+ */
+ bool randomizeTargets;
} CmdOpts;
extern CmdOpts opts;
+extern bool forceJobs;
+extern char **environ;
/* arch.c */
void Arch_Init(void);
@@ -796,22 +810,23 @@ void Arch_End(void);
bool Arch_ParseArchive(char **, GNodeList *, GNode *);
void Arch_Touch(GNode *);
void Arch_TouchLib(GNode *);
-void Arch_UpdateMTime(GNode *gn);
-void Arch_UpdateMemberMTime(GNode *gn);
+void Arch_UpdateMTime(GNode *);
+void Arch_UpdateMemberMTime(GNode *);
void Arch_FindLib(GNode *, SearchPath *);
bool Arch_LibOODate(GNode *) MAKE_ATTR_USE;
bool Arch_IsLib(GNode *) MAKE_ATTR_USE;
/* compat.c */
bool Compat_RunCommand(const char *, GNode *, StringListNode *);
-void Compat_Run(GNodeList *);
+void Compat_MakeAll(GNodeList *);
void Compat_Make(GNode *, GNode *);
/* cond.c */
+extern unsigned int cond_depth;
CondResult Cond_EvalCondition(const char *) MAKE_ATTR_USE;
CondResult Cond_EvalLine(const char *) MAKE_ATTR_USE;
-void Cond_restore_depth(unsigned int);
-unsigned int Cond_save_depth(void) MAKE_ATTR_USE;
+Guard *Cond_ExtractGuard(const char *) MAKE_ATTR_USE;
+void Cond_EndFile(void);
/* dir.c; see also dir.h */
@@ -838,8 +853,9 @@ int For_Eval(const char *) MAKE_ATTR_USE;
bool For_Accum(const char *, int *) MAKE_ATTR_USE;
void For_Run(unsigned, unsigned);
bool For_NextIteration(struct ForLoop *, Buffer *);
-char *ForLoop_Details(struct ForLoop *);
+char *ForLoop_Details(const struct ForLoop *);
void ForLoop_Free(struct ForLoop *);
+void For_Break(struct ForLoop *);
/* job.c */
void JobReapChild(pid_t, int, bool);
@@ -852,7 +868,7 @@ void Fatal(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;
void Punt(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;
void DieHorribly(void) MAKE_ATTR_DEAD;
void Finish(int) MAKE_ATTR_DEAD;
-bool unlink_file(const char *) MAKE_ATTR_USE;
+int unlink_file(const char *) MAKE_ATTR_USE;
void execDie(const char *, const char *);
char *getTmpdir(void) MAKE_ATTR_USE;
bool ParseBoolean(const char *, bool) MAKE_ATTR_USE;
@@ -863,16 +879,18 @@ bool GetBooleanExpr(const char *, bool);
void Parse_Init(void);
void Parse_End(void);
-void PrintLocation(FILE *, bool, const char *, unsigned);
+void PrintLocation(FILE *, bool, const GNode *);
void PrintStackTrace(bool);
void Parse_Error(ParseErrorLevel, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
bool Parse_VarAssign(const char *, bool, GNode *) MAKE_ATTR_USE;
-void Parse_AddIncludeDir(const char *);
void Parse_File(const char *, int);
void Parse_PushInput(const char *, unsigned, unsigned, Buffer,
struct ForLoop *);
void Parse_MainName(GNodeList *);
int Parse_NumErrors(void) MAKE_ATTR_USE;
+unsigned int CurFile_CondMinDepth(void) MAKE_ATTR_USE;
+void Parse_GuardElse(void);
+void Parse_GuardEndif(void);
/* suff.c */
@@ -929,6 +947,14 @@ typedef enum VarEvalMode {
*/
VARE_PARSE_ONLY,
+ /*
+ * Parse text in which '${...}' and '$(...)' are not parsed as
+ * subexpressions (with all their individual escaping rules) but
+ * instead simply as text with balanced '${}' or '$()'. Other '$'
+ * are copied verbatim.
+ */
+ VARE_PARSE_BALANCED,
+
/* Parse and evaluate the expression. */
VARE_WANTRES,
@@ -978,35 +1004,12 @@ typedef enum VarSetFlags {
/*
* Make the variable read-only. No further modification is possible,
- * except for another call to Var_Set with the same flag.
+ * except for another call to Var_Set with the same flag. See the
+ * special targets '.NOREADONLY' and '.READONLY'.
*/
VAR_SET_READONLY = 1 << 1
} VarSetFlags;
-/* The state of error handling returned by Var_Parse. */
-typedef enum VarParseResult {
-
- /* Both parsing and evaluation succeeded. */
- VPR_OK,
-
- /* Parsing or evaluating failed, with an error message. */
- VPR_ERR,
-
- /*
- * Parsing succeeded, undefined expressions are allowed and the
- * expression was still undefined after applying all modifiers.
- * No error message is printed in this case.
- *
- * Some callers handle this case differently, so return this
- * information to them, for now.
- *
- * TODO: Instead of having this special return value, rather ensure
- * that VARE_EVAL_KEEP_UNDEF is processed properly.
- */
- VPR_UNDEF
-
-} VarParseResult;
-
typedef enum VarExportMode {
/* .export-env */
VEM_ENV,
@@ -1027,19 +1030,21 @@ bool Var_Exists(GNode *, const char *) MAKE_ATTR_USE;
bool Var_ExistsExpand(GNode *, const char *) MAKE_ATTR_USE;
FStr Var_Value(GNode *, const char *) MAKE_ATTR_USE;
const char *GNode_ValueDirect(GNode *, const char *) MAKE_ATTR_USE;
-VarParseResult Var_Parse(const char **, GNode *, VarEvalMode, FStr *);
-VarParseResult Var_Subst(const char *, GNode *, VarEvalMode, char **);
+FStr Var_Parse(const char **, GNode *, VarEvalMode);
+char *Var_Subst(const char *, GNode *, VarEvalMode);
void Var_Expand(FStr *, GNode *, VarEvalMode);
void Var_Stats(void);
void Var_Dump(GNode *);
-void Var_ReexportVars(void);
+void Var_ReexportVars(GNode *);
void Var_Export(VarExportMode, const char *);
void Var_ExportVars(const char *);
void Var_UnExport(bool, const char *);
+void Var_ReadOnly(const char *, bool);
void Global_Set(const char *, const char *);
void Global_Append(const char *, const char *);
void Global_Delete(const char *);
+void Global_Set_ReadOnly(const char *, const char *);
/* util.c */
typedef void (*SignalProc)(int);
@@ -1059,10 +1064,14 @@ void PrintOnError(GNode *, const char *);
void Main_ExportMAKEFLAGS(bool);
bool Main_SetObjdir(bool, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
int mkTempFile(const char *, char *, size_t) MAKE_ATTR_USE;
-int str2Lst_Append(StringList *, char *);
+void AppendWords(StringList *, char *);
void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *);
bool GNode_ShouldExecute(GNode *gn) MAKE_ATTR_USE;
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char *, const char *, size_t);
+#endif
+
/* See if the node was seen on the left-hand side of a dependency operator. */
MAKE_INLINE bool MAKE_ATTR_USE
GNode_IsTarget(const GNode *gn)
@@ -1212,7 +1221,8 @@ pp_skip_hspace(char **pp)
}
#if defined(lint)
-# define MAKE_RCSID(id) extern void do_not_define_rcsid(void)
+void do_not_define_rcsid(void); /* for lint */
+# define MAKE_RCSID(id) void do_not_define_rcsid(void)
#elif defined(MAKE_NATIVE)
# include <sys/cdefs.h>
# ifndef __IDSTRING
@@ -1231,7 +1241,7 @@ pp_skip_hspace(char **pp)
# define MAKE_RCSID(id) static volatile char \
MAKE_RCSID_CONCAT(rcsid_, __COUNTER__)[] = id
#elif defined(MAKE_ALL_IN_ONE)
-# define MAKE_RCSID(id) extern void do_not_define_rcsid(void)
+# define MAKE_RCSID(id) void do_not_define_rcsid(void)
#else
# define MAKE_RCSID(id) static volatile char rcsid[] = id
#endif