1dnl configure.ac -- autoconf template for nmh 2dnl 3 4AC_PREREQ([2.68]) 5 6AC_INIT([nmh], m4_normalize(m4_include([VERSION])), [nmh-workers@nongnu.org]) 7AC_CONFIG_SRCDIR([h/nmh.h]) 8AC_CONFIG_HEADER([config.h]) 9AM_INIT_AUTOMAKE([-Wall foreign serial-tests subdir-objects 1.12]) 10 11AC_CANONICAL_HOST 12 13AC_MSG_NOTICE([configuring for AC_PACKAGE_NAME-AC_PACKAGE_VERSION]) 14AC_SUBST(VERSION,AC_PACKAGE_VERSION)dnl 15 16dnl What date of nmh are we building? 17DATE=`cat ${srcdir}/DATE` 18AC_MSG_NOTICE([configuring for nmh dated $DATE]) 19AC_SUBST([DATE])dnl 20 21dnl -------------------------- 22dnl CHECK COMMAND LINE OPTIONS 23dnl -------------------------- 24 25dnl Do you want client-side support for using SASL for authentication? 26dnl Note that this code will be enabled for both POP and SMTP 27AC_ARG_WITH([cyrus-sasl], AS_HELP_STRING([--with-cyrus-sasl], 28 [Enable SASL support via the Cyrus SASL library])) 29AS_IF([test x"$with_cyrus_sasl" != x -a x"$with_cyrus_sasl" != xyes -a \ 30 x"$with_cyrus_sasl" != xno],[ 31 AC_MSG_WARN([Arguments to --with-cyrus-sasl now ignored]) 32 AC_MSG_WARN([Please pass the appropriate arguments to CPPFLAGS/LDFLAGS])]) 33 34dnl Do you want client-side support for encryption with TLS? 35AC_ARG_WITH([tls], AS_HELP_STRING([--with-tls], [Enable TLS support])) 36 37dnl Do you want client-side support for using OAuth2 for SMTP & POP auth? 38AC_ARG_WITH([oauth], AS_HELP_STRING([--with-oauth], 39 [Enable OAuth2 support in SMTP and POP auth])) 40 41dnl Set the backup prefix 42AC_ARG_WITH([hash-backup], 43 AS_HELP_STRING([--with-hash-backup],[use # as the backup prefix (default: ,)])) 44AS_IF([test x"$with_hash_backup" != x -a x"$with_hash_backup" != x"no"], 45 [backup_prefix="#"], [backup_prefix=","]) 46AC_DEFINE_UNQUOTED([BACKUP_PREFIX], "$backup_prefix", 47 [The prefix that is prepended to the name of message files when they are "removed" by rmm. This should typically be `,' or `#'.])dnl 48 49dnl What method of posting should post use? 50AC_ARG_WITH([mts], 51 AS_HELP_STRING([--with-mts=@<:@smtp|sendmail/smtp|sendmail/pipe@:>@], 52 [specify the default mail transport agent/service])) 53 54AS_IF([test x"$with_mts" = x"smtp"], [MTS="smtp"], 55 [test x"$with_mts" = x"sendmail"], [MTS="sendmail/smtp"], 56 [test x"$with_mts" = x"sendmail/smtp"], [MTS="sendmail/smtp"], 57 [test x"$with_mts" = x"sendmail/pipe"], [MTS="sendmail/pipe"], 58 [MTS="smtp"]) 59AC_SUBST([MTS])dnl 60 61dnl What should be the default mail server? 62AC_ARG_WITH([smtpserver], 63 [AS_HELP_STRING([--with-smtpserver='SMTPSERVER'], 64 [specify the default SMTP server @<:@localhost@:>@])]) 65AS_IF([test -n "$with_smtpserver"], [smtpserver="$with_smtpserver"], 66 [smtpserver="localhost"]) 67AC_SUBST([smtpserver])dnl 68 69dnl ------------------------------------------------------------------- 70dnl Default location is /usr/local/nmh/{bin,etc,libexec,man}, unless we 71dnl find an existing installation, in which case we use its location. 72dnl ------------------------------------------------------------------- 73AC_PREFIX_DEFAULT([/usr/local/nmh]) 74AC_PREFIX_PROGRAM([mhparam]) 75 76dnl ------------------ 77dnl CHECK THE COMPILER 78dnl ------------------ 79 80AC_PROG_CC([cc gcc]) 81AM_PROG_CC_C_O 82 83dnl ------------------ 84dnl CHECK HEADER FILES 85dnl ------------------ 86 87AC_HEADER_TIOCGWINSZ 88AC_CHECK_HEADERS([fcntl.h stdbool.h wchar.h wctype.h \ 89 sys/param.h sys/time.h sys/stream.h]) 90 91AC_CHECK_HEADER([sys/ptem.h], AC_DEFINE(WINSIZE_IN_PTEM,1, 92 [Define to 1 if `struct winsize' requires <sys/ptem.h>.]),, 93[[#if HAVE_SYS_STREAM_H 94# include <sys/stream.h> 95#endif 96]]) 97 98dnl --------------- 99dnl CHECK FUNCTIONS 100dnl --------------- 101AC_CHECK_FUNCS([wcwidth mbtowc getutxent arc4random mkstemps]) 102 103dnl Use custom getline for platforms that don't have it. 104AC_CONFIG_LIBOBJ_DIR([sbr]) 105AC_REPLACE_FUNCS([getline]) 106 107dnl ----------------------- 108dnl CHECK MULTIBYTE SUPPORT 109dnl ----------------------- 110AS_IF([test "x$ac_cv_header_wchar_h" = "xyes" -a \ 111 "x$ac_cv_header_wctype_h" = "xyes" -a \ 112 "x$ac_cv_func_wcwidth" = "xyes" -a \ 113 "x$ac_cv_func_mbtowc" = "xyes"], 114 [AC_DEFINE([MULTIBYTE_SUPPORT], [1], 115 [Define to enable support for multibyte character sets.]) 116 MULTIBYTE_ENABLED=1], 117 [MULTIBYTE_ENABLED=0]) 118AC_SUBST([MULTIBYTE_ENABLED]) 119 120dnl ---------------- 121dnl CUSTOMIZE CFLAGS 122dnl ---------------- 123dnl The user didn't specify CFLAGS, so customize them. 124 125if test "$GCC" != yes; then 126 dnl Use -v and some other options with SunStudio cc. lex produces 127 dnl code that causes unreachable-statement warnings. It might be 128 dnl better to use an autoconf test, except -v will probably succeed 129 dnl with many other compilers but have different meaning. 130 AS_CASE([`${CC} -V 2>&1`], 131 [cc:*\ Sun\ C*], [CFLAGS=\ 132"${CFLAGS:+$CFLAGS }-v -errtags=yes -erroff=E_STATEMENT_NOT_REACHED"]) 133fi 134 135AC_CACHE_CHECK([whether compiler supports -Wall], [nmh_cv_has_wall], 136 [nmh_saved_cflags="$CFLAGS" 137 CFLAGS="$AM_CFLAGS $CFLAGS -Wall -Werror" 138 AC_TRY_COMPILE([],[],nmh_cv_has_wall=yes,nmh_cv_has_wall=no) 139 CFLAGS="$nmh_saved_cflags"]) 140test "$nmh_cv_has_wall" = "yes" && CFLAGS="${CFLAGS:+$CFLAGS }-Wall" 141 142AC_CACHE_CHECK([whether compiler supports -Wextra], [nmh_cv_has_wextra], 143 [nmh_saved_cflags="$CFLAGS" 144 CFLAGS="$AM_CFLAGS $CFLAGS -Wextra -Werror" 145 AC_TRY_COMPILE([],[],nmh_cv_has_wextra=yes, 146 nmh_cv_has_wextra=no) 147 CFLAGS="$nmh_saved_cflags"]) 148test "$nmh_cv_has_wextra" = "yes" && CFLAGS="${CFLAGS:+$CFLAGS }-Wextra" 149 150AC_SUBST([AM_CFLAGS]) 151 152dnl Check for any platform-specific additional AM_CPPFLAGS. This depends on 153dnl MULTIBYTE_ENABLED having already been set. 154NMH_ADDL_CPPFLAGS 155 156dnl FreeBSD needs a bit of magic to bring getline() into scope. 157dnl We do this here rather than in (say) h/mh.h because this macro must 158dnl be defined before <stdio.h> is pulled in. 159dnl 160dnl And while we're here, add the packages tree to the cpp and ld search 161dnl paths. Note that FreeBSD's pkg(8) seems to be hardwired to use /usr/local. 162dnl If /usr/ports is installed, we use its idea of where things are installed, 163dnl otherwise we assume /usr/local. 164 165AS_IF([test `uname` = FreeBSD], 166 [CPPFLAGS="${CPPFLAGS:+$CPPFLAGS }-D_WITH_GETLINE" 167 nmh_cv_freebsd_localbase=`echo '.include <bsd.port.mk>' \ 168 | make -k -f /dev/stdin -V LOCALBASE 2>/dev/null | sed 1q` 169 test -z "$nmh_cv_freebsd_localbase" && nmh_cv_freebsd_localbase=/usr/local 170 CPPFLAGS="${CPPFLAGS:+$CPPFLAGS }-I$nmh_cv_freebsd_localbase/include" 171 LDFLAGS="${LDFLAGS:+$LDFLAGS }-L$nmh_cv_freebsd_localbase/lib" 172]) 173 174dnl -------------- 175dnl CUSTOMIZE LINK 176dnl -------------- 177AS_IF([test `uname` = OpenBSD], 178 dnl Munge "often/almost always misused" warnings from OpenBSD linker 179 dnl so that they don't color the waterfall. 180 [POSTLINK="2>&1 | sed -e \ 181's/: w\(arning: s.*() is .* misused, please use\)/: W\1/'"]) 182AC_SUBST([POSTLINK]) 183 184dnl ----------------- 185dnl CUSTOMIZE LDFLAGS 186dnl ----------------- 187dnl Disable clang complaint about unused -ansi when linking. 188AC_CACHE_CHECK([whether linker supports -Qunused-arguments], 189 [nmh_cv_has_q_unused_arguments], 190 [AS_IF([test "$GCC" = yes && `${CC} --version 2>&1 | \ 191 grep clang >/dev/null`], 192 [nmh_saved_ldflags="$LDFLAGS" 193 LDFLAGS="$AM_LDFLAGS $LDFLAGS -Qunused-arguments" 194 AC_TRY_LINK([],[],nmh_cv_has_q_unused_arguments=yes, 195 nmh_cv_has_q_unused_arguments=no) 196 LDFLAGS="$nmh_saved_ldflags"], 197 [nmh_cv_has_q_unused_arguments=no])]) 198test "$nmh_cv_has_q_unused_arguments" = "yes" && \ 199 AM_LDFLAGS="${AM_LDFLAGS:+$AM_LDFLAGS }-Qunused-arguments" 200AC_SUBST([AM_LDFLAGS]) 201 202AC_HEADER_ASSERT 203 204dnl ------------------ 205dnl CHECK FOR PROGRAMS 206dnl ------------------ 207AC_PROG_MAKE_SET dnl Does make define $MAKE 208AC_PROG_INSTALL dnl Check for BSD compatible `install' 209AC_PROG_RANLIB dnl Check for `ranlib' 210AC_PROG_AWK dnl Check for mawk,gawk,nawk, then awk 211AC_PROG_SED dnl Check for Posix-compliant sed 212AC_PROG_YACC dnl Check for yacc/bison 213AM_PROG_LEX dnl Check for lex/flex 214 215AM_PROG_AR 216 217dnl Look for `cut' 218pathtmp=/usr/xpg4/bin:/usr/bin:/bin:/usr/local/bin:/usr/ucb 219AC_PATH_PROG([cutpath], [cut], [no], [$pathtmp]) 220 221dnl 222dnl Check for MD5 program and formatting command 223dnl 224AC_CHECK_PROGS([MD5SUM], [md5sum md5], [missing]) 225AS_CASE(["${MD5SUM}"], 226 [md5sum], [MD5FMT="cat"], 227 [md5], [[MD5FMT="${SED} -e 's/MD5 *(.*) *= \([0-9a-f]*\)/\1/'"]], 228 [MD5FMT="missing"]) 229AC_SUBST([MD5FMT]) 230 231dnl Look for `ls' 232pathtmp=/usr/xpg4/bin:/usr/bin:/bin:/usr/local/bin:/usr/ucb 233AC_PATH_PROG([lspath], [ls], [no], [$pathtmp]) 234 235dnl See how we get ls to display the owner and the group 236AS_IF([test "$lspath" != "no"], 237 [AC_CACHE_CHECK([how to get ls to show us the group ownership of a file], 238 [nmh_cv_ls_grpopt], 239 [AS_IF([test x"`$lspath -dl / | $AWK '{print $9}'`" = x"/"],[ 240 dnl There were 9 parameters, so unless this is a really bizarre, nonstandard 241 dnl ls, it would seem -l gave us both the user and group. On this type of 242 dnl ls, -g makes _only_ the group be displayed (and not the user). 243 nmh_cv_ls_grpopt="-l"],[ 244 dnl Looks like -l only gave us the user, so we need -g to get the group too. 245 nmh_cv_ls_grpopt="-lg"])])]) 246 247dnl Look for `sendmail' 248pathtmp=/usr/sbin:/usr/lib:/usr/etc:/usr/ucblib:/usr/bin:/bin 249AC_PATH_PROG([sendmailpath], [sendmail], [/usr/sbin/sendmail], [$pathtmp]) 250 251dnl Cygwin FAT filesystems do not support hard links. So default to 252dnl cp instead, even if running on an NTFS or other filesystem. (And 253dnl therefore, this cannot be made into a dynamic test, in order to 254dnl support the least common Cygwin denominator. 255AS_CASE(["$host_os"], 256 [cygwin*], [LN=cp], 257 [LN=ln]) 258AC_SUBST([LN]) 259 260dnl ---------------------------------------------------------- 261dnl FIND MAIL SPOOL AND SEE IF WE NEED TO MAKE inc SETGID MAIL 262dnl ---------------------------------------------------------- 263AC_CACHE_CHECK(where mail spool is located, nmh_cv_mailspool, 264[for mailspool in /var/mail dnl 265 /var/spool/mail dnl 266 /usr/spool/mail dnl 267 /dev/null; dnl Just in case we fall through 268do 269 test -d $mailspool && break 270done 271nmh_cv_mailspool=$mailspool 272]) 273mailspool=$nmh_cv_mailspool 274AC_SUBST([mailspool])dnl 275 276dnl See whether the mail spool directory is world-writable. 277if test "$lspath" != "no" -a "$cutpath" != "no"; then 278 AC_CACHE_CHECK(whether the mail spool is world-writable, 279 nmh_cv_mailspool_world_writable, 280 [if test "`$lspath -dlL $mailspool | $cutpath -c9`" = "-"; then 281 nmh_cv_mailspool_world_writable=no 282 else 283 nmh_cv_mailspool_world_writable=yes 284 fi]) 285fi 286 287dnl Also, check for liblockfile (as found on Debian systems) 288AC_CHECK_HEADER([lockfile.h], [AC_CHECK_LIB(lockfile, lockfile_create)]) 289 290dnl and whether its companion program dotlockfile is setgid 291AC_PATH_PROG(dotlockfilepath, dotlockfile, no) 292if test "$ac_cv_lib_lockfile_lockfile_create" != "no" ; then 293 if test "$ac_cv_path_dotlockfilepath" != "no" ; then 294 AC_CACHE_CHECK(whether dotlockfile is setgid, nmh_cv_dotlockfile_setgid, 295 [ if test -g "$ac_cv_path_dotlockfilepath" ; then 296 nmh_cv_dotlockfile_setgid=yes 297 else 298 nmh_cv_dotlockfile_setgid=no 299 fi]) 300 fi 301fi 302 303dnl Provide a way for distcheck to disable setgid_mail via 304dnl DISTCHECK_CONFIGURE_FLAGS. 305AS_IF([test x"$DISABLE_SETGID_MAIL" != x -a x"$DISABLE_SETGID_MAIL" != x0], 306 [nmh_cv_dotlockfile_setgid=yes]) 307 308dnl If mailspool is not world-writable and dotlockfile is not setgid, 309dnl we need to #define MAILGROUP to 1 and make inc setgid. 310if test x"$with_locking" = x"dot" -a x"$nmh_cv_mailspool_world_writable" = x"no" -a x"$nmh_cv_dotlockfile_setgid" != x"yes" ; then 311 dnl do we really need both of these? 312 AC_DEFINE([MAILGROUP],[1], 313 [Define to 1 if you need to make `inc' set-group-id because your mail spool is not world writable. There are no guarantees as to the safety of doing this, but this #define will add some extra security checks.])dnl 314 SETGID_MAIL=1 315fi 316AC_SUBST([SETGID_MAIL])dnl 317 318dnl Use ls to see which group owns the mail spool directory. 319AC_CACHE_CHECK(what group owns the mail spool, nmh_cv_ls_mail_grp, 320[nmh_cv_ls_mail_grp=`$lspath -dL $nmh_cv_ls_grpopt $mailspool|$AWK '{print $4}'` 321]) 322MAIL_SPOOL_GRP=$nmh_cv_ls_mail_grp 323AC_SUBST([MAIL_SPOOL_GRP])dnl 324 325NMH_MIMETYPEPROC 326NMH_MIMEENCODINGPROC 327 328dnl ------------------- 329dnl CHECK FOR LIBRARIES 330dnl ------------------- 331dnl Checks for network libraries (nsl, socket) 332NMH_CHECK_NETLIBS 333 334dnl Check the locking functions supported and what we should use by default 335NMH_LOCKING 336 337dnl Check for iconv 338NMH_CHECK_ICONV 339 340dnl Check for tputs() callback argument 341NMH_TPUTS_PUTC_ARG 342 343termcap_curses_order="termcap curses ncurses" 344for lib in $termcap_curses_order; do 345 AC_CHECK_LIB([${lib}], [setupterm], [TERMLIB="-l$lib"; break]) 346done 347AC_SUBST([TERMLIB])dnl 348AS_IF([test "x$TERMLIB" = "x"], 349 [AC_MSG_FAILURE([Could not find setupterm in any library. Is there a 350curses or ncurses library or package that you can install?])]) 351 352dnl Check for readline support 353NMH_READLINE 354 355dnl -------------- 356dnl CHECK FOR NDBM 357dnl -------------- 358 359AC_ARG_WITH([ndbm],AS_HELP_STRING([--with-ndbm=ARG],[use -lARG to link with ndbm]), 360 [nmh_ndbm=$withval],[nmh_ndbm=autodetect]) 361AC_ARG_WITH([ndbmheader],AS_HELP_STRING([--with-ndbmheader=ARG],[#include <ARG> to use ndbm]), 362 [nmh_ndbmheader=$withval],[nmh_ndbmheader=autodetect]) 363 364if test "$nmh_ndbm" = "autodetect"; then 365 if test "$nmh_ndbmheader" != "autodetect"; then 366 AC_MSG_ERROR([must specify both --with-ndbm and --with-ndbmheader or neither]) 367 else 368 369 dnl There are at least four implementations of ndbm, and 370 dnl several of those can be in different places at the whim 371 dnl of the system integrator. A good summary of this mess 372 dnl can be found at http://www.unixpapa.com/incnote/dbm.html 373 374 dnl Classic ndbm with no library required (eg NetBSD): try this 375 dnl first so we don't accidentally link in a pointless but harmless 376 dnl library in one of the later ndbm.h+libfoo tests: 377 NMH_CHECK_NDBM(ndbm.h,,, 378 dnl Berkeley DBv2 emulating ndbm: header in db.h, e.g., 32-bit Cygwin: 379 NMH_CHECK_NDBM(db.h,db,, 380 dnl Berkeley DBv1 emulating ndbm: 381 NMH_CHECK_NDBM(ndbm.h,db,, 382 NMH_CHECK_NDBM(ndbm.h,db1,, 383 dnl Classic ndbm: 384 NMH_CHECK_NDBM(ndbm.h,ndbm,, 385 dnl glibc2.1 systems put db1 in a subdir: 386 NMH_CHECK_NDBM(db1/ndbm.h,db1,, 387 dnl GNU gdbm emulating ndbm, with header possibly in gdbm/ 388 dnl and possibly needing gbdm_compat library: 389 NMH_CHECK_NDBM(gdbm/ndbm.h,gdbm,, 390 NMH_CHECK_NDBM(gdbm/ndbm.h,gdbm_compat -lgdbm,, 391 NMH_CHECK_NDBM(ndbm.h,gdbm,, 392 dnl 64-bit Cygwin: 393 NMH_CHECK_NDBM(ndbm.h,gdbm_compat -lgdbm,, 394 dnl On Linux, libgdbm_compat.so loads libgdbm.so as well, so it doesn't 395 dnl need to be explicit: 396 NMH_CHECK_NDBM(gdbm-ndbm.h,gdbm_compat))))))))))) 397 fi 398else 399 dnl We don't really need to check that the user-specified values work, 400 dnl but it is a convenience to the user to bomb out early rather than 401 dnl after configure and half the compile process. 402 NMH_CHECK_NDBM([$nmh_ndbmheader],[$nmh_ndbm]) 403fi 404 405if test "$nmh_ndbm_found" = "no"; then 406 AC_MSG_ERROR([could not find a working ndbm library/header combination]) 407else 408 dnl Now export the lib/header to our makefile/config.h: 409 if test x"$nmh_ndbmheader" != x; then 410 AC_DEFINE_UNQUOTED(NDBM_HEADER, <$nmh_ndbmheader>, 411 [Define to the header containing the ndbm API prototypes.]) 412 fi 413 if test x"$nmh_ndbm" != x; then 414 NDBM_LIBS="-l$nmh_ndbm" 415 else 416 NDBM_LIBS= 417 fi 418 AC_SUBST([NDBM_LIBS]) 419fi 420 421dnl ------------------ 422dnl Set RPM build root 423dnl ------------------ 424dnl nmhrpm is used in the final summary, see below. The default value is 425dnl reported there as ./RPM, consistent with the reporting of the default 426dnl source code location as ., but its absolute path is used in the Makefile. 427AC_ARG_WITH([rpmdir], 428 [AS_HELP_STRING([--with-rpmdir=RPMDIR], [RPM build directory @<:@RPM@:>@])]) 429 AS_IF([test x"$with_rpmdir" = x], [rpmdir='$(abs_srcdir)/RPM'; nmhrpm=./RPM], 430 [rpmdir="$with_rpmdir"; eval "nmhrpm=${rpmdir}"]) 431AC_SUBST([rpmdir]) 432 433 434dnl -------------------- 435dnl CHECK FOR CYRUS-SASL 436dnl -------------------- 437 438AS_IF([test x"$with_cyrus_sasl" != x"no"],[ 439 AC_CHECK_HEADER([sasl/sasl.h], HAVE_SASL_H=1) 440 AC_CHECK_LIB([sasl2], [sasl_client_new], [SASLLIB="-lsasl2"])]) 441AC_SUBST([SASLLIB]) 442 443dnl ----------------- 444dnl Enable SASL? 445dnl ----------------- 446dnl By default (with_cyrus_sasl=''), enable SASL if header and lib are found. 447dnl If SASL requested (--with-cyrus-sasl with_cyrus_sasl=yes), error if header or lib not found. 448dnl If SASL disabled (--without-cyrus-sasl with_cyrus_sasl=no), don't enable it. 449sasl_support=no 450CYRUS_SASL=0 451AC_SUBST([CYRUS_SASL]) 452AS_IF([test "x$with_cyrus_sasl" = xyes && test "x$HAVE_SASL_H" = x], 453 [AC_MSG_ERROR([SASL requested but sasl.h not found])], 454 [test "x$with_cyrus_sasl" = xyes && test "x$SASLLIB" = x], 455 [AC_MSG_ERROR([SASL requested but Cyrus SASL library not found])], 456 [test "x$with_cyrus_sasl" != xno && test "x$HAVE_SASL_H" = x1 && 457 test "x$SASLLIB" != x], 458 [AC_DEFINE([CYRUS_SASL], [1], 459 [Define to use the Cyrus SASL library for authentication of POP and SMTP.]) 460 CYRUS_SASL=1 461 sasl_support=yes]) 462 463dnl ----------------- 464dnl CHECK FOR OPENSSL 465dnl ----------------- 466 467AS_IF([test x"$with_tls" != x"no"],[ 468 dnl OpenBSD 5 needs the other-libraries (fifth argument) to the 469 dnl AC_CHECK_LIB for SSL_new, because it doesn't 470 dnl automatically append -lcrypto when linking with -lssl. 471 AC_CHECK_HEADER([openssl/ssl.h], HAVE_SSL_H=1) 472 AC_CHECK_LIB([crypto], [BIO_write], [TLSLIB="-lcrypto"]) 473 AC_CHECK_LIB([ssl], [SSL_new], [TLSLIB="-lssl $TLSLIB"], [TLSLIB=], 474 [$TLSLIB])]) 475AC_SUBST([TLSLIB]) 476 477dnl ----------------- 478dnl Enable TLS? 479dnl ----------------- 480dnl By default (with_tls=''), enable TLS if header and libs were found. 481dnl If TLS requested (--with-tls with_tls=yes), error if header/lib not found. 482dnl If TLS disabled (--without-tls with_tls=no), don't enable it. 483tls_support=no 484TLS_SUPPORT=0 485AC_SUBST([TLS_SUPPORT]) 486AS_IF([test "x$with_tls" = xyes && test "x$HAVE_SSL_H" = x], 487 [AC_MSG_ERROR([TLS requested but openssl/ssl.h not found])], 488 [test "x$with_tls" = xyes && test "x$TLSLIB" = x], 489 [AC_MSG_ERROR([TLS requested but crypto or ssl library not found])], 490 [test "x$with_tls" != xno && test "x$HAVE_SSL_H" = x1 && test "x$TLSLIB" != x], 491 [AC_DEFINE([TLS_SUPPORT], [1], [Support TLS for session encryption.]) 492 TLS_SUPPORT=1 493 tls_support=yes 494 save_LIBS="$LIBS" 495 LIBS="$LIBS $TLSLIB" 496 AC_CHECK_FUNCS([X509_VERIFY_PARAM_set1_host]) 497 LIBS="$save_LIBS"]) 498 499dnl ----------------- 500dnl CHECK FOR CURL 501dnl ----------------- 502dnl Look for curl if oauth not disabled (--without-oauth). 503AC_PATH_PROG([curl_config], [curl-config]) 504AS_IF([test "x$with_oauth" != xno && test -n "$curl_config"], [ 505 save_CFLAGS="$CFLAGS" 506 CFLAGS="$AM_CPPFLAGS $AM_CFLAGS $CFLAGS `$curl_config --cflags`" 507 AC_CHECK_HEADER([curl/curl.h], [ 508 HAVE_CURL_H=1 509 AC_CHECK_LIB([curl], [curl_easy_init], [ 510 CURLLIB="`$curl_config --libs`" 511 AC_SUBST([CURLLIB]) 512 CURL_USER_AGENT="`$curl_config --version | sed 's|^libcurl *|libcurl/|; q'`" 513 AS_IF([test "x$CURL_USER_AGENT" != "x`echo $CURL_USER_AGENT | sed 's/ //'`"], 514 [AC_MSG_WARN([unexpected curl-config --version: $CURL_USER_AGENT]) 515 CURL_USER_AGENT=libcurl/UNKNOWN]) 516 AC_SUBST([CURL_USER_AGENT]) 517 ]) 518 ]) 519 CFLAGS="$save_CFLAGS" 520 ]) 521 522dnl ----------------- 523dnl Enable OAuth? 524dnl ----------------- 525dnl By default (with_oauth=''), enable OAuth if curl is found. 526dnl If OAuth requested (--with-oauth with_oauth=yes), error if curl not found. 527dnl If OAuth disabled (--without-oauth with_oauth=no), don't enable it. 528oauth_support=no 529OAUTH_SUPPORT=0 530AC_SUBST([OAUTH_SUPPORT]) 531AS_IF([test "x$with_oauth" = xyes && test "x$HAVE_CURL_H" = x], 532 [AC_MSG_ERROR([OAuth requested but curl/curl.h not found])], 533 [test "x$with_oauth" = xyes && test "x$CURLLIB" = x], 534 [AC_MSG_ERROR([OAuth requested but curl library not found])], 535 [test "x$with_oauth" != xno && test "x$HAVE_CURL_H" = x1 && test "x$CURLLIB" != x], 536 [AC_DEFINE([OAUTH_SUPPORT], [1], [Support OAuth2 in SMTP auth.]) 537 OAUTH_SUPPORT=1 538 oauth_support=yes]) 539 540dnl ---------------- 541dnl CHECK FLEX FIXUP 542dnl ---------------- 543dnl Use AM_LFLAGS make variable setting to work around bugs in flex 544dnl 2.5.36-37 that cause signed/unsigned mismatch, 545dnl http://sourceforge.net/p/flex/bugs/140/ 546dnl 2.6.1 bug: https://github.com/westes/flex/issues/97 547AS_IF([test "$LEX" = flex], 548 [AS_CASE([`$LEX -V`], 549 [flex\ 2.5.35], [AM_LFLAGS=\ 550'; sed "s/ int n;/ size_t n;/" $@ >$@.tmp && mv -f $@.tmp $@;'], 551 [flex\ 2.5.3[[67]]], [AM_LFLAGS=\ 552'; sed "s/\( \)int i;/\1yy_size_t i;/" $@ >$@.tmp && mv -f $@.tmp $@;'], 553 [flex\ 2.6.0], [AM_LFLAGS=\ 554'; sed "s/, num_to_read/, (size_t) num_to_read/" $@ >$@.tmp && mv -f $@.tmp $@;'], 555 [flex\ 2.6.1], [AM_LFLAGS=\ 556'; sed '\''/\<int num_to_read\>/s/int/size_t/; \ 557 s/\<yy_size_t i\>/int i/; \ 558 s/int n; \\/yy_size_t n; \\/'\'' $@ >$@.tmp && mv -f $@.tmp $@;']) 559 AC_SUBST([AM_LFLAGS])]) 560 561dnl ------------------ 562dnl FOR INTERNAL USE by the NMH test suite 563dnl ------------------ 564AC_ARG_VAR([NMHETCDIRINST], [for internal use by nmh test suite]) 565AS_IF([test -n "$NMHETCDIRINST"], [nmhetcdirinst=$NMHETCDIRINST] 566 AC_SUBST([nmhetcdirinst])) 567 568dnl ---------------- 569dnl CHECK STRUCTURES 570dnl ---------------- 571 572dnl For platforms such as FreeBSD that have tm_gmtoff in struct tm. 573dnl (FreeBSD has a timezone() function but not a timezone global 574dnl variable that is visible). 575dnl On Linux, $AM_CPPFLAGS contains -D_GNU_SOURCE, which makes 576dnl tm_gmtoff visible. 577nmh_saved_CPPFLAGS="$CPPFLAGS" 578CPPFLAGS="$AM_CPPFLAGS $CPPFLAGS" 579AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[[#include <time.h>]]) 580CPPFLAGS="$nmh_saved_CPPFLAGS" 581 582AC_STRUCT_DIRENT_D_TYPE 583 584dnl 585dnl Sigh, this is required because under the new world order autoconf has 586dnl nothing to create in a few of the build directories when doing an object 587dnl tree build. So make sure we created certain directories if they don't 588dnl exist. 589dnl 590 591AC_CONFIG_COMMANDS([build-directories], 592[AS_MKDIR_P([etc]); AS_MKDIR_P([man])]) 593 594AC_CONFIG_COMMANDS_POST([ 595 596dnl These odd looking assignments are done to expand out unexpanded 597dnl variables in bindir et al (for instance mandir is '${datarootdir}/man'), 598dnl but expanding that gives '${prefix}/share/man', so we need to expand 599dnl again to get the final answer. 600dnl We only use the expanded versions to print the install paths in 601dnl the final summary and should use them nowhere else (see the autoconf 602dnl docs for the rationale for bindir etc being unexpanded). 603eval "nmhbin=${bindir}"; eval "nmhbin=${nmhbin}" 604eval "nmhlibexec=${libexecdir}"; eval "nmhlibexec=${nmhlibexec}" 605eval "nmhsysconf=${sysconfdir}"; eval "nmhsysconf=${nmhsysconf}" 606eval "nmhman=${mandir}"; eval "nmhman=${nmhman}" 607eval "nmhdoc=${docdir}"; eval "nmhdoc=${nmhdoc}" 608eval "nmhrpm=${nmhrpm}"; 609 610AC_MSG_NOTICE([ 611nmh configuration 612----------------- 613nmh version : AC_PACKAGE_VERSION 614host os : ${host} 615compiler : ${CC} 616compiler flags : ${AM_CFLAGS} ${CFLAGS} 617linker flags : ${AM_LDFLAGS} ${LDFLAGS} 618preprocessor flags : ${AM_CPPFLAGS} ${CPPFLAGS} 619source code location : ${srcdir} 620binary install path : ${nmhbin} 621libexec install path : ${nmhlibexec}/nmh 622config files install path : ${nmhsysconf}/nmh 623man page install path : ${nmhman} 624docs install path : ${nmhdoc} 625RPM build root : ${nmhrpm} 626backup prefix : ${backup_prefix} 627transport system : ${MTS} 628spool default locking type : ${with_locking} 629default smtp server : ${smtpserver} 630SASL support : ${sasl_support} 631TLS support : ${tls_support} 632OAuth support : ${oauth_support} 633])])dnl 634 635dnl --------------- 636dnl OUTPUT MAKEFILE 637dnl --------------- 638AC_CONFIG_FILES([Makefile test/common.sh]) 639AC_CONFIG_FILES([uip/spost], [chmod +x uip/spost]) 640AC_OUTPUT 641