configure.in 7.1 KB

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