-/* $OpenBSD: suff.c,v 1.86 2013/11/22 15:47:35 espie Exp $ */
+/* $OpenBSD: suff.c,v 1.87 2014/01/06 12:08:18 espie Exp $ */
/* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */
/*
if (DEBUG(SUFF))
printf("SuffFindDeps (%s)\n", gn->name);
+ current_node = gn;
if (gn->type & OP_ARCHV)
SuffFindArchiveDeps(gn, slst);
else
SuffFindNormalDeps(gn, slst);
+ current_node = NULL;
}
/*-
-/* $OpenBSD: var.c,v 1.94 2013/04/23 14:32:53 espie Exp $ */
+/* $OpenBSD: var.c,v 1.95 2014/01/06 12:08:18 espie Exp $ */
/* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */
/*
*/
char var_Error[] = "";
+GNode *current_node = NULL;
/*
* Similar to var_Error, but returned when the 'err' flag for Var_Parse is
* set false. Why not just use a constant? Well, gcc likes to condense
return val;
}
+#define ERRMSG1 "Using $< in a non-suffix rule context is a GNUmake idiom "
+#define ERRMSG2 "Using undefined dynamic variable $%s "
+static void
+bad_dynamic_variable(int idx)
+{
+ Location origin;
+
+ Parse_FillLocation(&origin);
+ if (idx >= LOCAL_SIZE)
+ idx = EXTENDED2SIMPLE(idx);
+ switch(idx) {
+ case IMPSRC_INDEX:
+ if (origin.fname)
+ Fatal(ERRMSG1 "(%s:%lu)",
+ origin.lineno, origin.fname);
+ else if (current_node)
+ Fatal(ERRMSG1 "(prereq of %s)", current_node->name);
+ else
+ Fatal(ERRMSG1 "(?)");
+ break;
+ default:
+ if (origin.fname)
+ Error(ERRMSG2 "(%s:%lu)", varnames[idx],
+ origin.lineno, origin.fname);
+ else if (current_node)
+ Error(ERRMSG2 "(prereq of %s)", varnames[idx],
+ current_node->name);
+ else
+ Error(ERRMSG2 "(?)", varnames[idx]);
+ break;
+ }
+}
+
char *
Var_Parse(const char *str, /* The string to parse */
SymTable *ctxt, /* The context for the variable */
*freePtr = true;
val = Str_dupi(str, tstr);
} else {
- Location origin;
-
- Parse_FillLocation(&origin);
- if (idx >= LOCAL_SIZE)
- idx = EXTENDED2SIMPLE(idx);
- switch(idx) {
- case IMPSRC_INDEX:
- Fatal(
-"Using $< in a non-suffix rule context is a GNUmake idiom (line %lu of %s)",
- origin.lineno, origin.fname);
- break;
- default:
- Error(
-"Using undefined dynamic variable $%s (line %lu of %s)",
- varnames[idx], origin.lineno,
- origin.fname);
- break;
- }
+ bad_dynamic_variable(idx);
}
}
}
#ifndef VAR_H
#define VAR_H
-/* $OpenBSD: var.h,v 1.16 2012/10/09 19:39:59 espie Exp $ */
+/* $OpenBSD: var.h,v 1.17 2014/01/06 12:08:18 espie Exp $ */
/*
* Copyright (c) 2001 Marc Espie.
*
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+extern GNode *current_node;
extern void Var_Init(void);
extern void Var_setCheckEnvFirst(bool);