home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / unix / configure.in next >
Encoding:
Text File  |  1997-08-15  |  36.3 KB  |  1,227 lines  |  [TEXT/ALFA]

  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(../generic/tcl.h)
  5. # SCCS: @(#) configure.in 1.140 97/08/12 10:36:18
  6.  
  7. TCL_VERSION=8.0
  8. TCL_MAJOR_VERSION=8
  9. TCL_MINOR_VERSION=0
  10. TCL_PATCH_LEVEL=""
  11. VERSION=${TCL_VERSION}
  12.  
  13. if test "${prefix}" = "NONE"; then
  14.     prefix=/usr/local
  15. fi
  16. if test "${exec_prefix}" = "NONE"; then
  17.     exec_prefix=$prefix
  18. fi
  19. TCL_SRC_DIR=`cd $srcdir/..; pwd`
  20.  
  21. AC_PROG_RANLIB
  22. AC_ARG_ENABLE(gcc, [  --enable-gcc            allow use of gcc if available],
  23.     [tcl_ok=$enableval], [tcl_ok=no])
  24. if test "$tcl_ok" = "yes"; then
  25.     AC_PROG_CC
  26. else
  27.     CC=${CC-cc}
  28. AC_SUBST(CC)
  29. fi
  30. AC_C_CROSS
  31.  
  32. #--------------------------------------------------------------------
  33. #    Supply substitutes for missing POSIX library procedures, or
  34. #    set flags so Tcl uses alternate procedures.
  35. #--------------------------------------------------------------------
  36.  
  37. # Check if Posix compliant getcwd exists, if not we'll use getwd.
  38. AC_CHECK_FUNCS(getcwd, , AC_DEFINE(USEGETWD))
  39. # Nb: if getcwd uses popen and pwd(1) (like Solaris) we should really
  40. # define USEGETWD even if the posix getcwd exists. Add a test ?
  41.  
  42. AC_REPLACE_FUNCS(opendir strstr)
  43.  
  44. AC_REPLACE_FUNCS(strtol tmpnam waitpid)
  45. AC_CHECK_FUNC(strerror, , AC_DEFINE(NO_STRERROR))
  46. AC_CHECK_FUNC(getwd, , AC_DEFINE(NO_GETWD))
  47. AC_CHECK_FUNC(wait3, , AC_DEFINE(NO_WAIT3))
  48. AC_CHECK_FUNC(uname, , AC_DEFINE(NO_UNAME))
  49.  
  50. #--------------------------------------------------------------------
  51. #    On a few very rare systems, all of the libm.a stuff is
  52. #    already in libc.a.  Set compiler flags accordingly.
  53. #    Also, Linux requires the "ieee" library for math to work
  54. #    right (and it must appear before "-lm").
  55. #--------------------------------------------------------------------
  56.  
  57. AC_CHECK_FUNC(sin, MATH_LIBS="", MATH_LIBS="-lm")
  58. AC_CHECK_LIB(ieee, main, [MATH_LIBS="-lieee $MATH_LIBS"])
  59.  
  60. #--------------------------------------------------------------------
  61. #       On AIX systems, libbsd.a has to be linked in to support
  62. #       non-blocking file IO.  This library has to be linked in after
  63. #       the MATH_LIBS or it breaks the pow() function.  The way to
  64. #       insure proper sequencing, is to add it to the tail of MATH_LIBS.
  65. #        This library also supplies gettimeofday.
  66. #--------------------------------------------------------------------
  67. libbsd=no
  68. if test "`uname -s`" = "AIX" ; then
  69.     AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes)
  70.     if test $libbsd = yes; then
  71.     MATH_LIBS="$MATH_LIBS -lbsd"
  72.     fi
  73. fi
  74.  
  75. #--------------------------------------------------------------------
  76. #    Supply substitutes for missing POSIX header files.  Special
  77. #    notes:
  78. #        - stdlib.h doesn't define strtol, strtoul, or
  79. #          strtod insome versions of SunOS
  80. #        - some versions of string.h don't declare procedures such
  81. #          as strstr
  82. #--------------------------------------------------------------------
  83.  
  84. AC_MSG_CHECKING(dirent.h)
  85. AC_TRY_LINK([#include <sys/types.h>
  86. #include <dirent.h>], [
  87. #ifndef _POSIX_SOURCE
  88. #   ifdef __Lynx__
  89.     /*
  90.      * Generate compilation error to make the test fail:  Lynx headers
  91.      * are only valid if really in the POSIX environment.
  92.      */
  93.  
  94.     missing_procedure();
  95. #   endif
  96. #endif
  97. DIR *d;
  98. struct dirent *entryPtr;
  99. char *p;
  100. d = opendir("foobar");
  101. entryPtr = readdir(d);
  102. p = entryPtr->d_name;
  103. closedir(d);
  104. ], tcl_ok=yes, tcl_ok=no)
  105. if test $tcl_ok = no; then
  106.     AC_DEFINE(NO_DIRENT_H)
  107. fi
  108. AC_MSG_RESULT($tcl_ok)
  109. AC_CHECK_HEADER(errno.h, , AC_DEFINE(NO_ERRNO_H))
  110. AC_CHECK_HEADER(float.h, , AC_DEFINE(NO_FLOAT_H))
  111. AC_CHECK_HEADER(values.h, , AC_DEFINE(NO_VALUES_H))
  112. AC_CHECK_HEADER(limits.h, , AC_DEFINE(NO_LIMITS_H))
  113. AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
  114. AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
  115. AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
  116. AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
  117. if test $tcl_ok = 0; then
  118.     AC_DEFINE(NO_STDLIB_H)
  119. fi
  120. AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
  121. AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
  122. AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0)
  123. if test $tcl_ok = 0; then
  124.     AC_DEFINE(NO_STRING_H)
  125. fi
  126. AC_CHECK_HEADER(sys/wait.h, , AC_DEFINE(NO_SYS_WAIT_H))
  127. AC_CHECK_HEADER(dlfcn.h, , AC_DEFINE(NO_DLFCN_H))
  128. AC_HAVE_HEADERS(unistd.h)
  129.  
  130. #---------------------------------------------------------------------------
  131. #    Determine which interface to use to talk to the serial port.
  132. #    Note that #include lines must begin in leftmost column for
  133. #    some compilers to recognize them as preprocessor directives.
  134. #---------------------------------------------------------------------------
  135.  
  136. AC_MSG_CHECKING([termios vs. termio vs. sgtty])
  137. AC_TRY_RUN([
  138. #include <termios.h>
  139.  
  140. main()
  141. {
  142.     struct termios t;
  143.     if (tcgetattr(0, &t) == 0) {
  144.     cfsetospeed(&t, 0);
  145.     t.c_cflag |= PARENB | PARODD | CSIZE | CSTOPB;
  146.     return 0;
  147.     }
  148.     return 1;
  149. }], tk_ok=termios, tk_ok=no, tk_ok=no)
  150. if test $tk_ok = termios; then
  151.     AC_DEFINE(USE_TERMIOS)
  152. else
  153. AC_TRY_RUN([
  154. #include <termio.h>
  155.  
  156. main()
  157. {
  158.     struct termio t;
  159.     if (ioctl(0, TCGETA, &t) == 0) {
  160.     t.c_cflag |= CBAUD | PARENB | PARODD | CSIZE | CSTOPB;
  161.     return 0;
  162.     }
  163.     return 1;
  164. }], tk_ok=termio, tk_ok=no, tk_ok=no)
  165. if test $tk_ok = termio; then
  166.     AC_DEFINE(USE_TERMIO)
  167. else
  168. AC_TRY_RUN([
  169. #include <sgtty.h>
  170.  
  171. main()
  172. {
  173.     struct sgttyb t;
  174.     if (ioctl(0, TIOCGETP, &t) == 0) {
  175.     t.sg_ospeed = 0;
  176.     t.sg_flags |= ODDP | EVENP | RAW;
  177.     return 0;
  178.     }
  179.     return 1;
  180. }], tk_ok=sgtty, tk_ok=none, tk_ok=none)
  181. if test $tk_ok = sgtty; then
  182.     AC_DEFINE(USE_SGTTY)
  183. fi
  184. fi
  185. fi
  186. AC_MSG_RESULT($tk_ok)
  187.  
  188. #--------------------------------------------------------------------
  189. #    Include sys/select.h if it exists and if it supplies things
  190. #    that appear to be useful and aren't already in sys/types.h.
  191. #    This appears to be true only on the RS/6000 under AIX.  Some
  192. #    systems like OSF/1 have a sys/select.h that's of no use, and
  193. #    other systems like SCO UNIX have a sys/select.h that's
  194. #    pernicious.  If "fd_set" isn't defined anywhere then set a
  195. #    special flag.
  196. #--------------------------------------------------------------------
  197.  
  198. AC_MSG_CHECKING([fd_set and sys/select])
  199. AC_TRY_COMPILE([#include <sys/types.h>],
  200.     [fd_set readMask, writeMask;], tk_ok=yes, tk_ok=no)
  201. if test $tk_ok = no; then
  202.     AC_HEADER_EGREP(fd_mask, sys/select.h, tk_ok=yes)
  203.     if test $tk_ok = yes; then
  204.     AC_DEFINE(HAVE_SYS_SELECT_H)
  205.     fi
  206. fi
  207. AC_MSG_RESULT($tk_ok)
  208. if test $tk_ok = no; then
  209.     AC_DEFINE(NO_FD_SET)
  210. fi
  211.  
  212. #------------------------------------------------------------------------------
  213. #       Find out all about time handling differences.
  214. #------------------------------------------------------------------------------
  215.  
  216. AC_CHECK_HEADERS(sys/time.h)
  217. AC_HEADER_TIME
  218. AC_STRUCT_TIMEZONE
  219.  
  220. AC_MSG_CHECKING([tm_tzadj in struct tm])
  221. AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_tzadj;],
  222.         [AC_DEFINE(HAVE_TM_TZADJ)
  223.          AC_MSG_RESULT(yes)],
  224.          AC_MSG_RESULT(no))
  225.  
  226. AC_MSG_CHECKING([tm_gmtoff in struct tm])
  227. AC_TRY_COMPILE([#include <time.h>], [struct tm tm; tm.tm_gmtoff;],
  228.         [AC_DEFINE(HAVE_TM_GMTOFF)
  229.          AC_MSG_RESULT(yes)],
  230.          AC_MSG_RESULT(no))
  231.  
  232. #
  233. # Its important to include time.h in this check, as some systems (like convex)
  234. # have timezone functions, etc.
  235. #
  236. have_timezone=no
  237. AC_MSG_CHECKING([long timezone variable])
  238. AC_TRY_COMPILE([#include <time.h>],
  239.         [extern long timezone;
  240.          timezone += 1;
  241.          exit (0);],
  242.         [have_timezone=yes
  243.      AC_DEFINE(HAVE_TIMEZONE_VAR)
  244.          AC_MSG_RESULT(yes)],
  245.          AC_MSG_RESULT(no))
  246.  
  247. #
  248. # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
  249. #
  250. if test "$have_timezone" = no; then
  251.    AC_MSG_CHECKING([time_t timezone variable])
  252.    AC_TRY_COMPILE([#include <time.h>],
  253.         [extern time_t timezone;
  254.          timezone += 1;
  255.          exit (0);],
  256.         [AC_DEFINE(HAVE_TIMEZONE_VAR)
  257.          AC_MSG_RESULT(yes)],
  258.          AC_MSG_RESULT(no))
  259. fi
  260.  
  261. #
  262. # AIX does not have a timezone field in struct tm. When the AIX bsd
  263. # library is used, the timezone global and the gettimeofday methods are
  264. # to be avoided for timezone deduction instead, we deduce the timezone
  265. # by comparing the localtime result on a known GMT value.
  266. #
  267. if test $libbsd = yes; then
  268.     AC_DEFINE(USE_DELTA_FOR_TZ)
  269. fi
  270.  
  271. #--------------------------------------------------------------------
  272. #    On some systems strstr is broken: it returns a pointer even
  273. #    even if the original string is empty.
  274. #--------------------------------------------------------------------
  275.  
  276. AC_MSG_CHECKING([proper strstr implementation])
  277. AC_TRY_RUN([
  278. extern int strstr();
  279. int main()
  280. {
  281.     exit(strstr("\0test", "test") ? 1 : 0);
  282. }
  283. ], tcl_ok=yes, tcl_ok=no, tcl_ok=no)
  284. if test $tcl_ok = yes; then
  285.     AC_MSG_RESULT(yes)
  286. else
  287.     AC_MSG_RESULT([broken, using substitute])
  288.     LIBOBJS="$LIBOBJS strstr.o"
  289. fi
  290.  
  291. #--------------------------------------------------------------------
  292. #    Check for strtoul function.  This is tricky because under some
  293. #    versions of AIX strtoul returns an incorrect terminator
  294. #    pointer for the string "0".
  295. #--------------------------------------------------------------------
  296.  
  297. AC_CHECK_FUNC(strtoul, tcl_ok=1, tcl_ok=0)
  298. AC_TRY_RUN([
  299. extern int strtoul();
  300. int main()
  301. {
  302.     char *string = "0";
  303.     char *term;
  304.     int value;
  305.     value = strtoul(string, &term, 0);
  306.     if ((value != 0) || (term != (string+1))) {
  307.         exit(1);
  308.     }
  309.     exit(0);
  310. }], , tcl_ok=0, tcl_ok=0)
  311. if test "$tcl_ok" = 0; then
  312.     test -n "$verbose" && echo "    Adding strtoul.o."
  313.     LIBOBJS="$LIBOBJS strtoul.o"
  314. fi
  315.  
  316. #--------------------------------------------------------------------
  317. #    Check for the strtod function.  This is tricky because in some
  318. #    versions of Linux strtod mis-parses strings starting with "+".
  319. #--------------------------------------------------------------------
  320.  
  321. AC_CHECK_FUNC(strtod, tcl_ok=1, tcl_ok=0)
  322. AC_TRY_RUN([
  323. extern double strtod();
  324. int main()
  325. {
  326.     char *string = " +69";
  327.     char *term;
  328.     double value;
  329.     value = strtod(string, &term);
  330.     if ((value != 69) || (term != (string+4))) {
  331.     exit(1);
  332.     }
  333.     exit(0);
  334. }], , tcl_ok=0, tcl_ok=0)
  335. if test "$tcl_ok" = 0; then
  336.     test -n "$verbose" && echo "    Adding strtod.o."
  337.     LIBOBJS="$LIBOBJS strtod.o"
  338. fi
  339.  
  340. #--------------------------------------------------------------------
  341. #    Under Solaris 2.4, strtod returns the wrong value for the
  342. #    terminating character under some conditions.  Check for this
  343. #    and if the problem exists use a substitute procedure
  344. #    "fixstrtod" that corrects the error.
  345. #--------------------------------------------------------------------
  346.  
  347. AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
  348. if test "$tcl_strtod" = 1; then
  349.     AC_MSG_CHECKING([for Solaris strtod bug])
  350.     AC_TRY_RUN([
  351. extern double strtod();
  352. int main()
  353. {
  354.     char *string = "NaN";
  355.     char *term;
  356.     strtod(string, &term);
  357.     if ((term != string) && (term[-1] == 0)) {
  358.     exit(1);
  359.     }
  360.     exit(0);
  361. }], tcl_ok=1, tcl_ok=0, tcl_ok=0)
  362.     if test $tcl_ok = 1; then
  363.     AC_MSG_RESULT(ok)
  364.     else
  365.     AC_MSG_RESULT(buggy)
  366.     LIBOBJS="$LIBOBJS fixstrtod.o"
  367.     AC_DEFINE(strtod, fixstrtod)
  368.     fi
  369. fi
  370.  
  371. #--------------------------------------------------------------------
  372. #    Check for various typedefs and provide substitutes if
  373. #    they don't exist.
  374. #--------------------------------------------------------------------
  375.  
  376. AC_TYPE_MODE_T
  377. AC_TYPE_PID_T
  378. AC_TYPE_SIZE_T
  379. AC_TYPE_UID_T
  380.  
  381. #--------------------------------------------------------------------
  382. #    If a system doesn't have an opendir function (man, that's old!)
  383. #    then we have to supply a different version of dirent.h which
  384. #    is compatible with the substitute version of opendir that's
  385. #    provided.  This version only works with V7-style directories.
  386. #--------------------------------------------------------------------
  387.  
  388. AC_CHECK_FUNC(opendir, , AC_DEFINE(USE_DIRENT2_H))
  389.  
  390. #--------------------------------------------------------------------
  391. #    The check below checks whether <sys/wait.h> defines the type
  392. #    "union wait" correctly.  It's needed because of weirdness in
  393. #    HP-UX where "union wait" is defined in both the BSD and SYS-V
  394. #    environments.  Checking the usability of WIFEXITED seems to do
  395. #    the trick.
  396. #--------------------------------------------------------------------
  397.  
  398. AC_MSG_CHECKING([union wait])
  399. AC_TRY_LINK([#include <sys/types.h> 
  400. #include <sys/wait.h>], [
  401. union wait x;
  402. WIFEXITED(x);        /* Generates compiler error if WIFEXITED
  403.              * uses an int. */
  404. ], tcl_ok=yes, tcl_ok=no)
  405. AC_MSG_RESULT($tcl_ok)
  406. if test $tcl_ok = no; then
  407.     AC_DEFINE(NO_UNION_WAIT)
  408. fi
  409.  
  410. #--------------------------------------------------------------------
  411. #    Check to see whether the system supports the matherr function
  412. #    and its associated type "struct exception".
  413. #--------------------------------------------------------------------
  414.  
  415. AC_MSG_CHECKING([matherr support])
  416. AC_TRY_COMPILE([#include <math.h>], [
  417. struct exception x;
  418. x.type = DOMAIN;
  419. x.type = SING;
  420. ], tcl_ok=yes, tcl_ok=no)
  421. AC_MSG_RESULT($tcl_ok)
  422. if test $tcl_ok = yes; then
  423.     AC_DEFINE(NEED_MATHERR)
  424. fi
  425.  
  426. #--------------------------------------------------------------------
  427. #    Check to see whether the system provides a vfork kernel call.
  428. #    If not, then use fork instead.  Also, check for a problem with
  429. #    vforks and signals that can cause core dumps if a vforked child
  430. #    resets a signal handler.  If the problem exists, then use fork
  431. #    instead of vfork.
  432. #--------------------------------------------------------------------
  433.  
  434. AC_CHECK_FUNC(vfork, tcl_ok=1, tcl_ok=0)
  435. if test "$tcl_ok" = 1; then
  436.     AC_MSG_CHECKING([vfork/signal bug]);
  437.     AC_TRY_RUN([
  438. #include <stdio.h>
  439. #include <signal.h>
  440. #include <sys/wait.h>
  441. int gotSignal = 0;
  442. sigProc(sig)
  443.     int sig;
  444. {
  445.     gotSignal = 1;
  446. }
  447. main()
  448. {
  449.     int pid, sts;
  450.     (void) signal(SIGCHLD, sigProc);
  451.     pid = vfork();
  452.     if (pid <  0) {
  453.     exit(1);
  454.     } else if (pid == 0) {
  455.     (void) signal(SIGCHLD, SIG_DFL);
  456.     _exit(0);
  457.     } else {
  458.     (void) wait(&sts);
  459.     }
  460.     exit((gotSignal) ? 0 : 1);
  461. }], tcl_ok=1, tcl_ok=0, tcl_ok=0)
  462.     if test "$tcl_ok" = 1; then
  463.     AC_MSG_RESULT(ok)
  464.     else
  465.     AC_MSG_RESULT([buggy, using fork instead])
  466.     fi
  467. fi
  468. rm -f core
  469. if test "$tcl_ok" = 0; then
  470.     AC_DEFINE(vfork, fork)
  471. fi
  472.  
  473. #--------------------------------------------------------------------
  474. #    Check whether there is an strncasecmp function on this system.
  475. #    This is a bit tricky because under SCO it's in -lsocket and
  476. #    under Sequent Dynix it's in -linet.
  477. #--------------------------------------------------------------------
  478.  
  479. AC_CHECK_FUNC(strncasecmp, tcl_ok=1, tcl_ok=0)
  480. if test "$tcl_ok" = 0; then
  481.     AC_CHECK_LIB(socket, strncasecmp, tcl_ok=1, tcl_ok=0)
  482. fi
  483. if test "$tcl_ok" = 0; then
  484.     AC_CHECK_LIB(inet, strncasecmp, tcl_ok=1, tcl_ok=0)
  485. fi
  486. if test "$tcl_ok" = 0; then
  487.     LIBOBJS="$LIBOBJS strncasecmp.o"
  488. fi
  489.  
  490. #--------------------------------------------------------------------
  491. #    The code below deals with several issues related to gettimeofday:
  492. #    1. Some systems don't provide a gettimeofday function at all
  493. #       (set NO_GETTOD if this is the case).
  494. #    2. SGI systems don't use the BSD form of the gettimeofday function,
  495. #       but they have a BSDgettimeofday function that can be used instead.
  496. #    3. See if gettimeofday is declared in the <sys/time.h> header file.
  497. #       if not, set the GETTOD_NOT_DECLARED flag so that tclPort.h can
  498. #       declare it.
  499. #--------------------------------------------------------------------
  500.  
  501. AC_CHECK_FUNC(BSDgettimeofday, AC_DEFINE(HAVE_BSDGETTIMEOFDAY),
  502.     AC_CHECK_FUNC(gettimeofday, , AC_DEFINE(NO_GETTOD)))
  503. AC_MSG_CHECKING([for gettimeofday declaration])
  504. AC_EGREP_HEADER(gettimeofday, sys/time.h, AC_MSG_RESULT(present), [
  505.     AC_MSG_RESULT(missing)
  506.     AC_DEFINE(GETTOD_NOT_DECLARED)
  507. ])
  508.  
  509. #--------------------------------------------------------------------
  510. #    Interactive UNIX requires -linet instead of -lsocket, plus it
  511. #    needs net/errno.h to define the socket-related error codes.
  512. #--------------------------------------------------------------------
  513.  
  514. AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
  515. AC_CHECK_HEADER(net/errno.h, AC_DEFINE(HAVE_NET_ERRNO_H))
  516.  
  517. #--------------------------------------------------------------------
  518. #    The following code checks to see whether it is possible to get
  519. #    signed chars on this platform.  This is needed in order to
  520. #    properly generate sign-extended ints from character values.
  521. #--------------------------------------------------------------------
  522.  
  523. AC_C_CHAR_UNSIGNED
  524. AC_MSG_CHECKING([signed char declarations])
  525. AC_TRY_COMPILE(, [
  526. signed char *p;
  527. p = 0;
  528. ], tcl_ok=yes, tcl_ok=no)
  529. AC_MSG_RESULT($tcl_ok)
  530. if test $tcl_ok = yes; then
  531.     AC_DEFINE(HAVE_SIGNED_CHAR)
  532. fi
  533.  
  534. #--------------------------------------------------------------------
  535. #    Check for the existence of the -lsocket and -lnsl libraries.
  536. #    The order here is important, so that they end up in the right
  537. #    order in the command line generated by make.  Here are some
  538. #    special considerations:
  539. #    1. Use "connect" and "accept" to check for -lsocket, and
  540. #       "gethostbyname" to check for -lnsl.
  541. #    2. Use each function name only once:  can't redo a check because
  542. #       autoconf caches the results of the last check and won't redo it.
  543. #    3. Use -lnsl and -lsocket only if they supply procedures that
  544. #       aren't already present in the normal libraries.  This is because
  545. #       IRIX 5.2 has libraries, but they aren't needed and they're
  546. #       bogus:  they goof up name resolution if used.
  547. #    4. On some SVR4 systems, can't use -lsocket without -lnsl too.
  548. #       To get around this problem, check for both libraries together
  549. #       if -lsocket doesn't work by itself.
  550. #--------------------------------------------------------------------
  551.  
  552. tcl_checkBoth=0
  553. AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
  554. if test "$tcl_checkSocket" = 1; then
  555.     AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", tcl_checkBoth=1)
  556. fi
  557. if test "$tcl_checkBoth" = 1; then
  558.     tk_oldLibs=$LIBS
  559.     LIBS="$LIBS -lsocket -lnsl"
  560.     AC_CHECK_FUNC(accept, tcl_checkNsl=0, [LIBS=$tk_oldLibs])
  561. fi
  562. AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
  563.  
  564. #--------------------------------------------------------------------
  565. #    The statements below define a collection of symbols related to
  566. #    dynamic loading and shared libraries:
  567. #
  568. #    DL_OBJS -    Name of the object file that implements dynamic
  569. #            loading for Tcl on this system.
  570. #    DL_LIBS -    Library file(s) to include in tclsh and other base
  571. #            applications in order for the "load" command to work.
  572. #    LD_FLAGS -    Flags to pass to the compiler when linking object
  573. #            files into an executable application binary such
  574. #            as tclsh.
  575. #    LD_SEARCH_FLAGS-Flags to pass to ld, such as "-R /usr/local/tcl/lib",
  576. #            that tell the run-time dynamic linker where to look
  577. #            for shared libraries such as libtcl.so.  Depends on
  578. #            the variable LIB_RUNTIME_DIR in the Makefile.
  579. #    MAKE_LIB -    Command to execute to build the Tcl library;
  580. #            differs depending on whether or not Tcl is being
  581. #            compiled as a shared library.
  582. #    SHLIB_CFLAGS -    Flags to pass to cc when compiling the components
  583. #            of a shared library (may request position-independent
  584. #            code, among other things).
  585. #    SHLIB_LD -    Base command to use for combining object files
  586. #            into a shared library.
  587. #    SHLIB_LD_LIBS -    Dependent libraries for the linker to scan when
  588. #            creating shared libraries.  This symbol typically
  589. #            goes at the end of the "ld" commands that build
  590. #            shared libraries. The value of the symbol is
  591. #            "${LIBS}" if all of the dependent libraries should
  592. #            be specified when creating a shared library.  If
  593. #            dependent libraries should not be specified (as on
  594. #            SunOS 4.x, where they cause the link to fail, or in
  595. #            general if Tcl and Tk aren't themselves shared
  596. #            libraries), then this symbol has an empty string
  597. #            as its value.
  598. #    SHLIB_SUFFIX -    Suffix to use for the names of dynamically loadable
  599. #            extensions.  An empty string means we don't know how
  600. #            to use shared libraries on this platform.
  601. #    TCL_LIB_FILE -    Name of the file that contains the Tcl library, such
  602. #            as libtcl7.8.so or libtcl7.8.a.
  603. #    TCL_LIB_SUFFIX -Specifies everything that comes after the "libtcl"
  604. #            in the shared library name, using the $VERSION variable
  605. #            to put the version in the right place.  This is used
  606. #            by platforms that need non-standard library names.
  607. #            Examples:  ${VERSION}.so.1.1 on NetBSD, since it needs
  608. #            to have a version after the .so, and ${VERSION}.a
  609. #            on AIX, since the Tcl shared library needs to have
  610. #            a .a extension whereas shared objects for loadable
  611. #            extensions have a .so extension.  Defaults to
  612. #            ${VERSION}${SHLIB_SUFFIX}.
  613. #--------------------------------------------------------------------
  614.  
  615. # Step 1: set the variable "system" to hold the name and version number
  616. # for the system.  This can usually be done via the "uname" command, but
  617. # there are a few systems, like Next, where this doesn't work.
  618.  
  619. AC_MSG_CHECKING([system version (for dynamic loading)])
  620. if test -f /usr/lib/NextStep/software_version; then
  621.     system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
  622. else
  623.     system=`uname -s`-`uname -r`
  624.     if test "$?" -ne 0 ; then
  625.     AC_MSG_RESULT([unknown (can't find uname command)])
  626.     system=unknown
  627.     else
  628.     # Special check for weird MP-RAS system (uname returns weird
  629.     # results, and the version is kept in special file).
  630.     
  631.     if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
  632.         system=MP-RAS-`awk '{print $3}' /etc/.relid'`
  633.     fi
  634.     if test "`uname -s`" = "AIX" ; then
  635.         system=AIX-`uname -v`.`uname -r`
  636.     fi
  637.     AC_MSG_RESULT($system)
  638.     fi
  639. fi
  640.  
  641. # Step 2: check for existence of -ldl library.  This is needed because
  642. # Linux can use either -ldl or -ldld for dynamic loading.
  643.  
  644. AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
  645.  
  646. # Step 3: set configuration options based on system name and version.
  647.  
  648. fullSrcDir=`cd $srcdir; pwd`
  649. TCL_SHARED_LIB_SUFFIX=""
  650. TCL_UNSHARED_LIB_SUFFIX=""
  651. TCL_LIB_VERSIONS_OK=ok
  652. case $system in
  653.     AIX-4.[[2-9]])
  654.     SHLIB_CFLAGS=""
  655.     SHLIB_LD="$fullSrcDir/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
  656.     SHLIB_LD_LIBS='${LIBS}'
  657.     SHLIB_SUFFIX=".so"
  658.     DL_OBJS="tclLoadDl.o"
  659.     DL_LIBS="-ldl"
  660.     LD_FLAGS=""
  661.     LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  662.     AIX=yes
  663.     TCL_SHARED_LIB_SUFFIX='${VERSION}.a'
  664.     ;;
  665.     AIX-*)
  666.     SHLIB_CFLAGS=""
  667.     SHLIB_LD="$fullSrcDir/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
  668.     SHLIB_LD_LIBS='${LIBS}'
  669.     SHLIB_SUFFIX=".so"
  670.     DL_OBJS="tclLoadDl.o tclLoadAix.o"
  671.     DL_LIBS="-lld"
  672.     LD_FLAGS=""
  673.     LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  674.     TCL_SHARED_LIB_SUFFIX='${VERSION}.a'
  675.     ;;
  676.     BSD/OS-2.1*|BSD/OS-3*)
  677.     SHLIB_CFLAGS=""
  678.     SHLIB_LD="shlicc -r"
  679.     SHLIB_LD_LIBS='${LIBS}'
  680.     SHLIB_SUFFIX=".so"
  681.     DL_OBJS="tclLoadDl.o"
  682.     DL_LIBS="-ldl"
  683.     LD_FLAGS=""
  684.     LD_SEARCH_FLAGS=""
  685.     ;;
  686.     dgux*)
  687.     SHLIB_CFLAGS="-K PIC"
  688.     SHLIB_LD="cc -G"
  689.     SHLIB_LD_LIBS=""
  690.     SHLIB_SUFFIX=".so"
  691.     DL_OBJS="tclLoadDl.o"
  692.     DL_LIBS="-ldl"
  693.     LD_FLAGS=""
  694.     LD_SEARCH_FLAGS=""
  695.     ;;
  696.     HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
  697.     AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
  698.     if test "$tcl_ok" = yes; then
  699.         SHLIB_CFLAGS="+z"
  700.         SHLIB_LD="ld -b"
  701.         SHLIB_LD_LIBS=""
  702.         SHLIB_SUFFIX=".sl"
  703.         DL_OBJS="tclLoadShl.o"
  704.         DL_LIBS="-ldld"
  705.         LD_FLAGS="-Wl,-E"
  706.         LD_SEARCH_FLAGS='-Wl,+b,${LIB_RUNTIME_DIR}:.'
  707.     fi
  708.     ;;
  709.     IRIX-4.*)
  710.     SHLIB_CFLAGS="-G 0"
  711.     SHLIB_SUFFIX=".a"
  712.     SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
  713.     SHLIB_LD_LIBS='${LIBS}'
  714.     DL_OBJS="tclLoadAout.o"
  715.     DL_LIBS=""
  716.     LD_FLAGS="-Wl,-D,08000000"
  717.     LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  718.     TCL_SHARED_LIB_SUFFIX='${VERSION}.a'
  719.     ;;
  720.     IRIX-5.*|IRIX-6.*)
  721.     SHLIB_CFLAGS=""
  722.     SHLIB_LD="ld -shared -rdata_shared"
  723.     SHLIB_LD_LIBS=""
  724.     SHLIB_SUFFIX=".so"
  725.     DL_OBJS="tclLoadDl.o"
  726.     DL_LIBS=""
  727.     LD_FLAGS=""
  728.     LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  729.     ;;
  730.     IRIX64-6.*)
  731.     SHLIB_CFLAGS=""
  732.     SHLIB_LD="ld -32 -shared -rdata_shared -rpath /usr/local/lib"
  733.     SHLIB_LD_LIBS=""
  734.     SHLIB_SUFFIX=".so"
  735.     DL_OBJS="tclLoadDl.o"
  736.     DL_LIBS=""
  737.     LD_FLAGS=""
  738.     LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  739.     ;;
  740.     Linux*)
  741.     SHLIB_CFLAGS="-fPIC"
  742.     SHLIB_LD_LIBS=""
  743.     SHLIB_SUFFIX=".so"
  744.     if test "$have_dl" = yes; then
  745.         SHLIB_LD="${CC} -shared"
  746.         DL_OBJS="tclLoadDl.o"
  747.         DL_LIBS="-ldl"
  748.         LD_FLAGS="-rdynamic"
  749.         LD_SEARCH_FLAGS=""
  750.     else
  751.         AC_CHECK_HEADER(dld.h, [
  752.         SHLIB_LD="ld -shared"
  753.         DL_OBJS="tclLoadDld.o"
  754.         DL_LIBS="-ldld"
  755.         LD_FLAGS=""
  756.         LD_SEARCH_FLAGS=""])
  757.     fi
  758.     ;;
  759.     MP-RAS-02*)
  760.     SHLIB_CFLAGS="-K PIC"
  761.     SHLIB_LD="cc -G"
  762.     SHLIB_LD_LIBS=""
  763.     SHLIB_SUFFIX=".so"
  764.     DL_OBJS="tclLoadDl.o"
  765.     DL_LIBS="-ldl"
  766.     LD_FLAGS=""
  767.     LD_SEARCH_FLAGS=""
  768.     ;;
  769.     MP-RAS-*)
  770.     SHLIB_CFLAGS="-K PIC"
  771.     SHLIB_LD="cc -G"
  772.     SHLIB_LD_LIBS=""
  773.     SHLIB_SUFFIX=".so"
  774.     DL_OBJS="tclLoadDl.o"
  775.     DL_LIBS="-ldl"
  776.     LD_FLAGS="-Wl,-Bexport"
  777.     LD_SEARCH_FLAGS=""
  778.     ;;
  779.     NetBSD-*|FreeBSD-*|OpenBSD-*)
  780.     # Not available on all versions:  check for include file.
  781.     AC_CHECK_HEADER(dlfcn.h, [
  782.         SHLIB_CFLAGS="-fpic"
  783.         SHLIB_LD="ld -Bshareable -x"
  784.         SHLIB_LD_LIBS=""
  785.         SHLIB_SUFFIX=".so"
  786.         DL_OBJS="tclLoadDl.o"
  787.         DL_LIBS=""
  788.         LD_FLAGS=""
  789.         LD_SEARCH_FLAGS=""
  790.         TCL_SHARED_LIB_SUFFIX='`echo ${VERSION} | tr -d .`.so.1.0'
  791.     ], [
  792.         SHLIB_CFLAGS=""
  793.         SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r"
  794.         SHLIB_LD_LIBS='${LIBS}'
  795.         SHLIB_SUFFIX=".a"
  796.         DL_OBJS="tclLoadAout.o"
  797.         DL_LIBS=""
  798.         LD_FLAGS=""
  799.         LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  800.         TCL_SHARED_LIB_SUFFIX='`echo ${VERSION} | tr -d .`.a'
  801.     ])
  802.  
  803.     # FreeBSD doesn't handle version numbers with dots.
  804.  
  805.     TCL_UNSHARED_LIB_SUFFIX='`echo ${VERSION} | tr -d .`.a'
  806.     TCL_LIB_VERSIONS_OK=nodots
  807.     ;;
  808.     NEXTSTEP-*)
  809.     SHLIB_CFLAGS=""
  810.     SHLIB_LD="cc -nostdlib -r"
  811.     SHLIB_LD_LIBS=""
  812.     SHLIB_SUFFIX=".so"
  813.     DL_OBJS="tclLoadNext.o"
  814.     DL_LIBS=""
  815.     LD_FLAGS=""
  816.     LD_SEARCH_FLAGS=""
  817.     ;;
  818.     OSF1-1.0|OSF1-1.1|OSF1-1.2)
  819.     # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
  820.     SHLIB_CFLAGS=""
  821.     # Hack: make package name same as library name
  822.     SHLIB_LD='ld -R -export $@:'
  823.     SHLIB_LD_LIBS=""
  824.     SHLIB_SUFFIX=".so"
  825.     DL_OBJS="tclLoadOSF.o"
  826.     DL_LIBS=""
  827.     LD_FLAGS=""
  828.     LD_SEARCH_FLAGS=""
  829.     ;;
  830.     OSF1-1.*)
  831.     # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
  832.     SHLIB_CFLAGS="-fpic"
  833.     SHLIB_LD="ld -shared"
  834.     SHLIB_LD_LIBS=""
  835.     SHLIB_SUFFIX=".so"
  836.     DL_OBJS="tclLoadDl.o"
  837.     DL_LIBS=""
  838.     LD_FLAGS=""
  839.     LD_SEARCH_FLAGS=""
  840.     ;;
  841.     OSF1-V*)
  842.         # Digital OSF/1
  843.     SHLIB_CFLAGS=""
  844.     SHLIB_LD='ld -shared -expect_unresolved "*"'
  845.     SHLIB_LD_LIBS=""
  846.     SHLIB_SUFFIX=".so"
  847.     DL_OBJS="tclLoadDl.o"
  848.     DL_LIBS=""
  849.     LD_FLAGS=""
  850.     LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  851.     ;;
  852.     RISCos-*)
  853.     SHLIB_CFLAGS="-G 0"
  854.     SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
  855.     SHLIB_LD_LIBS='${LIBS}'
  856.     SHLIB_SUFFIX=".a"
  857.     DL_OBJS="tclLoadAout.o"
  858.     DL_LIBS=""
  859.     LD_FLAGS="-Wl,-D,08000000"
  860.     LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  861.     ;;
  862.     SCO_SV-3.2*)
  863.         # Note, dlopen is available only on SCO 3.2.5 and greater.  However,
  864.         # this test works, since "uname -s" was non-standard in 3.2.4 and
  865.         # below.
  866.     SHLIB_CFLAGS="-Kpic -belf"
  867.     SHLIB_LD="ld -G"
  868.     SHLIB_LD_LIBS=""
  869.     SHLIB_SUFFIX=".so"
  870.     DL_OBJS="tclLoadDl.o"
  871.     DL_LIBS=""
  872.     LD_FLAGS="-belf -Wl,-Bexport"
  873.     LD_SEARCH_FLAGS=""
  874.     ;;
  875.      SINIX*5.4*)
  876.     SHLIB_CFLAGS="-K PIC"
  877.     SHLIB_LD="cc -G"
  878.     SHLIB_LD_LIBS=""
  879.     SHLIB_SUFFIX=".so"
  880.     DL_OBJS="tclLoadDl.o"
  881.     DL_LIBS="-ldl"
  882.     LD_FLAGS=""
  883.     LD_SEARCH_FLAGS=""
  884.     ;;
  885.     SunOS-4*)
  886.     SHLIB_CFLAGS="-PIC"
  887.     SHLIB_LD="ld"
  888.     SHLIB_LD_LIBS=""
  889.     SHLIB_SUFFIX=".so"
  890.     DL_OBJS="tclLoadDl.o"
  891.     DL_LIBS="-ldl"
  892.     LD_FLAGS=""
  893.     LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  894.  
  895.     # SunOS can't handle version numbers with dots in them in library
  896.     # specs, like -ltcl7.5, so use -ltcl75 instead.  Also, it
  897.     # requires an extra version number at the end of .so file names.
  898.     # So, the library has to have a name like libtcl75.so.1.0
  899.  
  900.     TCL_SHARED_LIB_SUFFIX='`echo ${VERSION} | tr -d .`.so.1.0'
  901.     TCL_UNSHARED_LIB_SUFFIX='`echo ${VERSION} | tr -d .`.a'
  902.     TCL_LIB_VERSIONS_OK=nodots
  903.     ;;
  904.     SunOS-5*)
  905.     SHLIB_CFLAGS="-KPIC"
  906.     SHLIB_LD="/usr/ccs/bin/ld -G -z text"
  907.  
  908.     # Note: need the LIBS below, otherwise Tk won't find Tcl's
  909.     # symbols when dynamically loaded into tclsh.
  910.  
  911.     SHLIB_LD_LIBS='${LIBS}'
  912.     SHLIB_SUFFIX=".so"
  913.     DL_OBJS="tclLoadDl.o"
  914.     DL_LIBS="-ldl"
  915.     LD_FLAGS=""
  916.     LD_SEARCH_FLAGS='-R ${LIB_RUNTIME_DIR}'
  917.     ;;
  918.     ULTRIX-4.*)
  919.     SHLIB_CFLAGS="-G 0"
  920.     SHLIB_SUFFIX=".a"
  921.     SHLIB_LD="echo tclLdAout $CC \{$SHLIB_CFLAGS\} | `pwd`/tclsh -r -G 0"
  922.     SHLIB_LD_LIBS='${LIBS}'
  923.     DL_OBJS="tclLoadAout.o"
  924.     DL_LIBS=""
  925.     LD_FLAGS="-Wl,-D,08000000"
  926.     LD_SEARCH_FLAGS='-L${LIB_RUNTIME_DIR}'
  927.     ;;
  928.     UNIX_SV*)
  929.     SHLIB_CFLAGS="-KPIC"
  930.     SHLIB_LD="cc -G"
  931.     SHLIB_LD_LIBS=""
  932.     SHLIB_SUFFIX=".so"
  933.     DL_OBJS="tclLoadDl.o"
  934.     DL_LIBS="-ldl"
  935.     # Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
  936.     # that don't grok the -Bexport option.  Test that it does.
  937.     hold_ldflags=$LDFLAGS
  938.     AC_MSG_CHECKING(for ld accepts -Bexport flag)
  939.     LDFLAGS="${LDFLAGS} -Wl,-Bexport"
  940.     AC_TRY_LINK(, [int i;], found=yes, found=no)
  941.     LDFLAGS=$hold_ldflags
  942.     AC_MSG_RESULT($found)
  943.     if test $found = yes; then
  944.       LD_FLAGS="-Wl,-Bexport"
  945.     else
  946.       LD_FLAGS=""
  947.     fi
  948.     LD_SEARCH_FLAGS=""
  949.     ;;
  950. esac
  951.  
  952. # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic
  953. # Loading for Tcl -- What Became of It?".  Proc. 2nd Tcl/Tk Workshop,
  954. # New Orleans, LA, Computerized Processes Unlimited, 1994), then we need
  955. # to determine which of several header files defines the a.out file
  956. # format (a.out.h, sys/exec.h, or sys/exec_aout.h).  At present, we
  957. # support only a file format that is more or less version-7-compatible. 
  958. # In particular,
  959. #    - a.out files must begin with `struct exec'.
  960. #    - the N_TXTOFF on the `struct exec' must compute the seek address
  961. #      of the text segment
  962. #    - The `struct exec' must contain a_magic, a_text, a_data, a_bss
  963. #      and a_entry fields.
  964. # The following compilation should succeed if and only if either sys/exec.h
  965. # or a.out.h is usable for the purpose.
  966. #
  967. # Note that the modified COFF format used on MIPS Ultrix 4.x is usable; the
  968. # `struct exec' includes a second header that contains information that
  969. # duplicates the v7 fields that are needed.
  970.  
  971. if test "x$DL_OBJS" = "xtclLoadAout.o" ; then
  972.     AC_MSG_CHECKING(sys/exec.h)
  973.     AC_TRY_COMPILE([#include <sys/exec.h>],[
  974.     struct exec foo;
  975.     unsigned long seek;
  976.     int flag;
  977. #if defined(__mips) || defined(mips)
  978.     seek = N_TXTOFF (foo.ex_f, foo.ex_o);
  979. #else
  980.     seek = N_TXTOFF (foo);
  981. #endif
  982.     flag = (foo.a_magic == OMAGIC);
  983.     return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
  984. ], tcl_ok=usable, tcl_ok=unusable)
  985.     AC_MSG_RESULT($tcl_ok)
  986.     if test $tcl_ok = usable; then
  987.     AC_DEFINE(USE_SYS_EXEC_H)
  988.     else
  989.     AC_MSG_CHECKING(a.out.h)
  990.     AC_TRY_COMPILE([#include <a.out.h>],[
  991.         struct exec foo;
  992.         unsigned long seek;
  993.         int flag;
  994. #if defined(__mips) || defined(mips)
  995.         seek = N_TXTOFF (foo.ex_f, foo.ex_o);
  996. #else
  997.         seek = N_TXTOFF (foo);
  998. #endif
  999.         flag = (foo.a_magic == OMAGIC);
  1000.         return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
  1001.     ], tcl_ok=usable, tcl_ok=unusable)
  1002.     AC_MSG_RESULT($tcl_ok)
  1003.     if test $tcl_ok = usable; then
  1004.         AC_DEFINE(USE_A_OUT_H)
  1005.     else
  1006.         AC_MSG_CHECKING(sys/exec_aout.h)
  1007.         AC_TRY_COMPILE([#include <sys/exec_aout.h>],[
  1008.         struct exec foo;
  1009.         unsigned long seek;
  1010.         int flag;
  1011. #if defined(__mips) || defined(mips)
  1012.         seek = N_TXTOFF (foo.ex_f, foo.ex_o);
  1013. #else
  1014.         seek = N_TXTOFF (foo);
  1015. #endif
  1016.         flag = (foo.a_midmag == OMAGIC);
  1017.         return foo.a_text + foo.a_data + foo.a_bss + foo.a_entry;
  1018.         ], tcl_ok=usable, tcl_ok=unusable)
  1019.         AC_MSG_RESULT($tcl_ok)
  1020.         if test $tcl_ok = usable; then
  1021.         AC_DEFINE(USE_SYS_EXEC_AOUT_H)
  1022.         else
  1023.         DL_OBJS=""
  1024.         fi
  1025.     fi
  1026.     fi
  1027. fi
  1028.  
  1029. # Step 5: disable dynamic loading if requested via a command-line switch.
  1030.  
  1031. AC_ARG_ENABLE(load, [  --disable-load          disallow dynamic loading and "load" command],
  1032.     [tcl_ok=$enableval], [tcl_ok=yes])
  1033. if test "$tcl_ok" = "no"; then
  1034.     DL_OBJS=""
  1035. fi
  1036.  
  1037. if test "x$DL_OBJS" != "x" ; then
  1038.     BUILD_DLTEST="\$(DLTEST_TARGETS)"
  1039. else
  1040.     echo "Can't figure out how to do dynamic loading or shared libraries"
  1041.     echo "on this system."
  1042.     SHLIB_CFLAGS=""
  1043.     SHLIB_LD=""
  1044.     SHLIB_SUFFIX=""
  1045.     DL_OBJS="tclLoadNone.o"
  1046.     DL_LIBS=""
  1047.     LD_FLAGS=""
  1048.     LD_SEARCH_FLAGS=""
  1049.     BUILD_DLTEST=""
  1050. fi
  1051.  
  1052. # If we're running gcc, then change the C flags for compiling shared
  1053. # libraries to the right flags for gcc, instead of those for the
  1054. # standard manufacturer compiler.
  1055.  
  1056. if test "$DL_OBJS" != "tclLoadNone.o" ; then
  1057.     if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
  1058.     case $system in
  1059.         AIX-*)
  1060.         ;;
  1061.         BSD/OS*)
  1062.         ;;
  1063.         IRIX*)
  1064.         ;;
  1065.         NetBSD-*|FreeBSD-*|OpenBSD-*)
  1066.         ;;
  1067.         RISCos-*)
  1068.         ;;
  1069.         ULTRIX-4.*)
  1070.         ;;
  1071.         *)
  1072.         SHLIB_CFLAGS="-fPIC"
  1073.         ;;
  1074.     esac
  1075.     fi
  1076. fi
  1077.  
  1078. #--------------------------------------------------------------------
  1079. #    The statements below check for systems where POSIX-style
  1080. #    non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented. 
  1081. #    On these systems (mostly older ones), use the old BSD-style
  1082. #    FIONBIO approach instead.
  1083. #--------------------------------------------------------------------
  1084.  
  1085. AC_CHECK_HEADERS(sys/ioctl.h)
  1086. AC_CHECK_HEADERS(sys/filio.h)
  1087. AC_MSG_CHECKING([FIONBIO vs. O_NONBLOCK for nonblocking I/O])
  1088. if test -f /usr/lib/NextStep/software_version; then
  1089.     system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
  1090. else
  1091.     system=`uname -s`-`uname -r`
  1092.     if test "$?" -ne 0 ; then
  1093.     system=unknown
  1094.     else
  1095.     # Special check for weird MP-RAS system (uname returns weird
  1096.     # results, and the version is kept in special file).
  1097.     
  1098.     if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
  1099.         system=MP-RAS-`awk '{print $3}' /etc/.relid'`
  1100.     fi
  1101.     if test "`uname -s`" = "AIX" ; then
  1102.         system=AIX-`uname -v`.`uname -r`
  1103.     fi
  1104.     fi
  1105. fi
  1106. case $system in
  1107.     # There used to be code here to use FIONBIO under AIX.  However, it
  1108.     # was reported that FIONBIO doesn't work under AIX 3.2.5.  Since
  1109.     # using O_NONBLOCK seems fine under AIX 4.*, I removed the FIONBIO
  1110.     # code (JO, 5/31/97).
  1111.  
  1112.     OSF*)
  1113.     AC_DEFINE(USE_FIONBIO)
  1114.     AC_MSG_RESULT(FIONBIO)
  1115.     ;;
  1116.     SunOS-4*)
  1117.     AC_DEFINE(USE_FIONBIO)
  1118.     AC_MSG_RESULT(FIONBIO)
  1119.     ;;
  1120.     ULTRIX-4.*)
  1121.     AC_DEFINE(USE_FIONBIO)
  1122.     AC_MSG_RESULT(FIONBIO)
  1123.     ;;
  1124.     *)
  1125.     AC_MSG_RESULT(O_NONBLOCK)
  1126.     ;;
  1127. esac
  1128.  
  1129. #--------------------------------------------------------------------
  1130. #    The statements below define a collection of symbols related to
  1131. #    building libtcl as a shared library instead of a static library.
  1132. #--------------------------------------------------------------------
  1133.  
  1134. realRanlib=$RANLIB
  1135. if test "$TCL_SHARED_LIB_SUFFIX" = "" ; then
  1136.     TCL_SHARED_LIB_SUFFIX='${VERSION}${SHLIB_SUFFIX}'
  1137. fi
  1138. if test "$TCL_UNSHARED_LIB_SUFFIX" = "" ; then
  1139.     TCL_UNSHARED_LIB_SUFFIX='${VERSION}.a'
  1140. fi
  1141. AC_ARG_ENABLE(shared,
  1142.     [  --enable-shared         build libtcl as a shared library],
  1143.     [tcl_ok=$enableval], [tcl_ok=no])
  1144. if test "$tcl_ok" = "yes" -a "${SHLIB_SUFFIX}" != "" ; then
  1145.     TCL_SHARED_BUILD=1
  1146.     TCL_SHLIB_CFLAGS="${SHLIB_CFLAGS}"
  1147.     TCL_LD_SEARCH_FLAGS="${LD_SEARCH_FLAGS}"
  1148.     eval "TCL_LIB_FILE=libtcl${TCL_SHARED_LIB_SUFFIX}"
  1149.     if test "x$DL_OBJS" = "xtclLoadAout.o"; then
  1150.     MAKE_LIB="ar cr ${TCL_LIB_FILE} \${OBJS}"
  1151.     else
  1152.     MAKE_LIB="\${SHLIB_LD} -o ${TCL_LIB_FILE} \${OBJS} ${SHLIB_LD_LIBS}"
  1153.     RANLIB=":"
  1154.     fi
  1155. else
  1156.     TCL_SHARED_BUILD=0
  1157.     case $system in
  1158.         BSD/OS*)
  1159.         ;;
  1160.  
  1161.     AIX-*)
  1162.             ;;
  1163.  
  1164.         *)
  1165.         SHLIB_LD_LIBS=""
  1166.         ;;
  1167.     esac
  1168.     TCL_SHLIB_CFLAGS=""
  1169.     TCL_LD_SEARCH_FLAGS=""
  1170.     eval "TCL_LIB_FILE=libtcl${TCL_UNSHARED_LIB_SUFFIX}"
  1171.     MAKE_LIB="ar cr ${TCL_LIB_FILE} \${OBJS}"
  1172. fi
  1173.  
  1174. # Note:  in the following variable, it's important to use the absolute
  1175. # path name of the Tcl directory rather than "..":  this is because
  1176. # AIX remembers this path and will attempt to use it at run-time to look
  1177. # up the Tcl library.
  1178.  
  1179. if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
  1180.     TCL_BUILD_LIB_SPEC="-L`pwd` -ltcl${VERSION}"
  1181.     TCL_LIB_SPEC="-L${exec_prefix}/lib -ltcl${VERSION}"
  1182. else
  1183.     TCL_BUILD_LIB_SPEC="-L`pwd` -ltcl`echo ${VERSION} | tr -d .`"
  1184.     TCL_LIB_SPEC="-L${exec_prefix}/lib -ltcl`echo ${VERSION} | tr -d .`"
  1185. fi
  1186.  
  1187. #--------------------------------------------------------------------
  1188. #    The statements below define the symbol TCL_PACKAGE_PATH, which
  1189. #    gives a list of directories that may contain packages.  The list
  1190. #    consists of one directory for machine-dependent binaries and
  1191. #    another for platform-independent scripts.
  1192. #--------------------------------------------------------------------
  1193.  
  1194. if test "$prefix" != "$exec_prefix"; then
  1195.     TCL_PACKAGE_PATH="${exec_prefix}/lib ${prefix}/lib"
  1196. else
  1197.     TCL_PACKAGE_PATH="${prefix}/lib"
  1198. fi
  1199.  
  1200. AC_SUBST(BUILD_DLTEST)
  1201. AC_SUBST(DL_LIBS)
  1202. AC_SUBST(DL_OBJS)
  1203. AC_SUBST(LD_FLAGS)
  1204. AC_SUBST(MAKE_LIB)
  1205. AC_SUBST(MATH_LIBS)
  1206. AC_SUBST(SHLIB_CFLAGS)
  1207. AC_SUBST(SHLIB_LD)
  1208. AC_SUBST(SHLIB_LD_LIBS)
  1209. AC_SUBST(SHLIB_SUFFIX)
  1210. AC_SUBST(TCL_BUILD_LIB_SPEC)
  1211. AC_SUBST(TCL_LD_SEARCH_FLAGS)
  1212. AC_SUBST(TCL_LIB_FILE)
  1213. AC_SUBST(TCL_LIB_SPEC)
  1214. AC_SUBST(TCL_LIB_VERSIONS_OK)
  1215. AC_SUBST(TCL_MAJOR_VERSION)
  1216. AC_SUBST(TCL_MINOR_VERSION)
  1217. AC_SUBST(TCL_PACKAGE_PATH)
  1218. AC_SUBST(TCL_PATCH_LEVEL)
  1219. AC_SUBST(TCL_SHARED_LIB_SUFFIX)
  1220. AC_SUBST(TCL_SHARED_BUILD)
  1221. AC_SUBST(TCL_SHLIB_CFLAGS)
  1222. AC_SUBST(TCL_SRC_DIR)
  1223. AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
  1224. AC_SUBST(TCL_VERSION)
  1225.  
  1226. AC_OUTPUT(Makefile tclConfig.sh)
  1227.