]> diplodocus.org Git - nmh/blob - configure.ac
vector.c: Move interface to own file.
[nmh] / configure.ac
1 dnl configure.ac -- autoconf template for nmh
2 dnl
3
4 AC_PREREQ([2.68])
5
6 AC_INIT([nmh], m4_normalize(m4_include([VERSION])), [nmh-workers@nongnu.org])
7 AC_CONFIG_SRCDIR([h/nmh.h])
8 AC_CONFIG_HEADER([config.h])
9 AM_INIT_AUTOMAKE([-Wall foreign serial-tests subdir-objects 1.12])
10
11 AC_CANONICAL_HOST
12
13 AC_MSG_NOTICE([configuring for AC_PACKAGE_NAME-AC_PACKAGE_VERSION])
14 AC_SUBST(VERSION,AC_PACKAGE_VERSION)dnl
15
16 dnl What date of nmh are we building?
17 DATE=`cat ${srcdir}/DATE`
18 AC_MSG_NOTICE([configuring for nmh dated $DATE])
19 AC_SUBST([DATE])dnl
20
21 dnl --------------------------
22 dnl CHECK COMMAND LINE OPTIONS
23 dnl --------------------------
24
25 dnl Do you want client-side support for using SASL for authentication?
26 dnl Note that this code will be enabled for both POP and SMTP
27 AC_ARG_WITH([cyrus-sasl], AS_HELP_STRING([--with-cyrus-sasl],
28 [Enable SASL support via the Cyrus SASL library]))
29 AS_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
34 dnl Do you want client-side support for encryption with TLS?
35 AC_ARG_WITH([tls], AS_HELP_STRING([--with-tls], [Enable TLS support]))
36
37 dnl Do you want client-side support for using OAuth2 for SMTP & POP auth?
38 AC_ARG_WITH([oauth], AS_HELP_STRING([--with-oauth],
39 [Enable OAuth2 support in SMTP and POP auth]))
40
41 dnl Set the backup prefix
42 AC_ARG_WITH([hash-backup],
43 AS_HELP_STRING([--with-hash-backup],[use # as the backup prefix (default: ,)]))
44 AS_IF([test x"$with_hash_backup" != x -a x"$with_hash_backup" != x"no"],
45 [backup_prefix="#"], [backup_prefix=","])
46 AC_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
49 dnl What method of posting should post use?
50 AC_ARG_WITH([mts],
51 AS_HELP_STRING([--with-mts=@<:@smtp|sendmail/smtp|sendmail/pipe@:>@],
52 [specify the default mail transport agent/service]))
53
54 AS_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"])
59 AC_SUBST([MTS])dnl
60
61 dnl What should be the default mail server?
62 AC_ARG_WITH([smtpserver],
63 [AS_HELP_STRING([--with-smtpserver='SMTPSERVER'],
64 [specify the default SMTP server @<:@localhost@:>@])])
65 AS_IF([test -n "$with_smtpserver"], [smtpserver="$with_smtpserver"],
66 [smtpserver="localhost"])
67 AC_SUBST([smtpserver])dnl
68
69 dnl -------------------------------------------------------------------
70 dnl Default location is /usr/local/nmh/{bin,etc,libexec,man}, unless we
71 dnl find an existing installation, in which case we use its location.
72 dnl -------------------------------------------------------------------
73 AC_PREFIX_DEFAULT([/usr/local/nmh])
74 AC_PREFIX_PROGRAM([mhparam])
75
76 dnl ------------------
77 dnl CHECK THE COMPILER
78 dnl ------------------
79
80 AC_PROG_CC([cc gcc])
81 AM_PROG_CC_C_O
82
83 dnl ------------------
84 dnl CHECK HEADER FILES
85 dnl ------------------
86
87 AC_HEADER_TIOCGWINSZ
88 AC_CHECK_HEADERS([fcntl.h stdbool.h wchar.h wctype.h \
89 sys/param.h sys/time.h sys/stream.h])
90
91 AC_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
98 dnl ---------------
99 dnl CHECK FUNCTIONS
100 dnl ---------------
101 AC_CHECK_FUNCS([wcwidth mbtowc getutxent arc4random mkstemps])
102
103 dnl Use custom getline for platforms that don't have it.
104 AC_CONFIG_LIBOBJ_DIR([sbr])
105 AC_REPLACE_FUNCS([getline])
106
107 dnl -----------------------
108 dnl CHECK MULTIBYTE SUPPORT
109 dnl -----------------------
110 AS_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])
118 AC_SUBST([MULTIBYTE_ENABLED])
119
120 dnl ----------------
121 dnl CUSTOMIZE CFLAGS
122 dnl ----------------
123 dnl The user didn't specify CFLAGS, so customize them.
124
125 if 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"])
133 fi
134
135 AC_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"])
140 test "$nmh_cv_has_wall" = "yes" && CFLAGS="${CFLAGS:+$CFLAGS }-Wall"
141
142 AC_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"])
148 test "$nmh_cv_has_wextra" = "yes" && CFLAGS="${CFLAGS:+$CFLAGS }-Wextra"
149
150 AC_SUBST([AM_CFLAGS])
151
152 dnl Check for any platform-specific additional AM_CPPFLAGS. This depends on
153 dnl MULTIBYTE_ENABLED having already been set.
154 NMH_ADDL_CPPFLAGS
155
156 dnl FreeBSD needs a bit of magic to bring getline() into scope.
157 dnl We do this here rather than in (say) h/mh.h because this macro must
158 dnl be defined before <stdio.h> is pulled in.
159 dnl
160 dnl And while we're here, add the packages tree to the cpp and ld search
161 dnl paths. Note that FreeBSD's pkg(8) seems to be hardwired to use /usr/local.
162 dnl If /usr/ports is installed, we use its idea of where things are installed,
163 dnl otherwise we assume /usr/local.
164
165 AS_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
174 dnl --------------
175 dnl CUSTOMIZE LINK
176 dnl --------------
177 AS_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/'"])
182 AC_SUBST([POSTLINK])
183
184 dnl -----------------
185 dnl CUSTOMIZE LDFLAGS
186 dnl -----------------
187 dnl Disable clang complaint about unused -ansi when linking.
188 AC_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])])
198 test "$nmh_cv_has_q_unused_arguments" = "yes" && \
199 AM_LDFLAGS="${AM_LDFLAGS:+$AM_LDFLAGS }-Qunused-arguments"
200 AC_SUBST([AM_LDFLAGS])
201
202 AC_HEADER_ASSERT
203
204 dnl ------------------
205 dnl CHECK FOR PROGRAMS
206 dnl ------------------
207 AC_PROG_MAKE_SET dnl Does make define $MAKE
208 AC_PROG_INSTALL dnl Check for BSD compatible `install'
209 AC_PROG_RANLIB dnl Check for `ranlib'
210 AC_PROG_AWK dnl Check for mawk,gawk,nawk, then awk
211 AC_PROG_SED dnl Check for Posix-compliant sed
212 AC_PROG_YACC dnl Check for yacc/bison
213 AM_PROG_LEX dnl Check for lex/flex
214
215 AM_PROG_AR
216
217 dnl Look for `cut'
218 pathtmp=/usr/xpg4/bin:/usr/bin:/bin:/usr/local/bin:/usr/ucb
219 AC_PATH_PROG([cutpath], [cut], [no], [$pathtmp])
220
221 dnl
222 dnl Check for MD5 program and formatting command
223 dnl
224 AC_CHECK_PROGS([MD5SUM], [md5sum md5], [missing])
225 AS_CASE(["${MD5SUM}"],
226 [md5sum], [MD5FMT="cat"],
227 [md5], [[MD5FMT="${SED} -e 's/MD5 *(.*) *= \([0-9a-f]*\)/\1/'"]],
228 [MD5FMT="missing"])
229 AC_SUBST([MD5FMT])
230
231 dnl Look for `ls'
232 pathtmp=/usr/xpg4/bin:/usr/bin:/bin:/usr/local/bin:/usr/ucb
233 AC_PATH_PROG([lspath], [ls], [no], [$pathtmp])
234
235 dnl See how we get ls to display the owner and the group
236 AS_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
247 dnl Look for `sendmail'
248 pathtmp=/usr/sbin:/usr/lib:/usr/etc:/usr/ucblib:/usr/bin:/bin
249 AC_PATH_PROG([sendmailpath], [sendmail], [/usr/sbin/sendmail], [$pathtmp])
250
251 dnl Cygwin FAT filesystems do not support hard links. So default to
252 dnl cp instead, even if running on an NTFS or other filesystem. (And
253 dnl therefore, this cannot be made into a dynamic test, in order to
254 dnl support the least common Cygwin denominator.
255 AS_CASE(["$host_os"],
256 [cygwin*], [LN=cp],
257 [LN=ln])
258 AC_SUBST([LN])
259
260 dnl ----------------------------------------------------------
261 dnl FIND MAIL SPOOL AND SEE IF WE NEED TO MAKE inc SETGID MAIL
262 dnl ----------------------------------------------------------
263 AC_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
268 do
269 test -d $mailspool && break
270 done
271 nmh_cv_mailspool=$mailspool
272 ])
273 mailspool=$nmh_cv_mailspool
274 AC_SUBST([mailspool])dnl
275
276 dnl See whether the mail spool directory is world-writable.
277 if 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])
285 fi
286
287 dnl Also, check for liblockfile (as found on Debian systems)
288 AC_CHECK_HEADER([lockfile.h], [AC_CHECK_LIB(lockfile, lockfile_create)])
289
290 dnl and whether its companion program dotlockfile is setgid
291 AC_PATH_PROG(dotlockfilepath, dotlockfile, no)
292 if 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
301 fi
302
303 dnl Provide a way for distcheck to disable setgid_mail via
304 dnl DISTCHECK_CONFIGURE_FLAGS.
305 AS_IF([test x"$DISABLE_SETGID_MAIL" != x -a x"$DISABLE_SETGID_MAIL" != x0],
306 [nmh_cv_dotlockfile_setgid=yes])
307
308 dnl If mailspool is not world-writable and dotlockfile is not setgid,
309 dnl we need to #define MAILGROUP to 1 and make inc setgid.
310 if 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
315 fi
316 AC_SUBST([SETGID_MAIL])dnl
317
318 dnl Use ls to see which group owns the mail spool directory.
319 AC_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 ])
322 MAIL_SPOOL_GRP=$nmh_cv_ls_mail_grp
323 AC_SUBST([MAIL_SPOOL_GRP])dnl
324
325 NMH_MIMETYPEPROC
326 NMH_MIMEENCODINGPROC
327
328 dnl -------------------
329 dnl CHECK FOR LIBRARIES
330 dnl -------------------
331 dnl Checks for network libraries (nsl, socket)
332 NMH_CHECK_NETLIBS
333
334 dnl Check the locking functions supported and what we should use by default
335 NMH_LOCKING
336
337 dnl Check for iconv
338 NMH_CHECK_ICONV
339
340 dnl Check for tputs() callback argument
341 NMH_TPUTS_PUTC_ARG
342
343 termcap_curses_order="termcap tinfo curses ncurses"
344 for lib in $termcap_curses_order; do
345 AC_CHECK_LIB([${lib}], [setupterm], [TERMLIB="-l$lib"; break])
346 done
347 AC_SUBST([TERMLIB])dnl
348 AS_IF([test "x$TERMLIB" = "x"],
349 [AC_MSG_FAILURE([Could not find setupterm in any library. Is there a
350 curses or ncurses library or package that you can install?])])
351
352 dnl Check for readline support
353 NMH_READLINE
354
355 dnl --------------
356 dnl CHECK FOR NDBM
357 dnl --------------
358
359 AC_ARG_WITH([ndbm],AS_HELP_STRING([--with-ndbm=ARG],[use -lARG to link with ndbm]),
360 [nmh_ndbm=$withval],[nmh_ndbm=autodetect])
361 AC_ARG_WITH([ndbmheader],AS_HELP_STRING([--with-ndbmheader=ARG],[#include <ARG> to use ndbm]),
362 [nmh_ndbmheader=$withval],[nmh_ndbmheader=autodetect])
363
364 if 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
398 else
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])
403 fi
404
405 if test "$nmh_ndbm_found" = "no"; then
406 AC_MSG_ERROR([could not find a working ndbm library/header combination])
407 else
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])
419 fi
420
421 dnl ------------------
422 dnl Set RPM build root
423 dnl ------------------
424 dnl nmhrpm is used in the final summary, see below. The default value is
425 dnl reported there as ./RPM, consistent with the reporting of the default
426 dnl source code location as ., but its absolute path is used in the Makefile.
427 AC_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}"])
431 AC_SUBST([rpmdir])
432
433
434 dnl --------------------
435 dnl CHECK FOR CYRUS-SASL
436 dnl --------------------
437
438 AS_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"])])
441 AC_SUBST([SASLLIB])
442
443 dnl -----------------
444 dnl Enable SASL?
445 dnl -----------------
446 dnl By default (with_cyrus_sasl=''), enable SASL if header and lib are found.
447 dnl If SASL requested (--with-cyrus-sasl with_cyrus_sasl=yes), error if header or lib not found.
448 dnl If SASL disabled (--without-cyrus-sasl with_cyrus_sasl=no), don't enable it.
449 sasl_support=no
450 CYRUS_SASL=0
451 AC_SUBST([CYRUS_SASL])
452 AS_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
463 dnl -----------------
464 dnl CHECK FOR OPENSSL
465 dnl -----------------
466
467 AS_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])])
475 AC_SUBST([TLSLIB])
476
477 dnl -----------------
478 dnl Enable TLS?
479 dnl -----------------
480 dnl By default (with_tls=''), enable TLS if header and libs were found.
481 dnl If TLS requested (--with-tls with_tls=yes), error if header/lib not found.
482 dnl If TLS disabled (--without-tls with_tls=no), don't enable it.
483 tls_support=no
484 TLS_SUPPORT=0
485 AC_SUBST([TLS_SUPPORT])
486 AS_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
499 dnl -----------------
500 dnl CHECK FOR CURL
501 dnl -----------------
502 dnl Look for curl if oauth not disabled (--without-oauth).
503 AC_PATH_PROG([curl_config], [curl-config])
504 AS_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
522 dnl -----------------
523 dnl Enable OAuth?
524 dnl -----------------
525 dnl By default (with_oauth=''), enable OAuth if curl is found.
526 dnl If OAuth requested (--with-oauth with_oauth=yes), error if curl not found.
527 dnl If OAuth disabled (--without-oauth with_oauth=no), don't enable it.
528 oauth_support=no
529 OAUTH_SUPPORT=0
530 AC_SUBST([OAUTH_SUPPORT])
531 AS_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
540 dnl ----------------
541 dnl CHECK FLEX FIXUP
542 dnl ----------------
543 dnl Use AM_LFLAGS make variable setting to work around bugs in flex
544 dnl 2.5.36-37 that cause signed/unsigned mismatch,
545 dnl http://sourceforge.net/p/flex/bugs/140/
546 dnl 2.6.1 bug: https://github.com/westes/flex/issues/97
547 AS_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
561 dnl ------------------
562 dnl FOR INTERNAL USE by the NMH test suite
563 dnl ------------------
564 AC_ARG_VAR([NMHETCDIRINST], [for internal use by nmh test suite])
565 AS_IF([test -n "$NMHETCDIRINST"], [nmhetcdirinst=$NMHETCDIRINST]
566 AC_SUBST([nmhetcdirinst]))
567
568 dnl ----------------
569 dnl CHECK STRUCTURES
570 dnl ----------------
571
572 dnl For platforms such as FreeBSD that have tm_gmtoff in struct tm.
573 dnl (FreeBSD has a timezone() function but not a timezone global
574 dnl variable that is visible).
575 dnl On Linux, $AM_CPPFLAGS contains -D_GNU_SOURCE, which makes
576 dnl tm_gmtoff visible.
577 nmh_saved_CPPFLAGS="$CPPFLAGS"
578 CPPFLAGS="$AM_CPPFLAGS $CPPFLAGS"
579 AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[[#include <time.h>]])
580 CPPFLAGS="$nmh_saved_CPPFLAGS"
581
582 AC_STRUCT_DIRENT_D_TYPE
583
584 dnl
585 dnl Sigh, this is required because under the new world order autoconf has
586 dnl nothing to create in a few of the build directories when doing an object
587 dnl tree build. So make sure we created certain directories if they don't
588 dnl exist.
589 dnl
590
591 AC_CONFIG_COMMANDS([build-directories],
592 [AS_MKDIR_P([etc]); AS_MKDIR_P([man])])
593
594 AC_CONFIG_COMMANDS_POST([
595
596 dnl These odd looking assignments are done to expand out unexpanded
597 dnl variables in bindir et al (for instance mandir is '${datarootdir}/man'),
598 dnl but expanding that gives '${prefix}/share/man', so we need to expand
599 dnl again to get the final answer.
600 dnl We only use the expanded versions to print the install paths in
601 dnl the final summary and should use them nowhere else (see the autoconf
602 dnl docs for the rationale for bindir etc being unexpanded).
603 eval "nmhbin=${bindir}"; eval "nmhbin=${nmhbin}"
604 eval "nmhlibexec=${libexecdir}"; eval "nmhlibexec=${nmhlibexec}"
605 eval "nmhsysconf=${sysconfdir}"; eval "nmhsysconf=${nmhsysconf}"
606 eval "nmhman=${mandir}"; eval "nmhman=${nmhman}"
607 eval "nmhdoc=${docdir}"; eval "nmhdoc=${nmhdoc}"
608 eval "nmhrpm=${nmhrpm}";
609
610 AC_MSG_NOTICE([
611 nmh configuration
612 -----------------
613 nmh version : AC_PACKAGE_VERSION
614 host os : ${host}
615 compiler : ${CC}
616 compiler flags : ${AM_CFLAGS} ${CFLAGS}
617 linker flags : ${AM_LDFLAGS} ${LDFLAGS}
618 preprocessor flags : ${AM_CPPFLAGS} ${CPPFLAGS}
619 source code location : ${srcdir}
620 binary install path : ${nmhbin}
621 libexec install path : ${nmhlibexec}/nmh
622 config files install path : ${nmhsysconf}/nmh
623 man page install path : ${nmhman}
624 docs install path : ${nmhdoc}
625 RPM build root : ${nmhrpm}
626 backup prefix : ${backup_prefix}
627 transport system : ${MTS}
628 spool default locking type : ${with_locking}
629 default smtp server : ${smtpserver}
630 SASL support : ${sasl_support}
631 TLS support : ${tls_support}
632 OAuth support : ${oauth_support}
633 ])])dnl
634
635 dnl ---------------
636 dnl OUTPUT MAKEFILE
637 dnl ---------------
638 AC_CONFIG_FILES([Makefile test/common.sh])
639 AC_CONFIG_FILES([uip/spost], [chmod +x uip/spost])
640 AC_OUTPUT