]> Pileus Git - ~andy/fetchmail/blob - configure.in
Improve processing of truncated messages.
[~andy/fetchmail] / configure.in
1 dnl Autoconfigure input file for fetchmail
2 dnl Eric S. Raymond <esr@thyrsus.com>
3 dnl
4 dnl Process this file with autoconf to produce a configure script.
5 dnl
6
7 AC_INIT(fetchmail.h)            dnl A distinctive file to look for in srcdir. 
8 AM_CONFIG_HEADER(config.h)
9
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=AC_SUBST(LDFLAGS)
13
14 PACKAGE=`sed -n '/PACKAGE *= *\(.*\)/s//\1/p' <$srcdir/Makefile.in`
15 VERSION=`sed -n '/VERSION *= *\(.*\)/s//\1/p' <$srcdir/Makefile.in`
16 AM_INIT_AUTOMAKE("$PACKAGE", "$VERSION")
17
18 AC_CANONICAL_HOST
19 AC_PROG_CC
20 AC_PROG_INSTALL
21 AC_PROG_CPP                     dnl Later checks need this.
22 AC_PROG_CC_C_O
23 AC_AIX
24 AC_ISC_POSIX
25 AC_MINIX
26 AC_HEADER_STDC
27 AC_TYPE_SIZE_T
28 AC_TYPE_PID_T
29 AC_TYPE_SIGNAL
30 AC_CHECK_HEADERS(unistd.h termios.h termio.h sgtty.h stdarg.h alloca.h)
31 AC_CHECK_HEADERS(sys/itimer.h fcntl.h sys/fcntl.h memory.h sys/wait.h sys/shm.h)
32 AC_CHECK_HEADERS(arpa/inet.h arpa/nameser.h resolv.h net/socket.h sys/select.h)
33
34 AC_C_CONST                      dnl getopt needs this.
35
36 dnl do NOT use AM_PROG_LEX, builds without LEX are not supported properly
37 AC_PROG_LEX
38 AC_PROG_MAKE_SET
39 AC_PROG_YACC
40 AC_SUBST(CPFLAGS)
41 AC_SUBST(CEFLAGS)
42 AC_SUBST(LDEFLAGS)
43
44 # Check for LynxOS special case: -lbsd needed (at least on 2.3.0) and -s
45 # not working.
46 if test `uname` = "LynxOS" 
47 then
48   echo "Adding -lbsd to standard libraries"
49   LIBS="$LIBS -lbsd"
50   LDFLAGS=""
51   echo "Prepending standard include path to gcc flags"
52   CPFLAGS="-I/usr/include"
53 fi
54
55 # Check for FreeBSD special case: more libs needed
56 if test `uname` = "FreeBSD" 
57 then
58    echo "Adding -lmd -lkvm -lcom_err to standard libraries"
59    LIBS="$LIBS -lmd -lkvm -lcom_err"
60 fi
61  
62 # Check for Rhapsody special case: it doesn't like -s
63 if test `uname` = "Rhapsody" 
64 then
65    echo "Removing -s load flag"
66    LDFLAGS=`echo $LDFLAGS | sed "s/-s //"`
67 fi
68  
69 dnl i18n
70 ALL_LINGUAS="ca cs da de es fr gl ja pl pt_BR tr"
71 AM_GNU_GETTEXT
72 dnl end i18n
73
74 # Under sysV68, socket and friends are provided by the C library.
75 # -linet does not provide socket, but causes multiple definition
76 # errors at link-time.  It is thus better to only use the C library.
77 # So don't add -linet to the link list unless it's necessary
78 AC_CHECK_FUNC(socket,
79     AC_MSG_RESULT(using libc's socket),
80     AC_CHECK_LIB(socket,socket)
81     AC_CHECK_LIB(inet,socket))
82
83 # The condition in this test copes with the presence of inet_addr in libc6.
84 AC_CHECK_FUNC(inet_addr,
85     AC_MSG_RESULT(using libc's inet_addr),
86     AC_CHECK_LIB(nsl,inet_addr))
87
88 dnl Port hack for Interactive UNIX System V/386 Release 3.2
89 AC_CHECK_LIB(cposix, strchr,
90                 [EXTRADEFS="$EXTRADEFS -D_SYSV3"
91                 LIBS="$LIBS -lcposix"])
92
93 dnl Port hack for Sparc/NetBSD-1.5
94 AC_CHECK_LIB(intl, gettext,
95                 [LIBS="$LIBS -lintl"])
96
97 AC_CHECK_FUNC(strstr, AC_DEFINE(HAVE_STRSTR), 
98               [EXTRASRC="$EXTRASRC \$(srcdir)/strstr.c"
99                EXTRAOBJ="$EXTRAOBJ strstr.o"])
100
101 AC_CHECK_FUNC(strcasecmp, AC_DEFINE(HAVE_STRCASECMP), 
102               [EXTRASRC="$EXTRASRC \$(srcdir)/strcasecmp.c"
103                EXTRAOBJ="$EXTRAOBJ strcasecmp.o"])
104              
105 AC_CHECK_FUNC(memmove, AC_DEFINE(HAVE_MEMMOVE), 
106               [EXTRASRC="$EXTRASRC \$(srcdir)/memmove.c"
107                EXTRAOBJ="$EXTRAOBJ memmove.o"])
108              
109 AC_CHECK_FUNC(MD5Init, AC_DEFINE(HAVE_MD5),
110               [EXTRASRC="$EXTRASRC \$(srcdir)/md5c.c"
111                EXTRAOBJ="$EXTRAOBJ md5c.o"])
112
113 AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPT_LONG),
114               [EXTRASRC="$EXTRASRC \$(srcdir)/getopt.c \$(srcdir)/getopt1.c"
115                EXTRAOBJ="$EXTRAOBJ getopt.o getopt1.o"])
116
117 AC_FUNC_VPRINTF
118 AC_FUNC_ALLOCA
119 if test -n "$ALLOCA" 
120 then
121   EXTRASRC="$EXTRASRC \$(srcdir)/alloca.c"
122   EXTRAOBJ="$EXTRAOBJ alloca.o"
123 fi
124
125 dnl AC_CHECK_FUNC calls that might hack the Makefile must precede
126 dnl the following AC_SUBSTs
127
128 AC_SUBST(EXTRADEFS)
129 AC_SUBST(EXTRASRC)
130 AC_SUBST(EXTRAOBJ)
131
132 AC_CHECK_FUNCS(tcsetattr stty setsid geteuid seteuid gethostbyname \
133   res_search herror strrchr strerror setlinebuf syslog \
134   snprintf vprintf vsnprintf vsyslog \
135   atexit inet_aton strftime setrlimit socketpair sigprocmask sigaction \
136   getopt_long)
137
138 # Under Red Hat 4.0 (and many other Linuxes) -lresolv is seriously flaky
139 # and breaks gethostbyname(2).  It's better to use the bind stuff in the C
140 # library.  So don't add -lresolv to the link list unless it's necessary
141 # (It will be necessary when using GNU libc6).
142 AC_CHECK_FUNC(res_search,
143     AC_MSG_RESULT(using libc's resolver functions),
144     AC_CHECK_LIB(resolv,res_search, 
145         [AC_DEFINE(HAVE_RES_SEARCH) AC_MSG_RESULT(found resolver functions in libresolv); LIBS="$LIBS -lresolv"], AC_MSG_RESULT(no resolver calls found)))
146
147 dnl Check for libcrypt -- it may live in libc or libcrypt, as on IRIX
148 AC_CHECK_FUNC(crypt, , AC_CHECK_LIB(crypt,crypt))
149
150 dnl Check for RSA refersence library in case we're using SSL
151 AC_CHECK_LIB(rsaref, RSAPublicDecrypt)
152
153 dnl AC_FUNC_SETVBUF_REVERSED
154
155 dnl Check for usable void pointer type
156 AC_MSG_CHECKING(use of void pointer type)
157 AC_TRY_COMPILE([],
158    [char *p;
159     void *xmalloc();
160     p = (char *) xmalloc(1);
161    ],
162  [AC_DEFINE(HAVE_VOIDPOINTER) AC_MSG_RESULT(yes)],
163  AC_MSG_RESULT(no))
164
165 dnl Check for ANSI volatile
166 AC_MSG_CHECKING(for ANSI volatile)
167 AC_TRY_COMPILE([],
168    [volatile int n;],
169  [AC_DEFINE(HAVE_VOLATILE) AC_MSG_RESULT(yes)],
170  AC_MSG_RESULT(no))
171
172 dnl Check out the wait reality.  We have to assume sys/wait.h is present.
173 AC_CHECK_FUNCS(waitpid wait3)
174 AC_MSG_CHECKING(for union wait);
175 AC_TRY_LINK([#include <sys/types.h>
176 #include <sys/wait.h>],
177                  [union wait status; int pid; pid = wait (&status);
178 #ifdef WEXITSTATUS
179 /* Some POSIXoid systems have both the new-style macros and the old
180    union wait type, and they do not work together.  If union wait
181    conflicts with WEXITSTATUS et al, we don't want to use it at all.  */
182 if (WEXITSTATUS (status) != 0) pid = -1;
183 #endif
184 #ifdef HAVE_WAITPID
185 /* Make sure union wait works with waitpid.  */
186 pid = waitpid (-1, &status, 0);
187 #endif
188 ],
189   [AC_DEFINE(HAVE_UNION_WAIT) AC_MSG_RESULT(yes)],
190   AC_MSG_RESULT(no))
191
192 AC_MSG_CHECKING(sys_siglist declaration in signal.h or unistd.h)
193 AC_TRY_LINK([#include <signal.h>
194 /* NetBSD declares sys_siglist in <unistd.h>.  */
195 #ifdef HAVE_UNISTD_H
196 #include <unistd.h>
197 #endif], [char *msg = *(sys_siglist + 1);],
198   [AC_DEFINE(SYS_SIGLIST_DECLARED) AC_MSG_RESULT(yes)],
199   AC_MSG_RESULT(no))
200
201 # Find the right directory to put the root-mode PID file in
202 for dir in "/var/run" "/etc"
203 do
204         if test -d $dir 
205         then
206                 break;
207         fi
208 done
209 AC_MSG_RESULT(root-mode pid file will go in $dir)
210 AC_DEFINE_UNQUOTED(PID_DIR, "$dir")
211
212 # We may have a fallback MDA available in case the socket open to the 
213 # local SMTP listener fails.  Best to use procmail for this, as we know
214 # it won't try delivering through local SMTP and cause a mail loop.
215 # Sendmail without the -t option to use the message headers will work too,
216 # not just for sendmail itself but for workalikes like exim.
217 #
218 # Note1: A disadvantage of using procmail is that local alias expansion
219 # according to /etc/aliases won't get done if we fall back.  This doesn't
220 # matter in single-drop mode.
221 #
222 # Note2: it would be a very bad idea to use any MDA that doesn't return
223 # a refuse-to-deliver status on disk- or process-table-full
224 # conditions; mail could get lost that way.  Sendmail and all of the MDAs
225 # like exim that might be lurking under a sendmail alias) do the right 
226 # thing in this circumstance.  Matthias Andree warns that procmail does
227 # not.  
228 #
229 # Note3: Defalt value of fallback is now off.  Matthias writes:
230 #
231 # 1. there is no way to predict when the fallback is used. With some MTAs
232 #    (such as those limiting load average), outer circumstances can cause
233 #    the fallback to kick in.
234
235 # 2. the fallback changes fetchmail behaviour in unpredictable ways. It's
236 #    not only about alias expansion, .forwards to special filters won't
237 #    work, mail may end up in a different place (users claim "mail loss"
238 #    for that).
239
240 # 3. The claim procmail did the right thing with its exit codes is plain
241 #    wrong. I've seen procmail exit with code 1 when it should have exited
242 #    with code 75, like, configuration errors. Procmail is a dangerous
243 #    beast and is best replaced by maildrop.
244
245 # 4. if multiple choices exist (like procmail and maildrop), fetchmail
246 #    cannot tell which one it should choose. Say, your MTA is configured
247 #    to use maildrop to deliver to user's mailboxes, if fetchmail then
248 #    chooses procmail, this is plain wrong.
249 #
250
251 AC_PATH_PROG(procmail, procmail, "", $PATH:/usr/sbin)
252 AC_PATH_PROG(sendmail, sendmail, "", $PATH:/usr/sbin:/usr/lib)
253 AC_PATH_PROG(maildrop, maildrop, "", $PATH:/usr/local/bin)
254
255 ###     use option --disable-fallback to disable fallback MDA
256 ###     use option --enable-fallback=procmail or 
257 ###                --enable-fallback=sendmail to select
258 AC_ARG_ENABLE(fallback,
259         [  --enable-fallback=procmail    enable procmail as fallback
260   --enable-fallback=sendmail    enable /usr/sbin/sendmail as fallback
261   --enable-fallback=maildrop    enable maildrop as fallback
262   --enable-fallback=no          disable fallback],,[enable_fallback=no])
263
264 case "$enable_fallback" in
265         sendmail)       if test -z "$sendmail" ; then 
266                                 AC_ERROR([Sendmail selected as fallback, but not found])
267                                 #not reached
268                         fi
269                         AC_DEFINE_UNQUOTED(FALLBACK_MDA, "$sendmail -i %T")
270                         echo "Will use $sendmail as fallback MDA."
271                         ;;
272         procmail)       if test -z "$procmail" ; then
273                                 AC_ERROR([procmail selected as fallback, but not found])
274                                 #not reached
275                         fi
276                         AC_DEFINE_UNQUOTED(FALLBACK_MDA, "$procmail -d %T")
277                         echo "Will use $procmail as fallback MDA."
278                         ;;
279         maildrop)       if test -z "$maildrop" ; then
280                                 AC_ERROR([maildrop selected as fallback, but not found])
281                                 #not reached
282                         fi
283                         AC_DEFINE_UNQUOTED(FALLBACK_MDA, "$maildrop -d %T")
284                         echo "Will use $maildrop as fallback MDA."
285                         ;;
286         no|unset)       echo "Will not use a fallback MDA"
287                         ;;
288         auto|yes|set)   if test -n "$sendmail" ; then
289                                 AC_DEFINE_UNQUOTED(FALLBACK_MDA,"$sendmail -i %T")
290                                 echo "Will use $sendmail as fallback MDA."
291                         else
292                                 echo "No fallback MDA available. procmail and maildrop are not eligible"
293                                 echo "for automatic fallback MDA configuration for reliability reasons."
294                         fi
295                         ;;
296         *)              AC_ERROR([unkown value for --enable-fallback given: $enable_fallback])
297                         #notreached
298                         ;;
299 esac
300
301 AC_CHECK_SIZEOF(short)
302 AC_CHECK_SIZEOF(int)
303 AC_CHECK_SIZEOF(long)
304
305 ###     use option --enable-POP2 to compile in the POP2 support
306 AC_ARG_ENABLE(POP2,
307         [  --enable-POP2           compile in POP2 protocol support (obsolete)],
308         [with_POP2=$enableval],
309         [with_POP2=no])
310 test "$with_POP2" = "yes" && AC_DEFINE(POP2_ENABLE)
311
312 ###     use option --disable-POP3 to omit the POP3 support
313 AC_ARG_ENABLE(POP3,
314         [  --disable-POP3          don't compile in POP3 protocol support],
315         [with_POP3=$enableval],
316         [with_POP3=yes])
317 test "$with_POP3" = "yes" && AC_DEFINE(POP3_ENABLE)
318
319 ###     use option --disable-IMAP to omit the IMAP support
320 AC_ARG_ENABLE(IMAP,
321         [  --disable-IMAP          don't compile in IMAP protocol support],
322         [with_IMAP=$enableval],
323         [with_IMAP=yes])
324 test "$with_IMAP" = "yes" && AC_DEFINE(IMAP_ENABLE)
325
326 ###     use option --disable-ETRN to omit the ETRN support
327 AC_ARG_ENABLE(ETRN,
328         [  --disable-ETRN          don't compile in ETRN protocol support],
329         [with_ETRN=$enableval],
330         [with_ETRN=yes])
331 test "$with_ETRN" = "yes" && AC_DEFINE(ETRN_ENABLE)
332
333 ###     use option --disable-ODMR to omit the ODMR support
334 AC_ARG_ENABLE(ODMR,
335         [  --disable-ODMR          don't compile in ODMR protocol support],
336         [with_ODMR=$enableval],
337         [with_ODMR=yes])
338 test "$with_ODMR" = "yes" && AC_DEFINE(ODMR_ENABLE)
339
340 ###     use option --enable-RPA to compile in the RPA support
341 AC_ARG_ENABLE(RPA,
342         [  --enable-RPA            compile in RPA protocol support],
343         [with_RPA=$enableval],
344         [with_RPA=no])
345 test "$with_RPA" = "yes" && AC_DEFINE(RPA_ENABLE)
346
347 ###     use option --enable-NTLM to compile in the NTLM support
348 AC_ARG_ENABLE(NTLM,
349         [  --enable-NTLM           compile in NTLM authentication support],
350         [with_NTLM=$enableval],
351         [with_NTLM=no])
352 test "$with_NTLM" = "yes" && AC_DEFINE(NTLM_ENABLE)
353
354 ###     use option --enable-SDPS to compile in the SDPS support
355 AC_ARG_ENABLE(SDPS,
356         [  --enable-SDPS           compile in SDPS protocol support],
357         [with_SDPS=$enableval],
358         [with_SDPS=no])
359 test "$with_SDPS" = "yes" && AC_DEFINE(SDPS_ENABLE)
360
361 ###     use option --enable-opie to compile in the OPIE support
362 AC_ARG_ENABLE(opie,
363         [  --enable-opie           support OTP through the OPIE library],
364         [ AC_CHECK_HEADER(opie.h,, [echo 'configure: cannot find <opie.h>, which is required for OPIE support.'; exit 1])
365           AC_CHECK_LIB(opie,opiegenerator,, [echo 'configure: cannot find libopie, which is required for OPIE support.'; exit 1])
366           with_opie=$enableval],
367         [with_opie=no])
368 test "$with_opie" = "yes" && AC_DEFINE(OPIE_ENABLE)
369
370 AC_ARG_ENABLE(inet6,
371         [  --enable-inet6          support IPv6 (requires the inet6-apps library)],
372
373         [ AC_CHECK_FUNC(getaddrinfo, [with_inet6=yes],
374           [ LDFLAGS="$LDFLAGS -L/usr/inet6/lib";
375             AC_CHECK_LIB(inet6, getaddrinfo, [with_inet6=yes
376             LIBS="$LIBS -linet6"],
377             [ echo 'configure: cannot find proper glibc version or libinet6,';
378               echo '           which is required for IPv6 support.';
379               exit 1]) ] )],
380         [with_inet6=no])
381 test "$with_inet6" = "yes" && AC_DEFINE(INET6_ENABLE)
382
383 AC_CHECK_FUNCS(inner_connect)
384
385 AC_ARG_ENABLE(netsec,
386         [  --enable-netsec         support network security (requires inet6-apps library)],
387         [ unset ac_cv_lib_inet6_net_security_strtorequest; AC_CHECK_LIB(inet6, net_security_strtorequest,,
388           [ unset ac_cv_lib_inet6_net_security_strtorequest;
389             LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; 
390             AC_CHECK_LIB(inet6, net_security_strtorequest,,
391             [ echo 'configure: cannot find net_security_strtorequest in libinet6, which is required';
392               echo '           for network security support. Either it does not exist, or it was';
393               echo '           not built with network security support enabled.';
394               exit 1]) ])
395         unset ac_cv_header_net_security_h; AC_CHECK_HEADER(net/security.h,,
396         [ unset ac_cv_header_net_security_h; 
397         CPPFLAGS="$CPPFLAGS -I/usr/inet6/include"; 
398         CFLAGS="$CFLAGS -I/usr/inet6/include"; AC_CHECK_HEADER(net/security.h,,
399           [ echo 'configure: cannot find <net/security.h>, which is required';
400           echo '             for network security support.';
401           exit 1]) ]) ]
402         [with_netsec=no])
403 test "$with_netsec" = "yes" && AC_DEFINE(NET_SECURITY)
404
405 # This version of the Kerberos 4 and 5 options addresses the follwing issues:
406
407 # * Build correctly under Heimdal kerberos if it is compiled with db2 and
408 #   OpenSSL support (Debian's is)
409 # * Build the kerberos.c stuff (KPOP) only for kerberosIV, to avoid breakage.
410 #   I don't know if this is 100% correct, but now at least IMAP and POP3
411 #   behave the same way regarding kerberosV.
412 # * Build without any fuss for both kerberosIV and V at the same time.
413 # * Move all the kerberos header mess to kerberos.h, and #include that
414 #   in driver.c and kerberos.c.
415
416 # Tested using the Heimdal Kerberos V libs, Kungliga Tekniska Högskolan (the
417 # Royal Institute of Technology in Stockholm, Sweden)'s kerberos IV libs, and
418 # the MIT reference implementation of KerberosV (all as packaged in Debian).
419
420 ###    use option --with-kerberos5=DIR to point at a Kerberos 5 directory
421 ### make sure --with-ssl is run before --with-kerberos* !
422 AC_ARG_WITH(kerberos5,
423        [  --with-kerberos5=DIR    point fetchmail compilation at a Kerberos 5
424 directory],
425 [
426 if test "$with_kerberos5" != "no"
427 then
428 # Check for a OpenBSD special case
429 if test "$with_kerberos5" = "yes" && ( test `uname` = "OpenBSD" )
430 then
431   AC_CHECKING([kerberosV for OpenBSD])
432   AC_DEFINE(HEIMDAL)
433   AC_DEFINE(KERBEROS_V5)
434   CEFLAGS="$CEFLAGS -I/usr/include/kerberosV"
435   LIBS="$LIBS -lasn1 -lkrb5 -lcom_err -lkafs"
436 else
437   if test "$with_kerberos5" != "yes" 
438   then
439       LDEFLAGS="$LDEFLAGS -L${with_kerberos5}/lib"
440       searchdirs="$with_kerberos5"
441   else
442       searchdirs="/usr/kerberos /usr/local/krb5 /usr/athena /usr"
443   fi
444   with_kerberos5=
445   for dir in $searchdirs
446   do AC_MSG_CHECKING([for Kerberos V in $dir])
447      if test -f "$dir/include/krb5.h"
448      then
449         ac_krblibs=
450         if test -f "$dir/include/roken.h"
451         then
452            ac_krblibs="-lasn1 -lroken -lcom_err"
453            AC_MSG_RESULT([Heimdal found])
454           dnl Attempt to detect if we need to -ldb2 to link Heimdal
455           dnl we assume we do if it is available
456            AC_CHECK_LIB(db2, db_open, ac_krblibs="$ac_krblibs -ldb2", [],
457                 ${LDEFLAGS})
458            AC_CHECK_LIB(des, des_string_to_key, libk5crypto=-ldes,
459               AC_CHECK_LIB(ssl, MD5_Init, [],
460                 AC_ERROR([DES libraries not found. Try adding --with-ssl to enable OpenSSL support]),
461                 ${LDEFLAGS} ${ac_krblibs}),
462            ${LDEFLAGS} ${ac_krblibs})
463            AC_DEFINE(HEIMDAL)
464         else
465           AC_MSG_RESULT([found])
466           ac_krblibs="-lcom_err"
467            AC_CHECK_LIB(crypto,
468              krb5_des_string_to_key,
469              libk5crypto=-lcrypto,
470                 AC_CHECK_LIB(k5crypto,
471                    krb5_des_string_to_key,
472                    libk5crypto=-lk5crypto,
473                       AC_ERROR([Kerberos 5 DES libraries not found]),
474                    ${LDEFLAGS} ${ac_krblibs}),
475                  ${LDEFLAGS} ${ac_krblibs})
476         fi
477         AC_CHECK_LIB(krb5, krb5_init_context,[],
478            continue,
479            ${LDEFLAGS} ${ac_krblibs})
480         AC_DEFINE(KERBEROS_V5)
481         test "$dir" != "/usr" && CEFLAGS="$CEFLAGS -I$dir/include"
482         LDEFLAGS="$LDEFLAGS -L$dir/lib"
483        LIBS="$LIBS $ac_krblibs $libk5crypto"
484         with_kerberos5=$dir
485         break
486      else
487         AC_MSG_RESULT([not found])
488      fi
489   done
490   if test -z "$with_kerberos5" ; then
491      AC_ERROR([Kerberos 5 libraries not found])
492   fi
493 fi
494 fi
495 ]) dnl --with-kerberos5=DIR
496
497 ###    use option --with-kerberos=DIR to point at a Kerberos 4 directory
498 AC_ARG_WITH(kerberos,
499        [  --with-kerberos=DIR     point fetchmail compilation at a Kerberos 4
500 directory],
501 [
502 if test "$with_kerberos" != "no"
503 then
504 # Check for a NetBSD/OpenBSD special case
505 if test "$with_kerberos" = "yes" && ( test `uname` = "NetBSD" || test `uname` = "OpenBSD" )
506 then
507   AC_CHECKING([kerberosIV for `uname`])
508   AC_DEFINE(KERBEROS_V4)
509   CEFLAGS="$CEFLAGS -I/usr/include/kerberosIV"
510   LIBS="$LIBS -lkrb -ldes"
511 else
512   #we need to detect when we're building under a kerberosV compatibility
513   #layer, btw...
514   if test "$with_kerberos" != "yes" ; then
515      searchdirs="$with_kerberos"
516   else
517      searchdirs="$with_kerberos5 /usr/kerberos /usr/kerberosIV /usr/athena/usr"
518   fi
519   with_kerberos=
520   ac_saveLDFLAGS="$LDFLAGS"
521   for dir in $searchdirs
522   do
523      AC_MSG_CHECKING([for Kerberos IV in $dir])
524      if test -f "$dir/include/krb.h" || test -f "$dir/include/krb4.h" \
525             || test -f "$dir/include/kerberosIV/krb.h"
526      then
527         AC_MSG_RESULT([found])
528      else
529         AC_MSG_RESULT([not found])
530        continue
531      fi
532      #Find libs
533      if test -f "$with_kerberos5/roken.h" ; then
534        AC_CHECK_LIB(45, krb_mk_req)
535      fi
536      LDFLAGS="-L$dir/lib $ac_saveLDFLAGS"
537      AC_SEARCH_LIBS(des_string_to_key, [des425 des], [], continue)
538      AC_SEARCH_LIBS(krb_realmofhost, [krb4 krb], [], continue)
539      with_kerberos="$dir"
540      if test -f "$dir/include/kerberosIV/krb.h" ; then
541         dir="$dir/include/kerberosIV"
542      else
543        dir="$dir/include"
544      fi
545      AC_DEFINE(KERBEROS_V4)
546      test -f "$with_kerberos5/roken.h" && AC_DEFINE(HEIMDAL)
547      test "$dir" != "/usr/include" && CEFLAGS="$CEFLAGS -I$dir"
548      LDEFLAGS="$LDEFLAGS -L$with_kerberos/lib"
549      break
550   done
551   if test -z "$with_kerberos" ; then
552      AC_ERROR([Kerberos 4 libraries not found])
553   fi
554   LDFLAGS="$ac_saveLDFLAGS"
555 fi
556 fi
557 ]) dnl --with-kerberos=DIR
558
559 ###     use option --with-ssl to compile in the SSL support
560 AC_ARG_WITH(ssl,
561         [  --with-ssl=[DIR]        enable SSL support using libraries in DIR],
562         [with_ssl=$withval],
563         [with_ssl=no])
564 test "$with_ssl" != "no" && AC_DEFINE(SSL_ENABLE)
565
566 if test "$with_ssl" = "yes"
567 then
568     #   He didn't specify an SSL location.  Let's look at some common
569     #   directories where SSL has been found in the past and try and auto
570     #   configure for SSL.  OpenSSL determination will be made later.
571     #   This will screw up if an OpenSSL install is located in a later
572     #   directory than an older SSLeay install, but the user should fix that
573     #   anyways and he can override on the configure line.
574     for ac_dir in \
575       /usr/local/ssl \
576       /usr/ssl \
577       /usr \
578       /local/ssl \
579       /opt/ssl \
580       ; \
581     do
582         if test -d "$ac_dir" ; then
583             with_ssl=$ac_dir
584             break;
585         fi
586     done
587 fi
588
589 if test -n "$with_ssl" -a "$with_ssl" != "no"
590 then
591   # With the autoconfigure above, the only time this is going to be
592   # true is going to be when we could not find the headers.  If they
593   # are not in system standard locations, we are going to be broken.
594   if test "$with_ssl" = "yes"
595   then
596     # Let's just define the standard location for the SSLeay root
597     with_ssl="/usr/local/ssl"
598   fi
599   if test -r $with_ssl/include/openssl/ssl.h
600   then
601     ### ssl.h found under openssl.  Use openssl configuration preferentially
602     echo "Enabling OpenSSL support in $with_ssl"
603     CEFLAGS="$CEFLAGS -I$with_ssl/include -I$with_ssl/include/openssl"
604     ### OpenBSD comes with ssl headers
605   elif test -r /usr/include/ssl/ssl.h
606   then
607     echo "Enabling SSLeay support in $with_ssl"
608     CEFLAGS="$CEFLAGS -I/usr/include/ssl"
609   else
610     echo "Enabling SSLeay support in $with_ssl"
611     CEFLAGS="$CEFLAGS -I$with_ssl/include"
612   fi
613   LDEFLAGS="$LDEFLAGS -L$with_ssl/lib"
614   LIBS="$LIBS -lssl -lcrypto"
615   AC_DEFINE(SSL_ENABLE)
616 else
617   echo 'Disabling SSL support...'
618 fi
619
620 ###     use option --with-socks=DIR to point at SOCKS library
621 AC_ARG_WITH(socks,
622         [  --with-socks[=DIR]      add built-in SOCKS firewall access],
623 [
624 if test "$with_socks" != no
625 then
626     if test "$with_socks" != yes
627     then
628         LDEFLAGS="$LDEFLAGS -L$with_socks"
629     else
630         AC_CHECK_LIB(socks, Rconnect,,
631                AC_MSG_ERROR([could not find libsocks which is needed for built-in SOCKS support]))
632     fi
633     AC_DEFINE(HAVE_SOCKS)
634     CEFLAGS="$CEFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
635     LIBS="-lsocks $LIBS"
636 fi])
637
638 ###     use option --with-socks5=DIR to point at SOCKS library
639 AC_ARG_WITH(socks5,
640         [  --with-socks5[=DIR]     add built-in SOCKS5 firewall access],
641 [
642 if test "$with_socks5" != no
643 then
644   if test "$with_socks5" != yes
645   then
646     LDEFLAGS="$LDEFLAGS -L$with_socks5"
647   fi
648   ac_savedLDFLAGS="$LDFLAGS"
649   LDFLAGS="$LDEFLAGS $LDFLAGS"
650   AC_CHECK_LIB(socks5, SOCKSconnect,,
651         AC_MSG_ERROR([could not find libsocks5 which is needed for built-in SOCKS5 support]))
652   AC_DEFINE(HAVE_SOCKS)
653   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 -Dgethostbyname=SOCKSgethostbyname"
654   AC_CHECK_FUNC(SOCKSfclose, [CFLAGS="$CFLAGS -Dfclose=SOCKSfclose"])
655   LDFLAGS="$ac_savedLDFLAGS"
656 fi])
657
658 ###     use option --with-hesiod=DIR to point at a HESIOD directory
659 AC_ARG_WITH(hesiod,
660         [  --with-hesiod=DIR       point fetchmail compilation at a HESIOD directory])
661
662 case "x$with_hesiod" in
663 xno)
664     ;;
665 x)
666     for dir in /usr/athena /usr /usr/local
667     do
668       if test -f "$dir/include/hesiod.h"
669       then
670         test "$dir" != "/usr" && CEFLAGS="$CEFLAGS -DHESIOD -I$dir/include"
671         LDEFLAGS="$LDEFLAGS -L$dir/lib"
672         LIBS="$LIBS -lhesiod"
673         with_hesiod=$dir
674         break
675       fi
676     done
677     ;;
678 *)
679     # Path given
680     CEFLAGS="$CEFLAGS -DHESIOD -I$with_hesiod/include"
681     LDEFLAGS="$LDEFLAGS -L$with_hesiod/lib"
682     LIBS="$LIBS -lhesiod"
683     ;;
684 esac
685
686 ###     use option --with-gssapi=DIR to compile in GSSAPI support
687 AC_ARG_WITH(gssapi,
688         [  --with-gssapi[=DIR]     compile in GSSAPI support using libraries in DIR],
689 [
690 if test "$with_gssapi" != "no"
691 then
692   if test "$with_gssapi" = "yes" -a -n "$with_kerberos5"
693   then
694     with_gssapi=$with_kerberos5
695   fi
696   if test "$with_gssapi" != "yes" -a -n "$with_gssapi"
697   then
698     CFLAGS="$CFLAGS -I$with_gssapi/include"
699     LDFLAGS="$LDFLAGS -L$with_gssapi/lib"
700   fi
701
702   if test -f "$with_gssapi/include/roken.h"
703   then
704      LIBS="$LIBS -lkrb5 -lasn1 -ldes -lroken -ldb -ldl"
705      AC_CHECK_LIB(gssapi, gss_init_sec_context,LIBS="$LIBS -lgssapi",
706                   AC_MSG_ERROR([could not find libgssapi which is needed for GSSAPI support]), )
707      AC_DEFINE(HEIMDAL)
708   else
709      AC_CHECK_LIB(gssapi_krb5, gss_init_sec_context,LIBS="$LIBS -lgssapi_krb5",
710                   AC_MSG_ERROR([could not find libgssapi_krb5 which is needed for GSSAPI support]), -lkrb5)
711   fi
712   AC_DEFINE(GSSAPI)
713   save_CPPFLAGS=$CPPFLAGS
714   CPPFLAGS="-I$with_gssapi/include"
715   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h gssapi/gssapi_generic.h)
716   if test "$ac_cv_header_gssapi_h" = "yes"; then
717     AC_EGREP_HEADER(GSS_C_NT_HOSTBASED_SERVICE, gssapi.h, AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE))
718   else
719     AC_EGREP_HEADER(GSS_C_NT_HOSTBASED_SERVICE, gssapi/gssapi.h, AC_DEFINE(HAVE_GSS_C_NT_HOSTBASED_SERVICE))
720   fi
721 fi])
722
723 AC_OUTPUT([Makefile intl/Makefile po/Makefile.in], [
724         # The reason for this odd makedepend line is that we want
725         # to have all dependencies evaluated relative to the source directory
726         # and let VPATH do all the dirty work when we build remotely
727         echo "You can ignore any makedepend error messages:";
728         echo timestamp > stamp-h;
729         (cd $srcdir; makedepend -f - *.c) >>Makefile])
730
731 dnl Local Variables:
732 dnl comment-start: "dnl "
733 dnl comment-end: ""
734 dnl comment-start-skip: "\\bdnl\\b\\s *"
735 dnl compile-command: "make configure config.h.in"
736 dnl End: