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