AC_PREREQ([2.53])
AC_INIT(rlm_smb.c)
AC_CONFIG_HEADER(config.h)
AC_REVISION($Revision$)
AC_DEFUN(modname,[rlm_smb])

if test x$with_[]modname != xno; then

	AC_PROG_CC
	AC_PROG_CPP

	dnl extra argument: --with-rlm-smb-lib-dir
	rlm_smb_lib_dir=
	AC_ARG_WITH(rlm-smb-lib-dir,
	[  --with-rlm-smb-lib-dir=DIR       Directory for samba library files []],
	[ case "$withval" in
	    no)
		AC_MSG_ERROR(Need rlm-smb-lib-dir)
		;;
	    yes)
		;;
	    *)
		rlm_smb_lib_dir="$withval"
		;;
	  esac ]
	)

	dnl extra argument: --with-rlm-smb-include-dir
	rlm_smb_inc_dir=
	AC_ARG_WITH(rlm-smb-include-dir,
	[  --with-rlm-smb-include-dir=DIR   Directory for samba include files []],
	[ case "$withval" in
	    no)
		AC_MSG_ERROR(Need rlm-smb-include-dir)
		;;
	    yes)
		;;
	    *)
		rlm_smb_include_dir="$withval"
		;;
	  esac ]
	)

	AC_CHECK_HEADERS(arpa/inet.h \
			dirent.h \
			sys/vfs.h \
			netinet/in.h \
			netinet/tcp.h \
			sys/uio.h \
			sys/signal.h \
			sys/socket.h \
			unistd.h \
			ctype.h \
			netdb.h \
			signal.h \
			)

	targetname=modname
	smb_cflags="-I."
else
	targetname=
	echo \*\*\* module modname is disabled.
fi

if test x"$fail" != x""; then
	if test x"${enable_strict_dependencies}" = x"yes"; then
		AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
	else
		AC_MSG_WARN([silently not building ]modname[.])
		AC_MSG_WARN([FAILURE: ]modname[ requires: $fail.]);
		targetname=""
	fi
fi

AC_SUBST(smb_cflags)
AC_SUBST(smb_ldflags)
AC_SUBST(targetname)
AC_OUTPUT(Makefile)
