1dnl ProFTPD - FTP server daemon
2dnl Copyright (c) 1997, 1998 Public Flood Software
3dnl Copyright (c) 1999, 2000 MacGyver aka Habeeb J. Dihu <macgyver@tos.net>
4dnl Copyright (c) 2001-2021 The ProFTPD Project team
5dnl
6dnl This program is free software; you can redistribute it and/or modify
7dnl it under the terms of the GNU General Public License as published by
8dnl the Free Software Foundation; either version 2 of the License, or
9dnl (at your option) any later version.
10dnl
11dnl This program is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14dnl GNU General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
17dnl along with this program; if not, write to the Free Software
18dnl Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19dnl
20dnl Process this file with autoconf to produce a configure script.
21
22AC_INIT(include/conf.h)
23
24ac_core_modules="mod_core.o mod_xfer.o mod_rlimit.o mod_auth_unix.o mod_auth_file.o mod_auth.o mod_ls.o mod_log.o mod_site.o mod_delay.o mod_facts.o"
25ac_build_core_modules="modules/mod_core.o modules/mod_xfer.o modules/mod_rlimit.o modules/mod_auth_unix.o modules/mod_auth_file.o modules/mod_auth.o modules/mod_ls.o modules/mod_log.o modules/mod_site.o modules/mod_delay.o modules/mod_facts.o"
26
27dnl Get the OS type
28AC_CONFIG_AUX_DIR(./)
29AC_CANONICAL_SYSTEM
30
31ostype=`echo $build_os | sed 's/\..*$//g' | sed 's/-.*//g' | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
32osrel=`echo $build_os | sed 's/-.*//g' | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | tr '.' '_'`
33
34OSTYPE="-D$ostype"
35OSREL="-D$osrel"
36platform="\"$ostype ($osrel)\""
37
38if test "$OSTYPE" = "$OSREL" ; then
39  OSTYPE=""
40  platform="\"$ostype\""
41fi
42
43BUILD_OPTS=`echo "$ac_configure_args"`
44AC_DEFINE_UNQUOTED(PR_BUILD_OPTS, "$BUILD_OPTS", [Define the build options])
45AC_DEFINE_UNQUOTED(PR_PLATFORM, $platform, [Define the build platform])
46AC_SUBST(BUILD_OPTS)
47AC_SUBST(OSREL)
48AC_SUBST(OSTYPE)
49
50dnl MacOSX requires -traditional-cpp; autodetecting it isn't impossible
51dnl AFAIK, since assuming the need for -traditional-cpp breaks the build
52dnl on other OSes. -jwm, 30 Jan 2001
53if test "$OSTYPE" = "-DRHAPSODY5"; then
54  CFLAGS="$CFLAGS -traditional-cpp -D__OT__"
55fi
56
57dnl This needs to happen here, prior to the creation of the libtool script,
58dnl so that that script uses the correct shell-isms
59AC_SUBST(CONFIG_SHELL)
60
61dnl AC_PROG_LIBTOOL relies on the top_builddir variable
62top_builddir=.
63LT_INIT([dlopen])
64
65dnl If LT_INIT provides an empty value for CONFIG_SHELL for some reason (it
66dnl happens on my MacOSX 10.5 machine, for example), have a fallback.
67if test x"$CONFIG_SHELL" = x; then
68  CONFIG_SHELL="$SHELL"
69fi
70
71dnl Checks for programs.
72AC_PROG_CC
73AC_PROG_CXX
74AC_PROG_MAKE_SET
75AC_PROG_INSTALL
76AC_PROG_LIBTOOL
77
78dnl This test must come as early as possible after the compiler
79dnl configuration tests, because the choice of the file model can (in
80dnl principle) affect whether functions and headers are available,
81dnl whether they work, etc.
82AC_SYS_LARGEFILE
83
84# The native HP-UX 10 compiler needs -Ae to enable Extended ANSI compliance
85# (-Ae is the default in the native compiler under HP-UX 11).
86if test $ac_cv_prog_gcc = no -a "$OSTYPE" = "-DHPUX10"; then
87  CFLAGS="$CFLAGS -Ae"
88fi
89
90LDFLAGS="-L\$(top_srcdir)/lib -L\$(top_builddir)/lib $LDFLAGS"
91
92# AIX has issues with the -rdynamic linker flag.  How many different AIX
93# versions should we support here?
94if test $ac_cv_prog_gcc = yes && test "$OSTYPE" != "-DAIX7"; then
95  dnl Make sure to use the -rdynamic linker flag, for stacktraces
96  LDFLAGS="$LDFLAGS -rdynamic"
97fi
98
99# Record the current CPPFLAGS, LDFLAGS, and LIBS here
100ac_orig_cppflags="$CPPFLAGS"
101ac_orig_ldflags="$LDFLAGS"
102ac_orig_libs="$LIBS"
103
104if test $ac_cv_prog_gcc = yes; then
105  if test x"$CFLAGS" = "x-g -O2"; then
106    fullCFLAGS="-O2"
107  else
108    fullCFLAGS="$CFLAGS"
109  fi
110
111  dnl Compilation tests
112
113  dnl test for -malign-jumps=2 -malign-loops=2 -malign-functions=2
114  if echo $ac_cv_build_cpu | egrep "^i[[34567]]86$" > /dev/null 2>&1; then
115    AC_MSG_CHECKING([whether the C compiler accepts -malign-jumps -malign-loops -malign-functions])
116    CFLAGS="-malign-jumps=2 -malign-loops=2 -malign-functions=2"
117    AC_TRY_COMPILE(,,
118      AC_MSG_RESULT(yes); fullCFLAGS="$fullCFLAGS $CFLAGS",
119      AC_MSG_RESULT(no))
120  fi
121
122  dnl test for -Wall
123  AC_MSG_CHECKING([whether the C compiler accepts -Wall])
124  CFLAGS="-Wall"
125  AC_TRY_COMPILE(,,
126    AC_MSG_RESULT(yes); fullCFLAGS="$fullCFLAGS $CFLAGS",
127    AC_MSG_RESULT(no))
128
129  dnl test for -fno-omit-frame-pointer
130  AC_MSG_CHECKING([whether the C compiler accepts -fno-omit-frame-pointer])
131  CFLAGS="-fno-omit-frame-pointer"
132  AC_TRY_COMPILE(,,
133    AC_MSG_RESULT(yes); fullCFLAGS="$fullCFLAGS $CFLAGS",
134    AC_MSG_RESULT(no))
135
136  dnl test for -fno-strict-aliasing
137  AC_MSG_CHECKING([whether the C compiler accepts -fno-strict-aliasing])
138  CFLAGS="-fno-strict-aliasing"
139  AC_TRY_COMPILE(,,
140    AC_MSG_RESULT(yes); fullCFLAGS="$fullCFLAGS $CFLAGS",
141    AC_MSG_RESULT(no))
142
143  CFLAGS="-g2 $fullCFLAGS"
144fi
145
146dnl We substitute these in the man page templates.
147if test x$exec_prefix = xNONE ; then
148  exec_prefix=$prefix
149fi
150
151if test x$prefix = xNONE ; then
152  prefix=/usr/local
153  bindir=/usr/local/bin
154  datadir=/usr/local/share
155  libexecdir=/usr/local/libexec
156  sbindir=/usr/local/sbin
157fi
158
159BINDIR=`eval echo $bindir`
160AC_SUBST(BINDIR)
161DATADIR=`eval echo $datadir`
162AC_SUBST(DATADIR)
163INCLUDEDIR=`eval echo $includedir`
164AC_SUBST(INCLUDEDIR)
165LIBEXECDIR=`eval echo $libexecdir`
166AC_SUBST(LIBEXECDIR)
167LOCALSTATEDIR=`eval echo $localstatedir`
168AC_SUBST(LOCALSTATEDIR)
169RUNSTATEDIR=`eval echo $runstatedir`
170AC_SUBST(RUNSTATEDIR)
171PREFIX=`eval echo $prefix`
172AC_SUBST(PREFIX)
173SBINDIR=`eval echo $sbindir`
174AC_SUBST(SBINDIR)
175SYSCONFDIR=`eval echo $sysconfdir`
176AC_SUBST(SYSCONFDIR)
177
178LIB_DEPS="\"\""
179
180AC_ARG_VAR(LIBS, [linker flags, e.g. -l<lib>.{a,so} if you have nonstandard libraries to link])
181
182dnl configure command line options...
183
184dnl --with options.
185
186dnl ProFTPD comes bundled with GNU's implementation of getopt, to be used
187dnl in case the host system doesn't have getopt.  However, this causes
188dnl problems for certain builds of proftpd, e.g. ProFTPD and MySQL (which
189dnl itself similarly bundles a getopt implementation).  Thus, we need to
190dnl support/handle --without-getopt, to disable use of ProFTPD's getopt.
191dnl I don't know if MySQL supports any similar option.
192LIB_OBJS="pr_fnmatch.o sstrncpy.o strsep.o vsnprintf.o glibc-glob.o glibc-hstrerror.o glibc-mkstemp.o pr-syslog.o pwgrent.o hanson-tpl.o ccan-json.o openbsd-blowfish.o openbsd-bcrypt.o"
193
194AC_ARG_WITH(getopt,
195  [AC_HELP_STRING(
196      [--without-getopt],
197      [prevent proftpd from using its bundled getopt implementation.  This is done automatically if the host supports getopt, but may need to be explicitly used when combining proftpd with other applications, such as MySQL])
198  ],
199  [
200    if test "$withval" != "no" ; then
201      AC_CHECK_FUNCS(getopt,
202        [AC_CHECK_HEADERS(getopt.h)
203         AC_CHECK_FUNCS(getopt_long)
204         AC_DEFINE(PR_USE_SYSTEM_GETOPT, 1,
205           [Define if using system getopt support])],
206        [LIB_OBJS="$LIB_OBJS getopt.o getopt1.o"]
207      )
208    fi
209  ],
210  [
211    AC_CHECK_FUNCS(getopt,
212      [AC_CHECK_HEADERS(getopt.h)
213       AC_CHECK_FUNCS(getopt_long)
214       AC_DEFINE(PR_USE_SYSTEM_GETOPT, 1,
215         [Define if using system getopt support])],
216      [LIB_OBJS="$LIB_OBJS getopt.o getopt1.o"]
217    )
218  ])
219
220dnl Lastlog support
221AC_ARG_WITH(lastlog,
222  [AC_HELP_STRING(
223    [--with-lastlog=PATH],
224    [specify lastlog location (Default: /var/adm/lastlog)],
225  )],
226  [
227    if test "x$withval" = "xno" ; then
228      # nothing to do
229      foo=bar
230
231    elif test -n "$withval" ; then
232      AC_DEFINE(PR_USE_LASTLOG, 1, [Define if enabling lastlog support.])
233      AC_CHECK_HEADERS(lastlog.h paths.h)
234
235      if test "x${withval}" != "xyes" ; then
236        pr_lastlog_path="$withval"
237
238      else
239        dnl Try to determine the correct lastlog location (be it file or
240        dnl directory) automagically.
241        AC_MSG_CHECKING([for LASTLOG_FILE])
242        AC_TRY_COMPILE([
243            #include <sys/types.h>
244            #include <utmp.h>
245            #ifdef HAVE_LASTLOG_H
246            #  include <lastlog.h>
247            #endif
248            #ifdef HAVE_PATHS_H
249            #  include <paths.h>
250            #endif
251            #ifdef HAVE_LOGIN_H
252            # include <login.h>
253            #endif
254          ],
255          [
256            char *lastlog = LASTLOG_FILE;
257          ],
258          [
259            AC_MSG_RESULT(yes)
260          ],
261          [
262            AC_MSG_RESULT(no)
263            AC_MSG_CHECKING([for _PATH_LASTLOG])
264            AC_TRY_COMPILE([
265                #include <sys/types.h>
266                #include <utmp.h>
267                #ifdef HAVE_LASTLOG_H
268                #  include <lastlog.h>
269                #endif
270                #ifdef HAVE_PATHS_H
271                #  include <paths.h>
272                #endif
273              ],
274              [
275                char *lastlog = _PATH_LASTLOG;
276              ],
277              [
278                AC_MSG_RESULT(yes)
279              ],
280              [
281                AC_MSG_RESULT(no)
282                found_lastlog_path=no
283              ])
284          ])
285
286         if test -z "$pr_lastlog_path" ; then
287           if test x"$found_lastlog_path" = x"no" ; then
288             for f in /var/log/lastlog /var/adm/lastlog /usr/adm/lastlog /etc/security/lastlog ; do
289               AC_MSG_CHECKING([for $f])
290               if (test -d "$f" || test -f "$f") ; then
291                 pr_lastlog_path=$f
292                 AC_MSG_RESULT(yes)
293
294               else
295                 AC_MSG_RESULT(no)
296               fi
297             done
298
299             if test -z "$pr_lastlog_path" ; then
300               AC_MSG_WARN([** Cannot find lastlog **])
301             fi
302          fi
303        fi
304      fi
305
306      if test -n "$pr_lastlog_path" ; then
307        AC_DEFINE_UNQUOTED(PR_LASTLOG_PATH, "`eval echo "$pr_lastlog_path"`", [Define the lastlog path])
308      fi
309    fi
310  ])
311
312dnl Modules...'nuff said.
313AC_ARG_WITH(includes,
314  [AC_HELP_STRING(
315    [--with-includes=LIST],
316    [add additional include paths to proftpd. LIST is a colon-separated list of include paths to add e.g. --with-includes=/some/mysql/include:/my/include])
317  ],
318  [
319    if test x"$withval" != x; then
320      if test x"$withval" = xyes; then
321        AC_MSG_ERROR([--with-includes parameter missing required colon-separated list of include paths])
322      fi
323
324      if test x"$withval" != xno; then
325        ac_addl_includes=`echo "$withval" | sed -e 's/:/ /g'` ;
326        for ainclude in $ac_addl_includes; do
327          if test x"$ac_build_addl_includes" = x ; then
328            ac_build_addl_includes="-I$ainclude"
329          else
330            ac_build_addl_includes="-I$ainclude $ac_build_addl_includes"
331          fi
332        done
333        CPPFLAGS="$CPPFLAGS $ac_build_addl_includes"
334      fi
335    fi
336  ])
337
338AC_ARG_WITH(libraries,
339  [AC_HELP_STRING(
340    [--with-libraries=LIST],
341    [add additional library paths to proftpd. LIST is a colon-separated list of library paths to add e.g. --with-libraries=/some/mysql/libdir:/my/libs])
342  ],
343  [
344    if test x"$withval" != x; then
345      if test x"$withval" = xyes; then
346        AC_MSG_ERROR([--with-libraries parameter missing required colon-separated list of library paths])
347      fi
348
349      if test x"$withval" != xno; then
350        ac_addl_libdirs=`echo "$withval" | sed -e 's/:/ /g'` ;
351        for alibdir in $ac_addl_libdirs; do
352          if test x"$ac_build_addl_libdirs" = x ; then
353            ac_build_addl_libdirs="-L$alibdir"
354          else
355            ac_build_addl_libdirs="-L$alibdir $ac_build_addl_libdirs"
356          fi
357        done
358        LDFLAGS="$LDFLAGS $ac_build_addl_libdirs"
359      fi
360    fi
361  ])
362
363dnl This variable is used to impose a certain ordering between mod_ifsession
364dnl and mod_cap, per Bug#3576
365ifsession_requested="false"
366AC_ARG_WITH(modules,
367  [AC_HELP_STRING(
368    [--with-modules=LIST],
369    [add additional modules to proftpd. LIST is a colon-separated list of modules to add e.g. --with-modules=mod_readme:mod_ifsession])
370  ],
371  [
372    if test x"$withval" != x; then
373      if test x"$withval" = xyes; then
374        AC_MSG_ERROR([--with-modules parameter missing required colon-separated list of modules])
375      fi
376
377      if test x"$withval" != xno; then
378        modules_list=`echo "$withval" | sed -e 's/:/ /g'`;
379
380        for amodule in $modules_list; do
381          if test x"$amodule" = xmod_dso ; then
382            AC_MSG_ERROR([use --enable-dso instead of --with-modules=mod_dso for DSO support])
383          fi
384
385          if test x"$amodule" = xmod_ifsession ; then
386            ifsession_requested="true"
387          fi
388
389          if test x"$amodule" = xmod_lang ; then
390            AC_MSG_ERROR([use --enable-nls instead of --with-modules=mod_lang for NLS/UTF8 support])
391          fi
392
393          if test x"$amodule" = xmod_memcache ; then
394            AC_MSG_ERROR([use --enable-memcache instead of --with-modules=mod_memcache for Memcache support])
395          fi
396
397          if test x"$amodule" = xmod_redis ; then
398            AC_MSG_ERROR([use --enable-redis instead of --with-modules=mod_redis for Redis support])
399          fi
400        done
401
402        # Trim off any leading/trailing colons, and collapse double-colons
403        # into single colons; these are common typos.
404        ac_static_modules=`echo "$withval" | sed 's/::/:/g' | sed 's/^://' | sed 's/:$//' | sed -e 's/:/.o /g'`.o ;
405
406        for amodule in $ac_static_modules; do
407          ac_build_static_modules="modules/$amodule $ac_build_static_modules"
408        done
409
410        dnl Make sure that mod_ifsession, if present in the list, appears at
411        dnl the end.
412        if test x"$ifsession_requested" = xtrue; then
413          ac_static_modules=`echo "$ac_static_modules" | sed -e 's/mod_ifsession\.o//g'`
414          ac_static_modules="$ac_static_modules mod_ifsession.o"
415
416          ac_build_static_modules=`echo "$ac_build_static_modules" | sed -e 's/modules\/mod_ifsession\.o//g'`
417          ac_build_static_modules="$ac_build_static_modules modules/mod_ifsession.o";
418        fi
419      fi
420    fi
421  ])
422
423dnl Memcache
424if test x"$enable_memcache" = xyes; then
425  AC_CHECK_LIB(memcached, memcached_create)
426  AC_CHECK_LIB(memcachedutil, libmemcached_util_ping)
427
428  # Yes, we DO want mod_memcache AFTER the other modules in the static
429  # module list. Otherwise, the module load ordering will be such that
430  # memcache support will not work as expected
431  ac_static_modules="$ac_static_modules mod_memcache.o"
432  ac_build_static_modules="$ac_build_static_modules modules/mod_memcache.o"
433fi
434
435dnl Redis
436if test x"$enable_redis" = xyes; then
437  AC_CHECK_LIB(hiredis, redisConnect)
438
439  # Yes, we DO want mod_redis AFTER the other modules in the static
440  # module list. Otherwise, the module load ordering will be such that
441  # Redis support will not work as expected.
442  ac_static_modules="$ac_static_modules mod_redis.o"
443  ac_build_static_modules="$ac_build_static_modules modules/mod_redis.o"
444fi
445
446dnl List of modules which are not allowed to be built as DSOs
447ac_unshareable_modules="mod_auth mod_rlimit mod_auth_unix mod_core mod_dso mod_ls mod_xfer mod_log mod_site mod_cap mod_ctrls mod_memcache mod_redis"
448
449AC_ARG_WITH(shared,
450  [AC_HELP_STRING(
451    [--with-shared=LIST],
452    [build DSO modules for proftpd. LIST is a colon-separated list of modules to build as DSOs e.g. --with-shared=mod_rewrite:mod_ifsession])
453  ],
454  [
455    if test x"$withval" != x; then
456      if test x"$withval" = xyes; then
457        AC_MSG_ERROR([--with-shared parameter missing required colon-separated list of modules])
458      fi
459
460      if test x"$withval" != xno; then
461        # Trim off any leading/trailing colons, and collapse double-colons
462        # into single colons; these are common typos.
463        shared_modules=`echo "$withval" | sed 's/::/:/g'| sed 's/^://' | sed 's/:$//' | sed -e 's/:/ /g'`;
464        ac_shared_modules=`echo "$withval" | sed 's/::/:/g'| sed 's/^://' | sed 's/:$//' | sed -e 's/:/.la /g'`.la;
465
466        # First double-check that the given list does not contain any
467        # unshareable modules
468        for amodule in $pr_shared_modules; do
469          for smodule in $ac_unshareable_modules; do
470            if test x"$amodule" = x"$smodule"; then
471              AC_MSG_ERROR([cannot build $amodule as a shared module])
472            fi
473          done
474        done
475
476        for amodule in $ac_shared_modules; do
477          ac_build_shared_modules="modules/$amodule $ac_build_shared_modules"
478        done
479
480        PR_CHECK_CC_OPT(Werror=implicit-function-declaration)
481      fi
482    fi
483  ])
484
485dnl Configuration location of mysql_config
486my_config="mysql_config"
487AC_ARG_WITH(mysql-config,
488  [AC_HELP_STRING(
489    [--with-mysql-config=PATH],
490    [configure location of the MySQL mysql_config script (default=mysql_config)])
491  ],
492  [
493    if test x"$withval" != x; then
494      my_config=`echo "$withval"`
495
496      if test -z "$my_config"; then
497        my_config="no"
498
499      elif test x"$my_config" = xno; then
500        # do nothing
501        foo=bar
502
503      elif test x"$my_config" = xyes; then
504        # Use the default
505        my_config="mysql_config"
506
507      elif test -x "$my_config"; then
508        # do nothing
509        foo=bar
510
511      else
512        AC_MSG_ERROR([mysql_config path $my_config is not executable])
513      fi
514
515    else
516      my_config="no"
517    fi
518  ])
519
520dnl Configuration location of openssl cmdline
521openssl_cmdline="openssl"
522AC_ARG_WITH(openssl-cmdline,
523  [AC_HELP_STRING(
524    [--with-openssl-cmdline=PATH],
525    [configure location of the openssl(1) command-line tool (default=openssl)])
526  ],
527  [
528    if test x"$withval" != x; then
529      openssl_cmdline=`echo "$withval"`
530
531      if test -z "$openssl_cmdline"; then
532        openssl_cmdline="no"
533
534      elif test x"$openssl_cmdline" = xno; then
535        # do nothing
536        foo=bar
537
538      elif test x"$openssl_cmdline" = xyes; then
539        # Use the default
540        openssl_cmdline="openssl"
541
542      elif test -x "$openssl_cmdline"; then
543        # do nothing
544        foo=bar
545
546      else
547        AC_MSG_ERROR([openssl path $openssl_cmdline is not executable])
548      fi
549
550    else
551      openssl_cmdline="no"
552    fi
553  ])
554
555
556dnl Configuration location of pg_config
557pg_config="pg_config"
558AC_ARG_WITH(postgres-config,
559  [AC_HELP_STRING(
560    [--with-postgres-config=PATH],
561    [configure location of the Postgres pg_config script (default=pg_config)])
562  ],
563  [
564    if test x"$withval" != x; then
565      pg_config=`echo "$withval"`
566
567      if test -z "$pg_config"; then
568        pg_config="no"
569
570      elif test x"$pg_config" = xno; then
571        # do nothing
572        foo=bar
573
574      elif test x"$pg_config" = xyes; then
575        # Use the default
576        pg_config="pg_config"
577
578      elif test -x "$pg_config"; then
579        # do nothing
580        foo=bar
581
582      else
583        AC_MSG_ERROR([pg_config path $pg_config is not executable])
584      fi
585
586    else
587      pg_config="no"
588    fi
589  ])
590
591dnl Configurable location of the pkgconfig file
592pkgconfigdir=NONE
593AC_ARG_WITH(pkgconfig,
594  [AC_HELP_STRING(
595    [--with-pkgconfig=PATH],
596    [configure directory that will contain the proftpd.pc pkgconfig file (default=lib/pkgconfig)])
597  ],
598  [
599    if test x"$withval" != x; then
600      if test x"$withval" = xyes; then
601        AC_MSG_ERROR([--with-pkgconfig parameter missing required directory path])
602      fi
603
604      if test x"$withval" != xno; then
605        pkgconfigdir=`echo "$withval"`
606      fi
607    fi
608  ])
609
610dnl --enable/--disable options.
611
612AC_ARG_ENABLE(auth-file,
613  [AC_HELP_STRING(
614    [--disable-auth-file],
615    [omit mod_auth_file from core modules])
616  ],
617  [
618    if test "$enableval" = "no"; then
619      ac_core_modules=`echo "$ac_core_modules" | sed -e 's/mod_auth_file\.o//'`
620      ac_build_core_modules=`echo "$ac_build_core_modules" | sed -e 's/modules\/mod_auth_file\.o//'`
621    fi
622  ])
623
624dnl Auto-detection of shadow passwords.
625AC_ARG_ENABLE(autoshadow,
626  [AC_HELP_STRING(
627    [--enable-autoshadow],
628    [enable run-time auto-detection of shadowed passwords (requires shadow)])
629  ],
630  [
631    dnl AIX does not have shadow file/library support.  Try to prevent a
632    dnl bad build if the admin, configuring on an AIX box, uses this option.
633    if test "$enableval" = "yes" && test "$OSTYPE" = "-DAIX4"; then
634      AC_MSG_WARN(AIX does not support traditional shadowed passwords)
635      enableval="no"
636    fi
637
638    if test "$enableval" != "no" ; then
639      AC_DEFINE(PR_USE_SHADOW, 1, [Define if using /etc/shadow files.])
640      AC_DEFINE(PR_USE_AUTO_SHADOW, 1,
641      [Define if auto-detection of shadow passwords is wanted.])
642      force_shadow="yes"
643    fi ])
644
645dnl PAM support.
646AC_ARG_ENABLE(auth-pam,
647  [AC_HELP_STRING(
648    [--enable-auth-pam],
649    [enable PAM support (default=auto)])
650  ],
651  [
652    if test "$enableval" = "no"; then
653      if test `echo $ac_static_modules | grep -c mod_auth_pam` != "0"; then
654        AC_MSG_ERROR([You cannot run configure with --disable-auth-pam and include mod_auth_pam in --with-modules at the same time])
655      fi
656
657      if test `echo $ac_shared_modules | grep -c mod_auth_pam` != "0"; then
658        AC_MSG_ERROR([You cannot run configure with --disable-auth-pam and include mod_auth_pam in --with-shared at the same time])
659      fi
660    fi
661  ])
662
663dnl Optional workaround for broken getaddrinfo on some systems (e.g. HP-UX 11.x)
664AC_ARG_ENABLE(builtin-getaddrinfo,
665  [AC_HELP_STRING(
666    [--enable-builtin-getaddrinfo],
667    [force use of builtin getaddrinfo (default=no)])
668  ],
669  [
670    if test x"$enableval" = xyes; then
671      AC_DEFINE(PR_USE_GETADDRINFO, 1, [Define if using builtin getaddrinfo()])
672    fi
673  ])
674
675dnl Since getaddrinfo() is broken on HP-UX 11.x, we automatically use the
676dnl builtin version.
677if test "$OSTYPE" = "-DHPUX11"; then
678  AC_MSG_WARN([HP-UX 11 has broken getaddrinfo(), using builtin version])
679  AC_DEFINE(PR_USE_GETADDRINFO, 1, [Define if using builtin getaddrinfo()])
680fi
681
682dnl Workaround for broken getnameinfo on some systems
683AC_ARG_ENABLE(builtin-getnameinfo,
684  [AC_HELP_STRING(
685    [--enable-builtin-getnameinfo],
686    [force use of builtin getnameinfo (default=no)])
687  ],
688  [
689    if test x"$enableval" = xyes; then
690      AC_DEFINE(PR_USE_GETNAMEINFO, 1, [Define if using builtin getnameinfo()])
691    fi
692  ])
693
694dnl Capabilities support
695AC_ARG_ENABLE(cap,
696  [AC_HELP_STRING(
697    [--enable-cap],
698    [enable POSIX.1e capabilities (default=yes on Linux)])
699  ])
700
701dnl Controls support
702AC_ARG_ENABLE(ctrls,
703  [AC_HELP_STRING(
704    [--enable-ctrls],
705    [enable proftpd controls via ftpdctl (default=no)])
706  ],
707  [ if test x"$enableval" = xyes ; then
708      AC_DEFINE(PR_USE_CTRLS, 1, [Define if using controls support.])
709    fi
710  ])
711
712dnl POSIX ACL support
713AC_ARG_ENABLE(facl,
714  [AC_HELP_STRING(
715    [--enable-facl],
716    [enable support for POSIX ACLs])
717  ])
718
719dnl Curses/ncurses support
720AC_ARG_ENABLE(curses,
721  [AC_HELP_STRING(
722    [--disable-curses],
723    [disable use of curses (default=no)])
724  ])
725
726dnl DSO support
727AC_ARG_ENABLE(dso,
728  [AC_HELP_STRING(
729    [--enable-dso],
730    [add mod_dso to core modules])
731  ],
732  [
733    if test x"$enableval" = x"yes"; then
734      ac_core_modules="$ac_core_modules mod_dso.o"
735      ac_build_core_modules="$ac_build_core_modules modules/mod_dso.o"
736
737      MAIN_LDFLAGS="-L\$(top_srcdir)/lib/libltdl -dlopen self -export-dynamic"
738      MAIN_LIBS="$MAIN_LIBS \$(LIBLTDL)"
739
740      MODULE_LDFLAGS="-avoid-version -export-dynamic -module"
741
742      INSTALL_DEPS="install-libltdl"
743      LIB_DEPS="libltdl"
744      MODULE_DEPS="libltdl"
745      AC_DEFINE(PR_USE_DSO, 1, [Define if using DSO support.])
746
747      dnl Run configure scripts in subdirectories
748      LT_CONFIG_LTDL_DIR([lib/libltdl])
749      LTDL_INIT([convenience])
750
751      dnl Even though this macro is deprecated, we need to use it to
752      dnl specifically tell ltdl that it is NOT to use any system directories,
753      dnl and ONLY to use this bundled location.
754      LTDL_CONVENIENCE([lib/libltdl])
755    fi
756  ])
757
758dnl ident (RFC1413) support
759AC_ARG_ENABLE(ident,
760  [AC_HELP_STRING(
761    [--enable-ident],
762    [enable use of ident (RFC1413) lookups (default=no)])
763  ])
764
765dnl Memcache support
766AC_ARG_ENABLE(memcache,
767  [AC_HELP_STRING(
768    [--enable-memcache],
769    [enable support for memcache (default=no)])
770  ],
771  [ if test x"$enableval" = xyes ; then
772      AC_DEFINE(PR_USE_MEMCACHE, 1, [Define if using Memcache support.])
773    fi
774  ])
775
776dnl NLS support
777ENABLE_NLS="\"\""
778AC_ARG_ENABLE(nls,
779  [AC_HELP_STRING(
780    [--enable-nls],
781    [enable Native Language Support (NLS) (default=no)])
782  ],
783  [ if test x"$enableval" = x"yes" ; then
784
785      dnl The libintl library is only needed on non-GNU systems.  If it
786      dnl is not installed, and the admin enables NLS support, then we
787      dnl should abort.
788
789      AC_CHECK_LIB(intl, bindtextdomain,
790        [ac_build_addl_libs="-lintl $ac_build_addl_libs" UTILS_LIBS="-lintl"
791         AC_DEFINE(HAVE_LIBINTL, 1, [Define if libintl is present.])
792         AC_DEFINE(PR_USE_NLS, 1, [Define if using NLS support.])
793         ENABLE_NLS="1"
794        ],
795        [AC_CHECK_LIB(c, bindtextdomain,
796          [AC_DEFINE(PR_USE_NLS, 1, [Define if using NLS support.])
797           ENABLE_NLS="1"
798          ],
799          [AC_MSG_ERROR([libintl support, required for NLS, not present -- aborting])]
800        ])
801      )
802
803      dnl Similarly, the libiconv library is only needed on some non-GNU
804      dnl systems.  Note that some systems redefine the iconv_open function
805      dnl to something else (Bug#3682), e.g. libiconv_open.
806      AC_CHECK_LIB(iconv, iconv_open,
807        [LIBS="$LIBS -liconv"
808         AC_DEFINE(HAVE_LIBICONV, 1, [Define if libiconv is present.])
809         AC_DEFINE(PR_USE_NLS, 1, [Define if using NLS support.])
810         ENABLE_NLS="1"
811        ],
812        [AC_CHECK_LIB(iconv, libiconv_open,
813          [LIBS="$LIBS -liconv"
814           AC_DEFINE(HAVE_LIBICONV, 1, [Define if libiconv is present.])
815           AC_DEFINE(PR_USE_NLS, 1, [Define if using NLS support.])
816           ENABLE_NLS="1"
817          ],
818          [AC_CHECK_LIB(c, iconv_open,
819            [AC_DEFINE(PR_USE_NLS, 1, [Define if using NLS support.])
820             ENABLE_NLS="1"
821            ],
822            [AC_MSG_ERROR([libiconv support, required for NLS, not present -- aborting])]
823          ])
824        ])
825      )
826    fi
827  ])
828
829AC_ARG_ENABLE(nonblocking-log-open,
830  [AC_HELP_STRING(
831    [--disable-nonblocking-log-open],
832    [disable use of nonblocking open of log files (default=no)])
833  ])
834
835AC_ARG_ENABLE(ncurses,
836  [AC_HELP_STRING(
837    [--disable-ncurses],
838    [disable use of ncurses (default=no)])
839  ])
840
841AC_ARG_ENABLE(pcre,
842  [AC_HELP_STRING(
843    [--enable-pcre],
844    [enable use of PCRE for POSIX regular expressions rather than the system library (default=no)],
845  )],
846  [
847    if test x"$enableval" = xyes ; then
848      AC_DEFINE(PR_USE_PCRE, 1, [Define if using PCRE support.])
849      ac_build_addl_libs="$ac_build_addl_libs -lpcreposix -lpcre"
850
851      # Check for other PCRE-specific functionality here
852      saved_ldflags="$LDFLAGS"
853      saved_libs="$LIBS"
854      saved_cppflags="$CPPFLAGS"
855
856      # fiddle with CPPFLAGS, LDFLAGS
857      CPPFLAGS="$CPPFLAGS $ac_build_addl_includes"
858      LDFLAGS="$LDFLAGS $ac_build_addl_libdirs"
859
860      dnl Splice out -lsupp, since that library hasn't been built yet
861      LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
862      LIBS="$LIBS -lpcre -lpcreposix"
863
864      AC_MSG_CHECKING([for PCRE's pcre_free_study])
865      AC_TRY_LINK(
866        [ #ifdef HAVE_STDDEF_H
867          # include <stddef.h>
868          #endif
869          #ifdef HAVE_STDLIB_H
870          # include <stdlib.h>
871          #endif
872          #ifdef HAVE_SYS_TYPES_H
873          # include <sys/types.h>
874          #endif
875          #include <pcre.h>
876        ],
877        [
878          pcre_extra *extra = NULL;
879          pcre_free_study(extra);
880        ],
881        [
882          AC_MSG_RESULT(yes)
883          AC_DEFINE(HAVE_PCRE_PCRE_FREE_STUDY, 1, [Define if you have PCRE's pcre_free_study])
884        ],
885        [
886          AC_MSG_RESULT(no)
887        ]
888      )
889
890      # restore CPPFLAGS, LDFLAGS
891      CPPFLAGS="$saved_cppflags"
892      LDFLAGS="$saved_ldflags"
893      LIBS="$saved_libs"
894    fi
895  ])
896
897dnl Redis support
898AC_ARG_ENABLE(redis,
899  [AC_HELP_STRING(
900    [--enable-redis],
901    [enable support for Redis (default=no)])
902  ],
903  [ if test x"$enableval" = xyes ; then
904      AC_CHECK_HEADER(hiredis/hiredis.h,
905        [AC_DEFINE(HAVE_HIREDIS_HIREDIS_H, 1, [Define if hiredis.h is present.])
906         AC_DEFINE(PR_USE_REDIS, 1, [Define if using Redis support.])
907      ])
908
909      # Check for the redisReconnect() function in Hiredis; earlier versions
910      # did not have this.
911      saved_ldflags="$LDFLAGS"
912      saved_libs="$LIBS"
913      saved_cppflags="$CPPFLAGS"
914
915      # fiddle with CPPFLAGS, LDFLAGS
916      CPPFLAGS="$CPPFLAGS $ac_build_addl_includes"
917      LDFLAGS="$LDFLAGS $ac_build_addl_libdirs"
918
919      dnl Splice out -lsupp, since that library hasn't been built yet
920      LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
921      LIBS="$LIBS -lhiredis"
922
923      AC_MSG_CHECKING([for Hiredis' redisReconnect])
924      AC_TRY_LINK(
925        [
926          #ifdef HAVE_STDLIB_H
927          # include <stdlib.h>
928          #endif
929          #ifdef HAVE_SYS_TYPES_H
930          # include <sys/types.h>
931          #endif
932          #include <hiredis/hiredis.h>
933        ],
934        [
935          (void) redisReconnect(NULL);
936        ],
937        [
938          AC_MSG_RESULT(yes)
939          AC_DEFINE(HAVE_HIREDIS_REDISRECONNECT, 1, [Define if you have Hiredis' redisReconnect])
940        ],
941        [
942          AC_MSG_RESULT(no)
943        ]
944      )
945
946      # restore CPPFLAGS, LDFLAGS
947      CPPFLAGS="$saved_cppflags"
948      LDFLAGS="$saved_ldflags"
949      LIBS="$saved_libs"
950    fi
951  ])
952
953dnl Workaround for broken setpassent on FreeBSD.
954AC_ARG_ENABLE(force-setpassent,
955  [AC_HELP_STRING(
956    [--enable-force-setpassent],
957    [force use of setpassent (default=no on FreeBSD)])
958  ])
959
960dnl IPv6 support.
961AC_ARG_ENABLE(ipv6,
962  [AC_HELP_STRING(
963    [--disable-ipv6],
964    [disable IPv6 support (default=no)])
965  ])
966
967dnl OpenSSL support
968pr_use_openssl=""
969AC_ARG_ENABLE(openssl,
970  [AC_HELP_STRING(
971    [--enable-openssl],
972    [enable OpenSSL support (default=no)])
973  ],
974  [ if test x"$enableval" = xno ; then
975      pr_use_openssl="no"
976    fi
977  ])
978
979dnl Sodium support
980pr_use_sodium=""
981AC_ARG_ENABLE(sodium,
982  [AC_HELP_STRING(
983    [--enable-sodium],
984    [enable Sodium support (default=auto)])
985  ],
986  [ if test x"$enableval" = xno ; then
987      pr_use_sodium="no"
988    fi
989  ])
990
991dnl Sendfile support.
992AC_ARG_ENABLE(sendfile,
993  [AC_HELP_STRING(
994    [--disable-sendfile],
995    [disable sendfile support (default=no)])
996  ])
997
998dnl Check for enabled shadow password support.
999AC_ARG_ENABLE(shadow,
1000  [AC_HELP_STRING(
1001    [--enable-shadow],
1002    [force compilation of shadowed password support])
1003  ],
1004  [
1005    dnl AIX does not have shadow file/library support.  Try to prevent a
1006    dnl bad build if the admin, configuring on an AIX box, uses this option.
1007    if test "$enableval" = "yes" && test "$OSTYPE" = "-DAIX4"; then
1008      AC_MSG_WARN([AIX does not support traditional shadowed passwords])
1009      enableval="no"
1010    fi
1011
1012    if test "$enableval" = "no" ; then
1013      use_shadow=""
1014      force_shadow="no"
1015    else
1016      AC_DEFINE(PR_USE_SHADOW, 1, [Define if using shadow password support.])
1017      force_shadow="yes"
1018    fi ])
1019
1020dnl Enable support for Tru64's C2 SIA authentication
1021AC_ARG_ENABLE(sia,
1022  [AC_HELP_STRING(
1023    [--enable-sia],
1024    [enable SIA authentication support (Tru64)])
1025  ],
1026  [
1027    if test x"$enableval" = xyes ; then
1028
1029      dnl Tru64's C2/SIA authentication requires these headers
1030      AC_CHECK_HEADERS(sia.h siad.h sys/security.h)
1031
1032      AC_CHECK_LIB(security, set_auth_parameters)
1033      AC_CHECK_FUNCS(set_auth_parameters)
1034
1035      AC_CHECK_LIB(sec, getprpwent)
1036      AC_CHECK_FUNCS(getprpwent)
1037
1038      AC_DEFINE(PR_USE_SIA, 1, [Define if using Tru64 SIA support.])
1039    fi
1040  ])
1041
1042dnl Test support
1043ENABLE_TESTS="\"\""
1044AC_ARG_ENABLE(tests,
1045  [AC_HELP_STRING(
1046    [--enable-tests],
1047    [enable unit tests (default=no)])
1048  ],
1049  [
1050    if test x"$enableval" != xno ; then
1051      AC_CHECK_HEADERS(check.h)
1052
1053      AC_CHECK_LIB(check, tcase_create,
1054        [AC_DEFINE(HAVE_LIBCHECK, 1, [Define if libcheck is present.])
1055         ENABLE_TESTS="1"
1056         AC_DEFINE(PR_USE_TESTS, 1, [Define if testsuite support is enabled.])
1057        ],
1058        [
1059         AC_MSG_ERROR([libcheck support, required for tests, not present -- aborting])
1060        ]
1061      )
1062
1063      if test x"$enableval" != x"nonetwork" ; then
1064        AC_DEFINE(PR_USE_NETWORK_TESTS, 1, [Define if non-local network tests are enabled.])
1065      fi
1066    fi
1067  ])
1068
1069dnl Trace support.
1070AC_ARG_ENABLE(trace,
1071  [AC_HELP_STRING(
1072    [--disable-trace],
1073    [disable trace support (default=no)])
1074  ])
1075
1076dnl Extended attribute (xattr) support
1077AC_ARG_ENABLE(xattr,
1078  [AC_HELP_STRING(
1079    [--disable-xattr],
1080    [disable extended attribute support (default=auto)])
1081  ])
1082
1083dnl Enable developer code
1084pr_devel_cflags="-g3 -O0 -Wcast-align -Wchar-subscripts -Winline -Wstrict-prototypes -Wmissing-declarations -Wnested-externs -Wpointer-arith -Wshadow -Wundef"
1085pr_devel_libs=""
1086
1087AC_ARG_ENABLE(devel,
1088  [AC_HELP_STRING(
1089    [--enable-devel],
1090    [enable developer-only code (default=no)])
1091  ],
1092  [
1093    if test x"$enableval" != xno ; then
1094      devel="yes"
1095
1096      # Additional warnings but only for developer mode.  Note that
1097      # -Wconversion is a bit noisy at the moment, thus why we
1098      # selectively choose which warnings to enable.
1099      PR_CHECK_CC_OPT(Wdangling-else)
1100      PR_CHECK_CC_OPT(Wextra)
1101      PR_CHECK_CC_OPT(Werror=implicit-function-declaration)
1102      PR_CHECK_CC_OPT(Winit-self)
1103      PR_CHECK_CC_OPT(Wno-missing-field-initializers)
1104      PR_CHECK_CC_OPT(Wno-unused-parameter)
1105      PR_CHECK_CC_OPT(Wnull-dereference)
1106      PR_CHECK_CC_OPT(Wstrict-prototypes)
1107      PR_CHECK_CC_OPT(fdelete-null-pointer-checks)
1108
1109      dnl Check to see if specific developer flags were requested
1110
1111      if test `echo $enableval | grep -c coredump` = "1" ; then
1112        pr_devel_cflags="-DPR_DEVEL_COREDUMP $pr_devel_cflags"
1113      fi
1114
1115      if test `echo $enableval | grep -c coverage` = "1" ; then
1116        pr_devel_cflags="-DPR_DEVEL_COVERAGE --coverage $pr_devel_cflags"
1117        pr_devel_libs="--coverage $pr_devel_libs"
1118      fi
1119
1120      if test `echo $enableval | grep -c nodaemon` = "1" ; then
1121        pr_devel_cflags="-DPR_DEVEL_NO_DAEMON $pr_devel_cflags"
1122      fi
1123
1124      if test `echo $enableval | grep -c nofork` = "1" ; then
1125        pr_devel_cflags="-DPR_DEVEL_NO_FORK $pr_devel_cflags"
1126      fi
1127
1128      if test `echo $enableval | grep -c profile` = "1" ; then
1129        pr_devel_cflags="-DPR_DEVEL_PROFILE -p -pg $pr_devel_cflags"
1130        pr_devel_libs="-pg $pr_devel_libs"
1131      fi
1132
1133      if test `echo $enableval | grep -c sanitize` = "1" ; then
1134        pr_devel_cflags="-fsanitize=address $pr_devel_cflags"
1135        pr_devel_libs="-fsanitize=address $pr_devel_libs"
1136
1137        # Determine whether we need to link with libasan (gcc) or not (clang)
1138        AC_MSG_CHECKING([whether the C compiler accepts -lasan])
1139        saved_ldflags=$LDFLAGS
1140        LDFLAGS="-lasan $LDFLAGS"
1141        AC_TRY_LINK(
1142          [
1143          ],
1144          [
1145            int i;
1146            i = 7;
1147          ],
1148          [
1149            AC_MSG_RESULT(yes)
1150            pr_devel_libs="-lasan $pr_devel_libs"
1151          ],
1152          [
1153            AC_MSG_RESULT(no)
1154          ]
1155        )
1156        LDFLAGS=$saved_ldflags
1157      fi
1158
1159      dnl Here is where we WOULD check for the stacktrace developer option.
1160      dnl However, as of Issue 276, stacktraces are now enabled by default.
1161
1162      if test `echo $enableval | grep -c timing` = "1"; then
1163        pr_devel_cflags="-DPR_DEVEL_TIMING $pr_devel_cflags"
1164      fi
1165
1166    else
1167      devel="no"
1168    fi
1169  ])
1170
1171dnl The "tunable" options, from include/options.h
1172AC_ARG_ENABLE(buffer-size,
1173  [AC_HELP_STRING(
1174    [--enable-buffer-size],
1175    [tune the the size (in bytes) of internal buffers (default=1024)])
1176  ],
1177  [
1178    if test "$enableval" = "yes" || test "$enableval" = "no" ; then
1179      AC_MSG_WARN(buffer size defaulting to 1024 bytes)
1180      AC_DEFINE_UNQUOTED(PR_TUNABLE_BUFFER_SIZE, 1024,
1181      [Default buffer size])
1182    else
1183      AC_DEFINE_UNQUOTED(PR_TUNABLE_BUFFER_SIZE, $enableval,
1184      [Default buffer size])
1185    fi
1186  ])
1187
1188AC_ARG_ENABLE(pool-size,
1189  [AC_HELP_STRING(
1190    [--enable-pool-size],
1191    [tune the size (in bytes) of memory pools (default=512)])
1192  ],
1193  [
1194    if test "$enableval" = "yes" || test "$enableval" = "no" ; then
1195      AC_MSG_WARN(pool size defaulting to 512 bytes)
1196      AC_DEFINE_UNQUOTED(PR_TUNABLE_NEW_POOL_SIZE, 512,
1197      [Default pool size])
1198    else
1199      AC_DEFINE_UNQUOTED(PR_TUNABLE_NEW_POOL_SIZE, $enableval,
1200      [Default pool size])
1201    fi
1202  ])
1203
1204AC_ARG_ENABLE(scoreboard-buffer-size,
1205  [AC_HELP_STRING(
1206    [--enable-scoreboard-buffer-size],
1207    [tune the the size (in bytes) of certain scoreboard buffers (default=80)])
1208  ],
1209  [
1210    if test "$enableval" = "yes" || test "$enableval" = "no" ; then
1211      AC_MSG_WARN(scoreboard buffer size defaulting to 80 bytes)
1212      AC_DEFINE_UNQUOTED(PR_TUNABLE_SCOREBOARD_BUFFER_SIZE, 80,
1213      [Default scoreboard buffer size])
1214    else
1215      AC_DEFINE_UNQUOTED(PR_TUNABLE_SCOREBOARD_BUFFER_SIZE, $enableval,
1216      [Default scoreboard buffer size])
1217    fi
1218  ])
1219
1220AC_ARG_ENABLE(scoreboard-updates,
1221  [AC_HELP_STRING(
1222    [--enable-scoreboard-updates],
1223    [set how often (in loops) the mod_xfer module updates the scoreboard (default=10)])
1224  ],
1225  [
1226    if test x"$enableval" = xyes || test x"$enableval" = xno ; then
1227      AC_MSG_WARN(scoreboard updates defaulting to 10)
1228      AC_DEFINE_UNQUOTED(PR_TUNABLE_XFER_SCOREBOARD_UPDATES, 10, [Define the scoreboard update count])
1229    else
1230      AC_DEFINE_UNQUOTED(PR_TUNABLE_XFER_SCOREBOARD_UPDATES, $enableval, [Define the scoreboard update count])
1231    fi
1232  ])
1233
1234keepsyms="yes"
1235AC_ARG_ENABLE(strip,
1236  [AC_HELP_STRING(
1237    [--enable-strip],
1238    [strip debugging symbols from installed code (default=no)])
1239  ],
1240  [
1241    if test x"$enableval" = xyes ; then
1242      keepsyms="no"
1243    fi
1244  ]
1245)
1246
1247AC_ARG_ENABLE(timeout-ident,
1248  [AC_HELP_STRING(
1249    [--enable-timeout-ident],
1250    [set the default timeout (in secs) for RFC931 connections (default=10)])
1251  ],
1252  [
1253    if test "$enableval" = "yes" || test "$enableval" = "no" ; then
1254      AC_MSG_WARN(ident timeout defaulting to 10 secs)
1255      AC_DEFINE_UNQUOTED(PR_TUNABLE_TIMEOUTIDENT, 10,
1256      [Default ident timeout])
1257    else
1258      AC_DEFINE_UNQUOTED(PR_TUNABLE_TIMEOUTIDENT, $enableval,
1259      [Default ident timeout])
1260    fi
1261  ])
1262
1263AC_ARG_ENABLE(timeout-idle,
1264  [AC_HELP_STRING(
1265    [--enable-timeout-idle],
1266    [set the default timeout (in secs) for idle connections (default=600)])
1267  ],
1268  [
1269    if test "$enableval" = "yes" || test "$enableval" = "no" ; then
1270      AC_MSG_WARN(idle timeout defaulting to 600 secs)
1271      AC_DEFINE_UNQUOTED(PR_TUNABLE_TIMEOUTIDLE, 600,
1272      [Default idle timeout])
1273    else
1274      AC_DEFINE_UNQUOTED(PR_TUNABLE_TIMEOUTIDLE, $enableval,
1275      [Default idle timeout])
1276    fi
1277  ])
1278
1279AC_ARG_ENABLE(timeout-linger,
1280  [AC_HELP_STRING(
1281    [--enable-timeout-linger],
1282    [set the default timeout (in secs) for lingering closes (default=30)])
1283  ],
1284  [
1285    if test "$enableval" = "yes" || test "$enableval" = "no" ; then
1286      AC_MSG_WARN(linger timeout defaulting to 30 secs)
1287      AC_DEFINE_UNQUOTED(PR_TUNABLE_TIMEOUTLINGER, 30,
1288      [Default linger timeout])
1289    else
1290      AC_DEFINE_UNQUOTED(PR_TUNABLE_TIMEOUTLINGER, $enableval,
1291      [Default linger timeout])
1292    fi
1293  ])
1294
1295AC_ARG_ENABLE(timeout-login,
1296  [AC_HELP_STRING(
1297    [--enable-timeout-login],
1298    [set the default timeout (in secs) for logging in after connecting (default=300)])
1299  ],
1300  [
1301    if test "$enableval" = "yes" || test "$enableval" = "no" ; then
1302      AC_MSG_WARN(login timeout defaulting to 300 secs)
1303      AC_DEFINE_UNQUOTED(PR_TUNABLE_TIMEOUTLOGIN, 300,
1304      [Default login timeout])
1305    else
1306      AC_DEFINE_UNQUOTED(PR_TUNABLE_TIMEOUTLOGIN, $enableval,
1307      [Default login timeout])
1308    fi
1309  ])
1310
1311AC_ARG_ENABLE(timeout-no-transfer,
1312  [AC_HELP_STRING(
1313    [--enable-timeout-no-transfer],
1314    [set the default timeout (in secs) for no data transferred (default=300)])
1315  ],
1316  [
1317    if test "$enableval" = "yes" || test "$enableval" = "no" ; then
1318      AC_MSG_WARN(no data transfer timeout defaulting to 300 secs)
1319      AC_DEFINE_UNQUOTED(PR_TUNABLE_TIMEOUTNOXFER, 300,
1320      [Default when no data transferred])
1321    else
1322      AC_DEFINE_UNQUOTED(PR_TUNABLE_TIMEOUTNOXFER, $enableval,
1323      [Default when no data transferred])
1324    fi
1325  ])
1326
1327AC_ARG_ENABLE(timeout-stalled,
1328  [AC_HELP_STRING(
1329    [--enable-timeout-stalled],
1330    [set the default timeout (in secs) for stalled transfers (default=3600)])
1331  ],
1332  [
1333    if test "$enableval" = "yes" || test "$enableval" = "no" ; then
1334      AC_MSG_WARN(stalled timeout defaulting to 3600 secs)
1335      AC_DEFINE_UNQUOTED(PR_TUNABLE_TIMEOUTSTALLED, 3600,
1336      [Default stalled timeout])
1337    else
1338      AC_DEFINE_UNQUOTED(PR_TUNABLE_TIMEOUTSTALLED, $enableval,
1339      [Default stalled timeout])
1340    fi
1341  ])
1342
1343AC_ARG_ENABLE(parser-buffer-size,
1344  [AC_HELP_STRING(
1345    [--enable-parser-buffer-size],
1346    [tune the the size (in bytes) of parser buffers (default=4096 bytes)])
1347  ],
1348  [
1349    if test "$enableval" = "yes" || test "$enableval" = "no" ; then
1350      AC_MSG_WARN(parser buffer size defaulting to regular buffer size)
1351      AC_DEFINE_UNQUOTED(PR_TUNABLE_PARSER_BUFFER_SIZE, 4096,
1352      [Default buffer size])
1353    else
1354      AC_DEFINE_UNQUOTED(PR_TUNABLE_PARSER_BUFFER_SIZE, $enableval,
1355      [Specified parser buffer size])
1356    fi
1357  ])
1358
1359AC_ARG_ENABLE(transfer-buffer-size,
1360  [AC_HELP_STRING(
1361    [--enable-transfer-buffer-size],
1362    [tune the the size (in bytes) of data transfer buffers (default=OS dependent)])
1363  ],
1364  [
1365    if test "$enableval" = "yes" || test "$enableval" = "no" ; then
1366      AC_MSG_WARN(transfer buffer size defaulting to regular buffer size)
1367      AC_DEFINE_UNQUOTED(PR_TUNABLE_XFER_BUFFER_SIZE, 8192,
1368      [Default buffer size])
1369    else
1370      AC_DEFINE_UNQUOTED(PR_TUNABLE_XFER_BUFFER_SIZE, $enableval,
1371      [Specified transfer buffer size])
1372    fi
1373  ])
1374
1375dnl Checks for libraries.  Yes, this is the hard way, but it's necessary.
1376AC_CACHE_CHECK(for standalone crypt,pr_cv_lib_standalone_crypt,
1377  AC_TRY_LINK(,[crypt();],
1378  	pr_cv_lib_standalone_crypt="yes", pr_cv_lib_standalone_crypt="no" ))
1379
1380if test "$pr_cv_lib_standalone_crypt" = "no"; then
1381  AC_CHECK_LIB(crypt, crypt)
1382fi
1383
1384AC_CACHE_CHECK(for standalone gethostbyname,pr_cv_lib_standalone_gethost,
1385  AC_TRY_LINK(,[gethostbyname();],
1386  	pr_cv_lib_standalone_gethost="yes",
1387	pr_cv_lib_standalone_gethost="no" ))
1388
1389if test "$pr_cv_lib_standalone_gethost" = "no"; then
1390  AC_CHECK_LIB(resolv, gethostbyname)
1391  AC_CHECK_LIB(resolv, inet_aton)
1392fi
1393
1394AC_CACHE_CHECK(for standalone inet_aton,pr_cv_lib_standalone_aton,
1395  AC_TRY_LINK(,[inet_aton();],
1396  	pr_cv_lib_standalone_aton="yes",
1397	pr_cv_lib_standalone_aton="no" ))
1398
1399if test "$pr_cv_lib_standalone_aton" = "no"; then
1400  AC_CHECK_LIB(bind, inet_aton)
1401fi
1402
1403AC_CACHE_CHECK(for standalone nsl functions,pr_cv_lib_standalone_nsl,[
1404  AC_TRY_LINK(,[gethostent();],
1405  pr_cv_lib_standalone_nsl="yes", pr_cv_lib_standalone_nsl="no") ])
1406
1407if test "$pr_cv_lib_standalone_nsl" = "no"; then
1408  AC_CHECK_LIB(nsl, gethostent)
1409fi
1410
1411AC_CACHE_CHECK(for standalone socket functions,pr_cv_lib_standalone_sockets,
1412  AC_TRY_LINK(,[bind();],
1413  pr_cv_lib_standalone_sockets="yes", pr_cv_lib_standalone_sockets="no"))
1414
1415if test "$pr_cv_lib_standalone_sockets" = "no"; then
1416  AC_CHECK_LIB(socket, bind)
1417fi
1418
1419AC_CACHE_CHECK(for _pw_stayopen variable,pr_cv_var__pw_stayopen,
1420  AC_TRY_LINK(
1421    [extern int _pw_stayopen; ],
1422    [_pw_stayopen = 1;],
1423    pr_cv_var__pw_stayopen="yes", pr_cv_var__pw_stayopen="no"))
1424
1425if test "$pr_cv_var__pw_stayopen" = "yes"; then
1426  AC_DEFINE(HAVE__PW_STAYOPEN, 1, [Define if you have __pw_stayopen variable.])
1427fi
1428
1429AC_CHECK_HEADERS(krb.h login.h prot.h usersec.h sys/audit.h)
1430
1431dnl HP-UX's hpsecurity.h can multiply define MAXINT and confuse configure
1432AC_CHECK_HEADERS(hpsecurity.h, [
1433    AC_SEARCH_LIBS(getprpwnam, sec)
1434  ],
1435  [
1436    AC_MSG_CHECKING(for hpsecurity.h workaround)
1437    AC_TRY_COMPILE([
1438#include <values.h>
1439#undef MAXINT
1440#include <hpsecurity.h>
1441  ], [],
1442  [
1443    AC_DEFINE(HAVE_HPSECURITY_H, 1, [Define you have <hpsecurity.h>])
1444    AC_SEARCH_LIBS(getprpwnam, sec)
1445    AC_MSG_RESULT(yes)
1446  ], [
1447    AC_MSG_RESULT(no)
1448  ])
1449])
1450
1451dnl AIX's "lastlog" support is done via specific functions, rather than a
1452dnl struct (Bug#4285).
1453AC_MSG_CHECKING(for AIX authenticate)
1454AC_TRY_LINK([
1455  #include <sys/types.h>
1456  #ifdef HAVE_USERSEC_H
1457  # include <usersec.h>
1458  #else
1459  # error "we are not on AIX"
1460  #endif
1461  ],
1462  [
1463    (void) authenticate(NULL, NULL, NULL, NULL);
1464  ],
1465  [
1466    AC_DEFINE(HAVE_AUTHENTICATE, 1, [Define if you have the AIX authenticate function])
1467    AC_MSG_RESULT(yes)
1468  ], [
1469    AC_MSG_RESULT(no)
1470  ]
1471)
1472
1473AC_MSG_CHECKING(for AIX loginfailed)
1474AC_TRY_LINK([
1475  #include <sys/types.h>
1476  #ifdef HAVE_USERSEC_H
1477  # include <usersec.h>
1478  #else
1479  # error "we are not on AIX"
1480  #endif
1481  ],
1482  [
1483    (void) loginfailed(NULL, NULL, NULL, 0);
1484  ],
1485  [
1486    AC_DEFINE(HAVE_LOGINFAILED, 1, [Define if you have the AIX loginfailed function])
1487    AC_MSG_RESULT(yes)
1488  ], [
1489    AC_MSG_RESULT(no)
1490  ]
1491)
1492
1493AC_MSG_CHECKING(for AIX loginsuccess)
1494AC_TRY_LINK([
1495  #include <sys/types.h>
1496  #ifdef HAVE_USERSEC_H
1497  # include <usersec.h>
1498  #else
1499  # error "we are not on AIX"
1500  #endif
1501  ],
1502  [
1503    (void) loginsuccess(NULL, NULL, NULL, NULL);
1504  ],
1505  [
1506    AC_DEFINE(HAVE_LOGINSUCCESS, 1, [Define if you have the AIX loginsuccess function]
1507)
1508    AC_MSG_RESULT(yes)
1509  ], [
1510    AC_MSG_RESULT(no)
1511  ]
1512)
1513
1514dnl Checks for installation user/group
1515
1516if test x"$install_user" = x; then
1517  if test "x$target_os" = "xcygwin"; then
1518    install_user=`id -u`
1519  else
1520    install_user=root
1521  fi
1522fi
1523if test x"$install_group" = x ; then
1524  if test "x$target_os" = "xcygwin"; then
1525    install_group=`id -g`
1526  else
1527    install_group=`sed -n '/.*:.*:0:/{s/^\(.*\):.*:0:.*/\1/p;q;}' /etc/group 2>/dev/null`
1528  fi
1529fi
1530
1531AC_SUBST(install_user)
1532AC_SUBST(install_group)
1533
1534dnl Checks for header files.
1535AC_HEADER_DIRENT
1536AC_HEADER_STDC
1537AC_HEADER_SYS_WAIT
1538AC_CHECK_HEADERS(fcntl.h signal.h linux/prctl.h sys/ioctl.h sys/prctl.h sys/resource.h sys/time.h junistd.h memory.h)
1539if test x"$force_shadow" != xno ; then
1540  AC_CHECK_HEADERS(shadow.h,
1541    [ if test "$use_shadow" = "" && test -f /etc/shadow ; then
1542        AC_DEFINE(PR_USE_SHADOW, 1, [Define if using shadow password support.])
1543
1544        AC_CHECK_MEMBER(struct spwd.sp_warn,
1545          [AC_DEFINE(HAVE_SPWD_SP_WARN, 1, [Define if struct spwd has sp_warn])],, [#include <shadow.h>])
1546        AC_CHECK_MEMBER(struct spwd.sp_inact,
1547          [AC_DEFINE(HAVE_SPWD_SP_INACT, 1, [Define if struct spwd has sp_inact])],, [#include <shadow.h>])
1548        AC_CHECK_MEMBER(struct spwd.sp_expire,
1549          [AC_DEFINE(HAVE_SPWD_SP_EXPIRE, 1, [Define if struct spwd has sp_expire])],, [#include <shadow.h>])
1550      fi ])
1551fi
1552
1553dnl The pam test used to disable use_shadow, and I'm not sure why, libpam
1554dnl really shouldn't have anything to do with force_shadow or use_shadow.
1555if test x"$enable_auth_pam" != xno ; then
1556  AC_CHECK_HEADERS(security/pam_appl.h security/pam_modules.h pam/pam_appl.h,
1557    [
1558      if test `echo $ac_static_modules | grep -c mod_auth_pam` = "0"; then
1559        ac_static_modules="mod_auth_pam.o $ac_static_modules"
1560        ac_build_static_modules="modules/mod_auth_pam.o $ac_build_static_modules"
1561      fi
1562    ], [],
1563    [
1564      #ifdef HAVE_SECURITY_PAM_APPL_H
1565      # include <security/pam_appl.h>
1566      #endif
1567    ])
1568
1569  dnl This next check looks funky due to a linker problem with some versions
1570  dnl of the PAM library.  Prior to 0.72 release, the Linux PAM shared library
1571  dnl omitted requiring libdl linking information. PAM-0.72 or better ships
1572  dnl with RedHat 6.2 and Debian 2.2 or better.
1573  dnl
1574  dnl This test used to add -lpam to the libraries list, however this isn't
1575  dnl necessary in light of the fact that mod_auth_pam.c has the $Libraries $
1576  dnl tag and is picked up at configure time.  The only thing we need is to
1577  dnl add -ldl in the event of broken PAM.
1578
1579  if test `echo $ac_static_modules | grep -c mod_auth_pam` = "1"; then
1580
1581	AC_CHECK_LIB(pam, pam_start,
1582		[AC_DEFINE(HAVE_PAM, 1, [Define if you have PAM support.])],
1583		[AC_CHECK_LIB(pam, pam_end,
1584				[AC_DEFINE(HAVE_PAM, 1,
1585                                  [Define if you have PAM support.])
1586					LIBS="$LIBS -ldl"],,
1587				[-ldl])])
1588  fi
1589
1590fi
1591
1592ac_add_mod_cap="no"
1593ac_have_libcap="no"
1594if test x"$enable_cap" != xno; then
1595  case "$host" in
1596    [*-linux-*])
1597      rev=`uname -r | awk -F'[[.-]]' '{printf "%03d%03d%03d", $1, $2, $3}'`
1598
1599      if test $rev -ge 002001097; then
1600        AC_CHECK_HEADERS(linux/capability.h sys/capability.h)
1601
1602        if test x"$ac_cv_header_linux_capability_h" = "xyes" && test x"$ac_cv_header_sys_capability_h" = "xyes"; then
1603          ac_add_mod_cap="yes"
1604        fi
1605
1606        AC_CHECK_LIB(cap2, cap_init,
1607          [ac_have_libcap="yes"
1608           AC_DEFINE(HAVE_LIBCAP2, 1, [Define if libcap2 is present.])
1609
1610          ],[AC_CHECK_LIB(cap, cap_init,
1611              [ac_have_libcap="yes"
1612               AC_DEFINE(HAVE_LIBCAP, 1, [Define if libcap is present.])
1613              ])
1614          ])
1615      fi
1616  esac
1617fi
1618
1619AC_MSG_CHECKING([whether to enable mod_cap])
1620AC_MSG_RESULT($ac_add_mod_cap)
1621
1622if test x"$ac_add_mod_cap" = xyes; then
1623
1624  dnl Make sure that mod_ifsession, if present in the list, appears at
1625  dnl the end.
1626  if test x"$ifsession_requested" = xtrue; then
1627    ac_static_modules=`echo "$ac_static_modules" | sed -e 's/mod_ifsession\.o//g'`
1628    ac_static_modules="$ac_static_modules mod_cap.o mod_ifsession.o"
1629
1630    ac_build_static_modules=`echo "$ac_build_static_modules" | sed -e 's/modules\/mod_ifsession\.o//g'`
1631    ac_build_static_modules="$ac_build_static_modules modules/mod_cap.o modules/mod_ifsession.o";
1632
1633  else
1634    ac_static_modules="$ac_static_modules mod_cap.o"
1635    ac_build_static_modules="$ac_build_static_modules modules/mod_cap.o"
1636  fi
1637fi
1638
1639AC_CHECK_HEADERS(bstring.h crypt.h ctype.h execinfo.h iconv.h inttypes.h langinfo.h limits.h locale.h sasl/sasl.h)
1640AC_CHECK_HEADERS(string.h strings.h stropts.h)
1641AC_CHECK_HEADERS(sys/file.h sys/mman.h sys/types.h sys/ucred.h sys/uio.h sys/socket.h)
1642AC_MSG_CHECKING(for net/if.h)
1643AC_TRY_COMPILE([
1644  #include <time.h>
1645  #ifdef HAVE_SYS_TYPES_H
1646  # include <sys/types.h>
1647  #endif
1648  #ifdef HAVE_SYS_SOCKET_H
1649  # include <sys/socket.h>
1650  #endif
1651  #include <net/if.h>
1652  ], [
1653  ],
1654  [
1655    AC_DEFINE(HAVE_NET_IF_H, 1, [Define if you have the net/if.h header.])
1656    AC_MSG_RESULT(yes)
1657  ], [
1658    AC_MSG_RESULT(no)
1659  ])
1660
1661AC_CHECK_HEADERS(ifaddrs.h)
1662
1663dnl These particular checks are done a little differently because on some
1664dnl platforms, <sys/mount.h> wants <sys/param.h> to be included first.
1665AC_CHECK_HEADERS(sys/param.h sys/mount.h,,,
1666  [
1667    [
1668     #if HAVE_SYS_PARAM_H
1669     # include <sys/param.h>
1670     #endif
1671    ]
1672  ])
1673
1674AC_CHECK_HEADERS(netdb.h netinet/in.h)
1675
1676dnl On AIX, it seems that in order for hstrerror to be properly seen
1677dnl from netdb.h, we need to define _USE_IRS.  And people wonder why
1678dnl there's all this effort for compatibility, when "Unix is Unix,
1679dnl right?"  Yeah, whatever.
1680AC_MSG_CHECKING(whether netdb.h requires _USE_IRS)
1681AC_EGREP_HEADER(_USE_IRS, netdb.h,
1682  [
1683    AC_DEFINE(_USE_IRS, 1, [Define if netdb.h requires _USE_IRS])
1684    AC_MSG_RESULT(yes)
1685  ],
1686  [
1687    AC_MSG_RESULT(no)
1688  ])
1689
1690AC_CHECK_HEADERS(netinet/in_systm.h,,,
1691  [
1692    [
1693     #if HAVE_SYS_TYPES_H
1694     # include <sys/types.h>
1695     #endif
1696    ]
1697  ])
1698
1699AC_CHECK_HEADERS(netinet/ip.h,,,
1700  [
1701    [
1702     #if HAVE_SYS_TYPES_H
1703     # include <sys/types.h>
1704     #endif
1705     #if HAVE_NETINET_IN_H
1706     # include <netinet/in.h>
1707     #endif
1708     #if HAVE_NETINET_IN_SYSTM_H
1709     # include <netinet/in_systm.h>
1710     #endif
1711    ]
1712  ])
1713
1714AC_CHECK_HEADERS(netinet/tcp.h arpa/inet.h idna.h libintl.h)
1715AC_CHECK_HEADERS(regex.h sys/stat.h errno.h sys/termios.h sys/termio.h)
1716AC_CHECK_HEADERS(sys/statfs.h sys/statvfs.h sys/un.h sys/vfs.h sys/select.h)
1717AC_CHECK_HEADERS(termios.h dirent.h ndir.h sys/ndir.h sys/dir.h vmsdir.h)
1718AC_CHECK_HEADERS(ucred.h ucontext.h utime.h utmpx.h)
1719AC_CHECK_HEADER(syslog.h, have_syslog_h="yes",)
1720AC_CHECK_HEADERS(curses.h ncurses.h)
1721
1722dnl Check for the presence of the tzname, timezone, and daylight global
1723dnl variables.
1724AC_MSG_CHECKING(for tzname global variable)
1725AC_TRY_COMPILE([
1726  #include <time.h>
1727  ], [
1728    char *dup[2];
1729    dup[0] = tzname[0];
1730    dup[1] = tzname[1];
1731  ],
1732  [
1733    AC_DEFINE(HAVE_TZNAME, 1, [Define if you have the tzname variable.])
1734    AC_MSG_RESULT(yes)
1735  ], [
1736    AC_MSG_RESULT(no)
1737  ])
1738
1739dnl Checks for typedefs, structures, and compiler characteristics.
1740AC_C_CONST
1741AC_C_INLINE
1742AC_TYPE_UID_T
1743AC_TYPE_PID_T
1744AC_TYPE_SIZE_T
1745AC_TYPE_MODE_T
1746AC_TYPE_OFF_T
1747AC_TYPE_GETGROUPS
1748
1749dnl Check the function signature of getgrouplist()
1750AC_MSG_CHECKING([whether the getgrouplist(3) function takes ints])
1751AC_TRY_LINK([
1752  #define _GNU_SOURCE
1753  #ifdef HAVE_GRP_H
1754  # include <grp.h>
1755  #endif
1756  #ifdef HAVE_UNISTD_H
1757  # include <unistd.h>
1758  #endif
1759], [
1760  int (*f)(const char *, int, int *, int *) = getgrouplist;
1761], [
1762  AC_MSG_RESULT(yes)
1763  AC_DEFINE(HAVE_GETGROUPLIST_TAKES_INTS, 1, [Define if getgrouplist3() takes ints as arguments])
1764], [
1765  AC_MSG_RESULT(no)
1766])
1767
1768AC_HEADER_TIME
1769AC_STRUCT_TM
1770
1771AC_CHECK_SIZEOF(short, 0)
1772AC_CHECK_SIZEOF(int, 0)
1773AC_CHECK_SIZEOF(long, 0)
1774AC_CHECK_SIZEOF(long long, 0)
1775AC_CHECK_SIZEOF(off_t, 0)
1776AC_CHECK_SIZEOF(size_t, 0)
1777AC_CHECK_SIZEOF(time_t, 0)
1778AC_CHECK_SIZEOF(char *, 0)
1779AC_CHECK_SIZEOF(void *, 0)
1780AC_CHECK_SIZEOF(uid_t, 0)
1781AC_CHECK_SIZEOF(gid_t, 0)
1782
1783dnl Check for generic typedefs
1784AC_CHECK_TYPE(mode_t, mode_t)
1785AC_CHECK_TYPE(ino_t, ino_t)
1786AC_CHECK_TYPE(intptr_t, AC_DEFINE(HAVE_INTPTR_T, 1, [Define if have intpr_t type]),, [
1787  #if HAVE_INTTYPES_H
1788  # include <inttypes.h>
1789  #endif
1790])
1791
1792AC_CHECK_TYPES(socklen_t, ,
1793  [AC_DEFINE(socklen_t, int)],
1794  [
1795    #if HAVE_SYS_TYPES_H
1796    # include <sys/types.h>
1797    #endif
1798    #if HAVE_NETDB_H
1799    # include <netdb.h>
1800    #endif
1801    #include <sys/socket.h>
1802  ])
1803
1804dnl See what type of utmp exists
1805AC_CHECK_HEADERS(utmp.h, have_utmp=1, have_utmp=0)
1806
1807if test $have_utmp; then
1808  AC_CACHE_CHECK(whether struct utmp has ut_user,
1809  		pr_cv_header_utmaxtype,
1810	AC_EGREP_HEADER([ *ut_user.*;],utmp.h,
1811			pr_cv_header_utmaxtype="yes",
1812			pr_cv_header_utmaxtype="no"))
1813  AC_CACHE_CHECK(whether struct utmp has ut_host,
1814  		pr_cv_header_ut_host,
1815	AC_EGREP_HEADER([ *ut_host.*;],utmp.h,
1816			pr_cv_header_ut_host="yes",
1817			pr_cv_header_ut_host="no"))
1818  AC_CACHE_CHECK(whether struct utmp has ut_exit,
1819		pr_cv_header_ut_exit,
1820	AC_EGREP_HEADER([ *ut_exit.*;],utmp.h,
1821			pr_cv_header_ut_exit="yes",
1822			pr_cv_header_ut_exit="no"))
1823  if test "$pr_cv_header_utmaxtype" = "yes"; then
1824    AC_DEFINE(HAVE_UTMAXTYPE, 1, [Define if struct utmp has ut_user.])
1825  fi
1826  if test "$pr_cv_header_ut_host" = "yes"; then
1827    AC_DEFINE(HAVE_UT_UT_HOST, 1, [Define if struct utmp has ut_host.])
1828  fi
1829  if test "$pr_cv_header_ut_exit" = "yes"; then
1830    AC_DEFINE(HAVE_UT_UT_EXIT, 1, [Define if struct utmp has ut_exit.])
1831  fi
1832fi
1833
1834dnl See if various LOG_ macros are defined
1835if test "$have_syslog_h" = "yes"; then
1836  AC_DEFINE(HAVE_SYSLOG_H, 1, [Define if you have <syslog.h>])
1837
1838  AC_CACHE_CHECK(whether syslog.h defines LOG_CRON,
1839  		pr_cv_header_syslog_log_cron,
1840  	AC_EGREP_CPP(yes,[
1841#include <syslog.h>
1842#ifdef LOG_CRON
1843  yes
1844#endif
1845	],pr_cv_header_syslog_log_cron="yes",
1846	pr_cv_header_syslog_log_cron="no") )
1847
1848  AC_CACHE_CHECK(whether syslog.h defines LOG_FTP,
1849  		pr_cv_header_syslog_log_ftp,
1850  	AC_EGREP_CPP(yes,[
1851#include <syslog.h>
1852#ifdef LOG_FTP
1853  yes
1854#endif
1855	],pr_cv_header_syslog_log_ftp="yes",
1856	pr_cv_header_syslog_log_ftp="no") )
1857
1858  if test "$pr_cv_header_syslog_log_cron" = "yes"; then
1859    AC_DEFINE(HAVE_LOG_CRON, 1, [Define if you have LOG_CRON])
1860  fi
1861  if test "$pr_cv_header_syslog_log_ftp" = "yes"; then
1862    AC_DEFINE(HAVE_LOG_FTP, 1, [Define if you have LOG_FTP])
1863  fi
1864fi
1865
1866dnl Check for directory file descriptor member ("d_fd", "dd_fd" or "__dd_fd")
1867dnl of the DIR struct, possibly defining one of:
1868dnl	HAVE_STRUCT_DIR_D_FD
1869dnl	HAVE_STRUCT_DIR_DD_FD
1870dnl	HAVE_STRUCT_DIR___DD_FD
1871dnl Should use AC_C_STRUCT_MEMBER, when available in an official release.
1872dnl The autoconf-2.14.1 floating around is NOT an official release.
1873dnl Note: use of either the _POSIX_C_SOURCE or the _XOPEN_SOURCE preprocessor
1874dnl macro could result in a wrong answer unless it is also defined here.
1875dnl Doing so may be automatic or may take some care or reordering.
1876dnl NB: autoheader won't pick up these macros, requiring acconfig.h entries.
1877dnl
1878for dirfd in d_fd dd_fd __dd_fd ; do
1879	AC_MSG_CHECKING(for $dirfd in DIR structure)
1880	AC_TRY_COMPILE([
1881#include <stdio.h>
1882#include <dirent.h>
1883], [
1884DIR *dirp;
1885int i = dirp->$dirfd;
1886], eval ac_cv_struct_dir_$dirfd=yes,)
1887	if test "`eval echo x'$''ac_cv_struct_dir_'$dirfd`" = xyes ; then
1888		ucdirfd=`echo $dirfd | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
1889		AC_DEFINE_UNQUOTED(HAVE_STRUCT_DIR_$ucdirfd)
1890		AC_MSG_RESULT(yes)
1891		break
1892	else
1893		AC_MSG_RESULT(no)
1894	fi
1895done
1896
1897
1898dnl Checks for library functions.
1899
1900AC_FUNC_ALLOCA
1901
1902dnl UnixWare's alloca is in libucb, in /usr/ucblib/. Muck about with
1903dnl $LDFLAGS so AC_CHECK_LIB() will find it there.
1904old_LDFLAGS=$LDFLAGS
1905LDFLAGS="$LDFLAGS -L/usr/ucblib/"
1906AC_CHECK_LIB(ucb, alloca)
1907LDFLAGS=$old_LDFLAGS
1908
1909AC_PROG_GCC_TRADITIONAL
1910AC_TYPE_SIGNAL
1911AC_FUNC_VPRINTF
1912
1913AC_CHECK_FUNCS(bcopy crypt ctime_r fdatasync fgetspent flock fpathconf freeaddrinfo fsync futimes getifaddrs getpgid getpgrp gmtime_r localtime_r mkdtemp nl_langinfo)
1914
1915AC_CHECK_FUNC(gai_strerror,
1916  AC_DEFINE(HAVE_GAI_STRERROR, 1,
1917    [Define if you have the gai_strerror() function]),
1918  LIB_OBJS="$LIB_OBJS glibc-gai_strerror.o"
1919)
1920
1921AC_MSG_CHECKING([for iconv])
1922AC_TRY_LINK(
1923  [ #ifdef HAVE_STDDEF_H
1924    # include <stddef.h>
1925    #endif
1926    #ifdef HAVE_STDLIB_H
1927    # include <stdlib.h>
1928    #endif
1929    #ifdef HAVE_SYS_TYPES_H
1930    # include <sys/types.h>
1931    #endif
1932    #ifdef HAVE_ICONV_H
1933    # include <iconv.h>
1934    #endif
1935  ],
1936  [
1937    size_t res, in_len = 0, out_len = 0;
1938    const char *in = NULL;
1939    char *out = NULL;
1940    res = iconv((iconv_t)-1, &in, &in_len, &out, &out_len);
1941  ],
1942  [
1943    AC_MSG_RESULT(yes)
1944    AC_DEFINE(HAVE_ICONV, 1, [Define if you have iconv])
1945  ],
1946  [
1947    AC_MSG_RESULT(no)
1948  ]
1949)
1950
1951AC_MSG_CHECKING([for idna_to_ascii_8z])
1952AC_TRY_COMPILE(
1953  [
1954    #include <sys/types.h>
1955    #ifdef HAVE_IDNA_H
1956    #  include <idna.h>
1957    #endif
1958  ],
1959  [
1960    int flags = 0, res = 0;
1961    const char *input = NULL;
1962    char *output = NULL;
1963    res = idna_to_ascii_8z(input, &output, flags);
1964  ],
1965  [
1966    AC_MSG_RESULT(yes)
1967    AC_DEFINE(HAVE_IDNA_TO_ASCII_8Z, 1, [Define if you have idna_to_ascii_8z])
1968    MAIN_LIBS="$MAIN_LIBS -lidn"
1969  ],
1970  [
1971    AC_MSG_RESULT(no)
1972  ]
1973)
1974
1975AC_MSG_CHECKING([for dirfd])
1976AC_TRY_LINK(
1977  [ #ifdef HAVE_STDDEF_H
1978    # include <stddef.h>
1979    #endif
1980    #ifdef HAVE_STDLIB_H
1981    # include <stdlib.h>
1982    #endif
1983    #ifdef HAVE_STDIO_H
1984    # include <stdio.h>
1985    #endif
1986    #ifdef HAVE_SYS_TYPES_H
1987    # include <sys/types.h>
1988    #endif
1989    #if HAVE_DIRENT_H
1990    # include <dirent.h>
1991    #endif
1992  ],
1993  [
1994    DIR *dirh = NULL;
1995    int fd;
1996
1997    fd = dirfd(dirh);
1998  ],
1999  [
2000    AC_MSG_RESULT(yes)
2001    AC_DEFINE(HAVE_DIRFD, 1, [Define if you have dirfd])
2002  ],
2003  [
2004    AC_MSG_RESULT(no)
2005  ]
2006)
2007
2008dnl getaddrinfo is a #define on Tru64 Unix.  How annoying.
2009AC_MSG_CHECKING([for getaddrinfo])
2010AC_TRY_LINK(
2011  [ #ifdef HAVE_STDDEF_H
2012    # include <stddef.h>
2013    #endif
2014    #ifdef HAVE_STDLIB_H
2015    # include <stdlib.h>
2016    #endif
2017    #ifdef HAVE_STDIO_H
2018    # include <stdio.h>
2019    #endif
2020    #if HAVE_SYS_TYPES_H
2021    # include <sys/types.h>
2022    #endif
2023    #if HAVE_SYS_SOCKET_H
2024    # include <sys/socket.h>
2025    #endif
2026    #if HAVE_NETDB_H
2027    # include <netdb.h>
2028    #endif
2029  ],
2030  [
2031    getaddrinfo(NULL, NULL, NULL, NULL);
2032  ],
2033  [
2034    AC_MSG_RESULT(yes)
2035    AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have getaddrinfo])
2036  ],
2037  [
2038    AC_MSG_RESULT(no)
2039  ]
2040)
2041
2042AC_CHECK_FUNCS(getcwd getenv getgrouplist getgroups getgrset gethostbyname2 gethostname getnameinfo)
2043AC_CHECK_FUNCS(gettimeofday hstrerror inet_aton inet_ntop inet_pton initgroups)
2044AC_CHECK_FUNCS(loginrestrictions)
2045AC_CHECK_FUNCS(explicit_bzero memcpy mempcpy memset_s mkdir mkstemp mlock mlockall munlock munlockall)
2046AC_CHECK_FUNCS(pathconf posix_fadvise pread prctl putenv pwrite random regcomp rmdir select setgroups socket srandom statfs strchr strcoll strerror timingsafe_bcmp)
2047AC_CHECK_FUNCS(strlcat strlcpy strsep strtod strtof strtol strtoll strtoull setprotoent setspent endprotoent)
2048# __snprintf and __vsnprintf are only on solaris and _really_ broken there.
2049AC_CHECK_FUNCS(vsnprintf snprintf)
2050if test x"$ac_cv_func_vsnprintf" != xyes || test x"$ac_cv_func_snprintf" != xyes
2051then
2052	AC_CHECK_FUNCS(fconvert fcvt)
2053	AC_CHECK_HEADERS(floatingpoint.h)
2054fi
2055AC_CHECK_FUNCS(setsid setgroupent seteuid setegid setenv setpgid siginterrupt)
2056AC_CHECK_FUNCS(tzset uname unsetenv)
2057
2058AC_CHECK_FUNC(setpassent,
2059[case "$target_os:$enable_force_setpassent" in
2060changequote(, )dnl
2061  *freebsd[23]\.[0-3]*:)
2062changequote([, ])dnl
2063    AC_MSG_WARN(Disabling broken FreeBSD setpassent(), see README for details.)
2064        ;;
2065  *:no) ;;
2066  *) AC_DEFINE(HAVE_SETPASSENT, 1, [Define if you have setpassent()]) ;;
2067esac])
2068
2069dnl Controls
2070if test x"$enable_ctrls" = xyes; then
2071  AC_CHECK_FUNCS(getpeereid getpeerucred)
2072  ac_static_modules="$ac_static_modules mod_ctrls.o"
2073  ac_build_static_modules="$ac_build_static_modules modules/mod_ctrls.o"
2074fi
2075
2076dnl NLS/LANG support
2077if test x"$enable_nls" = xyes; then
2078  ac_static_modules="$ac_static_modules mod_lang.o"
2079  ac_build_static_modules="$ac_build_static_modules modules/mod_lang.o"
2080
2081  dnl Make sure that mod_ifsession, if present in the list, appears at the end.
2082  if test x"$ifsession_requested" = xtrue; then
2083    ac_static_modules=`echo "$ac_static_modules" | sed -e 's/mod_ifsession\.o//g'`
2084    ac_static_modules="$ac_static_modules mod_ifsession.o"
2085
2086    ac_build_static_modules=`echo "$ac_build_static_modules" | sed -e 's/modules\/mod_ifsession\.o//g'`
2087    ac_build_static_modules="$ac_build_static_modules modules/mod_ifsession.o";
2088  fi
2089fi
2090
2091dnl Controls-related checks
2092AC_CHECK_MEMBER(struct cmsgcred.cmcred_uid,
2093  [AC_DEFINE(HAVE_STRUCT_CMSGCRED, 1, [Define if you have struct cmsgcred])],,
2094  [
2095    #if HAVE_SYS_TYPES_H
2096    # include <sys/types.h>
2097    #endif
2098    #if HAVE_SYS_SOCKET_H
2099    # include <sys/socket.h>
2100    #endif
2101    #if HAVE_SYS_UIO_H
2102    # include <sys/uio.h>
2103    #endif
2104  ])
2105
2106AC_CHECK_MEMBER(struct sockcred.sc_uid,
2107  [AC_DEFINE(HAVE_STRUCT_SOCKCRED, 1, [Define if you have struct sockcred])],,
2108  [
2109    #if HAVE_SYS_TYPES_H
2110    # include <sys/types.h>
2111    #endif
2112    #if HAVE_SYS_SOCKET_H
2113    # include <sys/socket.h>
2114    #endif
2115    #if HAVE_SYS_UIO_H
2116    # include <sys/uio.h>
2117    #endif
2118  ])
2119
2120# See:
2121#   https://github.com/proftpd/proftpd/issues/75
2122AC_CHECK_MEMBER(struct sockpeercred.uid,
2123  [AC_DEFINE(HAVE_STRUCT_SOCKPEERCRED, 1, [Define if you have struct sockpeercred])],,
2124  [
2125    #if HAVE_SYS_TYPES_H
2126    # include <sys/types.h>
2127    #endif
2128    #if HAVE_SYS_SOCKET_H
2129    # include <sys/socket.h>
2130    #endif
2131    #if HAVE_SYS_UIO_H
2132    # include <sys/uio.h>
2133    #endif
2134  ])
2135
2136dnl IPv4/IPv6-related checks
2137AC_CHECK_MEMBER(struct sockaddr_in.sin_len,
2138  [AC_DEFINE(SIN_LEN, 1, [Define if you have sockaddr_in.sin_len])],,
2139  [
2140    #if HAVE_SYS_TYPES_H
2141    # include <sys/types.h>
2142    #endif
2143    #if HAVE_SYS_SOCKET_H
2144    # include <sys/socket.h>
2145    #endif
2146    #if HAVE_NETINET_IN_H
2147    # include <netinet/in.h>
2148    #endif
2149  ])
2150
2151dnl NFS-related checks
2152AC_CHECK_MEMBER(struct statfs.f_fstypename,
2153  [AC_DEFINE(HAVE_STATFS_F_FSTYPENAME, 1, [Define if you have struct statfs.f_fstypename])],,
2154  [
2155    #if HAVE_SYS_TYPES_H
2156    # include <sys/types.h>
2157    #endif
2158    #if HAVE_SYS_PARAM_H
2159    # include <sys/param.h>
2160    #endif
2161    #if HAVE_SYS_MOUNT_H
2162    # include <sys/mount.h>
2163    #endif
2164    #if HAVE_SYS_VFS_H
2165    # include <sys/vfs.h>
2166    #endif
2167    #if HAVE_SYS_STATFS_H
2168    # include <sys/statfs.h>
2169    #endif
2170  ])
2171
2172AC_CHECK_MEMBER(struct statfs.f_type,
2173  [AC_DEFINE(HAVE_STATFS_F_TYPE, 1, [Define if you have struct statfs.f_type])],,
2174  [
2175    #if HAVE_SYS_TYPES_H
2176    # include <sys/types.h>
2177    #endif
2178    #if HAVE_SYS_PARAM_H
2179    # include <sys/param.h>
2180    #endif
2181    #if HAVE_SYS_MOUNT_H
2182    # include <sys/mount.h>
2183    #endif
2184    #if HAVE_SYS_VFS_H
2185    # include <sys/vfs.h>
2186    #endif
2187    #if HAVE_SYS_STATFS_H
2188    # include <sys/statfs.h>
2189    #endif
2190  ])
2191
2192dnl Largefile support
2193if test x"$enable_largefile" = xno; then
2194  AC_DEFINE(PR_USE_LARGEFILES, 0, [Define if you have largefile support])
2195else
2196  AC_DEFINE(PR_USE_LARGEFILES, 1, [Define if you have largefile support])
2197fi
2198
2199PR_CHECK_STRUCT_ADDRINFO
2200PR_CHECK_STRUCT_SS
2201PR_CHECK_SS_FAMILY
2202PR_CHECK_SS_LEN
2203
2204dnl POSIX ACL checks.  Always perform these, in case the administrator
2205dnl wants to use mod_facl.
2206AC_CHECK_HEADERS(sys/acl.h acl/libacl.h)
2207AC_CHECK_LIB(acl, perm_copy_fd,
2208  [AC_DEFINE(HAVE_LIBACL, 1, [Define if you have libacl])]
2209)
2210AC_CACHE_CHECK(
2211  [which POSIX ACL implementation to use],
2212  pr_cv_func_facl,
2213  pr_cv_func_facl="none"
2214
2215  dnl BSD.
2216  if test "$pr_cv_func_facl" = "none"; then
2217    AC_TRY_LINK(
2218      [ #include <sys/types.h>
2219        #ifdef HAVE_SYS_ACL_H
2220        # include <sys/acl.h>
2221        #endif
2222        #ifdef HAVE_ACL_LIBACL_H
2223        # include <acl/libacl.h>
2224        #endif
2225      ],
2226      [ acl_permset_t permset;
2227        /* On BSD, ACL_READ_DATA is a #define. */
2228        #ifdef ACL_READ_DATA
2229        acl_perm_t perm = ACL_READ_DATA;
2230        #else
2231        # error "ACL_READ_DATA not #defined on this platform"
2232        #endif /* ACL_READ_DATA */
2233        (void)acl_get_perm_np(permset, perm);
2234      ], pr_cv_func_facl="BSD")
2235  fi
2236
2237  dnl Linux.
2238  if test "$pr_cv_func_facl" = "none"; then
2239    old_ldflags=$LDFLAGS
2240    old_libs=$LIBS
2241    new_ldflags=`echo "$LDFLAGS" | sed -e 's/-L\$(top_srcdir)\/lib//g'`
2242    LDFLAGS="$new_ldflags"
2243    LIBS="-lacl $LIBS"
2244    AC_TRY_LINK(
2245      [ #include <sys/types.h>
2246        #ifdef HAVE_SYS_ACL_H
2247        # include <sys/acl.h>
2248        #endif
2249        #ifdef HAVE_ACL_LIBACL_H
2250        # include <acl/libacl.h>
2251        #endif
2252      ],
2253      [ acl_permset_t permset;
2254        acl_perm_t perm;
2255        (void)acl_get_perm(permset, perm);
2256      ], pr_cv_func_facl="Linux")
2257    LDFLAGS=$old_ldflags
2258    LIBS=$old_libs
2259  fi
2260
2261  dnl MacOSX.
2262  if test "$pr_cv_func_facl" = "none"; then
2263    AC_TRY_LINK(
2264      [ #include <sys/types.h>
2265        #ifdef HAVE_SYS_ACL_H
2266        # include <sys/acl.h>
2267        #endif
2268        #ifdef HAVE_ACL_LIBACL_H
2269        # include <acl/libacl.h>
2270        #endif
2271      ],
2272      [ acl_entry_t ae;
2273        /* On Mac, ACL_READ_DATA is an enum value. */
2274        acl_perm_t perm = ACL_READ_DATA;
2275        (void)acl_get_qualifier(ae);
2276      ], pr_cv_func_facl="MacOSX")
2277  fi
2278
2279  dnl Solaris.
2280  if test "$pr_cv_func_facl" = "none"; then
2281    old_ldflags=$LDFLAGS
2282    LDFLAGS="-lsec $LDFLAGS"
2283    AC_TRY_LINK(
2284      [ #ifdef HAVE_STDDEF_H
2285        # include <stddef.h>
2286        #endif
2287        #ifdef HAVE_STDLIB_H
2288        # include <stdlib.h>
2289        #endif
2290        #ifdef HAVE_SYS_TYPES_H
2291        # include <sys/types.h>
2292        #endif
2293        #ifdef HAVE_SYS_ACL_H
2294        # include <sys/acl.h>
2295        #endif
2296        #ifdef HAVE_ACL_LIBACL_H
2297        # include <acl/libacl.h>
2298        #endif
2299      ],
2300      [ aclent_t ae;
2301        (void)aclcheck(&ae,0,NULL);
2302      ], pr_cv_func_facl="Solaris")
2303    LDFLAGS=$old_ldflags
2304  fi
2305)
2306
2307dnl Now, set the appropriate defines based on our investigations...
2308if test "$pr_cv_func_facl" != "none"; then
2309  AC_DEFINE(HAVE_POSIX_ACL, 1, [Define if you have POSIX ACL support])
2310
2311  case "$pr_cv_func_facl" in
2312    "BSD")
2313      AC_DEFINE(HAVE_BSD_POSIX_ACL, 1,
2314        [Define if you have BSD-flavoured POSIX ACL support])
2315      ;;
2316
2317    "Linux")
2318      AC_DEFINE(HAVE_LINUX_POSIX_ACL, 1,
2319        [Define if you have Linux-flavoured POSIX ACL support])
2320      ;;
2321
2322    "MacOSX")
2323      AC_DEFINE(HAVE_MACOSX_POSIX_ACL, 1,
2324        [Define if you have MacOSX-flavoured POSIX ACL support])
2325      ;;
2326
2327    "Solaris")
2328      AC_DEFINE(HAVE_LIBSEC, 1, [Define if you have libsec])
2329      AC_DEFINE(HAVE_SOLARIS_POSIX_ACL, 1,
2330        [Define if you have Solaris-flavoured POSIX ACL support])
2331      ;;
2332  esac
2333fi
2334
2335if test x"$enable_facl" = xyes ; then
2336  AC_DEFINE(PR_USE_FACL, 1, [Define if using POSIX ACL support.])
2337
2338  case "$pr_cv_func_facl" in
2339    "Linux")
2340      ac_build_addl_libs="-lacl $ac_build_addl_libs"
2341      ;;
2342
2343    "Solaris")
2344      ac_build_addl_libs="-lsec $ac_build_addl_libs"
2345      ;;
2346  esac
2347fi
2348
2349dnl IPv6.  Remember that the option is --disable-ipv6, despite the
2350dnl $enable_ipv6 variable name.
2351if test x"$enable_ipv6" != xno ; then
2352  AC_DEFINE(PR_USE_IPV6, 1, [Define if using IPv6 support.])
2353fi
2354
2355dnl sendfile() checks
2356if test x"$enable_sendfile" != xno ; then
2357  AC_CACHE_CHECK(
2358    [which sendfile() implementation to use],
2359    pr_cv_func_sendfile,
2360    pr_cv_func_sendfile="none"
2361
2362    dnl Linux.
2363    if test "$pr_cv_func_sendfile" = "none"; then
2364      AC_TRY_LINK(
2365        [ #include <sys/types.h>
2366          #include <sys/sendfile.h>
2367          #include <unistd.h>
2368        ],
2369        [ int i;
2370          off_t o;
2371          size_t c;
2372          (void)sendfile(i,i,&o,c);
2373        ], pr_cv_func_sendfile="Linux")
2374    fi
2375
2376    dnl BSD.
2377    if test "$pr_cv_func_sendfile" = "none"; then
2378      AC_TRY_LINK(
2379        [ #include <sys/types.h>
2380          #include <sys/socket.h>
2381          #include <sys/uio.h>
2382        ],
2383        [ int i;
2384          off_t o;
2385          size_t n;
2386          struct sf_hdtr h;
2387          (void)sendfile(i,i,o,n,&h,&o,i);
2388        ], pr_cv_func_sendfile="BSD")
2389    fi
2390
2391    dnl AIX.
2392    if test "$pr_cv_func_sendfile" = "none"; then
2393      AC_TRY_LINK(
2394        [ #include <sys/types.h>
2395          #include <sys/socket.h>
2396        ],
2397        [ uint f;
2398          int h;
2399          struct sf_parms p;
2400          (void)send_file(&(h),&(p),f);
2401        ], pr_cv_func_sendfile="AIX")
2402    fi
2403
2404    dnl Solaris
2405    if test "$pr_cv_func_sendfile" = "none"; then
2406      old_ldflags=$LDFLAGS
2407      LDFLAGS="-lsendfile $LDFLAGS"
2408      AC_TRY_LINK(
2409        [ #include <sys/types.h>
2410          #include <sys/sendfile.h>
2411          #include <unistd.h>
2412        ],
2413        [ int i;
2414          off_t o;
2415          size_t c;
2416          (void)sendfile(i,i,&o,c);
2417        ], pr_cv_func_sendfile="Solaris")
2418      LDFLAGS=$old_ldflags
2419    fi
2420
2421    dnl Mac OSX (10.5 and later)
2422    if test "$pr_cv_func_sendfile" = "none"; then
2423      AC_TRY_LINK(
2424        [ #include <sys/types.h>
2425          #include <sys/socket.h>
2426          #include <sys/uio.h>
2427        ],
2428        [ int i;
2429          off_t o, n;
2430          struct sf_hdtr h;
2431          (void)sendfile(i,i,o,&n,&h,i);
2432        ], pr_cv_func_sendfile="MacOSX")
2433    fi
2434  )
2435
2436  dnl Now, set the appropriate defines based on our investigations...
2437
2438  if test x"$pr_cv_func_sendfile" != x"none"; then
2439    dnl Avoid defining these for AIX and its buggy sendfile implementation,
2440    dnl as per Bug#3675
2441    if test x"$pr_cv_func_sendfile" != x"AIX"; then
2442      AC_DEFINE(HAVE_SENDFILE, 1, [Define if you have <sendfile.h>])
2443      AC_DEFINE(PR_USE_SENDFILE, 1,
2444        [Define if using sendfile support.])
2445    fi
2446  fi
2447
2448  case "$pr_cv_func_sendfile" in
2449    "Linux")
2450      AC_CHECK_HEADERS(sys/sendfile.h)
2451      AC_DEFINE(HAVE_LINUX_SENDFILE, 1,
2452        [Define if using Linux sendfile support.])
2453      ;;
2454
2455    "BSD")
2456      AC_DEFINE(HAVE_BSD_SENDFILE, 1,
2457        [Define if using BSD sendfile support.])
2458      ;;
2459
2460    "AIX")
2461      AC_MSG_WARN([** AIX sendfile support automatically disabled **])
2462      ;;
2463
2464    "Solaris")
2465      AC_CHECK_HEADERS(sys/sendfile.h)
2466      AC_DEFINE(HAVE_SOLARIS_SENDFILE, 1,
2467        [Define if using Solaris sendfile support.])
2468      ac_build_addl_libs="-lsendfile $ac_build_addl_libs"
2469      ;;
2470
2471    "MacOSX")
2472      AC_DEFINE(HAVE_MACOSX_SENDFILE, 1,
2473        [Define if using MacOSX sendfile support.])
2474      ;;
2475  esac
2476fi
2477
2478dnl Trace checks
2479if test x"$enable_trace" != xno ; then
2480  AC_DEFINE(PR_USE_TRACE, 1, [Define for trace support])
2481fi
2482
2483dnl Extended attribute checks
2484if test x"$enable_xattr" != xno ; then
2485  # On Free/Net/OpenBSD, it's sys/extattr.h
2486  AC_CHECK_HEADER(sys/extattr.h,
2487    [AC_DEFINE(HAVE_SYS_EXTATTR_H, 1, [Define if sys/extattr.h is present.])
2488     AC_DEFINE(PR_USE_XATTR, 1, [Define if using xattr support.])
2489
2490     AC_MSG_CHECKING([for extattr_delete_link])
2491     AC_TRY_LINK(
2492       [ #ifdef HAVE_STDDEF_H
2493         # include <stddef.h>
2494         #endif
2495         #ifdef HAVE_STDLIB_H
2496         # include <stdlib.h>
2497         #endif
2498         #ifdef HAVE_SYS_TYPES_H
2499         # include <sys/types.h>
2500         #endif
2501         #ifdef HAVE_SYS_EXTATTR_H
2502         # include <sys/extattr.h>
2503         #endif
2504       ],
2505       [
2506         int res;
2507         int namespace = 0;
2508         const char *path = NULL, name = NULL;
2509         res = extattr_delete_link(path, namespace, name);
2510       ],
2511       [
2512         AC_MSG_RESULT(yes)
2513         AC_DEFINE(HAVE_EXTATTR_DELETE_LINK, 1, [Define if you have extattr_delete_link])
2514       ],
2515       [
2516         AC_MSG_RESULT(no)
2517       ]
2518     )
2519
2520     AC_MSG_CHECKING([for extattr_get_link])
2521     AC_TRY_LINK(
2522       [ #ifdef HAVE_STDDEF_H
2523         # include <stddef.h>
2524         #endif
2525         #ifdef HAVE_STDLIB_H
2526         # include <stdlib.h>
2527         #endif
2528         #ifdef HAVE_SYS_TYPES_H
2529         # include <sys/types.h>
2530         #endif
2531         #ifdef HAVE_SYS_EXTATTR_H
2532         # include <sys/extattr.h>
2533         #endif
2534       ],
2535       [
2536         ssize_t res;
2537         int namespace = 0;
2538         const char *path = NULL, name = NULL;
2539         void *val = NULL;
2540         size_t sz = 0;
2541         res = extattr_get_link(path, namespace, name, val, sz);
2542       ],
2543       [
2544         AC_MSG_RESULT(yes)
2545         AC_DEFINE(HAVE_EXTATTR_GET_LINK, 1, [Define if you have extattr_get_link])
2546       ],
2547       [
2548         AC_MSG_RESULT(no)
2549       ]
2550     )
2551
2552     AC_MSG_CHECKING([for extattr_list_link])
2553     AC_TRY_LINK(
2554       [ #ifdef HAVE_STDDEF_H
2555         # include <stddef.h>
2556         #endif
2557         #ifdef HAVE_STDLIB_H
2558         # include <stdlib.h>
2559         #endif
2560         #ifdef HAVE_SYS_TYPES_H
2561         # include <sys/types.h>
2562         #endif
2563         #ifdef HAVE_SYS_EXTATTR_H
2564         # include <sys/extattr.h>
2565         #endif
2566       ],
2567       [
2568         ssize_t res;
2569         int namespace = 0;
2570         const char *path = NULL;
2571         void *val = NULL;
2572         size_t sz = 0;
2573         res = extattr_list_link(path, namespace, val, sz);
2574       ],
2575       [
2576         AC_MSG_RESULT(yes)
2577         AC_DEFINE(HAVE_EXTATTR_LIST_LINK, 1, [Define if you have extattr_list_link])
2578       ],
2579       [
2580         AC_MSG_RESULT(no)
2581       ]
2582     )
2583
2584     AC_MSG_CHECKING([for extattr_set_link])
2585     AC_TRY_LINK(
2586       [ #ifdef HAVE_STDDEF_H
2587         # include <stddef.h>
2588         #endif
2589         #ifdef HAVE_STDLIB_H
2590         # include <stdlib.h>
2591         #endif
2592         #ifdef HAVE_SYS_TYPES_H
2593         # include <sys/types.h>
2594         #endif
2595         #ifdef HAVE_SYS_EXTATTR_H
2596         # include <sys/extattr.h>
2597         #endif
2598       ],
2599       [
2600         int res;
2601         int namespace = 0;
2602         const char *path = NULL, name = NULL;
2603         void *val = NULL;
2604         size_t sz = 0;
2605         res = extattr_set_link(path, namespace, name, val, sz);
2606       ],
2607       [
2608         AC_MSG_RESULT(yes)
2609         AC_DEFINE(HAVE_EXTATTR_SET_LINK, 1, [Define if you have extattr_set_link])
2610       ],
2611       [
2612         AC_MSG_RESULT(no)
2613       ]
2614     )
2615   ])
2616
2617  # On Linux/MacOSX, it's sys/xattr.h
2618  AC_CHECK_HEADER(sys/xattr.h,
2619    [AC_DEFINE(HAVE_SYS_XATTR_H, 1, [Define if sys/xattr.h is present.])
2620     AC_DEFINE(PR_USE_XATTR, 1, [Define if using xattr support.])
2621     AC_CHECK_HEADERS(attr/xattr.h)
2622
2623     # Some platforms need libattr for extended attributes
2624     AC_CHECK_LIB(attr, setxattr)
2625
2626     AC_MSG_CHECKING([for lgetxattr])
2627     AC_TRY_LINK(
2628       [ #ifdef HAVE_STDDEF_H
2629         # include <stddef.h>
2630         #endif
2631         #ifdef HAVE_STDLIB_H
2632         # include <stdlib.h>
2633         #endif
2634         #ifdef HAVE_SYS_TYPES_H
2635         # include <sys/types.h>
2636         #endif
2637         #ifdef HAVE_SYS_XATTR_H
2638         # include <sys/xattr.h>
2639         #endif
2640       ],
2641       [
2642         ssize_t res;
2643         const char *path = NULL, *name = NULL;
2644         void *val = NULL;
2645         size_t sz = 0;
2646         res = lgetxattr(path, name, val, sz);
2647       ],
2648       [
2649         AC_MSG_RESULT(yes)
2650         AC_DEFINE(HAVE_LGETXATTR, 1, [Define if you have lgetxattr])
2651       ],
2652       [
2653         AC_MSG_RESULT(no)
2654       ]
2655     )
2656
2657     AC_MSG_CHECKING([for llistxattr])
2658     AC_TRY_LINK(
2659       [ #ifdef HAVE_STDDEF_H
2660         # include <stddef.h>
2661         #endif
2662         #ifdef HAVE_STDLIB_H
2663         # include <stdlib.h>
2664         #endif
2665         #ifdef HAVE_SYS_TYPES_H
2666         # include <sys/types.h>
2667         #endif
2668         #ifdef HAVE_SYS_XATTR_H
2669         # include <sys/xattr.h>
2670         #endif
2671       ],
2672       [
2673         ssize_t res;
2674         const char *path = NULL;
2675         char *names = NUL;
2676         size_t namessz = 0;
2677         res = llistxattr(path, names, namessz);
2678       ],
2679       [
2680         AC_MSG_RESULT(yes)
2681         AC_DEFINE(HAVE_LLISTXATTR, 1, [Define if you have llistxattr])
2682       ],
2683       [
2684         AC_MSG_RESULT(no)
2685       ]
2686     )
2687
2688     AC_MSG_CHECKING([for lremovexattr])
2689     AC_TRY_LINK(
2690       [ #ifdef HAVE_STDDEF_H
2691         # include <stddef.h>
2692         #endif
2693         #ifdef HAVE_STDLIB_H
2694         # include <stdlib.h>
2695         #endif
2696         #ifdef HAVE_SYS_TYPES_H
2697         # include <sys/types.h>
2698         #endif
2699         #ifdef HAVE_SYS_XATTR_H
2700         # include <sys/xattr.h>
2701         #endif
2702       ],
2703       [
2704         ssize_t res;
2705         const char *path = NULL, *name = NULL;
2706         res = lremovexattr(path, name);
2707       ],
2708       [
2709         AC_MSG_RESULT(yes)
2710         AC_DEFINE(HAVE_LREMOVEXATTR, 1, [Define if you have lremovexattr])
2711       ],
2712       [
2713         AC_MSG_RESULT(no)
2714       ]
2715     )
2716
2717     AC_MSG_CHECKING([for lsetxattr])
2718     AC_TRY_LINK(
2719       [ #ifdef HAVE_STDDEF_H
2720         # include <stddef.h>
2721         #endif
2722         #ifdef HAVE_STDLIB_H
2723         # include <stdlib.h>
2724         #endif
2725         #ifdef HAVE_SYS_TYPES_H
2726         # include <sys/types.h>
2727         #endif
2728         #ifdef HAVE_SYS_XATTR_H
2729         # include <sys/xattr.h>
2730         #endif
2731       ],
2732       [
2733         int res, flags = 0;
2734         const char *path = NULL, *name = NULL;
2735         const void *val = NULL;
2736         res = lsetxattr(path, name, val, flags);
2737       ],
2738       [
2739         AC_MSG_RESULT(yes)
2740         AC_DEFINE(HAVE_LSETXATTR, 1, [Define if you have lsetxattr])
2741       ],
2742       [
2743         AC_MSG_RESULT(no)
2744       ]
2745     )
2746   ])
2747fi
2748
2749dnl Custom-rolled macro for checking return type of setgrent(3)
2750PR_FUNC_SETGRENT_VOID
2751
2752if test x"$enable_curses" != xno ; then
2753  AC_CHECK_LIB(curses, initscr,
2754    [ CURSES_LIBS="-lcurses"
2755      AC_DEFINE(HAVE_LIBCURSES, 1, [Define if you have curses])
2756      AC_DEFINE(PR_USE_CURSES, 1, [Define if using curses support])
2757    ])
2758
2759  dnl Check for the libtinfo library, which contains the stdscr symbol,
2760  dnl halfdelay curses function on some systems (e.g. Gentoo); see
2761  dnl Issue #1207.  Note that on some systems, this may need to be libtinfow
2762  dnl instead.
2763  if test x"$enable_nls" = xyes ; then
2764    AC_CHECK_LIB(tinfow, halfdelay,
2765      [ UTILS_LIBS="$UTILS_LIBS -ltinfow"
2766        AC_DEFINE(HAVE_LIBTINFOW, 1, [Define if you have libtinfow])
2767      ],
2768      [ AC_CHECK_LIB(tinfo, halfdelay,
2769        [ UTILS_LIBS="$UTILS_LIBS -ltinfo"
2770          AC_DEFINE(HAVE_LIBTINFO, 1, [Define if you have libtinfo])
2771        ])
2772      ])
2773  else
2774    AC_CHECK_LIB(tinfo, halfdelay,
2775      [ UTILS_LIBS="$UTILS_LIBS -ltinfo"
2776        AC_DEFINE(HAVE_LIBTINFO, 1, [Define if you have libtinfo])
2777      ])
2778  fi
2779fi
2780
2781if test x"$enable_ncurses" != xno ; then
2782  pr_have_ncursesw="no"
2783
2784  dnl If NLS support has been enabled, then check for the locale-sensitive
2785  dnl libncursesw library first; if not found, or if no NLS support, then
2786  dnl check for libncurses.
2787
2788  if test x"$enable_nls" = xyes ; then
2789    AC_CHECK_LIB(ncursesw, initscr,
2790      [ CURSES_LIBS="-lncursesw"
2791        pr_have_ncursesw="yes"
2792        AC_DEFINE(HAVE_LIBNCURSESW, 1, [Define if you have ncursesw])
2793      ], [
2794        AC_CHECK_LIB(ncurses, initscr,
2795          [ CURSES_LIBS="-lncurses"
2796            AC_DEFINE(HAVE_LIBNCURSES, 1, [Define if you have ncurses])
2797          ])
2798      ])
2799
2800  else
2801    AC_CHECK_LIB(ncurses, initscr,
2802      [ CURSES_LIBS="-lncurses"
2803        AC_DEFINE(HAVE_LIBNCURSES, 1, [Define if you have ncurses])
2804      ])
2805  fi
2806
2807  dnl Check for the libtinfo library, which contains the halfdelay() curses
2808  dnl function on some systems (e.g. OpenSuSE); see Bug#3718.  Note that on
2809  dnl some systems, this may need to be libtinfow instead; see Issue #1174.
2810
2811  if test x"$pr_have_ncursesw" = xyes ; then
2812    AC_DEFINE(PR_USE_NCURSESW, 1, [Define if using ncursesw support])
2813    AC_CHECK_LIB(tinfow, halfdelay,
2814      [ UTILS_LIBS="$UTILS_LIBS -ltinfow"
2815        AC_DEFINE(HAVE_LIBTINFOW, 1, [Define if you have libtinfow])
2816      ],
2817      [ AC_CHECK_LIB(tinfo, halfdelay,
2818        [ UTILS_LIBS="$UTILS_LIBS -ltinfo"
2819          AC_DEFINE(HAVE_LIBTINFO, 1, [Define if you have libtinfo])
2820        ])
2821      ])
2822  else
2823    AC_DEFINE(PR_USE_NCURSES, 1, [Define if using ncurses support])
2824    AC_CHECK_LIB(tinfo, halfdelay,
2825      [ UTILS_LIBS="$UTILS_LIBS -ltinfo"
2826        AC_DEFINE(HAVE_LIBTINFO, 1, [Define if you have libtinfo])
2827      ])
2828  fi
2829fi
2830
2831if test x"$enable_nonblocking_log_open" != xno; then
2832  AC_DEFINE(PR_USE_NONBLOCKING_LOG_OPEN, 1, [Define if using nonblocking open of log files])
2833fi
2834
2835if test x"$enable_ident" == xyes ; then
2836  ac_static_modules="mod_ident.o $ac_static_modules"
2837  ac_build_static_modules="modules/mod_ident.o $ac_build_static_modules"
2838fi
2839
2840dnl Check for various argv[] replacing functions on various OSs
2841AC_CHECK_FUNCS(setproctitle)
2842AC_CHECK_HEADERS(libutil.h)
2843AC_CHECK_LIB(util, setproctitle,
2844	[AC_DEFINE(HAVE_SETPROCTITLE)
2845		ac_cv_func_setproctitle="yes" ; LIBS="$LIBS -lutil"])
2846
2847if test "$ac_cv_func_setproctitle" = "yes"; then
2848  AC_DEFINE(PF_ARGV_TYPE, PF_ARGV_NONE)
2849else
2850  pf_argv_set="no"
2851
2852  AC_CHECK_HEADERS(sys/pstat.h,have_pstat_h="yes",have_pstat_h="no")
2853  if test "$have_pstat_h" = "yes"; then
2854    AC_CHECK_FUNCS(pstat)
2855
2856    if test "$ac_cv_func_pstat" = "yes"; then
2857	AC_DEFINE(PF_ARGV_TYPE, PF_ARGV_PSTAT)
2858    else
2859	AC_DEFINE(PF_ARGV_TYPE, PF_ARGV_WRITEABLE)
2860    fi
2861
2862    pf_argv_set="yes"
2863  fi
2864
2865  if test "$pf_argv_set" = "no"; then
2866    AC_EGREP_HEADER([#define.*PS_STRINGS.*],sys/exec.h,
2867			have_psstrings="yes",have_psstrings="no")
2868    if test "$have_psstrings" = "yes"; then
2869	AC_DEFINE(PF_ARGV_TYPE, PF_ARGV_PSSTRINGS)
2870	pf_argv_set="yes"
2871    fi
2872  fi
2873
2874  if test "$pf_argv_set" = "no"; then
2875    AC_CACHE_CHECK(whether __progname and __progname_full are available,
2876		    pf_cv_var_progname,
2877		    AC_TRY_LINK([extern char *__progname, *__progname_full;],
2878			[__progname = "foo"; __progname_full = "foo bar";],
2879			pf_cv_var_progname="yes", pf_cv_var_progname="no"))
2880
2881    if test "$pf_cv_var_progname" = "yes"; then
2882	AC_DEFINE(HAVE___PROGNAME, 1, [Define if you have __progname])
2883    fi
2884
2885    AC_CACHE_CHECK(which argv replacement method to use,
2886		    pf_cv_argv_type,
2887		    AC_EGREP_CPP(yes,[
2888#if defined(__GNU_HURD__)
2889  yes
2890#endif
2891  ],pf_cv_argv_type="new", pf_cv_argv_type="writeable"))
2892
2893    if test "$pf_cv_argv_type" = "new"; then
2894	AC_DEFINE(PF_ARGV_TYPE, PF_ARGV_NEW)
2895	pf_argv_set="yes"
2896    fi
2897
2898    if test "$pf_argv_set" = "no"; then
2899	AC_DEFINE(PF_ARGV_TYPE, PF_ARGV_WRITEABLE)
2900    fi
2901  fi
2902fi
2903
2904dnl Check for stacktrace support
2905dnl On FreeBSD, the libexecinfo port is needed for the backtrace(3) function;
2906dnl we thus also need to check for the libexecinfo library
2907AC_CHECK_LIB(execinfo, backtrace)
2908
2909dnl Some libcs need the execinfo.h header for their backtrace symbols, and
2910dnl some (like Solaris) want ucontext.h.  Check for those headers here.
2911AC_CHECK_HEADERS(execinfo.h ucontext.h)
2912
2913dnl Make sure that we can find the backtrace(3) and backtrace_symbols(3)
2914dnl functions
2915AC_MSG_CHECKING([for backtrace])
2916AC_TRY_LINK(
2917  [
2918    #ifdef HAVE_STDDEF_H
2919    # include <stddef.h>
2920    #endif
2921    #ifdef HAVE_STDLIB_H
2922    # include <stdlib.h>
2923    #endif
2924    #ifdef HAVE_EXECINFO_H
2925    # include <execinfo.h>
2926    #endif
2927    #ifdef HAVE_UCONTEXT_H
2928    # include <ucontext.h>
2929    #endif
2930  ], [
2931    void **syms = NULL;
2932    int res, nsyms = 0;
2933    res = backtrace(syms, nsyms);
2934  ], [
2935    AC_MSG_RESULT(yes)
2936    AC_DEFINE(HAVE_BACKTRACE, 1, [Define if you have backtrace])
2937  ], [
2938    AC_MSG_RESULT(no)
2939  ]
2940)
2941
2942AC_MSG_CHECKING([for backtrace_symbols])
2943AC_TRY_LINK(
2944  [
2945    #ifdef HAVE_STDDEF_H
2946    # include <stddef.h>
2947    #endif
2948    #ifdef HAVE_STDLIB_H
2949    # include <stdlib.h>
2950    #endif
2951    #ifdef HAVE_EXECINFO_H
2952    # include <execinfo.h>
2953    #endif
2954    #ifdef HAVE_UCONTEXT_H
2955    # include <ucontext.h>
2956    #endif
2957  ], [
2958    void **syms = NULL;
2959    int nsyms = 0;
2960    char **res;
2961    res = backtrace_symbols(syms, nsyms);
2962  ], [
2963    AC_MSG_RESULT(yes)
2964    AC_DEFINE(HAVE_BACKTRACE_SYMBOLS, 1, [Define if you have backtrace_symbols])
2965  ], [
2966    AC_MSG_RESULT(no)
2967  ]
2968)
2969
2970dnl Run a small test program to see if the host's printf(3) family can
2971dnl actually handle the %llu format.
2972AC_MSG_CHECKING([whether printf supports %llu format]);
2973AC_TRY_RUN(
2974  [ #include <stdio.h>
2975    int main(int argc, char *argv[]) {
2976      return (fprintf(stderr, "%llu\n", (unsigned long long) 1) == 2 ? 0 : 1);
2977    }
2978  ],
2979  AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LLU, 1, [Define if you have %llu support]),
2980  AC_MSG_RESULT(no); AC_DEFINE(HAVE_LU, 1, [Define if you have %lu support]),
2981  AC_MSG_RESULT(cross-compiling); AC_DEFINE(HAVE_LU, 1, [Define if you have %lu support])
2982)
2983
2984dnl Add the proftpd support library
2985LIBS="-lsupp $LIBS"
2986
2987dnl Module handling.
2988ac_shared_module_dirs=
2989ac_static_module_dirs=
2990
2991dnl Remove any modules in the shared module list from the core and static
2992dnl module lists
2993for amodule in $ac_shared_modules; do
2994  module=`echo "$amodule" | sed -e 's/\.la//g'`.o;
2995
2996  ac_core_modules=`echo "$ac_core_modules" | sed -e "s/$module//g"`;
2997  ac_build_core_modules=`echo "$ac_build_core_modules" | sed -e "s/modules\/$module//g"`;
2998
2999  ac_static_modules=`echo "$ac_static_modules" | sed -e "s/$module//g"`;
3000  ac_build_static_modules=`echo "$ac_build_static_modules" | sed -e "s/modules\/$module//g"`;
3001done
3002
3003GLUE_MODULE_OBJS="$ac_core_modules $ac_static_modules"
3004
3005dnl Check for any duplicates
3006my_core_modules=`echo "$ac_core_modules" | sed -e 's/\.o//g'`;
3007my_static_modules=`echo "$ac_static_modules" | sed -e 's/\.o//g'`;
3008my_shared_modules=`echo "$ac_shared_modules" | sed -e 's/\.la//g'`;
3009all_modules="$my_core_modules $my_static_modules $my_shared_modules";
3010
3011pr_use_mysql="no"
3012pr_use_postgres="no"
3013
3014AC_MSG_CHECKING([for duplicate module build requests])
3015for i in $all_modules; do
3016  once=no;
3017
3018  dnl Make sure the OpenSSL define is set if mod_tls, mod_sftp, or other
3019  dnl whitelisted modules are being used
3020  if test x"$i" = x"mod_auth_otp"; then
3021    if test x"$pr_use_openssl" = x ; then
3022      pr_use_openssl=yes
3023    fi
3024
3025  elif test x"$i" = x"mod_digest"; then
3026    if test x"$pr_use_openssl" = x ; then
3027      pr_use_openssl=yes
3028    fi
3029
3030  elif test x"$i" = x"mod_tls"; then
3031    if test x"$pr_use_openssl" = x ; then
3032      pr_use_openssl=yes
3033    fi
3034
3035  elif test x"$i" = x"mod_sftp"; then
3036    if test x"$pr_use_openssl" = x ; then
3037      pr_use_openssl=yes
3038    fi
3039
3040    if test x"$pr_use_sodium" = x ; then
3041      pr_use_sodium=yes
3042    fi
3043
3044  elif test x"$i" = x"mod_sql_passwd"; then
3045    if test x"$pr_use_openssl" = x ; then
3046      pr_use_openssl=yes
3047    fi
3048
3049    if test x"$pr_use_sodium" = x ; then
3050      pr_use_sodium=yes
3051    fi
3052  fi
3053
3054  for j in $all_modules; do
3055    if test x"$i" = x"$j"; then
3056      if test x"$once" = xno; then
3057        once=yes;
3058
3059      else
3060        AC_MSG_RESULT([yes])
3061        AC_MSG_ERROR([duplicate build request for $j -- aborting])
3062      fi
3063    fi
3064  done
3065
3066  dnl Use database-specific config scripts, if we can.  Note that
3067  dnl these will cause problems for cross-compiles!
3068  if test x"$i" = x"mod_sql_mysql"; then
3069    pr_use_mysql="yes"
3070
3071    if test x"$my_config" != xno; then
3072      if `$my_config --version 2>/dev/null 1>&2`; then
3073        # mysql_config --include gives path WITH -I prefix
3074        mysql_includes=`$my_config --include 2>/dev/null`
3075        if test ! -z "$mysql_includes"; then
3076          ac_build_addl_includes="$ac_build_addl_includes $mysql_includes"
3077        fi
3078
3079        # mysql_config --libs gives ALL options; use just the -L ones.
3080        #
3081        # Note that due to Bug#3702, we also need to look for -pthread, and
3082        # if present, add it to the LIBS list of flags.
3083
3084        mysql_libdirs=`$my_config --libs 2>/dev/null`
3085        if test ! -z "$mysql_libdirs"; then
3086          for my_libdir in $mysql_libdirs; do
3087            l=`echo -n "$my_libdir" | sed -n '/^-L/{p;}'`
3088            if test ! -z "$l"; then
3089              ac_build_addl_libdirs="$ac_build_addl_libdirs $my_libdir"
3090            fi
3091
3092            if test x"$my_libdir" = x"-pthread"; then
3093              LIBS="$LIBS -pthread"
3094            fi
3095          done
3096        fi
3097      fi
3098    fi
3099
3100  elif test x"$i" = x"mod_sql_postgres"; then
3101    pr_use_postgres="yes"
3102
3103    if test x"$pg_config" != xno; then
3104      if `$pg_config 2>/dev/null 1>&2`; then
3105        # pg_config --includedir gives path, no -I prefix
3106        pg_includes=`$pg_config --includedir 2>/dev/null`
3107        if test ! -z "$pg_includes"; then
3108          ac_build_addl_includes="$ac_build_addl_includes -I$pg_includes"
3109        fi
3110
3111        # pg_config --libdir gives path, no -L prefix
3112        pg_libdirs=`$pg_config --libdir 2>/dev/null`
3113        if test ! -z "pg_libdirs"; then
3114          ac_build_addl_libdirs="$ac_build_addl_libdirs -L$pg_libdirs"
3115        fi
3116
3117        # I suspect that we will also need to look for -pthread here
3118        # (a la Bug#3702), as a forums post about proftpd+postgres describes
3119        # the same "Alarm clock" symptom as seen with MySQL; see:
3120        #
3121        #  http://forums.proftpd.org/smf/index.php/topic,1424.0.html
3122
3123        # pg_config --libs gives libs, with -l prefixes
3124        pg_libs=`$pg_config --libs 2>/dev/null`
3125        if test ! -z "$pg_libs"; then
3126          for pg_lib in $pg_lib; do
3127            if test x"$pg_lib" = x"-pthread"; then
3128              LIBS="$LIBS -pthread"
3129            fi
3130          done
3131        fi
3132      fi
3133    fi
3134  fi
3135done
3136AC_MSG_RESULT([no])
3137
3138if test x"$pr_use_mysql" = xyes; then
3139  dnl Check for other MySQL-specific functionality here
3140  saved_cppflags="$CPPFLAGS"
3141  saved_ldflags="$LDFLAGS"
3142  saved_libs="$LIBS"
3143
3144  dnl Fiddle with CPPFLAGS, LDFLAGS
3145  CPPFLAGS="$CPPFLAGS $ac_build_addl_includes"
3146  LDFLAGS="$LDFLAGS $ac_build_addl_libdirs"
3147
3148  dnl Splice out -lsupp FROM LIBS, since that library hasn't been built yet
3149  LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3150  LIBS="$LIBS -lm -lmysqlclient -lz"
3151
3152  AC_MSG_CHECKING([for mysql_get_option])
3153  AC_TRY_LINK(
3154    [ #ifdef HAVE_STDDEF_H
3155      # include <stddef.h>
3156      #endif
3157      #ifdef HAVE_STDLIB_H
3158      # include <stdlib.h>
3159      #endif
3160      #ifdef HAVE_SYS_TYPES_H
3161      # include <sys/types.h>
3162      #endif
3163      #include <mysql.h>
3164    ],
3165    [
3166      (void) mysql_get_option(NULL, 0, NULL);
3167    ],
3168    [
3169      AC_MSG_RESULT(yes)
3170      AC_DEFINE(HAVE_MYSQL_GET_OPTION, 1, [Define if you have the mysql_get_option function])
3171    ],
3172    [
3173      AC_MSG_RESULT(no)
3174    ]
3175  )
3176
3177  dnl For Bug#3669, we need to check for make_scrambled_password_323.
3178  dnl While we're at it, check for other variants as well.
3179
3180  AC_MSG_CHECKING([for MySQL's make_scrambled_password])
3181  AC_TRY_LINK(
3182    [ #ifdef HAVE_STDDEF_H
3183      # include <stddef.h>
3184      #endif
3185      #ifdef HAVE_STDLIB_H
3186      # include <stdlib.h>
3187      #endif
3188      #ifdef HAVE_SYS_TYPES_H
3189      # include <sys/types.h>
3190      #endif
3191      #include <mysql.h>
3192    ],
3193    [
3194      char output[32];
3195      char *input = NULL;
3196      (void) make_scrambled_password(output, input);
3197    ],
3198    [
3199      AC_MSG_RESULT(yes)
3200      AC_DEFINE(HAVE_MYSQL_MAKE_SCRAMBLED_PASSWORD, 1, [Define if you have MySQL's make_scrambled_password function])
3201    ],
3202    [
3203      AC_MSG_RESULT(no)
3204    ]
3205  )
3206
3207  AC_MSG_CHECKING([for MySQL's make_scrambled_password_323])
3208  AC_TRY_LINK(
3209    [ #ifdef HAVE_STDDEF_H
3210      # include <stddef.h>
3211      #endif
3212      #ifdef HAVE_STDLIB_H
3213      # include <stdlib.h>
3214      #endif
3215      #ifdef HAVE_SYS_TYPES_H
3216      # include <sys/types.h>
3217      #endif
3218      #include <mysql.h>
3219    ],
3220    [
3221      char output[32];
3222      char *input = NULL;
3223      (void) make_scrambled_password_323(output, input);
3224    ],
3225    [
3226      AC_MSG_RESULT(yes)
3227      AC_DEFINE(HAVE_MYSQL_MAKE_SCRAMBLED_PASSWORD_323, 1, [Define if you have MySQL's make_scrambled_password_323 function])
3228    ],
3229    [
3230      AC_MSG_RESULT(no)
3231    ]
3232  )
3233
3234  # For Bug#3669 in the RedHat case, we need to check for
3235  # my_make_scrambled_password.
3236  AC_MSG_CHECKING([for MySQL's my_make_scrambled_password])
3237  AC_TRY_LINK(
3238    [ #ifdef HAVE_STDDEF_H
3239      # include <stddef.h>
3240      #endif
3241      #ifdef HAVE_STDLIB_H
3242      # include <stdlib.h>
3243      #endif
3244      #ifdef HAVE_SYS_TYPES_H
3245      # include <sys/types.h>
3246      #endif
3247      #include <mysql.h>
3248    ],
3249    [
3250      char output[32];
3251      char *input = NULL;
3252      size_t inputlen = 0;
3253      (void) my_make_scrambled_password(output, input, inputlen);
3254    ],
3255    [
3256      AC_MSG_RESULT(yes)
3257      AC_DEFINE(HAVE_MYSQL_MY_MAKE_SCRAMBLED_PASSWORD, 1, [Define if you have MySQL's my_make_scrambled_password function])
3258    ],
3259    [
3260      AC_MSG_RESULT(no)
3261    ]
3262  )
3263
3264  AC_MSG_CHECKING([for MySQL's my_make_scrambled_password_323])
3265  AC_TRY_LINK(
3266    [ #ifdef HAVE_STDDEF_H
3267      # include <stddef.h>
3268      #endif
3269      #ifdef HAVE_STDLIB_H
3270      # include <stdlib.h>
3271      #endif
3272      #ifdef HAVE_SYS_TYPES_H
3273      # include <sys/types.h>
3274      #endif
3275      #include <mysql.h>
3276    ],
3277    [
3278      char output[32];
3279      char *input = NULL;
3280      size_t inputlen = 0;
3281      (void) my_make_scrambled_password_323(output, input, inputlen);
3282    ],
3283    [
3284      AC_MSG_RESULT(yes)
3285      AC_DEFINE(HAVE_MYSQL_MY_MAKE_SCRAMBLED_PASSWORD_323, 1, [Define if you have MySQL's my_make_scrambled_password_323 function])
3286    ],
3287    [
3288      AC_MSG_RESULT(no)
3289    ]
3290  )
3291
3292  AC_MSG_CHECKING([for MySQL's mysql_ssl_set])
3293  AC_TRY_LINK(
3294    [ #ifdef HAVE_STDDEF_H
3295      # include <stddef.h>
3296      #endif
3297      #ifdef HAVE_STDLIB_H
3298      # include <stdlib.h>
3299      #endif
3300      #ifdef HAVE_SYS_TYPES_H
3301      # include <sys/types.h>
3302      #endif
3303      #include <mysql.h>
3304    ],
3305    [
3306      MYSQL *mysql = NULL;
3307      (void) mysql_ssl_set(mysql, NULL, NULL, NULL, NULL, NULL);
3308    ],
3309    [
3310      AC_MSG_RESULT(yes)
3311      AC_DEFINE(HAVE_MYSQL_MYSQL_SSL_SET, 1, [Define if you have MySQL's mysql_ssl_set function])
3312    ],
3313    [
3314      AC_MSG_RESULT(no)
3315    ]
3316  )
3317
3318  AC_MSG_CHECKING([for MySQL's mysql_get_ssl_cipher])
3319  AC_TRY_LINK(
3320    [ #ifdef HAVE_STDDEF_H
3321      # include <stddef.h>
3322      #endif
3323      #ifdef HAVE_STDLIB_H
3324      # include <stdlib.h>
3325      #endif
3326      #ifdef HAVE_SYS_TYPES_H
3327      # include <sys/types.h>
3328      #endif
3329      #include <mysql.h>
3330    ],
3331    [
3332      MYSQL *mysql = NULL;
3333      (void) mysql_get_ssl_cipher(mysql);
3334    ],
3335    [
3336      AC_MSG_RESULT(yes)
3337      AC_DEFINE(HAVE_MYSQL_MYSQL_GET_SSL_CIPHER, 1, [Define if you have MySQL's mysql_get_ssl_cipher function])
3338    ],
3339    [
3340      AC_MSG_RESULT(no)
3341    ]
3342  )
3343
3344  dnl Restore CPPFLAGS, LDFLAGS
3345  CPPFLAGS="$saved_cppflags"
3346  LDFLAGS="$saved_ldflags"
3347  LIBS="$saved_libs"
3348fi
3349
3350if test x"$pr_use_openssl" = xyes; then
3351  AC_DEFINE(PR_USE_OPENSSL, 1, [Define if using OpenSSL support.])
3352  ac_build_addl_libs="$ac_build_addl_libs -lssl -lcrypto"
3353
3354  AC_MSG_CHECKING([whether OpenSSL is compiled with FIPS support])
3355  saved_libs="$LIBS"
3356
3357  dnl Splice out -lsupp, since that library hasn't been built yet
3358  LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3359  LIBS="$LIBS -lcrypto"
3360
3361  AC_TRY_RUN(
3362    [
3363      #include <openssl/crypto.h>
3364      #include <openssl/fips.h>
3365      int main(int argc, char *argv[]) {
3366      # ifdef OPENSSL_FIPS
3367        return 0;
3368      # else
3369        return 1;
3370      #endif
3371      }
3372    ],
3373    AC_MSG_RESULT(yes); AC_DEFINE(PR_USE_OPENSSL_FIPS, 1, [Define if your OpenSSL supports FIPS]),
3374    AC_MSG_RESULT(no),
3375    AC_MSG_RESULT(unknown)
3376  )
3377  LIBS="$saved_libs"
3378
3379  AC_MSG_CHECKING([whether linking with OpenSSL functions succeeds])
3380  saved_libs="$LIBS"
3381
3382  dnl Splice out -lsupp, since that library hasn't been built yet
3383  LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3384  LIBS="-lcrypto $LIBS"
3385
3386  AC_TRY_LINK(
3387    [
3388      #include <openssl/evp.h>
3389    ],
3390    [
3391      SSLeay_add_all_algorithms();
3392    ],
3393    [
3394      AC_MSG_RESULT(yes)
3395      LIBS="$saved_libs"
3396    ],
3397    [
3398      AC_MSG_RESULT(no)
3399
3400      AC_MSG_CHECKING([whether linking with OpenSSL functions requires -ldl])
3401      LIBS="-lcrypto -ldl $LIBS"
3402      AC_TRY_LINK(
3403        [
3404          #include <openssl/evp.h>
3405        ],
3406        [
3407          SSLeay_add_all_algorithms();
3408        ],
3409        [
3410          AC_MSG_RESULT(yes)
3411          LIBS="$saved_libs -ldl"
3412        ],
3413        [
3414          AC_MSG_RESULT(no)
3415          LIBS="$saved_libs"
3416        ]
3417      )
3418
3419      AC_MSG_CHECKING([whether linking with OpenSSL functions requires -lz])
3420      saved_libs="$LIBS"
3421
3422      dnl Splice out -lsupp, since that library hasn't been built yet
3423      LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3424      LIBS="-lcrypto -lz $LIBS"
3425
3426      AC_TRY_LINK(
3427        [
3428          #include <openssl/evp.h>
3429          #include <openssl/bio.h>
3430          #include <openssl/comp.h>
3431        ],
3432        [
3433          BIO *bio;
3434          SSLeay_add_all_algorithms();
3435          bio = BIO_new(BIO_f_zlib());
3436        ],
3437        [
3438          AC_MSG_RESULT(yes)
3439          LIBS="$saved_libs -lz"
3440        ],
3441        [
3442          AC_MSG_RESULT(no)
3443          LIBS="$saved_libs"
3444        ]
3445      )
3446    ]
3447  )
3448
3449  AC_MSG_CHECKING([whether OpenSSL has complete ECC support])
3450  saved_libs="$LIBS"
3451
3452  dnl Splice out -lsupp, since that library hasn't been built yet
3453  LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3454  LIBS="-lcrypto $LIBS"
3455
3456  AC_TRY_LINK(
3457    [
3458      #include <openssl/ec.h>
3459      #include <openssl/ecdh.h>
3460      #include <openssl/ecdsa.h>
3461      #include <openssl/evp.h>
3462      #include <openssl/objects.h>
3463      #include <openssl/opensslv.h>
3464      #if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
3465      # error "OpenSSL < 0.9.8g has unreliable ECC code"
3466      #endif
3467    ],
3468    [
3469      EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
3470      const EVP_MD *m = EVP_sha512();
3471    ],
3472    [
3473      AC_MSG_RESULT(yes)
3474      AC_DEFINE(PR_USE_OPENSSL_ECC, 1, [Define if your OpenSSL supports ECC])
3475    ],
3476    [
3477      AC_MSG_RESULT(no)
3478    ]
3479  )
3480  LIBS="$saved_libs"
3481
3482  AC_MSG_CHECKING([whether OpenSSL has EVP_CipherInit_ex support])
3483  saved_libs="$LIBS"
3484
3485  dnl Splice out -lsupp, since that library hasn't been built yet
3486  LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3487  LIBS="-lcrypto $LIBS"
3488
3489  AC_TRY_LINK(
3490    [
3491      #include <openssl/evp.h>
3492    ],
3493    [
3494      (void) EVP_CipherInit_ex(NULL, NULL, NULL, NULL, NULL, 1);
3495    ],
3496    [
3497      AC_MSG_RESULT(yes)
3498      AC_DEFINE(PR_USE_OPENSSL_EVP_CIPHERINIT_EX, 1, [Define if your OpenSSL supports EVP_CipherInit_ex])
3499    ],
3500    [
3501      AC_MSG_RESULT(no)
3502    ]
3503  )
3504  LIBS="$saved_libs"
3505
3506  AC_MSG_CHECKING([whether OpenSSL has ALPN support])
3507  saved_libs="$LIBS"
3508
3509  dnl Splice out -lsupp, since that library hasn't been built yet
3510  LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3511  LIBS="-lcrypto -lssl $LIBS"
3512
3513  AC_TRY_LINK(
3514    [
3515      #ifdef HAVE_STDDEF_H
3516      # include <stddef.h>
3517      #endif
3518      #ifdef HAVE_STDLIB_H
3519      # include <stdlib.h>
3520      #endif
3521      #include <openssl/ssl.h>
3522    ],
3523    [
3524      SSL_CTX *ctx = NULL;
3525      SSL_CTX_set_alpn_select_cb(ctx, NULL, NULL);
3526    ],
3527    [
3528      AC_MSG_RESULT(yes)
3529      AC_DEFINE(PR_USE_OPENSSL_ALPN, 1, [Define if your OpenSSL supports ALPN])
3530    ],
3531    [
3532      AC_MSG_RESULT(no)
3533    ]
3534  )
3535  LIBS="$saved_libs"
3536
3537  AC_MSG_CHECKING([whether OpenSSL has NPN support])
3538  saved_libs="$LIBS"
3539
3540  dnl Splice out -lsupp, since that library hasn't been built yet
3541  LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3542  LIBS="-lcrypto -lssl $LIBS"
3543
3544  AC_TRY_LINK(
3545    [
3546      #ifdef HAVE_STDDEF_H
3547      # include <stddef.h>
3548      #endif
3549      #ifdef HAVE_STDLIB_H
3550      # include <stdlib.h>
3551      #endif
3552      #include <openssl/ssl.h>
3553    ],
3554    [
3555      SSL_CTX *ctx = NULL;
3556      SSL_CTX_set_next_protos_advertised_cb(ctx, NULL, NULL);
3557    ],
3558    [
3559      AC_MSG_RESULT(yes)
3560      AC_DEFINE(PR_USE_OPENSSL_NPN, 1, [Define if your OpenSSL supports NPN])
3561    ],
3562    [
3563      AC_MSG_RESULT(no)
3564    ]
3565  )
3566  LIBS="$saved_libs"
3567
3568  AC_MSG_CHECKING([whether OpenSSL has OCSP support])
3569  saved_libs="$LIBS"
3570
3571  dnl Splice out -lsupp, since that library hasn't been built yet
3572  LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3573  LIBS="-lcrypto -lssl $LIBS"
3574
3575  AC_TRY_LINK(
3576    [
3577      #ifdef HAVE_STDDEF_H
3578      # include <stddef.h>
3579      #endif
3580      #ifdef HAVE_STDLIB_H
3581      # include <stdlib.h>
3582      #endif
3583      #include <openssl/ssl.h>
3584      #include <openssl/ocsp.h>
3585    ],
3586    [
3587      SSL_CTX *ctx = NULL;
3588      SSL_CTX_set_tlsext_status_cb(ctx, NULL);
3589      SSL_CTX_set_tlsext_status_arg(ctx, NULL);
3590    ],
3591    [
3592      AC_MSG_RESULT(yes)
3593      AC_DEFINE(PR_USE_OPENSSL_OCSP, 1, [Define if your OpenSSL supports OCSP])
3594    ],
3595    [
3596      AC_MSG_RESULT(no)
3597    ]
3598  )
3599  LIBS="$saved_libs"
3600
3601  AC_MSG_CHECKING([whether OpenSSL has SSL num tickets support])
3602  saved_libs="$LIBS"
3603
3604  dnl Splice out -lsupp, since that library hasn't been built yet
3605  LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3606  LIBS="-lcrypto -lssl $LIBS"
3607
3608  AC_TRY_LINK(
3609    [
3610      #include <openssl/ssl.h>
3611    ],
3612    [
3613      (void) SSL_set_num_tickets(NULL, 0);
3614    ],
3615    [
3616      AC_MSG_RESULT(yes)
3617      AC_DEFINE(PR_USE_OPENSSL_SSL_NUM_TICKETS, 1, [Define if your OpenSSL supports SSL num tickets])
3618    ],
3619    [
3620      AC_MSG_RESULT(no)
3621    ]
3622  )
3623  LIBS="$saved_libs"
3624
3625  AC_MSG_CHECKING([whether OpenSSL has SSL read ahead support])
3626  saved_libs="$LIBS"
3627
3628  dnl Splice out -lsupp, since that library hasn't been built yet
3629  LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3630  LIBS="-lcrypto -lssl $LIBS"
3631
3632  AC_TRY_LINK(
3633    [
3634      #include <openssl/ssl.h>
3635    ],
3636    [
3637      (void) SSL_set_read_ahead(NULL, 1);
3638    ],
3639    [
3640      AC_MSG_RESULT(yes)
3641      AC_DEFINE(PR_USE_OPENSSL_SSL_READ_AHEAD, 1, [Define if your OpenSSL supports SSL read ahead])
3642    ],
3643    [
3644      AC_MSG_RESULT(no)
3645    ]
3646  )
3647  LIBS="$saved_libs"
3648
3649  AC_MSG_CHECKING([whether OpenSSL has SSL session ID context set support])
3650  saved_libs="$LIBS"
3651
3652  dnl Splice out -lsupp, since that library hasn't been built yet
3653  LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3654  LIBS="-lcrypto -lssl $LIBS"
3655
3656  AC_TRY_LINK(
3657    [
3658      #include <openssl/ssl.h>
3659    ],
3660    [
3661      (void) SSL_SESSION_set1_id_context(NULL, NULL, 0);
3662    ],
3663    [
3664      AC_MSG_RESULT(yes)
3665      AC_DEFINE(PR_USE_OPENSSL_SSL_SESSION_SET1_ID_CONTEXT, 1, [Define if your OpenSSL supports setting SSL session ID context])
3666    ],
3667    [
3668      AC_MSG_RESULT(no)
3669    ]
3670  )
3671  LIBS="$saved_libs"
3672
3673  AC_MSG_CHECKING([whether OpenSSL has SSL session ticket callback support])
3674  saved_libs="$LIBS"
3675
3676  dnl Splice out -lsupp, since that library hasn't been built yet
3677  LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3678  LIBS="-lcrypto -lssl $LIBS"
3679
3680  AC_TRY_LINK(
3681    [
3682      #include <openssl/ssl.h>
3683    ],
3684    [
3685
3686      (void) SSL_CTX_set_session_ticket_cb(NULL, NULL, NULL, NULL);
3687    ],
3688    [
3689      AC_MSG_RESULT(yes)
3690      AC_DEFINE(PR_USE_OPENSSL_SSL_SESSION_TICKET_CALLBACK, 1, [Define if your OpenSSL supports SSL session ticket callbacks])
3691    ],
3692    [
3693      AC_MSG_RESULT(no)
3694    ]
3695  )
3696  LIBS="$saved_libs"
3697
3698  pr_use_pthread_for_openssl="no"
3699  if test x"$openssl_cmdline" != xno; then
3700    if `$openssl_cmdline version 2>/dev/null 1>&2`; then
3701      openssl_cflags=`$openssl_cmdline version -f 2>/dev/null`
3702      if test ! -z "$openssl_cflags"; then
3703        # Look for the -pthread flag, indicating that this OpenSSL was built
3704        # with threads support (see Bug#3795)
3705        for openssl_cflag in $openssl_cflags; do
3706          if test x"$openssl_cflag" = x"-pthread"; then
3707            pr_use_pthread_for_openssl="yes"
3708          fi
3709        done
3710
3711        if test x"$pr_use_pthread_for_openssl" = xno ; then
3712          # If we're on FreeBSD, AND if OpenSSL is being used, AND if
3713          # openssl version -f shows no flags, then ASSUME that we do need
3714          # the -pthread flag, to avoid regressions of Bug#3795.
3715          if test `echo $ostype | grep -c FREEBSD` != "0" ; then
3716            pr_use_pthread_for_openssl="yes"
3717          fi
3718        fi
3719      fi
3720    fi
3721  else
3722    # If we're on FreeBSD, AND if OpenSSL is being used, then ASSUME that we
3723    # do need the -pthread flag, to avoid regressions of Bug#3795.
3724    if test `echo $ostype | grep -c DFREEBSD` != "0" ; then
3725      pr_use_pthread_for_openssl="yes"
3726    fi
3727  fi
3728
3729  if test x"$pr_use_pthread_for_openssl" = xyes ; then
3730    LIBS="$LIBS -pthread"
3731  fi
3732fi
3733
3734if test x"$pr_use_postgres" = xyes; then
3735  # Check for other Postgres-specific functionality here
3736  saved_ldflags="$LDFLAGS"
3737  saved_libs="$LIBS"
3738  saved_cppflags="$CPPFLAGS"
3739
3740  # fiddle with CPPFLAGS, LDFLAGS
3741  CPPFLAGS="$CPPFLAGS $ac_build_addl_includes"
3742  LDFLAGS="$LDFLAGS $ac_build_addl_libdirs"
3743
3744  dnl Splice out -lsupp, since that library hasn't been built yet
3745  LIBS=`echo "$LIBS" | sed -e 's/-lsupp//g'`;
3746  LIBS="$LIBS -lm -lpq"
3747
3748  AC_MSG_CHECKING([for Postgres's PQescapeStringConn])
3749  AC_TRY_LINK(
3750    [ #ifdef HAVE_STDDEF_H
3751      # include <stddef.h>
3752      #endif
3753      #ifdef HAVE_STDLIB_H
3754      # include <stdlib.h>
3755      #endif
3756      #ifdef HAVE_SYS_TYPES_H
3757      # include <sys/types.h>
3758      #endif
3759      #include <libpq-fe.h>
3760    ],
3761    [
3762      char *input = NULL, *output = NULL;
3763      size_t inputlen = 0;
3764      PGconn *postgres = NULL;
3765      int pgerr = 0;
3766      PQescapeStringConn(postgres, output, input, inputlen, &pgerr);
3767    ],
3768    [
3769      AC_MSG_RESULT(yes)
3770      AC_DEFINE(HAVE_POSTGRES_PQESCAPESTRINGCONN, 1, [Define if you have Postgres's PQescapeStringConn])
3771    ],
3772    [
3773      AC_MSG_RESULT(no)
3774    ]
3775  )
3776
3777  AC_MSG_CHECKING([for Postgres's PQgetssl])
3778  AC_TRY_LINK(
3779    [ #ifdef HAVE_STDDEF_H
3780      # include <stddef.h>
3781      #endif
3782      #ifdef HAVE_STDLIB_H
3783      # include <stdlib.h>
3784      #endif
3785      #ifdef HAVE_SYS_TYPES_H
3786      # include <sys/types.h>
3787      #endif
3788      #include <libpq-fe.h>
3789    ],
3790    [
3791      const PGconn *pg = NULL;
3792      (void) PQgetssl(pg);
3793    ],
3794    [
3795      AC_MSG_RESULT(yes)
3796      AC_DEFINE(HAVE_POSTGRES_PQGETSSL, 1, [Define if you have Postgres's PQgetssl])
3797    ],
3798    [
3799      AC_MSG_RESULT(no)
3800    ]
3801  )
3802
3803  # restore CPPFLAGS, LDFLAGS
3804  CPPFLAGS="$saved_cppflags"
3805  LDFLAGS="$saved_ldflags"
3806
3807  AC_MSG_CHECKING([for Postgres's PQinitOpenSSL])
3808  AC_TRY_LINK(
3809    [
3810      #ifdef HAVE_STDLIB_H
3811      # include <stdlib.h>
3812      #endif
3813      #ifdef HAVE_SYS_TYPES_H
3814      # include <sys/types.h>
3815      #endif
3816      #include <libpq-fe.h>
3817    ],
3818    [
3819      int init_ssl = 0, init_crypto = 0;
3820      PQinitOpenSSL(init_ssl, init_crypto);
3821    ],
3822    [
3823      AC_MSG_RESULT(yes)
3824      AC_DEFINE(HAVE_POSTGRES_PQINITOPENSSL, 1, [Define if you have Postgres's PQinitOpenSSL])
3825    ],
3826    [
3827      AC_MSG_RESULT(no)
3828    ]
3829  )
3830
3831  # restore CPPFLAGS, LDFLAGS
3832  CPPFLAGS="$saved_cppflags"
3833  LDFLAGS="$saved_ldflags"
3834  LIBS="$saved_libs"
3835fi
3836
3837if test x"$pr_use_sodium" = xyes; then
3838  AC_CHECK_HEADER(sodium.h,
3839    [AC_DEFINE(HAVE_SODIUM_H, 1, [Define if sodium.h is present.])
3840     AC_DEFINE(PR_USE_SODIUM, 1, [Define if using Sodium support.])
3841     ac_build_addl_libs="$ac_build_addl_libs -lsodium"
3842     ac_orig_libs="$ac_orig_libs -lsodium"
3843     SHARED_MODULE_LIBS="$SHARED_MODULE_LIBS -lsodium"
3844    ])
3845fi
3846
3847for module in $ac_shared_modules ; do
3848  moduledir=`echo "$module" | sed -e 's/\.la$//'`;
3849
3850  if test -f $srcdir/modules/$src -o -f $srcdir/contrib/$src; then
3851    continue
3852
3853  elif test -d $srcdir/modules/$moduledir; then
3854    ac_shared_module_dirs="$ac_shared_module_dirs modules/$moduledir";
3855    ac_shared_modules=`echo "$ac_shared_modules" | sed -e "s/$module//"`
3856
3857  elif test -d $srcdir/contrib/$moduledir; then
3858    ac_shared_module_dirs="$ac_shared_module_dirs contrib/$moduledir";
3859    ac_shared_modules=`echo "$ac_shared_modules" | sed -e "s/$module//"`
3860  fi
3861done
3862
3863for module in $ac_static_modules ; do
3864  moduledir=`echo "$module" | sed -e 's/\.o$//'`;
3865
3866  if test -f $srcdir/modules/$src -o -f $srcdir/contrib/$src; then
3867    continue
3868
3869  elif test -d $srcdir/modules/$moduledir; then
3870    ac_static_module_dirs="$ac_static_module_dirs modules/$moduledir";
3871    ac_static_modules=`echo "$ac_static_modules" | sed -e "s/$module//"`
3872
3873  elif test -d $srcdir/contrib/$moduledir; then
3874    ac_static_module_dirs="$ac_static_module_dirs contrib/$moduledir";
3875    ac_static_modules=`echo "$ac_static_modules" | sed -e "s/$module//"`
3876
3877    addonlibs=""
3878    src=`echo "$module" | sed -e 's/\.o$//'`.c;
3879    srcinc=`echo "$module" | sed -e 's/\.o$//'`.h;
3880
3881    if test -f $srcdir/contrib/$moduledir/$src ; then
3882      srcarch=`sed -n '/.*\$Archive: \(.*\)\$.*/s//\1/p' "$srcdir/contrib/$moduledir/$src"`
3883      srclib=`sed -n '/.*\$Libraries: \(.*\)\$.*/s//\1/p' "$srcdir/contrib/$moduledir/$src"`
3884    else
3885      srcarch=
3886      srclib=
3887    fi
3888
3889    if test -f $srcdir/contrib/$moduledir/$srcinc ; then
3890      if test -z $srcarch ; then
3891        incarch=`sed -n '/.*\$Archive: \(.*\)\$.*/s//\1/p' "$srcdir/contrib/$moduledir/$srcinc"`
3892      else
3893        incarch=
3894      fi
3895
3896      inclib=`sed -n '/.*\$Libraries: \(.*\)\$.*/s//\1/p' "$srcdir/contrib/$moduledir/$srcinc"`
3897    else
3898      incarch=
3899      inclib=
3900    fi
3901
3902    dnl If the module will be providing an archive (.a file), then remove it
3903    dnl from the list of static module objects (.o files).
3904    for thearch in $srcarch $incarch; do
3905      archive=`echo "$thearch" | sed -e 's/\.a$//'`
3906
3907      if test x"$archive" != x"$moduledir" ; then
3908        AC_MSG_ERROR([specified archive '$thearch' does not match expected module archive name '$moduledir.a' -- aborting])
3909      fi
3910
3911      ac_static_modules=`echo "$ac_static_modules" | sed -e "s/$module//g"`
3912      ac_build_static_modules=`echo "$ac_build_static_modules" | sed -e "s/modules\/$module//g"`
3913      ac_build_static_module_archives="$ac_build_static_module_archives contrib/$moduledir/$thearch"
3914    done
3915
3916    dnl Test for duplicate libraries, just in case.
3917    for thelib in $srclib $inclib; do
3918      dup="xno"
3919
3920      for somelib in $ac_addl_libs $LIBS; do
3921        if test "$thelib" = "$somelib"; then
3922          dup="xyes"
3923          break
3924        fi
3925      done
3926
3927      if test "$dup" = x"no"; then
3928        addonlibs="$addonlibs $thelib"
3929      fi
3930    done
3931
3932    test x"$addonlibs" = x || ac_addl_libs="$addonlibs $ac_addl_libs"
3933  fi
3934done
3935
3936dnl Yes, I know that this is not recommended Autoconf practice.  I doubt,
3937dnl though, that many users will require the use of
3938dnl `./configure --help=recursive' to see all of the options.
3939if test ! -z "$ac_shared_module_dirs" ; then
3940  AC_CONFIG_SUBDIRS($ac_shared_module_dirs)
3941else
3942  ac_shared_module_dirs="\"\""
3943fi
3944
3945if test ! -z "$ac_static_module_dirs" ; then
3946  AC_CONFIG_SUBDIRS($ac_static_module_dirs)
3947else
3948  ac_static_module_dirs="\"\""
3949fi
3950
3951for module in $ac_shared_modules; do
3952  if test x"$enable_dso" != xyes ; then
3953    AC_MSG_ERROR([cannot build shared modules without DSO support -- aborting])
3954  fi
3955
3956  moduledir=`echo "$module" | sed -e 's/\.la$//'`;
3957  src=`echo "$module" | sed -e 's/\.la$//'`.c;
3958  srcinc=`echo "$module" | sed -e 's/\.la$//'`.h;
3959
3960  if test -f $srcdir/modules/$src -o -f $srcdir/contrib/$src; then
3961    if test ! -e $srcdir/modules/$src; then
3962      olddir=`pwd`
3963      cd $srcdir/modules
3964      ln -s ../contrib/$src $src
3965      cd $olddir
3966    fi
3967
3968    if test ! -e $srcdir/include/$srcinc -a -f $srcdir/contrib/$srcinc ; then
3969      olddir=`pwd`
3970      cd $srcdir/include
3971      ln -s ../contrib/$srcinc $srcinc
3972      cd $olddir
3973    fi
3974
3975  elif test -d $srcdir/modules/$moduledir -o -d $srcdir/contrib/$moduledir; then
3976    continue
3977
3978  else
3979    AC_MSG_ERROR([source file '$srcdir/modules/$src' cannot be found -- aborting])
3980  fi
3981done
3982
3983for module in $ac_static_modules; do
3984  addonlibs=""
3985  moduledir=`echo "$module" | sed -e 's/\.o$//'`;
3986  src=`echo "$module" | sed -e 's/\.o$//'`.c;
3987  srcinc=`echo "$module" | sed -e 's/\.o$//'`.h;
3988
3989  if test -f $srcdir/modules/$src -o -f $srcdir/contrib/$src; then
3990    if test ! -e $srcdir/modules/$src; then
3991      olddir=`pwd`
3992      cd $srcdir/modules
3993      ln -s ../contrib/$src $src
3994      cd $olddir
3995    fi
3996
3997    if test ! -f $srcdir/include/$srcinc -a -f $srcdir/contrib/$srcinc ; then
3998      olddir=`pwd`
3999      cd $srcdir/include
4000      ln -s ../contrib/$srcinc $srcinc
4001      cd $olddir
4002    fi
4003
4004    srclib=`sed -n '/.*\$Libraries: \(.*\)\$.*/s//\1/p' "$srcdir/modules/$src"`
4005
4006    if test -f $srcdir/include/$srcinc ; then
4007      inclib=`sed -n '/.*\$Libraries: \(.*\)\$.*/s//\1/p' "$srcdir/include/$srcinc"`
4008    else
4009      inclib=
4010    fi
4011
4012    dnl Test for duplicate libraries, just in case.
4013    for thelib in $srclib $inclib; do
4014      dup="xno"
4015
4016      for somelib in $ac_addl_libs $LIBS; do
4017        if test "$thelib" = "$somelib"; then
4018          dup="xyes"
4019          break
4020        fi
4021      done
4022
4023      if test "$dup" = x"no"; then
4024        addonlibs="$addonlibs $thelib"
4025      fi
4026    done
4027
4028    test x"$addonlibs" = x || ac_addl_libs="$addonlibs $ac_addl_libs"
4029
4030  elif test -d $srcdir/modules/$moduledir -o -d $srcdir/contrib/$moduledir; then
4031    continue
4032
4033  else
4034    AC_MSG_ERROR([source file '$srcdir/modules/$src' cannot be found -- aborting])
4035  fi
4036done
4037
4038ac_addl_libs=`echo "$ac_addl_libs" | sed -e 's/ *\$//'`
4039ac_addl_libs=`echo "$ac_addl_libs" | sed -e 's/^ *//'`
4040test "x$ac_addl_libs" = x || ac_build_addl_libs="$ac_build_addl_libs $ac_addl_libs"
4041ac_addl_dirs=`echo "$ac_addl_dirs" | sed -e 's/ *\$//'`
4042ac_addl_dirs=`echo "$ac_addl_dirs" | sed -e 's/^ *//'`
4043ADDL_DIRS="$ac_addl_dirs"
4044
4045ADDL_CPPFLAGS="$ac_orig_cppflags"
4046
4047# Restore the original CPPFLAGS and LDFLAGS settings
4048CPPFLAGS="$ac_orig_cppflags"
4049LDFLAGS="$ac_orig_ldflags"
4050
4051INCLUDES="$ac_build_addl_includes"
4052LIBDIRS="$ac_build_addl_libdirs"
4053LIBRARIES="$ac_build_addl_libs"
4054SHARED_MODULE_DIRS="$ac_shared_module_dirs"
4055if test ! -z "$ac_shared_modules" ; then
4056  SHARED_MODULE_OBJS="$ac_shared_modules"
4057else
4058  SHARED_MODULE_OBJS="\"\""
4059fi
4060STATIC_MODULE_DIRS="$ac_static_module_dirs"
4061STATIC_MODULE_OBJS="$ac_core_modules $ac_static_modules"
4062BUILD_SHARED_MODULE_OBJS="$ac_build_shared_modules"
4063BUILD_STATIC_MODULE_ARCHIVES="$ac_build_static_module_archives"
4064BUILD_STATIC_MODULE_OBJS="$ac_build_core_modules $ac_build_static_modules"
4065SHARED_MODULE_LIBS="$ac_orig_libs"
4066
4067build_version=`cat $srcdir/include/version.h | grep "#define PROFTPD_VERSION_TEXT" | sed -e 's/^.*\"\(.*\)\"/\1/'`
4068BUILD_VERSION="$build_version"
4069RELEASE_VERSION=`echo $build_version | sed 's/rc.*$//'`
4070RC_VERSION=""
4071if test `echo $build_version | grep -c rc` != "0"; then
4072  RC_VERSION=`echo $build_version | sed 's/^.*rc/rc/'`
4073fi
4074
4075dnl Substitute in our configuration paths as appropriate.  We also have to
4076dnl sweet talk the environment into helping us get this right, like so...
4077pr_saved_prefix="$prefix"
4078pr_saved_exec_prefix="$exec_prefix"
4079
4080test "x$prefix" = xNONE && prefix=$ac_default_prefix
4081test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
4082
4083AC_DEFINE_UNQUOTED(PR_CONFIG_DIR, "`eval echo "${sysconfdir}"`", [Define the config directory])
4084AC_DEFINE_UNQUOTED(PR_INCLUDE_DIR, "`eval echo "${includedir}"`", [Define the include directory])
4085AC_DEFINE_UNQUOTED(PR_LIBEXEC_DIR, "`eval echo "${libexecdir}"`", [Define the libexec directory])
4086
4087dnl We evaluate the string twice.  Once to go from $datadir to $prefix/share,
4088dnl and once more to substitute in the $prefix value.  What a pain.
4089locale_dir="`eval echo ${localedir}`"
4090locale_dir="`eval echo ${locale_dir}`"
4091AC_DEFINE_UNQUOTED(PR_LOCALE_DIR, "`eval echo "${locale_dir}"`", [Define the locale directory])
4092
4093AC_DEFINE_UNQUOTED(PR_RUN_DIR, "`eval echo "${localstatedir}"`", [Define the run directory])
4094AC_DEFINE_UNQUOTED(PR_CONFIG_FILE_PATH, "`eval echo "${sysconfdir}/proftpd.conf"`", [Define the configuration file path])
4095AC_DEFINE_UNQUOTED(PR_PID_FILE_PATH, "`eval echo "${localstatedir}/proftpd.pid"`", [Define the PID file path])
4096
4097prefix="$pr_saved_prefix"
4098exec_prefix="$pr_saved_exec_prefix"
4099
4100if test x"$pkgconfigdir" = xNONE ; then
4101  pkgconfigdir="${libdir}/pkgconfig"
4102else
4103  pkgconfigdir="${prefix}/$pkgconfigdir"
4104fi
4105AC_SUBST(pkgconfigdir)
4106
4107if test x"$devel" = xyes ; then
4108  AC_DEFINE(PR_USE_DEVEL, 1, [Define if enabling developer support])
4109
4110  dnl Remove optimization flags from CFLAGS
4111  CFLAGS=`echo "$CFLAGS" | sed -e 's/\-O2//'`
4112  CFLAGS="$CFLAGS $pr_devel_cflags"
4113  LIBS="$LIBS $pr_devel_libs"
4114
4115  if test x"$GCC" = xyes; then
4116
4117    dnl Some C compilers (e.g. older gcc versions) may not accept these
4118    dnl options.  Check if they are supported.  They will be added to
4119    dnl CFLAGS if supported.
4120    PR_CHECK_CC_OPT(Wcomment)
4121    PR_CHECK_CC_OPT(Wdangling-else)
4122    PR_CHECK_CC_OPT(Wdeclaration-after-statement)
4123    PR_CHECK_CC_OPT(Wduplicated-branches)
4124    PR_CHECK_CC_OPT(Wfloat-equal)
4125    PR_CHECK_CC_OPT(Wformat)
4126    PR_CHECK_CC_OPT(Wformat-security)
4127    PR_CHECK_CC_OPT(Wimplicit-function-declaration)
4128    PR_CHECK_CC_OPT(Wmaybe-uninitialized)
4129    PR_CHECK_CC_OPT(Wmissing-braces)
4130    PR_CHECK_CC_OPT(Wparentheses)
4131    PR_CHECK_CC_OPT(Wpointer-to-int-cast)
4132    PR_CHECK_CC_OPT(Wreturn-local-addr)
4133    PR_CHECK_CC_OPT(Wstack-protector)
4134    PR_CHECK_CC_OPT(Wstrict-overflow)
4135    PR_CHECK_CC_OPT(Wswitch)
4136    PR_CHECK_CC_OPT(Wunreachable-code)
4137    PR_CHECK_CC_OPT(Wunused-variable)
4138    PR_CHECK_CC_OPT(fstack-protector)
4139    PR_CHECK_CC_OPT(fstack-protector-all)
4140    PR_CHECK_CC_OPT(fno-common)
4141  fi
4142
4143  dnl Do not strip symbols from developer object files.
4144  INSTALL_STRIP=""
4145else
4146
4147  if test x"$keepsyms" = xyes ; then
4148    dnl Do not strip symbols from object files.
4149    INSTALL_STRIP=""
4150
4151  else
4152    dnl Make sure to strip symbols from object files.
4153    INSTALL_STRIP="-s"
4154  fi
4155fi
4156
4157if test "$OSTYPE" = "-DDARWIN6" -o "$OSTYPE" = "-DDARWIN7" -o "$OSTYPE" = "-DDARWIN8"; then
4158  dnl Check whether the C compiler accepts -Wno-long-double. This helps to
4159  dnl quell unnecessary OSX compiler complaints.  Use of this macro should
4160  dnl be as late in the configure script as possible, for it changes the
4161  dnl CFLAGS environment variable (which may possible cause other autoconf
4162  dnl tests to fail).
4163  PR_CHECK_CC_OPT(Wno-long-double)
4164fi
4165
4166my_cflags="\"$CFLAGS\""
4167AC_DEFINE_UNQUOTED(PR_BUILD_CFLAGS, $my_cflags, [Define the build CFLAGS])
4168my_ldflags="\"$LDFLAGS $LIBDIRS\""
4169AC_DEFINE_UNQUOTED(PR_BUILD_LDFLAGS, $my_ldflags, [Define the build LDFLAGS])
4170my_libs="\"$LIBRARIES $LIBS\""
4171AC_DEFINE_UNQUOTED(PR_BUILD_LIBS, $my_libs, [Define the build LIBS])
4172
4173dnl And finally, generate the appropriate Make* and config.h
4174AC_SUBST(ENABLE_NLS)
4175AC_SUBST(ENABLE_TESTS)
4176AC_SUBST(GLUE_MODULE_OBJS)
4177AC_SUBST(INSTALL_STRIP)
4178AC_SUBST(INSTALL_DEPS)
4179AC_SUBST(LIB_DEPS)
4180AC_SUBST(LIB_OBJS)
4181AC_SUBST(LIBTOOL_DEPS)
4182AC_SUBST(LIBLTDL)
4183AC_SUBST(LTDLINCL)
4184AC_SUBST(MAIN_LDFLAGS)
4185AC_SUBST(MAIN_LIBS)
4186AC_SUBST(MODULE_DEPS)
4187AC_SUBST(MODULE_LDFLAGS)
4188AC_SUBST(SHARED_MODULE_DIRS)
4189AC_SUBST(SHARED_MODULE_LIBS)
4190AC_SUBST(SHARED_MODULE_OBJS)
4191AC_SUBST(STATIC_MODULE_DIRS)
4192AC_SUBST(STATIC_MODULE_OBJS)
4193AC_SUBST(BUILD_SHARED_MODULE_OBJS)
4194AC_SUBST(BUILD_STATIC_MODULE_ARCHIVES)
4195AC_SUBST(BUILD_STATIC_MODULE_OBJS)
4196AC_SUBST(ADDL_CPPFLAGS)
4197AC_SUBST(ADDL_DIRS)
4198AC_SUBST(INCLUDES)
4199AC_SUBST(LIBDIRS)
4200AC_SUBST(LIBRARIES)
4201AC_SUBST(CURSES_LIBS)
4202AC_SUBST(UTILS_LIBS)
4203AC_SUBST(BUILD_VERSION)
4204AC_SUBST(RELEASE_VERSION)
4205AC_SUBST(RC_VERSION)
4206
4207AC_CONFIG_HEADER(config.h)
4208
4209AC_OUTPUT(
4210  contrib/Makefile
4211  include/Makefile
4212  lib/Makefile
4213  locale/Makefile
4214  modules/Makefile
4215  src/Makefile
4216  src/prxs
4217  src/ftpdctl.8
4218  src/proftpd.8
4219  src/proftpd.conf.5
4220  src/xferlog.5
4221  tests/Makefile
4222  utils/Makefile
4223  utils/ftpcount.1
4224  utils/ftpscrub.8
4225  utils/ftpshut.8
4226  utils/ftptop.1
4227  utils/ftpwho.1
4228  Makefile
4229  Make.rules,
4230  [echo timestamp > stamp-h]
4231)
4232
4233dnl After everything has been generated, we need to double-check for
4234dnl header files in the module directories.
4235builddir=.
4236for moduledir in $ac_shared_module_dirs $ac_static_module_dirs; do
4237  srcinc=`echo "$moduledir" | sed -e 's/^.*\///'`.h;
4238
4239  if test -d $builddir/$moduledir ; then
4240    if test ! -e $builddir/include/$srcinc ; then
4241      if test -e $builddir/$moduledir/$srcinc ; then
4242        olddir=`pwd`
4243        cd $builddir/include
4244        ln -s ../$moduledir/$srcinc $srcinc
4245        cd $olddir
4246      fi
4247    fi
4248  fi
4249done
4250
4251# Display a summary of what modules will be compiled
4252echo
4253echo "--------------"
4254echo "Build Summary"
4255echo "--------------"
4256if test ! -z "$my_static_modules"; then
4257  echo "Building the following static modules:"
4258  for amodule in $my_static_modules; do
4259   echo "  $amodule"
4260  done
4261fi
4262
4263if test ! -z "$my_shared_modules"; then
4264  echo
4265  echo "Building the following shared modules:"
4266  for amodule in $my_shared_modules; do
4267    echo "  $amodule"
4268  done
4269fi
4270
4271echo
4272echo "--------------"
4273