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 Ck installation
3 dnl to configure the system for the local environment.
9 AC_HAVE_HEADERS(unistd.h limits.h)
11 #--------------------------------------------------------------------
12 # Supply a substitute for stdlib.h if it doesn't define strtol,
13 # strtoul, or strtod (which it doesn't in some versions of SunOS).
14 #--------------------------------------------------------------------
16 AC_MSG_CHECKING(stdlib.h)
17 AC_HEADER_EGREP(strtol, stdlib.h, tk_ok=yes, tk_ok=no)
18 AC_HEADER_EGREP(strtoul, stdlib.h, , tk_ok=no)
19 AC_HEADER_EGREP(strtod, stdlib.h, , tk_ok=no)
20 if test $tk_ok = no; then
21 AC_DEFINE(NO_STDLIB_H)
25 #--------------------------------------------------------------------
26 # Check for various typedefs and provide substitutes if
28 #--------------------------------------------------------------------
35 #------------------------------------------------------------------------------
36 # What type do signals return? Do we have sigaction ?
37 #------------------------------------------------------------------------------
40 AC_HAVE_FUNCS(sigaction)
42 #--------------------------------------------------------------------
43 # See if there was a command-line option for where Tcl is; if
44 # not, assume that its top-level directory is a sibling of ours.
45 #--------------------------------------------------------------------
47 AC_ARG_WITH(tcl, [ --with-tcl=DIR use Tcl 8.X binaries from DIR],
48 TCL_BIN_DIR=$withval, TCL_BIN_DIR=`cd ../tcl8.0/unix ; pwd`)
49 if test ! -d $TCL_BIN_DIR ; then
50 AC_MSG_ERROR(Tcl directory $TCL_BIN_DIR doesn't exist)
53 #--------------------------------------------------------------------
54 # Read in configuration information generated by Tcl for shared
55 # libraries, and arrange for it to be substituted into our
57 #--------------------------------------------------------------------
59 if test -r $TCL_BIN_DIR/tclConfig.sh ; then
60 file=$TCL_BIN_DIR/tclConfig.sh
61 if test -d $TCL_BIN_DIR/../generic ; then
62 TCL_DIR=`cd $TCL_BIN_DIR/../generic ; pwd`
63 elif test -d $TCL_BIN_DIR/../include ; then
64 TCL_DIR=`cd $TCL_BIN_DIR/../include ; pwd`
70 SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
71 SHLIB_LD=$TCL_SHLIB_LD
72 SHLIB_LD_LIBS=$TCL_SHLIB_LD_LIBS
73 SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
74 SHLIB_VERSION=$TCL_SHLIB_VERSION
76 LD_FLAGS=$TCL_LD_FLAGS
77 LD_SEARCH_FLAGS=$TCL_LD_SEARCH_FLAGS
81 TCL_LIB_VERSIONS_OK=no
82 TCL_BUILD_LIB_SPEC="-L$TCL_BIN_DIR -ltcl"
83 TCL_INCLUDE_SPEC="-I$TCL_DIR"
86 AC_MSG_CHECKING([Ck version])
87 if test "${TCL_VERSION}" = "7.4"; then
92 elif test "${TCL_VERSION}" = "7.5"; then
97 elif test "${TCL_VERSION}" = "7.6"; then
103 # Assume Tcl8.0 or higher
106 CK_MAJOR_VERSION=$TCL_MAJOR_VERSION
107 CK_MINOR_VERSION=$TCL_MINOR_VERSION
109 AC_MSG_RESULT(${CK_VERSION})
111 #--------------------------------------------------------------------
112 # Include sys/select.h if it exists and if it supplies things
113 # that appear to be useful and aren't already in sys/types.h.
114 # This appears to be true only on the RS/6000 under AIX. Some
115 # systems like OSF/1 have a sys/select.h that's of no use, and
116 # other systems like SCO UNIX have a sys/select.h that's
117 # pernicious. If "fd_set" isn't defined anywhere then set a
119 #--------------------------------------------------------------------
121 AC_MSG_CHECKING([fd_set and sys/select])
122 AC_TRY_COMPILE([#include <sys/types.h>],
123 [fd_set readMask, writeMask;], tk_ok=yes, tk_ok=no)
124 if test $tk_ok = no; then
125 AC_HEADER_EGREP(fd_mask, sys/select.h, tk_ok=yes)
126 if test $tk_ok = yes; then
127 AC_DEFINE(HAVE_SYS_SELECT_H)
130 AC_MSG_RESULT($tk_ok)
131 if test $tk_ok = no; then
135 #---------------------------------------------------------------------
136 # Locate the curses header files and the curses library archive.
139 # /usr/include and /usr/lib
143 #---------------------------------------------------------------------
145 echo checking for curses/ncurses header files
148 dirs="../ncurses/include /usr/include /usr/include/ncurses /opt/ncurses/include /usr/local/include /usr/local/include/ncurses"
150 if test -r $i/ncurses.h; then
151 AC_MSG_CHECKING([ncurses headers])
153 CFLAGS="$CFLAGS -I$i"
154 AC_TRY_COMPILE([#include <ncurses.h>],
155 [int c; initscr(); c = ACS_ULCORNER; curs_set(1);],
157 CURSESINCLUDES="-I$i"], AC_MSG_RESULT(no))
159 if test "$CURSESINCLUDES" != nope; then
164 if test -r $i/curses.h; then
165 AC_MSG_CHECKING([curses headers])
167 CFLAGS="$CFLAGS -I$i"
168 AC_TRY_COMPILE([#include <curses.h>],
169 [int c; initscr(); c = ACS_ULCORNER; curs_set(1);],
171 CURSESINCLUDES="-I$i"], AC_MSG_RESULT(no))
173 if test "$CURSESINCLUDES" != nope; then
178 if test "$CURSESINCLUDES" = nope; then
179 echo "Warning: couldn't find any curses header file."
180 CURSESINCLUDES="# no header file found"
182 if test $USE_NCURSES = 1 ; then
183 echo "using ncurses.h from $CURSESINCLUDES"
185 echo "using curses.h from $CURSESINCLUDES"
189 echo checking for curses/ncurses library files
191 dirs="../ncurses/lib /usr/lib /usr/lib/ncurses /opt/ncurses/lib /usr/local/lib /usr/local/ncurses/lib"
193 if test $USE_NCURSES = 0 ; then
194 if test -r $i/libcurses.a || test -r $i/libcurses$SHLIB_SUFFIX ; then
195 AC_MSG_CHECKING([curses library])
197 CFLAGS="$CFLAGS $CURSESINCLUDES"
198 if test "$i" = "/usr/lib" ; then
199 LIBSW="-lcurses -ltermcap"
201 LIBSW="-L$i -lcurses -ltermcap"
205 AC_TRY_LINK([#include <curses.h>],
206 [int c; initscr(); c = ACS_ULCORNER; curs_set(1);],
208 CURSESLIBSW="$LIBSW"], AC_MSG_RESULT(no))
211 if test "$CURSESLIBSW" != nope; then
216 if test -r $i/libncurses.a || test -r $i/libncurses$SHLIB_SUFFIX ; then
217 AC_MSG_CHECKING([ncurses library])
219 CFLAGS="$CFLAGS $CURSESINCLUDES"
220 if test "$i" = "/usr/lib" ; then
223 LIBSW="-L$i -lncurses"
227 AC_TRY_LINK([#include <ncurses.h>],
228 [int c; initscr(); c = ACS_ULCORNER; curs_set(1);],
230 CURSESLIBSW="$LIBSW"], AC_MSG_RESULT(no))
233 if test "$CURSESLIBSW" != nope; then
240 if test "$CURSESLIBSW" = nope ; then
241 echo "Warning: couldn't find the curses library archive. Using -lcurses."
242 CURSESLIBSW="-lcurses -ltermcap"
244 echo "using curses library: $CURSESLIBSW"
245 AC_MSG_CHECKING([curses scr_dump function])
247 CFLAGS="$CFLAGS $CURSESINCLUDES"
250 if test $USE_NCURSES = 1 ; then
251 AC_TRY_LINK([#include <ncurses.h>],
252 [int c; initscr(); scr_dump("xx");],
254 AC_DEFINE(HAVE_SCR_DUMP)], AC_MSG_RESULT(no))
256 AC_TRY_LINK([#include <curses.h>],
257 [int c; initscr(); scr_dump("xx");],
259 AC_DEFINE(HAVE_SCR_DUMP)], AC_MSG_RESULT(no))
265 if test $USE_NCURSES = 1 ; then
266 USE_NCURSES="-DUSE_NCURSES"
271 #---------------------------------------------------------------------
272 # Check for GPM (General Purpose Mouse)
273 #---------------------------------------------------------------------
275 AC_MSG_CHECKING([GPM library])
278 AC_TRY_LINK([#include <gpm.h>],
279 [Gpm_Connect conn; Gpm_Open(&conn, 0);],
282 CURSESLIBSW="$CURSESLIBSW -lgpm"],
286 #--------------------------------------------------------------------
287 # Check for the existence of various libraries. The order here
288 # is important, so that then end up in the right order in the
289 # command line generated by make. The -lsocket and -lnsl libraries
290 # require a couple of special tricks:
291 # 1. Use "connect" and "accept" to check for -lsocket, and
292 # "gethostbyname" to check for -lnsl.
293 # 2. Use each function name only once: can't redo a check because
294 # autoconf caches the results of the last check and won't redo it.
295 # 3. Use -lnsl and -lsocket only if they supply procedures that
296 # aren't already present in the normal libraries. This is because
297 # IRIX 5.2 has libraries, but they aren't needed and they're
298 # bogus: they goof up name resolution if used.
299 # 4. On some SVR4 systems, can't use -lsocket without -lnsl too.
300 # To get around this problem, check for both libraries together
301 # if -lsocket doesn't work by itself.
302 #--------------------------------------------------------------------
304 AC_CHECK_LIB(Xbsd, main, [LIBS="$LIBS -lXbsd"])
307 AC_CHECK_FUNC(connect, tk_checkSocket=0, tk_checkSocket=1)
308 if test "$tk_checkSocket" = 1; then
309 AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", tk_checkBoth=1)
311 if test "$tk_checkBoth" = 1; then
313 LIBS="$LIBS -lsocket -lnsl"
314 AC_CHECK_FUNC(accept, tk_checkNsl=0, [LIBS=$tk_oldLibs])
316 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
318 #--------------------------------------------------------------------
319 # On Interactive the str(n)casecmp is burried in libinet.a
320 #--------------------------------------------------------------------
322 AC_CHECK_FUNC(strncasecmp, , AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"]))
324 #--------------------------------------------------------------------
325 # Figure out how to find out whether a FILE structure contains
326 # buffered readable data. Some known names for the count field:
327 # _cnt: Most UNIX systems
331 # Or, in GNU libc there are two fields, _gptr and _egptr, which
332 # have to be compared.
333 #--------------------------------------------------------------------
335 AC_MSG_CHECKING([count field in FILE structures])
336 AC_TRY_COMPILE([#include <stdio.h>],
337 [FILE *f = stdin; f->_cnt = 0;], fcnt="_cnt", )
338 if test "$fcnt" = ""; then
339 AC_TRY_COMPILE([#include <stdio.h>],
340 [FILE *f = stdin; f->__cnt = 0;], fcnt="__cnt", )
342 if test "$fcnt" = ""; then
343 AC_TRY_COMPILE([#include <stdio.h>],
344 [FILE *f = stdin; f->_r = 0;], fcnt="_r", )
346 if test "$fcnt" = ""; then
347 AC_TRY_COMPILE([#include <stdio.h>],
348 [FILE *f = stdin; f->readCount = 0;], fcnt="readCount", )
350 if test "$fcnt" != ""; then
351 AC_DEFINE_UNQUOTED(TK_FILE_COUNT, $fcnt)
353 if test "$fcnt" = ""; then
354 AC_TRY_COMPILE([#include <stdio.h>],
355 [FILE *f = stdin; f->_gptr = f->_egptr;],
357 if test $tk_ok = yes; then
358 AC_DEFINE(TK_FILE_GPTR)
362 if test "$fcnt" = ""; then
363 AC_TRY_COMPILE([#include <stdio.h>],
364 [FILE *f = stdin; f->_IO_read_ptr = f->_IO_read_end;],
366 if test $tk_ok = yes; then
367 AC_DEFINE(TK_FILE_READ_PTR)
368 fcnt="_IO_read_ptr/_IO_read_end"
371 if test "$fcnt" = ""; then
372 AC_MSG_RESULT([not found; must supply TkReadDataPending procedure])
374 AC_MSG_RESULT("$fcnt")
377 #--------------------------------------------------------------------
378 # On a few very rare systems, all of the libm.a stuff is
379 # already in libc.a. Set compiler flags accordingly.
380 # Also, Linux requires the "ieee" library for math to
381 # work right (and it must appear before "-lm").
382 #--------------------------------------------------------------------
385 AC_CHECK_FUNC(sin, , MATH_LIBS="-lm")
386 AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
388 #--------------------------------------------------------------------
389 # If this system doesn't have a memmove procedure, use memcpy
391 #--------------------------------------------------------------------
393 AC_CHECK_FUNC(memmove, , [AC_DEFINE(memmove, memcpy)])
395 #--------------------------------------------------------------------
396 # SGI systems don't use the BSD form of the gettimeofday function,
397 # but they have a BSDgettimeofday function that can be used instead.
399 # Also, check for the existence of a gettimeofday declaration,
400 # to tkPort.h can declare it if it isn't already declared.
401 #--------------------------------------------------------------------
403 AC_CHECK_FUNC(BSDgettimeofday, AC_DEFINE(HAVE_BSDGETTIMEOFDAY))
404 AC_MSG_CHECKING([for gettimeofday declaration])
405 AC_EGREP_HEADER(gettimeofday, sys/time.h, AC_MSG_RESULT(present), [
406 AC_MSG_RESULT(missing)
407 AC_DEFINE(GETTOD_NOT_DECLARED)
410 #--------------------------------------------------------------------
411 # Under Solaris 2.4, strtod returns the wrong value for the
412 # terminating character under some conditions. Check for this
413 # and if the problem exists use a substitute procedure
414 # "fixstrtod" (provided by Tcl) that corrects the error.
415 #--------------------------------------------------------------------
417 AC_CHECK_FUNC(strtod, tk_strtod=1, tk_strtod=0)
418 if test "$tk_strtod" = 1; then
419 AC_MSG_CHECKING([for Solaris 2.4 strtod bug])
421 extern double strtod();
424 char *string = "NaN";
426 strtod(string, &term);
427 if ((term != string) && (term[-1] == 0)) {
431 }], tk_ok=1, tk_ok=0, tk_ok=0)
432 if test "$tk_ok" = 1; then
436 AC_DEFINE(strtod, fixstrtod)
440 #--------------------------------------------------------------------
441 # The statements below define a collection of symbols related to
442 # building libck as a shared library instead of a static library.
443 #--------------------------------------------------------------------
445 AC_ARG_ENABLE(shared,
446 [ --enable-shared build libck as a shared library],
447 [ok=$enableval], [ok=no])
448 if test "$ok" = "yes" -a "${SHLIB_SUFFIX}" != ""; then
449 CK_SHLIB_CFLAGS="${SHLIB_CFLAGS}"
450 eval "CK_LIB_FILE=libck${TCL_SHARED_LIB_SUFFIX}"
451 MAKE_LIB="\${SHLIB_LD} -o ${CK_LIB_FILE} \${OBJS} ${SHLIB_LD_LIBS}"
455 eval "CK_LIB_FILE=libck${TCL_UNSHARED_LIB_SUFFIX}"
456 # Fixup if suffix missing
457 if test "$CK_LIB_FILE" = "libck" ; then
460 MAKE_LIB="ar cr ${CK_LIB_FILE} \${OBJS}"
463 # Note: in the following variable, it's important to use the absolute
464 # path name of the Tcl directory rather than "..": this is because
465 # AIX remembers this path and will attempt to use it at run-time to look
466 # up the Tcl library.
468 if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
469 CK_BUILD_LIB_SPEC="-L`pwd` -lck${VERSION}"
470 CK_LIB_SPEC="-L${exec_prefix}/lib -lck${VERSION}"
472 CK_BUILD_LIB_SPEC="-L`pwd` -lck`echo ${VERSION} | tr -d .`"
473 CK_LIB_SPEC="-L${exec_prefix}/lib -lck`echo ${VERSION} | tr -d .`"
481 AC_SUBST(SHLIB_CFLAGS)
483 AC_SUBST(SHLIB_LD_LIBS)
484 AC_SUBST(SHLIB_SUFFIX)
485 AC_SUBST(SHLIB_VERSION)
487 AC_SUBST(TCL_BIN_DIR)
489 AC_SUBST(TCL_INCLUDE_SPEC)
490 AC_SUBST(TCL_VERSION)
491 AC_SUBST(TCL_BUILD_LIB_SPEC)
492 AC_SUBST(CK_LD_SEARCH_FLAGS)
493 AC_SUBST(CK_LIB_FILE)
494 AC_SUBST(CK_LIB_SPEC)
495 AC_SUBST(CK_MAJOR_VERSION)
496 AC_SUBST(CK_MINOR_VERSION)
497 AC_SUBST(CK_SHLIB_CFLAGS)
499 AC_SUBST(CK_BUILD_LIB_SPEC)
500 AC_SUBST(USE_NCURSES)
501 AC_SUBST(CURSESINCLUDES)
502 AC_SUBST(CURSESLIBSW)
505 AC_OUTPUT(Makefile ckConfig.sh pkgIndex.tcl)