Makefile.helpers 1.5 KB

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