-# Texinfo_rules.make
-.SUFFIXES: .1 .html .texinfo
+.SUFFIXES: .html .info .texi .texinfo
-texi2man = $(step-bindir)/out/texi2man $< $@
-texi2html =\
- rm -f $@.urg;\
- cat $< | sed "s!@include.*!!" > $@.urg;\
- $(TEXI2HTML) $@.urg;\
- rm -f $@.urg;\
- mv $(@F).urg.html $@;\
- rm -f $(@F:%.html=%.html.urg_toc.html);\
- add-URLs $@
+# "makeinfo --info" MUST be able to read PNGs from CWD for info images
+# to work, hence $(INFO_IMAGES_DIR) -> $(outdir)/ symlink.
+# $(outdir)/$(INFO_IMAGES_DIR)/*.png symlinks are only needed to view
+# out-www/*.info with Emacs -- HTML docs no longer need these
+# symlinks, see replace_symlinks_urls in
+# python/auxiliar/postprocess_html.py.
-$(outdir)/%.1: %.texinfo
- $(texi2man)
+# make dereferences symlinks, and $(INFO_IMAGES_DIR) is a symlink
+# to $(outdir), so we can't use directly $(INFO_IMAGES_DIR) as a
+# prerequisite, otherwise %.info are always outdated (because older
+# than $(outdir)), hence this .dep file
-$(outdir)/%.info: $(outdir)/%.texinfo
- $(MAKEINFO) --force -o $@ $<
+$(outdir)/$(INFO_IMAGES_DIR).info-images-dir-dep: $(INFO_DOCS:%=$(outdir)/%.texi)
+ifneq ($(INFO_IMAGES_DIR),)
+ rm -f $(INFO_IMAGES_DIR)
+ ln -s $(outdir) $(INFO_IMAGES_DIR)
+ mkdir -p $(outdir)/$(INFO_IMAGES_DIR)
+ rm -f $(outdir)/$(INFO_IMAGES_DIR)/[a-f0-9][a-f0-9]
+ cd $(outdir)/$(INFO_IMAGES_DIR) && $(buildscript-dir)/mass-link symbolic .. . [a-f0-9][a-f0-9]
+endif
+ touch $@
-# $(outdir)/%.html: %.texinfo
-# $(texi2html)
-# add-html-footer --index $(depth)/../index.html $@
+$(outdir)/%.info: $(outdir)/%.texi $(outdir)/$(INFO_IMAGES_DIR).info-images-dir-dep $(outdir)/version.itexi
+ $(MAKEINFO) -I$(src-dir) -I$(outdir) --output=$@ $<
-# texi2html is as broken as pod2html 5004 :-)
-# we'll have to use pod2html 5003 for now.
-# don't burn your .pod sources!
-#
-$(outdir)/%.html: $(outdir)/%.texinfo
- $(texi2html)
- $(PYTHON) $(step-bindir)/add-html-footer.py --package=$(topdir) --index $(depth)/../index.html $@
+ifeq (,$(findstring texi2html,$(MISSING_OPTIONAL)))
+$(outdir)/%-big-page.html: $(outdir)/%.texi $(XREF_MAPS_DIR)/%.xref-map $(outdir)/version.itexi
+ $(TEXI2HTML) --I=$(src-dir) --I=$(outdir) -D bigpage --output=$@ $(TEXI2HTML_INIT) $<
+ cp $(top-src-dir)/Documentation/lilypond*.css $(dir $@)
-$(outdir)/%.1: $(outdir)/%.texinfo
- -$(texi2man)
+$(outdir)/%.html: $(outdir)/%.texi $(XREF_MAPS_DIR)/%.xref-map $(outdir)/version.itexi
+ $(TEXI2HTML) --I=$(src-dir) --I=$(outdir) --output=$@ $(TEXI2HTML_INIT) $<
+ cp $(top-src-dir)/Documentation/lilypond*.css $(dir $@)
+$(outdir)/%/index.html: $(outdir)/%.texi $(XREF_MAPS_DIR)/%.xref-map $(outdir)/version.itexi
+ mkdir -p $(dir $@)
+ $(TEXI2HTML) --I=$(src-dir) --I=$(outdir) --output=$(dir $@) --prefix=index --split=section $(TEXI2HTML_INIT) $<
+ cp $(top-src-dir)/Documentation/lilypond*.css $(dir $@)
+
+else # Rules using makeinfo follow
+$(outdir)/%-big-page.html: $(outdir)/%.texi $(outdir)/version.itexi
+ $(MAKEINFO) -I$(src-dir) -I $(outdir) --output=$@ --css-include=$(top-src-dir)/Documentation/texinfo.css --html --no-split -D bigpage --no-headers $<
+
+$(outdir)/%.html: $(outdir)/%.texi $(outdir)/version.itexi
+ $(MAKEINFO) -I$(src-dir) -I$(outdir) --output=$@ --css-include=$(top-src-dir)/Documentation/texinfo.css --html --no-split --no-headers $<
+
+$(outdir)/%/index.html: $(outdir)/%.texi $(outdir)/version.itexi
+ mkdir -p $(dir $@)
+ $(MAKEINFO) -I$(src-dir) -I$(outdir) --output=$(dir $@) --css-include=$(top-src-dir)/Documentation/texinfo.css --html $<
+endif
+
+$(outdir)/%.html.omf: %.texi
+ $(call GENERATE_OMF,html)
+
+$(outdir)/%.pdf.omf: %.texi
+ $(call GENERATE_OMF,pdf)
+
+$(outdir)/%.ps.gz.omf: %.texi
+ $(call GENERATE_OMF,ps.gz)
+
+$(outdir)/%.pdf: $(outdir)/%.texi $(outdir)/version.itexi
+ cd $(outdir); texi2pdf $(TEXI2PDF_FLAGS) --batch $(TEXINFO_PAPERSIZE_OPTION) $(<F)
+
+
+MAKEINFO_TXT_COMMAND =
+
+$(outdir)/%.txt: $(outdir)/%.texi $(outdir)/version.itexi
+ $(MAKEINFO) -I$(src-dir) -I$(outdir) --no-split --no-headers --output $@ $<
+
+$(XREF_MAPS_DIR)/%.xref-map: $(outdir)/%.texi
+ $(buildscript-dir)/extract_texi_filenames -o $(XREF_MAPS_DIR) $<
+
+$(outdir)/%.texi: %.texi
+ cp -f $< $@
+
+$(outdir)/version.%: $(top-src-dir)/VERSION
+ echo '@macro version'> $@
+ echo $(TOPLEVEL_VERSION)>> $@
+ echo '@end macro'>> $@
+
+.SECONDARY: $(outdir)/version.itexi $(outdir)/version.texi \
+ $(outdir)/$(INFO_IMAGES_DIR).info-images-dir-dep \
+ $(outdir)/*.texi