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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603
|
dnl Process this file with autoconf to produce a configure script.
dnl #########################################################################
dnl
dnl This file is part of libESMTP, a library for submission of RFC 2822
dnl formatted electronic mail messages using the SMTP protocol described
dnl in RFC 2821.
dnl
dnl Copyright (C) 2001 Brian Stafford <brian@stafford.uklinux.net>
dnl
dnl This library is free software; you can redistribute it and/or
dnl modify it under the terms of the GNU Lesser General Public
dnl License as published by the Free Software Foundation; either
dnl version 2.1 of the License, or (at your option) any later version.
dnl
dnl This library is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl Lesser General Public License for more details.
dnl
dnl You should have received a copy of the GNU Lesser General Public
dnl License along with this library; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
dnl
dnl #########################################################################
AC_INIT(smtp-api.c)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([libesmtp],[0.8.11])
AC_CANONICAL_HOST
dnl #########################################################################
dnl Library versioning
dnl #########################################################################
LIB_CURRENT=5
LIB_REVISION=11
LIB_AGE=0
AC_SUBST(LIB_CURRENT)
AC_SUBST(LIB_REVISION)
AC_SUBST(LIB_AGE)
LIBESMTP_VERSION="$LIB_CURRENT:$LIB_REVISION:$LIB_AGE"
AC_SUBST(LIBESMTP_VERSION)
subdirs=
dnl #########################################################################
dnl Checks for programs.
dnl #########################################################################
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AM_PROG_LIBTOOL
dnl #########################################################################
dnl Miscellaneous stuff
dnl #########################################################################
EXTRA_CFLAGS=""
case $host_vendor-$host_os in
sun*)
AC_DEFINE(__EXTENSIONS__,1,[Sun's netdb.h needs this for getaddrinfo])
;;
osf*)
AC_DEFINE(_OSF_SOURCE,1,[OSF needs this for getaddrinfo])
;;
*gnu*)
AC_DEFINE(_GNU_SOURCE,1,[GNU needs this for strcasecmp etc])
;;
esac
dnl #########################################################################
dnl turn warnings into errors to enforce clean code
dnl #########################################################################
AC_ARG_ENABLE([more-warnings],
ACX_HELP_STRING([--enable-more-warnings=no/yes/picky],[additional compiler warnings (default=yes)]),
,
enable_more_warnings=yes)
if test "$GCC" = "yes" -a "$enable_more_warnings" != "no"; then
EXTRA_CFLAGS="$EXTRA_CFLAGS \
-Wall -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \
-Wstrict-prototypes -Wnested-externs -Wpointer-arith \
-Wbad-function-cast -Wcast-align -Wsign-promo"
fi
if test "$GCC" = "yes" -a "$enable_more_warnings" = "picky"; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -fno-builtin -W -Werror -Wwrite-strings \
-Wcast-qual"
fi
AC_ARG_ENABLE([isoc],
ACX_HELP_STRING([--disable-isoc],[check ISO C compliance (default=yes)]),
,
enable_isoc=yes)
if test "$enable_isoc" != "no"; then
if test "$GCC" = "yes"; then
CFLAGS="-ansi -pedantic $CFLAGS"
fi
AC_DEFINE(_ISOC9X_SOURCE,1,[ISO compliant code])
AC_DEFINE(_POSIX_C_SOURCE,199506L,[POSIX compliant code])
AC_DEFINE(_XOPEN_SOURCE,500,[Single Unix conformance])
fi
dnl #########################################################################
dnl Checks for libraries and options.
dnl #########################################################################
AC_ARG_ENABLE([all],ACX_HELP_STRING([--enable-all], [convenience: enable features which default to off]),
,
enable_all=no)
dnl #########################################################################
dnl Check whether to use SUS functions or libltdl for loading plugins.
dnl #########################################################################
have_dl=no
AC_SEARCH_LIBS(dlsym, dl svdl, [
AC_DEFINE([HAVE_DLSYM],1,[the dlsym() function is available])
have_dl=yes
])
if test x$have_dl = xno ; then
dnl # WARNING: I don't know what libraries ltdl depends on. I just assume
dnl # that if the punter asks for it, then it must be properly
dnl # installed and the dynamic linker will sort the dependencies
dnl # at link time.
AC_SEARCH_LIBS(lt_dlsym, ltdl,
have_dl=yes,
AC_MSG_ERROR([libltdl not found (available from http://www.gnu.org/software/libtool/)])
)
fi
dnl #########################################################################
dnl Check if using Posix Threads
dnl #########################################################################
AC_ARG_ENABLE([pthreads],
ACX_HELP_STRING([--enable-pthreads], [build with support for Posix threads (default=auto)]),
,
enable_pthreads=auto)
if test x"$enable_pthreads" != xno ; then
ACX_PTHREAD(enable_pthreads=yes,
if test x"$enable_pthreads" = xyes ; then
AC_MSG_ERROR([Cannot find the pthread library.])
else
enable_pthreads=no
fi
)
fi
AC_MSG_CHECKING(whether to use Posix Threads)
if test x"$enable_pthreads" != xno ; then
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
LDFLAGS="$PTHREAD_LDFLAGS $LDFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
CC="$PTHREAD_CC"
AC_DEFINE([USE_PTHREADS],1,[Build with support for Posix threading])
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
dnl #########################################################################
dnl Check if Posix getaddrinfo() is available. It is also possible to use
dnl the version from the lwres library distributed with BIND.
dnl #########################################################################
AC_ARG_ENABLE([emulate-getaddrinfo],
ACX_HELP_STRING([--enable-emulate-getaddrinfo],
[enable getaddrinfo emulation (default=no)]),
,
enable_emulate_getaddrinfo=no)
AC_ARG_WITH(lwres,
ACX_HELP_STRING([--with-lwres=DIR],
[use lwres library for getaddrinfo (default=no)]),
,
with_lwres=no)
dnl ## enable force to test getaddrinfo.c
if test x$enable_emulate_getaddrinfo = xforce ; then
enable_emulate_getaddrinfo=yes
have_getaddrinfo=no
else
have_getaddrinfo=no
if test x$with_lwres != xno ; then
if test "$with_lwres" != yes ; then
CPPFLAGS="-I${with_lwres}/include $CPPFLAGS"
LDFLAGS="-L${with_lwres}/lib $LDFLAGS"
fi
AC_CHECK_HEADERS(lwres/netdb.h, ,
[AC_MSG_ERROR([cannot find <lwres/netdb.h>])])
AC_CHECK_LIB(lwres, lwres_getaddrinfo, ,
[AC_MSG_ERROR([cannot find the lwres library])],
-lnsl -lpthread)
have_getaddrinfo=yes
fi
if test x$have_getaddrinfo != xyes ; then
AC_SEARCH_LIBS(getaddrinfo, socket resolv bind nsl c_r cr, have_getaddrinfo=yes)
fi
dnl # Special nonsense for systems that actually have getaddrinfo but
dnl # redefine the name to something else, e.g. OSF
if test x$have_getaddrinfo != xyes ; then
AC_MSG_CHECKING(if getaddrinfo is redefined in netdb.h)
AC_TRY_LINK([
# include <netdb.h>
], [
struct addrinfo hints, *res;
int err;
err = getaddrinfo ("host", "service", &hints, &res);
], [
have_getaddrinfo=yes
AC_MSG_RESULT(yes)
], [AC_MSG_RESULT(no)])
fi
fi
if test x$have_getaddrinfo != xno ; then
if test x$enable_emulate_getaddrinfo != xno ; then
AC_MSG_ERROR([getaddrinfo found but emulate-getaddrinfo was enabled])
fi
AC_DEFINE(HAVE_GETADDRINFO, 1,
[Does system provide RFC 2553/Posix getaddrinfo?])
else
if test x$enable_emulate_getaddrinfo != xyes ; then
AC_MSG_ERROR([getaddrinfo not found: try --with-lwres or --enable-emulate-getaddrinfo])
fi
LIBOBJS="$LIBOBJS getaddrinfo.o"
fi
if test x"$enable_emulate_getaddrinfo" != xno ; then
have_resolver=no
dnl Try for getipnodebyname
AC_SEARCH_LIBS(getipnodebyname, resolv bind nsl c_r cr, have_resolver=yes)
if test x"$have_resolver" != xno ; then
AC_DEFINE(HAVE_GETIPNODEBYNAME, 1,
[Set when getipnodebyname is available])
fi
dnl Try for gethostbyname_r
if test x"$have_resolver" = xno ; then
AC_SEARCH_LIBS(gethostbyname_r, resolv bind nsl c_r cr,
[have_resolver=yes
ACX_WHICH_GETHOSTBYNAME_R])
fi
dnl Try for gethostbyname
if test x"$have_resolver" = xno ; then
if test x"$enable_pthreads" != xno ; then
AC_MSG_WARN([using threads but cannot find gethostbyname_r or getipnodebyname])
fi
AC_SEARCH_LIBS(gethostbyname, resolv bind nsl, ,
[AC_MSG_ERROR([cannot find gethostbyname])])
fi
LIBOBJS="$LIBOBJS gethostbyname.o"
AC_CACHE_CHECK([for IPv6 support], acx_cv_sys_use_ipv6, [
AC_TRY_COMPILE([
# include <netinet/in.h>
], [
struct sockaddr_in6 sin6;
void *p;
sin6.sin6_family = AF_INET6;
sin6.sin6_port = 587;
p = &sin6.sin6_addr;
], [acx_cv_sys_use_ipv6=yes], [acx_cv_sys_use_ipv6=no])
])
if test x"$acx_cv_sys_use_ipv6" != xno ; then
AC_DEFINE(USE_IPV6,1,[Enable IPv6 support])
fi
fi
dnl #########################################################################
dnl Check if using OpenSSL
dnl #########################################################################
AC_ARG_WITH(openssl,
ACX_HELP_STRING([--with-openssl=DIR],
[build features depending on OpenSSL (default=auto)]),
,
with_openssl=auto)
if test x$with_openssl != xno ; then
if test "$with_openssl" != yes -a "$with_openssl" != auto ; then
CPPFLAGS="-I${with_openssl}/include $CPPFLAGS"
LDFLAGS="-L${with_openssl}/lib $LDFLAGS"
with_openssl=yes
fi
dnl *** with_openssl is either "yes" or "auto"
AC_CHECK_HEADER(openssl/ssl.h,,
if test x"$with_openssl" = xyes ; then
AC_MSG_ERROR([cannot find the ssl headers])
else
with_openssl=no
fi
)
fi
if test x$with_openssl != xno ; then
AC_CHECK_LIB(ssl, SSL_library_init, [
with_openssl=yes
LIBS="-lssl -lcrypto $LIBS"
], [
if test x"$with_openssl" = xyes ; then
AC_MSG_ERROR([cannot find the ssl library])
else
with_openssl=no
fi],
-lcrypto
)
fi
dnl #########################################################################
dnl Set OpenSSL dependencies for RPM - this sucks, there must be a better way.
dnl #########################################################################
RPM_REQUIRES=""
RPM_BUILDREQUIRES=""
RPM_OPENSSL=""
RPM_OPENSSLDEVEL=""
if test x$with_openssl != xno ; then
RPM_REQUIRES="Requires:"
RPM_BUILDREQUIRES="BuildRequires:"
RPM_OPENSSL="openssl >= %{openssl}"
RPM_OPENSSLDEVEL="openssl-devel >= %{openssl}"
fi
AC_SUBST(RPM_REQUIRES)
AC_SUBST(RPM_BUILDREQUIRES)
AC_SUBST(RPM_OPENSSL)
AC_SUBST(RPM_OPENSSLDEVEL)
dnl #########################################################################
dnl Check if using SMTP AUTH using SASL
dnl #########################################################################
dnl Force use of SMTP AUTH for now. Eventually it is hoped that
dnl the SASL API will move into a library of its own. The USE_SASL
dnl option will then be needed to select whether SMTP AUTH is to be
dnl built since libESMTP will depend on the SASL library.
AC_DEFINE(USE_SASL,1,[Build with support for SMTP AUTH using SASL])
SASL_PLUGINS="login plain crammd5"
dnl Set up the authentication plugin directory
AC_ARG_WITH(auth-plugin-dir,
ACX_HELP_STRING([--with-auth-plugin-dir=DIR],
[directory for SASL plugins (default=LIBDIR/esmtp-plugins)]),
plugindir=$withval)
if test x$plugindir = x ; then
plugindir=$libdir/esmtp-plugins
fi
AC_SUBST(plugindir)
ACX_DEFINE_DIR([AUTHPLUGINDIR], $plugindir, [location of authentication plugins.])
have_libcrypto=no
dnl Check for md5 functions in OpenSSL. If these are present, use them
dnl in preference to the supplied md5.[ch] when building the CRAM-MD5
dnl SASL plugin. The assumption is that the OpenSSL functions are optimised
dnl and actively maintained.
use_local_md5_c=yes
CRAMMD5_LIBOBJS=""
if test x$with_openssl != xno ; then
AC_CHECK_HEADER(openssl/md5.h, [
AC_CHECK_LIB(crypto, MD5_Init, [
have_libcrypto=yes
use_local_md5_c=no
CRAMMD5_LIBS="-lcrypto"
AC_SUBST(CRAMMD5_LIBS)
])
])
fi
if test x$use_local_md5_c != xno ; then
CRAMMD5_LIBOBJS="$CRAMMD5_LIBOBJS md5.o"
fi
CRAMMD5_LTLIBOBJS=`echo "$CRAMMD5_LIBOBJS" | sed ['s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/']`
AC_SUBST(CRAMMD5_LTLIBOBJS)
dnl Check if enabling NTLM authentication. For now this requires that
dnl OpenSSL is available.
if test x$with_openssl != xno ; then
AC_CHECK_HEADER(openssl/md4.h, [
AC_CHECK_LIB(crypto, MD4_Init, [
have_libcrypto=yes
SASL_PLUGINS="$SASL_PLUGINS ntlm"
NTLM_LIBS="-lcrypto"
AC_SUBST(NTLM_LIBS)
])
])
fi
if test x$have_libcrypto != xno ; then
AC_DEFINE(HAVE_LIBCRYPTO,1,[Set when -lcrypto from OpenSSL is available])
fi
dnl #########################################################################
dnl Check if enabling STARTTLS
dnl #########################################################################
AC_MSG_CHECKING(whether to enable STARTTLS)
if test x"$with_openssl" != xno ; then
AC_MSG_RESULT([yes])
AC_DEFINE(USE_TLS,1,[Build with support for SMTP STARTTLS extension])
else
AC_MSG_RESULT([no])
fi
dnl #########################################################################
dnl Enable ETRN (experimental)
dnl #########################################################################
AC_ARG_ENABLE([etrn],
ACX_HELP_STRING([--enable-etrn],[experimental support for ETRN (default=no)]),
,
enable_etrn=$enable_all)
AC_MSG_CHECKING(whether to enable ETRN)
if test x"$enable_etrn" = xyes ; then
AC_MSG_RESULT([yes])
AC_DEFINE(USE_ETRN,1,[Enable experimental support for SMTP STARTTLS extension])
else
AC_MSG_RESULT([no])
fi
dnl #########################################################################
dnl Enable XUSR
dnl #########################################################################
AC_ARG_ENABLE([xusr],
ACX_HELP_STRING([--disable-xusr],
[support for sendmail XUSR extension (default=yes)]),
,
enable_xusr=yes)
AC_MSG_CHECKING(whether to enable sendmail XUSR)
if test x"$enable_xusr" = xyes ; then
AC_MSG_RESULT([yes])
AC_DEFINE(USE_XUSR,1,[Enable support for sendmail XUSR extension])
else
AC_MSG_RESULT([no])
fi
dnl #########################################################################
dnl Enable non-standard AUTH= syntax in EHLO response
dnl #########################################################################
AC_ARG_ENABLE([nsauth],
ACX_HELP_STRING([--enable-nsauth],
[support non-standard EHLO AUTH= response (default=no)]),
,
enable_nsauth=$enable_all)
AC_MSG_CHECKING([whether to enable non-standard EHLO AUTH= response])
if test x"$enable_nsauth" = xyes ; then
AC_MSG_RESULT([yes])
AC_DEFINE(AUTH_ID_HACK,1,[support non-standard EHLO AUTH= response])
else
AC_MSG_RESULT([no])
fi
dnl #########################################################################
dnl Require all recipients hack (not recommended)
dnl #########################################################################
AC_ARG_ENABLE([require-all-recipients],
ACX_HELP_STRING([--enable-require-all-recipients],
[[add extra API call, needed for Balsa (default=no)]]),
,
enable_require_all_recipients=$enable_all)
if test x"$enable_require_all_recipients" != xno ; then
AC_DEFINE(USE_REQUIRE_ALL_RECIPIENTS,1,
[Build smtp_option_require_all_recipients() API])
fi
dnl #########################################################################
dnl Enable debugging code, e.g. assert()
dnl #########################################################################
AC_ARG_ENABLE([debug],
ACX_HELP_STRING([--enable-debug],
[enable use of debugging code (default=no)]),
,
enable_debug=no)
if test x"$enable_debug" != xno ; then
AC_DEFINE(DEBUG,1, [Enable additional debugging code])
else
AC_DEFINE(NDEBUG,1, [Disable assertions])
fi
dnl #########################################################################
dnl Checks for header files.
dnl #########################################################################
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/ioctl.h unistd.h)
dnl #########################################################################
dnl Checks for typedefs, structures, and compiler characteristics.
dnl #########################################################################
AC_C_CONST
AC_C_INLINE
AC_C_BIGENDIAN
AC_STRUCT_TM
AC_HEADER_TIME
AC_STRUCT_TIMEZONE
dnl #########################################################################
dnl Check for types
dnl #########################################################################
AC_CHECK_SIZEOF(unsigned short)
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long)
dnl #########################################################################
dnl Checks for library functions.
dnl #########################################################################
AC_REPLACE_FUNCS(strdup strcasecmp strncasecmp)
AC_CHECK_FUNCS(strtol uname gethostname)
AC_SEARCH_LIBS(socket, socket)
dnl Conditional check for functions needed in threaded code
if test x"$enable_pthreads" != xno ; then
AC_SEARCH_LIBS(localtime_r, c_r cr,
AC_DEFINE(HAVE_LOCALTIME_R,1,[Set when localtime_r is available]),
AC_MSG_ERROR([Cannot find localtime_r.]))
AC_CHECK_FUNCS(strerror_r,[
AC_CACHE_CHECK([for working strerror_r],
acx_cv_sys_working_strerror_r, [
AC_TRY_COMPILE([
# define _SVID_SOURCE 1
# include <string.h>
], [
char *s;
s = strerror_r (0, (char *) 0, 0);
],
[acx_cv_sys_working_strerror_r=yes],
[acx_cv_working_strerror_r=no])
])
if test x$acx_cv_sys_working_strerror_r = xyes ; then
AC_DEFINE(HAVE_WORKING_STRERROR_R,1,[strerror_r works!])
fi
])
else
AC_CHECK_FUNCS(localtime strerror)
fi
dnl #########################################################################
dnl Check that snprintf works correctly.
dnl #########################################################################
ACX_SNPRINTF(,[LIBOBJS="$LIBOBJS snprintf.o"])
dnl #########################################################################
dnl Make substitutions
dnl #########################################################################
AC_SUBST(SASL_PLUGINS)
AC_SUBST(LIBTOOL_DEPS)
AC_SUBST(LIBS)
AC_SUBST(CFLAGS)
AC_SUBST(EXTRA_CFLAGS)
AC_SUBST(CC)
AC_SUBST(RANLIB)
AC_SUBST(subdirs)
LTLIBOBJS=`echo "$LIBOBJS" | sed ['s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/']`
AC_SUBST(LTLIBOBJS)
LTALLOCA=`echo "$ALLOCA" | sed ['s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/']`
AC_SUBST(LTALLOCA)
AC_OUTPUT([libesmtp-config libesmtp.spec
Makefile login/Makefile plain/Makefile crammd5/Makefile ntlm/Makefile])
dnl #########################################################################
dnl Feature synopsis
dnl #########################################################################
echo
echo '*************************'
echo '*** libESMTP features ***'
echo '*************************'
d=`eval echo $plugindir`
ACX_FEATURE([with],[auth-plugin-dir],[`eval echo $d`])
ACX_FEATURE([with],[lwres])
ACX_FEATURE([with],[openssl])
ACX_FEATURE([enable],[pthreads])
ACX_FEATURE([enable],[etrn])
ACX_FEATURE([enable],[xusr])
ACX_FEATURE([enable],[nsauth])
ACX_FEATURE([enable],[require-all-recipients])
ACX_FEATURE([enable],[debug])
|