-
Notifications
You must be signed in to change notification settings - Fork 70
/
configure.in
212 lines (178 loc) · 6.39 KB
/
configure.in
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
AC_PREREQ(2.50)
dnl Autoconf. ick.
dnl Here's how to rebuild the "configure" script from this source file:
dnl
dnl cd spamc; autoconf; autoheader
AC_INIT
AC_ARG_ENABLE(ssl,
AC_HELP_STRING([--enable-ssl],
[build spamc with ssl support ('yes'/'no', default is 'no')]),
[sa_ssl_enabled=${enableval:-no}],
[sa_ssl_enabled=${enableval:-no}])
AC_CONFIG_SRCDIR([Makefile.PL])
AC_CONFIG_HEADER(config.h)
dnl ensure Makefile.PL has been run too
if test -f Makefile.PL -a ! -f Makefile ; then
perl Makefile.PL || exit 1
fi
AC_PROG_CC
# off: breaks gcc 3.3.x! doh
# if test "x$GCC" = "xyes" ; then
# CFLAGS="-Wall -Wextra -Wdeclaration-after-statement $CFLAGS"
# fi
AC_EXEEXT
dnl ----------------------------------------------------------------------
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/time.h syslog.h unistd.h errno.h sys/errno.h)
AC_CHECK_HEADERS(time.h sysexits.h sys/socket.h netdb.h netinet/in.h)
AC_CHECK_HEADERS(pwd.h signal.h openssl/crypto.h zlib.h)
dnl AC_CHECK_HEADERS(getopt.h)
AC_C_CONST
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_UID_T
AC_TYPE_SIZE_T
dnl ----------------------------------------------------------------------
AC_CACHE_CHECK([for SHUT_RD],
shutrd, [
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>],
[printf ("%d", SHUT_RD); return 0;],
[shutrd=yes],
[shutrd=no]),
])
if test $shutrd = yes ; then
AC_DEFINE(HAVE_SHUT_RD)
fi
dnl ----------------------------------------------------------------------
AC_CHECK_LIB(socket, socket)
SSLLIBS=""
SSLCFLAGS=""
if test yes = "$sa_ssl_enabled"; then
AC_CHECK_LIB(crypto, CRYPTO_lock,[SSLLIBS="-lcrypto $SSLLIBS"])
AC_CHECK_LIB(ssl, SSL_CTX_free,[SSLLIBS="-lssl $SSLLIBS"],,-lcrypto)
# before defining SPAMC_SSL check that all its requirements are
# actually available
if test yes = "$ac_cv_header_openssl_crypto_h" && \
test yes = "$ac_cv_lib_crypto_CRYPTO_lock" && \
test yes = "$ac_cv_lib_ssl_SSL_CTX_free"; then
SSLCFLAGS="-DSPAMC_SSL"
else
AC_MSG_ERROR([Cannot use SSL; libraries or header files are missing.
You may try using 'configure --disable-ssl'.])
fi
fi
AC_CHECK_LIB(inet, connect)
AC_CHECK_LIB(nsl, t_accept)
AC_CHECK_LIB(z, deflate)
AC_CHECK_LIB(dl, dlopen)
AC_CHECK_FUNCS(socket strdup strtod strtol snprintf shutdown)
dnl ----------------------------------------------------------------------
AC_CACHE_CHECK([for h_errno],
herrno, [
AC_TRY_COMPILE([#include <netdb.h>],
[printf ("%d", h_errno); return 0;],
[herrno=yes],
[herrno=no]),
])
if test $herrno = yes ; then
AC_DEFINE(HAVE_H_ERRNO)
fi
dnl ----------------------------------------------------------------------
dnl AC_CACHE_CHECK([for optarg],
dnl haveoptarg, [
dnl AC_TRY_COMPILE([#include <getopt.h>],
dnl [if (optarg == (char *) 0L) { return 0; } return 1;],
dnl [haveoptarg=yes],
dnl [haveoptarg=no]),
dnl ])
dnl if test $haveoptarg = yes ; then
dnl AC_DEFINE(HAVE_OPTARG)
dnl fi
dnl ----------------------------------------------------------------------
AC_CACHE_CHECK([for in_addr_t],
inaddrt, [
AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>],
[in_addr_t foo; return 0;],
[inaddrt=yes],
[inaddrt=no]),
])
if test $inaddrt = no ; then
AC_CHECK_TYPE(in_addr_t, unsigned long)
fi
dnl ----------------------------------------------------------------------
AC_CACHE_CHECK([for INADDR_NONE],
haveinaddrnone, [
AC_TRY_COMPILE([#include <sys/types.h>
#include <netinet/in.h>],
[in_addr_t foo = INADDR_NONE; return 0;],
[haveinaddrnone=yes],
[haveinaddrnone=no]),
])
if test $haveinaddrnone = yes ; then
AC_DEFINE(HAVE_INADDR_NONE)
fi
dnl ----------------------------------------------------------------------
AC_CACHE_CHECK([for EX__MAX],
haveexmax, [
AC_TRY_COMPILE([#ifdef HAVE_SYSEXITS_H
#include <sysexits.h>
#endif
#include <errno.h>],
[int foo = EX__MAX; return 0;],
[haveexmax=yes],
[haveexmax=no]),
])
if test $haveexmax = yes ; then
AC_DEFINE(HAVE_EX__MAX)
fi
dnl ----------------------------------------------------------------------
AC_CACHE_CHECK([for EAI_ADDRFAMILY],
haveitem, [
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>],
[int foo = EAI_ADDRFAMILY; return 0;],
[haveitem=yes],
[haveitem=no]),
])
if test $haveitem = yes ; then
AC_DEFINE(HAVE_EAI_ADDRFAMILY, 1, [Define if EAI_ADDRFAMILY is valid.])
fi
AC_CACHE_CHECK([for EAI_SYSTEM],
haveitem, [
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>],
[int foo = EAI_SYSTEM; return 0;],
[haveitem=yes],
[haveitem=no]),
])
if test $haveitem = yes ; then
AC_DEFINE(HAVE_EAI_SYSTEM, 1, [Define if EAI_SYSTEM is valid.])
fi
AC_CACHE_CHECK([for EAI_NODATA],
haveitem, [
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>],
[int foo = EAI_NODATA; return 0;],
[haveitem=yes],
[haveitem=no]),
])
if test $haveitem = yes ; then
AC_DEFINE(HAVE_EAI_NODATA, 1, [Define if EAI_NODATA is valid.])
fi
dnl ----------------------------------------------------------------------
# we cheat, since we *know* we have Perl installed ;)
CCCDLFLAGS=`perl -e 'use Config; print $Config::Config{cccdlflags}'`
LDDLFLAGS=`perl -e 'use Config; print $Config::Config{lddlflags}'`
AC_SUBST([SSLLIBS])
AC_SUBST([SSLCFLAGS])
AC_SUBST(CCCDLFLAGS)
AC_SUBST(LDDLFLAGS)
AC_SUBST(HAVE_SHUT_RD)
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([spamc.h])
AC_OUTPUT