1 /*        $NetBSD: make.h,v 1.353 2025/04/22 19:28:50 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 #include <sys/types.h>
84 #include <sys/param.h>
85 #include <sys/stat.h>
86 
87 #include <assert.h>
88 #include <ctype.h>
89 #include <fcntl.h>
90 #include <stdarg.h>
91 #include <stdio.h>
92 #include <stdlib.h>
93 #include <string.h>
94 #include <unistd.h>
95 
96 #ifdef BSD4_4
97 # include <sys/cdefs.h>
98 #endif
99 
100 #ifndef FD_CLOEXEC
101 #define FD_CLOEXEC 1
102 #endif
103 
104 #if defined(__GNUC__)
105 #define MAKE_GNUC_PREREQ(x, y)                                                            \
106           ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) ||                        \
107            (__GNUC__ > (x)))
108 #else
109 #define MAKE_GNUC_PREREQ(x, y)          0
110 #endif
111 
112 #if MAKE_GNUC_PREREQ(2, 7) || lint
113 #define MAKE_ATTR_UNUSED      __attribute__((__unused__))
114 #else
115 #define MAKE_ATTR_UNUSED      /* delete */
116 #endif
117 
118 #if MAKE_GNUC_PREREQ(2, 5)
119 #define MAKE_ATTR_DEAD                  __attribute__((__noreturn__))
120 #elif defined(__GNUC__)
121 #define MAKE_ATTR_DEAD                  __volatile
122 #else
123 #define MAKE_ATTR_DEAD                  /* delete */
124 #endif
125 
126 #if MAKE_GNUC_PREREQ(2, 7)
127 #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) \
128               __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
129 #else
130 #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */
131 #endif
132 
133 #if MAKE_GNUC_PREREQ(4, 0)
134 #define MAKE_ATTR_USE                   __attribute__((__warn_unused_result__))
135 #else
136 #define MAKE_ATTR_USE                   /* delete */
137 #endif
138 
139 #if MAKE_GNUC_PREREQ(8, 0)
140 #define MAKE_ATTR_NOINLINE              __attribute__((__noinline__))
141 #else
142 #define MAKE_ATTR_NOINLINE              /* delete */
143 #endif
144 
145 #if __STDC_VERSION__ >= 199901L || defined(lint)
146 #define MAKE_INLINE static inline MAKE_ATTR_UNUSED
147 #else
148 #define MAKE_INLINE static MAKE_ATTR_UNUSED
149 #endif
150 
151 /* MAKE_STATIC marks a function that may or may not be inlined. */
152 #if defined(lint)
153 /* As of 2021-07-31, NetBSD lint ignores __attribute__((unused)). */
154 #define MAKE_STATIC MAKE_INLINE
155 #else
156 #define MAKE_STATIC static MAKE_ATTR_UNUSED
157 #endif
158 
159 #if __STDC_VERSION__ >= 199901L || defined(lint) || defined(USE_C99_BOOLEAN)
160 #include <stdbool.h>
161 #elif defined(__bool_true_false_are_defined)
162 /*
163  * All files of make must be compiled with the same definition of bool.
164  * Since one of the files includes <stdbool.h>, that means the header is
165  * available on this platform.  Recompile everything with -DUSE_C99_BOOLEAN.
166  */
167 #error "<stdbool.h> is included in pre-C99 mode"
168 #elif defined(bool) || defined(true) || defined(false)
169 /*
170  * In pre-C99 mode, make does not expect that bool is already defined.
171  * You need to ensure that all translation units use the same definition for
172  * bool.
173  */
174 #error "bool/true/false is defined in pre-C99 mode"
175 #else
176 typedef unsigned char bool;
177 #define true        1
178 #define false       0
179 #endif
180 
181 /*
182  * In code coverage mode with gcc>=12, calling vfork/exec does not mark any
183  * further code from the parent process as covered. gcc-10.5.0 is fine, as
184  * are fork/exec calls, as well as posix_spawn.
185  */
186 #ifndef FORK_FUNCTION
187 #define FORK_FUNCTION vfork
188 #endif
189 
190 #include "lst.h"
191 #include "make_malloc.h"
192 #include "str.h"
193 #include "hash.h"
194 #include "config.h"
195 #include "buf.h"
196 
197 /*
198  * The typical flow of states is:
199  *
200  * The direct successful path:
201  * UNMADE -> BEINGMADE -> MADE.
202  *
203  * The direct error path:
204  * UNMADE -> BEINGMADE -> ERROR.
205  *
206  * The successful path when dependencies need to be made first:
207  * UNMADE -> DEFERRED -> REQUESTED -> BEINGMADE -> MADE.
208  *
209  * A node that has dependencies, and one of the dependencies cannot be made:
210  * UNMADE -> DEFERRED -> ABORTED.
211  *
212  * A node that turns out to be up-to-date:
213  * UNMADE -> BEINGMADE -> UPTODATE.
214  */
215 typedef enum GNodeMade {
216           /* Not examined yet. */
217           UNMADE,
218           /*
219            * The node has been examined but is not yet ready since its
220            * dependencies have to be made first.
221            */
222           DEFERRED,
223 
224           /* The node is on the toBeMade list. */
225           REQUESTED,
226 
227           /*
228            * The node is already being made. Trying to build a node in this
229            * state indicates a cycle in the graph.
230            */
231           BEINGMADE,
232 
233           /* Was out-of-date and has been made. */
234           MADE,
235           /* Was already up-to-date, does not need to be made. */
236           UPTODATE,
237           /*
238            * An error occurred while it was being made. Used only in compat
239            * mode.
240            */
241           ERROR,
242           /*
243            * The target was aborted due to an error making a dependency. Used
244            * only in compat mode.
245            */
246           ABORTED
247 } GNodeMade;
248 
249 /*
250  * The OP_ constants are used when parsing a dependency line as a way of
251  * communicating to other parts of the program the way in which a target
252  * should be made.
253  *
254  * Some of the OP_ constants can be combined, others cannot.
255  *
256  * See the tests depsrc-*.mk and deptgt-*.mk.
257  */
258 typedef enum GNodeType {
259           OP_NONE             = 0,
260 
261           /*
262            * The dependency operator ':' is the most common one.  The commands
263            * of this node are executed if any child is out-of-date.
264            */
265           OP_DEPENDS          = 1 << 0,
266           /*
267            * The dependency operator '!' always executes its commands, even if
268            * its children are up-to-date.
269            */
270           OP_FORCE  = 1 << 1,
271           /*
272            * The dependency operator '::' behaves like ':', except that it
273            * allows multiple dependency groups to be defined.  Each of these
274            * groups is executed on its own, independently from the others. Each
275            * individual dependency group is called a cohort.
276            */
277           OP_DOUBLEDEP        = 1 << 2,
278 
279           /* Matches the dependency operators ':', '!' and '::'. */
280           OP_OPMASK = OP_DEPENDS | OP_FORCE | OP_DOUBLEDEP,
281 
282           /* Don't care if the target doesn't exist and can't be created. */
283           OP_OPTIONAL         = 1 << 3,
284           /* Use associated commands for parents. */
285           OP_USE              = 1 << 4,
286           /*
287            * Target is never out of date, but always execute commands anyway.
288            * Its time doesn't matter, so it has none...sort of.
289            */
290           OP_EXEC             = 1 << 5,
291           /*
292            * Ignore non-zero exit status from shell commands when creating the
293            * node.
294            */
295           OP_IGNORE = 1 << 6,
296           /* Don't remove the target when interrupted. */
297           OP_PRECIOUS         = 1 << 7,
298           /* Don't echo commands when executed. */
299           OP_SILENT = 1 << 8,
300           /*
301            * Target is a recursive make so its commands should always be
302            * executed when it is out of date, regardless of the state of the -n
303            * or -t flags.
304            */
305           OP_MAKE             = 1 << 9,
306           /*
307            * Target is out-of-date only if any of its children was out-of-date.
308            */
309           OP_JOIN             = 1 << 10,
310           /* Assume the children of the node have been already made. */
311           OP_MADE             = 1 << 11,
312           /* Special .BEGIN, .END or .INTERRUPT. */
313           OP_SPECIAL          = 1 << 12,
314           /* Like .USE, only prepend commands. */
315           OP_USEBEFORE        = 1 << 13,
316           /*
317            * The node is invisible to its parents. I.e. it doesn't show up in
318            * the parents' local variables (.IMPSRC, .ALLSRC).
319            */
320           OP_INVISIBLE        = 1 << 14,
321           /*
322            * The node does not become the main target, even if it is the first
323            * target in the first makefile.
324            */
325           OP_NOTMAIN          = 1 << 15,
326           /* Not a file target; run always. */
327           OP_PHONY  = 1 << 16,
328           /* Don't search for the file in the path. */
329           OP_NOPATH = 1 << 17,
330           /*
331            * In a dependency line "target: source1 .WAIT source2", source1 is
332            * made first, including its children.  Once that is finished,
333            * source2 is made, including its children.  The .WAIT keyword may
334            * appear more than once in a single dependency declaration.
335            */
336           OP_WAIT             = 1 << 18,
337           /* .NOMETA do not create a .meta file */
338           OP_NOMETA = 1 << 19,
339           /* .META we _do_ want a .meta file */
340           OP_META             = 1 << 20,
341           /* Do not compare commands in .meta file */
342           OP_NOMETA_CMP       = 1 << 21,
343           /* Possibly a submake node */
344           OP_SUBMAKE          = 1 << 22,
345 
346           /* Attributes applied by PMake */
347 
348           /* The node is a transformation rule, such as ".c.o". */
349           OP_TRANSFORM        = 1 << 30,
350           /* Target is a member of an archive */
351           /* XXX: How does this differ from OP_ARCHV? */
352           OP_MEMBER = 1 << 29,
353           /*
354            * The node is a library, its name has the form "-l<libname>".
355            */
356           OP_LIB              = 1 << 28,
357           /*
358            * The node is an archive member, its name has the form
359            * "archive(member)".
360            */
361           /* XXX: How does this differ from OP_MEMBER? */
362           OP_ARCHV  = 1 << 27,
363           /*
364            * Target has all the commands it should. Used when parsing to catch
365            * multiple command groups for a target.  Only applies to the
366            * dependency operators ':' and '!', but not to '::'.
367            */
368           OP_HAS_COMMANDS     = 1 << 26,
369           /*
370            * The special command "..." has been seen. All further commands from
371            * this node will be saved on the .END node instead, to be executed
372            * at the very end.
373            */
374           OP_SAVE_CMDS        = 1 << 25,
375           /*
376            * Already processed by Suff_FindDeps, to find dependencies from
377            * suffix transformation rules.
378            */
379           OP_DEPS_FOUND       = 1 << 24,
380           /* Node found while expanding .ALLSRC */
381           OP_MARK             = 1 << 23
382 } GNodeType;
383 
384 typedef struct GNodeFlags {
385           /* this target needs to be (re)made */
386           bool remake:1;
387           /* children of this target were made */
388           bool childMade:1;
389           /* children don't exist, and we pretend made */
390           bool force:1;
391           /* Set by Make_ProcessWait() */
392           bool doneWait:1;
393           /* Build requested by .ORDER processing */
394           bool doneOrder:1;
395           /* Node created from .depend */
396           bool fromDepend:1;
397           /* We do it once only */
398           bool doneAllsrc:1;
399           /* Used by MakePrintStatus */
400           bool cycle:1;
401           /* Used by MakePrintStatus */
402           bool doneCycle:1;
403 } GNodeFlags;
404 
405 typedef struct List StringList;
406 typedef struct ListNode StringListNode;
407 
408 typedef struct List GNodeList;
409 typedef struct ListNode GNodeListNode;
410 
411 typedef struct SearchPath {
412           List /* of CachedDir */ dirs;
413 } SearchPath;
414 
415 /*
416  * A graph node represents a target that can possibly be made, including its
417  * relation to other targets.
418  */
419 typedef struct GNode {
420           /* The target's name, such as "clean" or "make.c" */
421           char *name;
422           /* The unexpanded name of a .USE node */
423           char *uname;
424           /*
425            * The full pathname of the file belonging to the target.
426            *
427            * XXX: What about .PHONY targets? These don't have an associated
428            * path.
429            */
430           char *path;
431 
432           /*
433            * The type of operator used to define the sources (see the OP flags
434            * below).
435            *
436            * XXX: This looks like a wild mixture of type and flags.
437            */
438           GNodeType type;
439           GNodeFlags flags;
440 
441           /* The state of processing on this node */
442           GNodeMade made;
443           /* The number of unmade children */
444           int unmade;
445 
446           /*
447            * The modification time; 0 means the node does not have a
448            * corresponding file; see GNode_IsOODate.
449            */
450           time_t mtime;
451           struct GNode *youngestChild;
452 
453           /*
454            * The GNodes for which this node is an implied source. May be empty.
455            * For example, when there is an inference rule for .c.o, the node
456            * for file.c has the node for file.o in this list.
457            */
458           GNodeList implicitParents;
459 
460           /*
461            * The nodes that depend on this one, or in other words, the nodes
462            * for which this is a source.
463            */
464           GNodeList parents;
465           /* The nodes on which this one depends. */
466           GNodeList children;
467 
468           /*
469            * .ORDER nodes we need made. The nodes that must be made (if they're
470            * made) before this node can be made, but that do not enter into the
471            * datedness of this node.
472            */
473           GNodeList order_pred;
474           /*
475            * .ORDER nodes who need us. The nodes that must be made (if they're
476            * made at all) after this node is made, but that do not depend on
477            * this node, in the normal sense.
478            */
479           GNodeList order_succ;
480 
481           /*
482            * Other nodes of the same name, for targets that were defined using
483            * the '::' dependency operator (OP_DOUBLEDEP).
484            */
485           GNodeList cohorts;
486           /* The "#n" suffix for this cohort, or "" for other nodes */
487           char cohort_num[8];
488           /* The number of unmade instances on the cohorts list */
489           int unmade_cohorts;
490           /*
491            * Pointer to the first instance of a '::' node; only set when on a
492            * cohorts list
493            */
494           struct GNode *centurion;
495 
496           /* Last time (sequence number) we tried to make this node */
497           unsigned checked_seqno;
498 
499           /*
500            * The "local" variables that are specific to this target and this
501            * target only, such as $@, $<, $?.
502            *
503            * Also used for the global variable scopes SCOPE_GLOBAL,
504            * SCOPE_CMDLINE, SCOPE_INTERNAL, which contain variables with
505            * arbitrary names.
506            */
507           HashTable /* of Var pointer */ vars;
508 
509           /* The commands to be given to a shell to create this target. */
510           StringList commands;
511 
512           /*
513            * Suffix for the node (determined by Suff_FindDeps and opaque to
514            * everyone but the Suff module)
515            */
516           struct Suffix *suffix;
517 
518           /* Filename where the GNode got defined, unlimited lifetime */
519           const char *fname;
520           /* Line number where the GNode got defined, 1-based */
521           unsigned lineno;
522           int exit_status;
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_SET,
534           PS_TOO_LATE
535 } posix_state;
536 
537 /* Error levels for diagnostics during parsing. */
538 typedef enum ParseErrorLevel {
539           /*
540            * Exit when the current top-level makefile has been parsed
541            * completely.
542            */
543           PARSE_FATAL = 1,
544           /* Print "warning"; may be upgraded to fatal by the -w option. */
545           PARSE_WARNING,
546           /* Informational, mainly used during development of makefiles. */
547           PARSE_INFO
548 } ParseErrorLevel;
549 
550 /*
551  * Values returned by Cond_EvalLine and Cond_EvalCondition.
552  */
553 typedef enum CondResult {
554           CR_TRUE,            /* Parse the next lines */
555           CR_FALSE,           /* Skip the next lines */
556           CR_ERROR            /* Unknown directive or parse error */
557 } CondResult;
558 
559 typedef struct {
560           enum GuardKind {
561                     GK_VARIABLE,
562                     GK_TARGET
563           } kind;
564           char *name;
565 } Guard;
566 
567 /* Names of the variables that are "local" to a specific target. */
568 #define TARGET      "@"                 /* Target of dependency */
569 #define OODATE      "?"                 /* All out-of-date sources */
570 #define ALLSRC      ">"                 /* All sources */
571 #define IMPSRC      "<"                 /* Source implied by transformation */
572 #define PREFIX      "*"                 /* Common prefix */
573 #define ARCHIVE     "!"                 /* Archive in "archive(member)" syntax */
574 #define MEMBER      "%"                 /* Member in "archive(member)" syntax */
575 
576 /*
577  * Global Variables
578  */
579 
580 /* True if every target is precious */
581 extern bool allPrecious;
582 /* True if failed targets should be deleted */
583 extern bool deleteOnError;
584 /* true while processing .depend */
585 extern bool doing_depend;
586 /* .DEFAULT rule */
587 extern GNode *defaultNode;
588 
589 /*
590  * Variables defined internally by make which should not override those set
591  * by makefiles.
592  */
593 extern GNode *SCOPE_INTERNAL;
594 /* Variables defined in a global scope, e.g in the makefile itself. */
595 extern GNode *SCOPE_GLOBAL;
596 /* Variables defined on the command line. */
597 extern GNode *SCOPE_CMDLINE;
598 
599 /*
600  * Value returned by Var_Parse when an error is encountered. It points to an
601  * empty string, so naive callers needn't worry about it.
602  */
603 extern char var_Error[];
604 
605 /* The time at the start of this whole process */
606 extern time_t now;
607 
608 /*
609  * The list of directories to search when looking for targets (set by the
610  * special target .PATH).
611  */
612 extern SearchPath dirSearchPath;
613 /* Used for .include "...". */
614 extern SearchPath *parseIncPath;
615 /*
616  * Used for .include <...>, for the built-in sys.mk and for makefiles from
617  * the command line arguments.
618  */
619 extern SearchPath *sysIncPath;
620 /* The default for sysIncPath. */
621 extern SearchPath *defSysIncPath;
622 
623 /* Startup directory */
624 extern char curdir[];
625 /* The basename of the program name, suffixed with [n] for sub-makes.  */
626 extern const char *progname;
627 extern int makelevel;
628 /* Name of the .depend makefile */
629 extern char *makeDependfile;
630 /* If we replaced environ, this will be non-NULL. */
631 extern char **savedEnv;
632 extern GNode *mainNode;
633 
634 extern pid_t myPid;
635 
636 #define MAKEFLAGS   ".MAKEFLAGS"
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 to be compatible to traditional make */
698           bool compatMake;
699 
700           /*
701            * -d: debug control: There is one flag 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 extern bool forceJobs;
797 extern char **environ;
798 
799 /* arch.c */
800 void Arch_Init(void);
801 #ifdef CLEANUP
802 void Arch_End(void);
803 #endif
804 
805 bool Arch_ParseArchive(char **, GNodeList *, GNode *);
806 void Arch_Touch(GNode *);
807 void Arch_TouchLib(GNode *);
808 void Arch_UpdateMTime(GNode *);
809 void Arch_UpdateMemberMTime(GNode *);
810 void Arch_FindLib(GNode *, SearchPath *);
811 bool Arch_LibOODate(GNode *) MAKE_ATTR_USE;
812 bool Arch_IsLib(GNode *) MAKE_ATTR_USE;
813 
814 /* compat.c */
815 bool Compat_RunCommand(const char *, GNode *, StringListNode *);
816 void Compat_MakeAll(GNodeList *);
817 void Compat_Make(GNode *, GNode *);
818 
819 /* cond.c */
820 extern unsigned cond_depth;
821 CondResult Cond_EvalCondition(const char *) MAKE_ATTR_USE;
822 CondResult Cond_EvalLine(const char *) MAKE_ATTR_USE;
823 Guard *Cond_ExtractGuard(const char *) MAKE_ATTR_USE;
824 void Cond_EndFile(void);
825 
826 /* dir.c; see also dir.h */
827 
828 MAKE_INLINE const char * MAKE_ATTR_USE
str_basename(const char * pathname)829 str_basename(const char *pathname)
830 {
831           const char *lastSlash = strrchr(pathname, '/');
832           return lastSlash != NULL ? lastSlash + 1 : pathname;
833 }
834 
835 MAKE_INLINE SearchPath * MAKE_ATTR_USE
SearchPath_New(void)836 SearchPath_New(void)
837 {
838           SearchPath *path = bmake_malloc(sizeof *path);
839           Lst_Init(&path->dirs);
840           return path;
841 }
842 
843 void SearchPath_Free(SearchPath *);
844 
845 /* for.c */
846 struct ForLoop;
847 int For_Eval(const char *) MAKE_ATTR_USE;
848 bool For_Accum(const char *, int *) MAKE_ATTR_USE;
849 void For_Run(unsigned, unsigned);
850 bool For_NextIteration(struct ForLoop *, Buffer *);
851 char *ForLoop_Details(const struct ForLoop *);
852 void ForLoop_Free(struct ForLoop *);
853 void For_Break(struct ForLoop *);
854 
855 /* job.c */
856 void JobReapChild(pid_t, int, bool);
857 
858 /* longer than this we use a temp file */
859 #ifndef MAKE_CMDLEN_LIMIT
860 # define MAKE_CMDLEN_LIMIT 1000
861 #endif
862 /* main.c */
863 void Main_ParseArgLine(const char *);
864 int Cmd_Argv(const char *, size_t, const char **, size_t, char *, size_t, bool, bool);
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 int unlink_file(const char *) MAKE_ATTR_USE;
871 void execDie(const char *, const char *);
872 char *getTmpdir(void) MAKE_ATTR_USE;
873 bool ParseBoolean(const char *, bool) MAKE_ATTR_USE;
874 const char *cached_realpath(const char *, char *);
875 bool GetBooleanExpr(const char *, bool);
876 
877 /* parse.c */
878 extern int parseErrors;
879 void Parse_Init(void);
880 #ifdef CLEANUP
881 void Parse_End(void);
882 #endif
883 
884 void PrintLocation(FILE *, bool, const GNode *);
885 void PrintStackTrace(bool);
886 void Parse_Error(ParseErrorLevel, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
887 bool Parse_VarAssign(const char *, bool, GNode *) MAKE_ATTR_USE;
888 void Parse_File(const char *, int);
889 void Parse_PushInput(const char *, unsigned, unsigned, Buffer,
890                          struct ForLoop *);
891 void Parse_MainName(GNodeList *);
892 unsigned CurFile_CondMinDepth(void) MAKE_ATTR_USE;
893 void Parse_GuardElse(void);
894 void Parse_GuardEndif(void);
895 
896 
897 /* suff.c */
898 void Suff_Init(void);
899 #ifdef CLEANUP
900 void Suff_End(void);
901 #endif
902 
903 void Suff_ClearSuffixes(void);
904 bool Suff_IsTransform(const char *) MAKE_ATTR_USE;
905 GNode *Suff_AddTransform(const char *);
906 void Suff_EndTransform(GNode *);
907 void Suff_AddSuffix(const char *);
908 SearchPath *Suff_GetPath(const char *) MAKE_ATTR_USE;
909 void Suff_ExtendPaths(void);
910 void Suff_AddInclude(const char *);
911 void Suff_AddLib(const char *);
912 void Suff_FindDeps(GNode *);
913 SearchPath *Suff_FindPath(GNode *) MAKE_ATTR_USE;
914 void Suff_SetNull(const char *);
915 void Suff_PrintAll(void);
916 char *Suff_NamesStr(void) MAKE_ATTR_USE;
917 
918 /* targ.c */
919 void Targ_Init(void);
920 void Targ_End(void);
921 
922 void Targ_Stats(void);
923 GNodeList *Targ_List(void) MAKE_ATTR_USE;
924 GNode *GNode_New(const char *) MAKE_ATTR_USE;
925 GNode *Targ_FindNode(const char *) MAKE_ATTR_USE;
926 GNode *Targ_GetNode(const char *) MAKE_ATTR_USE;
927 GNode *Targ_NewInternalNode(const char *) MAKE_ATTR_USE;
928 GNode *Targ_GetEndNode(void);
929 void Targ_FindList(GNodeList *, StringList *);
930 void Targ_PrintCmds(GNode *);
931 void Targ_PrintNode(GNode *, int);
932 void Targ_PrintNodes(GNodeList *, int);
933 const char *Targ_FmtTime(time_t) MAKE_ATTR_USE;
934 void Targ_PrintType(GNodeType);
935 void Targ_PrintGraph(int);
936 void Targ_Propagate(void);
937 const char *GNodeMade_Name(GNodeMade) MAKE_ATTR_USE;
938 #ifdef CLEANUP
939 void Parse_RegisterCommand(char *);
940 #else
941 MAKE_INLINE
Parse_RegisterCommand(char * cmd MAKE_ATTR_UNUSED)942 void Parse_RegisterCommand(char *cmd MAKE_ATTR_UNUSED)
943 {
944 }
945 #endif
946 
947 /* var.c */
948 
949 typedef enum VarEvalMode {
950 
951           /*
952            * Only parse the expression but don't evaluate any part of it.
953            *
954            * TODO: Document what Var_Parse and Var_Subst return in this mode.
955            *  As of 2021-03-15, they return unspecified, inconsistent results.
956            */
957           VARE_PARSE,
958 
959           /*
960            * Parse text in which '${...}' and '$(...)' are not parsed as
961            * subexpressions (with all their individual escaping rules) but
962            * instead simply as text with balanced '${}' or '$()'.  Other '$'
963            * are copied verbatim.
964            */
965           VARE_PARSE_BALANCED,
966 
967           /* Parse and evaluate the expression. */
968           VARE_EVAL,
969 
970           /*
971            * Parse and evaluate the expression.  It is an error if a
972            * subexpression evaluates to undefined.
973            */
974           VARE_EVAL_DEFINED_LOUD,
975 
976           /*
977            * Parse and evaluate the expression.  It is a silent error if a
978            * subexpression evaluates to undefined.
979            */
980           VARE_EVAL_DEFINED,
981 
982           /*
983            * Parse and evaluate the expression.  Keep undefined variables as-is
984            * instead of expanding them to an empty string.
985            *
986            * Example for a ':=' assignment:
987            *        CFLAGS = $(.INCLUDES)
988            *        CFLAGS := -I.. $(CFLAGS)
989            *        # If .INCLUDES (an undocumented special variable, by the
990            *        # way) is still undefined, the updated CFLAGS becomes
991            *        # "-I.. $(.INCLUDES)".
992            */
993           VARE_EVAL_KEEP_UNDEFINED,
994 
995           /*
996            * Parse and evaluate the expression.  Keep '$$' as '$$' and preserve
997            * undefined subexpressions.
998            */
999           VARE_EVAL_KEEP_DOLLAR_AND_UNDEFINED
1000 } VarEvalMode;
1001 
1002 typedef enum VarSetFlags {
1003           VAR_SET_NONE                  = 0,
1004 
1005           /* do not export */
1006           VAR_SET_NO_EXPORT   = 1 << 0,
1007 
1008           /*
1009            * Make the variable read-only. No further modification is possible,
1010            * except for another call to Var_Set with the same flag. See the
1011            * special targets '.NOREADONLY' and '.READONLY'.
1012            */
1013           VAR_SET_READONLY    = 1 << 1,
1014           VAR_SET_INTERNAL    = 1 << 2
1015 } VarSetFlags;
1016 
1017 typedef enum VarExportMode {
1018           /* .export-all */
1019           VEM_ALL,
1020           /* .export-env */
1021           VEM_ENV,
1022           /* .export: Initial export or update an already exported variable. */
1023           VEM_PLAIN,
1024           /* .export-literal: Do not expand the variable value. */
1025           VEM_LITERAL
1026 } VarExportMode;
1027 
1028 void Var_Delete(GNode *, const char *);
1029 #ifdef CLEANUP
1030 void Var_DeleteAll(GNode *scope);
1031 #endif
1032 void Var_Undef(const char *);
1033 void Var_Set(GNode *, const char *, const char *);
1034 void Var_SetExpand(GNode *, const char *, const char *);
1035 void Var_SetWithFlags(GNode *, const char *, const char *, VarSetFlags);
1036 void Var_Append(GNode *, const char *, const char *);
1037 void Var_AppendExpand(GNode *, const char *, const char *);
1038 bool Var_Exists(GNode *, const char *) MAKE_ATTR_USE;
1039 bool Var_ExistsExpand(GNode *, const char *) MAKE_ATTR_USE;
1040 FStr Var_Value(GNode *, const char *) MAKE_ATTR_USE;
1041 const char *GNode_ValueDirect(GNode *, const char *) MAKE_ATTR_USE;
1042 FStr Var_Parse(const char **, GNode *, VarEvalMode);
1043 char *Var_Subst(const char *, GNode *, VarEvalMode);
1044 char *Var_SubstInTarget(const char *, GNode *);
1045 void Var_Expand(FStr *, GNode *, VarEvalMode);
1046 void Var_Stats(void);
1047 void Var_Dump(GNode *);
1048 void Var_ReexportVars(GNode *);
1049 void Var_Export(VarExportMode, const char *);
1050 void Var_ExportVars(const char *);
1051 void Var_UnExport(bool, const char *);
1052 void Var_ReadOnly(const char *, bool);
1053 
1054 void Global_Set(const char *, const char *);
1055 void Global_Append(const char *, const char *);
1056 void Global_Delete(const char *);
1057 void Global_Set_ReadOnly(const char *, const char *);
1058 
1059 bool EvalStack_PrintDetails(void) MAKE_ATTR_USE;
1060 
1061 /* util.c */
1062 typedef void (*SignalProc)(int);
1063 SignalProc bmake_signal(int, SignalProc);
1064 
1065 /* make.c */
1066 void GNode_UpdateYoungestChild(GNode *, GNode *);
1067 bool GNode_IsOODate(GNode *) MAKE_ATTR_USE;
1068 void Make_ExpandUse(GNodeList *);
1069 time_t Make_Recheck(GNode *) MAKE_ATTR_USE;
1070 void Make_HandleUse(GNode *, GNode *);
1071 void Make_Update(GNode *);
1072 void GNode_SetLocalVars(GNode *);
1073 bool Make_Run(GNodeList *);
1074 bool shouldDieQuietly(GNode *, int) MAKE_ATTR_USE;
1075 void PrintOnError(GNode *, const char *);
1076 void Main_ExportMAKEFLAGS(bool);
1077 bool Main_SetObjdir(bool, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
1078 int mkTempFile(const char *, char *, size_t) MAKE_ATTR_USE;
1079 void AppendWords(StringList *, char *);
1080 void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *);
1081 bool GNode_ShouldExecute(GNode *gn) MAKE_ATTR_USE;
1082 
1083 /* See if the node was seen on the left-hand side of a dependency operator. */
1084 MAKE_INLINE bool MAKE_ATTR_USE
GNode_IsTarget(const GNode * gn)1085 GNode_IsTarget(const GNode *gn)
1086 {
1087           return (gn->type & OP_OPMASK) != OP_NONE;
1088 }
1089 
1090 MAKE_INLINE const char * MAKE_ATTR_USE
GNode_Path(const GNode * gn)1091 GNode_Path(const GNode *gn)
1092 {
1093           return gn->path != NULL ? gn->path : gn->name;
1094 }
1095 
1096 MAKE_INLINE bool MAKE_ATTR_USE
GNode_IsWaitingFor(const GNode * gn)1097 GNode_IsWaitingFor(const GNode *gn)
1098 {
1099           return gn->flags.remake && gn->made <= REQUESTED;
1100 }
1101 
1102 MAKE_INLINE bool MAKE_ATTR_USE
GNode_IsReady(const GNode * gn)1103 GNode_IsReady(const GNode *gn)
1104 {
1105           return gn->made > DEFERRED;
1106 }
1107 
1108 MAKE_INLINE bool MAKE_ATTR_USE
GNode_IsDone(const GNode * gn)1109 GNode_IsDone(const GNode *gn)
1110 {
1111           return gn->made >= MADE;
1112 }
1113 
1114 MAKE_INLINE bool MAKE_ATTR_USE
GNode_IsError(const GNode * gn)1115 GNode_IsError(const GNode *gn)
1116 {
1117           return gn->made == ERROR || gn->made == ABORTED;
1118 }
1119 
1120 MAKE_INLINE bool MAKE_ATTR_USE
GNode_IsMainCandidate(const GNode * gn)1121 GNode_IsMainCandidate(const GNode *gn)
1122 {
1123           return (gn->type & (OP_NOTMAIN | OP_USE | OP_USEBEFORE |
1124                                   OP_EXEC | OP_TRANSFORM)) == 0;
1125 }
1126 
1127 /* Return whether the target file should be preserved on interrupt. */
1128 MAKE_INLINE bool MAKE_ATTR_USE
GNode_IsPrecious(const GNode * gn)1129 GNode_IsPrecious(const GNode *gn)
1130 {
1131           /* XXX: Why are '::' targets precious? */
1132           return allPrecious || gn->type & (OP_PRECIOUS | OP_DOUBLEDEP);
1133 }
1134 
1135 MAKE_INLINE const char * MAKE_ATTR_USE
GNode_VarTarget(GNode * gn)1136 GNode_VarTarget(GNode *gn) { return GNode_ValueDirect(gn, TARGET); }
1137 MAKE_INLINE const char * MAKE_ATTR_USE
GNode_VarOodate(GNode * gn)1138 GNode_VarOodate(GNode *gn) { return GNode_ValueDirect(gn, OODATE); }
1139 MAKE_INLINE const char * MAKE_ATTR_USE
GNode_VarAllsrc(GNode * gn)1140 GNode_VarAllsrc(GNode *gn) { return GNode_ValueDirect(gn, ALLSRC); }
1141 MAKE_INLINE const char * MAKE_ATTR_USE
GNode_VarImpsrc(GNode * gn)1142 GNode_VarImpsrc(GNode *gn) { return GNode_ValueDirect(gn, IMPSRC); }
1143 MAKE_INLINE const char * MAKE_ATTR_USE
GNode_VarPrefix(GNode * gn)1144 GNode_VarPrefix(GNode *gn) { return GNode_ValueDirect(gn, PREFIX); }
1145 MAKE_INLINE const char * MAKE_ATTR_USE
GNode_VarArchive(GNode * gn)1146 GNode_VarArchive(GNode *gn) { return GNode_ValueDirect(gn, ARCHIVE); }
1147 MAKE_INLINE const char * MAKE_ATTR_USE
GNode_VarMember(GNode * gn)1148 GNode_VarMember(GNode *gn) { return GNode_ValueDirect(gn, MEMBER); }
1149 
1150 MAKE_INLINE void * MAKE_ATTR_USE
UNCONST(const void * ptr)1151 UNCONST(const void *ptr)
1152 {
1153           void *ret;
1154           memcpy(&ret, &ptr, sizeof(ret));
1155           return ret;
1156 }
1157 
1158 /* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */
1159 #include <limits.h>
1160 #ifndef MAXPATHLEN
1161 #define MAXPATHLEN  4096
1162 #endif
1163 #ifndef PATH_MAX
1164 #define PATH_MAX    MAXPATHLEN
1165 #endif
1166 
1167 #if defined(SYSV)
1168 #define KILLPG(pid, sig) kill(-(pid), (sig))
1169 #else
1170 #define KILLPG(pid, sig) killpg((pid), (sig))
1171 #endif
1172 
1173 MAKE_INLINE bool MAKE_ATTR_USE
ch_isalnum(char ch)1174 ch_isalnum(char ch) { return isalnum((unsigned char)ch) != 0; }
1175 MAKE_INLINE bool MAKE_ATTR_USE
ch_isalpha(char ch)1176 ch_isalpha(char ch) { return isalpha((unsigned char)ch) != 0; }
1177 MAKE_INLINE bool MAKE_ATTR_USE
ch_isdigit(char ch)1178 ch_isdigit(char ch) { return isdigit((unsigned char)ch) != 0; }
1179 MAKE_INLINE bool MAKE_ATTR_USE
ch_islower(char ch)1180 ch_islower(char ch) { return islower((unsigned char)ch) != 0; }
1181 MAKE_INLINE bool MAKE_ATTR_USE
ch_isspace(char ch)1182 ch_isspace(char ch) { return isspace((unsigned char)ch) != 0; }
1183 MAKE_INLINE bool MAKE_ATTR_USE
ch_isupper(char ch)1184 ch_isupper(char ch) { return isupper((unsigned char)ch) != 0; }
1185 MAKE_INLINE char MAKE_ATTR_USE
ch_tolower(char ch)1186 ch_tolower(char ch) { return (char)tolower((unsigned char)ch); }
1187 MAKE_INLINE char MAKE_ATTR_USE
ch_toupper(char ch)1188 ch_toupper(char ch) { return (char)toupper((unsigned char)ch); }
1189 
1190 MAKE_INLINE void
cpp_skip_whitespace(const char ** pp)1191 cpp_skip_whitespace(const char **pp)
1192 {
1193           while (ch_isspace(**pp))
1194                     (*pp)++;
1195 }
1196 
1197 MAKE_INLINE void
cpp_skip_hspace(const char ** pp)1198 cpp_skip_hspace(const char **pp)
1199 {
1200           while (**pp == ' ' || **pp == '\t')
1201                     (*pp)++;
1202 }
1203 
1204 MAKE_INLINE bool
cpp_skip_string(const char ** pp,const char * s)1205 cpp_skip_string(const char **pp, const char *s)
1206 {
1207           const char *p = *pp;
1208           while (*p == *s && *s != '\0')
1209                     p++, s++;
1210           if (*s == '\0')
1211                     *pp = p;
1212           return *s == '\0';
1213 }
1214 
1215 MAKE_INLINE void
pp_skip_whitespace(char ** pp)1216 pp_skip_whitespace(char **pp)
1217 {
1218           while (ch_isspace(**pp))
1219                     (*pp)++;
1220 }
1221 
1222 MAKE_INLINE void
pp_skip_hspace(char ** pp)1223 pp_skip_hspace(char **pp)
1224 {
1225           while (**pp == ' ' || **pp == '\t')
1226                     (*pp)++;
1227 }
1228 
1229 #if defined(lint)
1230 void do_not_define_rcsid(void); /* for lint */
1231 # define MAKE_RCSID(id) void do_not_define_rcsid(void)
1232 #elif defined(MAKE_NATIVE)
1233 # include <sys/cdefs.h>
1234 # define MAKE_RCSID(id) __RCSID(id)
1235 #elif defined(MAKE_ALL_IN_ONE) && defined(__COUNTER__)
1236 # define MAKE_RCSID_CONCAT(x, y) CONCAT(x, y)
1237 # define MAKE_RCSID(id) static volatile char \
1238           MAKE_RCSID_CONCAT(rcsid_, __COUNTER__)[] = id
1239 #elif defined(MAKE_ALL_IN_ONE)
1240 # define MAKE_RCSID(id) void do_not_define_rcsid(void)
1241 #else
1242 # define MAKE_RCSID(id) static volatile char rcsid[] = id
1243 #endif
1244 
1245 #endif
1246