Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Add -C directory, same as gmake and freebsd make.
details: https://anonhg.NetBSD.org/src/rev/6fd7297111e2
branches: trunk
changeset: 746991:6fd7297111e2
user: sjg <sjg%NetBSD.org@localhost>
date: Wed Aug 26 23:17:11 2009 +0000
description:
Add -C directory, same as gmake and freebsd make.
diffstat:
usr.bin/make/main.c | 20 +++++++++++++++-----
usr.bin/make/make.1 | 15 ++++++++++++++-
2 files changed, 29 insertions(+), 6 deletions(-)
diffs (98 lines):
diff -r 9826b426d5e7 -r 6fd7297111e2 usr.bin/make/main.c
--- a/usr.bin/make/main.c Wed Aug 26 23:17:03 2009 +0000
+++ b/usr.bin/make/main.c Wed Aug 26 23:17:11 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.170 2009/03/24 13:53:21 perry Exp $ */
+/* $NetBSD: main.c,v 1.171 2009/08/26 23:17:11 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.170 2009/03/24 13:53:21 perry Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.171 2009/08/26 23:17:11 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.170 2009/03/24 13:53:21 perry Exp $");
+__RCSID("$NetBSD: main.c,v 1.171 2009/08/26 23:17:11 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -333,7 +333,7 @@
Boolean inOption, dashDash = FALSE;
char found_path[MAXPATHLEN + 1]; /* for searching for sys.mk */
-#define OPTFLAGS "BD:I:J:NST:V:WXd:ef:ij:km:nqrst"
+#define OPTFLAGS "BC:D:I:J:NST:V:WXd:ef:ij:km:nqrst"
/* Can't actually use getopt(3) because rescanning is not portable */
getopt_def = OPTFLAGS;
@@ -384,6 +384,15 @@
compatMake = TRUE;
Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL);
break;
+ case 'C':
+ if (chdir(argvalue) == -1) {
+ (void)fprintf(stderr,
+ "%s: chdir %s: %s\n",
+ progname, argvalue,
+ strerror(errno));
+ exit(1);
+ }
+ break;
case 'D':
if (argvalue == NULL || argvalue[0] == 0) goto noarg;
Var_Set(argvalue, "1", VAR_GLOBAL, 0);
@@ -1773,7 +1782,8 @@
usage(void)
{
(void)fprintf(stderr,
-"usage: %s [-BeikNnqrstWX] [-D variable] [-d flags] [-f makefile]\n\
+"usage: %s [-BeikNnqrstWX] \n\
+ [-C directory] [-D variable] [-d flags] [-f makefile]\n\
[-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]\n\
[-V variable] [variable=value] [target ...]\n", progname);
exit(2);
diff -r 9826b426d5e7 -r 6fd7297111e2 usr.bin/make/make.1
--- a/usr.bin/make/make.1 Wed Aug 26 23:17:03 2009 +0000
+++ b/usr.bin/make/make.1 Wed Aug 26 23:17:11 2009 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.158 2009/06/01 23:28:39 sjg Exp $
+.\" $NetBSD: make.1,v 1.159 2009/08/26 23:17:11 sjg Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -39,6 +39,9 @@
.Nm
.Op Fl BeikNnqrstWX
.Bk -words
+.Op Fl C Ar directory
+.Ek
+.Bk -words
.Op Fl D Ar variable
.Ek
.Bk -words
@@ -104,6 +107,16 @@
.It Fl B
Try to be backwards compatible by executing a single shell per command and
by executing the commands to make the sources of a dependency line in sequence.
+.It Fl C Ar directory
+Change to
+.Ar directory
+before reading the makefiles or doing anything else.
+If multiple
+.Fl C
+options are specified, each is interpreted relative to the previous one:
+.Fl C Pa / Fl C Pa etc
+is equivalent to
+.Fl C Pa /etc .
.It Fl D Ar variable
Define
.Ar variable
Home |
Main Index |
Thread Index |
Old Index