AC_INIT(cmds.c) AC_PREFIX_PROGRAM(ftpd) AC_CONFIG_HEADER(config.h) AC_PROG_CC dnl dnl Set of libraries to use dnl LIBS="" AC_SUBST(LIBS) AC_C_CONST AC_FUNC_MMAP AC_TYPE_SIGNAL AC_CHECK_FUNCS(snprintf vsnprintf) dnl dnl Check if we need -lsocket -- taken from wu-ftpd dnl AC_CHECK_LIB(socket,socket,result=yes,result=no) if test "$result" = "yes"; then LIBS="$LIBS -lsocket" else AC_CHECK_LIB(socket,connect,result=yes,result=no) if test "$result" = "yes"; then LIBS="$LIBS -lsocket" fi fi dnl dnl Check if we need -lcrypt dnl AC_CHECK_LIB(crypt,crypt,result=yes,result=no) if test "$result" = "yes"; then LIBS="$LIBS -lcrypt" fi dnl dnl The following weirdness is to support --disable as well as --enable dnl (but long live m4!) dnl define(ARG_ENABLE_BETAFTPD,[ AC_MSG_CHECKING(whether to enable $1) AC_ARG_ENABLE($1,[$2],result=yes,result=no) if test "$result" = "no"; then enableval=no fi if test "$enableval" = "yes"; then $3 fi AC_MSG_RESULT($enableval) ]) dnl dnl Check for options dnl ARG_ENABLE_BETAFTPD(xferlog,[ --enable-xferlog Enable transfer log support],AC_DEFINE(WANT_XFERLOG)) ARG_ENABLE_BETAFTPD(ascii,[ --enable-ascii Enable ASCII mode support],AC_DEFINE(WANT_ASCII)) ARG_ENABLE_BETAFTPD(fullscreen,[ --enable-fullscreen Run in fullscreen mode (implies --disable-fork)],AC_DEFINE(WANT_FULLSCREEN)) if test "$enableval" = "no"; then ARG_ENABLE_BETAFTPD(fork,[ --enable-fork Make the server fork into the background],AC_DEFINE(WANT_FORK)) fi ARG_ENABLE_BETAFTPD(upload,[ --enable-upload Enable upload support],AC_DEFINE(WANT_UPLOAD)) ARG_ENABLE_BETAFTPD(stat,[ --enable-stat Enable STAT command (see README first)],AC_DEFINE(WANT_STAT)) ARG_ENABLE_BETAFTPD(dcache,[ --enable-dcache Enable directory listing cache],AC_DEFINE(WANT_DCACHE)) ARG_ENABLE_BETAFTPD(message,[ --enable-message Enable .message files etc.],AC_DEFINE(WANT_MESSAGE)) dnl dnl The following line _must_ be last... dnl ARG_ENABLE_BETAFTPD(shadow,[ --enable-shadow Enable shadow password support],AC_DEFINE(WANT_SHADOW)) nonroot_support=yes if test "$enableval" = "yes"; then AC_CHECK_HEADERS(shadow.h) nonroot_support=no else dnl Causes unknown trouble on SunOS, so it's disabled dnl if test -e "/etc/shadow"; then dnl AC_MSG_WARN() dnl AC_MSG_WARN([It looks like you're using shadow passwords, consider]) dnl AC_MSG_WARN([giving the --enable-shadow flag to configure. Proceeding]) dnl AC_MSG_WARN([_without_ support for shadow passwords -- you might not]) dnl AC_MSG_WARN([be able to log in!]) dnl AC_MSG_WARN() dnl fi echo fi if test "$nonroot_support" = "yes"; then ARG_ENABLE_BETAFTPD(nonroot,[ --enable-nonroot Do not need root access (EXPERIMENTAL)],AC_DEFINE(WANT_NONROOT)) else enableval=no fi if test "$enableval" = "yes"; then AC_MSG_WARN() AC_MSG_WARN([Please read the README.nonroot file before using --enable-nonroot]) AC_MSG_WARN() else dnl dnl Try to find our effective userid (use our own C program?) dnl AC_MSG_CHECKING(how to get effective uid) if test -n "$EUID"; then B_UID=$EUID AC_MSG_RESULT([\$EUID ($EUID)]) elif test -n "$euid"; then B_UID=$euid AC_MSG_RESULT([\$euid ($euid)]) elif test -n "$UID"; then B_UID=$UID AC_MSG_RESULT([\$UID ($UID)]) elif test -n "$uid"; then B_UID=$uid AC_MSG_RESULT([\$uid ($uid)]) elif test "`whoami 2>/dev/null`" = "root"; then B_UID=0 AC_MSG_RESULT([whoami (root)]) else # assume we're not root B_UID=1 AC_MSG_RESULT(not found, assuming not root) fi if test "$B_UID" -ne 0; then AC_MSG_WARN() AC_MSG_WARN([You do not seem to have root privilegies. If you]) AC_MSG_WARN([want to run BetaFTPD without being root, please]) AC_MSG_WARN([consider giving the --enable-nonroot flag to]) AC_MSG_WARN([configure, and read the README.nonroot file.]) AC_MSG_WARN() fi fi AC_CHECK_TYPE(uid_t,int) AC_CHECK_TYPE(gid_t,int) AC_CHECK_HEADERS(crypt.h unistd.h time.h sys/time.h errno.h netinet/in.h) AC_CHECK_HEADERS(netinet/ip.h stropts.h sys/conf.h arpa/inet.h sys/filio.h) AC_CHECK_HEADERS(netinet/tcp.h sys/types.h netdb.h glob.h stdio.h) AC_CHECK_HEADERS(stdlib.h stdarg.h stdlib.h string.h strings.h fcntl.h) AC_CHECK_HEADERS(sys/ioctl.h sys/socket.h sys/stat.h sys/param.h signal.h) AC_CHECK_HEADERS(sys/signal.h dirent.h pwd.h grp.h netinet/in_systm.h) AC_CHECK_HEADERS(assert.h) AC_CHECK_HEADER(netinet/tcp.h,result=yes,result=no) dnl dnl linux/socket.h can create some problems on Debian GNU/Linux systems dnl if test "$result" = "yes"; then AC_MSG_CHECKING(if netinet/tcp.h is enough) AC_EGREP_CPP(yes, [#include #ifndef TCP_NODELAY yes #endif ], result=no, result=yes) AC_MSG_RESULT($result) fi if test "$result" = "no"; then AC_CHECK_HEADER(linux/socket.h) fi AC_CHECK_HEADERS(sys/poll.h) AC_MSG_CHECKING([for poll()]) AC_TRY_COMPILE([ #if HAVE_SYS_POLL_H #include #endif ],[ struct pollfd fds[1]; fds[0].fd = 0; fds[0].events = POLLIN | POLLOUT | POLLERR | POLLHUP | POLLNVAL; poll(fds, 1, 1000); ],enableval=yes,enableval=no) AC_MSG_RESULT($enableval) if test "$enableval" = "yes"; then AC_DEFINE(HAVE_POLL, 1, [Define if you have poll().]) fi dnl dnl sendfile() is not standard -- we'll have to check the different dnl versions one by one :-) dnl AC_CHECK_HEADERS(sys/sendfile.h,result=yes,result=no) if test "$result" = "yes"; then AC_MSG_CHECKING([for Linux sendfile()]) AC_TRY_COMPILE([ #if HAVE_SYS_SOCKET_H #include #endif #if HAVE_SYS_LIMITS_H #include #endif #if HAVE_UNISTD_H #include #endif #if HAVE_SYS_SENDFILE_H #include #endif #if HAVE_SYS_TYPES_H #include #endif #if HAVE_SYS_UIO_H #include #endif],[ int out_fd = 1, in_fd = 0; off_t offset = 0; size_t size = 1024; sendfile(out_fd, in_fd, &offset, size); ],enableval=yes,enableval=no) AC_MSG_RESULT($enableval) if test "$enableval" = "yes"; then AC_DEFINE(HAVE_LINUX_SENDFILE, 1, [Define if you have sendfile() with the Linux semantics.]) fi fi AC_CHECK_HEADER(sys/uio.h,result=yes,result=no) if test "$result" = "yes"; then AC_MSG_CHECKING([for BSD sendfile()]) AC_TRY_COMPILE([ #if HAVE_SYS_LIMITS_H #include #endif #if HAVE_UNISTD_H #include #endif #if HAVE_SYS_SENDFILE_H #include #endif #if HAVE_SYS_TYPES_H #include #endif #if HAVE_SYS_SOCKET_H #include #endif #if HAVE_SYS_UIO_H #include #endif ],[ int in_fd = 0, out_sock = 3; off_t offset; size_t size = 1024; struct sf_hdtr hdtr; hdtr.hdr_cnt = 0; hdtr.trl_cnt = 0; sendfile(in_fd, out_sock, offset, size, &hdtr, &offset, 0); ],enableval=yes,enableval=no) AC_MSG_RESULT($enableval) if test "$enableval" = "yes"; then AC_DEFINE(HAVE_BSD_SENDFILE, 1, [Define if you have sendfile() with the BSD semantics.]) fi fi AC_OUTPUT(Makefile)