1dnl
2dnl Copyright (c) 2004, Stefan Walter
3dnl All rights reserved.
4dnl
5dnl Redistribution and use in source and binary forms, with or without
6dnl modification, are permitted provided that the following conditions
7dnl are met:
8dnl
9dnl     * Redistributions of source code must retain the above
10dnl       copyright notice, this list of conditions and the
11dnl       following disclaimer.
12dnl     * Redistributions in binary form must reproduce the
13dnl       above copyright notice, this list of conditions and
14dnl       the following disclaimer in the documentation and/or
15dnl       other materials provided with the distribution.
16dnl     * The names of contributors to this software may not be
17dnl       used to endorse or promote products derived from this
18dnl       software without specific prior written permission.
19dnl
20dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23dnl FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24dnl COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25dnl INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26dnl BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27dnl OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28dnl AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30dnl THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31dnl DAMAGE.
32dnl
33dnl
34dnl CONTRIBUTORS
35dnl  Stef Walter <stef@memberwebs.com>
36dnl
37
38dnl Process this file with autoconf to produce a configure script.
39AC_INIT(clamsmtp, 1.10, stef@memberwebs.com)
40AM_INIT_AUTOMAKE(clamsmtp, 1.10)
41
42LDFLAGS="$LDFLAGS -L/usr/local/lib"
43CFLAGS="$CFLAGS -I/usr/local/include"
44
45AC_CONFIG_SRCDIR([src/clamsmtpd.c])
46AM_CONFIG_HEADER([config.h])
47
48# Checks for programs.
49AC_PROG_CC
50AC_PROG_INSTALL
51AC_PROG_LN_S
52AC_PROG_MAKE_SET
53
54# Debug mode
55AC_ARG_ENABLE(debug,
56        AC_HELP_STRING([--enable-debug],
57        [Compile binaries in debug mode]))
58
59if test "$enable_debug" = "yes"; then
60  CFLAGS="$CFLAGS -g -O0 -Wall"
61  AC_DEFINE_UNQUOTED(_DEBUG, 1, [In debug mode])
62  echo "enabling debug compile mode"
63fi
64
65# TODO: Figure out why we need this wierd hack
66ACX_PTHREAD( , [echo "ERROR: Pthread support not found."; exit 1] )
67
68LIBS="$PTHREAD_LIBS $LIBS"
69CFLAGS="$CFLAGS $PTHREAD_CFLAGS -D_POSIX_PTHREAD_SEMANTICS"
70
71# Some checks for Solaris
72AC_CHECK_LIB(socket, getsockname)
73AC_CHECK_LIB(nsl, getaddrinfo)
74
75# Checks for header files.
76AC_HEADER_STDC
77AC_CHECK_HEADERS([limits.h err.h paths.h],,)
78AC_CHECK_HEADERS([unistd.h stdio.h stddef.h fcntl.h stdlib.h assert.h errno.h stdarg.h string.h netdb.h], ,
79    [echo "ERROR: Required C header missing"; exit 1])
80
81# Check for linux type transparent proxy support
82AC_CHECK_HEADERS([linux/netfilter_ipv4.h],
83   AC_DEFINE(LINUX_TRANSPARENT_PROXY, 1, [Whether the system supports a linux type transparent proxy]),
84   ,
85   [[
86   #ifdef HAVE_LIMITS_H
87   #include <limits.h>
88   #endif
89   ]] )
90
91# Checks for typedefs, structures, and compiler characteristics.
92AC_C_CONST
93AC_TYPE_SIZE_T
94
95# We use error checking mutexes whenever possible
96AC_CHECK_DECL(PTHREAD_MUTEX_ERRORCHECK_NP, [AC_DEFINE(HAVE_ERR_MUTEX, 1, "Error Mutex Type")],
97    [AC_CHECK_DECL(PTHREAD_MUTEX_ERRORCHECK, [AC_DEFINE(HAVE_ERR_MUTEX, 2)], ,
98    [ #include <pthread.h> ])], [ #include <pthread.h> ])
99
100# Required Variables
101AC_CHECK_MEMBER(struct tm.tm_gmtoff,
102    [AC_DEFINE(HAVE_TM_GMTOFF, 1, "Time Zone GMT Offset")],
103    ,[ #include <time.h> ])
104AC_CHECK_GLOBAL(__argv)
105
106# Required Functions
107AC_CHECK_FUNCS([memset strerror malloc realloc getopt strchr tolower getaddrinfo], ,
108           [echo "ERROR: Required function missing"; exit 1])
109AC_CHECK_FUNCS([strlwr strlcat strlcpy strncat strncpy strcasestr setenv daemon])
110AC_CHECK_FUNCS([getline getdelim flockfile])
111
112# DMALLOC memory debugging
113AC_ARG_ENABLE(dmalloc,
114        AC_HELP_STRING([--enable-dmalloc],
115        [malloc memory debugging (default: no)]))
116
117if test "$enable_dmalloc" = "yes"; then
118
119    AC_CHECK_LIB(dmalloc, malloc, , [echo "DMalloc library not installed"; exit 1])
120
121    AC_DEFINE_UNQUOTED(WITH_DMALLOC, 1, [malloc memory debugging])
122    LIBS="${LIBS} -ldmalloc"
123    echo "enabling dmalloc memory debugging"
124
125fi
126
127# Have to resolve this for the path below
128if test "${prefix}" = "NONE"; then
129    prefix=$ac_default_prefix
130fi
131
132AC_DEFINE_UNQUOTED(CONF_PREFIX, "`eval echo ${sysconfdir}`", [Installation Prefix] )
133
134AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile])
135AC_OUTPUT
136