###############################################################################
#
#  FileName    [Makefile]
#
#  PackageName [ft]
#
#  Synopsis    [The Makefile of the ft package]
#
#  Author      [Marco Pistore] 
#
#  Copyright   [Copyright (C) 2003 by University of Trento.
#
#  T-Tool is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as
#  published by the Free Software Foundation; either version 2 of the
#  License, or (at your option) any later version.
#
#  T-Tool 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
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with this library; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
#
#  For more information on the T-Tool see <http://dit.unitn.it/~ft>
#  or email to <ft@dit.unitn.it>. Please report bugs to <ft@dit.unitn.it>.]
#
###############################################################################

HSRC=ft.h ft-int.h
CSRC=ft-dom.c ft-type.c ft-print.c ft-bounds.c ft-to-il.c il-to-smv.c
LSRC=ft-lex.l il-lex.l
YSRC=ft-gra.y il-gra.y

YHEA=$(YSRC:.y=.h)

COBJ=$(CSRC:.c=.o)
LOBJ=$(LSRC:.l=.o)
YOBJ=$(YSRC:.y=.o)

OBJ=$(COBJ) $(LOBJ) $(YOBJ)

all : ft2il il2smv ft2smv

$(OBJ) : $(HSRC)

$(COBJ) $(LOBJ) : $(YHEA)

%.o : %.c 
	gcc -c -g -W -Wall $< -o $@

%.c : %.l
	flex $<
	mv lex.yy.c $@

%.c %.h : %.y
	bison -dv $<
	mv $(<:.y=.tab.c) $(<:.y=.c) 
	mv $(<:.y=.tab.h) $(<:.y=.h) 

ft2il : $(OBJ) ft2il.o
	gcc -g -o $@ $^

ft2smv : $(OBJ) ft2smv.o
	gcc -g -o $@ $^

il2smv : $(OBJ) il2smv.o
	gcc -g -o $@ $^

clean:
	-rm -f *~ *.o \
		ft-gra.output ft-gra.c ft-gra.h ft-lex.c \
		il-gra.output il-gra.c il-gra.h il-lex.c

distclean: clean
	-rm -f ft2il il2smv ft2smv

