aboutsummaryrefslogtreecommitdiff
path: root/configure.in
blob: d0dddc4acb8068f82f2536ca4f9f9cee5f794883 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
AC_INIT
AM_INIT_AUTOMAKE(tor, 0.0.2pre9)
AM_CONFIG_HEADER(orconfig.h)

CFLAGS="-Wall -O2 -I/usr/kerberos/include"

AC_ARG_ENABLE(debug,
[  --enable-debug          compiles with debugging info],
[if test x$enableval = xyes; then
    CFLAGS="$CFLAGS -g"
fi])

AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_RANLIB

# The big search for OpenSSL
# copied from openssh's configure.ac
AC_ARG_WITH(ssl-dir,
        [  --with-ssl-dir=PATH     Specify path to OpenSSL installation ],
        [
                if test "x$withval" != "xno" ; then
                        tryssldir=$withval
                fi
        ]
)

saved_LIBS="$LIBS"
saved_LDFLAGS="$LDFLAGS"
saved_CPPFLAGS="$CPPFLAGS"
if test "x$prefix" != "xNONE" ; then
        tryssldir="$tryssldir $prefix"
fi
AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
        for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
                CPPFLAGS="$saved_CPPFLAGS"
                LDFLAGS="$saved_LDFLAGS"
                LIBS="$saved_LIBS -lcrypto -lssl"
                
                # Skip directories if they don't exist
                if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
                        continue;
                fi
                if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
                        # Try to use $ssldir/lib if it exists, otherwise 
                        # $ssldir
                        if test -d "$ssldir/lib" ; then
                                LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
                                if test ! -z "$need_dash_r" ; then
                                        LDFLAGS="-R$ssldir/lib $LDFLAGS"
                                fi
                        else
                                LDFLAGS="-L$ssldir $saved_LDFLAGS"
                                if test ! -z "$need_dash_r" ; then
                                        LDFLAGS="-R$ssldir $LDFLAGS"
                                fi
                        fi
                        # Try to use $ssldir/include if it exists, otherwise 
                        # $ssldir
                        if test -d "$ssldir/include" ; then
                                CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
                        else
                                CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
                        fi
                fi

                # Basic test to check for compatible version and correct linking
                # *does not* test for RSA - that comes later.
                AC_TRY_RUN(
                        [
#include <string.h>
#include <openssl/rand.h>
int main(void) 
{
        char a[2048];
        memset(a, 0, sizeof(a));
        RAND_add(a, sizeof(a), sizeof(a));
        return(RAND_status() <= 0);
}
                        ],
                        [
                                found_crypto=1
                                break;
                        ], []
                )

                if test ! -z "$found_crypto" ; then
                        break;
                fi
        done

        if test -z "$found_crypto" ; then
                AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])      
        fi
        if test -z "$ssldir" ; then
                ssldir="(system)"
        fi

        ac_cv_openssldir=$ssldir
])
if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
 then
        dnl Need to recover ssldir - test above runs in subshell
        ssldir=$ac_cv_openssldir
        if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
                # Try to use $ssldir/lib if it exists, otherwise 
                # $ssldir
                if test -d "$ssldir/lib" ; then
                        LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
                        if test ! -z "$need_dash_r" ; then
                                LDFLAGS="-R$ssldir/lib $LDFLAGS"
                        fi
                else
                        LDFLAGS="-L$ssldir $saved_LDFLAGS"
                        if test ! -z "$need_dash_r" ; then
                                LDFLAGS="-R$ssldir $LDFLAGS"
                        fi
                fi
                # Try to use $ssldir/include if it exists, otherwise 
                # $ssldir
                if test -d "$ssldir/include" ; then
                        CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
                else
                        CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
                fi
        fi
fi
LIBS="$saved_LIBS -lcrypto -lssl"

dnl The warning message here is no longer strictly accurate.

AC_CHECK_HEADERS(unistd.h string.h signal.h netdb.h ctype.h poll.h sys/stat.h sys/poll.h sys/types.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, , AC_MSG_WARN(some headers were not found, compilation may fail))

dnl These headers are not essential

AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/wait.h netinet/in.h arpa/inet.h)

AC_CHECK_FUNCS(gettimeofday ftime socketpair uname)

dnl In case we aren't given a working stdint.h, we'll need to grow our own.
dnl Watch out.

AC_CHECK_SIZEOF(int8_t)
AC_CHECK_SIZEOF(int16_t)
AC_CHECK_SIZEOF(int32_t)
AC_CHECK_SIZEOF(int64_t)
AC_CHECK_SIZEOF(uint8_t)
AC_CHECK_SIZEOF(uint16_t)
AC_CHECK_SIZEOF(uint32_t)
AC_CHECK_SIZEOF(uint64_t)

dnl AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t])

AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(__int64)

AC_OUTPUT(Makefile src/Makefile doc/Makefile src/config/Makefile src/common/Makefile src/or/Makefile)