From 972beca9d8c56ec5eb3f77753d58c84b6bfd6650 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 10 Sep 2025 17:52:37 +0200 Subject: [PATCH] share/mk/: Unify variable names for regex files Within recipes, variables have delayed expansion, which means that we can't use variables that we've undefined. That's why we need to use a filter to get the regex file name from the rule prerequisites. This trick was suggested by Philip. Cc: Philip Guenther Cc: Paul Smith Cc: Martin Dorey Signed-off-by: Alejandro Colomar --- share/mk/build/catman/troff.mk | 9 ++++----- share/mk/lint/man/mandoc.mk | 9 ++++----- share/mk/lint/man/quote.mk | 11 +++++------ share/mk/lint/man/ws.mk | 11 +++++------ 4 files changed, 18 insertions(+), 22 deletions(-) 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 diff --git a/share/mk/lint/man/mandoc.mk b/share/mk/lint/man/mandoc.mk index 3a3335467..4d0436f6a 100644 --- a/share/mk/lint/man/mandoc.mk +++ b/share/mk/lint/man/mandoc.mk @@ -17,6 +17,7 @@ include $(MAKEFILEDIR)/configure/xfail.mk ext := .lint-man.mandoc.touch xfail := $(MAKEFILEDIR)/lint/man/mandoc.xfail +regexf := $(MAKEFILEDIR)/lint/man/mandoc.ignore.grep tgts := $(patsubst %, %$(ext), $(_NONSO)) ifeq ($(SKIP_XFAIL),yes) @@ -24,13 +25,10 @@ tgts := $(filter-out $(patsubst %, $(_MANDIR)/%$(ext), $(file < $(xfail))), $(tg endif -mandoc_man_ignore_grep := $(MAKEFILEDIR)/lint/man/mandoc.ignore.grep - - -$(tgts): %$(ext): % $(mandoc_man_ignore_grep) $(MK) | $$(@D)/ +$(tgts): %$(ext): % $(regexf) $(MK) | $$(@D)/ $(info $(INFO_)MANDOC $@) ! ($(MANDOC) $(MANDOCFLAGS_) $< 2>&1 \ - | $(GREP) -v -f '$(mandoc_man_ignore_grep)' \ + | $(GREP) -v -f '$(filter %.grep, $^)' \ || $(TRUE); \ ) \ | $(GREP) ^ >&2 @@ -43,6 +41,7 @@ lint-man-mandoc: $(tgts); undefine ext undefine xfail +undefine regexf undefine tgts diff --git a/share/mk/lint/man/quote.mk b/share/mk/lint/man/quote.mk index 28cae6533..d42bb7fc9 100644 --- a/share/mk/lint/man/quote.mk +++ b/share/mk/lint/man/quote.mk @@ -15,6 +15,7 @@ include $(MAKEFILEDIR)/configure/build-depends/grep/grep.mk ext := .lint-man.quote.touch xfail := $(MAKEFILEDIR)/lint/man/quote.xfail +regexf := $(MAKEFILEDIR)/lint/man/quote.Pgrep tgts := $(patsubst %, %$(ext), $(_NONSO)) ifeq ($(SKIP_XFAIL),yes) @@ -22,15 +23,12 @@ tgts := $(filter-out $(patsubst %, $(_MANDIR)/%$(ext), $(file < $(xfail))), $(tg endif -quote_Pgrep := $(MAKEFILEDIR)/lint/man/quote.Pgrep - - -$(tgts): %$(ext): % $(quote_Pgrep) $(MK) | $$(@D)/ +$(tgts): %$(ext): % $(regexf) $(MK) | $$(@D)/ $(info $(INFO_)GREP $@) $(CAT) <$< \ - | if $(GREP) -Pf $(quote_Pgrep) >/dev/null; then \ + | if $(GREP) -Pf $(filter %.Pgrep, $^) >/dev/null; then \ >&2 $(ECHO) "lint-man-quote: $<: Unmatched quote:"; \ - >&2 $(GREP) -PTnf '$(quote_Pgrep)' <$<; \ + >&2 $(GREP) -PTnf '$(filter %.Pgrep, $^)' <$<; \ exit 1; \ fi; $(TOUCH) $@ @@ -42,6 +40,7 @@ lint-man-quote: $(tgts); undefine ext undefine xfail +undefine regexf undefine tgts diff --git a/share/mk/lint/man/ws.mk b/share/mk/lint/man/ws.mk index eb1bb6c64..2cb36e40f 100644 --- a/share/mk/lint/man/ws.mk +++ b/share/mk/lint/man/ws.mk @@ -15,6 +15,7 @@ include $(MAKEFILEDIR)/configure/build-depends/grep/grep.mk ext := .lint-man.ws.touch xfail := $(MAKEFILEDIR)/lint/man/ws.xfail +regexf := $(MAKEFILEDIR)/lint/man/ws.egrep tgts := $(patsubst %, %$(ext), $(_NONSO)) ifeq ($(SKIP_XFAIL),yes) @@ -22,15 +23,12 @@ tgts := $(filter-out $(patsubst %, $(_MANDIR)/%$(ext), $(file < $(xfail))), $(tg endif -ws_egrep := $(MAKEFILEDIR)/lint/man/ws.egrep - - -$(tgts): %$(ext): % $(ws_egrep) $(MK) | $$(@D)/ +$(tgts): %$(ext): % $(regexf) $(MK) | $$(@D)/ $(info $(INFO_)GREP $@) $(CAT) <$< \ - | if $(GREP) -Ef $(ws_egrep) >/dev/null; then \ + | if $(GREP) -Ef $(filter %.egrep, $^) >/dev/null; then \ >&2 $(ECHO) "lint-man-ws: $<: Spurious white space:"; \ - >&2 $(GREP) -ETnf '$(ws_egrep)' <$<; \ + >&2 $(GREP) -ETnf '$(filter %.egrep, $^)' <$<; \ exit 1; \ fi; $(TOUCH) $@ @@ -42,6 +40,7 @@ lint-man-ws: $(tgts); undefine ext undefine xfail +undefine regexf undefine tgts -- 2.47.3