#!/usr/bin/env make
#
# Extra rules to be appended to the generated qmake makefile for xxdiff build.
#

# Extra targets.
EXTRA_FILES = version.h $(MAKEDIR)/doc.h

.SUFFIXES: .html .txt .h


#
# resParser.o
#

# Extra dependencies for the included lex/yacc generated files.
resParser_lex.h: resParser_lex.cpp
resParser.cpp: resParser_lex.h


#
# version.h
#

# Automatically generate a simple include file with version number in it.
version.h: $(MAKEDIR)/../VERSION
	echo "#define XX_VERSION \"`cat $(MAKEDIR)/../VERSION`\"" > $@

# Dependencies for the generated version file.
proginfo.o: version.h
proginfo.obj: version.h


#
# doc.h
#

# Convert the html/qml documentation to an C include file.
# This needs to be automated.
.html.h:
	sed -e 's/\"/\\\"/g;s/$$/\\n\\/;1s/^/char text[]=\"/;$$s/\\$$/\"\;/' $< > $@

# Dependencies for the generated documentation file.
help.o: $(MAKEDIR)/doc.h
help.obj: $(MAKEDIR)/doc.h

# Convert the reStructuredText documentation to html.  (this is only used by the
# author, directly, manually, not that important for xxdiff packagers.)
.txt.html:
	rst2html.py --output-encoding=iso-8859-1 $< $@

#
# clean_extra
#

# Clean up some of the generated files automatically.
clean: clean_extra

clean_extra:
	rm -f $(EXTRA_FILES)


# Note: we would need to add this to be correct.  Danger!  If the Makefile gets
# remade, this file does not get appended again to the new makefile!
all: Makefile

Makefile: $(MAKEDIR)/xxdiff.pro
	$(MAKE) -f $(MAKEDIR)/Makefile.bootstrap Makefile
