1depth = ..
2
3########################
4#  Documentation build #
5########################
6
7#############
8### Variables
9
10NAME = documentation
11
12SUBDIRS = po
13LOCALSTEPMAKE_TEMPLATES = lilypond ly lilypond-book
14
15### Extra flags
16
17LILYPOND_BOOK_FLAGS = \
18  --extra-options '-e "(ly:set-option (quote internal-type-checking) \#t)"'
19TEXI2PDF_FLAGS = \
20  -I $(outdir) \
21  -I $(top-build-dir)/Documentation/$(outconfbase)
22
23### ly examples
24
25LY_EXAMPLES = $(call src-wildcard,ly-examples/*.ly)
26OUT_BITMAP_IMAGES += \
27  $(LY_EXAMPLES:%.ly=$(outdir)/%.png) \
28  $(LY_EXAMPLES:%.ly=$(outdir)/%-small.png)
29LILYPOND_PREVIEW = $(LILYPOND_BINARY) -dpreview -dresolution=150
30
31### Pictures
32
33BITMAP_IMAGES = \
34  $(call src-wildcard,pictures/*.png) \
35  $(call src-wildcard,pictures/*.jpg)
36EPS_ILLUSTRATIONS = $(call src-wildcard,pictures/*.eps)
37SVG_FILES = $(call src-wildcard,pictures/*.svg)
38PDF_DIR = $(call src-wildcard,pictures/pdf/*.pdf)
39
40OUT_PDF_IMAGES = $(EPS_ILLUSTRATIONS:%.eps=$(outdir)/%.pdf)
41OUT_BITMAP_IMAGES += $(BITMAP_IMAGES:%=$(outdir)/%)
42OUT_BITMAP_IMAGES += $(EPS_ILLUSTRATIONS:%.eps=$(outdir)/%.png)
43
44### Miscellaneous files
45
46MISC_FILES = \
47  ANNOUNCE-0.1 ANNOUNCE-1.0 ANNOUNCE-1.2 \
48  announce-v2.0.html announce-v2.10.html announce-v2.12.ca.html \
49    announce-v2.12.de.html announce-v2.12.es.html announce-v2.12.fr.html \
50    announce-v2.12.html announce-v2.2.html announce-v2.4.html \
51    announce-v2.6.html announce-v2.8.html \
52  browser-language.ca.html browser-language.de.html \
53    browser-language.es.html browser-language.fr.html \
54    browser-language.html browser-language.hu.html \
55    browser-language.it.html browser-language.ja.html \
56    browser-language.nl.html \
57  ChangeLog-1.5 ChangeLog-2.1 ChangeLog-2.10 ChangeLog-2.3 \
58  CHANGES-0.0 CHANGES-0.1 CHANGES-1.0 CHANGES-1.1 CHANGES-1.2 CHANGES-1.3 \
59    CHANGES-1.4 CHANGES-1.5 \
60  NEWS-1.2 NEWS-1.4 \
61  THANKS-1.8 THANKS-2.0 THANKS-2.10 THANKS-2.12 THANKS-2.14 THANKS-2.16 \
62    THANKS-2.18 THANKS-2.2 THANKS-2.4 THANKS-2.6 THANKS-2.8
63
64OUT_MISC_FILES = $(addprefix $(outdir)/misc/,$(MISC_FILES))
65OUT_CSS_FILES = $(addprefix $(outdir)/,$(call src-wildcard,css/*.css))
66
67
68### Snippets
69#
70# The base files (`.ly` with english doc) are synced in from the LSR project.
71# Each language adds translated titles under `LANGUAGE/texidocs/`.  All
72# translated titles are merged by `makesnippets.py`.  `lilypond-book` texi
73# language support picks up the right header based on document language.
74
75IN_ITELY_FILES = $(call src-wildcard,snippets/*-intro.itely)
76SNIPPET_LY_FILES = $(call src-wildcard,snippets/*.ly)
77OUT_SNIPPET_LY_FILES = $(SNIPPET_LY_FILES:%.ly=$(outdir)/%.ly)
78
79### Out files
80
81LANG_TELY_FILES = $(call src-wildcard,$(1)/*.tely)
82LANG_TEXI_FILES = $(call src-wildcard,$(1)/*.texi)
83
84DOC_TELY_FILES = $(foreach L, $(LANGS), $(call LANG_TELY_FILES,$(L)))
85DOC_TEXI_FILES = $(foreach L, $(LANGS), $(call LANG_TEXI_FILES,$(L)))
86
87# All .xref-map files for a single language.
88LANG_XREF_FILES = \
89  $(addprefix $(outdir)/, \
90    $(patsubst %.tely,%.xref-map, \
91      $(patsubst %.texi,%.xref-map, \
92        $(call LANG_TEXI_FILES,$(1)) \
93        $(call LANG_TELY_FILES,$(1)))))
94
95DOC_BASENAMES = \
96  contributor \
97  changes \
98  essay \
99  extending \
100  internals \
101  learning \
102  music-glossary \
103  notation \
104  snippets \
105  usage \
106  web
107
108# Main manuals
109TEXINFO_MANUALS = \
110  en/internals \
111  $(DOC_TELY_FILES:%.tely=%) \
112  $(DOC_TEXI_FILES:%.texi=%)
113
114# In info, images will be loaded from this dir.
115INFO_IMAGES_DIR = lilypond
116
117# Some PDF files require extra packages to build.
118#
119# Czech - needs XeTeX.
120#
121# Chinese/Japanese - needs:
122#
123#   XeTeX 0.9998+ (TeX Live 2012+)
124#     The modern TeX engine used for LilyPond's PDF documents.  It might be
125#     contained in the 'texlive-xetex' package.
126#
127#   IPAex fonts
128#     Japanese fonts.  It might be contained in the 'texlive-lang-japanese'
129#     package.
130#
131#   zhspacing
132#     Spacing for mixed CJK-English documents using XeTeX.  It might be
133#     contained in the 'texlive-lang-chinese' package.  (This package is for
134#     Chinese, but can also be used for Japanese.)
135#
136# Note: Even if Japanese PDF documents have been built, links from HTML
137#       documents to Japanese PDFs are not created.
138
139ALL_PDF_FILES = $(TEXINFO_MANUALS:%=$(outdir)/%.pdf)
140
141# Uncomment below to build PDF in cs/ja/zh.
142# PDF_FILES = $(ALL_PDF_FILES)
143PDF_FILES = \
144  $(filter-out \
145    $(outdir)/cs/% $(outdir)/zh/% $(outdir)/ja/%, \
146    $(ALL_PDF_FILES))
147
148target_language = $(word 2, $(subst /, ,$@))
149
150TEXI2HTML_INIT = \
151  --init-file=$(top-src-dir)/Documentation/lilypond-texi2html-lang.init \
152  --document-language=$(call target_language) \
153  --init-file=$(top-src-dir)/Documentation/lilypond-texi2html.init
154
155TEXI2HTML_INCLUDES += $(DOCUMENTATION_INCLUDES)
156
157TEXI2HTML_FLAGS += \
158  $(TEXI2HTML_ERROR_LIMIT) \
159  $(TEXI2HTML_INCLUDES) \
160  $(TEXI2HTML_INIT) \
161  $(if $(VERBOSE),--verbose)
162TEXI2HTML = TOP_SRC_DIR=$(top-src-dir) PERL_UNICODE=SD $(TEXI2HTML_PROGRAM)
163
164ifeq ($(WEB_VERSION),yes)
165  TEXI2HTML_FLAGS += -D web_version
166  TEXI2PDF_LOCAL_FLAGS += -D web_version
167  # As version, use the released $(VERSION_DEVEL) instead of the in-development
168  # $(MAJOR_VERSION).$(MINOR_VERSION).  This makes a difference after branching
169  # for next stable release.
170  WEB_ENV = ONLY_WEB_VERSION=v$(basename $(VERSION_DEVEL))
171endif
172
173SPLIT_HTML_MANUALS = $(TEXINFO_MANUALS)
174SPLIT_HTML_INDEX_FILES = $(SPLIT_HTML_MANUALS:%=$(outdir)/%/index.html)
175
176# Other out files
177
178MAIN_INFO_DOC = lilypond-web
179
180# This list must stay in sync with the corresponding @direntry block in file
181# `web.texi`.
182INFO_DOCS = \
183  lilypond-changes \
184  lilypond-contributor \
185  lilypond-essay \
186  lilypond-extending \
187  lilypond-internals \
188  lilypond-learning \
189  lilypond-notation \
190  lilypond-snippets \
191  lilypond-usage \
192  music-glossary
193# Some info files should only be processed if `$(out)` is equal to `www`, but we
194# generate them anyway.  Reason is that we use repeated calls to `install-info`
195# during installation to properly remove old entries in info's `dir` file, and
196# older LilyPond versions inserted more entries that are no longer present.
197ALL_INFO_DOCS = \
198  $(INFO_DOCS) \
199  lilypond-web
200ifeq ($(out),www)
201  INFO_DOCS += lilypond-web
202endif
203INFO_FILES = $(INFO_DOCS:%=$(outdir)/%.info)
204ALL_INFO_FILES = $(ALL_INFO_DOCS:%=$(outdir)/%.info)
205
206include $(depth)/make/stepmake.make
207
208# Must be here, or overwritten by `lilypond-book-var`.
209OUT_HTML_FILES = \
210  $(foreach m, $(SPLIT_HTML_MANUALS), $(outdir)/$(m)-big-page.html)
211EXTRACT_TEXI_FILENAMES_FLAGS += $(if $(VERBOSE),,--quiet)
212
213# xref map maps section titles <> node names for translated split HTML docs.
214$(outdir)/%.xref-map: $(outdir)/%.texi
215	$(call ly_progress,Making,$@,< texi)
216	$(PYTHON) -tt $(buildscript-dir)/extract_texi_filenames.py \
217	  $(EXTRACT_TEXI_FILENAMES_FLAGS) \
218	  $(if $(call target_language), \
219	    --master-map-file=$(subst $(call target_language)/,en/,$@)) \
220	  $(DOCUMENTATION_INCLUDES) \
221	  -o $(dir $@) \
222	  $<
223
224$(outdir)/%.pdf: \
225  $(outdir)/%.texi \
226  $(outdir)/version.itexi \
227  $(outdir)/weblinks.itexi \
228  $(OUT_PDF_IMAGES) \
229  $(OUT_BITMAP_IMAGES) \
230  | pre-pdf
231	$(call ly_progress,Making,$@,< texi)
232	TEX=$(PDFTEX) PDFTEX=$(PDFTEX) PDFLATEX=$(PDFLATEX) \
233	  $(buildscript-dir)/run-and-check.sh \
234\
235"cd $(dir $@); \
236   texi2pdf \
237     --batch \
238     $(TEXI2PDF_LOCAL_FLAGS) \
239     -I ../ \
240     -I $(abs-src-dir)/$(call target_language) \
241     -I $(abs-src-dir) \
242     -I $(abs-src-dir)/en/ \
243     -o $(CURDIR)/$(outdir)/$*.tmp.pdf \
244     $(CURDIR)/$< \
245   < /dev/null" \
246\
247	    "$(outdir)/$*.texi2pdf.log"
248ifeq ($(USE_EXTRACTPDFMARK),yes)
249	  $(EXTRACTPDFMARK) -o $(outdir)/$*.pdfmark $(outdir)/$*.tmp.pdf
250	  $(GS920) \
251	    -dBATCH \
252	    -dNOSAFER \
253	    -dNOPAUSE \
254	    -q \
255	    -sDEVICE=pdfwrite \
256	    -dAutoRotatePages=/None \
257	    -dPrinted=false \
258	    -sOutputFile=$@ \
259	    -c "30000000 setvmthreshold" \
260	    -I $(top-build-dir)/out-fonts \
261	    -I $(top-build-dir)/out-fonts/Font \
262	    $(outdir)/$*.pdfmark \
263	    $(outdir)/$*.tmp.pdf
264	  rm $(outdir)/$*.tmp.pdf
265else
266	  mv $(outdir)/$*.tmp.pdf $@
267endif
268
269# LilyPond uses Cyrillic in its documentation; the used fonts are from the LH
270# family.  By default, its metrics files are generated on the fly, which might
271# cause problems in parallel make jobs.  For this reason we make TeX Live
272# generate the needed TFM files in advance.
273pre-pdf:
274	$(call ly_info,Making latt1095.tfm in TeX Live (mktextfm))
275	$(buildscript-dir)/run-and-check.sh \
276	  "mktextfm latt1095" "$(outdir)/latt1095.mktextfm.log"
277	$(call ly_info,Making larm1095.tfm in TeX Live (mktextfm))
278	$(buildscript-dir)/run-and-check.sh \
279	  "mktextfm larm1095" "$(outdir)/larm1095.mktextfm.log"
280
281$(outdir)/%/index.html: \
282  $(outdir)/%.texi \
283  $(outdir)/version.itexi \
284  $(outdir)/weblinks.itexi \
285  $(OUT_BITMAP_IMAGES) \
286  $(OUT_CSS_FILES)
287	$(call ly_progress,Making,$@,< texi)
288	mkdir -p $(dir $@)
289	rm -f $(dir $@)/pictures && ln -s ../pictures $(dir $@)/pictures
290	rm -f $(dir $@)/css && ln -s ../../css $(dir $@)/css
291	$(buildscript-dir)/run-and-check.sh \
292\
293"$(WEB_ENV) \
294 DEPTH=$(depth)/../ \
295   $(TEXI2HTML) \
296     --prefix=index \
297     --split=section \
298     $(TEXI2HTML_FLAGS) \
299     --output=$(dir $@) \
300     $<" \
301\
302	  "$(outdir)/$*.splittexi.log"
303
304$(outdir)/%-big-page.html: \
305  $(outdir)/%.texi \
306  $(outdir)/version.itexi \
307  $(outdir)/weblinks.itexi
308	$(call ly_progress,Making,$@,< texi)
309	$(buildscript-dir)/run-and-check.sh \
310\
311"DEPTH=$(depth) \
312   $(TEXI2HTML) \
313     $(TEXI2HTML_FLAGS) \
314     -D bigpage \
315     --output=$@ \
316     $<" \
317\
318	  "$(outdir)/$*.bigtexi.log"
319
320DOCUMENTATION_INCLUDE_DIRS = \
321  $(src-dir)/pictures \
322  $(dir $@) \
323  $(outdir)/en \
324  $(outdir) \
325  $(src-dir)
326
327DOCUMENTATION_INCLUDES = $(addprefix -I ,$(DOCUMENTATION_INCLUDE_DIRS))
328
329LILYPOND_BOOK_INCLUDE_DIRS = \
330  $(outdir) \
331  $(src-dir)/$(call target_language) \
332  $(src-dir)/pictures \
333  $(src-dir)/en/included \
334  $(src-dir)
335
336LILYPOND_BOOK_INCLUDES = $(addprefix -I ,$(LILYPOND_BOOK_INCLUDE_DIRS))
337
338### Bad hack for badly-integrated roadmap.
339# TODO: move into CG.
340$(outdir)/en/ROADMAP: $(top-src-dir)/ROADMAP
341	$(call ly_progress,Making,$@,(copy))
342	mkdir -p $(dir $@)
343	cp $(top-src-dir)/ROADMAP $@
344
345$(outdir)/en/contributor.texi: $(outdir)/en/ROADMAP
346
347$(outdir)/topdocs/NEWS.texi: $(outdir)/en/changes.texi
348	mkdir -p $(dir $@)
349	cp $< $@
350
351### Bad hack for badly-integrated bibliography.
352$(outdir)/%.itexi: bib/%.bib
353	$(call ly_progress,Making,$@,< bib)
354	BSTINPUTS=$(src-dir)/essay \
355	  $(PYTHON) $(buildscript-dir)/bib2texi.py \
356	    -s $(top-src-dir)/Documentation/lily-bib -o $@ -q $<
357
358$(DOC_TELY_FILES:%.tely=$(outdir)/%.texi):
359
360
361###########
362### Targets
363
364default: $(ALL_INFO_FILES)
365
366local-help: extra-local-help
367
368extra-local-help:
369	@echo "  check-xrefs [ISOLANG=LL] validate Texinfo cross-references"
370	@echo "  fix-xrefs [ISOLANG=LL]   interactively fix Texinfo cross-references"
371	@echo "                             (use with caution)"
372	@echo "  info                     update info pages"
373	@echo
374	@echo "Translations specific targets (see TRANSLATION for details):"
375	@echo "  new-lang ISOLANG=LL           create and initialize"
376	@echo "                                  subdirectory \'LL' for language \'LL"
377	@echo "                                  (if \'LL exists, update missing file)"
378	@echo "  po-update                     update and replace PO files for"
379	@echo "                                  documentation with msgmerged versions"
380	@echo "  check-translation ISOLANG=LL  show changes in English docs since"
381	@echo "                                  last translation update"
382	@echo "  update-translation ISOLANG=LL call $$$$EDITOR to help updating"
383	@echo "                                  the translation"
384	@echo "  snippet-update ISOLANG=LL     update ly snippets in Texinfo translation"
385	@echo "                                  according to docs in English"
386	@echo "                                  (use with caution)"
387	@echo
388	@echo "  LL refers to the desired locale"
389	@echo "    (most often only the ISO 639 language code)."
390	@echo
391
392
393####
394## Info targets (optionally with images)
395
396info: $(ALL_INFO_FILES)
397
398local-install: install-info
399
400install-info: \
401  $(INFO_FILES) \
402  install-info-images \
403  update-info-directory-file-install
404	$(INSTALLPY) -d $(DESTDIR)$(infodir) ; \
405	$(INSTALLPY) -c -m 644 \
406	  $(addsuffix *,$(INFO_FILES)) $(DESTDIR)$(infodir)
407
408uninstall-info: \
409  uninstall-info-images \
410  update-info-directory-file-uninstall
411	rm -f $(addprefix $(DESTDIR)$(infodir)/,$(addsuffix *,$(INFO_DOCS)))
412
413ifeq ($(out),www)
414  UPDATE_IMAGE_SYMLINKS = \
415    mkdir -p $(outdir)/$(INFO_IMAGES_DIR) \
416      && cd $(outdir)/$(INFO_IMAGES_DIR) \
417      && ln -sf ../en/[a-f0-9][a-f0-9] .
418else
419  UPDATE_IMAGE_SYMLINKS = true
420endif
421
422install-info-images: $(INFO_FILES)
423ifeq ($(out),www)
424  # Remove $(infodir)/$(INFO_IMAGES_DIR) in case it is a symlink.
425	  rm -rf $(DESTDIR)$(infodir)/$(INFO_IMAGES_DIR)
426  ifneq ($(COPY_INFO_IMAGES),no)
427	    $(INSTALLPY) -d $(DESTDIR)$(infodir)/$(INFO_IMAGES_DIR)
428	    rsync \
429	      --copy-links \
430	      --recursive \
431	      --include="*/" \
432	      --include="*.png" \
433	      --exclude="*" \
434	      $(outdir)/lilypond/?? \
435	      $(DESTDIR)$(infodir)/$(INFO_IMAGES_DIR)
436  else # !COPY_INFO_IMAGES
437	    $(INSTALLPY) -d $(DESTDIR)$(infodir)
438	    cd $(DESTDIR)$(infodir) \
439	      && ln -sf $$($(PYTHON) $(buildscript-dir)/relative.py \
440	                     $(DESTDIR)$(webdir)/Documentation) \
441	           $(INFO_IMAGES_DIR)
442  endif # !COPY_INFO_IMAGES
443else
444	  true
445endif # out=www
446
447uninstall-info-images:
448	rm -rf $(DESTDIR)$(infodir)/$(INFO_IMAGES_DIR)
449
450
451ifeq ($(patsubst %/local,%,$(DESTDIR)$(prefix)),/usr)
452  # Installing directly into standard /usr/...
453  update-info-directory-file-install: \
454    $(ALL_INFO_FILES) \
455    update-info-directory-file-uninstall
456	  $(INSTALLPY) -d $(DESTDIR)$(infodir)
457	  install-info --info-dir=$(infodir) $(outdir)/$(MAIN_INFO_DOC).info
458
459  update-info-directory-file-uninstall:
460	  $(foreach f, \
461	            $(ALL_INFO_FILES), \
462	            install-info --remove \
463	                         --info-dir=$(infodir) \
464	                         $(f) &> /dev/null ; )true
465
466else
467  ## Installing elsewhere; probably part of a packaging step.  `install-info`
468  ## can't do all its job for binary packages' build systems.  Best we can do is
469  ## to notify the builder or packager.
470  update-info-directory-file-install: $(INFO_FILES)
471	  $(INSTALLPY) -d $(DESTDIR)$(infodir)
472	  @echo
473	  @echo "***************************************************************"
474	  @echo "Please add or update the LilyPond direntries,"
475	  @echo "do or add in the postinstall script"
476	  @echo
477	  @echo "    install-info --info-dir=$(infodir) $(DESTDIR)$(infodir)/$(MAIN_INFO_DOC).info"
478	  @echo
479
480  update-info-directory-file-uninstall:
481  # Nothing to be done: we can't remove the dir because it might have other info
482  # files.
483	  true
484endif
485
486
487### Web targets
488
489PICTURE_SYMLINKS = $(foreach L, $(LANGS), $(outdir)/$(L)/pictures)
490
491PDF_TARGETS = $(OUT_PDF_IMAGES) $(PDF_FILES)
492pdf: $(PDF_TARGETS)
493
494HTML_TARGETS = $(OUT_HTML_FILES) $(SPLIT_HTML_INDEX_FILES)
495HTML_MISC_TARGETS = $(OUT_BITMAP_IMAGES) $(OUT_CSS_FILES) $(OUT_MISC_FILES)
496html: $(HTML_TARGETS) $(HTML_MISC_TARGETS)
497
498# Do not specify phony targets (pdf, html) as dependencies to avoid building the
499# webdoc tree every time.
500$(outdir)/webdoc/dep: \
501  $(PDF_TARGETS) \
502  $(PICTURE_SYMLINKS) \
503  $(HTML_TARGETS) \
504  $(HTML_MISC_TARGETS)
505	$(call ly_progress,Making,$(dir $@),)
506	cd $(outdir) \
507	  && $(buildscript-dir)/build-doc-tree.sh \
508	       webdoc "$(LANGS)" $(LYS_OUTPUT_DIR) "$(DOC_BASENAMES)"
509	touch $@
510
511local-WWW: $(outdir)/webdoc/dep
512
513WEB_HTML_TARGETS = \
514  $(foreach L, \
515            $(LANGS), \
516            $(outdir)/$(L)/web/index.html $(outdir)/$(L)/web-big-page.html)
517$(outdir)/website/dep: \
518  $(WEB_HTML_TARGETS) \
519  $(HTML_MISC_TARGETS) \
520  $(PICTURE_SYMLINKS)
521	$(call ly_progress,Making,$(dir $@),)
522	cd $(outdir) \
523	  && $(buildscript-dir)/build-doc-tree.sh website "$(LANGS)" "" "web"
524	cp $(foreach F, \
525	             favicon.ico robots.txt tweets.xml, \
526	             $(src-dir)/webserver/$(F)) \
527	  $(outdir)/website/web/
528	cp $(src-dir)/webserver/website-dir.htaccess \
529	  $(outdir)/website/web/.htaccess
530	touch $@
531
532website: $(outdir)/website/dep
533
534
535#########
536### Rules
537
538$(outdir)/misc/%: misc/%
539	$(call ly_progress,Copying,$@,< source)
540	mkdir -p $(dir $@)
541	cp -f $< $@
542
543# Copy files while tracking their dependencies.
544$(outdir)/%.texi: %.texi
545	$(call ly_progress,Making,$@,(copy))
546	mkdir -p $(dir $@)
547	cp -f $< $@
548
549$(outdir)/%.txt: $(outdir)/%.texi $(outdir)/version.itexi $(outdir)/weblinks.itexi
550	$(call ly_progress,Making,$@,< texi)
551	$(buildscript-dir)/run-and-check.sh \
552\
553"$(MAKEINFO) \
554   $(DOCUMENTATION_INCLUDES) \
555   --no-split \
556   --no-headers \
557   --output $@ \
558   $<" \
559\
560	  "$(outdir)/$*.makeinfotxt.log"
561
562$(outdir)/version.itexi: $(top-src-dir)/VERSION
563	$(call ly_progress,Making,$@,)
564	$(PYTHON) -tt $(buildscript-dir)/create-version-itexi.py > $@
565
566$(outdir)/weblinks.itexi: $(top-src-dir)/VERSION
567	$(call ly_progress,Making,$@,)
568	$(PYTHON) -tt $(buildscript-dir)/create-weblinks-itexi.py > $@
569
570$(outdir)/lilypond-%.info: \
571  $(outdir)/en/%.texi \
572  $(outdir)/version.itexi \
573  $(outdir)/weblinks.itexi
574	$(call ly_progress,Making,$@,< texi)
575	$(buildscript-dir)/run-and-check.sh \
576\
577"$(MAKEINFO) \
578   $(DOCUMENTATION_INCLUDES) \
579   --output=$@ \
580   $<" \
581\
582	  "$(outdir)/$*.makeinfo.log"
583	$(UPDATE_IMAGE_SYMLINKS)
584
585$(outdir)/lilypond-internals.info: \
586  $(outdir)/en/internals.texi \
587  $(outdir)/version.itexi \
588  $(outdir)/weblinks.itexi
589	$(call ly_progress,Making,$@,< texi)
590	$(buildscript-dir)/run-and-check.sh \
591\
592"$(MAKEINFO) \
593   $(DOCUMENTATION_INCLUDES) \
594   -I$(outdir) \
595   --output=$@ \
596   $<" \
597\
598	  "$(outdir)/$*.makeinfo.log"
599	$(UPDATE_IMAGE_SYMLINKS)
600
601$(outdir)/music-glossary.info: \
602  $(outdir)/en/music-glossary.texi \
603  $(outdir)/version.itexi \
604  $(outdir)/weblinks.itexi
605	$(call ly_progress,Making,$@,< texi)
606	$(buildscript-dir)/run-and-check.sh \
607\
608"$(MAKEINFO) \
609   $(DOCUMENTATION_INCLUDES) \
610   --output=$@ \
611   $<" \
612\
613	  "$(outdir)/$*.makeinfo.log"
614	$(UPDATE_IMAGE_SYMLINKS)
615
616$(outdir)/learning.texi $(outdir)/notation.texi: $(OUT_PDF_IMAGES)
617
618## Snippets rules idiosyncrasies.
619# The snippets are generated by combining the `.ly` files in snippets (imported
620# from the LSR) with the translations in `${LANG}/texidocs/`.
621$(outdir)/snippets/%.itely: snippets/%-intro.itely snippets/%.snippet-list
622	$(call ly_progress,Making,$@,)
623	mkdir -p $(dir $@)
624	xargs $(LYS_TO_TELY) \
625	  --prefix=snippets/ \
626	  -f doctitle,texidoc,verbatim \
627	  --name=$@ \
628	  --template=$< \
629	  < $(filter %.snippet-list, $^)
630
631$(outdir)/snippets/dep: $(SNIPPET_LY_FILES)
632	$(call ly_progress,Making,$@,)
633	mkdir -p $(dir $@)
634	$(PYTHON) $(buildscript-dir)/makesnippets.py \
635	  $(src-dir)/snippets $(dir $@) "$(LANGS)" $(src-dir)
636	mkdir -p out
637	touch $@
638
639$(outdir)/en/internals.texi:
640	$(call ly_progress,Making,$@,)
641	mkdir -p $(dir $@)
642	cd $(dir $@) \
643	  && $(buildscript-dir)/run-and-check.sh \
644\
645"$(LILYPOND_BINARY) \
646   --verbose \
647   $(top-src-dir)/ly/generate-documentation" \
648\
649	       generate-documentation.log
650
651
652## Different manuals within a language link to each other.  This can only work
653## if the target document has an xref-map, too.
654define per_lang_per_doc_deps
655  # `lilypond-book` automatically generates `.dep` files, but only for `.itely`
656  # files.
657  $(outdir)/$(1)/$(2).texi: \
658    $(call src-wildcard,$(1)/$(2)/*.itexi) \
659    $(outdir)/version.itexi
660
661  $(outdir)/$(1)/$(2).xref-map: $(outdir)/$(1)/$(2).texi
662
663  ifneq ($(1),en)
664    $(outdir)/$(1)/$(2).xref-map: $(outdir)/en/$(2).xref-map
665  endif
666
667  $(outdir)/$(1)/$(2)/index.html: $(call LANG_XREF_FILES,$(1))
668
669  $(outdir)/$(1)/$(2)-big-page.html: $(call LANG_XREF_FILES,$(1))
670endef
671
672
673## Dependencies on the automatically generated content.
674define per_lang_dep
675  include $(wildcard $(outdir)/$(1)/*.dep)
676
677  $(outdir)/$(1)/snippets.texi: \
678    $(IN_ITELY_FILES:snippets/%-intro.itely=$(outdir)/snippets/%.itely) \
679    $(outdir)/snippets/dep
680
681  $(outdir)/$(1)/notation.texi: $(outdir)/snippets/dep
682
683  $(outdir)/$(1)/learning.texi: $(outdir)/snippets/dep
684
685  $(outdir)/$(1)/usage.texi: $(outdir)/snippets/dep
686
687  $(outdir)/$(1)/web.xref-map: EXTRACT_TEXI_FILENAMES_FLAGS += --split=node
688
689  $(outdir)/$(1)/pictures:
690	  rm -f $$@ && mkdir -p $$(dir $$@) && ln -s ../pictures $$@
691
692  # Adjust the @direntry block to only list installed info files.
693  $(outdir)/$(1)/web.texi: \
694    $(1)/web.texi \
695    $(outdir)/we-wrote.itexi \
696    $(outdir)/others-did.itexi \
697    $(outdir)/weblinks.itexi \
698    $(outdir)/version.itexi
699  ifneq ($(out),www)
700	  $(call ly_progress,Making,$$@,(sed))
701	  mkdir -p $$(dir $$@)
702	  sed -e '/^\*.*lilypond-snippets/d' \
703	      -e '/^\*.*lilypond-web/d' \
704	      < $$< \
705	      > $$@
706  endif
707
708  $(outdir)/$(1)/essay.texi: \
709    $(outdir)/colorado.itexi \
710    $(outdir)/computer-notation.itexi \
711    $(outdir)/engravingbib.itexi
712
713  # `notation.tely` includes generated files, including `hyphenation.itexi`,
714  # as well as many like `markup-commands.tely` via
715  # `notation/notation-appendices.itely`.  These are the result of processing
716  # `ly/generate-documentation.ly` for `internals.texi` (see above).
717  $(outdir)/$(1)/notation.texi: $(outdir)/en/internals.texi
718
719  $(foreach D, \
720            $(DOC_BASENAMES), \
721            $(eval $(call per_lang_per_doc_deps,$(1),$(D))))
722endef
723
724$(foreach L, $(LANGS), $(eval $(call per_lang_dep,$(L))))
725
726
727###############################################
728#  Documentation and translations maintenance #
729###############################################
730po-update:
731	$(MAKE) -C po po-update
732
733ifneq ($(NO_COLOR),)
734  CHECK_TRANSLATION_FLAGS = --no-color
735endif
736
737ifneq ($(ISOLANG),)
738  new-lang-dir:
739	  mkdir -p $(ISOLANG)/$(DIR)
740	  rm -f $(outdir)/*.*tely $(outdir)/*.*texi
741	  $(PYTHON) $(auxscript-dir)/texi-langutils.py \
742	    -d $(outdir) \
743	    -l $(ISOLANG) \
744	    -o doc.pot \
745	    --skeleton \
746	    --gettext \
747	    $$(cd $(ISOLANG) && ls -1 ../$(DIR).tely ../$(DIR).texi)
748	  for i in $$(cd $(outdir) && ls -1 $(DIR).tely $(DIR).texi); do \
749	    test -e $(ISOLANG)/$$i || mv $(outdir)/$$i $(ISOLANG)/$$i; \
750	  done
751	  rm -f $(outdir)/$(DIR).tely $(outdir)/$(DIR).texi
752	  for i in $$(cd $(outdir) && ls -1 *.*tely *.*texi); do \
753	    test -e $(ISOLANG)/$(DIR)/$$i \
754	      || test -e $(ISOLANG)/$$i \
755	      || mv $(outdir)/$$i $(ISOLANG)/$(DIR)/$$i; \
756	  done
757
758  new-lang:
759  # Also for updating/adding missing files.
760	  mkdir -p $(ISOLANG)/included
761	  if test -z "`ls $(ISOLANG)/included`"; then \
762	    touch $(ISOLANG)/included/.gitignore; \
763	  fi
764	  $(foreach i, \
765	            $(TRANSLATION_DIRS), \
766	            $(MAKE) new-lang-dir DIR=$(i) &&) :
767	  msgmerge -U po/lilypond-doc.pot $(outdir)/doc.pot
768	  test -e po/$(ISOLANG).po || cp po/lilypond-doc.pot po/$(ISOLANG).po
769	  @echo "***  Please add a language definition for $(ISOLANG) in python/langdefs.py  ***"
770
771  TRANSLATION_DIRS = web texidocs
772  TRANSLATION_FILES = $(shell git ls-files $(ISOLANG))
773
774  TELY_FILES = $(call src-wildcard,$(ISOLANG)/*.tely)
775
776  snippet-update:
777	  $(PYTHON) $(auxscript-dir)/update-snippets.py \
778	    user $(ISOLANG) '*.itely'
779endif # ISOLANG
780
781check-xrefs:
782	$(PYTHON) $(auxscript-dir)/check_texi_refs.py --batch \
783	  $(DOCUMENTATION_INCLUDES)
784
785fix-xrefs:
786	$(PYTHON) $(auxscript-dir)/check_texi_refs.py --auto-fix \
787	  $(DOCUMENTATION_INCLUDES)
788
789check-translation:
790	cd $(src-dir) \
791	  && ISOLANG=$(ISOLANG) \
792	     $(PYTHON) $(auxscript-dir)/check_translation.py \
793	       $(CHECK_TRANSLATION_FLAGS) $(TRANSLATION_FILES)
794
795update-translation:
796	cd $(src-dir) \
797	  && ISOLANG=$(ISOLANG) \
798	     $(PYTHON) $(auxscript-dir)/check_translation.py \
799	       --update $(CHECK_TRANSLATION_FLAGS) $(TRANSLATION_FILES)
800
801translation-status:
802	cd $(src-dir) \
803	  && PYTHONPATH=$(top-src-dir)/python:$(top-src-dir)/python/auxiliar \
804	       $(PYTHON) $(top-src-dir)/scripts/auxiliar/translations-status.py
805
806
807#########
808### Image rules
809
810$(outdir)/%-flat-gray.png: %-flat-gray.png
811	$(call ly_progress,Making,$@,(convert))
812	mkdir -p $(dir $@)
813	convert -strip -depth 8 -geometry 50x50% $< $@
814
815$(outdir)/%-flat-bw.png: %-flat-bw.png
816	$(call ly_progress,Making,$@,(convert))
817	mkdir -p $(dir $@)
818	convert -strip -depth 8 -geometry 50x50% $< $@
819
820$(outdir)/%.png: %.png
821	$(call ly_progress,Making,$@,)
822	mkdir -p $(dir $@)
823	cp $< $@
824
825$(outdir)/%.jpg: %.jpg
826	$(call ly_progress,Making,$@,)
827	mkdir -p $(dir $@)
828	cp $< $@
829
830$(outdir)/%.png: %.eps
831	$(call ly_progress,Making,$@,< eps)
832	mkdir -p $(dir $@)
833	gs -dAutoRotatePages=/None \
834           -dPrinted=false \
835           -dTextAlphaBits=4 \
836           -dGraphicsAlphaBits=4 \
837           -q \
838           -sOutputFile=$@ \
839           -sDEVICE=png16m \
840           -dEPSCrop \
841           -dNOPAUSE \
842           -f $< \
843           -c quit
844
845$(outdir)/%.pdf: %.eps
846	$(call ly_progress,Making,$@,< eps)
847	mkdir -p $(dir $@)
848	gs -dAutoRotatePages=/None \
849           -dPrinted=false \
850           -q \
851           -sDEVICE=pdfwrite \
852           -dNOPAUSE \
853           -dBATCH \
854           -sOutputFile=$@ \
855           -dEPSCrop \
856           -f $<
857
858# ly-examples/
859$(outdir)/%.png: %.ly
860	$(call ly_progress,Making,$@,< ly)
861	mkdir -p $(dir $@)
862	$(buildscript-dir)/run-and-check.sh \
863\
864"$(LILYPOND_PREVIEW) \
865   -o $(dir $@) \
866   $<" \
867\
868	  "$(outdir)/$*.preview.log"
869	mv $(outdir)/$*.preview.png $@
870
871# Must have `ly-examples/`, to avoid conflicts with `xxx-small.png` from
872# `pictures/`.
873$(outdir)/ly-examples/%-small.png: $(outdir)/ly-examples/%.png
874	$(call ly_progress,Making,$@,(convert))
875	convert -strip -resize 600 -posterize 8 $< png8:$@
876
877## LOGO
878
879ifeq ($(PLATFORM_WINDOWS),yes)
880  $(outdir)/%.ico: %.xpm
881	  $(call ly_progress,Making,$@,< xpm)
882	  mkdir -p $(dir $@)
883	  $(PYTHON) $(buildscript-dir)/genicon.py $< $@
884endif # PLATFORM_WINDOWS
885
886$(outdir)/%.css: %.css
887	$(call ly_progress,Making,$@,(copy))
888	mkdir -p $(dir $@)
889	cp -f $< $@
890