]> www.wagner.pp.ru Git - oss/ck.git/blob - configure.in
Ck console graphics toolkit
[oss/ck.git] / 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 Ck installation
3 dnl     to configure the system for the local environment.
4 AC_INIT(ck.h)
5
6 AC_PROG_INSTALL
7 AC_PROG_RANLIB
8 CC=${CC-cc}
9 AC_HAVE_HEADERS(unistd.h limits.h)
10
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 #--------------------------------------------------------------------
15
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)
22 fi
23 AC_MSG_RESULT($tk_ok)
24
25 #--------------------------------------------------------------------
26 #       Check for various typedefs and provide substitutes if
27 #       they don't exist.
28 #--------------------------------------------------------------------
29
30 AC_MODE_T
31 AC_PID_T
32 AC_SIZE_T
33 AC_UID_T
34
35 #------------------------------------------------------------------------------
36 #       What type do signals return? Do we have sigaction ?
37 #------------------------------------------------------------------------------
38
39 AC_RETSIGTYPE
40 AC_HAVE_FUNCS(sigaction)
41
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 #--------------------------------------------------------------------
46
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)
51 fi
52
53 #--------------------------------------------------------------------
54 #       Read in configuration information generated by Tcl for shared
55 #       libraries, and arrange for it to be substituted into our
56 #       Makefile.
57 #--------------------------------------------------------------------
58
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`
65     else
66         TCL_DIR=$TCL_BIN_DIR
67     fi
68     . $file
69     CC=$TCL_CC
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
75     DL_LIBS=$TCL_DL_LIBS
76     LD_FLAGS=$TCL_LD_FLAGS
77     LD_SEARCH_FLAGS=$TCL_LD_SEARCH_FLAGS
78 else
79     TCL_DIR=$TCL_BIN_DIR
80     TCL_LIB_FILE=libtcl.a
81     TCL_LIB_VERSIONS_OK=no
82     TCL_BUILD_LIB_SPEC="-L$TCL_BIN_DIR -ltcl"
83         TCL_INCLUDE_SPEC="-I$TCL_DIR"
84 fi
85
86 AC_MSG_CHECKING([Ck version])
87 if test "${TCL_VERSION}" = "7.4"; then
88     VERSION=4.0
89     CK_VERSION=4.0
90     CK_MAJOR_VERSION=4
91     CK_MINOR_VERSION=0
92 elif test "${TCL_VERSION}" = "7.5"; then
93     VERSION=4.1
94     CK_VERSION=4.1
95     CK_MAJOR_VERSION=4
96     CK_MINOR_VERSION=1
97 elif test "${TCL_VERSION}" = "7.6"; then
98     VERSION=4.2
99     CK_VERSION=4.2
100     CK_MAJOR_VERSION=4
101     CK_MINOR_VERSION=2
102 else
103     # Assume Tcl8.0 or higher
104     VERSION=$TCL_VERSION
105     CK_VERSION=$VERSION
106     CK_MAJOR_VERSION=$TCL_MAJOR_VERSION
107     CK_MINOR_VERSION=$TCL_MINOR_VERSION
108 fi
109 AC_MSG_RESULT(${CK_VERSION})
110
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
118 #       special flag.
119 #--------------------------------------------------------------------
120
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)
128     fi
129 fi
130 AC_MSG_RESULT($tk_ok)
131 if test $tk_ok = no; then
132     AC_DEFINE(NO_FD_SET)
133 fi
134
135 #---------------------------------------------------------------------
136 #       Locate the curses header files and the curses library archive.
137 #       The order is:
138 #               ../ncurses
139 #               /usr/include and /usr/lib
140 #               /opt/ncurses
141 #               /usr/local
142 #               /usr/local/ncurses
143 #---------------------------------------------------------------------
144
145 echo checking for curses/ncurses header files
146 CURSESINCLUDES=nope
147 USE_NCURSES=0
148 dirs="../ncurses/include /usr/include /usr/include/ncurses /opt/ncurses/include /usr/local/include /usr/local/include/ncurses"
149 for i in $dirs ; do
150     if test -r $i/ncurses.h; then
151         AC_MSG_CHECKING([ncurses headers])
152         tk_oldCFlags=$CFLAGS
153         CFLAGS="$CFLAGS -I$i"
154         AC_TRY_COMPILE([#include <ncurses.h>],
155            [int c; initscr(); c = ACS_ULCORNER; curs_set(1);],
156            [AC_MSG_RESULT(yes)
157             CURSESINCLUDES="-I$i"], AC_MSG_RESULT(no))
158         CFLAGS=$tk_oldCFlags
159         if test "$CURSESINCLUDES" != nope; then
160             USE_NCURSES=1
161             break
162         fi
163     fi
164     if test -r $i/curses.h; then
165         AC_MSG_CHECKING([curses headers])
166         tk_oldCFlags=$CFLAGS
167         CFLAGS="$CFLAGS -I$i"
168         AC_TRY_COMPILE([#include <curses.h>],
169            [int c; initscr(); c = ACS_ULCORNER; curs_set(1);],
170            [AC_MSG_RESULT(yes)
171             CURSESINCLUDES="-I$i"], AC_MSG_RESULT(no))
172         CFLAGS=$tk_oldCFlags
173         if test "$CURSESINCLUDES" != nope; then
174             break
175         fi
176     fi
177 done
178 if test "$CURSESINCLUDES" = nope; then
179     echo "Warning:  couldn't find any curses header file."
180     CURSESINCLUDES="# no header file found"
181 else
182     if test $USE_NCURSES = 1 ; then
183         echo "using ncurses.h from $CURSESINCLUDES"
184     else
185         echo "using curses.h from $CURSESINCLUDES"
186     fi
187 fi
188
189 echo checking for curses/ncurses library files
190 CURSESLIBSW=nope
191 dirs="../ncurses/lib /usr/lib /usr/lib/ncurses /opt/ncurses/lib /usr/local/lib /usr/local/ncurses/lib"
192 for i in $dirs ; do
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])
196         tk_oldCFlags=$CFLAGS
197         CFLAGS="$CFLAGS $CURSESINCLUDES"
198         if test "$i" = "/usr/lib" ; then
199             LIBSW="-lcurses -ltermcap"
200         else
201             LIBSW="-L$i -lcurses -ltermcap"
202         fi
203         tk_oldLibs=$LIBS
204         LIBS="$LIBSW"
205         AC_TRY_LINK([#include <curses.h>],
206             [int c; initscr(); c = ACS_ULCORNER; curs_set(1);],
207             [AC_MSG_RESULT(yes)
208              CURSESLIBSW="$LIBSW"], AC_MSG_RESULT(no))
209         CFLAGS=$tk_oldCFlags
210         LIBS=$tk_oldLibs
211         if test "$CURSESLIBSW" != nope; then
212             break
213         fi
214     fi
215   else
216     if test -r $i/libncurses.a || test -r $i/libncurses$SHLIB_SUFFIX ; then
217         AC_MSG_CHECKING([ncurses library])
218         tk_oldCFlags=$CFLAGS
219         CFLAGS="$CFLAGS $CURSESINCLUDES"
220         if test "$i" = "/usr/lib" ; then
221             LIBSW="-lncurses"
222         else
223             LIBSW="-L$i -lncurses"
224         fi
225         tk_oldLibs=$LIBS
226         LIBS="$LIBSW"
227         AC_TRY_LINK([#include <ncurses.h>],
228             [int c; initscr(); c = ACS_ULCORNER; curs_set(1);],
229             [AC_MSG_RESULT(yes)
230              CURSESLIBSW="$LIBSW"], AC_MSG_RESULT(no))
231         CFLAGS=$tk_oldCFlags
232         LIBS=$tk_oldLibs
233         if test "$CURSESLIBSW" != nope; then
234             break
235         fi
236     fi
237   fi
238 done
239
240 if test "$CURSESLIBSW" = nope ; then
241     echo "Warning:  couldn't find the curses library archive.  Using -lcurses."
242     CURSESLIBSW="-lcurses -ltermcap"
243 else
244     echo "using curses library: $CURSESLIBSW"
245     AC_MSG_CHECKING([curses scr_dump function])
246     tk_oldCFlags=$CFLAGS
247     CFLAGS="$CFLAGS $CURSESINCLUDES"
248     tk_oldLibs=$LIBS
249     LIBS="$CURSESLIBSW"
250     if test $USE_NCURSES = 1 ; then
251         AC_TRY_LINK([#include <ncurses.h>],
252            [int c; initscr(); scr_dump("xx");],
253            [AC_MSG_RESULT(yes)
254            AC_DEFINE(HAVE_SCR_DUMP)], AC_MSG_RESULT(no))
255     else
256         AC_TRY_LINK([#include <curses.h>],
257            [int c; initscr(); scr_dump("xx");],
258            [AC_MSG_RESULT(yes)
259            AC_DEFINE(HAVE_SCR_DUMP)], AC_MSG_RESULT(no))
260     fi
261     CFLAGS=$tk_oldCFlags
262     LIBS=$tk_oldLibs
263 fi
264
265 if test $USE_NCURSES = 1 ; then
266     USE_NCURSES="-DUSE_NCURSES"
267 else
268     USE_NCURSES=""
269 fi
270
271 #---------------------------------------------------------------------
272 #       Check for GPM (General Purpose Mouse)
273 #---------------------------------------------------------------------
274
275 AC_MSG_CHECKING([GPM library])
276 tk_oldLibs=$LIBS
277 LIBS="-lgpm"
278 AC_TRY_LINK([#include <gpm.h>],
279     [Gpm_Connect conn; Gpm_Open(&conn, 0);],
280     [AC_MSG_RESULT(yes)
281      AC_DEFINE(HAVE_GPM)
282      CURSESLIBSW="$CURSESLIBSW -lgpm"],
283     [AC_MSG_RESULT(no)])
284 LIBS=$tk_oldLibs
285
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 #--------------------------------------------------------------------
303
304 AC_CHECK_LIB(Xbsd, main, [LIBS="$LIBS -lXbsd"])
305
306 tk_checkBoth=0
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)
310 fi
311 if test "$tk_checkBoth" = 1; then
312     tk_oldLibs=$LIBS
313     LIBS="$LIBS -lsocket -lnsl"
314     AC_CHECK_FUNC(accept, tk_checkNsl=0, [LIBS=$tk_oldLibs])
315 fi
316 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
317
318 #--------------------------------------------------------------------
319 #       On Interactive the str(n)casecmp is burried in libinet.a
320 #--------------------------------------------------------------------
321
322 AC_CHECK_FUNC(strncasecmp, , AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"]))
323
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
328 #               __cnt:          HPUX
329 #               _r:             BSD
330 #               readCount:      Sprite
331 #       Or, in GNU libc there are two fields, _gptr and _egptr, which
332 #       have to be compared.
333 #--------------------------------------------------------------------
334
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", )
341 fi
342 if test "$fcnt" = ""; then
343     AC_TRY_COMPILE([#include <stdio.h>],
344         [FILE *f = stdin; f->_r = 0;], fcnt="_r", )
345 fi
346 if test "$fcnt" = ""; then
347     AC_TRY_COMPILE([#include <stdio.h>],
348         [FILE *f = stdin; f->readCount = 0;], fcnt="readCount", )
349 fi
350 if test "$fcnt" != ""; then
351     AC_DEFINE_UNQUOTED(TK_FILE_COUNT, $fcnt)
352 fi
353 if test "$fcnt" = ""; then
354     AC_TRY_COMPILE([#include <stdio.h>],
355         [FILE *f = stdin; f->_gptr = f->_egptr;],
356         tk_ok=yes, tk_ok=no)
357     if test $tk_ok = yes; then
358         AC_DEFINE(TK_FILE_GPTR)
359         fcnt="_gptr/_egptr"
360     fi
361 fi
362 if test "$fcnt" = ""; then
363     AC_TRY_COMPILE([#include <stdio.h>],
364         [FILE *f = stdin; f->_IO_read_ptr = f->_IO_read_end;],
365         tk_ok=yes, tk_ok=no)
366     if test $tk_ok = yes; then
367         AC_DEFINE(TK_FILE_READ_PTR)
368         fcnt="_IO_read_ptr/_IO_read_end"
369     fi
370 fi
371 if test "$fcnt" = ""; then
372     AC_MSG_RESULT([not found; must supply TkReadDataPending procedure])
373 else
374     AC_MSG_RESULT("$fcnt")
375 fi
376
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 #--------------------------------------------------------------------
383
384 MATH_LIBS=""
385 AC_CHECK_FUNC(sin, , MATH_LIBS="-lm")
386 AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
387
388 #--------------------------------------------------------------------
389 #       If this system doesn't have a memmove procedure, use memcpy
390 #       instead.
391 #--------------------------------------------------------------------
392
393 AC_CHECK_FUNC(memmove, , [AC_DEFINE(memmove, memcpy)])
394
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.
398 #
399 #       Also, check for the existence of a gettimeofday declaration,
400 #       to tkPort.h can declare it if it isn't already declared.
401 #--------------------------------------------------------------------
402
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)
408 ])
409
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 #--------------------------------------------------------------------
416
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])
420     AC_TRY_RUN([
421         extern double strtod();
422         int main()
423         {
424             char *string = "NaN";
425             char *term;
426             strtod(string, &term);
427             if ((term != string) && (term[-1] == 0)) {
428                 exit(1);
429             }
430             exit(0);
431         }], tk_ok=1, tk_ok=0, tk_ok=0)
432     if test "$tk_ok" = 1; then
433         AC_MSG_RESULT(ok)
434     else
435         AC_MSG_RESULT(buggy)
436         AC_DEFINE(strtod, fixstrtod)
437     fi
438 fi
439
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 #--------------------------------------------------------------------
444
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}"
452     RANLIB=":"
453 else
454     CK_SHLIB_CFLAGS=""
455     eval "CK_LIB_FILE=libck${TCL_UNSHARED_LIB_SUFFIX}"
456     # Fixup if suffix missing
457     if test "$CK_LIB_FILE" = "libck" ; then
458         CK_LIB_FILE=libck.a
459     fi
460     MAKE_LIB="ar cr ${CK_LIB_FILE} \${OBJS}"
461 fi
462
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.
467
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}"
471 else
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 .`"
474 fi
475
476 AC_SUBST(CC)
477 AC_SUBST(DL_LIBS)
478 AC_SUBST(LD_FLAGS)
479 AC_SUBST(MATH_LIBS)
480 AC_SUBST(MAKE_LIB)
481 AC_SUBST(SHLIB_CFLAGS)
482 AC_SUBST(SHLIB_LD)
483 AC_SUBST(SHLIB_LD_LIBS)
484 AC_SUBST(SHLIB_SUFFIX)
485 AC_SUBST(SHLIB_VERSION)
486 AC_SUBST(TCL_DIR)
487 AC_SUBST(TCL_BIN_DIR)
488 AC_SUBST(TCL_LIB)
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)
498 AC_SUBST(CK_VERSION)
499 AC_SUBST(CK_BUILD_LIB_SPEC)
500 AC_SUBST(USE_NCURSES)
501 AC_SUBST(CURSESINCLUDES)
502 AC_SUBST(CURSESLIBSW)
503
504
505 AC_OUTPUT(Makefile ckConfig.sh pkgIndex.tcl)