# Makefile for Taylor UUCP

# Prefix directory for installation directories.
prefix = /usr/local

# Where to install uucico and uuxqt, and where to read configuration files
# from by default.  If you use this definition, $(prefix)/lib must exist.
libdir = $(prefix)/lib/uucp

# Where to install uucp, uux and uuchk.
bindir = $(prefix)/bin

# Where to install man pages.  Section 1 for user programs, 8 for daemons.
man1dir = $(prefix)/man/man1
man1ext = .1
man8dir = $(prefix)/man/man8
man8ext = .8

# The directory to look in for new style configuration files (when
# using HAVE_TAYLOR_CONFIG).
newconfigdir = $(libdir)

# The directory to look in for BNU (when using HAVE_BNU_CONFIG) or
# V2 (when using HAVE_V2_CONFIG) style configuration files.
oldconfigdir = /usr/lib/uucp

# Define programs and flags
CC = gcc
CFLAGS = -Wall -Wshadow -Wwrite-strings -g
LIBS =

INSTALL = cp
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL)

# If you don't want to compile tstuu, which requires BSD style ptys
# and the Taylor configuration files, comment out the following line.
# The tstuu program is only used to test the package; it is described
# further in INSTALL.
TSTUU = tstuu

#
# Nothing else to configure
#

SHELL = /bin/sh

VERSION = 1.02

CONFIG = -DLIBDIR=\"$(libdir)\" -DNEWCONFIGLIB=\"$(newconfigdir)\" -DOLDCONFIGLIB=\"$(oldconfigdir)\"

UUOBJS = uucico.o prot.o protg.o protf.o prott.o prote.o config.o v2.o bnu.o \
	file.o util.o sysinf.o prtinf.o time.o log.o chat.o port.o tcp.o \
	parse.o copy.o sys1.o sys2.o sys3.o sys4.o version.o getopt.o
XQTOBJS = uuxqt.o config.o v2.o bnu.o util.o sysinf.o prtinf.o time.o log.o \
	copy.o sys1.o sys3.o sys5.o version.o getopt.o
UUXOBJS = uux.o config.o v2.o bnu.o util.o sysinf.o prtinf.o time.o log.o \
	copy.o sys1.o sys3.o sys6.o version.o getopt.o
UUCPOBJS = uucp.o config.o v2.o bnu.o util.o sysinf.o prtinf.o time.o log.o \
	copy.o sys1.o sys3.o sys6.o version.o getopt.o
UUCHKOBJS = uuchk.o config.o v2.o bnu.o util.o sysinf.o prtinf.o time.o \
	log.o sys1.o version.o getopt.o
TSTOBJS = tstuu.o version.o getopt.o

ALLOBJS = uucico.o uuxqt.o uux.o uucp.o uuchk.o tstuu.o prot.o protg.o \
	protf.o prott.o prote.o config.o v2.o bnu.o file.o util.o sysinf.o \
	prtinf.o time.o log.o chat.o port.o tcp.o parse.o copy.o sys1.o \
	sys2.o sys3.o sys4.o sys5.o sys6.o version.o getopt.o

all: uucico uuxqt uux uucp uuchk $(TSTUU)

install: uucico uuxqt uux uucp uuchk
	-mkdir $(libdir) $(bindir)
	-ln $(libdir)/uucico $(libdir)/uucico.old
	-ln $(libdir)/uuxqt $(libdir)/uuxqt.old
	rm -f $(libdir)/uucico $(libdir)/uuxqt
	$(INSTALL_PROGRAM) uucico $(libdir)/uucico
	$(INSTALL_PROGRAM) uuxqt $(libdir)/uuxqt
	$(INSTALL_PROGRAM) uuchk $(libdir)/uuchk
	chown uucp $(libdir)/uucico $(libdir)/uuxqt $(libdir)/uuchk
	chmod 4555 $(libdir)/uucico $(libdir)/uuxqt
	-ln $(bindir)/uux $(bindir)/uux.old
	-ln $(bindir)/uucp $(bindir)/uucp.old
	rm -f $(bindir)/uux $(bindir)/uucp
	$(INSTALL_PROGRAM) uux $(bindir)/uux
	$(INSTALL_PROGRAM) uucp $(bindir)/uucp
	chown uucp $(bindir)/uux $(bindir)/uucp
	chmod 4555 $(bindir)/uux $(bindir)/uucp
	$(INSTALL_DATA) uucico.8 $(man8dir)/uucico$(man8ext)
	$(INSTALL_DATA) uuxqt.8 $(man8dir)/uuxqt$(man8ext)
	$(INSTALL_DATA) uux.1 $(man1dir)/uux$(man1ext)
	$(INSTALL_DATA) uucp.1 $(man1dir)/uucp$(man1ext)

uninstall:
	cp $(libdir)/uucico.old $(libdir)/uucico
	cp $(libdir)/uuxqt.old $(libdir)/uuxqt
	cp $(bindir)/uux.old $(bindir)/uux
	cp $(bindir)/uucp.old $(bindir)/uucp

uucico: $(UUOBJS)
	$(CC) $(CFLAGS) -o uucico $(UUOBJS) $(LIBS)

uuxqt: $(XQTOBJS)
	$(CC) $(CFLAGS) -o uuxqt $(XQTOBJS) $(LIBS)

uux: $(UUXOBJS)
	$(CC) $(CFLAGS) -o uux $(UUXOBJS) $(LIBS)

uucp: $(UUCPOBJS)
	$(CC) $(CFLAGS) -o uucp $(UUCPOBJS) $(LIBS)

uuchk: $(UUCHKOBJS)
	$(CC) $(CFLAGS) -o uuchk $(UUCHKOBJS) $(LIBS)

tstuu: $(TSTOBJS)
	$(CC) $(CFLAGS) -o tstuu $(TSTOBJS) $(LIBS)

uucico.o: uucico.c
	$(CC) -c $(CFLAGS) $(CONFIG) uucico.c
uuxqt.o: uuxqt.c
	$(CC) -c $(CFLAGS) $(CONFIG) uuxqt.c
uux.o: uux.c
	$(CC) -c $(CFLAGS) $(CONFIG) uux.c
uucp.o: uucp.c
	$(CC) -c $(CFLAGS) $(CONFIG) uucp.c
uuchk.o: uuchk.c
	$(CC) -c $(CFLAGS) $(CONFIG) uuchk.c
config.o: config.c
	$(CC) -c $(CFLAGS) $(CONFIG) config.c
v2.o: v2.c
	$(CC) -c $(CFLAGS) $(CONFIG) v2.c
bnu.o: bnu.c
	$(CC) -c $(CFLAGS) $(CONFIG) bnu.c
sys1.o: sys1.c
	$(CC) -c $(CFLAGS) $(CONFIG) sys1.c

configure-unix:
	ln sysh.unx sysdep.h
	ln sys1.unx sys1.c
	ln sys2.unx sys2.c
	ln sys3.unx sys3.c
	ln sys4.unx sys4.c
	ln sys5.unx sys5.c
	ln sys6.unx sys6.c

clean:
	rm -f $(ALLOBJS) uucico uuxqt uux uucp uuchk tstuu
	rm -f uucp-$(VERSION).tar.Z
	rm -rf uucp-$(VERSION)

dist: uucp.info
	-rm -rf uucp-$(VERSION)
	-rm -f taylor-uucp-$(VERSION).tar taylor-uucp-$(VERSION).tar.Z
	mkdir uucp-$(VERSION)
	ln `cat MANIFEST` uucp-$(VERSION)
	rm -f uucp-$(VERSION)/conf.h uucp-$(VERSION)/sysh.unx
	rm -f uucp-$(VERSION)/Makefile
	cp conf.h sysh.unx Makefile uucp-$(VERSION)
	chmod 0644 uucp-$(VERSION)/conf.h uucp-$(VERSION)/sysh.unx
	chmod 0644 uucp-$(VERSION)/Makefile
	tar -cvf taylor-uucp-$(VERSION).tar uucp-$(VERSION)
	compress taylor-uucp-$(VERSION).tar

uucp.info: uucp.texi
	makeinfo uucp.texi

# GNU standards want these targets

distclean: clean
realclean: clean

TAGS:
	etags *.h *.c

# Header file depedencies.  These are maintained by hand.

uucico.o: uucp.h conf.h system.h prot.h port.h sysdep.h getopt.h
uuxqt.o: uucp.h conf.h system.h getopt.h sysdep.h
uux.o: uucp.h conf.h system.h getopt.h sysdep.h
uucp.o: uucp.h conf.h system.h getopt.h sysdep.h
uuchk.o: uucp.h conf.h port.h sysdep.h system.h getopt.h
tstuu.o: uucp.h conf.h sysdep.h getopt.h
prot.o: uucp.h conf.h system.h prot.h port.h sysdep.h
protg.o: uucp.h conf.h system.h prot.h port.h sysdep.h
protf.o: uucp.h conf.h prot.h port.h sysdep.h system.h
prott.o: uucp.h conf.h prot.h port.h sysdep.h system.h
prote.o: uucp.h conf.h prot.h port.h sysdep.h system.h
config.o: uucp.h conf.h system.h sysdep.h
v2.o: uucp.h conf.h port.h sysdep.h
bnu.o: uucp.h conf.h port.h sysdep.h
file.o: uucp.h conf.h system.h
util.o: uucp.h conf.h
sysinf.o: uucp.h conf.h system.h port.h sysdep.h
time.o: uucp.h conf.h
log.o: uucp.h conf.h system.h
chat.o: uucp.h conf.h system.h port.h sysdep.h
port.o: uucp.h conf.h port.h sysdep.h
tcp.o: uucp.h conf.h port.h sysdep.h system.h
prtinf.o: uucp.h conf.h port.h sysdep.h
parse.o: uucp.h conf.h
copy.o: uucp.h conf.h system.h sysdep.h
sys1.o: uucp.h conf.h system.h sysdep.h
sys2.o: uucp.h conf.h system.h port.h sysdep.h
sys3.o: uucp.h conf.h system.h sysdep.h
sys4.o: uucp.h conf.h system.h sysdep.h
sys5.o: uucp.h conf.h system.h sysdep.h
sys6.o: uucp.h conf.h system.h sysdep.h
version.o: uucp.h conf.h
getopt.o: uucp.h conf.h getopt.h
