# $Id: Makefile,v 2.0 1996/12/16 17:33:16 gaertner Exp $
# ----------------------------------------------------------------------

#
# Makefile for the main pretzel program and plainpp/plaindpp files
#

# this is the current version
VERSION	= 2.0

# ----------------------------------------------------------------------
# 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 PRETZEL_DEBUG

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


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

# Groups of files:

# all noweb sources
NOWEBS	= pretzel.nw

# root chunk name of headers
HEADERCHUNK     = header

# root chunk name of implementation
IMPLEMENTATIONCHUNK     = implementation

# all `WEB' sources (old)
#WEBS	= pretzel.w

# all other program WEB sources (old)
#ETCWEBS	=

# all TeX documents
TEXDOCS	=

# all other files for the distribution
DISTFILES = Makefile pascal.correct.l pascal.correct.y pascal.ft pascal.fg \
	plainpp.c plaindpp.c

# name of the distribution package
#DISTNAME = main


# Which program to make by default:
PROG	= pretzel

# objects of this program:
OBJS 	= pretzel.o

# C sources of this program:
CSRCES	= pretzel.c

# these objects should be created too:
RELOBJS	= plainpp.o plaindpp.o

# all stuff to be removed too:
OTHERCRAP = pretzel.tex pretzel.aux pretzel.idx pretzel.log 	\
		pretzel.scn pretzel.toc pretzel.dvi 		\
		pascal.l pascal.y

# ----------------------------------------------------------------------
# these are all the headers for the compiler
HEADERS =

# 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) $(RELOBJS)

# these are all header files produced from WEBs that may appear
ALLHEADERS =

# these are all the executables that could be produced
ALLPROGS = $(PROG)

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

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

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

.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

.w.c:
	$(CTANGLE) $*

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

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

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



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

# regenerate whole system:


system: $(PROG)


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

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


# 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)
	$(REMOVE) $(DISTNAME).tar


# bundle source files together into an archive:

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

# make a regression test:
regression: $(PROG)
	./pretzel pascal
	if { diff pascal.l pascal.correct.l && 		\
		diff pascal.y pascal.correct.y; } 	\
		then echo "Regression test is fine.";	\
	else echo "Regression test failed.";		\
	fi


# copy executables into PATH directories, et al.

release: $(PROG) $(RELOBJS)
	cp $(PROG) ../bin
	cp $(RELOBJS) ..



# ======================================================================
#
# $Log: Makefile,v $
# Revision 2.0  1996/12/16 17:33:16  gaertner
# *** empty log message ***
#
# Revision 1.9  1996/09/12  18:40:05  gaertner
# Changed CC to g++ and added $(PROG) to regression line.
#
# Revision 1.8  1996/03/22  11:21:36  gaertner
# Uses noweb stuff now.
# Added plaindpp.c/o parts.
#
# Revision 1.7  1995/09/07  17:36:59  gaertner
# Changed target `install' to `release'.
#
# Revision 1.6  1995/04/26  16:47:09  gaertner
# The .w.dvi implicit rule now uses Latex.
# The used library is now lpretzel.
# The binary is copied to ../bin instead of ../../bin (this
# makes it more portable).
# You can make a regression test with `make regression'.
# `clean' now removes all stuff produced by regression and Latex'ing
# of pretzel.w.
# `clobber' also removes main.tar
#
# Revision 1.5  1994/10/31  19:06:06  gaertner
# Now make bundle makes main.tar
#
# Revision 1.4  1994/10/24  17:45:58  gaertner
# Doesn't create a debug version anymore.
#
# Revision 1.3  1994/10/24  17:14:14  gaertner
# Installs pretzel to ../../bin when you `make install'.
#
# Revision 1.2  1994/10/21  17:36:00  gaertner
# Compiles with PRETZEL_DEBUG set.
#
# Revision 1.1  1994/10/21  17:16:54  gaertner
# Initial revision
#
#
