xref: /freebsd/contrib/bmake/make.h (revision 954401e68e797868ab04a0147b94849feefbb199)
1*954401e6SSimon J. Gerraty /*	$NetBSD: make.h,v 1.303 2022/06/12 13:37:32 rillig Exp $	*/
23955d011SMarcel Moolenaar 
33955d011SMarcel Moolenaar /*
43955d011SMarcel Moolenaar  * Copyright (c) 1988, 1989, 1990, 1993
53955d011SMarcel Moolenaar  *	The Regents of the University of California.  All rights reserved.
63955d011SMarcel Moolenaar  *
73955d011SMarcel Moolenaar  * This code is derived from software contributed to Berkeley by
83955d011SMarcel Moolenaar  * Adam de Boor.
93955d011SMarcel Moolenaar  *
103955d011SMarcel Moolenaar  * Redistribution and use in source and binary forms, with or without
113955d011SMarcel Moolenaar  * modification, are permitted provided that the following conditions
123955d011SMarcel Moolenaar  * are met:
133955d011SMarcel Moolenaar  * 1. Redistributions of source code must retain the above copyright
143955d011SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer.
153955d011SMarcel Moolenaar  * 2. Redistributions in binary form must reproduce the above copyright
163955d011SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer in the
173955d011SMarcel Moolenaar  *    documentation and/or other materials provided with the distribution.
183955d011SMarcel Moolenaar  * 3. Neither the name of the University nor the names of its contributors
193955d011SMarcel Moolenaar  *    may be used to endorse or promote products derived from this software
203955d011SMarcel Moolenaar  *    without specific prior written permission.
213955d011SMarcel Moolenaar  *
223955d011SMarcel Moolenaar  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
233955d011SMarcel Moolenaar  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
243955d011SMarcel Moolenaar  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
253955d011SMarcel Moolenaar  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
263955d011SMarcel Moolenaar  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
273955d011SMarcel Moolenaar  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
283955d011SMarcel Moolenaar  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
293955d011SMarcel Moolenaar  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
303955d011SMarcel Moolenaar  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
313955d011SMarcel Moolenaar  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
323955d011SMarcel Moolenaar  * SUCH DAMAGE.
333955d011SMarcel Moolenaar  *
343955d011SMarcel Moolenaar  *	from: @(#)make.h	8.3 (Berkeley) 6/13/95
353955d011SMarcel Moolenaar  */
363955d011SMarcel Moolenaar 
373955d011SMarcel Moolenaar /*
383955d011SMarcel Moolenaar  * Copyright (c) 1989 by Berkeley Softworks
393955d011SMarcel Moolenaar  * All rights reserved.
403955d011SMarcel Moolenaar  *
413955d011SMarcel Moolenaar  * This code is derived from software contributed to Berkeley by
423955d011SMarcel Moolenaar  * Adam de Boor.
433955d011SMarcel Moolenaar  *
443955d011SMarcel Moolenaar  * Redistribution and use in source and binary forms, with or without
453955d011SMarcel Moolenaar  * modification, are permitted provided that the following conditions
463955d011SMarcel Moolenaar  * are met:
473955d011SMarcel Moolenaar  * 1. Redistributions of source code must retain the above copyright
483955d011SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer.
493955d011SMarcel Moolenaar  * 2. Redistributions in binary form must reproduce the above copyright
503955d011SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer in the
513955d011SMarcel Moolenaar  *    documentation and/or other materials provided with the distribution.
523955d011SMarcel Moolenaar  * 3. All advertising materials mentioning features or use of this software
533955d011SMarcel Moolenaar  *    must display the following acknowledgement:
543955d011SMarcel Moolenaar  *	This product includes software developed by the University of
553955d011SMarcel Moolenaar  *	California, Berkeley and its contributors.
563955d011SMarcel Moolenaar  * 4. Neither the name of the University nor the names of its contributors
573955d011SMarcel Moolenaar  *    may be used to endorse or promote products derived from this software
583955d011SMarcel Moolenaar  *    without specific prior written permission.
593955d011SMarcel Moolenaar  *
603955d011SMarcel Moolenaar  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
613955d011SMarcel Moolenaar  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
623955d011SMarcel Moolenaar  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
633955d011SMarcel Moolenaar  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
643955d011SMarcel Moolenaar  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
653955d011SMarcel Moolenaar  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
663955d011SMarcel Moolenaar  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
673955d011SMarcel Moolenaar  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
683955d011SMarcel Moolenaar  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
693955d011SMarcel Moolenaar  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
703955d011SMarcel Moolenaar  * SUCH DAMAGE.
713955d011SMarcel Moolenaar  *
723955d011SMarcel Moolenaar  *	from: @(#)make.h	8.3 (Berkeley) 6/13/95
733955d011SMarcel Moolenaar  */
743955d011SMarcel Moolenaar 
75dba7b0efSSimon J. Gerraty /*
763955d011SMarcel Moolenaar  * make.h --
779f45a3c8SSimon J. Gerraty  *	The global definitions for make
783955d011SMarcel Moolenaar  */
793955d011SMarcel Moolenaar 
802c3632d1SSimon J. Gerraty #ifndef MAKE_MAKE_H
812c3632d1SSimon J. Gerraty #define MAKE_MAKE_H
823955d011SMarcel Moolenaar 
833955d011SMarcel Moolenaar #ifdef HAVE_CONFIG_H
843955d011SMarcel Moolenaar # include "config.h"
853955d011SMarcel Moolenaar #endif
863955d011SMarcel Moolenaar 
873955d011SMarcel Moolenaar #include <sys/types.h>
883955d011SMarcel Moolenaar #include <sys/param.h>
892c3632d1SSimon J. Gerraty #include <sys/stat.h>
903955d011SMarcel Moolenaar 
912c3632d1SSimon J. Gerraty #include <assert.h>
923955d011SMarcel Moolenaar #include <ctype.h>
93be19d90bSSimon J. Gerraty #include <fcntl.h>
94956e45f6SSimon J. Gerraty #include <stdarg.h>
953955d011SMarcel Moolenaar #include <stdio.h>
963955d011SMarcel Moolenaar #include <stdlib.h>
973955d011SMarcel Moolenaar #ifdef HAVE_STRING_H
983955d011SMarcel Moolenaar #include <string.h>
993955d011SMarcel Moolenaar #else
1003955d011SMarcel Moolenaar #include <strings.h>
1013955d011SMarcel Moolenaar #endif
1023955d011SMarcel Moolenaar #include <unistd.h>
1033955d011SMarcel Moolenaar #include <sys/cdefs.h>
1043955d011SMarcel Moolenaar 
105be19d90bSSimon J. Gerraty #ifndef FD_CLOEXEC
106be19d90bSSimon J. Gerraty #define FD_CLOEXEC 1
107be19d90bSSimon J. Gerraty #endif
108be19d90bSSimon J. Gerraty 
1093955d011SMarcel Moolenaar #if defined(__GNUC__)
1103955d011SMarcel Moolenaar #define MAKE_GNUC_PREREQ(x, y)						\
1113955d011SMarcel Moolenaar 	((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) ||			\
1123955d011SMarcel Moolenaar 	 (__GNUC__ > (x)))
1139f45a3c8SSimon J. Gerraty #else
1141748de26SSimon J. Gerraty #define MAKE_GNUC_PREREQ(x, y)	0
1159f45a3c8SSimon J. Gerraty #endif
1163955d011SMarcel Moolenaar 
1173955d011SMarcel Moolenaar #if MAKE_GNUC_PREREQ(2, 7)
1183955d011SMarcel Moolenaar #define MAKE_ATTR_UNUSED	__attribute__((__unused__))
1193955d011SMarcel Moolenaar #else
1203955d011SMarcel Moolenaar #define MAKE_ATTR_UNUSED	/* delete */
1213955d011SMarcel Moolenaar #endif
1223955d011SMarcel Moolenaar 
1233955d011SMarcel Moolenaar #if MAKE_GNUC_PREREQ(2, 5)
1243955d011SMarcel Moolenaar #define MAKE_ATTR_DEAD		__attribute__((__noreturn__))
1253955d011SMarcel Moolenaar #elif defined(__GNUC__)
1263955d011SMarcel Moolenaar #define MAKE_ATTR_DEAD		__volatile
1273955d011SMarcel Moolenaar #else
1283955d011SMarcel Moolenaar #define MAKE_ATTR_DEAD		/* delete */
1293955d011SMarcel Moolenaar #endif
1303955d011SMarcel Moolenaar 
1313955d011SMarcel Moolenaar #if MAKE_GNUC_PREREQ(2, 7)
1323955d011SMarcel Moolenaar #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg)	\
1333955d011SMarcel Moolenaar 	    __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
1343955d011SMarcel Moolenaar #else
1353955d011SMarcel Moolenaar #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg)	/* delete */
1363955d011SMarcel Moolenaar #endif
1373955d011SMarcel Moolenaar 
1389f45a3c8SSimon J. Gerraty #if MAKE_GNUC_PREREQ(4, 0)
1399f45a3c8SSimon J. Gerraty #define MAKE_ATTR_USE		__attribute__((__warn_unused_result__))
1409f45a3c8SSimon J. Gerraty #else
1419f45a3c8SSimon J. Gerraty #define MAKE_ATTR_USE		/* delete */
1429f45a3c8SSimon J. Gerraty #endif
1439f45a3c8SSimon J. Gerraty 
1441d3f2ddcSSimon J. Gerraty #if __STDC_VERSION__ >= 199901L || defined(lint)
145e2eeea75SSimon J. Gerraty #define MAKE_INLINE static inline MAKE_ATTR_UNUSED
1469f45a3c8SSimon J. Gerraty #else
1479f45a3c8SSimon J. Gerraty #define MAKE_INLINE static MAKE_ATTR_UNUSED
1489f45a3c8SSimon J. Gerraty #endif
14912904384SSimon J. Gerraty 
15012904384SSimon J. Gerraty /* MAKE_STATIC marks a function that may or may not be inlined. */
15112904384SSimon J. Gerraty #if defined(lint)
15212904384SSimon J. Gerraty /* As of 2021-07-31, NetBSD lint ignores __attribute__((unused)). */
15312904384SSimon J. Gerraty #define MAKE_STATIC MAKE_INLINE
15412904384SSimon J. Gerraty #else
155b0c40a00SSimon J. Gerraty #define MAKE_STATIC static MAKE_ATTR_UNUSED
15612904384SSimon J. Gerraty #endif
157e2eeea75SSimon J. Gerraty 
158b0c40a00SSimon J. Gerraty #if __STDC_VERSION__ >= 199901L || defined(lint) || defined(USE_C99_BOOLEAN)
15906b9b3e0SSimon J. Gerraty #include <stdbool.h>
16012904384SSimon J. Gerraty #elif defined(__bool_true_false_are_defined)
16112904384SSimon J. Gerraty /*
16212904384SSimon J. Gerraty  * All files of make must be compiled with the same definition of bool.
16312904384SSimon J. Gerraty  * Since one of the files includes <stdbool.h>, that means the header is
16412904384SSimon J. Gerraty  * available on this platform.  Recompile everything with -DUSE_C99_BOOLEAN.
16512904384SSimon J. Gerraty  */
16612904384SSimon J. Gerraty #error "<stdbool.h> is included in pre-C99 mode"
16712904384SSimon J. Gerraty #elif defined(bool) || defined(true) || defined(false)
16812904384SSimon J. Gerraty /*
16912904384SSimon J. Gerraty  * In pre-C99 mode, make does not expect that bool is already defined.
17012904384SSimon J. Gerraty  * You need to ensure that all translation units use the same definition for
17112904384SSimon J. Gerraty  * bool.
17212904384SSimon J. Gerraty  */
17312904384SSimon J. Gerraty #error "bool/true/false is defined in pre-C99 mode"
1742c3632d1SSimon J. Gerraty #else
17512904384SSimon J. Gerraty typedef unsigned char bool;
176b0c40a00SSimon J. Gerraty #define true	1
177b0c40a00SSimon J. Gerraty #define false	0
178956e45f6SSimon J. Gerraty #endif
1792c3632d1SSimon J. Gerraty 
1803955d011SMarcel Moolenaar #include "lst.h"
181b0c40a00SSimon J. Gerraty #include "make_malloc.h"
182b0c40a00SSimon J. Gerraty #include "str.h"
1833955d011SMarcel Moolenaar #include "hash.h"
1843955d011SMarcel Moolenaar #include "make-conf.h"
1853955d011SMarcel Moolenaar #include "buf.h"
1863955d011SMarcel Moolenaar 
1873955d011SMarcel Moolenaar /*
1883955d011SMarcel Moolenaar  * some vendors don't have this --sjg
1893955d011SMarcel Moolenaar  */
1903955d011SMarcel Moolenaar #if defined(S_IFDIR) && !defined(S_ISDIR)
1913955d011SMarcel Moolenaar # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
1923955d011SMarcel Moolenaar #endif
1933955d011SMarcel Moolenaar 
1943955d011SMarcel Moolenaar #if defined(sun) && (defined(__svr4__) || defined(__SVR4))
1953955d011SMarcel Moolenaar # define POSIX_SIGNALS
1963955d011SMarcel Moolenaar #endif
1973955d011SMarcel Moolenaar 
19806b9b3e0SSimon J. Gerraty /*
19906b9b3e0SSimon J. Gerraty  * The typical flow of states is:
20006b9b3e0SSimon J. Gerraty  *
20106b9b3e0SSimon J. Gerraty  * The direct successful path:
20206b9b3e0SSimon J. Gerraty  * UNMADE -> BEINGMADE -> MADE.
20306b9b3e0SSimon J. Gerraty  *
20406b9b3e0SSimon J. Gerraty  * The direct error path:
20506b9b3e0SSimon J. Gerraty  * UNMADE -> BEINGMADE -> ERROR.
20606b9b3e0SSimon J. Gerraty  *
20706b9b3e0SSimon J. Gerraty  * The successful path when dependencies need to be made first:
20806b9b3e0SSimon J. Gerraty  * UNMADE -> DEFERRED -> REQUESTED -> BEINGMADE -> MADE.
20906b9b3e0SSimon J. Gerraty  *
21006b9b3e0SSimon J. Gerraty  * A node that has dependencies, and one of the dependencies cannot be made:
21106b9b3e0SSimon J. Gerraty  * UNMADE -> DEFERRED -> ABORTED.
21206b9b3e0SSimon J. Gerraty  *
21306b9b3e0SSimon J. Gerraty  * A node that turns out to be up-to-date:
21406b9b3e0SSimon J. Gerraty  * UNMADE -> BEINGMADE -> UPTODATE.
21506b9b3e0SSimon J. Gerraty  */
216e2eeea75SSimon J. Gerraty typedef enum GNodeMade {
21706b9b3e0SSimon J. Gerraty 	/* Not examined yet. */
21806b9b3e0SSimon J. Gerraty 	UNMADE,
2199f45a3c8SSimon J. Gerraty 	/*
2209f45a3c8SSimon J. Gerraty 	 * The node has been examined but is not yet ready since its
2219f45a3c8SSimon J. Gerraty 	 * dependencies have to be made first.
2229f45a3c8SSimon J. Gerraty 	 */
22306b9b3e0SSimon J. Gerraty 	DEFERRED,
22406b9b3e0SSimon J. Gerraty 
22506b9b3e0SSimon J. Gerraty 	/* The node is on the toBeMade list. */
22606b9b3e0SSimon J. Gerraty 	REQUESTED,
22706b9b3e0SSimon J. Gerraty 
2289f45a3c8SSimon J. Gerraty 	/*
2299f45a3c8SSimon J. Gerraty 	 * The node is already being made. Trying to build a node in this
2309f45a3c8SSimon J. Gerraty 	 * state indicates a cycle in the graph.
2319f45a3c8SSimon J. Gerraty 	 */
23206b9b3e0SSimon J. Gerraty 	BEINGMADE,
23306b9b3e0SSimon J. Gerraty 
23406b9b3e0SSimon J. Gerraty 	/* Was out-of-date and has been made. */
23506b9b3e0SSimon J. Gerraty 	MADE,
23606b9b3e0SSimon J. Gerraty 	/* Was already up-to-date, does not need to be made. */
23706b9b3e0SSimon J. Gerraty 	UPTODATE,
2389f45a3c8SSimon J. Gerraty 	/*
2399f45a3c8SSimon J. Gerraty 	 * An error occurred while it was being made. Used only in compat
2409f45a3c8SSimon J. Gerraty 	 * mode.
2419f45a3c8SSimon J. Gerraty 	 */
24206b9b3e0SSimon J. Gerraty 	ERROR,
2439f45a3c8SSimon J. Gerraty 	/*
2449f45a3c8SSimon J. Gerraty 	 * The target was aborted due to an error making a dependency. Used
2459f45a3c8SSimon J. Gerraty 	 * only in compat mode.
2469f45a3c8SSimon J. Gerraty 	 */
24706b9b3e0SSimon J. Gerraty 	ABORTED
2482c3632d1SSimon J. Gerraty } GNodeMade;
2493955d011SMarcel Moolenaar 
25006b9b3e0SSimon J. Gerraty /*
25106b9b3e0SSimon J. Gerraty  * The OP_ constants are used when parsing a dependency line as a way of
2522c3632d1SSimon J. Gerraty  * communicating to other parts of the program the way in which a target
2532c3632d1SSimon J. Gerraty  * should be made.
2542c3632d1SSimon J. Gerraty  *
25506b9b3e0SSimon J. Gerraty  * Some of the OP_ constants can be combined, others cannot.
256b0c40a00SSimon J. Gerraty  *
257b0c40a00SSimon J. Gerraty  * See the tests depsrc-*.mk and deptgt-*.mk.
25806b9b3e0SSimon J. Gerraty  */
259956e45f6SSimon J. Gerraty typedef enum GNodeType {
260e2eeea75SSimon J. Gerraty 	OP_NONE		= 0,
261e2eeea75SSimon J. Gerraty 
2629f45a3c8SSimon J. Gerraty 	/*
2639f45a3c8SSimon J. Gerraty 	 * The dependency operator ':' is the most common one.  The commands
2649f45a3c8SSimon J. Gerraty 	 * of this node are executed if any child is out-of-date.
2659f45a3c8SSimon J. Gerraty 	 */
2662c3632d1SSimon J. Gerraty 	OP_DEPENDS	= 1 << 0,
2679f45a3c8SSimon J. Gerraty 	/*
2689f45a3c8SSimon J. Gerraty 	 * The dependency operator '!' always executes its commands, even if
2699f45a3c8SSimon J. Gerraty 	 * its children are up-to-date.
2709f45a3c8SSimon J. Gerraty 	 */
2712c3632d1SSimon J. Gerraty 	OP_FORCE	= 1 << 1,
2729f45a3c8SSimon J. Gerraty 	/*
2739f45a3c8SSimon J. Gerraty 	 * The dependency operator '::' behaves like ':', except that it
27406b9b3e0SSimon J. Gerraty 	 * allows multiple dependency groups to be defined.  Each of these
2759f45a3c8SSimon J. Gerraty 	 * groups is executed on its own, independently from the others. Each
2769f45a3c8SSimon J. Gerraty 	 * individual dependency group is called a cohort.
2779f45a3c8SSimon J. Gerraty 	 */
2782c3632d1SSimon J. Gerraty 	OP_DOUBLEDEP	= 1 << 2,
2792c3632d1SSimon J. Gerraty 
280956e45f6SSimon J. Gerraty 	/* Matches the dependency operators ':', '!' and '::'. */
2812c3632d1SSimon J. Gerraty 	OP_OPMASK	= OP_DEPENDS | OP_FORCE | OP_DOUBLEDEP,
2822c3632d1SSimon J. Gerraty 
28306b9b3e0SSimon J. Gerraty 	/* Don't care if the target doesn't exist and can't be created. */
2842c3632d1SSimon J. Gerraty 	OP_OPTIONAL	= 1 << 3,
28506b9b3e0SSimon J. Gerraty 	/* Use associated commands for parents. */
2862c3632d1SSimon J. Gerraty 	OP_USE		= 1 << 4,
2879f45a3c8SSimon J. Gerraty 	/*
2889f45a3c8SSimon J. Gerraty 	 * Target is never out of date, but always execute commands anyway.
2899f45a3c8SSimon J. Gerraty 	 * Its time doesn't matter, so it has none...sort of.
2909f45a3c8SSimon J. Gerraty 	 */
2912c3632d1SSimon J. Gerraty 	OP_EXEC		= 1 << 5,
2929f45a3c8SSimon J. Gerraty 	/*
2939f45a3c8SSimon J. Gerraty 	 * Ignore non-zero exit status from shell commands when creating the
2949f45a3c8SSimon J. Gerraty 	 * node.
2959f45a3c8SSimon J. Gerraty 	 */
2962c3632d1SSimon J. Gerraty 	OP_IGNORE	= 1 << 6,
29706b9b3e0SSimon J. Gerraty 	/* Don't remove the target when interrupted. */
2982c3632d1SSimon J. Gerraty 	OP_PRECIOUS	= 1 << 7,
29906b9b3e0SSimon J. Gerraty 	/* Don't echo commands when executed. */
3002c3632d1SSimon J. Gerraty 	OP_SILENT	= 1 << 8,
3019f45a3c8SSimon J. Gerraty 	/*
3029f45a3c8SSimon J. Gerraty 	 * Target is a recursive make so its commands should always be
3039f45a3c8SSimon J. Gerraty 	 * executed when it is out of date, regardless of the state of the -n
3049f45a3c8SSimon J. Gerraty 	 * or -t flags.
3059f45a3c8SSimon J. Gerraty 	 */
3062c3632d1SSimon J. Gerraty 	OP_MAKE		= 1 << 9,
3079f45a3c8SSimon J. Gerraty 	/*
3089f45a3c8SSimon J. Gerraty 	 * Target is out-of-date only if any of its children was out-of-date.
3099f45a3c8SSimon J. Gerraty 	 */
3102c3632d1SSimon J. Gerraty 	OP_JOIN		= 1 << 10,
31106b9b3e0SSimon J. Gerraty 	/* Assume the children of the node have been already made. */
3122c3632d1SSimon J. Gerraty 	OP_MADE		= 1 << 11,
31306b9b3e0SSimon J. Gerraty 	/* Special .BEGIN, .END or .INTERRUPT. */
3142c3632d1SSimon J. Gerraty 	OP_SPECIAL	= 1 << 12,
31506b9b3e0SSimon J. Gerraty 	/* Like .USE, only prepend commands. */
3162c3632d1SSimon J. Gerraty 	OP_USEBEFORE	= 1 << 13,
3179f45a3c8SSimon J. Gerraty 	/*
3189f45a3c8SSimon J. Gerraty 	 * The node is invisible to its parents. I.e. it doesn't show up in
3199f45a3c8SSimon J. Gerraty 	 * the parents' local variables (.IMPSRC, .ALLSRC).
3209f45a3c8SSimon J. Gerraty 	 */
3212c3632d1SSimon J. Gerraty 	OP_INVISIBLE	= 1 << 14,
3229f45a3c8SSimon J. Gerraty 	/*
3239f45a3c8SSimon J. Gerraty 	 * The node does not become the main target, even if it is the first
3249f45a3c8SSimon J. Gerraty 	 * target in the first makefile.
3259f45a3c8SSimon J. Gerraty 	 */
3262c3632d1SSimon J. Gerraty 	OP_NOTMAIN	= 1 << 15,
32706b9b3e0SSimon J. Gerraty 	/* Not a file target; run always. */
3282c3632d1SSimon J. Gerraty 	OP_PHONY	= 1 << 16,
32906b9b3e0SSimon J. Gerraty 	/* Don't search for the file in the path. */
3302c3632d1SSimon J. Gerraty 	OP_NOPATH	= 1 << 17,
3319f45a3c8SSimon J. Gerraty 	/*
3329f45a3c8SSimon J. Gerraty 	 * In a dependency line "target: source1 .WAIT source2", source1 is
33306b9b3e0SSimon J. Gerraty 	 * made first, including its children.  Once that is finished,
33406b9b3e0SSimon J. Gerraty 	 * source2 is made, including its children.  The .WAIT keyword may
3359f45a3c8SSimon J. Gerraty 	 * appear more than once in a single dependency declaration.
3369f45a3c8SSimon J. Gerraty 	 */
3372c3632d1SSimon J. Gerraty 	OP_WAIT		= 1 << 18,
3382c3632d1SSimon J. Gerraty 	/* .NOMETA do not create a .meta file */
3392c3632d1SSimon J. Gerraty 	OP_NOMETA	= 1 << 19,
3402c3632d1SSimon J. Gerraty 	/* .META we _do_ want a .meta file */
3412c3632d1SSimon J. Gerraty 	OP_META		= 1 << 20,
3422c3632d1SSimon J. Gerraty 	/* Do not compare commands in .meta file */
3432c3632d1SSimon J. Gerraty 	OP_NOMETA_CMP	= 1 << 21,
3442c3632d1SSimon J. Gerraty 	/* Possibly a submake node */
3452c3632d1SSimon J. Gerraty 	OP_SUBMAKE	= 1 << 22,
3462c3632d1SSimon J. Gerraty 
3472c3632d1SSimon J. Gerraty 	/* Attributes applied by PMake */
3482c3632d1SSimon J. Gerraty 
349e2eeea75SSimon J. Gerraty 	/* The node is a transformation rule, such as ".c.o". */
35006b9b3e0SSimon J. Gerraty 	OP_TRANSFORM	= 1 << 30,
3512c3632d1SSimon J. Gerraty 	/* Target is a member of an archive */
352956e45f6SSimon J. Gerraty 	/* XXX: How does this differ from OP_ARCHV? */
35306b9b3e0SSimon J. Gerraty 	OP_MEMBER	= 1 << 29,
3549f45a3c8SSimon J. Gerraty 	/*
3559f45a3c8SSimon J. Gerraty 	 * The node is a library, its name has the form "-l<libname>".
3569f45a3c8SSimon J. Gerraty 	 */
35706b9b3e0SSimon J. Gerraty 	OP_LIB		= 1 << 28,
3589f45a3c8SSimon J. Gerraty 	/*
3599f45a3c8SSimon J. Gerraty 	 * The node is an archive member, its name has the form
3609f45a3c8SSimon J. Gerraty 	 * "archive(member)".
3619f45a3c8SSimon J. Gerraty 	 */
362956e45f6SSimon J. Gerraty 	/* XXX: How does this differ from OP_MEMBER? */
36306b9b3e0SSimon J. Gerraty 	OP_ARCHV	= 1 << 27,
3649f45a3c8SSimon J. Gerraty 	/*
3659f45a3c8SSimon J. Gerraty 	 * Target has all the commands it should. Used when parsing to catch
36606b9b3e0SSimon J. Gerraty 	 * multiple command groups for a target.  Only applies to the
3679f45a3c8SSimon J. Gerraty 	 * dependency operators ':' and '!', but not to '::'.
3689f45a3c8SSimon J. Gerraty 	 */
36906b9b3e0SSimon J. Gerraty 	OP_HAS_COMMANDS	= 1 << 26,
3709f45a3c8SSimon J. Gerraty 	/*
3719f45a3c8SSimon J. Gerraty 	 * The special command "..." has been seen. All further commands from
3729f45a3c8SSimon J. Gerraty 	 * this node will be saved on the .END node instead, to be executed
3739f45a3c8SSimon J. Gerraty 	 * at the very end.
3749f45a3c8SSimon J. Gerraty 	 */
37506b9b3e0SSimon J. Gerraty 	OP_SAVE_CMDS	= 1 << 25,
3769f45a3c8SSimon J. Gerraty 	/*
3779f45a3c8SSimon J. Gerraty 	 * Already processed by Suff_FindDeps, to find dependencies from
3789f45a3c8SSimon J. Gerraty 	 * suffix transformation rules.
3799f45a3c8SSimon J. Gerraty 	 */
38006b9b3e0SSimon J. Gerraty 	OP_DEPS_FOUND	= 1 << 24,
3812c3632d1SSimon J. Gerraty 	/* Node found while expanding .ALLSRC */
3829f45a3c8SSimon J. Gerraty 	OP_MARK		= 1 << 23
3832c3632d1SSimon J. Gerraty } GNodeType;
3842c3632d1SSimon J. Gerraty 
38512904384SSimon J. Gerraty typedef struct GNodeFlags {
38606b9b3e0SSimon J. Gerraty 	/* this target needs to be (re)made */
38712904384SSimon J. Gerraty 	bool remake:1;
38806b9b3e0SSimon J. Gerraty 	/* children of this target were made */
38912904384SSimon J. Gerraty 	bool childMade:1;
39006b9b3e0SSimon J. Gerraty 	/* children don't exist, and we pretend made */
39112904384SSimon J. Gerraty 	bool force:1;
39206b9b3e0SSimon J. Gerraty 	/* Set by Make_ProcessWait() */
39312904384SSimon J. Gerraty 	bool doneWait:1;
39406b9b3e0SSimon J. Gerraty 	/* Build requested by .ORDER processing */
39512904384SSimon J. Gerraty 	bool doneOrder:1;
39606b9b3e0SSimon J. Gerraty 	/* Node created from .depend */
39712904384SSimon J. Gerraty 	bool fromDepend:1;
39806b9b3e0SSimon J. Gerraty 	/* We do it once only */
39912904384SSimon J. Gerraty 	bool doneAllsrc:1;
40006b9b3e0SSimon J. Gerraty 	/* Used by MakePrintStatus */
40112904384SSimon J. Gerraty 	bool cycle:1;
40206b9b3e0SSimon J. Gerraty 	/* Used by MakePrintStatus */
40312904384SSimon J. Gerraty 	bool doneCycle:1;
4042c3632d1SSimon J. Gerraty } GNodeFlags;
4052c3632d1SSimon J. Gerraty 
406956e45f6SSimon J. Gerraty typedef struct List StringList;
407956e45f6SSimon J. Gerraty typedef struct ListNode StringListNode;
408956e45f6SSimon J. Gerraty 
409956e45f6SSimon J. Gerraty typedef struct List GNodeList;
410956e45f6SSimon J. Gerraty typedef struct ListNode GNodeListNode;
411956e45f6SSimon J. Gerraty 
412dba7b0efSSimon J. Gerraty typedef struct SearchPath {
413dba7b0efSSimon J. Gerraty 	List /* of CachedDir */ dirs;
414dba7b0efSSimon J. Gerraty } SearchPath;
415956e45f6SSimon J. Gerraty 
41606b9b3e0SSimon J. Gerraty /*
41706b9b3e0SSimon J. Gerraty  * A graph node represents a target that can possibly be made, including its
41806b9b3e0SSimon J. Gerraty  * relation to other targets and a lot of other details.
41906b9b3e0SSimon J. Gerraty  */
4202c3632d1SSimon J. Gerraty typedef struct GNode {
4212c3632d1SSimon J. Gerraty 	/* The target's name, such as "clean" or "make.c" */
4222c3632d1SSimon J. Gerraty 	char *name;
4232c3632d1SSimon J. Gerraty 	/* The unexpanded name of a .USE node */
4242c3632d1SSimon J. Gerraty 	char *uname;
4259f45a3c8SSimon J. Gerraty 	/*
4269f45a3c8SSimon J. Gerraty 	 * The full pathname of the file belonging to the target.
4279f45a3c8SSimon J. Gerraty 	 *
42806b9b3e0SSimon J. Gerraty 	 * XXX: What about .PHONY targets? These don't have an associated
4299f45a3c8SSimon J. Gerraty 	 * path.
4309f45a3c8SSimon J. Gerraty 	 */
4312c3632d1SSimon J. Gerraty 	char *path;
4322c3632d1SSimon J. Gerraty 
4339f45a3c8SSimon J. Gerraty 	/*
4349f45a3c8SSimon J. Gerraty 	 * The type of operator used to define the sources (see the OP flags
43506b9b3e0SSimon J. Gerraty 	 * below).
4369f45a3c8SSimon J. Gerraty 	 *
4379f45a3c8SSimon J. Gerraty 	 * XXX: This looks like a wild mixture of type and flags.
4389f45a3c8SSimon J. Gerraty 	 */
4392c3632d1SSimon J. Gerraty 	GNodeType type;
4402c3632d1SSimon J. Gerraty 	GNodeFlags flags;
4412c3632d1SSimon J. Gerraty 
4422c3632d1SSimon J. Gerraty 	/* The state of processing on this node */
4432c3632d1SSimon J. Gerraty 	GNodeMade made;
44406b9b3e0SSimon J. Gerraty 	/* The number of unmade children */
44506b9b3e0SSimon J. Gerraty 	int unmade;
4463955d011SMarcel Moolenaar 
4479f45a3c8SSimon J. Gerraty 	/*
4489f45a3c8SSimon J. Gerraty 	 * The modification time; 0 means the node does not have a
4499f45a3c8SSimon J. Gerraty 	 * corresponding file; see GNode_IsOODate.
4509f45a3c8SSimon J. Gerraty 	 */
451956e45f6SSimon J. Gerraty 	time_t mtime;
452956e45f6SSimon J. Gerraty 	struct GNode *youngestChild;
4533955d011SMarcel Moolenaar 
4549f45a3c8SSimon J. Gerraty 	/*
4559f45a3c8SSimon J. Gerraty 	 * The GNodes for which this node is an implied source. May be empty.
4569f45a3c8SSimon J. Gerraty 	 * For example, when there is an inference rule for .c.o, the node
4579f45a3c8SSimon J. Gerraty 	 * for file.c has the node for file.o in this list.
4589f45a3c8SSimon J. Gerraty 	 */
45906b9b3e0SSimon J. Gerraty 	GNodeList implicitParents;
4603955d011SMarcel Moolenaar 
4619f45a3c8SSimon J. Gerraty 	/*
4629f45a3c8SSimon J. Gerraty 	 * The nodes that depend on this one, or in other words, the nodes
4639f45a3c8SSimon J. Gerraty 	 * for which this is a source.
4649f45a3c8SSimon J. Gerraty 	 */
46506b9b3e0SSimon J. Gerraty 	GNodeList parents;
4662c3632d1SSimon J. Gerraty 	/* The nodes on which this one depends. */
46706b9b3e0SSimon J. Gerraty 	GNodeList children;
4683955d011SMarcel Moolenaar 
4699f45a3c8SSimon J. Gerraty 	/*
4709f45a3c8SSimon J. Gerraty 	 * .ORDER nodes we need made. The nodes that must be made (if they're
4712c3632d1SSimon J. Gerraty 	 * made) before this node can be made, but that do not enter into the
4729f45a3c8SSimon J. Gerraty 	 * datedness of this node.
4739f45a3c8SSimon J. Gerraty 	 */
47406b9b3e0SSimon J. Gerraty 	GNodeList order_pred;
4759f45a3c8SSimon J. Gerraty 	/*
4769f45a3c8SSimon J. Gerraty 	 * .ORDER nodes who need us. The nodes that must be made (if they're
47706b9b3e0SSimon J. Gerraty 	 * made at all) after this node is made, but that do not depend on
4789f45a3c8SSimon J. Gerraty 	 * this node, in the normal sense.
4799f45a3c8SSimon J. Gerraty 	 */
48006b9b3e0SSimon J. Gerraty 	GNodeList order_succ;
4812c3632d1SSimon J. Gerraty 
482dba7b0efSSimon J. Gerraty 	/*
483dba7b0efSSimon J. Gerraty 	 * Other nodes of the same name, for targets that were defined using
484dba7b0efSSimon J. Gerraty 	 * the '::' dependency operator (OP_DOUBLEDEP).
485dba7b0efSSimon J. Gerraty 	 */
48606b9b3e0SSimon J. Gerraty 	GNodeList cohorts;
487956e45f6SSimon J. Gerraty 	/* The "#n" suffix for this cohort, or "" for other nodes */
4882c3632d1SSimon J. Gerraty 	char cohort_num[8];
4892c3632d1SSimon J. Gerraty 	/* The number of unmade instances on the cohorts list */
4902c3632d1SSimon J. Gerraty 	int unmade_cohorts;
4919f45a3c8SSimon J. Gerraty 	/*
4929f45a3c8SSimon J. Gerraty 	 * Pointer to the first instance of a '::' node; only set when on a
4939f45a3c8SSimon J. Gerraty 	 * cohorts list
4949f45a3c8SSimon J. Gerraty 	 */
4952c3632d1SSimon J. Gerraty 	struct GNode *centurion;
4962c3632d1SSimon J. Gerraty 
4972c3632d1SSimon J. Gerraty 	/* Last time (sequence number) we tried to make this node */
498956e45f6SSimon J. Gerraty 	unsigned int checked_seqno;
4992c3632d1SSimon J. Gerraty 
500dba7b0efSSimon J. Gerraty 	/*
501dba7b0efSSimon J. Gerraty 	 * The "local" variables that are specific to this target and this
50206b9b3e0SSimon J. Gerraty 	 * target only, such as $@, $<, $?.
503956e45f6SSimon J. Gerraty 	 *
504dba7b0efSSimon J. Gerraty 	 * Also used for the global variable scopes SCOPE_GLOBAL,
505dba7b0efSSimon J. Gerraty 	 * SCOPE_CMDLINE, SCOPE_INTERNAL, which contain variables with
506dba7b0efSSimon J. Gerraty 	 * arbitrary names.
507dba7b0efSSimon J. Gerraty 	 */
50806b9b3e0SSimon J. Gerraty 	HashTable /* of Var pointer */ vars;
5092c3632d1SSimon J. Gerraty 
5102c3632d1SSimon J. Gerraty 	/* The commands to be given to a shell to create this target. */
51106b9b3e0SSimon J. Gerraty 	StringList commands;
5122c3632d1SSimon J. Gerraty 
5139f45a3c8SSimon J. Gerraty 	/*
5149f45a3c8SSimon J. Gerraty 	 * Suffix for the node (determined by Suff_FindDeps and opaque to
5159f45a3c8SSimon J. Gerraty 	 * everyone but the Suff module)
5169f45a3c8SSimon J. Gerraty 	 */
51706b9b3e0SSimon J. Gerraty 	struct Suffix *suffix;
5182c3632d1SSimon J. Gerraty 
5199f45a3c8SSimon J. Gerraty 	/* Filename where the GNode got defined, unlimited lifetime */
5202c3632d1SSimon J. Gerraty 	const char *fname;
5219f45a3c8SSimon J. Gerraty 	/* Line number where the GNode got defined, 1-based */
5229f45a3c8SSimon J. Gerraty 	unsigned lineno;
5233955d011SMarcel Moolenaar } GNode;
5243955d011SMarcel Moolenaar 
5252f2a5ecdSSimon J. Gerraty /*
5262f2a5ecdSSimon J. Gerraty  * Keep track of whether to include <posix.mk> when parsing the line
5272f2a5ecdSSimon J. Gerraty  * '.POSIX:'.
5282f2a5ecdSSimon J. Gerraty  */
5292f2a5ecdSSimon J. Gerraty extern enum PosixState {
5302f2a5ecdSSimon J. Gerraty 	PS_NOT_YET,
5312f2a5ecdSSimon J. Gerraty 	PS_MAYBE_NEXT_LINE,
5322f2a5ecdSSimon J. Gerraty 	PS_NOW_OR_NEVER,
5332f2a5ecdSSimon J. Gerraty 	PS_TOO_LATE
5342f2a5ecdSSimon J. Gerraty } posix_state;
5352f2a5ecdSSimon J. Gerraty 
536e2eeea75SSimon J. Gerraty /* Error levels for diagnostics during parsing. */
537956e45f6SSimon J. Gerraty typedef enum ParseErrorLevel {
5389f45a3c8SSimon J. Gerraty 	/*
5399f45a3c8SSimon J. Gerraty 	 * Exit when the current top-level makefile has been parsed
5409f45a3c8SSimon J. Gerraty 	 * completely.
5419f45a3c8SSimon J. Gerraty 	 */
542956e45f6SSimon J. Gerraty 	PARSE_FATAL = 1,
543e2eeea75SSimon J. Gerraty 	/* Print "warning"; may be upgraded to fatal by the -w option. */
544956e45f6SSimon J. Gerraty 	PARSE_WARNING,
545e2eeea75SSimon J. Gerraty 	/* Informational, mainly used during development of makefiles. */
546956e45f6SSimon J. Gerraty 	PARSE_INFO
547956e45f6SSimon J. Gerraty } ParseErrorLevel;
5483955d011SMarcel Moolenaar 
5493955d011SMarcel Moolenaar /*
550956e45f6SSimon J. Gerraty  * Values returned by Cond_EvalLine and Cond_EvalCondition.
5513955d011SMarcel Moolenaar  */
5529f45a3c8SSimon J. Gerraty typedef enum CondResult {
5539f45a3c8SSimon J. Gerraty 	CR_TRUE,		/* Parse the next lines */
5549f45a3c8SSimon J. Gerraty 	CR_FALSE,		/* Skip the next lines */
5559f45a3c8SSimon J. Gerraty 	CR_ERROR		/* Unknown directive or parse error */
5569f45a3c8SSimon J. Gerraty } CondResult;
5573955d011SMarcel Moolenaar 
558e2eeea75SSimon J. Gerraty /* Names of the variables that are "local" to a specific target. */
5593955d011SMarcel Moolenaar #define TARGET	"@"		/* Target of dependency */
5603955d011SMarcel Moolenaar #define OODATE	"?"		/* All out-of-date sources */
5613955d011SMarcel Moolenaar #define ALLSRC	">"		/* All sources */
5623955d011SMarcel Moolenaar #define IMPSRC	"<"		/* Source implied by transformation */
5633955d011SMarcel Moolenaar #define PREFIX	"*"		/* Common prefix */
5643955d011SMarcel Moolenaar #define ARCHIVE	"!"		/* Archive in "archive(member)" syntax */
5653955d011SMarcel Moolenaar #define MEMBER	"%"		/* Member in "archive(member)" syntax */
5663955d011SMarcel Moolenaar 
5673955d011SMarcel Moolenaar /*
5683955d011SMarcel Moolenaar  * Global Variables
5693955d011SMarcel Moolenaar  */
5703955d011SMarcel Moolenaar 
571e2eeea75SSimon J. Gerraty /* True if every target is precious */
572b0c40a00SSimon J. Gerraty extern bool allPrecious;
573e2eeea75SSimon J. Gerraty /* True if failed targets should be deleted */
574b0c40a00SSimon J. Gerraty extern bool deleteOnError;
575b0c40a00SSimon J. Gerraty /* true while processing .depend */
576b0c40a00SSimon J. Gerraty extern bool doing_depend;
577e2eeea75SSimon J. Gerraty /* .DEFAULT rule */
578e2eeea75SSimon J. Gerraty extern GNode *defaultNode;
5793955d011SMarcel Moolenaar 
58006b9b3e0SSimon J. Gerraty /*
58106b9b3e0SSimon J. Gerraty  * Variables defined internally by make which should not override those set
58206b9b3e0SSimon J. Gerraty  * by makefiles.
58306b9b3e0SSimon J. Gerraty  */
584dba7b0efSSimon J. Gerraty extern GNode *SCOPE_INTERNAL;
585dba7b0efSSimon J. Gerraty /* Variables defined in a global scope, e.g in the makefile itself. */
586dba7b0efSSimon J. Gerraty extern GNode *SCOPE_GLOBAL;
587e2eeea75SSimon J. Gerraty /* Variables defined on the command line. */
588dba7b0efSSimon J. Gerraty extern GNode *SCOPE_CMDLINE;
589e2eeea75SSimon J. Gerraty 
59006b9b3e0SSimon J. Gerraty /*
59106b9b3e0SSimon J. Gerraty  * Value returned by Var_Parse when an error is encountered. It actually
59206b9b3e0SSimon J. Gerraty  * points to an empty string, so naive callers needn't worry about it.
59306b9b3e0SSimon J. Gerraty  */
594e2eeea75SSimon J. Gerraty extern char var_Error[];
595e2eeea75SSimon J. Gerraty 
596e2eeea75SSimon J. Gerraty /* The time at the start of this whole process */
597e2eeea75SSimon J. Gerraty extern time_t now;
598e2eeea75SSimon J. Gerraty 
599e2eeea75SSimon J. Gerraty /*
60006b9b3e0SSimon J. Gerraty  * The list of directories to search when looking for targets (set by the
60106b9b3e0SSimon J. Gerraty  * special target .PATH).
6021bbe5942SSimon J. Gerraty  */
60306b9b3e0SSimon J. Gerraty extern SearchPath dirSearchPath;
604e2eeea75SSimon J. Gerraty /* Used for .include "...". */
605e2eeea75SSimon J. Gerraty extern SearchPath *parseIncPath;
60606b9b3e0SSimon J. Gerraty /*
607dba7b0efSSimon J. Gerraty  * Used for .include <...>, for the built-in sys.mk and for makefiles from
608dba7b0efSSimon J. Gerraty  * the command line arguments.
60906b9b3e0SSimon J. Gerraty  */
610e2eeea75SSimon J. Gerraty extern SearchPath *sysIncPath;
611e2eeea75SSimon J. Gerraty /* The default for sysIncPath. */
612e2eeea75SSimon J. Gerraty extern SearchPath *defSysIncPath;
6133955d011SMarcel Moolenaar 
614e2eeea75SSimon J. Gerraty /* Startup directory */
615e2eeea75SSimon J. Gerraty extern char curdir[];
616e2eeea75SSimon J. Gerraty /* The basename of the program name, suffixed with [n] for sub-makes.  */
61706b9b3e0SSimon J. Gerraty extern const char *progname;
618dba7b0efSSimon J. Gerraty extern int makelevel;
619e2eeea75SSimon J. Gerraty /* Name of the .depend makefile */
620e2eeea75SSimon J. Gerraty extern char *makeDependfile;
621e2eeea75SSimon J. Gerraty /* If we replaced environ, this will be non-NULL. */
622e2eeea75SSimon J. Gerraty extern char **savedEnv;
6239f45a3c8SSimon J. Gerraty extern GNode *mainNode;
6243955d011SMarcel Moolenaar 
6253955d011SMarcel Moolenaar extern pid_t myPid;
6263955d011SMarcel Moolenaar 
6273955d011SMarcel Moolenaar #define MAKEFLAGS	".MAKEFLAGS"
6283955d011SMarcel Moolenaar #define MAKEOVERRIDES	".MAKEOVERRIDES"
62906b9b3e0SSimon J. Gerraty /* prefix when printing the target of a job */
63006b9b3e0SSimon J. Gerraty #define MAKE_JOB_PREFIX	".MAKE.JOB.PREFIX"
63106b9b3e0SSimon J. Gerraty #define MAKE_EXPORTED	".MAKE.EXPORTED"	/* exported variables */
63206b9b3e0SSimon J. Gerraty #define MAKE_MAKEFILES	".MAKE.MAKEFILES"	/* all loaded makefiles */
6333955d011SMarcel Moolenaar #define MAKE_LEVEL	".MAKE.LEVEL"		/* recursion level */
634e2eeea75SSimon J. Gerraty #define MAKE_MAKEFILE_PREFERENCE ".MAKE.MAKEFILE_PREFERENCE"
6353955d011SMarcel Moolenaar #define MAKE_DEPENDFILE	".MAKE.DEPENDFILE"	/* .depend */
6363955d011SMarcel Moolenaar #define MAKE_MODE	".MAKE.MODE"
63751ee2c1cSSimon J. Gerraty #ifndef MAKE_LEVEL_ENV
63851ee2c1cSSimon J. Gerraty # define MAKE_LEVEL_ENV	"MAKELEVEL"
6393955d011SMarcel Moolenaar #endif
6403955d011SMarcel Moolenaar 
6419f45a3c8SSimon J. Gerraty typedef struct DebugFlags {
6429f45a3c8SSimon J. Gerraty 	bool DEBUG_ARCH:1;
6439f45a3c8SSimon J. Gerraty 	bool DEBUG_COND:1;
6449f45a3c8SSimon J. Gerraty 	bool DEBUG_CWD:1;
6459f45a3c8SSimon J. Gerraty 	bool DEBUG_DIR:1;
6469f45a3c8SSimon J. Gerraty 	bool DEBUG_ERROR:1;
6479f45a3c8SSimon J. Gerraty 	bool DEBUG_FOR:1;
6489f45a3c8SSimon J. Gerraty 	bool DEBUG_GRAPH1:1;
6499f45a3c8SSimon J. Gerraty 	bool DEBUG_GRAPH2:1;
6509f45a3c8SSimon J. Gerraty 	bool DEBUG_GRAPH3:1;
6519f45a3c8SSimon J. Gerraty 	bool DEBUG_HASH:1;
6529f45a3c8SSimon J. Gerraty 	bool DEBUG_JOB:1;
6539f45a3c8SSimon J. Gerraty 	bool DEBUG_LOUD:1;
6549f45a3c8SSimon J. Gerraty 	bool DEBUG_MAKE:1;
6559f45a3c8SSimon J. Gerraty 	bool DEBUG_META:1;
6569f45a3c8SSimon J. Gerraty 	bool DEBUG_PARSE:1;
6579f45a3c8SSimon J. Gerraty 	bool DEBUG_SCRIPT:1;
6589f45a3c8SSimon J. Gerraty 	bool DEBUG_SHELL:1;
6599f45a3c8SSimon J. Gerraty 	bool DEBUG_SUFF:1;
6609f45a3c8SSimon J. Gerraty 	bool DEBUG_TARG:1;
6619f45a3c8SSimon J. Gerraty 	bool DEBUG_VAR:1;
662956e45f6SSimon J. Gerraty } DebugFlags;
6632c3632d1SSimon J. Gerraty 
6643955d011SMarcel Moolenaar #define CONCAT(a, b) a##b
6653955d011SMarcel Moolenaar 
6669f45a3c8SSimon J. Gerraty #define DEBUG(module) (opts.debug.CONCAT(DEBUG_, module))
667956e45f6SSimon J. Gerraty 
668956e45f6SSimon J. Gerraty void debug_printf(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
669956e45f6SSimon J. Gerraty 
67006b9b3e0SSimon J. Gerraty #define DEBUG_IMPL(module, args) \
67106b9b3e0SSimon J. Gerraty 	do { \
67206b9b3e0SSimon J. Gerraty 		if (DEBUG(module)) \
67306b9b3e0SSimon J. Gerraty 			debug_printf args; \
67412904384SSimon J. Gerraty 	} while (false)
67506b9b3e0SSimon J. Gerraty 
6769f45a3c8SSimon J. Gerraty #define DEBUG0(module, fmt) \
6779f45a3c8SSimon J. Gerraty 	DEBUG_IMPL(module, (fmt))
678956e45f6SSimon J. Gerraty #define DEBUG1(module, fmt, arg1) \
67906b9b3e0SSimon J. Gerraty 	DEBUG_IMPL(module, (fmt, arg1))
680956e45f6SSimon J. Gerraty #define DEBUG2(module, fmt, arg1, arg2) \
68106b9b3e0SSimon J. Gerraty 	DEBUG_IMPL(module, (fmt, arg1, arg2))
682956e45f6SSimon J. Gerraty #define DEBUG3(module, fmt, arg1, arg2, arg3) \
68306b9b3e0SSimon J. Gerraty 	DEBUG_IMPL(module, (fmt, arg1, arg2, arg3))
684956e45f6SSimon J. Gerraty #define DEBUG4(module, fmt, arg1, arg2, arg3, arg4) \
68506b9b3e0SSimon J. Gerraty 	DEBUG_IMPL(module, (fmt, arg1, arg2, arg3, arg4))
686956e45f6SSimon J. Gerraty #define DEBUG5(module, fmt, arg1, arg2, arg3, arg4, arg5) \
68706b9b3e0SSimon J. Gerraty 	DEBUG_IMPL(module, (fmt, arg1, arg2, arg3, arg4, arg5))
688956e45f6SSimon J. Gerraty 
689956e45f6SSimon J. Gerraty typedef enum PrintVarsMode {
690e2eeea75SSimon J. Gerraty 	PVM_NONE,
691e2eeea75SSimon J. Gerraty 	PVM_UNEXPANDED,
692e2eeea75SSimon J. Gerraty 	PVM_EXPANDED
693956e45f6SSimon J. Gerraty } PrintVarsMode;
694956e45f6SSimon J. Gerraty 
695956e45f6SSimon J. Gerraty /* Command line options */
696956e45f6SSimon J. Gerraty typedef struct CmdOpts {
697956e45f6SSimon J. Gerraty 	/* -B: whether we are make compatible */
698b0c40a00SSimon J. Gerraty 	bool compatMake;
699956e45f6SSimon J. Gerraty 
7009f45a3c8SSimon J. Gerraty 	/*
7019f45a3c8SSimon J. Gerraty 	 * -d: debug control: There is one bit per module.  It is up to the
7029f45a3c8SSimon J. Gerraty 	 * module what debug information to print.
7039f45a3c8SSimon J. Gerraty 	 */
704956e45f6SSimon J. Gerraty 	DebugFlags debug;
705956e45f6SSimon J. Gerraty 
706956e45f6SSimon J. Gerraty 	/* -df: debug output is written here - default stderr */
707956e45f6SSimon J. Gerraty 	FILE *debug_file;
708956e45f6SSimon J. Gerraty 
7099f45a3c8SSimon J. Gerraty 	/*
7109f45a3c8SSimon J. Gerraty 	 * -dL: lint mode
711e2eeea75SSimon J. Gerraty 	 *
712e2eeea75SSimon J. Gerraty 	 * Runs make in strict mode, with additional checks and better error
7139f45a3c8SSimon J. Gerraty 	 * handling.
7149f45a3c8SSimon J. Gerraty 	 */
715b0c40a00SSimon J. Gerraty 	bool strict;
716e2eeea75SSimon J. Gerraty 
717956e45f6SSimon J. Gerraty 	/* -dV: for the -V option, print unexpanded variable values */
718b0c40a00SSimon J. Gerraty 	bool debugVflag;
719956e45f6SSimon J. Gerraty 
720956e45f6SSimon J. Gerraty 	/* -e: check environment variables before global variables */
721b0c40a00SSimon J. Gerraty 	bool checkEnvFirst;
722956e45f6SSimon J. Gerraty 
723956e45f6SSimon J. Gerraty 	/* -f: the makefiles to read */
72406b9b3e0SSimon J. Gerraty 	StringList makefiles;
725956e45f6SSimon J. Gerraty 
726956e45f6SSimon J. Gerraty 	/* -i: if true, ignore all errors from shell commands */
727b0c40a00SSimon J. Gerraty 	bool ignoreErrors;
728956e45f6SSimon J. Gerraty 
7299f45a3c8SSimon J. Gerraty 	/*
7309f45a3c8SSimon J. Gerraty 	 * -j: the maximum number of jobs that can run in parallel; this is
7319f45a3c8SSimon J. Gerraty 	 * coordinated with the submakes
7329f45a3c8SSimon J. Gerraty 	 */
733956e45f6SSimon J. Gerraty 	int maxJobs;
734956e45f6SSimon J. Gerraty 
7359f45a3c8SSimon J. Gerraty 	/*
7369f45a3c8SSimon J. Gerraty 	 * -k: if true and an error occurs while making a node, continue
7379f45a3c8SSimon J. Gerraty 	 * making nodes that do not depend on the erroneous node
7389f45a3c8SSimon J. Gerraty 	 */
739b0c40a00SSimon J. Gerraty 	bool keepgoing;
740956e45f6SSimon J. Gerraty 
741956e45f6SSimon J. Gerraty 	/* -N: execute no commands from the targets */
742b0c40a00SSimon J. Gerraty 	bool noRecursiveExecute;
743956e45f6SSimon J. Gerraty 
744956e45f6SSimon J. Gerraty 	/* -n: execute almost no commands from the targets */
745b0c40a00SSimon J. Gerraty 	bool noExecute;
746956e45f6SSimon J. Gerraty 
747dba7b0efSSimon J. Gerraty 	/*
748dba7b0efSSimon J. Gerraty 	 * -q: if true, do not really make anything, just see if the targets
749dba7b0efSSimon J. Gerraty 	 * are out-of-date
750dba7b0efSSimon J. Gerraty 	 */
7519f45a3c8SSimon J. Gerraty 	bool query;
752956e45f6SSimon J. Gerraty 
753dba7b0efSSimon J. Gerraty 	/* -r: raw mode, do not load the builtin rules. */
754b0c40a00SSimon J. Gerraty 	bool noBuiltins;
755956e45f6SSimon J. Gerraty 
756956e45f6SSimon J. Gerraty 	/* -s: don't echo the shell commands before executing them */
7579f45a3c8SSimon J. Gerraty 	bool silent;
758956e45f6SSimon J. Gerraty 
7599f45a3c8SSimon J. Gerraty 	/*
7609f45a3c8SSimon J. Gerraty 	 * -t: touch the targets if they are out-of-date, but don't actually
7619f45a3c8SSimon J. Gerraty 	 * make them
7629f45a3c8SSimon J. Gerraty 	 */
7639f45a3c8SSimon J. Gerraty 	bool touch;
764956e45f6SSimon J. Gerraty 
765956e45f6SSimon J. Gerraty 	/* -[Vv]: print expanded or unexpanded selected variables */
766956e45f6SSimon J. Gerraty 	PrintVarsMode printVars;
767956e45f6SSimon J. Gerraty 	/* -[Vv]: the variables to print */
76806b9b3e0SSimon J. Gerraty 	StringList variables;
769956e45f6SSimon J. Gerraty 
770956e45f6SSimon J. Gerraty 	/* -W: if true, makefile parsing warnings are treated as errors */
771b0c40a00SSimon J. Gerraty 	bool parseWarnFatal;
772956e45f6SSimon J. Gerraty 
773dba7b0efSSimon J. Gerraty 	/* -w: print 'Entering' and 'Leaving' for submakes */
774b0c40a00SSimon J. Gerraty 	bool enterFlag;
775956e45f6SSimon J. Gerraty 
7769f45a3c8SSimon J. Gerraty 	/*
7779f45a3c8SSimon J. Gerraty 	 * -X: if true, do not export variables set on the command line to
7789f45a3c8SSimon J. Gerraty 	 * the environment.
7799f45a3c8SSimon J. Gerraty 	 */
780b0c40a00SSimon J. Gerraty 	bool varNoExportEnv;
781956e45f6SSimon J. Gerraty 
7829f45a3c8SSimon J. Gerraty 	/*
7839f45a3c8SSimon J. Gerraty 	 * The target names specified on the command line. Used to resolve
7849f45a3c8SSimon J. Gerraty 	 * .if make(...) statements.
7859f45a3c8SSimon J. Gerraty 	 */
78606b9b3e0SSimon J. Gerraty 	StringList create;
787956e45f6SSimon J. Gerraty 
788*954401e6SSimon J. Gerraty 	/*
789*954401e6SSimon J. Gerraty 	 * Randomize the order in which the targets from toBeMade are made,
790*954401e6SSimon J. Gerraty 	 * to catch undeclared dependencies.
791*954401e6SSimon J. Gerraty 	 */
792*954401e6SSimon J. Gerraty 	bool randomizeTargets;
793956e45f6SSimon J. Gerraty } CmdOpts;
794956e45f6SSimon J. Gerraty 
795956e45f6SSimon J. Gerraty extern CmdOpts opts;
7963955d011SMarcel Moolenaar 
7979f45a3c8SSimon J. Gerraty /* arch.c */
7989f45a3c8SSimon J. Gerraty void Arch_Init(void);
7999f45a3c8SSimon J. Gerraty void Arch_End(void);
8003955d011SMarcel Moolenaar 
8019f45a3c8SSimon J. Gerraty bool Arch_ParseArchive(char **, GNodeList *, GNode *);
8029f45a3c8SSimon J. Gerraty void Arch_Touch(GNode *);
8039f45a3c8SSimon J. Gerraty void Arch_TouchLib(GNode *);
8049f45a3c8SSimon J. Gerraty void Arch_UpdateMTime(GNode *gn);
8059f45a3c8SSimon J. Gerraty void Arch_UpdateMemberMTime(GNode *gn);
8069f45a3c8SSimon J. Gerraty void Arch_FindLib(GNode *, SearchPath *);
8079f45a3c8SSimon J. Gerraty bool Arch_LibOODate(GNode *) MAKE_ATTR_USE;
8089f45a3c8SSimon J. Gerraty bool Arch_IsLib(GNode *) MAKE_ATTR_USE;
8099f45a3c8SSimon J. Gerraty 
8109f45a3c8SSimon J. Gerraty /* compat.c */
8119f45a3c8SSimon J. Gerraty bool Compat_RunCommand(const char *, GNode *, StringListNode *);
812*954401e6SSimon J. Gerraty void Compat_MakeAll(GNodeList *);
8139f45a3c8SSimon J. Gerraty void Compat_Make(GNode *, GNode *);
8149f45a3c8SSimon J. Gerraty 
8159f45a3c8SSimon J. Gerraty /* cond.c */
8169f45a3c8SSimon J. Gerraty CondResult Cond_EvalCondition(const char *) MAKE_ATTR_USE;
8179f45a3c8SSimon J. Gerraty CondResult Cond_EvalLine(const char *) MAKE_ATTR_USE;
8189f45a3c8SSimon J. Gerraty void Cond_restore_depth(unsigned int);
8199f45a3c8SSimon J. Gerraty unsigned int Cond_save_depth(void) MAKE_ATTR_USE;
8209f45a3c8SSimon J. Gerraty 
8219f45a3c8SSimon J. Gerraty /* dir.c; see also dir.h */
8229f45a3c8SSimon J. Gerraty 
8239f45a3c8SSimon J. Gerraty MAKE_INLINE const char * MAKE_ATTR_USE
8249f45a3c8SSimon J. Gerraty str_basename(const char *pathname)
8259f45a3c8SSimon J. Gerraty {
8269f45a3c8SSimon J. Gerraty 	const char *lastSlash = strrchr(pathname, '/');
8279f45a3c8SSimon J. Gerraty 	return lastSlash != NULL ? lastSlash + 1 : pathname;
8289f45a3c8SSimon J. Gerraty }
8299f45a3c8SSimon J. Gerraty 
8309f45a3c8SSimon J. Gerraty MAKE_INLINE SearchPath * MAKE_ATTR_USE
8319f45a3c8SSimon J. Gerraty SearchPath_New(void)
8329f45a3c8SSimon J. Gerraty {
8339f45a3c8SSimon J. Gerraty 	SearchPath *path = bmake_malloc(sizeof *path);
8349f45a3c8SSimon J. Gerraty 	Lst_Init(&path->dirs);
8359f45a3c8SSimon J. Gerraty 	return path;
8369f45a3c8SSimon J. Gerraty }
8379f45a3c8SSimon J. Gerraty 
8389f45a3c8SSimon J. Gerraty void SearchPath_Free(SearchPath *);
8399f45a3c8SSimon J. Gerraty 
8409f45a3c8SSimon J. Gerraty /* for.c */
8419f45a3c8SSimon J. Gerraty struct ForLoop;
8429f45a3c8SSimon J. Gerraty int For_Eval(const char *) MAKE_ATTR_USE;
8439f45a3c8SSimon J. Gerraty bool For_Accum(const char *, int *) MAKE_ATTR_USE;
8449f45a3c8SSimon J. Gerraty void For_Run(unsigned, unsigned);
8459f45a3c8SSimon J. Gerraty bool For_NextIteration(struct ForLoop *, Buffer *);
8469f45a3c8SSimon J. Gerraty char *ForLoop_Details(struct ForLoop *);
8479f45a3c8SSimon J. Gerraty void ForLoop_Free(struct ForLoop *);
8489f45a3c8SSimon J. Gerraty 
8499f45a3c8SSimon J. Gerraty /* job.c */
8509f45a3c8SSimon J. Gerraty void JobReapChild(pid_t, int, bool);
8519f45a3c8SSimon J. Gerraty 
8529f45a3c8SSimon J. Gerraty /* main.c */
8539f45a3c8SSimon J. Gerraty void Main_ParseArgLine(const char *);
8549f45a3c8SSimon J. Gerraty char *Cmd_Exec(const char *, char **) MAKE_ATTR_USE;
8559f45a3c8SSimon J. Gerraty void Error(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
8569f45a3c8SSimon J. Gerraty void Fatal(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;
8579f45a3c8SSimon J. Gerraty void Punt(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;
8589f45a3c8SSimon J. Gerraty void DieHorribly(void) MAKE_ATTR_DEAD;
8599f45a3c8SSimon J. Gerraty void Finish(int) MAKE_ATTR_DEAD;
8609f45a3c8SSimon J. Gerraty bool unlink_file(const char *) MAKE_ATTR_USE;
8619f45a3c8SSimon J. Gerraty void execDie(const char *, const char *);
8629f45a3c8SSimon J. Gerraty char *getTmpdir(void) MAKE_ATTR_USE;
8639f45a3c8SSimon J. Gerraty bool ParseBoolean(const char *, bool) MAKE_ATTR_USE;
8649f45a3c8SSimon J. Gerraty const char *cached_realpath(const char *, char *);
8659f45a3c8SSimon J. Gerraty bool GetBooleanExpr(const char *, bool);
8669f45a3c8SSimon J. Gerraty 
8679f45a3c8SSimon J. Gerraty /* parse.c */
8689f45a3c8SSimon J. Gerraty void Parse_Init(void);
8699f45a3c8SSimon J. Gerraty void Parse_End(void);
8709f45a3c8SSimon J. Gerraty 
871*954401e6SSimon J. Gerraty void PrintLocation(FILE *, bool, const GNode *);
8729f45a3c8SSimon J. Gerraty void PrintStackTrace(bool);
8739f45a3c8SSimon J. Gerraty void Parse_Error(ParseErrorLevel, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
8749f45a3c8SSimon J. Gerraty bool Parse_VarAssign(const char *, bool, GNode *) MAKE_ATTR_USE;
8759f45a3c8SSimon J. Gerraty void Parse_AddIncludeDir(const char *);
8769f45a3c8SSimon J. Gerraty void Parse_File(const char *, int);
8779f45a3c8SSimon J. Gerraty void Parse_PushInput(const char *, unsigned, unsigned, Buffer,
8789f45a3c8SSimon J. Gerraty 		     struct ForLoop *);
8799f45a3c8SSimon J. Gerraty void Parse_MainName(GNodeList *);
8809f45a3c8SSimon J. Gerraty int Parse_NumErrors(void) MAKE_ATTR_USE;
8819f45a3c8SSimon J. Gerraty 
8829f45a3c8SSimon J. Gerraty 
8839f45a3c8SSimon J. Gerraty /* suff.c */
8849f45a3c8SSimon J. Gerraty void Suff_Init(void);
8859f45a3c8SSimon J. Gerraty void Suff_End(void);
8869f45a3c8SSimon J. Gerraty 
8879f45a3c8SSimon J. Gerraty void Suff_ClearSuffixes(void);
8889f45a3c8SSimon J. Gerraty bool Suff_IsTransform(const char *) MAKE_ATTR_USE;
8899f45a3c8SSimon J. Gerraty GNode *Suff_AddTransform(const char *);
8909f45a3c8SSimon J. Gerraty void Suff_EndTransform(GNode *);
8919f45a3c8SSimon J. Gerraty void Suff_AddSuffix(const char *);
8929f45a3c8SSimon J. Gerraty SearchPath *Suff_GetPath(const char *) MAKE_ATTR_USE;
8939f45a3c8SSimon J. Gerraty void Suff_ExtendPaths(void);
8949f45a3c8SSimon J. Gerraty void Suff_AddInclude(const char *);
8959f45a3c8SSimon J. Gerraty void Suff_AddLib(const char *);
8969f45a3c8SSimon J. Gerraty void Suff_FindDeps(GNode *);
8979f45a3c8SSimon J. Gerraty SearchPath *Suff_FindPath(GNode *) MAKE_ATTR_USE;
8989f45a3c8SSimon J. Gerraty void Suff_SetNull(const char *);
8999f45a3c8SSimon J. Gerraty void Suff_PrintAll(void);
9009f45a3c8SSimon J. Gerraty char *Suff_NamesStr(void) MAKE_ATTR_USE;
9019f45a3c8SSimon J. Gerraty 
9029f45a3c8SSimon J. Gerraty /* targ.c */
9039f45a3c8SSimon J. Gerraty void Targ_Init(void);
9049f45a3c8SSimon J. Gerraty void Targ_End(void);
9059f45a3c8SSimon J. Gerraty 
9069f45a3c8SSimon J. Gerraty void Targ_Stats(void);
9079f45a3c8SSimon J. Gerraty GNodeList *Targ_List(void) MAKE_ATTR_USE;
9089f45a3c8SSimon J. Gerraty GNode *GNode_New(const char *) MAKE_ATTR_USE;
9099f45a3c8SSimon J. Gerraty GNode *Targ_FindNode(const char *) MAKE_ATTR_USE;
9109f45a3c8SSimon J. Gerraty GNode *Targ_GetNode(const char *) MAKE_ATTR_USE;
9119f45a3c8SSimon J. Gerraty GNode *Targ_NewInternalNode(const char *) MAKE_ATTR_USE;
9129f45a3c8SSimon J. Gerraty GNode *Targ_GetEndNode(void);
9139f45a3c8SSimon J. Gerraty void Targ_FindList(GNodeList *, StringList *);
9149f45a3c8SSimon J. Gerraty void Targ_PrintCmds(GNode *);
9159f45a3c8SSimon J. Gerraty void Targ_PrintNode(GNode *, int);
9169f45a3c8SSimon J. Gerraty void Targ_PrintNodes(GNodeList *, int);
9179f45a3c8SSimon J. Gerraty const char *Targ_FmtTime(time_t) MAKE_ATTR_USE;
9189f45a3c8SSimon J. Gerraty void Targ_PrintType(GNodeType);
9199f45a3c8SSimon J. Gerraty void Targ_PrintGraph(int);
9209f45a3c8SSimon J. Gerraty void Targ_Propagate(void);
9219f45a3c8SSimon J. Gerraty const char *GNodeMade_Name(GNodeMade) MAKE_ATTR_USE;
9229f45a3c8SSimon J. Gerraty 
9239f45a3c8SSimon J. Gerraty /* var.c */
9249f45a3c8SSimon J. Gerraty void Var_Init(void);
9259f45a3c8SSimon J. Gerraty void Var_End(void);
9269f45a3c8SSimon J. Gerraty 
9279f45a3c8SSimon J. Gerraty typedef enum VarEvalMode {
9289f45a3c8SSimon J. Gerraty 
9299f45a3c8SSimon J. Gerraty 	/*
9309f45a3c8SSimon J. Gerraty 	 * Only parse the expression but don't evaluate any part of it.
9319f45a3c8SSimon J. Gerraty 	 *
9329f45a3c8SSimon J. Gerraty 	 * TODO: Document what Var_Parse and Var_Subst return in this mode.
9339f45a3c8SSimon J. Gerraty 	 *  As of 2021-03-15, they return unspecified, inconsistent results.
9349f45a3c8SSimon J. Gerraty 	 */
9359f45a3c8SSimon J. Gerraty 	VARE_PARSE_ONLY,
9369f45a3c8SSimon J. Gerraty 
9379f45a3c8SSimon J. Gerraty 	/* Parse and evaluate the expression. */
9389f45a3c8SSimon J. Gerraty 	VARE_WANTRES,
9399f45a3c8SSimon J. Gerraty 
9409f45a3c8SSimon J. Gerraty 	/*
9419f45a3c8SSimon J. Gerraty 	 * Parse and evaluate the expression.  It is an error if a
9429f45a3c8SSimon J. Gerraty 	 * subexpression evaluates to undefined.
9439f45a3c8SSimon J. Gerraty 	 */
9449f45a3c8SSimon J. Gerraty 	VARE_UNDEFERR,
9459f45a3c8SSimon J. Gerraty 
9469f45a3c8SSimon J. Gerraty 	/*
9479f45a3c8SSimon J. Gerraty 	 * Parse and evaluate the expression.  Keep '$$' as '$$' instead of
9489f45a3c8SSimon J. Gerraty 	 * reducing it to a single '$'.  Subexpressions that evaluate to
9499f45a3c8SSimon J. Gerraty 	 * undefined expand to an empty string.
9509f45a3c8SSimon J. Gerraty 	 *
9519f45a3c8SSimon J. Gerraty 	 * Used in variable assignments using the ':=' operator.  It allows
9529f45a3c8SSimon J. Gerraty 	 * multiple such assignments to be chained without accidentally
9539f45a3c8SSimon J. Gerraty 	 * expanding '$$file' to '$file' in the first assignment and
9549f45a3c8SSimon J. Gerraty 	 * interpreting it as '${f}' followed by 'ile' in the next assignment.
9559f45a3c8SSimon J. Gerraty 	 */
9569f45a3c8SSimon J. Gerraty 	VARE_EVAL_KEEP_DOLLAR,
9579f45a3c8SSimon J. Gerraty 
9589f45a3c8SSimon J. Gerraty 	/*
9599f45a3c8SSimon J. Gerraty 	 * Parse and evaluate the expression.  Keep undefined variables as-is
9609f45a3c8SSimon J. Gerraty 	 * instead of expanding them to an empty string.
9619f45a3c8SSimon J. Gerraty 	 *
9629f45a3c8SSimon J. Gerraty 	 * Example for a ':=' assignment:
9639f45a3c8SSimon J. Gerraty 	 *	CFLAGS = $(.INCLUDES)
9649f45a3c8SSimon J. Gerraty 	 *	CFLAGS := -I.. $(CFLAGS)
9659f45a3c8SSimon J. Gerraty 	 *	# If .INCLUDES (an undocumented special variable, by the
9669f45a3c8SSimon J. Gerraty 	 *	# way) is still undefined, the updated CFLAGS becomes
9679f45a3c8SSimon J. Gerraty 	 *	# "-I.. $(.INCLUDES)".
9689f45a3c8SSimon J. Gerraty 	 */
9699f45a3c8SSimon J. Gerraty 	VARE_EVAL_KEEP_UNDEF,
9709f45a3c8SSimon J. Gerraty 
9719f45a3c8SSimon J. Gerraty 	/*
9729f45a3c8SSimon J. Gerraty 	 * Parse and evaluate the expression.  Keep '$$' as '$$' and preserve
9739f45a3c8SSimon J. Gerraty 	 * undefined subexpressions.
9749f45a3c8SSimon J. Gerraty 	 */
9759f45a3c8SSimon J. Gerraty 	VARE_KEEP_DOLLAR_UNDEF
9769f45a3c8SSimon J. Gerraty } VarEvalMode;
9779f45a3c8SSimon J. Gerraty 
9789f45a3c8SSimon J. Gerraty typedef enum VarSetFlags {
9799f45a3c8SSimon J. Gerraty 	VAR_SET_NONE		= 0,
9809f45a3c8SSimon J. Gerraty 
9819f45a3c8SSimon J. Gerraty 	/* do not export */
9829f45a3c8SSimon J. Gerraty 	VAR_SET_NO_EXPORT	= 1 << 0,
9839f45a3c8SSimon J. Gerraty 
9849f45a3c8SSimon J. Gerraty 	/*
9859f45a3c8SSimon J. Gerraty 	 * Make the variable read-only. No further modification is possible,
9869f45a3c8SSimon J. Gerraty 	 * except for another call to Var_Set with the same flag.
9879f45a3c8SSimon J. Gerraty 	 */
9889f45a3c8SSimon J. Gerraty 	VAR_SET_READONLY	= 1 << 1
9899f45a3c8SSimon J. Gerraty } VarSetFlags;
9909f45a3c8SSimon J. Gerraty 
9919f45a3c8SSimon J. Gerraty /* The state of error handling returned by Var_Parse. */
9929f45a3c8SSimon J. Gerraty typedef enum VarParseResult {
9939f45a3c8SSimon J. Gerraty 
9949f45a3c8SSimon J. Gerraty 	/* Both parsing and evaluation succeeded. */
9959f45a3c8SSimon J. Gerraty 	VPR_OK,
9969f45a3c8SSimon J. Gerraty 
9979f45a3c8SSimon J. Gerraty 	/* Parsing or evaluating failed, with an error message. */
9989f45a3c8SSimon J. Gerraty 	VPR_ERR,
9999f45a3c8SSimon J. Gerraty 
10009f45a3c8SSimon J. Gerraty 	/*
10019f45a3c8SSimon J. Gerraty 	 * Parsing succeeded, undefined expressions are allowed and the
10029f45a3c8SSimon J. Gerraty 	 * expression was still undefined after applying all modifiers.
10039f45a3c8SSimon J. Gerraty 	 * No error message is printed in this case.
10049f45a3c8SSimon J. Gerraty 	 *
10059f45a3c8SSimon J. Gerraty 	 * Some callers handle this case differently, so return this
10069f45a3c8SSimon J. Gerraty 	 * information to them, for now.
10079f45a3c8SSimon J. Gerraty 	 *
10089f45a3c8SSimon J. Gerraty 	 * TODO: Instead of having this special return value, rather ensure
10099f45a3c8SSimon J. Gerraty 	 *  that VARE_EVAL_KEEP_UNDEF is processed properly.
10109f45a3c8SSimon J. Gerraty 	 */
10119f45a3c8SSimon J. Gerraty 	VPR_UNDEF
10129f45a3c8SSimon J. Gerraty 
10139f45a3c8SSimon J. Gerraty } VarParseResult;
10149f45a3c8SSimon J. Gerraty 
10159f45a3c8SSimon J. Gerraty typedef enum VarExportMode {
10169f45a3c8SSimon J. Gerraty 	/* .export-env */
10179f45a3c8SSimon J. Gerraty 	VEM_ENV,
10189f45a3c8SSimon J. Gerraty 	/* .export: Initial export or update an already exported variable. */
10199f45a3c8SSimon J. Gerraty 	VEM_PLAIN,
10209f45a3c8SSimon J. Gerraty 	/* .export-literal: Do not expand the variable value. */
10219f45a3c8SSimon J. Gerraty 	VEM_LITERAL
10229f45a3c8SSimon J. Gerraty } VarExportMode;
10239f45a3c8SSimon J. Gerraty 
10249f45a3c8SSimon J. Gerraty void Var_Delete(GNode *, const char *);
10259f45a3c8SSimon J. Gerraty void Var_Undef(const char *);
10269f45a3c8SSimon J. Gerraty void Var_Set(GNode *, const char *, const char *);
10279f45a3c8SSimon J. Gerraty void Var_SetExpand(GNode *, const char *, const char *);
10289f45a3c8SSimon J. Gerraty void Var_SetWithFlags(GNode *, const char *, const char *, VarSetFlags);
10299f45a3c8SSimon J. Gerraty void Var_Append(GNode *, const char *, const char *);
10309f45a3c8SSimon J. Gerraty void Var_AppendExpand(GNode *, const char *, const char *);
10319f45a3c8SSimon J. Gerraty bool Var_Exists(GNode *, const char *) MAKE_ATTR_USE;
10329f45a3c8SSimon J. Gerraty bool Var_ExistsExpand(GNode *, const char *) MAKE_ATTR_USE;
10339f45a3c8SSimon J. Gerraty FStr Var_Value(GNode *, const char *) MAKE_ATTR_USE;
10349f45a3c8SSimon J. Gerraty const char *GNode_ValueDirect(GNode *, const char *) MAKE_ATTR_USE;
10359f45a3c8SSimon J. Gerraty VarParseResult Var_Parse(const char **, GNode *, VarEvalMode, FStr *);
10369f45a3c8SSimon J. Gerraty VarParseResult Var_Subst(const char *, GNode *, VarEvalMode, char **);
10379f45a3c8SSimon J. Gerraty void Var_Expand(FStr *, GNode *, VarEvalMode);
10389f45a3c8SSimon J. Gerraty void Var_Stats(void);
10399f45a3c8SSimon J. Gerraty void Var_Dump(GNode *);
10409f45a3c8SSimon J. Gerraty void Var_ReexportVars(void);
10419f45a3c8SSimon J. Gerraty void Var_Export(VarExportMode, const char *);
10429f45a3c8SSimon J. Gerraty void Var_ExportVars(const char *);
10439f45a3c8SSimon J. Gerraty void Var_UnExport(bool, const char *);
10449f45a3c8SSimon J. Gerraty 
10459f45a3c8SSimon J. Gerraty void Global_Set(const char *, const char *);
10469f45a3c8SSimon J. Gerraty void Global_Append(const char *, const char *);
10479f45a3c8SSimon J. Gerraty void Global_Delete(const char *);
10489f45a3c8SSimon J. Gerraty 
10499f45a3c8SSimon J. Gerraty /* util.c */
10509f45a3c8SSimon J. Gerraty typedef void (*SignalProc)(int);
10519f45a3c8SSimon J. Gerraty SignalProc bmake_signal(int, SignalProc);
10529f45a3c8SSimon J. Gerraty 
10539f45a3c8SSimon J. Gerraty /* make.c */
1054e2eeea75SSimon J. Gerraty void GNode_UpdateYoungestChild(GNode *, GNode *);
10559f45a3c8SSimon J. Gerraty bool GNode_IsOODate(GNode *) MAKE_ATTR_USE;
1056956e45f6SSimon J. Gerraty void Make_ExpandUse(GNodeList *);
10579f45a3c8SSimon J. Gerraty time_t Make_Recheck(GNode *) MAKE_ATTR_USE;
10583955d011SMarcel Moolenaar void Make_HandleUse(GNode *, GNode *);
10593955d011SMarcel Moolenaar void Make_Update(GNode *);
1060b0c40a00SSimon J. Gerraty void GNode_SetLocalVars(GNode *);
1061b0c40a00SSimon J. Gerraty bool Make_Run(GNodeList *);
10629f45a3c8SSimon J. Gerraty bool shouldDieQuietly(GNode *, int) MAKE_ATTR_USE;
10633955d011SMarcel Moolenaar void PrintOnError(GNode *, const char *);
1064b0c40a00SSimon J. Gerraty void Main_ExportMAKEFLAGS(bool);
1065b0c40a00SSimon J. Gerraty bool Main_SetObjdir(bool, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
10669f45a3c8SSimon J. Gerraty int mkTempFile(const char *, char *, size_t) MAKE_ATTR_USE;
1067e2eeea75SSimon J. Gerraty int str2Lst_Append(StringList *, char *);
10682c3632d1SSimon J. Gerraty void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *);
10699f45a3c8SSimon J. Gerraty bool GNode_ShouldExecute(GNode *gn) MAKE_ATTR_USE;
1070956e45f6SSimon J. Gerraty 
1071956e45f6SSimon J. Gerraty /* See if the node was seen on the left-hand side of a dependency operator. */
10729f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
1073956e45f6SSimon J. Gerraty GNode_IsTarget(const GNode *gn)
1074956e45f6SSimon J. Gerraty {
107512904384SSimon J. Gerraty 	return (gn->type & OP_OPMASK) != OP_NONE;
1076956e45f6SSimon J. Gerraty }
1077956e45f6SSimon J. Gerraty 
10789f45a3c8SSimon J. Gerraty MAKE_INLINE const char * MAKE_ATTR_USE
1079956e45f6SSimon J. Gerraty GNode_Path(const GNode *gn)
1080956e45f6SSimon J. Gerraty {
1081956e45f6SSimon J. Gerraty 	return gn->path != NULL ? gn->path : gn->name;
1082956e45f6SSimon J. Gerraty }
1083956e45f6SSimon J. Gerraty 
10849f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
108506b9b3e0SSimon J. Gerraty GNode_IsWaitingFor(const GNode *gn)
108606b9b3e0SSimon J. Gerraty {
108712904384SSimon J. Gerraty 	return gn->flags.remake && gn->made <= REQUESTED;
108806b9b3e0SSimon J. Gerraty }
108906b9b3e0SSimon J. Gerraty 
10909f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
109106b9b3e0SSimon J. Gerraty GNode_IsReady(const GNode *gn)
109206b9b3e0SSimon J. Gerraty {
109306b9b3e0SSimon J. Gerraty 	return gn->made > DEFERRED;
109406b9b3e0SSimon J. Gerraty }
109506b9b3e0SSimon J. Gerraty 
10969f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
109706b9b3e0SSimon J. Gerraty GNode_IsDone(const GNode *gn)
109806b9b3e0SSimon J. Gerraty {
109906b9b3e0SSimon J. Gerraty 	return gn->made >= MADE;
110006b9b3e0SSimon J. Gerraty }
110106b9b3e0SSimon J. Gerraty 
11029f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
110306b9b3e0SSimon J. Gerraty GNode_IsError(const GNode *gn)
110406b9b3e0SSimon J. Gerraty {
110506b9b3e0SSimon J. Gerraty 	return gn->made == ERROR || gn->made == ABORTED;
110606b9b3e0SSimon J. Gerraty }
110706b9b3e0SSimon J. Gerraty 
11089f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
11099f45a3c8SSimon J. Gerraty GNode_IsMainCandidate(const GNode *gn)
11109f45a3c8SSimon J. Gerraty {
11119f45a3c8SSimon J. Gerraty 	return (gn->type & (OP_NOTMAIN | OP_USE | OP_USEBEFORE |
11129f45a3c8SSimon J. Gerraty 			    OP_EXEC | OP_TRANSFORM)) == 0;
11139f45a3c8SSimon J. Gerraty }
11149f45a3c8SSimon J. Gerraty 
11159f45a3c8SSimon J. Gerraty /* Return whether the target file should be preserved on interrupt. */
11169f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
11179f45a3c8SSimon J. Gerraty GNode_IsPrecious(const GNode *gn)
11189f45a3c8SSimon J. Gerraty {
11199f45a3c8SSimon J. Gerraty 	/* XXX: Why are '::' targets precious? */
11209f45a3c8SSimon J. Gerraty 	return allPrecious || gn->type & (OP_PRECIOUS | OP_DOUBLEDEP);
11219f45a3c8SSimon J. Gerraty }
11229f45a3c8SSimon J. Gerraty 
11239f45a3c8SSimon J. Gerraty MAKE_INLINE const char * MAKE_ATTR_USE
1124dba7b0efSSimon J. Gerraty GNode_VarTarget(GNode *gn) { return GNode_ValueDirect(gn, TARGET); }
11259f45a3c8SSimon J. Gerraty MAKE_INLINE const char * MAKE_ATTR_USE
1126dba7b0efSSimon J. Gerraty GNode_VarOodate(GNode *gn) { return GNode_ValueDirect(gn, OODATE); }
11279f45a3c8SSimon J. Gerraty MAKE_INLINE const char * MAKE_ATTR_USE
1128dba7b0efSSimon J. Gerraty GNode_VarAllsrc(GNode *gn) { return GNode_ValueDirect(gn, ALLSRC); }
11299f45a3c8SSimon J. Gerraty MAKE_INLINE const char * MAKE_ATTR_USE
1130dba7b0efSSimon J. Gerraty GNode_VarImpsrc(GNode *gn) { return GNode_ValueDirect(gn, IMPSRC); }
11319f45a3c8SSimon J. Gerraty MAKE_INLINE const char * MAKE_ATTR_USE
1132dba7b0efSSimon J. Gerraty GNode_VarPrefix(GNode *gn) { return GNode_ValueDirect(gn, PREFIX); }
11339f45a3c8SSimon J. Gerraty MAKE_INLINE const char * MAKE_ATTR_USE
1134dba7b0efSSimon J. Gerraty GNode_VarArchive(GNode *gn) { return GNode_ValueDirect(gn, ARCHIVE); }
11359f45a3c8SSimon J. Gerraty MAKE_INLINE const char * MAKE_ATTR_USE
1136dba7b0efSSimon J. Gerraty GNode_VarMember(GNode *gn) { return GNode_ValueDirect(gn, MEMBER); }
11373955d011SMarcel Moolenaar 
11389f45a3c8SSimon J. Gerraty MAKE_INLINE void * MAKE_ATTR_USE
113912904384SSimon J. Gerraty UNCONST(const void *ptr)
114012904384SSimon J. Gerraty {
114112904384SSimon J. Gerraty 	void *ret;
114212904384SSimon J. Gerraty 	memcpy(&ret, &ptr, sizeof(ret));
114312904384SSimon J. Gerraty 	return ret;
114412904384SSimon J. Gerraty }
11453955d011SMarcel Moolenaar 
11464c620fe5SSimon J. Gerraty /* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */
11474c620fe5SSimon J. Gerraty #ifdef HAVE_LIMITS_H
11484c620fe5SSimon J. Gerraty #include <limits.h>
11494c620fe5SSimon J. Gerraty #endif
11500dede8b0SSimon J. Gerraty #ifndef MAXPATHLEN
11510dede8b0SSimon J. Gerraty #define MAXPATHLEN	BMAKE_PATH_MAX
11520dede8b0SSimon J. Gerraty #endif
11534c620fe5SSimon J. Gerraty #ifndef PATH_MAX
11544c620fe5SSimon J. Gerraty #define PATH_MAX	MAXPATHLEN
11554c620fe5SSimon J. Gerraty #endif
11560dede8b0SSimon J. Gerraty 
1157c7019bf7SSimon J. Gerraty #if defined(SYSV)
1158c7019bf7SSimon J. Gerraty #define KILLPG(pid, sig) kill(-(pid), (sig))
1159c7019bf7SSimon J. Gerraty #else
1160c7019bf7SSimon J. Gerraty #define KILLPG(pid, sig) killpg((pid), (sig))
1161c7019bf7SSimon J. Gerraty #endif
1162c7019bf7SSimon J. Gerraty 
11639f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
1164e2eeea75SSimon J. Gerraty ch_isalnum(char ch) { return isalnum((unsigned char)ch) != 0; }
11659f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
1166e2eeea75SSimon J. Gerraty ch_isalpha(char ch) { return isalpha((unsigned char)ch) != 0; }
11679f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
1168e2eeea75SSimon J. Gerraty ch_isdigit(char ch) { return isdigit((unsigned char)ch) != 0; }
11699f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
11709f45a3c8SSimon J. Gerraty ch_islower(char ch) { return islower((unsigned char)ch) != 0; }
11719f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
1172e2eeea75SSimon J. Gerraty ch_isspace(char ch) { return isspace((unsigned char)ch) != 0; }
11739f45a3c8SSimon J. Gerraty MAKE_INLINE bool MAKE_ATTR_USE
1174e2eeea75SSimon J. Gerraty ch_isupper(char ch) { return isupper((unsigned char)ch) != 0; }
11759f45a3c8SSimon J. Gerraty MAKE_INLINE char MAKE_ATTR_USE
1176e2eeea75SSimon J. Gerraty ch_tolower(char ch) { return (char)tolower((unsigned char)ch); }
11779f45a3c8SSimon J. Gerraty MAKE_INLINE char MAKE_ATTR_USE
1178e2eeea75SSimon J. Gerraty ch_toupper(char ch) { return (char)toupper((unsigned char)ch); }
1179956e45f6SSimon J. Gerraty 
1180e2eeea75SSimon J. Gerraty MAKE_INLINE void
1181956e45f6SSimon J. Gerraty cpp_skip_whitespace(const char **pp)
1182956e45f6SSimon J. Gerraty {
1183956e45f6SSimon J. Gerraty 	while (ch_isspace(**pp))
1184956e45f6SSimon J. Gerraty 		(*pp)++;
1185956e45f6SSimon J. Gerraty }
1186956e45f6SSimon J. Gerraty 
1187e2eeea75SSimon J. Gerraty MAKE_INLINE void
1188e2eeea75SSimon J. Gerraty cpp_skip_hspace(const char **pp)
1189e2eeea75SSimon J. Gerraty {
1190e2eeea75SSimon J. Gerraty 	while (**pp == ' ' || **pp == '\t')
1191e2eeea75SSimon J. Gerraty 		(*pp)++;
1192e2eeea75SSimon J. Gerraty }
1193e2eeea75SSimon J. Gerraty 
11949f45a3c8SSimon J. Gerraty MAKE_INLINE bool
11959f45a3c8SSimon J. Gerraty cpp_skip_string(const char **pp, const char *s)
11969f45a3c8SSimon J. Gerraty {
11979f45a3c8SSimon J. Gerraty 	const char *p = *pp;
11989f45a3c8SSimon J. Gerraty 	while (*p == *s && *s != '\0')
11999f45a3c8SSimon J. Gerraty 		p++, s++;
12009f45a3c8SSimon J. Gerraty 	if (*s == '\0')
12019f45a3c8SSimon J. Gerraty 		*pp = p;
12029f45a3c8SSimon J. Gerraty 	return *s == '\0';
12039f45a3c8SSimon J. Gerraty }
12049f45a3c8SSimon J. Gerraty 
1205e2eeea75SSimon J. Gerraty MAKE_INLINE void
1206956e45f6SSimon J. Gerraty pp_skip_whitespace(char **pp)
1207956e45f6SSimon J. Gerraty {
1208956e45f6SSimon J. Gerraty 	while (ch_isspace(**pp))
1209956e45f6SSimon J. Gerraty 		(*pp)++;
1210956e45f6SSimon J. Gerraty }
1211956e45f6SSimon J. Gerraty 
1212e2eeea75SSimon J. Gerraty MAKE_INLINE void
1213e2eeea75SSimon J. Gerraty pp_skip_hspace(char **pp)
1214e2eeea75SSimon J. Gerraty {
1215e2eeea75SSimon J. Gerraty 	while (**pp == ' ' || **pp == '\t')
1216e2eeea75SSimon J. Gerraty 		(*pp)++;
1217e2eeea75SSimon J. Gerraty }
1218e2eeea75SSimon J. Gerraty 
121906b9b3e0SSimon J. Gerraty #if defined(lint)
122006b9b3e0SSimon J. Gerraty # define MAKE_RCSID(id) extern void do_not_define_rcsid(void)
122106b9b3e0SSimon J. Gerraty #elif defined(MAKE_NATIVE)
1222956e45f6SSimon J. Gerraty # include <sys/cdefs.h>
122312904384SSimon J. Gerraty # ifndef __IDSTRING
122412904384SSimon J. Gerraty #   define __IDSTRING(name,string) \
122512904384SSimon J. Gerraty 	static const char name[] MAKE_ATTR_UNUSED = string
122612904384SSimon J. Gerraty # endif
122712904384SSimon J. Gerraty # ifndef __RCSID
122812904384SSimon J. Gerraty #   define __RCSID(s) __IDSTRING(rcsid,s)
122912904384SSimon J. Gerraty # endif
123012904384SSimon J. Gerraty # ifndef __COPYRIGHT
123112904384SSimon J. Gerraty #   define __COPYRIGHT(s) __IDSTRING(copyright,s)
123212904384SSimon J. Gerraty # endif
1233956e45f6SSimon J. Gerraty # define MAKE_RCSID(id) __RCSID(id)
123406b9b3e0SSimon J. Gerraty #elif defined(MAKE_ALL_IN_ONE) && defined(__COUNTER__)
123506b9b3e0SSimon J. Gerraty # define MAKE_RCSID_CONCAT(x, y) CONCAT(x, y)
123606b9b3e0SSimon J. Gerraty # define MAKE_RCSID(id) static volatile char \
123706b9b3e0SSimon J. Gerraty 	MAKE_RCSID_CONCAT(rcsid_, __COUNTER__)[] = id
123806b9b3e0SSimon J. Gerraty #elif defined(MAKE_ALL_IN_ONE)
123906b9b3e0SSimon J. Gerraty # define MAKE_RCSID(id) extern void do_not_define_rcsid(void)
1240956e45f6SSimon J. Gerraty #else
1241956e45f6SSimon J. Gerraty # define MAKE_RCSID(id) static volatile char rcsid[] = id
1242956e45f6SSimon J. Gerraty #endif
1243956e45f6SSimon J. Gerraty 
12449f45a3c8SSimon J. Gerraty #endif
1245