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