configure.in 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. AC_INIT
  2. AM_INIT_AUTOMAKE(tor, 0.0.9pre6-cvs)
  3. AM_CONFIG_HEADER(orconfig.h)
  4. AC_CANONICAL_HOST
  5. if test -f /etc/redhat-release; then
  6. CFLAGS="$CFLAGS -I/usr/kerberos/include"
  7. fi
  8. AC_ARG_ENABLE(debug,
  9. [ --enable-debug compiles with debugging info],
  10. [if test x$enableval = xyes; then
  11. CFLAGS="$CFLAGS -g"
  12. fi])
  13. AC_PROG_CC
  14. AC_PROG_MAKE_SET
  15. AC_PROG_RANLIB
  16. # The big search for OpenSSL
  17. # copied from openssh's configure.ac
  18. AC_ARG_WITH(ssl-dir,
  19. [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
  20. [
  21. if test "x$withval" != "xno" ; then
  22. tryssldir=$withval
  23. fi
  24. ]
  25. )
  26. AC_SEARCH_LIBS(socket, [socket])
  27. AC_SEARCH_LIBS(gethostbyname, [nsl])
  28. saved_LIBS="$LIBS"
  29. saved_LDFLAGS="$LDFLAGS"
  30. saved_CPPFLAGS="$CPPFLAGS"
  31. if test "x$prefix" != "xNONE" ; then
  32. tryssldir="$tryssldir $prefix"
  33. fi
  34. AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
  35. for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /usr/pkg /opt /opt/openssl ; do
  36. CPPFLAGS="$saved_CPPFLAGS"
  37. LDFLAGS="$saved_LDFLAGS"
  38. LIBS="$saved_LIBS -lssl -lcrypto"
  39. # Skip directories if they don't exist
  40. if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
  41. continue;
  42. fi
  43. if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
  44. # Try to use $ssldir/lib if it exists, otherwise
  45. # $ssldir
  46. if test -d "$ssldir/lib" ; then
  47. LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
  48. if test ! -z "$need_dash_r" ; then
  49. LDFLAGS="-R$ssldir/lib $LDFLAGS"
  50. fi
  51. else
  52. LDFLAGS="-L$ssldir $saved_LDFLAGS"
  53. if test ! -z "$need_dash_r" ; then
  54. LDFLAGS="-R$ssldir $LDFLAGS"
  55. fi
  56. fi
  57. # Try to use $ssldir/include if it exists, otherwise
  58. # $ssldir
  59. if test -d "$ssldir/include" ; then
  60. CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
  61. else
  62. CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
  63. fi
  64. fi
  65. # Basic test to check for compatible version and correct linking
  66. # *does not* test for RSA - that comes later.
  67. AC_TRY_RUN(
  68. [
  69. #include <string.h>
  70. #include <openssl/rand.h>
  71. int main(void)
  72. {
  73. char a[2048];
  74. memset(a, 0, sizeof(a));
  75. RAND_add(a, sizeof(a), sizeof(a));
  76. return(RAND_status() <= 0);
  77. }
  78. ],
  79. [
  80. found_crypto=1
  81. break;
  82. ], []
  83. )
  84. if test ! -z "$found_crypto" ; then
  85. break;
  86. fi
  87. done
  88. if test -z "$found_crypto" ; then
  89. AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
  90. fi
  91. if test -z "$ssldir" ; then
  92. ssldir="(system)"
  93. fi
  94. ac_cv_openssldir=$ssldir
  95. ])
  96. if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
  97. then
  98. dnl Need to recover ssldir - test above runs in subshell
  99. ssldir=$ac_cv_openssldir
  100. if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
  101. # Try to use $ssldir/lib if it exists, otherwise
  102. # $ssldir
  103. if test -d "$ssldir/lib" ; then
  104. LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
  105. if test ! -z "$need_dash_r" ; then
  106. LDFLAGS="-R$ssldir/lib $LDFLAGS"
  107. fi
  108. else
  109. LDFLAGS="-L$ssldir $saved_LDFLAGS"
  110. if test ! -z "$need_dash_r" ; then
  111. LDFLAGS="-R$ssldir $LDFLAGS"
  112. fi
  113. fi
  114. # Try to use $ssldir/include if it exists, otherwise
  115. # $ssldir
  116. if test -d "$ssldir/include" ; then
  117. CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
  118. else
  119. CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
  120. fi
  121. fi
  122. fi
  123. LIBS="$saved_LIBS"
  124. AC_SYS_LARGEFILE
  125. dnl The warning message here is no longer strictly accurate.
  126. 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 zlib.h, , AC_MSG_WARN(some headers were not found, compilation may fail))
  127. dnl These headers are not essential
  128. AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/param.h sys/wait.h sys/limits.h netinet/in.h arpa/inet.h machine/limits.h syslog.h sys/time.h sys/resource.h)
  129. AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit setrlimit strlcat strlcpy strtoull getpwnam fseeko ftello)
  130. AC_CHECK_MEMBERS([struct timeval.tv_sec])
  131. dnl In case we aren't given a working stdint.h, we'll need to grow our own.
  132. dnl Watch out.
  133. AC_CHECK_SIZEOF(int8_t)
  134. AC_CHECK_SIZEOF(int16_t)
  135. AC_CHECK_SIZEOF(int32_t)
  136. AC_CHECK_SIZEOF(int64_t)
  137. AC_CHECK_SIZEOF(uint8_t)
  138. AC_CHECK_SIZEOF(uint16_t)
  139. AC_CHECK_SIZEOF(uint32_t)
  140. AC_CHECK_SIZEOF(uint64_t)
  141. AC_CHECK_SIZEOF(intptr_t)
  142. AC_CHECK_SIZEOF(uintptr_t)
  143. dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
  144. AC_CHECK_SIZEOF(char)
  145. AC_CHECK_SIZEOF(short)
  146. AC_CHECK_SIZEOF(int)
  147. AC_CHECK_SIZEOF(long)
  148. AC_CHECK_SIZEOF(long long)
  149. AC_CHECK_SIZEOF(__int64)
  150. AC_CHECK_SIZEOF(void *)
  151. # Now, let's see about alignment requirements. On some platforms, we override
  152. # the default.
  153. case $host in
  154. ia64-*-* | arm-*-* )
  155. tor_cv_unaligned_ok=no
  156. ;;
  157. *)
  158. AC_CACHE_CHECK([whether unaligned int access is allowed], tor_cv_unaligned_ok,
  159. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  160. [[int main () { char s[] = "A\x00\x00\x00\x00\x00\x00\x00";
  161. return *(int*)(&s[1]); }]])],
  162. [tor_cv_unaligned_ok=yes],
  163. [tor_cv_unaligned_ok=no],
  164. [tor_cv_unaligned_ok=cross])])
  165. esac
  166. if test $tor_cv_unaligned_ok = yes; then
  167. AC_DEFINE([UNALIGNED_INT_ACCESS_OK], 1,
  168. [Define to 1 iff unaligned int access is allowed])
  169. fi
  170. # Now make sure that NULL can be represented as zero bytes.
  171. AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
  172. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  173. [[#include <stdlib.h>
  174. int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
  175. return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
  176. [tor_cv_null_is_zero=yes],
  177. [tor_cv_null_is_zero=no],
  178. [tor_cv_null_is_zero=cross])])
  179. if test $tor_cv_null_is_zero = yes; then
  180. AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
  181. [Define to 1 iff memset(0) sets pointers to NULL])
  182. fi
  183. # $prefix stores the value of the --prefix command line option, or
  184. # NONE if the option wasn't set. In the case that it wasn't set, make
  185. # it be the default, so that we can use it to expand directories now.
  186. if test "x$prefix" = "xNONE"; then
  187. prefix=$ac_default_prefix
  188. fi
  189. # and similarly for $exec_prefix
  190. if test "x$exec_prefix" = "xNONE"; then
  191. exec_prefix=$prefix
  192. fi
  193. CONFDIR=`eval echo $sysconfdir/tor`
  194. AC_SUBST(CONFDIR)
  195. AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
  196. AC_DEFINE([CONFDIR], [], [tor's configuration directory])
  197. BINDIR=`eval echo $bindir`
  198. AC_SUBST(BINDIR)
  199. LOCALSTATEDIR=`eval echo $localstatedir`
  200. AC_SUBST(LOCALSTATEDIR)
  201. # Set CFLAGS _after_ all the above checks, since our warnings are stricter
  202. # than autoconf's macros like.
  203. CFLAGS="$CFLAGS -Wall -g -O2"
  204. # Add some more warnings which we use in the cvs version but not in the
  205. # released versions.
  206. #CFLAGS="$CFLAGS -W -Wno-unused-parameter -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes"
  207. #CFLAGS="$CFLAGS -Wwrite-strings -Wredundant-decls"
  208. # Add these in when you feel like fun.
  209. # -Wbad-function-cast -Werror -Wdeclaration-after-statement
  210. echo "confdir: $CONFDIR"
  211. AC_OUTPUT(Makefile tor.spec contrib/tor.sh contrib/torify contrib/Makefile src/config/torrc.sample doc/tor.1 src/Makefile doc/Makefile doc/design-paper/Makefile src/config/Makefile src/common/Makefile src/or/Makefile src/win32/Makefile src/tools/Makefile)