aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
blob: b4f042304612c818e5053be3aad2614ea9902234 (plain)
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
# This file is part of mailfrom filter.
# Copyright (C) 2005, 2006 Sergey Poznyakoff
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA 

AC_PREREQ(2.59)
AC_INIT([mailfromd], [1.4.91], [bug-mailfromd@gnu.org.ua])
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_LIBOBJ_DIR([src])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE
	
# Checks for programs.
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_YACC
AC_PROG_LEX

# Checks for libraries.
AC_CHECK_LIB(resolv, res_query)

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h unistd.h sysexits.h])

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.
AC_CHECK_FUNCS([vsyslog setegid setregid setresgid seteuid setreuid])
AC_REPLACE_FUNCS(daemon snprintf strtok_r)
AC_FUNC_OBSTACK

AC_CHECK_DECLS([strtok_r],
 , , [
#include <stdio.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif])

AH_BOTTOM([
#if !HAVE_DECL_STRTOK_R
extern char *strtok_r (char *s, const char *delim, char **save_ptr);
#endif
])

# Check for pthreads (required by milter)
HAVE_PTHREAD=no
AC_CHECK_LIB(pthread, pthread_self,
             [ HAVE_PTHREAD=yes
               LIBS="$LIBS -lpthread -lc" ],
             [ LIBS="$LIBS -pthread"
               AC_CHECK_FUNC(pthread_self,
                             [HAVE_PTHREAD=yes]) ])

if test $HAVE_PTHREAD != yes; then
	AC_MSG_ERROR([POSIX threads library not found. Please install one and then reconfigure])
fi
  
# Check for GNU Mailutils
AC_PATH_PROG(MU_CONFIG, mailutils-config, none, $PATH)
if test "$MU_CONFIG" = "none"; then
  AC_MSG_ERROR(cannot find GNU Mailutils)
fi

AC_MSG_CHECKING(whether extern program_invocation_name is present)
AC_TRY_COMPILE([#include <argp.h>
#include <errno.h>],
[ program_invocation_name = "test"; ],
[AC_DEFINE(PROGRAM_INVOCATION_NAME_DECLARED,1,
           [Define if program_invocation_name is declared in argp.h])
 AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])

AH_BOTTOM([
#ifndef PROGRAM_INVOCATION_NAME_DECLARED
extern char *program_invocation_short_name;
extern char *program_invocation_name;
#endif])


AC_SUBST(MAILUTILS_VERSION)
AC_SUBST(MAILUTILS_INCLUDES)
AC_SUBST(MAILUTILS_LIBS)
MAILUTILS_VERSION=`$MU_CONFIG --info version|sed s/.*=//`
MAILUTILS_INCLUDES=`$MU_CONFIG --compile`
MAILUTILS_LIBS=`$MU_CONFIG --link auth`
AC_DEFINE([MAILUTILS_VERSION_STRING], "\"$MAILUTILS_VERSION\"",
          [Mailutils Version String])

save_LIBS=$LIBS
LIBS="$LIBS $MAILUTILS_LIBS"
AC_CHECK_FUNCS([argcv_unescape_char])
LIBS=$save_LIBS

AH_BOTTOM([#ifndef HAVE_ARGCV_UNESCAPE_CHAR
# define argcv_unescape_char argcv_unquote_char
# define argcv_escape_char argcv_quote_char
#endif
])

AC_SUBST(MILTER)
MILTER=-lmilter
AC_MSG_CHECKING(for libmilter variant to use)
AC_ARG_WITH([forks],
            AC_HELP_STRING([--with-forks@<:@=FILENAME@:>@],
                           [link with forked version of libmilter (Recommended. See chapter 'Building' in the docs.)]),
            [case $withval in
	     yes) MILTER=-lmilter-fork;;
	     no)  ;;
             /*)  MILTER=$withval;;
	     *)   AC_MSG_ERROR([Invalid --with-forks option.])
             esac])
AC_MSG_RESULT($MILTER)

save_LIBS=$LIBS
LIBS="$LIBS $MILTER"
AC_LINK_IFELSE(AC_LANG_PROGRAM([#include <libmilter/mfapi.h>],
                                [return smfi_main();]),
               [:],
               [AC_MSG_ERROR(Required library $MILTER not found or unusable)])
LIBS=$save_LIBS

# Check for DBM flavor
AH_TEMPLATE(BDB2_CURSOR_LASTARG,
            [Last argument to the cursor member of Berkeley 2 DB structure])

dnl The cursor member of DB structure used to take three arguments in older
dnl implementations of Berkeley DB. Newer versions (>= 4.0) declare
dnl it as taking four arguments.
dnl This macro checks which of the variants we have.
AC_DEFUN([MU_DB2_CURSOR],
 [AC_CACHE_CHECK([whether db->cursor takes 4 arguments],
                 [mu_cv_bdb2_cursor_four_args],
  [AC_TRY_COMPILE([#include <db.h>],
                  [
DB *db;
db->cursor(NULL, NULL, NULL, 0)
                  ],
                  [mu_cv_bdb2_cursor_four_args=yes],
                  [mu_cv_bdb2_cursor_four_args=no])])
 if test $mu_cv_bdb2_cursor_four_args = yes; then
   AC_DEFINE(BDB2_CURSOR_LASTARG,[,0])
 else
   AC_DEFINE(BDB2_CURSOR_LASTARG,[])
 fi])

use_dbm=no
AC_ARG_WITH([gdbm],
            AC_HELP_STRING([--with-gdbm],
                           [use GNU DBM]),
            [
case "${withval}" in
  yes) use_dbm=GDBM ;;
  no)  use_dbm=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --with-gdbm) ;;
esac])

AC_ARG_WITH([db2],
            AC_HELP_STRING([--with-db2],
                           [use Berkeley DB]),
            [
case "${withval}" in
  yes) use_dbm=BDB2 ;;
  no)  use_dbm=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --with-db) ;;
esac])

AC_ARG_WITH([ndbm],
            AC_HELP_STRING([--with-ndbm],
                           [use NDBM]),
            [
case "${withval}" in
  yes) use_dbm=NDBM ;;
  no)  use_dbm=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --with-ndbm) ;;
esac])

AC_ARG_WITH([dbm],
            AC_HELP_STRING([--with-dbm],
                           [use old DBM]),
            [
case "${withval}" in
  yes) use_dbm=ODBM ;;
  no)  use_dbm=no ;;
  *)   AC_MSG_ERROR(bad value ${withval} for --with-old-dbm) ;;
esac])

case "$use_dbm" in
GDBM)
	AC_CHECK_LIB(gdbm, gdbm_open,
                     [AC_CHECK_HEADERS(gdbm.h,
                                       AC_DEFINE(WITH_GDBM,1,
                                                 [Enable use of GNU DBM library]))
                     LIBS="$LIBS -lgdbm"],
                     [use_dbm=no]);;
BDB2)
	AC_CHECK_LIB(db, db_open,
                     [AC_CHECK_HEADERS(db.h,
                                       AC_DEFINE(WITH_BDB2,1,
                                                 [Enable use of Berkeley DB]))
                     LIBS="$LIBS -ldb"
                     MU_DB2_CURSOR],
                     [use_dbm=no]);;
NDBM)
	AC_CHECK_LIB(ndbm, dbm_open,
                     [AC_CHECK_HEADERS(ndbm.h,
                                       AC_DEFINE(WITH_NDBM,1,
                                                 [Enable use of NDBM]))
                     LIBS="$LIBS -lndbm"],
                     [use_dbm=no]);;
ODBM)
	AC_CHECK_LIB(dbm, dbminit,
                     [AC_CHECK_HEADERS(dbm.h,
                                       AC_DEFINE(WITH_OLD_DBM,1,
                                                 [Enable use of old DBM library]))
                     LIBS="$LIBS -ldbm"],
                     [use_dbm=no]);;
esac

# Set default state directory
AC_SUBST(MAILFROMSTATEDIR)
AC_MSG_CHECKING(for default mailfromd state directory)

AC_ARG_VAR([MAILFROMSTATEDIR],
           [Set default mailfromd state directory])

if test -z "$MAILFROMSTATEDIR"; then
  MAILFROMSTATEDIR='$(localstatedir)/$(PACKAGE)'
fi

AC_MSG_RESULT($MAILFROMSTATEDIR)

# Prepare default socket spec
AC_SUBST(DEFAULT_SOCKET)
AC_MSG_CHECKING(for default communication socket)

AC_ARG_VAR([DEFAULT_SOCKET],
           [Set default communication socket.])

if test -z "$DEFAULT_SOCKET"; then
  DEFAULT_SOCKET='unix:$(MAILFROMSTATEDIR)/mailfrom'
fi

AC_MSG_RESULT($DEFAULT_SOCKET)

# Test for default user name
AC_SUBST(DEFAULT_USER)
AC_MSG_CHECKING(for default user name)

AC_ARG_VAR([DEFAULT_USER],
           [Set default user name])

if test -z "$DEFAULT_USER"; then
  DEFAULT_USER=mail
fi

AC_MSG_RESULT($DEFAULT_USER)

# Test for default expiration interval
AC_SUBST(DEFAULT_EXPIRE_INTERVAL)
AC_MSG_CHECKING(for default expiration interval)

AC_ARG_VAR([DEFAULT_EXPIRE_INTERVAL],
           [Set default expiration interval])

if test -z "$DEFAULT_EXPIRE_INTERVAL"; then
  DEFAULT_EXPIRE_INTERVAL=86400
fi

AC_MSG_RESULT($DEFAULT_EXPIRE_INTERVAL)

# Test for default expiration interval
AC_SUBST(DEFAULT_EXPIRE_RATES_INTERVAL)
AC_MSG_CHECKING(for default rates expiration interval)

AC_ARG_VAR([DEFAULT_EXPIRE_RATES_INTERVAL],
           [Set default expiration interval])

if test -z "$DEFAULT_EXPIRE_RATES_INTERVAL"; then
  DEFAULT_EXPIRE_RATES_INTERVAL=300
fi

AC_MSG_RESULT($DEFAULT_EXPIRE_RATES_INTERVAL)

AC_CONFIG_FILES([Makefile src/Makefile etc/Makefile doc/Makefile])	  
AC_OUTPUT

if test $use_dbm = no; then
	AC_MSG_WARN(Configured without DBM support. Caching will not be available)
fi

Return to:

Send suggestions and report system problems to the System administrator.