2 include ../scripts/Makefile.include
3 include ../scripts/utilities.mak
5 # Assume Makefile.helpers is being run from bpftool/Documentation
6 # subdirectory. Go up two more directories to fetch bpf.h header and
13 RMDIR ?= rmdir --ignore-fail-on-non-empty
22 mandir ?= $(prefix)/man
23 man7dir = $(mandir)/man7
25 HELPERS_RST = bpf-helpers.rst
26 MAN7_RST = $(HELPERS_RST)
28 _DOC_MAN7 = $(patsubst %.rst,%.7,$(MAN7_RST))
29 DOC_MAN7 = $(addprefix $(OUTPUT),$(_DOC_MAN7))
34 RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
36 $(OUTPUT)$(HELPERS_RST): $(UP2DIR)../../include/uapi/linux/bpf.h
37 $(QUIET_GEN)$(UP2DIR)../../scripts/bpf_helpers_doc.py --filename $< > $@
39 $(OUTPUT)%.7: $(OUTPUT)%.rst
41 $(error "rst2man not found, but required to generate man pages")
43 $(QUIET_GEN)rst2man $< > $@
46 $(call QUIET_CLEAN, eBPF_helpers-manpage)
47 $(Q)$(RM) $(DOC_MAN7) $(OUTPUT)$(HELPERS_RST)
49 helpers-install: helpers
50 $(call QUIET_INSTALL, eBPF_helpers-manpage)
51 $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
52 $(Q)$(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
55 $(call QUIET_UNINST, eBPF_helpers-manpage)
56 $(Q)$(RM) $(addprefix $(DESTDIR)$(man7dir)/,$(_DOC_MAN7))
57 $(Q)$(RMDIR) $(DESTDIR)$(man7dir)
59 .PHONY: helpers helpers-clean helpers-install helpers-uninstall