# Agent Tcl
# Bob Gray
# 12 February 1995
#
# This Makefile compiles the "agent" interpreter and the "libagent.a" library.
#
# Copyright (c) 1995, Robert S. Gray Dartmouth College
#
# See the file "agent.terms" for information on usage and redistribution
# of this file and for a DISCLAIMER OF ALL WARRANTIES.

  # force use of the Bourne shell on machines such as SGI's

SHELL			= /bin/sh

  # ranlib, C compiler and source directory

RANLIB 			= @RANLIB@
CC       		= @CXX@
SOURCE_DIR		= @srcdir@

  # version information

LIB_VERSIONS_OK		= @LIB_VERSIONS_OK@
VERSION_SUFFIX		= @VERSION_SUFFIX@
TCL_VERSION_SUFFIX	= @TCL_VERSION_SUFFIX@

  # middle part of the library name

LIBMIDDLE		= agtcl

  # objects that go into the library

OBJS			= tclCryptCmd.o \
			  tclMaskCmd.o \
			  tclMain.o \
			  tclParse.o \
			  tclServerMain.o \
		  	  tclRandomCmd.o \
			  tclTimeCmd.o \
		  	  tclToolCmd.o \
			  tclBasic.o \
			  tclBlob.o \
			  tclBlobCmd.o \
			  tclConversion.o \
		  	  tclMask.o \
			  tclTime.o \
		  	  tclTool.o \
			  tclSecure.o \
			  tclRandom.o \
		  	  tclSecureCmd.o \
			  tclBasicCmd.o \
			  tclSafeInit.o \
			  tcpipBasic.o \
			  tcpipBasicCmd.o \
			  agentScript.o \
			  requireScript.o \
			  safetyScript.o \
			  ../generic-tcl/*.o \
		    	  ../restrict-tcl/*.o \
		  	  ../generic/*.o \
		  	  ../support/*.o \
		  	  ../messaging/*.o \
			  ../platform/common/*.o \
			  ../platform/unix/*.o

  # libraries on which the library depends

LIBS 	= -L../../lib -lagrand${VERSION_SUFFIX} \
  	  -L../../lib -lsttcl${TCL_VERSION_SUFFIX} $(BUILTIN_LIBS) @MATH_LIBS@ @CRYPT_LIBS@ @DL_LIBS@ @LIBS@ 

  # objects needed for the interpreter

INTERP_OBJS		= tclAppInit.o

  # additional libraries required for the interpreter

INTERP_LIBS		= -L../../lib -l${LIBMIDDLE}${VERSION_SUFFIX}

  # defines that are set by the "configure" script

DEFINES			= @DEFS@

  # shared libaries

LD_FLAGS		= @LD_FLAGS@
SHLIB_CFLAGS		= @SHLIB_CFLAGS@
SHLIB_LD		= @SHLIB_LD@
SHLIB_LD_LIBS		= @SHLIB_LD_LIBS@
SHLIB_SUFFIX		= @SHLIB_SUFFIX@
LD_SEARCH_FLAGS 	= @LD_SEARCH_FLAGS@
LIB_FILE		= @LIB_FILE@
LINK_FILE		= @LINK_FILE@
MAKE_LIB		= @MAKE_LIB@

  # include directories

INCLUDE_DIR		= -I${SOURCE_DIR} \
			  -I${SOURCE_DIR}/../tcl7.5/generic \
			  -I${SOURCE_DIR}/../tcl7.5/unix \
		  	  -I${SOURCE_DIR}/../support \
		  	  -I${SOURCE_DIR}/../messaging \
		  	  -I${SOURCE_DIR}/../generic \
		  	  -I${SOURCE_DIR}/../platform/include \
		  	  -I${SOURCE_DIR}/../generic-tcl \
		  	  -I${SOURCE_DIR}/../restrict-tcl \
			  -I${SOURCE_DIR}/../random

  # switches

CC_SWITCHES		= $(CFLAGS) $(SHLIB_CFLAGS) $(DEFINES) \
			  $(INCLUDE_DIR) \
			  -DLANGUAGE_NAME=\"${LANGUAGE_NAME}\"

../../bin/$(INTERP_NAME): ../../lib/${LIB_FILE} ${INTERP_OBJS}
	$(CC) ${CFLAGS} $(LD_FLAGS) ${INTERP_OBJS} ${INTERP_LIBS} ${LIBS} ${LD_SEARCH_FLAGS} -o ../../bin/$(INTERP_NAME) 

lib: ../../lib/${LIB_FILE}

../../lib/${LIB_FILE}: $(OBJS)
	rm -f ${LIB_FILE} 
	${MAKE_LIB} 
	$(RANLIB) ${LIB_FILE}
	rm -f ../../lib/lib${LIBMIDDLE}*
	mv ${LIB_FILE} ../../lib/${LIB_FILE}
	cd ../../lib; ln -s ${LIB_FILE} ${LINK_FILE} 

tclBasic.o: ${SOURCE_DIR}/tclBasic.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclBasic.cc

tclBasicCmd.o: ${SOURCE_DIR}/tclBasicCmd.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclBasicCmd.cc

tclBlob.o: ${SOURCE_DIR}/tclBlob.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclBlob.cc

tclBlobCmd.o: ${SOURCE_DIR}/tclBlobCmd.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclBlobCmd.cc

tclCryptCmd.o: ${SOURCE_DIR}/tclCryptCmd.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclCryptCmd.cc

tclMain.o: ${SOURCE_DIR}/tclMain.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclMain.cc

tclParse.o: ${SOURCE_DIR}/tclParse.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclParse.cc

tclServerMain.o: ${SOURCE_DIR}/tclServerMain.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclServerMain.cc

tclMask.o: ${SOURCE_DIR}/tclMask.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclMask.cc

tclMaskCmd.o: ${SOURCE_DIR}/tclMaskCmd.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclMaskCmd.cc

tclRandomCmd.o: ${SOURCE_DIR}/tclRandomCmd.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclRandomCmd.cc

tclRandom.o: ${SOURCE_DIR}/tclRandom.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclRandom.cc

tclSecure.o: ${SOURCE_DIR}/tclSecure.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclSecure.cc

tclSecureCmd.o: ${SOURCE_DIR}/tclSecureCmd.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclSecureCmd.cc

tclTime.o: ${SOURCE_DIR}/tclTime.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclTime.cc

tclTimeCmd.o: ${SOURCE_DIR}/tclTimeCmd.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclTimeCmd.cc

tclTool.o: ${SOURCE_DIR}/tclTool.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclTool.cc

tclToolCmd.o: ${SOURCE_DIR}/tclToolCmd.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclToolCmd.cc

tclAppInit.o: ${SOURCE_DIR}/tclAppInit.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclAppInit.cc

tclSafeInit.o: ${SOURCE_DIR}/tclSafeInit.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclSafeInit.cc

tcpipBasic.o: ${SOURCE_DIR}/tcpipBasic.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tcpipBasic.cc

tcpipBasicCmd.o: ${SOURCE_DIR}/tcpipBasicCmd.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tcpipBasicCmd.cc

agentScript.o: ${SOURCE_DIR}/agentScript.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/agentScript.cc

requireScript.o: ${SOURCE_DIR}/requireScript.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/requireScript.cc

safetyScript.o: ${SOURCE_DIR}/safetyScript.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/safetyScript.cc

tclConversion.o: ${SOURCE_DIR}/tclConversion.cc Makefile
	$(CC) $(CC_SWITCHES) -c ${SOURCE_DIR}/tclConversion.cc

depend:
	makedepend -- $(CC_SWITCHES) -- ${SOURCE_DIR}/*.cc

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