]> Pileus Git - ~andy/fetchmail/blob - configure.in
16b81a11b3cce6b5b400687ece6235c15d5b4f54
[~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) 
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(getopt_long, AC_DEFINE(HAVE_GETOPTLONG),
64               [EXTRASRC="$EXTRASRC \$(srcdir)/getopt.c \$(srcdir)/getopt1.c"
65                EXTRAOBJ="$EXTRAOBJ getopt.o getopt1.o"])
66
67 AC_FUNC_VPRINTF
68 AC_FUNC_ALLOCA
69 if test -n "$ALLOCA" 
70 then
71   EXTRASRC="$EXTRASRC \$(srcdir)/alloca.c"
72   EXTRAOBJ="$EXTRAOBJ alloca.o"
73 fi
74
75 dnl All AC_CHECK_FUNCs must precede the following AC_SUBSTs
76
77 AC_SUBST(EXTRADEFS)
78 AC_SUBST(EXTRASRC)
79 AC_SUBST(EXTRAOBJ)
80
81 AC_CHECK_FUNCS(tcsetattr stty setsid seteuid gethostbyname res_search herror \
82   strrchr strerror setlinebuf syslog snprintf vsnprintf vsyslog atexit \
83   inet_aton)
84
85 # Under Red Hat 4.0 (and many other Linuxes) -lresolv is seriously flaky
86 # and breaks gethostbyname(2).  It's better to use the bind stuff in the C
87 # library.  So don't add -lresolv to the link list unless it's necessary
88 # (It will be necessary when using GNU libc6).
89 AC_CHECK_FUNC(res_search,
90     AC_MSG_RESULT(using libc's resolver functions),
91     AC_CHECK_LIB(resolv,res_search, 
92         [AC_DEFINE(HAVE_RES_SEARCH) AC_MSG_RESULT(found resolver functions in libresolv); LIBS="$LIBS -lresolv"], AC_MSG_RESULT(no resolver calls found)))
93
94 dnl AC_FUNC_SETVBUF_REVERSED
95
96 dnl Check for usable void pointer type
97 AC_MSG_CHECKING(use of void pointer type)
98 AC_TRY_COMPILE([],
99    [char *p;
100     void *xmalloc();
101     p = (char *) xmalloc(1);
102    ],
103  [AC_DEFINE(HAVE_VOIDPOINTER) AC_MSG_RESULT(yes)],
104  AC_MSG_RESULT(no))
105
106 dnl Check out the wait reality.  We have to assume sys/wait.h is present.
107 AC_CHECK_FUNCS(waitpid wait3)
108 AC_MSG_CHECKING(for union wait);
109 AC_TRY_LINK([#include <sys/types.h>
110 #include <sys/wait.h>],
111                  [union wait status; int pid; pid = wait (&status);
112 #ifdef WEXITSTATUS
113 /* Some POSIXoid systems have both the new-style macros and the old
114    union wait type, and they do not work together.  If union wait
115    conflicts with WEXITSTATUS et al, we don't want to use it at all.  */
116 if (WEXITSTATUS (status) != 0) pid = -1;
117 #endif
118 #ifdef HAVE_WAITPID
119 /* Make sure union wait works with waitpid.  */
120 pid = waitpid (-1, &status, 0);
121 #endif
122 ],
123   [AC_DEFINE(HAVE_UNION_WAIT) AC_MSG_RESULT(yes)],
124   AC_MSG_RESULT(no))
125
126 AC_MSG_CHECKING(sys_siglist declaration in signal.h or unistd.h)
127 AC_TRY_LINK([#include <signal.h>
128 /* NetBSD declares sys_siglist in <unistd.h>.  */
129 #ifdef HAVE_UNISTD_H
130 #include <unistd.h>
131 #endif], [char *msg = *(sys_siglist + 1);],
132   [AC_DEFINE(SYS_SIGLIST_DECLARED) AC_MSG_RESULT(yes)],
133   AC_MSG_RESULT(no))
134
135 # Find the right directory to put the root-mode PID file in
136 for dir in "/var/run" "/etc"
137 do
138         if test -d $dir 
139         then
140                 break;
141         fi
142 done
143 AC_MSG_RESULT(root-mode pid file will go in $dir)
144 AC_DEFINE_UNQUOTED(PID_DIR, "$dir")
145
146 AC_CHECK_SIZEOF(short)
147 AC_CHECK_SIZEOF(int)
148 AC_CHECK_SIZEOF(long)
149
150 ###     use option --enable-POP2 to compile in the POP2 support
151 AC_ARG_ENABLE(POP2,
152         [  --enable-POP2        compile in POP2 protocol support (obsolete)],
153         [with_POP2=$enableval],
154         [with_POP2=no])
155 test "$with_POP2" = "yes" && AC_DEFINE(POP2_ENABLE)
156
157 ###     use option --enable-RPA to compile in the RPA support
158 AC_ARG_ENABLE(RPA,
159         [  --enable-RPA         compile in RPA protocol support],
160         [with_RPA=$enableval],
161         [with_RPA=no])
162 test "$with_RPA" = "yes" && AC_DEFINE(RPA_ENABLE)
163
164 ###     use option --enable-OPIE to compile in the OPIE support
165 AC_ARG_ENABLE(opie,
166         [  --enable-OPIE        support OTP through the OPIE library],
167         [with_opie=$enableval],
168         [with_opie=no])
169 if test "$with_opie" = "yes";
170 then
171     AC_CHECK_HEADER(opie.h,, 
172         [echo 'configure: cannot find <opie.h>, which is required for OPIE support.'; exit 1])
173     AC_CHECK_LIB(opie,opiegenerator,, 
174         [echo 'configure: cannot find libopie, which is required for OPIE support.'; exit 1])
175     AC_DEFINE(OPIE,1)
176 fi
177
178 ###     use option --with-kerberos=DIR to point at a Kerberos directory
179 AC_ARG_WITH(kerberos,
180         [  --with-kerberos=DIR  point fetchmail compilation at a Kerberos directory])
181
182 # The "then" arm (nonempty $with_kerberos) is kind of a crock.  It works for
183 # configuring the BSD/OS Kerberos IV support, though. 
184 if test -n "$with_kerberos"
185 then
186     CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$with_kerberos"
187     LDEFLAGS="$LDEFLAGS -L$dir/lib"
188     LIBS="$LIBS -lkrb -ldes"
189 else
190     for dir in /usr/kerberos /usr/kerberosIV /usr/athena
191     do
192       if test -f "$dir/include/krb.h"
193       then
194         CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$dir/include"
195         LDEFLAGS="$LDEFLAGS -L$dir/lib"
196         LIBS="$LIBS -lkrb -ldes"
197         break
198       fi
199     done
200 fi
201
202 AC_OUTPUT(Makefile, [
203         # The reason for this odd makedepend line is that we want
204         # to have all dependencies evaluated relative to the source directory
205         # and let VPATH do all the dirty work when we build remotely
206         echo "You can ignore any makedepend error messages";
207         (cd $srcdir; makedepend -f - *.c) >>Makefile])
208
209 dnl Local Variables:
210 dnl comment-start: "dnl "
211 dnl comment-end: ""
212 dnl comment-start-skip: "\\bdnl\\b\\s *"
213 dnl compile-command: "make configure config.h.in"
214 dnl End: