# 
# Copyright (C) 1999, 2000, 2001  Network Associates, Incorporated (NAI)
# All rights reserved.
#
# This file is part of the NAI Generic Software Wrappers Toolkit
# (GSWTK).  See ftp://ftp.tislabs.com/pub/wrappers/ for the latest
# distribution.
#
# The GSWTK 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, or (at your option)
# any later version.
#
# The GSWTK 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 software; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

TOPDIR = ../..

#include ${TOPDIR}/mak/config.mak

YACC=bison
OBJ = .o
CXXFLAGS = -g -I${TOPDIR}/wr.include -I./
#CXXFLAGS = -O2
CFLAGS = -g

OBJS = peg.tab${OBJ} source${OBJ} pegc${OBJ} type${OBJ} expr${OBJ} pathfind${OBJ} gram${OBJ} code-wdl${OBJ} code-cpp${OBJ}

all:	pegc

pegc:	$(OBJS) 
	${CXX} -o pegc ${OBJS}

lex.peg.c:	pegram.l
	flex -Sflex.skl -Ppeg pegram.l

peg.tab.cc: smodule.h pegram.y lex.peg.c gram.h expr.h type.h
	${YACC} -t -v -p peg -o peg.tab.cc pegram.y

gram.o:	gram.h codesrc.h

clean:
	rm -rf ${OBJS} pegc

tar:
	rm -rf ${OBJS} peg.tab.cc peg.tab.cc.output peg.tgz pegc
	tar -cvf peg.tar .
	gzip peg.tar
	mv peg.tar.gz peg.tgz

bsd.mod: bsd.seed
	rm -rf tmpfile.mod
	cp bsd.seed tmpfile.c	
	gcc -E -C -P tmpfile.c > tmpfile.mod
	fix.pl tmpfile.mod bsd.mod
	rm tmpfile.c
	rm tmpfile.mod

