1 # -*- makefile-gmake -*-
5 # You can set these variables from the command line.
7 SPHINXBUILD = env LD_LIBRARY_PATH=${NOTMUCH_BUILDDIR}/lib sphinx-build
8 DOCBUILDDIR := $(dir)/_build
11 ALLSPHINXOPTS := $(SPHINXOPTS) $(srcdir)/$(dir)
12 APIMAN := $(DOCBUILDDIR)/man/man3/notmuch.3
13 DOXYFILE := $(srcdir)/$(dir)/doxygen.cfg
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
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)
28 MAN_GZIP_FILES := $(addsuffix .gz,${MAN_ROFF_FILES})
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
38 COPY_INFO1 := $(patsubst $(DOCBUILDDIR)/man/man1/%.1,$(DOCBUILDDIR)/texinfo/%.info,$(COPY_ROFF1))
39 INFO_INFO_FILES := $(INFO_TEXI_FILES:.texi=.info) $(COPY_INFO1)
41 .PHONY: sphinx-html sphinx-texinfo sphinx-info
43 .PHONY: install-man build-man apidocs install-apidocs
46 rm -f $@ && gzip --no-name --stdout $^ > $@
48 ifeq ($(WITH_EMACS),1)
49 $(DOCBUILDDIR)/.roff.stamp $(DOCBUILDDIR)/.html.stamp $(DOCBUILDDIR)/.texi.stamp : docstring.stamp
52 ifeq ($(HAVE_PYTHON3_CFFI),1)
53 DOC_PREREQS=bindings/python-cffi.stamp
58 sphinx-html: $(DOCBUILDDIR)/.html.stamp
60 $(DOCBUILDDIR)/.html.stamp: $(ALL_RST_FILES) $(DOC_PREREQS)
61 $(SPHINXBUILD) -b html -d $(DOCBUILDDIR)/html_doctrees $(ALLSPHINXOPTS) $(DOCBUILDDIR)/html
64 sphinx-texinfo: $(DOCBUILDDIR)/.texi.stamp
66 $(DOCBUILDDIR)/.texi.stamp: $(ALL_RST_FILES) $(DOC_PREREQS)
67 $(SPHINXBUILD) -b texinfo -d $(DOCBUILDDIR)/texinfo_doctrees $(ALLSPHINXOPTS) $(DOCBUILDDIR)/texinfo
70 sphinx-info: $(DOCBUILDDIR)/.info.stamp
72 $(DOCBUILDDIR)/.info.stamp: $(DOCBUILDDIR)/.texi.stamp $(DOC_PREREQS)
73 $(MAKE) -C $(DOCBUILDDIR)/texinfo info
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
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}; \
92 @echo "Fatal: build dependency fail."
97 install-man: install-apidocs
99 ifeq ($(HAVE_DOXYGEN),1)
100 MAN_GZIP_FILES += ${APIMAN}.gz
102 install-apidocs: ${APIMAN}.gz
103 mkdir -p "$(DESTDIR)$(mandir)/man3"
104 install -m0644 $(filter %.3.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man3
106 $(APIMAN): $(dir)/config.dox $(srcdir)/$(dir)/doxygen.cfg $(srcdir)/lib/notmuch.h
107 mkdir -p $(DOCBUILDDIR)/man/man3
109 rm -f $(DOCBUILDDIR)/man/man3/_*.3
110 perl -pi -e 's/^[.]RI "\\fI/.RI "\\fP/' $(APIMAN)
116 # Do not try to build or install man pages if a man page converter is
118 ifeq ($(HAVE_SPHINX),0)
121 @echo "No sphinx, will not install man pages."
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
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
138 ifneq ($(HAVE_SPHINX)$(HAVE_MAKEINFO),11)
140 @echo "Missing sphinx or makeinfo, not building info pages"
142 build-info: $(DOCBUILDDIR)/.info.stamp
145 ifneq ($(HAVE_SPHINX)$(HAVE_MAKEINFO)$(HAVE_INSTALL_INFO),111)
147 @echo "Missing prerequisites, not installing info pages"
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
155 $(dir)/config.dox: version.stamp
156 echo "PROJECT_NAME = \"Notmuch $(VERSION)\"" > $@
157 echo "INPUT=${srcdir}/lib/notmuch.h" >> $@
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