summaryrefslogtreecommitdiffstats
path: root/Documentation/tools/rtla/Makefile
blob: 093af6d7a0e93da0f8b96e19757cf731f95922df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# SPDX-License-Identifier: GPL-2.0-only
# Based on bpftool's Documentation Makefile

INSTALL		?= install
RM		?= rm -f
RMDIR		?= rmdir --ignore-fail-on-non-empty

PREFIX		?= /usr/share
MANDIR		?= $(PREFIX)/man
MAN1DIR		= $(MANDIR)/man1

MAN1_RST	= $(wildcard rtla*.rst)

_DOC_MAN1	= $(patsubst %.rst,%.1,$(MAN1_RST))
DOC_MAN1	= $(addprefix $(OUTPUT),$(_DOC_MAN1))

RST2MAN_DEP	:= $(shell command -v rst2man 2>/dev/null)
RST2MAN_OPTS	+= --verbose

TEST_RST2MAN = $(shell sh -c "rst2man --version > /dev/null 2>&1 || echo n")

$(OUTPUT)%.1: %.rst
ifndef RST2MAN_DEP
	$(info ********************************************)
	$(info ** NOTICE: rst2man not found)
	$(info **)
	$(info ** Consider installing the latest rst2man from your)
	$(info ** distribution, e.g., 'dnf install python3-docutils' on Fedora,)
	$(info ** or from source:)
	$(info **)
	$(info **  https://docutils.sourceforge.io/docs/dev/repository.html )
	$(info **)
	$(info ********************************************)
	$(error NOTICE: rst2man required to generate man pages)
endif
	rst2man $(RST2MAN_OPTS) $< > $@

man1: $(DOC_MAN1)
man: man1

clean:
	$(RM) $(DOC_MAN1)

install: man
	$(INSTALL) -d -m 755 $(DESTDIR)$(MAN1DIR)
	$(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(MAN1DIR)

uninstall:
	$(RM) $(addprefix $(DESTDIR)$(MAN1DIR)/,$(_DOC_MAN1))
	$(RMDIR) $(DESTDIR)$(MAN1DIR)

.PHONY: man man1 clean install uninstall
.DEFAULT_GOAL := man