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