dnl ProFTPD - mod_wrap2
dnl Copyright (c) 2012-2017 TJ Saunders <tj@castaglia.org>
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
dnl
dnl Process this file with autoconf to produce a configure script.

AC_INIT(./mod_wrap2.c)

dnl Need to support/handle the --with-includes and --with-libraries options
AC_ARG_WITH(includes,
  [AC_HELP_STRING(
    [--with-includes=LIST],
    [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])
  ],
  [ ac_addl_includes=`echo "$withval" | sed -e 's/:/ /g'` ;
    for ainclude in $ac_addl_includes; do
      if test x"$ac_build_addl_includes" = x ; then
        ac_build_addl_includes="-I$ainclude"
      else
        ac_build_addl_includes="-I$ainclude $ac_build_addl_includes"
      fi
    done
    CPPFLAGS="$CPPFLAGS $ac_build_addl_includes"
  ])

AC_ARG_WITH(libraries,
  [AC_HELP_STRING(
    [--with-libraries=LIST],
    [add additional library paths to proftpd. LIST is a colon-separated list of include paths to add e.g. --with-libraries=/some/mysql/libdir:/my/libs])
  ],
  [ ac_addl_libdirs=`echo "$withval" | sed -e 's/:/ /g'` ;
    for alibdir in $ac_addl_libdirs; do
      if test x"$ac_build_addl_libdirs" = x ; then
        ac_build_addl_libdirs="-L$alibdir"
      else
        ac_build_addl_libdirs="-L$alibdir $ac_build_addl_libdirs"
      fi
    done
    LDFLAGS="$LDFLAGS $ac_build_addl_libdirs"
  ])

ac_wrap2_libs=""

dnl Auto-detection of shadow passwords.
AC_ARG_ENABLE(nis,
  [  --enable-nis            enable use of NIS/netgroups (default=no)
  ],
  [
    if test "$enableval" != "no" ; then
      AC_DEFINE(WRAP2_USE_NIS)

      dnl Hack to make sure that the correct libraries are linked on the right
      dnl platforms: FreeBSD's libc itself defines the NIS/YP functions, rather
      dnl than defining those functions in a separate libnsl library.  Same
      dnl for Mac OSX as well, apparently.

      ac_os=`uname`
      if test x"$ac_os" != xFreeBSD -a x"$ac_os" != xDarwin; then
        ac_wrap2_libs="$ac_wrap2_libs -lnsl"
      fi
    fi ])

AC_ARG_ENABLE(wrapper-options,
  [  --enable-wrapper-options
                          enable use of tcpwrapper options (default=no)
                          see hosts_options(5) man page for details
  ],
  [
    if test "$enableval" != "no" ; then
      AC_DEFINE(WRAP2_USE_OPTIONS)
    fi
  ])

MODULE_LIBS="$ac_wrap2_libs"

INCLUDES="$ac_build_addl_includes"
LIBDIRS="$ac_build_addl_libdirs"

AC_SUBST(INCLUDES)
AC_SUBST(LDFLAGS)
AC_SUBST(LIBDIRS)
AC_SUBST(MODULE_LIBS)

AC_CONFIG_HEADER(mod_wrap2.h)
AC_OUTPUT(Makefile)
