home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tcl7.4 / configure.in < prev    next >
Encoding:
Text File  |  1995-06-30  |  10.4 KB  |  334 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 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_C_CROSS
  11. CC=${CC-cc}
  12. AC_SUBST(CC)
  13.  
  14. #--------------------------------------------------------------------
  15. #    Supply substitutes for missing POSIX library procedures, or
  16. #    set flags so Tcl uses alternate procedures.
  17. #--------------------------------------------------------------------
  18.  
  19. AC_REPLACE_FUNCS(getcwd opendir strerror strstr)
  20. AC_REPLACE_FUNCS(strtol tmpnam waitpid)
  21. AC_CHECK_FUNC(getwd, , AC_DEFINE(NO_GETWD))
  22. AC_CHECK_FUNC(wait3, , AC_DEFINE(NO_WAIT3))
  23.  
  24. #--------------------------------------------------------------------
  25. #    On a few very rare systems, all of the libm.a stuff is
  26. #    already in libc.a.  Set compiler flags accordingly.
  27. #    Also, Linux requires the "ieee" library for math to work
  28. #    right (and it must appear before "-lm").
  29. #--------------------------------------------------------------------
  30.  
  31. AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
  32. AC_SUBST(MATH_LIBS)
  33. AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
  34.  
  35. #--------------------------------------------------------------------
  36. #    Supply substitutes for missing POSIX header files.  Special
  37. #    notes:
  38. #        - Sprite's dirent.h exists but is bogus.
  39. #        - stdlib.h doesn't define strtol, strtoul, or
  40. #          strtod insome versions of SunOS
  41. #        - some versions of string.h don't declare procedures such
  42. #          as strstr
  43. #--------------------------------------------------------------------
  44.  
  45. AC_HAVE_HEADERS(unistd.h)
  46. AC_MSG_CHECKING(dirent.h)
  47. AC_TRY_LINK([#include <sys/types.h>
  48. #include <dirent.h>], [
  49. #ifndef _POSIX_SOURCE
  50. #   ifdef __Lynx__
  51.     /*
  52.      * Generate compilation error to make the test fail:  Lynx headers
  53.      * are only valid if really in the POSIX environment.
  54.      */
  55.  
  56.     missing_procedure();
  57. #   endif
  58. #endif
  59. DIR *d;
  60. struct dirent *entryPtr;
  61. char *p;
  62. d = opendir("foobar");
  63. entryPtr = readdir(d);
  64. p = entryPtr->d_name;
  65. closedir(d);
  66. ], tcl_ok=yes, tcl_ok=no)
  67. AC_EGREP_HEADER([Sprite version.* NOT POSIX], dirent.h, tcl_ok=no)
  68. if test $tcl_ok = no; then
  69.     AC_DEFINE(NO_DIRENT_H)
  70. fi
  71. AC_MSG_RESULT($tcl_ok)
  72. AC_CHECK_HEADER(errno.h, , AC_DEFINE(NO_ERRNO_H))
  73. AC_CHECK_HEADER(float.h, , AC_DEFINE(NO_FLOAT_H))
  74. AC_CHECK_HEADER(limits.h, , AC_DEFINE(NO_LIMITS_H))
  75. AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
  76. AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
  77. AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
  78. AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
  79. if test $tcl_ok = 0; then
  80.     AC_DEFINE(NO_STDLIB_H)
  81. fi
  82. AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
  83. AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
  84. AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
  85. if test $tcl_ok = 0; then
  86.     AC_DEFINE(NO_STRING_H)
  87. fi
  88. AC_CHECK_HEADER(sys/time.h, , AC_DEFINE(NO_SYS_TIME_H))
  89. AC_CHECK_HEADER(sys/wait.h, , AC_DEFINE(NO_SYS_WAIT_H))
  90.  
  91. #--------------------------------------------------------------------
  92. #    On some systems strstr is broken: it returns a pointer even
  93. #    even if the original string is empty.
  94. #--------------------------------------------------------------------
  95.  
  96. AC_MSG_CHECKING([proper strstr implementation])
  97. AC_TRY_RUN([
  98. extern int strstr();
  99. int main()
  100. {
  101.     exit(strstr("\0test", "test") ? 1 : 0);
  102. }
  103. ], tcl_ok=yes, tcl_ok=no)
  104. if test $tcl_ok = yes; then
  105.     AC_MSG_RESULT(yes)
  106. else
  107.     AC_MSG_RESULT([broken, using substitute])
  108.     LIBOBJS="$LIBOBJS strstr.o"
  109. fi
  110.  
  111. #--------------------------------------------------------------------
  112. #    Check for strtoul function.  This is tricky because under some
  113. #    versions of AIX strtoul returns an incorrect terminator
  114. #    pointer for the string "0".
  115. #--------------------------------------------------------------------
  116.  
  117. AC_CHECK_FUNC(strtoul, tcl_ok=1, tcl_ok=0)
  118. AC_TRY_RUN([
  119. extern int strtoul();
  120. int main()
  121. {
  122.     char *string = "0";
  123.     char *term;
  124.     int value;
  125.     value = strtoul(string, &term, 0);
  126.     if ((value != 0) || (term != (string+1))) {
  127.         exit(1);
  128.     }
  129.     exit(0);
  130. }], , tcl_ok=0)
  131. if test $tcl_ok = 0; then
  132.     test -n "$verbose" && echo "    Adding strtoul.o."
  133.     LIBOBJS="$LIBOBJS strtoul.o"
  134. fi
  135.  
  136. #--------------------------------------------------------------------
  137. #    Check for the strtod function.  This is tricky because in some
  138. #    versions of Linux strtod mis-parses strings starting with "+".
  139. #--------------------------------------------------------------------
  140.  
  141. AC_CHECK_FUNC(strtod, tcl_ok=1, tcl_ok=0)
  142. AC_TRY_RUN([
  143. extern double strtod();
  144. int main()
  145. {
  146.     char *string = " +69";
  147.     char *term;
  148.     double value;
  149.     value = strtod(string, &term);
  150.     if ((value != 69) || (term != (string+4))) {
  151.     exit(1);
  152.     }
  153.     exit(0);
  154. }], , tcl_ok=0)
  155. if test $tcl_ok = 0; then
  156.     test -n "$verbose" && echo "    Adding strtod.o."
  157.     LIBOBJS="$LIBOBJS strtod.o"
  158. fi
  159.  
  160. #--------------------------------------------------------------------
  161. #    Under Solaris 2.4, strtod returns the wrong value for the
  162. #    terminating character under some conditions.  Check for this
  163. #    and if the problem exists use a substitute procedure
  164. #    "fixstrtod" that corrects the error.
  165. #--------------------------------------------------------------------
  166.  
  167. AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
  168. if test "$tcl_strtod" = 1; then
  169.     AC_MSG_CHECKING([for Solaris strtod bug])
  170.     AC_TRY_RUN([
  171.     extern double strtod();
  172.     int main()
  173.     {
  174.         char *string = "NaN";
  175.         char *term;
  176.         strtod(string, &term);
  177.         if ((term != string) && (term[-1] == 0)) {
  178.         exit(1);
  179.         }
  180.         exit(0);
  181.     }], AC_MSG_RESULT(ok), [
  182.         AC_MSG_RESULT(buggy)
  183.         LIBOBJS="$LIBOBJS fixstrtod.o"
  184.         AC_DEFINE(strtod, fixstrtod)
  185.     ])
  186. fi
  187.  
  188. #--------------------------------------------------------------------
  189. #    Check for various typedefs and provide substitutes if
  190. #    they don't exist.
  191. #--------------------------------------------------------------------
  192.  
  193. AC_TYPE_MODE_T
  194. AC_TYPE_PID_T
  195. AC_TYPE_SIZE_T
  196. AC_TYPE_UID_T
  197.  
  198. #--------------------------------------------------------------------
  199. #    If a system doesn't have an opendir function (man, that's old!)
  200. #    then we have to supply a different version of dirent.h which
  201. #    is compatible with the substitute version of opendir that's
  202. #    provided.  This version only works with V7-style directories.
  203. #--------------------------------------------------------------------
  204.  
  205. AC_CHECK_FUNC(opendir, , AC_DEFINE(USE_DIRENT2_H))
  206.  
  207. #--------------------------------------------------------------------
  208. #    Check for the existence of sys_errlist (this is only needed if
  209. #    there's no strerror, but I don't know how to conditionalize the
  210. #    check).
  211. #--------------------------------------------------------------------
  212.  
  213. AC_MSG_CHECKING(sys_errlist)
  214. AC_TRY_LINK(, [
  215. extern char *sys_errlist[];
  216. extern int sys_nerr;
  217. sys_errlist[sys_nerr-1][0] = 0;
  218. ], tcl_ok=yes, tcl_ok=no)
  219. AC_MSG_RESULT($tcl_ok)
  220. if test $tcl_ok = no; then
  221.     AC_DEFINE(NO_SYS_ERRLIST)
  222. fi
  223.  
  224. #--------------------------------------------------------------------
  225. #    The check below checks whether <sys/wait.h> defines the type
  226. #    "union wait" correctly.  It's needed because of weirdness in
  227. #    HP-UX where "union wait" is defined in both the BSD and SYS-V
  228. #    environments.  Checking the usability of WIFEXITED seems to do
  229. #    the trick.
  230. #--------------------------------------------------------------------
  231.  
  232. AC_MSG_CHECKING([union wait])
  233. AC_TRY_LINK([#include <sys/types.h> 
  234. #include <sys/wait.h>], [
  235. union wait x;
  236. WIFEXITED(x);        /* Generates compiler error if WIFEXITED
  237.              * uses an int. */
  238. ], tcl_ok=yes, tcl_ok=no)
  239. AC_MSG_RESULT($tcl_ok)
  240. if test $tcl_ok = no; then
  241.     AC_DEFINE(NO_UNION_WAIT)
  242. fi
  243.  
  244. #--------------------------------------------------------------------
  245. #    Check to see whether the system supports the matherr function
  246. #    and its associated type "struct exception".
  247. #--------------------------------------------------------------------
  248.  
  249. AC_MSG_CHECKING([matherr support])
  250. AC_TRY_COMPILE([#include <math.h>], [
  251. struct exception x;
  252. x.type = DOMAIN;
  253. x.type = SING;
  254. ], tcl_ok=yes, tcl_ok=no)
  255. AC_MSG_RESULT($tcl_ok)
  256. if test $tcl_ok = yes; then
  257.     AC_DEFINE(NEED_MATHERR)
  258. fi
  259.  
  260. #--------------------------------------------------------------------
  261. #    Check to see whether the system provides a vfork kernel call.
  262. #    If not, then use fork instead.  Also, check for a problem with
  263. #    Solaris 2.4 and vforks and signals that can core dumps can occur
  264. #    if a vforked child resets a signal handler.  If the problem
  265. #    exists, then use fork instead of vfork.
  266. #--------------------------------------------------------------------
  267.  
  268. AC_CHECK_FUNC(vfork, tcl_ok=1, tcl_ok=0)
  269. if test "$tcl_ok" = 1; then
  270.     AC_MSG_CHECKING([Solaris 2.4 vfork/signal bug]);
  271.     AC_TRY_RUN([
  272.     #include <stdio.h>
  273.     #include <signal.h>
  274.     #include <sys/wait.h>
  275.     int gotSignal = 0;
  276.     sigProc(sig)
  277.         int sig;
  278.     {
  279.         gotSignal = 1;
  280.     }
  281.     main()
  282.     {
  283.         int pid, sts;
  284.         (void) signal(SIGCHLD, sigProc);
  285.         pid = vfork();
  286.         if (pid <  0) {
  287.         exit(1);
  288.         } else if (pid == 0) {
  289.         (void) signal(SIGCHLD, SIG_DFL);
  290.         _exit(0);
  291.         } else {
  292.         (void) wait(&sts);
  293.         }
  294.         exit((gotSignal) ? 0 : 1);
  295.     }], AC_MSG_RESULT(ok), [
  296.         AC_MSG_RESULT(buggy)
  297.         tcl_ok=0
  298.     ])
  299. fi
  300. rm -f core
  301. if test "$tcl_ok" = 0; then
  302.     AC_DEFINE(vfork, fork)
  303. fi
  304.  
  305. #--------------------------------------------------------------------
  306. #    Check whether there is an strncasecmp function on this system.
  307. #    This is a bit tricky because under SCO it's in the socket
  308. #    library.
  309. #--------------------------------------------------------------------
  310.  
  311. AC_CHECK_FUNC(strncasecmp, ,
  312.     AC_CHECK_LIB(socket, strncasecmp, , [LIBOBJS="$LIBOBJS strncasecmp.o"]))
  313.  
  314. #--------------------------------------------------------------------
  315. #    The code below deals with several issues related to gettimeofday:
  316. #    1. Some systems don't provide a gettimeofday function at all
  317. #       (set NO_GETTOD if this is the case).
  318. #    2. SGI systems don't use the BSD form of the gettimeofday function,
  319. #       but they have a BSDgettimeofday function that can be used instead.
  320. #    3. See if gettimeofday is declared in the <sys/time.h> header file.
  321. #       if not, set the GETTOD_NOT_DECLARED flag so that tclPort.h can
  322. #       declare it.
  323. #--------------------------------------------------------------------
  324.  
  325. AC_CHECK_FUNC(BSDgettimeofday, AC_DEFINE(HAVE_BSDGETTIMEOFDAY),
  326.     AC_CHECK_FUNC(gettimeofday, , AC_DEFINE(NO_GETTOD)))
  327. AC_MSG_CHECKING([for gettimeofday declaration])
  328. AC_EGREP_HEADER(gettimeofday, sys/time.h, AC_MSG_RESULT(present), [
  329.     AC_MSG_RESULT(missing)
  330.     AC_DEFINE(GETTOD_NOT_DECLARED)
  331. ])
  332.  
  333. AC_OUTPUT(Makefile)
  334.