1 dnl This file is duplicated in four places:
3 dnl * gdb/testsuite/aclocal.m4
4 dnl * expect/aclocal.m4
5 dnl * dejagnu/aclocal.m4
6 dnl Consider modifying all copies in parallel.
7 dnl written by Rob Savoye <rob@cygnus.com> for Cygnus Support
8 dnl CYGNUS LOCAL: This gets the right posix flag for gcc
9 AC_DEFUN(CY_AC_TCL_LYNX_POSIX,
10 [AC_REQUIRE([AC_PROG_CC])AC_REQUIRE([AC_PROG_CPP])
11 AC_MSG_CHECKING([to see if this is LynxOS])
12 AC_CACHE_VAL(ac_cv_os_lynx,
15 * The old Lynx "cc" only defines "Lynx", but the newer one uses "__Lynx__"
17 #if defined(__Lynx__) || defined(Lynx)
20 ], ac_cv_os_lynx=yes, ac_cv_os_lynx=no)])
22 if test "$ac_cv_os_lynx" = "yes" ; then
25 AC_MSG_CHECKING([whether -mposix or -X is available])
26 AC_CACHE_VAL(ac_cv_c_posix_flag,
29 * This flag varies depending on how old the compiler is.
30 * -X is for the old "cc" and "gcc" (based on 1.42).
31 * -mposix is for the new gcc (at least 2.5.8).
33 #if defined(__GNUC__) && __GNUC__ >= 2
36 ], ac_cv_c_posix_flag=" -mposix", ac_cv_c_posix_flag=" -X")])
37 CC="$CC $ac_cv_c_posix_flag"
38 AC_MSG_RESULT($ac_cv_c_posix_flag)
43 AC_DEFUN(CY_AC_PATH_TCLH, [
45 # Ok, lets find the tcl source trees so we can use the headers
46 # Warning: transition of version 9 to 10 will break this algorithm
47 # because 10 sorts before 9. We also look for just tcl. We have to
48 # be careful that we don't match stuff like tclX by accident.
49 # the alternative search directory is involked by --with-tclinclude
52 AC_MSG_CHECKING(for Tcl private headers)
53 AC_ARG_WITH(tclinclude, [ --with-tclinclude directory where tcl private headers are], with_tclinclude=${withval})
54 AC_CACHE_VAL(ac_cv_c_tclh,[
55 # first check to see if --with-tclinclude was specified
56 if test x"${with_tclinclude}" != x ; then
57 if test -f ${with_tclinclude}/tclInt.h ; then
58 ac_cv_c_tclh=`(cd ${with_tclinclude}; pwd)`
60 AC_MSG_ERROR([${with_tclinclude} directory doesn't contain private headers])
63 # next check in private source directory
65 # since ls returns lowest version numbers first, reverse its output
66 if test x"${ac_cv_c_tclh}" = x ; then
69 `ls -dr ${srcdir}/../tcl[[0-9]]* 2>/dev/null` \
71 `ls -dr ${srcdir}/../../tcl[[0-9]]* 2>/dev/null` \
72 ${srcdir}/../../../tcl \
73 `ls -dr ${srcdir}/../../../tcl[[0-9]]* 2>/dev/null ` ; do
74 if test -f $i/tclInt.h ; then
75 ac_cv_c_tclh=`(cd $i; pwd)`
78 # Tcl 7.5 and greater puts headers in subdirectory.
79 if test -f $i/generic/tclInt.h ; then
80 ac_cv_c_tclh=`(cd $i; pwd)`/generic
84 # finally check in a few common install locations
86 # since ls returns lowest version numbers first, reverse its output
87 if test x"${ac_cv_c_tclh}" = x ; then
89 `ls -dr /usr/local/src/tcl[[0-9]]* 2>/dev/null` \
90 `ls -dr /usr/local/lib/tcl[[0-9]]* 2>/dev/null` \
93 ${prefix}/include ; do
94 if test -f $i/tclInt.h ; then
95 ac_cv_c_tclh=`(cd $i; pwd)`
100 # see if one is installed
101 if test x"${ac_cv_c_tclh}" = x ; then
102 AC_HEADER_CHECK(tclInt.h, ac_cv_c_tclh=installed, ac_cv_c_tclh="")
105 if test x"${ac_cv_c_tclh}" = x ; then
106 TCLHDIR="# no Tcl private headers found"
107 AC_MSG_ERROR([Can't find Tcl private headers])
109 if test x"${ac_cv_c_tclh}" != x ; then
111 if test x"${ac_cv_c_tkh}" = x"installed" ; then
112 AC_MSG_RESULT([is installed])
115 AC_MSG_RESULT([found in ${ac_cv_c_tclh}])
116 # this hack is cause the TCLHDIR won't print if there is a "-I" in it.
117 TCLHDIR="-I${ac_cv_c_tclh}"
121 AC_MSG_CHECKING([Tcl version])
122 orig_includes="$CPPFLAGS"
124 if test x"${TCLHDIR}" != x ; then
125 CPPFLAGS="$CPPFLAGS $TCLHDIR"
128 # Get major and minor versions of Tcl.
129 cat > conftest.c <<'EOF'
131 major = TCL_MAJOR_VERSION
132 minor = TCL_MINOR_VERSION
137 if (eval "$CPP $CPPFLAGS conftest.c") 2>/dev/null >conftest.out; then
139 tclmajor=`egrep '^major = ' conftest.out | sed -e 's/^major = *//' -e 's/ *$//'`
140 tclminor=`egrep '^minor = ' conftest.out | sed -e 's/^minor = *//' -e 's/ *$//'`
142 rm -f conftest.c conftest.out
144 if test -z "$tclmajor" || test -z "$tclminor"; then
145 AC_MSG_RESULT([fatal error: could not find major or minor version number of Tcl])
148 AC_MSG_RESULT(${tclmajor}.${tclminor})
150 CPPFLAGS="${orig_includes}"
155 AC_DEFUN(CY_AC_PATH_TCLLIB, [
157 # Ok, lets find the tcl library
158 # First, look for one uninstalled.
159 # the alternative search directory is invoked by --with-tcllib
162 if test $tclmajor -ge 7 -a $tclminor -ge 4 ; then
163 installedtcllibroot=tcl$tclversion
165 installedtcllibroot=tcl
168 if test x"${no_tcl}" = x ; then
169 # we reset no_tcl incase something fails here
171 AC_ARG_WITH(tcllib, [ --with-tcllib directory where the tcl library is],
172 with_tcllib=${withval})
173 AC_MSG_CHECKING([for Tcl library])
174 AC_CACHE_VAL(ac_cv_c_tcllib,[
175 # First check to see if --with-tcllib was specified.
176 # This requires checking for both the installed and uninstalled name-styles
177 # since we have no idea if it's installed or not.
178 if test x"${with_tcllib}" != x ; then
179 if test -f "${with_tcllib}/lib$installedtcllibroot.so" ; then
180 ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/lib$installedtcllibroot.so
181 elif test -f "${with_tcllib}/libtcl.so" ; then
182 ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/libtcl.so
183 # then look for a freshly built statically linked library
184 # if Makefile exists we assume its configured and libtcl will be built first.
185 elif test -f "${with_tcllib}/lib$installedtcllibroot.a" ; then
186 ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/lib$installedtcllibroot.a
187 elif test -f "${with_tcllib}/libtcl.a" ; then
188 ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/libtcl.a
190 AC_MSG_ERROR([${with_tcllib} directory doesn't contain libraries])
193 # then check for a private Tcl library
194 # Since these are uninstalled, use the simple lib name root.
195 if test x"${ac_cv_c_tcllib}" = x ; then
198 `ls -dr ../tcl[[0-9]]* 2>/dev/null` \
200 `ls -dr ../../tcl[[0-9]]* 2>/dev/null` \
202 `ls -dr ../../../tcl[[0-9]]* 2>/dev/null` ; do
203 # Tcl 7.5 and greater puts library in subdir. Look there first.
204 if test -f "$i/unix/libtcl.so" ; then
205 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.so
207 elif test -f "$i/unix/libtcl.a" -o -f "$i/unix/Makefile"; then
208 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.a
210 # look for a freshly built dynamically linked library
211 elif test -f "$i/libtcl.so" ; then
212 ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.so
215 # then look for a freshly built statically linked library
216 # if Makefile exists we assume its configured and libtcl will be
218 elif test -f "$i/libtcl.a" -o -f "$i/Makefile" ; then
219 ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.a
224 # check in a few common install locations
225 if test x"${ac_cv_c_tcllib}" = x ; then
226 for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
227 # first look for a freshly built dynamically linked library
228 if test -f "$i/lib$installedtcllibroot.so" ; then
229 ac_cv_c_tcllib=`(cd $i; pwd)`/lib$installedtcllibroot.so
231 # then look for a freshly built statically linked library
232 # if Makefile exists we assume its configured and libtcl will be built first.
233 elif test -f "$i/lib$installedtcllibroot.a" -o -f "$i/Makefile" ; then
234 ac_cv_c_tcllib=`(cd $i; pwd)`/lib$installedtcllibroot.a
239 # check in a few other private locations
240 if test x"${ac_cv_c_tcllib}" = x ; then
243 `ls -dr ${srcdir}/../tcl[[0-9]]* 2>/dev/null` ; do
244 # Tcl 7.5 and greater puts library in subdir. Look there first.
245 if test -f "$i/unix/libtcl.so" ; then
246 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.so
248 elif test -f "$i/unix/libtcl.a" -o -f "$i/unix/Makefile"; then
249 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.a
251 # look for a freshly built dynamically linked library
252 elif test -f "$i/libtcl.so" ; then
253 ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.so
256 # then look for a freshly built statically linked library
257 # if Makefile exists we assume its configured and libtcl will be
259 elif test -f "$i/libtcl.a" -o -f "$i/Makefile" ; then
260 ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.a
266 # see if one is conveniently installed with the compiler
267 if test x"${ac_cv_c_tcllib}" = x ; then
269 LIBS="$LIBS -l$installedtcllibroot -lm"
272 { exit(0); }], ac_cv_c_tcllib="-l$installedtcllibroot", ac_cv_c_tcllib=""
273 , ac_cv_c_tclib="-l$installedtcllibroot")
277 if test x"${ac_cv_c_tcllib}" = x ; then
278 TCLLIB="# no Tcl library found"
279 AC_MSG_WARN(Can't find Tcl library)
281 TCLLIB=${ac_cv_c_tcllib}
282 AC_MSG_RESULT(found $TCLLIB)
290 AC_DEFUN(CY_AC_PATH_TKH, [
292 # Ok, lets find the tk source trees so we can use the headers
293 # If the directory (presumably symlink) named "tk" exists, use that one
294 # in preference to any others. Same logic is used when choosing library
295 # and again with Tcl. The search order is the best place to look first, then in
296 # decreasing significance. The loop breaks if the trigger file is found.
297 # Note the gross little conversion here of srcdir by cd'ing to the found
298 # directory. This converts the path from a relative to an absolute, so
299 # recursive cache variables for the path will work right. We check all
300 # the possible paths in one loop rather than many seperate loops to speed
302 # the alternative search directory is invoked by --with-tkinclude
304 AC_MSG_CHECKING(for Tk private headers)
305 AC_ARG_WITH(tkinclude, [ --with-tkinclude directory where the tk private headers are],
306 with_tkinclude=${withval})
308 AC_CACHE_VAL(ac_cv_c_tkh,[
309 # first check to see if --with-tkinclude was specified
310 if test x"${with_tkinclude}" != x ; then
311 if test -f ${with_tkinclude}/tk.h ; then
312 ac_cv_c_tkh=`(cd ${with_tkinclude}; pwd)`
314 AC_MSG_ERROR([${with_tkinclude} directory doesn't contain private headers])
317 # next check in private source directory
319 # since ls returns lowest version numbers first, reverse the entire list
320 # and search for the worst fit, overwriting it with better fits as we find them
321 if test x"${ac_cv_c_tkh}" = x ; then
324 `ls -dr ${srcdir}/../tk[[0-9]]* 2>/dev/null` \
326 `ls -dr ${srcdir}/../../tk[[0-9]]* 2>/dev/null` \
327 ${srcdir}/../../../tk \
328 `ls -dr ${srcdir}/../../../tk[[0-9]]* 2>/dev/null ` ; do
329 if test -f $i/tk.h ; then
330 ac_cv_c_tkh=`(cd $i; pwd)`
333 # Tk 4.1 and greater puts this in a subdir.
334 if test -f $i/generic/tk.h; then
335 ac_cv_c_tkh=`(cd $i; pwd)`/generic
339 # finally check in a few common install locations
341 # since ls returns lowest version numbers first, reverse the entire list
342 # and search for the worst fit, overwriting it with better fits as we find them
343 if test x"${ac_cv_c_tkh}" = x ; then
345 `ls -dr /usr/local/src/tk[[0-9]]* 2>/dev/null` \
346 `ls -dr /usr/local/lib/tk[[0-9]]* 2>/dev/null` \
349 ${prefix}/include ; do
350 if test -f $i/tk.h ; then
351 ac_cv_c_tkh=`(cd $i; pwd)`
356 # see if one is installed
357 if test x"${ac_cv_c_tkh}" = x ; then
358 AC_HEADER_CHECK(tk.h, ac_cv_c_tkh=installed)
361 if test x"${ac_cv_c_tkh}" != x ; then
363 if test x"${ac_cv_c_tkh}" = x"installed" ; then
364 AC_MSG_RESULT([is installed])
367 AC_MSG_RESULT([found in $ac_cv_c_tkh])
368 # this hack is cause the TKHDIR won't print if there is a "-I" in it.
369 TKHDIR="-I${ac_cv_c_tkh}"
372 TKHDIR="# no Tk directory found"
373 AC_MSG_WARN([Can't find Tk private headers])
377 # if Tk is installed, extract the major/minor version
378 if test x"${no_tk}" = x ; then
379 AC_MSG_CHECKING([Tk version])
380 orig_includes="$CPPFLAGS"
382 if test x"${TCLHDIR}" != x ; then
383 CPPFLAGS="$CPPFLAGS $TCLHDIR"
385 if test x"${TKHDIR}" != x ; then
386 CPPFLAGS="$CPPFLAGS $TKHDIR"
388 if test x"${x_includes}" != x -a x"${x_includes}" != xNONE ; then
389 CPPFLAGS="$CPPFLAGS -I$x_includes"
392 # Get major and minor versions of Tk.
393 cat > conftest.c <<'EOF'
395 major = TK_MAJOR_VERSION
396 minor = TK_MINOR_VERSION
401 if (eval "$CPP $CPPFLAGS conftest.c") 2>/dev/null >conftest.out; then
403 tkmajor=`egrep '^major = ' conftest.out | sed -e 's/^major = *//' -e 's/ *$//'`
404 tkminor=`egrep '^minor = ' conftest.out | sed -e 's/^minor = *//' -e 's/ *$//'`
406 rm -f conftest.c conftest.out
408 if test -z "$tkmajor" || test -z "$tkminor"; then
409 AC_MSG_RESULT([fatal error: could not find major or minor version number of Tk])
412 AC_MSG_RESULT(${tkmajor}.${tkminor})
414 CPPFLAGS="${orig_includes}"
420 AC_DEFUN(CY_AC_PATH_TKLIB, [
421 AC_REQUIRE([CY_AC_PATH_TCL])
423 # Ok, lets find the tk library
424 # First, look for the latest private (uninstalled) copy
425 # Notice that the destinations in backwards priority since the tests have
427 # Then we look for either .a, .so, or Makefile. A Makefile is acceptable
428 # is it indicates the target has been configured and will (probably)
429 # soon be built. This allows an entire tree of Tcl software to be
430 # configured at once and then built.
431 # the alternative search directory is invoked by --with-tklib
434 if test x"${no_tk}" = x ; then
435 # reset no_tk incase something fails here
438 if test $tkmajor -ge 4 ; then
439 installedtklibroot=tk$tkversion
441 installedtkllibroot=tk
444 AC_ARG_WITH(tklib, [ --with-tklib directory where the tk library is],
445 with_tklib=${withval})
446 AC_MSG_CHECKING([for Tk library])
447 AC_CACHE_VAL(ac_cv_c_tklib,[
448 # first check to see if --with-tklib was specified
449 # This requires checking for both the installed and uninstalled name-styles
450 # since we have no idea if it's installed or not.
451 if test x"${with_tklib}" != x ; then
452 if test -f "${with_tklib}/lib$installedtklibroot.so" ; then
453 ac_cv_c_tklib=`(cd ${with_tklib}; pwd)`/lib$installedtklibroot.so
455 elif test -f "${with_tklib}/libtk.so" ; then
456 ac_cv_c_tklib=`(cd ${with_tklib}; pwd)`/libtk.so
458 # then look for a freshly built statically linked library
459 # if Makefile exists we assume its configured and libtk will be built
460 elif test -f "${with_tklib}/lib$installedtklibroot.a" ; then
461 ac_cv_c_tklib=`(cd ${with_tklib}; pwd)`/lib$installedtklibroot.a
463 elif test -f "${with_tklib}/libtk.a" ; then
464 ac_cv_c_tklib=`(cd ${with_tklib}; pwd)`/libtk.a
467 AC_MSG_ERROR([${with_tklib} directory doesn't contain libraries])
470 # then check for a private Tk library
471 # Since these are uninstalled, use the simple lib name root.
472 if test x"${ac_cv_c_tklib}" = x ; then
475 `ls -dr ../tk[[0-9]]* 2>/dev/null` \
477 `ls -dr ../../tk[[0-9]]* 2>/dev/null` \
479 `ls -dr ../../../tk[[0-9]]* 2>/dev/null` ; do
480 # Tk 4.1 and greater puts things in subdirs. Check these first.
481 if test -f "$i/unix/libtk.so" ; then
482 ac_cv_c_tklib=`(cd $i; pwd)`/unix/libtk.so
485 elif test -f "$i/unix/libtk.a" -o -f "$i/unix/Makefile"; then
486 ac_cv_c_tklib=`(cd $i; pwd)`/unix/libtk.a
489 # look for a freshly built dynamically linked library
490 elif test -f "$i/libtk.so" ; then
491 ac_cv_c_tklib=`(cd $i; pwd)`/libtk.so
494 # then look for a freshly built statically linked library
495 # if Makefile exists we assume its configured and libtk will be built
496 elif test -f "$i/libtk.a" -o -f "$i/Makefile" ; then
497 ac_cv_c_tklib=`(cd $i; pwd)`/libtk.a
503 # finally check in a few common install locations
504 if test x"${ac_cv_c_tklib}" = x ; then
505 for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
506 # first look for a freshly built dynamically linked library
507 if test -f "$i/lib$installedtklibroot.so" ; then
508 ac_cv_c_tklib=`(cd $i; pwd)`/lib$installedtklibroot.so
511 # then look for a freshly built statically linked library
512 # if Makefile exists, we assume it's configured and libtcl will be built
513 elif test -f "$i/lib$installedtklibroot.a" -o -f "$i/Makefile" ; then
514 ac_cv_c_tklib=`(cd $i; pwd)`/lib$installedtklibroot.a
520 # check in a few other private locations
521 if test x"${ac_cv_c_tklib}" = x ; then
524 `ls -dr ${srcdir}/../tk[[0-9]]* 2>/dev/null` ; do
525 # Tk 4.1 and greater puts things in subdirs. Check these first.
526 if test -f "$i/unix/libtk.so" ; then
527 ac_cv_c_tklib=`(cd $i; pwd)`/unix/libtk.so
530 elif test -f "$i/unix/libtk.a" -o -f "$i/unix/Makefile"; then
531 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtk.a
534 # look for a freshly built dynamically linked library
535 elif test -f "$i/libtk.so" ; then
536 ac_cv_c_tklib=`(cd $i; pwd)`/libtk.so
539 # then look for a freshly built statically linked library
540 # if Makefile exists, we assume it's configured and libtcl will be built
541 elif test -f "$i/libtk.a" -o -f "$i/Makefile" ; then
542 ac_cv_c_tklib=`(cd $i; pwd)`/libtk.a
548 # see if one is conveniently installed with the compiler
549 if test x"${ac_cv_c_tklib}" = x ; then
550 AC_REQUIRE([AC_PATH_X])
552 LIBS="$LIBS -l$installedtklibroot $x_libraries $ac_cv_c_tcllib -lm"
555 { exit(0); }], ac_cv_c_tklib="-l$installedtklibroot", ac_cv_c_tklib=""
556 , ac_cv_c_tklib="-l$installedtklibroot")
560 if test x"${ac_cv_c_tklib}" = x ; then
561 TKLIB="# no Tk library found"
562 AC_MSG_WARN(Can't find Tk library)
565 AC_MSG_RESULT(found $TKLIB)
572 AC_DEFUN(CY_AC_PATH_TK, [
576 AC_DEFUN(CY_AC_PATH_TCL, [