#
# This file is a Makefile for TRF (2.1p2, as of August 20, 2001).
# If it has the name "Makefile.in" then it is a template for a
# Makefile;  to generate the actual Makefile, run "./configure",
# which is a configuration script generated by the "autoconf"
# program (constructs like "@foo@" will get replaced in the
# actual Makefile.
# $Id: Makefile.in,v 1.42 2000/03/21 20:35:33 aku Exp $

EXTENSION	=	Trf
LOW_EXTENSION	=	trf

VERSION		=	2.1

#----------------------------------------------------------------
# Things you can change to personalize the Makefile for your own
# site (you can make these changes in either Makefile.in or
# Makefile, but changes to Makefile will get lost if you re-run
# the configuration script).
#----------------------------------------------------------------

# Directory containing the unix specific part of the extension
srcdir		=	@srcdir@
TOP_DIR		=	@srcdir@/..
GENERIC_DIR	=	$(TOP_DIR)/generic
UNIX_DIR	=	@srcdir@

# Directories in which the tcl core can be found
TCL_INCLUDE_DIR		=	@TCL_INCLUDE_DIR@
TCL_LIB_DIR		=	@TCL_LIB_DIR@
TCL_LIB			=	@TCL_LIB@
TCL_SRC_DIR		=	@TCL_SRC_DIR@
TCL_VERSION		=	@TCL_VERSION@
#SSL_INSTALL_DIR		=	/usr/local/ssl

# Directories for zlib / ssl (message digests)
ZLIB_INCLUDE_DIR	=	@ZLIB_INCLUDE_DIR@
ZLIB_LIB_DIR		=	@ZLIB_LIB_DIR@

SSL_INCLUDE_DIR		=	@SSL_INCLUDE_DIR@
SSL_LIB_DIR		=	@SSL_LIB_DIR@


# Default top-level directories in which to install architecture-
# specific files (exec_prefix) and machine-independent files such
# as scripts (prefix).  The values specified here may be overridden
# at configure-time with the --exec-prefix and --prefix options
# to the "configure" script.

prefix		=	@prefix@
exec_prefix	=	@exec_prefix@

# Directory containing scripts supporting the work of this makefile
tool		=	$(TOP_DIR)/tools
top_tool	=	./tools


# The following definition can be set to non-null for special systems
# like AFS with replication.  It allows the pathnames used for installation
# to be different than those used for actually reference files at
# run-time.  INSTALL_ROOT is prepended to $prefix and $exec_prefix
# when installing files.
INSTALL_ROOT =


# Directory where libtrf.a is at run-time:
LIB_RUNTIME_DIR =	$(exec_prefix)/lib/$(EXTENSION)$(VERSION)


# Directory in which to install the archive libtrf.a:
LIB_INSTALL_DIR =	$(INSTALL_ROOT)$(LIB_RUNTIME_DIR)


# Directory in which to install the extended shell tclsh:
BIN_INSTALL_DIR =	$(INSTALL_ROOT)$(exec_prefix)/bin


# Directory in which to install the include file transform.h:
INCLUDE_INSTALL_DIR =	$(INSTALL_ROOT)$(prefix)/include


# Top-level directory in which to install manual entries:
MAN_INSTALL_DIR =	$(INSTALL_ROOT)$(prefix)/man


# To change the compiler switches, for example to change from -O
# to -g, change the following line:
CFLAGS		=	-O

# options for libdes target
LIBDES_OPTS= -DRAND -DTERMIO
#-DNOCONST



# To disable ANSI-C procedure prototypes reverse the comment characters
# on the following lines:
PROTO_FLAGS =
#PROTO_FLAGS = -DNO_PROTOTYPE


# To enable memory debugging reverse the comment characters on the following
# lines.  Warning:  if you enable memory debugging, you must do it
# *everywhere*, including all the code that calls Tcl, and you must use
# ckalloc and ckfree everywhere instead of malloc and free.
MEM_DEBUG_FLAGS =
#MEM_DEBUG_FLAGS = -DTCL_MEM_DEBUG


# Some versions of make, like SGI's, use the following variable to
# determine which shell to use for executing commands:
SHELL =		/bin/sh


# Tcl used to let the configure script choose which program to use
# for installing, but there are just too many different versions of
# "install" around;  better to use the install-sh script that comes
# with the distribution, which is slower but guaranteed to work.

INSTALL = $(tool)/install-sh -c


# The symbols below provide support for dynamic loading and shared
# libraries.  The values of the symbols are normally set by the
# configure script.  You shouldn't normally need to modify any of
# these definitions by hand.

TRF_SHLIB_CFLAGS = @TRF_SHLIB_CFLAGS@


# The symbol below provides support for dynamic loading and shared
# libraries.  See configure.in for a description of what it means.
# The values of the symbolis normally set by the configure script.

SHLIB_LD = @SHLIB_LD@


# Libraries to use when linking:  must include at least the dynamic
# loading library and the math library (in that order).  This
# definition is determined by the configure script.
ALL_LIBS =  $(TCL_LIB) @TCL_LIBS@ @LIBS@ @TRF_CC_SEARCH_FLAGS@

LIBS = @TRF_LD_SEARCH_FLAGS@ @SHARED_LIBS@

#TRF_LIB_FILE = libtrf.a

TRF_TESTS	=	@TRF_TESTS@
TRF_LIB_FILE	=	@TRF_LIB_FILE@
TRF_STUB_LIB_FILE=	@TRF_STUB_LIB_FILE@

ZLIB_LIB_FILE	=	@ZLIB_LIB_FILE@
LIBDES_LIB_FILE	=	@LIBDES_LIB_FILE@

MD5_LIB_FILE	=	@MD5_LIB_FILE@

#----------------------------------------------------------------
# The information below is modified by the configure script when
# Makefile is generated from Makefile.in.  You shouldn't normally
# modify any of this stuff by hand.
#----------------------------------------------------------------

INSTALL_PROGRAM =	$(INSTALL) -m 755
INSTALL_DATA =		$(INSTALL) -m 644
RANLIB =		@RANLIB@

#----------------------------------------------------------------
# The information below should be usable as is.  The configure
# script won't modify it and you shouldn't need to modify it
# either.
#----------------------------------------------------------------

# locations of 'tclsh' and 'wish', via $PATH
# I'm not sure wether the 'which' command is portable or not.
# So I wrote it myself

TCLSH_PATH	=	`tclsh $(tool)/findinpath tclsh`
WISH_PATH	=	`tclsh $(tool)/findinpath wish`

TOOLS		=	md


CC		=	@CC@

CC_SWITCHES	=	$(CFLAGS) $(TRF_SHLIB_CFLAGS) $(CPPFLAGS)	\
			-DZ_LIB_NAME=\"$(ZLIB_LIB_FILE)\"		\
			-DLIBDES_LIB_NAME=\"$(LIBDES_LIB_FILE)\"	\
			-DTRF_VERSION=\"$(VERSION)\"			\
			$(LIBDES_OPTS) @TCL_DEFS@ @TRF_DEFS@
# $(TCL_CC_SWITCHES)
CPPFLAGS	=	$(DEFINES) $(INCLUDES)

MD5_INCLUDES	=	$(INCLUDES) -I$(TOP_DIR)/md5-crypt
MD5_CPPFLAGS	=	$(DEFINES) $(MD5_INCLUDES)
MD5_CC_SWITCHES	=	$(CFLAGS) $(TRF_SHLIB_CFLAGS) $(MD5_CPPFLAGS)

INCLUDES	=	-I. -I$(srcdir) -I$(GENERIC_DIR) -I$(TOP_DIR)	\
			-I$(TCL_INCLUDE_DIR) -I$(SSL_INCLUDE_DIR)	\
			-I$(ZLIB_INCLUDE_DIR)
DEFINES		=	$(PROTO_FLAGS) $(MEM_DEBUG_FLAGS)		\
			@DEFS@ @TCL_DEFS@ @TRF_DEFS@

HEADER		=	$(GENERIC_HDRS)
GENERIC_HDRS	=	$(GENERIC_DIR)/transform.h	\
			$(GENERIC_DIR)/transformInt.h	\
			$(GENERIC_DIR)/crc.h

SOURCES		=	$(BASE_SRC) $(CVT_SRC) $(MD_SRC) $(ECC_SRC) $(COMPRESS_SRC)
OBJECTS		=	$(BASE_OBJ) $(CVT_OBJ) $(MD_OBJ) $(ECC_OBJ) $(COMPRESS_OBJ)

#		fundamentals of this library
BASE_SRC	=	$(GENERIC_DIR)/zlib.c		\
			$(GENERIC_DIR)/bz2lib.c		\
			$(GENERIC_DIR)/loadman.c	\
			$(GENERIC_DIR)/init.c		\
			$(GENERIC_DIR)/registry.c	\
			$(GENERIC_DIR)/unstack.c	\
			$(GENERIC_DIR)/binio.c		\
			$(GENERIC_DIR)/trfStubInit.c	\
			$(GENERIC_DIR)/load.c		\
			$(GENERIC_DIR)/crypt.c

BASE_OBJ	=	bz2lib.o zlib.o loadman.o init.o	\
			registry.o unstack.o binio.o load.o	\
			crypt.o @DL_OBJS@ @STUB_OBJS@

#		conversions, base & algorithms
CVT_SRC		=	$(CVT_BASE_SRC) $(CVT_ALG_SRC)
CVT_OBJ		=	$(CVT_BASE_OBJ) $(CVT_ALG_OBJ)

#		utilities for conversions
CVT_BASE_SRC	=	$(GENERIC_DIR)/convert.c	\
			$(GENERIC_DIR)/util.c		\
			$(GENERIC_DIR)/ref_opt.c
CVT_BASE_OBJ	=	convert.o util.o ref_opt.o

#		conversion algorithms
CVT_ALG_SRC	=	$(GENERIC_DIR)/bincode.c	\
			$(GENERIC_DIR)/hexcode.c	\
			$(GENERIC_DIR)/octcode.c	\
			$(GENERIC_DIR)/uucode.c		\
			$(GENERIC_DIR)/b64code.c	\
			$(GENERIC_DIR)/asc85code.c	\
			$(GENERIC_DIR)/otpcode.c	\
			$(GENERIC_DIR)/qpcode.c		\
			$(GENERIC_DIR)/reflect.c
CVT_ALG_OBJ	=	bincode.o hexcode.o octcode.o uucode.o b64code.o asc85code.o otpcode.o qpcode.o reflect.o


#		message digests, base & algorithms
MD_SRC		=	$(GENERIC_DIR)/dig_opt.c	\
			$(GENERIC_DIR)/digest.c		\
			$(GENERIC_DIR)/crc.c		\
			$(GENERIC_DIR)/md5dig.c		\
			$(GENERIC_DIR)/haval.c		\
			$(GENERIC_DIR)/sha.c		\
			$(GENERIC_DIR)/adler.c		\
			$(GENERIC_DIR)/crc_zlib.c	\
			$(GENERIC_DIR)/md2.c		\
			$(GENERIC_DIR)/sha1.c		\
			$(GENERIC_DIR)/rmd160.c		\
			$(GENERIC_DIR)/rmd128.c		\
			$(GENERIC_DIR)/otpmd5.c		\
			$(GENERIC_DIR)/otpsha1.c

MD_OBJ		=	dig_opt.o digest.o crc.o md5dig.o haval.o sha.o	\
			adler.o crc_zlib.o md2.o sha1.o rmd160.o rmd128.o \
			otpmd5.o otpsha1.o


#		error correction
ECC_SRC		=	$(GENERIC_DIR)/rs_ecc.c
ECC_OBJ		=	rs_ecc.o

#		compression, base
COMPRESS_SRC	=	$(GENERIC_DIR)/zip_opt.c	\
			$(GENERIC_DIR)/zip.c		\
			$(GENERIC_DIR)/bz2_opt.c	\
			$(GENERIC_DIR)/bz2.c
COMPRESS_OBJ	=	zip_opt.o zip.o bz2_opt.o bz2.o


#		initialization for tclsh with trf preloaded
TCLSH_OBJS	=	$(TOP_DIR)/app/tclAppInit.o

DOCTEMP		=	$(TOP_DIR)/doc/man.log		\
			$(TOP_DIR)/doc/man.aux		\
			$(TOP_DIR)/doc/man.toc		\
			$(TOP_DIR)/doc/man.dvi		\
			$(TOP_DIR)/doc/man.ps		\
			$(TOP_DIR)/doc/install.log	\
			$(TOP_DIR)/doc/install.aux	\
			$(TOP_DIR)/doc/install.toc	\
			$(TOP_DIR)/doc/install.dvi	\
			$(TOP_DIR)/doc/install.ps

APP		=	$(srcdir)/tclsh

LDFLAGS		=	@LD_FLAGS@
LOADLIBES	=	@TRF_BUILD_LIB_SPEC@ $(ALL_LIBS)

STUB_OBJ	=	@STUB_LIBOBJS@


MD5_OBJECTS	=	stpncpy.o	\
			crypt-entry.o	\
			md5-crypt.o	\
			md5.o

#-------------------------------------------------------#

all:	check-package library

clean:
	rm -f $(OBJECTS) $(MD5_OBJECTS) $(TRF_LIB_FILE) $(MD5_LIB_FILE) $(TRF_STUB_LIB_FILE) $(APP) $(TCLSH_OBJS) $(DOCTEMP) $(STUB_OBJ)
	rm -f TAGS *~ */*~ core*

distclean:	clean
	rm -f config.status config.cache config.log Makefile \
	$(srcdir)/pkgIndex.tcl

install:	install-lib install-header @install_other@ install-tools


install-lib: $(TRF_LIB_FILE) $(MD5_LIB_FILE) $(TRF_STUB_LIB_FILE)
	$(tool)/mkinstalldirs $(LIB_INSTALL_DIR)
	@echo "Installing $(TRF_LIB_FILE)"
	@$(INSTALL_DATA) $(TRF_LIB_FILE) $(LIB_INSTALL_DIR)
	-@$(INSTALL_DATA) $(MD5_LIB_FILE) $(LIB_INSTALL_DIR)
	-@$(INSTALL_DATA) $(TRF_STUB_LIB_FILE) $(LIB_INSTALL_DIR)
	@$(RANLIB) $(LIB_INSTALL_DIR)/$(TRF_LIB_FILE)
	@$(RANLIB) $(LIB_INSTALL_DIR)/$(MD5_LIB_FILE)
	@$(INSTALL_DATA) $(UNIX_DIR)/pkgIndex.tcl $(LIB_INSTALL_DIR)/pkgIndex.tcl


install-header:
	$(tool)/mkinstalldirs  $(INCLUDE_INSTALL_DIR)
	@echo "Installing transform.h"
	@$(INSTALL_DATA) $(GENERIC_DIR)/transform.h $(INCLUDE_INSTALL_DIR)
	@$(INSTALL_DATA) $(GENERIC_DIR)/trfDecls.h $(INCLUDE_INSTALL_DIR)

install-bin:	application
	$(tool)/mkinstalldirs  $(BIN_INSTALL_DIR)
	@echo "Installing tclsh"
	@$(INSTALL_PROGRAM) $(APP) $(BIN_INSTALL_DIR)

install-tools:
	$(tool)/mkinstalldirs  $(BIN_INSTALL_DIR)
	@echo "Installing tools"
	for i in $(TOOLS);		\
	do 					\
		$(INSTALL_PROGRAM) $(tool)/$$i $(BIN_INSTALL_DIR); \
		tclsh $(tool)/fixhbline $(TCLSH_PATH) $(WISH_PATH) $(BIN_INSTALL_DIR)/$$i; \
	done

#fix-hashbang-line:
#	for i in $(TOOLS);		\
#	do 					\
#	tclsh $(tool)/fixhbline $(TCLSH_PATH) $(WISH_PATH) $(tool)/$$i; \
#	done


#-------------------------------------------------------#

lib:	library

library:	$(TRF_LIB_FILE) $(TRF_STUB_LIB_FILE) $(MD5_LIB_FILE)
	@echo ... done

app:	application

application:	library $(APP)
	@echo ... done tclsh

#depend:	$(HEADER) $(SOURCES)
#	@MAKEDEPEND@ -D___MAKEDEPEND___ -- @MKDEP_FLAGS@ $(CC_SWITCHES) -- $(SOURCES)
#	touch depend

#-------------------------------------------------------#

TCLSH_PROG	=	@TCLSH_PROG@

TAGS:
		etags *.[ch]

check-package:
	@cd .. ; tclsh $(top_tool)/check_manifest MANIFEST


check:	test

test:
	TCL_LIBRARY=$(TCL_SRC_DIR)/library; export TCL_LIBRARY; \
	LD_LIBRARY_PATH="$(srcdir):./unix:../unix:$(TCL_LIB_DIR):$(ZLIB_LIB_DIR):$(SSL_LIB_DIR)"; \
	export LD_LIBRARY_PATH; SHLIB_PATH="$LD_LIBRARY_PATH"; export SHLIB_PATH ; \
	echo package require Memchan \; load ./$(TRF_LIB_FILE) \; cd $(TOP_DIR)/tests \; source defs \; defConstraints \"$(TRF_TESTS)\" \; source all | $(TCLSH_PROG)

# 'unix' is required to have a path for the
# recursive call to unix/tclsh in '________.test'.


#-------------------------------------------------------#
# unix specific files

.c.o:
	$(CC) -c $(CC_SWITCHES) $< -o $@

#-------------------------------------------------------#
# generic files

trfStubLib.o:	$(GENERIC_DIR)/trfStubLib.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/trfStubLib.c -o $@

trfStubInit.o:	$(GENERIC_DIR)/trfStubInit.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/trfStubInit.c -o $@

load.o: $(GENERIC_DIR)/load.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/load.c -o $@

crypt.o: $(GENERIC_DIR)/crypt.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/crypt.c -o $@

zlib.o: $(GENERIC_DIR)/zlib.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/zlib.c -o $@

bz2lib.o: $(GENERIC_DIR)/bz2lib.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/bz2lib.c -o $@

loadman.o: $(GENERIC_DIR)/loadman.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/loadman.c -o $@

init.o: $(GENERIC_DIR)/init.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/init.c -o $@

registry.o: $(GENERIC_DIR)/registry.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/registry.c -o $@

unstack.o: $(GENERIC_DIR)/unstack.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/unstack.c -o $@

binio.o: $(GENERIC_DIR)/binio.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/binio.c -o $@

convert.o: $(GENERIC_DIR)/convert.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/convert.c -o $@

util.o: $(GENERIC_DIR)/util.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/util.c -o $@

bincode.o: $(GENERIC_DIR)/bincode.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/bincode.c -o $@

hexcode.o: $(GENERIC_DIR)/hexcode.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/hexcode.c -o $@

octcode.o: $(GENERIC_DIR)/octcode.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/octcode.c -o $@

uucode.o: $(GENERIC_DIR)/uucode.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/uucode.c -o $@

b64code.o: $(GENERIC_DIR)/b64code.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/b64code.c -o $@

asc85code.o: $(GENERIC_DIR)/asc85code.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/asc85code.c -o $@

otpcode.o: $(GENERIC_DIR)/otpcode.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/otpcode.c -o $@

dig_opt.o: $(GENERIC_DIR)/dig_opt.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/dig_opt.c -o $@

digest.o: $(GENERIC_DIR)/digest.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/digest.c -o $@

crc.o: $(GENERIC_DIR)/crc.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/crc.c -o $@

md5dig.o: $(GENERIC_DIR)/md5dig.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/md5dig.c -o $@

md2.o: $(GENERIC_DIR)/md2.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/md2.c -o $@

haval.o: $(GENERIC_DIR)/haval.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/haval.c -o $@

sha.o: $(GENERIC_DIR)/sha.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/sha.c -o $@

sha1.o: $(GENERIC_DIR)/sha1.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/sha1.c -o $@

rmd160.o: $(GENERIC_DIR)/rmd160.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/rmd160.c -o $@

rmd128.o: $(GENERIC_DIR)/rmd128.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/rmd128.c -o $@

otpmd5.o: $(GENERIC_DIR)/otpmd5.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/otpmd5.c -o $@

otpsha1.o: $(GENERIC_DIR)/otpsha1.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/otpsha1.c -o $@

adler.o: $(GENERIC_DIR)/adler.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/adler.c -o $@

crc_zlib.o: $(GENERIC_DIR)/crc_zlib.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/crc_zlib.c -o $@

rs_ecc.o: $(GENERIC_DIR)/rs_ecc.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/rs_ecc.c -o $@

zip_opt.o: $(GENERIC_DIR)/zip_opt.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/zip_opt.c -o $@

zip.o: $(GENERIC_DIR)/zip.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/zip.c -o $@

bz2_opt.o: $(GENERIC_DIR)/bz2_opt.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/bz2_opt.c -o $@

bz2.o: $(GENERIC_DIR)/bz2.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/bz2.c -o $@

qpcode.o: $(GENERIC_DIR)/qpcode.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/qpcode.c -o $@

reflect.o: $(GENERIC_DIR)/reflect.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/reflect.c -o $@

ref_opt.o: $(GENERIC_DIR)/ref_opt.c
	$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/ref_opt.c -o $@


#-------------------------------------------------------#
# compat files

tclLoadAix.o:	$(TOP_DIR)/compat/tclLoadAix.c
	$(CC) -c $(CC_SWITCHES) $(TOP_DIR)/compat/tclLoadAix.c -o $@

tclLoadDld.o:	$(TOP_DIR)/compat/tclLoadDld.c
	$(CC) -c $(CC_SWITCHES) $(TOP_DIR)/compat/tclLoadDld.c -o $@

tclLoadShl.o:	$(TOP_DIR)/compat/tclLoadShl.c
	$(CC) -c $(CC_SWITCHES) $(TOP_DIR)/compat/tclLoadShl.c -o $@

tclLoadAout.o:	$(TOP_DIR)/compat/tclLoadAout.c
	$(CC) -c $(CC_SWITCHES) $(TOP_DIR)/compat/tclLoadAout.c -o $@

tclLoadNone.o:	$(TOP_DIR)/compat/tclLoadNone.c
	$(CC) -c $(CC_SWITCHES) $(TOP_DIR)/compat/tclLoadNone.c -o $@

_eprintf.o:	$(TOP_DIR)/compat/_eprintf.c
	$(CC) -c $(CC_SWITCHES) $(TOP_DIR)/compat/_eprintf.c -o $@

#-------------------------------------------------------#
# MD5 files for supporting library

stpncpy.o:	$(TOP_DIR)/compat/stpncpy.c
	$(CC) -c $(MD5_CC_SWITCHES) $(TOP_DIR)/compat/stpncpy.c -o $@

crypt-entry.o:	$(TOP_DIR)/md5-crypt/crypt-entry.c
	$(CC) -c $(MD5_CC_SWITCHES) $(TOP_DIR)/md5-crypt/crypt-entry.c -o $@

md5-crypt.o:	$(TOP_DIR)/md5-crypt/md5-crypt.c
	$(CC) -c $(MD5_CC_SWITCHES) $(TOP_DIR)/md5-crypt/md5-crypt.c -o $@

md5.o:	$(TOP_DIR)/md5-crypt/md5.c
	$(CC) -c $(MD5_CC_SWITCHES) $(TOP_DIR)/md5-crypt/md5.c -o $@

#-------------------------------------------------------#

$(TRF_STUB_LIB_FILE):	$(STUB_OBJ)
	$(AR) cr $@ $(STUB_OBJ)

$(TRF_LIB_FILE):	$(OBJECTS)
	rm -f		$(TRF_LIB_FILE)
	@MAKE_LIB@
	$(RANLIB)	$(TRF_LIB_FILE)

$(MD5_LIB_FILE):	$(MD5_OBJECTS)
	rm -f		$(MD5_LIB_FILE)
	@MAKE_MD5_LIB@
	$(RANLIB)	$(MD5_LIB_FILE)

#$(APP): $(TCLSH_OBJS) $(TRF_LIB_FILE)
#	$(CC) $(LDFLAGS) $(TCLSH_OBJS) $(LOADLIBES) -o $(APP)


#-------------------------------------------------------#
# support for external libraries (zlib, libdes)

zlibdir		=	$(TOP_DIR)/zlib
libdesdir	=	$(TOP_DIR)/libdes


ZLIB_SRC	=	\
			$(zlibdir)/adler32.c	$(zlibdir)/compress.c	$(zlibdir)/crc32.c	\
			$(zlibdir)/gzio.c	$(zlibdir)/uncompr.c	$(zlibdir)/deflate.c	\
			$(zlibdir)/trees.c	$(zlibdir)/zutil.c	$(zlibdir)/inflate.c 	\
			$(zlibdir)/infblock.c	$(zlibdir)/inftrees.c	$(zlibdir)/infcodes.c	\
			$(zlibdir)/infutil.c	$(zlibdir)/inffast.c

ZLIB_OBJ	=	\
			$(zlibdir)/adler32.o	$(zlibdir)/compress.o	$(zlibdir)/crc32.o	\
			$(zlibdir)/gzio.o	$(zlibdir)/uncompr.o	$(zlibdir)/deflate.o	\
			$(zlibdir)/trees.o	$(zlibdir)/zutil.o	$(zlibdir)/inflate.o	\
			$(zlibdir)/infblock.o	$(zlibdir)/inftrees.o	$(zlibdir)/infcodes.o	\
			$(zlibdir)/infutil.o	$(zlibdir)/inffast.o


LIBDES_SRC	=	\
			$(libdesdir)/cbc3_enc.c $(libdesdir)/cbc_cksm.c $(libdesdir)/cbc_enc.c	\
			$(libdesdir)/ncbc_enc.c $(libdesdir)/pcbc_enc.c $(libdesdir)/qud_cksm.c	\
			$(libdesdir)/cfb64ede.c $(libdesdir)/cfb64enc.c $(libdesdir)/cfb_enc.c	\
			$(libdesdir)/ecb3_enc.c $(libdesdir)/ecb_enc.c  $(libdesdir)/ede_enc.c	\
			$(libdesdir)/enc_read.c $(libdesdir)/enc_writ.c $(libdesdir)/fcrypt.c	\
			$(libdesdir)/ofb64ede.c $(libdesdir)/ofb64enc.c $(libdesdir)/ofb_enc.c	\
			$(libdesdir)/rand_key.c $(libdesdir)/read_pwd.c $(libdesdir)/set_key.c	\
			$(libdesdir)/rpc_enc.c  $(libdesdir)/str2key.c  $(libdesdir)/supp.c

LIBDES_OBJ	=	\
			$(libdesdir)/cbc3_enc.o $(libdesdir)/cbc_cksm.o $(libdesdir)/cbc_enc.o	\
			$(libdesdir)/ncbc_enc.o $(libdesdir)/pcbc_enc.o $(libdesdir)/qud_cksm.o	\
			$(libdesdir)/cfb64ede.o $(libdesdir)/cfb64enc.o $(libdesdir)/cfb_enc.o	\
			$(libdesdir)/ecb3_enc.o $(libdesdir)/ecb_enc.o  $(libdesdir)/ede_enc.o	\
			$(libdesdir)/enc_read.o $(libdesdir)/enc_writ.o $(libdesdir)/fcrypt.o	\
			$(libdesdir)/ofb64ede.o $(libdesdir)/ofb64enc.o $(libdesdir)/ofb_enc.o  \
			$(libdesdir)/rand_key.o $(libdesdir)/read_pwd.o $(libdesdir)/set_key.o	\
			$(libdesdir)/rpc_enc.o  $(libdesdir)/str2key.o $(libdesdir)/supp.o


zlib:	$(ZLIB_LIB_FILE)
	@echo ... done

$(ZLIB_LIB_FILE):	$(ZLIB_OBJ)
	rm -f		$(ZLIB_LIB_FILE)
	@MAKE_ZLIB@
	$(RANLIB)	$(ZLIB_LIB_FILE)


libdes:	$(LIBDES_LIB_FILE)
	@echo ... done

$(LIBDES_LIB_FILE):	$(LIBDES_OBJ)
	rm -f		$(LIBDES_LIB_FILE)
	@MAKE_LIBDES@
	$(RANLIB)	$(LIBDES_LIB_FILE)

#-------------------------------------------------------#
#
# Target to regenerate header files and stub files from the *.decls tables.
#

TRF_DECLS = \
	$(GENERIC_DIR)/trf.decls \
	$(GENERIC_DIR)/trfInt.decls


trfDecls.h trfIntDecls.h : genstubs

genstubs: $(GENERIC_DIR)/trf.decls $(GENERIC_DIR)/trfInt.decls
	tclsh $(tool)/genStubs.tcl $(GENERIC_DIR) \
		$(GENERIC_DIR)/trf.decls $(GENERIC_DIR)/trfInt.decls

#
# Target to check that all exported functions have an entry in the stubs
# tables.
#

checkstubs:
	-@for i in `nm -p $(TRF_LIB_FILE) | awk '$$2 ~ /T/ { print $$3 }' \
		| sort -n`; do \
		match=0; \
		for j in $(TRF_DECLS); do \
		    if [ `grep -c $$i $$j` -gt 0 ]; then \
			match=1; \
		    fi; \
		done; \
		if [ $$match -eq 0 ]; then echo $$i; fi \
	done

#-------------------------------------------------------#
# DO NOT DELETE THIS LINE -- make depend depends on it.

