Initial revision
[catagits/fcgi2.git] / tcl / tcl7.4 / configure.in
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.
4 AC_INIT(tcl.h)
5 # @(#) configure.in 1.15 95/06/27 21:53:14
6
7 AC_PROG_INSTALL
8 AC_PROG_RANLIB
9 AC_PREFIX_PROGRAM(tclsh)
10 AC_PROG_CC
11 AC_C_CROSS
12 AC_SUBST(CC)
13
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"])
19 AC_SUBST(LIBS)
20
21 #--------------------------------------------------------------------
22 #       Supply substitutes for missing POSIX library procedures, or
23 #       set flags so Tcl uses alternate procedures.
24 #--------------------------------------------------------------------
25
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))
30
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 #--------------------------------------------------------------------
37
38 AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
39 AC_SUBST(MATH_LIBS)
40 AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
41
42 #--------------------------------------------------------------------
43 #       Supply substitutes for missing POSIX header files.  Special
44 #       notes:
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
49 #             as strstr
50 #--------------------------------------------------------------------
51
52 AC_HAVE_HEADERS(unistd.h)
53 AC_MSG_CHECKING(dirent.h)
54 AC_TRY_LINK([#include <sys/types.h>
55 #include <dirent.h>], [
56 #ifndef _POSIX_SOURCE
57 #   ifdef __Lynx__
58         /*
59          * Generate compilation error to make the test fail:  Lynx headers
60          * are only valid if really in the POSIX environment.
61          */
62
63         missing_procedure();
64 #   endif
65 #endif
66 DIR *d;
67 struct dirent *entryPtr;
68 char *p;
69 d = opendir("foobar");
70 entryPtr = readdir(d);
71 p = entryPtr->d_name;
72 closedir(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)
77 fi
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)
88 fi
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)
94 fi
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))
97
98 #--------------------------------------------------------------------
99 #       On some systems strstr is broken: it returns a pointer even
100 #       even if the original string is empty.
101 #--------------------------------------------------------------------
102
103 AC_MSG_CHECKING([proper strstr implementation])
104 AC_TRY_RUN([
105 extern int strstr();
106 int main()
107 {
108     exit(strstr("\0test", "test") ? 1 : 0);
109 }
110 ], tcl_ok=yes, tcl_ok=no)
111 if test $tcl_ok = yes; then
112     AC_MSG_RESULT(yes)
113 else
114     AC_MSG_RESULT([broken, using substitute])
115     LIBOBJS="$LIBOBJS strstr.o"
116 fi
117
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 #--------------------------------------------------------------------
123
124 AC_CHECK_FUNC(strtoul, tcl_ok=1, tcl_ok=0)
125 AC_TRY_RUN([
126 extern int strtoul();
127 int main()
128 {
129     char *string = "0";
130     char *term;
131     int value;
132     value = strtoul(string, &term, 0);
133     if ((value != 0) || (term != (string+1))) {
134         exit(1);
135     }
136     exit(0);
137 }], , tcl_ok=0)
138 if test $tcl_ok = 0; then
139     test -n "$verbose" && echo "        Adding strtoul.o."
140     LIBOBJS="$LIBOBJS strtoul.o"
141 fi
142
143 #--------------------------------------------------------------------
144 #       Check for the strtod function.  This is tricky because in some
145 #       versions of Linux strtod mis-parses strings starting with "+".
146 #--------------------------------------------------------------------
147
148 AC_CHECK_FUNC(strtod, tcl_ok=1, tcl_ok=0)
149 AC_TRY_RUN([
150 extern double strtod();
151 int main()
152 {
153     char *string = " +69";
154     char *term;
155     double value;
156     value = strtod(string, &term);
157     if ((value != 69) || (term != (string+4))) {
158         exit(1);
159     }
160     exit(0);
161 }], , tcl_ok=0)
162 if test $tcl_ok = 0; then
163     test -n "$verbose" && echo "        Adding strtod.o."
164     LIBOBJS="$LIBOBJS strtod.o"
165 fi
166
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 #--------------------------------------------------------------------
173
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])
177     AC_TRY_RUN([
178         extern double strtod();
179         int main()
180         {
181             char *string = "NaN";
182             char *term;
183             strtod(string, &term);
184             if ((term != string) && (term[-1] == 0)) {
185                 exit(1);
186             }
187             exit(0);
188         }], AC_MSG_RESULT(ok), [
189             AC_MSG_RESULT(buggy)
190             LIBOBJS="$LIBOBJS fixstrtod.o"
191             AC_DEFINE(strtod, fixstrtod)
192         ])
193 fi
194
195 #--------------------------------------------------------------------
196 #       Check for various typedefs and provide substitutes if
197 #       they don't exist.
198 #--------------------------------------------------------------------
199
200 AC_TYPE_MODE_T
201 AC_TYPE_PID_T
202 AC_TYPE_SIZE_T
203 AC_TYPE_UID_T
204
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 #--------------------------------------------------------------------
211
212 AC_CHECK_FUNC(opendir, , AC_DEFINE(USE_DIRENT2_H))
213
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
217 #       check).
218 #--------------------------------------------------------------------
219
220 AC_MSG_CHECKING(sys_errlist)
221 AC_TRY_LINK(, [
222 extern char *sys_errlist[];
223 extern int sys_nerr;
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)
229 fi
230
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
236 #       the trick.
237 #--------------------------------------------------------------------
238
239 AC_MSG_CHECKING([union wait])
240 AC_TRY_LINK([#include <sys/types.h> 
241 #include <sys/wait.h>], [
242 union wait x;
243 WIFEXITED(x);           /* Generates compiler error if WIFEXITED
244                          * uses an int. */
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)
249 fi
250
251 #--------------------------------------------------------------------
252 #       Check to see whether the system supports the matherr function
253 #       and its associated type "struct exception".
254 #--------------------------------------------------------------------
255
256 AC_MSG_CHECKING([matherr support])
257 AC_TRY_COMPILE([#include <math.h>], [
258 struct exception x;
259 x.type = DOMAIN;
260 x.type = SING;
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)
265 fi
266
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 #--------------------------------------------------------------------
274
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]);
278     AC_TRY_RUN([
279         #include <stdio.h>
280         #include <signal.h>
281         #include <sys/wait.h>
282         int gotSignal = 0;
283         sigProc(sig)
284             int sig;
285         {
286             gotSignal = 1;
287         }
288         main()
289         {
290             int pid, sts;
291             (void) signal(SIGCHLD, sigProc);
292             pid = vfork();
293             if (pid <  0) {
294                 exit(1);
295             } else if (pid == 0) {
296                 (void) signal(SIGCHLD, SIG_DFL);
297                 _exit(0);
298             } else {
299                 (void) wait(&sts);
300             }
301             exit((gotSignal) ? 0 : 1);
302         }], AC_MSG_RESULT(ok), [
303             AC_MSG_RESULT(buggy)
304             tcl_ok=0
305         ])
306 fi
307 rm -f core
308 if test "$tcl_ok" = 0; then
309     AC_DEFINE(vfork, fork)
310 fi
311
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
315 #       library.
316 #--------------------------------------------------------------------
317
318 AC_CHECK_FUNC(strncasecmp, ,
319     AC_CHECK_LIB(socket, strncasecmp, , [LIBOBJS="$LIBOBJS strncasecmp.o"]))
320
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
329 #          declare it.
330 #--------------------------------------------------------------------
331
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)
338 ])
339
340 AC_OUTPUT(Makefile)