]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
src.mk: Optimize pipeline
authorAlejandro Colomar <alx@kernel.org>
Fri, 14 Apr 2023 15:12:30 +0000 (17:12 +0200)
committerAlejandro Colomar <alx@kernel.org>
Fri, 14 Apr 2023 15:37:41 +0000 (17:37 +0200)
This pipeline is run for every make(1) invokation, and it was very slow,
due to running a new sed(1) process for every manual page.  Remove the
while loop, and rewrite so that all the commands in the pipeline are
only run once.  This brings times down ~10x in my system, from 1.5 s, to
just 0.14 s.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
share/mk/build/src.mk

index 747cbd39850d9b7ff0ed07b6447b6c376ff46be9..365d6c8e6f7e15b9bfba1090bd44263975edca83 100644 (file)
@@ -60,11 +60,9 @@ _SRCPAGEDIRS   := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.d,$(NONSO_MAN))
 _UNITS_src_src := $(patsubst $(MANDIR)/%,$(_MANDIR)/%,$(shell \
                $(FIND) $(MANDIR)/man*/ -type f \
                | $(GREP) '$(MANEXT)' \
-               | $(XARGS) $(GREP) -l '^\.TH ' \
-               | while read m; do \
-                   <$$m \
-                   $(SED) -n "s,^\... SRC BEGIN (\(.*.[ch]\))$$,$$m.d/\1,p"; \
-               done \
+               | $(XARGS) $(GREP) -H '^\.\\" SRC BEGIN ' \
+               | $(SED) 's,:\.\\" SRC BEGIN (,.d/,' \
+               | $(SED) 's/)//' \
                | $(SORT)))
 _UNITS_src_h   := $(filter %.h,$(_UNITS_src_src))
 _UNITS_src_c   := $(filter %.c,$(_UNITS_src_src))