]> 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 # Sequentialize the calls to sphinx-build to avoid races with
45 # reading/writing cached state. This uses GNU make specific
46 # "order-only" prerequisites.
47
48 sphinx-html: | $(DOCBUILDDIR)/.roff.stamp
49 sphinx-texinfo: | sphinx-html
50 sphinx-info: | sphinx-texinfo
51
52 sphinx-html:
53         $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(DOCBUILDDIR)/html
54
55 sphinx-texinfo:
56         $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(DOCBUILDDIR)/texinfo
57
58 sphinx-info: sphinx-texinfo
59         make -C $(DOCBUILDDIR)/texinfo info
60
61 # Use the man page converter that is available. We should never depend
62 # on MAN_ROFF_FILES if a converter is not available.
63 ${MAN_ROFF_FILES}: $(DOCBUILDDIR)/.roff.stamp
64
65 # By using $(DOCBUILDDIR)/.roff.stamp instead of ${MAN_ROFF_FILES}, we
66 # convey to make that a single invocation of this recipe builds all
67 # of the roff files.  This prevents parallel make from starting an
68 # instance of this recipe for each roff file.
69 $(DOCBUILDDIR)/.roff.stamp: ${MAN_RST_FILES}
70 ifeq ($(HAVE_SPHINX),1)
71         $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
72         for section in 1 5 7; do \
73             mkdir -p $(DOCBUILDDIR)/man/man$${section}; \
74             mv $(DOCBUILDDIR)/man/*.$${section} $(DOCBUILDDIR)/man/man$${section}; \
75         done
76 else
77         @echo "Fatal: build dependency fail."
78         @false
79 endif
80         touch $@
81
82 install-man: install-apidocs
83
84 ifeq ($(HAVE_DOXYGEN),1)
85 MAN_GZIP_FILES += ${APIMAN}.gz
86 apidocs: $(APIMAN)
87 install-apidocs: ${APIMAN}.gz
88         mkdir -p "$(DESTDIR)$(mandir)/man3"
89         install -m0644 $(filter %.3.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man3
90
91 $(APIMAN): $(dir)/config.dox $(srcdir)/$(dir)/doxygen.cfg $(srcdir)/lib/notmuch.h
92         mkdir -p $(DOCBUILDDIR)/man/man3
93         doxygen $(DOXYFILE)
94         rm -f $(DOCBUILDDIR)/man/man3/_*.3
95         perl -pi -e 's/^[.]RI "\\fI/.RI "\\fP/' $(APIMAN)
96 else
97 apidocs:
98 install-apidocs:
99 endif
100
101 # Do not try to build or install man pages if a man page converter is
102 # not available.
103 ifeq ($(HAVE_SPHINX),0)
104 build-man:
105 install-man:
106         @echo "No sphinx, will not install man pages."
107 else
108 build-man: ${MAN_GZIP_FILES}
109 install-man: ${MAN_GZIP_FILES}
110         mkdir -m0755 -p "$(DESTDIR)$(mandir)/man1"
111         mkdir -m0755 -p "$(DESTDIR)$(mandir)/man5"
112         mkdir -m0755 -p "$(DESTDIR)$(mandir)/man7"
113         install -m0644 $(filter %.1.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man1
114         install -m0644 $(filter %.5.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man5
115         install -m0644 $(filter %.7.gz,$(MAN_GZIP_FILES)) $(DESTDIR)/$(mandir)/man7
116         cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz
117 endif
118
119 ifneq ($(HAVE_SPHINX)$(HAVE_MAKEINFO),11)
120 build-info:
121         @echo "Missing sphinx or makeinfo, not building info pages"
122 else
123 build-info: sphinx-info
124 endif
125
126 ifneq ($(HAVE_SPHINX)$(HAVE_MAKEINFO)$(HAVE_INSTALL_INFO),111)
127 install-info:
128         @echo "Missing prerequisites, not installing info pages"
129 else
130 install-info: build-info
131         mkdir -m0755 -p "$(DESTDIR)$(infodir)"
132         install -m0644 $(INFO_INFO_FILES) $(DESTDIR)$(infodir)
133         for file in $(INFO_INFO_FILES); do install-info $$file $(DESTDIR)$(infodir)/dir; done
134 endif
135
136 $(dir)/config.dox: version.stamp
137         echo "PROJECT_NAME = \"Notmuch $(VERSION)\"" > $@
138         echo "INPUT=${srcdir}/lib/notmuch.h" >> $@
139
140 CLEAN := $(CLEAN) $(DOCBUILDDIR) $(DOCBUILDDIR)/.roff.stamp
141 CLEAN := $(CLEAN) $(MAN_GZIP_FILES) $(MAN_ROFF_FILES) $(dir)/conf.pyc $(dir)/config.dox