The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
dnl Process this file with autoconf to produce a configure script.
AC_INIT(libauthSamba.h)

AC_CONFIG_HEADERS(config.h)

dnl Checks for library functions.
AC_FUNC_ALLOCA

# Force use of a samba directory
AC_ARG_WITH(samba-prefix,
    [  --with-samba-prefix=ARG
                          Use specified curses libraries instead of 
                          those automatically found by configure.],
    [ 
      CFLAGS="$CFLAGS -I$withval/include" 
      LDFLAGS="$LDFLAGS -L$withval/lib -lsmbclient"
    ],
    [ with_samba=no ]
    )

dnl Check for library existence
AC_CHECK_LIB(smbclient, smbc_mkdir, ,
[ AC_MSG_ERROR([I can't find your libsmbclient.so or symbol smbc_mkdir. 
	        Check config.log for details.]) ])
AC_CHECK_LIB(smbclient, smbc_open, ,
[ AC_MSG_ERROR([I can't find your libsmbclient.so or symbol smbc_open. 
	        Check config.log for details.]) ])
AC_CHECK_LIB(smbclient, smbc_fstat, ,
[ AC_MSG_ERROR([I can't find your libsmbclient.so or symbol smbc_fstat. 
	        Check config.log for details.]) ])

dnl Check for context
AC_CHECK_LIB(smbclient, 
             smbc_init_context, , 
             [ AC_MSG_ERROR([Your libsmbclient.so is too old. Please update to samba 3.]) ])

dnl Did we have SMBCTXX->flags ?
AC_TRY_COMPILE([#include <libsmbclient.h>],
	       [SMBCCTX *c; c->flags=0;], 
		smbctxFlags_ok=yes, smbctxFlags_ok=no)
if test "$smbctxFlags_ok" = yes; then
  AC_DEFINE(HAVE_SMBCTXX_FLAG,,[define if SMBCTXX->flags flag exist.])
  AC_MSG_RESULT([Good you have SMBCTXX->flags ])
  CFLAGS="$CFLAGS -DHAVE_SMBCTXX_FLAG"
else
  AC_MSG_RESULT([You don't define SMBCTXX->flags. Samba older than 3.0.11. Filesys::SmbClient::set_flag will not work])
fi

dnl This is context->close_fn or context close ?
AC_TRY_COMPILE([#include <libsmbclient.h>],
           [SMBCCTX *c; c->close_fn(c,0);],
        smbctxclosefn=yes, smbctxclosefn=no)
if test "$smbctxclosefn" = yes; then
  AC_DEFINE(HAVE_CLOSEFN,, [define if SMBCTXX->close_fn exist.])
  AC_MSG_RESULT([You use SMBCTXX->close_fn (release >= 3.0.20). ])
  CFLAGS="$CFLAGS -DHAVE_CLOSEFN"
else
  AC_MSG_RESULT([You use SMBCTXX->close (release < 3.0.20). ])
fi

AC_OUTPUT