1 dnl FIRST PASS AFTER STEALING THIS FROM CYRUS!
2 dnl USE AT YOUR OWN PERIL!
5 dnl tcl.m4: an autoconf Tcl locator
6 dnl $Id: tcl.m4,v 1.4 2003/10/08 20:35:25 rjs3 Exp $
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.
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
18 dnl The command-line arguments are overcomplicated.
19 dnl There are doubtlessly others...
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".
27 # --- BEGIN CMU_TCL ---
28 dnl To link against Tcl, configure does several things to make my life
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
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.
44 dnl > Checking for Tcl first puts -lm before -lkrb on the library list.
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)],
58 if test "$TCLSH" = "no" -o "$with_tclconfig" = "no" ; then
59 AC_MSG_WARN([Tcl disabled because tclsh or tclconfig specified as "no"])
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.])
68 if test \! -z "$TCLSH" -a \! -x "$TCLSH" ; then
69 AC_MSG_ERROR([--with-tclsh must specify an executable file.])
72 if test -z "$TclLibBase"; then # do we already know?
73 # No? Run tclsh and ask it where it lives.
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
82 AC_PATH_PROGS(TCLSH, [tclsh8.1 tclsh8.0 tclsh], "unknown")
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)
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.])
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}" \
102 "${TclLibBase}"`echo ${TCLSH} | sed s/sh//` ; do
103 if test -f "${tcldir}/tclConfig.sh"; then
104 TclLibBase="${tcldir}"
109 if test -z "${TclLibBase}" ; then
110 AC_MSG_RESULT("unknown")
111 AC_MSG_WARN([can't find Tcl configuration; use of Tcl disabled.])
114 AC_MSG_RESULT(${TclLibBase}/)
117 if test "${with_tcl}" != no ; then
118 AC_MSG_CHECKING([Tcl configuration on what Tcl needs to compile])
119 . ${TclLibBase}/tclConfig.sh
121 dnl no TK stuff for us.
122 dnl . ${TclLibBase}/tkConfig.sh
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}"
139 if test -z "${TCL_CPPFLAGS}" ; then
140 AC_MSG_WARN(can't find Tcl includes; use of Tcl disabled.)
143 AC_MSG_RESULT(${TCL_CPPFLAGS})
146 # Finally, pick up the Tcl configuration if we haven't found an
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}"
157 AC_SUBST(TCL_CPPFLAGS)
159 # --- END CMU_TCL ---