xref: /linux/Documentation/tools/rtla/Makefile (revision cbac924200b838cfb8d8b1415113d788089dc50b)
1# SPDX-License-Identifier: GPL-2.0-only
2# Based on bpftool's Documentation Makefile
3
4INSTALL		?= install
5RM		?= rm -f
6RMDIR		?= rmdir --ignore-fail-on-non-empty
7
8PREFIX		?= /usr/share
9MANDIR		?= $(PREFIX)/man
10MAN1DIR		= $(MANDIR)/man1
11
12MAN1_RST	= $(wildcard rtla*.rst)
13
14_DOC_MAN1	= $(patsubst %.rst,%.1,$(MAN1_RST))
15DOC_MAN1	= $(addprefix $(OUTPUT),$(_DOC_MAN1))
16
17RST2MAN_DEP	:= $(shell command -v rst2man 2>/dev/null)
18RST2MAN_OPTS	+= --verbose
19
20$(OUTPUT)%.1: %.rst
21ifndef RST2MAN_DEP
22	$(error "rst2man not found, but required to generate man pages")
23endif
24	rst2man $(RST2MAN_OPTS) $< > $@
25
26man1: $(DOC_MAN1)
27man: man1
28
29clean:
30	$(RM) $(DOC_MAN1)
31
32install: man
33	$(INSTALL) -d -m 755 $(DESTDIR)$(MAN1DIR)
34	$(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(MAN1DIR)
35
36uninstall:
37	$(RM) $(addprefix $(DESTDIR)$(MAN1DIR)/,$(_DOC_MAN1))
38	$(RMDIR) $(DESTDIR)$(MAN1DIR)
39
40.PHONY: man man1 clean install uninstall
41.DEFAULT_GOAL := man
42