1 dnl written by Rob Savoye <rob@cygnus.com> for Cygnus Support
2 dnl major rewriting for Tcl 7.5 by Don Libes <libes@nist.gov>
4 dnl CY_AC_PATH_TCLCONFIG and CY_AC_LOAD_TCLCONFIG should be invoked
5 dnl (in that order) before any other TCL macros. Similarly for TK.
7 dnl CYGNUS LOCAL: This gets the right posix flag for gcc
8 AC_DEFUN(CY_AC_TCL_LYNX_POSIX,
9 [AC_REQUIRE([AC_PROG_CC])AC_REQUIRE([AC_PROG_CPP])
10 AC_MSG_CHECKING([if running LynxOS])
11 AC_CACHE_VAL(ac_cv_os_lynx,
14 * The old Lynx "cc" only defines "Lynx", but the newer one uses "__Lynx__"
16 #if defined(__Lynx__) || defined(Lynx)
19 ], ac_cv_os_lynx=yes, ac_cv_os_lynx=no)])
21 if test "$ac_cv_os_lynx" = "yes" ; then
24 AC_MSG_CHECKING([whether -mposix or -X is available])
25 AC_CACHE_VAL(ac_cv_c_posix_flag,
28 * This flag varies depending on how old the compiler is.
29 * -X is for the old "cc" and "gcc" (based on 1.42).
30 * -mposix is for the new gcc (at least 2.5.8).
32 #if defined(__GNUC__) && __GNUC__ >= 2
35 ], ac_cv_c_posix_flag=" -mposix", ac_cv_c_posix_flag=" -X")])
36 CC="$CC $ac_cv_c_posix_flag"
37 AC_MSG_RESULT($ac_cv_c_posix_flag)
44 # Sometimes the native compiler is a bogus stub for gcc or /usr/ucb/cc. This
45 # makes configure think it's cross compiling. If --target wasn't used, then
46 # we can't configure, so something is wrong. We don't use the cache
47 # here cause if somebody fixes their compiler install, we want this to work.
48 AC_DEFUN(CY_AC_C_WORKS,
49 [# If we cannot compile and link a trivial program, we can't expect anything to work
50 AC_MSG_CHECKING(whether the compiler ($CC) actually works)
51 AC_TRY_COMPILE(, [/* don't need anything here */],
52 c_compiles=yes, c_compiles=no)
54 AC_TRY_LINK(, [/* don't need anything here */],
55 c_links=yes, c_links=no)
57 if test x"${c_compiles}" = x"no" ; then
58 AC_MSG_ERROR(the native compiler is broken and won't compile.)
61 if test x"${c_links}" = x"no" ; then
62 AC_MSG_ERROR(the native compiler is broken and won't link.)
67 AC_DEFUN(CY_AC_PATH_TCLH, [
69 # Ok, lets find the tcl source trees so we can use the headers
70 # Warning: transition of version 9 to 10 will break this algorithm
71 # because 10 sorts before 9. We also look for just tcl. We have to
72 # be careful that we don't match stuff like tclX by accident.
73 # the alternative search directory is involked by --with-tclinclude
76 AC_MSG_CHECKING(for Tcl private headers)
77 AC_ARG_WITH(tclinclude, [ --with-tclinclude directory where tcl private headers are], with_tclinclude=${withval})
78 AC_CACHE_VAL(ac_cv_c_tclh,[
79 # first check to see if --with-tclinclude was specified
80 if test x"${with_tclinclude}" != x ; then
81 if test -f ${with_tclinclude}/tclInt.h ; then
82 ac_cv_c_tclh=`(cd ${with_tclinclude}; pwd)`
83 elif test -f ${with_tclinclude}/generic/tclInt.h ; then
84 ac_cv_c_tclh=`(cd ${with_tclinclude}/generic; pwd)`
86 AC_MSG_ERROR([${with_tclinclude} directory doesn't contain private headers])
90 # next check if it came with Tcl configuration file
91 if test x"${ac_cv_c_tclconfig}" != x ; then
92 if test -f $ac_cv_c_tclconfig/../generic/tclInt.h ; then
93 ac_cv_c_tclh=`(cd $ac_cv_c_tclconfig/../generic; pwd)`
97 # next check in private source directory
99 # since ls returns lowest version numbers first, reverse its output
100 if test x"${ac_cv_c_tclh}" = x ; then
103 `ls -dr ${srcdir}/../tcl[[7-9]]* 2>/dev/null` \
104 ${srcdir}/../../tcl \
105 `ls -dr ${srcdir}/../../tcl[[7-9]]* 2>/dev/null` \
106 ${srcdir}/../../../tcl \
107 `ls -dr ${srcdir}/../../../tcl[[7-9]]* 2>/dev/null ` ; do
108 if test -f $i/generic/tclInt.h ; then
109 ac_cv_c_tclh=`(cd $i/generic; pwd)`
114 # finally check in a few common install locations
116 # since ls returns lowest version numbers first, reverse its output
117 if test x"${ac_cv_c_tclh}" = x ; then
119 `ls -dr /usr/local/src/tcl[[7-9]]* 2>/dev/null` \
120 `ls -dr /usr/local/lib/tcl[[7-9]]* 2>/dev/null` \
123 ${prefix}/include ; do
124 if test -f $i/generic/tclInt.h ; then
125 ac_cv_c_tclh=`(cd $i/generic; pwd)`
130 # see if one is installed
131 if test x"${ac_cv_c_tclh}" = x ; then
132 AC_HEADER_CHECK(tclInt.h, ac_cv_c_tclh=installed, ac_cv_c_tclh="")
135 if test x"${ac_cv_c_tclh}" = x ; then
136 TCLHDIR="# no Tcl private headers found"
137 AC_MSG_ERROR([Can't find Tcl private headers])
139 if test x"${ac_cv_c_tclh}" != x ; then
141 if test x"${ac_cv_c_tclh}" = x"installed" ; then
142 AC_MSG_RESULT([is installed])
145 AC_MSG_RESULT([found in ${ac_cv_c_tclh}])
146 # this hack is cause the TCLHDIR won't print if there is a "-I" in it.
147 TCLHDIR="-I${ac_cv_c_tclh}"
155 AC_DEFUN(CY_AC_PATH_TCLCONFIG, [
157 # Ok, lets find the tcl configuration
158 # First, look for one uninstalled.
159 # the alternative search directory is invoked by --with-tclconfig
162 if test x"${no_tcl}" = x ; then
163 # we reset no_tcl in case something fails here
165 AC_ARG_WITH(tclconfig, [ --with-tclconfig directory containing tcl configuration (tclConfig.sh)],
166 with_tclconfig=${withval})
167 AC_MSG_CHECKING([for Tcl configuration])
168 AC_CACHE_VAL(ac_cv_c_tclconfig,[
170 # First check to see if --with-tclconfig was specified.
171 if test x"${with_tclconfig}" != x ; then
172 if test -f "${with_tclconfig}/tclConfig.sh" ; then
173 ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
175 AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
179 # then check for a private Tcl installation
180 if test x"${ac_cv_c_tclconfig}" = x ; then
183 `ls -dr ../tcl[[7-9]]* 2>/dev/null` \
185 `ls -dr ../../tcl[[7-9]]* 2>/dev/null` \
187 `ls -dr ../../../tcl[[7-9]]* 2>/dev/null` ; do
188 if test -f "$i/unix/tclConfig.sh" ; then
189 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
194 # check in a few common install locations
195 if test x"${ac_cv_c_tclconfig}" = x ; then
196 for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
197 if test -f "$i/tclConfig.sh" ; then
198 ac_cv_c_tclconfig=`(cd $i; pwd)`
203 # check in a few other private locations
204 if test x"${ac_cv_c_tclconfig}" = x ; then
207 `ls -dr ${srcdir}/../tcl[[7-9]]* 2>/dev/null` ; do
208 if test -f "$i/unix/tclConfig.sh" ; then
209 ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
215 if test x"${ac_cv_c_tclconfig}" = x ; then
216 TCLCONFIG="# no Tcl configs found"
217 AC_MSG_WARN(Can't find Tcl configuration definitions)
220 TCLCONFIG=${ac_cv_c_tclconfig}/tclConfig.sh
221 AC_MSG_RESULT(found $TCLCONFIG)
226 # Defined as a separate macro so we don't have to cache the values
227 # from PATH_TCLCONFIG (because this can also be cached).
228 AC_DEFUN(CY_AC_LOAD_TCLCONFIG, [
231 dnl AC_SUBST(TCL_VERSION)
232 dnl AC_SUBST(TCL_MAJOR_VERSION)
233 dnl AC_SUBST(TCL_MINOR_VERSION)
237 dnl not used, don't export to save symbols
238 dnl AC_SUBST(TCL_LIB_FILE)
241 dnl not used, don't export to save symbols
242 dnl AC_SUBST(TCL_PREFIX)
244 dnl not used, don't export to save symbols
245 dnl AC_SUBST(TCL_EXEC_PREFIX)
247 AC_SUBST(TCL_SHLIB_CFLAGS)
248 AC_SUBST(TCL_SHLIB_LD)
249 dnl don't export, not used outside of configure
250 dnl AC_SUBST(TCL_SHLIB_LD_LIBS)
251 dnl AC_SUBST(TCL_SHLIB_SUFFIX)
252 dnl not used, don't export to save symbols
253 dnl AC_SUBST(TCL_DL_LIBS)
254 AC_SUBST(TCL_LD_FLAGS)
255 dnl don't export, not used outside of configure
256 AC_SUBST(TCL_LD_SEARCH_FLAGS)
257 dnl AC_SUBST(TCL_COMPAT_OBJS)
259 AC_SUBST(TCL_BUILD_LIB_SPEC)
260 AC_SUBST(TCL_LIB_SPEC)
261 dnl AC_SUBST(TCL_LIB_VERSIONS_OK)
263 dnl not used, don't export to save symbols
264 dnl AC_SUBST(TCL_SHARED_LIB_SUFFIX)
266 dnl not used, don't export to save symbols
267 dnl AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
270 # Warning: Tk definitions are very similar to Tcl definitions but
271 # are not precisely the same. There are a couple of differences,
272 # so don't do changes to Tcl thinking you can cut and paste it do
273 # the Tk differences and later simply substitute "Tk" for "Tcl".
275 # - Acceptable Tcl major version #s is 7-9 while Tk is 4-9
276 # - Searching for Tcl includes looking for tclInt.h, Tk looks for tk.h
277 # - Computing major/minor versions is different because Tk depends on
278 # headers to Tcl, Tk, and X.
279 # - Symbols in tkConfig.sh are different than tclConfig.sh
280 # - Acceptable for Tk to be missing but not Tcl.
282 AC_DEFUN(CY_AC_PATH_TKH, [
284 # Ok, lets find the tk source trees so we can use the headers
285 # If the directory (presumably symlink) named "tk" exists, use that one
286 # in preference to any others. Same logic is used when choosing library
287 # and again with Tcl. The search order is the best place to look first, then in
288 # decreasing significance. The loop breaks if the trigger file is found.
289 # Note the gross little conversion here of srcdir by cd'ing to the found
290 # directory. This converts the path from a relative to an absolute, so
291 # recursive cache variables for the path will work right. We check all
292 # the possible paths in one loop rather than many seperate loops to speed
294 # the alternative search directory is involked by --with-tkinclude
297 AC_MSG_CHECKING(for Tk private headers)
298 AC_ARG_WITH(tkinclude, [ --with-tkinclude directory where tk private headers are], with_tkinclude=${withval})
299 AC_CACHE_VAL(ac_cv_c_tkh,[
300 # first check to see if --with-tkinclude was specified
301 if test x"${with_tkinclude}" != x ; then
302 if test -f ${with_tkinclude}/tk.h ; then
303 ac_cv_c_tkh=`(cd ${with_tkinclude}; pwd)`
304 elif test -f ${with_tkinclude}/generic/tk.h ; then
305 ac_cv_c_tkh=`(cd ${with_tkinclude}/generic; pwd)`
307 AC_MSG_ERROR([${with_tkinclude} directory doesn't contain private headers])
311 # next check if it came with Tk configuration file
312 if test x"${ac_cv_c_tkconfig}" != x ; then
313 if test -f $ac_cv_c_tkconfig/../generic/tk.h ; then
314 ac_cv_c_tkh=`(cd $ac_cv_c_tkconfig/../generic; pwd)`
318 # next check in private source directory
320 # since ls returns lowest version numbers first, reverse its output
321 if test x"${ac_cv_c_tkh}" = x ; then
324 `ls -dr ${srcdir}/../tk[[4-9]]* 2>/dev/null` \
326 `ls -dr ${srcdir}/../../tk[[4-9]]* 2>/dev/null` \
327 ${srcdir}/../../../tk \
328 `ls -dr ${srcdir}/../../../tk[[4-9]]* 2>/dev/null ` ; do
329 if test -f $i/generic/tk.h ; then
330 if test x"${TK_BUILD_INCLUDES}" != x; then
331 ac_cv_c_tkh=`echo "${TK_BUILD_INCLUDES}" | sed -e 's/^-I//'`
333 ac_cv_c_tkh=`(cd $i/generic; pwd)`
339 # finally check in a few common install locations
341 # since ls returns lowest version numbers first, reverse its output
342 if test x"${ac_cv_c_tkh}" = x ; then
344 `ls -dr /usr/local/src/tk[[4-9]]* 2>/dev/null` \
345 `ls -dr /usr/local/lib/tk[[4-9]]* 2>/dev/null` \
348 ${prefix}/include ; do
349 if test -f $i/generic/tk.h ; then
350 ac_cv_c_tkh=`(cd $i/generic; pwd)`
355 # see if one is installed
356 if test x"${ac_cv_c_tkh}" = x ; then
357 AC_HEADER_CHECK(tk.h, ac_cv_c_tkh=installed, ac_cv_c_tkh="")
360 if test x"${ac_cv_c_tkh}" != x ; then
362 if test x"${ac_cv_c_tkh}" = x"installed" ; then
363 AC_MSG_RESULT([is installed])
366 AC_MSG_RESULT([found in ${ac_cv_c_tkh}])
367 # this hack is cause the TKHDIR won't print if there is a "-I" in it.
368 TKHDIR="-I${ac_cv_c_tkh}"
371 TKHDIR="# no Tk directory found"
372 AC_MSG_WARN([Can't find Tk private headers])
380 AC_DEFUN(CY_AC_PATH_TKCONFIG, [
382 # Ok, lets find the tk configuration
383 # First, look for one uninstalled.
384 # the alternative search directory is invoked by --with-tkconfig
387 if test x"${no_tk}" = x ; then
388 # we reset no_tk in case something fails here
390 AC_ARG_WITH(tkconfig, [ --with-tkconfig directory containing tk configuration (tkConfig.sh)],
391 with_tkconfig=${withval})
392 AC_MSG_CHECKING([for Tk configuration])
393 AC_CACHE_VAL(ac_cv_c_tkconfig,[
395 # First check to see if --with-tkconfig was specified.
396 if test x"${with_tkconfig}" != x ; then
397 if test -f "${with_tkconfig}/tkConfig.sh" ; then
398 ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
400 AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
404 # then check for a private Tk library
405 if test x"${ac_cv_c_tkconfig}" = x ; then
408 `ls -dr ../tk[[4-9]]* 2>/dev/null` \
410 `ls -dr ../../tk[[4-9]]* 2>/dev/null` \
412 `ls -dr ../../../tk[[4-9]]* 2>/dev/null` ; do
413 if test -f "$i/unix/tkConfig.sh" ; then
414 ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
419 # check in a few common install locations
420 if test x"${ac_cv_c_tkconfig}" = x ; then
421 for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
422 if test -f "$i/tkConfig.sh" ; then
423 ac_cv_c_tkconfig=`(cd $i; pwd)`
428 # check in a few other private locations
429 if test x"${ac_cv_c_tkconfig}" = x ; then
432 `ls -dr ${srcdir}/../tk[[4-9]]* 2>/dev/null` ; do
433 if test -f "$i/unix/tkConfig.sh" ; then
434 ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
440 if test x"${ac_cv_c_tkconfig}" = x ; then
441 TKCONFIG="# no Tk configs found"
442 AC_MSG_WARN(Can't find Tk configuration definitions)
445 TKCONFIG=${ac_cv_c_tkconfig}/tkConfig.sh
446 AC_MSG_RESULT(found $TKCONFIG)
452 # Defined as a separate macro so we don't have to cache the values
453 # from PATH_TKCONFIG (because this can also be cached).
454 AC_DEFUN(CY_AC_LOAD_TKCONFIG, [
455 if test -f "$TKCONFIG" ; then
460 dnl not actually used, don't export to save symbols
461 dnl AC_SUBST(TK_MAJOR_VERSION)
462 dnl AC_SUBST(TK_MINOR_VERSION)
465 dnl not used, don't export to save symbols
466 dnl AC_SUBST(TK_LIB_FILE)
468 dnl not used outside of configure
469 dnl AC_SUBST(TK_LIBS)
470 dnl not used, don't export to save symbols
471 dnl AC_SUBST(TK_PREFIX)
473 dnl not used, don't export to save symbols
474 dnl AC_SUBST(TK_EXEC_PREFIX)
476 AC_SUBST(TK_XINCLUDES)
478 AC_SUBST(TK_BUILD_LIB_SPEC)
479 AC_SUBST(TK_LIB_SPEC)