Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0-only
0002 
0003 include ../../../scripts/Makefile.include
0004 include ../../../scripts/utilities.mak
0005 
0006 INSTALL ?= install
0007 RM ?= rm -f
0008 RMDIR ?= rmdir --ignore-fail-on-non-empty
0009 
0010 ifeq ($(V),1)
0011   Q =
0012 else
0013   Q = @
0014 endif
0015 
0016 prefix ?= /usr/local
0017 mandir ?= $(prefix)/man
0018 man2dir = $(mandir)/man2
0019 man7dir = $(mandir)/man7
0020 
0021 SYSCALL_RST = bpf-syscall.rst
0022 MAN2_RST = $(SYSCALL_RST)
0023 
0024 HELPERS_RST = bpf-helpers.rst
0025 MAN7_RST = $(HELPERS_RST)
0026 
0027 _DOC_MAN2 = $(patsubst %.rst,%.2,$(MAN2_RST))
0028 DOC_MAN2 = $(addprefix $(OUTPUT),$(_DOC_MAN2))
0029 
0030 _DOC_MAN7 = $(patsubst %.rst,%.7,$(MAN7_RST))
0031 DOC_MAN7 = $(addprefix $(OUTPUT),$(_DOC_MAN7))
0032 
0033 DOCTARGETS := helpers syscall
0034 
0035 docs: $(DOCTARGETS)
0036 syscall: man2
0037 helpers: man7
0038 man2: $(DOC_MAN2)
0039 man7: $(DOC_MAN7)
0040 
0041 RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
0042 
0043 # Configure make rules for the man page bpf-$1.$2.
0044 # $1 - target for scripts/bpf_doc.py
0045 # $2 - man page section to generate the troff file
0046 define DOCS_RULES =
0047 $(OUTPUT)bpf-$1.rst: ../../../../include/uapi/linux/bpf.h
0048         $$(QUIET_GEN)../../../../scripts/bpf_doc.py $1 \
0049                 --filename $$< > $$@
0050 
0051 $(OUTPUT)%.$2: $(OUTPUT)%.rst
0052 ifndef RST2MAN_DEP
0053         $$(error "rst2man not found, but required to generate man pages")
0054 endif
0055         $$(QUIET_GEN)rst2man --exit-status=1 $$< > $$@.tmp
0056         $$(QUIET_GEN)mv $$@.tmp $$@
0057 
0058 docs-clean-$1:
0059         $$(call QUIET_CLEAN, eBPF_$1-manpage)
0060         $(Q)$(RM) $$(DOC_MAN$2) $(OUTPUT)bpf-$1.rst
0061 
0062 docs-install-$1: docs
0063         $$(call QUIET_INSTALL, eBPF_$1-manpage)
0064         $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$$(man$2dir)
0065         $(Q)$(INSTALL) -m 644 $$(DOC_MAN$2) $(DESTDIR)$$(man$2dir)
0066 
0067 docs-uninstall-$1:
0068         $$(call QUIET_UNINST, eBPF_$1-manpage)
0069         $(Q)$(RM) $$(addprefix $(DESTDIR)$$(man$2dir)/,$$(_DOC_MAN$2))
0070         $(Q)$(RMDIR) $(DESTDIR)$$(man$2dir)
0071 
0072 .PHONY: $1 docs-clean-$1 docs-install-$1 docs-uninstall-$1
0073 endef
0074 
0075 # Create the make targets to generate manual pages by name and section
0076 $(eval $(call DOCS_RULES,helpers,7))
0077 $(eval $(call DOCS_RULES,syscall,2))
0078 
0079 docs-clean: $(foreach doctarget,$(DOCTARGETS), docs-clean-$(doctarget))
0080 docs-install: $(foreach doctarget,$(DOCTARGETS), docs-install-$(doctarget))
0081 docs-uninstall: $(foreach doctarget,$(DOCTARGETS), docs-uninstall-$(doctarget))
0082 
0083 .PHONY: docs docs-clean docs-install docs-uninstall man2 man7