]>
Commit | Line | Data |
---|---|---|
eec79e02 AC |
1 | # Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> |
2 | # SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception | |
0110da57 AC |
3 | |
4 | ||
5 | ifndef MAKEFILE_INSTALL_MAN_INCLUDED | |
6 | MAKEFILE_INSTALL_MAN_INCLUDED := 1 | |
7 | ||
8 | ||
16322535 AC |
9 | include $(MAKEFILEDIR)/configure/build-depends/bzip2/bzip2.mk |
10 | include $(MAKEFILEDIR)/configure/build-depends/coreutils/install.mk | |
11 | include $(MAKEFILEDIR)/configure/build-depends/coreutils/ln.mk | |
12 | include $(MAKEFILEDIR)/configure/build-depends/coreutils/test.mk | |
13 | include $(MAKEFILEDIR)/configure/build-depends/findutils/xargs.mk | |
14 | include $(MAKEFILEDIR)/configure/build-depends/grep/grep.mk | |
15 | include $(MAKEFILEDIR)/configure/build-depends/gzip/gzip.mk | |
16 | include $(MAKEFILEDIR)/configure/build-depends/lzip/lzip.mk | |
17 | include $(MAKEFILEDIR)/configure/build-depends/moreutils/sponge.mk | |
18 | include $(MAKEFILEDIR)/configure/build-depends/sed/sed.mk | |
19 | include $(MAKEFILEDIR)/configure/build-depends/xz-utils/xz.mk | |
57d0f8b4 AC |
20 | include $(MAKEFILEDIR)/configure/directory_variables/install.mk |
21 | include $(MAKEFILEDIR)/configure/directory_variables/src.mk | |
22 | include $(MAKEFILEDIR)/configure/man/link_pages.mk | |
23 | include $(MAKEFILEDIR)/configure/man/z.mk | |
edaa12e6 | 24 | include $(MAKEFILEDIR)/install/_.mk |
57d0f8b4 | 25 | include $(MAKEFILEDIR)/src/man.mk |
8bb88d5f AC |
26 | |
27 | ||
c988f384 | 28 | _mandir := $(DESTDIR)$(mandir) |
402d0926 | 29 | $(foreach s, $(MANSECTIONS), \ |
c988f384 AC |
30 | $(eval _man$(s)dir := $(DESTDIR)$(man$(s)dir))) |
31 | ||
402d0926 | 32 | $(foreach s, $(MANSECTIONS), \ |
c988f384 | 33 | $(eval _man$(s)pages := \ |
333bd846 | 34 | $(patsubst $(MAN$(s)DIR)/%.$(s), $(_man$(s)dir)/%$(man$(s)ext)$(Z), \ |
c988f384 | 35 | $(MAN$(s)PAGES)))) |
333bd846 AC |
36 | $(foreach s, $(MANSECTIONS), \ |
37 | $(eval _man$(s)intropage := \ | |
38 | $(patsubst $(MAN$(s)DIR)/%.$(s), $(_man$(s)dir)/%$(man$(s)ext)$(Z), \ | |
39 | $(MAN$(s)INTROPAGE)))) | |
40 | _manintropages := $(foreach s, $(MANSECTIONS), $(_man$(s)intropage)) | |
402d0926 | 41 | _manpages := $(_manintropages) $(foreach s, $(MANSECTIONS), $(_man$(s)pages)) |
c988f384 AC |
42 | |
43 | _manintropages_rm := $(addsuffix -rm, $(wildcard $(_manintropages))) | |
402d0926 | 44 | $(foreach s, $(MANSECTIONS), \ |
c988f384 AC |
45 | $(eval _man$(s)pages_rm := \ |
46 | $(addsuffix -rm, \ | |
47 | $(wildcard $(_man$(s)pages))))) | |
48 | ||
49 | ||
402d0926 | 50 | $(foreach s, $(MANSECTIONS), \ |
333bd846 AC |
51 | $(eval $(_man$(s)pages) $(_man$(s)intropage): \ |
52 | $(_man$(s)dir)/%$(man$(s)ext)$(Z): \ | |
63d245ab | 53 | $(_MANDIR)/man$(s)/%.$(s) $(MK) | $$$$(@D)/)) |
04fdef68 AC |
54 | |
55 | ||
56 | $(_manpages): | |
d965e737 | 57 | $(info $(INFO_)INSTALL $@) |
30c38a8b | 58 | <$< \ |
ee0086c3 | 59 | $(SED) $(foreach s, $(MANSECTIONS), \ |
1cf32969 | 60 | -e '/^\.so /s, man$(s)/\(.*\)\.$(s)$$, $(notdir $(man$(s)dir))/\1$(man$(s)ext)$(Z),') \ |
30c38a8b | 61 | | $(INSTALL_DATA) -T /dev/stdin $@ |
335acbfb AC |
62 | ifeq ($(LINK_PAGES),symlink) |
63 | if $(GREP) '^\.so ' <$@ >/dev/null; then \ | |
c4d8bc8f | 64 | $(GREP) '^\.so ' <$@ \ |
701ed069 | 65 | | $(SED) 's,^\.so \(.*\),../\1,' \ |
335acbfb AC |
66 | | $(XARGS) -I tgt $(LN) -fsT tgt $@; \ |
67 | fi | |
68 | endif | |
6a828d5b AC |
69 | ifeq ($(Z),.bz2) |
70 | if ! $(TEST) -L $@; then \ | |
c2fffefb | 71 | $(BZIP2) $(BZIP2FLAGS) <$@ \ |
6a828d5b AC |
72 | | $(SPONGE) $@; \ |
73 | fi | |
74 | else ifeq ($(Z),.gz) | |
1a35f5b7 | 75 | if ! $(TEST) -L $@; then \ |
799cfcf2 | 76 | $(GZIP) $(GZIPFLAGS) <$@ \ |
1a35f5b7 AC |
77 | | $(SPONGE) $@; \ |
78 | fi | |
b220bc5b AC |
79 | else ifeq ($(Z),.lz) |
80 | if ! $(TEST) -L $@; then \ | |
799cfcf2 | 81 | $(LZIP) $(LZIPFLAGS) <$@ \ |
b220bc5b AC |
82 | | $(SPONGE) $@; \ |
83 | fi | |
db579553 AC |
84 | else ifeq ($(Z),.xz) |
85 | if ! $(TEST) -L $@; then \ | |
799cfcf2 | 86 | $(XZ) $(XZFLAGS) <$@ \ |
db579553 AC |
87 | | $(SPONGE) $@; \ |
88 | fi | |
1a35f5b7 | 89 | endif |
0110da57 | 90 | |
0110da57 | 91 | |
ad0321aa AC |
92 | .PHONY: install-manintro |
93 | install-manintro: $(_manintropages); | |
402d0926 | 94 | $(foreach s, $(MANSECTIONS), \ |
c988f384 | 95 | $(eval .PHONY: install-man$(s))) |
402d0926 | 96 | $(foreach s, $(MANSECTIONS), \ |
c988f384 | 97 | $(eval install-man$(s): $(_man$(s)pages);)) |
0110da57 | 98 | .PHONY: install-man |
402d0926 | 99 | install-man: install-manintro $(foreach s, $(MANSECTIONS), install-man$(s)); |
0110da57 | 100 | |
ad0321aa AC |
101 | .PHONY: uninstall-manintro |
102 | uninstall-manintro: $(_manintropages_rm); | |
402d0926 | 103 | $(foreach s, $(MANSECTIONS), \ |
c988f384 | 104 | $(eval .PHONY: uninstall-man$(s))) |
402d0926 | 105 | $(foreach s, $(MANSECTIONS), \ |
c988f384 | 106 | $(eval uninstall-man$(s): $(_man$(s)pages_rm);)) |
0110da57 | 107 | .PHONY: uninstall-man |
402d0926 | 108 | uninstall-man: uninstall-manintro $(foreach s, $(MANSECTIONS), uninstall-man$(s)); |
0110da57 AC |
109 | |
110 | ||
b8d2c839 | 111 | endif # include guard |