2 AC_PREFIX_PROGRAM(ftpd)
3 AC_CONFIG_HEADER(config.h)
7 dnl Set of libraries to use
15 AC_CHECK_FUNCS(snprintf vsnprintf)
18 dnl Check if we need -lsocket -- taken from wu-ftpd
20 AC_CHECK_LIB(socket,socket,result=yes,result=no)
21 if test "$result" = "yes"; then
24 AC_CHECK_LIB(socket,connect,result=yes,result=no)
25 if test "$result" = "yes"; then
31 dnl Check if we need -lcrypt
33 AC_CHECK_LIB(crypt,crypt,result=yes,result=no)
34 if test "$result" = "yes"; then
39 dnl The following weirdness is to support --disable as well as --enable
40 dnl (but long live m4!)
42 define(ARG_ENABLE_BETAFTPD,[
43 AC_MSG_CHECKING(whether to enable $1)
44 AC_ARG_ENABLE($1,[$2],result=yes,result=no)
45 if test "$result" = "no"; then
49 if test "$enableval" = "yes"; then
52 AC_MSG_RESULT($enableval)
58 ARG_ENABLE_BETAFTPD(xferlog,[ --enable-xferlog Enable transfer log support],AC_DEFINE(WANT_XFERLOG))
59 ARG_ENABLE_BETAFTPD(ascii,[ --enable-ascii Enable ASCII mode support],AC_DEFINE(WANT_ASCII))
60 ARG_ENABLE_BETAFTPD(fullscreen,[ --enable-fullscreen Run in fullscreen mode (implies --disable-fork)],AC_DEFINE(WANT_FULLSCREEN))
62 if test "$enableval" = "no"; then
63 ARG_ENABLE_BETAFTPD(fork,[ --enable-fork Make the server fork into the background],AC_DEFINE(WANT_FORK))
66 ARG_ENABLE_BETAFTPD(upload,[ --enable-upload Enable upload support],AC_DEFINE(WANT_UPLOAD))
67 ARG_ENABLE_BETAFTPD(stat,[ --enable-stat Enable STAT command (see README first)],AC_DEFINE(WANT_STAT))
68 ARG_ENABLE_BETAFTPD(dcache,[ --enable-dcache Enable directory listing cache],AC_DEFINE(WANT_DCACHE))
69 ARG_ENABLE_BETAFTPD(message,[ --enable-message Enable .message files etc.],AC_DEFINE(WANT_MESSAGE))
72 dnl The following line _must_ be last...
74 ARG_ENABLE_BETAFTPD(shadow,[ --enable-shadow Enable shadow password support],AC_DEFINE(WANT_SHADOW))
78 if test "$enableval" = "yes"; then
79 AC_CHECK_HEADERS(shadow.h)
82 dnl Causes unknown trouble on SunOS, so it's disabled
83 dnl if test -e "/etc/shadow"; then
85 dnl AC_MSG_WARN([It looks like you're using shadow passwords, consider])
86 dnl AC_MSG_WARN([giving the --enable-shadow flag to configure. Proceeding])
87 dnl AC_MSG_WARN([_without_ support for shadow passwords -- you might not])
88 dnl AC_MSG_WARN([be able to log in!])
94 if test "$nonroot_support" = "yes"; then
95 ARG_ENABLE_BETAFTPD(nonroot,[ --enable-nonroot Do not need root access (EXPERIMENTAL)],AC_DEFINE(WANT_NONROOT))
100 if test "$enableval" = "yes"; then
102 AC_MSG_WARN([Please read the README.nonroot file before using --enable-nonroot])
107 dnl Try to find our effective userid (use our own C program?)
109 AC_MSG_CHECKING(how to get effective uid)
110 if test -n "$EUID"; then
112 AC_MSG_RESULT([\$EUID ($EUID)])
113 elif test -n "$euid"; then
115 AC_MSG_RESULT([\$euid ($euid)])
116 elif test -n "$UID"; then
118 AC_MSG_RESULT([\$UID ($UID)])
119 elif test -n "$uid"; then
121 AC_MSG_RESULT([\$uid ($uid)])
122 elif test "`whoami 2>/dev/null`" = "root"; then
124 AC_MSG_RESULT([whoami (root)])
126 # assume we're not root
128 AC_MSG_RESULT(not found, assuming not root)
131 if test "$B_UID" -ne 0; then
133 AC_MSG_WARN([You do not seem to have root privilegies. If you])
134 AC_MSG_WARN([want to run BetaFTPD without being root, please])
135 AC_MSG_WARN([consider giving the --enable-nonroot flag to])
136 AC_MSG_WARN([configure, and read the README.nonroot file.])
141 AC_CHECK_TYPE(uid_t,int)
142 AC_CHECK_TYPE(gid_t,int)
144 AC_CHECK_HEADERS(crypt.h unistd.h time.h sys/time.h errno.h netinet/in.h)
145 AC_CHECK_HEADERS(netinet/ip.h stropts.h sys/conf.h arpa/inet.h sys/filio.h)
146 AC_CHECK_HEADERS(netinet/tcp.h sys/types.h netdb.h glob.h stdio.h)
147 AC_CHECK_HEADERS(stdlib.h stdarg.h stdlib.h string.h strings.h fcntl.h)
148 AC_CHECK_HEADERS(sys/ioctl.h sys/socket.h sys/stat.h sys/param.h signal.h)
149 AC_CHECK_HEADERS(sys/signal.h dirent.h pwd.h grp.h netinet/in_systm.h)
150 AC_CHECK_HEADERS(assert.h)
152 AC_CHECK_HEADER(netinet/tcp.h,result=yes,result=no)
155 dnl linux/socket.h can create some problems on Debian GNU/Linux systems
158 if test "$result" = "yes"; then
159 AC_MSG_CHECKING(if netinet/tcp.h is enough)
161 [#include <netinet/tcp.h>
165 ], result=no, result=yes)
166 AC_MSG_RESULT($result)
169 if test "$result" = "no"; then
170 AC_CHECK_HEADERS(linux/socket.h linux/tcp.h)
173 AC_CHECK_HEADERS(sys/poll.h)
175 AC_MSG_CHECKING([for poll()])
178 #include <sys/poll.h>
181 struct pollfd fds[1];
183 fds[0].events = POLLIN | POLLOUT | POLLERR | POLLHUP | POLLNVAL;
186 ],enableval=yes,enableval=no)
187 AC_MSG_RESULT($enableval)
189 if test "$enableval" = "yes"; then
190 AC_DEFINE(HAVE_POLL, 1, [Define if you have poll().])
194 dnl sendfile() is not standard -- we'll have to check the different
195 dnl versions one by one :-)
197 dnl Unfortunately, we'll have to run the program too -- this is a
198 dnl problem with newer libc's and not-so-new kernels :-)
200 AC_CHECK_HEADERS(sys/sendfile.h,result=yes,result=no)
202 if test "$result" = "yes"; then
203 AC_MSG_CHECKING([for Linux sendfile()])
205 #if HAVE_SYS_SOCKET_H
206 #include <sys/socket.h>
209 #if HAVE_SYS_LIMITS_H
210 #include <sys/limits.h>
217 #if HAVE_SYS_SENDFILE_H
218 #include <sys/sendfile.h>
222 #include <sys/types.h>
233 int out_fd = 1, in_fd = 0;
237 sendfile(out_fd, in_fd, &offset, size);
238 ],enableval=yes,enableval=no)
239 AC_MSG_RESULT($enableval)
241 if test "$enableval" = "yes"; then
243 dnl If the compile fails now, we assume sendfile() exists (since this
244 dnl is by far the most common case)
246 AC_MSG_CHECKING([that sendfile() really is implemented])
249 #if HAVE_SYS_SOCKET_H
250 #include <sys/socket.h>
253 #if HAVE_SYS_LIMITS_H
254 #include <sys/limits.h>
261 #if HAVE_SYS_SENDFILE_H
262 #include <sys/sendfile.h>
266 #include <sys/types.h>
278 int out_fd = 1, in_fd = 0;
283 sendfile(out_fd, in_fd, &offset, size);
289 enableval=no,enableval=yes,[enableval="cross-compiling, not checked"])
290 AC_MSG_RESULT($enableval)
292 has_sendfile=$enableval
295 dnl Force sendfile() `state' if the user tells us to
297 AC_ARG_WITH(linux-sendfile,[ --with-linux-sendfile Force sendfile() support],has_sendfile=$withval)
299 if test $has_sendfile != "no"; then
300 AC_DEFINE(HAVE_LINUX_SENDFILE, 1, [Define if you have sendfile() with the Linux semantics.])
303 has_sendfile=disabled
305 AC_MSG_CHECKING([final status of Linux sendfile() support])
306 AC_MSG_RESULT($has_sendfile)
310 AC_CHECK_HEADER(sys/uio.h,result=yes,result=no)
311 if test "$result" = "yes"; then
312 AC_MSG_CHECKING([for BSD sendfile()])
314 #if HAVE_SYS_LIMITS_H
315 #include <sys/limits.h>
322 #if HAVE_SYS_SENDFILE_H
323 #include <sys/sendfile.h>
327 #include <sys/types.h>
330 #if HAVE_SYS_SOCKET_H
331 #include <sys/socket.h>
338 int in_fd = 0, out_sock = 3;
346 sendfile(in_fd, out_sock, offset, size, &hdtr, &offset, 0);
347 ],enableval=yes,enableval=no)
348 AC_MSG_RESULT($enableval)
350 if test "$enableval" = "yes"; then
351 AC_DEFINE(HAVE_BSD_SENDFILE, 1, [Define if you have sendfile() with the BSD semantics.])