Date: Wed, 17 Apr 2002 23:50:03 -0700 (PDT) From: "Tim J. Robbins" <tim@robbins.dropbear.id.au> To: freebsd-standards@FreeBSD.org Subject: Re: bin/11114: make(1) does not work as documented with .POSIX: target Message-ID: <200204180650.g3I6o3A00572@freefall.freebsd.org>
index | next in thread | raw e-mail
The following reply was made to PR bin/11114; it has been noted by GNATS.
From: "Tim J. Robbins" <tim@robbins.dropbear.id.au>
To: Jens Schweikhardt <schweikh@schweikhardt.net>
Cc: bug-followup@FreeBSD.ORG, cjclark@alum.mit.edu,
jmallett@FreeBSD.ORG
Subject: Re: bin/11114: make(1) does not work as documented with .POSIX: target
Date: Thu, 18 Apr 2002 15:50:09 +1000
Please try this patch & let me know whether it corrects the problems
with the special .POSIX target. It is against HEAD, to try it on a 4.x
release you will need to edit str.c and remove __DECONST macro usage.
I realise it's not a particularly clean solution, and I'd be interested
to hear how it could be done better.
Index: main.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/main.c,v
retrieving revision 1.56
diff -u -r1.56 main.c
--- main.c 2002/04/13 12:20:51 1.56
+++ main.c 2002/04/18 06:25:35
@@ -113,7 +113,7 @@
GNode *DEFAULT; /* .DEFAULT node */
Boolean allPrecious; /* .PRECIOUS given on line by itself */
-static Boolean noBuiltins; /* -r flag */
+Boolean noBuiltins; /* -r flag */
static Lst makefiles; /* ordered list of makefiles to read */
static Boolean printVars; /* print value of one or more vars */
static Boolean expandVars; /* fully expand printed variables */
@@ -138,7 +138,6 @@
static void MainParseArgs(int, char **);
char * chdir_verify_path(char *, char *);
-static int ReadMakefile(void *, void *);
static void usage(void);
static char *curdir; /* startup directory */
@@ -728,22 +727,9 @@
}
/*
- * Read in the built-in rules first, followed by the specified
- * makefile, if it was (makefile != (char *) NULL), or the default
- * Makefile and makefile, in that order, if it wasn't.
+ * Read the specified makefile, if it was (makefile != (char *) NULL),
+ * or the default Makefile and makefile, in that order, if it wasn't.
*/
- if (!noBuiltins) {
- LstNode ln;
-
- sysMkPath = Lst_Init (FALSE);
- Dir_Expand (_PATH_DEFSYSMK, sysIncPath, sysMkPath);
- if (Lst_IsEmpty(sysMkPath))
- Fatal("make: no system rules (%s).", _PATH_DEFSYSMK);
- ln = Lst_Find(sysMkPath, (void *)NULL, ReadMakefile);
- if (ln != NULL)
- Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
- }
-
if (!Lst_IsEmpty(makefiles)) {
LstNode ln;
@@ -899,7 +885,7 @@
* Side Effects:
* lots
*/
-static Boolean
+Boolean
ReadMakefile(p, q)
void *p;
void *q;
Index: make.h
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/make.h,v
retrieving revision 1.17
diff -u -r1.17 make.h
--- make.h 2002/04/13 10:57:56 1.17
+++ make.h 2002/04/18 06:25:36
@@ -293,6 +293,8 @@
* anything, just see if the targets are out-
* of-date */
+extern Boolean noBuiltins; /* TRUE if sys.mk should not be sourced */
+
extern Boolean checkEnvFirst; /* TRUE if environment should be searched for
* all variables before the global context */
extern Lst envFirstVars; /* List of specific variables for which the
@@ -353,5 +355,6 @@
void Make_Update(GNode *);
void Make_DoAllVar(GNode *);
Boolean Make_Run(Lst);
+int ReadMakefile(void *, void *);
#endif /* _MAKE_H_ */
Index: parse.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/parse.c,v
retrieving revision 1.32
diff -u -r1.32 parse.c
--- parse.c 2002/04/13 10:17:17 1.32
+++ parse.c 2002/04/18 06:25:42
@@ -252,6 +252,7 @@
static char *ParseReadLine(void);
static char *ParseSkipLine(int);
static void ParseFinishLine(void);
+static void ParseSysMk(void);
/*-
*----------------------------------------------------------------------
@@ -2354,6 +2355,50 @@
}
}
+/*-
+ *-----------------------------------------------------------------------
+ * ParseSysMk --
+ * Read and parse the builtin rules file (sys.mk)
+ *
+ * Results:
+ * Nothing.
+ *
+ * Side Effects:
+ * Same as Parse_File(): dependencies added, variables set, etc.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+ParseSysMk(void)
+{
+ LstNode ln;
+ Lst sysMkPath;
+ Boolean old_inLine;
+ int old_lineno;
+ char *old_fname;
+ FILE *old_curFILE;
+
+ /* Save parser globals before Parse_File() clobbers them */
+ old_inLine = inLine;
+ old_lineno = lineno;
+ old_fname = fname;
+ old_curFILE = curFILE;
+
+ /* Parse rules from sys.mk */
+ sysMkPath = Lst_Init (FALSE);
+ Dir_Expand (_PATH_DEFSYSMK, sysIncPath, sysMkPath);
+ if (Lst_IsEmpty(sysMkPath))
+ Fatal("make: no system rules (%s).", _PATH_DEFSYSMK);
+ ln = Lst_Find(sysMkPath, (void *)NULL, ReadMakefile);
+ if (ln != NULL)
+ Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
+
+ /* Restore globals */
+ inLine = old_inLine;
+ lineno = old_lineno;
+ curFILE = old_curFILE;
+ fname = old_fname;
+}
/*-
*---------------------------------------------------------------------
@@ -2375,6 +2420,7 @@
char *name; /* the name of the file being read */
FILE * stream; /* Stream open to makefile to parse */
{
+ static int donesysmk;
char *cp, /* pointer into the line */
*line; /* the line we're working on */
@@ -2386,6 +2432,20 @@
do {
while ((line = ParseReadLine ()) != NULL) {
+ /*
+ * Read sys.mk right before we parse the first line that isn't
+ * either a comment, blank, or .POSIX. The .POSIX pseudo-target
+ * sets a variable that affects what sys.mk defines.
+ */
+ if (!donesysmk) {
+ for (cp = line; isspace(*cp); cp++)
+ ;
+ if (*cp != '#' && *cp != '\0' && !noBuiltins &&
+ strncmp(line, ".POSIX", 6) != 0) {
+ donesysmk = 1;
+ ParseSysMk();
+ }
+ }
if (*line == '.') {
/*
* Lines that begin with the special character are either
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-standards" in the body of the message
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204180650.g3I6o3A00572>
