#
# VNPForth - Compiled native Forth for IA32 Linux systems
# Copyright (C) 2000  Simon Baldwin (simonb@sco.com)
#
# This program 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 2
# of the License, or (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

OBJECTS = utils.o compiler.o pstore.o ifile.o sfile.o ident.o codegen.o \
	  optimizer.o forth.o forth.tab.o getopts.o
CFLAGS  = -O -Wall
LDFLAGS	=
#CFLAGS  = -g -Wall
#LDFLAGS = -g

default: all

#
# Build the forth compiler, and name mangler helper
#
all: forthc mangle

forthc: $(OBJECTS)
	cc $(LDFLAGS) -o forthc $(OBJECTS) -lfl

mangle: mangle.o ident.o
	cc $(LDFLAGS) -o mangle mangle.o ident.o

#
# Define dependencies related to header/include files
#
compiler.o: utils.h ifile.h sfile.h codegen.h optimizer.h getopts.h forth_y.h

forth.tab.c forth.tab.h: forth.y forth_y.h ident.h ifile.h pstore.h
	bison -v -d forth.y

forth.c: forth.tab.h forth.l forth_y.h
	flex -oforth.c forth.l

codegen.o: codegen.h pstore.h ident.h

optimizer.o: optimizer.h pstore.h sfile.h

pstore.o: pstore.h ifile.h

mangle.o: ident.h

#
# Cleanup targets
#
clean:
	rm -f mangle forthc
	rm -f forth.c forth.tab.c forth.tab.h forth.output *.o
	rm -f core gmon.out

clobber: clean
