11a8b597dSQuentin Monnet# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2ff69c21aSJakub Kicinskiinclude ../../../scripts/Makefile.include 3ff69c21aSJakub Kicinski 4ff69c21aSJakub KicinskiINSTALL ?= install 5ff69c21aSJakub KicinskiRM ?= rm -f 6d3244248SQuentin MonnetRMDIR ?= rmdir --ignore-fail-on-non-empty 7ff69c21aSJakub Kicinski 8658e85aaSQuentin Monnetprefix ?= /usr/local 9658e85aaSQuentin Monnetmandir ?= $(prefix)/man 10ff69c21aSJakub Kicinskiman8dir = $(mandir)/man8 11ff69c21aSJakub Kicinski 12f28ef96dSQuentin MonnetMAN8_RST = $(wildcard bpftool*.rst) 13ff69c21aSJakub Kicinski 14ff69c21aSJakub Kicinski_DOC_MAN8 = $(patsubst %.rst,%.8,$(MAN8_RST)) 15ff69c21aSJakub KicinskiDOC_MAN8 = $(addprefix $(OUTPUT),$(_DOC_MAN8)) 16ff69c21aSJakub Kicinski 17a01d935bSJoe Stringerman: man8 18ff69c21aSJakub Kicinskiman8: $(DOC_MAN8) 19ff69c21aSJakub Kicinski 2092426820SQuentin MonnetRST2MAN_DEP := $(shell command -v rst2man 2>/dev/null) 2143448428SQuentin MonnetRST2MAN_OPTS += --verbose --strip-comments 2292426820SQuentin Monnet 2318841da9SQuentin Monnetlist_pages = $(sort $(basename $(filter-out $(1),$(MAN8_RST)))) 2418841da9SQuentin Monnetsee_also = $(subst " ",, \ 2518841da9SQuentin Monnet "\n" \ 2618841da9SQuentin Monnet "SEE ALSO\n" \ 2718841da9SQuentin Monnet "========\n" \ 28*f7b68543SRameez Rehman "**bpf**\ (2),\n" \ 29*f7b68543SRameez Rehman "**bpf-helpers**\\ (7)" \ 30*f7b68543SRameez Rehman $(foreach page,$(call list_pages,$(1)),",\n**$(page)**\\ (8)") \ 3118841da9SQuentin Monnet "\n") 3218841da9SQuentin Monnet 33ff69c21aSJakub Kicinski$(OUTPUT)%.8: %.rst 3492426820SQuentin Monnetifndef RST2MAN_DEP 3592426820SQuentin Monnet $(error "rst2man not found, but required to generate man pages") 3692426820SQuentin Monnetendif 3763bea244SYonghong Song $(QUIET_GEN)( cat $< ; printf "%b" $(call see_also,$<) ) | rst2man $(RST2MAN_OPTS) > $@ 38ff69c21aSJakub Kicinski 39a01d935bSJoe Stringerclean: 40658e85aaSQuentin Monnet $(call QUIET_CLEAN, Documentation) 41658e85aaSQuentin Monnet $(Q)$(RM) $(DOC_MAN8) 42ff69c21aSJakub Kicinski 43a01d935bSJoe Stringerinstall: man 44658e85aaSQuentin Monnet $(call QUIET_INSTALL, Documentation-man) 45658e85aaSQuentin Monnet $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(man8dir) 46658e85aaSQuentin Monnet $(Q)$(INSTALL) -m 644 $(DOC_MAN8) $(DESTDIR)$(man8dir) 47ff69c21aSJakub Kicinski 48a01d935bSJoe Stringeruninstall: 49d3244248SQuentin Monnet $(call QUIET_UNINST, Documentation-man) 50d3244248SQuentin Monnet $(Q)$(RM) $(addprefix $(DESTDIR)$(man8dir)/,$(_DOC_MAN8)) 51d3244248SQuentin Monnet $(Q)$(RMDIR) $(DESTDIR)$(man8dir) 52d3244248SQuentin Monnet 53d3244248SQuentin Monnet.PHONY: man man8 clean install uninstall 54ff69c21aSJakub Kicinski.DEFAULT_GOAL := man 55