#Copyright (C) The University of Melbourne 1993
#All Rights Reserved

#Permission to use, copy, modify, and distribute this software and
#its documentation for any purpose and without fee is hereby
#granted, provided that the above copyright notice appear in all
#copies and that both that the copyright notice and this
#permission notice and warranty disclaimer appear in supporting
#documentation, and that the name of The University of Melbourne 
#or any of its entities not be used in advertising or publicity
#pertaining to distribution of the software without specific,
#written prior permission.

#THE UNIVERSITY OF MELBOURNE DISCLAIMS ALL WARRANTIES WITH REGARD
#TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
#MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL THE UNIVERSITY
#OF MELBOURNE OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
#SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
#WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
#IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
#ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
#THIS SOFTWARE.

#AUTHORS : Jason Lee (jasonl@cs.mu.oz.au)
# 	   Andrew Davison (ad@cs.mu.oz.au)


#***************************************************************
# NOTE : WHEN CALLED FROM THE TOP LEVEL, ALL MACROS GET DEFINED
# SO DON'T EDIT THIS FILE ONLY THE TOP LEVEL MAKEFILE NEEDS TO
# BE CHANGED

# the yacc source file name prefix name
YACCFILE=	parse

# the lex source file name prefix name
LEXFILE=	lexical

YFLAGS=
INSTALLDIR=
LEX=
YACC=
LIBS=
CFLAGS=
TRADCC=
CC2=
CC=

# Source files etc
NONCFILES=	$(YACCFILE).y $(LEXFILE).l

CFILES=		error.c bebop.c symbol.c dump_tree.c free_tree.c compile.c \
		bebop_functions.c

SRC=	 $(NONCFILES) $(CFILES) $(HDR)

OBJ=     $(YACCFILE).o $(LEXFILE).o error.o bebop.o symbol.o dump_tree.o \
		free_tree.o compile.o bebop_functions.o

HDR=	 bebop.h


# rules
bebopcc:	$(OBJ) 
		$(CC) $(OBJ) -o bebop $(LIBS) 

$(YACCFILE).c y.tab.h:	$(YACCFILE).y
			@/bin/echo ""
			@/bin/echo "******* Expect 2 shift/reduce conflicts *********"
			@/bin/echo "***** See compiler/CHANGES for more info ********"
			@/bin/echo ""
			$(YACC) $(YFLAGS) $(YACCFILE).y
			/bin/mv y.tab.c $(YACCFILE).c

$(LEXFILE).c:	$(LEXFILE).l
		$(LEX) $(LEXFILE).l
		/bin/mv lex.yy.c $(LEXFILE).c

$(YACCFILE).o:	$(YACCFILE).c
		$(CC2) $(CFLAGS) -c $(YACCFILE).c

$(LEXFILE).o:	tokens.h $(LEXFILE).c
		$(TRADCC) $(CFLAGS) -c $(LEXFILE).c

tokens.h:	y.tab.h 
		- /bin/cmp -s y.tab.h tokens.h || cp y.tab.h tokens.h

symbol.o free_tree.o error.o dump.tree.o compile.o: tokens.h


install:
	strip bebop
	-/bin/cp $(INSTALLDIR)/bebop $(INSTALLDIR)/bebop.old
	/bin/cp bebop $(INSTALLDIR)

clean:
	 -/bin/rm core
	 -/bin/rm $(OBJ)
	 -/bin/rm y.tab.h
	 -/bin/rm $(YACCFILE).c $(LEXFILE).c
	 -/bin/rm y.output tokens.h 

clobber:
	 -/bin/rm core
	 -/bin/rm $(OBJ)
	 -/bin/rm y.tab.h
	 -/bin/rm $(YACCFILE).c $(LEXFILE).c
	 -/bin/rm y.output tokens.h
	 -/bin/rm bebop

