diff options
author | Ed Schouten <ed@FreeBSD.org> | 2008-07-30 21:18:38 +0000 |
---|---|---|
committer | Ed Schouten <ed@FreeBSD.org> | 2008-07-30 21:18:38 +0000 |
commit | 40e761838e814670d754868ec81870025079253f (patch) | |
tree | aa5645765b80e98ee35c6998b3bbd0a030a509ea /usr.bin/make/main.c | |
parent | 3cca4b6fe82407c00af262ed63ed3b531b8b2acf (diff) | |
download | src-40e761838e814670d754868ec81870025079253f.tar.gz src-40e761838e814670d754868ec81870025079253f.zip |
Add POSIX -p flag to make(1).
This article [1] describes the -p flag for make(1):
Write to standard output the complete set of macro definitions and
target descriptions. The output format is unspecified.
We already support a similar flag (-d g1), but unlike -p, it still
executes commands. Our implementation just turns it into -d g1, but also
sets flag `printGraphOnly', which will cause make(1) to skip execution.
[1] http://www.opengroup.org/onlinepubs/009695399/utilities/make.html
Reviewed by: imp
PR: standards/99960
Notes
Notes:
svn path=/head/; revision=181021
Diffstat (limited to 'usr.bin/make/main.c')
-rw-r--r-- | usr.bin/make/main.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 7be2aa2a940b..7569d428ccde 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -133,6 +133,7 @@ int jobLimit; /* -j argument */ Boolean jobsRunning; /* TRUE if the jobs might be running */ Boolean keepgoing; /* -k flag */ Boolean noExecute; /* -n flag */ +Boolean printGraphOnly; /* -p flag */ Boolean queryFlag; /* -q flag */ Boolean touchFlag; /* -t flag */ Boolean usePipes; /* !-P flag */ @@ -150,7 +151,7 @@ static void usage(void) { fprintf(stderr, - "usage: make [-BPSXeiknqrstv] [-C directory] [-D variable]\n" + "usage: make [-BPSXeiknpqrstv] [-C directory] [-D variable]\n" "\t[-d flags] [-E variable] [-f makefile] [-I directory]\n" "\t[-j max_jobs] [-m directory] [-V variable]\n" "\t[variable=value] [target ...]\n"); @@ -368,7 +369,7 @@ MainParseArgs(int argc, char **argv) rearg: optind = 1; /* since we're called more than once */ optreset = 1; -#define OPTFLAGS "ABC:D:E:I:PSV:Xd:ef:ij:km:nqrstvx:" +#define OPTFLAGS "ABC:D:E:I:PSV:Xd:ef:ij:km:npqrstvx:" for (;;) { if ((optind < argc) && strcmp(argv[optind], "--") == 0) { found_dd = TRUE; @@ -510,6 +511,10 @@ rearg: noExecute = TRUE; MFLAGS_append("-n", NULL); break; + case 'p': + printGraphOnly = TRUE; + debug |= DEBUG_GRAPH1; + break; case 'q': queryFlag = TRUE; /* Kind of nonsensical, wot? */ @@ -903,6 +908,7 @@ main(int argc, char **argv) beSilent = FALSE; /* Print commands as executed */ ignoreErrors = FALSE; /* Pay attention to non-zero returns */ noExecute = FALSE; /* Execute all commands */ + printGraphOnly = FALSE; /* Don't stop after printing graph */ keepgoing = FALSE; /* Stop on error */ allPrecious = FALSE; /* Remove targets when interrupted */ queryFlag = FALSE; /* This is not just a check-run */ @@ -1242,7 +1248,7 @@ main(int argc, char **argv) Targ_PrintGraph(1); /* print the values of any variables requested by the user */ - if (Lst_IsEmpty(&variables)) { + if (Lst_IsEmpty(&variables) && !printGraphOnly) { /* * Since the user has not requested that any variables * be printed, we can build targets. |