1dnl Process this file with autoconf to produce a configure script.
2
3AC_PREREQ(2.59)
4AC_INIT(masqmail, 0.3.5, meillo@marmaro.de)
5AC_CONFIG_SRCDIR([src/masqmail.c])
6AM_CONFIG_HEADER(config.h)
7AM_INIT_AUTOMAKE()
8
9dnl Checks for programs.
10
11dnl Checks for libraries.
12
13AC_PROG_CC
14AC_ISC_POSIX
15AC_STDC_HEADERS
16dnl AC_ARG_PROGRAM
17AC_PROG_RANLIB
18
19PKG_CHECK_MODULES(GLIB, glib-2.0)
20dnl # use the next line to use glib-1.2
21dnl PKG_CHECK_MODULES(GLIB, glib)
22
23AC_SUBST(GLIB_LIBS)
24AC_SUBST(GLIB_CFLAGS)
25
26dnl resolver support (default is use it)
27AC_ARG_ENABLE(resolver,
28	[  --disable-resolver      disable resolver support],
29	if test "$enable_resolver" != 'no'; then
30		resolver_enabled='yes'
31	fi,
32	resolver_enabled='yes'
33	)
34
35if test "$resolver_enabled" = yes; then
36	AC_DEFINE(ENABLE_RESOLVER, 1, [If the resolver is to be used])
37dnl checks necessary for libc5:
38dnl if there is res_search in libc, it is probably libc5
39dnl if not, it is probably libc6 and we need libresolv
40	AC_CHECK_LIB(c, res_search, need_resolv=no, need_resolv=yes)
41	if test "$need_resolv" = yes; then
42		AC_CHECK_LIB(resolv, res_search,
43			has_resolv=yes; RESOLV_LIBS="-lresolv",
44			has_resolv=no)
45		if test "$has_resolv" = no; then
46			saved_LIBS="$LIBS"
47			LIBS="$LIBS -lresolv"
48			AC_MSG_CHECKING(for res_search in -lresolv)
49			AC_TRY_LINK([#include <resolv.h>],
50				[res_search (0, 0, 0, 0, 0);],
51				RESOLV_LIBS="-lresolv"; has_resolv=yes; AC_MSG_RESULT(yes),
52				AC_MSG_RESULT(no));
53			LIBS="$saved_LIBS"
54		fi
55		if test "$has_resolv" = no; then
56			AC_MSG_ERROR("no libresolv")
57			RESOLV_LIBS=''
58		fi
59	fi
60else
61	RESOLV_LIBS=''
62fi
63AC_SUBST(RESOLV_LIBS)
64
65dnl if there is no getline, we define it using getdelim in src/masqmail.h
66AC_CHECK_FUNCS(getline)
67
68dnl if there is no fdatasync, we define it to fsync in src/masqmail.h
69AC_CHECK_FUNCS(fdatasync)
70
71dnl Checks for header files.
72AC_HEADER_STDC
73AC_CHECK_HEADERS(fcntl.h sys/time.h syslog.h unistd.h)
74
75dnl Checks for typedefs, structures, and compiler characteristics.
76AC_C_CONST
77AC_TYPE_PID_T
78AC_TYPE_SIZE_T
79AC_HEADER_TIME
80AC_STRUCT_TM
81
82dnl Checks for library functions.
83AC_FUNC_FNMATCH
84AC_TYPE_SIGNAL
85AC_FUNC_STRFTIME
86AC_FUNC_VPRINTF
87AC_CHECK_FUNCS(select socket strerror strstr)
88
89dnl user and group configuration
90AC_ARG_WITH(user,
91	[  --with-user=USER        set user [mail]],
92	)
93if test "x$with_user" = 'x'; then
94	with_user='mail'
95fi
96
97AC_ARG_WITH(group,
98	[  --with-group=GROUP      set group [mail]],
99	)
100if test "x$with_group" = 'x'; then
101	with_group='mail'
102fi
103
104dnl debugging support (default is use it)
105AC_ARG_ENABLE(debug,
106	[  --disable-debug         disable debugging],
107	if test "x$enable_debug" != 'xno'; then
108		debug_enabled='yes'
109	fi,
110	debug_enabled='yes'
111	)
112if test "x$debug_enabled" = xyes; then
113	AC_DEFINE(ENABLE_DEBUG, 1, [If debugging is enabled])
114fi
115
116AC_DEFINE_UNQUOTED(DEF_MAIL_USER, "${with_user}", [The mail user])
117AC_SUBST(with_user)
118AC_DEFINE_UNQUOTED(DEF_MAIL_GROUP, "${with_group}", [The mail group])
119AC_SUBST(with_group)
120
121dnl optional features
122MD5_LIBS=''
123BASE64_LIBS=''
124
125dnl auth support (default: use it)
126AC_ARG_ENABLE(auth,
127	[  --disable-auth          disable AUTH (RFC 2554) client support],
128	if test "x$enable_auth" != 'xno'; then
129		auth_enabled='yes'
130	fi,
131	auth_enabled='yes'
132	)
133if test "x$auth_enabled" = xyes; then
134	AC_DEFINE(ENABLE_AUTH, 1, [If AUTH is enabled])
135	BASE64_LIBS='base64/libbase64.a'
136	need_md5='yes'
137fi
138AC_SUBST(BASE64_LIBS)
139
140if test "x$need_md5" = 'xyes'; then
141	MD5_LIBS='md5/libmd5.a'
142fi
143AC_SUBST(MD5_LIBS)
144
145dnl liblockfile
146AC_ARG_WITH(liblockfile,
147	[  --with-liblockfile      use liblock (for Debian)],
148	)
149if test "x$with_liblockfile" = 'xno'; then
150	with_liblockfile=''
151fi
152if test "x$with_liblockfile" != 'x'; then
153	with_liblockfile='yes'
154fi
155if test "x$with_liblockfile" = xyes; then
156	AC_CHECK_LIB(lockfile, maillock, has_lockfile=yes, AC_MSG_ERROR("no liblockfile"))
157	LOCKFILE_LIBS='-llockfile'
158	AC_DEFINE(USE_LIBLOCKFILE, 1, [If liblockfile is to be used])
159else
160	LOCKFILE_LIBS=''
161fi
162AC_SUBST(LOCKFILE_LIBS)
163AC_SUBST(USE_LIBLOCKFILE)
164
165dnl log and spool directories
166AC_ARG_WITH(logdir,
167	[  --with-logdir=DIR       set log directory [/var/log/masqmail]],
168	,
169        with_logdir='/var/log/masqmail'
170	)
171AC_DEFINE_UNQUOTED(LOG_DIR, "${with_logdir}", [The log directory])
172AC_SUBST(with_logdir)
173
174AC_ARG_WITH(spooldir,
175	[  --with-spooldir=DIR     set spool directory [/var/spool/masqmail]],
176	,
177	with_spooldir='/var/spool/masqmail'
178	)
179AC_DEFINE_UNQUOTED(SPOOL_DIR, "${with_spooldir}", [The spool directory])
180AC_SUBST(with_spooldir)
181
182dnl configuration file
183AC_ARG_WITH(confdir,
184	[  --with-confdir=DIR      directory for configuration [/etc/masqmail]],
185	,
186	with_confdir='/etc/masqmail'
187	)
188AC_DEFINE_UNQUOTED(CONF_DIR, "${with_confdir}", [The configuration file location])
189AC_SUBST(with_confdir)
190
191dnl dir for pid files
192AC_ARG_WITH(piddir,
193	[  --with-piddir=DIR       directory for pid files [/var/run]],
194	,
195	with_piddir='/var/run'
196	)
197AC_DEFINE_UNQUOTED(PID_DIR, "${with_piddir}", [The pid file location])
198AC_SUBST(with_piddir)
199
200dnl dir for lock files
201AC_ARG_WITH(lockdir,
202	[  --with-lockdir=DIR      directory for lock files [/var/lock/masqmail]],
203	,
204	with_lockdir='/var/lock/masqmail'
205	)
206AC_DEFINE_UNQUOTED(LOCK_DIR, "${with_lockdir}", [The lock file location])
207AC_SUBST(with_lockdir)
208
209test "x$prefix" = xNONE && prefix="$ac_default_prefix"
210
211dnl well, /me/ thought that autoconf should make things _easy_ ... -- oku
212dnl I needed the two `eval's to get the variable expanded in all cases -- meillo
213dnl this is just horrible! -- meillo
214AC_DEFINE_UNQUOTED(DATA_DIR, "`eval eval echo $datadir`/masqmail", [The data directory])
215
216dnl gymnastics to get the correct path where masqmail should be installed
217dnl we need this to call ourselves in failmsg.c
218if test "x${exec_prefix}" != 'xNONE'; then
219	AC_DEFINE_UNQUOTED(SBINDIR, "${exec_prefix}/sbin", [The sbin directory])
220else
221	if test "x${prefix}" != 'xNONE'; then
222		AC_DEFINE_UNQUOTED(SBINDIR, "${prefix}/sbin")
223	else
224		AC_DEFINE_UNQUOTED(SBINDIR, "/usr/sbin")
225	fi
226fi
227
228AC_OUTPUT(Makefile \
229	src/Makefile \
230	src/base64/Makefile \
231	src/md5/Makefile \
232	man/Makefile
233	)
234