From acdb9a105ea74732809e6beb7b10eeccf0c8567e Mon Sep 17 00:00:00 2001 From: Juli Mallett Date: Sun, 25 Aug 2002 02:45:04 +0000 Subject: [PATCH] Add a -C ala GNU make(1) for Makefiles which are too lazy to use $(MAKE) and this particular GNU flag. It changes into the given directory for the operation in question. This just goes into said directory at the time of parsing the argument for getopt(3). Submitted by: Rachel Hestilow --- usr.bin/make/Makefile | 2 +- usr.bin/make/main.c | 7 +++++-- usr.bin/make/make.1 | 5 +++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index 208c2cc40c2..4f46cae0653 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -15,7 +15,7 @@ SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \ NOSHARED?= YES -CFLAGS+=-DMAKE_VERSION=\"5200205240\" +CFLAGS+=-DMAKE_VERSION=\"5200208240\" main.o: ${MAKEFILE} diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 0028e157607..f1439750472 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -167,12 +167,15 @@ MainParseArgs(argc, argv) optind = 1; /* since we're called more than once */ #ifdef REMOTE -# define OPTFLAGS "BD:E:I:L:PSV:Xd:ef:ij:km:nqrstv" +# define OPTFLAGS "BC:D:E:I:L:PSV:Xd:ef:ij:km:nqrstv" #else -# define OPTFLAGS "BD:E:I:PSV:Xd:ef:ij:km:nqrstv" +# define OPTFLAGS "BC:D:E:I:PSV:Xd:ef:ij:km:nqrstv" #endif rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { switch(c) { + case 'C': + chdir(optarg); + break; case 'D': Var_Set(optarg, "1", VAR_GLOBAL); Var_Append(MAKEFLAGS, "-D", VAR_GLOBAL); diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1 index 85f83e12b3a..b35649e61c1 100644 --- a/usr.bin/make/make.1 +++ b/usr.bin/make/make.1 @@ -41,6 +41,7 @@ .Sh SYNOPSIS .Nm .Op Fl BPSXeiknqrstv +.Op Fl C Ar directory .Op Fl D Ar variable .Op Fl d Ar flags .Op Fl E Ar variable @@ -88,6 +89,10 @@ by executing the commands to make the sources of a dependency line in sequence. This is turned on by default unless .Fl j is used. +.It Fl C Ar directory +Change to +.Ar directory +while running. .It Fl D Ar variable Define .Ar variable