# $Id: Makefile.SH,v 4.4.3.1 1992/02/01 03:09:32 sob PATCH_3 sob $
#
# 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 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 = /usr/local/bin
rnlib = /usr/lib/news/rn
mansrc = /usr/man/LOCAL
manext = 1
CFLAGS =    -O -DGETCWD -UGETWD
LDFLAGS =  
NDIRC = 
NDIRO = 

#libs =  -lcurses   -lm
libs =  -lterm   -lm
mlibs = 
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

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

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




# 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 $(rnbin)/rn $(rnbin)/rn.old
	- if test `pwd` != $(rnbin); then cp $(public) $(rnbin); fi
	- if test `pwd` != $(rnbin); then cd $(rnbin); chmod 755 $(public); strip rn ; fi
	- ./makedir `./filexp $(rnlib)`
	- chmod 755 `./filexp $(rnlib)`
	- if test `pwd` != `./filexp $(rnlib)`; then cp INIT $(private) `./filexp $(rnlib)`; fi
	- if test ! -f `./filexp $(rnlib)/newsnews`; then cp newsnews `./filexp $(rnlib)`; fi
	cd `./filexp $(rnlib)`; chmod 755 $(private); chmod 644 INIT newsnews
	- if test `pwd` != $(mansrc); then \
for page in $(manpages); do \
cp $$page $(mansrc)/`basename $$page .1`.$(manext); \
chmod 444 $(mansrc)/`basename $$page .1`.$(manext); \
done; \
fi

clean:
	rm -f *.o

realclean:
	rm -f rn *.o core $(addedbyconf) 

# 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

# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
# If this runs make out of memory, delete /usr/include lines.
Makefile: Makefile.SH config.sh ; /bin/sh Makefile.SH
Pnews: Pnews.SH config.sh ; /bin/sh Pnews.SH
Rnmail: Rnmail.SH config.sh ; /bin/sh Rnmail.SH
config.h: config.h.SH config.sh ; /bin/sh config.h.SH
makedepend: makedepend.SH config.sh ; /bin/sh makedepend.SH
makedir: makedir.SH config.sh ; /bin/sh makedir.SH
mbox.saver: mbox.saver.SH config.sh ; /bin/sh mbox.saver.SH
ndir.h: ndir.h.SH config.sh ; /bin/sh ndir.h.SH
newsetup: newsetup.SH config.sh ; /bin/sh newsetup.SH
newsgroups: newsgroups.SH config.sh ; /bin/sh newsgroups.SH
newsnews: newsnews.SH config.sh ; /bin/sh newsnews.SH
norm.saver: norm.saver.SH config.sh ; /bin/sh norm.saver.SH
server.h: server.h.SH config.sh ; /bin/sh server.h.SH
# WARNING: Put nothing here or make depend will gobble it up!
