#
# SSH Library Makefile for Unix machines
# Copyright 1997 Tadayoshi Kohno.  See License file.
#

#
# Where to install libSSH
#
INSTALLTOP = /usr/local/ssh


#
# What type of os?
#

#OS_TYPE = HPUX
OS_TYPE = LINUX
#OS_TYPE = SUNOS

#
# Where are our include files and our library files
#

# I use this because I have my libraries divided by architecture
# within my personal account.  Most installations probably
# won't even care what ARCH is set to.

#ARCH = pa-risc
#ARCH = i586
#ARCH = sun4
#ARCH = i86pc

#IFLAGS = -I/home/cia/kohno/Arch/$(ARCH)/include
#LFLAGS = -L/home/cia/kohno/Arch/$(ARCH)/lib

IFLAGS = -I/usr/local/ssl/include
LFLAGS = -L/usr/local/ssl/lib

# we'll always need the SSLeay crypto library, but may need nsl, socket
# (for example, SunOS systems)
LIBS = -lcrypto
#LIBS = -lcrypto -lnsl -lsocket

# how do we compile?
CC = gcc -Wall -D$(OS_TYPE) $(IFLAGS)
AR = ar r
RANLIB = ranlib

# our target library
TARGETLIB = libssh.a

# what to install
INST_LIBS = $(TARGETLIB)
INST_INCLUDE = ssh_mp_int.h ssh_mp_int_dec.h ssh_mp_stream.h ssh.h ssh_auth.h \
	ssh_cmsg.h ssh_comm.h ssh_connect.h ssh_crypt.h ssh_debug.h \
	ssh_errno.h ssh_ident.h ssh_misc.h ssh_msg.h ssh_packet.h \
	ssh_prepare.h ssh_presetup.h ssh_proto.h ssh_smsg.h ssh_types.h \
	ssh_util.h ssh_random.h



# what do we compile?
LIBOBJ = ssh_crc32.o ssh_util.o ssh_smsg.o ssh_proto.o\
	 ssh_packet.o ssh_msg.o ssh_misc.o ssh_ident.o ssh_errno.o ssh_debug.o\
	 ssh_crypt.o ssh_connect.o ssh_comm.o ssh_cmsg.o ssh_mp_stream.o\
	 ssh_mp_int_dec.o ssh_mp_int.o ssh_presetup.o ssh_prepare.o ssh_random.o

#
# make all will make the library
#
all : $(INST_LIBS)

$(TARGETLIB): $(LIBOBJ)
	$(AR) $(TARGETLIB) $(LIBOBJ)
	$(RANLIB) $(TARGETLIB)

ssh_mp_int.o : ssh_mp_int.c  ssh_util.h ssh_mp_int.h

ssh_mp_int_dec.o : ssh_mp_int_dec.c  ssh_util.h ssh_debug.h ssh_mp_int_dec.h

ssh_mp_stream.o : ssh_mp_stream.c  ssh_mp_stream.h

ssh_cmsg.o : ssh_cmsg.c  ssh_util.h ssh_cmsg.h ssh.h ssh_errno.h

ssh_comm.o : ssh_comm.c  ssh_util.h ssh_cmsg.h ssh_smsg.h ssh_crypt.h \
	 ssh_packet.h ssh_comm.h ssh.h ssh_errno.h

ssh_connect.o : ssh_connect.c  ssh_util.h ssh_mp_int.h \
	 ssh_ident.h ssh_comm.h ssh_cmsg.h ssh_smsg.h \
	 ssh_msg.h ssh_packet.h ssh_crypt.h ssh_proto.h ssh_connect.h ssh.h \
	 ssh_errno.h

ssh_crypt.o : ssh_crypt.c  ssh_util.h ssh_types.h ssh_crypt.h ssh.h \
	ssh_errno.h

ssh_debug.o : ssh_debug.c  ssh_debug.h	ssh_errno.h

ssh_errno.o : ssh_errno.c  ssh_errno.h	ssh_errno.h

ssh_ident.o : ssh_ident.c ssh_util.h ssh_mp_int_dec.h \
	 ssh_mp_int.h ssh_ident.h ssh_crypt.h ssh_debug.h ssh.h	ssh_errno.h

ssh_misc.o : ssh_misc.c  ssh_misc.h ssh_comm.h ssh_cmsg.h ssh.h	ssh_errno.h

ssh_msg.o : ssh_msg.c  ssh_mp_stream.h ssh_types.h ssh_msg.h	ssh_errno.h

ssh_packet.o : ssh_packet.c  ssh_util.h ssh_crypt.h ssh_packet.h\
	 ssh_debug.h ssh.h	ssh_errno.h

ssh_prepare.o : ssh_prepare.c ssh_prepare.h ssh.h ssh_types.h\
	ssh_comm.h

ssh_presetup.o : ssh_presetup.c ssh_presetup.h ssh.h ssh_types.h\
	ssh_debug.h

ssh_proto.o : ssh_proto.c  ssh_proto.h ssh.h	ssh_errno.h

ssh_smsg.o : ssh_smsg.c  ssh_util.h ssh_mp_stream.h ssh_smsg.h ssh_msg.h ssh.h \
	ssh_errno.h

ssh_util.o : ssh_util.c  ssh_util.h

ssh_crc32.o : ssh_crc32.c  ssh_crypt.h ssh_types.h

ssh_random.o : ssh_random.c ssh_random.h


#
# install
#
install: all
	@-mkdir -p $(INSTALLTOP)/lib 2>/dev/null
	@-mkdir -p $(INSTALLTOP)/include 2>/dev/null

	@for i in $(INST_LIBS) ;\
	do \
	( \
		echo installing $$i; \
		cp $$i $(INSTALLTOP)/lib; \
		chmod 644 $(INSTALLTOP)/lib/$$i \
	); \
	done

	@for i in $(INST_INCLUDE) ;\
	do \
	( \
		echo installing $$i; \
		cp $$i $(INSTALLTOP)/include; \
		chmod 644 $(INSTALLTOP)/include/$$i \
	); \
	done


#
# cleanup
#
clean :
	rm -f core $(LIBOBJ) $(TARGETLIB)

