aboutsummaryrefslogtreecommitdiffstats
path: root/configure.in
blob: 06035b27601f6754e3c95a01626a6986a3a2a42f (plain) (blame)
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
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
#
# 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
# of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

dnl Process this file with autoconf to produce a configure script.
AC_REVISION($Revision: 6389 $)
AC_PREREQ(2.0)
AC_INIT(src/common.h)


# /usr/local/mailman is the default installation directory
AC_PREFIX_DEFAULT(/usr/local/mailman)


# Check for Python!  Better be found on $PATH
AC_MSG_CHECKING(for --with-python)
AC_ARG_WITH(python, dnl
[  --with-python                specify path to Python interpreter])
case "$with_python" in
    "") ans="no";;
    *)  ans="$with_python"
esac
AC_MSG_RESULT($ans)

if test -z "$with_python"
then
        AC_PATH_PROG(with_python, python, /usr/local/bin/python)
fi

AC_MSG_CHECKING(Python interpreter)
if test ! -x $with_python
then
    AC_MSG_ERROR([

***** No Python interpreter found!
***** Try including the configure option
***** --with-python=/path/to/python/interpreter])
fi
AC_SUBST(PYTHON)
PYTHON=$with_python
AC_MSG_RESULT($PYTHON)

# See if Python is new enough.  2.1 or better is required, with 2.1.3
# recommended.
AC_MSG_CHECKING(Python version)
changequote(,)
cat > conftest.py <<EOF
import sys
try:
    v = sys.hexversion
except AttributeError:
    v = 0
# int of hexversion 0x2010000
if v >= 0x2010000:
    s = sys.version.split()[0]
else:
    s = ""
fp = open("conftest.out", "w")
fp.write("%s\n" % s)
fp.close()
EOF
changequote([, ])
$PYTHON conftest.py
version=`cat conftest.out`
rm -f conftest.out conftest.py
if test -z "$version"
then
    AC_MSG_ERROR([

***** $PYTHON is too old (or broken)
***** Python 2.1 or newer is required
***** Python 2.1.3 or better is recommended])
fi
AC_MSG_RESULT($version)

# Make sure distutils is available.  Some Linux Python packages split
# distutils into the "-devel" package, so they need both.
AC_MSG_CHECKING(that Python has a working distutils)
changequote(,)
cat > conftest.py <<EOF
try:
    import distutils.errors
    import distutils.sysconfig
except ImportError:
    res = "no"
else:
    try:
        distutils.sysconfig.get_config_vars()
    except distutils.errors.DistutilsPlatformError:
        res = "no"
    else:
        res = "yes"
fp = open("conftest.out", "w")
fp.write("%s\n" % res)
fp.close()
EOF
changequote([, ])
$PYTHON conftest.py
havedistutils=`cat conftest.out`
rm -f conftest.out conftest.py
if test "$havedistutils" != "yes"
then
    AC_MSG_ERROR([

***** Distutils is not available or is incomplete for $PYTHON
***** If you installed Python from RPM (or other package manager)
***** be sure to install the -devel package, or install Python
***** from source.  See README.LINUX for details])
fi
AC_MSG_RESULT($havedistutils)

# Checks for programs.
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PATH_PROG(TRUE, true, true, $PATH:/bin:/usr/bin)

# Find compiler, allow alternatives to gcc
AC_MSG_CHECKING(for --without-gcc)
AC_ARG_WITH(gcc, [  --without-gcc               never use gcc], [
        case $withval in
        no)     CC=cc
                without_gcc=yes;;
        yes)    CC=gcc
                without_gcc=no;;
        *)      CC=$withval
                without_gcc=$withval;;
        esac], without_gcc=no;)
AC_MSG_RESULT($without_gcc)

# If the user switches compilers, we can't believe the cache
if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
then
  AC_ERROR(cached CC is different -- throw away $cache_file
(it is also a good idea to do 'make clean' before compiling))
fi

AC_PROG_CC


# Optimizer/debugger flags passed between Makefiles
AC_SUBST(OPT)
if test -z "$OPT"
then
        case $GCC in
        yes)
                case $ac_cv_prog_cc_g in
                yes)    OPT="-g -O2";;
                *)      OPT="-O2";;
                esac
                ;;
        *)      OPT="-O";;
        esac
fi

# We better be able to execute interpreters
AC_SYS_INTERPRETER
if test "$ac_cv_sys_interpreter" != "yes"
then
    AC_MSG_ERROR([

***** Cannot execute interpreter scripts?
***** Are you sure you system doesn't support this?])
fi


# Check for an alternate data directory, separate from installation dir.
default_var_prefix="/var/mailman"
AC_SUBST(VAR_PREFIX)
AC_MSG_CHECKING(for --with-var-prefix)
AC_ARG_WITH(var-prefix, dnl
[  --with-var-prefix     directory for mutable data [/var/mailman]])
case "$with_var_prefix" in
        yes)    VAR_PREFIX="$default_var_prefix"; ans=$VAR_PREFIX;;
        ""|no)  VAR_PREFIX="$prefix"; ans="no";;
        *)      VAR_PREFIX="$with_var_prefix"; ans=$VAR_PREFIX;
esac
AC_MSG_RESULT($ans)

AC_MSG_CHECKING(for --with-permcheck)
AC_ARG_WITH(permcheck, dnl
[  --without-permcheck  skip the check for target directory permissions])
if test -z "$with_permcheck"
then
        with_permcheck="yes"
fi
AC_MSG_RESULT($with_permcheck)
# Now make sure that $prefix is set up correctly.  It must be group
# owned by the target group, it must have the group sticky bit set, and
# it must be a+rx
if test "$VAR_PREFIX" = "NONE"
then
    VAR_PREFIX=$ac_default_prefix
    prefixcheck=$ac_default_prefix
else
    prefixcheck=$VAR_PREFIX
fi

# new macro for finding group names
AC_DEFUN(MM_FIND_GROUP_NAME, [
# $1 == variable name
# $2 == user id to check for
AC_SUBST($1)
changequote(,)
if test -z "$$1"
then
    cat > conftest.py <<EOF
import grp
gid = ''
for group in "$2".split():
    try:
        try:
            gname = grp.getgrgid(int(group))[0]
            break
        except ValueError:
            gname = grp.getgrnam(group)[0]
            break
    except KeyError:
        gname = ''
fp = open("conftest.out", "w")
fp.write("%s\n" % gname)
fp.close()
EOF
    $PYTHON conftest.py
    $1=`cat conftest.out`
fi
changequote([, ])
rm -f conftest.out conftest.py])


# new macro for finding UIDs
AC_DEFUN(MM_FIND_USER_NAME, [
# $1 == variable name
# $2 == user id to check for
AC_SUBST($1)
changequote(,)
if test -z "$$1"
then
    cat > conftest.py <<EOF
import pwd
uid = ''
for user in "$2".split():
    try:
        try:
            uname = pwd.getpwuid(int(user))[0]
            break
        except ValueError:
            uname = pwd.getpwnam(user)[0]
            break
    except KeyError:
        uname = ''
fp = open("conftest.out", "w")
fp.write("%s\n" % uname)
fp.close()
EOF
    $PYTHON conftest.py
    $1=`cat conftest.out`
fi
changequote([, ])
rm -f conftest.out conftest.py])

# Check for some other uid to use than `mailman'
AC_MSG_CHECKING(for --with-username)
AC_ARG_WITH(username, dnl
[  --with-username      specify a user name other than \"mailman\"])

if test -z "$with_username"
then
        with_username="mailman"
fi
USERNAME=$with_username
AC_MSG_RESULT($USERNAME)

# User `mailman' must exist
AC_SUBST(MAILMAN_USER)
AC_MSG_CHECKING(for user name \"$USERNAME\")
MM_FIND_USER_NAME(MAILMAN_USER, $USERNAME)
if test -z "$MAILMAN_USER"
then
  if test "$with_permcheck" = "yes"
  then
    AC_MSG_ERROR([
***** No \"$USERNAME\" user found!
***** Your system must have a \"$USERNAME\" user defined
***** (usually in your /etc/passwd file).  Please see the INSTALL
***** file for details.])
  fi
fi
AC_MSG_RESULT(okay)


# Check for some other gid to use than `mailman'
AC_MSG_CHECKING(for --with-groupname)
AC_ARG_WITH(groupname, dnl
[  --with-groupname     specify a group name other than \"mailman\"])

if test -z "$with_groupname"
then
        with_groupname="mailman"
fi
GROUPNAME=$with_groupname
AC_MSG_RESULT($GROUPNAME)


# Target group must exist
AC_SUBST(MAILMAN_GROUP)
AC_MSG_CHECKING(for group name \"$GROUPNAME\")
MM_FIND_GROUP_NAME(MAILMAN_GROUP, $GROUPNAME)
if test -z "$MAILMAN_GROUP"
then
  if test "$with_permcheck" = "yes"
  then
    AC_MSG_ERROR([
***** No \"$GROUPNAME\" group found!
***** Your system must have a \"$GROUPNAME\" group defined
***** (usually in your /etc/group file).  Please see the INSTALL
***** file for details.])
  fi
fi
AC_MSG_RESULT(okay)


AC_MSG_CHECKING(permissions on $prefixcheck)
changequote(,)
cat > conftest.py <<EOF
import os, grp
from stat import *
prefix = "$prefixcheck"
groupname = "$GROUPNAME"
mailmangroup = "$MAILMAN_GROUP"
try:
    mailmangid = grp.getgrnam(mailmangroup)[2]
except KeyError:
    mailmangid = -1
problems = []
try: statdata = os.stat(prefix)
except OSError:
    problems.append("Directory doesn't exist: " + prefix)
else:
    mode = statdata[ST_MODE]
    gid = statdata[ST_GID]
    if mailmangid <> gid:
        problems.append("Directory must be owned by group " +
                        groupname + ": " + prefix)
    if (mode & S_ISGID) <> S_ISGID:
        problems.append("Set-gid bit must be set for directory: " + prefix)
    perms = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH
    if (mode & perms) <> perms:
        problems.append("Permissions should be at least 02775: " + prefix)
if not problems:
    msg = "okay\n"
else:
    msg = '***** ' + '\n***** '.join(problems) + '\n'
fp = open("conftest.out", "w")
fp.write(msg)
fp.close()
EOF
changequote([, ])
$PYTHON conftest.py
status=`cat conftest.out`
rm -f conftest.out conftest.py
if test "$with_permcheck" = "yes"
then
    if test "$status" != "okay"
    then
        AC_MSG_ERROR([
***** Installation directory $prefixcheck is not configured properly!
$status])
    fi
else
    status="skipped"
fi
AC_MSG_RESULT($status)


# Now find the UIDs and GIDs
# Support --with-mail-gid and --with-cgi-gid
AC_MSG_CHECKING(for mail wrapper group; i.e. --with-mail-gid)
AC_ARG_WITH(mail-gid, dnl
[  --with-mail-gid      group name mail programs run as])
if test -z "$with_mail_gid"
then
    with_mail_gid="mailman other mail daemon"
fi
MM_FIND_GROUP_NAME(MAIL_GROUP, $with_mail_gid)
if test -z "$MAIL_GROUP"
then
  if test "$with_permcheck" = "yes"
  then
    AC_MSG_ERROR([
***** No group name \"$with_mail_gid\" found for the mail wrapper program.
***** This is the group that your mail server will use to run Mailman's
***** programs.  You should specify an existing group with the
***** --with-mail-gid configure option, or use --without-permcheck to
***** skip this verification step.  See also your mail server's documentation,
***** and Mailman's INSTALL file for details])
  else
    MAIL_GROUP=$with_mail_gid
  fi
fi
AC_MSG_RESULT($MAIL_GROUP)


AC_MSG_CHECKING(for CGI wrapper group; i.e. --with-cgi-gid)
AC_ARG_WITH(cgi-gid, dnl
[  --with-cgi-gid       group name CGI programs run as])
if test -z "$with_cgi_gid"
then
    with_cgi_gid="www www-data nobody"
fi

MM_FIND_GROUP_NAME(CGI_GROUP, $with_cgi_gid)
if test -z "$CGI_GROUP"
then
  if test "$with_permcheck" = "yes"
  then
    AC_MSG_ERROR([
***** No group name \"$with_cgi_gid\" found for the CGI wrapper program.
***** This is the group that your web server will use to run Mailman's
***** programs.  You should specify an existing group with the
***** --with-cgi-gid configure option, or use --without-permcheck to
***** skip this verification step.  See also your web server's documentation,
***** and Mailman's INSTALL file for details])
  else
    CGI_GROUP=$with_cgi_gid
  fi
fi
AC_MSG_RESULT($CGI_GROUP)


# Check for CGI extensions, required by some Web servers
AC_SUBST(CGIEXT)
AC_MSG_CHECKING(for CGI extensions)
AC_ARG_WITH(cgi-ext, dnl
[  --with-cgi-ext       specify extension for CGI programs (include dot)])
if test -z "$with_cgi_ext"
then
        CGIEXT=''
        with_cgi_ext='no'
else
        CGIEXT=$with_cgi_ext
fi
AC_MSG_RESULT($with_cgi_ext)


# figure out the default mail hostname and url host component
AC_SUBST(MAILHOST)
AC_MSG_CHECKING(for --with-mailhost)
AC_ARG_WITH(mailhost, dnl
[  --with-mailhost      specify the hostname part for outgoing email])
if test -z "$with_mailhost"
then
        MAILHOST=''
        with_mailhost='no'
else
        MAILHOST=$with_mailhost
fi
AC_MSG_RESULT($with_mailhost)

AC_SUBST(URLHOST)
AC_MSG_CHECKING(for --with-urlhost)
AC_ARG_WITH(urlhost, dnl
[  --with-urlhost       specify the hostname part of urls])
if test -z "$with_urlhost"
then
        URLHOST=''
        with_urlhost='no'
else
        URLHOST=$with_urlhost
fi
AC_MSG_RESULT($with_urlhost)

changequote(,)
cat > conftest.py <<EOF
# python
from socket import *
fqdn = getfqdn()
fp = open('conftest.out', 'w')
print >> fp, fqdn
print >> fp, fqdn
fp.close()
EOF
$PYTHON conftest.py
changequote([, ])
AC_MSG_CHECKING(for default mail host name)
if test -z "$MAILHOST"
then
    MAILHOST=`sed q conftest.out`
fi
AC_MSG_RESULT($MAILHOST)
AC_MSG_CHECKING(for default URL host component)
if test -z "$URLHOST"
then
    URLHOST=`sed -n '$p' conftest.out`
fi
AC_MSG_RESULT($URLHOST)
rm -f conftest.out conftest.py

# Checks for libraries.
AC_CHECK_FUNCS(strerror setregid syslog)
if test $ac_cv_func_syslog = no; then
  # syslog is not in the default libraries.  See if it's in some other.
  # Additionally, for at least SCO OpenServer, syslog() is #defined to
  # one of several _real_ functions in syslog.h, so we need to do the test
  # with the appropriate include.
  for lib in bsd socket inet; do
    AC_MSG_CHECKING(for syslog in -l$lib)
    Mailman_LIBS_save="$LIBS"; LIBS="$LIBS -l$lib"
    AC_TRY_LINK([#include <syslog.h>],
                [syslog(LOG_DEBUG, "Just a test...");],
                [AC_MSG_RESULT(yes)
      AC_DEFINE(HAVE_SYSLOG)
      break],
                [AC_MSG_RESULT(no)
      LIBS="$Mailman_LIBS_save"])
    unset Mailman_LIBS_save
  done
fi

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(syslog.h)

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_UID_T
AC_TYPE_GETGROUPS

# Checks for library functions.
AC_CHECK_FUNCS(vsnprintf)

dnl Expand PYTHON path in the scripts, output into build/scriptname

AC_DEFUN(MM_SCRIPTS, [dnl
bin/add_members \
bin/arch \
bin/change_pw \
bin/check_db \
bin/check_perms \
bin/cleanarch \
bin/clone_member \
bin/config_list \
bin/convert.py \
bin/dumpdb \
bin/find_member \
bin/fix_url.py \
bin/genaliases \
bin/inject \
bin/list_admins \
bin/list_lists \
bin/list_members \
bin/list_owners \
bin/mailmanctl \
bin/mmsitepass \
bin/msgfmt.py \
bin/newlist \
bin/pygettext.py \
bin/qrunner \
bin/remove_members \
bin/rmlist \
bin/sync_members \
bin/transcheck \
bin/unshunt \
bin/update \
bin/version \
bin/withlist \
bin/b4b5-archfix \
contrib/check_perms_grsecurity.py \
contrib/qmail-to-mailman.py \
contrib/rotatelogs.py \
cron/bumpdigests \
cron/checkdbs \
cron/disabled \
cron/gate_news \
cron/mailpasswds \
cron/nightly_gzip \
cron/senddigests \
])

dnl Please make sure to leave a space at the end of the last entry.
dnl (This is so we don't have to use [a-z/] style character classes
dnl in the regexp below and mess with m4 quoting, which is not fun.)

dnl This regexp munges each line in MM_SCRIPTS, replacing:
dnl   path/script \
dnl with:
dnl   build/path/script:path/script \
dnl so that we can macro-expand variables in scripts without using
dnl script.in filenames, outputting the new files in build/ .

SCRIPTS="patsubst(MM_SCRIPTS, \(.+\) \(\\?\), build/\1:\1 \2)"

AC_SUBST(SCRIPTS)

# These directories are temporary directories to store macro-expanded
# scripts.  They're removed on a make distclean, so we make them here.
mkdir -p build/bin build/contrib build/cron

dnl Output everything
AC_OUTPUT([misc/paths.py Mailman/Defaults.py Mailman/mm_cfg.py.dist
           src/Makefile misc/Makefile bin/Makefile
           Mailman/Makefile Mailman/Cgi/Makefile Mailman/Logging/Makefile
           Mailman/Archiver/Makefile Mailman/Commands/Makefile
           Mailman/Handlers/Makefile Mailman/Bouncers/Makefile
           Mailman/Queue/Makefile Mailman/MTA/Makefile Mailman/Gui/Makefile
           templates/Makefile cron/Makefile scripts/Makefile messages/Makefile
           cron/crontab.in misc/mailman Makefile
           tests/Makefile tests/bounces/Makefile tests/msgs/Makefile
           $SCRIPTS],
        echo "configuration completed at" `date`)

# Make sure all the build scripts are executable.
chmod -R +x build

# Test for the Chinese codecs.
dnl AC_MSG_CHECKING(for Python Chinese Unicode codecs)
dnl cat > conftest.py <<EOF
dnl try:
dnl   unicode("abc", "big5-tw")
dnl   print "found"
dnl except LookupError:
dnl   print "not found"
dnl EOF
dnl chinese=`$PYTHON conftest.py 2>/dev/null`
dnl rm -f conftest.py
dnl AC_MSG_RESULT($chinese)
dnl if test "x$chinese" != "xfound"
dnl then
dnl     AC_MSG_WARN([

dnl ***** Python Unicode codecs for Chinese not found.
dnl ***** Chinese emails generated by or manipulated in Mailman will not
dnl ***** be sent in the correct encoding and may be unreadable.
dnl ***** Please uncompress and install the Chinese codecs from:
dnl ***** http://sourceforge.net/projects/python-codecs/
dnl *****
dnl ***** Note: Everything else will work just fine.
dnl ])
dnl fi