]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
*.mk: Handle pathnames with ':'
authorAlejandro Colomar <alx@kernel.org>
Tue, 25 Apr 2023 23:39:22 +0000 (01:39 +0200)
committerAlejandro Colomar <alx@kernel.org>
Wed, 26 Apr 2023 21:35:50 +0000 (23:35 +0200)
Since make(1) uses ':' as a special character in rules, it needs to be
handled carefully.  A way to make it work is to escape it with '\:'.  We
can use sed(1) to do that right when we get the pathnames.  The only
problem with ':' is in rules' targets and prerequisites: everywhere else
it's fine; so let's discuss what needs to be done in those places:

-  In the targets, it's as easy as escaping.

-  In prerequisites, we can't second-expand variables containing such
   pathnames, as the '\' would not be used by make(1) to escape the ':',
   but it would be interpreted as part of the pathname.  This means we
   need to expand rules written using second expansion into several
   rules that only expand their variables once.

-  $(wildcard ...) also performs the escape, so after using it the
   pathnames are not escaped.  If we used those variables in targets, we
   would need to escape the ':'s again, but since we don't we can skip
   that.  The trick to make this work is to second-expand these
   variables.

Link: <https://stackoverflow.com/a/76096683/6872717>
Cc: GNU Make <bug-make@gnu.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
share/mk/build/_.mk
share/mk/build/src.mk
share/mk/dist.mk
share/mk/install/man.mk
share/mk/lint/man/man.mk
share/mk/src.mk

index a02301ff10ec91b88f78f016e30c1686f1857308..6cc82007348a59cbfb12e032a4659e02e738391b 100644 (file)
@@ -26,11 +26,13 @@ RM    := rm
 NONSO_MAN := $(shell $(FIND) $(MANDIR)/man*/ -type f \
                | $(GREP) '$(MANEXT)' \
                | $(XARGS) $(GREP) -l '^\.TH ' \
-               | $(SORT))
+               | $(SORT) \
+               | $(SED) 's,:,\\:,g')
 NONSO_MDOC := $(shell $(FIND) $(MANDIR)/man*/ -type f \
                | $(GREP) '$(MANEXT)' \
                | $(XARGS) $(GREP) -l '^\.Dt ' \
-               | $(SORT))
+               | $(SORT) \
+               | $(SED) 's,:,\\:,g')
 
 
 $(builddir)/%/:
index fcee7fa4355a520b0b1c76bde1ad0f5e97c8a4fb..4da142a74ec5eb1c54f3415aa3730a9afaa67dcf 100644 (file)
@@ -62,7 +62,8 @@ _UNITS_src_src := $(patsubst $(MANDIR)/%,$(_MANDIR)/%,$(shell \
                | $(XARGS) $(GREP) -H '^\.\\" SRC BEGIN ' \
                | $(SED) 's,:\.\\" SRC BEGIN (,.d/,' \
                | $(SED) 's/)//' \
-               | $(SORT)))
+               | $(SORT) \
+               | $(SED) 's,:,\\:,g'))
 _UNITS_src_h   := $(filter %.h,$(_UNITS_src_src))
 _UNITS_src_c   := $(filter %.c,$(_UNITS_src_src))
 _UNITS_src_o   := $(patsubst %.c,%.o,$(_UNITS_src_c))
index da76e7bf30af8b92ee193ba305d00cc7f960c94b..90e2870e5c58be23302d0cb25e21c1f5786dfc11 100644 (file)
@@ -27,7 +27,9 @@ EXTRA_TARFLAGS   :=
 TARFLAGS         := $(DEFAULT_TARFLAGS) $(EXTRA_TARFLAGS)
 
 
-DISTFILES   := $(shell $(GIT) ls-files $(HIDE_ERR) | $(SED) 's,^,$(srcdir)/,')
+DISTFILES   := $(shell $(GIT) ls-files $(HIDE_ERR) \
+                       | $(SED) 's,^,$(srcdir)/,' \
+                       | $(SED) 's,:,\\:,g')
 _DISTFILES  := $(patsubst $(srcdir)/%,$(_DISTDIR)/%,$(DISTFILES))
 _DISTPAGES  := $(filter     $(_DISTDIR)/man%,$(_DISTFILES))
 _DISTOTHERS := $(filter-out $(_DISTDIR)/man%,$(_DISTFILES))
index f1043a9d629bc934f0f5c81e78241a5ea41effe8..caafe5e093911c61651a0c99af2dea7395cb804f 100644 (file)
@@ -191,8 +191,30 @@ $(_mandirs_rmdir): $(_mandir)/man%/-rmdir: $$(_man%pages_rm) FORCE
 $(_mandir_rmdir): $(uninstall_manX) FORCE
 
 
-.PHONY: $(install_manX)
-$(install_manX): install-man%: $$(_man%pages);
+.PHONY: install-man1
+install-man1:      $(_man1pages);
+.PHONY: install-man2
+install-man2:      $(_man2pages);
+.PHONY: install-man2type
+install-man2type:  $(_man2typepages);
+.PHONY: install-man3
+install-man3:      $(_man3pages);
+.PHONY: install-man3const
+install-man3const: $(_man3constpages);
+.PHONY: install-man3head
+install-man3head:  $(_man3headpages);
+.PHONY: install-man3type
+install-man3type:  $(_man3typepages);
+.PHONY: install-man4
+install-man4:      $(_man4pages);
+.PHONY: install-man5
+install-man5:      $(_man5pages);
+.PHONY: install-man6
+install-man6:      $(_man6pages);
+.PHONY: install-man7
+install-man7:      $(_man7pages);
+.PHONY: install-man8
+install-man8:      $(_man8pages);
 
 .PHONY: install-man
 install-man: $(install_manX);
index 4b3d1db8b8c1551216a5abe3bc1a695f12f633ba..a3f2ae9607cd9d22a11ab3c818efa59f04071308 100644 (file)
@@ -60,8 +60,10 @@ $(_LINT_man_tbl): $(_MANDIR)/%.lint-man.tbl.touch: $(MANDIR)/% | $$(@D)/
        touch $@
 
 
-.PHONY: $(lint_man)
-$(lint_man): lint-man-%: $$(_LINT_man_%);
+.PHONY: lint-man-mandoc
+lint-man-mandoc: $(_LINT_man_mandoc);
+.PHONY: lint-man-tbl
+lint-man-tbl:    $(_LINT_man_tbl);
 
 .PHONY: lint-man
 lint-man: $(lint_man);
index 256b6ca855215fc938ad179e5cbc06f05d1b5d02..84ebcb97feac9e39d6b894f72c1b124798a199f5 100644 (file)
@@ -17,7 +17,8 @@ MANEXT := \.[0-9]\w*$
 
 MANPAGES := $(shell $(FIND) $(MANDIR)/man*/ -type f \
                | $(GREP) '$(MANEXT)' \
-               | $(SORT))
+               | $(SORT) \
+               | $(SED) 's,:,\\:,g')
 MANDIRS  := $(shell $(FIND) $(MANDIR)/man* -type d \
                | $(SORT))