]> Pileus Git - ~andy/fetchmail/blob - configure.in
Try to fix the build code.
[~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 # 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) 
27
28 AC_C_CONST                      dnl getopt needs this.
29
30 AC_PROG_LEX
31 AC_PROG_YACC
32 AC_SUBST(LIBOBJS)
33
34 AC_CHECK_LIB(nsl,inet_addr)
35 AC_CHECK_LIB(socket,socket)
36 AC_CHECK_LIB(inet,socket)
37 AC_CHECK_LIB(opie,opiegenerator)
38
39 AC_CHECK_FUNC(strstr, AC_DEFINE(HAVE_STRSTR), 
40               [EXTRASRC="$EXTRASRC \$(srcdir)/strstr.c"
41                EXTRAOBJ="$EXTRAOBJ strstr.o"])
42
43 AC_CHECK_FUNC(strcasecmp, AC_DEFINE(HAVE_STRCASECMP), 
44               [EXTRASRC="$EXTRASRC \$(srcdir)/strcasecmp.c"
45                EXTRAOBJ="$EXTRAOBJ strcasecmp.o"])
46              
47 AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPTLONG),
48               [EXTRASRC="$EXTRASRC \$(srcdir)/getopt.c \$(srcdir)/getopt1.c"
49                EXTRAOBJ="$EXTRAOBJ getopt.o getopt1.o"])
50
51 AC_FUNC_VPRINTF
52 AC_FUNC_ALLOCA
53 if test -n "$ALLOCA" 
54 then
55   EXTRASRC="$EXTRASRC \$(srcdir)/alloca.c"
56   EXTRAOBJ="$EXTRAOBJ alloca.o"
57 fi
58
59 dnl All AC_CHECK_FUNCs must precede the following AC_SUBSTs
60
61 AC_SUBST(EXTRASRC)
62 AC_SUBST(EXTRAOBJ)
63
64 AC_CHECK_FUNCS(tcsetattr stty setsid seteuid gethostbyname res_search herror \
65   strrchr strerror setlinebuf syslog snprintf vsnprintf vsyslog atexit)
66
67 # Under Red Hat 4.0 (and many other Linuxes) -lresolv is seriously flaky
68 # and breaks gethostbyname(2).  It's better to use the bind stuff in the C
69 # library.  So don't add -lresolv to the link list unless it's necessary
70 # (It will be necessary when using GNU libc6).
71 AC_CHECK_FUNC(res_search,
72     AC_MSG_RESULT(using libc's resolver functions),
73     AC_CHECK_LIB(resolv,res_search, 
74         [AC_DEFINE(HAVE_RES_SEARCH) AC_MSG_RESULT(found resolver functions in libresolv); LIBS="$LIBS -lresolv"], AC_MSG_RESULT(no resolver calls found)))
75
76 dnl AC_FUNC_SETVBUF_REVERSED
77
78 dnl Check for usable void pointer type
79 AC_MSG_CHECKING(use of void pointer type)
80 AC_TRY_COMPILE([],
81    [char *p;
82     void *xmalloc();
83     p = (char *) xmalloc(1);
84    ],
85  [AC_DEFINE(HAVE_VOIDPOINTER) AC_MSG_RESULT(yes)],
86  AC_MSG_RESULT(no))
87
88 dnl Check out the wait reality.  We have to assume sys/wait.h is present.
89 AC_CHECK_FUNCS(waitpid wait3)
90 AC_MSG_CHECKING(for union wait);
91 AC_TRY_LINK([#include <sys/types.h>
92 #include <sys/wait.h>],
93                  [union wait status; int pid; pid = wait (&status);
94 #ifdef WEXITSTATUS
95 /* Some POSIXoid systems have both the new-style macros and the old
96    union wait type, and they do not work together.  If union wait
97    conflicts with WEXITSTATUS et al, we don't want to use it at all.  */
98 if (WEXITSTATUS (status) != 0) pid = -1;
99 #endif
100 #ifdef HAVE_WAITPID
101 /* Make sure union wait works with waitpid.  */
102 pid = waitpid (-1, &status, 0);
103 #endif
104 ],
105   [AC_DEFINE(HAVE_UNION_WAIT) AC_MSG_RESULT(yes)],
106   AC_MSG_RESULT(no))
107
108 AC_MSG_CHECKING(sys_siglist declaration in signal.h or unistd.h)
109 AC_TRY_LINK([#include <signal.h>
110 /* NetBSD declares sys_siglist in <unistd.h>.  */
111 #ifdef HAVE_UNISTD_H
112 #include <unistd.h>
113 #endif], [char *msg = *(sys_siglist + 1);],
114   [AC_DEFINE(SYS_SIGLIST_DECLARED) AC_MSG_RESULT(yes)],
115   AC_MSG_RESULT(no))
116
117 AC_CHECK_SIZEOF(short)
118 AC_CHECK_SIZEOF(int)
119 AC_CHECK_SIZEOF(long)
120
121 ###     use option --enable-POP2 to compile in the POP2 fallback support
122 AC_ARG_ENABLE(POP2,
123         [  --enable-POP2        compile in POP2 protocol support (obsolete)],
124         [with_POP2=$enableval],
125         [with_POP2=no])
126 test "$with_POP2" = "yes" && AC_DEFINE(POP2_ENABLE)
127
128 ###     use option --with-kerberos=DIR to point at a Kerberos directory
129 AC_ARG_WITH(kerberos,
130         [  --with-kerberos=DIR  point fetchmail compilation at a Kerberos directory])
131
132 # The "then" arm (nonempty $with_kerberos) is kind of a crock.  It works for
133 # configuring the BSD/OS Kerberos IV support, though. 
134 if test -n "$with_kerberos"
135 then
136     CFLAGS="$CFLAGS -DKERBEROS_V4 -I$with_kerberos"
137     LDFLAGS="$LDFLAGS -L$dir/lib"
138     LIBS="$LIBS -lkrb -ldes"
139 else
140     for dir in /usr/kerberos /usr/kerberosIV /usr/athena
141     do
142       if test -f "$dir/include/krb.h"
143       then
144         CFLAGS="$CFLAGS -DKERBEROS_V4 -I$dir/include"
145         LDFLAGS="$LDFLAGS -L$dir/lib"
146         LIBS="$LIBS -lkrb -ldes"
147         break
148       fi
149     done
150 fi
151
152 AC_OUTPUT(Makefile, [
153         echo "You can ignore any makedepend error messages";
154         makedepend -I$srcdir -I. -fMakefile ${srcdir}/*.c])
155
156 dnl Local Variables:
157 dnl comment-start: "dnl "
158 dnl comment-end: ""
159 dnl comment-start-skip: "\\bdnl\\b\\s *"
160 dnl compile-command: "make configure config.h.in"
161 dnl End: