#!/bin/sh

# Retrieve expand distribution and modify it for use by the TclPro
# build framework. Assume WD is parent of 'tclpro' directory.

if [ -f expand2.0.tar.gz ]
then
    mv expand2.0.tar.gz expand2.0.tar.gz.old
    rm -rf expand2.0.old
    mv expand2.0 expand2.0.old
fi

wget http://www.wjduquette.com/expand/expand2.0.tar.gz
if test $? -ne 0
then
    echo "wget failed"
    exit 1
fi
#cp  ~/activestate/new-modules/expand/expand2.0.tar.gz .

mkdir expand2.0
cd    expand2.0
tar xfz ../expand2.0.tar.gz

ln -s ../config config
#echo "builtin(include,config/tcl.m4)" > aclocal.m4

patch -p0 << '__EOF__'
diff -ruP ../expand2.0.orig/Makefile.in ./Makefile.in
--- ../expand2.0.orig/Makefile.in	Thu Jan  1 01:00:00 1970
+++ ./Makefile.in	Tue Mar  6 20:45:41 2001
@@ -0,0 +1,180 @@
+# Makefile.in --
+#
+#	This file is a Makefile for the expand macro processoor. If this
+#	is "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.
+#
+# Copyright (c) 2001 Andreas Kupries
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#
+# RCS: @(#) $Id: get-expand,v 1.3 2001/03/16 21:25:28 andreas_kupries Exp $
+
+MODULES= expand
+
+#========================================================================
+# Nothing of the variables below this line need to be changed.  Please
+# check the TARGETS section below to make sure the make targets are
+# correct.
+#========================================================================
+
+SHELL = @SHELL@
+
+INSTALL_ROOT =
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+prefix = $(INSTALL_ROOT)@prefix@
+exec_prefix = $(INSTALL_ROOT)@exec_prefix@
+
+bindir = $(prefix)/bin
+libdir = @libdir@
+mandir = @mandir@
+
+DESTDIR =
+
+pkglibdir = $(prefix)/lib/@PACKAGE@@VERSION@
+
+top_builddir = .
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_FLAG =
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+
+PACKAGE = @PACKAGE@
+VERSION = @VERSION@
+CYGPATH = @CYGPATH@
+TCLSH_PROG = @TCLSH_PROG@
+
+AUTOCONF = autoconf
+
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+CONFIGDIR = @CONFIGDIR@
+mkinstalldirs = $(SHELL) $(CONFIGDIR)/mkinstalldirs
+CONFIG_CLEAN_FILES =
+
+#========================================================================
+# Start of user-definable TARGETS section
+#========================================================================
+
+#========================================================================
+# TEA TARGETS.  Please note that the "libraries:" target refers to platform
+# independent files, and the "binaries:" target inclues executable programs and
+# platform-dependent libraries.  Modify these targets so that they install
+# the various pieces of your package.  The make and install rules
+# for the BINARIES that you specified above have already been done.
+#========================================================================
+
+all: libraries doc
+
+#========================================================================
+# The binaries target builds executable programs, Windows .dll's, unix
+# shared/static libraries, and any other platform-dependent files.
+# The list of targets to build for "binaries:" is specified at the top
+# of the Makefile, in the "BINARIES" variable.
+#========================================================================
+
+binaries:
+
+libraries:
+
+doc:
+
+install: all install-libraries install-doc install-binaries
+
+install-binaries: 
+	$(srcdir)/mkinstalldirs $(bindir)
+	$(INSTALL_PROGRAM) $(srcdir)/expand.tcl $(bindir)/expand@VERSION@
+
+#========================================================================
+# This rule installs platform-independent files, such as header files.
+#========================================================================
+
+install-libraries: libraries
+
+#========================================================================
+# Install documentation.  Unix manpages should go in the $(mandir)
+# directory.
+#========================================================================
+
+install-doc: doc
+
+test:
+
+depend:
+
+# Make a distribution.  This includes:
+#   Code, doc's, and tests for all modules
+#   Generated installer for Windows (INSTALL.BAT) and UNIX (install.sh)
+# This all gets archived together (tcllib$(VERSION).zip or 
+# tcllib$(VERSION).tar.gz).
+dist:
+
+#========================================================================
+# End of user-definable section
+#========================================================================
+
+#========================================================================
+# Don't modify the file to clean here.  Instead, set the "CLEANFILES"
+# variable in configure.in
+#========================================================================
+
+clean:  
+
+distclean: clean
+	-rm -f Makefile $(CONFIG_CLEAN_FILES)
+	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
+	-rm -f config.status
+
+#========================================================================
+# Install binary object libraries.  On Windows this includes both .dll and
+# .lib files.  Because the .lib files are not explicitly listed anywhere,
+# we need to deduce their existence from the .dll file of the same name.
+# Additionally, the .dll files go into the bin directory, but the .lib
+# files go into the lib directory.  On Unix platforms, all library files
+# go into the lib directory.  In addition, this will generate the pkgIndex.tcl
+# file in the install location (assuming it can find a usable tclsh8.2 shell)
+#
+# You should not have to modify this target.
+#========================================================================
+
+install-lib-binaries: installdirs
+
+#========================================================================
+# Install binary executables (e.g. .exe files)
+#
+# You should not have to modify this target.
+#========================================================================
+
+install-bin-binaries: installdirs
+
+.SUFFIXES: .c .o .obj
+
+Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) \
+	  && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+uninstall-binaries:
+
+installdirs:
+	$(mkinstalldirs)  $(DESTDIR)$(pkglibdir)
+
+.PHONY: all binaries clean depend distclean doc install installdirs \
+libraries test
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff -ruP ../expand2.0.orig/aclocal.m4 ./aclocal.m4
--- ../expand2.0.orig/aclocal.m4	Thu Jan  1 01:00:00 1970
+++ ./aclocal.m4	Tue Mar  6 19:58:03 2001
@@ -0,0 +1 @@
+builtin(include,config/tcl.m4)
diff -ruP ../expand2.0.orig/configure.in ./configure.in
--- ../expand2.0.orig/configure.in	Thu Jan  1 01:00:00 1970
+++ ./configure.in	Tue Mar  6 20:42:03 2001
@@ -0,0 +1,33 @@
+AC_INIT(expand.tcl)
+
+AC_CONFIG_AUX_DIR(config)
+CONFIGDIR=${srcdir}/config
+AC_SUBST(CONFIGDIR)
+
+PACKAGE=expand
+
+MAJOR_VERSION=2
+MINOR_VERSION=0
+PATCHLEVEL=""
+
+VERSION=${MAJOR_VERSION}.${MINOR_VERSION}${PATCHLEVEL}
+NODOT_VERSION=${MAJOR_VERSION}${MINOR_VERSION}
+
+AC_SUBST(PACKAGE)
+AC_SUBST(VERSION)
+
+case "`uname -s`" in
+    *win32* | *WIN32* | *CYGWIN_NT* | *CYGWIN_98* | *CYGWIN_95*)
+	CYGPATH="cygpath -w"
+	;;
+    *)
+	CYGPATH=echo
+	;;
+esac
+AC_SUBST(CYGPATH)
+
+AC_PROG_INSTALL
+SC_SIMPLE_EXEEXT
+SC_PROG_TCLSH
+
+AC_OUTPUT([Makefile])
diff -ruP ../expand2.0.orig/mkinstalldirs ./mkinstalldirs
--- ../expand2.0.orig/mkinstalldirs	Thu Jan  1 01:00:00 1970
+++ ./mkinstalldirs	Tue Mar  6 20:45:00 2001
@@ -0,0 +1,40 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+# $Id: get-expand,v 1.3 2001/03/16 21:25:28 andreas_kupries Exp $
+
+errstatus=0
+
+for file
+do
+   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+   shift
+
+   pathcomp=
+   for d
+   do
+     pathcomp="$pathcomp$d"
+     case "$pathcomp" in
+       -* ) pathcomp=./$pathcomp ;;
+     esac
+
+     if test ! -d "$pathcomp"; then
+        echo "mkdir $pathcomp"
+
+        mkdir "$pathcomp" || lasterr=$?
+
+        if test ! -d "$pathcomp"; then
+  	  errstatus=$lasterr
+        fi
+     fi
+
+     pathcomp="$pathcomp/"
+   done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here
__EOF__

rm -f configure
autoconf

chmod u+x mkinstalldirs
exit
