5 # You can set these variables from the command line.
7 SPHINXBUILD = sphinx-build
8 DOCBUILDDIR := $(dir)/_build
11 ALLSPHINXOPTS := -d $(DOCBUILDDIR)/doctrees $(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)
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)
25 MAN_GZIP_FILES := $(addsuffix .gz,${MAN_ROFF_FILES})
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)
33 .PHONY: sphinx-html sphinx-texinfo sphinx-info
35 .PHONY: install-man build-man apidocs install-apidocs
38 rm -f $@ && gzip --stdout $^ > $@
41 $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(DOCBUILDDIR)/html
44 $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(DOCBUILDDIR)/texinfo
46 sphinx-info: sphinx-texinfo
47 make -C $(DOCBUILDDIR)/texinfo info
49 # Use the man page converter that is available. We should never depend
50 # on MAN_ROFF_FILES if a converter is not available.
51 ${MAN_ROFF_FILES}: $(DOCBUILDDIR)/.roff.stamp
53 # By using $(DOCBUILDDIR)/.roff.stamp instead of ${MAN_ROFF_FILES}, we
54 # convey to make that a single invocation of this recipe builds all
55 # of the roff files. This prevents parallel make from starting an
56 # instance of this recipe for each roff file.
57 $(DOCBUILDDIR)/.roff.stamp: ${MAN_RST_FILES}
58 ifeq ($(HAVE_SPHINX),1)
59 $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
60 for section in 1 5 7; do \
61 mkdir -p $(DOCBUILDDIR)/man/man$${section}; \
62 mv $(DOCBUILDDIR)/man/*.$${section} $(DOCBUILDDIR)/man/man$${section}; \
65 @echo "Fatal: build dependency fail."
70 install-man: install-apidocs
72 ifeq ($(HAVE_DOXYGEN),1)
73 MAN_GZIP_FILES += ${APIMAN}.gz
75 install-apidocs: ${APIMAN}.gz
76 mkdir -p "$(DESTDIR)$(mandir)/man3"
77 install -m0644 $(filter %.3.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man3
79 $(APIMAN): $(dir)/config.dox $(srcdir)/$(dir)/doxygen.cfg $(srcdir)/lib/notmuch.h
80 mkdir -p $(DOCBUILDDIR)/man/man3
82 rm -f $(DOCBUILDDIR)/man/man3/_*.3
83 perl -pi -e 's/^[.]RI "\\fI/.RI "\\fP/' $(APIMAN)
89 # Do not try to build or install man pages if a man page converter is
91 ifeq ($(HAVE_SPHINX),0)
94 @echo "No sphinx, will not install man pages."
96 build-man: ${MAN_GZIP_FILES}
97 install-man: ${MAN_GZIP_FILES}
98 mkdir -m0755 -p "$(DESTDIR)$(mandir)/man1"
99 mkdir -m0755 -p "$(DESTDIR)$(mandir)/man5"
100 mkdir -m0755 -p "$(DESTDIR)$(mandir)/man7"
101 install -m0644 $(filter %.1.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man1
102 install -m0644 $(filter %.5.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man5
103 install -m0644 $(filter %.7.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man7
104 cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz
107 ifneq ($(HAVE_SPHINX)$(HAVE_MAKEINFO),11)
109 @echo "Missing sphinx or makeinfo, not building info pages"
111 build-info: sphinx-info
114 ifneq ($(HAVE_SPHINX)$(HAVE_MAKEINFO)$(HAVE_INSTALL_INFO),111)
116 @echo "Missing prerequisites, not installing info pages"
118 install-info: build-info
119 mkdir -m0755 -p "$(DESTDIR)$(infodir)"
120 install -m0644 $(INFO_INFO_FILES) $(DESTDIR)$(infodir)
121 for file in $(INFO_INFO_FILES); do install-info $$file $(DESTDIR)$(infodir)/dir; done
124 $(dir)/config.dox: version.stamp
125 echo "PROJECT_NAME = \"Notmuch $(VERSION)\"" > $@
126 echo "INPUT=${srcdir}/lib/notmuch.h" >> $@
128 CLEAN := $(CLEAN) $(DOCBUILDDIR) $(DOCBUILDDIR)/.roff.stamp
129 CLEAN := $(CLEAN) $(MAN_GZIP_FILES) $(MAN_ROFF_FILES) $(dir)/conf.pyc $(dir)/config.dox