* aclocal.m4: Include ../bfd/aclocal.m4.
[external/binutils.git] / gdb / aclocal.m4
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>
3
4 sinclude(../bfd/aclocal.m4)
5
6 dnl CY_AC_PATH_TCLCONFIG and CY_AC_LOAD_TCLCONFIG should be invoked
7 dnl (in that order) before any other TCL macros.  Similarly for TK.
8
9 dnl CYGNUS LOCAL: This gets the right posix flag for gcc
10 AC_DEFUN(CY_AC_TCL_LYNX_POSIX,
11 [AC_REQUIRE([AC_PROG_CC])AC_REQUIRE([AC_PROG_CPP])
12 AC_MSG_CHECKING([if running LynxOS])
13 AC_CACHE_VAL(ac_cv_os_lynx,
14 [AC_EGREP_CPP(yes,
15 [/*
16  * The old Lynx "cc" only defines "Lynx", but the newer one uses "__Lynx__"
17  */
18 #if defined(__Lynx__) || defined(Lynx)
19 yes
20 #endif
21 ], ac_cv_os_lynx=yes, ac_cv_os_lynx=no)])
22 #
23 if test "$ac_cv_os_lynx" = "yes" ; then
24   AC_MSG_RESULT(yes)
25   AC_DEFINE(LYNX)
26   AC_MSG_CHECKING([whether -mposix or -X is available])
27   AC_CACHE_VAL(ac_cv_c_posix_flag,
28   [AC_TRY_COMPILE(,[
29   /*
30    * This flag varies depending on how old the compiler is.
31    * -X is for the old "cc" and "gcc" (based on 1.42).
32    * -mposix is for the new gcc (at least 2.5.8).
33    */
34   #if defined(__GNUC__) && __GNUC__ >= 2
35   choke me
36   #endif
37   ], ac_cv_c_posix_flag=" -mposix", ac_cv_c_posix_flag=" -X")])
38   CC="$CC $ac_cv_c_posix_flag"
39   AC_MSG_RESULT($ac_cv_c_posix_flag)
40   else
41   AC_MSG_RESULT(no)
42 fi
43 ])
44
45 #
46 # Sometimes the native compiler is a bogus stub for gcc or /usr/ucb/cc. This
47 # makes configure think it's cross compiling. If --target wasn't used, then
48 # we can't configure, so something is wrong. We don't use the cache
49 # here cause if somebody fixes their compiler install, we want this to work.
50 AC_DEFUN(CY_AC_C_WORKS,
51 [# If we cannot compile and link a trivial program, we can't expect anything to work
52 AC_MSG_CHECKING(whether the compiler ($CC) actually works)
53 AC_TRY_COMPILE(, [/* don't need anything here */],
54         c_compiles=yes, c_compiles=no)
55
56 AC_TRY_LINK(, [/* don't need anything here */],
57         c_links=yes, c_links=no)
58
59 if test x"${c_compiles}" = x"no" ; then
60   AC_MSG_ERROR(the native compiler is broken and won't compile.)
61 fi
62
63 if test x"${c_links}" = x"no" ; then
64   AC_MSG_ERROR(the native compiler is broken and won't link.)
65 fi
66 AC_MSG_RESULT(yes)
67 ])
68
69 AC_DEFUN(CY_AC_PATH_TCLH, [
70 #
71 # Ok, lets find the tcl source trees so we can use the headers
72 # Warning: transition of version 9 to 10 will break this algorithm
73 # because 10 sorts before 9. We also look for just tcl. We have to
74 # be careful that we don't match stuff like tclX by accident.
75 # the alternative search directory is involked by --with-tclinclude
76 #
77 no_tcl=true
78 AC_MSG_CHECKING(for Tcl private headers)
79 AC_ARG_WITH(tclinclude, [  --with-tclinclude       directory where tcl private headers are], with_tclinclude=${withval})
80 AC_CACHE_VAL(ac_cv_c_tclh,[
81 # first check to see if --with-tclinclude was specified
82 if test x"${with_tclinclude}" != x ; then
83   if test -f ${with_tclinclude}/tclInt.h ; then
84     ac_cv_c_tclh=`(cd ${with_tclinclude}; pwd)`
85   elif test -f ${with_tclinclude}/generic/tclInt.h ; then
86     ac_cv_c_tclh=`(cd ${with_tclinclude}/generic; pwd)`
87   else
88     AC_MSG_ERROR([${with_tclinclude} directory doesn't contain private headers])
89   fi
90 fi
91
92 # next check if it came with Tcl configuration file
93 if test x"${ac_cv_c_tclconfig}" = x ; then
94   if test -f $ac_cv_c_tclconfig/../generic/tclInt.h ; then
95     ac_cv_c_tclh=`(cd $ac_cv_c_tclconfig/..; pwd)`
96   fi
97 fi
98
99 # next check in private source directory
100 #
101 # since ls returns lowest version numbers first, reverse its output
102 if test x"${ac_cv_c_tclh}" = x ; then
103   for i in \
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` \
108                 ${srcdir}/../../../tcl \
109                 `ls -dr ${srcdir}/../../../tcl[[7-9]]* 2>/dev/null ` ; do
110     if test -f $i/generic/tclInt.h ; then
111       ac_cv_c_tclh=`(cd $i/generic; pwd)`
112       break
113     fi
114   done
115 fi
116 # finally check in a few common install locations
117 #
118 # since ls returns lowest version numbers first, reverse its output
119 if test x"${ac_cv_c_tclh}" = x ; then
120   for i in \
121                 `ls -dr /usr/local/src/tcl[[7-9]]* 2>/dev/null` \
122                 `ls -dr /usr/local/lib/tcl[[7-9]]* 2>/dev/null` \
123                 /usr/local/src/tcl \
124                 /usr/local/lib/tcl \
125                 ${prefix}/include ; do
126     if test -f $i/generic/tclInt.h ; then
127       ac_cv_c_tclh=`(cd $i/generic; pwd)`
128       break
129     fi
130   done
131 fi
132 # see if one is installed
133 if test x"${ac_cv_c_tclh}" = x ; then
134    AC_HEADER_CHECK(tclInt.h, ac_cv_c_tclh=installed, ac_cv_c_tclh="")
135 fi
136 ])
137 if test x"${ac_cv_c_tclh}" = x ; then
138   TCLHDIR="# no Tcl private headers found"
139   AC_MSG_ERROR([Can't find Tcl private headers])
140 fi
141 if test x"${ac_cv_c_tclh}" != x ; then
142   no_tcl=""
143   if test x"${ac_cv_c_tclh}" = x"installed" ; then
144     AC_MSG_RESULT([is installed])
145     TCLHDIR=""
146   else
147     AC_MSG_RESULT([found in ${ac_cv_c_tclh}])
148     # this hack is cause the TCLHDIR won't print if there is a "-I" in it.
149     TCLHDIR="-I${ac_cv_c_tclh}"
150   fi
151 fi
152
153 AC_SUBST(TCLHDIR)
154 ])
155
156
157 AC_DEFUN(CY_AC_PATH_TCLCONFIG, [
158 #
159 # Ok, lets find the tcl configuration
160 # First, look for one uninstalled.  
161 # the alternative search directory is invoked by --with-tclconfig
162 #
163
164 if test x"${no_tcl}" = x ; then
165   # we reset no_tcl in case something fails here
166   no_tcl=true
167   AC_ARG_WITH(tclconfig, [  --with-tclconfig           directory containing tcl configuration (tclConfig.sh)],
168          with_tclconfig=${withval})
169   AC_MSG_CHECKING([for Tcl configuration])
170   AC_CACHE_VAL(ac_cv_c_tclconfig,[
171
172   # First check to see if --with-tclconfig was specified.
173   if test x"${with_tclconfig}" != x ; then
174     if test -f "${with_tclconfig}/tclConfig.sh" ; then
175       ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
176     else
177       AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
178     fi
179   fi
180
181   # then check for a private Tcl installation
182   if test x"${ac_cv_c_tclconfig}" = x ; then
183     for i in \
184                 ../tcl \
185                 `ls -dr ../tcl[[7-9]]* 2>/dev/null` \
186                 ../../tcl \
187                 `ls -dr ../../tcl[[7-9]]* 2>/dev/null` \
188                 ../../../tcl \
189                 `ls -dr ../../../tcl[[7-9]]* 2>/dev/null` ; do
190       if test -f "$i/unix/tclConfig.sh" ; then
191         ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
192         break
193       fi
194     done
195   fi
196   # check in a few common install locations
197   if test x"${ac_cv_c_tclconfig}" = x ; then
198     for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
199       if test -f "$i/tclConfig.sh" ; then
200         ac_cv_c_tclconfig=`(cd $i; pwd)`
201         break
202       fi
203     done
204   fi
205   # check in a few other private locations
206   if test x"${ac_cv_c_tclconfig}" = x ; then
207     for i in \
208                 ${srcdir}/../tcl \
209                 `ls -dr ${srcdir}/../tcl[[7-9]]* 2>/dev/null` ; do
210       if test -f "$i/unix/tclConfig.sh" ; then
211         ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
212         break
213       fi
214     done
215   fi
216   ])
217   if test x"${ac_cv_c_tclconfig}" = x ; then
218     TCLCONFIG="# no Tcl configs found"
219     AC_MSG_WARN(Can't find Tcl configuration definitions)
220   else
221     no_tcl=
222     TCLCONFIG=${ac_cv_c_tclconfig}/tclConfig.sh
223     AC_MSG_RESULT(found $TCLCONFIG)
224   fi
225 fi
226 ])
227
228 # Defined as a separate macro so we don't have to cache the values
229 # from PATH_TCLCONFIG (because this can also be cached).
230 AC_DEFUN(CY_AC_LOAD_TCLCONFIG, [
231     . $TCLCONFIG
232
233     AC_SUBST(TCL_VERSION)
234     AC_SUBST(TCL_MAJOR_VERSION)
235     AC_SUBST(TCL_MINOR_VERSION)
236     AC_SUBST(TCL_CC)
237     AC_SUBST(TCL_DEFS)
238
239 dnl not used, don't export to save symbols
240 dnl    AC_SUBST(TCL_LIB_FILE)
241
242 dnl don't export, not used outside of configure
243 dnl     AC_SUBST(TCL_LIBS)
244 dnl not used, don't export to save symbols
245 dnl    AC_SUBST(TCL_PREFIX)
246
247 dnl not used, don't export to save symbols
248 dnl    AC_SUBST(TCL_EXEC_PREFIX)
249
250     AC_SUBST(TCL_SHLIB_CFLAGS)
251     AC_SUBST(TCL_SHLIB_LD)
252 dnl don't export, not used outside of configure
253     AC_SUBST(TCL_SHLIB_LD_LIBS)
254     AC_SUBST(TCL_SHLIB_SUFFIX)
255 dnl not used, don't export to save symbols
256     AC_SUBST(TCL_DL_LIBS)
257     AC_SUBST(TCL_LD_FLAGS)
258 dnl don't export, not used outside of configure
259     AC_SUBST(TCL_LD_SEARCH_FLAGS)
260     AC_SUBST(TCL_COMPAT_OBJS)
261     AC_SUBST(TCL_RANLIB)
262     AC_SUBST(TCL_BUILD_LIB_SPEC)
263     AC_SUBST(TCL_LIB_SPEC)
264     AC_SUBST(TCL_LIB_VERSIONS_OK)
265
266 dnl not used, don't export to save symbols
267 dnl    AC_SUBST(TCL_SHARED_LIB_SUFFIX)
268
269 dnl not used, don't export to save symbols
270 dnl    AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
271 ])
272
273 # Warning: Tk definitions are very similar to Tcl definitions but
274 # are not precisely the same.  There are a couple of differences,
275 # so don't do changes to Tcl thinking you can cut and paste it do 
276 # the Tk differences and later simply substitute "Tk" for "Tcl".
277 # Known differences:
278 #  - Acceptable Tcl major version #s is 7-9 while Tk is 4-9
279 #  - Searching for Tcl includes looking for tclInt.h, Tk looks for tk.h
280 #  - Computing major/minor versions is different because Tk depends on
281 #    headers to Tcl, Tk, and X.
282 #  - Symbols in tkConfig.sh are different than tclConfig.sh
283 #  - Acceptable for Tk to be missing but not Tcl.
284
285 AC_DEFUN(CY_AC_PATH_TKH, [
286 #
287 # Ok, lets find the tk source trees so we can use the headers
288 # If the directory (presumably symlink) named "tk" exists, use that one
289 # in preference to any others.  Same logic is used when choosing library
290 # and again with Tcl. The search order is the best place to look first, then in
291 # decreasing significance. The loop breaks if the trigger file is found.
292 # Note the gross little conversion here of srcdir by cd'ing to the found
293 # directory. This converts the path from a relative to an absolute, so
294 # recursive cache variables for the path will work right. We check all
295 # the possible paths in one loop rather than many seperate loops to speed
296 # things up.
297 # the alternative search directory is involked by --with-tkinclude
298 #
299 no_tk=true
300 AC_MSG_CHECKING(for Tk private headers)
301 AC_ARG_WITH(tkinclude, [  --with-tkinclude       directory where tk private headers are], with_tkinclude=${withval})
302 AC_CACHE_VAL(ac_cv_c_tkh,[
303 # first check to see if --with-tkinclude was specified
304 if test x"${with_tkinclude}" != x ; then
305   if test -f ${with_tkinclude}/tk.h ; then
306     ac_cv_c_tkh=`(cd ${with_tkinclude}; pwd)`
307   elif test -f ${with_tkinclude}/generic/tk.h ; then
308     ac_cv_c_tkh=`(cd ${with_tkinclude}/generic; pwd)`
309   else
310     AC_MSG_ERROR([${with_tkinclude} directory doesn't contain private headers])
311   fi
312 fi
313
314 # next check if it came with Tk configuration file
315 if test x"${ac_cv_c_tkconfig}" = x ; then
316   if test -f $ac_cv_c_tkconfig/../generic/tk.h ; then
317     ac_cv_c_tkh=`(cd $ac_cv_c_tkconfig/..; pwd)`
318   fi
319 fi
320
321 # next check in private source directory
322 #
323 # since ls returns lowest version numbers first, reverse its output
324 if test x"${ac_cv_c_tkh}" = x ; then
325   for i in \
326                 ${srcdir}/../tk \
327                 `ls -dr ${srcdir}/../tk[[4-9]]* 2>/dev/null` \
328                 ${srcdir}/../../tk \
329                 `ls -dr ${srcdir}/../../tk[[4-9]]* 2>/dev/null` \
330                 ${srcdir}/../../../tk \
331                 `ls -dr ${srcdir}/../../../tk[[4-9]]* 2>/dev/null ` ; do
332     if test -f $i/generic/tk.h ; then
333       ac_cv_c_tkh=`(cd $i/generic; pwd)`
334       break
335     fi
336   done
337 fi
338 # finally check in a few common install locations
339 #
340 # since ls returns lowest version numbers first, reverse its output
341 if test x"${ac_cv_c_tkh}" = x ; then
342   for i in \
343                 `ls -dr /usr/local/src/tk[[4-9]]* 2>/dev/null` \
344                 `ls -dr /usr/local/lib/tk[[4-9]]* 2>/dev/null` \
345                 /usr/local/src/tk \
346                 /usr/local/lib/tk \
347                 ${prefix}/include ; do
348     if test -f $i/generic/tk.h ; then
349       ac_cv_c_tkh=`(cd $i/generic; pwd)`
350       break
351     fi
352   done
353 fi
354 # see if one is installed
355 if test x"${ac_cv_c_tkh}" = x ; then
356    AC_HEADER_CHECK(tk.h, ac_cv_c_tkh=installed, ac_cv_c_tkh="")
357 fi
358 ])
359 if test x"${ac_cv_c_tkh}" != x ; then
360   no_tk=""
361   if test x"${ac_cv_c_tkh}" = x"installed" ; then
362     AC_MSG_RESULT([is installed])
363     TKHDIR=""
364   else
365     AC_MSG_RESULT([found in ${ac_cv_c_tkh}])
366     # this hack is cause the TKHDIR won't print if there is a "-I" in it.
367     TKHDIR="-I${ac_cv_c_tkh}"
368   fi
369 else
370   TKHDIR="# no Tk directory found"
371   AC_MSG_WARN([Can't find Tk private headers])
372   no_tk=true
373 fi
374
375 AC_SUBST(TKHDIR)
376 ])
377
378
379 AC_DEFUN(CY_AC_PATH_TKCONFIG, [
380 #
381 # Ok, lets find the tk configuration
382 # First, look for one uninstalled.  
383 # the alternative search directory is invoked by --with-tkconfig
384 #
385
386 if test x"${no_tk}" = x ; then
387   # we reset no_tk in case something fails here
388   no_tk=true
389   AC_ARG_WITH(tkconfig, [  --with-tkconfig           directory containing tk configuration (tkConfig.sh)],
390          with_tkconfig=${withval})
391   AC_MSG_CHECKING([for Tk configuration])
392   AC_CACHE_VAL(ac_cv_c_tkconfig,[
393
394   # First check to see if --with-tkconfig was specified.
395   if test x"${with_tkconfig}" != x ; then
396     if test -f "${with_tkconfig}/tkConfig.sh" ; then
397       ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
398     else
399       AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
400     fi
401   fi
402
403   # then check for a private Tk library
404   if test x"${ac_cv_c_tkconfig}" = x ; then
405     for i in \
406                 ../tk \
407                 `ls -dr ../tk[[4-9]]* 2>/dev/null` \
408                 ../../tk \
409                 `ls -dr ../../tk[[4-9]]* 2>/dev/null` \
410                 ../../../tk \
411                 `ls -dr ../../../tk[[4-9]]* 2>/dev/null` ; do
412       if test -f "$i/unix/tkConfig.sh" ; then
413         ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
414         break
415       fi
416     done
417   fi
418   # check in a few common install locations
419   if test x"${ac_cv_c_tkconfig}" = x ; then
420     for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
421       if test -f "$i/tkConfig.sh" ; then
422         ac_cv_c_tkconfig=`(cd $i; pwd)`
423         break
424       fi
425     done
426   fi
427   # check in a few other private locations
428   if test x"${ac_cv_c_tkconfig}" = x ; then
429     for i in \
430                 ${srcdir}/../tk \
431                 `ls -dr ${srcdir}/../tk[[4-9]]* 2>/dev/null` ; do
432       if test -f "$i/unix/tkConfig.sh" ; then
433         ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
434         break
435       fi
436     done
437   fi
438   ])
439   if test x"${ac_cv_c_tkconfig}" = x ; then
440     TKCONFIG="# no Tk configs found"
441     AC_MSG_WARN(Can't find Tk configuration definitions)
442   else
443     no_tk=
444     TKCONFIG=${ac_cv_c_tkconfig}/tkConfig.sh
445     AC_MSG_RESULT(found $TKCONFIG)
446   fi
447 fi
448
449 ])
450
451 # Defined as a separate macro so we don't have to cache the values
452 # from PATH_TKCONFIG (because this can also be cached).
453 AC_DEFUN(CY_AC_LOAD_TKCONFIG, [
454     if test -f "$TKCONFIG" ; then
455       . $TKCONFIG
456     fi
457
458     AC_SUBST(TK_VERSION)
459 dnl not actually used, don't export to save symbols
460 dnl    AC_SUBST(TK_MAJOR_VERSION)
461 dnl    AC_SUBST(TK_MINOR_VERSION)
462     AC_SUBST(TK_DEFS)
463
464 dnl not used, don't export to save symbols
465     dnl AC_SUBST(TK_LIB_FILE)
466
467 dnl not used outside of configure
468 dnl    AC_SUBST(TK_LIBS)
469 dnl not used, don't export to save symbols
470 dnl    AC_SUBST(TK_PREFIX)
471
472 dnl not used, don't export to save symbols
473 dnl    AC_SUBST(TK_EXEC_PREFIX)
474
475     AC_SUBST(TK_XINCLUDES)
476     AC_SUBST(TK_XLIBSW)
477     AC_SUBST(TK_BUILD_LIB_SPEC)
478     AC_SUBST(TK_LIB_SPEC)
479 ])
480