Re: [BUG] undefined variable used in recipe before undefine directive

Alejandro Colomar <[email protected]> Thu, 11 Sep 2025 23:46:43 +0200
Newsgroups gmane.comp.gnu.make.bugs
Message-ID <o5w24gauszbo2n4mj2rhgfefxm6vesd3qvekzkqvyc2ynmtlff@gtx6xikkbv7s>
Hi Philip,

On Thu, Sep 11, 2025 at 02:26:37PM -0700, Philip Guenther wrote:
> Hmm, if the regexp file names match a consistent, unambiguous pattern
> (like, all have the suffix “.ref”) then the command in the recipe could
> match that from the prerequisite list with $(filter %.ref, $^) so that the
> filename only appears as a literal in the prerequisite list.

Hmmm, currently I was using slightly different extensions:

	.grep	- for basic regexes.
	.egrep	- for regexes interpreted by grep -E.
	.pgrep	- for regexes interpreted by grep -P.

But yeah, that would be enough, since I can have a slightly different
filter for each recipe; that's okay.  Thanks!

I've applied this change (and the same thing in several other files,
just with slightly different file names and filters):

	diff --git a/share/mk/build/catman/troff.mk b/share/mk/build/catman/troff.mk
	index eda2a5faf..d17531990 100644
	--- a/share/mk/build/catman/troff.mk
	+++ b/share/mk/build/catman/troff.mk
	@@ -17,6 +17,7 @@ include $(MAKEFILEDIR)/configure/xfail.mk
	 
	 ext := .cat.set
	 xfail := $(MAKEFILEDIR)/build/catman/troff.xfail
	+regexf := $(MAKEFILEDIR)/build/catman/troff.ignore.grep
	 
	 tgts := $(patsubst %, %$(ext), $(_NONSO))
	 ifeq ($(SKIP_XFAIL),yes)
	@@ -24,16 +25,13 @@ tgts := $(filter-out $(patsubst %, $(_MANDIR)/%$(ext), $(file < $(xfail))), $(tg
	 endif
	 
	 
	-troff_catman_ignore_grep := $(MAKEFILEDIR)/build/catman/troff.ignore.grep
	-
	-
	 _CATMAN_set := $(tgts)
	 
	 
	-$(_CATMAN_set): %$(ext): %.cat.troff $(troff_catman_ignore_grep) $(MK) | $$(@D)/
	+$(_CATMAN_set): %$(ext): %.cat.troff $(regexf) $(MK) | $$(@D)/
		$(info  $(INFO_)TROFF           $@)
		! ($(TROFF) -mandoc $(TROFFFLAGS_) $(NROFFFLAGS_) <$< 2>&1 >$@ \
	-          | $(GREP) -v -f '$(troff_catman_ignore_grep)' \
	+          | $(GREP) -v -f '$(filter %.grep, $^)' \
		   || $(TRUE); \
		) \
		| $(GREP) ^ >&2
	@@ -45,6 +43,7 @@ build-catman-troff: $(_CATMAN_set);
	 
	 undefine ext
	 undefine xfail
	+undefine regexf
	 undefine tgts

And it works perfectly.  Thanks!  I've had to add a comment in the
commit message about why I need this, but that's fine.

> Philip Guenther


Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmjDQ0IACgkQ64mZXMKQ
wqmMsQ/+OrLpDYzc7BaPOuq6a1NcWg6nKzZ3APE2epNLTKpBY5snqRZ9/wC9uaym
5IHKgNL4iV9ZVJsSLKgEZQb3yk7a0IO58bE8ZXWwjfu+wGan75C+MDbtpOw3dGuJ
6ovMv+6+tDHRwKoEeBISNucNBzUivi3EoczqwK9X1yxlzfqRh5SXE5iCFV+ZeUkD
KiZf5cVXnvTRE1cDrzLTt3EmZPR+gHojgTtPNAaymnFeVPIolDhgvJtt/E3+MSfm
QVlU8lhZ0wxjq2I95welFBv7B34dXGESyNCOSf7MSk02dvNhvHyfTE09DSKMyAP4
P69aiiT7n1pzdqyNFED2eJqr6T53WN8NML5sOuJzxiRLqbnXhNI/tBp4XK7dagFc
MTn+olzSibkGprHEzsnCVGIYYeSnlTWeqcYJSzTdnZQbKI8IwbWn1spufIAhZc79
a+M10e1LydkpBxQDvCgkK1zdQqSU1olpy870VGzYAlagF2EUWRfZzEHpkIg4lqwx
vdd9I3lmKRuFGVURt9ORXB+euYoXTStVjHBv+p0fCer+9gBSWY6ka2BUFewyNtKj
dvZazSx72zO3WuiBaPZFM6ztE18tkEkN4kFUU6M5Rb4KzvATPVHA25/fRjtzwhCo
3xHRsJq4OLdWZwcxv56S6ZMEbRCehb7Me69pCsrq3RBtrZoHh0I=
=cl4y
-----END PGP SIGNATURE-----