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)
27 AC_CHECK_HEADERS(arpa/inet.h arpa/nameser.h resolv.h net/socket.h)
29 AC_C_CONST dnl getopt needs this.
39 PACKAGE=`sed -n '/PACKAGE *= *\(.*\)/s//\1/p' <$srcdir/Makefile.in`
40 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
43 VERSION=`sed -n '/VERSION *= *\(.*\)/s//\1/p' <$srcdir/Makefile.in`
44 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
47 # Check for LynxOS special case: -lbsd needed (at least on 2.3.0) and -s
49 if test `uname` = "LynxOS"
51 echo "Adding -lbsd to standard libraries"
54 echo "Prepending standard include path to gcc flags"
55 CPFLAGS="-I/usr/include"
58 # Check for FreeBSD special case: -lkvm needed
59 if test `uname` = "FreeBSD"
61 echo "Adding -lkvm to standard libraries"
65 # Check for Rhapsody special case: it doesn't like -s
66 if test `uname` = "Rhapsody"
68 echo "Removing -s load flag"
69 LDFLAGS=`echo $LDFLAGS | sed "s/-s //"`
73 ALL_LINGUAS="cs es fr pl pt_BR gl da"
79 # Under sysV68, socket and friends are provided by the C library.
80 # -linet does not provide socket, but causes multiple definition
81 # errors at link-time. It is thus better to only use the C library.
82 # So don't add -linet to the link list unless it's necessary
84 AC_MSG_RESULT(using libc's socket),
85 AC_CHECK_LIB(socket,socket)
86 AC_CHECK_LIB(inet,socket))
88 # If gettext isn't in the C library, maybe there's a -lintl.
89 AC_CHECK_FUNC(gettext,
90 AC_MSG_RESULT(using libc's gettext),
91 AC_CHECK_LIB(intl,gettext))
93 # The condition in this test copes with the presence of inet_addr in libc6.
94 AC_CHECK_FUNC(inet_addr,
95 AC_MSG_RESULT(using libc's inet_addr),
96 AC_CHECK_LIB(nsl,inet_addr))
98 dnl Port hack for Interactive UNIX System V/386 Release 3.2
99 AC_CHECK_LIB(cposix, strchr,
100 [EXTRADEFS="$EXTRADEFS -D_SYSV3"
101 LIBS="$LIBS -lcposix"])
103 AC_CHECK_FUNC(strstr, AC_DEFINE(HAVE_STRSTR),
104 [EXTRASRC="$EXTRASRC \$(srcdir)/strstr.c"
105 EXTRAOBJ="$EXTRAOBJ strstr.o"])
107 AC_CHECK_FUNC(strcasecmp, AC_DEFINE(HAVE_STRCASECMP),
108 [EXTRASRC="$EXTRASRC \$(srcdir)/strcasecmp.c"
109 EXTRAOBJ="$EXTRAOBJ strcasecmp.o"])
111 AC_CHECK_FUNC(memmove, AC_DEFINE(HAVE_MEMMOVE),
112 [EXTRASRC="$EXTRASRC \$(srcdir)/memmove.c"
113 EXTRAOBJ="$EXTRAOBJ memmove.o"])
115 AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPTLONG),
116 [EXTRASRC="$EXTRASRC \$(srcdir)/getopt.c \$(srcdir)/getopt1.c"
117 EXTRAOBJ="$EXTRAOBJ getopt.o getopt1.o"])
119 AC_CHECK_FUNC(MD5Init, AC_DEFINE(HAVE_MD5),
120 [EXTRASRC="$EXTRASRC \$(srcdir)/md5c.c"
121 EXTRAOBJ="$EXTRAOBJ md5c.o"])
127 EXTRASRC="$EXTRASRC \$(srcdir)/alloca.c"
128 EXTRAOBJ="$EXTRAOBJ alloca.o"
131 dnl AC_CHECK_FUNC calls that might hack the Makefile must precede
132 dnl the following AC_SUBSTs
138 AC_CHECK_FUNCS(tcsetattr stty setsid geteuid seteuid gethostbyname \
139 res_search herror strrchr strerror setlinebuf syslog \
140 snprintf vprintf vsnprintf vsyslog \
141 atexit inet_aton strftime setrlimit socketpair sigprocmask sigaction)
143 # Under Red Hat 4.0 (and many other Linuxes) -lresolv is seriously flaky
144 # and breaks gethostbyname(2). It's better to use the bind stuff in the C
145 # library. So don't add -lresolv to the link list unless it's necessary
146 # (It will be necessary when using GNU libc6).
147 AC_CHECK_FUNC(res_search,
148 AC_MSG_RESULT(using libc's resolver functions),
149 AC_CHECK_LIB(resolv,res_search,
150 [AC_DEFINE(HAVE_RES_SEARCH) AC_MSG_RESULT(found resolver functions in libresolv); LIBS="$LIBS -lresolv"], AC_MSG_RESULT(no resolver calls found)))
152 dnl Check for libcrypt -- it may live in libc or libcrypt, as on IRIX
153 AC_CHECK_FUNC(crypt, , AC_CHECK_LIB(crypt,crypt))
155 dnl Check for RSA refersence library in case we're using SSL
156 AC_CHECK_LIB(rsaref, RSAPublicDecrypt)
158 dnl AC_FUNC_SETVBUF_REVERSED
160 dnl Check for usable void pointer type
161 AC_MSG_CHECKING(use of void pointer type)
165 p = (char *) xmalloc(1);
167 [AC_DEFINE(HAVE_VOIDPOINTER) AC_MSG_RESULT(yes)],
170 dnl Check for ANSI volatile
171 AC_MSG_CHECKING(for ANSI volatile)
174 [AC_DEFINE(HAVE_VOLATILE) AC_MSG_RESULT(yes)],
177 dnl Check out the wait reality. We have to assume sys/wait.h is present.
178 AC_CHECK_FUNCS(waitpid wait3)
179 AC_MSG_CHECKING(for union wait);
180 AC_TRY_LINK([#include <sys/types.h>
181 #include <sys/wait.h>],
182 [union wait status; int pid; pid = wait (&status);
184 /* Some POSIXoid systems have both the new-style macros and the old
185 union wait type, and they do not work together. If union wait
186 conflicts with WEXITSTATUS et al, we don't want to use it at all. */
187 if (WEXITSTATUS (status) != 0) pid = -1;
190 /* Make sure union wait works with waitpid. */
191 pid = waitpid (-1, &status, 0);
194 [AC_DEFINE(HAVE_UNION_WAIT) AC_MSG_RESULT(yes)],
197 AC_MSG_CHECKING(sys_siglist declaration in signal.h or unistd.h)
198 AC_TRY_LINK([#include <signal.h>
199 /* NetBSD declares sys_siglist in <unistd.h>. */
202 #endif], [char *msg = *(sys_siglist + 1);],
203 [AC_DEFINE(SYS_SIGLIST_DECLARED) AC_MSG_RESULT(yes)],
206 # Find the right directory to put the root-mode PID file in
207 for dir in "/var/run" "/etc"
214 AC_MSG_RESULT(root-mode pid file will go in $dir)
215 AC_DEFINE_UNQUOTED(PID_DIR, "$dir")
217 AC_CHECK_SIZEOF(short)
219 AC_CHECK_SIZEOF(long)
221 if test "$USE_NLS" = "yes"
223 echo 'Enabling internationalization support...'
224 POMAKE='$(MAKE) -C po'
225 if test "x$prefix" != xNONE; then
226 EXTRADEFS="$EXTRADEFS -DLOCALEDIR='\"$prefix/share/locale\"'"
228 EXTRADEFS="$EXTRADEFS -DLOCALEDIR='\"$ac_default_prefix/share/locale\"'"
231 echo 'Disabling internationalization support...'
232 POMAKE="@echo '(NLS support disabled)'; #"
235 ### use option --enable-POP2 to compile in the POP2 support
237 [ --enable-POP2 compile in POP2 protocol support (obsolete)],
238 [with_POP2=$enableval],
240 test "$with_POP2" = "yes" && AC_DEFINE(POP2_ENABLE)
242 ### use option --disable-POP3 to omit the POP3 support
244 [ --disable-POP3 don't compile in POP3 protocol support],
245 [with_POP3=$enableval],
247 test "$with_POP3" = "yes" && AC_DEFINE(POP3_ENABLE)
249 ### use option --disable-IMAP to omit the IMAP support
251 [ --disable-IMAP don't compile in IMAP protocol support],
252 [with_IMAP=$enableval],
254 test "$with_IMAP" = "yes" && AC_DEFINE(IMAP_ENABLE)
256 ### use option --disable-ETRN to omit the ETRN support
258 [ --disable-ETRN don't compile in ETRN protocol support],
259 [with_ETRN=$enableval],
261 test "$with_ETRN" = "yes" && AC_DEFINE(ETRN_ENABLE)
263 ### use option --enable-RPA to compile in the RPA support
265 [ --enable-RPA compile in RPA protocol support],
266 [with_RPA=$enableval],
268 test "$with_RPA" = "yes" && AC_DEFINE(RPA_ENABLE)
270 ### use option --enable-NTLM to compile in the NTLM support
272 [ --enable-NTLM compile in NTLM authentication support],
273 [with_NTLM=$enableval],
275 test "$with_NTLM" = "yes" && AC_DEFINE(NTLM_ENABLE)
277 ### use option --enable-SDPS to compile in the SDPS support
279 [ --enable-SDPS compile in SDPS protocol support],
280 [with_SDPS=$enableval],
282 test "$with_SDPS" = "yes" && AC_DEFINE(SDPS_ENABLE)
284 ### use option --enable-opie to compile in the OPIE support
286 [ --enable-opie support OTP through the OPIE library],
287 [ AC_CHECK_HEADER(opie.h,, [echo 'configure: cannot find <opie.h>, which is required for OPIE support.'; exit 1])
288 AC_CHECK_LIB(opie,opiegenerator,, [echo 'configure: cannot find libopie, which is required for OPIE support.'; exit 1])
289 with_opie=$enableval],
291 test "$with_opie" = "yes" && AC_DEFINE(OPIE_ENABLE)
294 [ --enable-inet6 support IPv6 (requires the inet6-apps library)],
296 [ AC_CHECK_FUNC(getaddrinfo, [with_inet6=yes],
297 [ LDFLAGS="$LDFLAGS -L/usr/inet6/lib";
298 AC_CHECK_LIB(inet6, getaddrinfo, [with_inet6=yes
299 LIBS="$LIBS -linet6"],
300 [ echo 'configure: cannot find proper glibc version or libinet6,';
301 echo ' which is required for IPv6 support.';
304 test "$with_inet6" = "yes" && AC_DEFINE(INET6_ENABLE)
306 AC_CHECK_FUNCS(inner_connect)
308 AC_ARG_ENABLE(netsec,
309 [ --enable-netsec support network security (requires inet6-apps library)],
310 [ unset ac_cv_lib_inet6_net_security_strtorequest; AC_CHECK_LIB(inet6, net_security_strtorequest,,
311 [ unset ac_cv_lib_inet6_net_security_strtorequest;
312 LDFLAGS="$LDFLAGS -L/usr/inet6/lib";
313 AC_CHECK_LIB(inet6, net_security_strtorequest,,
314 [ echo 'configure: cannot find net_security_strtorequest in libinet6, which is required';
315 echo ' for network security support. Either it does not exist, or it was';
316 echo ' not built with network security support enabled.';
318 unset ac_cv_header_net_security_h; AC_CHECK_HEADER(net/security.h,,
319 [ unset ac_cv_header_net_security_h;
320 CPPFLAGS="$CPPFLAGS -I/usr/inet6/include";
321 CFLAGS="$CFLAGS -I/usr/inet6/include"; AC_CHECK_HEADER(net/security.h,,
322 [ echo 'configure: cannot find <net/security.h>, which is required';
323 echo ' for network security support.';
326 test "$with_netsec" = "yes" && AC_DEFINE(NET_SECURITY)
328 ### use option --with-kerberos5=DIR to point at a Kerberos 5 directory
329 AC_ARG_WITH(kerberos5,
330 [ --with-kerberos5=DIR point fetchmail compilation at a Kerberos 5 directory])
332 # The "then" arm (nonempty $with_kerberos5) is kind of a crock. It works for
333 # configuring the BSD/OS Kerberos IV support, though.
334 if test -n "$with_kerberos5" -a "$with_kerberos5" != "no"
337 CEFLAGS="$CEFLAGS -DKERBEROS_V5 -I$with_kerberos5/include"
338 LDEFLAGS="$LDEFLAGS -L$with_kerberos5/lib"
339 if test -f "$with_kerberos5/include/roken.h"
342 LIBS="$LIBS -lkrb5 -lasn1 -ldes -lroken -lcom_err"
344 LIBS="$LIBS -lkrb5 -lcrypto -lcom_err"
346 elif test "$with_kerberos" != "no"; then
347 for dir in /usr/kerberos /usr/local/krb5 /usr/athena
349 if test -f "$dir/include/krb5.h"
351 CEFLAGS="$CEFLAGS -DKERBEROS_V5 -I$dir/include"
352 LDEFLAGS="$LDEFLAGS -L$dir/lib"
353 if test -f "$dir/include/roken.h"
356 LIBS="$LIBS -lkrb5 -lasn1 -ldes -lcom_err"
358 LIBS="$LIBS -lkrb5 -lcrypto -lcom_err"
366 ### use option --with-ssl to compile in the SSL support
368 [ --with-ssl=[DIR] enable SSL support using libraries in DIR],
371 test "$with_ssl" = "yes" && AC_DEFINE(SSL_ENABLE)
373 if test "$with_ssl" = "yes"
375 # He didn't specify an SSL location. Let's look at some common
376 # directories where SSL has been found in the past and try and auto
377 # configure for SSL. OpenSSL determination will be made later.
378 # This will screw up if an OpenSSL install is located in a later
379 # directory than an older SSLeay install, but the user should fix that
380 # anyways and he can override on the configure line.
389 if test -d "$ac_dir" ; then
396 if test -n "$with_ssl" -a "$with_ssl" != "no"
398 # With the autoconfigure above, the only time this is going to be
399 # true is going to be when we could not find the headers. If they
400 # are not in system standard locations, we are going to be broken.
401 if test "$with_ssl" = "yes"
403 # Let's just define the standard location for the SSLeay root
404 with_ssl="/usr/local/ssl"
406 if test -r $with_ssl/include/openssl/ssl.h
408 ### ssl.h found under openssl. Use openssl configuration preferentially
409 echo "Enabling OpenSSL support in $with_ssl"
410 CEFLAGS="$CEFLAGS -I$with_ssl/include -I$with_ssl/include/openssl"
411 ### OpenBSD comes with ssl headers
412 elif test -r /usr/include/ssl/ssl.h
414 echo "Enabling SSLeay support in $with_ssl"
415 CEFLAGS="$CEFLAGS -I/usr/include/ssl"
417 echo "Enabling SSLeay support in $with_ssl"
418 CEFLAGS="$CEFLAGS -I$with_ssl/include"
420 LDEFLAGS="$LDEFLAGS -L$with_ssl/lib"
421 LIBS="$LIBS -lssl -lcrypto"
422 AC_DEFINE(SSL_ENABLE)
424 echo 'Disabling SSL support...'
427 ### use option --with-kerberos=DIR to point at a Kerberos directory
428 AC_ARG_WITH(kerberos,
429 [ --with-kerberos=DIR point fetchmail compilation at a Kerberos directory])
431 # The "elif" arm (nonempty $with_kerberos) is kind of a crock. It works for
432 # configuring the BSD/OS Kerberos IV support, though.
434 # Check for a NetBSD/OpenBSD special case
435 if test "$with_kerberos" = "yes" && test `uname` = "NetBSD" -o `uname` = "OpenBSD"
437 echo "Configuring kerberosIV for `uname`"
438 CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I/usr/include/kerberosIV"
439 LIBS="$LIBS -lkrb -ldes"
440 elif test -n "$with_kerberos" -a -n "$with_kerberos5" -a "$with_kerberos" != "no"
442 CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$with_kerberos/include"
443 LDEFLAGS="$LDEFLAGS -L$with_kerberos/lib"
444 if test -f "$with_kerberos5/roken.h"
447 LIBS="-lkrb4 -l45 $LIBS"
449 LIBS="-lkrb4 -ldes425 $LIBS"
451 elif test -n "$with_kerberos5" -a "$with_kerberos" != "no"
453 for dir in /usr/kerberos /usr/kerberosIV /usr/athena
455 if test -f "$dir/include/kerberosIV/krb.h"
457 CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$dir/include"
458 LDEFLAGS="$LDEFLAGS -L$dir/lib"
459 LIBS="-lkrb4 -ldes425 $LIBS"
463 elif test -n "$with_kerberos" -a "$with_kerberos" != "no"
465 CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$with_kerberos/include"
466 LDEFLAGS="$LDEFLAGS -L$with_kerberos/lib"
467 LIBS="$LIBS -lkrb -ldes"
469 if test "$with_kerberos" != "no"
471 for dir in /usr/kerberos /usr/kerberosIV /usr/athena
473 if test -f "$dir/include/krb.h"
475 CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$dir/include"
476 LDEFLAGS="$LDEFLAGS -L$dir/lib"
477 LIBS="$LIBS -lkrb -ldes"
483 ### use option --with-socks=DIR to point at SOCKS library
485 [ --with-socks[=DIR] add built-in SOCKS firewall access],
487 if test "$with_socks" != no
489 if test "$with_socks" != yes
491 LDEFLAGS="$LDEFLAGS -L$with_socks"
493 AC_CHECK_LIB(socks, Rconnect,,
494 AC_MSG_ERROR([could not find libsocks which is needed for built-in SOCKS support]))
496 AC_DEFINE(HAVE_SOCKS)
497 CEFLAGS="$CEFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
501 ### use option --with-socks5=DIR to point at SOCKS library
503 [ --with-socks5[=DIR] add built-in SOCKS5 firewall access],
505 if test "$with_socks5" != no
507 if test "$with_socks5" != yes
509 LDEFLAGS="$LDEFLAGS -L$with_socks5"
511 AC_CHECK_LIB(socks5, SOCKSconnect,,
512 AC_MSG_ERROR([could not find libsocks5 which is needed for built-in SOCKS5 support]))
514 AC_DEFINE(HAVE_SOCKS)
515 CEFLAGS="$CEFLAGS -Dconnect=SOCKSconnect -Dgetsockname=SOCKSgetsockname -Dbind=SOCKSbind -Daccept=SOCKSaccept -Dlisten=SOCKSlisten -Dselect=SOCKSselect -Drecvfrom=SOCKSrecvfrom -Dsendto=SOCKSsendto -Drecv=SOCKSrecv -Dsend=SOCKSsend -Dread=SOCKSread -Dwrite=SOCKSwrite -Drresvport=SOCKSrresvport -Dshutdown=SOCKSshutdown -Dlisten=SOCKSlisten -Dclose=SOCKSclose -Ddup=SOCKSdup -Ddup2=SOCKSdup2 -Dfclose=SOCKSfclose -Dgethostbyname=SOCKSgethostbyname"
516 LIBS="-lsocks5 $LIBS"
519 ### use option --with-hesiod=DIR to point at a HESIOD directory
521 [ --with-hesiod=DIR point fetchmail compilation at a HESIOD directory])
523 case "x$with_hesiod" in
527 for dir in /usr/athena /usr /usr/local
529 if test -f "$dir/include/hesiod.h"
531 CEFLAGS="$CEFLAGS -DHESIOD -I$dir/include"
532 LDEFLAGS="$LDEFLAGS -L$dir/lib"
533 LIBS="$LIBS -lhesiod"
541 CEFLAGS="$CEFLAGS -DHESIOD -I$with_hesiod/include"
542 LDEFLAGS="$LDEFLAGS -L$with_hesiod/lib"
543 LIBS="$LIBS -lhesiod"
548 ### use option --with-gssapi=DIR to compile in GSSAPI support
550 [ --with-gssapi[=DIR] compile in GSSAPI support using libraries in DIR],
552 if test "$with_gssapi" != "no"
554 if test "$with_gssapi" = "yes" -a -n "$with_kerberos5"
556 with_gssapi=$with_kerberos5
558 if test "$with_gssapi" != "yes" -a -n "$with_gssapi"
560 CFLAGS="$CFLAGS -I$with_gssapi/include"
561 LDFLAGS="$LDFLAGS -L$with_gssapi/lib"
564 if test -f "$with_gssapi/include/roken.h"
566 LIBS="$LIBS -lkrb5 -lasn1 -ldes -lroken -ldb -ldl"
567 AC_CHECK_LIB(gssapi, gss_init_sec_context,LIBS="$LIBS -lgssapi",
568 AC_MSG_ERROR([could not find libgssapi which is needed for GSSAPI support]), )
571 AC_CHECK_LIB(gssapi_krb5, gss_init_sec_context,LIBS="$LIBS -lgssapi_krb5",
572 AC_MSG_ERROR([could not find libgssapi_krb5 which is needed for GSSAPI support]), -lkrb5)
575 save_CPPFLAGS=$CPPFLAGS
576 CPPFLAGS="-I$with_gssapi/include"
577 AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h gssapi/gssapi_generic.h)
578 if test "$ac_cv_header_gssapi_h" = "yes"; then
579 AC_EGREP_HEADER(GSS_C_NT_HOSTBASED_SERVICE, gssapi.h, AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE))
581 AC_EGREP_HEADER(GSS_C_NT_HOSTBASED_SERVICE, gssapi/gssapi.h, AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE))
585 AC_OUTPUT([Makefile intl/Makefile po/Makefile.in], [
586 # The reason for this odd makedepend line is that we want
587 # to have all dependencies evaluated relative to the source directory
588 # and let VPATH do all the dirty work when we build remotely
589 echo "You can ignore any makedepend error messages:";
590 echo timestamp > stamp-h;
591 (cd $srcdir; makedepend -f - *.c) >>Makefile])
594 dnl comment-start: "dnl "
596 dnl comment-start-skip: "\\bdnl\\b\\s *"
597 dnl compile-command: "make configure config.h.in"