GNU Linux-libre 4.19.264-gnu1
[releases.git] / tools / bpf / bpftool / Documentation / Makefile
1 include ../../../scripts/Makefile.include
2 include ../../../scripts/utilities.mak
3
4 INSTALL ?= install
5 RM ?= rm -f
6 RMDIR ?= rmdir --ignore-fail-on-non-empty
7
8 ifeq ($(V),1)
9   Q =
10 else
11   Q = @
12 endif
13
14 prefix ?= /usr/local
15 mandir ?= $(prefix)/man
16 man8dir = $(mandir)/man8
17
18 # Load targets for building eBPF helpers man page.
19 include ../../Makefile.helpers
20
21 MAN8_RST = $(filter-out $(HELPERS_RST),$(wildcard *.rst))
22
23 _DOC_MAN8 = $(patsubst %.rst,%.8,$(MAN8_RST))
24 DOC_MAN8 = $(addprefix $(OUTPUT),$(_DOC_MAN8))
25
26 man: man8 helpers
27 man8: $(DOC_MAN8)
28
29 RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
30
31 $(OUTPUT)%.8: %.rst
32 ifndef RST2MAN_DEP
33         $(error "rst2man not found, but required to generate man pages")
34 endif
35         $(QUIET_GEN)rst2man $< > $@
36
37 clean: helpers-clean
38         $(call QUIET_CLEAN, Documentation)
39         $(Q)$(RM) $(DOC_MAN8)
40
41 install: man helpers-install
42         $(call QUIET_INSTALL, Documentation-man)
43         $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
44         $(Q)$(INSTALL) -m 644 $(DOC_MAN8) $(DESTDIR)$(man8dir)
45
46 uninstall: helpers-uninstall
47         $(call QUIET_UNINST, Documentation-man)
48         $(Q)$(RM) $(addprefix $(DESTDIR)$(man8dir)/,$(_DOC_MAN8))
49         $(Q)$(RMDIR) $(DESTDIR)$(man8dir)
50
51 .PHONY: man man8 clean install uninstall
52 .DEFAULT_GOAL := man