# $Source: /afs/athena.mit.edu/user/b/e/bert/Thesis/src/exact/RCS/Makefile,v $
#

CC=/mit/gnu/bin/gcc
# CC=/mit/cygnus/sun4bin/gcc
# CC=/afs/sipb/project/gnu/bin/gcc

PURIFY=purify

# DEBUG= -g -DDEBUG -DDO_TRACK_SYNC
# DEBUG= -g -pg -DDEBUG
# DEBUG= -O3 -ffast-math -pg -DDEBUG -msupersparc
DEBUG= -g -DDEBUG

# DEFS=  -DSHORT
# DEFS=  -DLONG

CFLAGS= -Wall $(DEFS) $(DEBUG)
LDFLAGS=-lm $(DEBUG)

# EXTRA_OBJS=strerror.o


TGRIND=tgrind
XDVI=xdvi
DVIPS=dvips
# PRINTOPTS= -hduplex
PRINTOPTS= -o'!lpr -h'

srcdir= /mit/bert/Thesis/src/exact
blddir= /mit/bert/Thesis/arch/@sys/exact

TARGETS= return
XTARGETS= twodim
2D_OBJS= twodim.o drfft.o complex.o oppack.o util.o matherr.o expect.o \
  propagate.o $(EXTRA_OBJS)
RTN_OBJS= return.o drfft.o complex.o oppack.o util.o matherr.o expect.o \
  propagate.o $(EXTRA_OBJS)
DVIFILES= twodim.c.dvi dfft.c.dvi drfft.c.dvi complex.c.dvi oppack.c.dvi \
  matherr.c.dvi complex.h.dvi fft.h.dvi oppack.h.dvi util.h.dvi util.c.dvi \
  expect.h.dvi expect.c.dvi propagate.h.dvi propagate.c.dvi return.c.dvi

.PHONY:	default all clean prev print sync

default: $(TARGETS)

all: default $(XTARGETS)

twodim: $(2D_OBJS)
	$(CC) $^ $(LDFLAGS) -o $@

return: $(RTN_OBJS)
	$(CC) $^ $(LDFLAGS) -o $@

return.pure: $(RTN_OBJS)
	$(PURIFY) $(CC) $^ $(LDFLAGS) -o $@

clean:
	$(RM) $(XTARGETS) $(TARGETS) *.o *.log *.dvi *.c.tex *.h.tex *~ .*~

%.c.tex: %.c
	$(TGRIND) -lc -f $^ > $@
%.h.tex: %.h
	$(TGRIND) -lc -f $^ > $@
.PRECIOUS: %.c.tex %.h.tex

prev: $(DVIFILES)
	for i in $(DVIFILES); do $(XDVI) -s 8 $$i& done
print: $(DVIFILES)
	for i in $(DVIFILES); do $(DVIPS) $(PRINTOPTS) $$i; done

sync: $(blddir)
	/usr/athena/etc/synctree -s $(srcdir) -d $(blddir)
