summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1996-02-23 18:33:03 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1996-02-23 18:33:03 +0000
commit10834da7ac78071b50354242a26cc30f9c97988b (patch)
tree35c192fe4f7eb8bb0c3dca50b9894fb932dbdd83 /usr.bin
parentaa0e6f45b5cc83e3a36d3ee5dfcf680d4a94a29b (diff)
Implement an -m option used for replacing /usr/share/mk with a
custom search path, like $DESTDIR/usr/share/mk
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/PSD.doc/tutorial.ms17
-rw-r--r--usr.bin/make/main.c55
-rw-r--r--usr.bin/make/make.114
-rw-r--r--usr.bin/make/make.h2
-rw-r--r--usr.bin/make/parse.c19
-rw-r--r--usr.bin/make/pathnames.h4
6 files changed, 77 insertions, 34 deletions
diff --git a/usr.bin/make/PSD.doc/tutorial.ms b/usr.bin/make/PSD.doc/tutorial.ms
index 84237218a5e..69c2c308c97 100644
--- a/usr.bin/make/PSD.doc/tutorial.ms
+++ b/usr.bin/make/PSD.doc/tutorial.ms
@@ -1271,6 +1271,15 @@ administrator. If locking is on,
will turn it off, and vice versa. Note that this locking will not
prevent \fIyou\fP from invoking PMake twice in the same place \*- if
you own the lock file, PMake will warn you about it but continue to execute.
+.IP "\fB\-m\fP \fIdirectory\fP"
+.Ix 0 def flags -m
+Tells PMake another place to search for included makefiles via the <...>
+style. Several
+.B \-m
+options can be given to form a search path. If this construct is used the
+default system makefile search path is completely overridden.
+To be explained in chapter 3, section 3.2.
+.Rm 2 3.2
.IP \fB\-n\fP
.Ix 0 def flags -n
This flag tells PMake not to execute the commands needed to update the
@@ -1911,11 +1920,15 @@ or this
.DE
The difference between the two is where PMake searches for the file:
the first way, PMake will look for
-the file only in the system makefile directory (to find out what that
-directory is, give PMake the
+the file only in the system makefile directory (or directories)
+(to find out what that directory is, give PMake the
.B \-h
flag).
.Ix 0 ref flags -h
+The system makefile directory search path can be overridden via the
+.B \-m
+option.
+.Ix 0 ref flags -m
For files in double-quotes, the search is more complex:
.RS
.IP 1)
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 6aec6531a2f..4f7b2cba68b 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -161,9 +161,9 @@ MainParseArgs(argc, argv)
optind = 1; /* since we're called more than once */
#ifdef REMOTE
-# define OPTFLAGS "BD:I:L:PSd:ef:ij:knqrst"
+# define OPTFLAGS "BD:I:L:PSd:ef:ij:km:nqrst"
#else
-# define OPTFLAGS "BD:I:PSd:ef:ij:knqrst"
+# define OPTFLAGS "BD:I:PSd:ef:ij:km:nqrst"
#endif
rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
switch(c) {
@@ -274,6 +274,11 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != EOF) {
keepgoing = TRUE;
Var_Append(MAKEFLAGS, "-k", VAR_GLOBAL);
break;
+ case 'm':
+ Dir_AddDir(sysIncPath, optarg);
+ Var_Append(MAKEFLAGS, "-m", VAR_GLOBAL);
+ Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
+ break;
case 'n':
noExecute = TRUE;
Var_Append(MAKEFLAGS, "-n", VAR_GLOBAL);
@@ -399,6 +404,10 @@ main(argc, argv)
char cdpath[MAXPATHLEN + 1];
struct utsname utsname;
char *machine = getenv("MACHINE");
+ Lst sysMkPath; /* Path of sys.mk */
+ char *cp = NULL, *start;
+ /* avoid faults on read-only strings */
+ static char syspath[] = _PATH_DEFSYSPATH;
#ifdef RLIMIT_NOFILE
/*
@@ -601,13 +610,41 @@ main(argc, argv)
} else
Var_Set(".TARGETS", "", VAR_GLOBAL);
+
/*
- * 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.
+ * If no user-supplied system path was given (through the -m option)
+ * add the directories from the DEFSYSPATH (more than one may be given
+ * as dir1:...:dirn) to the system include path.
*/
- if (!noBuiltins && !ReadMakefile(_PATH_DEFSYSMK))
- Fatal("make: no system rules (%s).", _PATH_DEFSYSMK);
+ if (Lst_IsEmpty(sysIncPath)) {
+ for (start = syspath; *start != '\0'; start = cp) {
+ for (cp = start; *cp != '\0' && *cp != ':'; cp++)
+ continue;
+ if (*cp == '\0') {
+ Dir_AddDir(sysIncPath, start);
+ } else {
+ *cp++ = '\0';
+ Dir_AddDir(sysIncPath, start);
+ }
+ }
+ }
+
+ /*
+ * 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.
+ */
+ 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, (ClientData)NULL, ReadMakefile);
+ if (ln != NILLNODE)
+ Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
+ }
if (!Lst_IsEmpty(makefiles)) {
LstNode ln;
@@ -745,7 +782,7 @@ static Boolean
ReadMakefile(fname)
char *fname; /* makefile to read */
{
- extern Lst parseIncPath, sysIncPath;
+ extern Lst parseIncPath;
FILE *stream;
char *name, path[MAXPATHLEN + 1];
@@ -990,7 +1027,7 @@ usage()
{
(void)fprintf(stderr,
"usage: make [-eiknqrst] [-D variable] [-d flags] [-f makefile ]\n\
- [-I directory] [-j max_jobs] [variable=value]\n");
+ [-I directory] [-j max_jobs] [-m directory] [variable=value]\n");
exit(2);
}
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index 87670d49b29..22d997ec01a 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -47,6 +47,7 @@
.Op Fl I Ar directory
.Bk -words
.Op Fl j Ar max_jobs
+.Op Fl m Ar directory
.Ek
.Op Ar variable=value
.Op Ar target ...
@@ -130,8 +131,9 @@ standard input is read.
Multiple makefile's may be specified, and are read in the order specified.
.It Fl I Ar directory
Specify a directory in which to search for makefiles and included makefiles.
-The system makefile directory is automatically included as part of this
-list.
+The system makefile directory (or directories, see the
+.Fl m
+option) is automatically included as part of this list.
.It Fl i
Ignore non-zero exit of shell commands in the makefile.
Equivalent to specifying
@@ -146,6 +148,14 @@ flag is also specified.
.It Fl k
Continue processing after errors are encountered, but only on those targets
that do not depend on the target whose creation caused the error.
+.It Fl m Ar directory
+Specify a directory in which to search for sys.mk and makefiles included
+via the <...> style. Multiple directories can be added to form a search path.
+This path will override the default system include path: /usr/share/mk.
+Furthermore the system include path will be appended to the search path used
+for "..."-style inclusions (see the
+.Fl I
+option).
.It Fl n
Display the commands that would have been executed, but do not actually
execute them.
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h
index b28ed3021d4..3da7124bf2b 100644
--- a/usr.bin/make/make.h
+++ b/usr.bin/make/make.h
@@ -326,6 +326,8 @@ extern time_t now; /* The time at the start of this whole
extern Boolean oldVars; /* Do old-style variable substitution */
+extern Lst sysIncPath; /* The system include path. */
+
/*
* debug control:
* There is one bit per module. It is up to the module what debug
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 785fad21dff..f1a6ac0e87a 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -2644,30 +2644,11 @@ Parse_File(name, stream)
void
Parse_Init ()
{
- char *cp = NULL, *start;
- /* avoid faults on read-only strings */
- static char syspath[] = _PATH_DEFSYSPATH;
-
mainNode = NILGNODE;
parseIncPath = Lst_Init (FALSE);
sysIncPath = Lst_Init (FALSE);
includes = Lst_Init (FALSE);
targCmds = Lst_Init (FALSE);
-
- /*
- * Add the directories from the DEFSYSPATH (more than one may be given
- * as dir1:...:dirn) to the system include path.
- */
- for (start = syspath; *start != '\0'; start = cp) {
- for (cp = start; *cp != '\0' && *cp != ':'; cp++)
- continue;
- if (*cp == '\0') {
- Dir_AddDir(sysIncPath, start);
- } else {
- *cp++ = '\0';
- Dir_AddDir(sysIncPath, start);
- }
- }
}
void
diff --git a/usr.bin/make/pathnames.h b/usr.bin/make/pathnames.h
index 5d49bea590a..b8ffcab31a9 100644
--- a/usr.bin/make/pathnames.h
+++ b/usr.bin/make/pathnames.h
@@ -33,10 +33,10 @@
* SUCH DAMAGE.
*
* from: @(#)pathnames.h 5.2 (Berkeley) 6/1/90
- * $Id: pathnames.h,v 1.1 1995/10/18 08:45:43 deraadt Exp $
+ * $Id: pathnames.h,v 1.2 1996/02/23 18:33:00 niklas Exp $
*/
#define _PATH_OBJDIR "obj"
#define _PATH_DEFSHELLDIR "/bin"
-#define _PATH_DEFSYSMK "/usr/share/mk/sys.mk"
+#define _PATH_DEFSYSMK "sys.mk"
#define _PATH_DEFSYSPATH "/usr/share/mk"