#
# SSLtelnet    - this is an implementation of ftp and ftpd using SSLeay
#
#
# - You may want to change SSLTOP depending on where you have SSL installed
# - You will probably have to choose which of the OS sections to
#   activate so that the right compiler switches and libraries are linked
# - if you don't want SOCKS support then unset sockslib and remove
#   the -DUSE_SOCKS from the CC line
#
# Then all that should be required is a straight:
# make install
#
# 06-Jun-95 tjh    original extraction from my SRA source tree into
# ................ this separate package
#
#

VERSION = 0.1
DIRECTORY=SSLtelnet-$(VERSION)
TARFILE=$(DIRECTORY).tar

GENERAL=Makefile README

#
#/* 
# * The modifications to support SSLeay were done by Tim Hudson
# * tjh@mincom.oz.au
# *
# * You can do whatever you like with these patches except pretend that
# * you wrote them. 
# *
# * Email ssl-users-request@mincom.oz.au to get instructions on how to
# * join the mailing list that discusses SSLeay and also these patches.
# *
# */
#

# the location where SSLeay is installed ... 
# - expect a include and lib directory under here 
SSLTOP=/usr/local/ssl

INSTALLTOP=$(SSLTOP)

SUBDIRS= lib telnet telnetd

# Decide if you want SOCKS support (which I haven't put into 
# the ftp client yet)
sockslib=
sockslib=/usr/local/lib/libsocks.a 

# SunOX 4.x (Solaris 1.x)
#CC= gcc -DSUNOS

# SunOS 5.x (Solaris 2.x)
CC = cc -DSUNOS -DSOLARIS2 -DUSE_SHADOW -DEAY_DES 
CC = cc -DSUNOS -DSOLARIS2 -DUSE_SHADOW -DEAY_DES -DUSE_SOCKS
# the extra libbsd crud is only there for inet_aton for GCC and
# I really do not want to think too hard about it --tjh
#LDADD= $(sockslib) -lresolv -lsocket -lnsl ../lib/libbsd/libbsd.a -ltermcap

# IRIX 5.x
CC = cc -DIRIX -DEAY_DES -DUSE_SOCKS
LDADD=$(sockslib) -ltermcap

# uncomment the next two lines for linux
#CC = gcc -DLINUX -DUSE_SHADOW
#LDADD = $(sockslib) -lshadow


all:
	@-mkdir bin 2>/dev/null
	@for i in $(SUBDIRS); \
	    do (cd $$i && echo $$i && $(MAKE) CC="$(CC)" SSLTOP="$(SSLTOP)" LDADD="$(LDADD)") || exit; \
	done

lib: /dev/null
	@for i in "lib" ; \
	do (cd $$i && echo $$i && $(MAKE) CC="$(CC)" SSLTOP="$(SSLTOP)" LDADD="$(LDADD)") || exit; \
	done

ftp: lib /dev/null
	@for i in "ftp" ; \
	do (cd $$i && echo $$i && $(MAKE) CC="$(CC)" SSLTOP="$(SSLTOP)" LDADD="$(LDADD)") || exit; \
	done

ftpd: lib /dev/null
	@for i in "ftpd" ; \
	do (cd $$i && echo $$i && $(MAKE) CC="$(CC)" SSLTOP="$(SSLTOP)" LDADD="$(LDADD)") || exit; \
	done


telnet: lib /dev/null
	@for i in "telnet" ; \
	do (cd $$i && echo $$i && $(MAKE) CC="$(CC)" SSLTOP="$(SSLTOP)" LDADD="$(LDADD)") || exit; \
	done


telnetd: lib /dev/null
	@for i in "telnetd" ; \
	do (cd $$i && echo $$i && $(MAKE) CC="$(CC)" SSLTOP="$(SSLTOP)" LDADD="$(LDADD)") || exit; \
	done

clean:
	@for i in $(SUBDIRS); \
		do (cd $$i && echo $$i && $(MAKE) clean) || exit; \
		if [ -f bin/$$i ]; then \
		    rm bin/$$i ;\
		fi; \
	done

tar:    clean
	(cd ..; tar cf $(TARFILE) $(DIRECTORY) )

install: telnet telnetd
	@-mkdir -p $(INSTALLTOP)/bin 2>/dev/null
	cp bin/telnet $(INSTALLTOP)/bin/telnet
	chmod 755 $(INSTALLTOP)/bin/telnet
	cp bin/telnetd $(INSTALLTOP)/bin/telnetd
	chmod 755 $(INSTALLTOP)/bin/telnetd
	@echo "******************************************************"
	@echo "* Do not forget to make the cert and key for telnetd *"
	@echo "******************************************************"


