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)
44 AC_DEFUN(CY_AC_PATH_TCLH, [
46 # Ok, lets find the tcl source trees so we can use the headers
47 # Warning: transition of version 9 to 10 will break this algorithm
48 # because 10 sorts before 9. We also look for just tcl. We have to
49 # be careful that we don't match stuff like tclX by accident.
50 # the alternative search directory is involked by --with-tclinclude
53 AC_MSG_CHECKING(for Tcl private headers)
54 AC_ARG_WITH(tclinclude, [ --with-tclinclude directory where tcl private headers are], with_tclinclude=${withval})
55 AC_CACHE_VAL(ac_cv_c_tclh,[
56 # first check to see if --with-tclinclude was specified
57 if test x"${with_tclinclude}" != x ; then
58 if test -f ${with_tclinclude}/tclInt.h ; then
59 ac_cv_c_tclh=`(cd ${with_tclinclude}; pwd)`
61 AC_MSG_ERROR([${with_tclinclude} directory doesn't contain private headers])
64 # next check in private source directory
66 # since ls returns lowest version numbers first, reverse its output
67 if test x"${ac_cv_c_tclh}" = x ; then
70 `ls -dr ${srcdir}/../tcl[[0-9]]* 2>/dev/null` \
72 `ls -dr ${srcdir}/../../tcl[[0-9]]* 2>/dev/null` \
73 ${srcdir}/../../../tcl \
74 `ls -dr ${srcdir}/../../../tcl[[0-9]]* 2>/dev/null ` ; do
75 if test -f $i/tclInt.h ; then
76 ac_cv_c_tclh=`(cd $i; pwd)`
79 # Tcl 7.5 and greater puts headers in subdirectory.
80 if test -f $i/generic/tclInt.h ; then
81 ac_cv_c_tclh=`(cd $i; pwd)`/generic
86 # finally check in a few common install locations
88 # since ls returns lowest version numbers first, reverse its output
89 if test x"${ac_cv_c_tclh}" = x ; then
91 `ls -dr /usr/local/src/tcl[[0-9]]* 2>/dev/null` \
92 `ls -dr /usr/local/lib/tcl[[0-9]]* 2>/dev/null` \
95 ${prefix}/include ; do
96 if test -f $i/tclInt.h ; then
97 ac_cv_c_tclh=`(cd $i; pwd)`
102 # see if one is installed
103 if test x"${ac_cv_c_tclh}" = x ; then
104 AC_HEADER_CHECK(tclInt.h, ac_cv_c_tclh=installed, ac_cv_c_tclh="")
107 if test x"${ac_cv_c_tclh}" = x ; then
108 TCLHDIR="# no Tcl private headers found"
109 AC_MSG_ERROR([Can't find Tcl private headers])
111 if test x"${ac_cv_c_tclh}" != x ; then
113 if test x"${ac_cv_c_tclh}" = x"installed" ; then
114 AC_MSG_RESULT([is installed])
117 AC_MSG_RESULT([found in ${ac_cv_c_tclh}])
118 # this hack is cause the TCLHDIR won't print if there is a "-I" in it.
119 TCLHDIR="-I${ac_cv_c_tclh}"
123 AC_MSG_CHECKING([Tcl version])
124 orig_includes="$CPPFLAGS"
126 if test x"${TCLHDIR}" != x ; then
127 CPPFLAGS="$CPPFLAGS $TCLHDIR"
130 # Get major and minor versions of Tcl. Use funny names to avoid
131 # clashes with eg SunOS.
132 cat > conftest.c <<'EOF'
134 MaJor = TCL_MAJOR_VERSION
135 MiNor = TCL_MINOR_VERSION
140 if (eval "$CPP $CPPFLAGS conftest.c") 2>/dev/null >conftest.out; then
142 tclmajor=`egrep '^MaJor = ' conftest.out | sed -e 's/^MaJor = *//' -e 's/ *$//'`
143 tclminor=`egrep '^MiNor = ' conftest.out | sed -e 's/^MiNor = *//' -e 's/ *$//'`
145 rm -f conftest.c conftest.out
147 if test -z "$tclmajor" || test -z "$tclminor"; then
148 AC_MSG_RESULT([fatal error: could not find major or minor version number of Tcl])
151 AC_MSG_RESULT(${tclmajor}.${tclminor})
153 CPPFLAGS="${orig_includes}"
158 AC_DEFUN(CY_AC_PATH_TCLLIB, [
160 # Ok, lets find the tcl library
161 # First, look for one uninstalled.
162 # the alternative search directory is invoked by --with-tcllib
165 if test $tclmajor -ge 7 -a $tclminor -ge 4 ; then
166 installedtcllibroot=tcl$tclversion
168 installedtcllibroot=tcl
171 if test x"${no_tcl}" = x ; then
172 # we reset no_tcl incase something fails here
174 AC_ARG_WITH(tcllib, [ --with-tcllib directory where the tcl library is],
175 with_tcllib=${withval})
176 AC_MSG_CHECKING([for Tcl library])
177 AC_CACHE_VAL(ac_cv_c_tcllib,[
178 # First check to see if --with-tcllib was specified.
179 # This requires checking for both the installed and uninstalled name-styles
180 # since we have no idea if it's installed or not.
181 if test x"${with_tcllib}" != x ; then
182 if test -f "${with_tcllib}/lib$installedtcllibroot.so" ; then
183 ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/lib$installedtcllibroot.so
184 elif test -f "${with_tcllib}/libtcl.so" ; then
185 ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/libtcl.so
186 # then look for a freshly built statically linked library
187 # if Makefile exists we assume its configured and libtcl will be built first.
188 elif test -f "${with_tcllib}/lib$installedtcllibroot.a" ; then
189 ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/lib$installedtcllibroot.a
190 elif test -f "${with_tcllib}/libtcl.a" ; then
191 ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/libtcl.a
193 AC_MSG_ERROR([${with_tcllib} directory doesn't contain libraries])
196 # then check for a private Tcl library
197 # Since these are uninstalled, use the simple lib name root.
198 if test x"${ac_cv_c_tcllib}" = x ; then
201 `ls -dr ../tcl[[0-9]]* 2>/dev/null` \
203 `ls -dr ../../tcl[[0-9]]* 2>/dev/null` \
205 `ls -dr ../../../tcl[[0-9]]* 2>/dev/null` ; do
206 # Tcl 7.5 and greater puts library in subdir. Look there first.
207 if test -f "$i/unix/libtcl.so" ; then
208 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.so
210 elif test -f "$i/unix/libtcl.a" -o -f "$i/unix/Makefile"; then
211 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.a
213 # look for a freshly built dynamically linked library
214 elif test -f "$i/libtcl.so" ; then
215 ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.so
218 # then look for a freshly built statically linked library
219 # if Makefile exists we assume its configured and libtcl will be
221 elif test -f "$i/libtcl.a" -o -f "$i/Makefile" ; then
222 ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.a
227 # check in a few common install locations
228 if test x"${ac_cv_c_tcllib}" = x ; then
229 for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
230 # first look for a freshly built dynamically linked library
231 if test -f "$i/lib$installedtcllibroot.so" ; then
232 ac_cv_c_tcllib=`(cd $i; pwd)`/lib$installedtcllibroot.so
234 # then look for a freshly built statically linked library
235 # if Makefile exists we assume its configured and libtcl will be built first.
236 elif test -f "$i/lib$installedtcllibroot.a" -o -f "$i/Makefile" ; then
237 ac_cv_c_tcllib=`(cd $i; pwd)`/lib$installedtcllibroot.a
242 # check in a few other private locations
243 if test x"${ac_cv_c_tcllib}" = x ; then
246 `ls -dr ${srcdir}/../tcl[[0-9]]* 2>/dev/null` ; do
247 # Tcl 7.5 and greater puts library in subdir. Look there first.
248 if test -f "$i/unix/libtcl.so" ; then
249 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.so
251 elif test -f "$i/unix/libtcl.a" -o -f "$i/unix/Makefile"; then
252 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.a
254 # look for a freshly built dynamically linked library
255 elif test -f "$i/libtcl.so" ; then
256 ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.so
259 # then look for a freshly built statically linked library
260 # if Makefile exists we assume its configured and libtcl will be
262 elif test -f "$i/libtcl.a" -o -f "$i/Makefile" ; then
263 ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.a
269 # see if one is conveniently installed with the compiler
270 if test x"${ac_cv_c_tcllib}" = x ; then
272 LIBS="$LIBS -l$installedtcllibroot -lm"
275 { exit(0); }], ac_cv_c_tcllib="-l$installedtcllibroot", ac_cv_c_tcllib=""
276 , ac_cv_c_tclib="-l$installedtcllibroot")
280 if test x"${ac_cv_c_tcllib}" = x ; then
281 TCLLIB="# no Tcl library found"
282 AC_MSG_WARN(Can't find Tcl library)
284 TCLLIB=${ac_cv_c_tcllib}
285 AC_MSG_RESULT(found $TCLLIB)
293 AC_DEFUN(CY_AC_PATH_TKH, [
295 # Ok, lets find the tk source trees so we can use the headers
296 # If the directory (presumably symlink) named "tk" exists, use that one
297 # in preference to any others. Same logic is used when choosing library
298 # and again with Tcl. The search order is the best place to look first, then in
299 # decreasing significance. The loop breaks if the trigger file is found.
300 # Note the gross little conversion here of srcdir by cd'ing to the found
301 # directory. This converts the path from a relative to an absolute, so
302 # recursive cache variables for the path will work right. We check all
303 # the possible paths in one loop rather than many seperate loops to speed
305 # the alternative search directory is invoked by --with-tkinclude
307 AC_MSG_CHECKING(for Tk private headers)
308 AC_ARG_WITH(tkinclude, [ --with-tkinclude directory where the tk private headers are],
309 with_tkinclude=${withval})
311 AC_CACHE_VAL(ac_cv_c_tkh,[
312 # first check to see if --with-tkinclude was specified
313 if test x"${with_tkinclude}" != x ; then
314 if test -f ${with_tkinclude}/tk.h ; then
315 ac_cv_c_tkh=`(cd ${with_tkinclude}; pwd)`
317 AC_MSG_ERROR([${with_tkinclude} directory doesn't contain private headers])
320 # next check in private source directory
322 # since ls returns lowest version numbers first, reverse the entire list
323 # and search for the worst fit, overwriting it with better fits as we find them
324 if test x"${ac_cv_c_tkh}" = x ; then
327 `ls -dr ${srcdir}/../tk[[0-9]]* 2>/dev/null` \
329 `ls -dr ${srcdir}/../../tk[[0-9]]* 2>/dev/null` \
330 ${srcdir}/../../../tk \
331 `ls -dr ${srcdir}/../../../tk[[0-9]]* 2>/dev/null ` ; do
332 if test -f $i/tk.h ; then
333 ac_cv_c_tkh=`(cd $i; pwd)`
336 # Tk 4.1 and greater puts this in a subdir.
337 if test -f $i/generic/tk.h; then
338 ac_cv_c_tkh=`(cd $i; pwd)`/generic
342 # finally check in a few common install locations
344 # since ls returns lowest version numbers first, reverse the entire list
345 # and search for the worst fit, overwriting it with better fits as we find them
346 if test x"${ac_cv_c_tkh}" = x ; then
348 `ls -dr /usr/local/src/tk[[0-9]]* 2>/dev/null` \
349 `ls -dr /usr/local/lib/tk[[0-9]]* 2>/dev/null` \
352 ${prefix}/include ; do
353 if test -f $i/tk.h ; then
354 ac_cv_c_tkh=`(cd $i; pwd)`
359 # see if one is installed
360 if test x"${ac_cv_c_tkh}" = x ; then
361 AC_HEADER_CHECK(tk.h, ac_cv_c_tkh=installed)
364 if test x"${ac_cv_c_tkh}" != x ; then
366 if test x"${ac_cv_c_tkh}" = x"installed" ; then
367 AC_MSG_RESULT([is installed])
370 AC_MSG_RESULT([found in $ac_cv_c_tkh])
371 # this hack is cause the TKHDIR won't print if there is a "-I" in it.
372 TKHDIR="-I${ac_cv_c_tkh}"
375 TKHDIR="# no Tk directory found"
376 AC_MSG_WARN([Can't find Tk private headers])
380 # if Tk is installed, extract the major/minor version
381 if test x"${no_tk}" = x ; then
382 AC_MSG_CHECKING([Tk version])
383 orig_includes="$CPPFLAGS"
385 if test x"${TCLHDIR}" != x ; then
386 CPPFLAGS="$CPPFLAGS $TCLHDIR"
388 if test x"${TKHDIR}" != x ; then
389 CPPFLAGS="$CPPFLAGS $TKHDIR"
391 if test x"${x_includes}" != x -a x"${x_includes}" != xNONE ; then
392 CPPFLAGS="$CPPFLAGS -I$x_includes"
395 # Get major and minor versions of Tk. Use funny names to avoid
396 # clashes with eg SunOS.
397 cat > conftest.c <<'EOF'
399 MaJor = TK_MAJOR_VERSION
400 MiNor = TK_MINOR_VERSION
405 if (eval "$CPP $CPPFLAGS conftest.c") 2>/dev/null >conftest.out; then
407 tkmajor=`egrep '^MaJor = ' conftest.out | sed -e 's/^MaJor = *//' -e 's/ *$//'`
408 tkminor=`egrep '^MiNor = ' conftest.out | sed -e 's/^MiNor = *//' -e 's/ *$//'`
410 rm -f conftest.c conftest.out
412 if test -z "$tkmajor" || test -z "$tkminor"; then
413 AC_MSG_RESULT([fatal error: could not find major or minor version number of Tk])
416 AC_MSG_RESULT(${tkmajor}.${tkminor})
418 CPPFLAGS="${orig_includes}"
424 AC_DEFUN(CY_AC_PATH_TKLIB, [
425 AC_REQUIRE([CY_AC_PATH_TCL])
427 # Ok, lets find the tk library
428 # First, look for the latest private (uninstalled) copy
429 # Notice that the destinations in backwards priority since the tests have
431 # Then we look for either .a, .so, or Makefile. A Makefile is acceptable
432 # is it indicates the target has been configured and will (probably)
433 # soon be built. This allows an entire tree of Tcl software to be
434 # configured at once and then built.
435 # the alternative search directory is invoked by --with-tklib
438 if test x"${no_tk}" = x ; then
439 # reset no_tk incase something fails here
442 if test $tkmajor -ge 4 ; then
443 installedtklibroot=tk$tkversion
445 installedtkllibroot=tk
448 AC_ARG_WITH(tklib, [ --with-tklib directory where the tk library is],
449 with_tklib=${withval})
450 AC_MSG_CHECKING([for Tk library])
451 AC_CACHE_VAL(ac_cv_c_tklib,[
452 # first check to see if --with-tklib was specified
453 # This requires checking for both the installed and uninstalled name-styles
454 # since we have no idea if it's installed or not.
455 if test x"${with_tklib}" != x ; then
456 if test -f "${with_tklib}/lib$installedtklibroot.so" ; then
457 ac_cv_c_tklib=`(cd ${with_tklib}; pwd)`/lib$installedtklibroot.so
459 elif test -f "${with_tklib}/libtk.so" ; then
460 ac_cv_c_tklib=`(cd ${with_tklib}; pwd)`/libtk.so
462 # then look for a freshly built statically linked library
463 # if Makefile exists we assume its configured and libtk will be built
464 elif test -f "${with_tklib}/lib$installedtklibroot.a" ; then
465 ac_cv_c_tklib=`(cd ${with_tklib}; pwd)`/lib$installedtklibroot.a
467 elif test -f "${with_tklib}/libtk.a" ; then
468 ac_cv_c_tklib=`(cd ${with_tklib}; pwd)`/libtk.a
471 AC_MSG_ERROR([${with_tklib} directory doesn't contain libraries])
474 # then check for a private Tk library
475 # Since these are uninstalled, use the simple lib name root.
476 if test x"${ac_cv_c_tklib}" = x ; then
479 `ls -dr ../tk[[0-9]]* 2>/dev/null` \
481 `ls -dr ../../tk[[0-9]]* 2>/dev/null` \
483 `ls -dr ../../../tk[[0-9]]* 2>/dev/null` ; do
484 # Tk 4.1 and greater puts things in subdirs. Check these first.
485 if test -f "$i/unix/libtk.so" ; then
486 ac_cv_c_tklib=`(cd $i; pwd)`/unix/libtk.so
489 elif test -f "$i/unix/libtk.a" -o -f "$i/unix/Makefile"; then
490 ac_cv_c_tklib=`(cd $i; pwd)`/unix/libtk.a
493 # look for a freshly built dynamically linked library
494 elif test -f "$i/libtk.so" ; then
495 ac_cv_c_tklib=`(cd $i; pwd)`/libtk.so
498 # then look for a freshly built statically linked library
499 # if Makefile exists we assume its configured and libtk will be built
500 elif test -f "$i/libtk.a" -o -f "$i/Makefile" ; then
501 ac_cv_c_tklib=`(cd $i; pwd)`/libtk.a
507 # finally check in a few common install locations
508 if test x"${ac_cv_c_tklib}" = x ; then
509 for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
510 # first look for a freshly built dynamically linked library
511 if test -f "$i/lib$installedtklibroot.so" ; then
512 ac_cv_c_tklib=`(cd $i; pwd)`/lib$installedtklibroot.so
515 # then look for a freshly built statically linked library
516 # if Makefile exists, we assume it's configured and libtcl will be built
517 elif test -f "$i/lib$installedtklibroot.a" -o -f "$i/Makefile" ; then
518 ac_cv_c_tklib=`(cd $i; pwd)`/lib$installedtklibroot.a
524 # check in a few other private locations
525 if test x"${ac_cv_c_tklib}" = x ; then
528 `ls -dr ${srcdir}/../tk[[0-9]]* 2>/dev/null` ; do
529 # Tk 4.1 and greater puts things in subdirs. Check these first.
530 if test -f "$i/unix/libtk.so" ; then
531 ac_cv_c_tklib=`(cd $i; pwd)`/unix/libtk.so
534 elif test -f "$i/unix/libtk.a" -o -f "$i/unix/Makefile"; then
535 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtk.a
538 # look for a freshly built dynamically linked library
539 elif test -f "$i/libtk.so" ; then
540 ac_cv_c_tklib=`(cd $i; pwd)`/libtk.so
543 # then look for a freshly built statically linked library
544 # if Makefile exists, we assume it's configured and libtcl will be built
545 elif test -f "$i/libtk.a" -o -f "$i/Makefile" ; then
546 ac_cv_c_tklib=`(cd $i; pwd)`/libtk.a
552 # see if one is conveniently installed with the compiler
553 if test x"${ac_cv_c_tklib}" = x ; then
554 AC_REQUIRE([AC_PATH_X])
556 LIBS="$LIBS -l$installedtklibroot $x_libraries $ac_cv_c_tcllib -lm"
559 { exit(0); }], ac_cv_c_tklib="-l$installedtklibroot", ac_cv_c_tklib=""
560 , ac_cv_c_tklib="-l$installedtklibroot")
564 if test x"${ac_cv_c_tklib}" = x ; then
565 TKLIB="# no Tk library found"
566 AC_MSG_WARN(Can't find Tk library)
569 AC_MSG_RESULT(found $TKLIB)
576 AC_DEFUN(CY_AC_PATH_TK, [
580 AC_DEFUN(CY_AC_PATH_TCL, [