# Generated automatically from Makefile.in by configure.
# This file makes WEB-related programs: tangle, weave, and pooltype.
# tangle is bootstrapped from a C source.

SHELL = /bin/sh

srcdir = .
VPATH = .

# Routines used everywhere.
commondefines=../$(srcdir)/lib/common.defines
commonh=../$(srcdir)/lib/common.h
commono=../lib/lib.a


CC = gcc
CFLAGS = -g
CPPFLAGS = -I../$(srcdir)/lib

CCLD = $(CC)
LDFLAGS = $(CFLAGS) $(XLDFLAGS)
LIBS =  $(extralibs)
libs = $(commono) $(LIBS)

INSTALL = cp
INSTALL_PROGRAM = $(INSTALL)


.SUFFIXES:
.SUFFIXES: .o .c .p .ch
.p.c:
	$(SHELL) ../$(srcdir)/lib/convert $*.p $*.c
.ch.p:
	./tangle $*.web $*.ch
.c.o:
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $*.c


default: triptrap
triptrap: tangle
all: triptrap pooltype weave


tangleboot: tangleboot.o $(commono)
	$(CCLD) -o tangleboot $(LDFLAGS) tangleboot.o $(libs)

tangleboot.o: tangleboot.c tangleboot.h

tangleboot.c tangleboot.h: tangleboot.p
	cd ../web2c; $(MAKE) all
	$(SHELL) ../$(srcdir)/lib/convert tangleboot.p temp.c
	sed s/tangle.h/tangleboot.h/ < temp.c > tangleboot.c
	rm -f temp.c

# To make tangleboot.p, we have to assume the presence of a working
# tangle somewhere in PATH.
tangleboot.p: tangle.web tangle.ch
	tangle tangle.web tangle.ch
	mv tangle.p tangleboot.p


tangle: tangle.o $(commono)
	$(CCLD) -o tangle $(LDFLAGS) tangle.o $(libs)
tangle.o: tangle.c $(commonh)
tangle.c: tangle.p $(commondefines)

# Making tangle.p is a special case, since it is needed to compile
# itself.  We compile the (distributed) tangleboot.c to make a tangle
# which we can use to make the other programs.  (We don't bother to make
# tangle again using itself.)
tangle.p: tangleboot tangle.web tangle.ch
	./tangleboot tangle.web tangle.ch


pooltype: pooltype.o $(commono)
	$(CCLD) -o pooltype $(LDFLAGS) pooltype.o $(libs)
pooltype.o: pooltype.c $(commonh)
pooltype.c: pooltype.p $(commondefines)
pooltype.p: pooltype.web pooltype.ch


weave: weave.o $(commono)
	$(CCLD) -o weave $(LDFLAGS) weave.o $(libs)
weave.o: weave.c $(commonh)
weave.c: weave.p $(commondefines)
weave.p: weave.web weave.ch


Makefile: Makefile.in ../config.status
	(cd ..; sh config.status)

# Prevent GNU make 3 from overflowing arg limit on system V.
.NOEXPORT:


c-sources: pooltype.c tangle.c weave.c
.PHONY: c-sources

install install-exec: all
	$(INSTALL_PROGRAM) pooltype $(bindir)/pooltype
	$(INSTALL_PROGRAM) tangle $(bindir)/tangle
	$(INSTALL_PROGRAM) weave $(bindir)/weave

install-data:

mostlyclean: 
	rm -f *.o *.pool patgen tangle weave tangleboot pooltype coerce.h

# Can't remove *.p *.c *.h because of tangleboot.
clean: mostlyclean
	rm -f pooltype.p pooltype.c pooltype.h
	rm -f tangle.p tangle.c tangle.h
	rm -f weave.p weave.c weave.h

distclean: clean
	rm -f Makefile

extraclean: distclean
	rm -f *~ *\#* patch* *.orig *.rej *.bak *.ckp
	rm -f *.dvi *.log *.aux *gf *pk *.tfm core a.out

# Do not remove tangleboot.[chp], even though there are targets for them
# in this Makefile, because we need a working Tangle to use them, and we
# might not have one.
realclean: distclean
