aboutsummaryrefslogtreecommitdiffstats
path: root/configure.in
blob: 32f756b308d5dca577b9b86ffda7e7cabe91c36c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
dnl Autoconfigure input file for fetchmail
dnl Eric S. Raymond <esr@thyrsus.com>
dnl
dnl Process this file with autoconf to produce a configure script.
dnl

AC_INIT(fetchmail.h)		dnl A distinctive file to look for in srcdir. 
AC_CONFIG_HEADER(config.h)

dnl We want these before the checks, so the checks can modify their values.
test -z "$CFLAGS" && CFLAGS=-O AC_SUBST(CFLAGS)
test -z "$LDFLAGS" && LDFLAGS=-s AC_SUBST(LDFLAGS)

AC_CANONICAL_HOST
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_CPP			dnl Later checks need this.
AC_PROG_CC_C_O
AC_AIX
AC_ISC_POSIX
AC_MINIX
AC_HEADER_STDC
AC_TYPE_SIZE_T
AC_TYPE_PID_T
AC_TYPE_SIGNAL
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) 

AC_C_CONST			dnl getopt needs this.

AC_PROG_LEX
AC_PROG_YACC
AC_SUBST(CEFLAGS)
AC_SUBST(LDEFLAGS)
AC_SUBST(LIBOBJS)

# Under sysV68, socket and friends are provided by the C library.
# -linet does not provide socket, but causes multiple definition
# errors at link-time.  It is thus better to only use the C library.
# So don't add -linet to the link list unless it's necessary
AC_CHECK_FUNC(socket,
    AC_MSG_RESULT(using libc's socket),
    AC_CHECK_LIB(socket,socket)
    AC_CHECK_LIB(inet,socket))

# The condition in this test copes with the presence of inet_addr in libc6.
AC_CHECK_FUNC(inet_addr,
    AC_MSG_RESULT(using libc's inet_addr),
    AC_CHECK_LIB(nsl,inet_addr))

dnl Port hack for Interactive UNIX System V/386 Release 3.2
AC_CHECK_LIB(cposix, strchr,
		[EXTRADEFS="$EXTRADEFS -D_SYSV3"
		LIBS="$LIBS -lcposix"])

AC_CHECK_FUNC(strstr, AC_DEFINE(HAVE_STRSTR), 
              [EXTRASRC="$EXTRASRC \$(srcdir)/strstr.c"
               EXTRAOBJ="$EXTRAOBJ strstr.o"])

AC_CHECK_FUNC(strcasecmp, AC_DEFINE(HAVE_STRCASECMP), 
              [EXTRASRC="$EXTRASRC \$(srcdir)/strcasecmp.c"
               EXTRAOBJ="$EXTRAOBJ strcasecmp.o"])
             
AC_CHECK_FUNC(getopt_long, AC_DEFINE(HAVE_GETOPTLONG),
              [EXTRASRC="$EXTRASRC \$(srcdir)/getopt.c \$(srcdir)/getopt1.c"
               EXTRAOBJ="$EXTRAOBJ getopt.o getopt1.o"])

AC_FUNC_VPRINTF
AC_FUNC_ALLOCA
if test -n "$ALLOCA" 
then
  EXTRASRC="$EXTRASRC \$(srcdir)/alloca.c"
  EXTRAOBJ="$EXTRAOBJ alloca.o"
fi

dnl All AC_CHECK_FUNCs must precede the following AC_SUBSTs

AC_SUBST(EXTRADEFS)
AC_SUBST(EXTRASRC)
AC_SUBST(EXTRAOBJ)

AC_CHECK_FUNCS(tcsetattr stty setsid seteuid gethostbyname res_search herror \
  strrchr strerror setlinebuf syslog snprintf vsnprintf vsyslog atexit \
  inet_aton)

# Under Red Hat 4.0 (and many other Linuxes) -lresolv is seriously flaky
# and breaks gethostbyname(2).  It's better to use the bind stuff in the C
# library.  So don't add -lresolv to the link list unless it's necessary
# (It will be necessary when using GNU libc6).
AC_CHECK_FUNC(res_search,
    AC_MSG_RESULT(using libc's resolver functions),
    AC_CHECK_LIB(resolv,res_search, 
	[AC_DEFINE(HAVE_RES_SEARCH) AC_MSG_RESULT(found resolver functions in libresolv); LIBS="$LIBS -lresolv"], AC_MSG_RESULT(no resolver calls found)))

dnl AC_FUNC_SETVBUF_REVERSED

dnl Check for usable void pointer type
AC_MSG_CHECKING(use of void pointer type)
AC_TRY_COMPILE([],
   [char *p;
    void *xmalloc();
    p = (char *) xmalloc(1);
   ],
 [AC_DEFINE(HAVE_VOIDPOINTER) AC_MSG_RESULT(yes)],
 AC_MSG_RESULT(no))

dnl Check out the wait reality.  We have to assume sys/wait.h is present.
AC_CHECK_FUNCS(waitpid wait3)
AC_MSG_CHECKING(for union wait);
AC_TRY_LINK([#include <sys/types.h>
#include <sys/wait.h>],
	 	 [union wait status; int pid; pid = wait (&status);
#ifdef WEXITSTATUS
/* Some POSIXoid systems have both the new-style macros and the old
   union wait type, and they do not work together.  If union wait
   conflicts with WEXITSTATUS et al, we don't want to use it at all.  */
if (WEXITSTATUS (status) != 0) pid = -1;
#endif
#ifdef HAVE_WAITPID
/* Make sure union wait works with waitpid.  */
pid = waitpid (-1, &status, 0);
#endif
],
  [AC_DEFINE(HAVE_UNION_WAIT) AC_MSG_RESULT(yes)],
  AC_MSG_RESULT(no))

AC_MSG_CHECKING(sys_siglist declaration in signal.h or unistd.h)
AC_TRY_LINK([#include <signal.h>
/* NetBSD declares sys_siglist in <unistd.h>.  */
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif], [char *msg = *(sys_siglist + 1);],
  [AC_DEFINE(SYS_SIGLIST_DECLARED) AC_MSG_RESULT(yes)],
  AC_MSG_RESULT(no))

# Find the right directory to put the root-mode PID file in
for dir in "/var/run" "/etc"
do
	if test -d $dir 
	then
		break;
	fi
done
AC_MSG_RESULT(root-mode pid file will go in $dir)
AC_DEFINE_UNQUOTED(PID_DIR, "$dir")

AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)

###	use option --enable-POP2 to compile in the POP2 support
AC_ARG_ENABLE(POP2,
	[  --enable-POP2        compile in POP2 protocol support (obsolete)],
	[with_POP2=$enableval],
	[with_POP2=no])
test "$with_POP2" = "yes" && AC_DEFINE(POP2_ENABLE)

###	use option --disable-POP3 to omit the POP3 support
AC_ARG_ENABLE(POP3,
	[  --disable-POP3       don't compile in POP3 protocol support],
	[with_POP3=$enableval],
	[with_POP3=yes])
test "$with_POP3" = "yes" && AC_DEFINE(POP3_ENABLE)

###	use option --disable-IMAP to omit the IMAP support
AC_ARG_ENABLE(IMAP,
	[  --disable-IMAP       don't compile in IMAP protocol support],
	[with_IMAP=$enableval],
	[with_IMAP=yes])
test "$with_IMAP" = "yes" && AC_DEFINE(IMAP_ENABLE)

###	use option --disable-ETRN to omit the ETRN support
AC_ARG_ENABLE(ETRN,
	[  --disable-ETRN       don't compile in ETRN protocol support],
	[with_ETRN=$enableval],
	[with_ETRN=yes])
test "$with_ETRN" = "yes" && AC_DEFINE(ETRN_ENABLE)

###	use option --enable-RPA to compile in the RPA support
AC_ARG_ENABLE(RPA,
	[  --enable-RPA         compile in RPA protocol support],
	[with_RPA=$enableval],
	[with_RPA=no])
test "$with_RPA" = "yes" && AC_DEFINE(RPA_ENABLE)

###	use option --enable-OPIE to compile in the OPIE support
AC_ARG_ENABLE(opie,
	[  --enable-OPIE        support OTP through the OPIE library],
	[with_opie=$enableval],
	[with_opie=no])
if test "$with_opie" = "yes";
then
    AC_CHECK_HEADER(opie.h,, 
	[echo 'configure: cannot find <opie.h>, which is required for OPIE support.'; exit 1])
    AC_CHECK_LIB(opie,opiegenerator,, 
	[echo 'configure: cannot find libopie, which is required for OPIE support.'; exit 1])
    AC_DEFINE(OPIE,1)
fi

###	use option --with-kerberos=DIR to point at a Kerberos directory
AC_ARG_WITH(kerberos,
	[  --with-kerberos=DIR  point fetchmail compilation at a Kerberos directory])

# The "then" arm (nonempty $with_kerberos) is kind of a crock.  It works for
# configuring the BSD/OS Kerberos IV support, though. 
if test -n "$with_kerberos"
then
    CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$with_kerberos"
    LDEFLAGS="$LDEFLAGS -L$dir/lib"
    LIBS="$LIBS -lkrb -ldes"
else
    for dir in /usr/kerberos /usr/kerberosIV /usr/athena
    do
      if test -f "$dir/include/krb.h"
      then
        CEFLAGS="$CEFLAGS -DKERBEROS_V4 -I$dir/include"
        LDEFLAGS="$LDEFLAGS -L$dir/lib"
        LIBS="$LIBS -lkrb -ldes"
        break
      fi
    done
fi

AC_OUTPUT(Makefile, [
	# The reason for this odd makedepend line is that we want
	# to have all dependencies evaluated relative to the source directory
	# and let VPATH do all the dirty work when we build remotely
	echo "You can ignore any makedepend error messages";
	(cd $srcdir; makedepend -f - *.c) >>Makefile])

dnl Local Variables:
dnl comment-start: "dnl "
dnl comment-end: ""
dnl comment-start-skip: "\\bdnl\\b\\s *"
dnl compile-command: "make configure config.h.in"
dnl End: