home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tk4.0 / configure.in < prev    next >
Encoding:
Text File  |  1995-06-28  |  10.9 KB  |  336 lines

  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 Tk installation
  3. dnl    to configure the system for the local environment.
  4. AC_INIT(tk.h)
  5.  
  6. # @(#) configure.in 1.17 95/06/27 21:54:20
  7.  
  8. AC_PROG_INSTALL
  9. AC_PROG_RANLIB
  10. AC_PREFIX_PROGRAM(wish)
  11. CC=${CC-cc}
  12. AC_SUBST(CC)
  13. AC_HAVE_HEADERS(unistd.h limits.h)
  14.  
  15. #--------------------------------------------------------------------
  16. #    Include sys/select.h if it exists and if it supplies things
  17. #    that appear to be useful and aren't already in sys/types.h.
  18. #    This appears to be true only on the RS/6000 under AIX.  Some
  19. #    systems like OSF/1 have a sys/select.h that's of no use, and
  20. #    other systems like SCO UNIX have a sys/select.h that's
  21. #    pernicious.  If "fd_set" isn't defined anywhere then set a
  22. #    special flag.
  23. #--------------------------------------------------------------------
  24.  
  25. AC_MSG_CHECKING([fd_set and sys/select])
  26. AC_TRY_COMPILE([#include <sys/types.h>],
  27.     [fd_set readMask, writeMask;], tk_ok=yes, tk_ok=no)
  28. if test $tk_ok = no; then
  29.     AC_HEADER_EGREP(fd_mask, sys/select.h, tk_ok=yes)
  30.     if test $tk_ok = yes; then
  31.     AC_DEFINE(HAVE_SYS_SELECT_H)
  32.     fi
  33. fi
  34. AC_MSG_RESULT($tk_ok)
  35. if test $tk_ok = no; then
  36.     AC_DEFINE(NO_FD_SET)
  37. fi
  38.  
  39. #--------------------------------------------------------------------
  40. #    Supply a substitute for stdlib.h if it doesn't define strtol,
  41. #    strtoul, or strtod (which it doesn't in some versions of SunOS).
  42. #--------------------------------------------------------------------
  43.  
  44. AC_MSG_CHECKING(stdlib.h)
  45. AC_HEADER_EGREP(strtol, stdlib.h, tk_ok=yes, tk_ok=no)
  46. AC_HEADER_EGREP(strtoul, stdlib.h, , tk_ok=no)
  47. AC_HEADER_EGREP(strtod, stdlib.h, , tk_ok=no)
  48. if test $tk_ok = no; then
  49.     AC_DEFINE(NO_STDLIB_H)
  50. fi
  51. AC_MSG_RESULT($tk_ok)
  52.  
  53. #--------------------------------------------------------------------
  54. #    Check for various typedefs and provide substitutes if
  55. #    they don't exist.
  56. #--------------------------------------------------------------------
  57.  
  58. AC_MODE_T
  59. AC_PID_T
  60. AC_SIZE_T
  61. AC_UID_T
  62.  
  63. #--------------------------------------------------------------------
  64. #    Locate the X11 header files and the X11 library archive.  Try
  65. #    the ac_path_x macro first, but if it doesn't find the X stuff
  66. #    (e.g. because there's no xmkmf program) then check through
  67. #    a list of possible directories.  Under some conditions the
  68. #    autoconf macro will return an include directory that contains
  69. #    no include files, so double-check its result just to be safe.
  70. #--------------------------------------------------------------------
  71.  
  72. AC_PATH_X
  73. not_really_there=""
  74. if test "$no_x" = ""; then
  75.     if test "$x_includes" = ""; then
  76.     AC_TRY_CPP([#include <X11/XIntrinsic.h>], , not_really_there="yes")
  77.     else
  78.     if test ! -r $x_includes/X11/Intrinsic.h; then
  79.         not_really_there="yes"
  80.     fi
  81.     fi
  82. fi
  83. if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then
  84.     echo checking for X11 header files
  85.     XINCLUDES="# no special path needed"
  86.     AC_TRY_CPP([#include <X11/Intrinsic.h>], , XINCLUDES="nope")
  87.     if test "$XINCLUDES" = nope; then
  88.         dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/include/X11R4 /usr/X11R5/include /usr/include/X11R5 /usr/openwin/include /usr/X11/include /usr/sww/include"
  89.         for i in $dirs ; do
  90.         if test -r $i/X11/Intrinsic.h; then
  91.             XINCLUDES=" -I$i"
  92.         fi
  93.         done
  94.     fi
  95. else
  96.     if test "$x_includes" != ""; then
  97.     XINCLUDES=-I$x_includes
  98.     else
  99.     XINCLUDES="# no special path needed"
  100.     fi
  101. fi
  102. if test "$XINCLUDES" = nope; then
  103.   echo "Warning:  couldn't find any X11 include files."
  104.   XINCLUDES="# no include files found"
  105. fi
  106. AC_SUBST(XINCLUDES)
  107.  
  108. if test "$no_x" = yes; then
  109.     XLIBSW=nope
  110.     if test "$XLIBSW" = nope; then
  111.     dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/lib/X11R4 /usr/X11R5/lib /usr/lib/X11R5 /usr/openwin/lib /usr/X11/lib /usr/sww/X11/lib"
  112.     for i in $dirs ; do
  113.         if test -r $i/libX11.a; then
  114.         XLIBSW="-L$i -lX11"
  115.         fi
  116.     done
  117.     fi
  118. else
  119.     if test "$x_libraries" = ""; then
  120.     XLIBSW=-lX11
  121.     else
  122.     XLIBSW="-L$x_libraries -lX11"
  123.     fi
  124. fi
  125. if test "$XLIBSW" = nope ; then
  126.     AC_CHECK_LIB(Xwindow, XCreateWindow, XLIBSW=-lXwindow)
  127. fi
  128. if test "$XLIBSW" = nope ; then
  129.     echo "Warning:  couldn't find the X11 library archive.  Using -lX11."
  130.     XLIBSW=-lX11
  131. fi
  132. AC_SUBST(XLIBSW)
  133.  
  134. #--------------------------------------------------------------------
  135. #    Check for the existence of various libraries.  The order here
  136. #    is important, so that then end up in the right order in the
  137. #    command line generated by make.  The -lsocket and -lnsl libraries
  138. #    require a couple of special tricks:
  139. #    1. Use "connect" and "accept" to check for -lsocket, and
  140. #       "gethostbyname" to check for -lnsl.
  141. #    2. Use each function name only once:  can't redo a check because
  142. #       autoconf caches the results of the last check and won't redo it.
  143. #    3. Use -lnsl and -lsocket only if they supply procedures that
  144. #       aren't already present in the normal libraries.  This is because
  145. #       IRIX 5.2 has libraries, but they aren't needed and they're
  146. #       bogus:  they goof up name resolution if used.
  147. #    4. On some SVR4 systems, can't use -lsocket without -lnsl too.
  148. #       To get around this problem, check for both libraries together
  149. #       if -lsocket doesn't work by itself.
  150. #--------------------------------------------------------------------
  151.  
  152. AC_CHECK_LIB(Xbsd, main, [LIBS="$LIBS -lXbsd"])
  153.  
  154. tk_checkBoth=0
  155. AC_CHECK_FUNC(connect, tk_checkSocket=0, tk_checkSocket=1)
  156. if test "$tk_checkSocket" = 1; then
  157.     AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", tk_checkBoth=1)
  158. fi
  159. if test "$tk_checkBoth" = 1; then
  160.     tk_oldLibs=$LIBS
  161.     LIBS="$LIBS -lsocket -lnsl"
  162.     AC_CHECK_FUNC(accept, tk_checkNsl=0, [LIBS=$tk_oldLibs])
  163. fi
  164. AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
  165.  
  166. #--------------------------------------------------------------------
  167. # One more check related to the X libraries.  The standard releases
  168. # of Ultrix don't support the "xauth" mechanism, so send won't work
  169. # unless TK_NO_SECURITY is defined.  However, there are usually copies
  170. # of the MIT X server available as well, which do support xauth.
  171. # Check for the MIT stuff and use it if it exists.
  172. #
  173. # Note: can't use ac_check_lib macro (at least, not in Autoconf 2.1)
  174. # because it can't deal with the "-" in the library name.
  175. #--------------------------------------------------------------------
  176.  
  177. if test -d /usr/include/mit ; then
  178.     AC_MSG_CHECKING([MIT X libraries])
  179.     tk_oldCFlags=$CFLAGS
  180.     CFLAGS="$CFLAGS -I/usr/include/mit"
  181.     tk_oldLibs=$LIBS
  182.     LIBS="$LIBS -lX11-mit"
  183.     AC_TRY_LINK([
  184.     #include <X11/Xlib.h>
  185.     ], [
  186.     XOpenDisplay(0);
  187.     ], [
  188.     AC_MSG_RESULT(yes)
  189.     XLIBSW="-lX11-mit"
  190.     XINCLUDES="-I/usr/include/mit"
  191.     ], AC_MSG_RESULT(no))
  192.     CFLAGS=$tk_oldCFlags
  193.     LIBS=$tk_oldLibs
  194. fi
  195.  
  196. #--------------------------------------------------------------------
  197. #    Figure out how to find out whether a FILE structure contains
  198. #    buffered readable data.  Some known names for the count field:
  199. #        _cnt:        Most UNIX systems
  200. #        __cnt:        HPUX
  201. #        _r:        BSD
  202. #        readCount:    Sprite
  203. #    Or, in GNU libc there are two fields, _gptr and _egptr, which
  204. #    have to be compared.
  205. #--------------------------------------------------------------------
  206.  
  207. AC_MSG_CHECKING([count field in FILE structures])
  208. AC_TRY_COMPILE([#include <stdio.h>],
  209.     [FILE *f = stdin; f->_cnt = 0;], fcnt="_cnt", )
  210. if test "$fcnt" = ""; then
  211.     AC_TRY_COMPILE([#include <stdio.h>],
  212.     [FILE *f = stdin; f->__cnt = 0;], fcnt="__cnt", )
  213. fi
  214. if test "$fcnt" = ""; then
  215.     AC_TRY_COMPILE([#include <stdio.h>],
  216.     [FILE *f = stdin; f->_r = 0;], fcnt="_r", )
  217. fi
  218. if test "$fcnt" = ""; then
  219.     AC_TRY_COMPILE([#include <stdio.h>],
  220.     [FILE *f = stdin; f->readCount = 0;], fcnt="readCount", )
  221. fi
  222. if test "$fcnt" != ""; then
  223.     AC_DEFINE_UNQUOTED(TK_FILE_COUNT, $fcnt)
  224. fi
  225. if test "$fcnt" = ""; then
  226.     AC_TRY_COMPILE([#include <stdio.h>],
  227.     [FILE *f = stdin; f->_gptr = f->egptr;],
  228.     tk_ok=yes, tk_ok=no)
  229.     if test $tk_ok = yes; then
  230.     AC_DEFINE(TK_FILE_GPTR)
  231.     fcnt="_gptr/_egptr"
  232.     fi
  233. fi
  234. if test "$fcnt" = ""; then
  235.     AC_TRY_COMPILE([#include <stdio.h>],
  236.     [FILE *f = stdin; f->_IO_read_ptr = f->_IO_read_end;],
  237.     tk_ok=yes, tk_ok=no)
  238.     if test $tk_ok = yes; then
  239.     AC_DEFINE(TK_FILE_READ_PTR)
  240.     fcnt="_IO_read_ptr/_IO_read_end"
  241.     fi
  242. fi
  243. if test "$fcnt" = ""; then
  244.     AC_MSG_RESULT([not found; must supply TkReadDataPending procedure])
  245. else
  246.     AC_MSG_RESULT("$fcnt")
  247. fi
  248.  
  249. #--------------------------------------------------------------------
  250. #    On a few very rare systems, all of the libm.a stuff is
  251. #    already in libc.a.  Set compiler flags accordingly.
  252. #    Also, Linux requires the "ieee" library for math to
  253. #    work right (and it must appear before "-lm").
  254. #--------------------------------------------------------------------
  255.  
  256. MATH_LIBS=""
  257. AC_CHECK_FUNC(sin, , MATH_LIBS="-lm")
  258. AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
  259. AC_SUBST(MATH_LIBS)
  260.  
  261. #--------------------------------------------------------------------
  262. #    If this system doesn't have a memmove procedure, use memcpy
  263. #    instead.
  264. #--------------------------------------------------------------------
  265.  
  266. AC_CHECK_FUNC(memmove, , [AC_DEFINE(memmove, memcpy)])
  267.  
  268. #--------------------------------------------------------------------
  269. #    Figure out whether "char" is unsigned.  If so, set a
  270. #    #define.
  271. #--------------------------------------------------------------------
  272.  
  273. AC_MSG_CHECKING(type of "char")
  274. AC_TRY_RUN([
  275. int main()
  276. {
  277.     char c;
  278.     int i;
  279.     c = 0377;
  280.     i = c;
  281.     if (i == -1) {
  282.     exit(0);
  283.     }
  284.     exit(1);
  285. }], tk_signed=1, tk_signed=0)
  286. if test $tk_signed = 0; then
  287.     AC_DEFINE(CHAR_UNSIGNED)
  288.     AC_MSG_RESULT(unsigned)
  289. else
  290.     AC_MSG_RESULT(signed)
  291. fi
  292.  
  293. #--------------------------------------------------------------------
  294. #    SGI systems don't use the BSD form of the gettimeofday function,
  295. #    but they have a BSDgettimeofday function that can be used instead.
  296. #
  297. #    Also, check for the existence of a gettimeofday declaration,
  298. #    to tkPort.h can declare it if it isn't already declared.
  299. #--------------------------------------------------------------------
  300.  
  301. AC_CHECK_FUNC(BSDgettimeofday, AC_DEFINE(HAVE_BSDGETTIMEOFDAY))
  302. AC_MSG_CHECKING([for gettimeofday declaration])
  303. AC_EGREP_HEADER(gettimeofday, sys/time.h, AC_MSG_RESULT(present), [
  304.     AC_MSG_RESULT(missing)
  305.     AC_DEFINE(GETTOD_NOT_DECLARED)
  306. ])
  307.  
  308. #--------------------------------------------------------------------
  309. #    Under Solaris 2.4, strtod returns the wrong value for the
  310. #    terminating character under some conditions.  Check for this
  311. #    and if the problem exists use a substitute procedure
  312. #    "fixstrtod" (provided by Tcl) that corrects the error.
  313. #--------------------------------------------------------------------
  314.  
  315. AC_CHECK_FUNC(strtod, tk_strtod=1, tk_strtod=0)
  316. if test "$tk_strtod" = 1; then
  317.     AC_MSG_CHECKING([for Solaris 2.4 strtod bug])
  318.     AC_TRY_RUN([
  319.     extern double strtod();
  320.     int main()
  321.     {
  322.         char *string = "NaN";
  323.         char *term;
  324.         strtod(string, &term);
  325.         if ((term != string) && (term[-1] == 0)) {
  326.         exit(1);
  327.         }
  328.         exit(0);
  329.     }], AC_MSG_RESULT(ok), [
  330.         AC_MSG_RESULT(buggy)
  331.         AC_DEFINE(strtod, fixstrtod)
  332.     ])
  333. fi
  334.  
  335. AC_OUTPUT(Makefile)
  336.