diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index 7682ba32607..4e0c1dfe51e 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.65 2023/09/04 11:35:11 espie Exp $ +# $OpenBSD: Makefile,v 1.66 2025/11/27 09:08:49 tb Exp $ PROG= make CFLAGS+= -I${.OBJDIR} -I${.CURDIR} @@ -27,7 +27,7 @@ CLEANFILES+=generate generate.o regress.o check CLEANFILES+= varhashconsts.h condhashconsts.h nodehashconsts.h # may need tweaking if you add variable synonyms or change the hash function -MAGICVARSLOTS=82 +MAGICVARSLOTS=36 MAGICCONDSLOTS=65 varhashconsts.h: generate diff --git a/usr.bin/make/generate.c b/usr.bin/make/generate.c index 70ec4c7f580..306431a619a 100644 --- a/usr.bin/make/generate.c +++ b/usr.bin/make/generate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: generate.c,v 1.18 2016/10/14 09:27:21 natano Exp $ */ +/* $OpenBSD: generate.c,v 1.19 2025/11/27 09:08:49 tb Exp $ */ /* * Copyright (c) 2001 Marc Espie. @@ -53,16 +53,6 @@ char *table_var[] = { M(LONGPREFIX), M(LONGARCHIVE), M(LONGMEMBER), - M(FTARGET), - M(DTARGET), - M(FPREFIX), - M(DPREFIX), - M(FARCHIVE), - M(DARCHIVE), - M(FMEMBER), - M(DMEMBER), - M(FIMPSRC), - M(DIMPSRC), NULL }; diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1 index f09ebb04cfe..74424f22195 100644 --- a/usr.bin/make/make.1 +++ b/usr.bin/make/make.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: make.1,v 1.141 2023/08/10 10:56:34 espie Exp $ +.\" $OpenBSD: make.1,v 1.142 2025/11/27 09:08:49 tb Exp $ .\" $NetBSD: make.1,v 1.18 1997/03/10 21:19:53 christos Exp $ .\" .\" Copyright (c) 1990, 1993 @@ -30,7 +30,7 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd $Mdocdate: August 10 2023 $ +.Dd $Mdocdate: November 27 2025 $ .Dt MAKE 1 .Os .Sh NAME @@ -639,19 +639,24 @@ The file prefix of the file, containing only the file portion, no suffix or preceding directory components. .El .Pp -The six variables -.Sq Va "@F" , -.Sq Va "@D" , -.Sq Va " +.Pc +may be suffixed with a +.Sq D +or a +.Sq F , +to yield the filename or directory part of the corresponding variables, e.g., +.Sq ${ Ns Va @F Ns } +is equivalent +to +.Sq ${@:T} and -.Qq directory -parts of the corresponding macros. +.Sq ${ Ns Va @D Ns } +is equivalent to +.Sq ${@:H} . .Pp For maximum compatibility, .Sq Va \&< diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 1ac643d7265..a93e82cdd8a 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $OpenBSD: var.c,v 1.107 2024/06/18 02:11:04 millert Exp $ */ +/* $OpenBSD: var.c,v 1.108 2025/11/27 09:08:49 tb Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* @@ -152,16 +152,6 @@ static char *varnames[] = { IMPSRC, OODATE, ALLSRC, - FTARGET, - DTARGET, - FPREFIX, - DPREFIX, - FARCHIVE, - DARCHIVE, - FMEMBER, - DMEMBER, - FIMPSRC, - DIMPSRC }; static bool xtlist[] = { @@ -173,16 +163,6 @@ static bool xtlist[] = { true, /* $< */ false, /* $? */ false, /* $> */ - true, /* ${@F} */ - true, /* ${@D} */ - false, /* ${*F} */ - false, /* ${*D} */ - false, /* ${!F} */ - false, /* ${!D} */ - true, /* ${%F} */ - true, /* ${%D} */ - true, /* ${locals[idx]; - else - val = ctxt->locals[EXTENDED2SIMPLE(idx)]; + val = ctxt->locals[idx]; } else val = NULL; if (val == NULL) return NULL; - if (idx >= LOCAL_SIZE) { - if (IS_EXTENDED_F(idx)) - val = Var_GetTail(val); - else - val = Var_GetHead(val); + if (ext == 'F') { + val = Var_GetTail(val); + *freePtr = true; + } else if (ext == 'D') { + val = Var_GetHead(val); *freePtr = true; } } @@ -1012,8 +948,6 @@ 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) @@ -1050,6 +984,7 @@ Var_Parse(const char *str, /* The string to parse */ uint32_t k; int idx; bool has_modifier; + char ext; *freePtr = false; @@ -1063,8 +998,9 @@ Var_Parse(const char *str, /* The string to parse */ has_modifier = parse_base_variable_name(&tstr, &name, ctxt); - idx = classify_var(name.s, &name.e, &k); - val = get_expanded_value(name.s, name.e, idx, k, ctxt, err, freePtr); + idx = classify_var(name.s, &name.e, &k, &ext); + val = get_expanded_value(name.s, name.e, idx, k, ext, ctxt, err, + freePtr); if (has_modifier) { val = VarModifiers_Apply(val, &name, ctxt, err, freePtr, &tstr, str[1]); @@ -1183,6 +1119,7 @@ Var_Check_for_target(const char *str) int idx; bool has_modifier; struct Name name; + char ext; /* skip over uninteresting stuff */ for (; *str != '\0' && *str != '$'; str++) @@ -1198,7 +1135,7 @@ Var_Check_for_target(const char *str) tstr = str; has_modifier = parse_base_variable_name(&tstr, &name, NULL); - idx = classify_var(name.s, &name.e, &k); + idx = classify_var(name.s, &name.e, &k, &ext); if (has_modifier) { bool doFree = false; char *val = VarModifiers_Apply(NULL, NULL, NULL, false, diff --git a/usr.bin/make/var_int.h b/usr.bin/make/var_int.h index f3cd53ec95d..b4882df766f 100644 --- a/usr.bin/make/var_int.h +++ b/usr.bin/make/var_int.h @@ -1,6 +1,6 @@ #ifndef VAR_INT_H #define VAR_INT_H -/* $OpenBSD: var_int.h,v 1.2 2010/07/19 19:46:44 espie Exp $ */ +/* $OpenBSD: var_int.h,v 1.3 2025/11/27 09:08:49 tb Exp $ */ /* * Copyright (c) 2001 Marc Espie. * @@ -42,16 +42,4 @@ #define LONGARCHIVE ".ARCHIVE" #define LONGMEMBER ".MEMBER" -/* System V extended variables (get directory/file part) */ -#define FTARGET "@F" -#define DTARGET "@D" -#define FIMPSRC "