#
# PCCTS makefile for: cplusplus.g stat.g expr.g
#
# [do a 'make Cplusplus=g++' or whatever if Cplusplus make macro not defined]
#
# PUBLIC DOMAIN PCCTS-BASED C++ GRAMMAR (cplusplus.g, stat.g, expr.g)
#
# VERSION 1.1
#
# Authors: Sumana Srinivasan, NeXT Inc.;            sumana_srinivasan@next.com
#          Terence Parr, Parr Research Corporation; parrt@parr-research.com
#          Russell Quong, Purdue University;        quong@ecn.purdue.edu
#
# SOFTWARE RIGHTS
#
# This file is a part of the ANTLR-based C++ grammar and is free
# software.  We do not reserve any LEGAL rights to its use or
# distribution, but you may NOT claim ownership or authorship of this
# grammar or support code.  An individual or company may otherwise do
# whatever they wish with the grammar distributed herewith including the
# incorporation of the grammar or the output generated by ANTLR into
# commerical software.  You may redistribute in source or binary form
# without payment of royalties to us as long as this header remains
# in all source distributions.
#
# We encourage users to develop parsers/tools using this grammar.
# In return, we ask that credit is given to us for developing this
# grammar.  By "credit", we mean that if you incorporate our grammar or
# the generated code into one of your programs (commercial product,
# research project, or otherwise) that you acknowledge this fact in the
# documentation, research report, etc....  In addition, you should say nice
# things about us at every opportunity.
#
# As long as these guidelines are kept, we expect to continue enhancing
# this grammar.  Feel free to send us enhancements, fixes, bug reports,
# suggestions, or general words of encouragement at parrt@parr-research.com.
# 
# NeXT Computer Inc.
# 900 Chesapeake Dr.
# Redwood City, CA 94555
# 12/02/1994
# 
# Restructured for public consumption by Terence Parr late February, 1995.
#
# Requires PCCTS 1.32b4 or higher to get past ANTLR. 
# 
# DISCLAIMER: we make no guarantees that this grammar works, makes sense,
#             or can be used to do anything useful.
#
# PCCTS release 1.32b4
# Project: cplusplus
# C++ output
# DLG scanner
# ANTLR-defined token types
#
TOKENS = tokens.h
#
# The following filenames must be consistent with ANTLR/DLG flags
DLG_FILE = parser.dlg
ERR = err
HDR_FILE =
SCAN = DLGLexer
#PCCTS = /projects/pccts
#PCCTS = /usr/local/pccts
PCCTS = /usr/local/src/pccts
ANTLR_H = $(PCCTS)/h
BIN = $(PCCTS)/bin
ANTLR = $(PCCTS)/bin/antlr
DLG = $(PCCTS)/bin/dlg
CFLAGS = -I. -I$(ANTLR_H) -g -DDBG_REFCOUNTTOKEN
AFLAGS = -CC -k 2 -gd -prc on -rl 150000
DFLAGS = -C2 -i -CC
CPPDIR = cppparser
GRM = cplusplus.g stat.g expr.g
SRC = main.cpp support.cpp Dictionary.cpp \
      cplusplus.cpp stat.cpp expr.cpp \
      CPPParser.cpp \
      $(ANTLR_H)/AParser.cpp $(ANTLR_H)/DLexerBase.cpp $(ANTLR_H)/ATokenBuffer.cpp $(SCAN).cpp
OBJ = main.o support.o Dictionary.o \
      cplusplus.o stat.o expr.o \
      CPPParser.o \
      AParser.o DLexerBase.o ATokenBuffer.o $(SCAN).o
ANTLR_SPAWN = cplusplus.cpp stat.cpp expr.cpp CPPParser.cpp \
              CPPParser.h $(DLG_FILE) $(TOKENS)
DLG_SPAWN = $(SCAN).cpp $(SCAN).h
#Cplusplus=g++
#CC=g++

cplusplus : $(OBJ) $(SRC)
	$(Cplusplus) -o cplusplus $(CFLAGS) $(OBJ)

main.o : main.cpp $(ANTLR_SPAWN) $(SCAN).h
	$(Cplusplus) -c $(CFLAGS) main.cpp

support.o : support.cpp $(ANTLR_SPAWN) $(SCAN).h
	$(Cplusplus) -c $(CFLAGS) support.cpp

cplusplus.o : $(TOKENS) $(SCAN).h cplusplus.cpp
	$(Cplusplus) -c $(CFLAGS) -o cplusplus.o cplusplus.cpp

stat.o : $(TOKENS) $(SCAN).h stat.cpp
	$(Cplusplus) -c $(CFLAGS) -o stat.o stat.cpp

expr.o : $(TOKENS) $(SCAN).h expr.cpp
	$(Cplusplus) -c $(CFLAGS) -o expr.o expr.cpp

CPPParser.o : $(TOKENS) $(SCAN).h CPPParser.cpp CPPParser.h
	$(Cplusplus) -c $(CFLAGS) -o CPPParser.o CPPParser.cpp

Dictionary.o : Dictionary.cpp
	$(Cplusplus) -c $(CFLAGS) Dictionary.cpp

$(SCAN).o : $(SCAN).cpp $(TOKENS)
	$(Cplusplus) -c $(CFLAGS) -o $(SCAN).o $(SCAN).cpp

$(ANTLR_SPAWN) : $(GRM)
	$(ANTLR) $(AFLAGS) $(GRM)

$(DLG_SPAWN) : $(DLG_FILE)
	$(DLG) $(DFLAGS) $(DLG_FILE)

AParser.o : $(ANTLR_H)/AParser.cpp
	$(Cplusplus) -c $(CFLAGS) -o AParser.o $(ANTLR_H)/AParser.cpp

ATokenBuffer.o : $(ANTLR_H)/ATokenBuffer.cpp
	$(Cplusplus) -c $(CFLAGS) -o ATokenBuffer.o $(ANTLR_H)/ATokenBuffer.cpp

DLexerBase.o : $(ANTLR_H)/DLexerBase.cpp
	$(Cplusplus) -c $(CFLAGS) -o DLexerBase.o $(ANTLR_H)/DLexerBase.cpp

clean:
	rm -f *.o core cplusplus

scrub:
	rm -f *.o core cplusplus $(ANTLR_SPAWN) $(DLG_SPAWN)

ci:
	ci -u main.cpp support.cpp CPPDictionary.h CPPSymbol.h \
	cplusplus.g stat.g expr.g \
	Makefile Dictionary.h Dictionary.cpp DictEntry.h input.c README

co:
	co -l main.cpp support.cpp CPPDictionary.h CPPSymbol.h \
	cplusplus.g stat.g expr.g \
	Makefile Dictionary.h Dictionary.cpp DictEntry.h input.c README

tar:
	cp test/t*.cpp $(CPPDIR)/test
	cp main.cpp support.cpp CPPDictionary.h CPPSymbol.h \
	cplusplus.g stat.g expr.g \
	Makefile Dictionary.h Dictionary.cpp DictEntry.h input.c README $(CPPDIR)
	tar cvf cplusplus.tar $(CPPDIR)
#	(cd $(CPPDIR); rm -rf *)
	echo "C++ Parser tar made: cplusplus.tar"
	
