• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SPDX-License-Identifier: GPL-2.0-only
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
18# Load targets for building eBPF helpers man page.
19include ../../Makefile.helpers
20
21MAN8_RST = $(wildcard bpftool*.rst)
22
23_DOC_MAN8 = $(patsubst %.rst,%.8,$(MAN8_RST))
24DOC_MAN8 = $(addprefix $(OUTPUT),$(_DOC_MAN8))
25
26man: man8 helpers
27man8: $(DOC_MAN8)
28
29RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
30RST2MAN_OPTS += --verbose
31
32list_pages = $(sort $(basename $(filter-out $(1),$(MAN8_RST))))
33see_also = $(subst " ",, \
34	"\n" \
35	"SEE ALSO\n" \
36	"========\n" \
37	"\t**bpf**\ (2),\n" \
38	"\t**bpf-helpers**\\ (7)" \
39	$(foreach page,$(call list_pages,$(1)),",\n\t**$(page)**\\ (8)") \
40	"\n")
41
42$(OUTPUT)%.8: %.rst
43ifndef RST2MAN_DEP
44	$(error "rst2man not found, but required to generate man pages")
45endif
46	$(QUIET_GEN)( cat $< ; printf "%b" $(call see_also,$<) ) | rst2man $(RST2MAN_OPTS) > $@
47
48clean: helpers-clean
49	$(call QUIET_CLEAN, Documentation)
50	$(Q)$(RM) $(DOC_MAN8)
51
52install: man helpers-install
53	$(call QUIET_INSTALL, Documentation-man)
54	$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
55	$(Q)$(INSTALL) -m 644 $(DOC_MAN8) $(DESTDIR)$(man8dir)
56
57uninstall: helpers-uninstall
58	$(call QUIET_UNINST, Documentation-man)
59	$(Q)$(RM) $(addprefix $(DESTDIR)$(man8dir)/,$(_DOC_MAN8))
60	$(Q)$(RMDIR) $(DESTDIR)$(man8dir)
61
62.PHONY: man man8 clean install uninstall
63.DEFAULT_GOAL := man
64