| 1 |
dnl FIRST PASS AFTER STEALING THIS FROM CYRUS! |
| 2 |
dnl USE AT YOUR OWN PERIL! |
| 3 |
dnl I MEAN IT! |
| 4 |
dnl |
| 5 |
dnl tcl.m4: an autoconf Tcl locator |
| 6 |
dnl $Id: tcl.m4,v 1.3 2002/05/25 19:57:42 leg Exp $ |
| 7 |
dnl |
| 8 |
dnl This is rob's Tcl macro, fixed by tjs. It may need occasional tweaking, |
| 9 |
dnl but until the next impediment to compilation, it's fill-in-the-blank, |
| 10 |
dnl and it should be able to do reasonable things with user input. |
| 11 |
dnl |
| 12 |
dnl This will probably just work on Andrew systems, but given the variety |
| 13 |
dnl and apparent creativity of people who compile Tcl elsewhere, I don't know |
| 14 |
dnl what it will do. I have yet to see an autoconf Tcl test that users were |
| 15 |
dnl happy with. |
| 16 |
dnl |
| 17 |
dnl BUGS |
| 18 |
dnl The command-line arguments are overcomplicated. |
| 19 |
dnl There are doubtlessly others... |
| 20 |
|
| 21 |
dnl To use this macro, just do CMU_TCL. It outputs |
| 22 |
dnl TCL_LIBS, TCL_CPPFLAGS, and TCL_DEFS and SUBSTs them. |
| 23 |
dnl If successful, these have stuff in them. If not, they're empty. |
| 24 |
dnl If not successful, with_tcl has the value "no". |
| 25 |
|
| 26 |
AC_DEFUN(CMU_TCL, [ |
| 27 |
# --- BEGIN CMU_TCL --- |
| 28 |
dnl To link against Tcl, configure does several things to make my life |
| 29 |
dnl "easier". |
| 30 |
dnl |
| 31 |
dnl * maybe ask the user where they think Tcl lives, and try to find it |
| 32 |
dnl * maybe ask the user what "tclsh" is called this week (i.e., "tclsh8.0") |
| 33 |
dnl * run tclsh, ask it for a path, then run that path through sed |
| 34 |
dnl * sanity check its result (many installs are a little broken) |
| 35 |
dnl * try to figure out where Tcl is based on this result |
| 36 |
dnl * try to guess where the Tcl include files are |
| 37 |
dnl |
| 38 |
dnl Notes from previous incarnations: |
| 39 |
dnl > XXX MUST CHECK FOR TCL BEFORE KERBEROS V4 XXX |
| 40 |
dnl > This is because some genius at MIT named one of the Kerberos v4 |
| 41 |
dnl > library functions log(). This of course conflicts with the |
| 42 |
dnl > logarithm function in the standard math library, used by Tcl. |
| 43 |
dnl |
| 44 |
dnl > Checking for Tcl first puts -lm before -lkrb on the library list. |
| 45 |
dnl |
| 46 |
|
| 47 |
dnl Check for some information from the user on what the world looks like |
| 48 |
AC_ARG_WITH(tclconfig,[ --with-tclconfig=PATH use tclConfig.sh from PATH |
| 49 |
(configure gets Tcl configuration from here)], |
| 50 |
dnl trim tclConfig.sh off the end so we can add it back on later. |
| 51 |
TclLibBase=`echo ${withval} | sed s/tclConfig.sh\$//`) |
| 52 |
AC_ARG_WITH(tcl, [ --with-tcl=PATH use Tcl from PATH], |
| 53 |
TclLibBase="${withval}/lib") |
| 54 |
AC_ARG_WITH(tclsh, [ --with-tclsh=TCLSH use TCLSH as the tclsh program |
| 55 |
(let configure find Tcl using this program)], |
| 56 |
TCLSH="${withval}") |
| 57 |
|
| 58 |
if test "$TCLSH" = "no" -o "$with_tclconfig" = "no" ; then |
| 59 |
AC_MSG_WARN([Tcl disabled because tclsh or tclconfig specified as "no"]) |
| 60 |
with_tcl=no |
| 61 |
fi |
| 62 |
|
| 63 |
if test "$with_tcl" != "no"; then |
| 64 |
if test \! -z "$with_tclconfig" -a \! -d "$with_tclconfig" ; then |
| 65 |
AC_MSG_ERROR([--with-tclconfig requires a directory argument.]) |
| 66 |
fi |
| 67 |
|
| 68 |
if test \! -z "$TCLSH" -a \! -x "$TCLSH" ; then |
| 69 |
AC_MSG_ERROR([--with-tclsh must specify an executable file.]) |
| 70 |
fi |
| 71 |
|
| 72 |
if test -z "$TclLibBase"; then # do we already know? |
| 73 |
# No? Run tclsh and ask it where it lives. |
| 74 |
|
| 75 |
# Do we know where a tclsh lives? |
| 76 |
if test -z "$TCLSH"; then |
| 77 |
# Try and find tclsh. Any tclsh. |
| 78 |
# If a new version of tcl comes out and unfortunately adds another |
| 79 |
# filename, it should be safe to add it (to the front of the line -- |
| 80 |
# somef vendors have older, badly installed tclshs that we want to avoid |
| 81 |
# if we can) |
| 82 |
AC_PATH_PROGS(TCLSH, [tclsh8.1 tclsh8.0 tclsh], "unknown") |
| 83 |
fi |
| 84 |
|
| 85 |
# Do we know where to get a tclsh? |
| 86 |
if test "${TCLSH}" != "unknown"; then |
| 87 |
AC_MSG_CHECKING([where Tcl says it lives]) |
| 88 |
TclLibBase=`echo puts \\\$tcl_library | ${TCLSH} | sed -e 's,[^/]*$,,'` |
| 89 |
AC_MSG_RESULT($TclLibBase) |
| 90 |
fi |
| 91 |
fi |
| 92 |
|
| 93 |
if test -z "$TclLibBase" ; then |
| 94 |
AC_MSG_RESULT([can't find tclsh]) |
| 95 |
AC_MSG_WARN([can't find Tcl installtion; use of Tcl disabled.]) |
| 96 |
with_tcl=no |
| 97 |
else |
| 98 |
AC_MSG_CHECKING([for tclConfig.sh]) |
| 99 |
# Check a list of places where the tclConfig.sh file might be. |
| 100 |
for tcldir in "${TclLibBase}" \ |
| 101 |
"${TclLibBase}/.." \ |
| 102 |
"${TclLibBase}"`echo ${TCLSH} | sed s/sh//` ; do |
| 103 |
if test -f "${tcldir}/tclConfig.sh"; then |
| 104 |
TclLibBase="${tcldir}" |
| 105 |
break |
| 106 |
fi |
| 107 |
done |
| 108 |
|
| 109 |
if test -z "${TclLibBase}" ; then |
| 110 |
AC_MSG_RESULT("unknown") |
| 111 |
AC_MSG_WARN([can't find Tcl configuration; use of Tcl disabled.]) |
| 112 |
with_tcl=no |
| 113 |
else |
| 114 |
AC_MSG_RESULT(${TclLibBase}/) |
| 115 |
fi |
| 116 |
|
| 117 |
if test "${with_tcl}" != no ; then |
| 118 |
AC_MSG_CHECKING([Tcl configuration on what Tcl needs to compile]) |
| 119 |
. ${TclLibBase}/tclConfig.sh |
| 120 |
AC_MSG_RESULT(ok) |
| 121 |
dnl no TK stuff for us. |
| 122 |
dnl . ${TclLibBase}/tkConfig.sh |
| 123 |
fi |
| 124 |
|
| 125 |
if test "${with_tcl}" != no ; then |
| 126 |
dnl Now, hunt for the Tcl include files, since we don't strictly |
| 127 |
dnl know where they are; some folks put them (properly) in the |
| 128 |
dnl default include path, or maybe in /usr/local; the *BSD folks |
| 129 |
dnl put them in other places. |
| 130 |
AC_MSG_CHECKING([where Tcl includes are]) |
| 131 |
for tclinclude in "${TCL_PREFIX}/include/tcl${TCL_VERSION}" \ |
| 132 |
"${TCL_PREFIX}/include/tcl" \ |
| 133 |
"${TCL_PREFIX}/include" ; do |
| 134 |
if test -r "${tclinclude}/tcl.h" ; then |
| 135 |
TCL_CPPFLAGS="-I${tclinclude}" |
| 136 |
break |
| 137 |
fi |
| 138 |
done |
| 139 |
if test -z "${TCL_CPPFLAGS}" ; then |
| 140 |
AC_MSG_WARN(can't find Tcl includes; use of Tcl disabled.) |
| 141 |
with_tcl=no |
| 142 |
fi |
| 143 |
AC_MSG_RESULT(${TCL_CPPFLAGS}) |
| 144 |
fi |
| 145 |
|
| 146 |
# Finally, pick up the Tcl configuration if we haven't found an |
| 147 |
# excuse not to. |
| 148 |
if test "${with_tcl}" != no; then |
| 149 |
dnl TCL_LIBS="${TK_LIB_SPEC} ${TK_XLIBSW} ${TCL_LD_SEARCH_FLAGS} ${TCL_LIB_SPEC}" |
| 150 |
TCL_LIBS="${TCL_LD_SEARCH_FLAGS} ${TCL_LIB_SPEC} ${TCL_LIBS}" |
| 151 |
fi |
| 152 |
fi |
| 153 |
fi |
| 154 |
|
| 155 |
AC_SUBST(TCL_DEFS) |
| 156 |
AC_SUBST(TCL_LIBS) |
| 157 |
AC_SUBST(TCL_CPPFLAGS) |
| 158 |
|
| 159 |
# --- END CMU_TCL --- |
| 160 |
]) dnl CMU_TCL |