xref: /freebsd/contrib/bmake/make.h (revision 7937bfbc0ca53fe7cdd0d54414f9296e273a518e)
1 /*	$NetBSD: make.h,v 1.344 2024/07/11 20:09:16 sjg Exp $	*/
2 
3 /*
4  * Copyright (c) 1988, 1989, 1990, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Adam de Boor.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  *	from: @(#)make.h	8.3 (Berkeley) 6/13/95
35  */
36 
37 /*
38  * Copyright (c) 1989 by Berkeley Softworks
39  * All rights reserved.
40  *
41  * This code is derived from software contributed to Berkeley by
42  * Adam de Boor.
43  *
44  * Redistribution and use in source and binary forms, with or without
45  * modification, are permitted provided that the following conditions
46  * are met:
47  * 1. Redistributions of source code must retain the above copyright
48  *    notice, this list of conditions and the following disclaimer.
49  * 2. Redistributions in binary form must reproduce the above copyright
50  *    notice, this list of conditions and the following disclaimer in the
51  *    documentation and/or other materials provided with the distribution.
52  * 3. All advertising materials mentioning features or use of this software
53  *    must display the following acknowledgement:
54  *	This product includes software developed by the University of
55  *	California, Berkeley and its contributors.
56  * 4. Neither the name of the University nor the names of its contributors
57  *    may be used to endorse or promote products derived from this software
58  *    without specific prior written permission.
59  *
60  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70  * SUCH DAMAGE.
71  *
72  *	from: @(#)make.h	8.3 (Berkeley) 6/13/95
73  */
74 
75 /*
76  * make.h --
77  *	The global definitions for make
78  */
79 
80 #ifndef MAKE_MAKE_H
81 #define MAKE_MAKE_H
82 
83 #ifdef HAVE_CONFIG_H
84 # include "config.h"
85 #endif
86 
87 #include <sys/types.h>
88 #include <sys/param.h>
89 #include <sys/stat.h>
90 
91 #include <assert.h>
92 #include <ctype.h>
93 #include <fcntl.h>
94 #include <stdarg.h>
95 #include <stdio.h>
96 #include <stdlib.h>
97 #ifdef HAVE_STRING_H
98 #include <string.h>
99 #else
100 #include <strings.h>
101 #endif
102 #include <unistd.h>
103 #include <sys/cdefs.h>
104 
105 #ifndef FD_CLOEXEC
106 #define FD_CLOEXEC 1
107 #endif
108 
109 #if defined(__GNUC__)
110 #define MAKE_GNUC_PREREQ(x, y)						\
111 	((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) ||			\
112 	 (__GNUC__ > (x)))
113 #else
114 #define MAKE_GNUC_PREREQ(x, y)	0
115 #endif
116 
117 #if MAKE_GNUC_PREREQ(2, 7) || lint
118 #define MAKE_ATTR_UNUSED	__attribute__((__unused__))
119 #else
120 #define MAKE_ATTR_UNUSED	/* delete */
121 #endif
122 
123 #if MAKE_GNUC_PREREQ(2, 5)
124 #define MAKE_ATTR_DEAD		__attribute__((__noreturn__))
125 #elif defined(__GNUC__)
126 #define MAKE_ATTR_DEAD		__volatile
127 #else
128 #define MAKE_ATTR_DEAD		/* delete */
129 #endif
130 
131 #if MAKE_GNUC_PREREQ(2, 7)
132 #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg)	\
133 	    __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
134 #else
135 #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg)	/* delete */
136 #endif
137 
138 #if MAKE_GNUC_PREREQ(4, 0)
139 #define MAKE_ATTR_USE		__attribute__((__warn_unused_result__))
140 #else
141 #define MAKE_ATTR_USE		/* delete */
142 #endif
143 
144 #if MAKE_GNUC_PREREQ(8, 0)
145 #define MAKE_ATTR_NOINLINE		__attribute__((__noinline__))
146 #else
147 #define MAKE_ATTR_NOINLINE		/* delete */
148 #endif
149 
150 #if __STDC_VERSION__ >= 199901L || defined(lint)
151 #define MAKE_INLINE static inline MAKE_ATTR_UNUSED
152 #else
153 #define MAKE_INLINE static MAKE_ATTR_UNUSED
154 #endif
155 
156 /* MAKE_STATIC marks a function that may or may not be inlined. */
157 #if defined(lint)
158 /* As of 2021-07-31, NetBSD lint ignores __attribute__((unused)). */
159 #define MAKE_STATIC MAKE_INLINE
160 #else
161 #define MAKE_STATIC static MAKE_ATTR_UNUSED
162 #endif
163 
164 #if __STDC_VERSION__ >= 199901L || defined(lint) || defined(USE_C99_BOOLEAN)
165 #include <stdbool.h>
166 #elif defined(__bool_true_false_are_defined)
167 /*
168  * All files of make must be compiled with the same definition of bool.
169  * Since one of the files includes <stdbool.h>, that means the header is
170  * available on this platform.  Recompile everything with -DUSE_C99_BOOLEAN.
171  */
172 #error "<stdbool.h> is included in pre-C99 mode"
173 #elif defined(bool) || defined(true) || defined(false)
174 /*
175  * In pre-C99 mode, make does not expect that bool is already defined.
176  * You need to ensure that all translation units use the same definition for
177  * bool.
178  */
179 #error "bool/true/false is defined in pre-C99 mode"
180 #else
181 typedef unsigned char bool;
182 #define true	1
183 #define false	0
184 #endif
185 
186 #include "lst.h"
187 #include "make_malloc.h"
188 #include "str.h"
189 #include "hash.h"
190 #include "make-conf.h"
191 #include "buf.h"
192 
193 /*
194  * some vendors don't have this --sjg
195  */
196 #if defined(S_IFDIR) && !defined(S_ISDIR)
197 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
198 #endif
199 
200 #if defined(sun) && (defined(__svr4__) || defined(__SVR4))
201 # define POSIX_SIGNALS
202 #endif
203 
204 /*
205  * IRIX defines OP_NONE in sys/fcntl.h
206  */
207 #if defined(OP_NONE)
208 # undef OP_NONE
209 #endif
210 
211 /*
212  * The typical flow of states is:
213  *
214  * The direct successful path:
215  * UNMADE -> BEINGMADE -> MADE.
216  *
217  * The direct error path:
218  * UNMADE -> BEINGMADE -> ERROR.
219  *
220  * The successful path when dependencies need to be made first:
221  * UNMADE -> DEFERRED -> REQUESTED -> BEINGMADE -> MADE.
222  *
223  * A node that has dependencies, and one of the dependencies cannot be made:
224  * UNMADE -> DEFERRED -> ABORTED.
225  *
226  * A node that turns out to be up-to-date:
227  * UNMADE -> BEINGMADE -> UPTODATE.
228  */
229 typedef enum GNodeMade {
230 	/* Not examined yet. */
231 	UNMADE,
232 	/*
233 	 * The node has been examined but is not yet ready since its
234 	 * dependencies have to be made first.
235 	 */
236 	DEFERRED,
237 
238 	/* The node is on the toBeMade list. */
239 	REQUESTED,
240 
241 	/*
242 	 * The node is already being made. Trying to build a node in this
243 	 * state indicates a cycle in the graph.
244 	 */
245 	BEINGMADE,
246 
247 	/* Was out-of-date and has been made. */
248 	MADE,
249 	/* Was already up-to-date, does not need to be made. */
250 	UPTODATE,
251 	/*
252 	 * An error occurred while it was being made. Used only in compat
253 	 * mode.
254 	 */
255 	ERROR,
256 	/*
257 	 * The target was aborted due to an error making a dependency. Used
258 	 * only in compat mode.
259 	 */
260 	ABORTED
261 } GNodeMade;
262 
263 /*
264  * The OP_ constants are used when parsing a dependency line as a way of
265  * communicating to other parts of the program the way in which a target
266  * should be made.
267  *
268  * Some of the OP_ constants can be combined, others cannot.
269  *
270  * See the tests depsrc-*.mk and deptgt-*.mk.
271  */
272 typedef enum GNodeType {
273 	OP_NONE		= 0,
274 
275 	/*
276 	 * The dependency operator ':' is the most common one.  The commands
277 	 * of this node are executed if any child is out-of-date.
278 	 */
279 	OP_DEPENDS	= 1 << 0,
280 	/*
281 	 * The dependency operator '!' always executes its commands, even if
282 	 * its children are up-to-date.
283 	 */
284 	OP_FORCE	= 1 << 1,
285 	/*
286 	 * The dependency operator '::' behaves like ':', except that it
287 	 * allows multiple dependency groups to be defined.  Each of these
288 	 * groups is executed on its own, independently from the others. Each
289 	 * individual dependency group is called a cohort.
290 	 */
291 	OP_DOUBLEDEP	= 1 << 2,
292 
293 	/* Matches the dependency operators ':', '!' and '::'. */
294 	OP_OPMASK	= OP_DEPENDS | OP_FORCE | OP_DOUBLEDEP,
295 
296 	/* Don't care if the target doesn't exist and can't be created. */
297 	OP_OPTIONAL	= 1 << 3,
298 	/* Use associated commands for parents. */
299 	OP_USE		= 1 << 4,
300 	/*
301 	 * Target is never out of date, but always execute commands anyway.
302 	 * Its time doesn't matter, so it has none...sort of.
303 	 */
304 	OP_EXEC		= 1 << 5,
305 	/*
306 	 * Ignore non-zero exit status from shell commands when creating the
307 	 * node.
308 	 */
309 	OP_IGNORE	= 1 << 6,
310 	/* Don't remove the target when interrupted. */
311 	OP_PRECIOUS	= 1 << 7,
312 	/* Don't echo commands when executed. */
313 	OP_SILENT	= 1 << 8,
314 	/*
315 	 * Target is a recursive make so its commands should always be
316 	 * executed when it is out of date, regardless of the state of the -n
317 	 * or -t flags.
318 	 */
319 	OP_MAKE		= 1 << 9,
320 	/*
321 	 * Target is out-of-date only if any of its children was out-of-date.
322 	 */
323 	OP_JOIN		= 1 << 10,
324 	/* Assume the children of the node have been already made. */
325 	OP_MADE		= 1 << 11,
326 	/* Special .BEGIN, .END or .INTERRUPT. */
327 	OP_SPECIAL	= 1 << 12,
328 	/* Like .USE, only prepend commands. */
329 	OP_USEBEFORE	= 1 << 13,
330 	/*
331 	 * The node is invisible to its parents. I.e. it doesn't show up in
332 	 * the parents' local variables (.IMPSRC, .ALLSRC).
333 	 */
334 	OP_INVISIBLE	= 1 << 14,
335 	/*
336 	 * The node does not become the main target, even if it is the first
337 	 * target in the first makefile.
338 	 */
339 	OP_NOTMAIN	= 1 << 15,
340 	/* Not a file target; run always. */
341 	OP_PHONY	= 1 << 16,
342 	/* Don't search for the file in the path. */
343 	OP_NOPATH	= 1 << 17,
344 	/*
345 	 * In a dependency line "target: source1 .WAIT source2", source1 is
346 	 * made first, including its children.  Once that is finished,
347 	 * source2 is made, including its children.  The .WAIT keyword may
348 	 * appear more than once in a single dependency declaration.
349 	 */
350 	OP_WAIT		= 1 << 18,
351 	/* .NOMETA do not create a .meta file */
352 	OP_NOMETA	= 1 << 19,
353 	/* .META we _do_ want a .meta file */
354 	OP_META		= 1 << 20,
355 	/* Do not compare commands in .meta file */
356 	OP_NOMETA_CMP	= 1 << 21,
357 	/* Possibly a submake node */
358 	OP_SUBMAKE	= 1 << 22,
359 
360 	/* Attributes applied by PMake */
361 
362 	/* The node is a transformation rule, such as ".c.o". */
363 	OP_TRANSFORM	= 1 << 30,
364 	/* Target is a member of an archive */
365 	/* XXX: How does this differ from OP_ARCHV? */
366 	OP_MEMBER	= 1 << 29,
367 	/*
368 	 * The node is a library, its name has the form "-l<libname>".
369 	 */
370 	OP_LIB		= 1 << 28,
371 	/*
372 	 * The node is an archive member, its name has the form
373 	 * "archive(member)".
374 	 */
375 	/* XXX: How does this differ from OP_MEMBER? */
376 	OP_ARCHV	= 1 << 27,
377 	/*
378 	 * Target has all the commands it should. Used when parsing to catch
379 	 * multiple command groups for a target.  Only applies to the
380 	 * dependency operators ':' and '!', but not to '::'.
381 	 */
382 	OP_HAS_COMMANDS	= 1 << 26,
383 	/*
384 	 * The special command "..." has been seen. All further commands from
385 	 * this node will be saved on the .END node instead, to be executed
386 	 * at the very end.
387 	 */
388 	OP_SAVE_CMDS	= 1 << 25,
389 	/*
390 	 * Already processed by Suff_FindDeps, to find dependencies from
391 	 * suffix transformation rules.
392 	 */
393 	OP_DEPS_FOUND	= 1 << 24,
394 	/* Node found while expanding .ALLSRC */
395 	OP_MARK		= 1 << 23
396 } GNodeType;
397 
398 typedef struct GNodeFlags {
399 	/* this target needs to be (re)made */
400 	bool remake:1;
401 	/* children of this target were made */
402 	bool childMade:1;
403 	/* children don't exist, and we pretend made */
404 	bool force:1;
405 	/* Set by Make_ProcessWait() */
406 	bool doneWait:1;
407 	/* Build requested by .ORDER processing */
408 	bool doneOrder:1;
409 	/* Node created from .depend */
410 	bool fromDepend:1;
411 	/* We do it once only */
412 	bool doneAllsrc:1;
413 	/* Used by MakePrintStatus */
414 	bool cycle:1;
415 	/* Used by MakePrintStatus */
416 	bool doneCycle:1;
417 } GNodeFlags;
418 
419 typedef struct List StringList;
420 typedef struct ListNode StringListNode;
421 
422 typedef struct List GNodeList;
423 typedef struct ListNode GNodeListNode;
424 
425 typedef struct SearchPath {
426 	List /* of CachedDir */ dirs;
427 } SearchPath;
428 
429 /*
430  * A graph node represents a target that can possibly be made, including its
431  * relation to other targets.
432  */
433 typedef struct GNode {
434 	/* The target's name, such as "clean" or "make.c" */
435 	char *name;
436 	/* The unexpanded name of a .USE node */
437 	char *uname;
438 	/*
439 	 * The full pathname of the file belonging to the target.
440 	 *
441 	 * XXX: What about .PHONY targets? These don't have an associated
442 	 * path.
443 	 */
444 	char *path;
445 
446 	/*
447 	 * The type of operator used to define the sources (see the OP flags
448 	 * below).
449 	 *
450 	 * XXX: This looks like a wild mixture of type and flags.
451 	 */
452 	GNodeType type;
453 	GNodeFlags flags;
454 
455 	/* The state of processing on this node */
456 	GNodeMade made;
457 	/* The number of unmade children */
458 	int unmade;
459 
460 	/*
461 	 * The modification time; 0 means the node does not have a
462 	 * corresponding file; see GNode_IsOODate.
463 	 */
464 	time_t mtime;
465 	struct GNode *youngestChild;
466 
467 	/*
468 	 * The GNodes for which this node is an implied source. May be empty.
469 	 * For example, when there is an inference rule for .c.o, the node
470 	 * for file.c has the node for file.o in this list.
471 	 */
472 	GNodeList implicitParents;
473 
474 	/*
475 	 * The nodes that depend on this one, or in other words, the nodes
476 	 * for which this is a source.
477 	 */
478 	GNodeList parents;
479 	/* The nodes on which this one depends. */
480 	GNodeList children;
481 
482 	/*
483 	 * .ORDER nodes we need made. The nodes that must be made (if they're
484 	 * made) before this node can be made, but that do not enter into the
485 	 * datedness of this node.
486 	 */
487 	GNodeList order_pred;
488 	/*
489 	 * .ORDER nodes who need us. The nodes that must be made (if they're
490 	 * made at all) after this node is made, but that do not depend on
491 	 * this node, in the normal sense.
492 	 */
493 	GNodeList order_succ;
494 
495 	/*
496 	 * Other nodes of the same name, for targets that were defined using
497 	 * the '::' dependency operator (OP_DOUBLEDEP).
498 	 */
499 	GNodeList cohorts;
500 	/* The "#n" suffix for this cohort, or "" for other nodes */
501 	char cohort_num[8];
502 	/* The number of unmade instances on the cohorts list */
503 	int unmade_cohorts;
504 	/*
505 	 * Pointer to the first instance of a '::' node; only set when on a
506 	 * cohorts list
507 	 */
508 	struct GNode *centurion;
509 
510 	/* Last time (sequence number) we tried to make this node */
511 	unsigned int checked_seqno;
512 
513 	/*
514 	 * The "local" variables that are specific to this target and this
515 	 * target only, such as $@, $<, $?.
516 	 *
517 	 * Also used for the global variable scopes SCOPE_GLOBAL,
518 	 * SCOPE_CMDLINE, SCOPE_INTERNAL, which contain variables with
519 	 * arbitrary names.
520 	 */
521 	HashTable /* of Var pointer */ vars;
522 
523 	/* The commands to be given to a shell to create this target. */
524 	StringList commands;
525 
526 	/*
527 	 * Suffix for the node (determined by Suff_FindDeps and opaque to
528 	 * everyone but the Suff module)
529 	 */
530 	struct Suffix *suffix;
531 
532 	/* Filename where the GNode got defined, unlimited lifetime */
533 	const char *fname;
534 	/* Line number where the GNode got defined, 1-based */
535 	unsigned lineno;
536 	int exit_status;
537 } GNode;
538 
539 /*
540  * Keep track of whether to include <posix.mk> when parsing the line
541  * '.POSIX:'.
542  */
543 extern enum PosixState {
544 	PS_NOT_YET,
545 	PS_MAYBE_NEXT_LINE,
546 	PS_NOW_OR_NEVER,
547 	PS_TOO_LATE
548 } posix_state;
549 
550 /* Error levels for diagnostics during parsing. */
551 typedef enum ParseErrorLevel {
552 	/*
553 	 * Exit when the current top-level makefile has been parsed
554 	 * completely.
555 	 */
556 	PARSE_FATAL = 1,
557 	/* Print "warning"; may be upgraded to fatal by the -w option. */
558 	PARSE_WARNING,
559 	/* Informational, mainly used during development of makefiles. */
560 	PARSE_INFO
561 } ParseErrorLevel;
562 
563 /*
564  * Values returned by Cond_EvalLine and Cond_EvalCondition.
565  */
566 typedef enum CondResult {
567 	CR_TRUE,		/* Parse the next lines */
568 	CR_FALSE,		/* Skip the next lines */
569 	CR_ERROR		/* Unknown directive or parse error */
570 } CondResult;
571 
572 typedef struct {
573 	enum GuardKind {
574 		GK_VARIABLE,
575 		GK_TARGET
576 	} kind;
577 	char *name;
578 } Guard;
579 
580 /* Names of the variables that are "local" to a specific target. */
581 #define TARGET	"@"		/* Target of dependency */
582 #define OODATE	"?"		/* All out-of-date sources */
583 #define ALLSRC	">"		/* All sources */
584 #define IMPSRC	"<"		/* Source implied by transformation */
585 #define PREFIX	"*"		/* Common prefix */
586 #define ARCHIVE	"!"		/* Archive in "archive(member)" syntax */
587 #define MEMBER	"%"		/* Member in "archive(member)" syntax */
588 
589 /*
590  * Global Variables
591  */
592 
593 /* True if every target is precious */
594 extern bool allPrecious;
595 /* True if failed targets should be deleted */
596 extern bool deleteOnError;
597 /* true while processing .depend */
598 extern bool doing_depend;
599 /* .DEFAULT rule */
600 extern GNode *defaultNode;
601 
602 /*
603  * Variables defined internally by make which should not override those set
604  * by makefiles.
605  */
606 extern GNode *SCOPE_INTERNAL;
607 /* Variables defined in a global scope, e.g in the makefile itself. */
608 extern GNode *SCOPE_GLOBAL;
609 /* Variables defined on the command line. */
610 extern GNode *SCOPE_CMDLINE;
611 
612 /*
613  * Value returned by Var_Parse when an error is encountered. It points to an
614  * empty string, so naive callers needn't worry about it.
615  */
616 extern char var_Error[];
617 
618 /* The time at the start of this whole process */
619 extern time_t now;
620 
621 /*
622  * The list of directories to search when looking for targets (set by the
623  * special target .PATH).
624  */
625 extern SearchPath dirSearchPath;
626 /* Used for .include "...". */
627 extern SearchPath *parseIncPath;
628 /*
629  * Used for .include <...>, for the built-in sys.mk and for makefiles from
630  * the command line arguments.
631  */
632 extern SearchPath *sysIncPath;
633 /* The default for sysIncPath. */
634 extern SearchPath *defSysIncPath;
635 
636 /* Startup directory */
637 extern char curdir[];
638 /* The basename of the program name, suffixed with [n] for sub-makes.  */
639 extern const char *progname;
640 extern int makelevel;
641 /* Name of the .depend makefile */
642 extern char *makeDependfile;
643 /* If we replaced environ, this will be non-NULL. */
644 extern char **savedEnv;
645 extern GNode *mainNode;
646 
647 extern pid_t myPid;
648 
649 #define MAKEFLAGS	".MAKEFLAGS"
650 #ifndef MAKE_LEVEL_ENV
651 # define MAKE_LEVEL_ENV	"MAKELEVEL"
652 #endif
653 
654 typedef struct DebugFlags {
655 	bool DEBUG_ARCH:1;
656 	bool DEBUG_COND:1;
657 	bool DEBUG_CWD:1;
658 	bool DEBUG_DIR:1;
659 	bool DEBUG_ERROR:1;
660 	bool DEBUG_FOR:1;
661 	bool DEBUG_GRAPH1:1;
662 	bool DEBUG_GRAPH2:1;
663 	bool DEBUG_GRAPH3:1;
664 	bool DEBUG_HASH:1;
665 	bool DEBUG_JOB:1;
666 	bool DEBUG_LOUD:1;
667 	bool DEBUG_MAKE:1;
668 	bool DEBUG_META:1;
669 	bool DEBUG_PARSE:1;
670 	bool DEBUG_SCRIPT:1;
671 	bool DEBUG_SHELL:1;
672 	bool DEBUG_SUFF:1;
673 	bool DEBUG_TARG:1;
674 	bool DEBUG_VAR:1;
675 } DebugFlags;
676 
677 #define CONCAT(a, b) a##b
678 
679 #define DEBUG(module) (opts.debug.CONCAT(DEBUG_, module))
680 
681 void debug_printf(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
682 
683 #define DEBUG_IMPL(module, args) \
684 	do { \
685 		if (DEBUG(module)) \
686 			debug_printf args; \
687 	} while (false)
688 
689 #define DEBUG0(module, fmt) \
690 	DEBUG_IMPL(module, (fmt))
691 #define DEBUG1(module, fmt, arg1) \
692 	DEBUG_IMPL(module, (fmt, arg1))
693 #define DEBUG2(module, fmt, arg1, arg2) \
694 	DEBUG_IMPL(module, (fmt, arg1, arg2))
695 #define DEBUG3(module, fmt, arg1, arg2, arg3) \
696 	DEBUG_IMPL(module, (fmt, arg1, arg2, arg3))
697 #define DEBUG4(module, fmt, arg1, arg2, arg3, arg4) \
698 	DEBUG_IMPL(module, (fmt, arg1, arg2, arg3, arg4))
699 #define DEBUG5(module, fmt, arg1, arg2, arg3, arg4, arg5) \
700 	DEBUG_IMPL(module, (fmt, arg1, arg2, arg3, arg4, arg5))
701 
702 typedef enum PrintVarsMode {
703 	PVM_NONE,
704 	PVM_UNEXPANDED,
705 	PVM_EXPANDED
706 } PrintVarsMode;
707 
708 /* Command line options */
709 typedef struct CmdOpts {
710 	/* -B: whether to be compatible to traditional make */
711 	bool compatMake;
712 
713 	/*
714 	 * -d: debug control: There is one flag per module.  It is up to the
715 	 * module what debug information to print.
716 	 */
717 	DebugFlags debug;
718 
719 	/* -df: debug output is written here - default stderr */
720 	FILE *debug_file;
721 
722 	/*
723 	 * -dL: lint mode
724 	 *
725 	 * Runs make in strict mode, with additional checks and better error
726 	 * handling.
727 	 */
728 	bool strict;
729 
730 	/* -dV: for the -V option, print unexpanded variable values */
731 	bool debugVflag;
732 
733 	/* -e: check environment variables before global variables */
734 	bool checkEnvFirst;
735 
736 	/* -f: the makefiles to read */
737 	StringList makefiles;
738 
739 	/* -i: if true, ignore all errors from shell commands */
740 	bool ignoreErrors;
741 
742 	/*
743 	 * -j: the maximum number of jobs that can run in parallel; this is
744 	 * coordinated with the submakes
745 	 */
746 	int maxJobs;
747 
748 	/*
749 	 * -k: if true and an error occurs while making a node, continue
750 	 * making nodes that do not depend on the erroneous node
751 	 */
752 	bool keepgoing;
753 
754 	/* -N: execute no commands from the targets */
755 	bool noRecursiveExecute;
756 
757 	/* -n: execute almost no commands from the targets */
758 	bool noExecute;
759 
760 	/*
761 	 * -q: if true, do not really make anything, just see if the targets
762 	 * are out-of-date
763 	 */
764 	bool query;
765 
766 	/* -r: raw mode, do not load the builtin rules. */
767 	bool noBuiltins;
768 
769 	/* -s: don't echo the shell commands before executing them */
770 	bool silent;
771 
772 	/*
773 	 * -t: touch the targets if they are out-of-date, but don't actually
774 	 * make them
775 	 */
776 	bool touch;
777 
778 	/* -[Vv]: print expanded or unexpanded selected variables */
779 	PrintVarsMode printVars;
780 	/* -[Vv]: the variables to print */
781 	StringList variables;
782 
783 	/* -W: if true, makefile parsing warnings are treated as errors */
784 	bool parseWarnFatal;
785 
786 	/* -w: print 'Entering' and 'Leaving' for submakes */
787 	bool enterFlag;
788 
789 	/*
790 	 * -X: if true, do not export variables set on the command line to
791 	 * the environment.
792 	 */
793 	bool varNoExportEnv;
794 
795 	/*
796 	 * The target names specified on the command line. Used to resolve
797 	 * .if make(...) statements.
798 	 */
799 	StringList create;
800 
801 	/*
802 	 * Randomize the order in which the targets from toBeMade are made,
803 	 * to catch undeclared dependencies.
804 	 */
805 	bool randomizeTargets;
806 } CmdOpts;
807 
808 extern CmdOpts opts;
809 extern bool forceJobs;
810 extern char **environ;
811 
812 /* arch.c */
813 void Arch_Init(void);
814 #ifdef CLEANUP
815 void Arch_End(void);
816 #endif
817 
818 bool Arch_ParseArchive(char **, GNodeList *, GNode *);
819 void Arch_Touch(GNode *);
820 void Arch_TouchLib(GNode *);
821 void Arch_UpdateMTime(GNode *);
822 void Arch_UpdateMemberMTime(GNode *);
823 void Arch_FindLib(GNode *, SearchPath *);
824 bool Arch_LibOODate(GNode *) MAKE_ATTR_USE;
825 bool Arch_IsLib(GNode *) MAKE_ATTR_USE;
826 
827 /* compat.c */
828 bool Compat_RunCommand(const char *, GNode *, StringListNode *);
829 void Compat_MakeAll(GNodeList *);
830 void Compat_Make(GNode *, GNode *);
831 
832 /* cond.c */
833 extern unsigned int cond_depth;
834 CondResult Cond_EvalCondition(const char *) MAKE_ATTR_USE;
835 CondResult Cond_EvalLine(const char *) MAKE_ATTR_USE;
836 Guard *Cond_ExtractGuard(const char *) MAKE_ATTR_USE;
837 void Cond_EndFile(void);
838 
839 /* dir.c; see also dir.h */
840 
841 MAKE_INLINE const char * MAKE_ATTR_USE
842 str_basename(const char *pathname)
843 {
844 	const char *lastSlash = strrchr(pathname, '/');
845 	return lastSlash != NULL ? lastSlash + 1 : pathname;
846 }
847 
848 MAKE_INLINE SearchPath * MAKE_ATTR_USE
849 SearchPath_New(void)
850 {
851 	SearchPath *path = bmake_malloc(sizeof *path);
852 	Lst_Init(&path->dirs);
853 	return path;
854 }
855 
856 void SearchPath_Free(SearchPath *);
857 
858 /* for.c */
859 struct ForLoop;
860 int For_Eval(const char *) MAKE_ATTR_USE;
861 bool For_Accum(const char *, int *) MAKE_ATTR_USE;
862 void For_Run(unsigned, unsigned);
863 bool For_NextIteration(struct ForLoop *, Buffer *);
864 char *ForLoop_Details(const struct ForLoop *);
865 void ForLoop_Free(struct ForLoop *);
866 void For_Break(struct ForLoop *);
867 
868 /* job.c */
869 void JobReapChild(pid_t, int, bool);
870 
871 /* longer than this we use a temp file */
872 #ifndef MAKE_CMDLEN_LIMIT
873 # define MAKE_CMDLEN_LIMIT 1000
874 #endif
875 /* main.c */
876 void Main_ParseArgLine(const char *);
877 int Cmd_Argv(const char *, size_t, const char **, size_t, char *, size_t, bool, bool);
878 char *Cmd_Exec(const char *, char **) MAKE_ATTR_USE;
879 void Error(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
880 void Fatal(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;
881 void Punt(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;
882 void DieHorribly(void) MAKE_ATTR_DEAD;
883 void Finish(int) MAKE_ATTR_DEAD;
884 int unlink_file(const char *) MAKE_ATTR_USE;
885 void execDie(const char *, const char *);
886 char *getTmpdir(void) MAKE_ATTR_USE;
887 bool ParseBoolean(const char *, bool) MAKE_ATTR_USE;
888 const char *cached_realpath(const char *, char *);
889 bool GetBooleanExpr(const char *, bool);
890 
891 /* parse.c */
892 extern int parseErrors;
893 void Parse_Init(void);
894 #ifdef CLEANUP
895 void Parse_End(void);
896 #endif
897 
898 void PrintLocation(FILE *, bool, const GNode *);
899 void PrintStackTrace(bool);
900 void Parse_Error(ParseErrorLevel, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
901 bool Parse_VarAssign(const char *, bool, GNode *) MAKE_ATTR_USE;
902 void Parse_File(const char *, int);
903 void Parse_PushInput(const char *, unsigned, unsigned, Buffer,
904 		     struct ForLoop *);
905 void Parse_MainName(GNodeList *);
906 unsigned int CurFile_CondMinDepth(void) MAKE_ATTR_USE;
907 void Parse_GuardElse(void);
908 void Parse_GuardEndif(void);
909 
910 
911 /* suff.c */
912 void Suff_Init(void);
913 #ifdef CLEANUP
914 void Suff_End(void);
915 #endif
916 
917 void Suff_ClearSuffixes(void);
918 bool Suff_IsTransform(const char *) MAKE_ATTR_USE;
919 GNode *Suff_AddTransform(const char *);
920 void Suff_EndTransform(GNode *);
921 void Suff_AddSuffix(const char *);
922 SearchPath *Suff_GetPath(const char *) MAKE_ATTR_USE;
923 void Suff_ExtendPaths(void);
924 void Suff_AddInclude(const char *);
925 void Suff_AddLib(const char *);
926 void Suff_FindDeps(GNode *);
927 SearchPath *Suff_FindPath(GNode *) MAKE_ATTR_USE;
928 void Suff_SetNull(const char *);
929 void Suff_PrintAll(void);
930 char *Suff_NamesStr(void) MAKE_ATTR_USE;
931 
932 /* targ.c */
933 void Targ_Init(void);
934 void Targ_End(void);
935 
936 void Targ_Stats(void);
937 GNodeList *Targ_List(void) MAKE_ATTR_USE;
938 GNode *GNode_New(const char *) MAKE_ATTR_USE;
939 GNode *Targ_FindNode(const char *) MAKE_ATTR_USE;
940 GNode *Targ_GetNode(const char *) MAKE_ATTR_USE;
941 GNode *Targ_NewInternalNode(const char *) MAKE_ATTR_USE;
942 GNode *Targ_GetEndNode(void);
943 void Targ_FindList(GNodeList *, StringList *);
944 void Targ_PrintCmds(GNode *);
945 void Targ_PrintNode(GNode *, int);
946 void Targ_PrintNodes(GNodeList *, int);
947 const char *Targ_FmtTime(time_t) MAKE_ATTR_USE;
948 void Targ_PrintType(GNodeType);
949 void Targ_PrintGraph(int);
950 void Targ_Propagate(void);
951 const char *GNodeMade_Name(GNodeMade) MAKE_ATTR_USE;
952 #ifdef CLEANUP
953 void Parse_RegisterCommand(char *);
954 #else
955 MAKE_INLINE
956 void Parse_RegisterCommand(char *cmd MAKE_ATTR_UNUSED)
957 {
958 }
959 #endif
960 
961 /* var.c */
962 
963 typedef enum VarEvalMode {
964 
965 	/*
966 	 * Only parse the expression but don't evaluate any part of it.
967 	 *
968 	 * TODO: Document what Var_Parse and Var_Subst return in this mode.
969 	 *  As of 2021-03-15, they return unspecified, inconsistent results.
970 	 */
971 	VARE_PARSE,
972 
973 	/*
974 	 * Parse text in which '${...}' and '$(...)' are not parsed as
975 	 * subexpressions (with all their individual escaping rules) but
976 	 * instead simply as text with balanced '${}' or '$()'.  Other '$'
977 	 * are copied verbatim.
978 	 */
979 	VARE_PARSE_BALANCED,
980 
981 	/* Parse and evaluate the expression. */
982 	VARE_EVAL,
983 
984 	/*
985 	 * Parse and evaluate the expression.  It is an error if a
986 	 * subexpression evaluates to undefined.
987 	 */
988 	VARE_EVAL_DEFINED,
989 
990 	/*
991 	 * Parse and evaluate the expression.  Keep undefined variables as-is
992 	 * instead of expanding them to an empty string.
993 	 *
994 	 * Example for a ':=' assignment:
995 	 *	CFLAGS = $(.INCLUDES)
996 	 *	CFLAGS := -I.. $(CFLAGS)
997 	 *	# If .INCLUDES (an undocumented special variable, by the
998 	 *	# way) is still undefined, the updated CFLAGS becomes
999 	 *	# "-I.. $(.INCLUDES)".
1000 	 */
1001 	VARE_EVAL_KEEP_UNDEFINED,
1002 
1003 	/*
1004 	 * Parse and evaluate the expression.  Keep '$$' as '$$' and preserve
1005 	 * undefined subexpressions.
1006 	 */
1007 	VARE_EVAL_KEEP_DOLLAR_AND_UNDEFINED
1008 } VarEvalMode;
1009 
1010 typedef enum VarSetFlags {
1011 	VAR_SET_NONE		= 0,
1012 
1013 	/* do not export */
1014 	VAR_SET_NO_EXPORT	= 1 << 0,
1015 
1016 	/*
1017 	 * Make the variable read-only. No further modification is possible,
1018 	 * except for another call to Var_Set with the same flag. See the
1019 	 * special targets '.NOREADONLY' and '.READONLY'.
1020 	 */
1021 	VAR_SET_READONLY	= 1 << 1,
1022 	VAR_SET_INTERNAL	= 1 << 2
1023 } VarSetFlags;
1024 
1025 typedef enum VarExportMode {
1026 	/* .export-all */
1027 	VEM_ALL,
1028 	/* .export-env */
1029 	VEM_ENV,
1030 	/* .export: Initial export or update an already exported variable. */
1031 	VEM_PLAIN,
1032 	/* .export-literal: Do not expand the variable value. */
1033 	VEM_LITERAL
1034 } VarExportMode;
1035 
1036 void Var_Delete(GNode *, const char *);
1037 #ifdef CLEANUP
1038 void Var_DeleteAll(GNode *scope);
1039 #endif
1040 void Var_Undef(const char *);
1041 void Var_Set(GNode *, const char *, const char *);
1042 void Var_SetExpand(GNode *, const char *, const char *);
1043 void Var_SetWithFlags(GNode *, const char *, const char *, VarSetFlags);
1044 void Var_Append(GNode *, const char *, const char *);
1045 void Var_AppendExpand(GNode *, const char *, const char *);
1046 bool Var_Exists(GNode *, const char *) MAKE_ATTR_USE;
1047 bool Var_ExistsExpand(GNode *, const char *) MAKE_ATTR_USE;
1048 FStr Var_Value(GNode *, const char *) MAKE_ATTR_USE;
1049 const char *GNode_ValueDirect(GNode *, const char *) MAKE_ATTR_USE;
1050 FStr Var_Parse(const char **, GNode *, VarEvalMode);
1051 char *Var_Subst(const char *, GNode *, VarEvalMode);
1052 char *Var_SubstInTarget(const char *, GNode *);
1053 void Var_Expand(FStr *, GNode *, VarEvalMode);
1054 void Var_Stats(void);
1055 void Var_Dump(GNode *);
1056 void Var_ReexportVars(GNode *);
1057 void Var_Export(VarExportMode, const char *);
1058 void Var_ExportVars(const char *);
1059 void Var_UnExport(bool, const char *);
1060 void Var_ReadOnly(const char *, bool);
1061 
1062 void Global_Set(const char *, const char *);
1063 void Global_Append(const char *, const char *);
1064 void Global_Delete(const char *);
1065 void Global_Set_ReadOnly(const char *, const char *);
1066 
1067 const char *EvalStack_Details(void);
1068 
1069 /* util.c */
1070 typedef void (*SignalProc)(int);
1071 SignalProc bmake_signal(int, SignalProc);
1072 
1073 /* make.c */
1074 void GNode_UpdateYoungestChild(GNode *, GNode *);
1075 bool GNode_IsOODate(GNode *) MAKE_ATTR_USE;
1076 void Make_ExpandUse(GNodeList *);
1077 time_t Make_Recheck(GNode *) MAKE_ATTR_USE;
1078 void Make_HandleUse(GNode *, GNode *);
1079 void Make_Update(GNode *);
1080 void GNode_SetLocalVars(GNode *);
1081 bool Make_Run(GNodeList *);
1082 bool shouldDieQuietly(GNode *, int) MAKE_ATTR_USE;
1083 void PrintOnError(GNode *, const char *);
1084 void Main_ExportMAKEFLAGS(bool);
1085 bool Main_SetObjdir(bool, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
1086 int mkTempFile(const char *, char *, size_t) MAKE_ATTR_USE;
1087 void AppendWords(StringList *, char *);
1088 void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *);
1089 bool GNode_ShouldExecute(GNode *gn) MAKE_ATTR_USE;
1090 
1091 #ifndef HAVE_STRLCPY
1092 size_t strlcpy(char *, const char *, size_t);
1093 #endif
1094 
1095 /* See if the node was seen on the left-hand side of a dependency operator. */
1096 MAKE_INLINE bool MAKE_ATTR_USE
1097 GNode_IsTarget(const GNode *gn)
1098 {
1099 	return (gn->type & OP_OPMASK) != OP_NONE;
1100 }
1101 
1102 MAKE_INLINE const char * MAKE_ATTR_USE
1103 GNode_Path(const GNode *gn)
1104 {
1105 	return gn->path != NULL ? gn->path : gn->name;
1106 }
1107 
1108 MAKE_INLINE bool MAKE_ATTR_USE
1109 GNode_IsWaitingFor(const GNode *gn)
1110 {
1111 	return gn->flags.remake && gn->made <= REQUESTED;
1112 }
1113 
1114 MAKE_INLINE bool MAKE_ATTR_USE
1115 GNode_IsReady(const GNode *gn)
1116 {
1117 	return gn->made > DEFERRED;
1118 }
1119 
1120 MAKE_INLINE bool MAKE_ATTR_USE
1121 GNode_IsDone(const GNode *gn)
1122 {
1123 	return gn->made >= MADE;
1124 }
1125 
1126 MAKE_INLINE bool MAKE_ATTR_USE
1127 GNode_IsError(const GNode *gn)
1128 {
1129 	return gn->made == ERROR || gn->made == ABORTED;
1130 }
1131 
1132 MAKE_INLINE bool MAKE_ATTR_USE
1133 GNode_IsMainCandidate(const GNode *gn)
1134 {
1135 	return (gn->type & (OP_NOTMAIN | OP_USE | OP_USEBEFORE |
1136 			    OP_EXEC | OP_TRANSFORM)) == 0;
1137 }
1138 
1139 /* Return whether the target file should be preserved on interrupt. */
1140 MAKE_INLINE bool MAKE_ATTR_USE
1141 GNode_IsPrecious(const GNode *gn)
1142 {
1143 	/* XXX: Why are '::' targets precious? */
1144 	return allPrecious || gn->type & (OP_PRECIOUS | OP_DOUBLEDEP);
1145 }
1146 
1147 MAKE_INLINE const char * MAKE_ATTR_USE
1148 GNode_VarTarget(GNode *gn) { return GNode_ValueDirect(gn, TARGET); }
1149 MAKE_INLINE const char * MAKE_ATTR_USE
1150 GNode_VarOodate(GNode *gn) { return GNode_ValueDirect(gn, OODATE); }
1151 MAKE_INLINE const char * MAKE_ATTR_USE
1152 GNode_VarAllsrc(GNode *gn) { return GNode_ValueDirect(gn, ALLSRC); }
1153 MAKE_INLINE const char * MAKE_ATTR_USE
1154 GNode_VarImpsrc(GNode *gn) { return GNode_ValueDirect(gn, IMPSRC); }
1155 MAKE_INLINE const char * MAKE_ATTR_USE
1156 GNode_VarPrefix(GNode *gn) { return GNode_ValueDirect(gn, PREFIX); }
1157 MAKE_INLINE const char * MAKE_ATTR_USE
1158 GNode_VarArchive(GNode *gn) { return GNode_ValueDirect(gn, ARCHIVE); }
1159 MAKE_INLINE const char * MAKE_ATTR_USE
1160 GNode_VarMember(GNode *gn) { return GNode_ValueDirect(gn, MEMBER); }
1161 
1162 MAKE_INLINE void * MAKE_ATTR_USE
1163 UNCONST(const void *ptr)
1164 {
1165 	void *ret;
1166 	memcpy(&ret, &ptr, sizeof(ret));
1167 	return ret;
1168 }
1169 
1170 /* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */
1171 #ifdef HAVE_LIMITS_H
1172 #include <limits.h>
1173 #endif
1174 #ifndef MAXPATHLEN
1175 #define MAXPATHLEN	BMAKE_PATH_MAX
1176 #endif
1177 #ifndef PATH_MAX
1178 #define PATH_MAX	MAXPATHLEN
1179 #endif
1180 
1181 #if defined(SYSV)
1182 #define KILLPG(pid, sig) kill(-(pid), (sig))
1183 #else
1184 #define KILLPG(pid, sig) killpg((pid), (sig))
1185 #endif
1186 
1187 MAKE_INLINE bool MAKE_ATTR_USE
1188 ch_isalnum(char ch) { return isalnum((unsigned char)ch) != 0; }
1189 MAKE_INLINE bool MAKE_ATTR_USE
1190 ch_isalpha(char ch) { return isalpha((unsigned char)ch) != 0; }
1191 MAKE_INLINE bool MAKE_ATTR_USE
1192 ch_isdigit(char ch) { return isdigit((unsigned char)ch) != 0; }
1193 MAKE_INLINE bool MAKE_ATTR_USE
1194 ch_islower(char ch) { return islower((unsigned char)ch) != 0; }
1195 MAKE_INLINE bool MAKE_ATTR_USE
1196 ch_isspace(char ch) { return isspace((unsigned char)ch) != 0; }
1197 MAKE_INLINE bool MAKE_ATTR_USE
1198 ch_isupper(char ch) { return isupper((unsigned char)ch) != 0; }
1199 MAKE_INLINE char MAKE_ATTR_USE
1200 ch_tolower(char ch) { return (char)tolower((unsigned char)ch); }
1201 MAKE_INLINE char MAKE_ATTR_USE
1202 ch_toupper(char ch) { return (char)toupper((unsigned char)ch); }
1203 
1204 MAKE_INLINE void
1205 cpp_skip_whitespace(const char **pp)
1206 {
1207 	while (ch_isspace(**pp))
1208 		(*pp)++;
1209 }
1210 
1211 MAKE_INLINE void
1212 cpp_skip_hspace(const char **pp)
1213 {
1214 	while (**pp == ' ' || **pp == '\t')
1215 		(*pp)++;
1216 }
1217 
1218 MAKE_INLINE bool
1219 cpp_skip_string(const char **pp, const char *s)
1220 {
1221 	const char *p = *pp;
1222 	while (*p == *s && *s != '\0')
1223 		p++, s++;
1224 	if (*s == '\0')
1225 		*pp = p;
1226 	return *s == '\0';
1227 }
1228 
1229 MAKE_INLINE void
1230 pp_skip_whitespace(char **pp)
1231 {
1232 	while (ch_isspace(**pp))
1233 		(*pp)++;
1234 }
1235 
1236 MAKE_INLINE void
1237 pp_skip_hspace(char **pp)
1238 {
1239 	while (**pp == ' ' || **pp == '\t')
1240 		(*pp)++;
1241 }
1242 
1243 #if defined(lint)
1244 void do_not_define_rcsid(void); /* for lint */
1245 # define MAKE_RCSID(id) void do_not_define_rcsid(void)
1246 #elif defined(MAKE_NATIVE)
1247 # include <sys/cdefs.h>
1248 # ifndef __IDSTRING
1249 #   define __IDSTRING(name,string) \
1250 	static const char name[] MAKE_ATTR_UNUSED = string
1251 # endif
1252 # ifndef __RCSID
1253 #   define __RCSID(s) __IDSTRING(rcsid,s)
1254 # endif
1255 # ifndef __COPYRIGHT
1256 #   define __COPYRIGHT(s) __IDSTRING(copyright,s)
1257 # endif
1258 # define MAKE_RCSID(id) __RCSID(id)
1259 #elif defined(MAKE_ALL_IN_ONE) && defined(__COUNTER__)
1260 # define MAKE_RCSID_CONCAT(x, y) CONCAT(x, y)
1261 # define MAKE_RCSID(id) static volatile char \
1262 	MAKE_RCSID_CONCAT(rcsid_, __COUNTER__)[] = id
1263 #elif defined(MAKE_ALL_IN_ONE)
1264 # define MAKE_RCSID(id) void do_not_define_rcsid(void)
1265 #else
1266 # define MAKE_RCSID(id) static volatile char rcsid[] = id
1267 #endif
1268 
1269 #endif
1270