]>
Commit | Line | Data |
---|---|---|
4e327047 TT |
1 | dnl This file is duplicated in four places: |
2 | dnl * gdb/aclocal.m4 | |
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 <[email protected]> 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, | |
13 | [AC_EGREP_CPP(yes, | |
14 | [/* | |
15 | * The old Lynx "cc" only defines "Lynx", but the newer one uses "__Lynx__" | |
16 | */ | |
17 | #if defined(__Lynx__) || defined(Lynx) | |
18 | yes | |
19 | #endif | |
20 | ], ac_cv_os_lynx=yes, ac_cv_os_lynx=no)]) | |
5436fc65 | 21 | # |
4e327047 TT |
22 | if test "$ac_cv_os_lynx" = "yes" ; then |
23 | AC_MSG_RESULT(yes) | |
24 | AC_DEFINE(LYNX) | |
25 | AC_MSG_CHECKING([whether -mposix or -X is available]) | |
26 | AC_CACHE_VAL(ac_cv_c_posix_flag, | |
27 | [AC_TRY_COMPILE(,[ | |
28 | /* | |
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). | |
32 | */ | |
33 | #if defined(__GNUC__) && __GNUC__ >= 2 | |
34 | choke me | |
35 | #endif | |
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) | |
39 | else | |
40 | AC_MSG_RESULT(no) | |
41 | fi | |
42 | ]) | |
5436fc65 | 43 | # |
4e327047 TT |
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. | |
47 | AC_DEFUN(CY_AC_C_CROSS, | |
48 | [# If we cannot run a trivial program, we must be cross compiling. | |
49 | AC_MSG_CHECKING(whether cross-compiling) | |
50 | AC_CACHE_VAL(ac_cv_c_cross,[ | |
51 | AC_TRY_RUN([ | |
52 | main(){return(0);}], | |
53 | ac_cv_c_cross=no, ac_cv_c_cross=yes, ac_cv_c_cross=yes) | |
54 | ]) | |
55 | if test x"${target}" = x"${host}" -a x"${ac_cv_c_cross}" = x"yes"; then | |
56 | dnl this hack is cause the message is so long we don't call AC_MSG_ERROR | |
57 | echo "configure: error: You need to specify --target to cross compile," 1>&2; | |
58 | echo " or the native compiler is broken" 1>&2; | |
59 | exit 1; | |
60 | else | |
61 | cross_compiling=$ac_cv_c_cross | |
62 | AC_MSG_RESULT($ac_cv_c_cross) | |
63 | fi | |
64 | ]) | |
65 | AC_DEFUN(CY_AC_PATH_TCLH, [ | |
66 | # | |
67 | # Ok, lets find the tcl source trees so we can use the headers | |
68 | # Warning: transition of version 9 to 10 will break this algorithm | |
69 | # because 10 sorts before 9. We also look for just tcl. We have to | |
70 | # be careful that we don't match stuff like tclX by accident. | |
71 | # the alternative search directory is involked by --with-tclinclude | |
72 | # | |
73 | no_tcl=true | |
74 | AC_MSG_CHECKING(for Tcl private headers) | |
75 | AC_ARG_WITH(tclinclude, [ --with-tclinclude directory where tcl private headers are], with_tclinclude=${withval}) | |
76 | AC_CACHE_VAL(ac_cv_c_tclh,[ | |
77 | # first check to see if --with-tclinclude was specified | |
78 | if test x"${with_tclinclude}" != x ; then | |
79 | if test -f ${with_tclinclude}/tclInt.h ; then | |
80 | ac_cv_c_tclh=`(cd ${with_tclinclude}; pwd)` | |
5436fc65 | 81 | else |
4e327047 | 82 | AC_MSG_ERROR([${with_tclinclude} directory doesn't contain private headers]) |
5436fc65 | 83 | fi |
4e327047 TT |
84 | fi |
85 | # next check in private source directory | |
86 | # | |
87 | # since ls returns lowest version numbers first, reverse its output | |
88 | if test x"${ac_cv_c_tclh}" = x ; then | |
89 | for i in \ | |
90 | ${srcdir}/../tcl \ | |
91 | `ls -dr ${srcdir}/../tcl[[0-9]]* 2>/dev/null` \ | |
92 | ${srcdir}/../../tcl \ | |
93 | `ls -dr ${srcdir}/../../tcl[[0-9]]* 2>/dev/null` \ | |
94 | ${srcdir}/../../../tcl \ | |
95 | `ls -dr ${srcdir}/../../../tcl[[0-9]]* 2>/dev/null ` ; do | |
96 | if test -f $i/tclInt.h ; then | |
97 | ac_cv_c_tclh=`(cd $i; pwd)` | |
98 | break | |
99 | fi | |
100 | # Tcl 7.5 and greater puts headers in subdirectory. | |
101 | if test -f $i/generic/tclInt.h ; then | |
102 | ac_cv_c_tclh=`(cd $i; pwd)`/generic | |
103 | fi | |
104 | done | |
105 | fi | |
106 | # finally check in a few common install locations | |
107 | # | |
108 | # since ls returns lowest version numbers first, reverse its output | |
109 | if test x"${ac_cv_c_tclh}" = x ; then | |
110 | for i in \ | |
111 | `ls -dr /usr/local/src/tcl[[0-9]]* 2>/dev/null` \ | |
112 | `ls -dr /usr/local/lib/tcl[[0-9]]* 2>/dev/null` \ | |
113 | /usr/local/src/tcl \ | |
114 | /usr/local/lib/tcl \ | |
115 | ${prefix}/include ; do | |
116 | if test -f $i/tclInt.h ; then | |
117 | ac_cv_c_tclh=`(cd $i; pwd)` | |
118 | break | |
119 | fi | |
120 | done | |
121 | fi | |
122 | # see if one is installed | |
123 | if test x"${ac_cv_c_tclh}" = x ; then | |
124 | AC_HEADER_CHECK(tclInt.h, ac_cv_c_tclh=installed, ac_cv_c_tclh="") | |
125 | fi | |
126 | ]) | |
127 | if test x"${ac_cv_c_tclh}" = x ; then | |
128 | TCLHDIR="# no Tcl private headers found" | |
129 | AC_MSG_ERROR([Can't find Tcl private headers]) | |
130 | fi | |
131 | if test x"${ac_cv_c_tclh}" != x ; then | |
132 | no_tcl="" | |
133 | if test x"${ac_cv_c_tkh}" = x"installed" ; then | |
134 | AC_MSG_RESULT([is installed]) | |
135 | TCLHDIR="" | |
136 | else | |
137 | AC_MSG_RESULT([found in ${ac_cv_c_tclh}]) | |
138 | # this hack is cause the TCLHDIR won't print if there is a "-I" in it. | |
139 | TCLHDIR="-I${ac_cv_c_tclh}" | |
5436fc65 C |
140 | fi |
141 | fi | |
4e327047 TT |
142 | |
143 | AC_MSG_CHECKING([Tcl version]) | |
144 | rm -rf tclmajor tclminor | |
145 | orig_includes="$CPPFLAGS" | |
146 | ||
147 | if test x"${TCLHDIR}" != x ; then | |
148 | CPPFLAGS="$CPPFLAGS $TCLHDIR" | |
5436fc65 C |
149 | fi |
150 | ||
4e327047 TT |
151 | AC_TRY_RUN([ |
152 | #include <stdio.h> | |
153 | #include "tcl.h" | |
154 | main() { | |
155 | FILE *maj = fopen("tclmajor","w"); | |
156 | FILE *min = fopen("tclminor","w"); | |
157 | fprintf(maj,"%d",TCL_MAJOR_VERSION); | |
158 | fprintf(min,"%d",TCL_MINOR_VERSION); | |
159 | fclose(maj); | |
160 | fclose(min); | |
161 | return 0; | |
162 | }], | |
163 | tclmajor=`cat tclmajor` | |
164 | tclminor=`cat tclminor` | |
165 | tclversion=$tclmajor.$tclminor | |
166 | AC_MSG_RESULT($tclversion) | |
167 | rm -f tclmajor tclminor | |
168 | , | |
169 | AC_MSG_RESULT([can't happen]) | |
170 | , | |
171 | AC_MSG_ERROR([can't be cross compiled]) | |
172 | ) | |
173 | CPPFLAGS="${orig_includes}" | |
174 | ||
175 | AC_PROVIDE([$0]) | |
176 | AC_SUBST(TCLHDIR) | |
177 | ]) | |
178 | AC_DEFUN(CY_AC_PATH_TCLLIB, [ | |
5436fc65 | 179 | # |
4e327047 | 180 | # Ok, lets find the tcl library |
5436fc65 | 181 | # First, look for one uninstalled. |
4e327047 | 182 | # the alternative search directory is invoked by --with-tcllib |
5436fc65 | 183 | # |
4e327047 TT |
184 | |
185 | if test $tclmajor -ge 7 -a $tclminor -ge 4 ; then | |
186 | installedtcllibroot=tcl$tclversion | |
187 | else | |
188 | installedtcllibroot=tcl | |
189 | fi | |
190 | ||
191 | if test x"${no_tcl}" = x ; then | |
192 | # we reset no_tcl incase something fails here | |
193 | no_tcl=true | |
194 | AC_ARG_WITH(tcllib, [ --with-tcllib directory where the tcl library is], | |
195 | with_tcllib=${withval}) | |
196 | AC_MSG_CHECKING([for Tcl library]) | |
197 | AC_CACHE_VAL(ac_cv_c_tcllib,[ | |
198 | # First check to see if --with-tcllib was specified. | |
199 | # This requires checking for both the installed and uninstalled name-styles | |
200 | # since we have no idea if it's installed or not. | |
201 | if test x"${with_tcllib}" != x ; then | |
202 | if test -f "${with_tcllib}/lib$installedtcllibroot.so" ; then | |
203 | ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/lib$installedtcllibroot.so | |
204 | elif test -f "${with_tcllib}/libtcl.so" ; then | |
205 | ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/libtcl.so | |
206 | # then look for a freshly built statically linked library | |
207 | # if Makefile exists we assume its configured and libtcl will be built first. | |
208 | elif test -f "${with_tcllib}/lib$installedtcllibroot.a" ; then | |
209 | ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/lib$installedtcllibroot.a | |
210 | elif test -f "${with_tcllib}/libtcl.a" ; then | |
211 | ac_cv_c_tcllib=`(cd ${with_tcllib}; pwd)`/libtcl.a | |
212 | else | |
213 | AC_MSG_ERROR([${with_tcllib} directory doesn't contain libraries]) | |
214 | fi | |
5436fc65 | 215 | fi |
4e327047 TT |
216 | # then check for a private Tcl library |
217 | # Since these are uninstalled, use the simple lib name root. | |
218 | if test x"${ac_cv_c_tcllib}" = x ; then | |
219 | for i in \ | |
220 | ../tcl \ | |
221 | `ls -dr ../tcl[[0-9]]* 2>/dev/null` \ | |
222 | ../../tcl \ | |
223 | `ls -dr ../../tcl[[0-9]]* 2>/dev/null` \ | |
224 | ../../../tcl \ | |
225 | `ls -dr ../../../tcl[[0-9]]* 2>/dev/null` ; do | |
226 | # Tcl 7.5 and greater puts library in subdir. Look there first. | |
227 | if test -f "$i/unix/libtcl.so" ; then | |
228 | ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.so | |
229 | break | |
230 | elif test -f "$i/unix/libtcl.a" -o -f "$i/unix/Makefile"; then | |
231 | ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.a | |
232 | break | |
233 | # look for a freshly built dynamically linked library | |
234 | elif test -f "$i/libtcl.so" ; then | |
235 | ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.so | |
236 | break | |
237 | ||
238 | # then look for a freshly built statically linked library | |
239 | # if Makefile exists we assume its configured and libtcl will be | |
240 | # built first. | |
241 | elif test -f "$i/libtcl.a" -o -f "$i/Makefile" ; then | |
242 | ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.a | |
243 | break | |
244 | fi | |
245 | done | |
5436fc65 | 246 | fi |
4e327047 TT |
247 | # check in a few common install locations |
248 | if test x"${ac_cv_c_tcllib}" = x ; then | |
249 | for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do | |
250 | # first look for a freshly built dynamically linked library | |
251 | if test -f "$i/lib$installedtcllibroot.so" ; then | |
252 | ac_cv_c_tcllib=`(cd $i; pwd)`/lib$installedtcllibroot.so | |
253 | break | |
254 | # then look for a freshly built statically linked library | |
255 | # if Makefile exists we assume its configured and libtcl will be built first. | |
256 | elif test -f "$i/lib$installedtcllibroot.a" -o -f "$i/Makefile" ; then | |
257 | ac_cv_c_tcllib=`(cd $i; pwd)`/lib$installedtcllibroot.a | |
258 | break | |
259 | fi | |
260 | done | |
5436fc65 | 261 | fi |
4e327047 TT |
262 | # check in a few other private locations |
263 | if test x"${ac_cv_c_tcllib}" = x ; then | |
264 | for i in \ | |
265 | ${srcdir}/../tcl \ | |
266 | `ls -dr ${srcdir}/../tcl[[0-9]]* 2>/dev/null` ; do | |
267 | # Tcl 7.5 and greater puts library in subdir. Look there first. | |
268 | if test -f "$i/unix/libtcl.so" ; then | |
269 | ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.so | |
270 | break | |
271 | elif test -f "$i/unix/libtcl.a" -o -f "$i/unix/Makefile"; then | |
272 | ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtcl.a | |
273 | break | |
274 | # look for a freshly built dynamically linked library | |
275 | elif test -f "$i/libtcl.so" ; then | |
276 | ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.so | |
277 | break | |
5436fc65 | 278 | |
4e327047 TT |
279 | # then look for a freshly built statically linked library |
280 | # if Makefile exists we assume its configured and libtcl will be | |
281 | # built first. | |
282 | elif test -f "$i/libtcl.a" -o -f "$i/Makefile" ; then | |
283 | ac_cv_c_tcllib=`(cd $i; pwd)`/libtcl.a | |
284 | break | |
285 | fi | |
286 | done | |
5436fc65 | 287 | fi |
5436fc65 | 288 | |
4e327047 TT |
289 | # see if one is conveniently installed with the compiler |
290 | if test x"${ac_cv_c_tcllib}" = x ; then | |
291 | orig_libs="$LIBS" | |
292 | LIBS="$LIBS -l$installedtcllibroot -lm" | |
293 | AC_TRY_RUN([ | |
294 | Tcl_AppInit() | |
295 | { exit(0); }], ac_cv_c_tcllib="-l$installedtcllibroot", ac_cv_c_tcllib="" | |
296 | , ac_cv_c_tclib="-l$installedtcllibroot") | |
297 | LIBS="${orig_libs}" | |
298 | fi | |
299 | ]) | |
300 | if test x"${ac_cv_c_tcllib}" = x ; then | |
301 | TCLLIB="# no Tcl library found" | |
302 | AC_MSG_WARN(Can't find Tcl library) | |
303 | else | |
304 | TCLLIB=${ac_cv_c_tcllib} | |
305 | AC_MSG_RESULT(found $TCLLIB) | |
306 | no_tcl= | |
307 | fi | |
5436fc65 C |
308 | fi |
309 | ||
4e327047 TT |
310 | AC_PROVIDE([$0]) |
311 | AC_SUBST(TCLLIB) | |
5436fc65 | 312 | ]) |
4e327047 | 313 | AC_DEFUN(CY_AC_PATH_TKH, [ |
5436fc65 | 314 | # |
4e327047 TT |
315 | # Ok, lets find the tk source trees so we can use the headers |
316 | # If the directory (presumably symlink) named "tk" exists, use that one | |
317 | # in preference to any others. Same logic is used when choosing library | |
318 | # and again with Tcl. The search order is the best place to look first, then in | |
319 | # decreasing significance. The loop breaks if the trigger file is found. | |
320 | # Note the gross little conversion here of srcdir by cd'ing to the found | |
321 | # directory. This converts the path from a relative to an absolute, so | |
322 | # recursive cache variables for the path will work right. We check all | |
323 | # the possible paths in one loop rather than many seperate loops to speed | |
324 | # things up. | |
325 | # the alternative search directory is invoked by --with-tkinclude | |
5436fc65 | 326 | # |
4e327047 TT |
327 | AC_MSG_CHECKING(for Tk private headers) |
328 | AC_ARG_WITH(tkinclude, [ --with-tkinclude directory where the tk private headers are], | |
329 | with_tkinclude=${withval}) | |
330 | no_tk=true | |
331 | AC_CACHE_VAL(ac_cv_c_tkh,[ | |
332 | # first check to see if --with-tkinclude was specified | |
333 | if test x"${with_tkinclude}" != x ; then | |
334 | if test -f ${with_tkinclude}/tk.h ; then | |
335 | ac_cv_c_tkh=`(cd ${with_tkinclude}; pwd)` | |
5436fc65 | 336 | else |
4e327047 | 337 | AC_MSG_ERROR([${with_tkinclude} directory doesn't contain private headers]) |
5436fc65 | 338 | fi |
4e327047 TT |
339 | fi |
340 | # next check in private source directory | |
341 | # | |
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 | |
345 | for i in \ | |
346 | ${srcdir}/../tk \ | |
347 | `ls -dr ${srcdir}/../tk[[0-9]]* 2>/dev/null` \ | |
348 | ${srcdir}/../../tk \ | |
349 | `ls -dr ${srcdir}/../../tk[[0-9]]* 2>/dev/null` \ | |
350 | ${srcdir}/../../../tk \ | |
351 | `ls -dr ${srcdir}/../../../tk[[0-9]]* 2>/dev/null ` ; do | |
352 | if test -f $i/tk.h ; then | |
353 | ac_cv_c_tkh=`(cd $i; pwd)` | |
354 | break | |
355 | fi | |
356 | # Tk 4.1 and greater puts this in a subdir. | |
357 | if test -f $i/generic/tk.h; then | |
358 | ac_cv_c_tkh=`(cd $i; pwd)`/generic | |
359 | fi | |
360 | done | |
361 | fi | |
362 | # finally check in a few common install locations | |
363 | # | |
364 | # since ls returns lowest version numbers first, reverse the entire list | |
365 | # and search for the worst fit, overwriting it with better fits as we find them | |
366 | if test x"${ac_cv_c_tkh}" = x ; then | |
367 | for i in \ | |
368 | `ls -dr /usr/local/src/tk[[0-9]]* 2>/dev/null` \ | |
369 | `ls -dr /usr/local/lib/tk[[0-9]]* 2>/dev/null` \ | |
370 | /usr/local/src/tk \ | |
371 | /usr/local/lib/tk \ | |
372 | ${prefix}/include ; do | |
373 | if test -f $i/tk.h ; then | |
374 | ac_cv_c_tkh=`(cd $i; pwd)` | |
375 | break | |
376 | fi | |
377 | done | |
378 | fi | |
379 | # see if one is installed | |
380 | if test x"${ac_cv_c_tkh}" = x ; then | |
381 | AC_HEADER_CHECK(tk.h, ac_cv_c_tkh=installed) | |
382 | fi | |
383 | ]) | |
384 | if test x"${ac_cv_c_tkh}" != x ; then | |
385 | no_tk="" | |
386 | if test x"${ac_cv_c_tkh}" = x"installed" ; then | |
387 | AC_MSG_RESULT([is installed]) | |
388 | TKHDIR="" | |
389 | else | |
390 | AC_MSG_RESULT([found in $ac_cv_c_tkh]) | |
391 | # this hack is cause the TKHDIR won't print if there is a "-I" in it. | |
392 | TKHDIR="-I${ac_cv_c_tkh}" | |
5436fc65 C |
393 | fi |
394 | else | |
4e327047 TT |
395 | TKHDIR="# no Tk directory found" |
396 | AC_MSG_WARN([Can't find Tk private headers]) | |
397 | no_tk=true | |
5436fc65 C |
398 | fi |
399 | ||
4e327047 TT |
400 | # if Tk is installed, extract the major/minor version |
401 | if test x"${no_tk}" = x ; then | |
402 | AC_MSG_CHECKING([Tk version]) | |
403 | rm -rf tkmajor tkminor | |
404 | orig_includes="$CPPFLAGS" | |
405 | ||
406 | if test x"${TCLHDIR}" != x ; then | |
407 | CPPFLAGS="$CPPFLAGS $TCLHDIR" | |
408 | fi | |
409 | if test x"${TKHDIR}" != x ; then | |
410 | CPPFLAGS="$CPPFLAGS $TKHDIR" | |
411 | fi | |
412 | if test x"${x_includes}" != x -a x"${x_includes}" != xNONE ; then | |
413 | CPPFLAGS="$CPPFLAGS -I$x_includes" | |
414 | fi | |
415 | ||
416 | AC_TRY_RUN([ | |
417 | #include <stdio.h> | |
418 | #include "tk.h" | |
419 | main() { | |
420 | FILE *maj = fopen("tkmajor","w"); | |
421 | FILE *min = fopen("tkminor","w"); | |
422 | fprintf(maj,"%d",TK_MAJOR_VERSION); | |
423 | fprintf(min,"%d",TK_MINOR_VERSION); | |
424 | fclose(maj); | |
425 | fclose(min); | |
426 | return 0; | |
427 | }], | |
428 | tkmajor=`cat tkmajor` | |
429 | tkminor=`cat tkminor` | |
430 | tkversion=$tkmajor.$tkminor | |
431 | AC_MSG_RESULT($tkversion) | |
432 | rm -f tkmajor tkminor | |
433 | , | |
434 | AC_MSG_ERROR([ | |
435 | cannot compile a simple X program - suspect your xmkmf is | |
436 | misconfigured and is incorrectly reporting the location of your X | |
437 | include or libraries - report this to your system admin]) , | |
438 | AC_MSG_ERROR([can't be cross compiled]) | |
439 | ) | |
440 | CPPFLAGS="${orig_includes}" | |
441 | fi | |
442 | ||
443 | AC_PROVIDE([$0]) | |
444 | AC_SUBST(TKHDIR) | |
445 | ]) | |
446 | AC_DEFUN(CY_AC_PATH_TKLIB, [ | |
447 | AC_REQUIRE([CY_AC_PATH_TCL]) | |
5436fc65 | 448 | # |
4e327047 TT |
449 | # Ok, lets find the tk library |
450 | # First, look for the latest private (uninstalled) copy | |
451 | # Notice that the destinations in backwards priority since the tests have | |
452 | # no break. | |
453 | # Then we look for either .a, .so, or Makefile. A Makefile is acceptable | |
454 | # is it indicates the target has been configured and will (probably) | |
455 | # soon be built. This allows an entire tree of Tcl software to be | |
456 | # configured at once and then built. | |
457 | # the alternative search directory is invoked by --with-tklib | |
5436fc65 | 458 | # |
4e327047 TT |
459 | |
460 | if test x"${no_tk}" = x ; then | |
461 | # reset no_tk incase something fails here | |
462 | no_tk="true" | |
463 | ||
464 | if test $tkmajor -ge 4 ; then | |
465 | installedtklibroot=tk$tkversion | |
466 | else | |
467 | installedtkllibroot=tk | |
5436fc65 | 468 | fi |
4e327047 TT |
469 | |
470 | AC_ARG_WITH(tklib, [ --with-tklib directory where the tk library is], | |
471 | with_tklib=${withval}) | |
472 | AC_MSG_CHECKING([for Tk library]) | |
473 | AC_CACHE_VAL(ac_cv_c_tklib,[ | |
474 | # first check to see if --with-tklib was specified | |
475 | # This requires checking for both the installed and uninstalled name-styles | |
476 | # since we have no idea if it's installed or not. | |
477 | if test x"${with_tklib}" != x ; then | |
478 | if test -f "${with_tklib}/lib$installedtklibroot.so" ; then | |
479 | ac_cv_c_tklib=`(cd ${with_tklib}; pwd)`/lib$installedtklibroot.so | |
480 | no_tk="" | |
481 | elif test -f "${with_tklib}/libtk.so" ; then | |
482 | ac_cv_c_tklib=`(cd ${with_tklib}; pwd)`/libtk.so | |
483 | no_tk="" | |
484 | # then look for a freshly built statically linked library | |
485 | # if Makefile exists we assume its configured and libtk will be built | |
486 | elif test -f "${with_tklib}/lib$installedtklibroot.a" ; then | |
487 | ac_cv_c_tklib=`(cd ${with_tklib}; pwd)`/lib$installedtklibroot.a | |
488 | no_tk="" | |
489 | elif test -f "${with_tklib}/libtk.a" ; then | |
490 | ac_cv_c_tklib=`(cd ${with_tklib}; pwd)`/libtk.a | |
491 | no_tk="" | |
492 | else | |
493 | AC_MSG_ERROR([${with_tklib} directory doesn't contain libraries]) | |
494 | fi | |
5436fc65 | 495 | fi |
4e327047 TT |
496 | # then check for a private Tk library |
497 | # Since these are uninstalled, use the simple lib name root. | |
498 | if test x"${ac_cv_c_tklib}" = x ; then | |
499 | for i in \ | |
500 | ../tk \ | |
501 | `ls -dr ../tk[[0-9]]* 2>/dev/null` \ | |
502 | ../../tk \ | |
503 | `ls -dr ../../tk[[0-9]]* 2>/dev/null` \ | |
504 | ../../../tk \ | |
505 | `ls -dr ../../../tk[[0-9]]* 2>/dev/null` ; do | |
506 | # Tk 4.1 and greater puts things in subdirs. Check these first. | |
507 | if test -f "$i/unix/libtk.so" ; then | |
508 | ac_cv_c_tklib=`(cd $i; pwd)`/unix/libtk.so | |
509 | no_tk= | |
510 | break | |
511 | elif test -f "$i/unix/libtk.a" -o -f "$i/unix/Makefile"; then | |
512 | ac_cv_c_tklib=`(cd $i; pwd)`/unix/libtk.a | |
513 | no_tk= | |
514 | break | |
515 | # look for a freshly built dynamically linked library | |
516 | elif test -f "$i/libtk.so" ; then | |
517 | ac_cv_c_tklib=`(cd $i; pwd)`/libtk.so | |
518 | no_tk= | |
519 | break | |
520 | # then look for a freshly built statically linked library | |
521 | # if Makefile exists we assume its configured and libtk will be built | |
522 | elif test -f "$i/libtk.a" -o -f "$i/Makefile" ; then | |
523 | ac_cv_c_tklib=`(cd $i; pwd)`/libtk.a | |
524 | no_tk="" | |
525 | break | |
526 | fi | |
527 | done | |
528 | fi | |
529 | # finally check in a few common install locations | |
530 | if test x"${ac_cv_c_tklib}" = x ; then | |
531 | for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do | |
532 | # first look for a freshly built dynamically linked library | |
533 | if test -f "$i/lib$installedtklibroot.so" ; then | |
534 | ac_cv_c_tklib=`(cd $i; pwd)`/lib$installedtklibroot.so | |
535 | no_tk="" | |
536 | break | |
537 | # then look for a freshly built statically linked library | |
538 | # if Makefile exists, we assume it's configured and libtcl will be built | |
539 | elif test -f "$i/lib$installedtklibroot.a" -o -f "$i/Makefile" ; then | |
540 | ac_cv_c_tklib=`(cd $i; pwd)`/lib$installedtklibroot.a | |
541 | no_tk="" | |
542 | break | |
543 | fi | |
544 | done | |
545 | fi | |
546 | # check in a few other private locations | |
547 | if test x"${ac_cv_c_tklib}" = x ; then | |
548 | for i in \ | |
549 | ${srcdir}/../tk \ | |
550 | `ls -dr ${srcdir}/../tk[[0-9]]* 2>/dev/null` ; do | |
551 | # Tk 4.1 and greater puts things in subdirs. Check these first. | |
552 | if test -f "$i/unix/libtk.so" ; then | |
553 | ac_cv_c_tklib=`(cd $i; pwd)`/unix/libtk.so | |
554 | no_tk= | |
555 | break | |
556 | elif test -f "$i/unix/libtk.a" -o -f "$i/unix/Makefile"; then | |
557 | ac_cv_c_tcllib=`(cd $i; pwd)`/unix/libtk.a | |
558 | no_tk= | |
559 | break | |
560 | # look for a freshly built dynamically linked library | |
561 | elif test -f "$i/libtk.so" ; then | |
562 | ac_cv_c_tklib=`(cd $i; pwd)`/libtk.so | |
563 | no_tk="" | |
564 | break | |
565 | # then look for a freshly built statically linked library | |
566 | # if Makefile exists, we assume it's configured and libtcl will be built | |
567 | elif test -f "$i/libtk.a" -o -f "$i/Makefile" ; then | |
568 | ac_cv_c_tklib=`(cd $i; pwd)`/libtk.a | |
569 | no_tk="" | |
570 | break | |
571 | fi | |
572 | done | |
573 | fi | |
574 | # see if one is conveniently installed with the compiler | |
575 | if test x"${ac_cv_c_tklib}" = x ; then | |
576 | AC_REQUIRE([AC_PATH_X]) | |
577 | orig_libs="$LIBS" | |
578 | LIBS="$LIBS -l$installedtklibroot $x_libraries $ac_cv_c_tcllib -lm" | |
579 | AC_TRY_RUN([ | |
580 | Tcl_AppInit() | |
581 | { exit(0); }], ac_cv_c_tklib="-l$installedtklibroot", ac_cv_c_tklib="" | |
582 | , ac_cv_c_tklib="-l$installedtklibroot") | |
583 | LIBS="${orig_libs}" | |
584 | fi | |
585 | ]) | |
586 | if test x"${ac_cv_c_tklib}" = x ; then | |
587 | TKLIB="# no Tk library found" | |
588 | AC_MSG_WARN(Can't find Tk library) | |
589 | else | |
590 | TKLIB=$ac_cv_c_tklib | |
591 | AC_MSG_RESULT(found $TKLIB) | |
592 | no_tk= | |
5436fc65 | 593 | fi |
5436fc65 | 594 | fi |
4e327047 TT |
595 | AC_PROVIDE([$0]) |
596 | AC_SUBST(TKLIB) | |
597 | ]) | |
598 | AC_DEFUN(CY_AC_PATH_TK, [ | |
599 | CY_AC_PATH_TKH | |
600 | CY_AC_PATH_TKLIB | |
601 | ]) | |
602 | AC_DEFUN(CY_AC_PATH_TCL, [ | |
603 | CY_AC_PATH_TCLH | |
604 | CY_AC_PATH_TCLLIB | |
605 | ]) |