summaryrefslogtreecommitdiffstats
path: root/doc/Makefile.in
blob: 1777da58a5b8ff2a4b66834b7c4068cb0f71a300 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
ADOC = asciidoctor
ADOC_FLAGS =
SED = sed
HTML_TO_TXT = w3m -dump -T text/html

MAN_FILES = chrony.conf.man chronyc.man chronyd.man
TXT_FILES = faq.txt installation.txt
HTML_FILES = $(MAN_FILES:%.man=%.html) $(TXT_FILES:%.txt=%.html)
MAN_IN_FILES = $(MAN_FILES:%.man=%.man.in)

SYSCONFDIR = @SYSCONFDIR@
BINDIR = @BINDIR@
SBINDIR = @SBINDIR@
MANDIR = @MANDIR@
DOCDIR = @DOCDIR@
CHRONYRUNDIR = @CHRONYRUNDIR@
CHRONYVARDIR = @CHRONYVARDIR@
CHRONY_VERSION = @CHRONY_VERSION@
DEFAULT_USER = @DEFAULT_USER@
DEFAULT_HWCLOCK_FILE = @DEFAULT_HWCLOCK_FILE@
DEFAULT_PID_FILE = @DEFAULT_PID_FILE@
DEFAULT_RTC_DEVICE = @DEFAULT_RTC_DEVICE@

SED_COMMANDS = "s%\@SYSCONFDIR\@%$(SYSCONFDIR)%g;\
	       s%\@BINDIR\@%$(BINDIR)%g;\
	       s%\@SBINDIR\@%$(SBINDIR)%g;\
	       s%\@CHRONY_VERSION\@%$(CHRONY_VERSION)%g;\
	       s%\@DEFAULT_HWCLOCK_FILE\@%$(DEFAULT_HWCLOCK_FILE)%g;\
	       s%\@DEFAULT_PID_FILE\@%$(DEFAULT_PID_FILE)%g;\
	       s%\@DEFAULT_RTC_DEVICE\@%$(DEFAULT_RTC_DEVICE)%g;\
	       s%\@DEFAULT_USER\@%$(DEFAULT_USER)%g;\
	       s%\@CHRONYRUNDIR\@%$(CHRONYRUNDIR)%g;\
	       s%\@CHRONYVARDIR\@%$(CHRONYVARDIR)%g;"

man: $(MAN_FILES) $(MAN_IN_FILES)
html: $(HTML_FILES)
txt: $(TXT_FILES)
docs: man html

%.html: %.adoc
	$(ADOC) $(ADOC_FLAGS) -b html -o - $< | $(SED) -e $(SED_COMMANDS) > $@

%.man.in: %.adoc
	$(ADOC) $(ADOC_FLAGS) -b manpage -o $@ $<

%.man: %.man.in
	$(SED) -e $(SED_COMMANDS) < $< > $@

%.txt: %.html
	$(HTML_TO_TXT) < $< > $@

install: $(MAN_FILES)
	[ -d $(DESTDIR)$(MANDIR)/man1 ] || mkdir -p $(DESTDIR)$(MANDIR)/man1
	[ -d $(DESTDIR)$(MANDIR)/man5 ] || mkdir -p $(DESTDIR)$(MANDIR)/man5
	[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
	cp chronyc.man $(DESTDIR)$(MANDIR)/man1/chronyc.1
	chmod 644 $(DESTDIR)$(MANDIR)/man1/chronyc.1
	cp chronyd.man $(DESTDIR)$(MANDIR)/man8/chronyd.8
	chmod 644 $(DESTDIR)$(MANDIR)/man8/chronyd.8
	cp chrony.conf.man $(DESTDIR)$(MANDIR)/man5/chrony.conf.5
	chmod 644 $(DESTDIR)$(MANDIR)/man5/chrony.conf.5

install-docs: $(HTML_FILES)
	[ -d $(DESTDIR)$(DOCDIR) ] || mkdir -p $(DESTDIR)$(DOCDIR)
	for f in $(HTML_FILES); do \
	  cp $$f $(DESTDIR)$(DOCDIR); \
	  chmod 644 $(DESTDIR)$(DOCDIR)/$$f; \
	done

clean:
	rm -f $(MAN_FILES) $(TXT_FILES) $(HTML_FILES)
	rm -f $(MAN_IN_FILES)

distclean:
	rm -f $(MAN_FILES) $(TXT_FILES) $(HTML_FILES)
	rm -f Makefile