CC       = gcc
RM       = rm -f
VPATH	=	../../telnet/telnet
XINCLUDES=	-I../../telnet/telnet
INCLUDES=	-I. -I.. -I../../bsd/bsd.h -I../../bsd
XDEFINES	= -DTN3270 -Dlinux -Dunix -DUSE_TERMIO -DTERMCAP -DKLUDGELINEMODE -DNO_URGENT -DDIAGNOSTICS
OPTIMIZE=	-O
CFLAGS	=	${OPTIMIZE} ${INCLUDES} ${DEFINES}
XCFLAGS=	${XINCLUDES} ${XDEFINES}
LD	=	ld
LDFLAGS	=	-r
PRINT	= print
LIBC=	/lib/libc.a
ALLH=	defines.h externs.h fdset.h general.h ring.h types.h
SRCS=	commands.c main.c network.c ring.c \
	sys_bsd.c telnet.c terminal.c \
	tn3270.c utilities.c
ALLHC=		${ALLH} ${SRCS}
ALLPRINT =	${ALLHC}
ALLSOURCE=	${ALLHC} Makefile 
OBJS=	commands.o main.o network.o ring.o sys_bsd.o \
	telnet.o terminal.o tn3270.o utilities.o

.c.o:
	${CC} -c ${CFLAGS} ${XCFLAGS} $<

telprog.o: cleantel ${OBJS} ${LIBC}
	${LD} ${LDFLAGS} -o $@ ${OBJS}

# This is because make decides he wants to use the VPATH directory to
# check if any of the *.c files have been updated against the *.o files
# also in the VPATH directory.  Unfortunately, TN3270 requires a 
# recompilation of the VPATH stuff, and if we don't do something the
# necessary files won't be recompiled for TN3270
cleantel:
	${RM} ${VPATH}/*.o

clean: 
	@echo "Cleaning tn3270/telnet..."
	@${RM} telprog.o ${OBJS} core telnet

