# $Id: Makefile,v 1.4 1998/06/11 10:56:53 felix Exp $
#----------------------------------------------------------------------

#
# Makefile for a noweb-pretzel combination
#
# see README for details
#



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

# prefix of .ft and .fg files of the small test language

TESTLANG	= test

# all sources generated from noweb files

SRCS	= pretty.h errors.h getline.h match.h strsave.h columns.h	\
		pretty.c errors.c getline.c match.c strsave.c columns.c	\
		nowebpretzelpp.c

# this object contains the main() function of the filter and
# is linked to any new noweb prettyprinting filter by pretzel-it

NWPPMAINOBJ	= pretty.o

# these are the other objects that are needed to build the main filter
# program that calls the prettyprinting function. The actual
# prettyprinter is a seperate set of objects.

NWPPOBJS	= errors.o getline.o match.o strsave.o columns.o

# this is the object that interfaces a pretzel prettyprinter with
# the noweb prettyprinter API

NWPRETZELPPOBJS	= nowebpretzelpp.o

# these are the objects that implement a test prettyprinter for this
# directory. Normally, these files must be supplied by the user and
# determine how the prettyprinted output looks

NWPRETZELTESTOBJS 	= test.tab.o test.lex.o

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

# which compiler are you using?
CC=g++

# make the CFLAGS point to the pretzel installation directorys:
CFLAGS=-I../../../include -L../../.. -lpretzel -g


NOWEAVE	= noweave
NOTANGLE	= notangle
CPIF	= >



.SUFFIXES: .nw .tex .dvi .h

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

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

.nw.o:
	$(NOTANGLE) -L $*.nw >$*.c
	$(CC) $(CFLAGS) -c $*.c

.nw.h:
	$(NOTANGLE) -Rheader $*.nw $(CPIF) $*.h

.tex.dvi:
	latex $*

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

# all:


prettytest: $(NWPPOBJS) $(NWPRETZELPPOBJS) $(NWPRETZELTESTOBJS) $(NWPPMAINOBJ)
	$(CC) 	$(NWPPOBJS) $(NWPRETZELPPOBJS) $(NWPRETZELTESTOBJS)	\
		$(NWPPMAINOBJ) $(CFLAGS) -o prettytest


# use pretzel, flex and Bison to build objects for the test language
# (use languages/pascal/Makefile as a reference for your own Makefiles
# for Pretzel). Don't use pretzel-it because pretzel-it uses released
# objects and we possibly want to link the non-released objects in
# this directory.

$(NWPRETZELTESTOBJS): $(TESTLANG).ft $(TESTLANG).fg
	pretzel $(TESTLANG)
	bison -d $(TESTLANG).y
	mv $(TESTLANG).tab.h ptokdefs.h
	flex -t $(TESTLANG).l > $(TESTLANG).lex.c
	$(CC) $(CFLAGS) -c $(TESTLANG).tab.c $(TESTLANG).lex.c


source:	$(SRCS)


clean:
	rm -f *.tex *.log *.dvi *.o *.toc *.aux

clobber: clean
	rm -f $(SRCS)
	rm -f prettytest ptokdefs.h $(TESTLANG).l $(TESTLANG).y		\
		$(TESTLANG).lex.c $(TESTLANG).tab.c

# copy pretty.o as nowebpretzelpp.o to pretzel library directory and
# add necessary objects to pretzel library

release: $(NWPRETZELPPOBJS) $(NWPPOBJS) $(NWPPMAINOBJ)
	cp $(NWPPMAINOBJ) ../../../nowebpretzelpp.o
	ar vrus ../../../libpretzel.a $(NWPPOBJS) $(NWPRETZELPPOBJS)


# test the resulting prettytest filter

regression: prettytest
	noweave -delay -filter prettytest -index testcode.nw > testcode.tex
	latex testcode.tex
	latex testcode.tex



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

# dependencies

columns.o:      columns.h
errors.o:       errors.h
getline.o:      columns.h errors.h getline.h
match.o:        match.h
pretty.o:	getline.h match.h errors.h pretty.h strsave.h
strsave.o:      strsave.h errors.h
nowebpretzelpp.o:	pretty.h
