# Process this file with autoconf to produce a configure script.
AC_INIT()

VTK_OBJ=`pwd`
AC_SUBST(VTK_OBJ)

#
# check for some programs we use
#
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
AC_PATH_XTRA

# get byte swapping info
AC_C_BIGENDIAN
if test $ac_cv_c_bigendian = yes; then
  BIGENDIAN="-DVTK_WORDS_BIGENDIAN"
fi
AC_SUBST(BIGENDIAN)

# some stuff Tcl uses
#
AC_CHECK_HEADER(limits.h, HAVE_LIMITS_H=-DHAVE_LIMITS_H,HAVE_LIMITS_H="")
AC_SUBST(HAVE_LIMITS_H)
AC_HAVE_HEADERS(unistd.h, HAVE_UNISTD_H=-DHAVE_UNISTD_H,HAVE_UNISTD_H="")
AC_SUBST(HAVE_UNISTD_H)

# Step 1: set the variable "system" to hold the name and version number
# for the system.  This can usually be done via the "uname" command, but
# there are a few systems, like Next, where this doesn't work.

AC_MSG_CHECKING([system version (for dynamic loading)])
if test -f /usr/lib/NextStep/software_version; then
  system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
else
    system=`uname -s`-`uname -r`
    if test "$?" -ne 0 ; then
	AC_MSG_RESULT([unknown (can't find uname command)])
	system=unknown
    else
	# Special check for weird MP-RAS system (uname returns weird
	# results, and the version is kept in special file).
    
	if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
	    system=MP-RAS-`awk '{print $3}' /etc/.relid'`
	fi
	AC_MSG_RESULT($system)
    fi
fi

##########################
##			##
##	Starbase	##
##			##
##########################
use_sbr=no
AC_CHECK_HEADERS(starbase.c.h, [use_sbr=yes])

GRAPHICS_API_LIBS=""
GRAPHICS_API_FLAGS=""
GRAPHICS_API_OBJ=""

if test "$use_sbr" = "yes"; then
  case $system in
    HP-UX-*.10.*)
	GRAPHICS_API_LIBS="${GRAPHICS_API_LIBS} -L/opt/graphics/common/lib -ldld -lXwindow -lhpgfx -lXhp11"
	GRAPHICS_API_OBJ="${GRAPHICS_API_OBJ} \${SBR_OBJ}"
	GRAPHICS_API_FLAGS="${GRAPHICS_API_FLAGS} -DVTK_USE_SBR"
	;;
    HP-UX-*.08.*|HP-UX-*.09.*)
	GRAPHICS_API_LIBS="${GRAPHICS_API_LIBS} -ldld -lXwindow -lsb -lXhp11"
	GRAPHICS_API_OBJ="${GRAPHICS_API_OBJ} \${SBR_OBJ}"
	GRAPHICS_API_FLAGS="${GRAPHICS_API_FLAGS} -DVTK_USE_SBR"
        ;;
  esac
fi

##########################
##			##
##	SGI GL		##
##			##
##########################
use_glr=no
AC_CHECK_HEADERS(gl/gl.h, [use_glr=yes])
AC_ARG_WITH(gl,
         [  --without-gl          do not use the gl graphics classes],
         [use_glr=$withval])

# only allow gl on SGIs some Linux boxes were getting confused
#
if test "$use_glr" = "yes"; then
  case $system in
    IRIX*)
	GRAPHICS_API_LIBS="${GRAPHICS_API_LIBS} -lgl"
	GRAPHICS_API_OBJ="${GRAPHICS_API_OBJ} \${GLR_OBJ}"
	GRAPHICS_API_FLAGS="${GRAPHICS_API_FLAGS} -DVTK_USE_GLR"
	;;
  esac
fi

##########################
##			##
##	OpenGL		##
##			##
##########################
use_oglr=no
# check for mesa
use_mesa_oglr=no
AC_ARG_WITH(mesa,
         [  --with-mesa               use the mesa opengl package],
         [use_oglr=yes]
	 [use_mesa_oglr=yes])

OGLR_INCLUDE=""
AC_CHECK_HEADERS(GL/gl.h, [use_oglr=yes])
AC_CHECK_HEADERS(/usr/openwin/share/include/GL/glxmd.h, 
		[use_oglr=yes]
		OGLR_INCLUDE="-I/usr/openwin/share/include/")
AC_CHECK_HEADERS(/opt/graphics/OpenGL/include/GL/glxmd.h, 
		[use_oglr=yes]
		OGLR_INCLUDE="-I/opt/graphics/OpenGL/include")

if test "$use_oglr" = "yes"; then
	GRAPHICS_API_OBJ="${GRAPHICS_API_OBJ} \${OGLR_OBJ}"

	if test "$use_mesa_oglr" = "yes"; then
	        GRAPHICS_API_LIBS="${GRAPHICS_API_LIBS} \${MESA_LIB}"
	        GRAPHICS_API_FLAGS="${GRAPHICS_API_FLAGS} \${MESA_INCLUDE} -DVTK_USE_OGLR"
	else
	        GRAPHICS_API_LIBS="${GRAPHICS_API_LIBS} -lGL"
	        GRAPHICS_API_FLAGS="${GRAPHICS_API_FLAGS} -DVTK_USE_OGLR ${OGLR_INCLUDE}"
	fi
fi

##########################
##			##
##	   XGL		##
##			##
##########################
use_xglr=no
# Check if the user set up XGL_HOME
if test "X$XGL_HOME" = "X" ; then
	XGL_HOME=/opt/SUNWits/Graphics-sw/xgl
fi

AC_CHECK_HEADERS(/usr/openwin/include/xgl/xgl.h, 
  [use_xglr=yes]
  XGLR_INCLUDE=/usr/openwin/include)
AC_CHECK_HEADERS($XGL_HOME/include/xgl/xgl.h, 
  [use_xglr=yes]
  XGLR_INCLUDE=$XGL_HOME/include)
if test "$use_xglr" = "yes"; then
        XGLR_LIBS="-R${XGL_HOME}/lib -L${XGL_HOME}/lib -lxgl"
        if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
          XGLR_LIBS="-Wl,-R${XGL_HOME}/lib -L${XGL_HOME}/lib -lxgl"
        fi
	GRAPHICS_API_LIBS="${GRAPHICS_API_LIBS} ${XGLR_LIBS}"
	GRAPHICS_API_OBJ="${GRAPHICS_API_OBJ} \${XGLR_OBJ}"
	GRAPHICS_API_FLAGS="${GRAPHICS_API_FLAGS} -DVTK_USE_XGLR -I${XGLR_INCLUDE}"
fi

AC_SUBST(GRAPHICS_API_OBJ)
AC_SUBST(GRAPHICS_API_FLAGS)
AC_SUBST(GRAPHICS_API_LIBS)

ac_save_path="$PATH"
PATH=/usr/gfx
AC_CHECK_PROG(HAVE_SETMON, setmon, -DHAVE_SETMON)
PATH="$ac_save_path"
AC_SUBST(HAVE_SETMON)

#
# use shared libs
#
AC_ARG_WITH(shared,
         [  --with-shared               create shared libraries],
         [vtk_shared_ok=$withval], [vtk_shared_ok=no])

INSTALL_TARGET="install"
AC_ARG_WITH(tcl,
         [  --with-tcl              build vtk the tcl based interpreter],
	 if test "$withval" = yes; then
         tcldir=tcl
         BUILD_TCL=build_tcl
         INSTALL_TARGET="${INSTALL_TARGET}_tcl"
         CLEAN_TCL=clean_tcl
         fi)

AC_SUBST(BUILD_TCL)
AC_SUBST(CLEAN_TCL)

USE_TOOLKIT_FLAGS=""

AC_ARG_WITH(java,
         [  --with-java             build vtk with java support],
	 if test "$withval" = yes; then
         javadir=java
         INSTALL_TARGET="${INSTALL_TARGET}_java"
         BUILD_JAVA=build_java
         CLEAN_JAVA=clean_java
         fi)

AC_SUBST(BUILD_JAVA)
AC_SUBST(CLEAN_JAVA)

AC_ARG_WITH(python,
         [  --with-python             build vtk with python support],
	 if test "$withval" = yes; then
         INSTALL_TARGET="${INSTALL_TARGET}_python"
         BUILD_PYTHON=build_python
         CLEAN_PYTHON=clean_python
         fi)

AC_SUBST(BUILD_PYTHON)
AC_SUBST(CLEAN_PYTHON)
AC_SUBST(INSTALL_TARGET)

BUILD_TOOLKITS=""
CLEAN_TOOLKITS=""
DEPEND_TOOLKITS=""
INSTALL_TOOLKITS=""

AC_ARG_WITH(graphics,
         [  --without-graphics      do not include the graphics classes],
	 if test "$withval" = yes; then
         graphicsdir=graphics
         USE_GRAPHICS_LIBS="-L\${VTK_OBJ}/graphics -lVTKGraphicsTcl"
         USE_GRAPHICS_JAVA="-L\${VTK_OBJ}/graphics -lVTKGraphicsJava"
         USE_TOOLKIT_FLAGS="${USE_TOOLKIT_FLAGS} -I\${srcdir}/../graphics -DVTK_USE_GRAPHICS"
         INSTALL_TOOLKITS="${INSTALL_TOOLKITS} install_graphics"
         BUILD_TOOLKITS="${BUILD_TOOLKITS} build_graphics"
         DEPEND_TOOLKITS="${DEPEND_TOOLKITS} depend_graphics"
         CLEAN_TOOLKITS="${CLEAN_TOOLKITS} clean_graphics"
         fi
         ,
         graphicsdir=graphics
         USE_GRAPHICS_LIBS="-L\${VTK_OBJ}/graphics -lVTKGraphicsTcl"
         USE_GRAPHICS_JAVA="-L\${VTK_OBJ}/graphics -lVTKGraphicsJava"
         USE_TOOLKIT_FLAGS="${USE_TOOLKIT_FLAGS} -I\${srcdir}/../graphics -DVTK_USE_GRAPHICS"
         INSTALL_TOOLKITS="${INSTALL_TOOLKITS} install_graphics"
         BUILD_TOOLKITS="${BUILD_TOOLKITS} build_graphics"
         DEPEND_TOOLKITS="${DEPEND_TOOLKITS} depend_graphics"
         CLEAN_TOOLKITS="${CLEAN_TOOLKITS} clean_graphics")

AC_ARG_WITH(imaging,
         [  --without-imaging       do not include the imaging classes],
	 if test "$withval" = yes; then
         imagingdir=imaging
         USE_IMAGING_LIBS="-L\${VTK_OBJ}/imaging -lVTKImagingTcl"
         USE_IMAGING_JAVA="-L\${VTK_OBJ}/imaging -lVTKImagingJava"
         USE_TOOLKIT_FLAGS="${USE_TOOLKIT_FLAGS} -I\${srcdir}/../imaging -DVTK_USE_IMAGING"
         INSTALL_TOOLKITS="${INSTALL_TOOLKITS} install_imaging"
         BUILD_TOOLKITS="${BUILD_TOOLKITS} build_imaging"
         DEPEND_TOOLKITS="${DEPEND_TOOLKITS} depend_imaging"
         CLEAN_TOOLKITS="${CLEAN_TOOLKITS} clean_imaging"
         fi,
         imagingdir=imaging
         USE_IMAGING_LIBS="-L\${VTK_OBJ}/imaging -lVTKImagingTcl"
         USE_IMAGING_JAVA="-L\${VTK_OBJ}/imaging -lVTKImagingJava"
         USE_TOOLKIT_FLAGS="${USE_TOOLKIT_FLAGS} -I\${srcdir}/../imaging -DVTK_USE_IMAGING"
         INSTALL_TOOLKITS="${INSTALL_TOOLKITS} install_imaging"
         BUILD_TOOLKITS="${BUILD_TOOLKITS} build_imaging"
         DEPEND_TOOLKITS="${DEPEND_TOOLKITS} depend_imaging"
         CLEAN_TOOLKITS="${CLEAN_TOOLKITS} clean_imaging")

AC_ARG_WITH(tkwidget,
         [  --with-tkwidget           build the vtkTkRenderWidget class],,)

AC_ARG_WITH(patented,
         [  --with-patented           include the patented classes],
	 if test "$withval" = yes; then
         patenteddir=patented
         USE_PATENTED_LIBS="-L\${VTK_OBJ}/patented -lVTKPatentedTcl"
         USE_PATENTED_JAVA="-L\${VTK_OBJ}/patented -lVTKPatentedJava"
         USE_TOOLKIT_FLAGS="${USE_TOOLKIT_FLAGS} -I\${srcdir}/../patented -DVTK_USE_PATENTED"
         INSTALL_TOOLKITS="${INSTALL_TOOLKITS} install_patented"
         BUILD_TOOLKITS="${BUILD_TOOLKITS} build_patented"
         DEPEND_TOOLKITS="${DEPEND_TOOLKITS} depend_patented"
         CLEAN_TOOLKITS="${CLEAN_TOOLKITS} clean_patented"
         fi,)

AC_ARG_WITH(contrib,
         [  --with-contrib          include the contrib classes],
	 if test "$withval" = yes; then
         contribdir=contrib
         USE_CONTRIB_LIBS="-L\${VTK_OBJ}/contrib -lVTKContribTcl"
         USE_CONTRIB_JAVA="-L\${VTK_OBJ}/contrib -lVTKContribJava"
         USE_TOOLKIT_FLAGS="${USE_TOOLKIT_FLAGS} -I\${srcdir}/../contrib -DVTK_USE_CONTRIB"
         INSTALL_TOOLKITS="${INSTALL_TOOLKITS} install_contrib"
         BUILD_TOOLKITS="${BUILD_TOOLKITS} build_contrib"
         DEPEND_TOOLKITS="${DEPEND_TOOLKITS} depend_contrib"
         CLEAN_TOOLKITS="${CLEAN_TOOLKITS} clean_contrib"
         fi,)

AC_SUBST(BUILD_TOOLKITS)
AC_SUBST(INSTALL_TOOLKITS)
AC_SUBST(DEPEND_TOOLKITS)
AC_SUBST(CLEAN_TOOLKITS)

# option for handling BSD style makefile includes
#
AC_ARG_WITH(bsdmake,
         [  --with-bsdmake            uses bsd style makefile includes],
	 if test "$withval" = yes; then
         MAKEINCLUDE=".include"
         MAKEQUOTE='"'
         fi,
         MAKEINCLUDE="include"
         MAKEQUOTE='')
AC_SUBST(MAKEINCLUDE)
AC_SUBST(MAKEQUOTE)


#------------------------------------------------------------------------------
#       If user.make is not in the build directory, copy it local.
#------------------------------------------------------------------------------

if test ! -r user.make
then
    echo "Copying $srcdir/user.make to build directory"
    cp $srcdir/user.make  user.make || exit 1
fi


# the following is an excerpt from the tcl7.5b2 configure.in
#--------------------------------------------------------------------
#	The statements below define a collection of symbols related to
#	dynamic loading and shared libraries:
#
#	SHLIB_CFLAGS -	Flags to pass to cc when compiling the components
#			of a shared library (may request position-independent
#			code, among other things).
#	SHLIB_LD_LIBS -	Dependent libraries for the linker to scan when
#			creating shared libraries.  This symbol typically
#			goes at the end of the "ld" commands that build
#			shared libraries. The value of the symbol if
#			"${LIBS}" if all of the dependent libraries should
#			be specified when creating a shared library.  If
#			dependent libraries should not be specified (as on
#			SunOS 4.x, where they cause the link to fail, or in
#			general if Tcl and Tk aren't themselves shared
#			libraries), then this symbol has an empty string
#			as its value.
#	SHLIB_SUFFIX -	Suffix to use for the name of the shared library.  An
#			empty string means we don't know how to use shared
#			libraries on this platform.
#	VTK_SHLIB_BUILD_FLAGS -
#                       Flags to use when building a shared library.	
#	VTK_SHLIB_LINK_FLAGS -	
#                       Flags to pass to the compiler when linking object
#			files into an executable application binary such
#			as tclsh.
#--------------------------------------------------------------------


# Step 2: check for existence of -ldl library.  This is needed because
# Linux can use either -ldl or -ldld for dynamic loading.

AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)

# Step 4: set configuration options based on system name and version.

fullSrcDir=`cd $srcdir; pwd`
case $system in
    AIX-*)
	# AIX: can't link shared library extensions unless Tcl and Tk are
	# also shared libraries.
	SHLIB_CFLAGS=""
	SHLIB_LD_LIBS='${LIBS}'
	SHLIB_SUFFIX="..o"
	DL_LIBS=""
        AC_CHECK_LIB(ld,printf, DL_LIBS="-lld")
	VTK_SHLIB_LINK_FLAGS=""
	;;
    HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
	SHLIB_CFLAGS="+z"
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".sl"
	DL_LIBS="-ldld"
	VTK_SHLIB_BUILD_FLAGS='+Z -Wl,-E -Wl,-b'
	VTK_SHLIB_LINK_FLAGS='-Wl,+s -Wl,+b,${LIB_RUNTIME_DIR}'
        if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
  	  VTK_SHLIB_BUILD_FLAGS='-shared -Wl,-E -Wl,-b'
	  VTK_SHLIB_LINK_FLAGS='-Wl,+s -Wl,+b,${LIB_RUNTIME_DIR}'
        fi
	;;
    IRIX-5.*)
	SHLIB_CFLAGS=""
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".so"
	DL_LIBS=""
	VTK_SHLIB_BUILD_FLAGS="-shared -rdata_shared"
	;;
    IRIX64-6* | IRIX-64-6*)
	SHLIB_CFLAGS=""
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".so"
	DL_LIBS=""
	VTK_SHLIB_BUILD_FLAGS="-shared -rdata_shared"
	;;
    Linux*)
	SHLIB_CFLAGS="-fPIC"
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".so"
	VTK_SHLIB_BUILD_FLAGS="-shared -rdata_shared"
	if test "$have_dl" = yes; then
	    DL_LIBS="-ldl"
	    VTK_SHLIB_LINK_FLAGS="-rdynamic"
	else
	    AC_CHECK_HEADER(dld.h, [
		DL_LIBS="-ldld"
		VTK_SHLIB_LINK_FLAGS=""])
	fi
	;;
    MP-RAS-02*)
	SHLIB_CFLAGS="-K PIC"
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".so"
	DL_LIBS="-ldl"
	VTK_SHLIB_LINK_FLAGS=""
	;;
    MP-RAS-*)
	SHLIB_CFLAGS="-K PIC"
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".so"
	DL_LIBS="-ldl"
	VTK_SHLIB_LINK_FLAGS="-Wl,-Bexport"
	;;
    NetBSD-*|FreeBSD-*)
	# Not available on all versions:  check for include file.
	if test -f /usr/include/dlfcn.h; then
	    SHLIB_CFLAGS="-fpic"
	    SHLIB_LD_LIBS=""
	    SHLIB_SUFFIX=".so"
	    DL_LIBS=""
	    VTK_SHLIB_LINK_FLAGS=""
	else
	    SHLIB_CFLAGS=""
	    SHLIB_LD_LIBS=""
	    SHLIB_SUFFIX="..o"
	    DL_LIBS=""
	    VTK_SHLIB_LINK_FLAGS=""
	fi
	;;
    NEXTSTEP-*)
	SHLIB_CFLAGS=""
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".so"
	DL_LIBS=""
	VTK_SHLIB_LINK_FLAGS=""
	;;
    OSF1-1.[012])
	# OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
	SHLIB_CFLAGS=""
	# Hack: make package name same as library name
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".so"
	DL_LIBS=""
	VTK_SHLIB_LINK_FLAGS=""
	;;
    OSF1-1.*)
	# OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
	SHLIB_CFLAGS="-fpic"
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".so"
	DL_LIBS=""
	VTK_SHLIB_LINK_FLAGS=""
	;;
    OSF1-V*)
        # Digital OSF/1
	SHLIB_CFLAGS=""
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".so"
	DL_LIBS=""
	VTK_SHLIB_BUILD_FLAGS='-shared -Wl,-expect_unresolved,"*"'
	VTK_SHLIB_LINK_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
	;;
    RISCos-*)
	SHLIB_CFLAGS="-G 0"
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX="..o"
	DL_LIBS=""
	VTK_SHLIB_LINK_FLAGS="-Wl,-D,08000000"
	;;
    SCO_SV-3.2*)
        # Note, dlopen is available only on SCO 3.2.5 and greater.  However,
        # this test works, since "uname -s" was non-standard in 3.2.4 and
        # below.
	SHLIB_CFLAGS="-Kpic -belf"
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".so"
	DL_LIBS=""
	VTK_SHLIB_LINK_FLAGS="-belf -Wl,-Bexport"
	;;
     SINIX*5.4*)
	SHLIB_CFLAGS="-K PIC"
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".so"
	DL_LIBS="-ldl"
	VTK_SHLIB_LINK_FLAGS=""
	;;
    SunOS-4*)
	SHLIB_CFLAGS="-PIC"
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".so"
	DL_LIBS="-ldl"
	VTK_SHLIB_BUILD_FLAGS='-shared -Wl,-r -nostdlib'
	VTK_SHLIB_LINK_FLAGS='-Wl,-L${LIB_RUNTIME_DIR}'
	;;
    SunOS-5*)
	SHLIB_CFLAGS="-KPIC"
	SHLIB_LD_LIBS='${LIBS}'
	SHLIB_SUFFIX=".so"
	DL_LIBS="-ldl"
	VTK_SHLIB_BUILD_FLAGS='-G'
	VTK_SHLIB_LINK_FLAGS='-R ${LIB_RUNTIME_DIR}'
        if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
	  VTK_SHLIB_BUILD_FLAGS='-Wl,-G'
	  VTK_SHLIB_LINK_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
        fi
	;;
    ULTRIX-4.*)
	SHLIB_CFLAGS="-G 0"
	SHLIB_SUFFIX="..o"
	SHLIB_LD_LIBS=""
	DL_LIBS=""
	VTK_SHLIB_LINK_FLAGS="-Wl,-D,08000000"
	;;
    UNIX_SV*)
	SHLIB_CFLAGS="-K PIC"
	SHLIB_LD_LIBS=""
	SHLIB_SUFFIX=".so"
	DL_LIBS="-ldl"
	VTK_SHLIB_LINK_FLAGS="-Wl,-Bexport"
	;;
esac

# If we're running gcc, then change the C flags for compiling shared
# libraries to the right flags for gcc, instead of those for the
# standard manufacturer compiler.
if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
  SHLIB_CFLAGS="-fPIC"
fi

if test "$vtk_shared_ok" = "yes"; then
    VTK_SHLIB_CFLAGS="${SHLIB_CFLAGS}"
    VTK_LD_SEARCH_FLAGS="${LD_SEARCH_FLAGS}"
    VTK_TCL_SHLIB_TARGET="vtktcl"
    RANLIB=":"
    TOOLKIT_DEPENDS=""
    VTK_LIB_EXT="${SHLIB_SUFFIX}"
else
    VTK_LIB_EXT=".a"
    SHLIB_LD_LIBS=""
    VTK_SHLIB_CFLAGS=""
    VTK_LD_SEARCH_FLAGS=""
    TOOLKIT_DEPENDS="../common/libVTKCommonTcl.a"
    if test "X$graphicsdir" != "X"; then
       TOOLKIT_DEPENDS="${TOOLKIT_DEPENDS} \${VTK_OBJ}/graphics/libVTKGraphicsTcl.a"
    fi
    if test "X$imagingdir" != "X"; then
       TOOLKIT_DEPENDS="${TOOLKIT_DEPENDS} \${VTK_OBJ}/imaging/libVTKImagingTcl.a"
    fi
    if test "X$patenteddir" != "X"; then
       TOOLKIT_DEPENDS="${TOOLKIT_DEPENDS} \${VTK_OBJ}/patented/libVTKPatentedTcl.a"
    fi
    if test "X$contribdir" != "X"; then
       TOOLKIT_DEPENDS="${TOOLKIT_DEPENDS} \${VTK_OBJ}/contrib/libVTKContribTcl.a"
    fi
fi

AC_SUBST(VTK_TCL_SHLIB_TARGET)

AC_SUBST(USE_GRAPHICS_LIBS)
AC_SUBST(USE_IMAGING_LIBS)
AC_SUBST(USE_PATENTED_LIBS)
AC_SUBST(USE_CONTRIB_LIBS)

AC_SUBST(USE_GRAPHICS_JAVA)
AC_SUBST(USE_IMAGING_JAVA)
AC_SUBST(USE_PATENTED_JAVA)
AC_SUBST(USE_CONTRIB_JAVA)

AC_SUBST(TOOLKIT_DEPENDS)
AC_SUBST(USE_TOOLKIT_FLAGS)

AC_SUBST(VTK_SHLIB_LINK_FLAGS)
AC_SUBST(VTK_SHLIB_BUILD_FLAGS)

AC_SUBST(VTK_SHLIB_CFLAGS)
AC_SUBST(VTK_LIB_EXT)
AC_SUBST(DL_LIBS)
AC_SUBST(SHLIB_LD_LIBS)
AC_SUBST(SHLIB_SUFFIX)

##########################
##			##
## Check thread support ##
##			##
##########################
THREAD_LIBS=""
THREAD_FLAGS=""
use_sproc=no
AC_CHECK_HEADERS(sys/prctl.h, [use_sproc=yes])
if test "$use_sproc" = "yes"; then
case $system in
    IRIX*)
	THREAD_FLAGS="-DVTK_USE_SPROC"
	;;
esac
fi

use_pthreads=no
AC_CHECK_HEADERS(pthread.h, [use_pthreads=yes])
if test "$use_pthreads" = "yes"; then
  if test "$use_sproc" = "no"; then
    AC_CHECK_LIB(pthreads, pthread_create, THREAD_LIBS="-lpthreads")
    AC_CHECK_LIB(pthread, pthread_create, THREAD_LIBS="-lpthread")
	THREAD_FLAGS="-DVTK_USE_PTHREADS"
  fi
fi

# on an HP with pthread we need to use -lcma
# on dec alphas we have had problems as well
if test "$use_pthreads" = "yes"; then
case $system in
    HP-UX-*.10.*)
	THREAD_LIBS="-lcma"
	THREAD_FLAGS="-DVTK_USE_PTHREADS -DVTK_HP_PTHREADS"
	;;
    OSF1-V*)
        THREAD_FLAGS=""
        THREAD_LIBS=""
        ;;
    Linux*)
        THREAD_FLAGS=""
        THREAD_LIBS=""
        ;;
esac
fi

# we cant have pthreads and java at the same time
# so clear them out if java was defined
AC_ARG_WITH(java,
         [  --with-java             build vtk with java support],
	 if test "$withval" = yes; then
	 THREAD_FLAGS=""
         THREAD_LIBS=""
         fi)

AC_SUBST(THREAD_FLAGS)
AC_SUBST(THREAD_LIBS)

# on hp use -Aa for ansi
if test $ac_cv_prog_gxx = no; then
case $system in
    HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
        echo $ac_n "checking whether ${CC} accepts -Aa""... $ac_c" 1>&6
        echo 'void f(){}' > conftest.c
        if test -z "`${CC} -Aa -c conftest.cc 2>&1`"; then
          echo "$ac_t""yes" 1>&6
          ANSI_CFLAGS="-Aa"
        else
          echo "$ac_t""no" 1>&6
        fi
        rm -f conftest*
	;;
esac
fi
AC_SUBST(ANSI_CFLAGS)

# if we are not running g++ then we might need some other flags
# to get the templates compiled correctly
VTK_TEMPLATE_FLAGS=""
if test $ac_cv_prog_gxx = no; then
    echo $ac_n "checking whether ${CXX} accepts -ptall -no_prelink""... $ac_c" 1>&6
  echo 'void f(){}' > conftest.cc
if test -z "`${CXX} -ptall -no_prelink -c conftest.cc 2>&1`"; then
  echo "$ac_t""yes" 1>&6
  VTK_TEMPLATE_FLAGS="-ptall -no_prelink"
else
  echo "$ac_t""no" 1>&6
fi
rm -f conftest*
    echo $ac_n "checking whether ${CXX} accepts -instances=static""... $ac_c" 1>&6
  echo 'void f(){}' > conftest.cc
if test -z "`${CXX} -instances=static -c conftest.cc 2>&1`"; then
  echo "$ac_t""yes" 1>&6
  VTK_TEMPLATE_FLAGS="-instances=static"
else
  echo "$ac_t""no" 1>&6
fi
rm -f conftest*
    echo $ac_n "checking whether ${CXX} accepts -pto""... $ac_c" 1>&6
  echo 'void f(){}' > conftest.cc
if test -z "`${CXX} -pto -c conftest.cc 2>&1`"; then
  echo "$ac_t""yes" 1>&6
  VTK_TEMPLATE_FLAGS="-pto"
else
  echo "$ac_t""no" 1>&6
fi
rm -f conftest*
fi
AC_SUBST(VTK_TEMPLATE_FLAGS)

if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
  SHLIB_CFLAGS="-fPIC"
fi

AC_CONFIG_SUBDIRS(common wrap $javadir $tcldir $graphicsdir $imagingdir $patenteddir $contribdir)

AC_OUTPUT(Makefile system.make)





