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_HEADER(linux/socket.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 AC_CHECK_HEADERS(sys/sendfile.h,result=yes,result=no)
199 if test "$result" = "yes"; then
200 AC_MSG_CHECKING([for Linux sendfile()])
202 #if HAVE_SYS_SOCKET_H
203 #include <sys/socket.h>
206 #if HAVE_SYS_LIMITS_H
207 #include <sys/limits.h>
214 #if HAVE_SYS_SENDFILE_H
215 #include <sys/sendfile.h>
219 #include <sys/types.h>
225 int out_fd = 1, in_fd = 0;
229 sendfile(out_fd, in_fd, &offset, size);
230 ],enableval=yes,enableval=no)
231 AC_MSG_RESULT($enableval)
233 if test "$enableval" = "yes"; then
234 AC_DEFINE(HAVE_LINUX_SENDFILE, 1, [Define if you have sendfile() with the Linux semantics.])
238 AC_CHECK_HEADER(sys/uio.h,result=yes,result=no)
239 if test "$result" = "yes"; then
240 AC_MSG_CHECKING([for BSD sendfile()])
242 #if HAVE_SYS_LIMITS_H
243 #include <sys/limits.h>
250 #if HAVE_SYS_SENDFILE_H
251 #include <sys/sendfile.h>
255 #include <sys/types.h>
258 #if HAVE_SYS_SOCKET_H
259 #include <sys/socket.h>
266 int in_fd = 0, out_sock = 3;
274 sendfile(in_fd, out_sock, offset, size, &hdtr, &offset, 0);
275 ],enableval=yes,enableval=no)
276 AC_MSG_RESULT($enableval)
278 if test "$enableval" = "yes"; then
279 AC_DEFINE(HAVE_BSD_SENDFILE, 1, [Define if you have sendfile() with the BSD semantics.])