1 dnl Autoconfigure input file for fetchmail
2 dnl Eric S. Raymond <esr@thyrsus.com>
4 dnl Process this file with autoconf to produce a configure script.
7 AC_INIT(fetchmail.h) dnl A distinctive file to look for in srcdir.
8 AC_CONFIG_HEADER(config.h)
10 dnl We want these before the checks, so the checks can modify their values.
11 test -z "$CFLAGS" && CFLAGS="-O" AC_SUBST(CFLAGS)
12 test -z "$LDFLAGS" && LDFLAGS=-s AC_SUBST(LDFLAGS)
17 AC_PROG_CPP dnl Later checks need this.
26 AC_CHECK_HEADERS(unistd.h termios.h termio.h sgtty.h stdarg.h alloca.h sys/itimer.h fcntl.h sys/fcntl.h memory.h sys/wait.h)
28 AC_C_CONST dnl getopt needs this.
36 # Under sysV68, socket and friends are provided by the C library.
37 # -linet does not provide socket, but causes multiple definition
38 # errors at link-time. It is thus better to only use the C library.
39 # So don't add -linet to the link list unless it's necessary
41 AC_MSG_RESULT(using libc's socket),
42 AC_CHECK_LIB(socket,socket)
43 AC_CHECK_LIB(inet,socket))
45 # The condition in this test copes with the presence of inet_addr in libc6.
46 AC_CHECK_FUNC(inet_addr,
47 AC_MSG_RESULT(using libc's inet_addr),
48 AC_CHECK_LIB(nsl,inet_addr))
50 dnl Port hack for Interactive UNIX System V/386 Release 3.2
51 AC_CHECK_LIB(cposix, strchr,
52 [EXTRADEFS="$EXTRADEFS -D_SYSV3"
53 LIBS="$LIBS -lcposix"])
55 AC_CHECK_FUNC(strstr, AC_DEFINE(HAVE_STRSTR),
56 [EXTRASRC="$EXTRASRC \$(srcdir)/strstr.c"
57 EXTRAOBJ="$EXTRAOBJ strstr.o"])
59 AC_CHECK_FUNC(strcasecmp, AC_DEFINE(HAVE_STRCASECMP),
60 [EXTRASRC="$EXTRASRC \$(srcdir)/strcasecmp.c"
61 EXTRAOBJ="$EXTRAOBJ strcasecmp.o"])
63 AC_CHECK_FUNC(memmove, AC_DEFINE(HAVE_MEMMOVE),
64 [EXTRASRC="$EXTRASRC \$(srcdir)/memmove.c"
65 EXTRAOBJ="$EXTRAOBJ memmove.o"])
67 AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPTLONG),
68 [EXTRASRC="$EXTRASRC \$(srcdir)/getopt.c \$(srcdir)/getopt1.c"
69 EXTRAOBJ="$EXTRAOBJ getopt.o getopt1.o"])
75 EXTRASRC="$EXTRASRC \$(srcdir)/alloca.c"
76 EXTRAOBJ="$EXTRAOBJ alloca.o"
79 dnl AC_CHECK_FUNC calls that might hack the Makefile must precede
80 dnl the following AC_SUBSTs
86 AC_CHECK_FUNCS(tcsetattr stty setsid seteuid gethostbyname res_search herror \
87 strrchr strerror setlinebuf syslog snprintf vprintf vsnprintf vsyslog \
88 atexit inet_aton strftime setrlimit)
90 # Under Red Hat 4.0 (and many other Linuxes) -lresolv is seriously flaky
91 # and breaks gethostbyname(2). It's better to use the bind stuff in the C
92 # library. So don't add -lresolv to the link list unless it's necessary
93 # (It will be necessary when using GNU libc6).
94 AC_CHECK_FUNC(res_search,
95 AC_MSG_RESULT(using libc's resolver functions),
96 AC_CHECK_LIB(resolv,res_search,
97 [AC_DEFINE(HAVE_RES_SEARCH) AC_MSG_RESULT(found resolver functions in libresolv); LIBS="$LIBS -lresolv"], AC_MSG_RESULT(no resolver calls found)))
99 dnl AC_FUNC_SETVBUF_REVERSED
101 dnl Check for usable void pointer type
102 AC_MSG_CHECKING(use of void pointer type)
106 p = (char *) xmalloc(1);
108 [AC_DEFINE(HAVE_VOIDPOINTER) AC_MSG_RESULT(yes)],
111 dnl Check for ANSI volatile
112 AC_MSG_CHECKING(for ANSI volatile)
115 [AC_DEFINE(HAVE_VOLATILE) AC_MSG_RESULT(yes)],
118 dnl Check out the wait reality. We have to assume sys/wait.h is present.
119 AC_CHECK_FUNCS(waitpid wait3)
120 AC_MSG_CHECKING(for union wait);
121 AC_TRY_LINK([#include <sys/types.h>
122 #include <sys/wait.h>],
123 [union wait status; int pid; pid = wait (&status);
125 /* Some POSIXoid systems have both the new-style macros and the old
126 union wait type, and they do not work together. If union wait
127 conflicts with WEXITSTATUS et al, we don't want to use it at all. */
128 if (WEXITSTATUS (status) != 0) pid = -1;
131 /* Make sure union wait works with waitpid. */
132 pid = waitpid (-1, &status, 0);
135 [AC_DEFINE(HAVE_UNION_WAIT) AC_MSG_RESULT(yes)],
138 AC_MSG_CHECKING(sys_siglist declaration in signal.h or unistd.h)
139 AC_TRY_LINK([#include <signal.h>
140 /* NetBSD declares sys_siglist in <unistd.h>. */
143 #endif], [char *msg = *(sys_siglist + 1);],
144 [AC_DEFINE(SYS_SIGLIST_DECLARED) AC_MSG_RESULT(yes)],
147 # Find the right directory to put the root-mode PID file in
148 for dir in "/var/run" "/etc"
155 AC_MSG_RESULT(root-mode pid file will go in $dir)
156 AC_DEFINE_UNQUOTED(PID_DIR, "$dir")
158 AC_CHECK_SIZEOF(short)
160 AC_CHECK_SIZEOF(long)
162 ### use option --enable-POP2 to compile in the POP2 support
164 [ --enable-POP2 compile in POP2 protocol support (obsolete)],
165 [with_POP2=$enableval],
167 test "$with_POP2" = "yes" && AC_DEFINE(POP2_ENABLE)
169 ### use option --disable-POP3 to omit the POP3 support
171 [ --disable-POP3 don't compile in POP3 protocol support],
172 [with_POP3=$enableval],
174 test "$with_POP3" = "yes" && AC_DEFINE(POP3_ENABLE)
176 ### use option --disable-IMAP to omit the IMAP support
178 [ --disable-IMAP don't compile in IMAP protocol support],
179 [with_IMAP=$enableval],
181 test "$with_IMAP" = "yes" && AC_DEFINE(IMAP_ENABLE)
183 ### use option --disable-ETRN to omit the ETRN support
185 [ --disable-ETRN don't compile in ETRN protocol support],
186 [with_ETRN=$enableval],
188 test "$with_ETRN" = "yes" && AC_DEFINE(ETRN_ENABLE)
190 ### use option --enable-RPA to compile in the RPA support
192 [ --enable-RPA compile in RPA protocol support],
193 [with_RPA=$enableval],
195 test "$with_RPA" = "yes" && AC_DEFINE(RPA_ENABLE)
197 ### use option --enable-SDPS to compile in the SDPS support
199 [ --enable-SDPS compile in SDPS protocol support],
200 [with_SDPS=$enableval],
202 test "$with_SDPS" = "yes" && AC_DEFINE(SDPS_ENABLE)
204 ### use option --enable-opie to compile in the OPIE support
206 [ --enable-opie support OTP through the OPIE library],
207 [ AC_CHECK_HEADER(opie.h,, [echo 'configure: cannot find <opie.h>, which is required for OPIE support.'; exit 1])
208 AC_CHECK_LIB(opie,opiegenerator,, [echo 'configure: cannot find libopie, which is required for OPIE support.'; exit 1])
213 [ --enable-inet6 support IPv6 (requires the inet6-apps library)],
214 [ unset ac_cv_lib_inet6_getaddrinfo; AC_CHECK_LIB(inet6, getaddrinfo,,
215 [ unset ac_cv_lib_inet6_getaddrinfo; LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; AC_CHECK_LIB(inet6, getaddrinfo,,
216 [ echo 'configure: cannot find libinet6, which is required for IPv6 support.'; exit 1]) ])
217 AC_DEFINE(INET6, 1) ])
219 AC_ARG_ENABLE(netsec,
220 [ --enable-netsec support network security (requires inet6-apps library)],
221 [ unset ac_cv_lib_inet6_net_security_strtorequest; AC_CHECK_LIB(inet6, net_security_strtorequest,,
222 [ unset ac_cv_lib_inet6_net_security_strtorequest; LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; AC_CHECK_LIB(inet6, net_security_strtorequest,,
223 [ echo 'configure: cannot find net_security_strtorequest in libinet6, which is required';
224 echo ' for network security support. Either it does not exist, or it was';
225 echo ' not built with network security support enabled.';
227 unset ac_cv_header_net_security_h; AC_CHECK_HEADER(net/security.h,,
228 [ unset ac_cv_header_net_security_h; CPPFLAGS="$CPPFLAGS -I/usr/inet6/include"; CFLAGS="$CFLAGS -I/usr/inet6/include"; AC_CHECK_HEADER(net/security.h,,
229 [ echo 'configure: cannot find <net/security.h>, which is required for network security';
232 AC_DEFINE(NET_SECURITY, 1) ])
234 ### use option --with-gssapi=DIR to compile in GSSAPI support
236 [ --with-gssapi[=DIR] compile in GSSAPI support using libraries in DIR],
238 if test "$with_gssapi" != "no"
240 if test "$with_gssapi" != "yes" -a -n "$with_gssapi"
242 CFLAGS="$CFLAGS -I$with_gssapi/include"
243 LDFLAGS="$LDFLAGS -L$with_gssapi/lib"
245 AC_CHECK_LIB(krb5, krb5_init_context,,
246 AC_MSG_ERROR([could not find libkrb5 which is needed for GSSAPI support]))
247 AC_CHECK_LIB(gssapi_krb5, gss_init_sec_context,,
248 AC_MSG_ERROR([could not find libgssapi_krb5 which is needed for GSSAPI support]), -lkrb5)
250 LIBS="$LIBS -lgssapi_krb5 -lkrb5"
253 ### use option --with-kerberos=DIR to point at a Kerberos directory
254 AC_ARG_WITH(kerberos,
255 [ --with-kerberos=DIR point fetchmail compilation at a Kerberos directory])
257 # The "elif" arm (nonempty $with_kerberos) is kind of a crock. It works for
258 # configuring the BSD/OS Kerberos IV support, though.
260 # Check for a NetBSD special case
261 if test "$with_kerberos" = "yes" -a `uname` = "NetBSD"
263 echo "Configuring kerberosIV for NetBSD"
264 CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I/usr/include/kerberosIV"
265 LIBS="$LIBS -lkrb -ldes"
266 elif test -n "$with_kerberos"
268 CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$with_kerberos/include"
269 LDEFLAGS="$LDEFLAGS -L$with_kerberos/lib"
270 LIBS="$LIBS -lkrb -ldes"
272 for dir in /usr/kerberos /usr/kerberosIV /usr/athena
274 if test -f "$dir/include/krb.h"
276 CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$dir/include"
277 LDEFLAGS="$LDEFLAGS -L$dir/lib"
278 LIBS="$LIBS -lkrb -ldes"
284 ### use option --with-kerberos5=DIR to point at a Kerberos 5 directory
285 AC_ARG_WITH(kerberos5,
286 [ --with-kerberos5=DIR point fetchmail compilation at a Kerberos 5 directory])
288 # The "then" arm (nonempty $with_kerberos5) is kind of a crock. It works for
289 # configuring the BSD/OS Kerberos IV support, though.
290 if test -n "$with_kerberos5"
293 CEFLAGS="$CEFLAGS -DKERBEROS_V5 -I$with_kerberos5/include"
294 LDEFLAGS="$LDEFLAGS -L$with_kerberos5/lib"
295 LIBS="$LIBS -lkrb5 -lcrypto -lcom_err"
297 for dir in /usr/kerberos /usr/local/krb5 /usr/athena
299 if test -f "$dir/include/krb5.h"
301 CEFLAGS="$CEFLAGS -DKERBEROS_V5 -I$dir/include"
302 LDEFLAGS="$LDEFLAGS -L$dir/lib"
303 LIBS="$LIBS -lkrb5 -lcrypto -lcom_err"
309 AC_OUTPUT(Makefile, [
310 # The reason for this odd makedepend line is that we want
311 # to have all dependencies evaluated relative to the source directory
312 # and let VPATH do all the dirty work when we build remotely
313 echo "You can ignore any makedepend error messages";
314 (cd $srcdir; makedepend -f - *.c) >>Makefile])
317 dnl comment-start: "dnl "
319 dnl comment-start-skip: "\\bdnl\\b\\s *"
320 dnl compile-command: "make configure config.h.in"