# $Id: Makefile.SH,v 4.4.2.1 1991/12/01 18:05:42 sob PATCH_2 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.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 = gcc
CFLAGS = -g

libs =  -ltermc -los2
mlibs = -los2
mthreading=mthreads.exe 
public = trn.exe tmpthread.exe acttimes.exe 
private = $(mthreading)

h1 = addng.h art.h artio.h artsrch.h autosub.h backpage.h bits.h cheat.h 
h2 = common.h decode.h final.h head.h hdbm.h hdbmint.h help.h init.h
h2 = intrp.h kfile.h last.h ng.h ngdata.h ngsrch.h ngstuff.h only.h rcln.h
h3 = rcstuff.h respond.h rn.h search.h sw.h term.h util.h os2patch.h

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

c1 = addng.c art.c artio.c artsrch.c autosub.c backpage.c bits.c cheat.c
c2 = decode.c final.c hdbm.c head.c help.c init.c intrp.c kfile.c last.c
c3 = $(NDIRC) ng.c ngdata.c nghash.c ngsrch.c ngstuff.c only.c rcln.c
c4 = rcstuff.c respond.c rn.c rthreads.c rt-rn.c rt-select.c search.c sw.c
c5 = term.c threads.c util.c unship.c uudecode.c os2patch.c os2trn.c

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

mtc1 = mthreads.c mt-read.c mt-process.c mt-write.c mt-misc.c threads.c 
mtc2 = os2patch.c $(NDIRC)
mtc = $(mtc1) $(mtc2)

tmc = tmpthread.c tm-read.c tm-process.c tm-write.c mt-misc.c threads.c $(mtc2)

actc = acttimes.c os2patch.c

obj1 = addng.o art.o artio.o artsrch.o autosub.o backpage.o bits.o cheat.o
obj2 = decode.o final.o head.o hdbm.o help.o init.o intrp.o kfile.o last.o
obj3 = $(NDIRO) ng.o ngdata.o nghash.o ngsrch.o ngstuff.o only.o
obj4 = rcln.o rcstuff.o respond.o rn.o rthreads.o rt-rn.o rt-select.o
obj5 = search.o sw.o term.o threads.o util.o unship.o uudecode.o os2trn.o
obj6 = os2patch.o

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

mto1 = mthreads.o mt-read.o mt-process.o mt-write.o mt-misc.o os2patch.o
mto2 = threads.o getdate.o $(NDIRO)
mtobj = $(mto1) $(mto2) $(mto3)

tmo1 = tmpthread.o tm-read.o tm-process.o tm-write.o mt-misc.o
tmo2 = threads.o getdate.o
tmobj = $(tmo1) $(tmo2) $(obj6)

acto = acttimes.o os2patch.o

add1 = Makefile.old Pnews Rnmail mt.check
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
add6 = all pyr grimble .falseactive Pnews.header s5uniq sigtest stardent

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

# grrr
SHELL = /bin/sh

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

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

trn.exe: $(obj)
	$(CC) $(LDFLAGS) $(obj) $(libs) -o trn.exe

mthreads.exe: $(mtobj)
	$(CC) $(LDFLAGS) $(mtobj) $(mlibs) -o mthreads.exe

tmpthread.exe: $(tmobj)
	$(CC) $(LDFLAGS) $(tmobj) $(mlibs) -o tmpthread.exe

acttimes.exe: $(acto)
	$(CC) $(LDFLAGS) $(acto) $(libs) -o acttimes.exe

mtgroups: mtgroups.o mt-misc.o
	$(CC) $(LDFLAGS) mtgroups.o mt-misc.o -lcurses $(libs) -o mtgroups


# 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)/trn.exe $(rnbin)/trn.exe.old
	- if test `pwd` != $(rnbin); then cp $(public) $(rnbin); fi
	- if test `pwd` != $(rnbin); then cd $(rnbin); chmod 755 $(public); strip trn.exe tmpthread ; fi
	- ./makedir `./filexp $(rnlib)`
	- cd `./filexp $(rnlib)`; mv mthreads mthreads.old
	- 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` != `./filexp $(rnlib)`; then strip `./filexp $(rnlib)`/mthreads ; fi
	- if test `pwd` != $(mansrc); then \
for page in $(manpages); do \
cp $$page $(mansrc)/`basename $$page .1`.$(manext); \
done; \
fi
	- if test `pwd` != $(mtmansrc); then \
cp mthreads.8 $(mtmansrc)/mthreads.$(mtmanext); \
fi

clean:
	rm -f *.o

realclean:
	rm -f trn.exe mthreads tmpthread *.o core $(addedbyconf) 

