]> Pileus Git - ~andy/fetchmail/blob - configure.in
This version appears ready to ship.
[~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   if test `uname -r` = "2.5.0"
54   then
55     echo "Prepending standard include path to gcc flags"
56     CPFLAGS="-I/usr/include"
57   fi
58 fi
59
60 # i18n
61 # Arnaldo Carvalho de Melo <acme@conectiva.com.br>
62 # Sat Nov  7 15:39:03 EDT 1998
63
64 ALL_LINGUAS="pt_BR es pl"
65
66 AM_GNU_GETTEXT
67
68 # end i18n
69
70 # Under sysV68, socket and friends are provided by the C library.
71 # -linet does not provide socket, but causes multiple definition
72 # errors at link-time.  It is thus better to only use the C library.
73 # So don't add -linet to the link list unless it's necessary
74 AC_CHECK_FUNC(socket,
75     AC_MSG_RESULT(using libc's socket),
76     AC_CHECK_LIB(socket,socket)
77     AC_CHECK_LIB(inet,socket))
78
79 # If gettext isn't in the C library, maybe there's a -lintl.
80 AC_CHECK_FUNC(gettext,
81     AC_MSG_RESULT(using libc's gettext),
82     AC_CHECK_LIB(intl,gettext))
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_FUNC_VPRINTF
111 AC_FUNC_ALLOCA
112 if test -n "$ALLOCA" 
113 then
114   EXTRASRC="$EXTRASRC \$(srcdir)/alloca.c"
115   EXTRAOBJ="$EXTRAOBJ alloca.o"
116 fi
117
118 dnl AC_CHECK_FUNC calls that might hack the Makefile must precede
119 dnl the following AC_SUBSTs
120
121 AC_SUBST(EXTRADEFS)
122 AC_SUBST(EXTRASRC)
123 AC_SUBST(EXTRAOBJ)
124
125 AC_CHECK_FUNCS(tcsetattr stty setsid seteuid gethostbyname res_search herror \
126   strrchr strerror setlinebuf syslog snprintf vprintf vsnprintf vsyslog \
127   atexit inet_aton strftime setrlimit socketpair sigprocmask)
128
129 # Under Red Hat 4.0 (and many other Linuxes) -lresolv is seriously flaky
130 # and breaks gethostbyname(2).  It's better to use the bind stuff in the C
131 # library.  So don't add -lresolv to the link list unless it's necessary
132 # (It will be necessary when using GNU libc6).
133 AC_CHECK_FUNC(res_search,
134     AC_MSG_RESULT(using libc's resolver functions),
135     AC_CHECK_LIB(resolv,res_search, 
136         [AC_DEFINE(HAVE_RES_SEARCH) AC_MSG_RESULT(found resolver functions in libresolv); LIBS="$LIBS -lresolv"], AC_MSG_RESULT(no resolver calls found)))
137
138 dnl AC_FUNC_SETVBUF_REVERSED
139
140 dnl Check for usable void pointer type
141 AC_MSG_CHECKING(use of void pointer type)
142 AC_TRY_COMPILE([],
143    [char *p;
144     void *xmalloc();
145     p = (char *) xmalloc(1);
146    ],
147  [AC_DEFINE(HAVE_VOIDPOINTER) AC_MSG_RESULT(yes)],
148  AC_MSG_RESULT(no))
149
150 dnl Check for ANSI volatile
151 AC_MSG_CHECKING(for ANSI volatile)
152 AC_TRY_COMPILE([],
153    [volatile int n;],
154  [AC_DEFINE(HAVE_VOLATILE) AC_MSG_RESULT(yes)],
155  AC_MSG_RESULT(no))
156
157 dnl Check out the wait reality.  We have to assume sys/wait.h is present.
158 AC_CHECK_FUNCS(waitpid wait3)
159 AC_MSG_CHECKING(for union wait);
160 AC_TRY_LINK([#include <sys/types.h>
161 #include <sys/wait.h>],
162                  [union wait status; int pid; pid = wait (&status);
163 #ifdef WEXITSTATUS
164 /* Some POSIXoid systems have both the new-style macros and the old
165    union wait type, and they do not work together.  If union wait
166    conflicts with WEXITSTATUS et al, we don't want to use it at all.  */
167 if (WEXITSTATUS (status) != 0) pid = -1;
168 #endif
169 #ifdef HAVE_WAITPID
170 /* Make sure union wait works with waitpid.  */
171 pid = waitpid (-1, &status, 0);
172 #endif
173 ],
174   [AC_DEFINE(HAVE_UNION_WAIT) AC_MSG_RESULT(yes)],
175   AC_MSG_RESULT(no))
176
177 AC_MSG_CHECKING(sys_siglist declaration in signal.h or unistd.h)
178 AC_TRY_LINK([#include <signal.h>
179 /* NetBSD declares sys_siglist in <unistd.h>.  */
180 #ifdef HAVE_UNISTD_H
181 #include <unistd.h>
182 #endif], [char *msg = *(sys_siglist + 1);],
183   [AC_DEFINE(SYS_SIGLIST_DECLARED) AC_MSG_RESULT(yes)],
184   AC_MSG_RESULT(no))
185
186 # Find the right directory to put the root-mode PID file in
187 for dir in "/var/run" "/etc"
188 do
189         if test -d $dir 
190         then
191                 break;
192         fi
193 done
194 AC_MSG_RESULT(root-mode pid file will go in $dir)
195 AC_DEFINE_UNQUOTED(PID_DIR, "$dir")
196
197 AC_CHECK_SIZEOF(short)
198 AC_CHECK_SIZEOF(int)
199 AC_CHECK_SIZEOF(long)
200
201 if test "$USE_NLS" = "yes"
202 then
203         echo 'Enabling internationalization support...'
204         POMAKE='$(MAKE) -C po'
205         if test "x$prefix" != xNONE; then
206                 EXTRADEFS="$EXTRADEFS -DLOCALEDIR='\"$prefix/share/locale\"'"
207         else
208                 EXTRADEFS="$EXTRADEFS -DLOCALEDIR='\"$ac_default_prefix/share/locale\"'"
209         fi
210 else
211         echo 'Disabling internationalization support...'
212         POMAKE="@echo '(NLS support disabled)'; #"
213 fi
214
215 ###     use option --enable-POP2 to compile in the POP2 support
216 AC_ARG_ENABLE(POP2,
217         [  --enable-POP2           compile in POP2 protocol support (obsolete)],
218         [with_POP2=$enableval],
219         [with_POP2=no])
220 test "$with_POP2" = "yes" && AC_DEFINE(POP2_ENABLE)
221
222 ###     use option --disable-POP3 to omit the POP3 support
223 AC_ARG_ENABLE(POP3,
224         [  --disable-POP3          don't compile in POP3 protocol support],
225         [with_POP3=$enableval],
226         [with_POP3=yes])
227 test "$with_POP3" = "yes" && AC_DEFINE(POP3_ENABLE)
228
229 ###     use option --disable-IMAP to omit the IMAP support
230 AC_ARG_ENABLE(IMAP,
231         [  --disable-IMAP          don't compile in IMAP protocol support],
232         [with_IMAP=$enableval],
233         [with_IMAP=yes])
234 test "$with_IMAP" = "yes" && AC_DEFINE(IMAP_ENABLE)
235
236 ###     use option --disable-ETRN to omit the ETRN support
237 AC_ARG_ENABLE(ETRN,
238         [  --disable-ETRN          don't compile in ETRN protocol support],
239         [with_ETRN=$enableval],
240         [with_ETRN=yes])
241 test "$with_ETRN" = "yes" && AC_DEFINE(ETRN_ENABLE)
242
243 ###     use option --enable-RPA to compile in the RPA support
244 AC_ARG_ENABLE(RPA,
245         [  --enable-RPA            compile in RPA protocol support],
246         [with_RPA=$enableval],
247         [with_RPA=no])
248 test "$with_RPA" = "yes" && AC_DEFINE(RPA_ENABLE)
249
250 ###     use option --enable-SDPS to compile in the SDPS support
251 AC_ARG_ENABLE(SDPS,
252         [  --enable-SDPS           compile in SDPS protocol support],
253         [with_SDPS=$enableval],
254         [with_SDPS=no])
255 test "$with_SDPS" = "yes" && AC_DEFINE(SDPS_ENABLE)
256
257 ###     use option --enable-opie to compile in the OPIE support
258 AC_ARG_ENABLE(opie,
259         [  --enable-opie           support OTP through the OPIE library],
260         [ AC_CHECK_HEADER(opie.h,, [echo 'configure: cannot find <opie.h>, which is required for OPIE support.'; exit 1])
261           AC_CHECK_LIB(opie,opiegenerator,, [echo 'configure: cannot find libopie, which is required for OPIE support.'; exit 1])
262           AC_DEFINE(OPIE,1) ],
263         [with_opie=no])
264
265 AC_ARG_ENABLE(inet6,
266         [  --enable-inet6          support IPv6 (requires the inet6-apps library)],
267         [ unset ac_cv_lib_inet6_getaddrinfo; AC_CHECK_LIB(inet6, getaddrinfo,,
268         [ unset ac_cv_lib_inet6_getaddrinfo; LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; AC_CHECK_LIB(inet6, getaddrinfo,,
269         [ echo 'configure: cannot find libinet6, which is required for IPv6 support.'; exit 1]) ])
270           AC_DEFINE(INET6, 1) ])
271
272 AC_ARG_ENABLE(netsec,
273         [  --enable-netsec         support network security (requires inet6-apps library)],
274         [ unset ac_cv_lib_inet6_net_security_strtorequest; AC_CHECK_LIB(inet6, net_security_strtorequest,,
275         [ unset ac_cv_lib_inet6_net_security_strtorequest; LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; AC_CHECK_LIB(inet6, net_security_strtorequest,,
276         [ echo 'configure: cannot find net_security_strtorequest in libinet6, which is required';
277           echo '           for network security support. Either it does not exist, or it was';
278           echo '           not built with network security support enabled.';
279           exit 1]) ])
280           unset ac_cv_header_net_security_h; AC_CHECK_HEADER(net/security.h,,
281         [ 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,,
282         [ echo 'configure: cannot find <net/security.h>, which is required for network security';
283           echo '           support.';
284           exit 1]) ])
285           AC_DEFINE(NET_SECURITY, 1) ])
286   
287 ###     use option --with-kerberos5=DIR to point at a Kerberos 5 directory
288 AC_ARG_WITH(kerberos5,
289         [  --with-kerberos5=DIR    point fetchmail compilation at a Kerberos 5 directory])
290
291 # The "then" arm (nonempty $with_kerberos5) is kind of a crock.  It works for
292 # configuring the BSD/OS Kerberos IV support, though. 
293 if test -n "$with_kerberos5"
294 then
295     # Path given
296     CEFLAGS="$CEFLAGS -DKERBEROS_V5 -I$with_kerberos5/include"
297     LDEFLAGS="$LDEFLAGS -L$with_kerberos5/lib"
298     LIBS="$LIBS -lkrb5 -lcrypto -lcom_err"
299 else
300     for dir in /usr/kerberos /usr/local/krb5 /usr/athena
301     do
302       if test -f "$dir/include/krb5.h"
303       then
304         CEFLAGS="$CEFLAGS -DKERBEROS_V5 -I$dir/include"
305         LDEFLAGS="$LDEFLAGS -L$dir/lib"
306         LIBS="$LIBS -lkrb5 -lcrypto -lcom_err"
307         with_kerberos5=$dir
308         break
309       fi
310     done
311 fi
312
313 ###     use option --with-kerberos=DIR to point at a Kerberos directory
314 AC_ARG_WITH(kerberos,
315         [  --with-kerberos=DIR     point fetchmail compilation at a Kerberos directory])
316
317 # The "elif" arm (nonempty $with_kerberos) is kind of a crock.  It works for
318 # configuring the BSD/OS Kerberos IV support, though. 
319
320 # Check for a NetBSD special case
321 if test "$with_kerberos" = "yes" -a `uname` = "NetBSD" 
322 then
323   echo "Configuring kerberosIV for NetBSD"
324   CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I/usr/include/kerberosIV"
325   LIBS="$LIBS -lkrb -ldes"
326 elif test -n "$with_kerberos" -a -n "$with_kerberos5"
327 then
328     CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$with_kerberos/include"
329     LDEFLAGS="$LDEFLAGS -L$with_kerberos/lib"
330     LIBS="-lkrb4 -ldes425 $LIBS"
331 elif test -n "$with_kerberos5"
332 then
333     for dir in /usr/kerberos /usr/kerberosIV /usr/athena
334     do
335       if test -f "$dir/include/kerberosIV/krb.h"
336       then
337         CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$dir/include"
338         LDEFLAGS="$LDEFLAGS -L$dir/lib"
339         LIBS="-lkrb4 -ldes425 $LIBS"
340         break
341       fi
342     done
343 elif test -n "$with_kerberos"
344 then
345     CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$with_kerberos/include"
346     LDEFLAGS="$LDEFLAGS -L$with_kerberos/lib"
347     LIBS="$LIBS -lkrb -ldes"
348 else
349     for dir in /usr/kerberos /usr/kerberosIV /usr/athena
350     do
351       if test -f "$dir/include/krb.h"
352       then
353         CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$dir/include"
354         LDEFLAGS="$LDEFLAGS -L$dir/lib"
355         LIBS="$LIBS -lkrb -ldes"
356         break
357       fi
358     done
359 fi
360
361 ###     use option --with-socks=DIR to point at SOCKS library
362 AC_ARG_WITH(socks,
363         [  --with-socks[=DIR]      add built-in SOCKS firewall access],
364 [
365 if test "$with_socks" != no
366 then
367     if test "$with_socks" != yes
368     then
369         LDEFLAGS="$LDEFLAGS -L$with_socks"
370     else
371         AC_CHECK_LIB(socks, Rconnect,,
372                AC_MSG_ERROR([could not find libsocks which is needed for built-in SOCKS support]))
373     fi
374     AC_DEFINE(HAVE_SOCKS)
375     CEFLAGS="$CEFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect"
376     LIBS="-lsocks $LIBS"
377 fi])
378
379 ###     use option --with-hesiod=DIR to point at a HESIOD directory
380 AC_ARG_WITH(hesiod,
381         [  --with-hesiod=DIR       point fetchmail compilation at a HESIOD directory])
382
383 if test -n "$with_hesiod"
384 then
385     # Path given
386     CEFLAGS="$CEFLAGS -DHESIOD -I$with_hesiod/include"
387     LDEFLAGS="$LDEFLAGS -L$with_hesiod/lib"
388     LIBS="$LIBS -lhesiod"
389 else
390     for dir in /usr/athena /usr /usr/local
391     do
392       if test -f "$dir/include/hesiod.h"
393       then
394         CEFLAGS="$CEFLAGS -DHESIOD -I$dir/include"
395         LDEFLAGS="$LDEFLAGS -L$dir/lib"
396         LIBS="$LIBS -lhesiod"
397         with_hesiod=$dir
398         break
399       fi
400     done
401 fi
402
403 ###     use option --with-gssapi=DIR to compile in GSSAPI support
404 AC_ARG_WITH(gssapi,
405         [  --with-gssapi[=DIR]     compile in GSSAPI support using libraries in DIR],
406 [
407 if test "$with_gssapi" != "no"
408 then
409   if test "$with_gssapi" = "yes" -a -n "$with_kerberos5"
410   then
411     with_gssapi=$with_kerberos5
412   fi
413   if test "$with_gssapi" != "yes" -a -n "$with_gssapi"
414   then
415     CFLAGS="$CFLAGS -I$with_gssapi/include"
416     LDFLAGS="$LDFLAGS -L$with_gssapi/lib"
417   fi
418
419   AC_CHECK_LIB(krb5, krb5_init_context,,
420                AC_MSG_ERROR([could not find libkrb5 which is needed for GSSAPI support]))
421   AC_CHECK_LIB(gssapi_krb5, gss_init_sec_context,,
422                AC_MSG_ERROR([could not find libgssapi_krb5 which is needed for GSSAPI support]), -lkrb5)
423   AC_DEFINE(GSSAPI)
424   LIBS="$LIBS -lgssapi_krb5 -lkrb5"
425 fi])
426
427 AC_OUTPUT([Makefile intl/Makefile po/Makefile.in], [
428         # The reason for this odd makedepend line is that we want
429         # to have all dependencies evaluated relative to the source directory
430         # and let VPATH do all the dirty work when we build remotely
431         echo "You can ignore any makedepend error messages";
432         (cd $srcdir; makedepend -f - *.c) >>Makefile])
433
434 dnl Local Variables:
435 dnl comment-start: "dnl "
436 dnl comment-end: ""
437 dnl comment-start-skip: "\\bdnl\\b\\s *"
438 dnl compile-command: "make configure config.h.in"
439 dnl End: