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