# $Id: Makefile,v 1.12 1996/09/12 18:42:11 gaertner Exp $
# ----------------------------------------------------------------------

#
# Makefile for the formatted token file scanner and parser
#


# ----------------------------------------------------------------------
# Here are the things that determine the configuration:
# ----------------------------------------------------------------------

# what compiler do we use?
CC 	= g++

# de-comment this if you want a debug version:
#DBVERSION = -D XXX

# flags :
CFLAGS 	= -g -I../include -L.. -lpretzel

# prefix for globals of scanner and parser (`yy' by default)
GLOBALSPREFIX = Pretzel_ft

# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# You probably don't need to change anything from here:
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------

# Groups of files:

# all noweb sources
NOWEBS	= ftscan.nw ftparse.nw ftokens.nw

# root chunk name of headers
HEADERCHUNK	= header

# root chunk name of C implementation
IMPLEMENTATIONCHUNK	= implementation

# root chunk name of flex implementation
FLEXIMPLCHUNK	= flex-implementation

# root chunk name of bison implementation
BISONIMPLCHUNK	= bison-implementation

# all `WEB' sources (old)
#WEBS	= ftokens.w ftparse.spc ftparse.y ftscan.spc ftscan.l

# all other program WEB sources (old)
#ETCWEBS	= pscan.spc

# all TeX documents
TEXDOCS	=

# all other files for the distribution
DISTFILES = Makefile pascal.ft test.output.correct README

# name of the distribution package
DISTNAME =


# Which program to make by default:
PROG	= ftokens

# objects of this program:
OBJS 	= ftokens.o ftparse.o ftscan.o

# objects to be released:
RELOBJS	= ftparse.o ftscan.o

# C sources of this program:
CSRCES	= ftokens.c ftparse.c ftscan.c

# intermediate products from which C sources are made
INTERMEDIATES = ftscan.l ftparse.y

# stuff to be deleted when cleaning up:
OTHERCRAP = ftparse.aux ftparse.dvi ftparse.idx ftparse.log 	\
		ftparse.scn ftparse.tex	ftparse.toc		\
		ftscan.aux ftscan.dvi ftscan.idx ftscan.log	\
		ftscan.scn ftscan.tex ftscan.toc		\
		ftscan.l ftparse.y				\
		pscan.dvi pscan.idx pscan.log pscan.scn	 	\
		pscan.tex pscan.toc				\
		Pscan.h Ppscan.h				\
		ftokens.aux ftokens.dvi ftokens.idx ftokens.log	\
		ftokens.scn ftokens.tex test.output

# ----------------------------------------------------------------------
# these are all the headers for the compiler
HEADERS = ftparse.h ftscan.h ftokdefs.h Pscan.h Ppscan.h

# these are all the objects for the compiler
OBJECTS = $(OBJS)

# these are all the C sources to make the objects
CSOURCES = $(CSRCES)

# These are all of the flags for the compiler:
CCFLAGS = $(CFLAGS) $(DBVERSION)

# these are all C sources that might possibly crop up
ALLCSRCS = $(CSOURCES)

# these are all object files that may appear
ALLOBJS = $(OBJECTS)

# these are all header files produced from WEBs that may appear
ALLHEADERS = $(HEADERS)

# these are all the executables that could be produced
ALLPROGS = ftokens

# ----------------------------------------------------------------------

CWEAVE 	= cweave
CTANGLE	= ctangle
NOTANGLE= notangle
NOWEAVE	= noweave
TEX 	= tex
DVIPS 	= dvips
REMOVE	= rm -f
MAKE	= make
LEX	= flex
#LEX	= lex
YACC	= bison
#YACC	= yacc
TEX	= tex
LATEX	= tex-it latex

# ----------------------------------------------------------------------

BISONOPTIONS 	= -p$(GLOBALSPREFIX)
FLEXOPTIONS 	= -L -P$(GLOBALSPREFIX)

# ----------------------------------------------------------------------

.SUFFIXES:	.nw .spc .ps .tex .dvi .w .c .o .h

# overall rules:

.nw.tex:
	$(NOWEAVE) -delay $*.nw > $*.tex

.w.tex:
	$(CWEAVE) $*

.tex.dvi:
	$(LATEX) $<

.w.dvi:
	$(MAKE) $*.tex
	$(MAKE) $*.dvi

.dvi.ps:
	$(DVIPS) $< -o $*.ps

.nw.h:
	$(NOTANGLE) -L -R$(HEADERCHUNK) $*.nw > $*.h

.nw.c:
	$(NOTANGLE) -L -R$(IMPLEMENTATIONCHUNK) $*.nw > $*.c

.nw.l:
	$(NOTANGLE) -R$(FLEXIMPLCHUNK) $*.nw > $*.l

.nw.y:
	$(NOTANGLE) -R$(BISONIMPLCHUNK) $*.nw > $*.y

.w.c:
	$(CTANGLE) $*

.spc.h:
	$(CTANGLE) $*.spc - $*.h

#.w.o:
#	$(MAKE) $*.c
#	$(MAKE) $*.o

.c.o:
	$(CC) -c $*.c $(CCFLAGS)


.y.c:
	$(YACC) $(BISONOPTIONS) $*.y
	mv $*.tab.c $*.c

.l.c:
	$(LEX) -t $(FLEXOPTIONS) $*.l > $*.c

# ----------------------------------------------------------------------

# regenerate whole system:


system: $(PROG)


$(PROG): $(OBJECTS)
	$(CC) -o $@ $(OBJECTS) $(CCFLAGS)

$(OBJS): $(HEADERS) $(CSRCES)

$(CSRCES): $(INTERMEDIATES)

# make the common token header
ftokdefs.h: ftparse.y
	$(YACC) -d ftparse.y
	mv ftparse.tab.h ftokdefs.h

Ppscan.h: ftparse.nw
	$(NOTANGLE) -R"header file for prettyprinting scanner" ftparse.nw >Ppscan.h

Pscan.h: ftparse.nw
	$(NOTANGLE) -R"header file for abstract base class of [[Pscan]]" ftparse.nw >Pscan.h

# regression:
regression: $(PROG)
	./ftokens <pascal.ft > test.output
	if  diff test.output test.output.correct;		\
		then echo "Regression test is fine."; 		\
		else echo "Regression test failed.";		\
		fi


# list all source code:

print:


# apply lint to all C sources:

lint:


# remove all intermediate products but not executables or sources!

clean:
	$(REMOVE) $(ALLOBJS) $(ALLCSRCS) $(ALLHEADERS) $(OTHERCRAP)


# remove everything that doesn't belong to original source:

clobber: clean
	$(REMOVE) $(ALLPROGS)


# bundle source files together into an archive:

#bundle:
#	tar cf $(DISTNAME).tar 			\
#		$(WEBS) $(ETCWEBS) $(TEXDOCS) $(DISTFILES)


# copy executables into PATH directories, et al.

install:


# release a new version:

release: $(HEADERS) $(RELOBJS)
	cp $(HEADERS) ../include
	ar vrus ../libpretzel.a $(RELOBJS)



# ======================================================================
#
# $Log: Makefile,v $
# Revision 1.12  1996/09/12  18:42:11  gaertner
# Changed to g++.
#
# Revision 1.11  1996/03/19  16:04:49  gaertner
# Tailored for the new noweb versions of the files.
#
# Revision 1.11  1996/03/19  16:04:49  gaertner
# Tailored for the new noweb versions of the files.
#
# Revision 1.10  1996/03/15  13:39:12  gaertner
# Check in before switching to noweb.
#
# Revision 1.9  1995/08/15  17:20:11  gaertner
# Moved options of CC to the end of the command line for portability.
#
# Revision 1.9  1995/08/15  17:20:11  gaertner
# Moved options of CC to the end of the command line for portability.
#
# Revision 1.8  1995/08/15  17:03:30  gaertner
# Added possibility to change the global prefix of scanner and
# parser variables.
#
# Revision 1.7  1995/04/26  18:06:46  gaertner
# You can now make a regression test.
# Compiling/releasing use lpretzel library.
# Making .dvi's will use LaTeX. Invoke TeX manually if you want to
# get a printout of the pscan.spc file.
#
# Revision 1.6  1994/10/31  19:03:27  gaertner
# Now make bundle creates ftokens.tar
#
# Revision 1.5  1994/10/24  16:49:48  gaertner
# now the ftokens.o object isn't released anymore.
#
# Revision 1.4  1994/10/24  16:30:29  gaertner
# Added pscan.spc that is also released.
#
# Revision 1.3  1994/10/18  10:58:30  gaertner
# Flex doesn't run in debug mode anymore.
#
# Revision 1.2  1994/10/14  15:54:38  gaertner
# Initial revision of granny version using the Makefile
# template.
#
#






