###############################################################################
# $Id:$
###############################################################################

##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@stdvars@
##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

## do not change this value
subdir=examples/cpp/exprAST

srcdir = @abs_top_srcdir@/examples/cpp/exprAST
objdir = @abs_this_builddir@/examples/cpp/exprAST

this : test
test : test1 test2

all: expr test

g_FILES = \
	$(srcdir)/expr.g \
	$(eol)

g_cxx_FILES = \
  $(objdir)/ExprLexer.cpp \
  $(objdir)/ExprParser.cpp \
  $(eol)

g_hpp_FILES = \
	$(objdir)/ExprLexer.hpp \
	$(objdir)/ExprParser.hpp \
	$(objdir)/ExprParserTokenTypes.hpp \
  $(eol)

g_txt_FILES = \
	$(objdir)/ExprParserTokenTypes.txt \
	$(eol)

g_gen_FILES = \
	$(g_cxx_FILES) \
	$(g_hpp_FILES) \
	$(g_txt_FILES) \
	$(eol)

g_obj_FILES = \
	 $(objdir)/ExprLexer@OBJEXT@ \
	 $(objdir)/ExprParser@OBJEXT@ \
	 $(eol)

## Source files
expr_cxx_FILES = \
	$(g_cxx_FILES) \
	$(srcdir)/Main.cpp  \
	$(eol)

## Object files
expr_obj_FILES = \
	$(g_obj_FILES) \
	$(objdir)/Main@OBJEXT@  \
	$(eol)

## Test commands ..
test1_cmd = $(objdir)/expr < $(srcdir)/test.in
test2_cmd = $(objdir)/expr < $(srcdir)/test2.in

## Tests to be executed
test1 : expr
	@ v="$(verbose)"; \
    if test $$v -gt 0 ; then \
      @ECHO@ "$(test1_cmd)" ; \
    else \
      @ECHO@ "exec test1 .."; \
    fi
	@ $(test1_cmd)

test2 : expr
	@ v="$(verbose)"; \
    if test $$v -gt 0 ; then \
      @ECHO@ "$(test2_cmd)" ; \
    else \
      @ECHO@ "exec test2 .."; \
    fi
	@ $(test2_cmd)

## How to make binaries
expr : $(expr_obj_FILES) @ANTLR_LIB@
	@ @CXX_LINK_CMD@ $@ $(expr_obj_FILES)

## How to compile ANTLR grammar files
$(g_gen_FILES) : $(g_FILES) @ANTLR_JAR@
	@ANTLR_COMPILE_CMD@  $(g_FILES)

## GNU make - how to make object file
$(objdir)/%@OBJEXT@ : $(srcdir)/%.cpp
	@ @CXX_COMPILE_CMD@ $<

## GNU make - how to make object file
$(objdir)/%@OBJEXT@ : $(objdir)/%.cpp
	@ @CXX_COMPILE_CMD@ $<

## GNU make - how to make object file
%@OBJEXT@ : $(srcdir)/%.cpp
	@ @CXX_COMPILE_CMD@ $<

## GNU make - how to make object file
%@OBJEXT@ : $(objdir)/%.cpp
	@ @CXX_COMPILE_CMD@ $<

## Housecleaning
clean:
	@RMF@ *.o *.obj *.exe expr $(g_gen_FILES) test1 test2

distclean: clean
	@RMF@ Makefile

# Dependencies
$(objdir)/ExprLexer@OBJEXT@: \
	$(objdir)/ExprLexer.hpp \
	$(objdir)/ExprParserTokenTypes.hpp

$(objdir)/ExprParser@OBJEXT@: \
	$(objdir)/ExprParser.hpp \
	$(objdir)/ExprParserTokenTypes.hpp

$(objdir)/Main@OBJEXT@: \
	$(objdir)/ExprLexer.hpp \
	$(objdir)/ExprParserTokenTypes.hpp \
	$(objdir)/ExprParser.hpp

## If cxx.sh script changed ..
$(expr_obj_FILES) : @abs_this_builddir@/scripts/cxx.sh

## If link.sh script changed ..
$(expr_obj_FILES) : @abs_this_builddir@/scripts/link.sh

##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@stddeps@
##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
