Makefile.helpers 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. ifndef allow-override
  3. include ../scripts/Makefile.include
  4. include ../scripts/utilities.mak
  5. else
  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 := ../../
  10. endif
  11. INSTALL ?= install
  12. RM ?= rm -f
  13. RMDIR ?= rmdir --ignore-fail-on-non-empty
  14. ifeq ($(V),1)
  15. Q =
  16. else
  17. Q = @
  18. endif
  19. prefix ?= /usr/local
  20. mandir ?= $(prefix)/man
  21. man7dir = $(mandir)/man7
  22. HELPERS_RST = bpf-helpers.rst
  23. MAN7_RST = $(HELPERS_RST)
  24. _DOC_MAN7 = $(patsubst %.rst,%.7,$(MAN7_RST))
  25. DOC_MAN7 = $(addprefix $(OUTPUT),$(_DOC_MAN7))
  26. helpers: man7
  27. man7: $(DOC_MAN7)
  28. RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
  29. $(OUTPUT)$(HELPERS_RST): $(UP2DIR)../../include/uapi/linux/bpf.h
  30. $(QUIET_GEN)$(UP2DIR)../../scripts/bpf_helpers_doc.py --filename $< > $@
  31. $(OUTPUT)%.7: $(OUTPUT)%.rst
  32. ifndef RST2MAN_DEP
  33. $(error "rst2man not found, but required to generate man pages")
  34. endif
  35. $(QUIET_GEN)rst2man $< > $@
  36. helpers-clean:
  37. $(call QUIET_CLEAN, eBPF_helpers-manpage)
  38. $(Q)$(RM) $(DOC_MAN7) $(OUTPUT)$(HELPERS_RST)
  39. helpers-install: helpers
  40. $(call QUIET_INSTALL, eBPF_helpers-manpage)
  41. $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
  42. $(Q)$(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
  43. helpers-uninstall:
  44. $(call QUIET_UNINST, eBPF_helpers-manpage)
  45. $(Q)$(RM) $(addprefix $(DESTDIR)$(man7dir)/,$(_DOC_MAN7))
  46. $(Q)$(RMDIR) $(DESTDIR)$(man7dir)
  47. .PHONY: helpers helpers-clean helpers-install helpers-uninstall