"Fossies" - the Fresh Open Source Software Archive

Member "pure-ftpd-1.0.49/configure.ac" (3 Apr 2019, 41347 Bytes) of package /linux/misc/pure-ftpd-1.0.49.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "configure.ac": 1.0.48_vs_1.0.49.

    1 dnl AM_ACLOCAL_INCLUDE(m4)
    2 
    3 AC_PREREQ(2.65)
    4 AC_INIT([pure-ftpd],[1.0.49],
    5   [https://github.com/jedisct1/pure-ftpd/issues],
    6   [pure-ftpd],
    7   [https://www.pureftpd.org])
    8 AC_CONFIG_SRCDIR(src/ftpd.c)
    9 AC_CONFIG_HEADERS([config.h])
   10 AM_INIT_AUTOMAKE([1.9 dist-bzip2 tar-ustar])
   11 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
   12 AM_MAINTAINER_MODE
   13 AM_DEP_TRACK
   14 AC_CONFIG_LIBOBJ_DIR(src)
   15 
   16 AC_SUBST(VERSION)
   17 
   18 dnl Checks for programs.
   19 LX_CFLAGS=${CFLAGS-NONE}
   20 AC_PROG_CC
   21 AC_PROG_RANLIB
   22 AC_USE_SYSTEM_EXTENSIONS
   23 
   24 AC_SEARCH_LIBS([strerror],[cposix])
   25 
   26 AX_CHECK_COMPILE_FLAG([-fPIC], [
   27   AX_CHECK_LINK_FLAG([-fPIC],
   28     [CFLAGS="$CFLAGS -fPIC"]
   29   )
   30 ])
   31 
   32 AS_IF([test "$enable_pie" != "no"],[
   33   AX_CHECK_COMPILE_FLAG([-fPIE], [
   34     AX_CHECK_LINK_FLAG([-pie], [
   35       [CFLAGS="$CFLAGS -fPIE"
   36        LDFLAGS="$LDFLAGS -pie"]
   37     ])
   38   ])
   39 ])
   40 
   41 AX_CHECK_COMPILE_FLAG([-fwrapv], [CFLAGS="$CFLAGS -fwrapv"])
   42 AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"])
   43 AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CFLAGS="$CFLAGS -fno-strict-overflow"])
   44 AS_IF([echo `(uname -s) 2>/dev/null` | $GREP "CYGWIN" > /dev/null], [
   45   AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [LDFLAGS="$LDFLAGS -Wl,--nxcompat"])
   46 ], [
   47   AS_IF([test `(uname -s) 2>/dev/null` = "DragonFly"],
   48     [
   49       AX_CHECK_COMPILE_FLAG([-fstack-protector], [
   50         AX_CHECK_LINK_FLAG([-fstack-protector],
   51           [CFLAGS="$CFLAGS -fstack-protector"]
   52         )
   53       ])
   54     ],
   55     [
   56       AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [
   57         AX_CHECK_LINK_FLAG([-fstack-protector-all],
   58           [CFLAGS="$CFLAGS -fstack-protector-all"]
   59         )
   60       ])
   61     ]
   62   )
   63 ])
   64 
   65 AX_CHECK_COMPILE_FLAG([-Winit-self], [CFLAGS="$CFLAGS -Winit-self"])
   66 AX_CHECK_COMPILE_FLAG([-Wwrite-strings], [CFLAGS="$CFLAGS -Wwrite-strings"])
   67 AX_CHECK_COMPILE_FLAG([-Wdiv-by-zero], [CFLAGS="$CFLAGS -Wdiv-by-zero"])
   68 
   69 AX_CHECK_COMPILE_FLAG([$CFLAGS -Wno-unused-command-line-argument],
   70 [CFLAGS="$CFLAGS -Wno-unused-command-line-argument"])
   71 
   72 AC_ARG_VAR([CWFLAGS], [define to compilation flags for generating extra warnings])
   73 AX_CHECK_COMPILE_FLAG([-Wall], [CWFLAGS="$CWFLAGS -Wall"])
   74 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wextra], [CWFLAGS="$CWFLAGS -Wextra"])
   75 
   76 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wbad-function-cast], [CWFLAGS="$CWFLAGS -Wbad-function-cast"])
   77 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcast-align], [CWFLAGS="$CWFLAGS -Wcast-align"])
   78 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcast-qual], [CWFLAGS="$CWFLAGS -Wcast-qual"])
   79 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wchar-subscripts], [CWFLAGS="$CWFLAGS -Wchar-subscripts"])
   80 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcomment], [CWFLAGS="$CWFLAGS -Wcomment"])
   81 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wfloat-equal], [CWFLAGS="$CWFLAGS -Wfloat-equal"])
   82 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wformat=2], [CWFLAGS="$CWFLAGS -Wformat=2"])
   83 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wimplicit], [CWFLAGS="$CWFLAGS -Wimplicit"])
   84 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wmissing-declarations], [CWFLAGS="$CWFLAGS -Wmissing-declarations"])
   85 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wmissing-prototypes], [CWFLAGS="$CWFLAGS -Wmissing-prototypes"])
   86 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wnormalized=id], [CWFLAGS="$CWFLAGS -Wnormalized=id"])
   87 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Woverride-init], [CWFLAGS="$CWFLAGS -Woverride-init"])
   88 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wparentheses], [CWFLAGS="$CWFLAGS -Wparentheses"])
   89 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wpointer-arith], [CWFLAGS="$CWFLAGS -Wpointer-arith"])
   90 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wredundant-decls], [CWFLAGS="$CWFLAGS -Wredundant-decls"])
   91 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wstrict-prototypes], [CWFLAGS="$CWFLAGS -Wstrict-prototypes"])
   92 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wswitch-enum], [CWFLAGS="$CWFLAGS -Wswitch-enum"])
   93 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wvariable-decl], [CWFLAGS="$CWFLAGS -Wvariable-decl"])
   94 
   95 AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"])
   96 AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"])
   97 AX_CHECK_LINK_FLAG([-Wl,-z,noexecstack], [LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"])
   98 
   99 if test "x$cross_compiling" != "xyes"; then
  100   for path in \
  101     /usr/kerberos \
  102     /usr/local /opt /usr/local/opt \
  103     /usr/openssl@1.1 /opt/openssl@1.1 /usr/local/opt/openssl@1.1 \
  104     /usr/openssl /opt/openssl /usr/local/opt/openssl; do
  105     if test -d $path/include; then
  106       CPPFLAGS="$CPPFLAGS -I${path}/include"
  107     fi
  108     if test -d $path/lib; then
  109       LDFLAGS="$LDFLAGS -L${path}/lib"
  110     fi
  111   done
  112 fi
  113 
  114 CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
  115 
  116 dnl Checks for header files
  117 
  118 AC_SYS_LARGEFILE
  119 AC_HEADER_STDC
  120 AC_HEADER_STAT
  121 AC_HEADER_TIME
  122 AC_HEADER_DIRENT
  123 AC_HEADER_SYS_WAIT
  124 AC_CHECK_HEADERS(unistd.h string.h strings.h sys/param.h ioctl.h sys/ioctl.h)
  125 AC_CHECK_HEADERS(sys/vfs.h sys/statvfs.h sys/sendfile.h sys/uio.h)
  126 AC_CHECK_HEADERS(sys/time.h sys/resource.h sys/capability.h)
  127 AC_CHECK_HEADERS(shadow.h getopt.h stddef.h stdint.h)
  128 AC_CHECK_HEADERS(netinet/in_systm.h netinet/in.h sys/pstat.h sys/file.h)
  129 AC_CHECK_HEADERS(sys/mount.h, [], [],
  130 [#ifdef HAVE_SYS_PARAM_H
  131 # include <sys/param.h>
  132 #endif])
  133 AC_CHECK_HEADERS(fcntl.h sys/fcntl.h sys/loadavg.h sys/ptrace.h)
  134 AC_CHECK_HEADERS(security/pam_appl.h security/pam_misc.h)
  135 AC_CHECK_HEADERS(security/pam_modules.h security/pam_filter.h)
  136 AC_CHECK_HEADERS(pam/pam_appl.h pam/pam_misc.h pam/pam_modules.h)
  137 AC_CHECK_HEADERS(pam/pam_filter.h)
  138 AC_CHECK_HEADERS(sgtty.h termio.h)
  139 AC_CHECK_HEADERS(locale.h)
  140 AC_CHECK_HEADERS(stdarg.h varargs.h)
  141 AC_CHECK_HEADERS(windows.h io.h)
  142 AC_CHECK_HEADERS(crypt.h)
  143 AC_CHECK_HEADERS(utime.h)
  144 AC_CHECK_HEADERS(openssl/ssl.h openssl/ec.h)
  145 AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h)
  146 AC_SYS_POSIX_TERMIOS
  147 
  148 if test "x$ac_cv_sys_posix_termios" = "xyes"; then
  149 AC_DEFINE(HAVE_POSIX_TERMIOS,,[Define if you have POSIX termios])
  150 fi
  151 
  152 dnl Check for endianness
  153 AC_C_BIGENDIAN
  154 
  155 dnl Checks for types
  156 
  157 AC_TYPE_SIGNAL
  158 AC_TYPE_SIZE_T
  159 AC_TYPE_SSIZE_T
  160 AC_TYPE_UID_T
  161 AC_TYPE_PID_T
  162 AC_TYPE_OFF_T
  163 AC_TYPE_MODE_T
  164 AC_STRUCT_TM
  165 AC_STRUCT_TIMEZONE
  166 AC_CHECK_MEMBER(struct tm.tm_gmtoff, [AC_DEFINE(STRUCT_TM_TM_GMTOFF,,[Define if you have struct tm/tm_gmtoff])],,[
  167 #include <sys/types.h>
  168 #include <$ac_cv_struct_tm>
  169 ])
  170 
  171 AC_MSG_CHECKING([whether timezone is scalar])
  172 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  173 #include <sys/types.h>
  174 #include <$ac_cv_struct_tm>    
  175     ]], [[timezone = 42L]])],[
  176          AC_MSG_RESULT(yes)
  177          AC_DEFINE(HAVE_SCALAR_TIMEZONE,,[Define if your timezone is a scalar number])
  178     ],[    AC_MSG_RESULT(no)    ])   
  179 
  180 AC_CHECK_TYPE(nlink_t, , [AC_DEFINE(nlink_t, int, [nlink_t type])],
  181 [
  182 #ifdef HAVE_UNISTD_H
  183 # include <unistd.h>
  184 #endif
  185 #include <sys/types.h>
  186 #include <sys/stat.h>
  187 ])
  188 
  189 
  190 AC_CHECK_TYPE(dev_t, , [AC_DEFINE(dev_t, unsigned int, [dev_t type])],
  191 [
  192 #ifdef HAVE_UNISTD_H
  193 # include <unistd.h>
  194 #endif
  195 #include <sys/types.h>
  196 #include <sys/stat.h>
  197 ])
  198 
  199 
  200 AC_CHECK_TYPE(ino_t, , [AC_DEFINE(ino_t, unsigned long, [ino_t type])],
  201 [
  202 #ifdef HAVE_UNISTD_H
  203 # include <unistd.h>
  204 #endif
  205 #include <sys/types.h>
  206 #include <sys/stat.h>
  207 ])
  208 
  209 dnl Check for sizes
  210 AC_CHECK_SIZEOF(short)
  211 AC_CHECK_SIZEOF(int)
  212 AC_CHECK_SIZEOF(long)
  213 AC_CHECK_SIZEOF(long long)
  214 AC_CHECK_SIZEOF(mode_t)
  215 
  216 dnl Socket things
  217 
  218 AC_CHECK_FUNC(connect, , [AC_CHECK_LIB(socket, connect)])
  219 
  220 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(resolv, gethostbyname)])
  221 
  222 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname)])
  223 
  224 if test "x$ac_cv_lib_nsl_gethostbyname" != "xyes" && test "x$ac_cv_func_gethostbyname" != "xyes" ; then
  225   AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(socket, gethostbyname)])
  226 fi
  227 
  228 if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname" ; then
  229   AC_MSG_CHECKING([if we can include libnsl + libsocket])
  230   LIBS="-lnsl -lsocket $LIBS"
  231   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[(void) gethostbyname]])],[my_ac_link_result=yes],[my_ac_link_result=no ])
  232   if test "$my_ac_link_result" = "no" ; then
  233     AC_MSG_RESULT([failure])
  234     AC_MSG_ERROR([unable to use gethostbyname()])
  235   else
  236     AC_MSG_RESULT([success])
  237   fi
  238 fi
  239 
  240 AC_CHECK_LIB(sendfile, sendfile)
  241 
  242 dnl Types - continued
  243 
  244 AC_CHECK_TYPE(socklen_t, , [AC_DEFINE(socklen_t, int, [socklen_t type])],
  245 [
  246 #ifdef HAVE_UNISTD_H
  247 # include <unistd.h>
  248 #endif
  249 #include <sys/types.h>
  250 #include <sys/socket.h>
  251 #ifdef HAVE_NETINET_IN_SYSTM_H
  252 # include <netinet/in_systm.h>
  253 #endif
  254 #include <netinet/in.h>
  255 ])
  256 
  257 AC_CHECK_TYPE(in_port_t, , [AC_DEFINE(in_port_t, unsigned short, [in_port_t type])],
  258 [
  259 #ifdef HAVE_UNISTD_H
  260 # include <unistd.h>
  261 #endif
  262 #include <sys/types.h>
  263 #include <sys/socket.h>
  264 #ifdef HAVE_NETINET_IN_SYSTM_H
  265 # include <netinet/in_systm.h>
  266 #endif
  267 #include <netinet/in.h>
  268 ])
  269 
  270 AC_CHECK_TYPE(sig_atomic_t, , [AC_DEFINE(sig_atomic_t, signed char, [sig_atomic_t type])],
  271 [
  272 #ifdef HAVE_UNISTD_H
  273 # include <unistd.h>
  274 #endif
  275 #include <sys/types.h>
  276 #include <signal.h>
  277 ])
  278 
  279 dnl Compiler characteristics
  280 
  281 AC_PROG_GCC_TRADITIONAL
  282 AC_C_CONST
  283 AC_C_INLINE
  284 
  285 dnl Options
  286 
  287 AM_WITH_DMALLOC
  288 
  289 AC_ARG_ENABLE(pie,
  290 [AS_HELP_STRING(--enable-pie,Produce position independent executables @<:@default=yes@:>@)],
  291  enable_pie=$enableval, enable_pie="maybe")
  292 
  293 AC_ARG_ENABLE(ssp,
  294 [AS_HELP_STRING(--disable-ssp,Don't compile with -fstack-protector)],
  295 [AS_IF([test "x$enableval" = "xno"], [
  296     nxflags=""
  297     for flag in `echo $CFLAGS`; do
  298       case "$flag" in
  299        -fstack-protector*) ;;
  300         *) AS_VAR_APPEND([nxflags], [" $flag"]) ;;
  301       esac
  302     done
  303     CFLAGS="$nxflags"
  304   ])
  305 ])
  306 
  307 AC_ARG_WITH(standalone,
  308 [AS_HELP_STRING(--without-standalone,Don't compile the standalone server code)],
  309 [ if test "x$withval" = "xno" ; then
  310     AC_DEFINE(NO_STANDALONE,,[without standalone])
  311     no_standalone=yes
  312   fi ])
  313 
  314 AC_ARG_WITH(inetd,
  315 [AS_HELP_STRING(--without-inetd,Don't support super-servers (like inetd))],
  316 [ if test "x$withval" = "xno" ; then
  317     AC_DEFINE(NO_INETD,,[without inetd])
  318     no_inetd=yes
  319   fi ])
  320 
  321 if test "x$no_standalone" = "xyes" && test "x$no_inetd" = "xyes" ; then
  322   AC_MSG_ERROR(You can't disable both standalone and inetd mode.)
  323 fi
  324 
  325 AC_ARG_WITH(capabilities,
  326 [AS_HELP_STRING(--without-capabilities,Don't use Linux capabilities (default=detect))],
  327 [ if test "x$withval" = "xno" ; then
  328     no_capabilities=1
  329   fi ])
  330   
  331 if test -z "$no_capabilities" ; then
  332   AC_CHECK_LIB(cap, cap_init, , )
  333   if test "x$ac_cv_lib_cap_cap_init" = "xyes"; then
  334     if test "x$ac_cv_header_sys_capability_h" = "xyes"; then
  335       AC_DEFINE(USE_CAPABILITIES,,[use capabilities])
  336     fi
  337   fi
  338 fi
  339 
  340 AC_ARG_WITH(shadow,
  341 [AS_HELP_STRING(--without-shadow,Don't use shadow passwords (default=detect))],
  342 [ if test "x$withval" = "xno" ; then
  343     no_shadow=1
  344   fi ])
  345   
  346 if test -z "$no_shadow" && test "x$ac_cv_header_shadow_h" = "xyes" ; then
  347   AC_CHECK_FUNC(getspnam, AC_DEFINE(USE_SHADOW,,[use shadow passwords]),
  348     AC_CHECK_LIB(shadow, getspnam, AC_DEFINE(USE_SHADOW),
  349       AC_MSG_WARN(shadow.h was found, but getspnam() isn't available)
  350     )
  351   )
  352 fi
  353 
  354 AC_ARG_WITH(usernames,
  355 [AS_HELP_STRING(--without-usernames,Use only numerical UIDs/GIDs)],
  356 [ if test "x$withval" = "xno" ; then
  357     AC_DEFINE(NO_FTP_USERS,,[without usernames])
  358   fi ])
  359 
  360 AC_ARG_WITH(iplogging,
  361 [AS_HELP_STRING(--without-iplogging,Never log remote IP addresses (privacy))],
  362 [ if test "x$withval" = "xno" ; then
  363     AC_DEFINE(DONT_LOG_IP,,[without iplogging])
  364   fi ])
  365 
  366 AC_ARG_WITH(humor,
  367 [AS_HELP_STRING(--without-humor,Disable humor (enabled by default))],
  368 [ if test "x$withval" = "xno" ; then
  369     AC_DEFINE(DISABLE_HUMOR,,[without humor])
  370   fi ])
  371 
  372 AC_ARG_WITH(longoptions,
  373 [AS_HELP_STRING(--without-longoptions,Ignored - just for backward compatibility)],
  374 [ if test "x$withval" = "xno" ; then
  375     AC_DEFINE(NO_GETOPT_LONG,,[without longoptions])
  376   fi ])
  377 
  378 AC_ARG_WITH(ascii,
  379 [AS_HELP_STRING(--without-ascii,Don't support 7-bits (ASCII) transfers)],
  380 [ if test "x$withval" = "xno" ; then
  381     AC_DEFINE(WITHOUT_ASCII,,[without ascii])
  382   fi ])
  383 
  384 AC_ARG_WITH(globbing,
  385 [AS_HELP_STRING(--without-globbing,Don't include globbing code)],
  386 [ if test "x$withval" = "xno" ; then
  387     AC_DEFINE(DISABLE_GLOBBING,,[without globbing])
  388   fi ])
  389 
  390 AC_ARG_WITH(nonalnum,
  391 [AS_HELP_STRING(--without-nonalnum,Only allow basic alphanumeric characters in file names)],
  392 [ if test "x$withval" = "xno" ; then
  393     AC_DEFINE(PARANOID_FILE_NAMES,,[disallow non-alphanumeric characters])
  394   fi ])
  395 
  396 AC_ARG_WITH(unicode,
  397 [AS_HELP_STRING(--without-unicode,Disable non-latin characters in file names)],
  398 [ if test "x$withval" = "xno" ; then
  399     AC_DEFINE(DISABLE_UNICODE_CONTROL_CHARS,,[disallow unicode control chars])
  400   fi ])
  401 
  402 AC_ARG_WITH(sendfile,
  403 [AS_HELP_STRING(--without-sendfile,Don't use zero-copy optimizations (for network FS))],
  404 [ if test "x$withval" = "xno" ; then
  405     AC_DEFINE(DISABLE_SENDFILE,,[without sendfile])
  406   fi ])
  407 
  408 AC_ARG_WITH(privsep,
  409 [AS_HELP_STRING(--without-privsep,Disable privilege separation)],
  410 [ if test "x$withval" = "xno" ; then
  411     without_privsep=yes
  412   fi ])
  413 
  414 AC_ARG_WITH(boring,
  415 [AS_HELP_STRING(--with-boring,Display only boring messages)],
  416 [ if test "x$withval" = "xyes" ; then
  417     AC_DEFINE(BORING_MODE,,[display only boring messages])
  418     AC_DEFINE(DISABLE_HUMOR)
  419   fi ])
  420 
  421 AC_ARG_WITH(brokenrealpath,
  422 [AS_HELP_STRING(--with-brokenrealpath,If your libc has a broken realpath() call)],
  423 [ if test "x$withval" = "xyes" ; then
  424     AC_DEFINE(USE_BUILTIN_REALPATH,,[realpath() is broken])
  425   fi ])
  426 
  427 AC_ARG_WITH(minimal,
  428 [AS_HELP_STRING(--with-minimal,Build only a small minimal server)],
  429 [ if test "x$withval" = "xyes" ; then
  430     AC_DEFINE(MINIMAL,,[with minimal])
  431     AC_DEFINE(NO_GETOPT_LONG)
  432     AC_DEFINE(DISABLE_HUMOR)
  433     AC_DEFINE(NO_FTP_USERS)
  434     AC_DEFINE(WITHOUT_ASCII)    
  435     AC_DEFINE(BORING_MODE)
  436     CFLAGS="$CFLAGS -Os -fomit-frame-pointer -fno-unroll-loops "
  437     LDFLAGS="$LDFLAGS -s "
  438   fi ])
  439 
  440 AC_ARG_WITH(paranoidmsg,
  441 [AS_HELP_STRING(--with-paranoidmsg,Use paranoid but not admin-friendly messages)],
  442 [ if test "x$withval" = "xyes" ; then
  443     AC_DEFINE(PARANOID_MESSAGES,,[with paranoidmsg])
  444   fi ])
  445 
  446 AC_ARG_WITH(sysquotas,
  447 [AS_HELP_STRING(--with-sysquotas,Use system (not virtual) quotas)],
  448 [ if test "x$withval" = "xyes" ; then
  449     AC_DEFINE(SYSTEM_QUOTAS,,[with sysquotas])
  450   fi ])
  451 
  452 AC_ARG_WITH(altlog,
  453 [AS_HELP_STRING(--with-altlog,Support alternative log format (Apache-like))],
  454 [ if test "x$withval" = "xyes" ; then
  455     AC_DEFINE(WITH_ALTLOG,,[with altlog]) 
  456   fi ])
  457 
  458 AC_ARG_WITH(puredb,
  459 [AS_HELP_STRING(--with-puredb,Support virtual (FTP-only) users)],
  460 [ if test "x$withval" = "xyes" ; then
  461     AC_DEFINE(WITH_PUREDB,,[with puredb])
  462   fi ])
  463 
  464 AC_ARG_WITH(extauth,
  465 [AS_HELP_STRING(--with-extauth,Support external authentication modules)],
  466 [ if test "x$withval" = "xyes" ; then
  467     AC_DEFINE(WITH_EXTAUTH,,[with extauth (*BETA*)])
  468   fi ])
  469 
  470 AC_ARG_WITH(pam,
  471 [AS_HELP_STRING(--with-pam,Enable PAM support (default=disabled))],
  472 [ if test "x$withval" = "xyes" ; then
  473     with_pam="yes"
  474   fi ])
  475 
  476 if test "x`uname`" = "xDarwin"; then
  477   if test "x$with_pam" = "x"; then
  478     with_pam="yes"
  479   fi
  480 fi
  481 
  482 if test "x$with_pam" = "xyes" ; then
  483   if test "x$ac_cv_header_security_pam_appl_h" != "xyes" &&
  484      test "x$ac_cv_header_pam_pam_appl_h" != "xyes"; then
  485     AC_MSG_ERROR(PAM headers not found.)  
  486   else
  487     AC_CHECK_LIB(dl, dlopen, , )
  488     LIBS="$LIBS -lpam"
  489     AC_DEFINE(USE_PAM,,[use pam])
  490     AC_CHECK_FUNCS(pam_getenvlist)
  491     AC_MSG_CHECKING([whether pam_strerror takes only one argument])
  492     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  493 #include <stdio.h>
  494 #ifdef STDC_HEADERS
  495 # include <stdlib.h>
  496 # include <stddef.h>
  497 #else
  498 # if HAVE_STDLIB_H
  499 #  include <stdlib.h>
  500 # endif
  501 #endif
  502 #include <security/pam_appl.h>
  503         ]], [[(void)pam_strerror((pam_handle_t *)NULL, -1)]])],[AC_MSG_RESULT(no)],[
  504             AC_DEFINE(HAVE_OLD_PAM,,[obsolete pam])
  505             AC_MSG_RESULT(yes)
  506         ])   
  507   fi
  508 fi  
  509 
  510 AC_MSG_CHECKING([whether syslog names are available])
  511 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  512 #define SYSLOG_NAMES 1
  513 #include <stdio.h>
  514 #include <syslog.h>
  515 ]], [[
  516  (void) facilitynames
  517 ]])],[
  518   AC_MSG_RESULT(yes)
  519   AC_DEFINE(HAVE_SYSLOG_NAMES,,[define if syslog names are available])
  520 ],[
  521   AC_MSG_RESULT(no)
  522 ])  
  523 
  524 
  525 AC_MSG_CHECKING([whether struct addrinfo is defined])
  526 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  527 #include <stdio.h>
  528 #ifdef HAVE_UNISTD_H
  529 # include <unistd.h>
  530 #endif
  531 #include <sys/types.h>
  532 #include <sys/socket.h>
  533 #include <netdb.h>
  534 ]], [[
  535 do {
  536  struct addrinfo a;
  537  (void) a.ai_flags;
  538 } while(0)
  539 ]])],[
  540   AC_MSG_RESULT(yes)
  541   AC_DEFINE(HAVE_STRUCT_ADDRINFO,,[define if you have struct addrinfo])
  542 ],[
  543   AC_MSG_RESULT(no)
  544 ])  
  545 
  546 
  547 AC_MSG_CHECKING([whether sin_len is defined])
  548 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  549 #include <stdio.h>
  550 #ifdef HAVE_UNISTD_H
  551 # include <unistd.h>
  552 #endif
  553 #include <sys/types.h>
  554 #include <sys/socket.h>
  555 #include <netinet/in.h>
  556 ]], [[
  557 do {
  558  struct sockaddr_in a;
  559  (void) a.sin_len;
  560 } while(0)
  561 ]])],[
  562   AC_MSG_RESULT(yes)
  563   AC_DEFINE(HAVE_SIN_LEN,,[define if you have sin_len])
  564 ],[
  565   AC_MSG_RESULT(no)
  566 ])  
  567 
  568 
  569 AC_MSG_CHECKING([whether __ss_family is defined])
  570 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  571 #include <stdio.h>
  572 #ifdef HAVE_UNISTD_H
  573 # include <unistd.h>
  574 #endif
  575 #include <sys/types.h>
  576 #include <sys/socket.h>
  577 ]], [[
  578 do {
  579  struct sockaddr_storage a;
  580  (void) a.__ss_family;
  581 } while(0)
  582 ]])],[
  583   AC_MSG_RESULT(yes)
  584   AC_DEFINE(HAVE___SS_FAMILY,,[define if you have __ss_family])
  585 ],[
  586   AC_MSG_RESULT(no)
  587 ])  
  588 
  589 
  590 AC_MSG_CHECKING([whether ss_len is defined])
  591 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  592 #include <stdio.h>
  593 #ifdef HAVE_UNISTD_H
  594 # include <unistd.h>
  595 #endif
  596 #include <sys/types.h>
  597 #include <sys/socket.h>
  598 ]], [[
  599 do {
  600  struct sockaddr_storage a;
  601  (void) a.ss_len;
  602 } while(0)
  603 ]])],[
  604   AC_MSG_RESULT(yes)
  605   AC_DEFINE(HAVE_SS_LEN,,[define if you have ss_len])
  606 ],[
  607   AC_MSG_RESULT(no)
  608 ])  
  609 
  610 
  611 AC_MSG_CHECKING([whether __ss_len is defined])
  612 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  613 #include <stdio.h>
  614 #ifdef HAVE_UNISTD_H
  615 # include <unistd.h>
  616 #endif
  617 #include <sys/types.h>
  618 #include <sys/socket.h>
  619 ]], [[
  620 do {
  621  struct sockaddr_storage a;
  622  (void) a.__ss_len;
  623 } while(0)
  624 ]])],[
  625   AC_MSG_RESULT(yes)
  626   AC_DEFINE(HAVE___SS_LEN,,[define if you have __ss_len])
  627 ],[
  628   AC_MSG_RESULT(no)
  629 ])  
  630 
  631 
  632 
  633 AC_MSG_CHECKING([if a linuxish sendfile is available])
  634 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  635 #ifdef HAVE_UNISTD_H
  636 # include <unistd.h>
  637 #endif
  638 #include <sys/types.h>
  639 #include <sys/socket.h>
  640 #ifdef HAVE_SYS_UIO_H
  641 # include <sys/uio.h>
  642 #endif
  643 #ifdef HAVE_SYS_SENDFILE_H
  644 # include <sys/sendfile.h>
  645 #endif
  646 ]], [[
  647 do {
  648  int fd = 0;
  649  off_t *off = NULL;
  650  size_t cnt = (size_t) 0;
  651  
  652  (void) sendfile(fd, fd, off, cnt);
  653 } while(0)
  654 ]])],[
  655   AC_MSG_RESULT(yes)
  656   AC_DEFINE(SENDFILE_LINUX,,[define if you have a linuxish sendfile])
  657 ],[
  658   AC_MSG_RESULT(no)
  659 ])  
  660 
  661 AC_MSG_CHECKING([if a linuxish sendfile64 is available])
  662 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  663 #ifdef HAVE_UNISTD_H
  664 # include <unistd.h>
  665 #endif
  666 #include <sys/types.h>
  667 #include <sys/socket.h>
  668 #ifdef HAVE_SYS_UIO_H
  669 # include <sys/uio.h>
  670 #endif
  671 #ifdef HAVE_SYS_SENDFILE_H
  672 # include <sys/sendfile.h>
  673 #endif
  674 ]], [[
  675 do {
  676  int fd = 0;
  677  off_t *off = NULL;
  678  size_t cnt = (size_t) 0;
  679  
  680  (void) sendfile64(fd, fd, off, cnt);
  681 } while(0)
  682 ]])],[
  683   AC_MSG_RESULT(yes)
  684   AC_DEFINE(SENDFILE64_LINUX,,[define if you have a linuxish sendfile64])
  685 ],[
  686   AC_MSG_RESULT(no)
  687 ])
  688 
  689 AC_MSG_CHECKING([if a freebsdish sendfile is available])
  690 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  691 #ifdef HAVE_UNISTD_H
  692 # include <unistd.h>
  693 #endif
  694 #include <sys/types.h>
  695 #include <sys/socket.h>
  696 #ifdef HAVE_SYS_UIO_H
  697 # include <sys/uio.h>
  698 #endif
  699 #ifdef HAVE_SYS_SENDFILE_H
  700 # include <sys/sendfile.h>
  701 #endif
  702 ]], [[
  703 do {
  704  int fd = 0;
  705  off_t off = (off_t) 0;
  706  size_t cnt = (size_t) 0;
  707  struct sf_hdtr *hdtr = NULL;
  708  
  709  (void) sendfile(fd, fd, off, cnt, hdtr, &off, 42);
  710 } while(0)
  711 ]])],[
  712   AC_MSG_RESULT(yes)
  713   AC_DEFINE(SENDFILE_FREEBSD,,[define if you have a freebsdish sendfile])
  714 ],[
  715   AC_MSG_RESULT(no)
  716 ])
  717 
  718 AC_MSG_CHECKING([if a hpuxish sendfile is available])
  719 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  720 #include <sys/socket.h>
  721 #include <stdio.h>
  722 ]], [[
  723 do {
  724  int fd = 0;
  725  off_t off = (off_t) 0;
  726  bsize_t nbytes = (size_t) 0;
  727  const struct iovec *hdtrl = NULL;
  728  
  729  (void) sendfile(fd, fd, off, nbytes, hdtrl, 42);
  730 } while(0)
  731 ]])],[
  732   AC_MSG_RESULT(yes)
  733   AC_DEFINE(SENDFILE_HPUX,,[define if you have a hpuxish sendfile])
  734 ],[
  735   AC_MSG_RESULT(no)
  736 ])
  737 
  738 AC_CHECK_FUNC(sendfilev, , [AC_CHECK_LIB(sendfile, sendfilev)])
  739 
  740 AC_MSG_CHECKING([if a solarisish sendfilev is available])
  741 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  742 #ifdef HAVE_UNISTD_H
  743 # include <unistd.h>
  744 #endif
  745 #include <sys/types.h>
  746 #include <sys/socket.h>
  747 #ifdef HAVE_SYS_UIO_H
  748 # include <sys/uio.h>
  749 #endif
  750 #ifdef HAVE_SYS_SENDFILE_H
  751 # include <sys/sendfile.h>
  752 #endif
  753 ]], [[
  754 do {
  755  int fd = 0, sfvcnt = 0;
  756  const struct sendfilevec vec;
  757  size_t xferred;
  758  
  759  (void) sendfilev(fd, &vec, sfvcnt, &xferred);
  760 } while(0)
  761 ]])],[
  762   AC_MSG_RESULT(yes)
  763   AC_DEFINE(SENDFILEV_SOLARIS,,[define if you have a solarisish sendfilev])
  764 ],[
  765   AC_MSG_RESULT(no)
  766 ])
  767 
  768 
  769 AC_ARG_WITH(cookie,
  770 [AS_HELP_STRING(--with-cookie,Support 'fortune' cookies (-F option))],
  771 [ if test "x$withval" = "xyes" ; then
  772     AC_DEFINE(COOKIE,,[with cookie])
  773   fi ])
  774 
  775 AC_ARG_WITH(throttling,
  776 [AS_HELP_STRING(--with-throttling,Support bandwidth throttling (disabled by default))],
  777 [ if test "x$withval" = "xyes" ; then
  778     AC_DEFINE(THROTTLING,,[with throttling])
  779   fi ])
  780 
  781 AC_ARG_WITH(ratios,
  782 [AS_HELP_STRING(--with-ratios,Support for upload/download ratios)],
  783 [ if test "x$withval" = "xyes" ; then
  784     AC_DEFINE(RATIOS,,[with ratios])
  785   fi ])
  786 
  787 AC_ARG_WITH(quotas,
  788 [AS_HELP_STRING(--with-quotas,Support .ftpquota files)],
  789 [ if test "x$withval" = "xyes" ; then
  790     AC_DEFINE(QUOTAS,,[with quotas])
  791   fi ])
  792 
  793 AC_ARG_WITH(ftpwho,
  794 [AS_HELP_STRING(--with-ftpwho,Support for pure-ftpwho)],
  795 [ if test "x$withval" = "xyes" ; then
  796     AC_DEFINE(FTPWHO,,[with ftpwho])
  797   fi ])
  798 
  799 AC_ARG_WITH(welcomemsg,
  800 [AS_HELP_STRING(--with-welcomemsg,Support welcome.msg backward compatibility (deprecated))],
  801 [ if test "x$withval" = "xyes" ; then
  802       AC_DEFINE(WITH_WELCOME_MSG,,[with welcomemsg])
  803   fi ])
  804 
  805 AC_ARG_WITH(uploadscript,
  806 [AS_HELP_STRING(--with-uploadscript,Allow running an external script after an upload (experimental))],
  807 [ if test "x$withval" = "xyes" ; then
  808       AC_DEFINE(WITH_UPLOAD_SCRIPT,,[with uploadscript])
  809   fi ])
  810 
  811 AC_ARG_WITH(virtualhosts,
  812 [AS_HELP_STRING(--with-virtualhosts,Handle virtual servers on different IP addresses)],
  813 [ if test "x$withval" = "xyes" ; then
  814       AC_DEFINE(WITH_VIRTUAL_HOSTS,,[with virtualhosts])
  815   fi ])
  816 
  817 AC_ARG_WITH(virtualchroot,
  818 [AS_HELP_STRING(--with-virtualchroot,Enable the ability to follow symlinks outside a chroot jail)],
  819 [ if test "x$withval" = "xyes" ; then
  820       AC_DEFINE(WITH_VIRTUAL_CHROOT,,[with virtual chroot])
  821   fi ])
  822 
  823 AC_ARG_WITH(diraliases,
  824 [AS_HELP_STRING(--with-diraliases,Enable directory aliases)],
  825 [ if test "x$withval" = "xyes" ; then
  826       AC_DEFINE(WITH_DIRALIASES,,[with directory aliases])
  827   fi ])
  828 
  829 AC_ARG_WITH(nonroot,
  830 [AS_HELP_STRING(--with-nonroot,[Compile a limited server designed to be started as a regular user. Only enable this option as a last resort if you really don't have root privileges on the server host.])],
  831 [ if test "x$withval" = "xyes" ; then
  832       AC_DEFINE(NON_ROOT_FTP,,[with nonroot])
  833       AC_DEFINE(WITH_VIRTUAL_CHROOT)      
  834       non_root_ftp=yes
  835       without_privsep=yes
  836   fi ])
  837 
  838 if test "x$without_privsep" = "xyes" ; then
  839   AC_DEFINE(WITHOUT_PRIVSEP,,[disable privilege separation])
  840 fi
  841 
  842 AC_ARG_WITH(peruserlimits,
  843 [AS_HELP_STRING(--with-peruserlimits,Support per-user concurrency limits)],
  844 [ if test "x$withval" = "xyes" ; then
  845       AC_DEFINE(PER_USER_LIMITS,,[with per-user limits])
  846       AC_DEFINE(FTPWHO)
  847   fi ])
  848 
  849 AC_ARG_WITH(implicittls,
  850 [AS_HELP_STRING(--with-implicittls,Implicit TLS (port 990) - DO NOT USE unless you know what you are doing)],
  851 [ if test "x$withval" = "xyes" ; then
  852       AC_DEFINE(IMPLICIT_TLS,,[with implicit TLS])
  853       with_tls="yes"
  854   fi ])
  855 
  856 AC_ARG_WITH(debug,
  857 [AS_HELP_STRING(--with-debug,For maintainers only - please do not use)],
  858 [ if test "x$withval" = "xyes" ; then
  859     if test "$LX_CFLAGS" = "NONE"; then
  860       nxflags=""
  861       for flag in `echo $CFLAGS`; do
  862         case "$flag" in
  863           -O*) ;;
  864           -g*) ;;
  865           *) nxflags="$nxflags $flag"
  866         esac
  867       done
  868       CFLAGS="$nxflags -O0 -g3 $CWFLAGS"
  869     fi
  870     CPPFLAGS="$CPPFLAGS -DDEBUG=1"
  871   fi ])
  872 
  873 AC_ARG_WITH(everything,
  874 [AS_HELP_STRING(--with-everything,Build a big server with almost everything)],
  875 [ if test "x$withval" = "xyes" ; then
  876     AC_DEFINE(WITH_ALTLOG)
  877     AC_DEFINE(COOKIE)
  878     AC_DEFINE(THROTTLING)
  879     AC_DEFINE(RATIOS)
  880     AC_DEFINE(QUOTAS)    
  881     AC_DEFINE(WITH_UPLOAD_SCRIPT)
  882     AC_DEFINE(WITH_VIRTUAL_HOSTS)
  883     AC_DEFINE(WITH_PUREDB)
  884     AC_DEFINE(WITH_EXTAUTH)
  885     AC_DEFINE(FTPWHO)
  886     AC_DEFINE(WITH_DIRALIASES)
  887     AC_DEFINE(PER_USER_LIMITS)
  888     with_bonjour='yes'
  889   fi ])
  890 
  891 AC_ARG_WITH(language,
  892 [AS_HELP_STRING(--with-language=,< english | albanian | german | romanian | french |
  893 french-funny | polish | spanish | danish | dutch | italian |
  894 brazilian-portuguese | slovak | korean | swedish | norwegian | russian |
  895 traditional-chinese | simplified-chinese | czech | turkish | hungarian |
  896 catalan>)],
  897 [ if test "x$withval" = "xenglish" ; then
  898     AC_DEFINE(MESSAGES_EN,,[english])
  899   elif test "x$withval" = "xalbanian" ; then
  900     AC_DEFINE(MESSAGES_SQ,,[albanian])
  901   elif test "x$withval" = "xgerman" ; then
  902     AC_DEFINE(MESSAGES_DE,,[german])
  903   elif test "x$withval" = "xromanian" ; then
  904     AC_DEFINE(MESSAGES_RO,,[romanian])
  905   elif test "x$withval" = "xfrench" ; then
  906     AC_DEFINE(MESSAGES_FR,,[french])
  907   elif test "x$withval" = "xfrench-funny" ; then
  908     AC_DEFINE(MESSAGES_FR_FUNNY,,[french-funny])    
  909   elif test "x$withval" = "xpolish" ; then  
  910     AC_DEFINE(MESSAGES_PL,,[polish])
  911   elif test "x$withval" = "xspanish" ; then
  912     AC_DEFINE(MESSAGES_ES,,[spanish])
  913   elif test "x$withval" = "xdanish" ; then
  914     AC_DEFINE(MESSAGES_DA,,[danish])
  915   elif test "x$withval" = "xdutch" ; then
  916     AC_DEFINE(MESSAGES_NL,,[dutch])
  917   elif test "x$withval" = "xitalian" ; then
  918     AC_DEFINE(MESSAGES_IT,,[italian])
  919   elif test "x$withval" = "xbrazilian-portuguese" ; then
  920     AC_DEFINE(MESSAGES_PT_BR,,[brazilian portuguese])
  921   elif test "x$withval" = "xslovak" ; then
  922     AC_DEFINE(MESSAGES_SK,,[slovak])
  923   elif test "x$withval" = "xkorean" ; then
  924     AC_DEFINE(MESSAGES_KR,,[korean])
  925   elif test "x$withval" = "xswedish" ; then
  926     AC_DEFINE(MESSAGES_SV,,[swedish])
  927   elif test "x$withval" = "xnorwegian" ; then
  928     AC_DEFINE(MESSAGES_NO,,[norwegian])
  929   elif test "x$withval" = "xrussian" ; then
  930     AC_DEFINE(MESSAGES_RU,,[russian])
  931   elif test "x$withval" = "xtraditional-chinese" ; then
  932     AC_DEFINE(MESSAGES_ZH_TW,,[traditional chinese])
  933   elif test "x$withval" = "xsimplified-chinese" ; then
  934     AC_DEFINE(MESSAGES_ZH_CN,,[simplified chinese])
  935   elif test "x$withval" = "xczech" ; then
  936     AC_DEFINE(MESSAGES_CS_CZ,,[czech])
  937   elif test "x$withval" = "xturkish" ; then
  938     AC_DEFINE(MESSAGES_TR,,[turkish])
  939   elif test "x$withval" = "xhungarian" ; then
  940     AC_DEFINE(MESSAGES_HU,,[hungarian])
  941   elif test "x$withval" = "xcatalan" ; then
  942     AC_DEFINE(MESSAGES_CA_ES,,[catalan])
  943   else 
  944     AC_MSG_WARN(--with-language=$withval is not recognized)
  945   fi ])
  946 
  947 
  948 
  949 dnl Checks for libraries.
  950 
  951 AC_CHECK_LIB(crypt, crypt, , )
  952 
  953 AC_CHECK_LIB(sodium, crypto_pwhash_scryptsalsa208sha256_str)
  954 
  955 dnl Checks for library functions.
  956 AC_FUNC_ALLOCA
  957 AC_FUNC_MMAP
  958 AC_FUNC_MEMCMP
  959 AC_FUNC_STRFTIME
  960 AC_FUNC_STAT
  961 AC_FUNC_VPRINTF
  962 AC_FUNC_GETLOADAVG(src)
  963 AC_FUNC_GETGROUPS
  964 AC_FUNC_WAIT3
  965 AC_FUNC_UTIME_NULL
  966 AC_FUNC_STRTOD
  967 AC_FUNC_SELECT_ARGTYPES
  968 AC_FUNC_MKTIME
  969 AC_FUNC_LSTAT
  970 AC_FUNC_FORK
  971 AC_FUNC_ERROR_AT_LINE
  972 AC_FUNC_CLOSEDIR_VOID
  973 AC_FUNC_CHOWN
  974 AC_C_VOLATILE
  975 
  976 
  977 AC_CHECK_FUNCS(initgroups setrlimit waitpid setproctitle getopt_long)
  978 AC_CHECK_FUNCS(seteuid setreuid setresuid setegid setregid setresgid)
  979 AC_CHECK_FUNCS(statvfs statfs putenv setenv unsetenv getpagesize realpath)
  980 AC_CHECK_FUNCS(pread posix_fadvise ptrace)
  981 AC_CHECK_FUNCS(strtoull strtoq)
  982 AC_CHECK_FUNCS(strlcpy strlcat)
  983 AC_CHECK_FUNCS(memset munmap strdup fileno mapviewoffile madvise)
  984 AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_ntop inet_pton)
  985 AC_CHECK_FUNCS(setusershell setgroups snprintf vsnprintf vfprintf gethostname)
  986 AC_CHECK_FUNCS(setlocale timegm)
  987 AC_CHECK_FUNCS(tzset utime utimes mknod mkfifo)
  988 AC_CHECK_FUNCS(random srandomdev arc4random arc4random_stir arc4random_addrandom)
  989 AC_CHECK_FUNCS(closefrom explicit_bzero getpwnam_shadow)
  990 
  991 AC_MSG_CHECKING([whether statvfs64() is defined])
  992 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  993 #include <stdio.h>
  994 #ifdef HAVE_UNISTD_H
  995 # include <unistd.h>
  996 #endif
  997 #include <sys/types.h>
  998 #ifdef HAVE_SYS_STATVFS_H
  999 # include <sys/statvfs.h>
 1000 #endif
 1001 ]], [[
 1002 for (;;) {
 1003  struct statvfs64 a;
 1004  if (statvfs64(".", &a) == 0 || a.f_bsize != 0) {
 1005    break;
 1006  }
 1007 } 
 1008 ]])],[
 1009   AC_MSG_RESULT(yes)
 1010   AC_DEFINE(HAVE_STATVFS64,,[define if you have statvfs64])
 1011 ],[
 1012   AC_MSG_RESULT(no)
 1013 ])  
 1014 
 1015 AC_MSG_CHECKING(whether snprintf is C99 conformant)
 1016 AC_RUN_IFELSE([AC_LANG_SOURCE([[
 1017 #include <stdio.h>
 1018 #ifdef STDC_HEADERS
 1019 # include <stdlib.h>
 1020 # include <stddef.h>
 1021 #else
 1022 # if HAVE_STDLIB_H
 1023 #  include <stdlib.h>
 1024 # endif
 1025 #endif
 1026 #ifdef HAVE_UNISTD_H
 1027 # include <unistd.h>
 1028 #endif
 1029 
 1030 int main(void)
 1031 {
 1032     char buf[4];
 1033     
 1034     (void) fprintf(fopen("conftestval", "w"), "%d\n",
 1035         (int) snprintf(buf, sizeof buf, "12345678"));
 1036     return 0;
 1037 }
 1038 ]])],[CONF_SNPRINTF_TYPE=`cat conftestval`
 1039 ],[],[CONF_SNPRINTF_TYPE=8])
 1040 AC_MSG_RESULT(done)
 1041 if test "x$CONF_SNPRINTF_TYPE" = "x" ; then
 1042   AC_MSG_WARN(your operating system doesn't implement snprintf)
 1043 else
 1044   AC_DEFINE_UNQUOTED(CONF_SNPRINTF_TYPE, $CONF_SNPRINTF_TYPE, [return value of an overflowed snprintf])
 1045 fi
 1046 
 1047 
 1048 AC_MSG_CHECKING(whether getgroups 0 is sane)
 1049 AC_RUN_IFELSE([AC_LANG_SOURCE([[
 1050 #include <stdio.h>
 1051 #ifdef STDC_HEADERS
 1052 # include <stdlib.h>
 1053 # include <stddef.h>
 1054 #else
 1055 # if HAVE_STDLIB_H
 1056 #  include <stdlib.h>
 1057 # endif
 1058 #endif
 1059 #ifdef HAVE_UNISTD_H
 1060 # include <unistd.h>
 1061 #endif
 1062 
 1063 int main(void)
 1064 {
 1065     return getgroups(0, NULL) <= 0;
 1066 }
 1067 ]])],[
 1068 AC_MSG_RESULT(yes)
 1069 AC_DEFINE(SAFE_GETGROUPS_0,,[Define is getgroups(0, NULL) works on your system])
 1070 ],[AC_MSG_RESULT(no)
 1071 ],[AC_MSG_RESULT(suppose that it doesnt)])
 1072 
 1073 AC_MSG_CHECKING(whether realpath likes unreadable directories)
 1074 AC_RUN_IFELSE([AC_LANG_SOURCE([[
 1075 #include <stdio.h>
 1076 #ifdef STDC_HEADERS
 1077 # include <stdlib.h>
 1078 # include <stddef.h>
 1079 #else
 1080 # if HAVE_STDLIB_H
 1081 #  include <stdlib.h>
 1082 # endif
 1083 #endif
 1084 #include <sys/types.h>
 1085 #include <sys/stat.h>
 1086 #ifdef HAVE_UNISTD_H
 1087 # include <unistd.h>
 1088 #endif
 1089 #ifdef HAVE_LIMITS_H
 1090 # include <limits.h>
 1091 #endif
 1092 #ifdef HAVE_SYS_PARAM_H
 1093 # include <sys/param.h>
 1094 #endif
 1095 
 1096 #ifndef PATH_MAX
 1097 # define PATH_MAX MAXPATHLEN
 1098 #endif
 1099 
 1100 int main(void)
 1101 {
 1102     char x[PATH_MAX];
 1103     
 1104     if (mkdir("x", 0300) != 0) {
 1105         return 1;
 1106     }
 1107     if (mkdir("x/y", 0300) != 0) {
 1108         rmdir("x");
 1109         return 2;
 1110     }    
 1111     if (chdir("x") != 0) {
 1112         rmdir("x/y");    
 1113         rmdir("x");
 1114         return 3;
 1115     }
 1116     if (realpath("y", x) == NULL) {
 1117         rmdir("y");
 1118         rmdir("../x");
 1119         return 4;
 1120     }
 1121     rmdir("y");
 1122     rmdir("../x");
 1123     
 1124     return 0;    
 1125 }
 1126 ]])],[
 1127 AC_MSG_RESULT(yes)
 1128 AC_DEFINE(REALPATH_WORKS_WITH_UNREADABLE_DIRECTORIES,,
 1129 [Define if realpath() works on unreadable directories])
 1130 ],[AC_MSG_RESULT(no)
 1131 AC_DEFINE(USE_BUILTIN_REALPATH)
 1132 ],[AC_MSG_RESULT(no)
 1133 AC_DEFINE(USE_BUILTIN_REALPATH)])
 1134 
 1135 AC_MSG_CHECKING(whether you already have a standard MD5 implementation)
 1136 AC_RUN_IFELSE([AC_LANG_SOURCE([[
 1137 #include <stdio.h>
 1138 #include <stdio.h>
 1139 #include <string.h>
 1140 #include <sys/types.h>
 1141 #include <md5.h>
 1142 
 1143 int main(void)
 1144 {
 1145     MD5_CTX ctx;
 1146     char b[33];
 1147     
 1148     MD5Init(&ctx);
 1149     MD5Update(&ctx, (const unsigned char *) "test", 4U);
 1150     MD5End(&ctx, b);
 1151     b[32] = 0;
 1152 
 1153     return strcasecmp(b, "098f6bcd4621d373cade4e832627b4f6");
 1154 }
 1155 ]])],[
 1156 AC_MSG_RESULT(yes)
 1157 AC_DEFINE(USE_SYSTEM_CRYPT_MD5,,[Define if you already have standard
 1158 MD5 functions])
 1159 ],[AC_MSG_RESULT(no)
 1160 ],[AC_MSG_RESULT(assuming no)])
 1161 
 1162 AC_MSG_CHECKING(whether you already have a standard SHA1 implementation)
 1163 AC_RUN_IFELSE([AC_LANG_SOURCE([[
 1164 #include <stdio.h>
 1165 #include <string.h>
 1166 #include <sys/types.h>
 1167 #include <sha1.h>
 1168 
 1169 int main(void)
 1170 {
 1171     SHA1_CTX ctx;
 1172     char b[41];
 1173     
 1174     SHA1Init(&ctx);
 1175     SHA1Update(&ctx, (const unsigned char *) "test", 4U);
 1176     SHA1End(&ctx, b);
 1177     b[40] = 0;
 1178     
 1179     return strcasecmp(b, "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3");
 1180 }
 1181 ]])],[
 1182 AC_MSG_RESULT(yes)
 1183 AC_DEFINE(USE_SYSTEM_CRYPT_SHA1,,[Define if you already have standard
 1184 SHA1 functions])
 1185 ],[AC_MSG_RESULT(no)
 1186 ],[AC_MSG_RESULT(assuming no)])
 1187 
 1188 AC_MSG_CHECKING([whether we are inside a Virtuozzo virtual host])
 1189 if test -d /proc/vz; then
 1190   AC_MSG_RESULT(yes)
 1191   AC_DEFINE(VIRTUOZZO,,[Define if you are inside a Virtuozzo virtual
 1192 host])
 1193 else
 1194   AC_MSG_RESULT(no)
 1195 fi
 1196 
 1197 AC_MSG_CHECKING(default TCP send buffer size)
 1198 AC_RUN_IFELSE([AC_LANG_SOURCE([[
 1199 #include <stdio.h>
 1200 #ifdef STDC_HEADERS
 1201 # include <stdlib.h>
 1202 # include <stddef.h>
 1203 #else
 1204 # if HAVE_STDLIB_H
 1205 #  include <stdlib.h>
 1206 # endif
 1207 #endif
 1208 #ifdef HAVE_UNISTD_H
 1209 # include <unistd.h>
 1210 #endif
 1211 #include <sys/types.h>
 1212 #include <sys/socket.h>
 1213 #include <netinet/in.h>
 1214 int main(void)
 1215 {
 1216     int fd,val=0,len=sizeof(int);
 1217     if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) return 1;
 1218         if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, &len) < 0) return 1;
 1219     if (val <= 0) return 1;
 1220         fprintf (fopen("conftestval", "w"), "%d\n", val);
 1221     return 0;
 1222 }
 1223 ]])],[CONF_TCP_SO_SNDBUF=`cat conftestval`],[CONF_TCP_SO_SNDBUF=65536],[CONF_TCP_SO_SNDBUF=65536])
 1224 AC_MSG_RESULT($CONF_TCP_SO_SNDBUF)
 1225 
 1226 AC_DEFINE_UNQUOTED(CONF_TCP_SO_SNDBUF, $CONF_TCP_SO_SNDBUF, [default TCP send buffer])
 1227 
 1228 AC_MSG_CHECKING(default TCP receive buffer size)
 1229 AC_RUN_IFELSE([AC_LANG_SOURCE([[
 1230 #include <stdio.h>
 1231 #ifdef STDC_HEADERS
 1232 # include <stdlib.h>
 1233 # include <stddef.h>
 1234 #else
 1235 # if HAVE_STDLIB_H
 1236 #  include <stdlib.h>
 1237 # endif
 1238 #endif
 1239 #ifdef HAVE_UNISTD_H
 1240 # include <unistd.h>
 1241 #endif
 1242 #include <sys/types.h>
 1243 #include <sys/socket.h>
 1244 #include <netinet/in.h>
 1245 int main(void)
 1246 {
 1247     int fd,val=0,len=sizeof(int);
 1248     if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) return 1;
 1249         if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, &len) < 0) return 1;
 1250     if (val <= 0) return 1;
 1251         fprintf (fopen("conftestval", "w"), "%d\n", val);
 1252     return 0;
 1253 }
 1254 ]])],[CONF_TCP_SO_RCVBUF=`cat conftestval`],[CONF_TCP_SO_RCVBUF=65536],[CONF_TCP_SO_RCVBUF=65536])
 1255 AC_MSG_RESULT($CONF_TCP_SO_RCVBUF)
 1256 
 1257 AC_DEFINE_UNQUOTED(CONF_TCP_SO_RCVBUF, $CONF_TCP_SO_RCVBUF, [defaut TCP receive buffer])
 1258 
 1259 
 1260 AC_ARG_WITH(ldap,
 1261 [AS_HELP_STRING(--with-ldap,Users database is an LDAP directory (see doc))],
 1262 [ if test "x$withval" != "xno" ; then
 1263     if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
 1264       LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"
 1265       LDFLAGS="$LDFLAGS -L${withval}/lib"
 1266       CPPFLAGS="$CPPFLAGS -I${withval}/include"
 1267     fi
 1268     with_ldap="yes"
 1269     AC_DEFINE(WITH_LDAP,,[with ldap])
 1270     AC_CHECK_LIB(resolv, res_query)
 1271     AC_CHECK_LIB(lber, ber_init, , 
 1272     [AC_MSG_ERROR(liblber is needed for LDAP support)])
 1273     AC_CHECK_LIB(ldap, ldap_init, ,
 1274      [AC_MSG_WARN(Initial check for -lldap failed! May need -lssl -lcrypto) 
 1275       AC_CHECK_LIB(ldap, ldap_bind, [ldap_ssl_libs=true], 
 1276       [AC_MSG_ERROR(libldap is needed for LDAP support)], -lssl -lcrypto)
 1277      ])
 1278     if test "x$ldap_ssl_libs" = "xtrue" ; then
 1279       LDAP_SSL_LIBS='-lssl -lcrypto'
 1280     fi
 1281   fi ])
 1282 
 1283 AC_SUBST(LDAP_SSL_LIBS)
 1284 
 1285 AC_ARG_WITH(mysql,
 1286 [AS_HELP_STRING(--with-mysql,Users database is a MySQL database (see doc))],
 1287 [ if test "x$withval" != "xno" ; then
 1288     if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
 1289       LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"    
 1290       LDFLAGS="$LDFLAGS -L${withval}/lib -L${withval}/lib/mysql -L${withval}/mysql/lib"
 1291       CPPFLAGS="$CPPFLAGS -I${withval}/include -I${withval}/include/mysql -I${withval}/mysql/include"
 1292     else
 1293       CFLAGS="$CFLAGS `mariadb_config --cflags 2> /dev/null || mysql_config --cflags`"
 1294       LDFLAGS="$LDFLAGS `mariadb_config --libs 2> /dev/null || mysql_config --libs`"
 1295     fi
 1296     AC_CHECK_LIB(m, floor)
 1297     AC_CHECK_LIB(z, gzclose)
 1298     with_mysql="yes"
 1299     AC_DEFINE(WITH_MYSQL,,[with mysql])
 1300     AC_CHECK_FUNC(mysql_init, , [
 1301       AC_CHECK_LIB(mariadb, mysql_init, , [
 1302         AC_CHECK_LIB(mysqlclient, mysql_init, ,
 1303           [AC_MSG_ERROR(libmysqlclient is needed for MySQL support)])
 1304       ])
 1305     ])
 1306     AC_MSG_CHECKING(whether mysql clients can run)
 1307     AC_LINK_IFELSE([AC_LANG_SOURCE([[
 1308       #include <stdio.h>
 1309       #include <mysql.h>    
 1310       int main(void)
 1311       {
 1312           MYSQL *a = mysql_init(NULL);
 1313           return 0;
 1314       }
 1315       ]])],[],[
 1316         AC_MSG_RESULT(no)
 1317         AC_MSG_ERROR(Your MySQL client libraries aren't properly installed)
 1318     ],[])
 1319     AC_MSG_RESULT(yes)
 1320   fi ])
 1321 
 1322 AC_ARG_WITH(pgsql,
 1323 [AS_HELP_STRING(--with-pgsql,Users database is a PostgreSQL database (see doc))],
 1324 [ if test "x$withval" != "xno" ; then
 1325     if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
 1326       LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"
 1327       LDFLAGS="$LDFLAGS -L${withval}/lib -L${withval}/lib/pgsql -L${withval}/lib/postgresql -L${withval}/pgsql/lib -L${withval}/postgresql/lib"
 1328       CPPFLAGS="$CPPFLAGS -I${withval}/include -I${withval}/include/pgsql -I${withval}/include/postgresql -I${withval}/pgsql/include -I${withval}/postgresql/include"
 1329     else
 1330       LD_RUN_PATH="`pg_config --libdir`${LD_RUN_PATH:+:}${LD_RUN_PATH}"
 1331       CPPFLAGS="$CPPFLAGS -I`pg_config --includedir`"
 1332       LDFLAGS="$LDFLAGS -L`pg_config --libdir`"
 1333     fi
 1334     AC_CHECK_LIB(m, floor)
 1335     AC_CHECK_LIB(z, gzclose)
 1336     with_pgsql="yes"
 1337     AC_DEFINE(WITH_PGSQL,,[with pgsql])
 1338     AC_CHECK_LIB(pq, PQconnectdb, ,
 1339       [AC_MSG_ERROR(libpq is needed for PostgreSQL support)])        
 1340     AC_MSG_CHECKING(whether postgresql clients can run)
 1341     AC_LINK_IFELSE([AC_LANG_SOURCE([[
 1342       #include <stdio.h>
 1343       #include <libpq-fe.h>
 1344       int main(void)
 1345       {
 1346           PGconn *a = PQconnectdb("");
 1347           return 0;
 1348       }
 1349       ]])],[],[
 1350         AC_MSG_RESULT(no)
 1351         AC_MSG_ERROR(Your PostgreSQL client libraries aren't properly installed)      
 1352     ],[])    
 1353     AC_MSG_RESULT(yes)
 1354   fi ])
 1355 
 1356 AC_ARG_WITH(tls,
 1357 [AS_HELP_STRING(--with-tls,Enable TLS support)],
 1358 [ if test "x$withval" = "xyes" ; then
 1359     with_tls="yes"
 1360   fi ])
 1361 
 1362 if test "x$with_tls" = "xyes" ; then
 1363   if test "x$ac_cv_header_openssl_ssl_h" != "xyes" ; then
 1364     AC_MSG_ERROR(OpenSSL headers not found.)  
 1365   fi
 1366   AC_CHECK_LIB(crypto, DH_new)
 1367   AC_CHECK_LIB(ssl, SSL_accept)
 1368   AC_CHECK_FUNCS(DH_get_2048_256 TLS_server_method)
 1369   AC_DEFINE(WITH_TLS,,[Enable TLS])
 1370 fi
 1371 
 1372 AC_ARG_WITH(certfile,
 1373 [AS_HELP_STRING(--with-certfile=,certificate file (default: /etc/ssl/private/pure-ftpd.pem))],
 1374 [ if test "x$withval" != "x" ; then
 1375     certfile="$withval"
 1376     AC_SUBST(certfile)
 1377     CPPFLAGS="$CPPFLAGS -DTLS_CERTIFICATE_FILE='\"$certfile\"'"
 1378     if test ! -e "$certfile"; then
 1379       AC_MSG_WARN(No certificate is installed in $certfile yet)
 1380     fi
 1381   fi ])
 1382 
 1383 AC_ARG_WITH(keyfile,
 1384 [AS_HELP_STRING(--with-keyfile=,certificate key file (default: /etc/ssl/private/pure-ftpd.pem))],
 1385 [ if test "x$withval" != "x" ; then
 1386     keyfile="$withval"
 1387     AC_SUBST(keyfile)
 1388     CPPFLAGS="$CPPFLAGS -DTLS_KEY_FILE='\"$keyfile\"'"
 1389     if test ! -e "$keyfile"; then
 1390       AC_MSG_WARN(No certificate key is installed in $keyfile yet)
 1391     fi
 1392   fi ])
 1393 
 1394 AC_ARG_WITH(bonjour,
 1395 [AS_HELP_STRING(--with-bonjour,Enable Bonjour support on MacOS X)],
 1396 [ if test "x$withval" = "xyes" ; then
 1397     with_bonjour="yes"
 1398   fi ])
 1399 
 1400 if test "x$with_bonjour" = "xyes" ; then
 1401   if test "x$ac_cv_header_CoreFoundation_CoreFoundation_h" = "xyes" ; then
 1402     AC_DEFINE(WITH_BONJOUR,,[Enable Bonjour on MacOS X])
 1403     BONJOUR_LDADD='-framework CoreFoundation -framework CoreServices'
 1404   fi
 1405 fi
 1406 
 1407 AC_SUBST(BONJOUR_LDADD)
 1408 
 1409 if test "x$sysconfdir" = 'xNONE' || test "x$sysconfdir" = 'x'; then
 1410   CONFDIR='/etc'
 1411 else
 1412   if test "x$sysconfdir" = 'x${prefix}/etc'; then
 1413     if test "x$prefix" = 'xNONE' || test "x$prefix" = 'x/usr'; then
 1414       CONFDIR='/etc'
 1415     else
 1416       CONFDIR="$sysconfdir"
 1417     fi
 1418   else
 1419     CONFDIR="$sysconfdir"
 1420   fi
 1421 fi  
 1422 
 1423 if test "x$localstatedir" = 'xNONE' || test "x$localstatedir" = 'x'; then
 1424   LOCALSTATEDIR='/var'
 1425 else
 1426   if test "x$localstatedir" = 'x${prefix}/var'; then
 1427     if test "x$prefix" = 'xNONE' || test "x$prefix" = 'x/usr' || test "x$localstatedir" = 'x${prefix}/var' ; then
 1428       LOCALSTATEDIR='/var'
 1429     else
 1430       LOCALSTATEDIR="$localstatedir"
 1431     fi
 1432   else
 1433     LOCALSTATEDIR="$localstatedir"
 1434   fi
 1435 fi  
 1436 
 1437 if test -r /dev/urandom; then
 1438   AC_MSG_NOTICE([You have /dev/urandom - Great])
 1439   AC_DEFINE(HAVE_DEV_URANDOM,,[Define if you have /dev/urandom])
 1440 fi
 1441 if test -r /dev/random; then
 1442   AC_MSG_NOTICE([You have /dev/random - Great])
 1443   AC_DEFINE(HAVE_DEV_RANDOM,,[Define if you have /dev/random])
 1444 fi
 1445 
 1446 CONFDIR=`eval echo "$CONFDIR"`
 1447 LOCALSTATEDIR=`eval echo "$LOCALSTATEDIR"`
 1448 
 1449 sysconfdir="$CONFDIR"
 1450 AC_SUBST(sysconfdir)
 1451 localstatedir="$LOCALSTATEDIR"
 1452 AC_SUBST(localstatedir)
 1453 
 1454 CPPFLAGS="$CPPFLAGS -DCONFDIR=\\\"$sysconfdir\\\""
 1455 CPPFLAGS="$CPPFLAGS -DSTATEDIR=\\\"$localstatedir\\\""
 1456 
 1457 AC_SUBST(CONFDIR)
 1458 AC_SUBST(LOCALSTATEDIR)
 1459 
 1460 AH_VERBATIM([NDEBUG], [/* Never ever ignore assertions */
 1461 #ifdef NDEBUG
 1462 #/**/undef/**/ NDEBUG
 1463 #endif])
 1464 
 1465 AC_CONFIG_FILES(Makefile src/Makefile pam/Makefile man/Makefile
 1466 gui/Makefile m4/Makefile pure-ftpd.conf puredb/Makefile
 1467 puredb/src/Makefile
 1468 man/pure-ftpd.8 man/pure-ftpwho.8 man/pure-mrtginfo.8 man/pure-uploadscript.8
 1469 man/pure-statsdecode.8 man/pure-quotacheck.8 man/pure-pw.8 man/pure-pwconvert.8
 1470 man/pure-authd.8 man/pure-certd.8)
 1471 
 1472 AC_OUTPUT