]> git.cworth.org Git - notmuch-old/blob - doc/Makefile.local
doc/emacs: add docstring and example for n-search-result-format
[notmuch-old] / doc / Makefile.local
1 # -*- makefile-gmake -*-
2
3 dir := doc
4
5 # You can set these variables from the command line.
6 SPHINXOPTS    := -q
7 SPHINXBUILD   = env LD_LIBRARY_PATH=${NOTMUCH_BUILDDIR}/lib sphinx-build
8 DOCBUILDDIR      := $(dir)/_build
9
10 # Internal variables.
11 ALLSPHINXOPTS   := $(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 ALL_RST_FILES := $(MAN_RST_FILES) $(srcdir)/doc/notmuch-emacs.rst
20
21 COPY_ROFF1 := $(patsubst %,$(DOCBUILDDIR)/man/man1/%.1,nmbug notmuch-setup)
22 MAN1_ROFF := $(patsubst $(srcdir)/doc/%,$(DOCBUILDDIR)/man/%,$(MAN1_RST:.rst=.1))
23 MAN1_ROFF := $(MAN1_ROFF) $(COPY_ROFF1)
24 MAN5_ROFF := $(patsubst $(srcdir)/doc/%,$(DOCBUILDDIR)/man/%,$(MAN5_RST:.rst=.5))
25 MAN7_ROFF := $(patsubst $(srcdir)/doc/%,$(DOCBUILDDIR)/man/%,$(MAN7_RST:.rst=.7))
26 MAN_ROFF_FILES := $(MAN1_ROFF) $(MAN5_ROFF) $(MAN7_ROFF)
27
28 MAN_GZIP_FILES := $(addsuffix .gz,${MAN_ROFF_FILES})
29
30 MAN1_TEXI := $(patsubst $(srcdir)/doc/man1/%.rst,$(DOCBUILDDIR)/texinfo/%.texi,$(MAN1_RST))
31 MAN5_TEXI := $(patsubst $(srcdir)/doc/man5/%.rst,$(DOCBUILDDIR)/texinfo/%.texi,$(MAN5_RST))
32 MAN7_TEXI := $(patsubst $(srcdir)/doc/man7/%.rst,$(DOCBUILDDIR)/texinfo/%.texi,$(MAN7_RST))
33 INFO_TEXI_FILES := $(MAN1_TEXI) $(MAN5_TEXI) $(MAN7_TEXI)
34 ifeq ($(WITH_EMACS),1)
35         INFO_TEXI_FILES += $(DOCBUILDDIR)/texinfo/notmuch-emacs.texi
36 endif
37
38 COPY_INFO1 := $(patsubst $(DOCBUILDDIR)/man/man1/%.1,$(DOCBUILDDIR)/texinfo/%.info,$(COPY_ROFF1))
39 INFO_INFO_FILES := $(INFO_TEXI_FILES:.texi=.info) $(COPY_INFO1)
40
41 .PHONY: sphinx-html sphinx-texinfo sphinx-info
42
43 .PHONY: install-man build-man apidocs install-apidocs
44
45 %.gz: %
46         rm -f $@ && gzip --no-name --stdout $^ > $@
47
48 ifeq ($(WITH_EMACS),1)
49 $(DOCBUILDDIR)/.roff.stamp $(DOCBUILDDIR)/.html.stamp $(DOCBUILDDIR)/.texi.stamp : docstring.stamp
50 endif
51
52 ifeq ($(HAVE_PYTHON3_CFFI),1)
53 DOC_PREREQS=bindings/python-cffi.stamp
54 else
55 DOC_PREREQS=
56 endif
57
58 sphinx-html: $(DOCBUILDDIR)/.html.stamp
59
60 $(DOCBUILDDIR)/.html.stamp: $(ALL_RST_FILES) $(DOC_PREREQS)
61         $(SPHINXBUILD) -b html -d $(DOCBUILDDIR)/html_doctrees $(ALLSPHINXOPTS) $(DOCBUILDDIR)/html
62         touch $@
63
64 sphinx-texinfo: $(DOCBUILDDIR)/.texi.stamp
65
66 $(DOCBUILDDIR)/.texi.stamp: $(ALL_RST_FILES) $(DOC_PREREQS)
67         $(SPHINXBUILD) -b texinfo -d $(DOCBUILDDIR)/texinfo_doctrees $(ALLSPHINXOPTS) $(DOCBUILDDIR)/texinfo
68         touch $@
69
70 sphinx-info: $(DOCBUILDDIR)/.info.stamp
71
72 $(DOCBUILDDIR)/.info.stamp: $(DOCBUILDDIR)/.texi.stamp $(DOC_PREREQS)
73         $(MAKE) -C $(DOCBUILDDIR)/texinfo info
74         touch $@
75
76 # Use the man page converter that is available. We should never depend
77 # on MAN_ROFF_FILES if a converter is not available.
78 ${MAN_ROFF_FILES}: $(DOCBUILDDIR)/.roff.stamp
79
80 # By using $(DOCBUILDDIR)/.roff.stamp instead of ${MAN_ROFF_FILES}, we
81 # convey to make that a single invocation of this recipe builds all
82 # of the roff files.  This prevents parallel make from starting an
83 # instance of this recipe for each roff file.
84 $(DOCBUILDDIR)/.roff.stamp: ${MAN_RST_FILES}
85 ifeq ($(HAVE_SPHINX),1)
86         $(SPHINXBUILD) -b man -d $(DOCBUILDDIR)/man_doctrees $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
87         for section in 1 5 7; do \
88             mkdir -p $(DOCBUILDDIR)/man/man$${section}; \
89             mv $(DOCBUILDDIR)/man/*.$${section} $(DOCBUILDDIR)/man/man$${section}; \
90         done
91 else
92         @echo "Fatal: build dependency fail."
93         @false
94 endif
95         touch $@
96
97 install-man: install-apidocs
98
99 ifeq ($(HAVE_DOXYGEN),1)
100 MAN_GZIP_FILES += ${APIMAN}.gz
101 apidocs: $(APIMAN)
102 install-apidocs: ${APIMAN}.gz
103         mkdir -p "$(DESTDIR)$(mandir)/man3"
104         install -m0644 $(filter %.3.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man3
105
106 $(APIMAN): $(dir)/config.dox $(srcdir)/$(dir)/doxygen.cfg $(srcdir)/lib/notmuch.h
107         mkdir -p $(DOCBUILDDIR)/man/man3
108         doxygen $(DOXYFILE)
109         rm -f $(DOCBUILDDIR)/man/man3/_*.3
110         perl -pi -e 's/^[.]RI "\\fI/.RI "\\fP/' $(APIMAN)
111 else
112 apidocs:
113 install-apidocs:
114 endif
115
116 # Do not try to build or install man pages if a man page converter is
117 # not available.
118 ifeq ($(HAVE_SPHINX),0)
119 build-man:
120 install-man:
121         @echo "No sphinx, will not install man pages."
122 else
123
124 # it should be safe to depend on the stamp file, because it is created
125 # after all roff files are moved into place.
126 ${MAN_GZIP_FILES}: ${DOCBUILDDIR}/.roff.stamp
127
128 build-man: ${MAN_GZIP_FILES}
129 install-man: ${MAN_GZIP_FILES}
130         mkdir -m0755 -p "$(DESTDIR)$(mandir)/man1"
131         mkdir -m0755 -p "$(DESTDIR)$(mandir)/man5"
132         mkdir -m0755 -p "$(DESTDIR)$(mandir)/man7"
133         install -m0644 $(filter %.1.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man1
134         install -m0644 $(filter %.5.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man5
135         install -m0644 $(filter %.7.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man7
136 endif
137
138 ifneq ($(HAVE_SPHINX)$(HAVE_MAKEINFO),11)
139 build-info:
140         @echo "Missing sphinx or makeinfo, not building info pages"
141 else
142 build-info: $(DOCBUILDDIR)/.info.stamp
143 endif
144
145 ifneq ($(HAVE_SPHINX)$(HAVE_MAKEINFO)$(HAVE_INSTALL_INFO),111)
146 install-info:
147         @echo "Missing prerequisites, not installing info pages"
148 else
149 install-info: build-info
150         mkdir -m0755 -p "$(DESTDIR)$(infodir)"
151         install -m0644 $(INFO_INFO_FILES) $(DESTDIR)$(infodir)
152         for file in $(INFO_INFO_FILES); do install-info $$file $(DESTDIR)$(infodir)/dir; done
153 endif
154
155 $(dir)/config.dox: version.stamp
156         echo "PROJECT_NAME = \"Notmuch $(VERSION)\"" > $@
157         echo "INPUT=${srcdir}/lib/notmuch.h" >> $@
158
159 CLEAN := $(CLEAN) $(DOCBUILDDIR) $(DOCBUILDDIR)/.roff.stamp $(DOCBUILDDIR)/.texi.stamp
160 CLEAN := $(CLEAN) $(DOCBUILDDIR)/.html.stamp $(DOCBUILDDIR)/.info.stamp
161 CLEAN := $(CLEAN) $(MAN_GZIP_FILES) $(MAN_ROFF_FILES) $(dir)/conf.pyc $(dir)/config.dox