# --*-sh-*--------------------------------------------------------------------
#
# sysloc.in
#
# Maurice LeBrun
# IFS, University of Texas at Austin
# 14-Jul-1994
#
# This script sets up config variables for a Unix-like system.
# The stuff set here is fairly generic and can be automated.
# This includes how to find required header files and libraries.
# Includes code and ideas taken from the BLT (Tk extension) configure.
# ----------------------------------------------------------------------------

INCPATH=
LIBPATH=

# Default linker library commands.  These may need version numbers
# appended to them though.

DPLIBSTR=-ldpnetwork
ITKLIBSTR=-litk
TKLIBSTR=-ltk
ITCLLIBSTR=-litcl
TCLLIBSTR=-ltcl
XLIBSTR=-lX11

# ----------------------------------------------------------------------------
# Run xmkmf to check for location of X libraries and includes.  If not
# found, I have to assume that X isn't available (it happens).  Can disable
# explicitly by specifying --disable-xwin or --without-x (the latter switch
# is built into autoconf so I might as well support it).
#
# Note:  ac_path_x gets it wrong sometimes.  If you need to specify
# the path yourself in cf_plplot.in, you should probably plan to
# provide both XINCDIR and XLIBDIR.
# ----------------------------------------------------------------------------

if test "$with_x" = "no"; then
    enable_xwin=no
fi

if test "$enable_xwin" = "yes"; then
    if test -z "$XINCDIR" -o -z "$XLIBDIR"; then
	AC_PATH_X

	XINCDIR="$x_includes"
	if test -z "$XINCDIR"; then
	    AC_TRY_CPP([#include <X11/Intrinsic.h>], [ XINCDIR=default ], [
	    incdirs="\
	    /usr/include \
	    /usr/include/X11 \
	    /usr/include/X11R5 \
	    /usr/include/X11R4 \
	    /usr/include/X11/X11R5 \
	    /usr/include/X11/X11R4 \
	    /usr/X11/include \
	    /usr/X386/include \
	    /usr/X11R5/include \
	    /usr/local/X11R5/include \
	    /usr/openwin/include \
	    /usr/local/X11R4/include \
	    /usr/include/X11R4 \
	    /usr/local/include \
	    /usr/unsupported/include"

	    for dir in $places; do
		if test -r "$dir/X11/Intrinsic.h"; then
		    XINCDIR="$dir"
		    break
		fi
	    done
	    if test -z "$XINCDIR"; then
		AC_MSG_RESULT(warning: X11 include files not found)
		XINCDIR=default
		enable_xwin=no
	    fi ])
	fi
	if test "$XINCDIR" = "/usr/include"; then
	    XINCDIR=default
	fi

	XLIBDIR="$x_libraries"
	if test -z "$XLIBDIR"; then
	    AC_CHECK_LIB(X11, main, [ XLIBDIR=default ], [
	    libdirs="\
	    /lib \
	    /usr/lib \
	    /usr/lib/X11R5 \
	    /usr/X11/lib \
	    /usr/X386/lib \
	    /usr/X11R5/lib \
	    /usr/local/X11R5/lib \
	    /usr/openwin/lib \
	    /usr/local/X11R4/lib \
	    /usr/lib/X11R4 \ 
	    /usr/local/lib \
	    /usr/unsupported/lib"

	    for dir in $places; do
		if test -r "$dir/libX11.a"; then
		    XLIBDIR="$dir"
		    break
		fi
	    done
	    if test -z "$XLIBDIR"; then
		AC_MSG_RESULT(warning: X11 library not found)
		XLIBDIR=default
	    fi ])
	fi
	if test "$XLIBDIR" = "/usr/lib"; then
	    XLIBDIR=default
	fi
    fi
fi

# ----------------------------------------------------------------------------
# Make some guesses where the Tcl/Tk include files and libraries are.
# Look first in the Tcl/Tk distributions and then move on to the standard
# include file/library locations.  If it's still not found I assume it's
# not here.
#
# Note: it is important to check in user directories _before_ checking
# anywhere else.  That way you can easily compile custom versions (of Tcl,
# Tk, etc), put them in your file space, and have them be found first.  Some
# examples: libraries compiled with debugging turned on, or from a different
# revision of the (Tcl, Tk, etc) package.  Also, when dealing with multiple
# versions (e.g. libtcl7.4.a vs the older libtcl.a), check for the newer
# version first.
# ----------------------------------------------------------------------------

# Default directories to search for include files

incdirs_default="\
$prefix/include/itcl \
$prefix/include \
$HOME/local/include \
$HOME/include \
/usr/local/include \
/usr/include/tcl \
/usr/include"

# Default directories to search for library files

libdirs_default="\
$prefix/lib/itcl \
$prefix/lib \
$HOME/local/lib \
$HOME/lib \
/usr/local/lib \
/usr/lib"

incdirs=$incdirs_default
libdirs=$libdirs_default

if test -n "$with_pkgdir"; then
    incdirs="$with_pkgdir/include $incdirs"
    libdirs="$with_pkgdir/lib $libdirs"
fi

# ----------------------------------------------------------------------------
# tcl.h
# ----------------------------------------------------------------------------

if test "$enable_tcl" = "yes"; then
    if test -z "$TCLINCDIR"; then
	FIND_INC(tcl, TCLINCDIR, enable_tcl)
    fi
fi

# ----------------------------------------------------------------------------
# libtcl
# ----------------------------------------------------------------------------

if test "$enable_tcl" = "yes"; then
    if test -z "$TCLLIBDIR"; then
	FIND_LIB_BEGIN(tcl, TCLLIBDIR)
	for version in 8.1 8.0 7.6i 7.5i 7.6 7.5 7.4 ""; do
	    if test -n "$TCLLIBDIR"; then
		break
	    fi
	    FIND_LIB_SET(tcl$version, TCLLIBDIR, TCLLIBSTR)
	done
	FIND_LIB_END(tcl, TCLLIBDIR, enable_tcl)
    fi
    if test "$enable_tcl" = "yes"; then
	if test -r $TCLLIBDIR/tclConfig.sh; then
	    . $TCLLIBDIR/tclConfig.sh
	fi
    fi
fi

# ----------------------------------------------------------------------------
# itcl.h
# ----------------------------------------------------------------------------

if test "$enable_tcl" = "no"; then
    enable_itcl=no
fi

if test "$enable_itcl" = "yes"; then
    if test -z "$ITCLINCDIR"; then
	FIND_INC(itcl, ITCLINCDIR, enable_itcl)
    fi
fi

# ----------------------------------------------------------------------------
# libitcl ([incr Tcl])
# ----------------------------------------------------------------------------

if test "$enable_itcl" = "yes"; then
    if test -z "$ITCLLIBDIR"; then
	FIND_LIB_BEGIN(itcl, ITCLLIBDIR)
	for version in 2.1 2.0 ""; do
	    if test -n "$ITCLLIBDIR"; then
		break
	    fi
	    FIND_LIB_SET(itcl$version, ITCLLIBDIR, ITCLLIBSTR)
	done
	FIND_LIB_END(itcl, ITCLLIBDIR, enable_itcl)
    fi
fi

# ----------------------------------------------------------------------------
# tk.h
# ----------------------------------------------------------------------------

if test "$enable_tcl" = "no" -o "$enable_xwin" = "no"; then
    enable_tk=no
fi

if test "$enable_tk" = "yes"; then
    if test -z "$TKINCDIR"; then
	FIND_INC(tk, TKINCDIR, enable_tk)
    fi
fi

# ----------------------------------------------------------------------------
# libtk
# ----------------------------------------------------------------------------

if test "$enable_tk" = "yes"; then
    if test -z "$TKLIBDIR"; then
	FIND_LIB_BEGIN(tk, TKLIBDIR)
	for version in 8.1 8.0 4.2i 4.1i 4.2 4.1 4.0 ""; do
	    if test -n "$TKLIBDIR"; then
		break
	    fi
	    FIND_LIB_SET(tk$version, TKLIBDIR, TKLIBSTR)
	done
	FIND_LIB_END(tk, TKLIBDIR, enable_tk)
    fi
fi

# ----------------------------------------------------------------------------
# libitk
# ----------------------------------------------------------------------------

enable_itk="yes"
if test "$enable_tk" = "no" -o "$enable_itcl" = "no"; then
    enable_itk="no"
fi

if test "$enable_itk" = "yes"; then
    if test -z "$ITKLIBDIR"; then
	FIND_LIB_BEGIN(itk, ITKLIBDIR)
	for version in 2.1 2.0 ""; do
	    if test -n "$ITKLIBDIR"; then
		break
	    fi
	    FIND_LIB_SET(itk$version, ITKLIBDIR, ITKLIBSTR)
	done
	FIND_LIB_END(itk, ITKLIBDIR, enable_itk)
    fi
fi

if test "$enable_itcl" = "yes"; then
    AC_DEFINE(HAVE_ITCL)
fi

if test "$enable_itk" = "yes"; then
    AC_DEFINE(HAVE_ITK)
fi

# ----------------------------------------------------------------------------
# makeindex - figure out how we're gonna generate tclIndex
# ----------------------------------------------------------------------------

if test -z "$MAKEINDEX"; then
    MAKEINDEX='BOGUS'
fi

if test "$enable_tcl" = "yes"; then
    if test "$TCLLIBDIR" = "default"; then
	MAKEINDEX="/usr/bin/tclsh$TCL_VERSION"
    else
	tclbindir="`echo $TCLLIBDIR | sed 's,/lib,,'`/bin"
#	echo "tclbindir = $tclbindir"
	if test -r "$tclbindir/tclsh$TCL_VERSION"; then
	    MAKEINDEX="$tclbindir/tclsh$TCL_VERSION"
#	    echo "setting MAKEINDEX to $MAKEINDEX"
	fi
    fi
    TCL_INDEX_FILES="*.tcl"
fi

if test "$enable_itcl" = "yes"; then
    itclbindir="`echo $ITCLLIBDIR | sed 's,/lib/itcl,,'`/bin"
#    echo "itclbindir = $itclbindir"
    if test -r "$itclbindir/itclsh"; then
	MAKEINDEX="$itclbindir/itclsh"
    fi
    TCL_INDEX_FILES="*.tcl"
fi

if test "$enable_tcl" = "yes" -a "$MAKEINDEX" = "BOGUS"; then
    AC_MSG_RESULT([warning: you must edit Makefile to fix MAKEINDEX.])
fi

AC_SUBST(MAKEINDEX)
AC_SUBST(TCL_INDEX_FILES)

# ----------------------------------------------------------------------------
# dp.h
# ----------------------------------------------------------------------------

if test "$enable_tcl" = "no" -o "$enable_tk" = "no"; then
    enable_dp=no
fi

if test "$enable_dp" = "yes"; then

    if test -z "$DPINCDIR"; then
	FIND_INC(dp, DPINCDIR, enable_dp)
    fi
fi

# ----------------------------------------------------------------------------
# libdpnetwork (Tcl-DP)
# ----------------------------------------------------------------------------

if test "$enable_dp" = "yes"; then
    if test -z "$DPLIBDIR"; then
	FIND_LIB(dpnetwork, DPLIBDIR, DPLIBSTR, enable_dp)
    fi
fi

# ----------------------------------------------------------------------------
# Assemble list of tcl/TK/X/whatever include directives.  These can go in
# any order.
# ----------------------------------------------------------------------------

if test "$enable_xwin" = "yes"; then
    ADD_TO_INCS($XINCDIR, INCS, INCPATH)
fi
if test "$enable_tcl" = "yes"; then
    ADD_TO_INCS($TCLINCDIR, INCS, INCPATH)
fi
if test "$enable_dp" = "yes"; then
    ADD_TO_INCS($DPINCDIR, INCS, INCPATH)
fi
if test "$enable_itcl" = "yes"; then
    ADD_TO_INCS($ITCLINCDIR, INCS, INCPATH)
fi
if test "$enable_tk" = "yes"; then
    ADD_TO_INCS($TKINCDIR, INCS, INCPATH)
fi

# ----------------------------------------------------------------------------
# Assemble list of tcl/TK/X/whatever libraries.
# Note the library order CAN be important, depending on the system:
# The full Tcl-DP library depends on both Tk and Tcl so must come first.
# Tk depends on Tcl and X11 so must come before both.
# Itcl depends on Tcl so must come before it.
# Tcl and X11 can be put in either order.
# ----------------------------------------------------------------------------

if test "$enable_dp" = "yes"; then
    ADD_TO_LIBS($DPLIBDIR, $DPLIBSTR, LIBS, LIBPATH)
fi
if test "$enable_itk" = "yes"; then
    ADD_TO_LIBS($ITKLIBDIR, $ITKLIBSTR, LIBS, LIBPATH)
fi
if test "$enable_tk" = "yes"; then
    ADD_TO_LIBS($TKLIBDIR, $TKLIBSTR, LIBS, LIBPATH)
fi
if test "$enable_itcl" = "yes"; then
    ADD_TO_LIBS($ITCLLIBDIR, $ITCLLIBSTR, LIBS, LIBPATH)
fi
if test "$enable_tcl" = "yes"; then
    ADD_TO_LIBS($TCLLIBDIR, $TCLLIBSTR, LIBS, LIBPATH)
fi
if test "$enable_xwin" = "yes"; then
    ADD_TO_LIBS($XLIBDIR, $XLIBSTR, LIBS, LIBPATH)
fi
if test ! -z "$TCL_DL_LIBS"; then
    ADD_TO_LIBS( default, $TCL_DL_LIBS, LIBS, LIBPATH)
fi

# ----------------------------------------------------------------------------
# Debugging malloc
# Even with debugging on, is off by default, because it can dramatically
# slow down program execution (particularly in combination with Tcl/Tk).
# ----------------------------------------------------------------------------

if test "$with_dbmalloc" = "yes"; then
    if test -z "$DBMALLOCLIBDIR"; then
	libdirs="\
	$prefix/lib \
	$HOME/local/lib \
	$HOME/dbmalloc/lib \
	$HOME/lib \
	/usr/local/lib \
	/usr/local/dbmalloc/lib \
	/usr/lib"

	FIND_LIB(dbmalloc, DBMALLOCLIBDIR, with_dbmalloc)
    fi
    if test -n "$DBMALLOCLIBDIR"; then
	ADD_TO_LIBS($DBMALLOCLIBDIR, -ldbmalloc, LIBS, LIBPATH)
    fi
fi

if test "$with_dbmalloc" = "yes"; then
    if test -z "$DBMALLOCINCDIR"; then
	incdirs="\
	$prefix/include \
	$HOME/local/include \
	$HOME/local/dbmalloc/include \
	$HOME/include \
	$HOME/debug_include \
	/usr/local/dbmalloc/include \
	/usr/local/debug_include"

	FIND_INC(malloc, DBMALLOCINCDIR, with_dbmalloc)
    fi
    if test -n "$DBMALLOCINCDIR"; then
	ADD_TO_INCS($DBMALLOCINCDIR, INCS, INCPATH)
    fi
fi

if test "with_dbmalloc" = "yes"; then
    AC_DEFINE(DEBUGGING_MALLOC)
fi

# -----------------------------------------------------------------------
# Python include and machdep directories
# -----------------------------------------------------------------------

if test "$enable_python" = "yes"; then
    if test "$with_shlib" = "no"; then
	AC_MSG_RESULT([warning: python support requires with_shlib=yes, setting enable_python=no])
	enable_python=no
    fi
fi

if test "$enable_python" = "yes"; then
    if test -z "$PYTHON_INC_DIR" -o ! -d "$PYTHON_INC_DIR"; then
	incdirs="\
	$prefix/include/python1.5 \
	/usr/include/python1.5 \
	$prefix/include/Py \
	$HOME/local/include/Py \
	$HOME/local/python/include/Py \
	$HOME/include/Py \
	/usr/local/python/include/Py \
	/usr/local/python-1.2/include/Py \
	/usr/local/include/Py"

# Should probably just drop everything after /usr/include/python1.4,
# have to think about it.

	FIND_INC(Python, PYTHON_INC_DIR, enable_python)

	if test "$enable_python" = "yes"; then
	    FIND_INC(arrayobject, PYTHON_INC_DIR, numeric_python)
	    if test "$numeric_python" = "no"; then
		AC_MSG_RESULT([plmodule needs Python numeric extension.])
		AC_MSG_RESULT([Setting enable_python to no])
		enable_python=no
	    fi
	fi
    fi
fi

if test "$enable_python" = "yes"; then
    if test -z "$PYTHON_MOD_DIR" -o ! -d "$PYTHON_MOD_DIR"; then
	if test -z "$MACHDEP"; then
	    ac_sys_system=`uname -s | tr -d ' ' | tr '[[A-Z]]' '[[a-z]]'`
	    ac_sys_release=`uname -r | tr -d ' ' | sed 's/\..*//'`
	    MACHDEP="$ac_sys_system$ac_sys_release"
	    case MACHDEP in
		'')	MACHDEP=unknown;;
	    esac
	fi

	python_dir=`echo $PYTHON_INC_DIR|sed 's,/[[^/]]*/[[^/]]*$,,'`
        # Changed by Rafael Laboissiere <rafael@icp.inpg.fr>
	# on Mon Oct 12 11:12:00 CEST 1998
        # (For the Debian plplot package).
	# PYTHON_MOD_DIR=$python_dir/lib/python
        PYTHON_MOD_DIR=$prefix/lib/python
	PYTHON_MACH_DIR=$PYTHON_MOD_DIR/$MACHDEP
	if test ! -d "$PYTHON_MOD_DIR"; then
	    # tricky, must be a new style
	    python_ver=`echo $PYTHON_INC_DIR|sed 's,/.*/,,'`
            # Changed by Rafael Laboissiere <rafael@icp.inpg.fr>
	    # on Mon Oct 12 11:12:00 CEST 1998
	    # (For the Debian plplot package).
	    # PYTHON_MOD_DIR=$python_dir/lib/$python_ver
            PYTHON_MOD_DIR=$prefix/lib/$python_ver
	    PYTHON_MACH_DIR=$PYTHON_MOD_DIR/$MACHDEP
	    if test ! -d "$PYTHON_MOD_DIR"; then
		enable_python=no

		AC_MSG_RESULT([PYTHON_MOD_DIR not found, setting enable_python to no])
		enable_python=no
	    fi

	fi
	# Changed by Rafael Laboissiere <rafael@icp.inpg.fr>
        # on Mon Oct 12 11:12:00 CEST 1998
	# (For the Debian plplot package).
	# PYTHON_CFG_DIR=$PYTHON_MOD_DIR/config
        PYTHON_CFG_DIR=$python_dir/lib/$python_ver/config
    fi
fi

AC_SUBST(PYTHON_INC_DIR)
AC_SUBST(PYTHON_MOD_DIR)
AC_SUBST(PYTHON_MACH_DIR)
AC_SUBST(PYTHON_CFG_DIR)

# ----------------------------------------------------------------------------
# libf2c
# ----------------------------------------------------------------------------

if test "$with_f2c" = "yes"; then
    AC_CHECK_LIB(f2c, main, [LIBS="$LIBS -lf2c"],
    AC_MSG_RESULT(warning: libf2c not found))
fi

# ----------------------------------------------------------------------------
# linuxvga support
# ----------------------------------------------------------------------------

if test "$enable_linuxvga" = "yes"; then
    if test -z "$VGALIBDIR"; then
	libdirs="\
	$prefix/lib \
	/usr/lib"

	FIND_LIB(vga, VGALIBDIR, VGALIBSTR, enable_linuxvga)	
    fi
    if test -n "$VGALIBDIR"; then
	ADD_TO_LIBS($VGALIBDIR, -lvga, LIBS, LIBPATH)
    fi
fi

# ----------------------------------------------------------------------------
# Check for the existence of various libraries.  The order here is
# important, so that then end up in the right order in the command line
# generated by Make.  I put these in the variable EXTRA_LIBS so that
# you can set it yourself and leave LIBS up to the script to get right.
#
# Most of this is copied from the BLT configure script.  Dunno if the
# Xbsd library is really needed.  libsocket and libnsl are needed on
# some SysV systems.  libieee.a is supposed to be a Linux deal, dunno if
# it's important either.
#
# On some systems the linker doesn't return an error code to the shell if
# you try to link with nonexistant libraries, so need to handle these
# explicitly.
#
# Note: using Autoconf-2.3, these tests do not work right when LIBS is set.
# So save the value and set it to null temporarily, restoring when done.
# ----------------------------------------------------------------------------

if test -z "$EXTRA_LIBS"; then
    EXTRA_LIBS=
    SAVE_LIBS=$LIBS
    LIBS=
    case $system in 
	CRAY* ) 
	    EXTRA_LIBS="$EXTRA_LIBS -lm"
	;;
	irix*|IRIX*|Irix*|sgi*|SGI* ) 
	    EXTRA_LIBS="$EXTRA_LIBS -lm"
	;;
	HP-UX* )
	    EXTRA_LIBS="-ldld -lm"
	;;
	Linux* )
	    EXTRA_LIBS="-ldl -lm"
	;;
	* ) 	
	    AC_CHECK_LIB(Xbsd,   main, [EXTRA_LIBS="$EXTRA_LIBS -lXbsd"])
	    AC_CHECK_LIB(socket, main, [EXTRA_LIBS="$EXTRA_LIBS -lsocket"])
	    AC_CHECK_LIB(nsl,    main, [EXTRA_LIBS="$EXTRA_LIBS -lnsl"])
	    AC_CHECK_LIB(ieee,   main, [EXTRA_LIBS="$EXTRA_LIBS -lieee"])
	    AC_CHECK_LIB(m,      main, [EXTRA_LIBS="$EXTRA_LIBS -lm"])
	;;
    esac
    LIBS=$SAVE_LIBS
fi

LIBS="$LIBS $EXTRA_LIBS"

AC_SUBST(INCS)
AC_SUBST(LIBS)

# ----------------------------------------------------------------------------
# Set up shared library support.
# VERY system dependent.
# Originally based on BLT's configure.in.
# This is really a mess.
# ----------------------------------------------------------------------------

if test "$with_shlib" = "yes"; then
    AC_MSG_CHECKING(how to make shared libraries)

    SA=".sa"
    SO=".so"
    LDSHARED="ld"
    SHLIB_LIBS=$LIBS

    if test "$with_gcc" = "yes"; then
	SHLIB_CCFLAGS="-fpic -fPIC"
	SHLIB_CXXFLAGS="-fpic -fPIC"
	SHLIB_BUILD="gcc -shared -fpic -fPIC -lc -o"
    else
	SHLIB_CCFLAGS=
	SHLIB_CXXFLAGS=
	SHLIB_BUILD=
    fi

    case "$system" in 
	SunOS-4* ) 
	    SHLIB_F77FLAGS=-pic
	    # Forget version numbers for now
	    #	SO='.so.$(MAJOR_VERSION).$(MINOR_VERSION)'
	    #	SA='.sa.$(MAJOR_VERSION).$(MINOR_VERSION)'
	    AC_MSG_RESULT(okay)
	    if test "$with_gcc" = "no"; then
		SHLIB_CCFLAGS=-pic
		SHLIB_CXXFLAGS=-pic
		SHLIB_BUILD="ld -assert pure-text -o"
	    fi
	;;
	SCO* ) 
#	    SO='.so.$(MAJOR_VERSION).$(MINOR_VERSION)'
#	    SA='.sa.$(MAJOR_VERSION).$(MINOR_VERSION)'
	    AC_MSG_RESULT([Assuming sco-3.2v5 with gcc. Otherwise, reconfigure --without-shlib])
		SOVERSION='$(MAJOR_VERSION).$(MINOR_VERSION)'
		LDSHARED='gcc -fpic -shared'
		SHLIB_BUILD="gcc -shared -fpic -o"
	;;
	Linux* )
            # Added by Rafael Laboissiere <rafael@icp.inpg.fr>
            # on Sat Nov  6 20:57:55 CET 1999  
	    SHLIB_F77FLAGS="-fpic -fPIC"

	    # Should do something to make sure this is an ELF system, as
	    # don't have patience for DLL...
	    AC_MSG_RESULT([Assuming Linux ELF.  Otherwise, reconfigure --without-shlib])
#	    SO='.so.$(MAJOR_VERSION).$(MINOR_VERSION)'
	    SHLIB_BUILD="gcc -shared -fpic -fPIC -lc -o"

	    SOVERSION='$(MAJOR_VERSION).$(MINOR_VERSION)'

	    # Hmm, would be good to replace that trailing .0 with the
	    # compilation number or some such.  Have to think about that.

	    LDSHARED='gcc -fpic -shared'
	;;
	HP-UX-* )
	    SO=".sl"
	    SHLIB_F77FLAGS="+z"
	    AC_MSG_RESULT(okay)
	    if test "$with_gcc" = "no"; then
		SHLIB_CCFLAGS=+z
		SHLIB_CXXFLAGS=+z
		SHLIB_F77FLAGS=+z
		SHLIB_BUILD="ld -b -o"
	    else
		AC_MSG_RESULT(warning: shared libs on HP with gcc is experimental)
	    fi
	    LDSHARED="ld -b"
	;;
	AIX-* )
	    SO=".a"
	    SHLIB_F77FLAGS=-fpic
	    if test "$with_gcc" = "no"; then
		AC_MSG_RESULT(okay)
		SHLIB_CCFLAGS=-fpic
		SHLIB_CXXFLAGS=-fpic
		SHLIB_BUILD="ar q"
		if test "$enable_cxx" = "yes"; then
		    SHLIB_LIBS="-L/usr/lpp/xlC/lib -lC $LIBS"
		fi
	    else
		with_shlib=no
	    fi
	;;

	# The rest are probably broken.  Someone please fix them.
	# Remove the 'with_shlib=no' line, comments, and go wild.

	SunOS-5* )
	    with_shlib=no
	    AC_MSG_RESULT(unknown)
	    #	SHLIB_CCFLAGS="-K pic"
	    #	SHLIB_F77FLAGS="-K pic"
	    #	SHLIB_BUILD="$CC '-G -ztext -h $(SHARED_LIBRARY)'"
	    #	SHLIB_SUFFIX='.so.$(MAJOR_VERSION)'
	    LDSHARED="ld -G"
	;;
	OSF-1.* )
	    with_shlib=no
	    AC_MSG_RESULT(unknown)
	    #	SHLIB_CCFLAGS=-fpic
	    #	SHLIB_F77FLAGS=-fpic
	    #	SHLIB_BUILD="$CC -shared"
	    #	SHLIB_SUFFIX='.so.$(MAJOR_VERSION)'
	    LDSHARED="ld -shared -expect_unresolved \"*\""
	;;
	IRIX-5.*|IRIX64-6.* )
	    AC_MSG_RESULT(okay)
	    SHLIB_BUILD="$CC -shared -o"
	    LDSHARED="ld -shared"
	    RPATH="-rpath ."
	;;
	* )
	    with_shlib=no
	    AC_MSG_RESULT(unknown)
	;;
    esac
fi

AC_SUBST(SHLIB_BUILD)
AC_SUBST(SA)
AC_SUBST(SO)
AC_SUBST(LDSHARED)
AC_SUBST(RPATH)

AC_SUBST(SOVERSION)

AC_SUBST(SHLIB_CCFLAGS)
AC_SUBST(SHLIB_CXXFLAGS)
AC_SUBST(SHLIB_F77FLAGS)
AC_SUBST(SHLIB_LIBS)

