]> Pileus Git - ~andy/fetchmail/blob - configure.in
Ready to ship the big one.
[~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 AC_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=-s AC_SUBST(LDFLAGS)
13
14 AC_CANONICAL_HOST
15 AC_PROG_CC
16 AC_PROG_INSTALL
17 AC_PROG_CPP                     dnl Later checks need this.
18 AC_PROG_CC_C_O
19 AC_AIX
20 AC_ISC_POSIX
21 AC_MINIX
22 AC_HEADER_STDC
23 AC_TYPE_SIZE_T
24 AC_TYPE_PID_T
25 AC_TYPE_SIGNAL
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
28 AC_C_CONST                      dnl getopt needs this.
29
30 AC_PROG_LEX
31 AC_PROG_YACC
32 AC_SUBST(CPFLAGS)
33 AC_SUBST(CEFLAGS)
34 AC_SUBST(LDEFLAGS)
35 AC_SUBST(LIBOBJS)
36 AC_SUBST(POMAKE)
37
38 PACKAGE=`sed -n '/PACKAGE *= *\(.*\)/s//\1/p' <$srcdir/Makefile.in`
39 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
40 AC_SUBST(PACKAGE)
41
42 VERSION=`sed -n '/VERSION *= *\(.*\)/s//\1/p' <$srcdir/Makefile.in`
43 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
44 AC_SUBST(VERSION)
45
46 # Check for LynxOS special case: -lbsd needed (at least on 2.3.0) and -s
47 # not working.
48 if test `uname` = "LynxOS" 
49 then
50   echo "Adding -lbsd to standard libraries"
51   LIBS="$LIBS -lbsd"
52   LDFLAGS=""
53   echo "Prepending standard include path to gcc flags"
54   CPFLAGS="-I/usr/include"
55 fi
56
57 # Check for FreeBSD special case: -lkvm needed
58 if test `uname` = "FreeBSD" 
59 then
60    echo "Adding -lkvm to standard libraries"
61    LIBS="$LIBS -lkvm"
62 fi
63  
64 # i18n
65 # Arnaldo Carvalho de Melo <acme@conectiva.com.br>
66 # Sat Nov  7 15:39:03 EDT 1998
67
68 ALL_LINGUAS="pt_BR es pl fr"
69
70 AM_GNU_GETTEXT
71
72 # 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 # If gettext isn't in the C library, maybe there's a -lintl.
84 AC_CHECK_FUNC(gettext,
85     AC_MSG_RESULT(using libc's gettext),
86     AC_CHECK_LIB(intl,gettext))
87
88 # The condition in this test copes with the presence of inet_addr in libc6.
89 AC_CHECK_FUNC(inet_addr,
90     AC_MSG_RESULT(using libc's inet_addr),
91     AC_CHECK_LIB(nsl,inet_addr))
92
93 dnl Port hack for Interactive UNIX System V/386 Release 3.2
94 AC_CHECK_LIB(cposix, strchr,
95                 [EXTRADEFS="$EXTRADEFS -D_SYSV3"
96                 LIBS="$LIBS -lcposix"])
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(getopt_long, AC_DEFINE(HAVE_GETOPTLONG),
111               [EXTRASRC="$EXTRASRC \$(srcdir)/getopt.c \$(srcdir)/getopt1.c"
112                EXTRAOBJ="$EXTRAOBJ getopt.o getopt1.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)
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 AC_FUNC_SETVBUF_REVERSED
144
145 dnl Check for usable void pointer type
146 AC_MSG_CHECKING(use of void pointer type)
147 AC_TRY_COMPILE([],
148    [char *p;
149     void *xmalloc();
150     p = (char *) xmalloc(1);
151    ],
152  [AC_DEFINE(HAVE_VOIDPOINTER) AC_MSG_RESULT(yes)],
153  AC_MSG_RESULT(no))
154
155 dnl Check for ANSI volatile
156 AC_MSG_CHECKING(for ANSI volatile)
157 AC_TRY_COMPILE([],
158    [volatile int n;],
159  [AC_DEFINE(HAVE_VOLATILE) AC_MSG_RESULT(yes)],
160  AC_MSG_RESULT(no))
161
162 dnl Check out the wait reality.  We have to assume sys/wait.h is present.
163 AC_CHECK_FUNCS(waitpid wait3)
164 AC_MSG_CHECKING(for union wait);
165 AC_TRY_LINK([#include <sys/types.h>
166 #include <sys/wait.h>],
167                  [union wait status; int pid; pid = wait (&status);
168 #ifdef WEXITSTATUS
169 /* Some POSIXoid systems have both the new-style macros and the old
170    union wait type, and they do not work together.  If union wait
171    conflicts with WEXITSTATUS et al, we don't want to use it at all.  */
172 if (WEXITSTATUS (status) != 0) pid = -1;
173 #endif
174 #ifdef HAVE_WAITPID
175 /* Make sure union wait works with waitpid.  */
176 pid = waitpid (-1, &status, 0);
177 #endif
178 ],
179   [AC_DEFINE(HAVE_UNION_WAIT) AC_MSG_RESULT(yes)],
180   AC_MSG_RESULT(no))
181
182 AC_MSG_CHECKING(sys_siglist declaration in signal.h or unistd.h)
183 AC_TRY_LINK([#include <signal.h>
184 /* NetBSD declares sys_siglist in <unistd.h>.  */
185 #ifdef HAVE_UNISTD_H
186 #include <unistd.h>
187 #endif], [char *msg = *(sys_siglist + 1);],
188   [AC_DEFINE(SYS_SIGLIST_DECLARED) AC_MSG_RESULT(yes)],
189   AC_MSG_RESULT(no))
190
191 # Find the right directory to put the root-mode PID file in
192 for dir in "/var/run" "/etc"
193 do
194         if test -d $dir 
195         then
196                 break;
197         fi
198 done
199 AC_MSG_RESULT(root-mode pid file will go in $dir)
200 AC_DEFINE_UNQUOTED(PID_DIR, "$dir")
201
202 AC_CHECK_SIZEOF(short)
203 AC_CHECK_SIZEOF(int)
204 AC_CHECK_SIZEOF(long)
205
206 if test "$USE_NLS" = "yes"
207 then
208         echo 'Enabling internationalization support...'
209         POMAKE='$(MAKE) -C po'
210         if test "x$prefix" != xNONE; then
211                 EXTRADEFS="$EXTRADEFS -DLOCALEDIR='\"$prefix/share/locale\"'"
212         else
213                 EXTRADEFS="$EXTRADEFS -DLOCALEDIR='\"$ac_default_prefix/share/locale\"'"
214         fi
215 else
216         echo 'Disabling internationalization support...'
217         POMAKE="@echo '(NLS support disabled)'; #"
218 fi
219
220 ###     use option --enable-POP2 to compile in the POP2 support
221 AC_ARG_ENABLE(POP2,
222         [  --enable-POP2           compile in POP2 protocol support (obsolete)],
223         [with_POP2=$enableval],
224         [with_POP2=no])
225 test "$with_POP2" = "yes" && AC_DEFINE(POP2_ENABLE)
226
227 ###     use option --disable-POP3 to omit the POP3 support
228 AC_ARG_ENABLE(POP3,
229         [  --disable-POP3          don't compile in POP3 protocol support],
230         [with_POP3=$enableval],
231         [with_POP3=yes])
232 test "$with_POP3" = "yes" && AC_DEFINE(POP3_ENABLE)
233
234 ###     use option --disable-IMAP to omit the IMAP support
235 AC_ARG_ENABLE(IMAP,
236         [  --disable-IMAP          don't compile in IMAP protocol support],
237         [with_IMAP=$enableval],
238         [with_IMAP=yes])
239 test "$with_IMAP" = "yes" && AC_DEFINE(IMAP_ENABLE)
240
241 ###     use option --disable-ETRN to omit the ETRN support
242 AC_ARG_ENABLE(ETRN,
243         [  --disable-ETRN          don't compile in ETRN protocol support],
244         [with_ETRN=$enableval],
245         [with_ETRN=yes])
246 test "$with_ETRN" = "yes" && AC_DEFINE(ETRN_ENABLE)
247
248 ###     use option --enable-RPA to compile in the RPA support
249 AC_ARG_ENABLE(RPA,
250         [  --enable-RPA            compile in RPA protocol support],
251         [with_RPA=$enableval],
252         [with_RPA=no])
253 test "$with_RPA" = "yes" && AC_DEFINE(RPA_ENABLE)
254
255 ###     use option --enable-SDPS to compile in the SDPS support
256 AC_ARG_ENABLE(SDPS,
257         [  --enable-SDPS           compile in SDPS protocol support],
258         [with_SDPS=$enableval],
259         [with_SDPS=no])
260 test "$with_SDPS" = "yes" && AC_DEFINE(SDPS_ENABLE)
261
262 ###     use option --enable-opie to compile in the OPIE support
263 AC_ARG_ENABLE(opie,
264         [  --enable-opie           support OTP through the OPIE library],
265         [ AC_CHECK_HEADER(opie.h,, [echo 'configure: cannot find <opie.h>, which is required for OPIE support.'; exit 1])
266           AC_CHECK_LIB(opie,opiegenerator,, [echo 'configure: cannot find libopie, which is required for OPIE support.'; exit 1])
267           AC_DEFINE(OPIE,1) ],
268         [with_opie=no])
269
270 AC_ARG_ENABLE(inet6,
271         [  --enable-inet6          support IPv6 (requires the inet6-apps library)],
272         [ unset ac_cv_lib_inet6_getaddrinfo; AC_CHECK_LIB(inet6, getaddrinfo,,
273         [ unset ac_cv_lib_inet6_getaddrinfo; LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; AC_CHECK_LIB(inet6, getaddrinfo,,
274         [ echo 'configure: cannot find libinet6, which is required for IPv6 support.'; exit 1]) ])
275           AC_DEFINE(INET6, 1) ])
276
277 AC_ARG_ENABLE(netsec,
278         [  --enable-netsec         support network security (requires inet6-apps library)],
279         [ unset ac_cv_lib_inet6_net_security_strtorequest; AC_CHECK_LIB(inet6, net_security_strtorequest,,
280         [ unset ac_cv_lib_inet6_net_security_strtorequest; LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; AC_CHECK_LIB(inet6, net_security_strtorequest,,
281         [ echo 'configure: cannot find net_security_strtorequest in libinet6, which is required';
282           echo '           for network security support. Either it does not exist, or it was';
283           echo '           not built with network security support enabled.';
284           exit 1]) ])
285           unset ac_cv_header_net_security_h; AC_CHECK_HEADER(net/security.h,,
286         [ unset ac_cv_header_net_security_h; CPPFLAGS="$CPPFLAGS -I/usr/inet6/include"; CFLAGS="$CFLAGS -I/usr/inet6/include"; AC_CHECK_HEADER(net/security.h,,
287         [ echo 'configure: cannot find <net/security.h>, which is required for network security';
288           echo '           support.';
289           exit 1]) ])
290           AC_DEFINE(NET_SECURITY, 1) ])
291   
292 ###     use option --with-kerberos5=DIR to point at a Kerberos 5 directory
293 AC_ARG_WITH(kerberos5,
294         [  --with-kerberos5=DIR    point fetchmail compilation at a Kerberos 5 directory])
295
296 # The "then" arm (nonempty $with_kerberos5) is kind of a crock.  It works for
297 # configuring the BSD/OS Kerberos IV support, though. 
298 if test -n "$with_kerberos5"
299 then
300     # Path given
301     CEFLAGS="$CEFLAGS -DKERBEROS_V5 -I$with_kerberos5/include"
302     LDEFLAGS="$LDEFLAGS -L$with_kerberos5/lib"
303     LIBS="$LIBS -lkrb5 -lcrypto -lcom_err"
304 else
305   if test "$with_kerberos5" != "no" ; then
306     for dir in /usr/kerberos /usr/local/krb5 /usr/athena
307     do
308       if test -f "$dir/include/krb5.h"
309       then
310         CEFLAGS="$CEFLAGS -DKERBEROS_V5 -I$dir/include"
311         LDEFLAGS="$LDEFLAGS -L$dir/lib"
312         LIBS="$LIBS -lkrb5 -lcrypto -lcom_err"
313         with_kerberos5=$dir
314         break
315       fi
316     done
317   fi
318 fi
319
320 ###     use option --with-kerberos=DIR to point at a Kerberos directory
321 AC_ARG_WITH(kerberos,
322         [  --with-kerberos=DIR     point fetchmail compilation at a Kerberos directory])
323
324 # The "elif" arm (nonempty $with_kerberos) is kind of a crock.  It works for
325 # configuring the BSD/OS Kerberos IV support, though. 
326
327 # Check for a NetBSD special case
328 if test "$with_kerberos" = "yes" -a `uname` = "NetBSD" 
329 then
330   echo "Configuring kerberosIV for NetBSD"
331   CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I/usr/include/kerberosIV"
332   LIBS="$LIBS -lkrb -ldes"
333 elif test -n "$with_kerberos" -a -n "$with_kerberos5"
334 then
335     CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$with_kerberos/include"
336     LDEFLAGS="$LDEFLAGS -L$with_kerberos/lib"
337     LIBS="-lkrb4 -ldes425 $LIBS"
338 elif test -n "$with_kerberos5"
339 then
340     for dir in /usr/kerberos /usr/kerberosIV /usr/athena
341     do
342       if test -f "$dir/include/kerberosIV/krb.h"
343       then
344         CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$dir/include"
345         LDEFLAGS="$LDEFLAGS -L$dir/lib"
346         LIBS="-lkrb4 -ldes425 $LIBS"
347         break
348       fi
349     done
350 elif test -n "$with_kerberos" -a "$with_kerberos" != "no"
351 then
352     CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$with_kerberos/include"
353     LDEFLAGS="$LDEFLAGS -L$with_kerberos/lib"
354     LIBS="$LIBS -lkrb -ldes"
355 else
356   if test "$with_kerberos" != "no"
357   then
358     for dir in /usr/kerberos /usr/kerberosIV /usr/athena
359     do
360       if test -f "$dir/include/krb.h"
361       then
362         CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$dir/include"
363         LDEFLAGS="$LDEFLAGS -L$dir/lib"
364         LIBS="$LIBS -lkrb -ldes"
365         break
366       fi
367     done
368 fi
369
370 ###     use option --with-socks=DIR to point at SOCKS library
371 AC_ARG_WITH(socks,
372         [  --with-socks[=DIR]      add built-in SOCKS firewall access],
373 [
374 if test "$with_socks" != no
375 then
376     if test "$with_socks" != yes
377     then
378         LDEFLAGS="$LDEFLAGS -L$with_socks"
379     else
380         AC_CHECK_LIB(socks, Rconnect,,
381                AC_MSG_ERROR([could not find libsocks which is needed for built-in SOCKS support]))
382     fi
383     AC_DEFINE(HAVE_SOCKS)
384     CEFLAGS="$CEFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
385     LIBS="-lsocks $LIBS"
386 fi])
387
388 ###     use option --with-hesiod=DIR to point at a HESIOD directory
389 AC_ARG_WITH(hesiod,
390         [  --with-hesiod=DIR       point fetchmail compilation at a HESIOD directory])
391
392 if test -n "$with_hesiod"
393 then
394     # Path given
395     CEFLAGS="$CEFLAGS -DHESIOD -I$with_hesiod/include"
396     LDEFLAGS="$LDEFLAGS -L$with_hesiod/lib"
397     LIBS="$LIBS -lhesiod"
398 else
399     for dir in /usr/athena /usr /usr/local
400     do
401       if test -f "$dir/include/hesiod.h"
402       then
403         CEFLAGS="$CEFLAGS -DHESIOD -I$dir/include"
404         LDEFLAGS="$LDEFLAGS -L$dir/lib"
405         LIBS="$LIBS -lhesiod"
406         with_hesiod=$dir
407         break
408       fi
409     done
410   fi
411 fi
412
413 ###     use option --with-gssapi=DIR to compile in GSSAPI support
414 AC_ARG_WITH(gssapi,
415         [  --with-gssapi[=DIR]     compile in GSSAPI support using libraries in DIR],
416 [
417 if test "$with_gssapi" != "no"
418 then
419   if test "$with_gssapi" = "yes" -a -n "$with_kerberos5"
420   then
421     with_gssapi=$with_kerberos5
422   fi
423   if test "$with_gssapi" != "yes" -a -n "$with_gssapi"
424   then
425     CFLAGS="$CFLAGS -I$with_gssapi/include"
426     LDFLAGS="$LDFLAGS -L$with_gssapi/lib"
427   fi
428
429   AC_CHECK_LIB(krb5, krb5_init_context,,
430                AC_MSG_ERROR([could not find libkrb5 which is needed for GSSAPI support]))
431   AC_CHECK_LIB(gssapi_krb5, gss_init_sec_context,,
432                AC_MSG_ERROR([could not find libgssapi_krb5 which is needed for GSSAPI support]), -lkrb5)
433   AC_DEFINE(GSSAPI)
434   LIBS="$LIBS -lgssapi_krb5 -lkrb5"
435 fi])
436
437 AC_OUTPUT([Makefile intl/Makefile po/Makefile.in], [
438         # The reason for this odd makedepend line is that we want
439         # to have all dependencies evaluated relative to the source directory
440         # and let VPATH do all the dirty work when we build remotely
441         echo "You can ignore any makedepend error messages";
442         (cd $srcdir; makedepend -f - *.c) >>Makefile])
443
444 dnl Local Variables:
445 dnl comment-start: "dnl "
446 dnl comment-end: ""
447 dnl comment-start-skip: "\\bdnl\\b\\s *"
448 dnl compile-command: "make configure config.h.in"
449 dnl End: