1# SPDX-License-Identifier: GPL-2.0-only 2ifndef allow-override 3 include ../scripts/Makefile.include 4 include ../scripts/utilities.mak 5else 6 # Assume Makefile.helpers is being run from bpftool/Documentation 7 # subdirectory. Go up two more directories to fetch bpf.h header and 8 # associated script. 9 UP2DIR := ../../ 10endif 11 12INSTALL ?= install 13RM ?= rm -f 14RMDIR ?= rmdir --ignore-fail-on-non-empty 15 16ifeq ($(V),1) 17 Q = 18else 19 Q = @ 20endif 21 22prefix ?= /usr/local 23mandir ?= $(prefix)/man 24man7dir = $(mandir)/man7 25 26HELPERS_RST = bpf-helpers.rst 27MAN7_RST = $(HELPERS_RST) 28 29_DOC_MAN7 = $(patsubst %.rst,%.7,$(MAN7_RST)) 30DOC_MAN7 = $(addprefix $(OUTPUT),$(_DOC_MAN7)) 31 32helpers: man7 33man7: $(DOC_MAN7) 34 35RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null) 36 37$(OUTPUT)$(HELPERS_RST): $(UP2DIR)../../include/uapi/linux/bpf.h 38 $(QUIET_GEN)$(UP2DIR)../../scripts/bpf_helpers_doc.py --filename $< > $@ 39 40$(OUTPUT)%.7: $(OUTPUT)%.rst 41ifndef RST2MAN_DEP 42 $(error "rst2man not found, but required to generate man pages") 43endif 44 $(QUIET_GEN)rst2man $< > $@ 45 46helpers-clean: 47 $(call QUIET_CLEAN, eBPF_helpers-manpage) 48 $(Q)$(RM) $(DOC_MAN7) $(OUTPUT)$(HELPERS_RST) 49 50helpers-install: helpers 51 $(call QUIET_INSTALL, eBPF_helpers-manpage) 52 $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(man7dir) 53 $(Q)$(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir) 54 55helpers-uninstall: 56 $(call QUIET_UNINST, eBPF_helpers-manpage) 57 $(Q)$(RM) $(addprefix $(DESTDIR)$(man7dir)/,$(_DOC_MAN7)) 58 $(Q)$(RMDIR) $(DESTDIR)$(man7dir) 59 60.PHONY: helpers helpers-clean helpers-install helpers-uninstall 61