2 dnl This file is an input file used by the GNU "autoconf" program to
3 dnl generate the file "configure", which is run during Tcl installation
4 dnl to configure the system for the local environment.
6 # CYGNUS LOCAL, need 2.5 or higher for --bindir et al
10 AC_INIT(../generic/tcl.h)
17 VERSION=${TCL_VERSION}
19 #------------------------------------------------------------------------
20 # Handle the --prefix=... option
21 #------------------------------------------------------------------------
23 if test "${prefix}" = "NONE"; then
26 if test "${exec_prefix}" = "NONE"; then
29 TCL_SRC_DIR=`cd $srcdir/..; pwd`
31 #------------------------------------------------------------------------
32 # Standard compiler checks
33 #------------------------------------------------------------------------
38 AC_HAVE_HEADERS(unistd.h limits.h)
43 # We need this for substitutions in Makefile.in.
47 #--------------------------------------------------------------------
49 # This is for LynxOS, which needs a flag to force true POSIX when
50 # building. It's weirder than that, cause the flag varies depending
51 # how old the compiler is. So...
52 # -X is for the old "cc" and "gcc" (based on 1.42)
53 # -mposix is for the new gcc (at least 2.5.8)
54 # This modifies the value of $CC to have the POSIX flag added
55 # so everything will configure correctly.
56 #--------------------------------------------------------------------
59 #------------------------------------------------------------------------
61 #------------------------------------------------------------------------
65 #------------------------------------------------------------------------
66 # If we're using GCC, see if the compiler understands -pipe. If so, use it.
67 # It makes compiling go faster. (This is only a performance feature.)
68 #------------------------------------------------------------------------
70 if test -z "$no_pipe"; then
71 if test -n "$GCC"; then
72 AC_MSG_CHECKING([if the compiler understands -pipe])
82 #--------------------------------------------------------------------
83 # Supply substitutes for missing POSIX library procedures, or
84 # set flags so Tcl uses alternate procedures.
85 #--------------------------------------------------------------------
87 # Check if Posix compliant getcwd exists, if not we'll use getwd.
88 AC_CHECK_FUNCS(getcwd, , AC_DEFINE(USEGETWD))
89 # Nb: if getcwd uses popen and pwd(1) (like SunOS 4) we should really
90 # define USEGETWD even if the posix getcwd exists. Add a test ?
92 AC_REPLACE_FUNCS(opendir strstr)
94 AC_REPLACE_FUNCS(strtol tmpnam waitpid)
95 AC_CHECK_FUNC(strerror, , AC_DEFINE(NO_STRERROR))
96 AC_CHECK_FUNC(getwd, , AC_DEFINE(NO_GETWD))
97 AC_CHECK_FUNC(wait3, , AC_DEFINE(NO_WAIT3))
98 AC_CHECK_FUNC(uname, , AC_DEFINE(NO_UNAME))
99 AC_CHECK_FUNC(realpath, , AC_DEFINE(NO_REALPATH))
101 #--------------------------------------------------------------------
102 # Supply substitutes for missing POSIX header files. Special
104 # - stdlib.h doesn't define strtol, strtoul, or
105 # strtod insome versions of SunOS
106 # - some versions of string.h don't declare procedures such
108 #--------------------------------------------------------------------
110 SC_MISSING_POSIX_HEADERS
112 #---------------------------------------------------------------------------
113 # Determine which interface to use to talk to the serial port.
114 # Note that #include lines must begin in leftmost column for
115 # some compilers to recognize them as preprocessor directives.
116 #---------------------------------------------------------------------------
120 #--------------------------------------------------------------------
121 # Include sys/select.h if it exists and if it supplies things
122 # that appear to be useful and aren't already in sys/types.h.
123 # This appears to be true only on the RS/6000 under AIX. Some
124 # systems like OSF/1 have a sys/select.h that's of no use, and
125 # other systems like SCO UNIX have a sys/select.h that's
126 # pernicious. If "fd_set" isn't defined anywhere then set a
128 #--------------------------------------------------------------------
130 AC_MSG_CHECKING([fd_set and sys/select])
131 AC_TRY_COMPILE([#include <sys/types.h>],
132 [fd_set readMask, writeMask;], tk_ok=yes, tk_ok=no)
133 if test $tk_ok = no; then
134 AC_HEADER_EGREP(fd_mask, sys/select.h, tk_ok=yes)
135 if test $tk_ok = yes; then
136 AC_DEFINE(HAVE_SYS_SELECT_H)
139 AC_MSG_RESULT($tk_ok)
140 if test $tk_ok = no; then
144 #------------------------------------------------------------------------------
145 # Find out all about time handling differences.
146 #------------------------------------------------------------------------------
150 #--------------------------------------------------------------------
151 # Some systems (e.g., IRIX 4.0.5) lack the st_blksize field
152 # in struct stat. But we might be able to use fstatfs instead.
153 #--------------------------------------------------------------------
155 AC_CHECK_FUNC(fstatfs, , AC_DEFINE(NO_FSTATFS))
157 #--------------------------------------------------------------------
158 # Some system have no memcmp or it does not work with 8 bit
159 # data, this checks it and add memcmp.o to LIBOBJS if needed
160 #--------------------------------------------------------------------
163 #--------------------------------------------------------------------
164 # Some system like SunOS 4 and other BSD like systems
165 # have no memmove (we assume they have bcopy instead).
166 # {The replacement define is in compat/string.h}
167 #--------------------------------------------------------------------
168 AC_CHECK_FUNC(memmove, , AC_DEFINE(NO_MEMMOVE) AC_DEFINE(NO_STRING_H))
170 #--------------------------------------------------------------------
171 # On some systems strstr is broken: it returns a pointer even
172 # even if the original string is empty.
173 #--------------------------------------------------------------------
175 AC_MSG_CHECKING([proper strstr implementation])
180 exit(strstr("\0test", "test") ? 1 : 0);
182 ], tcl_ok=yes, tcl_ok=no, tcl_ok=no)
183 if test $tcl_ok = yes; then
186 AC_MSG_RESULT([broken, using substitute])
187 LIBOBJS="$LIBOBJS strstr.o"
190 #--------------------------------------------------------------------
191 # Check for strtoul function. This is tricky because under some
192 # versions of AIX strtoul returns an incorrect terminator
193 # pointer for the string "0".
194 #--------------------------------------------------------------------
196 AC_CHECK_FUNC(strtoul, tcl_ok=1, tcl_ok=0)
198 extern int strtoul();
204 value = strtoul(string, &term, 0);
205 if ((value != 0) || (term != (string+1))) {
209 }], , tcl_ok=0, tcl_ok=0)
210 if test "$tcl_ok" = 0; then
211 test -n "$verbose" && echo " Adding strtoul.o."
212 LIBOBJS="$LIBOBJS strtoul.o"
215 #--------------------------------------------------------------------
216 # Check for the strtod function. This is tricky because in some
217 # versions of Linux strtod mis-parses strings starting with "+".
218 #--------------------------------------------------------------------
220 AC_CHECK_FUNC(strtod, tcl_ok=1, tcl_ok=0)
222 extern double strtod();
225 char *string = " +69";
228 value = strtod(string, &term);
229 if ((value != 69) || (term != (string+4))) {
233 }], , tcl_ok=0, tcl_ok=0)
234 if test "$tcl_ok" = 0; then
235 test -n "$verbose" && echo " Adding strtod.o."
236 LIBOBJS="$LIBOBJS strtod.o"
239 #--------------------------------------------------------------------
240 # Under Solaris 2.4, strtod returns the wrong value for the
241 # terminating character under some conditions. Check for this
242 # and if the problem exists use a substitute procedure
243 # "fixstrtod" that corrects the error.
244 #--------------------------------------------------------------------
248 #--------------------------------------------------------------------
249 # Check for various typedefs and provide substitutes if
251 #--------------------------------------------------------------------
258 #--------------------------------------------------------------------
259 # If a system doesn't have an opendir function (man, that's old!)
260 # then we have to supply a different version of dirent.h which
261 # is compatible with the substitute version of opendir that's
262 # provided. This version only works with V7-style directories.
263 #--------------------------------------------------------------------
265 AC_CHECK_FUNC(opendir, , AC_DEFINE(USE_DIRENT2_H))
267 #--------------------------------------------------------------------
268 # The check below checks whether <sys/wait.h> defines the type
269 # "union wait" correctly. It's needed because of weirdness in
270 # HP-UX where "union wait" is defined in both the BSD and SYS-V
271 # environments. Checking the usability of WIFEXITED seems to do
273 #--------------------------------------------------------------------
275 AC_MSG_CHECKING([union wait])
276 AC_TRY_LINK([#include <sys/types.h>
277 #include <sys/wait.h>], [
279 WIFEXITED(x); /* Generates compiler error if WIFEXITED
281 ], tcl_ok=yes, tcl_ok=no)
282 AC_MSG_RESULT($tcl_ok)
283 if test $tcl_ok = no; then
284 AC_DEFINE(NO_UNION_WAIT)
287 #--------------------------------------------------------------------
288 # Check to see whether the system supports the matherr function
289 # and its associated type "struct exception".
290 #--------------------------------------------------------------------
292 AC_MSG_CHECKING([matherr support])
293 AC_TRY_COMPILE([#include <math.h>], [
297 ], tcl_ok=yes, tcl_ok=no)
298 AC_MSG_RESULT($tcl_ok)
299 if test $tcl_ok = yes; then
300 AC_DEFINE(NEED_MATHERR)
303 #--------------------------------------------------------------------
304 # Check to see whether the system provides a vfork kernel call.
305 # If not, then use fork instead. Also, check for a problem with
306 # vforks and signals that can cause core dumps if a vforked child
307 # resets a signal handler. If the problem exists, then use fork
309 #--------------------------------------------------------------------
312 AC_CHECK_FUNC(vfork, tcl_ok=1, tcl_ok=0)
313 if test "$tcl_ok" = 1; then
314 AC_MSG_CHECKING([vfork/signal bug]);
318 #include <sys/wait.h>
328 (void) signal(SIGCHLD, sigProc);
332 } else if (pid == 0) {
333 (void) signal(SIGCHLD, SIG_DFL);
338 exit((gotSignal) ? 0 : 1);
339 }], tcl_ok=1, tcl_ok=0, tcl_ok=0)
340 if test "$tcl_ok" = 1; then
343 AC_MSG_RESULT([buggy, using fork instead])
347 if test "$tcl_ok" = 0; then
348 AC_DEFINE(vfork, fork)
351 #--------------------------------------------------------------------
352 # Check whether there is an strncasecmp function on this system.
353 # This is a bit tricky because under SCO it's in -lsocket and
354 # under Sequent Dynix it's in -linet.
355 #--------------------------------------------------------------------
357 AC_CHECK_FUNC(strncasecmp, tcl_ok=1, tcl_ok=0)
358 if test "$tcl_ok" = 0; then
359 AC_CHECK_LIB(socket, strncasecmp, tcl_ok=1, tcl_ok=0)
361 if test "$tcl_ok" = 0; then
362 AC_CHECK_LIB(inet, strncasecmp, tcl_ok=1, tcl_ok=0)
364 if test "$tcl_ok" = 0; then
365 LIBOBJS="$LIBOBJS strncasecmp.o"
368 #--------------------------------------------------------------------
369 # The code below deals with several issues related to gettimeofday:
370 # 1. Some systems don't provide a gettimeofday function at all
371 # (set NO_GETTOD if this is the case).
372 # 2. SGI systems don't use the BSD form of the gettimeofday function,
373 # but they have a BSDgettimeofday function that can be used instead.
374 # 3. See if gettimeofday is declared in the <sys/time.h> header file.
375 # if not, set the GETTOD_NOT_DECLARED flag so that tclPort.h can
377 #--------------------------------------------------------------------
379 AC_CHECK_FUNC(BSDgettimeofday, AC_DEFINE(HAVE_BSDGETTIMEOFDAY),
380 AC_CHECK_FUNC(gettimeofday, , AC_DEFINE(NO_GETTOD)))
381 AC_MSG_CHECKING([for gettimeofday declaration])
382 AC_EGREP_HEADER(gettimeofday, sys/time.h, AC_MSG_RESULT(present), [
383 AC_MSG_RESULT(missing)
384 AC_DEFINE(GETTOD_NOT_DECLARED)
387 #--------------------------------------------------------------------
388 # The following code checks to see whether it is possible to get
389 # signed chars on this platform. This is needed in order to
390 # properly generate sign-extended ints from character values.
391 #--------------------------------------------------------------------
394 AC_MSG_CHECKING([signed char declarations])
398 ], tcl_ok=yes, tcl_ok=no)
399 AC_MSG_RESULT($tcl_ok)
400 if test $tcl_ok = yes; then
401 AC_DEFINE(HAVE_SIGNED_CHAR)
405 #--------------------------------------------------------------------
406 # Look for libraries that we will need when compiling the Tcl shell
407 #--------------------------------------------------------------------
411 # Add the threads support libraries
413 LIBS="$LIBS$THREADS_LIBS"
415 #--------------------------------------------------------------------
416 # The statements below define a collection of compile flags. This
417 # macro depends on the value of SHARED_BUILD, and should be called
418 # after SC_ENABLE_SHARED checks the configure switches.
419 #--------------------------------------------------------------------
427 #--------------------------------------------------------------------
428 # The statements below check for systems where POSIX-style
429 # non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented.
430 # On these systems (mostly older ones), use the old BSD-style
431 # FIONBIO approach instead.
432 #--------------------------------------------------------------------
436 #--------------------------------------------------------------------
437 # The statements below define a collection of symbols related to
438 # building libtcl as a shared library instead of a static library.
439 #--------------------------------------------------------------------
441 TCL_UNSHARED_LIB_SUFFIX=${UNSHARED_LIB_SUFFIX}
442 TCL_SHARED_LIB_SUFFIX=${SHARED_LIB_SUFFIX}
446 if test "${SHARED_BUILD}" = "1" -a "${SHLIB_SUFFIX}" != "" ; then
447 TCL_SHLIB_CFLAGS="${SHLIB_CFLAGS}"
448 TCL_LD_SEARCH_FLAGS="${LD_SEARCH_FLAGS}"
449 TCL_TOOL_SHARED_LIB_LONGNAME(TCL_LIB_FILE, tcl, ${TCL_SHARED_LIB_SUFFIX})
451 # FIXME: Why does MAKE_LIB not use a generic LIB_FILE variable
452 # that is replaced with the Makefiles specific stub lib name?
453 if test "x$DL_OBJS" = "xtclLoadAout.o"; then
454 MAKE_LIB="\${STLIB_LD} \${TCL_LIB_FILE} \${OBJS}"
456 MAKE_LIB="\${SHLIB_LD} -o \${TCL_LIB_FILE} \${OBJS} ${SHLIB_LD_LIBS}"
472 TCL_LD_SEARCH_FLAGS="${LD_SEARCH_FLAGS}"
473 TCL_TOOL_STATIC_LIB_LONGNAME(TCL_LIB_FILE, tcl, ${TCL_UNSHARED_LIB_SUFFIX})
474 MAKE_LIB="\${STLIB_LD} \${TCL_LIB_FILE} \${OBJS}"
477 # Note: in the following variable, it's important to use the absolute
478 # path name of the Tcl directory rather than "..": this is because
479 # AIX remembers this path and will attempt to use it at run-time to look
480 # up the Tcl library.
482 if test "$SHARED_BUILD" = "0" -o $TCL_NEEDS_EXP_FILE = 0; then
483 TCL_TOOL_LIB_SHORTNAME(TCL_LIB_FLAG, tcl, $TCL_VERSION)
484 TCL_TOOL_LIB_SPEC(TCL_BUILD_LIB_SPEC, `pwd`, ${TCL_LIB_FLAG})
485 TCL_TOOL_LIB_SPEC(TCL_LIB_SPEC, ${exec_prefix}/lib, ${TCL_LIB_FLAG})
487 # FIXME: This if branch needs to be updated with respect
488 # to the library macro changes above!
489 TCL_BUILD_EXP_FILE="lib.exp"
490 eval "TCL_EXP_FILE=libtcl${TCL_EXPORT_FILE_SUFFIX}"
492 # Replace DBGX with TCL_DBGX
493 eval "TCL_EXP_FILE=\"${TCL_EXP_FILE}\""
495 if test "$using_gcc" = "yes" ; then
496 TCL_BUILD_LIB_SPEC="-Wl,-bI:`pwd`/${TCL_BUILD_EXP_FILE} -L`pwd`"
497 TCL_LIB_SPEC="-Wl,-bI:${exec_prefix}/lib/${TCL_EXP_FILE} -L`pwd`"
499 TCL_BUILD_LIB_SPEC="-bI:`pwd`/${TCL_BUILD_EXP_FILE}"
500 TCL_LIB_SPEC="-bI:${exec_prefix}/lib/${TCL_EXP_FILE}"
503 TCL_TOOL_LIB_PATH(TCL_LIB_FULL_PATH, `pwd`, ${TCL_LIB_FILE})
506 eval "CFG_TCL_SHARED_LIB_SUFFIX=${TCL_SHARED_LIB_SUFFIX}"
507 eval "CFG_TCL_UNSHARED_LIB_SUFFIX=${TCL_UNSHARED_LIB_SUFFIX}"
508 eval "CFG_TCL_EXPORT_FILE_SUFFIX=${TCL_EXPORT_FILE_SUFFIX}"
509 VERSION=${TCL_VERSION}
511 #--------------------------------------------------------------------
512 # The statements below define the symbol TCL_PACKAGE_PATH, which
513 # gives a list of directories that may contain packages. The list
514 # consists of one directory for machine-dependent binaries and
515 # another for platform-independent scripts.
516 #--------------------------------------------------------------------
518 if test "$prefix" != "$exec_prefix"; then
519 TCL_PACKAGE_PATH="${exec_prefix}/lib ${prefix}/lib"
521 TCL_PACKAGE_PATH="${prefix}/lib"
524 #--------------------------------------------------------------------
525 # The statements below define various symbols relating to Tcl
526 # stub support. Note that the STUB_LIB_FILE variable must
527 # be set in the Makefile before running MAKE_STUB_LIB.
528 #--------------------------------------------------------------------
530 MAKE_STUB_LIB="\${STLIB_LD} \${STUB_LIB_FILE} \${STUB_LIB_OBJS}"
532 TCL_TOOL_STATIC_LIB_LONGNAME(TCL_STUB_LIB_FILE, tclstub, ${TCL_UNSHARED_LIB_SUFFIX})
534 TCL_TOOL_LIB_SHORTNAME(TCL_STUB_LIB_FLAG, tclstub, $TCL_VERSION)
535 TCL_TOOL_LIB_SPEC(TCL_BUILD_STUB_LIB_SPEC, `pwd`, ${TCL_STUB_LIB_FLAG})
536 TCL_TOOL_LIB_SPEC(TCL_STUB_LIB_SPEC, ${exec_prefix}/lib, ${TCL_STUB_LIB_FLAG})
538 TCL_TOOL_LIB_PATH(TCL_BUILD_STUB_LIB_PATH, `pwd`, ${TCL_STUB_LIB_FILE})
539 TCL_TOOL_LIB_PATH(TCL_STUB_LIB_PATH, ${exec_prefix}/lib, ${TCL_STUB_LIB_FILE})
541 #------------------------------------------------------------------------
542 # tclConfig.sh refers to this by a different name
543 #------------------------------------------------------------------------
545 TCL_SHARED_BUILD=${SHARED_BUILD}
547 AC_SUBST(TCL_STUB_LIB_FILE)
548 AC_SUBST(TCL_STUB_LIB_FLAG)
549 AC_SUBST(TCL_BUILD_STUB_LIB_SPEC)
550 AC_SUBST(TCL_STUB_LIB_SPEC)
551 AC_SUBST(TCL_BUILD_STUB_LIB_PATH)
552 AC_SUBST(TCL_STUB_LIB_PATH)
553 AC_SUBST(MAKE_STUB_LIB)
555 AC_SUBST(BUILD_DLTEST)
556 AC_SUBST(CFLAGS_DEFAULT)
557 AC_SUBST(CFG_TCL_SHARED_LIB_SUFFIX)
558 AC_SUBST(CFG_TCL_UNSHARED_LIB_SUFFIX)
559 AC_SUBST(CFG_TCL_EXPORT_FILE_SUFFIX)
562 AC_SUBST(EXTRA_CFLAGS)
563 AC_SUBST(LDFLAGS_DEFAULT)
564 AC_SUBST(LDFLAGS_DEBUG)
565 AC_SUBST(LDFLAGS_OPTIMIZE)
569 AC_SUBST(TCL_SHARED_BUILD)
570 AC_SUBST(SHLIB_CFLAGS)
573 AC_SUBST(SHLIB_LD_LIBS)
574 AC_SUBST(SHLIB_SUFFIX)
575 AC_SUBST(TCL_BUILD_LIB_SPEC)
576 AC_SUBST(TCL_LD_SEARCH_FLAGS)
577 AC_SUBST(TCL_LDFLAGS_DEBUG)
578 AC_SUBST(TCL_LDFLAGS_OPTIMIZE)
579 AC_SUBST(TCL_LIB_FILE)
580 AC_SUBST(TCL_LIB_FULL_PATH)
581 AC_SUBST(TCL_LIB_FLAG)
582 AC_SUBST(TCL_NEEDS_EXP_FILE)
583 AC_SUBST(TCL_BUILD_EXP_FILE)
584 AC_SUBST(TCL_EXP_FILE)
585 AC_SUBST(TCL_LIB_SPEC)
586 AC_SUBST(TCL_LIB_VERSIONS_OK)
587 AC_SUBST(TCL_MAJOR_VERSION)
588 AC_SUBST(TCL_MINOR_VERSION)
589 AC_SUBST(TCL_PACKAGE_PATH)
590 AC_SUBST(TCL_PATCH_LEVEL)
591 AC_SUBST(TCL_SHARED_LIB_SUFFIX)
592 AC_SUBST(TCL_SHLIB_CFLAGS)
593 AC_SUBST(TCL_SRC_DIR)
594 AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
595 AC_SUBST(TCL_VERSION)
596 AC_SUBST(VENDORPREFIX)
598 AC_OUTPUT(Makefile tclConfig.sh)