5 # You can set these variables from the command line.
7 SPHINXBUILD = HAVE_EMACS=${HAVE_EMACS} WITH_EMACS=${WITH_EMACS} 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 MAN1_ROFF := $(patsubst $(srcdir)/doc/%,$(DOCBUILDDIR)/man/%,$(MAN1_RST:.rst=.1))
22 MAN5_ROFF := $(patsubst $(srcdir)/doc/%,$(DOCBUILDDIR)/man/%,$(MAN5_RST:.rst=.5))
23 MAN7_ROFF := $(patsubst $(srcdir)/doc/%,$(DOCBUILDDIR)/man/%,$(MAN7_RST:.rst=.7))
24 MAN_ROFF_FILES := $(MAN1_ROFF) $(MAN5_ROFF) $(MAN7_ROFF)
26 MAN_GZIP_FILES := $(addsuffix .gz,${MAN_ROFF_FILES})
28 MAN1_TEXI := $(patsubst $(srcdir)/doc/man1/%.rst,$(DOCBUILDDIR)/texinfo/%.texi,$(MAN1_RST))
29 MAN5_TEXI := $(patsubst $(srcdir)/doc/man5/%.rst,$(DOCBUILDDIR)/texinfo/%.texi,$(MAN5_RST))
30 MAN7_TEXI := $(patsubst $(srcdir)/doc/man7/%.rst,$(DOCBUILDDIR)/texinfo/%.texi,$(MAN7_RST))
31 INFO_TEXI_FILES := $(MAN1_TEXI) $(MAN5_TEXI) $(MAN7_TEXI) $(DOCBUILDDIR)/texinfo/notmuch-emacs.texi
32 INFO_INFO_FILES := $(INFO_TEXI_FILES:.texi=.info)
34 .PHONY: sphinx-html sphinx-texinfo sphinx-info
36 .PHONY: install-man build-man apidocs install-apidocs
39 rm -f $@ && gzip --stdout $^ > $@
41 ifeq ($(WITH_EMACS),1)
42 $(DOCBUILDDIR)/.roff.stamp sphinx-html sphinx-texinfo: docstring.stamp
45 sphinx-html: $(DOCBUILDDIR)/.html.stamp
47 $(DOCBUILDDIR)/.html.stamp: $(ALL_RST_FILES)
48 $(SPHINXBUILD) -b html -d $(DOCBUILDDIR)/html_doctrees $(ALLSPHINXOPTS) $(DOCBUILDDIR)/html
51 sphinx-texinfo: $(DOCBUILDDIR)/.texi.stamp
53 $(DOCBUILDDIR)/.texi.stamp: $(ALL_RST_FILES)
54 $(SPHINXBUILD) -b texinfo -d $(DOCBUILDDIR)/texinfo_doctrees $(ALLSPHINXOPTS) $(DOCBUILDDIR)/texinfo
57 sphinx-info: sphinx-texinfo
58 $(MAKE) -C $(DOCBUILDDIR)/texinfo info
60 # Use the man page converter that is available. We should never depend
61 # on MAN_ROFF_FILES if a converter is not available.
62 ${MAN_ROFF_FILES}: $(DOCBUILDDIR)/.roff.stamp
64 # By using $(DOCBUILDDIR)/.roff.stamp instead of ${MAN_ROFF_FILES}, we
65 # convey to make that a single invocation of this recipe builds all
66 # of the roff files. This prevents parallel make from starting an
67 # instance of this recipe for each roff file.
68 $(DOCBUILDDIR)/.roff.stamp: ${MAN_RST_FILES}
69 ifeq ($(HAVE_SPHINX),1)
70 $(SPHINXBUILD) -b man -d $(DOCBUILDDIR)/man_doctrees $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
71 for section in 1 5 7; do \
72 mkdir -p $(DOCBUILDDIR)/man/man$${section}; \
73 mv $(DOCBUILDDIR)/man/*.$${section} $(DOCBUILDDIR)/man/man$${section}; \
76 @echo "Fatal: build dependency fail."
81 install-man: install-apidocs
83 ifeq ($(HAVE_DOXYGEN),1)
84 MAN_GZIP_FILES += ${APIMAN}.gz
86 install-apidocs: ${APIMAN}.gz
87 mkdir -p "$(DESTDIR)$(mandir)/man3"
88 install -m0644 $(filter %.3.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man3
90 $(APIMAN): $(dir)/config.dox $(srcdir)/$(dir)/doxygen.cfg $(srcdir)/lib/notmuch.h
91 mkdir -p $(DOCBUILDDIR)/man/man3
93 rm -f $(DOCBUILDDIR)/man/man3/_*.3
94 perl -pi -e 's/^[.]RI "\\fI/.RI "\\fP/' $(APIMAN)
100 # Do not try to build or install man pages if a man page converter is
102 ifeq ($(HAVE_SPHINX),0)
105 @echo "No sphinx, will not install man pages."
107 build-man: ${MAN_GZIP_FILES}
108 install-man: ${MAN_GZIP_FILES}
109 mkdir -m0755 -p "$(DESTDIR)$(mandir)/man1"
110 mkdir -m0755 -p "$(DESTDIR)$(mandir)/man5"
111 mkdir -m0755 -p "$(DESTDIR)$(mandir)/man7"
112 install -m0644 $(filter %.1.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man1
113 install -m0644 $(filter %.5.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man5
114 install -m0644 $(filter %.7.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man7
115 cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz
118 ifneq ($(HAVE_SPHINX)$(HAVE_MAKEINFO),11)
120 @echo "Missing sphinx or makeinfo, not building info pages"
122 build-info: sphinx-info
125 ifneq ($(HAVE_SPHINX)$(HAVE_MAKEINFO)$(HAVE_INSTALL_INFO),111)
127 @echo "Missing prerequisites, not installing info pages"
129 install-info: build-info
130 mkdir -m0755 -p "$(DESTDIR)$(infodir)"
131 install -m0644 $(INFO_INFO_FILES) $(DESTDIR)$(infodir)
132 for file in $(INFO_INFO_FILES); do install-info $$file $(DESTDIR)$(infodir)/dir; done
135 $(dir)/config.dox: version.stamp
136 echo "PROJECT_NAME = \"Notmuch $(VERSION)\"" > $@
137 echo "INPUT=${srcdir}/lib/notmuch.h" >> $@
139 CLEAN := $(CLEAN) $(DOCBUILDDIR) $(DOCBUILDDIR)/.roff.stamp $(DOCBUILDDIR)/.texi.stamp
140 CLEAN := $(CLEAN) $(DOCBUILDDIR)/.html.stamp
141 CLEAN := $(CLEAN) $(MAN_GZIP_FILES) $(MAN_ROFF_FILES) $(dir)/conf.pyc $(dir)/config.dox