0001
0002 include ../../../scripts/Makefile.include
0003
0004 INSTALL ?= install
0005 RM ?= rm -f
0006 RMDIR ?= rmdir --ignore-fail-on-non-empty
0007
0008 ifeq ($(V),1)
0009 Q =
0010 else
0011 Q = @
0012 endif
0013
0014 prefix ?= /usr/local
0015 mandir ?= $(prefix)/man
0016 man8dir = $(mandir)/man8
0017
0018 MAN8_RST = $(wildcard bpftool*.rst)
0019
0020 _DOC_MAN8 = $(patsubst %.rst,%.8,$(MAN8_RST))
0021 DOC_MAN8 = $(addprefix $(OUTPUT),$(_DOC_MAN8))
0022
0023 man: man8
0024 man8: $(DOC_MAN8)
0025
0026 RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
0027 RST2MAN_OPTS += --verbose --strip-comments
0028
0029 list_pages = $(sort $(basename $(filter-out $(1),$(MAN8_RST))))
0030 see_also = $(subst " ",, \
0031 "\n" \
0032 "SEE ALSO\n" \
0033 "========\n" \
0034 "\t**bpf**\ (2),\n" \
0035 "\t**bpf-helpers**\\ (7)" \
0036 $(foreach page,$(call list_pages,$(1)),",\n\t**$(page)**\\ (8)") \
0037 "\n")
0038
0039 $(OUTPUT)%.8: %.rst
0040 ifndef RST2MAN_DEP
0041 $(error "rst2man not found, but required to generate man pages")
0042 endif
0043 $(QUIET_GEN)( cat $< ; printf "%b" $(call see_also,$<) ) | rst2man $(RST2MAN_OPTS) > $@
0044
0045 clean:
0046 $(call QUIET_CLEAN, Documentation)
0047 $(Q)$(RM) $(DOC_MAN8)
0048
0049 install: man
0050 $(call QUIET_INSTALL, Documentation-man)
0051 $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
0052 $(Q)$(INSTALL) -m 644 $(DOC_MAN8) $(DESTDIR)$(man8dir)
0053
0054 uninstall:
0055 $(call QUIET_UNINST, Documentation-man)
0056 $(Q)$(RM) $(addprefix $(DESTDIR)$(man8dir)/,$(_DOC_MAN8))
0057 $(Q)$(RMDIR) $(DESTDIR)$(man8dir)
0058
0059 .PHONY: man man8 clean install uninstall
0060 .DEFAULT_GOAL := man