configure.in 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. dnl The -cckr (K&R) flag is for the IRIX C compiler. If this is left
  7. dnl out, scheme48vm.c breaks because the rather pedantic SGI compiler
  8. dnl decides that a char is not the same thing as an unsigned char.
  9. dnl - Bryan O'Sullivan 3/94
  10. dnl Note, this test didn't work correctly on Sun's which take -cckr as a
  11. dnl synonym for -c. (HCC)
  12. define(S48_CFLAG_CKR, [dnl
  13. if test "z$GCC" = z; then
  14. AC_MSG_CHECKING([-cckr])
  15. oldCFLAGS="$CFLAGS"
  16. CFLAGS="$CFLAGS -cckr"
  17. AC_TRY_RUN([int main() { return 0;}],
  18. [AC_MSG_RESULT(yes)],
  19. [AC_MSG_RESULT(no)
  20. CFLAGS="$oldCFLAGS"],
  21. [AC_MSG_RESULT(no)
  22. CFLAGS="$oldCFLAGS"])
  23. fi
  24. ])dnl
  25. dnl
  26. define(S48_POSIX_LIBC, [dnl
  27. echo checking for RISC/OS POSIX library lossage
  28. if test -f /usr/posix/usr/lib/libc.a; then
  29. LIBS="${LIBS} /usr/posix/usr/lib/libc.a"
  30. fi
  31. ])dnl
  32. dnl
  33. dnl Run AC_PROG_CC, but don't accept it's changes to CFLAGS.
  34. dnl For some insane reason, it sets CFLAGS to either `-O' or `-g -O' for gcc.
  35. dnl I don't want the silly -g (because if you are using nlist, you can't strip
  36. dnl the binary), I want -O2 for gcc and -O for other C compilers.
  37. define(S48_PROG_CC, [dnl
  38. oldCFLAGS="$CFLAGS"
  39. AC_PROG_CC
  40. if test "z$oldCFLAGS" = z; then
  41. if test "z$GCC" = z; then
  42. CFLAGS='-O'
  43. else
  44. CFLAGS='-O2'
  45. fi
  46. fi
  47. ])dnl
  48. dnl
  49. dnl Linux/ELF systems need the -rdynamic flag when linking so that
  50. dnl dlsym() can find symbols in the executable.
  51. dnl Note, on some Sun's, you can link with -rdynamic but the resulting
  52. dnl a.out always core dumps.
  53. define(S48_RDYNAMIC, [dnl
  54. AC_MSG_CHECKING([link with -rdynamic])
  55. AC_TRY_COMPILE([],
  56. [#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
  57. this must not compile
  58. #endif],
  59. [AC_MSG_RESULT(no)],
  60. [AC_MSG_RESULT(yes)
  61. LDFLAGS="$LDFLAGS -rdynamic"])
  62. ])dnl
  63. dnl
  64. define(S48_USCORE, [dnl
  65. AC_MSG_CHECKING([underscore before symbols])
  66. echo 'main() { return 0; } fnord() {}' >conftest.c
  67. if ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c ${LIBS} &&
  68. nm a.out | grep _fnord >/dev/null; then
  69. AC_MSG_RESULT([yes])
  70. AC_DEFINE(USCORE)
  71. else
  72. AC_MSG_RESULT([no])
  73. fi
  74. rm -f conftest.c a.out
  75. ])dnl
  76. dnl
  77. define(S48_CREATE_BUILD_DIRS, [dnl
  78. mkdir -p c/unix &&
  79. mkdir -p c/posix &&
  80. mkdir -p c/fake
  81. ])dnl
  82. AC_INIT(c/prescheme.h)
  83. AC_CONFIG_HEADER(c/sysdep.h)
  84. S48_PROG_CC
  85. AC_ISC_POSIX
  86. dnl set the cross-compile flag before we try anything.
  87. AC_TRY_RUN([int main() { return 0;}], [], [], [true])
  88. S48_CFLAG_CKR
  89. AC_PROG_INSTALL
  90. AC_CHECK_LIB(m, main)
  91. AC_CHECK_LIB(dl, main)
  92. AC_CHECK_LIB(mld, main)
  93. AC_CHECK_LIB(nsl, main)
  94. AC_CHECK_LIB(gen, main)
  95. AC_CHECK_LIB(socket, main)
  96. AC_CHECK_LIB(sun, getpwnam)
  97. dnl Solaris 2.3 seems to need -lelf for nlist(). (tnx Bryan O'Sullivan)
  98. AC_CHECK_LIB(elf, main)
  99. S48_POSIX_LIBC
  100. AC_CONST
  101. AC_MSG_CHECKING(for socklen_t)
  102. AC_TRY_COMPILE([#include <sys/types.h>
  103. #include <sys/socket.h>
  104. socklen_t x;
  105. ],[],
  106. [AC_MSG_RESULT(yes)],
  107. [AC_TRY_COMPILE([#include <sys/types.h>
  108. #include <sys/socket.h>
  109. int accept (int,
  110. struct sockaddr *,
  111. size_t *);
  112. ],[],
  113. [AC_MSG_RESULT(size_t)
  114. AC_DEFINE(socklen_t,size_t)],
  115. [AC_MSG_RESULT(int)
  116. AC_DEFINE(socklen_t,int)])])
  117. AC_RETSIGTYPE
  118. AC_CHECK_HEADERS(libgen.h sys/timeb.h posix/time.h)
  119. AC_CHECK_HEADERS(sys/select.h)
  120. AC_CHECK_FUNCS(gettimeofday ftime nlist select setitimer sigaction)
  121. AC_CHECK_FUNC(dlopen,
  122. [AC_DEFINE(HAVE_DLOPEN)],
  123. [AC_CHECK_FUNC(nlist, [AC_LIBOBJ([c/fake/libdl1.o])],
  124. [AC_LIBOBJ([c/fake/libdl2.o])])])
  125. AC_CHECK_FUNCS(socket chroot)
  126. AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR),
  127. [AC_LIBOBJ([c/fake/strerror])])
  128. dnl Some idiot renamed `environ' as `__environ' in some versions of Linux.
  129. dnl POSIX says it's `environ'.
  130. AC_MSG_CHECKING([environ])
  131. AC_TRY_LINK([],
  132. [extern char **environ;
  133. if (environ)
  134. return 0;
  135. else
  136. return 1;],
  137. dnl Have `environ'
  138. [AC_DEFINE(ENVIRON_NAME,environ)
  139. AC_MSG_RESULT([using environ])],
  140. dnl Do not have `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_MSG_WARN([no environ variable found])
  152. AC_LIBOBJ([c/fake/environ])])])
  153. AC_MSG_CHECKING([n_name])
  154. AC_TRY_LINK([#include <nlist.h>],
  155. [struct nlist name_list;
  156. name_list.n_name = "foo";],
  157. AC_DEFINE(NLIST_HAS_N_NAME)
  158. AC_MSG_RESULT([yes]),
  159. AC_MSG_RESULT([no]))
  160. AC_MSG_CHECKING([__NEXT__])
  161. AC_TRY_LINK(,[
  162. #ifdef __NeXT__
  163. return 0;
  164. #else
  165. fail
  166. #endif
  167. ],
  168. CC="$CC -posix"
  169. AC_DEFINE(HAVE_SIGACTION)
  170. AC_MSG_RESULT([yes]),
  171. AC_MSG_RESULT([no]))
  172. S48_USCORE
  173. S48_RDYNAMIC
  174. AC_SUBST(CFLAGS)
  175. AC_SUBST(LDFLAGS)
  176. S48_CREATE_BUILD_DIRS
  177. AC_OUTPUT(Makefile)