summaryrefslogtreecommitdiffstats
path: root/usr.bin/make
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2008-07-30 21:18:38 +0000
committered <ed@FreeBSD.org>2008-07-30 21:18:38 +0000
commit7383a7e483c4eb82dcc2467fae1a2e59931f700d (patch)
treeaa5645765b80e98ee35c6998b3bbd0a030a509ea /usr.bin/make
parent746c7fb6aab7b5162ba5e64a1e721c75e0a8d7ec (diff)
downloadFreeBSD-src-7383a7e483c4eb82dcc2467fae1a2e59931f700d.zip
FreeBSD-src-7383a7e483c4eb82dcc2467fae1a2e59931f700d.tar.gz
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
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/main.c12
-rw-r--r--usr.bin/make/make.111
2 files changed, 19 insertions, 4 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 7be2aa2..7569d42 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.
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index 173aef3..44421e5 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -40,7 +40,7 @@
.Nd maintain program dependencies
.Sh SYNOPSIS
.Nm
-.Op Fl ABPSXeiknqrstv
+.Op Fl ABPSXeiknpqrstv
.Op Fl C Ar directory
.Op Fl D Ar variable
.Op Fl d Ar flags
@@ -249,6 +249,15 @@ instead of mixing the output of parallel jobs together.
This option has no effect unless
.Fl j
is used too.
+.It Fl p
+Only print the input graph, not executing any commands.
+The output is the same as
+.Fl d Ar g1 .
+When combined with
+.Fl f Pa /dev/null ,
+only the builtin rules of
+.Nm
+are displayed.
.It Fl q
Do not execute any commands, but exit 0 if the specified targets are
up-to-date and 1, otherwise.
OpenPOWER on IntegriCloud