# vim: set noexpandtab:
#
# GNU Solfege - ear training for GNOME
# Copyright (C) 2000, 2001, 2002, 2003, 2004  Tom Cato Amundsen
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

LANGUAGES:=C no nl ru es_MX

I18NDEFS:=--stringparam chunker.output.encoding "UTF-8"
XSLTPARAMS:=--stringparam suppress.navigation 1 --param use.id.as.filename 1

include online-docs/C/Makefile
include online-docs/no/Makefile
include online-docs/es_MX/Makefile
include online-docs/ru/Makefile
include online-docs/nl/Makefile

include online-docs/png/Makefile

dist_files += online-docs/Makefile online-docs/texidefinitions.m4.in \
	      $(wildcard online-docs/*.py) online-docs/stupid_catalog_file.cat

#FIXME broken deps
%.html: %.xml
ifeq ($(WITH_LOCAL_XMLCATALOG),yes)
	(cd $(dir $<); SGML_CATALOG_FILES=$(SGML_CATALOG_FILES) $(XSLTPROC) $(XSLTPARAMS) $(I18NDEFS) --catalogs  $(stylesheet_filename) $(notdir $<))
else
	(cd $(dir $<); $(XSLTPROC) $(XSLTPARAMS) $(I18NDEFS) $(stylesheet_filename) $(notdir $<))
endif
	$(PYTHON) online-docs/addstyle.py $(dir $<)*.html
	echo "Dummy file." > $@

%.texi: %.tely
	$(LILYPONDBOOK) --output $(dir $<) $<

%.html: %.src.html
	$(PYTHON) online-docs/process-lilygenerated-docs.py < $< > $@

# Used to create gpl and html file, but not the main document. FIXME.
%.html: %.sgml
ifeq ($(WITH_LOCAL_XMLCATALOG),yes)
	SGML_CATALOG_FILES=$(SGML_CATALOG_FILES) $(XSLTPROC) -o $@ $(XSLTPARAMS) $(I18NDEFS) --catalogs  --nonet $(dir $(stylesheet_filename))/docbook.xsl $<
else
	$(XSLTPROC) -o $@ $(XSLTPARAMS) $(I18NDEFS) $(dir $(stylesheet_filename))/docbook.xsl $<
endif

%/toc.html:
	LC_ALL=$(patsubst online-docs/%/,%,$(dir $@)) $(PYTHON) online-docs/create_toc.py $(dir $@)

clean-files += update-version-strings-stamp
distclean-files += texidefinitions.m4

update-version-strings: update-version-strings-stamp
update-version-strings-stamp:
	for lang in $(filter-out nl, $(LANGUAGES)); do\
	cat online-docs/$$lang/solfege.xml | sed 's/ENTITY version ".*"/ENTITY version "$(VERSION)"/' | sed 's/ENTITY shortversion ".*"/ENTITY shortversion "$(MAJOR_VERSION).$(MINOR_VERSION)"/' > _mk.tmp && rm -f online-docs/$$lang/solfege.xml && mv _mk.tmp online-docs/$$lang/solfege.xml; \
	done
	touch update-version-strings-stamp

#dvi:
#	$(MAKE) -C png ps
#	$(MAKE) -C C dvi

#win32-dist:
#	$(foreach i, $(LANGUAGES), $(MAKE) -C $(i) win32-dist-local &&) true

