# Generated automatically from Makefile.in by configure.
#
# Makefile for Expect
#

VERSION = \"4.8.2\"
SHORT_VERSION = 4.8

# Requires at least Tcl 6.5
# Known to work with up to Tcl 6.7

# While Tk is optional, if you do use Tk, it must be at least Tk 3.0
# Known to work with up to 3.2

srcdir 	= .
VPATH = .

######################################################################
# The following lines are things you may want to change
######################################################################

# Tcl include files.  (If you haven't installed Tcl yet, read the README file).
# This must point to the directory that contains ALL of Tcl's include
# files, not just the public ones.
TCLHDIR = $(srcdir)/../tcl

# Tcl library.  The following first tries ../tcl/libtcl.a and then -ltcl
TCLLIB = `if [ -f ../tcl/libtcl.a ]; then echo ../tcl/libtcl.a; else echo -ltcl; fi`
# If neither of these is sufficient, comment this out and use something like:
# TCLLIB = ../tcl/libtcl.a

# The following three defs are only nec. if you want to use Tk with Expect.
# Tk include files
TKHDIR = $(srcdir)/../tk
# Tk library
TKLIB = ../tk/libtk.a
# X11 include files
X11HDIR = # no X support on this system

# flags to pass to both cc and ld
# -O for production version
# -g for debuggable version
# -DTCL_DEBUGGER for enabling debugger
CFLAGS = -g -DTCL_DEBUGGER

# which C compiler to use
CC = cc

# By default, `make install' will install the appropriate files in
# /usr/local/bin, /usr/local/lib, /usr/local/man, etc.  You can specify
# an installation prefix other than /usr/local here:
prefix = /usr/local

# You can specify a separate installation prefix for architecture-specific
# files such as binaries and libraries.
exec_prefix = $(prefix)

# The following Expect scripts are not necessary to have installed as
# commands, but are very useful.  Edit out what you don't want installed.
# The INSTALL file describes these and others in more detail.
# Some Make's screw up if you delete all of them because SCRIPTS is a
# target.  If this is a problem, just comment out the SCRIPTS target itself.
SCRIPTS = timed-run timed-read ftp-rfc autopasswd robohunt lpunlock weather \
	passmass rftp kibitz rlogin-cwd xpstat
# A couple (well, one for now) of the scripts have man pages of their own.
# You can delete these too, if you don't want'em.
SCRIPTS_MANPAGES = kibitz

# Short directory path where expect binary can be found to support #! hack.
# This directory path can be the same as the directory in which the binary
# actually sits except when the path is so long that the #! mechanism breaks
# (usually at 32 characters).
# The solution is to create a directory with a very short name, which consists
# only of symbolic links back to the true binaries.  Subtracting two for "#!"
# and a couple more for arguments (typically " -f" or " --") gives you 27
# characters.  Pathnames over this length won't be able to use the #! magic.
# For more info on this, see the execve(2) man page.
SHORT_BINDIR = $(prefix)/bin

# If you have ranlib but it should be avoided, change this from "ranlib" #
# to something innocuous like "echo".  Known systems with this problem:
# older SCO boxes.
RANLIB = ranlib

# One of the following: select, poll, or simple
EVENT_TYPE = select
#
# You will need to change EVENT_TYPE to poll if your system is:
# NCR SVR4 (1.03.01), select is broken on ttys
# StarServer (SVR3 and SVR4.0), select is broken on ttys
#
# You will need to change EVENT_TYPE to simple if your system is:
# 3b2 SVR3, poll is unsupported on ptys
# old SCO system, selected is supported on ptys
#    If you do use "simple", please note:
# 1) you must also edit exp_conf.h and change
#    "#undef SIMPLE_EVENT" to "#define SIMPLE_EVENT",
# 2) you cannot use Expect with Tk since Tk's event manager insists on
#    reading all events through select, and
# 3) you cannot expect or interact with two or more processes simultaneously

######################################################################
# End of things you may want to change
#
# Do not change anything after this
######################################################################

bindir 	= $(exec_prefix)/bin
bindir_arch_indep = $(prefix)/bin
libdir 	= $(exec_prefix)/lib
tooldir = $(libdir)
datadir = $(prefix)/lib

mandir 	= $(prefix)/man
man1dir = $(mandir)/man1
man3dir = $(mandir)/man3
infodir = $(prefix)/info
includedir = $(prefix)/include
oldincludedir =
docdir = $(datadir)/doc

SHELL = /bin/sh

INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = /usr/bin/install -c
INSTALL_DATA = $(INSTALL) -m 644

AR = ar
ARFLAGS = cr

RUNTEST = runtest
RUNTESTFLAGS =

# X library
X11_LIB_FLAGS=
X11_LIB = nope
X11_PROGS = # no X support on this system

# expect must be setuid on crays in order to open ptys (and accordingly,
# you must run this Makefile as root).
# See the FAQ for more info on why this is necessary on Crays.
SETUID = @:
# SETUID = chmod u+s

SCRIPTDIR	= $(datadir)/expect

# Define default parameters for ptys.  This is used when 1) running in the
# background, 2) user has not defined the variable STTY_INIT to initialize
# ptys, and 3) the pty-driver's defaults suck.
# Use whatever format your local stty program likes.  
STTY=\"sane\"

PTY_TYPE = termios

CPPFLAGS =	-I. -I$(srcdir) -I$(TCLHDIR) -I$(TKHDIR) $(X11HDIR) \
		-DVERSION=$(VERSION) \
		-DDFLT_STTY=$(STTY) \
		-DSCRIPTDIR=\"$(SCRIPTDIR)/\"

#
# Flags to pass to cc (i.e. add to the end of the CFLAGS line below).
# Note that setting one will not set others automatically.  Set all that
# are relevant.
#
# NOTE THAT THESE FLAGS ARE NO LONGER SUPPORTED.  THE FUNCTIONALLY IS REPLACED
# BY THE AUTOMATIC CONFIGURATION CODE.  ONLY MESS WITH THE FOLLOWING DEFS IF
# YOU ARE POSITIVE THE AUTO CONFIG CODE IS FAILING.
# 
# -DNOWAITPID if your system doesn't have waitpid.  Only really old systems
#	lack this.
# -DSYSV3 if you are running SVR3 or later.
# -DSYSV4 if you are running SVR4.  This option does not preclude -DSYSV3.
# -DAUX2 if you are running Mac A/UX 2.
# -DUTS if you are on an Amdahl.
# -DSCO if you are running SCO Unix.
# -DMIPS_BSD if you are on a Mips machine using the BSD universe.
# -D_BSD_SIGNALS if you are on a Silicon Graphics AND want BSD semantics when
#	using the expect library.  Otherwise, you are better off just sticking
#	with rearming signals.
# -DNOSTDLIB if your system doesn't have /usr/include/stdlib.h.  If you don't
#	know, try without.  If you get bad declarations on malloc, then add.

# Flags to pass to ld (i.e., add to the end of the LIBS line below).
#
# -lc -lBSD     If you are using the BSD compatibility library on an HP/UX,
#		force libc.a to be loaded first.
# -lsocket	For SCO UNIX 3.2.2
#  /usr/ucblib/libucb.a is needed for solaris 2.0 after -lm
LIBS = -lm 

# If your "make" automatically includes CPPFLAGS in CC, use
#CFLAGS = $(CLFLAGS)
# else use following two lines 
# use these flags on an HP700 running hp-ux
#CFLAGS = $(CLFLAGS) $(CPPFLAGS) -DHPUX -DSYSV3 -DREARM_SIG
CFLAGS_INT = $(MH_CFLAGS) $(CPPFLAGS) $(CFLAGS)

.c.o:
	$(CC) -c $(CFLAGS_INT) $(HDEFS) $<

EVENT = exp_$(EVENT_TYPE)
PTY = pty_$(PTY_TYPE)
CFILES = $(srcdir)/exp_command.c $(srcdir)/expect.c $(srcdir)/$(PTY).c \
	$(srcdir)/exp_inter.c $(srcdir)/exp_regexp.c $(srcdir)/exp_tty.c \
	$(srcdir)/exp_log.c $(srcdir)/exp_main_sub.c $(srcdir)/exp_pty.c \
	$(srcdir)/exp_printify.c $(srcdir)/Dbg.c
OFILES = exp_command.o expect.o $(PTY).o exp_inter.o exp_regexp.o exp_tty.o \
	exp_log.o exp_main_sub.o exp_pty.o exp_printify.o Dbg.o
LIBCFILES = $(srcdir)/lib_exp.c $(srcdir)/lib_string.c $(srcdir)/lib_debug.c
LIBOFILES = lib_exp.o lib_string.o lib_debug.o
LIBEXPECT = libexpect.a
LIBEXPTCL = libexptcl.a
LIBEXPTK  = libexptk.a

all: expect $(LIBEXPECT) $(LIBEXPTCL) ${X11_PROGS}
# exp_test

info:
dvi:

expect:	$(OFILES) exp_main_exp.o $(EVENT).o
	$(CC) $(CFLAGS) -o expect $(OFILES) exp_main_exp.o $(EVENT).o $(LIBS) $(TCLLIB)
	$(SETUID) expect

expectk:        $(OFILES) exp_main_tk.o exp_tk.o
	$(CC) $(CLFLAGS) -o expectk $(OFILES) exp_main_tk.o exp_tk.o $(TKLIB) $(TCLLIB) $(X11_LIB_FLAGS) $(X11_LIB) $(LIBS) 
	$(SETUID) expectk

exp_test: $(srcdir)/exp_test.c
	$(CC) $(CFLAGS) $(srcdir)/exp_test.c -o exp_test

Makefile : $(srcdir)/Makefile.in $(host_makefile_frag)
	$(SHELL) config.status

$(LIBEXPECT): $(LIBOFILES)
	$(AR) $(ARFLAGS) $(LIBEXPECT) $(LIBOFILES)
	-$(RANLIB) $(LIBEXPECT)

$(LIBEXPTCL): $(OFILES) $(EVENT).o
	$(AR) $(ARFLAGS) $(LIBEXPTCL) $(OFILES) $(EVENT).o
	-$(RANLIB) $(LIBEXPTCL)

$(LIBEXPTK): $(OFILES) exp_tk.o
	$(AR) $(ARFLAGS) $(LIBEXPTK) $(OFILES) exp_tk.o
	-$(RANLIB) $(LIBEXPTK)

install-info:
install:	expect ${X11_PROGS} $(LIBEXPECT) $(SCRIPTS)
# install Expect
	-parent=`echo $(bindir)|sed -e 's@/[^/]*$$@@'`; \
	if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi
	-if [ -d $(bindir) ] ; then true ; else mkdir $(bindir) ; fi
	$(INSTALL_PROGRAM) expect $(bindir)/expect
# install Expect man page
	-parent=`echo $(man1dir)|sed -e 's@/[^/]*$$@@'`; \
	if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi
	-if [ -d $(man1dir) ] ; then true ; else mkdir $(man1dir) ; fi
	$(INSTALL_DATA) $(srcdir)/expect.man $(man1dir)/expect.1
# install Expect library
	-parent=`echo $(libdir)|sed -e 's@/[^/]*$$@@'`; \
	if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi
	-if [ -d $(libdir) ] ; then true ; else mkdir $(libdir) ; fi
	$(INSTALL_DATA) libexpect.a $(libdir)/libexpect.a.n
	-$(RANLIB) $(libdir)/libexpect.a.n
	mv -f $(libdir)/libexpect.a.n $(libdir)/libexpect.a
# install Expect library man page
	-parent=`echo $(man3dir)|sed -e 's@/[^/]*$$@@'`; \
	if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi
	-if [ -d $(man3dir) ] ; then true ; else mkdir $(man3dir) ; fi
	$(INSTALL_DATA) $(srcdir)/libexpect.man $(man3dir)/libexpect.3
# install Expect library include file
	-parent=`echo $(includedir)|sed -e 's@/[^/]*$$@@'`; \
	if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi
	-if [ -d $(includedir) ] ; then true ; else mkdir $(includedir) ; fi
	$(INSTALL_DATA) $(srcdir)/expect.h $(includedir)/expect.h
# ditto but for Expect-Tcl library if present
	-if [ -s $(LIBEXPTCL) ] ; then \
		$(INSTALL_DATA) $(LIBEXPTCL) $(libdir)/$(LIBEXPTCL).n ; \
		$(RANLIB) $(libdir)/$(LIBEXPTCL).n 2>>/dev/null ; \
		mv -f $(libdir)/$(LIBEXPTCL).n $(libdir)/$(LIBEXPTCL) ; \
		$(INSTALL_DATA) $(srcdir)/libexptcl.man $(man3dir)/libexptcl.3 ; \
	fi
# ditto but for Expectk
	-if [ -x expectk ] ; then \
		$(INSTALL_PROGRAM) expectk $(bindir)/expectk ; \
	fi
# ditto but for Expect-Tk library if present
	-if [ -s $(LIBEXPTK) ] ; then \
		$(INSTALL_DATA) $(LIBEXPTK) $(libdir)/$(LIBEXPTK).n ; \
		$(RANLIB) $(libdir)/$(LIBEXPTK).n 2>>/dev/null ; \
		mv -f $(libdir)/$(LIBEXPTK).n $(libdir)/$(LIBEXPTK) ; \
		$(INSTALL_DATA) $(srcdir)/libexptk.man $(man3dir)/libexptk.3 ; \
	fi
# create utility-script directory
	-parent=`echo $(SCRIPTDIR)|sed -e 's@/[^/]*$$@@'`; \
	if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi
	-if [ -d $(SCRIPTDIR) ] ; then true ; else mkdir $(SCRIPTDIR) ; fi
# install standalone scripts and their man pages, if requested
	-if [ -n "$(SCRIPTS)" ] ; then \
		for i in $(SCRIPTS) ; do \
		  if [ -f $$i ] ; then \
		    $(INSTALL_PROGRAM) $$i $(bindir_arch_indep)/$$i ; \
		    chmod a+x $(bindir_arch_indep)/$$i ; \
		    rm $$i ; \
		  fi ; \
		done ; \
	fi
	-if [ -n "$(SCRIPTS_MANPAGES)" ]; then \
		for file in "$(SCRIPTS_MANPAGES)" ; do \
 		  if [ -f $$file ] ; then \
			$(INSTALL_DATA) $(srcdir)/example/$$file.man $(man1dir)/$$file.1 ; \
 		  fi ; \
		done ; \
	fi

$(SCRIPTS):
	./expect $(srcdir)/fixline1 $(SHORT_BINDIR) < $(srcdir)/example/$@ > $@

clean:
	-rm -f *~ *.o core expect expectk dumb exho devtty *.a exp_test

check:	all exp_test
	rootme=`pwd`; export rootme; \
	$(RUNTEST) $(RUNTESTFLAGS) --tool expect EXPECT=$$rootme/expect \
		--srcdir $(srcdir)/testsuite

distclean: clean
	-rm -f Makefile config.status exp_conf.h

configure: configure.in
	-@mv -f configure configure.bak
	autoconf configure.in > configure
	-@chmod a+x configure

LINTFLAGS = -h -q -x 

lint:
	lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) $(TCLLINTLIB) | tee expect.lint
	lint $(LINTFLAGS) $(CPPFLAGS) $(LIBCFILES) | tee libexpect.lint

# Following target builds expect under CodeCenter.
exp:	$(CFILES) exp_main_exp.c $(EVENT).c
	#load $(CPPFLAGS) $(CFILES) exp_main_exp.c $(EVENT).c $(TCLLIB) $(LIBS)

# Following target builds expectk under CodeCenter.  Notes:
# Because of explicit #includes of <X11/...> in tk.h, you need to create
# a symlink from your X11 include directory to this directory
tk:     $(CFILES) exp_main_tk.c exp_tk.c
	#load $(CPPFLAGS) $(CFILES) exp_main_tk.c exp_tk.c $(TKLIB) $(TCLLIB) $(X11_LIB) $(LIBS)

# Follow definitions are for building expect and expectk under ObjectCenter
oexp:   $(CFILES) exp_main_exp.c $(EVENT).c
	#load $(CPPFLAGS) -C $(CFILES) exp_main_exp.c $(EVENT).c $(TCLLIB)

otk:    $(CFILES) exp_main_tk.c exp_tk.c
	#load $(CPPFLAGS) -C $(CFILES) exp_main_tk.c exp_tk.c $(TKLIB)

FTPDIR = /proj/elib/online/pub/expect

# make a private tar file for myself
tar:	expect-$(SHORT_VERSION).tar
	mv expect-$(SHORT_VERSION).tar expect.tar

# make a public tar file and install it on ftp server
ftp:	expect-$(SHORT_VERSION).tar.Z expect-$(SHORT_VERSION).tar.gz
	cp expect-$(SHORT_VERSION).tar.Z $(FTPDIR)/expect.tar.Z
	cp expect-$(SHORT_VERSION).tar.gz $(FTPDIR)/expect.tar.gz
	cp HISTORY $(FTPDIR)
	rm expect-$(SHORT_VERSION).tar*
	ls -l $(FTPDIR)/expect.tar*

expect-$(SHORT_VERSION).tar:
	rm -f ../expect-$(SHORT_VERSION)
	ln -s `pwd` ../expect-$(SHORT_VERSION)
	rm -f ../pubfile
	ln pubfile ..
	cd ..;tar cvf expect-$(SHORT_VERSION).tar `pubfile expect-$(SHORT_VERSION)`
	mv ../expect-$(SHORT_VERSION).tar .

expect-$(SHORT_VERSION).tar.Z:	expect-$(SHORT_VERSION).tar
	compress -fc expect-$(SHORT_VERSION).tar > $@

expect-$(SHORT_VERSION).tar.gz:	expect-$(SHORT_VERSION).tar
	gzip -fc expect-$(SHORT_VERSION).tar > $@

expect.o:	$(srcdir)/exp_global.h $(srcdir)/exp_command.h exp_conf.h
exp_main_exp.o:	$(srcdir)/exp_global.h exp_conf.h
exp_command.o:	$(srcdir)/exp_global.h $(srcdir)/exp_command.h exp_conf.h
$(EVENT).o:	$(srcdir)/exp_global.h $(srcdir)/exp_command.h exp_conf.h
$(PTY).o:	$(srcdir)/exp_tty.h $(srcdir)/exp_rename.h exp_conf.h
