]>
Commit | Line | Data |
---|---|---|
0dbc1ea9 AC |
1 | # Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> |
2 | # SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception | |
3 | ||
4 | ||
5 | ifndef MAKEFILE_BUILD_EX_SRC_INCLUDED | |
6 | MAKEFILE_BUILD_EX_SRC_INCLUDED := 1 | |
7 | ||
8 | ||
9 | include $(MAKEFILEDIR)/build/_.mk | |
16322535 AC |
10 | include $(MAKEFILEDIR)/configure/build-depends/coreutils/head.mk |
11 | include $(MAKEFILEDIR)/configure/build-depends/findutils/find.mk | |
12 | include $(MAKEFILEDIR)/configure/build-depends/findutils/xargs.mk | |
13 | include $(MAKEFILEDIR)/configure/build-depends/grep/grep.mk | |
14 | include $(MAKEFILEDIR)/configure/build-depends/mandoc/mandoc.mk | |
15 | include $(MAKEFILEDIR)/configure/build-depends/sed/sed.mk | |
0dbc1ea9 AC |
16 | include $(MAKEFILEDIR)/configure/directory_variables.mk |
17 | include $(MAKEFILEDIR)/src.mk | |
18 | ||
19 | ||
20 | _UNITS_ex_src := \ | |
21 | $(patsubst $(MANDIR)/%, $(_MANDIR)/%, \ | |
22 | $(shell \ | |
23 | $(FIND) $(MANDIR)/* -type f \ | |
24 | | $(GREP) '$(MANEXT)' \ | |
25 | | $(XARGS) $(GREP) -H '^\.\\" SRC BEGIN ' \ | |
26 | | $(SED) 's,:\.\\" SRC BEGIN (,.d/,' \ | |
27 | | $(SED) 's/)//' \ | |
28 | | $(SORTMAN) \ | |
29 | | $(SED) 's,:,\\:,g' \ | |
30 | ) \ | |
31 | ) | |
32 | _UNITS_ex_h := $(filter %.h,$(_UNITS_ex_src)) | |
33 | _UNITS_ex_c := $(filter %.c,$(_UNITS_ex_src)) | |
34 | ||
35 | ||
36 | $(_UNITS_ex_src): $$(patsubst $(_MANDIR)/%.d,$(MANDIR)/%,$$(@D)) $(MK) | $$(@D)/ | |
37 | $(_UNITS_ex_c): $$(filter $$(@D)/%.h,$(_UNITS_ex_h)) | |
38 | $(_UNITS_ex_src): | |
d965e737 | 39 | $(info $(INFO_)SED $@) |
0dbc1ea9 AC |
40 | <$< \ |
41 | $(SED) -n \ | |
42 | -e '/^\.TH/,/^\.SH/{/^\.SH/!p}' \ | |
43 | -e '/^\.SH EXAMPLES/p' \ | |
44 | -e "/^\... SRC BEGIN ($(@F))$$/,/^\... SRC END$$/p" \ | |
45 | | $(MANDOC) -Tutf8 \ | |
281f7e72 | 46 | | $(HEAD) -n-2 \ |
0dbc1ea9 AC |
47 | | $(SED) '/^[^ ]/d' \ |
48 | | $(SED) 's/^ //' \ | |
49 | >$@ | |
50 | ||
51 | ||
52 | .PHONY: build-ex-src | |
53 | build-ex-src: $(_UNITS_ex_src); | |
54 | ||
55 | ||
56 | endif # include guard |