case $CONFIG in
    '') . ./config.sh ;;
esac
echo "Extracting Makefile (with variable substitutions)"
cat >Makefile <<!GROK!THIS!
# $Header: Makefile.SH,v 4.3.2.11 90/11/22 13:57:53 sob Exp $
#
# $Log:	Makefile.SH,v $
# Revision 4.3.2.11  90/11/22  13:57:53  sob
# Added support for additional CFLAGS and better cleanup.
# 
# Revision 4.3.2.10  90/05/04  00:44:51  sob
# Added socketlib to list of libs.
# 
# Revision 4.3.2.9  90/04/23  00:27:12  sob
# Added better support for XENIX
# 
# Revision 4.3.2.8  89/12/20  23:20:14  sob
# Added "hp-ux" to the list of files created by Configure.
# 
# Revision 4.3.2.7  89/12/09  01:49:48  sob
# make clean cleans up better.
# 
# Revision 4.3.2.6  89/12/08  22:43:45  sob
# Added suggestions by weening@gang-of-four.stanford.edu and 
# jik@pit-manager.mit.edu. rrn manual page is now created when
# doing an installation. getactive will only be made when rrn is being
# created.
# 
# Revision 4.3.2.5  89/11/08  04:47:38  sob
# Added VOIDSIG handling for SunOS 4.X
# 
# Revision 4.3.2.4  89/11/08  03:16:29  sob
# Added server.h to list of things created by Configure
# 
# Revision 4.3.2.3  89/11/08  01:05:52  sob
# Updated to work with RRN or RN
# 
# Revision 4.3.2.2  89/11/06  00:03:19  sob
# Added RRN support originally distributed with NNTP 1.5
# 
# Revision 4.3.2.1  89/11/05  23:55:09  sob
# RRN support branch
#
# Revision 4.3.1.2  85/05/13  17:21:18  lwall
# System V make needs space before line-continuing backslash.
# 
# Revision 4.3.1.1  85/05/10  11:30:15  lwall
# Branch for patches.
# 
# Revision 4.3  85/05/01  11:33:26  lwall
# Baseline for release with 4.3bsd.
# 

CC = $cc
rnbin = $rnbin
rnlib = $rnlib
mansrc = $mansrc
manext = $manext
#NNTPNNTPDIR = $NNTPSRC
#NNTPNNTPINC = $rrninclude
CFLAGS = $iandd $addcflags -O $include
LDFLAGS = $iandd
NDIRC = $ndirc
NDIRO = $ndiro

libs = $ndirlib $termlib $jobslib $socketlib
!GROK!THIS!
cat >>Makefile <<'!NO!SUBS!'
#NNTPnntp=getactive
public = rn newsetup newsgroups Pnews Rnmail
private = norm.saver mbox.saver ng.help art.help pager.help subs.help makedir filexp Pnews.header $(nntp)
manpages = rn.1 Pnews.1 Rnmail.1 newsetup.1 newsgroups.1
util = Makefile makedepend newsnews


h1 = addng.h art.h artio.h artsrch.h backpage.h bits.h cheat.h common.h
h2 = final.h head.h help.h init.h intrp.h kfile.h last.h ndir.h ng.h
h3 = ngdata.h ngsrch.h ngstuff.h only.h rcln.h rcstuff.h
h4 = respond.h rn.h search.h sw.h term.h util.h
#NNTPh5 = server.h

h = $(h1) $(h2) $(h3) $(h4) $(h5)

c1 = addng.c art.c artio.c artsrch.c backpage.c bits.c cheat.c
c2 = final.c head.c help.c init.c intrp.c kfile.c last.c $(NDIRC) ng.c
c3 = ngdata.c ngsrch.c ngstuff.c only.c rcln.c rcstuff.c
c4 = respond.c rn.c search.c sw.c term.c util.c
#NNTPc5 = $(NNTPDIR)/common/clientlib.c

c = $(c1) $(c2) $(c3) $(c4) $(c5)

obj1 = addng.o art.o artio.o artsrch.o backpage.o bits.o cheat.o
obj2 = final.o head.o help.o init.o intrp.o kfile.o last.o $(NDIRO) ng.o
obj3 = ngdata.o ngsrch.o ngstuff.o only.o rcln.o rcstuff.o
obj4 = respond.o rn.o search.o sw.o term.o util.o
#NNTPobj5 =  $(NNTPDIR)/common/clientlib.o

obj = $(obj1) $(obj2) $(obj3) $(obj4) $(obj5)

lintflags = -phbvxac

add1 = Makefile.old Pnews Rnmail art.help
add2 = bsd config.h config.sh eunice filexp
add3 = loc makedepend makedir mbox.saver newsetup
add4 = newsgroups newsnews ng.help norm.saver pager.help
add5 = pdp11 rn subs.help usg v7 ultrix sun hp-ux sgi xenix server.h
add6 = all pyr grimble .falseactive Pnews.header s5uniq

addedbyconf = $(add1) $(add2) $(add3) $(add4) $(add5) $(add6)

# grrr
SHELL = /bin/sh

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

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

rn: $(obj)
	$(CC) $(LDFLAGS) $(obj) $(libs) -o rn

#NNTPgetactive: getactive.o $(NNTPDIR)/common/clientlib.o
#NNTP	$(CC) $(LDFLAGS) getactive.o $(NNTPDIR)/common/clientlib.o -o getactive $(libs)

# Eek! This is gross.
$(NNTPDIR)/common/clientlib.o:
	$(CC) -c $(CFLAGS) $(NNTPINC) $(NNTPDIR)/common/clientlib.c
	mv clientlib.o $(NNTPDIR)/common/clientlib.o

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

install: rn
# won't work with csh
	export PATH || exit 1
	- mv $(rnbin)/rn $(rnbin)/rn.old
#NNTP	- ln -s rn $(rnbin)/rrn
	- if test `pwd` != $(rnbin); then cp $(public) $(rnbin); fi
	cd $(rnbin); chmod 755 $(public)
	chmod 755 makedir
	- ./makedir `./filexp $(rnlib)`
	- if test `pwd` != `./filexp $(rnlib)`; then cp INIT $(private) `./filexp $(rnlib)`; fi
	cd `./filexp $(rnlib)`; chmod 755 $(private)
	- if test ! -f `./filexp $(rnlib)/newsnews`; then cp newsnews `./filexp $(rnlib)`; fi
	- if test `pwd` != $(mansrc); then \
for page in $(manpages); do \
cp $$page $(mansrc)/`basename $$page .1`.$(manext); \
done; \
#NNTPecho ".so man$(manext)/rn.$(manext)" > $(mansrc)/rrn.$(manext) ; \
fi

clean:
	rm -f *.o

realclean:
	rm -f rn *.o core $(addedbyconf) 
#NNTP	rm -f $(NNTPDIR)/common/clientlib.o getactive

# The following lint has practically everything turned on.  Unfortunately,
# you have to wade through a lot of mumbo jumbo that can't be suppressed.
# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
# for that spot.

lint:
	lint $(lintflags) $(defs) $(c) > rn.fuzz

depend:
	./makedepend

# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
$(obj):
	@ echo "You haven't done a "'"make depend" yet!'; exit 1
!NO!SUBS!
case "$isrrn" in
define)  sed < Makefile -e '/^#NNTP/s/^#NNTP//' > Makefile.new ;;
*) sed < Makefile -e '/^#NNTP/d' > Makefile.new ;;
esac
mv Makefile.new Makefile
$eunicefix Makefile
