Merge tag 'trace-v5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux-2.6-microblaze.git] / tools / bpf / bpftool / Documentation / Makefile
1 # SPDX-License-Identifier: GPL-2.0-only
2 include ../../../scripts/Makefile.include
3 include ../../../scripts/utilities.mak
4
5 INSTALL ?= install
6 RM ?= rm -f
7 RMDIR ?= rmdir --ignore-fail-on-non-empty
8
9 ifeq ($(V),1)
10   Q =
11 else
12   Q = @
13 endif
14
15 prefix ?= /usr/local
16 mandir ?= $(prefix)/man
17 man8dir = $(mandir)/man8
18
19 # Load targets for building eBPF helpers man page.
20 include ../../Makefile.helpers
21
22 MAN8_RST = $(wildcard bpftool*.rst)
23
24 _DOC_MAN8 = $(patsubst %.rst,%.8,$(MAN8_RST))
25 DOC_MAN8 = $(addprefix $(OUTPUT),$(_DOC_MAN8))
26
27 man: man8 helpers
28 man8: $(DOC_MAN8)
29
30 RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
31 RST2MAN_OPTS += --verbose
32
33 list_pages = $(sort $(basename $(filter-out $(1),$(MAN8_RST))))
34 see_also = $(subst " ",, \
35         "\n" \
36         "SEE ALSO\n" \
37         "========\n" \
38         "\t**bpf**\ (2),\n" \
39         "\t**bpf-helpers**\\ (7)" \
40         $(foreach page,$(call list_pages,$(1)),",\n\t**$(page)**\\ (8)") \
41         "\n")
42
43 $(OUTPUT)%.8: %.rst
44 ifndef RST2MAN_DEP
45         $(error "rst2man not found, but required to generate man pages")
46 endif
47         $(QUIET_GEN)( cat $< ; printf "%b" $(call see_also,$<) ) | rst2man $(RST2MAN_OPTS) > $@
48
49 clean: helpers-clean
50         $(call QUIET_CLEAN, Documentation)
51         $(Q)$(RM) $(DOC_MAN8)
52
53 install: man helpers-install
54         $(call QUIET_INSTALL, Documentation-man)
55         $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
56         $(Q)$(INSTALL) -m 644 $(DOC_MAN8) $(DESTDIR)$(man8dir)
57
58 uninstall: helpers-uninstall
59         $(call QUIET_UNINST, Documentation-man)
60         $(Q)$(RM) $(addprefix $(DESTDIR)$(man8dir)/,$(_DOC_MAN8))
61         $(Q)$(RMDIR) $(DESTDIR)$(man8dir)
62
63 .PHONY: man man8 clean install uninstall
64 .DEFAULT_GOAL := man