# last edited: Fri Mar 26 13:14:35 1999 by piumarta (Ian Piumarta) on pingu

include ccg/ccg.mk

PROG:=		vmc

DISTFILES:=	Makefile *.[chly] *.cg

MAKEFLAGS=	--no-print-directory

.PHONY:		opt depend dist clean stats sunos

CC:=		gcc
CFLAGS:=	-O -g -Wall

GEN:=		vmc_ppc.o vmc_sparc.o vmc_i386.o
OBJ:=		generate.o label.o lexer.o parser.o

$(PROG):	parser.o lexer.o $(OBJ) $(GEN)
		$(CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(GEN) -lfl

ccg/ccg.mk:
		ln -s ../../.. ccg

opt:
		$(MAKE) CFLAGS="$(CFLAGS) $(OPTCFLAGS)" clean $(PROG)

parser.h \
parser.c:	parser.y
		bison -d -o parser.c parser.y

lexer.c:	lexer.l parser.h
		flex -olexer.c lexer.l

parser.o lexer.o: generate.h yy.h

test:		test.o label.o $(GEN)

dist:		$(DISTFILES)
		mkdir -p $(DISTDIR)
		cp -p $(DISTFILES) $(DISTDIR)

depend:
		-$(CC) -MM *.c > .depend

clean:
		/bin/rm -f parser.h parser.c parser.output lexer.c *.o *~ core vmc_*.c

spotless:	clean
		/bin/rm -f $(PROG) test .depend

distclean:	spotless

stats:
		@fgrep -v include $(SRC) $(HDR) parser.y lexer.l | sort | uniq | wc -l

ifeq (.depend,$(wildcard .depend))
include .depend
endif

sunos:
		$(MAKE) CPPFLAGS="-I/usr/5include" LDFLAGS="-L/usr/5lib"
