dnl Process this file with autoconf to produce a configure script.

dnl NOTES:
dnl * As of 1.34, we no longer use and test for "nope" to indicate
dnl   an empty variable.  Instead, we use `VAR=' (set the variable
dnl   to nothing) and `test -z "$VAR"' or `test -n "$VAR"' as the
dnl   case may be.  --ttn, 2000/08/04 12:11:26

AC_INIT(Source/Swig/swig.h)
AC_PREREQ(2.0)
. $srcdir/VERSION
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
AC_SUBST(SWIG_VERSION)
AC_SUBST(SWIG_SPIN)

# Set name for machine-dependent library files
AC_SUBST(MACHDEP)
AC_MSG_CHECKING(MACHDEP)
if test -z "$MACHDEP"
then
	if test -f /usr/lib/NextStep/software_version; then
		set X `hostinfo | grep 'NeXT Mach.*:' | \
			sed -e 's/://' -e 's/\./_/'` && \
		ac_sys_system=next && ac_sys_release=$4
		MACHDEP="$ac_sys_system$ac_sys_release$ac_sys_cpu"
	else
		ac_sys_system=`uname -s`
		if test "$ac_sys_system" = "AIX" ; then
			ac_sys_release=`uname -v`
		else
			ac_sys_release=`uname -r`
		fi
		ac_md_system=`echo $ac_sys_system |
				   tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
		ac_md_release=`echo $ac_sys_release |
				   tr -d '[/ ]' | sed 's/\..*//'`
		MACHDEP="$ac_md_system$ac_md_release"
	fi
	case MACHDEP in
	'')	MACHDEP=unknown;;
	esac
fi
AC_MSG_RESULT($MACHDEP)

AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB

dnl Checks for programs.

AC_SUBST(AR)
AC_CHECK_PROGS(AR, ar aal, ar)
AC_CHECK_PROGS(AUTOCONF, autoconf, "")

dnl Checks for header files.
AC_HEADER_STDC
dnl Checks for library functions.

# Set info about shared libraries.
AC_SUBST(SO)
AC_SUBST(LDSHARED)
AC_SUBST(CCSHARED)
AC_SUBST(LINKFORSHARED)

# SO is the extension of shared libraries `(including the dot!)
# -- usually .so, .sl on HP-UX
AC_MSG_CHECKING(SO)
if test -z "$SO"
then
	case $ac_sys_system in
	hp*|HP*)   SO=.sl;;
	*)	   SO=.so;;
	esac
fi
AC_MSG_RESULT($SO)
# LDSHARED is the ld *command* used to create shared library
# -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
# (Shared libraries in this instance are shared modules to be loaded into
# Python, as opposed to building Python itself as a shared library.)
AC_MSG_CHECKING(LDSHARED)
if test -z "$LDSHARED"
then
	case $ac_sys_system/$ac_sys_release in
	AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";;
	IRIX/5*) LDSHARED="ld -shared";;
	IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
	SunOS/4*) LDSHARED="ld";;
	SunOS/5*) LDSHARED="ld -G";;
	hp*|HP*) LDSHARED="ld -b";;
	OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
	DYNIX/ptx*) LDSHARED="ld -G";;
	next/*)
		if test "$ns_dyld"
		then LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind'
		else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';
		fi
                if test "$with_next_framework" ; then
		    LDSHARED="$LDSHARED \$(LDLIBRARY)"
		fi ;;
	Linux*) LDSHARED="gcc -shared";;
	dgux*) LDSHARED="ld -G";;
	FreeBSD*/3*) LDSHARED="gcc -shared";;
	FreeBSD*|OpenBSD*) LDSHARED="ld -Bshareable";;
	NetBSD*)
		if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
		then
			LDSHARED="cc -shared"
		else
			LDSHARED="ld -Bshareable"
		fi;;
	SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
	*)	LDSHARED="ld";;
	esac
fi
AC_MSG_RESULT($LDSHARED)
# CCSHARED are the C *flags* used to create objects to go into a shared
# library (module) -- this is only needed for a few systems
AC_MSG_CHECKING(CCSHARED)
if test -z "$CCSHARED"
then
	case $ac_sys_system/$ac_sys_release in
	hp*|HP*) if test "$GCC" = yes;
		 then CCSHARED="-fpic";
		 else CCSHARED="+z";
		 fi;;
	Linux*) CCSHARED="-fpic";;
	FreeBSD*|OpenBSD*) CCSHARED="-fpic";;
	NetBSD*) CCSHARED="-fPIC";;
	SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
	IRIX*/6*)  case $CC in
		   *gcc*) CCSHARED="-shared";;
		   *) CCSHARED="";;
		   esac;;
	esac
fi
AC_MSG_RESULT($CCSHARED)

AC_PROG_YACC
YFLAGS=-d
AC_SUBST(YFLAGS)

# RPATH is the path used to look for shared library files.
AC_MSG_CHECKING(RPATH)
if test -z "$RPATH"
then
	case $ac_sys_system/$ac_sys_release in
	SunOS/5*) RPATH="-R. -R$(exec_prefix)/lib";;
        IRIX*) RPATH="-rpath .:$(exec_prefix)/lib";;
	Linux*) RPATH="-Xlinker -rpath $(exec_prefix)/lib -Xlinker -rpath .";;
	*)	RPATH="";;
	esac
fi
AC_MSG_RESULT($RPATH)
AC_SUBST(RPATH)

# LINKFORSHARED are the flags passed to the $(CC) command that links
# the a few executables -- this is only needed for a few systems

AC_MSG_CHECKING(LINKFORSHARED)
if test -z "$LINKFORSHARED"
then
	case $ac_sys_system/$ac_sys_release in
	AIX*)	LINKFORSHARED='-Wl,-bE:$(srcdir)/python.exp -lld';;
	hp*|HP*)
	    LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
	Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
	next/*) LINKFORSHARED="-u libsys_s";;
	SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
	IRIX*/6*) LINKFORSHARED="-all";;
	esac
fi
AC_MSG_RESULT($LINKFORSHARED)


echo ""
echo "Checking for installed packages."
echo "Note : None of the following packages are required to compile SWIG"
echo ""

# Check for specific libraries.   Used for SWIG examples
AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX

# The following three (nsl,inet,socket) are needed on Sequent;
# the order of checking must be this.  Most SVR4 platforms will
# need -lsocket and -lnsl.  However on SGI IRIX 5, these exist but
# broken.  I see no elegant solution (probably CHECK_LIB should be
# fixed to only add the library if the given entry point is not
# satisfied without it).
if test "`uname -s`" != IRIX
then
AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
AC_CHECK_LIB(inet, gethostbyname, [LIBS="-linet $LIBS"], [], -lnsl) # Sequent
AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
fi

# check for --with-libm=...
AC_SUBST(LIBM)
LIBM=-lm
AC_ARG_WITH(libm, [  --with-libm=STRING      math library], [
if test "$withval" != yes
then LIBM=$withval
else AC_ERROR(proper usage is --with-libm=STRING)
fi])
AC_CHECK_LIB(ieee, main, [LIBM="-lieee $LIBM"])
AC_CHECK_LIB(crypt,crypt, [LIBCRYPT="-lcrypt"])
AC_SUBST(LIBCRYPT)

# check for --with-libc=...
AC_SUBST(LIBC)
AC_ARG_WITH(libc, [  --with-libc=STRING      C library], [
if test "$withval" != yes
then LIBC=$withval
else AC_ERROR(proper usage is --with-libc=STRING)
fi])

#--------------------------------------------------------------------
#	Locate the X11 header files and the X11 library archive.  Try
#	the ac_path_x macro first, but if it doesn't find the X stuff
#	(e.g. because there's no xmkmf program) then check through
#	a list of possible directories.  Under some conditions the
#	autoconf macro will return an include directory that contains
#	no include files, so double-check its result just to be safe.
#--------------------------------------------------------------------

AC_PATH_X
not_really_there=""
if test "$no_x" = ""; then
    if test "$x_includes" = ""; then
	AC_TRY_CPP([#include <X11/XIntrinsic.h>], , not_really_there="yes")
    else
	if test ! -r $x_includes/X11/Intrinsic.h; then
	    not_really_there="yes"
	fi
    fi
fi
if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
    AC_MSG_CHECKING(for X11 header files)
    XINCLUDES="# no special path needed"
    AC_TRY_CPP([#include <X11/Intrinsic.h>], , XINCLUDES="")
    if test -z "$XINCLUDES"; then
        dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/include/X11R4 /usr/X11R5/include /usr/include/X11R5 /usr/openwin/include /usr/X11/include /usr/sww/include /usr/X11R6/include /usr/include/X11R6"
        for i in $dirs ; do
	    if test -r $i/X11/Intrinsic.h; then
		AC_MSG_RESULT($i)
	        XINCLUDES=" -I$i"
		break
	    fi
        done
    fi
else
    if test "$x_includes" != ""; then
	XINCLUDES=-I$x_includes
    else
	XINCLUDES="# no special path needed"
    fi
fi
if test -z "$XINCLUDES"; then
    AC_MSG_RESULT(couldn't find any!)
    XINCLUDES="# no include files found"
fi

if test "$no_x" = yes; then
    AC_MSG_CHECKING(for X11 libraries)
    XLIBSW=
    dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/lib/X11R4 /usr/X11R5/lib /usr/lib/X11R5 /usr/X11R6/lib /usr/lib/X11R6 /usr/openwin/lib /usr/X11/lib /usr/sww/X11/lib"
    for i in $dirs ; do
	if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then
	    AC_MSG_RESULT($i)
	    XLIBSW="-L$i -lX11"
	    break
	fi
    done
else
    if test "$x_libraries" = ""; then
	XLIBSW=-lX11
    else
	XLIBSW="-L$x_libraries -lX11"
    fi
fi
if test -z "$XLIBSW" ; then
    AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow)
fi
if test -z "$XLIBSW" ; then
    AC_MSG_RESULT(couldn't find any!  Using -lX11.)
    XLIBSW=-lX11
fi

AC_SUBST(XINCLUDES)
AC_SUBST(XLIBSW)

#--------------------------------------------------------------------
#	Try to locate the Tcl package
#--------------------------------------------------------------------

TCLINCLUDE=
TCLLIB=
TCLPACKAGE=

AC_ARG_WITH(tcl,[  --with-tcl=path         Set location of Tcl package],[
	TCLPACKAGE="$withval"], [TCLPACKAGE=])
AC_ARG_WITH(tclincl,[  --with-tclincl=path     Set location of Tcl include directory],[
	TCLINCLUDE="-I$withval"], [TCLINCLUDE=])
AC_ARG_WITH(tcllib,[  --with-tcllib=path      Set location of Tcl library directory],[
	TCLLIB="-L$withval"], [TCLLIB=])

if test -z "$TCLINCLUDE"; then
   if test -n "$TCLPACKAGE"; then
	TCLINCLUDE="-I$TCLPACKAGE/include"
   fi
fi

if test -z "$TCLLIB"; then
   if test -n "$TCLPACKAGE"; then
	TCLLIB="-L$TCLPACKAGE/lib"
   fi
fi

AC_MSG_CHECKING(for Tcl header files)
if test -z "$TCLINCLUDE"; then
AC_TRY_CPP([#include <tcl.h>], , TCLINCLUDE="")
if test -z "$TCLINCLUDE"; then
	dirs="$prefix/include /usr/local/include /usr/include /opt/local/include /home/sci/local/include"
	for i in $dirs ; do
		if test -r $i/tcl.h; then
			AC_MSG_RESULT($i)
			TCLINCLUDE="-I$i"
			break
		fi
	done
fi
if test -z "$TCLINCLUDE"; then
	TCLINCLUDE="-I/usr/local/include"
    	AC_MSG_RESULT(not found)
fi
else
        AC_MSG_RESULT($TCLINCLUDE)
fi

AC_MSG_CHECKING(for Tcl library)
if test -z "$TCLLIB"; then
dirs="$prefix/lib /usr/local/lib /usr/lib /opt/local/lib /home/sci/local/lib"
for i in $dirs ; do
	if test -r $i/libtcl.a; then
	    AC_MSG_RESULT($i)
	    TCLLIB="-L$i"
	    break
	fi
done
if test -z "$TCLLIB"; then
	AC_MSG_RESULT(not found)
	TCLLIB="-L/usr/local/lib"
fi
else
AC_MSG_RESULT($TCLLIB)
fi

AC_SUBST(TCLINCLUDE)
AC_SUBST(TCLLIB)

#----------------------------------------------------------------
# Look for Python
#----------------------------------------------------------------

PYINCLUDE=
PYLIB=
PYPACKAGE=
PYLINK="-lModules -lPython -lObjects -lParser"

AC_ARG_WITH(py,[  --with-py=path          Set location of Python],[
	PYPACKAGE="$withval"], [PYPACKAGE=])
AC_ARG_WITH(pyincl,[  --with-pyincl=path      Set location of Python include directory],[
	PYINCLUDE="$withval"], [PYINCLUDE=])
AC_ARG_WITH(pylib,[  --with-pylib=path       Set location of Python library directory],[
	PYLIB="$withval"], [PYLIB=])

if test -z "$PYINCLUDE"; then
   if test -n "$PYPACKAGE"; then
	PYINCLUDE="$PYPACKAGE/include"
   fi
fi

if test -z "$PYLIB"; then
   if test -n "$PYPACKAGE"; then
	PYLIB="$PYPACKAGE/lib"
   fi
fi


AC_MSG_CHECKING(for Python header files)

dirs="$PYINCLUDE $PYINCLUDE/python1.6 $PYINCLUDE/python1.5 $PYINCLUDE/python1.4 $PYINCLUDE/Py $prefix=/include/python1.6 $prefix/include/python1.5 $prefix/include/python1.4 /usr/local/include/python1.6 /usr/local/include/python1.5 /usr/include/python1.5 /usr/local/include/python1.4 /usr/include/python1.4 $prefix/include/Py /usr/local/include/Py /usr/include/Py"
for i in $dirs ; do
	if test -r $i/Python.h; then
		AC_MSG_RESULT($i)
		PYINCLUDE="-I$i"
		break
	fi
done
if test -z "$PYINCLUDE"; then
	PYINCLUDE="-I/usr/local/include/Py"
    	AC_MSG_RESULT(not found)
fi

AC_MSG_CHECKING(for Python library)
dirs="$PYLIB $PYLIB/config $PYLIB/lib $PYLIB/python1.6/config $PYLIB/python1.5/config $PYLIB/python1.4/config $PYLIB/python/lib $prefix/lib/python1.6/config $prefix/lib/python1.5/config $prefix/lib/python1.4/config /usr/local/lib/python1.6/config /usr/local/lib/python1.5/config /usr/lib/python1.5 /usr/local/lib/python1.4/config /usr/lib/python1.4 $prefix/lib/python/lib /usr/local/lib/python/lib /usr/lib/python/lib /home/sci/local/lib/python"

for i in $dirs ; do
	if test -r $i/libpython1.6.a; then
	    AC_MSG_RESULT($i)
	    PYLIB="$i"
	    PYINCLUDE="$PYINCLUDE -I$i"
            PYLINK="-lpython1.6"
	    break
	fi
	if test -r $i/libpython1.5.a; then
	    AC_MSG_RESULT($i)
	    PYLIB="$i"
	    PYINCLUDE="$PYINCLUDE -I$i"
            PYLINK="-lpython1.5"
	    break
	fi
	if test -r $i/libPython.a; then
	    AC_MSG_RESULT($i)
	    PYLIB="$i"
	    PYINCLUDE="$PYINCLUDE -I$i"
	    break
	fi
done
if test -z "$PYLIB"; then
	AC_MSG_RESULT(not found)
	PYLIB="/usr/local/lib/python/lib"
	PYINCLUDE="$PYINCLUDE -I$PYLIB"
fi

AC_SUBST(PYINCLUDE)
AC_SUBST(PYLIB)
AC_SUBST(PYLINK)

#----------------------------------------------------------------
# Look for Perl5
#----------------------------------------------------------------

PERLBIN=

AC_ARG_WITH(perl5,[  --with-perl5=path       Set location of Perl5 executable],[ PERLBIN="$withval"], [PERLBIN=])

# First figure out what the name of Perl5 is

if test -z "$PERLBIN"; then
AC_CHECK_PROGS(PERL, perl5.004 perl5.003 perl5.002 perl5.001 perl5 perl)
else
PERL="$PERLBIN"
fi
AC_MSG_CHECKING(for Perl5 header files)
if test -n "$PERL"; then
	PERL5DIR=`($PERL -e 'use Config; print $Config{archlib};') 2>/dev/null`
	if test "$PERL5DIR" != ""; then
		dirs="$PERL5DIR $PERL5DIR/CORE"
		PERL5EXT=none
		for i in $dirs; do
			if test -r $i/perl.h; then
				AC_MSG_RESULT($i)
				PERL5EXT="$i"
				break;
			fi
		done
		if test "$PERL5EXT" = none; then
			PERL5EXT="$PERL5DIR/CORE"
			AC_MSG_RESULT(could not locate perl.h...using $PERL5EXT)
		fi
	else
		AC_MSG_RESULT(unable to determine perl5 configuration)
		PERL5EXT=$PERL5DIR
	fi
    else
       	AC_MSG_RESULT(could not figure out how to run perl5)
	PERL5EXT="/usr/local/lib/perl/archname/5.003/CORE"
    fi

AC_SUBST(PERL5EXT)

#----------------------------------------------------------------
# Look for java
#----------------------------------------------------------------

AC_ARG_WITH(java, [  --with-java=path        Set location of Java],[JAVABIN="$withval"], [JAVABIN=])
AC_ARG_WITH(javac, [  --with-javac=path       Set location of Javac],[JAVACBIN="$withval"], [JAVACBIN=])

if test -z "$JAVABIN" ; then
  AC_CHECK_PROGS(JAVA, java kaffe guavac)
else
  JAVA="$JAVABIN"
fi

if test -z "$JAVACBIN" ; then
  AC_CHECK_PROGS(JAVAC, javac)
else
  JAVAC="$JAVACBIN"
fi

AC_MSG_CHECKING(for java include file jni.h)
AC_ARG_WITH(javaincl, [  --with-javaincl=path    Set location of Java include directory], [JAVAINCDIR="$withval"], [JAVAINCDIR=])

if test -z "$JAVAINCDIR"; then
  JAVAINCDIR="/usr/jdk*/include /usr/local/jdk*/include /opt/jdk*/include /usr/java/include /usr/local/java/include /opt/java/include /usr/include/java /usr/local/include/java /usr/include/kaffe /usr/local/include/kaffe /usr/include /usr/local/include"
fi

JAVAINC=""
for d in $JAVAINCDIR ; do
  if test -r $d/jni.h ; then
    AC_MSG_RESULT($d)
    JAVAINCDIR=$d
    JAVAINC="-I$d"
    break
  fi
done

if test "$JAVAINC" = "" ; then
  AC_MSG_RESULT(not found)
else
  # now look for <arch>/jni_md.h
  AC_MSG_CHECKING(for java include file jni_md.h)
  JAVAMDDIR=`find $JAVAINCDIR -name jni_md.h -print`
  if test "$JAVAMDDIR" = "" ; then
    AC_MSG_RESULT(not found)
  else
    JAVAMDDIR=`dirname $JAVAMDDIR`
    JAVAINC="${JAVAINC} -I$JAVAMDDIR"
    AC_MSG_RESULT($JAVAMDDIR)
  fi
fi

AC_SUBST(JAVA)
AC_SUBST(JAVAC)
AC_SUBST(JAVAINC)

AC_SUBST(ROOT_DIR)ROOT_DIR=`pwd`

#----------------------------------------------------------------
# Look for Guile
#----------------------------------------------------------------

GUILEINCLUDE=
GUILELIB=
GUILELINK=

AC_PATH_PROG(GUILE_CONFIG, guile-config)

if test -n "$GUILE_CONFIG" ; then

  GUILEPACKAGE=

  AC_ARG_WITH(guile,[  --with-guile=path       Set location of Guile],[
	GUILEPACKAGE="$withval"], [GUILEPACKAGE=])
  AC_ARG_WITH(guilencl,[  --with-guileincl=path   Set location of Guile include directory],[
	GUILEINCLUDE="$withval"], [GUILEINCLUDE=])
  AC_ARG_WITH(guilelib,[  --with-guilelib=path    Set location of Guile library directory],[
	GUILELIB="$withval"], [GUILELIB=])

  if test -z "$GUILEINCLUDE"; then
     if test -n "$GUILEPACKAGE"; then
  	GUILEINCLUDE="$GUILEPACKAGE/include"
     fi
  fi

  if test -z "$GUILELIB"; then
     if test -n "$GUILEPACKAGE"; then
  	GUILELIB="$GUILEPACKAGE/lib"
     fi
  fi

  AC_MSG_CHECKING(for Guile header files)

  dirs="$GUILEINCLUDE `guile-config info includedir`"
  for i in $dirs ; do
  	if test -r $i/guile/gh.h; then
  		AC_MSG_RESULT($i)
  		GUILEINCLUDE="-I$i"
  		break
  	fi
  done
  if test -z "$GUILEINCLUDE"; then
  	GUILEINCLUDE="-I/usr/local/include"
      	AC_MSG_RESULT(not found)
  fi

  AC_MSG_CHECKING(for Guile library)
  dirs="$GUILELIB `guile-config info libdir`"
  for i in $dirs ; do
  	if test -r $i/libguile.so; then
  	    AC_MSG_RESULT($i)
  	    GUILELIB="$i"
  	    break
  	fi
  done
  if test -z "$GUILELIB"; then
  	AC_MSG_RESULT(not found)
  	GUILELIB="/usr/local/lib"
  fi

  GUILELINK="`guile-config link`"

fi # have GUILE_CONFIG

AC_SUBST(GUILEINCLUDE)
AC_SUBST(GUILELIB)
AC_SUBST(GUILELINK)

#----------------------------------------------------------------
# Look for MzScheme
#----------------------------------------------------------------

AC_PATH_PROG(MZC, mzc)

#----------------------------------------------------------------
# Look for Ruby
#----------------------------------------------------------------

RUBYBIN=

AC_ARG_WITH(ruby,[  --with-ruby=path        Set location of Ruby executable],[ RUBYBIN="$withval"], [RUBYBIN=])

# First figure out what the name of Ruby is

if test -z "$RUBYBIN"; then
AC_CHECK_PROGS(RUBY, ruby)
else
RUBY="$RUBYBIN"
fi
AC_MSG_CHECKING(for Ruby header files)
if test -n "$RUBY"; then
	RUBYDIR=`($RUBY -rmkmf -e 'print $archdir') 2>/dev/null`
	if test "$RUBYDIR" != ""; then
		dirs="$RUBYDIR"
		RUBYINCLUDE=none
		for i in $dirs; do
			if test -r $i/ruby.h; then
				AC_MSG_RESULT($i)
				RUBYINCLUDE="-I$i"
				break;
			fi
		done
		if test "$RUBYINCLUDE" = none; then
			RUBYINCLUDE="-I$RUBYDIR"
			AC_MSG_RESULT(could not locate ruby.h...using $RUBYINCLUDE)
		fi

		AC_MSG_CHECKING(for Ruby library)
		RUBYLIB=none
		for i in $dirs; do
			if test -r $i/libruby.a; then
				AC_MSG_RESULT($i)
				RUBYLIB="$i"
				break;
			fi
		done
		if test "$RUBYLIB" = none; then
			RUBYLIB="$RUBYDIR"
			AC_MSG_RESULT(could not locate libruby.a...using $RUBYLIB)
		fi
	else
		AC_MSG_RESULT(unable to determine ruby configuration)
		RUBYINCLUDE="-I$RUBYDIR"
		RUBYLIB="$RUBYDIR"
	fi
	RUBYLINK=`($RUBY -rrbconfig -e 'print Config::CONFIG[["RUBY_INSTALL_NAME"]]') 2>/dev/null`
	RUBYLINK="-l$RUBYLINK"
	RUBYLINK="$RUBYLINK `($RUBY -rrbconfig -e 'print Config::CONFIG[["LIBS"]]') 2>/dev/null`"
else
       	AC_MSG_RESULT(could not figure out how to run ruby)
	RUBYINCLUDE="-I/usr/local/lib/ruby/1.4/arch"
	RUBYLIB="-I/usr/local/lib/ruby/1.4/arch"
	RUBYLINK="-lruby -lm"
fi

AC_SUBST(RUBYINCLUDE)
AC_SUBST(RUBYLIB)
AC_SUBST(RUBYLINK)


#----------------------------------------------------------------
# Miscellaneous
#----------------------------------------------------------------

# These commands are only intended for use in a development environment.
# When one makes a fresh CVS checkout, no 'configure' scripts exist. This
# Makes the CONFIG_SUBDIRS macro fail below. To fix this, one needs to
# generate the configure script by calling autoconf manually.  This is
# not an issue in non-CVS releases--the mkdist.py script creates all
# of the configure scripts before making a tar-ball. -- beazley 2000/03/01

if test ! -r $srcdir/Source/DOH/configure; then
	(cd $srcdir/Source/DOH ; autoconf)
fi

#if test -d $srcdir/Source/SWILL/SWILL; then
#  if test ! -r $srcdir/Source/SWILL/configure; then
#  	(cd $srcdir/Source/SWILL ; autoconf)
#  fi
#fi

if test ! -r $srcdir/Tools/configure ; then
	(cd $srcdir/Tools ; autoconf)
fi

#
#AC_OUTPUT_COMMANDS(test -f Examples/install-sh || cp install-sh Examples)
# DB: Maybe I'm missings something, but why is it necessary to put
# an 'install-sh' script in the Examples directory?

AC_CONFIG_SUBDIRS(Source/DOH Tools)

# NOTE: The following ref to `Source' should NOT be prefixed w/ `$srcdir/'.
# We can remove it if `Source' ever has a generated file but not before.
test -d Source || mkdir Source

dnl We use the following in `AC_OUTPUT' and "make distclean".
configure_substituted_files=`echo	\
    Examples/Makefile			\
    Examples/C++/test_conf.py		\
    Examples/guile/Makefile		\
    Makefile				\
    Runtime/Makefile			\
    		\
    Source/Include/swigconfig.h		\
    Source/Include/swigver.h		\
    		\
    Source/Modules/Makefile		\
    Source/Modules1.1/Makefile		\
    Source/Preprocessor/Makefile	\
    Source/SWIG1.1/Makefile		\
    Source/Swig/Makefile		\
`
AC_SUBST(configure_substituted_files)

AC_OUTPUT([$configure_substituted_files])

dnl configure.in ends here
