Makefile.in   [plain text]


#
# Makefile for Expect
#

# Requires at least Tcl 7.5
# Known to work with up to Tcl 7.5

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

VERSION_FULL = \"@EXP_VERSION_FULL@\"
# Tcl's tclConfig requires VERSION have a short-style version string.
VERSION = @EXP_VERSION@

srcdir = @srcdir@
VPATH = @srcdir@
SUBDIRS = @subdirs@

EXEEXT = @EXEEXT@

######################################################################
# 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 = @TCLHDIR@
ITCLHDIR = @ITCLHDIR@
TCLHDIRDASHI = @TCLHDIRDASHI@
# Tcl's Tcl library (definitions of parray, etc)
TCL_LIBRARY = @TCL_LIBRARY@

# Tcl library uninstalled.  Should be something like -ltcl or ../tcl/libtcl.a
TCLLIB = @TCL_BUILD_LIB_SPEC@
ITCLLIB = @ITCLLIB@
# Tcl library installed.  Should be something like -ltcl or ../tcl/libtcl.a
TCLLIB_INSTALLED = @TCL_LIB_SPEC@

# The following definitions are only nec. if you want to use Tk with Expect.
# Tk include files
TKHDIR = @TKHDIR@
TKHDIRDASHI = @TKHDIRDASHI@

# Tk library
TKLIB = @TK_BUILD_LIB_SPEC@
TKLIB_INSTALLED = @TK_LIB_SPEC@

# X11 include files and other flags to compiler
X11_CFLAGS = @TK_XINCLUDES@
# X library
X11_LD_FLAGS =
# XXX Temporarily commented out until expectk is working again.
#X11_PROGS = @X_PROGS@
# X11_PROGS_INSTALLED should really be a separate symbol generated by configure but we're
# hitting configure's limit on substitutions, so be crude and use one less symbol.
# XXX Temporarily commented out until expectk is workign again.
#X11_PROGS_INSTALLED = @X_PROGS@

# Flags to pass to both cc and ld
# You should be able to leave this just the way it is.  However, here are some
# note if you run into problems:
#
# Avoid -O (optimize) unless you are convinced your optimizer is flawless
# (hint: not a chance).  I have heard many reports of -O causing Expect to
# misbehave.
# I encourage you to use -g (debugging).  While it is unlikely you will
# encounter an internal error in Expect, should this happen, I may just need
# the -g information and then you will need to recompile Expect.  As an aside,
# Expect is not a space or time pig, so this won't affect the performance of
# your Expect scripts.
# Note: On Linux systems which only have dynamic X libraries, the -g prevents
# the linker from using them.  So do not use -g on such systems.
# From now on, CFLAGS is never used.  Instead, use XCFLAGS.  This is done so
# that we can provide a public interface for CFLAGS thereby allowing users
# to add to it on the Make command-line and still get the rest of the flags
# computed by configure.  Do this at your own risk - it obvious goes against
# the idea of configure's interface, however this is established tradition
# at some sites (e.g., Cygnus)!
CFLAGS = @CFLAGS@
XCFLAGS = $(CFLAGS) @EXP_CFLAGS@ @EXP_SHLIB_CFLAGS@ 
#XCFLAGS = @CFLAGS@ @EXP_CFLAGS@ @EXP_SHLIB_CFLAGS@ 
XCFLAGS = @CFLAGS@ @EXP_CFLAGS@

# Flags to pass only to linker (after .o files but before libraries)
LDFLAGS = @EXP_LDFLAGS@

# Which C compiler to use.  For simplicity, we inherit the same definition
# used when Tcl was compiled.  Changing this definition here can screw up
# deductions that the configure script made on the assumption that you were
# using a different compiler. 
CC = @CC@

# By default, "make install" will install the appropriate files in
# /usr/local/bin, /usr/local/lib, /usr/local/man, etc.  By changing this
# variable, you can specify an installation prefix other than /usr/local.
# You may find it preferable to call configure with the --prefix option
# to control this information.  This is especially handy if you are
# installing Expect several times (perhaps on a number of machines or
# in different places).  Then you don't have to hand-edit this file.
# See the INSTALL file for more information.  (Analogous information
# applies to the next variable as well.)
prefix = @prefix@

# You can specify a separate installation prefix for architecture-specific
# files such as binaries and libraries.
exec_prefix = @exec_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 lpunlock weather \
	passmass rftp kibitz rlogin-cwd xpstat tkpasswd dislocate xkibitz \
	tknewsbiff unbuffer mkpasswd cryptdir decryptdir autoexpect
# A couple of the scripts have man pages of their own.
# You can delete these too if you don't want'em.
SCRIPTS_MANPAGES = kibitz dislocate xkibitz tknewsbiff unbuffer mkpasswd \
	passmass cryptdir decryptdir autoexpect

# Short directory path where 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 = @bindir@

# 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 = @TCL_RANLIB@
UNSHARED_RANLIB = @UNSHARED_RANLIB@

# Change EVENT_ABLE to "noevent" if your system is:
# old SCO	because poll doesn't exist and select is broken on ptys
# 3b2 SVR3	because select doesn't exist and poll is broken on ptys
#    If you do use "noevent":
# 1) you must also edit expect_cf.h and change
#    "#undef SIMPLE_EVENT" to "#define SIMPLE_EVENT",
# 2) you cannot use any event facilities such as "after" or anything in Tk.
# 3) you cannot expect or interact with two or more processes simultaneously
#
EVENT_ABLE = @EVENT_ABLE@

# Change EVENT_TYPE to poll if your system is:
# NCR SVR4 (1.03.01)			where select is broken on ttys
# StarServer (SVR3 and SVR4.0)		where select is broken on ttys
#
# You will need to change EVENT_TYPE to select if your system is:
# Pyramid OSx in the att universe	where poll is broken (see LIBS below)
#
EVENT_TYPE = @EVENT_TYPE@

# 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.
#
# If your system doesn't understand "sane", try "cooked".  Apollo systems
# need nothing at all and should delete this line.  Systems using 8-bit
# character sets may need to disable parity.
# Systems that define sane to use @ as line kill and # as erase should
# use something like "sane kill  erase ".
STTY = -DDFLT_STTY="\"@DEFAULT_STTY_ARGS@\""

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

bindir = @bindir@
bindir_arch_indep = $(prefix)/bin
libdir 	= @libdir@/expect$(VERSION)
tcl_libdir = @libdir@
# CYGNUS LOCAL: use datadir, not $(prefix)/lib.
libdir_arch_indep = @datadir@
# END CYGNUS LOCAL

mandir 	= @mandir@
man1dir = $(mandir)/man1
man3dir = $(mandir)/man3
infodir = @infodir@
includedir = @includedir@

# Expect's utility script directories - arch-independent and arch-non-
# independent.  These correspond to the variables "exp_library" and
# "exp_exec_library".
SCRIPTDIR	= $(libdir_arch_indep)
EXECSCRIPTDIR	= $(libdir)

SHELL = @EXP_CONFIG_SHELL@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

AR = ar
ARFLAGS = cr

LOCAL_EXPECT=LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH ./expect$(EXEEXT)

# These definitions are used by the "subdirs_do" target to pass
# the compile flags down recursively.
FLAGS_TO_PASS = \
	"CC=$(CC)" \
	"CFLAGS=$(XCFLAGS)" \
	"CFLAGS_INT=$(CFLAGS_INT)" \
	"HDEFS=$(HDEFS)" \
	"INSTALL=$(INSTALL)" \
	"INSTALL_DATA=$(INSTALL_DATA)" \
	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
	"LDFLAGS=$(LDFLAGS)" \
        "RUNTEST=$(RUNTEST)" \
        "RUNTESTFLAGS=$(RUNTESTFLAGS)" \
        "SHLIB_CFLAGS=$(@EXP_SHLIB_CFLAGS@)" \
	"prefix=$(prefix)" \
	"exec_prefix=$(exec_prefix)"

#
# Following defines are for DejaGnu
#

# These let the DejaGnu test suite run when DejaGnu isn't 
# installed yet, so run it from the srcdir and objdir.
EXPECT = ` \
  if [ -f $${rootme}/expect$(EXEEXT) ] ; then \
    echo $${rootme}/expect$(EXEEXT) ; \
  else echo expect ; fi`

RUNTESTFLAGS =
RUNTEST = ` \
  if [ -f ${srcdir}/../dejagnu/runtest$(EXEEXT) ] ; then \
    echo ${srcdir}/../dejagnu/runtest$(EXEEXT) ; \
  else echo runtest ;  fi`

PTY_TYPE = @PTY_TYPE@
PTY = pty_$(PTY_TYPE)
CFILES = exp_command.c expect.c $(PTY).c \
	exp_inter.c exp_regexp.c exp_tty.c \
	exp_log.c exp_main_sub.c exp_pty.c \
	exp_printify.c exp_trap.c exp_strf.c \
	exp_console.c exp_glob.c exp_win.c Dbg.c exp_clib.c \
	exp_closetcl.c exp_memmove.c exp_tty_comm.c \
	exp_$(EVENT_TYPE).c exp_$(EVENT_ABLE).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 exp_trap.o \
	exp_console.o exp_strf.o exp_glob.o exp_win.o Dbg.o exp_clib.o \
	exp_closetcl.o exp_memmove.o exp_tty_comm.o \
	exp_$(EVENT_TYPE).o exp_$(EVENT_ABLE).o
SHARED_OFILES = shared/exp_command.o shared/expect.o shared/$(PTY).o \
        shared/exp_inter.o shared/exp_regexp.o shared/exp_tty.o \
        shared/exp_log.o shared/exp_main_sub.o shared/exp_pty.o \
        shared/exp_printify.o shared/exp_trap.o \
        shared/exp_console.o shared/exp_strf.o shared/exp_glob.o \
        shared/exp_win.o shared/Dbg.o shared/exp_clib.o \
        shared/exp_closetcl.o shared/exp_memmove.o shared/exp_tty_comm.o \
        shared/exp_$(EVENT_TYPE).o shared/exp_$(EVENT_ABLE).o

# Expect libraries (both .a and shared)
EXP_LIB_FILES = @EXP_LIB_FILES@
# default Expect library (shared if possible, otherwise static)
EXP_LIB_FILE = @EXP_LIB_FILE@
# Expect object library (.a)
EXP_UNSHARED_LIB_FILE = @EXP_UNSHARED_LIB_FILE@
# Expect object library (shared, if possible)
EXP_SHARED_LIB_FILE = @EXP_SHARED_LIB_FILE@

# 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@
# SETUID = chmod u+s

# allow us to handle null list gracefully, "end_of_list" should not exist
SCRIPT_LIST = $(SCRIPTS) end_of_list
SCRIPT_MANPAGE_LIST = $(SCRIPTS_MANPAGES) end_of_list

# flags to pass only to the C compiler (not to ld)
# because STTY can include whitespace and quotes, pass STTY separately
CPPFLAGS = -I. -I$(srcdir) $(TCLHDIRDASHI) $(TKHDIRDASHI) $(X11_CFLAGS) \
		-DEXP_VERSION=\"$(VERSION)\" \
		-DSCRIPTDIR=\"$(SCRIPTDIR)\" \
		-DEXECSCRIPTDIR=\"$(EXECSCRIPTDIR)\" \
		-DTCL_DEBUGGER

# Flags to pass to cc (i.e. add to the end of the CLDFLAGS 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.
# 
# -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.
# -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.

# Flags to pass to ld
# You may need to add additional ones 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 (this should now be done automatically)
# -lX11		For Pyramid OSx, poll is broken, so use select from X lib
#  /usr/ucblib/libucb.a is needed for solaris 2.0 after -lm
EXP_AND_TCL_LIBS = $(LDFLAGS) @EXP_AND_TCL_LIBS@
EXP_AND_TK_LIBS = $(LDFLAGS) @EXP_AND_TK_LIBS@

CFLAGS_INT = $(MH_CFLAGS) $(CPPFLAGS) $(XCFLAGS)

LIB_INSTALL_DIR = $(tcl_libdir)
LIB_RUNTIME_DIR = $(tcl_libdir)
# I don't understand why Tcl splits these up, but it does.  LIB_RUNTIME_DIR
# can appear as part of the LD_SEARCH_FLAGS inherited by configure.

.c.o:
	$(CC) -c $(CFLAGS_INT) $(STTY) $(HDEFS) $<
	if [ "@EXP_SHLIB_CFLAGS@" != "x" ] ; then \
	   if [ ! -d shared ] ; then \
                mkdir shared ; \
           else true; fi ; \
           $(CC) -c $(CFLAGS_INT) @EXP_SHLIB_CFLAGS@ $(STTY) $(HDEFS) $< -o shared/$@ ; \
        fi


all: expect$(EXEEXT) $(EXP_LIB_FILES) ${X11_PROGS}
	@$(MAKE) subdir_do DO=$@  $(FLAGS_TO_PASS)

info:
dvi:

# CYGNUS LOCAL aoliva
LOCAL_EXPECT=$(SHELL) ./expect-bld.sh
all: expect-bld.sh
# Run expect within the build tree
expect-bld.sh: Makefile
	-rm -f $@ $@T
	echo "#! $(SHELL)" > $@T
	r=`pwd`; for var in LD_LIBRARY_PATH SHLIB_PATH ; do \
	  echo "$$var=$$r:$$r/../tk/unix:$$r/../tcl/unix\$${$$var+:\$$$$var}; export $$var" >> $@T ; \
	done; echo "exec $$r/expect \$${1+\"\$$@\"}" >> $@T
	chmod +x $@T
	mv $@T $@
# END CYGNUS LOCAL

# build expect binary that does not depend on Expect's shared libs
expect$(EXEEXT): exp_main_exp.o $(EXP_UNSHARED_LIB_FILE)
	$(CC) $(XCFLAGS) @TCL_LD_FLAGS@ -o expect$(EXEEXT) exp_main_exp.o @EXP_BUILD_LIB_SPEC@ $(TCLLIB) $(EXP_AND_TCL_LIBS)
	$(SETUID) expect$(EXEEXT)

expecti$(EXEEXT): exp_main_exp.c $(EXP_UNSHARED_LIB_FILE)
	$(CC) $(CFLAGS_INT) $(STTY) $(HDEFS) $(ITCLHDIR) $(XCFLAGS) @TCL_LD_FLAGS@ -o expecti$(EXEEXT) -DUSE_ITCL $(srcdir)/exp_main_exp.c @EXP_BUILD_LIB_SPEC@ $(TCLLIB) $(ITCLLIB) $(EXP_AND_TCL_LIBS)

# install Expect library
# This is done before the install target because the libraries have to be
# in place before the installed expect is built.  Actually, only the shared
# lib has to be handled this way, but do both here for consistency.
# Can't seem to embed shell comments in backslashed lines, so comments here:
# - To allow bare "load" commands, install shared libs in tcl_libdir rather
#   than Expect's lib-specific directory (libdir).
# - install hand-generated pkgIndex.tcl file.
#   Local copy is pkgIndex rather than pkgIndex.tcl because pkgIndex.tcl.in
#   is too long for some filesystems, sigh.
install_shared_lib: $(EXP_LIB_FILES)
	${srcdir}/mkinstalldirs $(libdir)
	if [ -s $(EXP_UNSHARED_LIB_FILE) ] ; then \
	  $(INSTALL_DATA) $(EXP_UNSHARED_LIB_FILE) $(libdir)/$(EXP_UNSHARED_LIB_FILE) ; \
	$(UNSHARED_RANLIB) $(libdir)/$(EXP_UNSHARED_LIB_FILE) ; \
	$(INSTALL_DATA) $(EXP_UNSHARED_LIB_FILE) $(tcl_libdir)/$(EXP_UNSHARED_LIB_FILE) ; \
	$(UNSHARED_RANLIB) $(tcl_libdir)/$(EXP_UNSHARED_LIB_FILE) ; \
	else true; fi
	if [ -s $(EXP_SHARED_LIB_FILE) ] ; then \
	  $(INSTALL_PROGRAM) $(EXP_SHARED_LIB_FILE) $(tcl_libdir)/$(EXP_SHARED_LIB_FILE) ; \
	  $(INSTALL_PROGRAM) pkgIndex $(libdir)/pkgIndex.tcl ; \
	else true; fi

expect_installed$(EXEEXT): exp_main_exp.o $(EXP_LIB_FILE) install_shared_lib
	$(CC) $(XCFLAGS) @EXP_SHLIB_CFLAGS@ @TCL_LD_FLAGS@ -o expect_installed$(EXEEXT) exp_main_exp.o @EXP_LIB_SPEC@ $(TCLLIB_INSTALLED) $(EXP_AND_TCL_LIBS)
	$(SETUID) expect_installed$(EXEEXT)

# Build Expect with TestCenter
expect.tc$(EXEEXT): exp_main_exp.o $(OFILES) 
	proof $(CC) $(XCFLAGS) @EXP_SHLIB_CFLAGS@ @TCL_LD_FLAGS@ -o expect.tc$(EXEEXT) $(OFILES) exp_main_exp.o $(TCLLIB) $(EXP_AND_TCL_LIBS) 
	$(SETUID) expect.tc$(EXEEXT)

# Build an executable with both Expect and Tk.
# Yes, I know that the link line can have libraries repeated.  This is a
# consequence of Tcl's configure combining the Tcl and X dependent libs
# together.  I could fix it by testing all the libraries (again, in Expect's
# configure) separately for Expectk, but as far as I know, it doesn't hurt
# anything here, so I'm not worrying about it.
expectk$(EXEEXT): exp_main_tk.o $(EXP_UNSHARED_LIB_FILE)
	$(CC) $(XCFLAGS) @TCL_LD_FLAGS@ -o expectk$(EXEEXT) exp_main_tk.o @EXP_UNSHARED_LIB_SPEC@ $(TKLIB) $(TCLLIB) $(X11_LD_FLAGS) $(EXP_AND_TK_LIBS) 
	$(SETUID) expectk$(EXEEXT)

expectk_installed$(EXEEXT): exp_main_tk.o $(EXP_LIB_FILE)
	$(CC) $(XCFLAGS) @EXP_SHLIB_CFLAGS@ @TCL_LD_FLAGS@ -o expectk_installed$(EXEEXT) exp_main_tk.o @EXP_LIB_SPEC@ $(TKLIB_INSTALLED) $(TCLLIB_INSTALLED) $(X11_LD_FLAGS) $(EXP_AND_TK_LIBS) 
	$(SETUID) expectk_installed$(EXEEXT)

# Build Expectk with TestCenter
expectk.tc$(EXEEXT): exp_main_tk.o $(OFILES) 
	proof $(CC) $(XCFLAGS) @TCL_LD_FLAGS@ -o expectk.tc$(EXEEXT) $(OFILES) exp_main_tk.o $(TKLIB) $(TCLLIB) $(X11_LD_FLAGS) $(EXP_AND_TK_LIBS) 
	$(SETUID) expectk.tc$(EXEEXT)

$(EXP_UNSHARED_LIB_FILE): $(OFILES)
	-rm -f $(EXP_UNSHARED_LIB_FILE)
	$(AR) $(ARFLAGS) $(EXP_UNSHARED_LIB_FILE) $(OFILES)
	-$(RANLIB) $(EXP_UNSHARED_LIB_FILE)

# the dependency should really be SHARED_OFILES rather than OFILES
# but there's no way to write a rule that says shared/XYZ.o should
# depend on XYZ.c in a different directory (except by writing the
# rule out for each file, sigh).
$(EXP_SHARED_LIB_FILE): $(OFILES)
	-rm -f $(EXP_SHARED_LIB_FILE)
	@TCL_SHLIB_LD@ -o $(EXP_SHARED_LIB_FILE) $(SHARED_OFILES) @EXP_LD_SEARCH_FLAGS@ @EXP_SHLIB_LD_LIBS@

.PHONY: install-info install info
install-info:

# CYGNUS LOCAL: minimal/angela
install-minimal: expect$(EXEEXT) pkgIndex
	${srcdir}/mkinstalldirs $(man1dir) $(bindir)
# install Expect
	$(INSTALL_PROGRAM) expect$(EXEEXT) $(bindir)/expect$(EXEEXT)
# install Expect man page
	$(INSTALL_DATA) $(srcdir)/expect.man $(man1dir)/expect.1
# END CYGNUS LOCAL

install: expect$(EXEEXT) expect_installed$(EXEEXT) ${X11_PROGS_INSTALLED} pkgIndex install_shared_lib
	${srcdir}/mkinstalldirs $(man1dir) $(man3dir) $(bindir) $(libdir) $(includedir)
# install Expect
	$(INSTALL_PROGRAM) expect_installed$(EXEEXT) $(bindir)/expect$(EXEEXT)
# install Expectk (and man page) if present
	-if [ -s expectk_installed$(EXEEXT) ] ; then \
	  $(INSTALL_PROGRAM) expectk_installed$(EXEEXT) $(bindir)/expectk$(EXEEXT) ; \
	  $(INSTALL_DATA) $(srcdir)/expectk.man $(man1dir)/expectk.1 ; \
	else true; fi
# install Expect man page
	$(INSTALL_DATA) $(srcdir)/expect.man $(man1dir)/expect.1
# install man page for Expect and Expectk libraries
	$(INSTALL_DATA) $(srcdir)/libexpect.man $(man3dir)/libexpect.3
# install Expect's public include files
#	$(INSTALL_DATA) expect_cf.h $(includedir)
	$(INSTALL_DATA) $(srcdir)/expect.h $(includedir)
	$(INSTALL_DATA) $(srcdir)/expect_tcl.h $(includedir)
	$(INSTALL_DATA) $(srcdir)/expect_comm.h $(includedir)
# force installation of Tcl's private regexp definition - we simply have to
# make it public in order for people to use Expect's C lib.
	$(INSTALL_DATA) $(TCLHDIR)/tclRegexp.h $(includedir)
# install Debugger's public include file (just in case it's not there)
	$(INSTALL_DATA) $(srcdir)/Dbg.h $(includedir)

install-scripts: $(SCRIPTS)
# some people don't install Tcl, sigh
	TCL_LIBRARY=$(TCL_LIBRARY) ; \
	   export TCL_LIBRARY ; \
	   if $(LOCAL_EXPECT) $(srcdir)/fixcat ; then \
	      $(INSTALL_DATA) $(srcdir)/fixcat $(EXECSCRIPTDIR)/cat-buffers ; \
	   else true; fi
# install standalone scripts and their man pages, if requested
	${srcdir}/mkinstalldirs $(bindir_arch_indep) $(man1dir) $(SCRIPTDIR) $(EXECSCRIPTDIR)
	-for i in $(SCRIPT_LIST) ; do \
	  if [ -f $$i ] ; then \
	    $(INSTALL_PROGRAM) $$i $(bindir_arch_indep)/$$i ; \
	    rm -f $$i ; \
	  else true; fi ; \
	done
	-for i in $(SCRIPT_MANPAGE_LIST) ; do \
	  if [ -f $(srcdir)/example/$$i.man ] ; then \
	    $(INSTALL_DATA) $(srcdir)/example/$$i.man $(man1dir)/$$i.1 ; \
	  else true; fi ; \
	done
	$(INSTALL_DATA) pkgIndex.tcl $(SCRIPTDIR)

$(SCRIPT_LIST):
	TCL_LIBRARY=$(TCL_LIBRARY) ; \
	export TCL_LIBRARY ; \
	$(LOCAL_EXPECT) $(srcdir)/fixline1 $(SHORT_BINDIR) < $(srcdir)/example/$@ > $@

# Delete all the installed files that the `install' target creates
# (but not the noninstalled files such as `make all' creates)
uninstall:
	-rm -f  $(bindir)/expectk \
	        $(man1dir)/expect.1 \
	        $(man1dir)/expectk.1 \
	        $(libdir)/$(EXP_SHARED_LIB_FILE) \
	        $(tcl_libdir)/$(EXP_SHARED_LIB_FILE) \
	        $(libdir)/$(EXP_UNSHARED_LIB_FILE) \
	        $(tcl_libdir)/$(EXP_UNSHARED_LIB_FILE) \
	        $(man3dir)/libexpect.3 \
	        $(includedir)/expect_cf.h \
	        $(includedir)/expect.h \
	        $(includedir)/expect_tcl.h \
	        $(includedir)/expect_comm.h \
	        $(EXECSCRIPTDIR)/cat-buffers
# debugger is not removed, since other things could depend on it
# remove standalone scripts and man pages
	-for i in $(SCRIPT_LIST) ; do \
          rm -f $(bindir_arch_indep)/$$i ; \
        done
	-for i in $(SCRIPT_MANPAGE_LIST) ; do \
          rm -f $(man1dir)/$$i.1 ; \
        done

###################################
# Targets for Makefile and configure
###################################

Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) config.status
	@echo "Rebuilding the Makefile..."
	$(SHELL) ./config.status

# CYGNUS LOCAL: Don't have dependancies, cause people get upset
# when autoconf gets run automatically.
#configure: $(srcdir)/configure.in $(srcdir)/Makefile.in \
#               $(srcdir)/expect_cf.h.in $(srcdir)/aclocal.m4
# Let "make -f Makefile.in" produce a configure file
configure:
	@echo "Rebuilding configure..."
	if [ x"${srcdir}" = x"@srcdir@" ] ; then \
	  srcdir=. ; export srcdir ; \
	else true ; fi ; \
	(cd $${srcdir}; autoconf)

config.status: $(srcdir)/configure
	@echo "Rebuilding config.status..."
	$(SHELL) ./config.status --recheck

check:
	@if [ -f testsuite/Makefile ]; then \
	   cd testsuite && $(MAKE) $(FLAGS_TO_PASS) check; \
	else true; fi

# Original Dbgconfig.in comes from the NIST Tcl debugger distribution.
# CYGNUS LOCAL: Don't have dependancies, cause people get upset
# when autoconf gets run automatically.
#Dbgconfigure: $(srcdir)/Dbgconfig.in $(srcdir)/Makefile.in \
#		$(srcdir)/Dbg_cf.h.in $(srcdir)/aclocal.m4
Dbgconfigure:
	@echo "Rebuilding Dbgconfigure..."
	@if [ x"${srcdir}" = x"@srcdir@" ] ; then \
	  srcdir=. ; export srcdir ; \
	else true ; fi ; \
	(cd $${srcdir}; rm -fr Dbgconfigure ; \
	 autoconf Dbgconfig.in > Dbgconfigure ; \
	 chmod a+x Dbgconfigure)

################################################
# Various "clean" targets follow GNU conventions
################################################

# delete all files from current directory that are created by "make"
clean:
	-rm -rf *~ *.o shared core \
	        expect$(EXEEXT) expect_installed$(EXEEXT) \
	        expecti$(EXEEXT) expecti_installed$(EXEEXT) \
		expectk$(EXEEXT) expectk_installed$(EXEEXT) \
	        dumb exho devtty \
		$(EXP_UNSHARED_LIB_FILE) $(EXP_SHARED_LIB_FILE) \
		$(SCRIPT_LIST)
	@$(MAKE) subdir_do DO=$@ $(FLAGS_TO_PASS)

# like "clean", but also delete files created by "configure"
distclean: clean
	@$(MAKE) subdir_do DO=$@  $(FLAGS_TO_PASS)
	-rm -f Makefile config.status config.cache config.log expect_cf.h
	-rm -f Dbg_cf.h

# like "clean", but doesn't delete test utilities or massaged scripts
# because most people don't have to worry about them
mostlyclean:
	-rm -f *~ *.o shared core \
	        expect$(EXEEXT) expect_installed$(EXEEXT) \
	        expecti$(EXEEXT) expecti_installed$(EXEEXT) \
		expectk$(EXEEXT) expectk_installed$(EXEEXT) \
		$(EXP_UNSHARED_LIB_FILE) $(EXP_SHARED_LIB_FILE)
	@$(MAKE) subdir_do DO=$@ $(FLAGS_TO_PASS)

# delete everything from current directory that can be reconstructed
# except for configure
realclean:	distclean

##################################
# Targets for development at NIST
##################################

# the unsets allow calling this via Makefile.in

nist:
	unset CC ; \
	configure --verbose --prefix=/depot/tcl --exec-prefix=/depot/tcl/arch

epg:
	unset CC ; \
	echo configure --verbose --prefix=/home/libes --exec-prefix=/home/libes/arch

mink:
	unset CC ; \
	configure --verbose --prefix=/usr/tmp --exec-prefix=/usr/tmp/arch

cam:
	unset CC ; \
	configure --verbose --prefix=/tmp_mnt/home/fs1a/libes \
		      --exec-prefix=/tmp_mnt/home/fs1a/libes/arch

granta:
	unset CC ; \
	configure --verbose --prefix=/home/nist/libes/cray --exec-prefix=/home/nist/libes/cray/arch


hudson:
	unset CC ; \
	configure --verbose --prefix=/granta/home/nist/libes/ibm --exec-prefix=/granta /home/nist/libes/ibm/arch

# report globals that shouldn't be public but are
bad_globals:
	nm $(EXP_UNSHARED_LIB_FILE) | egrep -v " [a-zU] | _exp| _Exp| _Dbg"

LINTFLAGS = -h -q -x 

lint:
	lint $(LINTFLAGS) $(CPPFLAGS) $(STTY) $(CFILES) exp_main_exp.c $(TCLLINTLIB) | tee expect.lint

# after copying source directory, reestablish all links
symlink:
	rm -rf Dbg* e ek testsuite/aclocal.m4
	ln -s ../tcl-debug/configure.in	Dbgconfig.in
	ln -s ../tcl-debug/Makefile.in	DbgMkfl.in
	ln -s ../tcl-debug/Dbg_cf.h.in
	ln -s ../tcl-debug/Dbg.h
	ln -s ../tcl-debug/Dbg.c
	ln -s ../aclocal.m4 testsuite

#########################################
# Targets for building with CodeCenter
#########################################

GCCROOT = /depot/gnu/arch/lib/gcc-lib/sparc-sun-sunos4.1/2.3.3
GCCLIB = $(GCCROOT)/libgcc.a
GCCINC = -I$(GCCROOT)/include
# following only on Sparcs
SABERDEFINE = -D__sparc__

# Following target builds expect under CodeCenter.
# If using ObjectCenter, before loading, type: setopt primary_language C
exp:	$(CFILES) exp_main_exp.c
	#load $(CPPFLAGS) $(STTY) $(CFILES) exp_main_exp.c $(TCLLIB) $(GCCLIB) $(EXP_AND_TCL_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
	#load $(CPPFLAGS) $(STTY) $(CFILES) exp_main_tk.c $(TKLIB) $(TCLLIB) $(EXP_AND_TK_LIBS)

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

otk:    $(CFILES) exp_main_tk.c
	#load $(CPPFLAGS) $(STTY) -C $(CFILES) exp_main_tk.c $(TKLIB) $(TCLLIB) $(EXP_AND_TK_LIBS)
######################################
# Targets for pushing out releases
######################################

# until we are completely switched over, keep updating old ftp site too
OLDFTPDIR = /proj/elib/online/pub/expect
FTPDIR = /proj/itl/www/div826/subject/expect

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

# make a release and install it on ftp server
ftp:	expect-$(VERSION).tar.Z expect-$(VERSION).tar.gz
	cp expect-$(VERSION).tar.Z $(FTPDIR)/expect.tar.Z
	cp expect-$(VERSION).tar.gz $(FTPDIR)/expect.tar.gz
	cp HISTORY $(FTPDIR)
	cp README $(FTPDIR)/README.distribution
	cp example/README $(FTPDIR)/example
	cp `pubfile example` $(FTPDIR)/example
	rm expect-$(SHORT_VERSION).tar*
	ls -l $(FTPDIR)/expect.tar*
#	update old ftp site too
	cp expect-$(VERSION).tar.Z $(OLDFTPDIR)/expect.tar.Z
	cp expect-$(VERSION).tar.gz $(OLDFTPDIR)/expect.tar.gz
	cp HISTORY $(OLDFTPDIR)
	cp README $(OLDFTPDIR)/README.distribution
	cp example/README $(OLDFTPDIR)/example
	cp `pubfile example` $(OLDFTPDIR)/example
#       delete temp files
	rm expect-$(VERSION).tar*
	ls -l $(OLDFTPDIR)/expect.tar*

# make an alpha relase and install it on ftp server
alpha:	expect-$(VERSION).tar.Z expect-$(VERSION).tar.gz
	cp expect-$(VERSION).tar.Z $(FTPDIR)/alpha.tar.Z
	cp expect-$(VERSION).tar.gz $(FTPDIR)/alpha.tar.gz
	cp HISTORY $(FTPDIR)
	rm expect-$(VERSION).tar*
	ls -l $(FTPDIR)/alpha.tar*

# make a beta relase and install it on ftp server
beta:	expect-$(VERSION).tar.Z expect-$(VERSION).tar.gz
	rm -rf $(FTPDIR)/alpha.tar*
	cp expect-$(VERSION).tar.Z $(FTPDIR)/beta.tar.Z
	cp expect-$(VERSION).tar.gz $(FTPDIR)/beta.tar.gz
	cp HISTORY $(FTPDIR)
	rm expect-$(VERSION).tar*
	ls -l $(FTPDIR)/beta.tar*

expect-$(VERSION).tar: configure
	rm -f ../expect-$(VERSION)
	ln -s `pwd` ../expect-$(VERSION)
	rm -f ../pubfile
	ln pubfile ..
	cd ..;tar cvfh $@ `pubfile expect-$(VERSION)`
	mv ../$@ .

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

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

test:   expect
	rm -f .tmp
	echo "set objdir" `pwd` > .tmp
	if [ "$(srcdir)" = "." ] ; then \
	   echo "set srcdir" `pwd` >> .tmp ; \
	else echo "set srcdir" $(srcdir) >> .tmp ; fi
	echo "cd \$${srcdir}/tests" >> .tmp
	echo "source all" >> .tmp
	rootme=`pwd`; export rootme; \
	srcdir=${srcdir} ; export srcdir ; \
	if [ -f ./expect ] ; then  \
	   TCL_LIBRARY=$(TCL_LIBRARY) ; \
	   export TCL_LIBRARY ; fi ; \
	$(LOCAL_EXPECT) -f .tmp
	rm -f .tmp

###########################
# Targets for producing FAQ and homepage
###########################

#WEBDIR = /proj/elib/online/pub/expect
WEBDIR = /proj/itl/www/div826/subject/expect

# create the FAQ in html form
FAQ.html:	FAQ.src FAQ.tcl
	FAQ.src html > FAQ.html

# create the FAQ in text form
FAQ:	FAQ.src FAQ.tcl
	FAQ.src text > FAQ

# generate Expect home page
homepage.html:	homepage.src homepage.tcl
	homepage.src > homepage.html

# install various html docs on our web server
install-html:	FAQ.html homepage.html
	cp homepage.html $(WEBDIR)/index.html
	cp FAQ.html $(WEBDIR)
#	cp FAQ.src $(WEBDIR)
#	cp FAQ.tcl $(WEBDIR)

# add recursive support to the build process.
subdir_do: force
	@for i in $(SUBDIRS); do \
	   echo "Making $(DO) in $${i}..." ; \
	   if [ -d ./$$i ] ; then \
	     if (rootme=`pwd`/ ; export rootme ; \
	       rootsrc=`cd $(srcdir); pwd`/ ; export rootsrc ; \
	       cd ./$$i; \
	       $(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
	     else exit 1 ; fi ; \
	   else true ; fi ; \
	done
force:

## dependencies will be put after this line... ##
Dbg.o: $(srcdir)/Dbg.c Dbg.h 
exp_$(EVENT_ABLE).o: $(srcdir)/exp_$(EVENT_ABLE).c expect_cf.h expect.h \
	exp_command.h exp_event.h 
exp_$(EVENT_TYPE).o: $(srcdir)/exp_$(EVENT_TYPE).c expect_cf.h expect.h \
	exp_command.h exp_event.h 
exp_command.o: $(srcdir)/exp_command.c expect_cf.h exp_tty.h \
	exp_rename.h expect.h exp_command.h \
	exp_log.h exp_printify.h exp_event.h exp_pty.h 
exp_inter.o: $(srcdir)/exp_inter.c expect_cf.h \
	exp_tty_in.h exp_tty.h exp_rename.h expect.h exp_command.h \
	exp_log.h exp_printify.h exp_regexp.h exp_tstamp.h
exp_log.o: $(srcdir)/exp_log.c expect_cf.h expect.h \
	exp_rename.h exp_log.h exp_printify.h 
exp_main_exp.o: $(srcdir)/exp_main_exp.c expect_cf.h \
	expect.h exp_rename.h exp_command.h exp_log.h exp_printify.h
exp_main_sub.o: $(srcdir)/exp_main_sub.c expect_cf.h \
	exp_rename.h \
	expect.h exp_command.h exp_tty_in.h exp_tty.h exp_log.h \
	exp_printify.h exp_event.h 
#exp_main_tk.o: $(srcdir)/exp_main_tk.c expect_cf.h Dbg.h 

exp_main_tk.o: $(srcdir)/exp_main_tk.c expect_cf.h Dbg.h
	$(CC) -c @TK_DEFS@ $(CFLAGS_INT) $(HDEFS) $<	
shared/exp_main_tk.o: $(srcdir)/exp_main_tk.c expect_cf.h Dbg.h
		      $(CC) -c @TK_DEFS@ $(CFLAGS_INT) $(HDEFS) $<
exp_noevent.o: $(srcdir)/exp_noevent.c expect_cf.h exp_prog.h exp_command.h \
	exp_event.h
exp_poll.o: $(srcdir)/exp_poll.c expect_cf.h expect.h \
	exp_command.h exp_event.h 
	$(CC) -c $(CFLAGS_INT) @TCL_DEFS@ $(HDEFS) $<
shared/exp_poll.o: $(srcdir)/exp_poll.c expect_cf.h expect.h \
        exp_command.h exp_event.h 
	$(CC) -c $(CFLAGS_INT) @EXP_SHLIB_CFLAGS@ @TCL_DEFS@ $(HDEFS) $< -o shared/$@
exp_printify.o: $(srcdir)/exp_printify.c expect_cf.h 
exp_pty.o: $(srcdir)/exp_pty.c expect_cf.h exp_rename.h exp_pty.h 
exp_regexp.o: $(srcdir)/exp_regexp.c expect_cf.h \
	expect.h exp_regexp.h 
exp_select.o: $(srcdir)/exp_select.c expect_cf.h \
	expect.h exp_command.h exp_event.h 
exp_simple.o: $(srcdir)/exp_simple.c expect_cf.h \
	expect.h exp_command.h exp_event.h 
exp_strf.o: $(srcdir)/exp_strf.c
exp_trap.o: $(srcdir)/exp_trap.c expect_cf.h expect.h \
	exp_command.h exp_log.h exp_printify.h 
exp_tty.o: $(srcdir)/exp_tty.c expect_cf.h \
	expect.h exp_rename.h exp_tty_in.h exp_tty.h exp_log.h \
	exp_printify.h exp_command.h 
exp_win.o: $(srcdir)/exp_win.c exp_win.h 
expect.o: $(srcdir)/expect.c expect_cf.h \
	exp_rename.h expect.h exp_command.h \
	exp_log.h exp_printify.h exp_event.h exp_tty.h exp_tstamp.h
lib_exp.o: $(srcdir)/lib_exp.c expect_cf.h exp_rename.h expect.h \
	exp_printify.h
pty_sgttyb.o: $(srcdir)/pty_sgttyb.c expect_cf.h exp_rename.h exp_tty_in.h \
	exp_tty.h exp_pty.h 
pty_termios.o: $(srcdir)/pty_termios.c expect_cf.h exp_win.h \
	exp_tty_in.h exp_tty.h exp_rename.h exp_pty.h 
pty_unicos.o: $(srcdir)/pty_unicos.c expect_cf.h exp_rename.h