2
dnl tcl.m4: an autoconf Tcl locator
6
dnl The command-line arguments are overcomplicated.
7
dnl There are doubtlessly others...
9
dnl To use this macro, just do MLX_LANG_TCL. It outputs
10
dnl TCL_LIBS, TCL_CPPFLAGS, and TCL_DEFS and SUBSTs them.
11
dnl If successful, these have stuff in them. If not, they're empty.
12
dnl If not successful, with_tcl has the value "no".
14
AC_DEFUN([MLX_LANG_TCL], [
15
# --- BEGIN MLX_LANG_TCL ---
16
dnl To link against Tcl, configure does several things to make my life
19
dnl * maybe ask the user where they think Tcl lives, and try to find it
20
dnl * maybe ask the user what "tclsh" is called this week (i.e., "tclsh8.0")
21
dnl * run tclsh, ask it for a path, then run that path through sed
22
dnl * sanity check its result (many installs are a little broken)
23
dnl * try to figure out where Tcl is based on this result
24
dnl * try to guess where the Tcl include files are
26
dnl Notes from previous incarnations:
27
dnl > XXX MUST CHECK FOR TCL BEFORE KERBEROS V4 XXX
28
dnl > This is because some genius at MIT named one of the Kerberos v4
29
dnl > library functions log(). This of course conflicts with the
30
dnl > logarithm function in the standard math library, used by Tcl.
32
dnl > Checking for Tcl first puts -lm before -lkrb on the library list.
35
dnl do not do anything if we are in disabled libcheck mode...
36
if test "x$libcheck" = "xtrue"; then
38
dnl Check for some information from the user on what the world looks like
39
AC_ARG_WITH(tclconfig,[ --with-tclconfig=PATH use tclConfig.sh from PATH
40
(configure gets Tcl configuration from here)],
41
dnl trim tclConfig.sh off the end so we can add it back on later.
42
TclLibBase=`echo ${withval} | sed s/tclConfig.sh\$//`)
43
AC_ARG_WITH(tcl, [ --with-tcl=PATH use Tcl from PATH],
44
TclLibBase="${withval}/lib")
45
AC_ARG_WITH(tclsh, [ --with-tclsh=TCLSH use TCLSH as the tclsh program
46
(let configure find Tcl using this program)],
49
if test "x$TCLSH" = "xno" -o "x$with_tclconfig" = "xno" ; then
50
AC_MSG_WARN([Tcl disabled because tclsh or tclconfig specified as "no"])
54
if test "x$with_tcl" != xno; then
55
if test \! -z "$with_tclconfig" -a \! -d "$with_tclconfig" ; then
56
AC_MSG_ERROR([--with-tclconfig requires a directory argument.])
59
if test \! -z "$TCLSH" -a \! -x "$TCLSH" ; then
60
AC_MSG_ERROR([--with-tclsh must specify an executable file.])
63
if test X"$TclLibBase" = X; then # do we already know?
64
# No? Run tclsh and ask it where it lives.
66
# Do we know where a tclsh lives?
67
if test X"$TCLSH" = X; then
68
# Try and find tclsh. Any tclsh.
69
# If a new version of tcl comes out and unfortunately adds another
70
# filename, it should be safe to add it (to the front of the line --
71
# somef vendors have older, badly installed tclshs that we want to avoid
73
AC_PATH_PROGS(TCLSH, [tclsh tclsh8.3 tclsh8.4], "unknown")
76
# Do we know where to get a tclsh?
77
if test "X${TCLSH}" != "Xunknown"; then
78
AC_MSG_CHECKING([where Tcl says it lives])
79
dnl to avoid .tclshrc issues use from a file...
80
echo "puts \$tcl_library" > /tmp/tcl.conf.$$
81
TclLibBase=`${TCLSH} /tmp/tcl.conf.$$ | sed -e 's,[^/]*$,,'`
83
AC_MSG_RESULT($TclLibBase)
87
if test -z "$TclLibBase" ; then
88
AC_MSG_RESULT([can't find tclsh])
89
AC_MSG_WARN([can't find Tcl installtion; use of Tcl disabled.])
92
AC_MSG_CHECKING([for tclConfig.sh])
93
# Check a list of places where the tclConfig.sh file might be.
94
# Note we prefer the 64 bit version if exists
95
tclCondifSearchPath="$tclCondifSearchPath ${TclLibBase}"
96
tclCondifSearchPath="$tclCondifSearchPath ${TclLibBase}/.."
97
tclCondifSearchPath="$tclCondifSearchPath `echo ${TCLSH} | sed s/sh//`"
98
tclCondifSearchPath="$tclCondifSearchPath /usr/lib64"
99
tclCondifSearchPath="$tclCondifSearchPath /usr/lib"
100
tclCondifSearchPath="$tclCondifSearchPath /usr/local/lib"
101
for tcldir in $tclCondifSearchPath; do
102
if test -f "${tcldir}/tclConfig.sh"; then
103
TclLibBase="${tcldir}"
108
if test -z "${TclLibBase}" ; then
109
AC_MSG_RESULT("unknown")
110
AC_MSG_WARN([can't find Tcl configuration; use of Tcl disabled.])
113
AC_MSG_RESULT(${TclLibBase}/)
116
if test "X${with_tcl}" != Xno ; then
117
AC_MSG_CHECKING([Tcl configuration on what Tcl needs to compile])
118
. ${TclLibBase}/tclConfig.sh
120
dnl no TK stuff for us.
121
dnl . ${TclLibBase}/tkConfig.sh
124
dnl We hack the provided TCL_LIB_SPEC since it is using the /usr/lib even
125
dnl if the build was using lib64
126
if test -d /usr/lib64 ; then
127
TCL_LIB_SPEC=`echo ${TCL_LIB_SPEC} | sed 's=/usr/lib =/usr/lib64 =g'`
130
if test "X${with_tcl}" != Xno ; then
131
dnl Now, hunt for the Tcl include files, since we don't strictly
132
dnl know where they are; some folks put them (properly) in the
133
dnl default include path, or maybe in /usr/local; the *BSD folks
134
dnl put them in other places.
135
AC_MSG_CHECKING([where Tcl includes are])
136
for tclinclude in "${TCL_PREFIX}/include/tcl${TCL_VERSION}" \
137
"${TCL_PREFIX}/include/tcl" \
138
"${TCL_PREFIX}/include" ; do
139
if test -r "${tclinclude}/tcl.h" ; then
140
TCL_CPPFLAGS="-I${tclinclude}"
144
if test X"${TCL_CPPFLAGS}" = X ; then
145
AC_MSG_WARN(can't find Tcl includes; use of Tcl disabled.)
148
AC_MSG_RESULT(${TCL_CPPFLAGS})
151
# Finally, pick up the Tcl configuration if we haven't found an
153
if test "X${with_tcl}" != Xno; then
154
dnl TCL_LIBS="${TK_LIB_SPEC} ${TK_XLIBSW} ${TCL_LD_SEARCH_FLAGS} ${TCL_LIB_SPEC}"
155
dnl we are using libtool so need to convert to -rpath if at all
156
TCL_SEARCH=`echo ${TCL_LD_SEARCH_FLAGS} | sed 's/-Wl,-rpath,/-rpath/'`
158
dnl sometimes we got empty libs: use TCL_LIB_FILE
159
if test X"$TCL_LIBS" = X; then
160
dnl extract the lib style name...
161
TCL_LIBS=`echo ${TCL_LIB_FILE} | sed 's/lib\([[^ \t]]*\)\.\(so\|a\)/-l\1/'`
164
dnl sometimes we got empty libs: use TCL_LIB_SPEC
165
if test X"$TCL_LIB_SPEC" = X; then
166
dnl extract the lib style name...
167
TCL_LIB_SPEC='-L/usr/lib'
170
TCL_LIBS1="${TCL_LIB_SPEC} ${TCL_LIBS}"
171
dnl Filter out the ieee - I do not see a shared version for it.
172
TCL_LIBS=`echo ${TCL_LIBS1} | sed 's/-lieee//'`
177
dnl disbled libcheck mode - we do not need anything...
180
TCL_CPPFLAGS=disabled
186
AC_SUBST(TCL_CPPFLAGS)
189
# --- END MLX_LANG_TCL ---