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>
_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))