BYACCJ=@BYACCJ@
JFLEX=@JAVA@ -cp @LIBCLASSPATH@ JFlex.Main
# Preserve compatibility with JRE 1.5, by cross-compiling to 1.5.
# Call this makefile with
#     BOOTCLASSPATH=-bootclasspath path/to/rt5.jar
# ...in order to do this without warnings.  The code still works --
# meaning it passes its unit tests -- when built with a later Java
# runtime, but it warns that
#    bootstrap class path not set in conjunction with -source 1.5
# When -source is provided, it's generally good to include
# -bootclasspath, too.
BOOTCLASSPATH=
JAVAC=@JAVAC@ -target 1.5 -source 1.5 $(BOOTCLASSPATH)

INSTALL=@INSTALL@
#MKDIR_P=mkdir -p
MKDIR_P=@MKDIR_P@
STRIPAT=../buildtools/build/stripat

PACKAGE_VERSION=@PACKAGE_VERSION@
LIBRARY_HOMEPAGE=@LIBRARY_HOMEPAGE@

PARSERS=@PARSERLIST@
CP=uk/me/nxg/unity

prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@




# We have to explicitly mention SimpleCSVReader, because we want it to
# be included in the jar file (for tests and as a general utility)
# even though it's not referred to by UnitParser.
unity.jar: build/$(CP)/UnitParser.class build/$(CP)/util/SimpleCSVReader.class
	rm -f $@
	echo "Main-Class: uk.me.nxg.unity.UnitParser" >manifest.txt
	cd build; jar cmf ../manifest.txt ../$@ .
	rm manifest.txt

build/$(CP)/UnitParser.class: $(CP)/UnitParser.java \
		$(CP)/OneUnit.java \
		$(patsubst %,gen/$(CP)/Parser_%.java,$(PARSERS)) \
		gen/uk/me/nxg/unity/UnityUnitDefinitionMap.java \
		gen/uk/me/nxg/unity/UnityFunctionDefinitionMap.java
	test -d build || mkdir build
	$(JAVAC) -encoding UTF8 -classpath .:gen -Xlint -d build $(CP)/UnitParser.java

build/$(CP)/util/SimpleCSVReader.class: $(CP)/util/SimpleCSVReader.java
	test -d build || mkdir build
	$(JAVAC) -encoding UTF8 -classpath . -Xlint -d build $(CP)/util/SimpleCSVReader.java


install: unity.jar
	test -d $(bindir) || $(MKDIR_P) $(bindir)
	$(INSTALL) unity.jar $(bindir)


check: unity.jar
	cd test; $(MAKE) check

clean:
	rm -Rf build gen dist docs unity.jar
	rm -f Parser*.java Yylex.java *.y
	cd test; $(MAKE) clean
