## This file is part of ANTLR (http://www.antlr.org).  Have a
## look into LICENSE.txt for  license  details. This file has 
## been written by (C) Wolfgang Haefelinger, 2004.

## do not change this value 
subdir=examples/java/tinybasic

## get  configured  (standard) variables - checkout or modify
## scripts/config.vars[.in] for details.
@stdvars@

### how to get rid of damned dos line ending style and -- al-
### most equally worse -- stupid tab character.
### dos2unix  = perl -p -i.tmp -e 's,\r,,g;s,\t, ,g' 
dos2unix = :

## get configured rules
@stdmake@

## By default we compile class files so we are ready to carry
## out a test. Note that deps have been setup in such a way
## that you can do a 'make compile' whithout having made 
## antlr.jar before. 
this : compile
all  :: compile
compile : .java
test :: test1 test2 test3


## My *.g files 
g_FILES  = \
  $(_srcdir)/TinyBasic.g \
  $(_srcdir)/TinyBasicTreeWalker.g \
  $(eol)

## Java files generated by *.g
g_src_FILES = \
  $(thisdir)/TinyBasicLexer.java \
  $(thisdir)/TinyBasicLexerTokenTypes.java \
  $(thisdir)/TinyBasicParser.java \
  $(thisdir)/TinyBasicTokenTypes.java \
  $(thisdir)/TinyBasicTreeWalker.java \
  $(thisdir)/TinyBasicTreeWalkerTokenTypes.java \
  $(eol)

## Text files generated by *.g
g_txt_FILES = \
	$(thisdir)/IDLTokenTypes.txt \
	$(eol)

## All generated files by *.g
g_gen_FILES = \
	$(g_src_FILES) \
	$(g_txt_FILES) \
	$(eol)

# All Java files
j_src_FILES = \
	$(g_src_FILES) \
  $(_srcdir)/Context.java \
  $(_srcdir)/DTArray1D.java \
  $(_srcdir)/DTArray2D.java \
  $(_srcdir)/DTArray3D.java \
  $(_srcdir)/DTCodeType.java \
  $(_srcdir)/DTDataType.java \
  $(_srcdir)/DTDataTypeProxy.java \
  $(_srcdir)/DTExecException.java \
  $(_srcdir)/DTExitModuleException.java \
  $(_srcdir)/DTFloat.java \
  $(_srcdir)/DTFunction.java \
  $(_srcdir)/DTInteger.java \
  $(_srcdir)/DTString.java \
  $(_srcdir)/DTSubroutine.java \
  $(_srcdir)/FunctionScope.java \
  $(_srcdir)/GlobalScope.java \
  $(_srcdir)/Main.java \
  $(_srcdir)/ProgramScope.java \
  $(_srcdir)/Scope.java \
  $(_srcdir)/SubroutineScope.java \
	$(eol)

## Dependencies of test 1
test1_deps = \
	.java \
	$(buildtree)/scripts/javac.sh \
	$(eol)
test2_deps = \
	.java \
	$(buildtree)/scripts/javac.sh \
	$(eol)
test3_deps = \
	.java \
	$(buildtree)/scripts/javac.sh \
	$(eol)

## Test 1
test1_cmd = \
	@ @JAVA_CMD@ tinybasic.Main $(_srcdir)/try.bas \
	$(eol)
## Test 2
test2_cmd = \
	@ @JAVA_CMD@ tinybasic.Main $(_srcdir)/try1.bas \
	$(eol)
## Test 3
test3_cmd = \
	@ @JAVA_CMD@ tinybasic.Main $(_srcdir)/try2.bas \
	$(eol)

## Tests
test1 : $(test1_deps)
	@ $(test1_cmd)

test2 : $(test2_deps)
	@ $(test2_cmd)

test3 : $(test3_deps)
	@ $(test3_cmd)


## How to generated *.java ..
$(g_src_FILES) : $(g_FILES)
	@ @RMF@ $(g_src_FILES)
	@ @ANTLR_COMPILE_CMD@ $(g_FILES)
	@ $(dos2unix) $(g_src_FILES)

$(g_src_FILES) : @ANTLR_JAR@
$(g_src_FILES) : $(buildtree)/scripts/antlr.sh

## How to generate class files
.java : $(j_src_FILES)
	@-@RMF@ $@
	@@JAVA_COMPILE_CMD@  $(j_src_FILES) && @ECHO@ > $@

.java : $(buildtree)/scripts/javac.sh

### cleanup astsupport
clean ::
	@@ECHO@ cleaning $(subdir) ...
	@ -@RMF@ .java *.class $(g_gen_FILES) tinybasic
	@ -@RMF@ *.pyc *.tmp *TokenTypes.txt *TokenTypes



### get configured dependencies - for example, just list
### autoconf variable ANTLR_JAR as reference and it will
### be  done  automatically  as stddeps contains appropr.
### rule. For details, checkout scripts/config.vars[.in] 
@stddeps@

.PHONY: compile
.PHONY: test1
