1 # SPDX-License-Identifier: GPL-2.0-only
3 include ../scripts/Makefile.include
4 include ../scripts/utilities.mak
6 # Assume Makefile.helpers is being run from bpftool/Documentation
7 # subdirectory. Go up two more directories to fetch bpf.h header and
14 RMDIR ?= rmdir --ignore-fail-on-non-empty
23 mandir ?= $(prefix)/man
24 man7dir = $(mandir)/man7
26 HELPERS_RST = bpf-helpers.rst
27 MAN7_RST = $(HELPERS_RST)
29 _DOC_MAN7 = $(patsubst %.rst,%.7,$(MAN7_RST))
30 DOC_MAN7 = $(addprefix $(OUTPUT),$(_DOC_MAN7))
35 RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
37 $(OUTPUT)$(HELPERS_RST): $(UP2DIR)../../include/uapi/linux/bpf.h
38 $(QUIET_GEN)$(UP2DIR)../../scripts/bpf_helpers_doc.py --filename $< > $@
40 $(OUTPUT)%.7: $(OUTPUT)%.rst
42 $(error "rst2man not found, but required to generate man pages")
44 $(QUIET_GEN)rst2man $< > $@
47 $(call QUIET_CLEAN, eBPF_helpers-manpage)
48 $(Q)$(RM) $(DOC_MAN7) $(OUTPUT)$(HELPERS_RST)
50 helpers-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)
56 $(call QUIET_UNINST, eBPF_helpers-manpage)
57 $(Q)$(RM) $(addprefix $(DESTDIR)$(man7dir)/,$(_DOC_MAN7))
58 $(Q)$(RMDIR) $(DESTDIR)$(man7dir)
60 .PHONY: helpers helpers-clean helpers-install helpers-uninstall