1 # Copyright (C) 1998-2006 by the Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 dnl Process this file with autoconf to produce a configure script.
18 AC_REVISION($Revision: 8122 $)
23 # /usr/local/mailman is the default installation directory
24 AC_PREFIX_DEFAULT(/usr/local/mailman)
27 # Check for Python! Better be found on $PATH
28 AC_MSG_CHECKING(for --with-python)
29 AC_ARG_WITH(python, dnl
30 [ --with-python specify path to Python interpreter])
31 case "$with_python" in
37 if test -z "$with_python"
39 AC_PATH_PROG(with_python, python, /usr/local/bin/python)
42 AC_MSG_CHECKING(Python interpreter)
43 if test ! -x $with_python
47 ***** No Python interpreter found!
48 ***** Try including the configure option
49 ***** --with-python=/path/to/python/interpreter])
53 AC_MSG_RESULT($PYTHON)
55 # See if Python is new enough. 2.1 or better is required, with 2.1.3
57 AC_MSG_CHECKING(Python version)
59 cat > conftest.py <<EOF
63 except AttributeError:
65 # int of hexversion 0x2010000
67 s = sys.version.split()[0]
70 fp = open("conftest.out", "w")
76 version=`cat conftest.out`
77 rm -f conftest.out conftest.py
82 ***** $PYTHON is too old (or broken)
83 ***** Python 2.1 or newer is required
84 ***** Python 2.1.3 or better is recommended])
86 AC_MSG_RESULT($version)
88 # Make sure distutils is available. Some Linux Python packages split
89 # distutils into the "-devel" package, so they need both.
90 AC_MSG_CHECKING(that Python has a working distutils)
92 cat > conftest.py <<EOF
94 import distutils.errors
95 import distutils.sysconfig
100 distutils.sysconfig.get_config_vars()
101 except distutils.errors.DistutilsPlatformError:
105 fp = open("conftest.out", "w")
106 fp.write("%s\n" % res)
111 havedistutils=`cat conftest.out`
112 rm -f conftest.out conftest.py
113 if test "$havedistutils" != "yes"
117 ***** Distutils is not available or is incomplete for $PYTHON
118 ***** If you installed Python from RPM (or other package manager)
119 ***** be sure to install the -devel package, or install Python
120 ***** from source. See README.LINUX for details])
122 AC_MSG_RESULT($havedistutils)
124 # Checks for programs.
127 AC_PATH_PROG(TRUE, true, true, $PATH:/bin:/usr/bin)
129 # Find compiler, allow alternatives to gcc
130 AC_MSG_CHECKING(for --without-gcc)
131 AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [
138 without_gcc=$withval;;
139 esac], without_gcc=no;)
140 AC_MSG_RESULT($without_gcc)
142 # If the user switches compilers, we can't believe the cache
143 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
145 AC_ERROR(cached CC is different -- throw away $cache_file
146 (it is also a good idea to do 'make clean' before compiling))
152 # Optimizer/debugger flags passed between Makefiles
158 case $ac_cv_prog_cc_g in
167 # We better be able to execute interpreters
169 if test "$ac_cv_sys_interpreter" != "yes"
173 ***** Cannot execute interpreter scripts?
174 ***** Are you sure you system doesn't support this?])
178 # Check for an alternate data directory, separate from installation dir.
179 default_var_prefix="/var/mailman"
181 AC_MSG_CHECKING(for --with-var-prefix)
182 AC_ARG_WITH(var-prefix, dnl
183 [ --with-var-prefix directory for mutable data [/var/mailman]])
184 case "$with_var_prefix" in
185 yes) VAR_PREFIX="$default_var_prefix"; ans=$VAR_PREFIX;;
186 ""|no) VAR_PREFIX="$prefix"; ans="no";;
187 *) VAR_PREFIX="$with_var_prefix"; ans=$VAR_PREFIX;
191 AC_MSG_CHECKING(for --with-permcheck)
192 AC_ARG_WITH(permcheck, dnl
193 [ --without-permcheck skip the check for target directory permissions])
194 if test -z "$with_permcheck"
198 AC_MSG_RESULT($with_permcheck)
199 # Now make sure that $prefix is set up correctly. It must be group
200 # owned by the target group, it must have the group sticky bit set, and
202 if test "$VAR_PREFIX" = "NONE"
204 VAR_PREFIX=$ac_default_prefix
205 prefixcheck=$ac_default_prefix
207 prefixcheck=$VAR_PREFIX
210 # new macro for finding group names
211 AC_DEFUN(MM_FIND_GROUP_NAME, [
212 # $1 == variable name
213 # $2 == user id to check for
218 cat > conftest.py <<EOF
221 for group in "$2".split():
224 gname = grp.getgrgid(int(group))[0]
227 gname = grp.getgrnam(group)[0]
231 fp = open("conftest.out", "w")
232 fp.write("%s\n" % gname)
236 $1=`cat conftest.out`
239 rm -f conftest.out conftest.py])
242 # new macro for finding UIDs
243 AC_DEFUN(MM_FIND_USER_NAME, [
244 # $1 == variable name
245 # $2 == user id to check for
250 cat > conftest.py <<EOF
253 for user in "$2".split():
256 uname = pwd.getpwuid(int(user))[0]
259 uname = pwd.getpwnam(user)[0]
263 fp = open("conftest.out", "w")
264 fp.write("%s\n" % uname)
268 $1=`cat conftest.out`
271 rm -f conftest.out conftest.py])
273 # Check for some other uid to use than `mailman'
274 AC_MSG_CHECKING(for --with-username)
275 AC_ARG_WITH(username, dnl
276 [ --with-username specify a user name other than \"mailman\"])
278 if test -z "$with_username"
280 with_username="mailman"
282 USERNAME=$with_username
283 AC_MSG_RESULT($USERNAME)
285 # User `mailman' must exist
286 AC_SUBST(MAILMAN_USER)
287 AC_MSG_CHECKING(for user name \"$USERNAME\")
288 MM_FIND_USER_NAME(MAILMAN_USER, $USERNAME)
289 if test -z "$MAILMAN_USER"
291 if test "$with_permcheck" = "yes"
294 ***** No \"$USERNAME\" user found!
295 ***** Your system must have a \"$USERNAME\" user defined
296 ***** (usually in your /etc/passwd file). Please see the INSTALL
297 ***** file for details.])
303 # Check for some other gid to use than `mailman'
304 AC_MSG_CHECKING(for --with-groupname)
305 AC_ARG_WITH(groupname, dnl
306 [ --with-groupname specify a group name other than \"mailman\"])
308 if test -z "$with_groupname"
310 with_groupname="mailman"
312 GROUPNAME=$with_groupname
313 AC_MSG_RESULT($GROUPNAME)
316 # Target group must exist
317 AC_SUBST(MAILMAN_GROUP)
318 AC_MSG_CHECKING(for group name \"$GROUPNAME\")
319 MM_FIND_GROUP_NAME(MAILMAN_GROUP, $GROUPNAME)
320 if test -z "$MAILMAN_GROUP"
322 if test "$with_permcheck" = "yes"
325 ***** No \"$GROUPNAME\" group found!
326 ***** Your system must have a \"$GROUPNAME\" group defined
327 ***** (usually in your /etc/group file). Please see the INSTALL
328 ***** file for details.])
334 AC_MSG_CHECKING(permissions on $prefixcheck)
336 cat > conftest.py <<EOF
339 prefix = "$prefixcheck"
340 groupname = "$GROUPNAME"
341 mailmangroup = "$MAILMAN_GROUP"
343 mailmangid = grp.getgrnam(mailmangroup)[2]
347 try: statdata = os.stat(prefix)
349 problems.append("Directory doesn't exist: " + prefix)
351 mode = statdata[ST_MODE]
352 gid = statdata[ST_GID]
353 if mailmangid <> gid:
354 problems.append("Directory must be owned by group " +
355 groupname + ": " + prefix)
356 if (mode & S_ISGID) <> S_ISGID:
357 problems.append("Set-gid bit must be set for directory: " + prefix)
358 perms = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH
359 if (mode & perms) <> perms:
360 problems.append("Permissions should be at least 02775: " + prefix)
364 msg = '***** ' + '\n***** '.join(problems) + '\n'
365 fp = open("conftest.out", "w")
371 status=`cat conftest.out`
372 rm -f conftest.out conftest.py
373 if test "$with_permcheck" = "yes"
375 if test "$status" != "okay"
378 ***** Installation directory $prefixcheck is not configured properly!
384 AC_MSG_RESULT($status)
387 # Now find the UIDs and GIDs
388 # Support --with-mail-gid and --with-cgi-gid
389 AC_MSG_CHECKING(for mail wrapper group; i.e. --with-mail-gid)
390 AC_ARG_WITH(mail-gid, dnl
391 [ --with-mail-gid group name mail programs run as])
392 if test -z "$with_mail_gid"
394 with_mail_gid="mailman other mail daemon"
396 MM_FIND_GROUP_NAME(MAIL_GROUP, $with_mail_gid)
397 if test -z "$MAIL_GROUP"
399 if test "$with_permcheck" = "yes"
402 ***** No group name \"$with_mail_gid\" found for the mail wrapper program.
403 ***** This is the group that your mail server will use to run Mailman's
404 ***** programs. You should specify an existing group with the
405 ***** --with-mail-gid configure option, or use --without-permcheck to
406 ***** skip this verification step. See also your mail server's documentation,
407 ***** and Mailman's INSTALL file for details])
409 MAIL_GROUP=$with_mail_gid
412 AC_MSG_RESULT($MAIL_GROUP)
415 AC_MSG_CHECKING(for CGI wrapper group; i.e. --with-cgi-gid)
416 AC_ARG_WITH(cgi-gid, dnl
417 [ --with-cgi-gid group name CGI programs run as])
418 if test -z "$with_cgi_gid"
420 with_cgi_gid="www www-data nobody"
423 MM_FIND_GROUP_NAME(CGI_GROUP, $with_cgi_gid)
424 if test -z "$CGI_GROUP"
426 if test "$with_permcheck" = "yes"
429 ***** No group name \"$with_cgi_gid\" found for the CGI wrapper program.
430 ***** This is the group that your web server will use to run Mailman's
431 ***** programs. You should specify an existing group with the
432 ***** --with-cgi-gid configure option, or use --without-permcheck to
433 ***** skip this verification step. See also your web server's documentation,
434 ***** and Mailman's INSTALL file for details])
436 CGI_GROUP=$with_cgi_gid
439 AC_MSG_RESULT($CGI_GROUP)
442 # Check for CGI extensions, required by some Web servers
444 AC_MSG_CHECKING(for CGI extensions)
445 AC_ARG_WITH(cgi-ext, dnl
446 [ --with-cgi-ext specify extension for CGI programs (include dot)])
447 if test -z "$with_cgi_ext"
454 AC_MSG_RESULT($with_cgi_ext)
457 # figure out the default mail hostname and url host component
459 AC_MSG_CHECKING(for --with-mailhost)
460 AC_ARG_WITH(mailhost, dnl
461 [ --with-mailhost specify the hostname part for outgoing email])
462 if test -z "$with_mailhost"
467 MAILHOST=$with_mailhost
469 AC_MSG_RESULT($with_mailhost)
472 AC_MSG_CHECKING(for --with-urlhost)
473 AC_ARG_WITH(urlhost, dnl
474 [ --with-urlhost specify the hostname part of urls])
475 if test -z "$with_urlhost"
480 URLHOST=$with_urlhost
482 AC_MSG_RESULT($with_urlhost)
485 cat > conftest.py <<EOF
489 fp = open('conftest.out', 'w')
496 AC_MSG_CHECKING(for default mail host name)
497 if test -z "$MAILHOST"
499 MAILHOST=`sed q conftest.out`
501 AC_MSG_RESULT($MAILHOST)
502 AC_MSG_CHECKING(for default URL host component)
503 if test -z "$URLHOST"
505 URLHOST=`sed -n '$p' conftest.out`
507 AC_MSG_RESULT($URLHOST)
508 rm -f conftest.out conftest.py
510 # Checks for libraries.
511 AC_CHECK_FUNCS(strerror setregid syslog)
512 if test $ac_cv_func_syslog = no; then
513 # syslog is not in the default libraries. See if it's in some other.
514 # Additionally, for at least SCO OpenServer, syslog() is #defined to
515 # one of several _real_ functions in syslog.h, so we need to do the test
516 # with the appropriate include.
517 for lib in bsd socket inet; do
518 AC_MSG_CHECKING(for syslog in -l$lib)
519 Mailman_LIBS_save="$LIBS"; LIBS="$LIBS -l$lib"
520 AC_TRY_LINK([#include <syslog.h>],
521 [syslog(LOG_DEBUG, "Just a test...");],
523 AC_DEFINE(HAVE_SYSLOG)
526 LIBS="$Mailman_LIBS_save"])
527 unset Mailman_LIBS_save
531 # Checks for header files.
533 AC_CHECK_HEADERS(syslog.h)
535 # Checks for typedefs, structures, and compiler characteristics.
539 # Checks for library functions.
540 AC_CHECK_FUNCS(vsnprintf)
542 dnl Expand PYTHON path in the scripts, output into build/scriptname
544 AC_DEFUN(MM_SCRIPTS, [dnl
583 contrib/check_perms_grsecurity.py \
584 contrib/qmail-to-mailman.py \
585 contrib/rotatelogs.py \
595 dnl Please make sure to leave a space at the end of the last entry.
596 dnl (This is so we don't have to use [a-z/] style character classes
597 dnl in the regexp below and mess with m4 quoting, which is not fun.)
599 dnl This regexp munges each line in MM_SCRIPTS, replacing:
602 dnl build/path/script:path/script \
603 dnl so that we can macro-expand variables in scripts without using
604 dnl script.in filenames, outputting the new files in build/ .
606 SCRIPTS="patsubst(MM_SCRIPTS, \(.+\) \(\\?\), build/\1:\1 \2)"
610 # These directories are temporary directories to store macro-expanded
611 # scripts. They're removed on a make distclean, so we make them here.
612 mkdir -p build/bin build/contrib build/cron
614 dnl Output everything
615 AC_OUTPUT([misc/paths.py Mailman/Defaults.py Mailman/mm_cfg.py.dist
616 src/Makefile misc/Makefile bin/Makefile
617 Mailman/Makefile Mailman/Cgi/Makefile Mailman/Logging/Makefile
618 Mailman/Archiver/Makefile Mailman/Commands/Makefile
619 Mailman/Handlers/Makefile Mailman/Bouncers/Makefile
620 Mailman/Queue/Makefile Mailman/MTA/Makefile Mailman/Gui/Makefile
621 templates/Makefile cron/Makefile scripts/Makefile messages/Makefile
622 cron/crontab.in misc/mailman Makefile
623 tests/Makefile tests/bounces/Makefile tests/msgs/Makefile
625 echo "configuration completed at" `date`)
627 # Make sure all the build scripts are executable.
630 # Test for the Chinese codecs.
631 dnl AC_MSG_CHECKING(for Python Chinese Unicode codecs)
632 dnl cat > conftest.py <<EOF
634 dnl unicode("abc", "big5-tw")
636 dnl except LookupError:
637 dnl print "not found"
639 dnl chinese=`$PYTHON conftest.py 2>/dev/null`
640 dnl rm -f conftest.py
641 dnl AC_MSG_RESULT($chinese)
642 dnl if test "x$chinese" != "xfound"
646 dnl ***** Python Unicode codecs for Chinese not found.
647 dnl ***** Chinese emails generated by or manipulated in Mailman will not
648 dnl ***** be sent in the correct encoding and may be unreadable.
649 dnl ***** Please uncompress and install the Chinese codecs from:
650 dnl ***** http://sourceforge.net/projects/python-codecs/
652 dnl ***** Note: Everything else will work just fine.