1# This file is part of Mailfromd.  -*- autoconf -*-
2# Copyright (C) 2005-2021 Sergey Poznyakoff
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17AC_PREREQ(2.63)
18m4_define([MF_VERSION_MAJOR], 8)
19m4_define([MF_VERSION_MINOR], 10)
20AC_INIT([mailfromd],
21        MF_VERSION_MAJOR.MF_VERSION_MINOR[]m4_ifdef([MF_VERSION_PATCH],.MF_VERSION_PATCH),
22        [bug-mailfromd@gnu.org.ua],
23	[mailfromd],
24	[http://www.gnu.org.ua/software/mailfromd])
25AC_CONFIG_SRCDIR([src/mailfromd.h])
26AC_CONFIG_AUX_DIR([build-aux])
27AC_CONFIG_HEADERS([config.h])
28AM_INIT_AUTOMAKE([1.11 gnits tar-ustar dist-bzip2 dist-xz std-options silent-rules])
29
30# Enable silent rules by default:
31AM_SILENT_RULES([yes])
32
33#
34AC_DEFINE_UNQUOTED([MAILFROMD_VERSION_MAJOR], MF_VERSION_MAJOR,
35                   [Major version number])
36AC_DEFINE_UNQUOTED([MAILFROMD_VERSION_MINOR], MF_VERSION_MINOR,
37                   [Minor version number])
38AC_DEFINE_UNQUOTED([MAILFROMD_VERSION_PATCH],
39                   m4_ifdef([MF_VERSION_PATCH],MF_VERSION_PATCH,0),
40                   [Patchlevel number])
41
42# Checks for programs.
43AC_PROG_CC
44AC_PROG_RANLIB
45AC_PROG_YACC
46AC_PROG_LEX
47AC_PROG_LN_S
48PKG_PROG_PKG_CONFIG
49
50# Debugging mode
51MU_DEBUG_MODE
52MF_GCC_QUIRKS
53
54# Checks for libraries.
55AC_CHECK_LIB(socket, socket)
56AC_CHECK_LIB(nsl, gethostbyaddr)
57AC_CHECK_LIB(rt, nanosleep)
58
59# Checks for header files.
60AC_HEADER_STDC
61AC_CHECK_HEADERS([stdlib.h unistd.h sysexits.h paths.h])
62
63# Checks for typedefs, structures, and compiler characteristics.
64AC_TYPE_SIGNAL
65AC_TYPE_SIZE_T
66AC_CHECK_SIZEOF(uint32_t)
67AC_CHECK_SIZEOF(unsigned long)
68AC_CHECK_SIZEOF(unsigned int)
69
70AH_TEMPLATE(GACOPYZ_UINT32_T, [32-bit unsigned data type])
71if test "$ac_cv_sizeof_uint32_t" = 4 ; then
72	AC_DEFINE_UNQUOTED(GACOPYZ_UINT32_T, uint32_t)
73elif test "$ac_cv_sizeof_unsigned_int" = 4 ; then
74	AC_DEFINE_UNQUOTED(GACOPYZ_UINT32_T, unsigned int)
75elif test "$ac_cv_sizeof_unsigned_long" = 4 ; then
76	AC_DEFINE_UNQUOTED(GACOPYZ_UINT32_T, unsigned long)
77else
78	AC_MSG_ERROR([cannot determine 32-bit unsigned data type])
79fi
80
81IU_CHECK_MEMBERS([struct msghdr.msg_control, struct msghdr.msg_accrights], , ,
82                 [#include <sys/types.h>
83	          #include <sys/socket.h>])
84
85# Checks for library functions.
86AC_CHECK_FUNCS([setegid setregid setresgid seteuid setreuid \
87                sysconf getdtablesize])
88AC_REPLACE_FUNCS(daemon)
89
90# Check for GNU Mailutils
91AM_GNU_MAILUTILS([3.4], [all auth dbm sieve], [:])
92
93AC_CHECK_LIB([adns], [adns_init],,
94    [AC_MSG_ERROR([required library libadns not found])])
95
96AC_SUBST([NETTLE_LIBS])
97AC_CHECK_HEADERS([nettle/sha2.h nettle/buffer.h nettle/rsa.h nettle/base64.h])
98if test "$ac_cv_header_nettle_sha2_h$ac_cv_header_nettle_buffer_h$ac_cv_header_nettle_rsa_h$ac_cv_header_nettle_base64_h" = "yesyesyesyes"; then
99  AC_CHECK_LIB([gmp],[__gmpz_init],
100    [AC_CHECK_LIB([hogweed],[nettle_rsa_sha256_sign],[
101       AC_CHECK_LIB([nettle],[nettle_sha256_init],[
102         NETTLE_LIBS="-lhogweed -lnettle -lgmp"
103       ],[],[-lgmp])])])
104fi
105AM_CONDITIONAL([NETTLE_COND],[test -n "$NETTLE_LIBS"])
106
107if test -n "$NETTLE_LIBS"; then
108  AC_DEFINE([WITH_DKIM], [1], [Enable DKIM functions])
109fi
110
111### Check for Emacs site-lisp directory
112AM_PATH_LISPDIR
113
114if test "$EMACS" != "no"; then
115	lisp_LISP='$(LISPSRC)'
116fi
117AC_SUBST(lisp_LISP)
118
119# Gettext.
120AM_GNU_GETTEXT([external], [need-formatstring-macros])
121AM_GNU_GETTEXT_VERSION([0.19])
122
123# Syslog
124AC_ARG_ENABLE([syslog-async],
125              AC_HELP_STRING([--enable-syslog-async],
126                             [compile non-blocking version of syslog]),
127              [case "${enableval}" in
128               yes) syslog_async=yes ;;
129               no)  syslog_async=no ;;
130               *)   AC_MSG_ERROR([bad value ${enableval} for --enable-syslog-async]) ;;
131               esac],[syslog_async=no])
132
133if test $syslog_async = "yes"; then
134  AC_ARG_VAR([DEFAULT_SYSLOG_ASYNC],
135             [Define to 1 if syslog-async is being used by default])
136  if test -z "$DEFAULT_SYSLOG_ASYNC"; then
137    DEFAULT_SYSLOG_ASYNC=0
138  fi
139  AC_DEFINE_UNQUOTED([DEFAULT_SYSLOG_ASYNC],$DEFAULT_SYSLOG_ASYNC,
140                     [Define to 1 to use syslog_async by default])
141  AC_SUBST([BUILD_SYSLOG_ASYNC], '$(SYSLOG_ASYNC_O)')
142  AC_DEFINE([USE_SYSLOG_ASYNC], [1], [Define if syslog-async is being used])
143fi
144# ######################
145# Default database type
146# ######################
147
148# A map of supported database types. The format is DBTYPE:FEATURE,
149# where FEATURE is the corresponding mailutils feature as listed by
150# 'mailutils info', without the WITH_ prefix and converted to lowercase.
151# The entries are sorted in ascending preference order.
152# Traditionally Mailfromd preferred Berkeley DB over GDBM.
153db_map="
154bdb:bdb
155gbdm:gdbm
156kc:kyotocabinet
157tc:tokyocabinet
158ndbm:ndbm
159"
160
161# Convert database type to mailutils feature
162db_type_to_feature() {
163    # Normalize the input
164    key=$(echo "$1" | tr A-Z a-z)
165    # Augment db_map with the line "$key:$key" and select from the resulting
166    # input the first entry starting with "$key:". On output, replace it with
167    # the characters that follow : up to the newline.
168    # The first expression looks for the string in the first line of input.
169    # If found, it replaces it and branches to the end of script. The second
170    # expression then has no chance to catch, since the scanning resumes from
171    # line 2. Otherwise, if key is not found in the first line, the second
172    # expression searches for it in the remaining lines.
173    # The default entry "$key:$key" ensures the normalized key is returned
174    # if no match was found.
175    sed -n -e "1s/^$key"'://p;t' -e '1,//{s///p}' <<EOF
176$db_map
177$key:$key
178EOF
179}
180
181# Convert mailutils feature to the database type
182db_feature_to_type() {
183    sed -n /:$(echo "$1" | tr A-Z a-z)'$/s/:.*//p' <<EOF
184$db_map
185EOF
186}
187
188# Produce the list of mailutils DBM features
189db_feature_list() {
190    sed 's/^.*://' <<EOF
191$db_map
192EOF
193}
194
195AC_ARG_VAR([DEFAULT_DB_TYPE],[Set default database type])
196
197AC_ARG_WITH([gdbm],
198             AC_HELP_STRING([--with-gdbm],
199                            [use GNU DBM by default]),
200            [
201case "${withval}" in
202  yes) DEFAULT_DB_TYPE=gdbm;;
203  no)  ;;
204  *)   AC_MSG_ERROR(bad value ${withval} for --with-gdbm) ;;
205esac])
206
207AC_ARG_WITH([berkeley-db],
208            AC_HELP_STRING([--with-berkeley-db],
209                           [use Berkeley DB by default]),
210            [
211case "${withval}" in
212  no)  ;;
213  *)   DEFAULT_DB_TYPE=bdb;;
214esac])
215
216AC_ARG_WITH([dbm],
217            AC_HELP_STRING([--with-dbm=TYPE],
218                           [set default DBM type]),
219            [DEFAULT_DB_TYPE=$withval])
220
221AH_TEMPLATE([DEFAULT_DB_TYPE], [Define default database type])
222if test -n "$DEFAULT_DB_TYPE"; then
223  if ! mailutils info $(db_type_to_feature $DEFAULT_DB_TYPE) >/dev/null; then
224    AC_MSG_ERROR([requested DBM type $DEFAULT_DB_TYPE not supported by Mailutils])
225  fi
226else
227  fl=$(db_feature_list)
228  feature=$(mailutils info $fl | head -n 1 | sed 's/WITH_//')
229  if test -n "$feature"; then
230      DEFAULT_DB_TYPE=$(db_feature_to_type $feature)
231      if test -z "$DEFAULT_DB_TYPE"; then
232        AC_MSG_WARN([can't select database type $feature, falling back to default])
233      fi
234  fi
235fi
236if test -n "$DEFAULT_DB_TYPE"; then
237  AC_DEFINE_UNQUOTED([DEFAULT_DB_TYPE], "$DEFAULT_DB_TYPE")
238  status_dbm=$DEFAULT_DB_TYPE
239else
240  AC_DEFINE_UNQUOTED([DEFAULT_DB_TYPE], NULL)
241fi
242
243## Preprocessor
244AC_ARG_WITH([preprocessor],
245            AC_HELP_STRING([--without-preprocessor],
246                           [do not use external preprocessor]),
247            [
248case "${withval}" in
249yes) use_ext_pp=yes ;;
250no)  use_ext_pp=no ;;
251*)   AC_MSG_ERROR(bad value ${withval} for --with-preprocessor) ;;
252esac],[use_ext_pp=yes])
253
254AC_ARG_VAR([DEFAULT_PREPROCESSOR],
255           [Set default preprocessor name])
256if test -z "$DEFAULT_PREPROCESSOR" ; then
257  DEFAULT_PREPROCESSOR="m4 -s"
258fi
259if test $use_ext_pp != no; then
260  save_PATH=$PATH
261  PREPROC_OPTIONS=`echo $DEFAULT_PREPROCESSOR | sed -n 's/[[^ ]][[^ ]]* //p'`
262  case "$DEFAULT_PREPROCESSOR" in
263  /*) PATH=`expr $DEFAULT_PREPROCESSOR : '\(.*\)/.*'`:$PATH
264      DEFAULT_PREPROCESSOR=`expr $DEFAULT_PREPROCESSOR : '.*/\(.*\)'`;;
265  esac
266  AC_PATH_PROG(PPBIN, $DEFAULT_PREPROCESSOR)
267  DEFAULT_PREPROCESSOR=$PPBIN
268  if test -n "$DEFAULT_PREPROCESSOR"; then
269    use_ext_pp=yes
270    DEFAULT_PREPROCESSOR="$DEFAULT_PREPROCESSOR $PREPROC_OPTIONS"
271    case $PPBIN in
272    *m4) AC_SUBST(PP_SETUP_FILE,'pp-setup');; # Install default pp-setup
273    esac
274  else
275    use_ext_pp=no
276  fi
277  PATH=$save_PATH
278else
279  unset DEFAULT_PREPROCESSOR
280fi
281AM_CONDITIONAL([PREPROC_COND], [test "$use_ext_pp" = yes])
282
283AC_ARG_WITH([readline],
284            AC_HELP_STRING([--without-readline],
285                           [do not use readline]),
286            [
287case "${withval}" in
288  yes) usereadline=yes ;;
289  no)  usereadline=no ;;
290  *)   AC_MSG_ERROR(bad value ${withval} for --without-readline) ;;
291esac],[usereadline=maybe])
292
293# Test for GNU Readline
294AC_SUBST(READLINE_LIBS)
295
296# IPv6 support
297MF_ENABLE_IPV6
298AC_SUBST([MF_IPV6_SUPPORT], $status_ipv6)
299
300if test "$usereadline" != "no"; then
301
302  dnl FIXME This should only link in the curses libraries if it's
303  dnl really needed!
304
305  dnl Check for Curses libs.
306  CURSES_LIBS=
307  for lib in ncurses curses termcap
308  do
309    AC_CHECK_LIB($lib, tputs, [CURSES_LIBS="-l$lib"; break])
310  done
311
312  saved_LIBS=$LIBS
313  LIBS="$LIBS $CURSES_LIBS"
314  AC_CHECK_LIB(readline, readline, mf_have_readline=yes)
315  LIBS=$saved_LIBS
316
317  if test "$mf_have_readline" = "yes"; then
318    AC_CHECK_HEADERS(readline/readline.h,
319  		     AC_DEFINE(WITH_READLINE,1,[Enable use of readline]))
320    READLINE_LIBS="-lreadline $CURSES_LIBS"
321    saved_LIBS=$LIBS
322    LIBS="$LIBS $READLINE_LIBS"
323    AC_CHECK_FUNCS(rl_completion_matches)
324    LIBS=$saved_LIBS
325    usereadline="yes"
326  else
327    if test "$usereadline" = "yes"; then
328      AC_MSG_WARN(readline requested but does not seem to be installed)
329    fi
330    usereadline="no"
331  fi
332fi
333
334AH_BOTTOM([
335/* Some older versions of readline have completion_matches */
336#ifndef HAVE_RL_COMPLETION_MATCHES
337# define rl_completion_matches completion_matches
338#endif])
339
340
341AC_SUBST(MILTER, '../gacopyz/libgacopyz.a')
342AC_SUBST(MILTER_INCLUDES, '-I$(top_srcdir)/gacopyz')
343
344# Set default state directory
345AC_SUBST(DEFAULT_STATE_DIR)
346AC_MSG_CHECKING(for default mfd state directory)
347
348AC_ARG_VAR([DEFAULT_STATE_DIR],
349           [Set default mfd state directory])
350
351if test -z "$DEFAULT_STATE_DIR"; then
352  DEFAULT_STATE_DIR='$(localstatedir)/$(PACKAGE)'
353fi
354
355AC_MSG_RESULT($DEFAULT_STATE_DIR)
356
357# Prepare default socket spec
358AC_SUBST(DEFAULT_SOCKET)
359AC_MSG_CHECKING(for default communication socket)
360
361AC_ARG_VAR([DEFAULT_SOCKET],
362           [Set default communication socket.])
363
364if test -z "$DEFAULT_SOCKET"; then
365  DEFAULT_SOCKET='mailfrom'
366fi
367
368AC_MSG_RESULT($DEFAULT_SOCKET)
369
370# Test for default user name
371AC_SUBST(DEFAULT_USER)
372AC_MSG_CHECKING(for default user name)
373
374AC_ARG_VAR([DEFAULT_USER],
375           [Set default user name])
376
377if test -z "$DEFAULT_USER"; then
378  DEFAULT_USER=mail
379fi
380
381AC_MSG_RESULT($DEFAULT_USER)
382AC_DEFINE_UNQUOTED(DEFAULT_USER, "$DEFAULT_USER", [Default mfd user])
383
384# Test for default expiration interval
385AC_SUBST(DEFAULT_EXPIRE_INTERVAL)
386AC_MSG_CHECKING(for default expiration interval)
387
388AC_ARG_VAR([DEFAULT_EXPIRE_INTERVAL],
389           [Set default expiration interval])
390
391if test -z "$DEFAULT_EXPIRE_INTERVAL"; then
392  DEFAULT_EXPIRE_INTERVAL=86400
393fi
394
395AC_MSG_RESULT($DEFAULT_EXPIRE_INTERVAL)
396AC_DEFINE_UNQUOTED(DEFAULT_EXPIRE_INTERVAL, $DEFAULT_EXPIRE_INTERVAL,
397                   [Default expiration interval])
398
399# Test for default dns negative expiration interval
400AC_SUBST(DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL)
401AC_MSG_CHECKING(for default dns negative expiration interval)
402
403AC_ARG_VAR([DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL],
404           [Set default expiration interval])
405
406if test -z "$DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL"; then
407  DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL=3600
408fi
409
410AC_MSG_RESULT($DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL)
411AC_DEFINE_UNQUOTED(DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL,
412                   $DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL,
413                   [Default expiration interval for negative DNS answers])
414
415# Test for default rates expiration interval
416AC_SUBST(DEFAULT_EXPIRE_RATES_INTERVAL)
417AC_MSG_CHECKING(for default rates expiration interval)
418
419AC_ARG_VAR([DEFAULT_EXPIRE_RATES_INTERVAL],
420           [Set default expiration interval])
421
422if test -z "$DEFAULT_EXPIRE_RATES_INTERVAL"; then
423  DEFAULT_EXPIRE_RATES_INTERVAL=300
424fi
425
426AC_MSG_RESULT($DEFAULT_EXPIRE_RATES_INTERVAL)
427AC_DEFINE_UNQUOTED(DEFAULT_EXPIRE_RATES_INTERVAL,
428                   $DEFAULT_EXPIRE_RATES_INTERVAL,
429                   [Default expiration interval for the rates database])
430
431# Test for default log facility
432AC_SUBST(DEFAULT_LOG_FACILITY)
433AC_MSG_CHECKING(for default log facility)
434
435AC_ARG_VAR([DEFAULT_LOG_FACILITY],
436           [Set default log facility])
437
438if test -z "$DEFAULT_LOG_FACILITY"; then
439  DEFAULT_LOG_FACILITY=mail
440fi
441
442DEFAULT_LOG_FACILITY=`echo $DEFAULT_LOG_FACILITY | tr a-z A-Z`
443case $DEFAULT_LOG_FACILITY in
444LOG_*) ;;
445*)   DEFAULT_LOG_FACILITY=LOG_$DEFAULT_LOG_FACILITY;;
446esac
447
448AC_TRY_COMPILE([#include <syslog.h>], [int lf = $DEFAULT_LOG_FACILITY],
449               :,
450               [AC_MSG_ERROR($DEFAULT_LOG_FACILITY: Unknown syslog facility)])
451
452AC_MSG_RESULT($DEFAULT_LOG_FACILITY)
453AC_DEFINE_UNQUOTED(DEFAULT_LOG_FACILITY, $DEFAULT_LOG_FACILITY,
454                   [Default log facility])
455
456# Test for setproctitle
457MF_PROCTITLE
458
459# Test for libpmilter
460AC_SUBST(META1_LIBS)
461AC_SUBST(META1_INCLUDES)
462
463AC_ARG_ENABLE([pmilter],
464              AC_HELP_STRING([--enable-pmilter[[=PATH]]],
465                             [enable pmilter support]),
466              [case "${enableval}" in
467               yes) enable_pmilter=yes;;
468               no)  enable_pmilter=no;;
469               /*)  dir=$enableval/lib/meta1
470                    if test -d $dir; then
471                      META1_LIBS="-L$dir"
472                    else
473                      AC_MSG_ERROR([$dir: No such directory])
474                    fi
475
476		    dir=$enableval/include
477		    if test -d $dir/sm; then
478                      META1_INCLUDES="-I$dir"
479                    else
480                      AC_MSG_ERROR([$dir: No such directory])
481                    fi
482
483                    enable_pmilter=yes
484                    ;;
485               *)   AC_MSG_ERROR([Bad argument to --enable-pmilter])
486               esac],[enable_pmilter=no])
487
488if test "$enable_pmilter" = yes; then
489  saved_LIBS=$LIBS
490  AC_SUBST(PTHREAD_LIBRARIES)
491  AC_CHECK_LIB(pthread, pthread_self,
492               [ have_pthread=yes
493                 PTHREAD_LIBRARIES="-lpthread -lc" ],
494               [ PTHREAD_LIBRARIES="-lpthread"
495                 AC_CHECK_FUNC(pthread_self,
496                               [HAVE_PTHREAD=yes]) ])
497  if test $have_pthread != yes; then
498    AC_MSG_ERROR([POSIX threads library not found. Please install it and then reconfigure])
499  fi
500
501  save_CPPFLAGS=$CPPFLAGS
502  CPPFLAGS="$CPPFLAGS $META1_INCLUDES"
503  AC_CHECK_HEADERS([sm/error.h sm/hdrmoddef.h sm/pmfapi.h sm/pmilter.h sm/smreplycodes.h sm/generic.h sm/mfapi.h sm/pmfdef.h sm/smmts.h],
504                   [],
505                   [AC_MSG_ERROR([Required header file $ac_header not found])],
506                   [
507#ifdef HAVE_SM_ERROR_H
508# include <sm/error.h>
509#endif])
510  CFFPLAGS=$save_CPPFLAGS
511
512  libs="pmilter pmutil evthr thr rcbcommr rcbr mtar cstrr replr"
513  save_LDFLAGS=$LDFLAGS
514  LDFLAGS="$LDFLAGS $META1_LIBS"
515  for file in $libs
516  do
517    AC_CHECK_LIB($file, main,
518                 [META1_LIBS="$META1_LIBS -l$file"],
519                 [AC_MSG_ERROR([Required library lib$file not found])])
520  done
521  LDFLAGS=$save_LDFLAGS
522
523  IU_CHECK_MEMBERS([struct pmilter_S.pmfi_thrmax_s,
524                    struct pmilter_S.pmfi_thrmax_h,
525		    struct pmilter_S.pmfi_fdmax], , ,
526		   [#include "sm/error.h"
527		    #include "sm/smreplycodes.h"
528		    #include "sm/pmilter.h"
529		    #include "sm/pmfdef.h"
530		    #include "sm/pmfapi.h"])
531
532  LIBS="$LIBS $META1_LIBS"
533  AC_CHECK_FUNCS([sm_pmfi_setmacs])
534  LIBS=$saved_LIBS
535fi
536
537AM_CONDITIONAL([PMULT_COND], [test "$enable_pmilter" = yes])
538
539# GeoIP
540AC_ARG_WITH([geoip],
541            AC_HELP_STRING([--with-geoip],
542                           [use the legacy GeoIP library (DEPRECATED)]),
543            [
544case "${withval}" in
545  yes) status_geoip=yes ;;
546  no)  status_geoip=no ;;
547  *)   AC_MSG_ERROR(bad value ${withval} for --with-geoip) ;;
548esac],[status_geoip=maybe])
549
550AC_SUBST(GEOIP_LIBS)
551if test "$status_geoip" != "no"; then
552  saved_LIBS=$LIBS
553  AC_CHECK_LIB(GeoIP, GeoIP_new,
554               [status_geoip="yes"
555	        GEOIP_LIBS="-lGeoIP"],
556               [if test $status_geoip = "yes"; then
557	          AC_MSG_WARN(GeoIP requested but does not seem to be installed)
558                fi
559		status_geoip="no"])
560  LIBS=$saved_LIBS
561  if test "$status_geoip" = "yes"; then
562    AC_DEFINE([WITH_GEOIP], [1], [Enable use of GeoIP library])
563  fi
564fi
565
566# GeoIP2
567AC_ARG_WITH([geoip2],
568            AC_HELP_STRING([--with-geoip2],
569                           [use MaxMind GeoIP2 library]),
570            [
571case "${withval}" in
572  yes) status_geoip2=yes ;;
573  no)  status_geoip2=no ;;
574  *)   AC_MSG_ERROR(bad value ${withval} for --with-geoip2) ;;
575esac],[status_geoip2=maybe])
576
577if test "$status_geoip2" != "no"; then
578  PKG_CHECK_MODULES([GEOIP2], [libmaxminddb], [status_geoip2=yes], [
579    if test $status_geoip2 = "yes"; then
580      AC_MSG_WARN(libmaxminddb requested but does not seem to be installed)
581    fi
582    status_geoip2="no"])
583fi
584if test "$status_geoip2" = "yes"; then
585  AC_DEFINE([WITH_GEOIP2], [1], [Enable use of Maxmind GeoIP2 library])
586fi
587
588## Dspam
589status_dspam=maybe
590AC_SUBST(DSPAM_CFLAGS)
591AC_SUBST(DSPAM_LIBS)
592
593AC_ARG_WITH([dspam],
594            [AC_HELP_STRING([--with-dspam],[build with DSPAM library])],
595            [status_dspam=$withval],
596            [status_dspam=maybe])
597
598if test $status_dspam != no; then
599  PKG_CHECK_MODULES([DSPAM], [dspam], [status_dspam=yes], [status_dspam=no])
600fi
601if test "$status_dspam" = "yes"; then
602  AC_DEFINE([WITH_DSPAM], [1], [Enable use of DSPAM library])
603fi
604AM_CONDITIONAL([DSPAM_COND], [test "$status_dspam" = yes])
605
606IMPRIMATUR_INIT
607if test $RENDITION = "PROOF"; then
608  if test -r $srcdir/git-describe; then
609    GIT_DESCRIBE=`sed '2,$d' $srcdir/git-describe`
610    AC_DEFINE_UNQUOTED([GIT_DESCRIBE], "$GIT_DESCRIBE",
611                       [The most recent git tag])
612  fi
613fi
614
615# Initialize the test suite.
616AC_CONFIG_TESTDIR(tests)
617AC_CONFIG_FILES([tests/Makefile tests/etc/Makefile tests/atlocal])
618AM_MISSING_PROG([AUTOM4TE], [autom4te])
619
620AC_CONFIG_COMMANDS([status],[
621cat <<EOF
622
623*******************************************************************
624Mailfromd configured with the following settings:
625
626Mailutils version......................... $mu_version
627External preprocessor..................... $ext_pp
628DBM version............................... $status_dbm
629Default user.............................. $user
630State directory........................... $stat_dir
631Socket.................................... $socket
632Expiration interval....................... $expire
633Negative DNS answer expiration interval... $negative_dns_expire
634Rates expire interval..................... $rates_expire
635Compile asynchronous syslog............... $syslog_async
636Readline (for mtasim)..................... $usereadline
637Documentation rendition type.............. $rendition
638Enable pmilter support.................... $enable_pmilter
639Enable GeoIP support...................... $status_geoip
640Enable GeoIP2 support..................... $status_geoip2
641Enable DSPAM support...................... $status_dspam
642IPv6 support.............................. $status_ipv6
643*******************************************************************
644
645EOF
646],
647[mu_version=$MAILUTILS_VERSION
648if test -z "$DEFAULT_PREPROCESSOR"; then
649  ext_pp=no
650else
651  ext_pp="$DEFAULT_PREPROCESSOR"
652fi
653status_dbm="$status_dbm"
654stat_dir='$DEFAULT_STATE_DIR'
655socket='$DEFAULT_SOCKET'
656user=$DEFAULT_USER
657expire=$DEFAULT_EXPIRE_INTERVAL
658negative_dns_expire=$DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL
659rates_expire=$DEFAULT_EXPIRE_RATES_INTERVAL
660usereadline=$usereadline
661rendition=$RENDITION
662syslog_async=$syslog_async
663enable_pmilter=$enable_pmilter
664status_geoip=$status_geoip
665status_geoip2=$status_geoip2
666status_dspam=$status_dspam
667status_ipv6=$status_ipv6
668])
669
670AC_CONFIG_FILES([Makefile
671	         lib/Makefile
672	         gacopyz/Makefile
673                 src/Makefile
674                 src/builtin/Makefile
675                 mflib/Makefile
676                 mtasim/Makefile
677                 pmult/Makefile
678                 elisp/Makefile
679                 po/Makefile.in
680                 etc/Makefile
681                 doc/Makefile])
682AC_OUTPUT
683
684
685
686