#  MAD: Software for the Modular Action Description Language
#  Copyright (C) 2008  Selim T. Erdogan
#
#  This file is part of MAD.
#
#  MAD 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 3 of the License, or
#  (at your option) any later version.
#
#  MAD 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 MAD.  If not, see <http://www.gnu.org/licenses/>.
#
#
#  Contact info: selim@cs.utexas.edu
#

.PHONY : all
all : mparse

HELPER_OBJECTS = yaccer.tab.o data-manipulation.o

mparse : mparse.o $(HELPER_OBJECTS)
	gcc -o mparse mparse.o $(HELPER_OBJECTS) -ll -ly

mparse.o : data-types.h yaccer.tab.h lex.yy.h mparse.c
	gcc -c mparse.c

yaccer.tab.o : data-types.h lex.yy.c yaccer.tab.c
	gcc -c yaccer.tab.c

data-manipulation.o : data-types.h data-manipulation.c
	gcc -c data-manipulation.c

lex.yy.c : flexer.l
	flex flexer.l

lex.yy.h : flexer.l
	flex flexer.l

yaccer.tab.c: yaccer.y
	bison -d yaccer.y

yaccer.tab.h: yaccer.y
	bison -d yaccer.y

.PHONY : clean
clean :
	-rm mparse \
            *.o \
            yaccer.tab.c yaccer.tab.h \
	    lex.yy.c lex.yy.h 


.PHONY : debug
debug : yaccer.tab-dbg.o mparse-dbg.o data-manipulation-dbg.o 
	gcc -o mparse mparse-dbg.o yaccer.tab-dbg.o data-manipulation-dbg.o -ll -ly

yaccer.tab-dbg.o : data-types.h lex.yy.c yaccer.tab.c
	gcc -c -g yaccer.tab.c -o yaccer.tab-dbg.o

data-manipulation-dbg.o : data-types.h data-manipulation.c
	gcc -c -g data-manipulation.c -o  data-manipulation-dbg.o

mparse-dbg.o : data-types.h yaccer.tab.h lex.yy.h mparse.c
	gcc -c -g mparse.c -o mparse-dbg.o
