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