]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/GNUmakefile
Doc build: create general->index.html in a slightly more stepmake-esque way.
[lilypond.git] / Documentation / GNUmakefile
1 depth = ..
2
3 ########################
4 #  Documentation build #
5 ########################
6
7 #############
8 ### Variables
9
10 NAME = documentation
11 LANGS = $(shell $(PYTHON) $(top-src-dir)/python/langdefs.py)
12 MANUALS_SUBDIRS = usage automated-engraving contributor essay \
13   general learning notation extending
14 SUBDIRS = $(MANUALS_SUBDIRS) snippets logo pictures misc po css topdocs \
15   included $(LANGS)
16 STEPMAKE_TEMPLATES = documentation texinfo tex omf
17 LOCALSTEPMAKE_TEMPLATES = lilypond ly
18
19 ### Extra flags
20
21 LILYPOND_BOOK_FLAGS = --extra-options '-e "(ly:set-option (quote internal-type-checking) \#t)"'
22 TEXI2PDF_FLAGS = \
23   -I $(outdir) \
24   -I $(top-build-dir)/Documentation/$(outconfbase)
25 $(outdir)/snippets-big-page.html: TEXI2HTML_FLAGS += -D short_toc
26 $(outdir)/snippets/index..html: TEXI2HTML_FLAGS += -D short_toc
27
28 ### Extra source files
29
30 README_TOP_FILES= DEDICATION THANKS
31
32 IN_ITELY_FILES = $(call src-wildcard,snippets/*-intro.itely)
33 SNIPPET_LY_FILES = $(call src-wildcard,snippets/*.ly)
34
35 EXTRA_DIST_FILES = $(call src-wildcard,*.init) search-box.html
36
37 ### Out files
38
39 # Dependencies
40 GENERATED_ITELY_FILES = $(IN_ITELY_FILES:snippets/%-intro.itely=$(outdir)/%.itely)
41
42 XREF_MAPS_FILES += $(XREF_MAPS_DIR)/internals.xref-map
43 OMF_FILES += $(outdir)/internals.html.omf $(outdir)/internals.pdf.omf
44
45 # Main manuals
46 TEXINFO_MANUALS = internals\
47  $(TELY_FILES:%.tely=%)\
48  $(TEXI_FILES:%.texi=%)
49 OUT_TEXINFO_MANUALS = $(TEXINFO_MANUALS:%=$(outdir)/%.texi)
50
51 ## CHAIN_RULE hack: keep the following line *before* including
52 # stepmake.make, so the Internals Reference is built before the
53 # Notation Reference, thus providing automatically generated sections
54 # of the NR
55 TEXI_FILES_FROM_TELY = $(outdir)/internals.texi
56
57 PDF_FILES = $(TEXINFO_MANUALS:%=$(outdir)/%.pdf)
58
59 TOPDIR_HTML_MANUALS = general
60 UNSPLITTED_HTML_MANUALS = changes
61 SPLITTED_HTML_MANUALS = $(foreach manual, $(TEXINFO_MANUALS),\
62  $(if $(findstring $(manual), $(UNSPLITTED_HTML_MANUALS)),,$(manual)))
63 NOT_TOPDIR_HTML_MANUALS = $(foreach manual, $(SPLITTED_HTML_MANUALS),\
64  $(if $(findstring $(manual), $(TOPDIR_HTML_MANUALS)),,$(manual)))
65
66 OUT_HTML_FILES = $(UNSPLITTED_HTML_MANUALS:%=$(outdir)/%.html)\
67  $(SPLITTED_HTML_MANUALS:%=$(outdir)/%-big-page.html)\
68  $(TOPDIR_HTML_MANUALS:%=$(outdir)/index.html)
69 DEEP_HTML_FILES = $(NOT_TOPDIR_HTML_MANUALS:%=$(outdir)/%/index.html)
70
71 # Symlinks to refer to external source documents from split and non-split HTML
72 source-links = $(outdir)/source\
73  $(foreach manual, $(SPLITTED_HTML_MANUALS), $(outdir)/$(manual)/source)
74
75 # Other out files
76
77 HTML_PAGE_NAMES= translations
78 OUT_HTML_FILES += $(HTML_PAGE_NAMES:%=$(outdir)/%.html)
79
80 MAIN_INFO_DOC = lilypond-notation
81 INFO_DOCS = lilypond-usage lilypond-changes lilypond-contributor lilypond-internals \
82  lilypond-essay lilypond-learning lilypond-notation music-glossary \
83  lilypond-general lilypond-extending
84 ifeq ($(out),www)
85 INFO_DOCS += lilypond-snippets 
86 endif
87 INFO_FILES = $(INFO_DOCS:%=$(outdir)/%.info)
88
89 ifeq ($(out),www)
90 INFO_IMAGES_DIR = lilypond
91 DEST_INFO_IMAGES_SUBDIR = Documentation/
92 endif
93
94 include $(depth)/make/stepmake.make
95
96 OUT_TXT_FILES = $(addprefix $(outdir)/, $(addsuffix .txt, $(README_TOP_FILES)))
97
98 ### Web site idiosyncrases
99
100 $(outdir)/index.html: TEXI2HTML_INIT = $(WEB_TEXI2HTML_INIT)
101 $(outdir)/index.html: TEXI2HTML_SPLIT = $(WEB_TEXI2HTML_SPLIT)
102
103 $(outdir)/index.html: $(outdir)/general.texi
104         $(TEXI2HTML) $(TEXI2HTML_SPLIT) $(TEXI2HTML_FLAGS) --output $(outdir)/ $(outdir)/general.texi
105
106 ###########
107 ### Targets
108
109 default: local-txt-doc
110
111 local-help: extra-local-help
112
113 extra-local-help:
114         @echo -e "\
115   check-xrefs [ISOLANG=LL] validate Texinfo cross-references\n\
116   fix-xrefs [ISOLANG=LL]   interactively fix Texinfo cross-references (use with caution)\n\
117   info        update info pages\n\
118   xml         update Docbook xml documentation\n\
119 \n\
120 Translations specific targets (see TRANSLATION for details):\n\
121   new-lang ISOLANG=LL  create and initialize subdirectory \'LL' for language \'LL\n\
122   po-update            update and replace PO files for documentation with msgmerged versions\n\
123   check-translation ISOLANG=LL   show changes in English docs since last translation update\n\
124   update-translation ISOLANG=LL  call $$$$EDITOR to help updating the translation\n\
125   skeleton-update ISOLANG=LL     update Texinfo skeleton files\n\
126   snippet-update ISOLANG=LL      update ly snippets in Texinfo translation according to\n\
127                               docs in English (use with caution)\n\
128 \n\
129 LL refers to the desired locale (most often only the ISO 639 language code).\n"
130
131 info: $(INFO_FILES)
132         @echo export LILYPOND_DATADIR=$(LILYPOND_DATADIR)
133         @echo export PYTHONPATH=$(PYTHONPATH)
134
135 xml: $(outdir)/notation/notation.xml $(outdir)/internals/internals.xml
136
137
138 local-clean:
139         rm -f $(INFO_IMAGES_DIR)
140
141 ### Web targets
142
143 ifeq ($(out),www)
144 local-WWW-1: $(OUT_TEXINFO_MANUALS) $(PDF_FILES) info
145
146 local-WWW-2: txt-to-html $(OUT_HTML_FILES) $(DEEP_HTML_FILES) $(source-links) $(OMF_FILES)
147 endif
148
149
150 #########
151 ### Rules
152
153 $(outdir)/lilypond-%.info: $(outdir)/%.texi $(outdir)/$(INFO_IMAGES_DIR).info-images-dir-dep $(outdir)/version.itexi
154         $(MAKEINFO) -I$(src-dir) -I$(outdir) --output=$@ $<
155
156 # cd $(outdir) rule gets bit hairy for --srcdir configure builds
157 txt-to-html:
158         $(foreach a, $(README_TOP_FILES), cp $(top-src-dir)/$(a) $(outdir)/$(a).txt && ) true
159         $(PYTHON) $(step-bindir)/text2html.py $(OUT_TXT_FILES)
160
161 ifeq ($(out),www)
162 ## Extra images dependencies
163 $(OUT_TEXINFO_MANUALS): $(outdir)/pictures
164
165 $(outdir)/pictures:
166         $(MAKE) -C pictures WWW-1
167         ln -sf ../pictures/$(outdir) $@
168
169 $(outdir)/general.texi: $(outdir)/examples
170
171 $(outdir)/examples:
172         $(MAKE) -C general/examples
173         ln -sf ../general/examples/$(outdir) $@
174 endif
175
176 # Ugh, using '%' twice not possible
177 $(outdir)/notation/notation.xml: $(outdir)/notation.texi
178         mkdir -p $(dir $@)
179         $(MAKEINFO) -I$(src-dir) -I$(outdir) --output=$(dir $@) --docbook $<
180
181 $(outdir)/internals/internals.xml: $(outdir)/internals.texi
182         mkdir -p $(dir $@)
183         $(MAKEINFO) -I$(src-dir) -I$(outdir) --output=$(dir $@) --docbook $<
184
185 $(outdir)/learning.texi $(outdir)/notation.texi: $(OUT_PDF_IMAGES)
186
187 $(foreach manual, $(MANUAL_SUBDIRS),\
188 $(eval $(outdir)/(manual).texi: $(call src-wildcard,$(manual)/*.ite??)))
189
190
191
192 $(outdir)/source:
193         @rm -f $(@)
194         ln -sf $(depth) $(@)
195
196 $(outdir)/%/source:
197         @rm -f $(@)
198         mkdir -p $(dir $@)
199         ln -sf $(depth)/.. $(@)
200
201
202 ## Snippets rules idiosyncrases
203 $(outdir)/%.itely: snippets/%-intro.itely snippets/%.snippet-list
204         xargs $(LYS_TO_TELY) -f doctitle,texidoc,verbatim --name=$@ --template=$< < $(filter %.snippet-list, $^)
205
206 $(outdir)/snippets.texi: $(GENERATED_ITELY_FILES) $(SNIPPET_LY_FILES)
207
208 $(outdir)/%.bib: %.bib
209         ln -f $< $@
210
211 ## notation.texi deps
212 $(top-build-dir)/mf/$(outconfbase)/feta16list.ly:
213         $(MAKE) -C $(top-src-dir)/mf
214
215 $(outdir)/notation.texi: $(outdir)/ly-grammar.txt
216
217 ## Rules for the automatically generated documentation
218 $(outdir)/ly-grammar.txt: $(top-src-dir)/lily/parser.yy
219         cd $(outdir) && $(BISON) -v $<
220         $(auxscript-dir)/yyout2grammar.py $(outdir)/parser.output $@
221
222 # There used to be a dependency on a dummy target, to force a rebuild
223 # of internals every time.  however, this triggers
224 # compilation during install, which is a bad thing (tm).
225
226 $(outdir)/internals.texi: $(LILYPOND_BINARY)
227         cd $(outdir) && $(LILYPOND_BINARY) --verbose $(top-src-dir)/ly/generate-documentation
228
229
230 ###############################################
231 #  Documentation and translations maintenance #
232 ###############################################
233 po-update:
234         make -C po po-update
235
236 all-translations-update: po-update translation-status
237         $(foreach lang, $(LANGS), make ISOLANG=$(lang) skeleton-update snippet-update &&) true
238
239 ifneq ($(NO_COLOR),)
240 CHECK_TRANSLATION_FLAGS = --no-color
241 endif
242
243 ifneq ($(ISOLANG),)
244 new-lang-dir:
245         mkdir -p $(ISOLANG)/$(DIR)
246         cp fr/GNUmakefile $(ISOLANG)
247         cp fr/$(DIR)/GNUmakefile $(ISOLANG)/$(DIR)
248         sed -i -e 's/ISOLANG *= *fr/ISOLANG = $(ISOLANG)/' $(ISOLANG)/GNUmakefile $(ISOLANG)/$(DIR)/GNUmakefile
249         rm -f $(outdir)/*.*tely $(outdir)/*.*texi
250         $(auxscript-dir)/texi-langutils.py -d $(outdir) -l $(ISOLANG) -o doc.pot --skeleton --gettext $$(cd $(ISOLANG) && ls -1 ../$(DIR).tely ../$(DIR).texi)
251         for i in $$(cd $(outdir) && ls -1 $(DIR).tely $(DIR).texi); do\
252             test -e $(ISOLANG)/$$i || mv $(outdir)/$$i $(ISOLANG)/$$i;\
253         done
254         rm -f $(outdir)/$(DIR).tely $(outdir)/$(DIR).texi
255         for i in $$(cd $(outdir) && ls -1 *.*tely *.*texi); do\
256             test -e $(ISOLANG)/$(DIR)/$$i\
257                 || mv $(outdir)/$$i $(ISOLANG)/$(DIR)/$$i;\
258         done
259
260 new-lang:
261 # Also for updating/adding missing files
262         $(foreach i,$(TRANSLATION_DIRS),$(MAKE) new-lang-dir DIR=$(i) &&) :
263         $(foreach i, $(EXTRA_TRANSLATION_FILES), \
264             (test -e $(ISOLANG)/$(i) \
265                 || cp fr/$(i) $(ISOLANG)/$(i)) && ) true
266         msgmerge -U po/lilypond-doc.pot $(outdir)/doc.pot
267         test -e po/$(ISOLANG).po || cp po/lilypond-doc.pot po/$(ISOLANG).po
268         @echo "***  Please add a language definition for $(ISOLANG) in python/langdefs.py  ***"
269
270 #TRANSLATION_DIRS = $(shell git ls-files $(ISOLANG) | $(PYTHON) $(buildscript-dir)/pytt.py '/[^/]*$$' / | sort -u )
271 TRANSLATION_DIRS = general learning notation texidocs usage
272 TRANSLATION_FILES = $(shell git ls-files $(ISOLANG) | grep -v GNUmakefile)
273 EXTRA_TRANSLATION_FILES =\
274  dedication.itely\
275  common-macros.itexi\
276  macros.itexi\
277  translations.html.in\
278  translations.template.html.in\
279 #
280
281
282 TELY_FILES = $(call src-wildcard,$(ISOLANG)/*.tely)
283 skeleton-update:
284         mkdir -p $(ISOLANG)
285         $(auxscript-dir)/texi-langutils.py -d $(outdir) -l $(ISOLANG) --skeleton $(TELY_FILES:$(ISOLANG)/%.tely=../%.tely)
286         $(auxscript-dir)/texi-skeleton-update.py $(ISOLANG) $(outdir)
287
288 snippet-update:
289         $(auxscript-dir)/update-snippets.py user $(ISOLANG) '*.itely'
290
291 DOCUMENTS_INCLUDES:=-I $(ISOLANG) \
292 -I $(top-build-dir)/Documentation/$(ISOLANG)/out-www \
293 -I $(top-src-dir)/Documentation/snippets \
294 -I $(top-build-dir)/Documentation/out-www
295
296 else # ISOLANG is empty
297
298 DOCUMENTS_INCLUDES:=-I . \
299 -I $(top-build-dir)/Documentation/out-www \
300 -I $(top-src-dir)/Documentation/snippets \
301 -I $(top-build-dir)/Documentation/snippets/out-www
302
303 endif # ISOLANG
304
305 check-xrefs:
306         $(auxscript-dir)/check_texi_refs.py --batch \
307         $(DOCUMENTS_INCLUDES) $(auxpython-dir)/manuals_definitions.py
308
309 fix-xrefs:
310         $(auxscript-dir)/check_texi_refs.py --auto-fix \
311         $(DOCUMENTS_INCLUDES) $(auxpython-dir)/manuals_definitions.py
312
313 check-translation:
314         ISOLANG=$(ISOLANG) $(auxscript-dir)/check_translation.py $(CHECK_TRANSLATION_FLAGS) $(TRANSLATION_FILES)
315
316 update-translation:
317         ISOLANG=$(ISOLANG) $(auxscript-dir)/check_translation.py --update $(CHECK_TRANSLATION_FLAGS) $(TRANSLATION_FILES)
318
319 translation-status:
320         make -C po out=www messages
321         $(auxscript-dir)/translations-status.py
322
323 .SECONDARY: