# Agent Tcl
# Bob Gray
# 2 October 1995
#
# This Makefile compiles the "agent-tk" interpreter.
#
# 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

  # X11_LIBS and X11_INCLUDES - set by "configure" but can be overridden

X11_LIBS		= @XLIBSW@
X11_INCLUDES		= @XINCLUDES@

  # CC, RANLIB and the 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@
TK_VERSION_SUFFIX	= @TK_VERSION_SUFFIX@

  # middle part of the library name

LIBMIDDLE		= agtk

  # objects that go into the library

OBJS			= tkBasicCmd.o tkMain.o

  # libraries on which the library depends

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

  # objects needed for the interpreter

INTERP_OBJS		= tkAppInit.o

  # additional libraries needed for the interpreter

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

  # defines that are set by "configure"

DEFINES			= @DEFS@ -DTK_LIBRARY=\"${TK_LIBRARY}\"
  
  # 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}/../tk4.1/generic \
                  	  -I${SOURCE_DIR}/../generic \
                  	  -I${SOURCE_DIR}/../platform/include \
                  	  -I${SOURCE_DIR}/../generic-tcl \
                  	  -I${SOURCE_DIR}/../tcpip-tcl \
                  	  -I${SOURCE_DIR}/../restrict-tcl \
		  	  -I${SOURCE_DIR}/../agent-tcl

  # switches

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

../../bin/$(INTERP_NAME): ../../lib/${LIB_FILE} $(INTERP_OBJS) 
	$(CC) $(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}

.SUFFIXES: .cc

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

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

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

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

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