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 rm -rf tclmajor tclminor
123 orig_includes="$CPPFLAGS"
125 if test x"${TCLHDIR}" != x ; then
126 CPPFLAGS="$CPPFLAGS $TCLHDIR"
133 FILE *maj = fopen("tclmajor","w");
134 FILE *min = fopen("tclminor","w");
135 fprintf(maj,"%d",TCL_MAJOR_VERSION);
136 fprintf(min,"%d",TCL_MINOR_VERSION);
141 tclmajor=`cat tclmajor`
142 tclminor=`cat tclminor`
143 tclversion=$tclmajor.$tclminor
144 AC_MSG_RESULT($tclversion)
145 rm -f tclmajor tclminor
147 AC_MSG_RESULT([can't happen])
149 AC_MSG_ERROR([can't be cross compiled])
151 CPPFLAGS="${orig_includes}"
156 AC_DEFUN(CY_AC_PATH_TCLLIB, [
158 # Ok, lets find the tcl library
159 # First, look for one uninstalled.
160 # the alternative search directory is invoked by --with-tcllib
163 if test $tclmajor -ge 7 -a $tclminor -ge 4 ; then
164 installedtcllibroot=tcl$tclversion
166 installedtcllibroot=tcl
169 if test x"${no_tcl}" = x ; then
170 # we reset no_tcl incase something fails here
172 AC_ARG_WITH(tcllib, [ --with-tcllib directory where the tcl library is],
173 with_tcllib=${withval})
174 AC_MSG_CHECKING([for Tcl library])
175 AC_CACHE_VAL(ac_cv_c_tcllib,[
176 # First check to see if --with-tcllib was specified.
177 # This requires checking for both the installed and uninstalled name-styles
178 # since we have no idea if it's installed or not.
179 if test x"${with_tcllib}" != x ; then
180 if test -f "${with_tcllib}/lib$installedtcllibroot.so" ; then
181 ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/lib$installedtcllibroot.so
182 elif test -f "${with_tcllib}/libtcl.so" ; then
183 ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/libtcl.so
184 # then look for a freshly built statically linked library
185 # if Makefile exists we assume its configured and libtcl will be built first.
186 elif test -f "${with_tcllib}/lib$installedtcllibroot.a" ; then
187 ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/lib$installedtcllibroot.a
188 elif test -f "${with_tcllib}/libtcl.a" ; then
189 ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/libtcl.a
191 AC_MSG_ERROR([${with_tcllib} directory doesn't contain libraries])
194 # then check for a private Tcl library
195 # Since these are uninstalled, use the simple lib name root.
196 if test x"${ac_cv_c_tcllib}" = x ; then
199 `ls -dr ../tcl[[0-9]]* 2>/dev/null` \
201 `ls -dr ../../tcl[[0-9]]* 2>/dev/null` \
203 `ls -dr ../../../tcl[[0-9]]* 2>/dev/null` ; do
204 # Tcl 7.5 and greater puts library in subdir. Look there first.
205 if test -f "$i/unix/libtcl.so" ; then
206 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.so
208 elif test -f "$i/unix/libtcl.a" -o -f "$i/unix/Makefile"; then
209 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.a
211 # look for a freshly built dynamically linked library
212 elif test -f "$i/libtcl.so" ; then
213 ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.so
216 # then look for a freshly built statically linked library
217 # if Makefile exists we assume its configured and libtcl will be
219 elif test -f "$i/libtcl.a" -o -f "$i/Makefile" ; then
220 ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.a
225 # check in a few common install locations
226 if test x"${ac_cv_c_tcllib}" = x ; then
227 for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
228 # first look for a freshly built dynamically linked library
229 if test -f "$i/lib$installedtcllibroot.so" ; then
230 ac_cv_c_tcllib=`(cd $i; pwd)`/lib$installedtcllibroot.so
232 # then look for a freshly built statically linked library
233 # if Makefile exists we assume its configured and libtcl will be built first.
234 elif test -f "$i/lib$installedtcllibroot.a" -o -f "$i/Makefile" ; then
235 ac_cv_c_tcllib=`(cd $i; pwd)`/lib$installedtcllibroot.a
240 # check in a few other private locations
241 if test x"${ac_cv_c_tcllib}" = x ; then
244 `ls -dr ${srcdir}/../tcl[[0-9]]* 2>/dev/null` ; do
245 # Tcl 7.5 and greater puts library in subdir. Look there first.
246 if test -f "$i/unix/libtcl.so" ; then
247 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.so
249 elif test -f "$i/unix/libtcl.a" -o -f "$i/unix/Makefile"; then
250 ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.a
252 # look for a freshly built dynamically linked library
253 elif test -f "$i/libtcl.so" ; then
254 ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.so
257 # then look for a freshly built statically linked library
258 # if Makefile exists we assume its configured and libtcl will be
260 elif test -f "$i/libtcl.a" -o -f "$i/Makefile" ; then
261 ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.a
267 # see if one is conveniently installed with the compiler
268 if test x"${ac_cv_c_tcllib}" = x ; then
270 LIBS="$LIBS -l$installedtcllibroot -lm"
273 { exit(0); }], ac_cv_c_tcllib="-l$installedtcllibroot", ac_cv_c_tcllib=""
274 , ac_cv_c_tclib="-l$installedtcllibroot")
278 if test x"${ac_cv_c_tcllib}" = x ; then
279 TCLLIB="# no Tcl library found"
280 AC_MSG_WARN(Can't find Tcl library)
282 TCLLIB=${ac_cv_c_tcllib}
283 AC_MSG_RESULT(found $TCLLIB)
291 AC_DEFUN(CY_AC_PATH_TKH, [
293 # Ok, lets find the tk source trees so we can use the headers
294 # If the directory (presumably symlink) named "tk" exists, use that one
295 # in preference to any others. Same logic is used when choosing library
296 # and again with Tcl. The search order is the best place to look first, then in
297 # decreasing significance. The loop breaks if the trigger file is found.
298 # Note the gross little conversion here of srcdir by cd'ing to the found
299 # directory. This converts the path from a relative to an absolute, so
300 # recursive cache variables for the path will work right. We check all
301 # the possible paths in one loop rather than many seperate loops to speed
303 # the alternative search directory is invoked by --with-tkinclude
305 AC_MSG_CHECKING(for Tk private headers)
306 AC_ARG_WITH(tkinclude, [ --with-tkinclude directory where the tk private headers are],
307 with_tkinclude=${withval})
309 AC_CACHE_VAL(ac_cv_c_tkh,[
310 # first check to see if --with-tkinclude was specified
311 if test x"${with_tkinclude}" != x ; then
312 if test -f ${with_tkinclude}/tk.h ; then
313 ac_cv_c_tkh=`(cd ${with_tkinclude}; pwd)`
315 AC_MSG_ERROR([${with_tkinclude} directory doesn't contain private headers])
318 # next check in private source directory
320 # since ls returns lowest version numbers first, reverse the entire list
321 # and search for the worst fit, overwriting it with better fits as we find them
322 if test x"${ac_cv_c_tkh}" = x ; then
325 `ls -dr ${srcdir}/../tk[[0-9]]* 2>/dev/null` \
327 `ls -dr ${srcdir}/../../tk[[0-9]]* 2>/dev/null` \
328 ${srcdir}/../../../tk \
329 `ls -dr ${srcdir}/../../../tk[[0-9]]* 2>/dev/null ` ; do
330 if test -f $i/tk.h ; then
331 ac_cv_c_tkh=`(cd $i; pwd)`
334 # Tk 4.1 and greater puts this in a subdir.
335 if test -f $i/generic/tk.h; then
336 ac_cv_c_tkh=`(cd $i; pwd)`/generic
340 # finally check in a few common install locations
342 # since ls returns lowest version numbers first, reverse the entire list
343 # and search for the worst fit, overwriting it with better fits as we find them
344 if test x"${ac_cv_c_tkh}" = x ; then
346 `ls -dr /usr/local/src/tk[[0-9]]* 2>/dev/null` \
347 `ls -dr /usr/local/lib/tk[[0-9]]* 2>/dev/null` \
350 ${prefix}/include ; do
351 if test -f $i/tk.h ; then
352 ac_cv_c_tkh=`(cd $i; pwd)`
357 # see if one is installed
358 if test x"${ac_cv_c_tkh}" = x ; then
359 AC_HEADER_CHECK(tk.h, ac_cv_c_tkh=installed)
362 if test x"${ac_cv_c_tkh}" != x ; then
364 if test x"${ac_cv_c_tkh}" = x"installed" ; then
365 AC_MSG_RESULT([is installed])
368 AC_MSG_RESULT([found in $ac_cv_c_tkh])
369 # this hack is cause the TKHDIR won't print if there is a "-I" in it.
370 TKHDIR="-I${ac_cv_c_tkh}"
373 TKHDIR="# no Tk directory found"
374 AC_MSG_WARN([Can't find Tk private headers])
378 # if Tk is installed, extract the major/minor version
379 if test x"${no_tk}" = x ; then
380 AC_MSG_CHECKING([Tk version])
381 rm -rf tkmajor tkminor
382 orig_includes="$CPPFLAGS"
384 if test x"${TCLHDIR}" != x ; then
385 CPPFLAGS="$CPPFLAGS $TCLHDIR"
387 if test x"${TKHDIR}" != x ; then
388 CPPFLAGS="$CPPFLAGS $TKHDIR"
390 if test x"${x_includes}" != x -a x"${x_includes}" != xNONE ; then
391 CPPFLAGS="$CPPFLAGS -I$x_includes"
398 FILE *maj = fopen("tkmajor","w");
399 FILE *min = fopen("tkminor","w");
400 fprintf(maj,"%d",TK_MAJOR_VERSION);
401 fprintf(min,"%d",TK_MINOR_VERSION);
406 tkmajor=`cat tkmajor`
407 tkminor=`cat tkminor`
408 tkversion=$tkmajor.$tkminor
409 AC_MSG_RESULT($tkversion)
410 rm -f tkmajor tkminor
413 cannot compile a simple X program - suspect your xmkmf is
414 misconfigured and is incorrectly reporting the location of your X
415 include or libraries - report this to your system admin]) ,
416 AC_MSG_ERROR([can't be cross compiled])
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, [