1 # SPDX-License-Identifier: GPL-2.0-only
2 include ../../../scripts/Makefile.include
6 RMDIR ?= rmdir --ignore-fail-on-non-empty
15 mandir ?= $(prefix)/man
16 man8dir = $(mandir)/man8
18 # Load targets for building eBPF helpers man page.
19 include ../../Makefile.helpers
21 MAN8_RST = $(wildcard bpftool*.rst)
23 _DOC_MAN8 = $(patsubst %.rst,%.8,$(MAN8_RST))
24 DOC_MAN8 = $(addprefix $(OUTPUT),$(_DOC_MAN8))
29 RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
30 RST2MAN_OPTS += --verbose
32 list_pages = $(sort $(basename $(filter-out $(1),$(MAN8_RST))))
33 see_also = $(subst " ",, \
38 "\t**bpf-helpers**\\ (7)" \
39 $(foreach page,$(call list_pages,$(1)),",\n\t**$(page)**\\ (8)") \
44 $(error "rst2man not found, but required to generate man pages")
46 $(QUIET_GEN)( cat $< ; printf "%b" $(call see_also,$<) ) | rst2man $(RST2MAN_OPTS) > $@
49 $(call QUIET_CLEAN, Documentation)
52 install: 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)
57 uninstall: helpers-uninstall
58 $(call QUIET_UNINST, Documentation-man)
59 $(Q)$(RM) $(addprefix $(DESTDIR)$(man8dir)/,$(_DOC_MAN8))
60 $(Q)$(RMDIR) $(DESTDIR)$(man8dir)
62 .PHONY: man man8 clean install uninstall