# Makefile for XC
# For XC, the following compiler switches are significant:
# 
#	-DDIDO=2
#	-DDIDO=3
#	-DDIDO=4
#		For a Dial-In/Dial-Out port. Just saying -DDIDO is a no-op, and is
#		equivalent to no definition at all of DIDO, and will not include any of
#		the LCK..file code respected by cu/uucp.
#
#		2 is for SCO Xenix 2.2 which uses ungetty.
#		3 is for SCO Xenix 2.3 whose getty is effectively a uugetty,
#		  for SCO Unix, or for other sites using uugetty.
#		4 is for Unix Sys V Release 4
#
#	-DT6000
#		Causes the Tandy-6000 specific code modifications to be compiled.
#
#	-DDEBUG
#		If this compiler switch is set, then whenever XC is run within a
#		directory that contains a file called "debug.log", XC will append to
#		that file a copy of all XC output, whether to the terminal "file" or
#		to standard error. This can be useful for debugging scripts, coupled
#		with the "debug" script command, which causes the lines of a script
#		to be echoed to the terminal as they get executed. Since often such
#		output passes up the terminal screen too quickly to read, the
#		"debug.log" file provides a hard-copy of the XC session.
#		No echoing to a "debug.log" file is done if XC is also capturing
#		incoming text to a capture file. If no "debug.log" file exists in the
#		current directory, then no such echoing is done regardless of whether
#		the -DDEBUG switch was set at compile time.
#
#	-DNOSHELL
#		This will disallow shell escapes. Both the "!" and "$" mechanisms from
#		the XC prompt, and the analogous SHELL and PIPE keywords in scripts,
#		silently do nothing. However the standard output of backquoted shell
#		commands can still be assigned to a script variable.
#

SHELL = /bin/sh

# uncomment to enable debugging output
# DEBUG = -DDEBUG

# uncomment to disallow shell escapes
# NOSHELL = -DNOSHELL

# choose your poison:
#  for SCO Xenix 2.2
# CFLAGS	= -O -DDIDO=2 $(DEBUG) $(NOSHELL)
#  for SCO Xenix 2.3
#  CFLAGS	= -O -DDIDO=3 $(DEBUG) $(NOSHELL)
#  for SCO Unix, to make version compatible for Unix or Xenix
# CFLAGS	= -O -DDIDO=3 $(DEBUG) $(NOSHELL) -D_NO_PROTOTYPE -xenix
#  for SYSVR4
# CFLAGS	= -O -DDIDO=4 $(DEBUG) $(NOSHELL)
#  for Tandy Xenix 3.2
# CFLAGS	= -O -n -DT6000 $(DEBUG) $(NOSHELL)
#  for SCO Xenix on an IBM PC/AT (80286)
# CFLAGS	= -O -i $(DEBUG) $(NOSHELL)
#  for "any" Unix or Xenix
CFLAGS	= $(DEBUG) $(NOSHELL)

# At least the termcap library; maybe you need the curses library
LDFLAGS = -lterm
# to use the shared library, if available
# LDFLAGS = -ltermcap -lc_s

# choose a nice home for XC
# INSDIR		=/usr/bin
# author's preference
INSDIR		=/usr/local/bin

OWNER		=uucp
GROUP		=uucp
BINMODE		=4755
MANDIR		=/usr/man/man
CATMANDIR	=/usr/man/cat
MANEXT		=.L
MANOWN		=bin
MANGRP		=bin
MANMODE		=0444
SHRINK		=compress

# you should have all of these files:
MANIFEST= .autocis .uni .callhq .cisdial .exrc .phonelist .xc .temp_opt .rz \
			.sz call cisdownload Makefile README myman xcb+.c xcdbglog.c \
			xcdial.c xc.h xc.nro xcmain.c xcport.c xcscrpt.c xcsubs.c \
			xcterm.c xcxmdm.c

OBJS	= xcmain.o xcb+.o xcdbglog.o xcdial.o xcport.o xcscrpt.o\
			xcsubs.o xcterm.o xcxmdm.o

xc:	 $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) -o xc $(LDFLAGS) 

install: xc
	-mkdir $(INSDIR)
	-mv $(INSDIR)/xc $(INSDIR)/xc-
	cp xc $(INSDIR)/xc
	strip $(INSDIR)/xc
	-mcs -d $(INSDIR)/xc
	chown $(OWNER) $(INSDIR)/xc
	chgrp $(GROUP) $(INSDIR)/xc
	chmod $(BINMODE) $(INSDIR)/xc
	-@ls -l xc $(INSDIR)/xc $(INSDIR)/xc-

man: xc.nro
	cp xc.nro $(MANDIR)$(MANEXT)/xc$(MANEXT)
	chown $(MANOWN) $(MANDIR)$(MANEXT)/xc$(MANEXT)
	chgrp $(MANGRP) $(MANDIR)$(MANEXT)/xc$(MANEXT)
	chmod $(MANMODE) $(MANDIR)$(MANEXT)/xc$(MANEXT)
	-$(SHRINK) $(MANDIR)$(MANEXT)/xc$(MANEXT)
	touch man

catman: xc.nro
	tbl xc.nro| nroff myman - | col > $(CATMANDIR)$(MANEXT)/xc$(MANEXT)
	chown $(MANOWN) $(CATMANDIR)$(MANEXT)/xc$(MANEXT)
	chgrp $(MANGRP) $(CATMANDIR)$(MANEXT)/xc$(MANEXT)
	chmod $(MANMODE) $(CATMANDIR)$(MANEXT)/xc$(MANEXT)
	-$(SHRINK) $(CATMANDIR)$(MANEXT)/xc$(MANEXT)
	touch catman

clean:
	rm -f $(OBJS) xc core catman

$(OBJS): xc.h

shar:
	shar  -awF -L47 -nXC -oXC -s jpr@jpr.com $(MANIFEST)
	l XC.??

taz:
	tar cf - $(MANIFEST) | compress > XC.TAR.Z
	@ls -l *Z

lzh:
	lha c XC.lzh $(MANIFEST)

shark:
	shark $(MANIFEST) > XC.SHK
	@ls -l *SHK
