File: Makefile

package info (click to toggle)
trace-cmd 3.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,992 kB
  • sloc: ansic: 33,557; makefile: 967; python: 604; sh: 400
file content (112 lines) | stat: -rw-r--r-- 2,816 bytes parent folder | download | duplicates (3)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# SPDX-License-Identifier: GPL-2.0

# Include the utils
include $(src)/scripts/utils.mk

# This Makefile and manpage XSL files were taken from libtracefs
# and modified for libtracecmd

MAN3_TXT= \
	$(wildcard libtracecmd-*.txt) \
	libtracecmd.txt

MAN_TXT = $(MAN3_TXT)
_MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
_MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
_DOC_MAN3=$(patsubst %.txt,%.m,$(MAN3_TXT))

MAN_XML=$(addprefix $(OUTPUT),$(_MAN_XML))
MAN_HTML=$(addprefix $(OUTPUT),$(_MAN_HTML))
DOC_MAN3=$(addprefix $(OUTPUT),$(_DOC_MAN3))

# Make the path relative to DESTDIR, not prefix
ifndef DESTDIR
prefix?=$(HOME)
endif
bindir?=$(prefix)/bin
htmldir?=$(prefix)/share/doc/libtracecmd-doc
pdfdir?=$(prefix)/share/doc/libtracecmd-doc
mandir?=$(prefix)/share/man
man3dir=$(mandir)/man3

ifdef USE_ASCIIDOCTOR
ASCIIDOC_EXTRA += -a mansource="libtracecmd" -a manmanual="libtracecmd Manual"
endif

all: check-man-tools html man

man: man3
man3: $(DOC_MAN3)

html: $(MAN_HTML)

$(MAN_HTML) $(DOC_MAN3): $(ASCIIDOC_CONF)

install: check-man-tools install-man install-html

check-man-tools:
ifdef missing_tools
	$(error "You need to install $(missing_tools) for man pages")
endif

install-%.3: $(OUTPUT)%.3
	$(Q)$(call do_install_docs,$<,$(man3dir),644);

do-install-man: man $(addprefix install-,$(wildcard $(OUTPUT)*.3))

install-man: man
	$(Q)$(MAKE) -C . do-install-man

install-%.txt: $(OUTPUT)%.html
	$(Q)$(call do_install_docs,$<,$(htmldir),644);

do-install-html: html $(addprefix install-,$(wildcard *.txt))

install-html: html do-install-html

uninstall: uninstall-man uninstall-html

uninstall-man:
	$(Q)$(RM) $(addprefix $(DESTDIR)$(man3dir)/,$(DOC_MAN3))

uninstall-html:
	$(Q)$(RM) $(addprefix $(DESTDIR)$(htmldir)/,$(MAN_HTML))

ifdef missing_tools
  DO_INSTALL_MAN = $(warning Please install $(missing_tools) to have the man pages installed)
else
  DO_INSTALL_MAN = do-install-man
endif

CLEAN_FILES =					\
	$(MAN_XML) $(addsuffix +,$(MAN_XML))	\
	$(MAN_HTML) $(addsuffix +,$(MAN_HTML))	\
	$(DOC_MAN3) *.3 *.m

clean:
	$(Q) $(RM) $(CLEAN_FILES)

ifdef USE_ASCIIDOCTOR
$(OUTPUT)%.m : $(OUTPUT)%.txt
	$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
	$(ASCIIDOC) -b manpage -d manpage \
		$(ASCIIDOC_EXTRA) -alibtracecmd_version=$(LIBTRACECMD_VERSION) -o $@+ $< && \
	mv $@+ $@
endif

$(OUTPUT)%.m : $(OUTPUT)%.xml
	$(QUIET_XMLTO)$(RM) $@ && \
	$(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<; \
	touch $@

$(OUTPUT)%.xml : %.txt
	$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
	$(ASCIIDOC) -b docbook -d manpage \
		$(ASCIIDOC_EXTRA) -alibtracecmd_version=$(LIBTRACECMD_VERSION) -o $@+ $< && \
	mv $@+ $@

$(MAN_HTML): $(OUTPUT)%.html : %.txt
	$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
	$(ASCIIDOC) -b $(ASCIIDOC_HTML) -d manpage \
		$(ASCIIDOC_EXTRA) -alibtracecmd_version=$(LIBTRACECMD_VERSION) -o $@+ $< && \
	mv $@+ $@