summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2012-10-09 19:51:51 +0000
committerMarc Espie <espie@cvs.openbsd.org>2012-10-09 19:51:51 +0000
commitcf78dd0c086660214fb7c5f6057285b329b7a5b2 (patch)
treee3e74eb6f9ad41930f5fda7d34928fb1ee4c627a /usr.bin
parentecdd2dd189ebb022bdfb8b902bd51e03d1cd2607 (diff)
steal .if commands() concept from NetBSD.
Actually less ambiguous than .if target().
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/cond.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c
index 941ca20e73f..c9d09badcb2 100644
--- a/usr.bin/make/cond.c
+++ b/usr.bin/make/cond.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cond.c,v 1.44 2012/03/22 13:47:12 espie Exp $ */
+/* $OpenBSD: cond.c,v 1.45 2012/10/09 19:51:50 espie Exp $ */
/* $NetBSD: cond.c,v 1.7 1996/11/06 17:59:02 christos Exp $ */
/*
@@ -70,6 +70,7 @@
* T -> exists(file)
* T -> empty(varspec)
* T -> target(name)
+ * T -> commands(name)
* T -> symbol
* T -> $(varspec) op value
* T -> $(varspec) == "string"
@@ -104,6 +105,7 @@ static bool CondDoDefined(struct Name *);
static bool CondDoMake(struct Name *);
static bool CondDoExists(struct Name *);
static bool CondDoTarget(struct Name *);
+static bool CondDoTargetWithCommands(struct Name *);
static bool CondCvtArg(const char *, double *);
static Token CondToken(bool);
static Token CondT(bool);
@@ -308,7 +310,7 @@ CondDoExists(struct Name *arg)
static bool
CondDoTarget(struct Name *arg)
{
- GNode *gn;
+ GNode *gn;
gn = Targ_FindNodei(arg->s, arg->e, TARG_NOCREATE);
if (gn != NULL && !OP_NOP(gn->type))
@@ -317,6 +319,27 @@ CondDoTarget(struct Name *arg)
return false;
}
+/*-
+ *-----------------------------------------------------------------------
+ * CondDoTargetWithCommands --
+ * See if the given node exists and has commands.
+ *
+ * Results:
+ * true if the node is complete and false if it does not.
+ *-----------------------------------------------------------------------
+ */
+static bool
+CondDoTargetWithCommands(struct Name *arg)
+{
+ GNode *gn;
+
+ gn = Targ_FindNodei(arg->s, arg->e, TARG_NOCREATE);
+ if (gn != NULL && !OP_NOP(gn->type) && (gn->type & OP_HAS_COMMANDS))
+ return true;
+ else
+ return false;
+}
+
/*-
*-----------------------------------------------------------------------
@@ -601,6 +624,7 @@ static struct operator {
{S("make"), CondDoMake},
{S("exists"), CondDoExists},
{S("target"), CondDoTarget},
+ {S("commands"), CondDoTargetWithCommands},
{NULL, 0, NULL}
};