#  Makefile for seyon-kermit
#
#  Author: R. Moniot
#  Date: 10 Sept. 1995
#
#  Targets:
#	config: Makes script seyon-kermit from seyon-kermit.in and
#		protocols file from protocols.in by inserting the
#		configuration options defined below.
#
#	install: Installs seyon-kermit in BINDIR (default /usr/local/bin)
#		 and adds protocols to SEYONDIR/protocols file if it exists,
#		 otherwise makes it the new protocols file.
#
#	tar:	 Creates tar file for distribution.
#
#	clean:	 Removes ~ and .old files created during editing.


#  Configuration options: edit these to your needs or specify them
#  on the "make config" command line.

# This is the version number for naming tar file.
VERSION=1.0

# This is the directory where uploads look for the file (on local host).
ULDIR=/usr/src

# This is the directory where downloads put the file (on local host).
DLDIR=/usr/dl

# This is the directory where lockfiles are kept on your system.
LOCKDIR=/var/spool/uucp
#LOCKDIR=/etc/locks	# some systems use this

# This is the prefix of all lockfiles, e.g. lockfile=LCK..modem.
LOCKPREFIX=LCK..

# This is the suffix of the modem lockfile.
MODEM=modem
#MODEM=cua1		# a common alternative

# This is the directory where seyon-kermit will go.
BINDIR=/usr/local/bin

# This is the directory where seyon keeps your protocols file.
SEYONDIR=$$HOME/.seyon

# Shell for make to use: don't change this.
SHELL=/bin/sh

#   Default target: tell the user what to do
dummy:
	@echo 'Use "make config [options..]" to configure'
	@echo 'Use "make install" to install seyon-kermit and protocols'

#   The config target creates new seyon-kermit and protocols files
#   from the respective .in files, using the options defined above.
config configure:
	@-mv seyon-kermit seyon-kermit.old
	@make -s LOCKDIR=$(LOCKDIR) LOCKPREFIX=$(LOCKPREFIX) MODEM=$(MODEM) \
		seyon-kermit
	@-mv protocols protocols.old
	@make -s ULDIR=$(ULDIR) DLDIR=$(DLDIR) protocols

seyon-kermit:
	@sed -e 's@%LOCKDIR%@$(LOCKDIR)@g' \
	     -e 's@%LOCKPREFIX%@$(LOCKPREFIX)@g' \
	     -e 's@%MODEM%@$(MODEM)@g' \
		seyon-kermit.in >  seyon-kermit
	@chmod +x seyon-kermit
	@echo "New seyon-kermit script created"

protocols:
	@sed -e 's@%ULDIR%@$(ULDIR)@g' \
	       -e 's@%DLDIR%@$(DLDIR)@g' \
		protocols.in > protocols
	@echo "New protocols file created"

#   Install seyon-kermit and update protocols file, editing them to match
#   The configuration options defined above.  If protocols file
#   exists, kermit protocols are added at top and old file is saved as
#   protocols.old.  Otherwise create new protocols file with only the
#   kermit protocols.
install:
	@cp seyon-kermit $(BINDIR)/seyon-kermit
	chmod 555 $(BINDIR)/seyon-kermit
	@echo '$(BINDIR)/seyon-kermit installed'
	@if [ -w $(SEYONDIR)/protocols ] ; then \
	   mv $(SEYONDIR)/protocols $(SEYONDIR)/protocols.old ; \
	   cat protocols $(SEYONDIR)/protocols.old \
		> $(SEYONDIR)/protocols ; \
	   echo "$(SEYONDIR)/protocols file updated" ; \
	else \
	   cp protocols $(SEYONDIR)/protocols ; \
	   echo "$(SEYONDIR)/protocols file created" ; \
	fi

tar: clean
	tar -czf ../seyon-kermit-$(VERSION).tgz -C .. seyon-kermit-$(VERSION)


clean:
	-rm *~ *.old
