1 dnl This file is an input file used by the GNU "autoconf" program to
2 dnl generate the file "configure", which is run during Tcl installation
3 dnl to configure the system for the local environment.
5 # @(#) configure.in 1.15 95/06/27 21:53:14
9 AC_PREFIX_PROGRAM(tclsh)
14 #--------------------------------------------------------------------
15 # On SVR4 systems, force linking with the socket libs
16 #--------------------------------------------------------------------
17 AC_CHECK_LIB(socket, main, [LIBS="$LIBS -lsocket"])
18 AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])
21 #--------------------------------------------------------------------
22 # Supply substitutes for missing POSIX library procedures, or
23 # set flags so Tcl uses alternate procedures.
24 #--------------------------------------------------------------------
26 AC_REPLACE_FUNCS(getcwd opendir strerror strstr)
27 AC_REPLACE_FUNCS(strtol tmpnam waitpid)
28 AC_CHECK_FUNC(getwd, , AC_DEFINE(NO_GETWD))
29 AC_CHECK_FUNC(wait3, , AC_DEFINE(NO_WAIT3))
31 #--------------------------------------------------------------------
32 # On a few very rare systems, all of the libm.a stuff is
33 # already in libc.a. Set compiler flags accordingly.
34 # Also, Linux requires the "ieee" library for math to work
35 # right (and it must appear before "-lm").
36 #--------------------------------------------------------------------
38 AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
40 AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
42 #--------------------------------------------------------------------
43 # Supply substitutes for missing POSIX header files. Special
45 # - Sprite's dirent.h exists but is bogus.
46 # - stdlib.h doesn't define strtol, strtoul, or
47 # strtod insome versions of SunOS
48 # - some versions of string.h don't declare procedures such
50 #--------------------------------------------------------------------
52 AC_HAVE_HEADERS(unistd.h)
53 AC_MSG_CHECKING(dirent.h)
54 AC_TRY_LINK([#include <sys/types.h>
55 #include <dirent.h>], [
59 * Generate compilation error to make the test fail: Lynx headers
60 * are only valid if really in the POSIX environment.
67 struct dirent *entryPtr;
69 d = opendir("foobar");
70 entryPtr = readdir(d);
73 ], tcl_ok=yes, tcl_ok=no)
74 AC_EGREP_HEADER([Sprite version.* NOT POSIX], dirent.h, tcl_ok=no)
75 if test $tcl_ok = no; then
76 AC_DEFINE(NO_DIRENT_H)
78 AC_MSG_RESULT($tcl_ok)
79 AC_CHECK_HEADER(errno.h, , AC_DEFINE(NO_ERRNO_H))
80 AC_CHECK_HEADER(float.h, , AC_DEFINE(NO_FLOAT_H))
81 AC_CHECK_HEADER(limits.h, , AC_DEFINE(NO_LIMITS_H))
82 AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
83 AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
84 AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
85 AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
86 if test $tcl_ok = 0; then
87 AC_DEFINE(NO_STDLIB_H)
89 AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
90 AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
91 AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
92 if test $tcl_ok = 0; then
93 AC_DEFINE(NO_STRING_H)
95 AC_CHECK_HEADER(sys/time.h, , AC_DEFINE(NO_SYS_TIME_H))
96 AC_CHECK_HEADER(sys/wait.h, , AC_DEFINE(NO_SYS_WAIT_H))
98 #--------------------------------------------------------------------
99 # On some systems strstr is broken: it returns a pointer even
100 # even if the original string is empty.
101 #--------------------------------------------------------------------
103 AC_MSG_CHECKING([proper strstr implementation])
108 exit(strstr("\0test", "test") ? 1 : 0);
110 ], tcl_ok=yes, tcl_ok=no)
111 if test $tcl_ok = yes; then
114 AC_MSG_RESULT([broken, using substitute])
115 LIBOBJS="$LIBOBJS strstr.o"
118 #--------------------------------------------------------------------
119 # Check for strtoul function. This is tricky because under some
120 # versions of AIX strtoul returns an incorrect terminator
121 # pointer for the string "0".
122 #--------------------------------------------------------------------
124 AC_CHECK_FUNC(strtoul, tcl_ok=1, tcl_ok=0)
126 extern int strtoul();
132 value = strtoul(string, &term, 0);
133 if ((value != 0) || (term != (string+1))) {
138 if test $tcl_ok = 0; then
139 test -n "$verbose" && echo " Adding strtoul.o."
140 LIBOBJS="$LIBOBJS strtoul.o"
143 #--------------------------------------------------------------------
144 # Check for the strtod function. This is tricky because in some
145 # versions of Linux strtod mis-parses strings starting with "+".
146 #--------------------------------------------------------------------
148 AC_CHECK_FUNC(strtod, tcl_ok=1, tcl_ok=0)
150 extern double strtod();
153 char *string = " +69";
156 value = strtod(string, &term);
157 if ((value != 69) || (term != (string+4))) {
162 if test $tcl_ok = 0; then
163 test -n "$verbose" && echo " Adding strtod.o."
164 LIBOBJS="$LIBOBJS strtod.o"
167 #--------------------------------------------------------------------
168 # Under Solaris 2.4, strtod returns the wrong value for the
169 # terminating character under some conditions. Check for this
170 # and if the problem exists use a substitute procedure
171 # "fixstrtod" that corrects the error.
172 #--------------------------------------------------------------------
174 AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
175 if test "$tcl_strtod" = 1; then
176 AC_MSG_CHECKING([for Solaris strtod bug])
178 extern double strtod();
181 char *string = "NaN";
183 strtod(string, &term);
184 if ((term != string) && (term[-1] == 0)) {
188 }], AC_MSG_RESULT(ok), [
190 LIBOBJS="$LIBOBJS fixstrtod.o"
191 AC_DEFINE(strtod, fixstrtod)
195 #--------------------------------------------------------------------
196 # Check for various typedefs and provide substitutes if
198 #--------------------------------------------------------------------
205 #--------------------------------------------------------------------
206 # If a system doesn't have an opendir function (man, that's old!)
207 # then we have to supply a different version of dirent.h which
208 # is compatible with the substitute version of opendir that's
209 # provided. This version only works with V7-style directories.
210 #--------------------------------------------------------------------
212 AC_CHECK_FUNC(opendir, , AC_DEFINE(USE_DIRENT2_H))
214 #--------------------------------------------------------------------
215 # Check for the existence of sys_errlist (this is only needed if
216 # there's no strerror, but I don't know how to conditionalize the
218 #--------------------------------------------------------------------
220 AC_MSG_CHECKING(sys_errlist)
222 extern char *sys_errlist[];
224 sys_errlist[sys_nerr-1][0] = 0;
225 ], tcl_ok=yes, tcl_ok=no)
226 AC_MSG_RESULT($tcl_ok)
227 if test $tcl_ok = no; then
228 AC_DEFINE(NO_SYS_ERRLIST)
231 #--------------------------------------------------------------------
232 # The check below checks whether <sys/wait.h> defines the type
233 # "union wait" correctly. It's needed because of weirdness in
234 # HP-UX where "union wait" is defined in both the BSD and SYS-V
235 # environments. Checking the usability of WIFEXITED seems to do
237 #--------------------------------------------------------------------
239 AC_MSG_CHECKING([union wait])
240 AC_TRY_LINK([#include <sys/types.h>
241 #include <sys/wait.h>], [
243 WIFEXITED(x); /* Generates compiler error if WIFEXITED
245 ], tcl_ok=yes, tcl_ok=no)
246 AC_MSG_RESULT($tcl_ok)
247 if test $tcl_ok = no; then
248 AC_DEFINE(NO_UNION_WAIT)
251 #--------------------------------------------------------------------
252 # Check to see whether the system supports the matherr function
253 # and its associated type "struct exception".
254 #--------------------------------------------------------------------
256 AC_MSG_CHECKING([matherr support])
257 AC_TRY_COMPILE([#include <math.h>], [
261 ], tcl_ok=yes, tcl_ok=no)
262 AC_MSG_RESULT($tcl_ok)
263 if test $tcl_ok = yes; then
264 AC_DEFINE(NEED_MATHERR)
267 #--------------------------------------------------------------------
268 # Check to see whether the system provides a vfork kernel call.
269 # If not, then use fork instead. Also, check for a problem with
270 # Solaris 2.4 and vforks and signals that can core dumps can occur
271 # if a vforked child resets a signal handler. If the problem
272 # exists, then use fork instead of vfork.
273 #--------------------------------------------------------------------
275 AC_CHECK_FUNC(vfork, tcl_ok=1, tcl_ok=0)
276 if test "$tcl_ok" = 1; then
277 AC_MSG_CHECKING([Solaris 2.4 vfork/signal bug]);
281 #include <sys/wait.h>
291 (void) signal(SIGCHLD, sigProc);
295 } else if (pid == 0) {
296 (void) signal(SIGCHLD, SIG_DFL);
301 exit((gotSignal) ? 0 : 1);
302 }], AC_MSG_RESULT(ok), [
308 if test "$tcl_ok" = 0; then
309 AC_DEFINE(vfork, fork)
312 #--------------------------------------------------------------------
313 # Check whether there is an strncasecmp function on this system.
314 # This is a bit tricky because under SCO it's in the socket
316 #--------------------------------------------------------------------
318 AC_CHECK_FUNC(strncasecmp, ,
319 AC_CHECK_LIB(socket, strncasecmp, , [LIBOBJS="$LIBOBJS strncasecmp.o"]))
321 #--------------------------------------------------------------------
322 # The code below deals with several issues related to gettimeofday:
323 # 1. Some systems don't provide a gettimeofday function at all
324 # (set NO_GETTOD if this is the case).
325 # 2. SGI systems don't use the BSD form of the gettimeofday function,
326 # but they have a BSDgettimeofday function that can be used instead.
327 # 3. See if gettimeofday is declared in the <sys/time.h> header file.
328 # if not, set the GETTOD_NOT_DECLARED flag so that tclPort.h can
330 #--------------------------------------------------------------------
332 AC_CHECK_FUNC(BSDgettimeofday, AC_DEFINE(HAVE_BSDGETTIMEOFDAY),
333 AC_CHECK_FUNC(gettimeofday, , AC_DEFINE(NO_GETTOD)))
334 AC_MSG_CHECKING([for gettimeofday declaration])
335 AC_EGREP_HEADER(gettimeofday, sys/time.h, AC_MSG_RESULT(present), [
336 AC_MSG_RESULT(missing)
337 AC_DEFINE(GETTOD_NOT_DECLARED)