3 AM_INIT_AUTOMAKE(tor, 0.1.0.0-alpha-cvs)
4 AM_CONFIG_HEADER(orconfig.h)
8 if test -f /etc/redhat-release; then
9 CFLAGS="$CFLAGS -I/usr/kerberos/include"
13 [ --enable-debug compiles with debugging info],
14 [if test x$enableval = xyes; then
22 # The big search for OpenSSL
23 # copied from openssh's configure.ac
25 [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
27 if test "x$withval" != "xno" ; then
33 AC_SEARCH_LIBS(socket, [socket])
34 AC_SEARCH_LIBS(gethostbyname, [nsl])
35 AC_SEARCH_LIBS(pthread_create, [pthread])
36 AC_SEARCH_LIBS(event_loop, [event], , AC_MSG_ERROR(Libevent library not found. Tor requires libevent to build.))
39 saved_LDFLAGS="$LDFLAGS"
40 saved_CPPFLAGS="$CPPFLAGS"
41 if test "x$prefix" != "xNONE" ; then
42 tryssldir="$tryssldir $prefix"
44 AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
45 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
46 CPPFLAGS="$saved_CPPFLAGS"
47 LDFLAGS="$saved_LDFLAGS"
48 LIBS="$saved_LIBS -lssl -lcrypto"
50 # Skip directories if they don't exist
51 if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
54 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
55 # Try to use $ssldir/lib if it exists, otherwise
57 if test -d "$ssldir/lib" ; then
58 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
59 if test ! -z "$need_dash_r" ; then
60 LDFLAGS="-R$ssldir/lib $LDFLAGS"
63 LDFLAGS="-L$ssldir $saved_LDFLAGS"
64 if test ! -z "$need_dash_r" ; then
65 LDFLAGS="-R$ssldir $LDFLAGS"
68 # Try to use $ssldir/include if it exists, otherwise
70 if test -d "$ssldir/include" ; then
71 CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
73 CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
77 # Basic test to check for compatible version and correct linking
78 # *does not* test for RSA - that comes later.
82 #include <openssl/rand.h>
86 memset(a, 0, sizeof(a));
87 RAND_add(a, sizeof(a), sizeof(a));
88 return(RAND_status() <= 0);
97 if test ! -z "$found_crypto" ; then
102 if test -z "$found_crypto" ; then
103 AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
105 if test -z "$ssldir" ; then
109 ac_cv_openssldir=$ssldir
111 if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
113 dnl Need to recover ssldir - test above runs in subshell
114 ssldir=$ac_cv_openssldir
115 if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
116 # Try to use $ssldir/lib if it exists, otherwise
118 if test -d "$ssldir/lib" ; then
119 LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
120 if test ! -z "$need_dash_r" ; then
121 LDFLAGS="-R$ssldir/lib $LDFLAGS"
124 LDFLAGS="-L$ssldir $saved_LDFLAGS"
125 if test ! -z "$need_dash_r" ; then
126 LDFLAGS="-R$ssldir $LDFLAGS"
129 # Try to use $ssldir/include if it exists, otherwise
131 if test -d "$ssldir/include" ; then
132 CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
134 CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
142 dnl The warning message here is no longer strictly accurate.
144 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, , AC_MSG_WARN(some headers were not found, compilation may fail))
146 AC_CHECK_HEADERS(event.h, , AC_MSG_ERROR(Libevent header (event.h) not found. Tor requires libevent to build.))
148 AC_CHECK_HEADERS(zlib.h, , AC_MSG_ERROR(Zlib header (zlib.h) not found. Tor requires zlib to build. You may need to install a zlib development package.))
150 dnl These headers are not essential
152 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 pthread.h stddef.h)
154 AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit setrlimit strlcat strlcpy strtoull getpwnam ftello pthread_create gethostbyname_r getaddrinfo)
157 AC_CHECK_MEMBERS([struct timeval.tv_sec])
159 dnl In case we aren't given a working stdint.h, we'll need to grow our own.
162 AC_CHECK_SIZEOF(int8_t)
163 AC_CHECK_SIZEOF(int16_t)
164 AC_CHECK_SIZEOF(int32_t)
165 AC_CHECK_SIZEOF(int64_t)
166 AC_CHECK_SIZEOF(uint8_t)
167 AC_CHECK_SIZEOF(uint16_t)
168 AC_CHECK_SIZEOF(uint32_t)
169 AC_CHECK_SIZEOF(uint64_t)
170 AC_CHECK_SIZEOF(intptr_t)
171 AC_CHECK_SIZEOF(uintptr_t)
173 dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t, intptr_t, uintptr_t])
175 AC_CHECK_SIZEOF(char)
176 AC_CHECK_SIZEOF(short)
178 AC_CHECK_SIZEOF(long)
179 AC_CHECK_SIZEOF(long long)
180 AC_CHECK_SIZEOF(__int64)
181 AC_CHECK_SIZEOF(void *)
183 # Now, let's see about alignment requirements. On some platforms, we override
187 tor_cv_unaligned_ok=no
190 AC_CACHE_CHECK([whether unaligned int access is allowed], tor_cv_unaligned_ok,
191 [AC_RUN_IFELSE([AC_LANG_SOURCE(
192 [[int main () { char s[] = "A\x00\x00\x00\x00\x00\x00\x00";
193 return *(int*)(&s[1]); }]])],
194 [tor_cv_unaligned_ok=yes],
195 [tor_cv_unaligned_ok=no],
196 [tor_cv_unaligned_ok=cross])])
199 if test $tor_cv_unaligned_ok = yes; then
200 AC_DEFINE([UNALIGNED_INT_ACCESS_OK], 1,
201 [Define to 1 iff unaligned int access is allowed])
204 # Now make sure that NULL can be represented as zero bytes.
205 AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tor_cv_null_is_zero,
206 [AC_RUN_IFELSE([AC_LANG_SOURCE(
207 [[#include <stdlib.h>
213 int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2));
214 return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])],
215 [tor_cv_null_is_zero=yes],
216 [tor_cv_null_is_zero=no],
217 [tor_cv_null_is_zero=cross])])
219 if test $tor_cv_null_is_zero = yes; then
220 AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1,
221 [Define to 1 iff memset(0) sets pointers to NULL])
224 # Whether we should use the dmalloc memory allocation debugging library.
225 AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
227 [ --with-dmalloc Use debug memory allocation library. ],
228 [if [[ "$withval" = "yes" ]]; then
234 fi], [ dmalloc=0; AC_MSG_RESULT(no) ]
237 if [[ $dmalloc -eq 1 ]]; then
238 AC_CHECK_HEADERS(dmalloc.h, , AC_MSG_ERROR(dmalloc header file not found. Do you have the development files for dmalloc installed?))
239 AC_SEARCH_LIBS(dmalloc_malloc, [dmalloc], , AC_MSG_ERROR(Libdmalloc library not found. If you enable it you better have it installed.))
240 AC_DEFINE(USE_DMALLOC, 1, [Debug memory allocation library])
241 AC_DEFINE(DMALLOC_FUNC_CHECK, 1, [Enable dmalloc's malloc function check])
244 # $prefix stores the value of the --prefix command line option, or
245 # NONE if the option wasn't set. In the case that it wasn't set, make
246 # it be the default, so that we can use it to expand directories now.
247 if test "x$prefix" = "xNONE"; then
248 prefix=$ac_default_prefix
251 # and similarly for $exec_prefix
252 if test "x$exec_prefix" = "xNONE"; then
256 CONFDIR=`eval echo $sysconfdir/tor`
258 AC_DEFINE_UNQUOTED(CONFDIR,"$CONFDIR")
259 AC_DEFINE([CONFDIR], [], [tor's configuration directory])
261 BINDIR=`eval echo $bindir`
264 LOCALSTATEDIR=`eval echo $localstatedir`
265 AC_SUBST(LOCALSTATEDIR)
267 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
268 # than autoconf's macros like.
269 CFLAGS="$CFLAGS -Wall -g -O2"
270 # Add some more warnings which we use in the cvs version but not in the
271 # released versions. (Some relevant gcc versions can't handle these.)
272 #CFLAGS="$CFLAGS -W -Wno-unused-parameter -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls"
273 # Add these in when you feel like fun.
274 #CFLAGS="$CFLAGS -Wbad-function-cast -Werror -Wdeclaration-after-statement"
276 echo "confdir: $CONFDIR"
278 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)
280 if test -x /usr/bin/perl && test -x ./contrib/updateVersions.pl ; then
281 ./contrib/updateVersions.pl