#
# 5799-WZQ (C) COPYRIGHT = NONE
# LICENSED MATERIALS - PROPERTY OF IBM
#
# $Header:Makefile 12.0$ 
# $ACIS:Makefile 12.0$ 
# $Source: /ibm/acis/usr/src/ucb/tn3270/RCS/Makefile,v $ 

# Makefile for tn3270 and friends...
# @(#)makefile	3.1  10/29/86
#
#	This is the makefile for tn3270.  Note that we use ./tn3270.c
# (compiled with special options; see below) to provide the telnet
# support we need.
#
#	The following are the defines that may be passed (via the cc
# -D option) to the compiler.
#
#	The first group relate only to ./tn3270.c:
#
#	TN3270		- 	This is to be linked with tn3270.  Necessary
#				for creating tn3270.
#
#	DEBUG		-	Allow for some extra debugging operations.
#
#	NOT43		-	Allows the program to compile and run on
#				a 4.2BSD system.
#
#	PUTCHAR		-	Within tn3270, on a NOT43 system,
#				allows the use of the 4.3 curses
#				(greater speed updating the screen).
#				You need the 4.3 curses for this to work.
#
#	FD_SETSIZE	-	On whichever system, if this isn't defined,
#				we patch over the FD_SET, etc., macros with
#				some homebrewed ones.
#
#	SO_OOBINLINE	-	This is a socket option which we would like
#				to set to allow TCP urgent data to come
#				to us "inline".  This is NECESSARY for
#				CORRECT operation, and desireable for
#				simpler operation.
#
#	LNOFLSH		-	Detects the presence of the LNOFLSH bit
#				in the tty structure.
#
#
#	Here are some which are used throughout the system:
#
#	SLOWSCREEN	-	If SLOWSCREEN is defined, we generate code
#				that attempts to optimize the line between
#				the computer (on which tn3270 runs) and the
#				user's terminal (which line may be 1200 baud,
#				or some such) at the cost of CPU time on
#				the above referenced computer.
#
#	unix		-	Compiles in unix specific stuff.
#
#	msdos		-	Compiles in msdos specific stuff.
#

PRINT	= print

DEFINES = -DSLOWSCREEN -DDEBUG
DEFINES = -DSLOWSCREEN

INCLUDES = -I.

OPTIMIZE = -O

CFLAGS	= $(OPTIMIZE) $(INCLUDES) $(DEFINES)

# Lint flags
LINTFLAGS	= -hbxaz
# How to install the bloody thing...

DESTDIR=

BINDIR		= $(DESTDIR)/usr/ucb
ETCDIR		= $(DESTDIR)/etc
MANDIR		= $(DESTDIR)/usr/man/man

IFLAGS	= -c -s

# Names for the terminal libraries...
LIBCURSES	= -lcurses
LIBTERM		= -ltermlib

# The source files...
ALLH =	3270.h ascebc.h DEFS.h ectype.h globals.h options.h screen.h state.h
M4FILE = termcodes.m4

MOSTC = asctab.c ebctab.c ectype.c globals.c inbound.c map3270.c options.c \
	outbound.c screen.c termin.c 

# TNMAIN was defined to ../telnet.c in the new and improved 4.3 version from UCB
# ../telnet.c is not the same as /usr/src/ucb/telnet.c; ../telnet.c renamed to
# ./tn3270.c
TNMAIN = ./tn3270.c
MSMAIN = mset.c
PRT3270MAIN = prt3270.c

#
#	In a vax environment, we use vaxbsubs.s, which gives us a fair amount
#	of increased performance.  We have provided genbsubs.c, which perform
#	(more or less) the same function.
SUBS = vaxbsubs.s
SUBS = genbsubs.c

SUBSO = vaxbsubs.o
SUBSO = genbsubs.o

ALLS = vaxbsubs.s
ALLS =

ALLC = ${MOSTC} ${TNMAIN} ${MSMAIN} ${SUBS}
ALLC = ${MOSTC} ${TNMAIN} ${MSMAIN}

MOSTO	= tn3270.o ebctab.o asctab.o termin.o inbound.o \
		outbound.o screen.o map3270.o options.o \
		ectype.o globals.o $(SUBSO)

ALLO	= $(MOSTO) mset.o prt3270.o

.s.o:
	/lib/cpp -E $< | as -o $@

all:	${ALLH} ${ALLC} ${ALLS} tn3270 mset

tn3270:	$(MOSTO)
	${CC} ${CFLAGS} -o tn3270 $(MOSTO) $(LIBCURSES) $(LIBTERM)

mset:	mset.o map3270.o
	${CC} ${CFLAGS} -o mset mset.o map3270.o $(LIBCURSES)

prt3270:	prt3270.o globals.o ebctab.o
	${CC} ${CFLAGS} -o prt3270 prt3270.o globals.o ebctab.o

tn3270.o:	$(TNMAIN)
	$(CC) $(CFLAGS) -DTN3270 -c $(TNMAIN)

install: all
	install $(IFLAGS) tn3270 $(BINDIR)/tn3270
	install $(IFLAGS) mset $(BINDIR)/mset
	install -c -m 444 map3270 ${ETCDIR}/map3270 

clean:
	rm -f $(ALLO) mset tn3270 prt3270 m4.out errs Makefile.bak

print:
	${PRINT} ${ALLH} ${M4FILE} default.map
	${PRINT} ${MOSTC}
	${PRINT} ${SUBS} ${MSMAIN} ${TNMAIN} ${PRT3270MAIN}

tags:	${ALLC} ${ALLH}
	ctags -t ${ALLC} ${ALLH}

lint:
	lint ${LINTFLAGS} ${INCLUDES} ${DEFINES} -DTN3270 \
				${TNMAIN} ${MOSTC} -lcurses
	lint ${LINTFLAGS} ${INCLUDES} ${DEFINES} ${MSMAIN} map3270.c -lcurses

.DEFAULT:
	sccs get $<

m4.out:		termcodes.m4
	/bin/rm -f m4.out
	m4 termcodes.m4 > m4.out
	/bin/chmod 444 m4.out

depend:
	grep '^#include' ${ALLC} | grep -v '<' | \
	sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' \
	    -e 's/\.c/.o/' \
	    -e 's,../[a-zA-Z]*/,,' | \
	awk ' { if ($$1 != prev) { print rec; rec = $$0; prev = $$1; } \
		else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
		       else rec = rec " " $$2 } } \
	      END { print rec } ' > makedep
	echo '$$r makedep' >>eddep
	echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	cp Makefile Makefile.bak
	ed - Makefile < eddep
	rm eddep makedep

# DO NOT DELETE THIS LINE

asctab.o: ascebc.h
ebctab.o: ascebc.h
ectype.o: ectype.h
globals.o: 3270.h ascebc.h ectype.h options.h screen.h state.h globals.h
inbound.o: m4.out ascebc.h 3270.h screen.h options.h ectype.h globals.h
inbound.o: inbound.ext screen.ext outbound.ext telnet.ext
map3270.o: m4.out state.h globals.h map3270.ext default.map
options.o: options.h globals.h options.ext
outbound.o: ascebc.h 3270.h screen.h globals.h map3270.ext options.ext
outbound.o: screen.ext telnet.ext termin.ext inbound.ext outbound.ext
screen.o: screen.h 3270.h globals.h bsubs.ext screen.ext
termin.o: m4.out state.h globals.h inbound.ext outbound.ext telnet.ext
termin.o: termin.ext
./tn3270.o: screen.h globals.h telnet.ext options.ext outbound.ext termin.ext
mset.o: state.h m4.out globals.h map3270.ext
