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 <rachel@jerkcity.com>
This commit is contained in:
Juli Mallett 2002-08-25 02:45:04 +00:00
parent 34bdf0dcbf
commit acdb9a105e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=102393
3 changed files with 11 additions and 3 deletions

View file

@ -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}

View file

@ -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);

View file

@ -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