]> Pileus Git - ~andy/fetchmail/blob - configure.in
Added URL.
[~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 -pipe" 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(CEFLAGS)
33 AC_SUBST(LDEFLAGS)
34 AC_SUBST(LIBOBJS)
35
36 # Under sysV68, socket and friends are provided by the C library.
37 # -linet does not provide socket, but causes multiple definition
38 # errors at link-time.  It is thus better to only use the C library.
39 # So don't add -linet to the link list unless it's necessary
40 AC_CHECK_FUNC(socket,
41     AC_MSG_RESULT(using libc's socket),
42     AC_CHECK_LIB(socket,socket)
43     AC_CHECK_LIB(inet,socket))
44
45 # The condition in this test copes with the presence of inet_addr in libc6.
46 AC_CHECK_FUNC(inet_addr,
47     AC_MSG_RESULT(using libc's inet_addr),
48     AC_CHECK_LIB(nsl,inet_addr))
49
50 dnl Port hack for Interactive UNIX System V/386 Release 3.2
51 AC_CHECK_LIB(cposix, strchr,
52                 [EXTRADEFS="$EXTRADEFS -D_SYSV3"
53                 LIBS="$LIBS -lcposix"])
54
55 AC_CHECK_FUNC(strstr, AC_DEFINE(HAVE_STRSTR), 
56               [EXTRASRC="$EXTRASRC \$(srcdir)/strstr.c"
57                EXTRAOBJ="$EXTRAOBJ strstr.o"])
58
59 AC_CHECK_FUNC(strcasecmp, AC_DEFINE(HAVE_STRCASECMP), 
60               [EXTRASRC="$EXTRASRC \$(srcdir)/strcasecmp.c"
61                EXTRAOBJ="$EXTRAOBJ strcasecmp.o"])
62              
63 AC_CHECK_FUNC(memmove, AC_DEFINE(HAVE_MEMMOVE), 
64               [EXTRASRC="$EXTRASRC \$(srcdir)/memmove.c"
65                EXTRAOBJ="$EXTRAOBJ memmove.o"])
66              
67 AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPTLONG),
68               [EXTRASRC="$EXTRASRC \$(srcdir)/getopt.c \$(srcdir)/getopt1.c"
69                EXTRAOBJ="$EXTRAOBJ getopt.o getopt1.o"])
70
71 AC_FUNC_VPRINTF
72 AC_FUNC_ALLOCA
73 if test -n "$ALLOCA" 
74 then
75   EXTRASRC="$EXTRASRC \$(srcdir)/alloca.c"
76   EXTRAOBJ="$EXTRAOBJ alloca.o"
77 fi
78
79 dnl AC_CHECK_FUNC calls that might hack the Makefile must precede
80 dnl the following AC_SUBSTs
81
82 AC_SUBST(EXTRADEFS)
83 AC_SUBST(EXTRASRC)
84 AC_SUBST(EXTRAOBJ)
85
86 AC_CHECK_FUNCS(tcsetattr stty setsid seteuid gethostbyname res_search herror \
87   strrchr strerror setlinebuf syslog snprintf vprintf vsnprintf vsyslog \
88   atexit inet_aton strftime setrlimit)
89
90 # Under Red Hat 4.0 (and many other Linuxes) -lresolv is seriously flaky
91 # and breaks gethostbyname(2).  It's better to use the bind stuff in the C
92 # library.  So don't add -lresolv to the link list unless it's necessary
93 # (It will be necessary when using GNU libc6).
94 AC_CHECK_FUNC(res_search,
95     AC_MSG_RESULT(using libc's resolver functions),
96     AC_CHECK_LIB(resolv,res_search, 
97         [AC_DEFINE(HAVE_RES_SEARCH) AC_MSG_RESULT(found resolver functions in libresolv); LIBS="$LIBS -lresolv"], AC_MSG_RESULT(no resolver calls found)))
98
99 dnl AC_FUNC_SETVBUF_REVERSED
100
101 dnl Check for usable void pointer type
102 AC_MSG_CHECKING(use of void pointer type)
103 AC_TRY_COMPILE([],
104    [char *p;
105     void *xmalloc();
106     p = (char *) xmalloc(1);
107    ],
108  [AC_DEFINE(HAVE_VOIDPOINTER) AC_MSG_RESULT(yes)],
109  AC_MSG_RESULT(no))
110
111 dnl Check out the wait reality.  We have to assume sys/wait.h is present.
112 AC_CHECK_FUNCS(waitpid wait3)
113 AC_MSG_CHECKING(for union wait);
114 AC_TRY_LINK([#include <sys/types.h>
115 #include <sys/wait.h>],
116                  [union wait status; int pid; pid = wait (&status);
117 #ifdef WEXITSTATUS
118 /* Some POSIXoid systems have both the new-style macros and the old
119    union wait type, and they do not work together.  If union wait
120    conflicts with WEXITSTATUS et al, we don't want to use it at all.  */
121 if (WEXITSTATUS (status) != 0) pid = -1;
122 #endif
123 #ifdef HAVE_WAITPID
124 /* Make sure union wait works with waitpid.  */
125 pid = waitpid (-1, &status, 0);
126 #endif
127 ],
128   [AC_DEFINE(HAVE_UNION_WAIT) AC_MSG_RESULT(yes)],
129   AC_MSG_RESULT(no))
130
131 AC_MSG_CHECKING(sys_siglist declaration in signal.h or unistd.h)
132 AC_TRY_LINK([#include <signal.h>
133 /* NetBSD declares sys_siglist in <unistd.h>.  */
134 #ifdef HAVE_UNISTD_H
135 #include <unistd.h>
136 #endif], [char *msg = *(sys_siglist + 1);],
137   [AC_DEFINE(SYS_SIGLIST_DECLARED) AC_MSG_RESULT(yes)],
138   AC_MSG_RESULT(no))
139
140 # Find the right directory to put the root-mode PID file in
141 for dir in "/var/run" "/etc"
142 do
143         if test -d $dir 
144         then
145                 break;
146         fi
147 done
148 AC_MSG_RESULT(root-mode pid file will go in $dir)
149 AC_DEFINE_UNQUOTED(PID_DIR, "$dir")
150
151 AC_CHECK_SIZEOF(short)
152 AC_CHECK_SIZEOF(int)
153 AC_CHECK_SIZEOF(long)
154
155 ###     use option --enable-POP2 to compile in the POP2 support
156 AC_ARG_ENABLE(POP2,
157         [  --enable-POP2        compile in POP2 protocol support (obsolete)],
158         [with_POP2=$enableval],
159         [with_POP2=no])
160 test "$with_POP2" = "yes" && AC_DEFINE(POP2_ENABLE)
161
162 ###     use option --disable-POP3 to omit the POP3 support
163 AC_ARG_ENABLE(POP3,
164         [  --disable-POP3       don't compile in POP3 protocol support],
165         [with_POP3=$enableval],
166         [with_POP3=yes])
167 test "$with_POP3" = "yes" && AC_DEFINE(POP3_ENABLE)
168
169 ###     use option --disable-IMAP to omit the IMAP support
170 AC_ARG_ENABLE(IMAP,
171         [  --disable-IMAP       don't compile in IMAP protocol support],
172         [with_IMAP=$enableval],
173         [with_IMAP=yes])
174 test "$with_IMAP" = "yes" && AC_DEFINE(IMAP_ENABLE)
175
176 ###     use option --disable-ETRN to omit the ETRN support
177 AC_ARG_ENABLE(ETRN,
178         [  --disable-ETRN       don't compile in ETRN protocol support],
179         [with_ETRN=$enableval],
180         [with_ETRN=yes])
181 test "$with_ETRN" = "yes" && AC_DEFINE(ETRN_ENABLE)
182
183 ###     use option --enable-RPA to compile in the RPA support
184 AC_ARG_ENABLE(RPA,
185         [  --enable-RPA         compile in RPA protocol support],
186         [with_RPA=$enableval],
187         [with_RPA=no])
188 test "$with_RPA" = "yes" && AC_DEFINE(RPA_ENABLE)
189
190 ###     use option --enable-SDPS to compile in the SDPS support
191 AC_ARG_ENABLE(SDPS,
192         [  --enable-SDPS        compile in SDPS protocol support],
193         [with_SDPS=$enableval],
194         [with_SDPS=no])
195 test "$with_SDPS" = "yes" && AC_DEFINE(SDPS_ENABLE)
196
197 ###     use option --enable-opie to compile in the OPIE support
198 AC_ARG_ENABLE(opie,
199         [  --enable-opie        support OTP through the OPIE library],
200         [ AC_CHECK_HEADER(opie.h,, [echo 'configure: cannot find <opie.h>, which is required for OPIE support.'; exit 1])
201           AC_CHECK_LIB(opie,opiegenerator,, [echo 'configure: cannot find libopie, which is required for OPIE support.'; exit 1])
202           AC_DEFINE(OPIE,1) ],
203         [with_opie=no])
204
205 AC_ARG_ENABLE(inet6,
206         [  --enable-inet6       support IPv6 (requires the inet6-apps library)],
207         [ unset ac_cv_lib_inet6_getaddrinfo; AC_CHECK_LIB(inet6, getaddrinfo,,
208         [ unset ac_cv_lib_inet6_getaddrinfo; LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; AC_CHECK_LIB(inet6, getaddrinfo,,
209         [ echo 'configure: cannot find libinet6, which is required for IPv6 support.'; exit 1]) ])
210           AC_DEFINE(INET6, 1) ])
211
212 AC_ARG_ENABLE(netsec,
213         [  --enable-netsec      support network security (requires inet6-apps library)],
214         [ unset ac_cv_lib_inet6_net_security_strtorequest; AC_CHECK_LIB(inet6, net_security_strtorequest,,
215         [ unset ac_cv_lib_inet6_net_security_strtorequest; LDFLAGS="$LDFLAGS -L/usr/inet6/lib"; AC_CHECK_LIB(inet6, net_security_strtorequest,,
216         [ echo 'configure: cannot find net_security_strtorequest in libinet6, which is required';
217           echo '           for network security support. Either it does not exist, or it was';
218           echo '           not built with network security support enabled.';
219           exit 1]) ])
220           unset ac_cv_header_net_security_h; AC_CHECK_HEADER(net/security.h,,
221         [ 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,,
222         [ echo 'configure: cannot find <net/security.h>, which is required for network security';
223           echo '           support.';
224           exit 1]) ])
225           AC_DEFINE(NET_SECURITY, 1) ])
226   
227 ###     use option --with-gssapi=DIR to compile in GSSAPI support
228 AC_ARG_WITH(gssapi,
229         [  --with-gssapi[=DIR]  compile in GSSAPI support using libraries in DIR],
230 [
231 if test "$with_gssapi" != "no"
232 then
233   if test "$with_gssapi" != "yes" -a -n "$with_gssapi"
234   then
235     CFLAGS="$CFLAGS -I$with_gssapi/include"
236     LDFLAGS="$LDFLAGS -L$with_gssapi/lib"
237   fi
238   AC_CHECK_LIB(krb5, krb5_init_context,,
239                AC_MSG_ERROR([could not find libkrb5 which is needed for GSSAPI support]))
240   AC_CHECK_LIB(gssapi_krb5, gss_init_sec_context,,
241                AC_MSG_ERROR([could not find libgssapi_krb5 which is needed for GSSAPI support]), -lkrb5)
242   AC_DEFINE(GSSAPI)
243   LIBS="$LIBS -lgssapi_krb5 -lkrb5"
244 fi])
245
246 ###     use option --with-kerberos=DIR to point at a Kerberos directory
247 AC_ARG_WITH(kerberos,
248         [  --with-kerberos=DIR  point fetchmail compilation at a Kerberos directory])
249
250 # The "elif" arm (nonempty $with_kerberos) is kind of a crock.  It works for
251 # configuring the BSD/OS Kerberos IV support, though. 
252
253 # Check for a NetBSD special case
254 if test "$with_kerberos" = "yes" -a `uname` = "NetBSD" 
255 then
256   echo "Configuring kerberosIV for NetBSD"
257   CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I/usr/include/kerberosIV"
258   LIBS="$LIBS -lkrb -ldes"
259 elif test -n "$with_kerberos"
260 then
261     CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$with_kerberos/include"
262     LDEFLAGS="$LDEFLAGS -L$with_kerberos/lib"
263     LIBS="$LIBS -lkrb -ldes"
264 else
265     for dir in /usr/kerberos /usr/kerberosIV /usr/athena
266     do
267       if test -f "$dir/include/krb.h"
268       then
269         CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$dir/include"
270         LDEFLAGS="$LDEFLAGS -L$dir/lib"
271         LIBS="$LIBS -lkrb -ldes"
272         break
273       fi
274     done
275 fi
276
277 ###     use option --with-kerberos5=DIR to point at a Kerberos 5 directory
278 AC_ARG_WITH(kerberos5,
279         [  --with-kerberos5=DIR  point fetchmail compilation at a Kerberos 5 directory])
280
281 # The "then" arm (nonempty $with_kerberos5) is kind of a crock.  It works for
282 # configuring the BSD/OS Kerberos IV support, though. 
283 if test -n "$with_kerberos5"
284 then
285     # Path given
286     CEFLAGS="$CEFLAGS -DKERBEROS_V5 -I$with_kerberos5/include"
287     LDEFLAGS="$LDEFLAGS -L$with_kerberos5/lib"
288     LIBS="$LIBS -lkrb5 -lcrypto -lcom_err"
289 else
290     for dir in /usr/kerberos /usr/local/krb5 /usr/athena
291     do
292       if test -f "$dir/include/krb5.h"
293       then
294         CEFLAGS="$CEFLAGS -DKERBEROS_V5 -I$dir/include"
295         LDEFLAGS="$LDEFLAGS -L$dir/lib"
296         LIBS="$LIBS -lkrb5 -lcrypto -lcom_err"
297         break
298       fi
299     done
300 fi
301
302 AC_OUTPUT(Makefile, [
303         # The reason for this odd makedepend line is that we want
304         # to have all dependencies evaluated relative to the source directory
305         # and let VPATH do all the dirty work when we build remotely
306         echo "You can ignore any makedepend error messages";
307         (cd $srcdir; makedepend -f - *.c) >>Makefile])
308
309 dnl Local Variables:
310 dnl comment-start: "dnl "
311 dnl comment-end: ""
312 dnl comment-start-skip: "\\bdnl\\b\\s *"
313 dnl compile-command: "make configure config.h.in"
314 dnl End: