dnl autoconf rules to find tk 
dnl $Header: /nfs/jade/faber/CVSROOT//acc-ns/conf/configure.in.tk,v 1.1.1.2 1999/05/19 21:48:19 faber Exp $ (LBL)


AC_ARG_WITH(tk,	--with-tk=path	specify a pathname for tk, d=$withval, d="")

dnl library version defaults to 8.0
AC_ARG_WITH(tk-ver, --with-tk-ver=path specify the version of tcl/tk, TK_VERS=$withval, TK_VERS=8.0.4)

TK_ALT_VERS=`echo $TK_VERS | sed 's/\.//'`

dnl Truncate anything beyond and including the second decimal point

TK_HI_VERS=`echo $TCL_VERS | sed "s/\([[^\.]]*\)\.\([[^\.]]*\).*/\1.\2/"`

dnl work with one version in the past
TK_OLD_VERS=4.2
TK_OLD_ALT_VERS=`echo $TK_OLD_VERS | sed 's/\.//'`

TK_TCL_PLACES_D="$d \
                $d/lib/tk$TK_VERS \
                $d/lib/tk$TK_ALT_VERS \
		$d/lib/tk$TK_HI_VERS \
                $d/library \
                $d/lib/tk \
                $d/../lib/tk$TK_VERS \
                $d/../lib/tk$TK_ALT_VERS \
                $d/../lib/tk$TK_HI_VERS \
                $d/../lib/tk \
                $d/lib/tk$TK_OLD_VERS \
                $d/lib/tk$TK_OLD_ALT_VERS \
                $d/../lib/tk$TK_OLD_VERS \
                $d/../lib/tk$TK_OLD_ALT_VERS \
                $d/../lib/tk \
                $d/lib \
                $d/library"
TK_TCL_PLACES="$PWD/../tk$TK_VERS/library \
                $PWD/../tk$TK_ALT_VERS/library \
                $PWD/../tk$TK_HI_VERS/library \
		$PWD/../tk/library \
                /usr/src/local/tk$TK_VERS/library \
                /usr/src/local/tk$TK_ALT_VERS/library \
                /usr/src/local/tk$TK_HI_VERS/library \
                /usr/contrib/include \
                /usr/local/lib/tk$TK_VERS \
                /usr/local/lib/tk$TK_ALT_VERS \
                /usr/local/lib/tk$TK_HI_VERS \
                /usr/local/include/tk$TK_VERS \
                /usr/local/include/tk$TK_ALT_VERS \
                /usr/local/include/tk$TK_HI_VERS \
                /usr/local/include \ 
                /usr/lib/tk$TK_VERS \
                /usr/lib/tk$TK_ALT_VERS \
                /usr/lib/tk$TK_HI_VERS \
		$PWD/../tk$TK_OLD_VERS/library \
                $PWD/../tk$TK_OLD_ALT_VERS/library \
                /usr/src/local/tk$TK_OLD_VERS/library \
                /usr/src/local/tk$TK_OLD_ALT_VERS/library \
                /usr/local/lib/tk$TK_OLD_VERS \
                /usr/local/lib/tk$TK_OLD_ALT_VERS \
                /usr/local/include/tk$TK_OLD_VERS \
                /usr/local/include/tk$TK_OLD_ALT_VERS \
                /usr/lib/tk$TK_OLD_VERS \
                /usr/lib/tk$TK_OLD_ALT_VERS \
                $prefix/include \
		$prefix/lib/tk \
                $x_includes/tk \
                $x_includes \
                /usr/include"
TK_H_PLACES_D="$d \
                $d/generic \
                $d/../include/tk$TK_VERS \
                $d/../include/tk$TK_HI_VERS \
                $d/../include/tk$TK_OLD_VERS \
		$d/include/tk$TK_VERS \
		$d/include/tk$TK_HI_VERS \
		$d/include/tk$TK_OLD_VERS \
                $d/include"
TK_H_PLACES="$PWD/../tk$TK_VERS/generic \
                $PWD/../tk$TK_ALT_VERS/generic \
                $PWD/../tk$TK_HI_VERS/generic \
		/usr/src/local/tk$TK_VERS/generic \
                /usr/src/local/tk$TK_ALT_VERS/generic \
                /usr/src/local/tk$TK_HI_VERS/generic \
                /usr/contrib/include \
                /usr/local/lib/tk$TK_VERS \
                /usr/local/lib/tk$TK_ALT_VERS \
                /usr/local/lib/tk$TK_HI_VERS \
                /usr/local/include/tk$TK_VERS \
                /usr/local/include/tk$TK_ALT_VERS \
                /usr/local/include/tk$TK_HI_VERS \
                /usr/local/include \
                /import/tk/include/tk$TK_VERS \
                /import/tk/include/tk$TK_ALT_VERS \
                /import/tk/include/tk$TK_HI_VERS \
		$PWD/../tk$TK_OLD_VERS/generic \
                $PWD/../tk$TK_OLD_ALT_VERS/generic \
		/usr/src/local/tk$TK_OLD_VERS/generic \
                /usr/src/local/tk$TK_OLD_ALT_VERS/generic \
                /usr/local/lib/tk$TK_OLD_VERS \
                /usr/local/lib/tk$TK_OLD_ALT_VERS \
                /usr/local/include/tk$TK_OLD_VERS \
                /usr/local/include/tk$TK_OLD_ALT_VERS \
                /import/tk/include/tk$TK_OLD_VERS \
                /import/tk/include/tk$TK_OLD_ALT_VERS \
                $prefix/include \
                $x_includes/tk \
                $x_includes \
                /usr/include \
                /usr/include/tcl"
dnl /usr/include/tcl for debian/linux
TK_LIB_PLACES_D="$d \ 
                $d/lib \
		$d/unix"
TK_LIB_PLACES="$PWD/../tk$TK_VERS/unix \
                $PWD/../tk$TK_ALT_VERS/unix \
                $PWD/../tk$TK_HI_VERS/unix \
                /usr/src/local/tk$TK_VERS/unix \
                /usr/src/local/tk$TK_ALT_VERS/unix \
                /usr/src/local/tk$TK_HI_VERS/unix \
                /usr/contrib/lib \
                /usr/local/lib/tk$TK_VERS \
                /usr/local/lib/tk$TK_ALT_VERS \
                /usr/local/lib/tk$TK_HI_VERS \
		$PWD/../tk$TK_OLD_VERS/unix \
                $PWD/../tk$TK_OLD_ALT_VERS/unix \
                /usr/src/local/tk$TK_OLD_VERS/unix \
                /usr/src/local/tk$TK_OLD_ALT_VERS/unix \
                /usr/local/lib/tk$TK_OLD_VERS \
                /usr/local/lib/tk$TK_OLD_ALT_VERS \
                /usr/local/lib \
                $prefix/lib \
                $x_libs/tk \
                $x_libs \
                /usr/lib"

NS_BEGIN_PACKAGE(tk)
NS_CHECK_HEADER_PATH(tk.h,$TK_H_PLACES,$d,$TK_H_PLACES_D,V_INCLUDE_TK,tk)
NS_CHECK_LIB_PATH(tk$TK_HI_VERS,$TK_LIB_PLACES,$d,$TK_LIB_PLACES_D,V_LIB_TK,tk)
NS_CHECK_ANY_PATH(tk.tcl,$TK_TCL_PLACES,$d,$TK_TCL_PLACES_D,V_LIBRARY_TK,tk)
NS_END_PACKAGE(tk,no)

if test -r $V_LIBRARY_TK/optionMenu.tcl ; then
	V_TKDOSNAMES='$(LIBRARY_TK)/optionMenu.tcl $(LIBRARY_TK)/scrollbar.tcl'
	V_NEED_DL=""
else
	V_TKDOSNAMES='$(LIBRARY_TK)/optMenu.tcl $(LIBRARY_TK)/scrlbar.tcl'
	V_NEED_DL=YES
fi

#if test -r $V_LIBRARY_TK/tkfbox.tcl ; then
#	echo copied tkfbox.tcl into tcl/
#	cp $V_LIBRARY_TK/tkfbox.tcl tcl/tkfbox.tcl
#	chmod +w tcl/tkfbox.tcl
#else 
#	echo ABORT: tkfbox.tcl not found! Please check your tk installation.
#	exit 1
#fi

AC_SUBST(V_TKDOSNAMES)
AC_SUBST(V_LIBRARY_TK)
