Loading...
1# SPDX-License-Identifier: GPL-2.0-only
2include ../../../scripts/Makefile.include
3include ../../../scripts/utilities.mak
4
5INSTALL ?= install
6RM ?= rm -f
7RMDIR ?= rmdir --ignore-fail-on-non-empty
8
9ifeq ($(V),1)
10 Q =
11else
12 Q = @
13endif
14
15prefix ?= /usr/local
16mandir ?= $(prefix)/man
17man8dir = $(mandir)/man8
18
19MAN8_RST = $(wildcard bpftool*.rst)
20
21_DOC_MAN8 = $(patsubst %.rst,%.8,$(MAN8_RST))
22DOC_MAN8 = $(addprefix $(OUTPUT),$(_DOC_MAN8))
23
24man: man8
25man8: $(DOC_MAN8)
26
27RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
28RST2MAN_OPTS += --verbose
29
30list_pages = $(sort $(basename $(filter-out $(1),$(MAN8_RST))))
31see_also = $(subst " ",, \
32 "\n" \
33 "SEE ALSO\n" \
34 "========\n" \
35 "\t**bpf**\ (2),\n" \
36 "\t**bpf-helpers**\\ (7)" \
37 $(foreach page,$(call list_pages,$(1)),",\n\t**$(page)**\\ (8)") \
38 "\n")
39
40$(OUTPUT)%.8: %.rst
41ifndef RST2MAN_DEP
42 $(error "rst2man not found, but required to generate man pages")
43endif
44 $(QUIET_GEN)( cat $< ; printf "%b" $(call see_also,$<) ) | rst2man $(RST2MAN_OPTS) > $@
45
46clean:
47 $(call QUIET_CLEAN, Documentation)
48 $(Q)$(RM) $(DOC_MAN8)
49
50install: man
51 $(call QUIET_INSTALL, Documentation-man)
52 $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
53 $(Q)$(INSTALL) -m 644 $(DOC_MAN8) $(DESTDIR)$(man8dir)
54
55uninstall:
56 $(call QUIET_UNINST, Documentation-man)
57 $(Q)$(RM) $(addprefix $(DESTDIR)$(man8dir)/,$(_DOC_MAN8))
58 $(Q)$(RMDIR) $(DESTDIR)$(man8dir)
59
60.PHONY: man man8 clean install uninstall
61.DEFAULT_GOAL := man
1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2include ../../../scripts/Makefile.include
3
4INSTALL ?= install
5RM ?= rm -f
6RMDIR ?= rmdir --ignore-fail-on-non-empty
7
8ifeq ($(V),1)
9 Q =
10else
11 Q = @
12endif
13
14prefix ?= /usr/local
15mandir ?= $(prefix)/man
16man8dir = $(mandir)/man8
17
18MAN8_RST = $(wildcard bpftool*.rst)
19
20_DOC_MAN8 = $(patsubst %.rst,%.8,$(MAN8_RST))
21DOC_MAN8 = $(addprefix $(OUTPUT),$(_DOC_MAN8))
22
23man: man8
24man8: $(DOC_MAN8)
25
26RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
27RST2MAN_OPTS += --verbose --strip-comments
28
29list_pages = $(sort $(basename $(filter-out $(1),$(MAN8_RST))))
30see_also = $(subst " ",, \
31 "\n" \
32 "SEE ALSO\n" \
33 "========\n" \
34 "\t**bpf**\ (2),\n" \
35 "\t**bpf-helpers**\\ (7)" \
36 $(foreach page,$(call list_pages,$(1)),",\n\t**$(page)**\\ (8)") \
37 "\n")
38
39$(OUTPUT)%.8: %.rst
40ifndef RST2MAN_DEP
41 $(error "rst2man not found, but required to generate man pages")
42endif
43 $(QUIET_GEN)( cat $< ; printf "%b" $(call see_also,$<) ) | rst2man $(RST2MAN_OPTS) > $@
44
45clean:
46 $(call QUIET_CLEAN, Documentation)
47 $(Q)$(RM) $(DOC_MAN8)
48
49install: man
50 $(call QUIET_INSTALL, Documentation-man)
51 $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
52 $(Q)$(INSTALL) -m 644 $(DOC_MAN8) $(DESTDIR)$(man8dir)
53
54uninstall:
55 $(call QUIET_UNINST, Documentation-man)
56 $(Q)$(RM) $(addprefix $(DESTDIR)$(man8dir)/,$(_DOC_MAN8))
57 $(Q)$(RMDIR) $(DESTDIR)$(man8dir)
58
59.PHONY: man man8 clean install uninstall
60.DEFAULT_GOAL := man