# This file was created from Makefile.in by ./configure.  You are 
# advised not to edit this file, but instead edit Makefile.in.

# Term program makefile for linux
# valid targets are:
#	all linecheck termtest clean binclean realclean ...
#	bin install.bin install.share install.net
#	lib install.lib

SRCDIR=.
VPATH=.
PWD=.
SHELL=/bin/sh

# Note: If you change the version #, you must "make realclean"
VERSION_MAJOR = 2
VERSION_MINOR = 3
PATCH_LEVEL   = 5
PATCH_NAME    = .5
VERSION_NUM   = 20305

CC=gcc -Wall
CPP=$(CC) -E

# ADDFLAGS=-DNO_LOOPBACK keep "termnet" from connecting to localhost.
# ADDFLAGS=-DUSE_IDENT allows term to use identd to find out who is connecting.
ADDFLAGS =

CFLAGS = -O  -DBUILD_LIBTERMNET $(ADDFLAGS) \
	-DSHAREDIR='"$(SHAREDIR)"' -DVERSION=$(VERSION_NUM)

AR		= ar rc
RANLIB		= ranlib
AS		= as
CHGRP		= chgrp term
CHMOD		= chmod
CP		= cp
LN		= ln
RM		= rm -f
RMDIR		= rmdir
MKDIR		= mkdir
MV		= mv
NM		= nm
SED		= sed
STRIP		= strip
SHAREDIR	= /var/lib/term
BINDIR		= /usr/bin
LIBDIR		= /usr/lib
INCDIR		= /usr/include
MANDIR		= /usr/man/man1
OSLIBS		= 
SOCKLIBS	= 
LIBS		= $(TERMNETLIB) $(OSLIBS) $(SOCKLIBS)
LINKFLAGS	= 
LDFLAGS		= -s
USRTMP		= /usr/tmp

#
# Change this if yours is different.
#
CURSES= -ltermcap

TERMNETDEP=libtermnet.a
TERMNETLIB=-L. -ltermnet

TERMOBJS=main.o serial.o misc.o do_link.o pty.o compress.o \
		meta.o statistics.o sevenbit.o

CLIENTOBJS=utils.o client.o termnet.o terminal.o do_select.o sockets.o \
		do_connect.o term_getopt.o term_putenv.o term_herror.o \
		spipe.o term_spair.o checksum.o host_lookup.o

WRAPOBJS = termwrapin.o termwrapout.o

MANPAGES=term.1 termrc.1 term_clients.1 term_setup.1 termtest.1 linecheck.1

LINKS = trdated
LINK_FROM = trdate
CLIENTS = tdownload tudpredir tmon tshutdown \
	trsh tupload tredir txconn trdate


PROGS = term $(CLIENTS) linecheck


all: bin $(LINKS) libtermnet.a libtermnet.so.2.3.5

help:
	@echo "To install, make one of the following:"
	@echo "  install - binaries, dynamic and static library, include file"
	@echo "  install.bin - binaries"
	@echo "  install.share - binaries in shared mode"
	@echo "  install.lib - static library"
	@echo "  install.include - include file"
	@echo "  install.man - manual pages"
	@echo "  install.net - full networking flag"

install:  install.bin install.lib

install.bin: all
	if [ ! -d $(BINDIR) ] ; then $(MKDIR) $(BINDIR); else true; fi
	cd $(BINDIR); $(RM) $(LINKS); true
	cd $(BINDIR); for i in $(PROGS) $(SCRIPTS) $(LINKS); do \
		if [ -f $$i ]; then $(MV) $$i $$i.old ; fi ; \
	done; true
	for i in $(PROGS) $(SCRIPTS); do \
		$(CP) $$i $(BINDIR)/. ; \
		$(CHMOD) 755 $(BINDIR)/$$i ; \
	done
	for i in $(PROGS); do \
		$(STRIP) $(BINDIR)/$$i ; \
	done
	cd $(BINDIR); for i in $(LINKS); do \
		$(LN) -s ./$(LINK_FROM) $$i ; \
	done; true
	if [ ! -d $(LIBDIR) ] ; then $(MKDIR) $(LIBDIR); else true; fi

install.lib: libtermnet.a install.include
	$(CP) ./libtermnet.a $(LIBDIR)
	cd $(LIBDIR);$(RANLIB) libtermnet.a; true

install.net installnet: install
	if [ ! -d $(SHAREDIR) ] ; then $(MKDIR) $(SHAREDIR); else true; fi
	echo "# This file activates full term networking" > $(SHAREDIR)/termnet
	if [ ! -f $(SHAREDIR)/hosts.term ] ; then \
		echo 127.0.0.254 remotehost > /etc/hosts.term ; \
	fi ; true
	if [ ! -f /etc/hosts ] ; then \
		echo 127.0.0.1 localhost `hostname` > /etc/hosts ; \
	fi ; true

install.include:
	if [ ! -d $(INCDIR) ]; then $(MKDIR) $(INCDIR); else true; fi
	$(CP) termnet.h $(INCDIR)/.
	$(CHMOD) 644 $(INCDIR)/termnet.h


install.share installshare share: install
	cd $(BINDIR) ; \
	for i in $(PROGS) \
	; do \
		$(CHGRP) $$i ; \
		$(CHMOD) g+s $$i ; \
	done
	if [ ! -d $(SHAREDIR) ] ; then $(MKDIR) $(SHAREDIR); else true; fi
	$(CHGRP) $(SHAREDIR)
	$(CHMOD) 0775 $(SHAREDIR)
	if [ -d $(SHAREDIR)/tmp ] ; then \
		$(MV) $(SHAREDIR)/tmp $(SHAREDIR)/tmp.old ; \
		$(RM) -r $(SHAREDIR)/tmp.old ; \
	fi; true
	$(LN) -s $(USRTMP) $(SHAREDIR)/tmp; true
	if [ ! -d $(SHAREDIR)/.term ]; then \
		 $(LN) -s $(SHAREDIR)/tmp/private $(SHAREDIR)/.term ; \
	fi; true

install.man installman: $(MANPAGES)
	if [ ! -d $(MANDIR) ]; then $(MKDIR) $(MANDIR); else true; fi
	cd $(SRCDIR); for i in *.1; do \
		$(CP) $$i $(MANDIR)/.; \
		$(CHMOD) 644 $(MANDIR)/$$i; \
	done
	for i in $(CLIENTS) $(LINKS); do \
		echo ".so man1/term_clients.1" > $(MANDIR)/$$i.1; \
		$(CHMOD) 644 $(MANDIR)/$$i.1; \
	done

# The next two targets are only used by GNU Make, as far as I know.
# They automatically rebuild Makefile and config.status when necessary.

Makefile: Makefile.in Makefile.depend.in config.status
	./config.status
	@echo ' '
	@echo "If this message appears recursively, your make command is broken."
	@echo "In that case, please upgrade your version of make."
	@echo ' '

config.status: configure
	@echo "Updating Makefile with a new ./configure script."
	./configure
	@echo "YOU WILL NEED TO RE-RUN 'make'."
	@echo ' '
	@echo "The following error is normal:"
	@false

Makefile.depend:

#-----------------------------------------------------------------
# if your make complains about not know how to make .o files, you
# may need to uncomment following two lines.. (for gnu make).
#%.o: %.c
#	$(CC) $(CFLAGS) -c $< -o $@
#     --- or following 5 lines ------
#.SUFFIXES
#.SUFFIXES:  .o .c
#
#.c.o:
#	$(CC) $(CFLAGS) -c $< -o $@
#-----------------------------------------------------------------

libtermnet.a: $(CLIENTOBJS)
	$(RM) libtermnet.a
	$(AR) libtermnet.a $(CLIENTOBJS)
	$(RANLIB) libtermnet.a

libtermnet.so.2.3.5: $(CLIENTOBJS)
	ld -shared -o libtermnet.so.2.3.5 -soname libtermnet.so.2 \
	/usr/lib/crtbeginS.o $(CLIENTOBJS) /usr/lib/crtendS.o

bin: $(PROGS) $(SCRIPTS)

termtest: $(TERMNETDEP) termtest.o
	$(CC) $(LINKFLAGS) $(NOPAG) -o termtest termtest.o $(LIBS)

term: $(TERMNETDEP) $(TERMOBJS)
	$(CC) $(LINKFLAGS) -o term $(TERMOBJS) $(LIBS)

termwrap: termwrap.sh
	$(CP) $(SRCDIR)/termwrap.sh termwrap
	$(CHMOD) 0755 termwrap

$(LINKS): $(LINK_FROM)
	for i in $(LINKS); do \
		$(RM) $$i ; \
		$(LN) -s ./$(LINK_FROM) $$i ; \
	done

linecheck: $(TERMNETDEP) linecheck.o freqtest.o
	$(CC) $(LINKFLAGS) $(NOPAG) -o linecheck linecheck.o freqtest.o $(LIBS)

trsh: $(TERMNETDEP) trshell.o
	$(CC) $(LINKFLAGS) $(NOPAG) -o trsh trshell.o $(LIBS)

tupload: $(TERMNETDEP) upload.o
	$(CC) $(LINKFLAGS) $(NOPAG) -o tupload upload.o $(LIBS)

tdownload: $(TERMNETDEP) download.o
	$(CC) $(LINKFLAGS) $(NOPAG) -o tdownload download.o $(LIBS)

tredir: $(TERMNETDEP) tcpredir.o
	$(CC) $(LINKFLAGS) $(NOPAG) -o tredir tcpredir.o $(LIBS)

tudpredir: $(TERMNETDEP) udpredir.o
	$(CC) $(LINKFLAGS) $(NOPAG) -o tudpredir udpredir.o $(LIBS)

txconn: $(TERMNETDEP) xconn.o
	$(CC) $(LINKFLAGS) $(NOPAG) -o txconn xconn.o $(LIBS)

tshutdown: $(TERMNETDEP) shutdown.o
	$(CC) $(LINKFLAGS) $(NOPAG) -o tshutdown shutdown.o $(LIBS)

tmon: $(TERMNETDEP) tmon.o
	$(CC) $(LINKFLAGS) $(NOPAG) -o tmon tmon.o $(CURSES) $(LIBS)

trdate: $(TERMNETDEP) trdate.o
	$(CC) $(LINKFLAGS) $(NOPAG) -o trdate trdate.o $(CURSES) $(LIBS)

tags:
	etags *.h *.c


clean:
	$(RM) *.o lib*.a lib*.sa lib*.so.* lib*.so core compress.debug *.out *~


realclean: clean
	$(RM) $(PROGS) $(SCRIPTS) $(LINKS) freqtest termtest 1 TAGS tags
	$(RM) *.log; true

depend:
	echo '### Dependencies' > Makefile.depend
	for i in `cd $(SRCDIR); echo *.c`; do \
		if [ -s $$i ]; then \
			echo $$i; \
			(cd $(SRCDIR); gcc -E -MM $$i) >> Makefile.depend ; \
		fi; \
	done
	./config.status








#######################################################################
# The following targets are mostly for my personal use. I use them to
# update the version of term when I am developing.
#

VERSION_NAME = term-$(VERSION_MAJOR).$(VERSION_MINOR)$(PATCH_NAME)
ARCHIVE = /user/bcr/term/$(VERSION_NAME)
ALPHA_DIR = /opt/ftp/pub/bcr/term/ALPHA
BETA_DIR = /opt/ftp/pub/bcr/term

distclean: realclean
	$(RM) config.status Makefile
	$(RM) `find . -name \*.orig`; true
	$(RM) `find . -name \*.rej`; true
	@echo 'all install clean depend config.status config: configure' > Makefile
	@echo '		./configure' >> Makefile
	@echo '		@echo "YOU WILL NEED TO RE-RUN 'make'."' >> Makefile
	@echo '		@echo " "' >> Makefile
	@echo '		@echo "The following error is normal:"' >> Makefile
	@echo '		@false' >> Makefile

rcs_extract:
	co -q`expr $(VERSION_MAJOR) \* 100 + $(VERSION_MINOR)`.$(PATCH_LEVEL) \
	  `find . -name \*,v -print | sed 's/,v$$//'`; true
	$(CHMOD) ugo+x configure

rcs_purge: rcs_extract
	rcs -o`expr $(VERSION_MAJOR) \* 100 + $(VERSION_MINOR)`.$(PATCH_LEVEL) \
	  `find . -name \*,v -print | sed 's/,v$$//'`

rcs_ver: distclean rcs_extract
	rcs -U `find . -name \*,v -print`
	yes|tr y .|ci -f`expr $(VERSION_MAJOR) \* 100 + $(VERSION_MINOR)`.$(PATCH_LEVEL) \
	  -n`echo term-$(VERSION_MAJOR).$(VERSION_MINOR)$(PATCH_NAME)|tr . _` \
	  `find . -type f -not -name \*,v -not -name \*.gz -not -name Makefile -print`
	co -q`expr $(VERSION_MAJOR) \* 100 + $(VERSION_MINOR)`.$(PATCH_LEVEL) \
	  `find . -name \*,v -print | sed 's/,v$$//'`
	$(CHMOD) ugo+x configure

rcs_tar: distclean rcs_extract
	$(RM) /tmp/$(VERSION_NAME)
	$(LN) -s `pwd` /tmp/$(VERSION_NAME)
	cd /tmp ; \
	  find $(VERSION_NAME) -follow -type f -not -empty -not -name \*,v -print | \
	  sort -u | tar Tcvvfz - $(ARCHIVE).tar.gz

rcs_patch: distclean rcs_extract
	$(RM) /tmp/$(VERSION_NAME)
	$(LN) -s `pwd` /tmp/$(VERSION_NAME)
	if [ $(PATCH_LEVEL) -gt 0 ] ; then \
	  (cd /tmp; version_name=$(VERSION_NAME); rcsdiff \
	  -u -r`expr $(VERSION_MAJOR) \* 100 + $(VERSION_MINOR)`.`expr $(PATCH_LEVEL) - 1` \
	  `find $$version_name -follow -type f -not -name \*,v -not -name \*.gz -not -name Makefile -print` \
	  | gzip -c ) > $(ARCHIVE).patch.gz ; \
	  if [ $(PATCH_LEVEL) -le 50 ] ; then \
		$(CP) $(ARCHIVE).patch.gz $(SRCDIR)/patches/. ; \
	  else true; fi; \
	else true; fi

rcs_update: rcs_ver rcs_patch rcs_tar
	$(RM) /tmp/$(VERSION_NAME)
	$(LN) -s `pwd` /tmp/$(VERSION_NAME)
	cd /tmp; if [ $(PATCH_LEVEL) -gt 50 ] ; then \
	  tupload -fvvr $(ARCHIVE).*.gz $(ALPHA_DIR) ; \
	else \
	  tupload -fvvr $(ARCHIVE).*.gz $(BETA_DIR) ; \
	fi
	cd /tmp; $(CHMOD) ugo-w $(ARCHIVE).*.gz

rcs_remote: rcs_tar
	$(RM) /tmp/$(VERSION_NAME)
	$(LN) -s `pwd` /tmp/$(VERSION_NAME)
	cd /tmp; tupload -fvvr $(ARCHIVE).tar.gz /tmp
	trsh -s 'cd /tmp;zcat $(VERSION_NAME).tar.gz|tar xvvf -'
	trsh -s 'cd /tmp/$(VERSION_NAME);./configure --user;make install'

rcs_spell: distclean rcs_extract
	ispell -p $(HOME)/.term_dict `find . -type f -not -name \*,v -not -name \*.gz`


### Dependencies
checksum.o: checksum.c
client.o: client.c includes.h config.h termnet.h term_main.h client.h terminal.h
compress.o: compress.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h debug.h
do_connect.o: do_connect.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
do_link.o: do_link.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h debug.h
do_select.o: do_select.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
download.o: download.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
freqtest.o: freqtest.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
host_lookup.o: host_lookup.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
linecheck.o: linecheck.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
main.o: main.c includes.h config.h termnet.h term_main.h client.h terminal.h \
  debug.h
meta.o: meta.c includes.h config.h termnet.h term_main.h client.h terminal.h \
  debug.h
misc.o: misc.c includes.h config.h termnet.h term_main.h client.h terminal.h \
  debug.h
pty.o: pty.c includes.h config.h termnet.h term_main.h client.h terminal.h \
  debug.h
serial.o: serial.c includes.h config.h termnet.h term_main.h client.h terminal.h \
  debug.h
server.o: server.c includes.h config.h termnet.h term_main.h client.h terminal.h
sevenbit.o: sevenbit.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h debug.h
shutdown.o: shutdown.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
sockets.o: sockets.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
spipe.o: spipe.c includes.h config.h termnet.h term_main.h client.h terminal.h
statistics.o: statistics.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
tclient.o: tclient.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
tcpredir.o: tcpredir.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
term_clients.o: term_clients.c includes.h config.h termnet.h term_main.h \
  client.h terminal.h
term_getopt.o: term_getopt.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
term_herror.o: term_herror.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
term_putenv.o: term_putenv.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
term_spair.o: term_spair.c
terminal.o: terminal.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
termnet.o: termnet.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
termtest.o: termtest.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
termwrapin.o: termwrapin.c
tmon.o: tmon.c includes.h config.h termnet.h term_main.h client.h terminal.h
trdate.o: trdate.c includes.h config.h termnet.h term_main.h client.h terminal.h
trshell.o: trshell.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
udpredir.o: udpredir.c includes.h config.h termnet.h term_main.h client.h \
  terminal.h
upload.o: upload.c includes.h config.h termnet.h term_main.h client.h terminal.h
utils.o: utils.c includes.h config.h termnet.h term_main.h client.h terminal.h \
  debug.h
xconn.o: xconn.c includes.h config.h termnet.h term_main.h client.h terminal.h
