some early thoughts on the requirements for our network discovery protocol
[tor.git] / configure.in
blob5a7022417d37d23fd52d812697a9be8d66ea3ebe
2 AC_INIT
3 AM_INIT_AUTOMAKE(tor, 0.1.0.0-alpha-cvs)
4 AM_CONFIG_HEADER(orconfig.h)
6 AC_CANONICAL_HOST
8 if test -f /etc/redhat-release; then
9     CFLAGS="$CFLAGS -I/usr/kerberos/include"
12 AC_ARG_ENABLE(debug,
13 [  --enable-debug          compiles with debugging info],
14 [if test x$enableval = xyes; then
15     CFLAGS="$CFLAGS -g"
16 fi])
18 AC_PROG_CC
19 AC_PROG_MAKE_SET
20 AC_PROG_RANLIB
22 # The big search for OpenSSL
23 # copied from openssh's configure.ac
24 AC_ARG_WITH(ssl-dir,
25         [  --with-ssl-dir=PATH     Specify path to OpenSSL installation ],
26         [
27                 if test "x$withval" != "xno" ; then
28                         tryssldir=$withval
29                 fi
30         ]
33 AC_SEARCH_LIBS(socket, [socket])
34 AC_SEARCH_LIBS(gethostbyname, [nsl])
35 AC_SEARCH_LIBS(event_loop, [event], , AC_MSG_ERROR(Libevent library not found. Tor requires libevent to build.))
37 saved_LIBS="$LIBS"
38 saved_LDFLAGS="$LDFLAGS"
39 saved_CPPFLAGS="$CPPFLAGS"
40 if test "x$prefix" != "xNONE" ; then
41         tryssldir="$tryssldir $prefix"
43 AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
44         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
45                 CPPFLAGS="$saved_CPPFLAGS"
46                 LDFLAGS="$saved_LDFLAGS"
47                 LIBS="$saved_LIBS -lssl -lcrypto"
49                 # Skip directories if they don't exist
50                 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
51                         continue;
52                 fi
53                 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
54                         # Try to use $ssldir/lib if it exists, otherwise
55                         # $ssldir
56                         if test -d "$ssldir/lib" ; then
57                                 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
58                                 if test ! -z "$need_dash_r" ; then
59                                         LDFLAGS="-R$ssldir/lib $LDFLAGS"
60                                 fi
61                         else
62                                 LDFLAGS="-L$ssldir $saved_LDFLAGS"
63                                 if test ! -z "$need_dash_r" ; then
64                                         LDFLAGS="-R$ssldir $LDFLAGS"
65                                 fi
66                         fi
67                         # Try to use $ssldir/include if it exists, otherwise
68                         # $ssldir
69                         if test -d "$ssldir/include" ; then
70                                 CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
71                         else
72                                 CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
73                         fi
74                 fi
76                 # Basic test to check for compatible version and correct linking
77                 # *does not* test for RSA - that comes later.
78                 AC_TRY_RUN(
79                         [
80 #include <string.h>
81 #include <openssl/rand.h>
82 int main(void)
84         char a[2048];
85         memset(a, 0, sizeof(a));
86         RAND_add(a, sizeof(a), sizeof(a));
87         return(RAND_status() <= 0);
89                         ],
90                         [
91                                 found_crypto=1
92                                 break;
93                         ], []
94                 )
96                 if test ! -z "$found_crypto" ; then
97                         break;
98                 fi
99         done
101         if test -z "$found_crypto" ; then
102                 AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
103         fi
104         if test -z "$ssldir" ; then
105                 ssldir="(system)"
106         fi
108         ac_cv_openssldir=$ssldir
110 if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
111  then
112         dnl Need to recover ssldir - test above runs in subshell
113         ssldir=$ac_cv_openssldir
114         if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
115                 # Try to use $ssldir/lib if it exists, otherwise
116                 # $ssldir
117                 if test -d "$ssldir/lib" ; then
118                         LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
119                         if test ! -z "$need_dash_r" ; then
120                                 LDFLAGS="-R$ssldir/lib $LDFLAGS"
121                         fi
122                 else
123                         LDFLAGS="-L$ssldir $saved_LDFLAGS"
124                         if test ! -z "$need_dash_r" ; then
125                                 LDFLAGS="-R$ssldir $LDFLAGS"
126                         fi
127                 fi
128                 # Try to use $ssldir/include if it exists, otherwise
129                 # $ssldir
130                 if test -d "$ssldir/include" ; then
131                         CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
132                 else
133                         CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
134                 fi
135         fi
137 LIBS="$saved_LIBS"
139 AC_SYS_LARGEFILE
141 dnl The warning message here is no longer strictly accurate.
143 AC_CHECK_HEADERS(unistd.h string.h signal.h netdb.h ctype.h sys/stat.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))
145 AC_CHECK_HEADERS(event.h, , AC_MSG_ERROR(Libevent header (event.h) not found. Tor requires libevent to build.))
147 dnl These headers are not essential
149 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)
151 AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit setrlimit strlcat strlcpy strtoull getpwnam ftello)
152 AC_FUNC_FSEEKO
154 AC_CHECK_MEMBERS([struct timeval.tv_sec])
156 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
157 dnl Watch out.
159 AC_CHECK_SIZEOF(int8_t)
160 AC_CHECK_SIZEOF(int16_t)
161 AC_CHECK_SIZEOF(int32_t)
162 AC_CHECK_SIZEOF(int64_t)
163 AC_CHECK_SIZEOF(uint8_t)
164 AC_CHECK_SIZEOF(uint16_t)
165 AC_CHECK_SIZEOF(uint32_t)
166 AC_CHECK_SIZEOF(uint64_t)
167 AC_CHECK_SIZEOF(intptr_t)
168 AC_CHECK_SIZEOF(uintptr_t)
170 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
172 AC_CHECK_SIZEOF(char)
173 AC_CHECK_SIZEOF(short)
174 AC_CHECK_SIZEOF(int)
175 AC_CHECK_SIZEOF(long)
176 AC_CHECK_SIZEOF(long long)
177 AC_CHECK_SIZEOF(__int64)
178 AC_CHECK_SIZEOF(void *)
180 # Now, let's see about alignment requirements.  On some platforms, we override
181 # the default.
182 case $host in
183  ia64-*-* | arm-*-* )
184     tor_cv_unaligned_ok=no
185     ;;
186  *)
187 AC_CACHE_CHECK([whether unaligned int access is allowed], tor_cv_unaligned_ok,
188 [AC_RUN_IFELSE([AC_LANG_SOURCE(
189 [[int main () { char s[] = "A\x00\x00\x00\x00\x00\x00\x00";
190 return *(int*)(&s[1]); }]])],
191        [tor_cv_unaligned_ok=yes],
192        [tor_cv_unaligned_ok=no],
193        [tor_cv_unaligned_ok=cross])])
194 esac
196 if test $tor_cv_unaligned_ok = yes; then
197   AC_DEFINE([UNALIGNED_INT_ACCESS_OK], 1,
198             [Define to 1 iff unaligned int access is allowed])
201 # Now make sure that NULL can be represented as zero bytes.
202 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
203 [AC_RUN_IFELSE([AC_LANG_SOURCE(
204 [[#include <stdlib.h>
205 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
206 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
207        [tor_cv_null_is_zero=yes],
208        [tor_cv_null_is_zero=no],
209        [tor_cv_null_is_zero=cross])])
211 if test $tor_cv_null_is_zero = yes; then
212   AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
213             [Define to 1 iff memset(0) sets pointers to NULL])
216 # $prefix stores the value of the --prefix command line option, or
217 # NONE if the option wasn't set.  In the case that it wasn't set, make
218 # it be the default, so that we can use it to expand directories now.
219 if test "x$prefix" = "xNONE"; then
220   prefix=$ac_default_prefix
223 # and similarly for $exec_prefix
224 if test "x$exec_prefix" = "xNONE"; then
225   exec_prefix=$prefix
228 CONFDIR=`eval echo $sysconfdir/tor`
229 AC_SUBST(CONFDIR)
230 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
231 AC_DEFINE([CONFDIR], [], [tor's configuration directory])
233 BINDIR=`eval echo $bindir`
234 AC_SUBST(BINDIR)
236 LOCALSTATEDIR=`eval echo $localstatedir`
237 AC_SUBST(LOCALSTATEDIR)
239 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
240 # than autoconf's macros like.
241 CFLAGS="$CFLAGS -Wall -g -O2"
242 # Add some more warnings which we use in the cvs version but not in the
243 # released versions.  (Some relevant gcc versions can't handle these.)
244 #CFLAGS="$CFLAGS -W -Wno-unused-parameter -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls"
245 # Add these in when you feel like fun.
246 #CFLAGS="$CFLAGS -Wbad-function-cast -Werror -Wdeclaration-after-statement"
248 echo "confdir: $CONFDIR"
250 AC_OUTPUT(Makefile tor.spec contrib/tor.sh contrib/torctl contrib/torify contrib/Makefile contrib/osx/Makefile contrib/osx/TorBundleDesc.plist contrib/osx/TorBundleInfo.plist contrib/osx/TorDesc.plist contrib/osx/TorInfo.plist 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)
252 if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
253   ./contrib/updateVersions.pl