# (c) Copyright 1988 Jim Frost.  All Rights Reserved.  Please see
# the accompanying file "Copyright" for more information.
#
# Be sure to read "Configuration" and make necessary changes to "config.h"
# before compiling.

# Send bugs, fixes, and ports to 'msend-bugs@world.std.com'.

# DESTDIR is the directory to install msend in.
DESTDIR = /usr/local/bin

# DAEMONDIR is the directory to install the msend daemon in.
DAEMONDIR = /usr/local/etc

# DAEMONNAME is what to call the daemon.  Sun likes "in.msendd", others may
# prefer "msendd".
DAEMONNAME = msendd

# MANDIR is the directory to install the man page in
MANDIR = /usr/local/man/man1
# MANSEC is the section the man page is to be installed it.
MANSEC = 1

# SPOOLDIR should be the same as the #define in config.h
SPOOLDIR = /usr/spool/msend

CFLAGS = -O

# Under SUNOS you may need "-lresolv" see Configuration
# Under IRIX  you may need "-lsun -lbsd" see Configuration
#LIBS = -lresolv
#LIBS = -lsun -lbsd

READLINELIBS = -lreadline -ltermcap

# It is unlikely you will need to change anything bellow.

# grrr
SHELL = /bin/sh

MISC = Configuration Copyright History Makefile patchlevel Protocol README \
       msend.man msend.h network.h config.h
SRCS = buildshar.c domessage.c establish.c fwdloop.c gnugets.c misc.c msend.c \
       msendd.c network.c sendrecv.c utmp.c whoami.c write.c
ALL = $(MISC) $(SRCS)

DSRCS = domessage.c establish.c fwdloop.c misc.c network.c msendd.c \
        sendrecv.c utmp.c write.c 
CSRCS = gnugets.c misc.c msend.c network.c sendrecv.c whoami.c
DOBJS = domessage.o establish.o fwdloop.o misc.o network.o msendd.o \
        sendrecv.o utmp.o write.o 
COBJS = gnugets.o misc.o msend.o network.o sendrecv.o whoami.o

all: msend msendd


msend: $(COBJS)
	$(CC) $(CFLAGS) $(COBJS) -object -s -o msend $(LIBS) $(READLINELIBS)

msendd:  $(DOBJS)
	$(CC) $(CFLAGS) $(DOBJS) -object -s -o msendd $(LIBS)

install: msend msendd
	install -c -s -m 6555 -g tty msend $(DESTDIR)
	install -c -s -m 2555 -g tty msendd $(DAEMONDIR)/$(DAEMONNAME)
	install -c -m 444 msend.man $(MANDIR)/msend.$(MANSEC)
	if [ ! -d $(SPOOLDIR) ]; then \
	 mkdir $(SPOOLDIR); \
	 chmod 2771 $(SPOOLDIR); \
	 chgrp tty $(SPOOLDIR); \
	fi

install-sysv: msend msendd
	strip msend msendd
	cp msend $(DESTDIR)
	cp msendd $(DAEMONDIR)/$(DAEMONNAME)
	chgrp tty $(DESTDIR)/msend $(DAEMONDIR)/$(DAEMONNAME)
	chmod 6555 $(DESTDIR)/msend
	chmod 2555 $(DAEMONDIR)/$(DAEMONNAME)
	cp msend.man $(MANDIR)/msend.$(MANSEC)
	chmod 444 $(MANDIR)/msend.$(MANSEC)
	if [ ! -d $(SPOOLDIR) ]; then \
	 mkdir $(SPOOLDIR); \
	 chmod 2771 $(SPOOLDIR); \
	 chgrp tty $(SPOOLDIR); \
	fi

buildshar: buildshar.o
	$(CC) -o buildshar buildshar.o

shar: buildshar
	rm -f doshar shar.*
	./buildshar $(ALL) > doshar
	sh ./doshar
	rm doshar

msend.tar:
	tar cf msend.tar $(ALL)

tar: msend.tar

tar.Z: msend.tar
	compress msend.tar

srcinsaber:: $(DSRCS)
	#load $(DSRCS)

srcinsaber:: $(CSRCS)
	#load $(CSRCS)

clean:
	rm -f *.o *~ shar.* doshar msend msendd buildshar msend.tar msend.tar.Z

domessage.o:  msend.h network.h config.h
establish.o: msend.h network.h
fwdloop.o: msend.h network.h
gnugets.o: config.h
misc.o: msend.h network.h config.h
msend.o: msend.h network.h config.h Copyright patchlevel
msendd.o: msend.h network.h config.h
network.o: msend.h network.h config.h
sendrecv.o: msend.h network.h config.h
utmp.o: msend.h network.h
whoami.o: msend.h network.h
write.o: msend.h network.h config.h
