1
dnl Process this file with autoconf to produce a configure script.
3
dnl #########################################################################
5
dnl This file is part of libESMTP, a library for submission of RFC 2822
6
dnl formatted electronic mail messages using the SMTP protocol described
9
dnl Copyright (C) 2001 Brian Stafford <brian@stafford.uklinux.net>
11
dnl This library is free software; you can redistribute it and/or
12
dnl modify it under the terms of the GNU Lesser General Public
13
dnl License as published by the Free Software Foundation; either
14
dnl version 2.1 of the License, or (at your option) any later version.
16
dnl This library is distributed in the hope that it will be useful,
17
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
18
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
dnl Lesser General Public License for more details.
21
dnl You should have received a copy of the GNU Lesser General Public
22
dnl License along with this library; if not, write to the Free Software
23
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
dnl #########################################################################
28
AM_CONFIG_HEADER(config.h)
29
AM_INIT_AUTOMAKE([libesmtp],[0.8.11])
32
dnl #########################################################################
33
dnl Library versioning
34
dnl #########################################################################
40
AC_SUBST(LIB_REVISION)
43
LIBESMTP_VERSION="$LIB_CURRENT:$LIB_REVISION:$LIB_AGE"
44
AC_SUBST(LIBESMTP_VERSION)
47
dnl #########################################################################
48
dnl Checks for programs.
49
dnl #########################################################################
55
dnl #########################################################################
56
dnl Miscellaneous stuff
57
dnl #########################################################################
60
case $host_vendor-$host_os in
62
AC_DEFINE(__EXTENSIONS__,1,[Sun's netdb.h needs this for getaddrinfo])
65
AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
68
AC_DEFINE(_GNU_SOURCE,1,[GNU needs this for strcasecmp etc])
72
dnl #########################################################################
73
dnl turn warnings into errors to enforce clean code
74
dnl #########################################################################
76
AC_ARG_ENABLE([more-warnings],
77
ACX_HELP_STRING([--enable-more-warnings=no/yes/picky],[additional compiler warnings (default=yes)]),
79
enable_more_warnings=yes)
81
if test "$GCC" = "yes" -a "$enable_more_warnings" != "no"; then
82
EXTRA_CFLAGS="$EXTRA_CFLAGS \
83
-Wall -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \
84
-Wstrict-prototypes -Wnested-externs -Wpointer-arith \
85
-Wbad-function-cast -Wcast-align -Wsign-promo"
87
if test "$GCC" = "yes" -a "$enable_more_warnings" = "picky"; then
88
EXTRA_CFLAGS="$EXTRA_CFLAGS -fno-builtin -W -Werror -Wwrite-strings \
93
ACX_HELP_STRING([--disable-isoc],[check ISO C compliance (default=yes)]),
96
if test "$enable_isoc" != "no"; then
97
if test "$GCC" = "yes"; then
98
CFLAGS="-ansi -pedantic $CFLAGS"
100
AC_DEFINE(_ISOC9X_SOURCE,1,[ISO compliant code])
101
AC_DEFINE(_POSIX_C_SOURCE,199506L,[POSIX compliant code])
102
AC_DEFINE(_XOPEN_SOURCE,500,[Single Unix conformance])
105
dnl #########################################################################
106
dnl Checks for libraries and options.
107
dnl #########################################################################
109
AC_ARG_ENABLE([all],ACX_HELP_STRING([--enable-all], [convenience: enable features which default to off]),
113
dnl #########################################################################
114
dnl Check whether to use SUS functions or libltdl for loading plugins.
115
dnl #########################################################################
118
AC_SEARCH_LIBS(dlsym, dl svdl, [
119
AC_DEFINE([HAVE_DLSYM],1,[the dlsym() function is available])
122
if test x$have_dl = xno ; then
123
dnl # WARNING: I don't know what libraries ltdl depends on. I just assume
124
dnl # that if the punter asks for it, then it must be properly
125
dnl # installed and the dynamic linker will sort the dependencies
128
AC_SEARCH_LIBS(lt_dlsym, ltdl,
130
AC_MSG_ERROR([libltdl not found (available from http://www.gnu.org/software/libtool/)])
134
dnl #########################################################################
135
dnl Check if using Posix Threads
136
dnl #########################################################################
138
AC_ARG_ENABLE([pthreads],
139
ACX_HELP_STRING([--enable-pthreads], [build with support for Posix threads (default=auto)]),
141
enable_pthreads=auto)
143
if test x"$enable_pthreads" != xno ; then
144
ACX_PTHREAD(enable_pthreads=yes,
145
if test x"$enable_pthreads" = xyes ; then
146
AC_MSG_ERROR([Cannot find the pthread library.])
153
AC_MSG_CHECKING(whether to use Posix Threads)
154
if test x"$enable_pthreads" != xno ; then
155
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
156
LDFLAGS="$PTHREAD_LDFLAGS $LDFLAGS"
157
LIBS="$PTHREAD_LIBS $LIBS"
159
AC_DEFINE([USE_PTHREADS],1,[Build with support for Posix threading])
165
dnl #########################################################################
166
dnl Check if Posix getaddrinfo() is available. It is also possible to use
167
dnl the version from the lwres library distributed with BIND.
168
dnl #########################################################################
169
AC_ARG_ENABLE([emulate-getaddrinfo],
170
ACX_HELP_STRING([--enable-emulate-getaddrinfo],
171
[enable getaddrinfo emulation (default=no)]),
173
enable_emulate_getaddrinfo=no)
175
ACX_HELP_STRING([--with-lwres=DIR],
176
[use lwres library for getaddrinfo (default=no)]),
180
dnl ## enable force to test getaddrinfo.c
181
if test x$enable_emulate_getaddrinfo = xforce ; then
182
enable_emulate_getaddrinfo=yes
187
if test x$with_lwres != xno ; then
188
if test "$with_lwres" != yes ; then
189
CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
190
LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
192
AC_CHECK_HEADERS(lwres/netdb.h, ,
193
[AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
194
AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
195
[AC_MSG_ERROR([cannot find the lwres library])],
200
if test x$have_getaddrinfo != xyes ; then
201
AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
204
dnl # Special nonsense for systems that actually have getaddrinfo but
205
dnl # redefine the name to something else, e.g. OSF
206
if test x$have_getaddrinfo != xyes ; then
207
AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
211
struct addrinfo hints, *res;
214
err = getaddrinfo ("host", "service", &hints, &res);
218
], [AC_MSG_RESULT(no)])
223
if test x$have_getaddrinfo != xno ; then
224
if test x$enable_emulate_getaddrinfo != xno ; then
225
AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
227
AC_DEFINE(HAVE_GETADDRINFO, 1,
228
[Does system provide RFC 2553/Posix getaddrinfo?])
230
if test x$enable_emulate_getaddrinfo != xyes ; then
231
AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
233
LIBOBJS="$LIBOBJS getaddrinfo.o"
236
if test x"$enable_emulate_getaddrinfo" != xno ; then
239
dnl Try for getipnodebyname
240
AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
241
if test x"$have_resolver" != xno ; then
242
AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
243
[Set when getipnodebyname is available])
246
dnl Try for gethostbyname_r
247
if test x"$have_resolver" = xno ; then
248
AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
250
ACX_WHICH_GETHOSTBYNAME_R])
253
dnl Try for gethostbyname
254
if test x"$have_resolver" = xno ; then
255
if test x"$enable_pthreads" != xno ; then
256
AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
258
AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
259
[AC_MSG_ERROR([cannot find gethostbyname])])
261
LIBOBJS="$LIBOBJS gethostbyname.o"
263
AC_CACHE_CHECK([for IPv6 support], acx_cv_sys_use_ipv6, [
265
# include <netinet/in.h>
267
struct sockaddr_in6 sin6;
270
sin6.sin6_family = AF_INET6;
271
sin6.sin6_port = 587;
273
], [acx_cv_sys_use_ipv6=yes], [acx_cv_sys_use_ipv6=no])
275
if test x"$acx_cv_sys_use_ipv6" != xno ; then
276
AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
280
dnl #########################################################################
281
dnl Check if using OpenSSL
282
dnl #########################################################################
284
ACX_HELP_STRING([--with-openssl=DIR],
285
[build features depending on OpenSSL (default=auto)]),
288
if test x$with_openssl != xno ; then
289
if test "$with_openssl" != yes -a "$with_openssl" != auto ; then
290
CPPFLAGS="-I${with_openssl}/include $CPPFLAGS"
291
LDFLAGS="-L${with_openssl}/lib $LDFLAGS"
294
dnl *** with_openssl is either "yes" or "auto"
295
AC_CHECK_HEADER(openssl/ssl.h,,
296
if test x"$with_openssl" = xyes ; then
297
AC_MSG_ERROR([cannot find the ssl headers])
303
if test x$with_openssl != xno ; then
304
AC_CHECK_LIB(ssl, SSL_library_init, [
306
LIBS="-lssl -lcrypto $LIBS"
308
if test x"$with_openssl" = xyes ; then
309
AC_MSG_ERROR([cannot find the ssl library])
317
dnl #########################################################################
318
dnl Set OpenSSL dependencies for RPM - this sucks, there must be a better way.
319
dnl #########################################################################
325
if test x$with_openssl != xno ; then
326
RPM_REQUIRES="Requires:"
327
RPM_BUILDREQUIRES="BuildRequires:"
328
RPM_OPENSSL="openssl >= %{openssl}"
329
RPM_OPENSSLDEVEL="openssl-devel >= %{openssl}"
331
AC_SUBST(RPM_REQUIRES)
332
AC_SUBST(RPM_BUILDREQUIRES)
333
AC_SUBST(RPM_OPENSSL)
334
AC_SUBST(RPM_OPENSSLDEVEL)
336
dnl #########################################################################
337
dnl Check if using SMTP AUTH using SASL
338
dnl #########################################################################
340
dnl Force use of SMTP AUTH for now. Eventually it is hoped that
341
dnl the SASL API will move into a library of its own. The USE_SASL
342
dnl option will then be needed to select whether SMTP AUTH is to be
343
dnl built since libESMTP will depend on the SASL library.
345
AC_DEFINE(USE_SASL,1,[Build with support for SMTP AUTH using SASL])
346
SASL_PLUGINS="login plain crammd5"
348
dnl Set up the authentication plugin directory
350
AC_ARG_WITH(auth-plugin-dir,
351
ACX_HELP_STRING([--with-auth-plugin-dir=DIR],
352
[directory for SASL plugins (default=LIBDIR/esmtp-plugins)]),
354
if test x$plugindir = x ; then
355
plugindir=$libdir/esmtp-plugins
358
ACX_DEFINE_DIR([AUTHPLUGINDIR], $plugindir, [location of authentication plugins.])
362
dnl Check for md5 functions in OpenSSL. If these are present, use them
363
dnl in preference to the supplied md5.[ch] when building the CRAM-MD5
364
dnl SASL plugin. The assumption is that the OpenSSL functions are optimised
365
dnl and actively maintained.
369
if test x$with_openssl != xno ; then
370
AC_CHECK_HEADER(openssl/md5.h, [
371
AC_CHECK_LIB(crypto, MD5_Init, [
374
CRAMMD5_LIBS="-lcrypto"
375
AC_SUBST(CRAMMD5_LIBS)
379
if test x$use_local_md5_c != xno ; then
380
CRAMMD5_LIBOBJS="$CRAMMD5_LIBOBJS md5.o"
382
CRAMMD5_LTLIBOBJS=`echo "$CRAMMD5_LIBOBJS" | sed ['s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/']`
383
AC_SUBST(CRAMMD5_LTLIBOBJS)
385
dnl Check if enabling NTLM authentication. For now this requires that
386
dnl OpenSSL is available.
387
if test x$with_openssl != xno ; then
388
AC_CHECK_HEADER(openssl/md4.h, [
389
AC_CHECK_LIB(crypto, MD4_Init, [
391
SASL_PLUGINS="$SASL_PLUGINS ntlm"
398
if test x$have_libcrypto != xno ; then
399
AC_DEFINE(HAVE_LIBCRYPTO,1,[Set when -lcrypto from OpenSSL is available])
402
dnl #########################################################################
403
dnl Check if enabling STARTTLS
404
dnl #########################################################################
406
AC_MSG_CHECKING(whether to enable STARTTLS)
407
if test x"$with_openssl" != xno ; then
409
AC_DEFINE(USE_TLS,1,[Build with support for SMTP STARTTLS extension])
414
dnl #########################################################################
415
dnl Enable ETRN (experimental)
416
dnl #########################################################################
418
AC_ARG_ENABLE([etrn],
419
ACX_HELP_STRING([--enable-etrn],[experimental support for ETRN (default=no)]),
421
enable_etrn=$enable_all)
423
AC_MSG_CHECKING(whether to enable ETRN)
424
if test x"$enable_etrn" = xyes ; then
426
AC_DEFINE(USE_ETRN,1,[Enable experimental support for SMTP STARTTLS extension])
431
dnl #########################################################################
433
dnl #########################################################################
435
AC_ARG_ENABLE([xusr],
436
ACX_HELP_STRING([--disable-xusr],
437
[support for sendmail XUSR extension (default=yes)]),
441
AC_MSG_CHECKING(whether to enable sendmail XUSR)
442
if test x"$enable_xusr" = xyes ; then
444
AC_DEFINE(USE_XUSR,1,[Enable support for sendmail XUSR extension])
449
dnl #########################################################################
450
dnl Enable non-standard AUTH= syntax in EHLO response
451
dnl #########################################################################
453
AC_ARG_ENABLE([nsauth],
454
ACX_HELP_STRING([--enable-nsauth],
455
[support non-standard EHLO AUTH= response (default=no)]),
457
enable_nsauth=$enable_all)
459
AC_MSG_CHECKING([whether to enable non-standard EHLO AUTH= response])
460
if test x"$enable_nsauth" = xyes ; then
462
AC_DEFINE(AUTH_ID_HACK,1,[support non-standard EHLO AUTH= response])
467
dnl #########################################################################
468
dnl Require all recipients hack (not recommended)
469
dnl #########################################################################
471
AC_ARG_ENABLE([require-all-recipients],
472
ACX_HELP_STRING([--enable-require-all-recipients],
473
[[add extra API call, needed for Balsa (default=no)]]),
475
enable_require_all_recipients=$enable_all)
477
if test x"$enable_require_all_recipients" != xno ; then
478
AC_DEFINE(USE_REQUIRE_ALL_RECIPIENTS,1,
479
[Build smtp_option_require_all_recipients() API])
482
dnl #########################################################################
483
dnl Enable debugging code, e.g. assert()
484
dnl #########################################################################
486
AC_ARG_ENABLE([debug],
487
ACX_HELP_STRING([--enable-debug],
488
[enable use of debugging code (default=no)]),
492
if test x"$enable_debug" != xno ; then
493
AC_DEFINE(DEBUG,1, [Enable additional debugging code])
495
AC_DEFINE(NDEBUG,1, [Disable assertions])
498
dnl #########################################################################
499
dnl Checks for header files.
500
dnl #########################################################################
503
AC_CHECK_HEADERS(sys/ioctl.h unistd.h)
505
dnl #########################################################################
506
dnl Checks for typedefs, structures, and compiler characteristics.
507
dnl #########################################################################
516
dnl #########################################################################
518
dnl #########################################################################
519
AC_CHECK_SIZEOF(unsigned short)
520
AC_CHECK_SIZEOF(unsigned int)
521
AC_CHECK_SIZEOF(unsigned long)
523
dnl #########################################################################
524
dnl Checks for library functions.
525
dnl #########################################################################
527
AC_REPLACE_FUNCS(strdup strcasecmp strncasecmp)
528
AC_CHECK_FUNCS(strtol uname gethostname)
529
AC_SEARCH_LIBS(socket, socket)
531
dnl Conditional check for functions needed in threaded code
533
if test x"$enable_pthreads" != xno ; then
534
AC_SEARCH_LIBS(localtime_r, c_r cr,
535
AC_DEFINE(HAVE_LOCALTIME_R,1,[Set when localtime_r is available]),
536
AC_MSG_ERROR([Cannot find localtime_r.]))
537
AC_CHECK_FUNCS(strerror_r,[
538
AC_CACHE_CHECK([for working strerror_r],
539
acx_cv_sys_working_strerror_r, [
541
# define _SVID_SOURCE 1
546
s = strerror_r (0, (char *) 0, 0);
548
[acx_cv_sys_working_strerror_r=yes],
549
[acx_cv_working_strerror_r=no])
551
if test x$acx_cv_sys_working_strerror_r = xyes ; then
552
AC_DEFINE(HAVE_WORKING_STRERROR_R,1,[strerror_r works!])
556
AC_CHECK_FUNCS(localtime strerror)
559
dnl #########################################################################
560
dnl Check that snprintf works correctly.
561
dnl #########################################################################
562
ACX_SNPRINTF(,[LIBOBJS="$LIBOBJS snprintf.o"])
564
dnl #########################################################################
565
dnl Make substitutions
566
dnl #########################################################################
568
AC_SUBST(SASL_PLUGINS)
569
AC_SUBST(LIBTOOL_DEPS)
572
AC_SUBST(EXTRA_CFLAGS)
577
LTLIBOBJS=`echo "$LIBOBJS" | sed ['s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/']`
579
LTALLOCA=`echo "$ALLOCA" | sed ['s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/']`
582
AC_OUTPUT([libesmtp-config libesmtp.spec
583
Makefile login/Makefile plain/Makefile crammd5/Makefile ntlm/Makefile])
585
dnl #########################################################################
587
dnl #########################################################################
590
echo '*************************'
591
echo '*** libESMTP features ***'
592
echo '*************************'
593
d=`eval echo $plugindir`
594
ACX_FEATURE([with],[auth-plugin-dir],[`eval echo $d`])
595
ACX_FEATURE([with],[lwres])
596
ACX_FEATURE([with],[openssl])
597
ACX_FEATURE([enable],[pthreads])
598
ACX_FEATURE([enable],[etrn])
599
ACX_FEATURE([enable],[xusr])
600
ACX_FEATURE([enable],[nsauth])
601
ACX_FEATURE([enable],[require-all-recipients])
602
ACX_FEATURE([enable],[debug])