]> git.notmuchmail.org Git - notmuch/blob - doc/Makefile.local
Merge branch 'release'
[notmuch] / doc / Makefile.local
1 # -*- makefile -*-
2
3 dir := doc
4
5 # You can set these variables from the command line.
6 SPHINXOPTS    := -q
7 SPHINXBUILD   = sphinx-build
8 DOCBUILDDIR      := $(dir)/_build
9
10 # Internal variables.
11 ALLSPHINXOPTS   := -d $(DOCBUILDDIR)/doctrees $(SPHINXOPTS) $(srcdir)/$(dir)
12 APIMAN          := $(DOCBUILDDIR)/man/man3/notmuch.3
13 DOXYFILE        := $(srcdir)/$(dir)/doxygen.cfg
14
15 MAN1_RST := $(wildcard $(srcdir)/doc/man1/*.rst)
16 MAN5_RST := $(wildcard $(srcdir)/doc/man5/*.rst)
17 MAN7_RST := $(wildcard $(srcdir)/doc/man7/*.rst)
18 MAN_RST_FILES := $(MAN1_RST) $(MAN5_RST) $(MAN7_RST)
19
20 MAN1_ROFF := $(patsubst $(srcdir)/doc/%,$(DOCBUILDDIR)/man/%,$(MAN1_RST:.rst=.1))
21 MAN5_ROFF := $(patsubst $(srcdir)/doc/%,$(DOCBUILDDIR)/man/%,$(MAN5_RST:.rst=.5))
22 MAN7_ROFF := $(patsubst $(srcdir)/doc/%,$(DOCBUILDDIR)/man/%,$(MAN7_RST:.rst=.7))
23 MAN_ROFF_FILES := $(MAN1_ROFF) $(MAN5_ROFF) $(MAN7_ROFF)
24
25 MAN_GZIP_FILES := $(addsuffix .gz,${MAN_ROFF_FILES})
26
27 MAN1_TEXI := $(patsubst $(srcdir)/doc/man1/%.rst,$(DOCBUILDDIR)/texinfo/%.texi,$(MAN1_RST))
28 MAN5_TEXI := $(patsubst $(srcdir)/doc/man5/%.rst,$(DOCBUILDDIR)/texinfo/%.texi,$(MAN5_RST))
29 MAN7_TEXI := $(patsubst $(srcdir)/doc/man7/%.rst,$(DOCBUILDDIR)/texinfo/%.texi,$(MAN7_RST))
30 INFO_TEXI_FILES := $(MAN1_TEXI) $(MAN5_TEXI) $(MAN7_TEXI) $(DOCBUILDDIR)/texinfo/notmuch-emacs.texi
31 INFO_INFO_FILES := $(INFO_TEXI_FILES:.texi=.info)
32
33 .PHONY: sphinx-html sphinx-texinfo sphinx-info
34
35 .PHONY: install-man build-man apidocs install-apidocs
36
37 %.gz: %
38         rm -f $@ && gzip --stdout $^ > $@
39
40 ifeq ($(WITH_EMACS),1)
41 $(DOCBUILDDIR)/.roff.stamp sphinx-html sphinx-texinfo: docstring.stamp
42 endif
43
44 sphinx-html:
45         $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(DOCBUILDDIR)/html
46
47 sphinx-texinfo:
48         $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(DOCBUILDDIR)/texinfo
49
50 sphinx-info: sphinx-texinfo
51         make -C $(DOCBUILDDIR)/texinfo info
52
53 # Use the man page converter that is available. We should never depend
54 # on MAN_ROFF_FILES if a converter is not available.
55 ${MAN_ROFF_FILES}: $(DOCBUILDDIR)/.roff.stamp
56
57 # By using $(DOCBUILDDIR)/.roff.stamp instead of ${MAN_ROFF_FILES}, we
58 # convey to make that a single invocation of this recipe builds all
59 # of the roff files.  This prevents parallel make from starting an
60 # instance of this recipe for each roff file.
61 $(DOCBUILDDIR)/.roff.stamp: ${MAN_RST_FILES}
62 ifeq ($(HAVE_SPHINX),1)
63         $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
64         for section in 1 5 7; do \
65             mkdir -p $(DOCBUILDDIR)/man/man$${section}; \
66             mv $(DOCBUILDDIR)/man/*.$${section} $(DOCBUILDDIR)/man/man$${section}; \
67         done
68 else
69         @echo "Fatal: build dependency fail."
70         @false
71 endif
72         touch $@
73
74 install-man: install-apidocs
75
76 ifeq ($(HAVE_DOXYGEN),1)
77 MAN_GZIP_FILES += ${APIMAN}.gz
78 apidocs: $(APIMAN)
79 install-apidocs: ${APIMAN}.gz
80         mkdir -p "$(DESTDIR)$(mandir)/man3"
81         install -m0644 $(filter %.3.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man3
82
83 $(APIMAN): $(dir)/config.dox $(srcdir)/$(dir)/doxygen.cfg $(srcdir)/lib/notmuch.h
84         mkdir -p $(DOCBUILDDIR)/man/man3
85         doxygen $(DOXYFILE)
86         rm -f $(DOCBUILDDIR)/man/man3/_*.3
87         perl -pi -e 's/^[.]RI "\\fI/.RI "\\fP/' $(APIMAN)
88 else
89 apidocs:
90 install-apidocs:
91 endif
92
93 # Do not try to build or install man pages if a man page converter is
94 # not available.
95 ifeq ($(HAVE_SPHINX),0)
96 build-man:
97 install-man:
98         @echo "No sphinx, will not install man pages."
99 else
100 build-man: ${MAN_GZIP_FILES}
101 install-man: ${MAN_GZIP_FILES}
102         mkdir -m0755 -p "$(DESTDIR)$(mandir)/man1"
103         mkdir -m0755 -p "$(DESTDIR)$(mandir)/man5"
104         mkdir -m0755 -p "$(DESTDIR)$(mandir)/man7"
105         install -m0644 $(filter %.1.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man1
106         install -m0644 $(filter %.5.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man5
107         install -m0644 $(filter %.7.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man7
108         cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz
109 endif
110
111 ifneq ($(HAVE_SPHINX)$(HAVE_MAKEINFO),11)
112 build-info:
113         @echo "Missing sphinx or makeinfo, not building info pages"
114 else
115 build-info: sphinx-info
116 endif
117
118 ifneq ($(HAVE_SPHINX)$(HAVE_MAKEINFO)$(HAVE_INSTALL_INFO),111)
119 install-info:
120         @echo "Missing prerequisites, not installing info pages"
121 else
122 install-info: build-info
123         mkdir -m0755 -p "$(DESTDIR)$(infodir)"
124         install -m0644 $(INFO_INFO_FILES) $(DESTDIR)$(infodir)
125         for file in $(INFO_INFO_FILES); do install-info $$file $(DESTDIR)$(infodir)/dir; done
126 endif
127
128 $(dir)/config.dox: version.stamp
129         echo "PROJECT_NAME = \"Notmuch $(VERSION)\"" > $@
130         echo "INPUT=${srcdir}/lib/notmuch.h" >> $@
131
132 CLEAN := $(CLEAN) $(DOCBUILDDIR) $(DOCBUILDDIR)/.roff.stamp
133 CLEAN := $(CLEAN) $(MAN_GZIP_FILES) $(MAN_ROFF_FILES) $(dir)/conf.pyc $(dir)/config.dox