# Hey! Emacs, this file is in -*- text -*- mode!
# $Id: Makefile,v 3.3 1991/09/01 14:01:58 piggy Rel $
#
# Makefile for "The Uucp Analyzer"
# piggy@idea.sublink.org
#
# make                  to compile and build TUA
# make shar             to create the shar files from the sources
# make clean            clean up the directory
# make veryclean        remove also those sources not checked out with -l
# make checkin			** USE THIS ** to do all checkins. 
#

CURRENT_RELEASE_SYMB = release3-3
LAST_RELEASED_VERSION = release3-3
VERSION = 3.3
PLEVEL = 1
SHELL =	/bin/sh

#
# Write here the libs you need to link in the directory package
# DIREC_LIB = -lx

#
# Uncomment the right place where I can find alloca()
# Do not define anything if you are using gcc
# If you do not have alloca, you can find it in the GNU Emacs distribution, 
# and in some other GNU's package.
# alloca() is used *only* in the GNU getopt package.
# ALLOCA_LIB = -lPW		# On SYSV & Xenix
# ALLOCA_LIB = -lalloca
# ALLOCA_LIB = -lGNU

# OS TYPE:
# Comment out the next definition if your system is not Sys5-like
# Actually, it just switches between <string.h> and <strings.h> and
# between bstr* <-> str* families of string functions
OS_TYPE = -DUSG

# HOST NAME:
# Uncomment the next definition if your system is a System V that
# accesses the system's name via uname instead of gethostname.
GETHOSTNAME = gethostn.o     # On System V

LIBS = $(DIREC_LIB) $(ALLOCA_LIB)
CFLAGS = $(OS_TYPE) -O
LDFLAGS = -f -s
COFLAGS = -r$(CURRENT_RELEASE_SYMB)

OBJS =	tua.o commtree.o procdaily.o prochist.o procuucico.o procuucp.o \
	procuuxqt.o procuux.o procxfer.o reports.o systree.o usertree.o \
	xferentry.o tmparse.o mem.o getopt.o getopt1.o porttree.o phonesw.o \
        $(GETHOSTNAME)

SOURCES = COPYING ChangeLog README PROJECTS Makefile commtree.c hdbstat.h \
        mem.c mem.h MANIFEST \
	procdaily.c prochist.c procuucico.c procuucp.c config.h \
	procuux.c procuuxqt.c procxfer.c reports.c systree.c tua.c \
	usertree.c xferentry.c tmparse.c getopt.c getopt1.c getopt.h \
        patchlevel.h tua.man porttree.c phonesw.c gethostn.c

SHARF = $(SOURCES) tua.1l

tua:	$(OBJS) 
	$(CC) $(LDFLAGS) -o tua $(OBJS) $(LIBS)

$(OBJS):	hdbstat.h config.h
commtree.o systree.o mem.o usertree.o:	mem.h
tua.o:	patchlevel.h getopt.h

shar:	$(SHARF)
	rm -f tua.shar.*
	shar -c -o tua.shar -l50 $(SHARF)

tua.1l: tua.man
	nroff -man tua.man > tua.1l

.PHONY:	clean
clean:
	rm -f *.o core tua.1l tua.shar.* tua *CKP *BAK *~ #*#

#
# Use this target ONLY if you have RCS'd all the sources!
# This target remove anything that can be rebuild from RCS
veryclean:	clean
	-rcsclean $(SOURCES)

checkin:	veryclean
	-(for i in $(SOURCES) ; \
		do \
			if [ -w $$i ] ;\
				then ci -N$(CURRENT_RELEASE_SYMB) -r$(VERSION).$(PLEVEL) $$i ;\
			fi ;\
		done;\
	)

checkoutall:
	-(for i in $(SOURCES) ; \
		do \
			if [ ! -w $$i ] ;\
				then co $(COFLAGS) -l $$i ;\
			fi ;\
		done;\
	)

release:        checkoutall
	-(for i in $(SOURCES) ; \
		do \
			if [ -w $$i ] ;\
				then ci -N$(LAST_RELEASED_VERSION) -r$(VERSION) $$i ;\
			fi ;\
		done;\
	)

diffs:	$(SOURCES)
	rm -f diffs
	for i in $(SOURCES); \
	do rcsdiff -r$(LAST_RELEASED_VERSION) -r$(CURRENT_RELEASE_SYMB) -c $$i > tmp_diffs; \
		if [ $$? = 1 ] ; then \
			echo "Index: $$i" >> diffs; \
			cat tmp_diffs >> diffs; \
		fi; \
	done
