configure.in 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. AC_INIT
  2. AM_INIT_AUTOMAKE(tor, 0.0.7pre1-cvs-2)
  3. AM_CONFIG_HEADER(orconfig.h)
  4. AC_CANONICAL_HOST
  5. CFLAGS="$CFLAGS -Wall -g -O2 -I/usr/kerberos/include"
  6. AC_ARG_ENABLE(debug,
  7. [ --enable-debug compiles with debugging info],
  8. [if test x$enableval = xyes; then
  9. CFLAGS="$CFLAGS -g"
  10. fi])
  11. AC_PROG_CC
  12. AC_PROG_MAKE_SET
  13. AC_PROG_RANLIB
  14. # The big search for OpenSSL
  15. # copied from openssh's configure.ac
  16. AC_ARG_WITH(ssl-dir,
  17. [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
  18. [
  19. if test "x$withval" != "xno" ; then
  20. tryssldir=$withval
  21. fi
  22. ]
  23. )
  24. AC_SEARCH_LIBS(socket, [socket])
  25. AC_SEARCH_LIBS(gethostbyname, [nsl])
  26. saved_LIBS="$LIBS"
  27. saved_LDFLAGS="$LDFLAGS"
  28. saved_CPPFLAGS="$CPPFLAGS"
  29. if test "x$prefix" != "xNONE" ; then
  30. tryssldir="$tryssldir $prefix"
  31. fi
  32. AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
  33. for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
  34. CPPFLAGS="$saved_CPPFLAGS"
  35. LDFLAGS="$saved_LDFLAGS"
  36. LIBS="$saved_LIBS -lssl -lcrypto"
  37. # Skip directories if they don't exist
  38. if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
  39. continue;
  40. fi
  41. if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
  42. # Try to use $ssldir/lib if it exists, otherwise
  43. # $ssldir
  44. if test -d "$ssldir/lib" ; then
  45. LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
  46. if test ! -z "$need_dash_r" ; then
  47. LDFLAGS="-R$ssldir/lib $LDFLAGS"
  48. fi
  49. else
  50. LDFLAGS="-L$ssldir $saved_LDFLAGS"
  51. if test ! -z "$need_dash_r" ; then
  52. LDFLAGS="-R$ssldir $LDFLAGS"
  53. fi
  54. fi
  55. # Try to use $ssldir/include if it exists, otherwise
  56. # $ssldir
  57. if test -d "$ssldir/include" ; then
  58. CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
  59. else
  60. CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
  61. fi
  62. fi
  63. # Basic test to check for compatible version and correct linking
  64. # *does not* test for RSA - that comes later.
  65. AC_TRY_RUN(
  66. [
  67. #include <string.h>
  68. #include <openssl/rand.h>
  69. int main(void)
  70. {
  71. char a[2048];
  72. memset(a, 0, sizeof(a));
  73. RAND_add(a, sizeof(a), sizeof(a));
  74. return(RAND_status() <= 0);
  75. }
  76. ],
  77. [
  78. found_crypto=1
  79. break;
  80. ], []
  81. )
  82. if test ! -z "$found_crypto" ; then
  83. break;
  84. fi
  85. done
  86. if test -z "$found_crypto" ; then
  87. AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
  88. fi
  89. if test -z "$ssldir" ; then
  90. ssldir="(system)"
  91. fi
  92. ac_cv_openssldir=$ssldir
  93. ])
  94. if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
  95. then
  96. dnl Need to recover ssldir - test above runs in subshell
  97. ssldir=$ac_cv_openssldir
  98. if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
  99. # Try to use $ssldir/lib if it exists, otherwise
  100. # $ssldir
  101. if test -d "$ssldir/lib" ; then
  102. LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
  103. if test ! -z "$need_dash_r" ; then
  104. LDFLAGS="-R$ssldir/lib $LDFLAGS"
  105. fi
  106. else
  107. LDFLAGS="-L$ssldir $saved_LDFLAGS"
  108. if test ! -z "$need_dash_r" ; then
  109. LDFLAGS="-R$ssldir $LDFLAGS"
  110. fi
  111. fi
  112. # Try to use $ssldir/include if it exists, otherwise
  113. # $ssldir
  114. if test -d "$ssldir/include" ; then
  115. CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
  116. else
  117. CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
  118. fi
  119. fi
  120. fi
  121. LIBS="$saved_LIBS -lssl -lcrypto"
  122. dnl The warning message here is no longer strictly accurate.
  123. AC_CHECK_HEADERS(unistd.h string.h signal.h netdb.h ctype.h poll.h sys/stat.h sys/poll.h sys/types.h fcntl.h sys/fcntl.h sys/ioctl.h sys/socket.h sys/time.h netinet/in.h arpa/inet.h errno.h assert.h time.h pwd.h grp.h, , AC_MSG_WARN(some headers were not found, compilation may fail))
  124. dnl These headers are not essential
  125. AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/wait.h sys/limits.h netinet/in.h arpa/inet.h machine/limits.h)
  126. AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime)
  127. AC_REPLACE_FUNCS(strlcat strlcpy)
  128. dnl In case we aren't given a working stdint.h, we'll need to grow our own.
  129. dnl Watch out.
  130. AC_CHECK_SIZEOF(int8_t)
  131. AC_CHECK_SIZEOF(int16_t)
  132. AC_CHECK_SIZEOF(int32_t)
  133. AC_CHECK_SIZEOF(int64_t)
  134. AC_CHECK_SIZEOF(uint8_t)
  135. AC_CHECK_SIZEOF(uint16_t)
  136. AC_CHECK_SIZEOF(uint32_t)
  137. AC_CHECK_SIZEOF(uint64_t)
  138. AC_CHECK_SIZEOF(intptr_t)
  139. AC_CHECK_SIZEOF(uintptr_t)
  140. dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
  141. AC_CHECK_SIZEOF(char)
  142. AC_CHECK_SIZEOF(short)
  143. AC_CHECK_SIZEOF(int)
  144. AC_CHECK_SIZEOF(long)
  145. AC_CHECK_SIZEOF(long long)
  146. AC_CHECK_SIZEOF(__int64)
  147. AC_CHECK_SIZEOF(void *)
  148. # Now, let's see about alignment requirements. On some platforms, we override
  149. # the default.
  150. case $host in
  151. ia64-*-* | arm-*-* )
  152. tor_cv_unaligned_ok=no
  153. ;;
  154. *)
  155. AC_CACHE_CHECK([whether unaligned int access is allowed], tor_cv_unaligned_ok,
  156. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  157. [[int main () { char s[] = "A\x00\x00\x00\x00\x00\x00\x00";
  158. return *(int*)(&s[1]); }]])],
  159. [tor_cv_unaligned_ok=yes],
  160. [tor_cv_unaligned_ok=no],
  161. [tor_cv_unaligned_ok=cross])])
  162. esac
  163. if test $tor_cv_unaligned_ok = yes; then
  164. AC_DEFINE([UNALIGNED_INT_ACCESS_OK], 1,
  165. [Define to 1 iff unaligned int access is allowed])
  166. fi
  167. # $prefix stores the value of the --prefix command line option, or
  168. # NONE if the option wasn't set. In the case that it wasn't set, make
  169. # it be the default, so that we can use it to expand directories now.
  170. if test "x$prefix" = "xNONE"; then
  171. prefix=$ac_default_prefix
  172. fi
  173. # and similarly for $exec_prefix
  174. if test "x$exec_prefix" = "xNONE"; then
  175. exec_prefix=$prefix
  176. fi
  177. CONFDIR=`eval echo $sysconfdir/tor`
  178. AC_SUBST(CONFDIR)
  179. AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
  180. AC_DEFINE([CONFDIR], [], [tor's configuration directory])
  181. BINDIR=`eval echo $bindir`
  182. AC_SUBST(BINDIR)
  183. LOCALSTATEDIR=`eval echo $localstatedir`
  184. AC_SUBST(LOCALSTATEDIR)
  185. echo "confdir: $CONFDIR"
  186. AC_OUTPUT(Makefile contrib/tor.sh contrib/torify contrib/Makefile contrib/tor.spec src/config/torrc.sample doc/tor.1 src/Makefile doc/Makefile src/config/Makefile src/common/Makefile src/or/Makefile)