case $CONFIG in
    '') . ./config.sh ;;
esac
echo "Extracting Makefile (with variable substitutions)"
$cat >Makefile <<!GROK!THIS!
# $Id: Makefile.SH,v 1.3 1992/08/09 16:52:27 jik Exp $
#
# This software is Copyright 1991 by Stan Barber. 
#
# Permission is hereby granted to copy, reproduce, redistribute or otherwise
# use this software as long as: there is no monetary profit gained
# specifically from the use or reproduction of this software, it is not
# sold, rented, traded or otherwise marketed, and this copyright notice is
# included prominently in any copy made. 
#
# The author make no claims as to the fitness or correctness of this software
# for any use whatsoever, and it is provided as is. Any use of this software
# is at the user's own risk. 
#
# $Log: Makefile.SH,v $
# Revision 1.3  1992/08/09  16:52:27  jik
# Add cross_device_op.c/o.
#
# Revision 1.2  1992/03/11  00:22:48  jik
# 1) Use Athena makedepend.
# 2) DESTDIR support.
#
# Revision 1.1  1992/03/11  00:21:50  jik
# Initial revision
#
# Revision 4.4.3.1  1992/02/01  03:09:32  sob
# Release 4.4 Patchlevel 3
#
# Revision 4.4.2.1  1991/12/01  18:05:42  sob
# Changed clientlib to be built in the rn tree instead of the nntp tree.
#
# Revision 4.4.1.1  1991/09/25  19:38:08  sob
# Changed some install directives
#
# Revision 4.4  1991/09/09  20:18:23  sob
# release 4.4
#
#
# 

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

libs = $ndirlib $termlib $jobslib $socketlib -lm
mlibs = $jobslib
!GROK!THIS!
$cat >>Makefile <<'!NO!SUBS!'
#NNTPnntp=getactive
public = rn newsetup newsgroups Pnews Rnmail
private = norm.saver mbox.saver 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 autosub.h backpage.h bits.h cheat.h 
h2 = common.h final.h head.h help.h init.h intrp.h kfile.h last.h 
h3 = ng.h 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 uudecode.h

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

c1 = addng.c art.c artio.c artsrch.c autosub.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 respond.c rn.c
c4 = search.c sw.c term.c util.c uudecode.c cross_device_op.c
#NNTPc5 = $(NNTPDIR)/common/clientlib.c

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

obj1 = addng.o art.o artio.o artsrch.o autosub.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 respond.o rn.o
obj4 = search.o sw.o term.o util.o uudecode.o cross_device_op.o
#NNTPobj5 =  clientlib.o

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

lintflags = -phbvxac

add1 = Makefile.old Pnews Rnmail
add2 = bsd config.h config.sh eunice filexp 
add3 = loc makedepend makedir mbox.saver ndir.h newsetup
add4 = newsgroups newsnews norm.saver
add5 = pdp11 usg v7 ultrix sun hp-ux sgi xenix next server.h mips uts DGUX
add6 = all pyr grimble .falseactive Pnews.header s5uniq sigtest stardent

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 clientlib.o
#NNTP	$(CC) $(LDFLAGS) getactive.o clientlib.o -o getactive $(libs)

#NNTPclientlib.o:
#NNTP	$(CC) -c $(CFLAGS) $(NNTPINC) $(NNTPDIR)/common/clientlib.c

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

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

clean:
	rm -f *.o

realclean:
	rm -f rn *.o core $(addedbyconf) 
#NNTP	rm -f 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_rn

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

depend: config.h Makefile
	makedepend -s '# AUTOMATICALLY ' -- *.c

# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
config.h: config.h.SH config.sh ; sh config.h.SH
Makefile: Makefile.SH config.sh ; sh Makefile.SH
$(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
