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