case $CONFIG in
    '') . ./config.sh ;;
esac
echo "Extracting Makefile (with variable substitutions)"
$cat >Makefile <<!GROK!THIS!
# $Id: Makefile.SH,v 3.0 1992/03/01 02:13:32 davison Trn $

CC = $cc
mtlib = $installprivlib
mansrc = $installmansrc
manext = $manext
CFLAGS = $optimize $ccflags
LDFLAGS = $ldflags
#NNTPNNTPFLAGS = $nntpflags
ndirc = $ndirc
ndiro = $ndiro

libs = $libndir $jobslib -lm $libs
!GROK!THIS!
$cat >>Makefile <<'!NO!SUBS!'

public = mthreads mt.check
private = makedir filexp
manpages = mthreads.8
util = Makefile makedepend
#NNTPnntpsrc=nntpinit.c nntpclient.c
#NNTPnntpobj=nntpinit.o nntpclient.o

h = common.h mthreads.h threads.h

c = mthreads.c mt-read.c mt-process.c mt-write.c mt-misc.c $(ndirc) $(nntpsrc)

obj = mthreads.o mt-read.o mt-process.o mt-write.o mt-misc.o parsedate.o \
	$(ndiro) $(nntpobj)

addedbymake = Makefile.old mt.check config.h makedepend makedir mthreads all

# grrr
SHELL = /bin/sh

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

all: $(public) $(private) $(util)
	touch all

mthreads: $(obj)
	$(CC) $(LDFLAGS) $(obj) $(libs) -o mthreads
#NNTP
#NNTPnntpinit.o:
#NNTP	$(CC) -c $(CFLAGS) $(NNTPFLAGS) $*.c

unipatch: unipatch.o
	$(CC) $(LDFLAGS) unipatch.o -o unipatch

# if a .h file depends on another .h file...
$(h):
	-touch $@

install: $(public) $(private) $(manpages)
# won't work with csh
	export PATH || exit 1
	- ./makedir `./filexp $(mtlib)`
	- cd `./filexp $(mtlib)`; mv mthreads mthreads.old
	- if test `pwd` != `./filexp $(mtlib)`; then cp $(public) `./filexp $(mtlib)`; fi
	- if test `pwd` != `./filexp $(mtlib)`; then cp $(private) `./filexp $(mtlib)`; fi
	- if test `pwd` != `./filexp $(mtlib)`; then strip `./filexp $(mtlib)`/mthreads ; fi
	- if test "X$(mansrc)" != "X" -a "X`pwd`" != X$(mansrc); then \
for page in $(manpages); do \
dest=$(mansrc)/`basename $$page .8`.$(manext); \
rm -f $$dest; cp $$page $$dest; chmod 444 $$dest; \
done; \
fi

clean:
	@ echo 'Use "make realclean" to remove the executables and Configure droppings.'
	@ echo 'Use "make spotless" to also remove config.sh'
	rm -f *.o

realclean: clean
	rm -f core $(addedbymake)

spotless: realclean
	rm -f config.sh

depend: config.h Makefile
	./makedepend

# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
!NO!SUBS!
$cat dependencies >>Makefile
case "$d_nntp" in
define)	sed < Makefile -e '/^#NNTP/s/^#NNTP//' > Makefile.new ;;
*)	sed < Makefile -e '/^#NNTP/d' > Makefile.new ;;
esac
mv Makefile.new Makefile
$eunicefix Makefile
