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
|
# This file is part of mailfromd.
# Copyright (C) 2005, 2006, 2007 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 3, 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)
m4_define([MF_VERSION_MAJOR], 4)
m4_define([MF_VERSION_MINOR], 1)
m4_define([MF_VERSION_PATCH], 1)
AC_INIT([mailfromd],
MF_VERSION_MAJOR.MF_VERSION_MINOR[]m4_ifdef([MF_VERSION_PATCH],.MF_VERSION_PATCH),
[bug-mailfromd@gnu.org.ua])
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE
#
AC_DEFINE_UNQUOTED([MAILFROMD_VERSION_MAJOR], MF_VERSION_MAJOR,
[Major version number])
AC_DEFINE_UNQUOTED([MAILFROMD_VERSION_MINOR], MF_VERSION_MINOR,
[Minor version number])
AC_DEFINE_UNQUOTED([MAILFROMD_VERSION_PATCH],
m4_ifdef([MF_VERSION_PATCH],MF_VERSION_PATCH,0),
[Patchlevel number])
# Checks for programs.
AC_PROG_CC
gl_EARLY
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.
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_CHECK_SIZEOF(uint32_t)
AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_SIZEOF(unsigned int)
AH_TEMPLATE(GACOPYZ_UINT32_T, [32-bit unsigned data type])
if test "$ac_cv_sizeof_uint32_t" = 4 ; then
AC_DEFINE_UNQUOTED(GACOPYZ_UINT32_T, uint32_t)
elif test "$ac_cv_sizeof_unsigned_int" = 4 ; then
AC_DEFINE_UNQUOTED(GACOPYZ_UINT32_T, unsigned int)
elif test "$ac_cv_sizeof_unsigned_long" = 4 ; then
AC_DEFINE_UNQUOTED(GACOPYZ_UINT32_T, unsigned long)
else
AC_MSG_ERROR([cannot determine 32-bit unsigned data type])
fi
# Checks for library functions.
AC_CHECK_FUNCS([vsyslog setegid setregid setresgid seteuid setreuid \
res_ninit res_nclose res_nquery res_nquerydomain \
sysconf getdtablesize])
AC_REPLACE_FUNCS(daemon)
gl_INIT
AH_BOTTOM([
#if !HAVE_DECL_STRTOK_R
extern char *strtok_r (char *s, const char *delim, char **save_ptr);
#endif
/* program_name is used by lib/error.c */
#define program_name program_invocation_name
])
# 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_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`
save_LIBS=$LIBS
LIBS="$LIBS $MAILUTILS_LIBS"
AC_CHECK_FUNCS([argcv_unescape_char mu_get_auth])
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
])
### Check for Emacs site-lisp directory
AM_PATH_LISPDIR
if test "$EMACS" != "no"; then
lisp_LISP='$(LISPSRC)'
fi
AC_SUBST(lisp_LISP)
# Gettext.
AM_GNU_GETTEXT([external], [need-formatstring-macros])
AM_GNU_GETTEXT_VERSION([0.16])
# Syslog -- removed due to version incompatibility
if test "${enable_syslog_async+set}" = set; then
AC_MSG_WARN([The option --enable-syslog-async is no longer supported.])
fi
# 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])
AH_TEMPLATE([WITH_BDB],
[Define to the major version of Berkeley DB library to use])
use_dbm=no
status_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])
## Support --with-db2 for backward compatibility
if test "${with_db2+set}" = set; then
case "${with_db2}" in
yes) use_dbm=BDB2 ;;
no) use_dbm=no ;;
*) AC_MSG_ERROR(bad value ${with_db2} for --with-db2) ;;
esac
fi
AC_ARG_WITH([berkeley-db],
AC_HELP_STRING([--with-berkeley-db@<:@=version@:>@],
[use Berkeley DB]),
[
case "${withval}" in
yes) use_dbm=BDB ;;
no) use_dbm=no ;;
*) use_dbm=BDB="${withval}";;
esac])
## Set the variable status_dbm to $1 if:
##
## 1. Function $3 is defined in the library $2
## 2. Header file db.h is available
##
## Then check if the major version, minor version and patchlevel of the
## library matches those from the header. If so, define WITH_BDB
## to the version (i.e. $1 with all dots removed). Otherwise, report
## an error and stop.
##
check_bdb() {
ver=`echo $1 | tr -d '.'`
major=`expr $ver : '\(.\).*'`
AC_CHECK_LIB($2, $3,
[AC_CHECK_HEADERS(db.h)
if test $ac_cv_header_db_h = yes; then
LIBS="$LIBS -l$2"
MU_DB2_CURSOR
status_dbm=$1
fi])
if test $status_dbm = no; then
:
else
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([#include "db.h"],
[int v_major, v_minor, v_patch;
db_version(&v_major, &v_minor, &v_patch);
return !(DB_VERSION_MAJOR == $major
&& v_major == DB_VERSION_MAJOR
&& v_minor == DB_VERSION_MINOR
&& v_patch == DB_VERSION_PATCH);
])],
[AC_DEFINE_UNQUOTED(WITH_BDB,$ver)],
[status_dbm=no])
fi
}
AC_SUBST(MU_COMMON_INCLUDES)
## Check for the Berkeley DB library version $1, assuming Slackware-like
## installation layout (header files in /usr/incude/db$vn and library named
## libdb-$version.so, where $version is the library version and $vn is
## $version with all dots removed.
##
check_slackware_bdb() {
dir=db`echo $1|tr -d '.'`
save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -I/usr/include/$dir"
check_bdb $1 db-$1 db_create
CPPFLAGS=$save_CPPFLAGS
if test $status_dbm = "$1"; then
MU_COMMON_INCLUDES="$MU_COMMON_INCLUDES -I/usr/include/$dir"
fi
}
try_dbm() {
case "$1" 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"
POPAUTH='popauth$(EXEEXT)'
status_dbm=GDBM]);;
BDB2) check_bdb 2 db db_open
test -n "$status_dbm" && status_dbm="Berkeley DB v. $status_dbm";;
BDB) for version in 4 3 2
do
case $version in
4|3) func=db_create;;
2) func=db_open;;
esac
check_bdb $version db $func
if test "$status_dbm" != no; then
status_dbm="Berkeley DB v. $status_dbm"
break;
fi
done;;
BDB=*)
name=`expr $1 : 'BDB=\(.*\)'`
case $name in
[[0-9]]*) check_slackware_bdb $name;;
*) for version in 4 3 2
do
case $version in
4|3) func=db_create;;
2) func=db_open;;
esac
check_bdb $version $name $func
if test "$status_dbm" != no; then
break;
fi
done
;;
esac
test -n "$status_dbm" && status_dbm="Berkeley DB v. $status_dbm"
;;
esac
}
if test $use_dbm = no; then
# Try all possible DBM values
for use_dbm in BDB GDBM
do
try_dbm $use_dbm
if test "$status_dbm" != no; then
break
fi
done
else
try_dbm $use_dbm
fi
if test "$status_dbm" = "no"; then
AC_MSG_ERROR([Cannot find DBM library to link with.])
fi
AC_ARG_WITH([preprocessor],
AC_HELP_STRING([--without-preprocessor],
[do not use external preprocessor]),
[
case "${withval}" in
yes) use_ext_pp=yes ;;
no) use_ext_pp=no ;;
*) AC_MSG_ERROR(bad value ${withval} for --with-preprocessor) ;;
esac],[use_ext_pp=yes])
AC_ARG_VAR([DEFAULT_PREPROCESSOR],
[Set default preprocessor name])
if test -z "$DEFAULT_PREPROCESSOR" ; then
DEFAULT_PREPROCESSOR="m4 -s"
fi
if test $use_ext_pp != no; then
save_PATH=$PATH
PREPROC_OPTIONS=`echo $DEFAULT_PREPROCESSOR | sed -n 's/[[^ ]][[^ ]]* //p'`
case "$DEFAULT_PREPROCESSOR" in
/*) PATH=`expr $DEFAULT_PREPROCESSOR : '\(.*\)/.*'`:$PATH
DEFAULT_PREPROCESSOR=`expr $DEFAULT_PREPROCESSOR : '.*/\(.*\)'`;;
esac
AC_PATH_PROG(PPBIN, $DEFAULT_PREPROCESSOR)
DEFAULT_PREPROCESSOR=$PPBIN
if test -n "$DEFAULT_PREPROCESSOR"; then
DEFAULT_PREPROCESSOR="$DEFAULT_PREPROCESSOR $PREPROC_OPTIONS"
case $PPBIN in
*m4) AC_SUBST(PP_SETUP_FILE,'pp-setup');; # Install default pp-setup
esac
fi
PATH=$save_PATH
fi
AC_ARG_WITH([readline],
AC_HELP_STRING([--without-readline],
[do not use readline]),
[
case "${withval}" in
yes) usereadline=yes ;;
no) usereadline=no ;;
*) AC_MSG_ERROR(bad value ${withval} for --without-readline) ;;
esac],[usereadline=maybe])
# Test for GNU Readline
AC_SUBST(READLINE_LIBS)
if test "$usereadline" != "no"; then
dnl FIXME This should only link in the curses libraries if it's
dnl really needed!
dnl Check for Curses libs.
CURSES_LIBS=
for lib in ncurses curses termcap
do
AC_CHECK_LIB($lib, tputs, [CURSES_LIBS="-l$lib"; break])
done
saved_LIBS=$LIBS
LIBS="$LIBS $CURSES_LIBS"
AC_CHECK_LIB(readline, readline, mf_have_readline=yes)
LIBS=$saved_LIBS
if test "$mf_have_readline" = "yes"; then
AC_CHECK_HEADERS(readline/readline.h,
AC_DEFINE(WITH_READLINE,1,[Enable use of readline]))
READLINE_LIBS="-lreadline $CURSES_LIBS"
saved_LIBS=$LIBS
LIBS="$LIBS $READLINE_LIBS"
AC_CHECK_FUNCS(rl_completion_matches)
LIBS=$saved_LIBS
usereadline="yes"
else
if test "$usereadline" = "yes"; then
AC_MSG_WARN(readline requested but does not seem to be installed)
fi
usereadline = "no"
fi
fi
AH_BOTTOM([
/* Some older versions of readline have completion_matches */
#ifndef HAVE_RL_COMPLETION_MATCHES
# define rl_completion_matches completion_matches
#endif])
AC_SUBST(MILTER, '../gacopyz/libgacopyz.a')
AC_SUBST(MILTER_INCLUDES, '-I$(top_srcdir)/gacopyz')
# Set default state directory
AC_SUBST(DEFAULT_STATE_DIR)
AC_MSG_CHECKING(for default mailfromd state directory)
AC_ARG_VAR([DEFAULT_STATE_DIR],
[Set default mailfromd state directory])
if test -z "$DEFAULT_STATE_DIR"; then
DEFAULT_STATE_DIR='$(localstatedir)/$(PACKAGE)'
fi
AC_MSG_RESULT($DEFAULT_STATE_DIR)
# 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='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)
AC_DEFINE_UNQUOTED(DEFAULT_USER, "$DEFAULT_USER", [Default mailfromd 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)
AC_DEFINE_UNQUOTED(DEFAULT_EXPIRE_INTERVAL, $DEFAULT_EXPIRE_INTERVAL,
[Default expiration interval])
# Test for default dns negative expiration interval
AC_SUBST(DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL)
AC_MSG_CHECKING(for default dns negative expiration interval)
AC_ARG_VAR([DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL],
[Set default expiration interval])
if test -z "$DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL"; then
DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL=3600
fi
AC_MSG_RESULT($DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL)
AC_DEFINE_UNQUOTED(DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL,
$DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL,
[Default expiration interval for negative DNS answers])
# Test for default rates 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_DEFINE_UNQUOTED(DEFAULT_EXPIRE_RATES_INTERVAL,
$DEFAULT_EXPIRE_RATES_INTERVAL,
[Default expiration interval for the rates database])
# Test for default log facility
AC_SUBST(DEFAULT_LOG_FACILITY)
AC_MSG_CHECKING(for default log facility)
AC_ARG_VAR([DEFAULT_LOG_FACILITY],
[Set default log facility])
if test -z "$DEFAULT_LOG_FACILITY"; then
DEFAULT_LOG_FACILITY=mail
fi
DEFAULT_LOG_FACILITY=`echo $DEFAULT_LOG_FACILITY | tr a-z A-Z`
case $DEFAULT_LOG_FACILITY in
LOG_*) ;;
*) DEFAULT_LOG_FACILITY=LOG_$DEFAULT_LOG_FACILITY;;
esac
AC_TRY_COMPILE([#include <syslog.h>], [int lf = $DEFAULT_LOG_FACILITY],
:,
[AC_MSG_ERROR($DEFAULT_LOG_FACILITY: Unknown syslog facility)])
AC_MSG_RESULT($DEFAULT_LOG_FACILITY)
AC_DEFINE_UNQUOTED(DEFAULT_LOG_FACILITY, $DEFAULT_LOG_FACILITY,
[Default log facility])
# Doc hints.
# Select a rendition level:
# DISTRIB for stable releases (at most one dot in the version number)
# and maintenance releases (two dots, patchlevel < 50)
# PROOF for alpha releases.
# PUBLISH can only be required manually when running make in doc/
AC_SUBST(RENDITION)
case `echo $VERSION|sed 's/[[^.]]//g'` in
""|".") RENDITION=DISTRIB;;
"..") if test `echo $VERSION | sed 's/.*\.//'` -lt 50; then
RENDITION=DISTRIB
else
RENDITION=PROOF
fi;;
*) RENDITION=PROOF;;
esac
# Debugging mode
MU_DEBUG_MODE
# Initialize the test suite.
AC_CONFIG_TESTDIR(tests)
AC_CONFIG_FILES([tests/Makefile tests/etc/Makefile tests/atlocal])
AM_MISSING_PROG([AUTOM4TE], [autom4te])
AC_CONFIG_COMMANDS([status],[
cat <<EOF
*******************************************************************
Mailfromd configured with the following settings:
External preprocessor..................... $ext_pp
DBM version............................... $status_dbm
Default user.............................. $user
State directory........................... $stat_dir
Socket.................................... $socket
Expiration interval....................... $expire
Negative DNS answer expiration interval... $negative_dns_expire
Rates expire interval..................... $rates_expire
Syslog implementation..................... $syslog_flavor
Readline (for mtasim)..................... $usereadline
Documentation rendition type.............. $rendition
*******************************************************************
EOF
],
[if test -z "$DEFAULT_PREPROCESSOR"; then
ext_pp=no
else
ext_pp="$DEFAULT_PREPROCESSOR"
fi
status_dbm="$status_dbm"
stat_dir='$DEFAULT_STATE_DIR'
socket='$DEFAULT_SOCKET'
user=$DEFAULT_USER
expire=$DEFAULT_EXPIRE_INTERVAL
negative_dns_expire=$DEFAULT_DNS_NEGATIVE_EXPIRE_INTERVAL
rates_expire=$DEFAULT_EXPIRE_RATES_INTERVAL
usereadline=$usereadline
rendition=$RENDITION
if test "$syslog_async" = "yes"; then
syslog_flavor="non-blocking"
else
syslog_flavor="standard"
fi
])
AC_CONFIG_FILES([Makefile
lib/Makefile
gacopyz/Makefile
src/Makefile
mflib/Makefile
elisp/Makefile
po/Makefile.in
etc/Makefile
doc/Makefile])
AC_OUTPUT
|