configure.in 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. dnl Process this file with autoconf to produce a configure script.
  2. dnl
  3. dnl We might want AC_WORDS_BIGENDIAN in the future.
  4. dnl We might want AC_CHAR_UNSIGNED in the future.
  5. dnl
  6. define(S48_POSIX_LIBC, [dnl
  7. echo checking for RISC/OS POSIX library lossage
  8. if test -f /usr/posix/usr/lib/libc.a; then
  9. LIBS="${LIBS} /usr/posix/usr/lib/libc.a"
  10. fi
  11. ])dnl
  12. dnl
  13. dnl Run AC_PROG_CC, but don't accept it's changes to CFLAGS.
  14. dnl For some insane reason, it sets CFLAGS to either `-O' or `-g -O' for gcc.
  15. dnl I don't want the silly -g (because if you are using nlist, you can't strip
  16. dnl the binary), I want -O2 for gcc and -O for other C compilers.
  17. define(S48_PROG_CC, [dnl
  18. oldCFLAGS="$CFLAGS"
  19. AC_PROG_CC
  20. if test "z$oldCFLAGS" = z; then
  21. if test "z$GCC" = z; then
  22. CFLAGS='-O'
  23. else
  24. CFLAGS='-O2'
  25. fi
  26. fi
  27. ])dnl
  28. dnl
  29. dnl Linux/ELF systems need the -rdynamic flag when linking so that
  30. dnl dlsym() can find symbols in the executable.
  31. dnl Note, on some Sun's, you can link with -rdynamic but the resulting
  32. dnl a.out always core dumps.
  33. define(S48_RDYNAMIC, [dnl
  34. AC_MSG_CHECKING([link with -rdynamic])
  35. AC_TRY_COMPILE([],
  36. [#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
  37. this must not compile
  38. #endif],
  39. [AC_MSG_RESULT(no)],
  40. [AC_MSG_RESULT(yes)
  41. LDFLAGS="$LDFLAGS -rdynamic"])
  42. ])dnl
  43. dnl
  44. define(S48_IEEE_ENDIANNESS, [dnl
  45. AC_MSG_CHECKING([IEEE floating-point endianness])
  46. AC_TRY_RUN([#include <stdio.h>
  47. typedef unsigned long word32_t;
  48. typedef union { double d; word32_t word[2]; } double_overlay;
  49. #define DOUBLE_WORD0(x) ((double_overlay*)&(x))->word[0]
  50. #define DOUBLE_WORD1(x) ((double_overlay*)&(x))->word[1]
  51. int
  52. main(void)
  53. {
  54. double n = 0.3;
  55. /* least significant byte first */
  56. if ((DOUBLE_WORD0(n) == 0x33333333) && (DOUBLE_WORD1(n) == 0x3fd33333))
  57. return 0;
  58. /* most significant byte first */
  59. else if ((DOUBLE_WORD1(n) == 0x33333333) && (DOUBLE_WORD0(n) == 0x3fd33333))
  60. return 1;
  61. else {
  62. fprintf(stderr, "WARNING: unknown IEEE format; assuming IEEE with least significant byte first\n");
  63. return 0;
  64. }
  65. }], ieee_endianness="least first", ieee_endianness="most first", ieee_endianness="least first")
  66. AC_MSG_RESULT([$ieee_endianness])
  67. if test "$ieee_endianness" = "most first"; then
  68. AC_DEFINE([IEEE_MOST_FIRST], 1, [Define if IEEE doubles are stored with most-significant byte first.])
  69. fi
  70. ])dnl
  71. dnl
  72. define(S48_USCORE, [dnl
  73. AC_MSG_CHECKING([underscore before symbols])
  74. echo 'main() { return 0; } fnord() {}' >conftest.c
  75. if ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c ${LIBS} &&
  76. nm a.out | grep _fnord >/dev/null; then
  77. AC_MSG_RESULT([yes])
  78. AC_DEFINE(USCORE)
  79. else
  80. AC_MSG_RESULT([no])
  81. fi
  82. rm -f conftest.c a.out
  83. ])dnl
  84. dnl
  85. define(S48_CREATE_BUILD_DIRS, [dnl
  86. mkdir -p c/unix
  87. mkdir -p c/posix
  88. mkdir -p c/fake
  89. ])dnl
  90. dnl
  91. AC_INIT(c/prescheme.h)
  92. AC_CONFIG_HEADER(c/sysdep.h)
  93. S48_CREATE_BUILD_DIRS
  94. S48_PROG_CC
  95. AC_ISC_POSIX
  96. dnl set the cross-compile flag before we try anything.
  97. AC_TRY_RUN([int main() { return 0;}], [], [], [true])
  98. AC_PROG_INSTALL
  99. AC_CHECK_LIB(m, main)
  100. AC_CHECK_LIB(dl, main)
  101. AC_CHECK_LIB(mld, main)
  102. AC_CHECK_LIB(nsl, main)
  103. AC_CHECK_LIB(gen, main)
  104. AC_CHECK_LIB(socket, main)
  105. AC_CHECK_LIB(sun, getpwnam)
  106. dnl Solaris 2.3 seems to need -lelf for nlist(). (tnx Bryan O'Sullivan)
  107. AC_CHECK_LIB(elf, main)
  108. S48_POSIX_LIBC
  109. AC_CONST
  110. AC_MSG_CHECKING(for socklen_t)
  111. AC_TRY_COMPILE([#include <sys/types.h>
  112. #include <sys/socket.h>
  113. socklen_t x;
  114. ],[],
  115. [AC_MSG_RESULT(yes)],
  116. [AC_TRY_COMPILE([#include <sys/types.h>
  117. #include <sys/socket.h>
  118. int accept (int,
  119. struct sockaddr *,
  120. size_t *);
  121. ],[],
  122. [AC_MSG_RESULT(size_t)
  123. AC_DEFINE(socklen_t,size_t)],
  124. [AC_MSG_RESULT(int)
  125. AC_DEFINE(socklen_t,int)])])
  126. AC_RETSIGTYPE
  127. AC_CHECK_HEADERS(libgen.h sys/timeb.h posix/time.h)
  128. AC_CHECK_HEADERS(sys/select.h)
  129. AC_CHECK_HEADERS(sysexits.h)
  130. AC_CHECK_FUNCS(gettimeofday ftime nlist select setitimer sigaction)
  131. AC_CHECK_FUNC(dlopen, [AC_DEFINE(HAVE_DLOPEN,
  132. 1, [Define to 1 if the interface to the dynamic linker exists])],
  133. [AC_CHECK_FUNC(nlist, [AC_LIBOBJ([c/fake/libdl1])],
  134. [AC_LIBOBJ([c/fake/libdl2])])])
  135. AC_CHECK_FUNCS(socket chroot)
  136. AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR),
  137. [AC_LIBOBJ([c/fake/strerror.o])])
  138. dnl Some idiot renamed `environ' as `__environ' in some versions of Linux.
  139. dnl POSIX says it's `environ'.
  140. AC_MSG_CHECKING([environ])
  141. AC_TRY_LINK([],
  142. [extern char **environ;
  143. if (environ)
  144. return 0;
  145. else
  146. return 1;],
  147. dnl Have `environ'
  148. [AC_DEFINE(ENVIRON_NAME,environ)
  149. AC_MSG_RESULT([using environ])],
  150. dnl Do not have `environ'
  151. [AC_TRY_LINK([],
  152. [extern char **__environ;
  153. if (__environ)
  154. return 0;
  155. else
  156. return 1;],
  157. dnl Have `__environ'
  158. [AC_DEFINE(ENVIRON_NAME,__environ)
  159. AC_MSG_RESULT([using __environ])],
  160. dnl Do not have `__environ'
  161. [AC_MSG_WARN([no environ variable found])
  162. AC_LIBOBJ([c/fake/environ.o])])])
  163. AC_MSG_CHECKING([n_name])
  164. AC_TRY_LINK([#include <nlist.h>],
  165. [struct nlist name_list;
  166. name_list.n_name = "foo";],
  167. AC_DEFINE(NLIST_HAS_N_NAME)
  168. AC_MSG_RESULT([yes]),
  169. AC_MSG_RESULT([no]))
  170. AC_MSG_CHECKING([__NEXT__])
  171. AC_TRY_LINK(,[
  172. #ifdef __NeXT__
  173. return 0;
  174. #else
  175. fail
  176. #endif
  177. ],
  178. CC="$CC -posix"
  179. AC_DEFINE(HAVE_SIGACTION)
  180. AC_MSG_RESULT([yes]),
  181. AC_MSG_RESULT([no]))
  182. S48_USCORE
  183. S48_RDYNAMIC
  184. S48_IEEE_ENDIANNESS
  185. AC_SUBST(CFLAGS)
  186. AC_SUBST(LDFLAGS)
  187. AC_OUTPUT(Makefile)