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