configure.in 6.6 KB

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