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