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 # Arnaldo Carvalho de Melo <acme@conectiva.com.br>
74 # Sat Nov 7 15:39:03 EDT 1998
76 ALL_LINGUAS="cs es fr pl pt_BR"
82 # Under sysV68, socket and friends are provided by the C library.
83 # -linet does not provide socket, but causes multiple definition
84 # errors at link-time. It is thus better to only use the C library.
85 # So don't add -linet to the link list unless it's necessary
87 AC_MSG_RESULT(using libc's socket),
88 AC_CHECK_LIB(socket,socket)
89 AC_CHECK_LIB(inet,socket))
91 # If gettext isn't in the C library, maybe there's a -lintl.
92 AC_CHECK_FUNC(gettext,
93 AC_MSG_RESULT(using libc's gettext),
94 AC_CHECK_LIB(intl,gettext))
96 # The condition in this test copes with the presence of inet_addr in libc6.
97 AC_CHECK_FUNC(inet_addr,
98 AC_MSG_RESULT(using libc's inet_addr),
99 AC_CHECK_LIB(nsl,inet_addr))
101 dnl Port hack for Interactive UNIX System V/386 Release 3.2
102 AC_CHECK_LIB(cposix, strchr,
103 [EXTRADEFS="$EXTRADEFS -D_SYSV3"
104 LIBS="$LIBS -lcposix"])
106 AC_CHECK_FUNC(strstr, AC_DEFINE(HAVE_STRSTR),
107 [EXTRASRC="$EXTRASRC \$(srcdir)/strstr.c"
108 EXTRAOBJ="$EXTRAOBJ strstr.o"])
110 AC_CHECK_FUNC(strcasecmp, AC_DEFINE(HAVE_STRCASECMP),
111 [EXTRASRC="$EXTRASRC \$(srcdir)/strcasecmp.c"
112 EXTRAOBJ="$EXTRAOBJ strcasecmp.o"])
114 AC_CHECK_FUNC(memmove, AC_DEFINE(HAVE_MEMMOVE),
115 [EXTRASRC="$EXTRASRC \$(srcdir)/memmove.c"
116 EXTRAOBJ="$EXTRAOBJ memmove.o"])
118 AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPTLONG),
119 [EXTRASRC="$EXTRASRC \$(srcdir)/getopt.c \$(srcdir)/getopt1.c"
120 EXTRAOBJ="$EXTRAOBJ getopt.o getopt1.o"])
122 AC_CHECK_FUNC(MD5Init, AC_DEFINE(HAVE_MD5),
123 [EXTRASRC="$EXTRASRC \$(srcdir)/md5c.c"
124 EXTRAOBJ="$EXTRAOBJ md5c.o"])
130 EXTRASRC="$EXTRASRC \$(srcdir)/alloca.c"
131 EXTRAOBJ="$EXTRAOBJ alloca.o"
134 dnl AC_CHECK_FUNC calls that might hack the Makefile must precede
135 dnl the following AC_SUBSTs
141 AC_CHECK_FUNCS(tcsetattr stty setsid geteuid seteuid gethostbyname \
142 res_search herror strrchr strerror setlinebuf syslog \
143 snprintf vprintf vsnprintf vsyslog \
144 atexit inet_aton strftime setrlimit socketpair sigprocmask)
146 # Under Red Hat 4.0 (and many other Linuxes) -lresolv is seriously flaky
147 # and breaks gethostbyname(2). It's better to use the bind stuff in the C
148 # library. So don't add -lresolv to the link list unless it's necessary
149 # (It will be necessary when using GNU libc6).
150 AC_CHECK_FUNC(res_search,
151 AC_MSG_RESULT(using libc's resolver functions),
152 AC_CHECK_LIB(resolv,res_search,
153 [AC_DEFINE(HAVE_RES_SEARCH) AC_MSG_RESULT(found resolver functions in libresolv); LIBS="$LIBS -lresolv"], AC_MSG_RESULT(no resolver calls found)))
155 dnl Check for libcrypt
156 AC_CHECK_LIB(crypt,crypt)
158 dnl Check for RSA refersence library in case we're using SSL
159 AC_CHECK_LIB(rsaref, RSAPublicDecrypt)
161 dnl AC_FUNC_SETVBUF_REVERSED
163 dnl Check for usable void pointer type
164 AC_MSG_CHECKING(use of void pointer type)
168 p = (char *) xmalloc(1);
170 [AC_DEFINE(HAVE_VOIDPOINTER) AC_MSG_RESULT(yes)],
173 dnl Check for ANSI volatile
174 AC_MSG_CHECKING(for ANSI volatile)
177 [AC_DEFINE(HAVE_VOLATILE) AC_MSG_RESULT(yes)],
180 dnl Check out the wait reality. We have to assume sys/wait.h is present.
181 AC_CHECK_FUNCS(waitpid wait3)
182 AC_MSG_CHECKING(for union wait);
183 AC_TRY_LINK([#include <sys/types.h>
184 #include <sys/wait.h>],
185 [union wait status; int pid; pid = wait (&status);
187 /* Some POSIXoid systems have both the new-style macros and the old
188 union wait type, and they do not work together. If union wait
189 conflicts with WEXITSTATUS et al, we don't want to use it at all. */
190 if (WEXITSTATUS (status) != 0) pid = -1;
193 /* Make sure union wait works with waitpid. */
194 pid = waitpid (-1, &status, 0);
197 [AC_DEFINE(HAVE_UNION_WAIT) AC_MSG_RESULT(yes)],
200 AC_MSG_CHECKING(sys_siglist declaration in signal.h or unistd.h)
201 AC_TRY_LINK([#include <signal.h>
202 /* NetBSD declares sys_siglist in <unistd.h>. */
205 #endif], [char *msg = *(sys_siglist + 1);],
206 [AC_DEFINE(SYS_SIGLIST_DECLARED) AC_MSG_RESULT(yes)],
209 # Find the right directory to put the root-mode PID file in
210 for dir in "/var/run" "/etc"
217 AC_MSG_RESULT(root-mode pid file will go in $dir)
218 AC_DEFINE_UNQUOTED(PID_DIR, "$dir")
220 AC_CHECK_SIZEOF(short)
222 AC_CHECK_SIZEOF(long)
224 if test "$USE_NLS" = "yes"
226 echo 'Enabling internationalization support...'
227 POMAKE='$(MAKE) -C po'
228 if test "x$prefix" != xNONE; then
229 EXTRADEFS="$EXTRADEFS -DLOCALEDIR='\"$prefix/share/locale\"'"
231 EXTRADEFS="$EXTRADEFS -DLOCALEDIR='\"$ac_default_prefix/share/locale\"'"
234 echo 'Disabling internationalization support...'
235 POMAKE="@echo '(NLS support disabled)'; #"
238 ### use option --enable-POP2 to compile in the POP2 support
240 [ --enable-POP2 compile in POP2 protocol support (obsolete)],
241 [with_POP2=$enableval],
243 test "$with_POP2" = "yes" && AC_DEFINE(POP2_ENABLE)
245 ### use option --disable-POP3 to omit the POP3 support
247 [ --disable-POP3 don't compile in POP3 protocol support],
248 [with_POP3=$enableval],
250 test "$with_POP3" = "yes" && AC_DEFINE(POP3_ENABLE)
252 ### use option --disable-IMAP to omit the IMAP support
254 [ --disable-IMAP don't compile in IMAP protocol support],
255 [with_IMAP=$enableval],
257 test "$with_IMAP" = "yes" && AC_DEFINE(IMAP_ENABLE)
259 ### use option --disable-ETRN to omit the ETRN support
261 [ --disable-ETRN don't compile in ETRN protocol support],
262 [with_ETRN=$enableval],
264 test "$with_ETRN" = "yes" && AC_DEFINE(ETRN_ENABLE)
266 ### use option --enable-RPA to compile in the RPA support
268 [ --enable-RPA compile in RPA protocol support],
269 [with_RPA=$enableval],
271 test "$with_RPA" = "yes" && AC_DEFINE(RPA_ENABLE)
273 ### use option --enable-NTLM to compile in the NTLM support
275 [ --enable-NTLM compile in NTLM authentication support],
276 [with_NTLM=$enableval],
278 test "$with_NTLM" = "yes" && AC_DEFINE(NTLM_ENABLE)
280 ### use option --enable-SDPS to compile in the SDPS support
282 [ --enable-SDPS compile in SDPS protocol support],
283 [with_SDPS=$enableval],
285 test "$with_SDPS" = "yes" && AC_DEFINE(SDPS_ENABLE)
287 ### use option --enable-opie to compile in the OPIE support
289 [ --enable-opie support OTP through the OPIE library],
290 [ AC_CHECK_HEADER(opie.h,, [echo 'configure: cannot find <opie.h>, which is required for OPIE support.'; exit 1])
291 AC_CHECK_LIB(opie,opiegenerator,, [echo 'configure: cannot find libopie, which is required for OPIE support.'; exit 1])
292 with_opie=$enableval],
294 test "$with_opie" = "yes" && AC_DEFINE(OPIE_ENABLE)
297 [ --enable-inet6 support IPv6 (requires the inet6-apps library)],
299 [ AC_CHECK_FUNC(getaddrinfo, [with_inet6=yes],
300 [ LDFLAGS="$LDFLAGS -L/usr/inet6/lib";
301 AC_CHECK_LIB(inet6, getaddrinfo, [with_inet6=yes
302 LIBS="$LIBS -linet6"],
303 [ echo 'configure: cannot find proper glibc version or libinet6,';
304 echo ' which is required for IPv6 support.';
307 test "$with_inet6" = "yes" && AC_DEFINE(INET6_ENABLE)
309 AC_CHECK_FUNCS(inner_connect)
311 AC_ARG_ENABLE(netsec,
312 [ --enable-netsec support network security (requires inet6-apps library)],
313 [ unset ac_cv_lib_inet6_net_security_strtorequest; AC_CHECK_LIB(inet6, net_security_strtorequest,,
314 [ unset ac_cv_lib_inet6_net_security_strtorequest;
315 LDFLAGS="$LDFLAGS -L/usr/inet6/lib";
316 AC_CHECK_LIB(inet6, net_security_strtorequest,,
317 [ echo 'configure: cannot find net_security_strtorequest in libinet6, which is required';
318 echo ' for network security support. Either it does not exist, or it was';
319 echo ' not built with network security support enabled.';
321 unset ac_cv_header_net_security_h; AC_CHECK_HEADER(net/security.h,,
322 [ unset ac_cv_header_net_security_h;
323 CPPFLAGS="$CPPFLAGS -I/usr/inet6/include";
324 CFLAGS="$CFLAGS -I/usr/inet6/include"; AC_CHECK_HEADER(net/security.h,,
325 [ echo 'configure: cannot find <net/security.h>, which is required';
326 echo ' for network security support.';
329 test "$with_netsec" = "yes" && AC_DEFINE(NET_SECURITY)
331 ### use option --with-kerberos5=DIR to point at a Kerberos 5 directory
332 AC_ARG_WITH(kerberos5,
333 [ --with-kerberos5=DIR point fetchmail compilation at a Kerberos 5 directory])
335 # The "then" arm (nonempty $with_kerberos5) is kind of a crock. It works for
336 # configuring the BSD/OS Kerberos IV support, though.
337 if test -n "$with_kerberos5" -a "$with_kerberos5" != "no"
340 CEFLAGS="$CEFLAGS -DKERBEROS_V5 -I$with_kerberos5/include"
341 LDEFLAGS="$LDEFLAGS -L$with_kerberos5/lib"
342 if test -f "$with_kerberos5/include/roken.h"
345 LIBS="$LIBS -lkrb5 -lasn1 -ldes -lroken -lcom_err"
347 LIBS="$LIBS -lkrb5 -lcrypto -lcom_err"
349 elif test "$with_kerberos" != "no"; then
350 for dir in /usr/kerberos /usr/local/krb5 /usr/athena
352 if test -f "$dir/include/krb5.h"
354 CEFLAGS="$CEFLAGS -DKERBEROS_V5 -I$dir/include"
355 LDEFLAGS="$LDEFLAGS -L$dir/lib"
356 if test -f "$dir/include/roken.h"
359 LIBS="$LIBS -lkrb5 -lasn1 -ldes -lcom_err"
361 LIBS="$LIBS -lkrb5 -lcrypto -lcom_err"
369 ### use option --with-ssl to compile in the SSL support
371 [ --with-ssl=[DIR] enable SSL support using libraries in DIR],
374 test "$with_ssl" = "yes" && AC_DEFINE(SSL_ENABLE)
376 if test "$with_ssl" = "yes"
378 # He didn't specify an SSL location. Let's look at some common
379 # directories where SSL has been found in the past and try and auto
380 # configure for SSL. OpenSSL determination will be made later.
381 # This will screw up if an OpenSSL install is located in a later
382 # directory than an older SSLeay install, but the user should fix that
383 # anyways and he can override on the configure line.
392 if test -d "$ac_dir" ; then
399 if test -n "$with_ssl" -a "$with_ssl" != "no"
401 # With the autoconfigure above, the only time this is going to be
402 # true is going to be when we could not find the headers. If they
403 # are not in system standard locations, we are going to be broken.
404 if test "$with_ssl" = "yes"
406 # Let's just define the standard location for the SSLeay root
407 with_ssl="/usr/local/ssl"
409 if test -r $with_ssl/include/openssl/ssl.h
411 ### ssl.h found under openssl. Use openssl configuration preferentially
412 echo "Enabling OpenSSL support in $with_ssl"
413 CEFLAGS="$CEFLAGS -I$with_ssl/include -I$with_ssl/include/openssl"
414 ### OpenBSD comes with ssl headers
415 elif test -r /usr/include/ssl/ssl.h
417 echo "Enabling SSLeay support in $with_ssl"
418 CEFLAGS="$CEFLAGS -I/usr/include/ssl"
420 echo "Enabling SSLeay support in $with_ssl"
421 CEFLAGS="$CEFLAGS -I$with_ssl/include"
423 LDEFLAGS="$LDEFLAGS -L$with_ssl/lib"
424 LIBS="$LIBS -lssl -lcrypto"
425 AC_DEFINE(SSL_ENABLE)
427 echo 'Disabling SSL support...'
430 ### use option --with-kerberos=DIR to point at a Kerberos directory
431 AC_ARG_WITH(kerberos,
432 [ --with-kerberos=DIR point fetchmail compilation at a Kerberos directory])
434 # The "elif" arm (nonempty $with_kerberos) is kind of a crock. It works for
435 # configuring the BSD/OS Kerberos IV support, though.
437 # Check for a NetBSD/OpenBSD special case
438 if test "$with_kerberos" = "yes" && test `uname` = "NetBSD" -o `uname` = "OpenBSD"
440 echo "Configuring kerberosIV for `uname`"
441 CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I/usr/include/kerberosIV"
442 LIBS="$LIBS -lkrb -ldes"
443 elif test -n "$with_kerberos" -a -n "$with_kerberos5" -a "$with_kerberos" != "no"
445 CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$with_kerberos/include"
446 LDEFLAGS="$LDEFLAGS -L$with_kerberos/lib"
447 if test -f "$with_kerberos5/roken.h"
450 LIBS="-lkrb4 -l45 $LIBS"
452 LIBS="-lkrb4 -ldes425 $LIBS"
454 elif test -n "$with_kerberos5" -a "$with_kerberos" != "no"
456 for dir in /usr/kerberos /usr/kerberosIV /usr/athena
458 if test -f "$dir/include/kerberosIV/krb.h"
460 CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$dir/include"
461 LDEFLAGS="$LDEFLAGS -L$dir/lib"
462 LIBS="-lkrb4 -ldes425 $LIBS"
466 elif test -n "$with_kerberos" -a "$with_kerberos" != "no"
468 CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$with_kerberos/include"
469 LDEFLAGS="$LDEFLAGS -L$with_kerberos/lib"
470 LIBS="$LIBS -lkrb -ldes"
472 if test "$with_kerberos" != "no"
474 for dir in /usr/kerberos /usr/kerberosIV /usr/athena
476 if test -f "$dir/include/krb.h"
478 CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$dir/include"
479 LDEFLAGS="$LDEFLAGS -L$dir/lib"
480 LIBS="$LIBS -lkrb -ldes"
486 ### use option --with-socks=DIR to point at SOCKS library
488 [ --with-socks[=DIR] add built-in SOCKS firewall access],
490 if test "$with_socks" != no
492 if test "$with_socks" != yes
494 LDEFLAGS="$LDEFLAGS -L$with_socks"
496 AC_CHECK_LIB(socks, Rconnect,,
497 AC_MSG_ERROR([could not find libsocks which is needed for built-in SOCKS support]))
499 AC_DEFINE(HAVE_SOCKS)
500 CEFLAGS="$CEFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
504 ### use option --with-socks5=DIR to point at SOCKS library
506 [ --with-socks5[=DIR] add built-in SOCKS5 firewall access],
508 if test "$with_socks5" != no
510 if test "$with_socks5" != yes
512 LDEFLAGS="$LDEFLAGS -L$with_socks5"
514 AC_CHECK_LIB(socks5, SOCKSconnect,,
515 AC_MSG_ERROR([could not find libsocks5 which is needed for built-in SOCKS5 support]))
517 AC_DEFINE(HAVE_SOCKS)
518 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"
519 LIBS="-lsocks5 $LIBS"
522 ### use option --with-hesiod=DIR to point at a HESIOD directory
524 [ --with-hesiod=DIR point fetchmail compilation at a HESIOD directory])
526 case "x$with_hesiod" in
530 for dir in /usr/athena /usr /usr/local
532 if test -f "$dir/include/hesiod.h"
534 CEFLAGS="$CEFLAGS -DHESIOD -I$dir/include"
535 LDEFLAGS="$LDEFLAGS -L$dir/lib"
536 LIBS="$LIBS -lhesiod"
544 CEFLAGS="$CEFLAGS -DHESIOD -I$with_hesiod/include"
545 LDEFLAGS="$LDEFLAGS -L$with_hesiod/lib"
546 LIBS="$LIBS -lhesiod"
551 ### use option --with-gssapi=DIR to compile in GSSAPI support
553 [ --with-gssapi[=DIR] compile in GSSAPI support using libraries in DIR],
555 if test "$with_gssapi" != "no"
557 if test "$with_gssapi" = "yes" -a -n "$with_kerberos5"
559 with_gssapi=$with_kerberos5
561 if test "$with_gssapi" != "yes" -a -n "$with_gssapi"
563 CFLAGS="$CFLAGS -I$with_gssapi/include"
564 LDFLAGS="$LDFLAGS -L$with_gssapi/lib"
567 if test -f "$with_gssapi/include/roken.h"
569 LIBS="$LIBS -lkrb5 -lasn1 -ldes -lroken -ldb -ldl"
570 AC_CHECK_LIB(gssapi, gss_init_sec_context,LIBS="$LIBS -lgssapi",
571 AC_MSG_ERROR([could not find libgssapi which is needed for GSSAPI support]), )
574 AC_CHECK_LIB(gssapi_krb5, gss_init_sec_context,LIBS="$LIBS -lgssapi_krb5",
575 AC_MSG_ERROR([could not find libgssapi_krb5 which is needed for GSSAPI support]), -lkrb5)
578 save_CPPFLAGS=$CPPFLAGS
579 CPPFLAGS="-I$with_gssapi/include"
580 AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h gssapi/gssapi_generic.h)
581 if test "$ac_cv_header_gssapi_h" = "yes"; then
582 AC_EGREP_HEADER(GSS_C_NT_HOSTBASED_SERVICE, gssapi.h, AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE))
584 AC_EGREP_HEADER(GSS_C_NT_HOSTBASED_SERVICE, gssapi/gssapi.h, AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE))
588 AC_OUTPUT([Makefile intl/Makefile po/Makefile.in], [
589 # The reason for this odd makedepend line is that we want
590 # to have all dependencies evaluated relative to the source directory
591 # and let VPATH do all the dirty work when we build remotely
592 echo "You can ignore any makedepend error messages:";
593 echo timestamp > stamp-h;
594 (cd $srcdir; makedepend -f - *.c) >>Makefile])
597 dnl comment-start: "dnl "
599 dnl comment-start-skip: "\\bdnl\\b\\s *"
600 dnl compile-command: "make configure config.h.in"