AC_INIT(rlm_eap_ikev2.c)
AC_REVISION($Revision$)
AC_DEFUN(modname,[rlm_eap_ikev2])

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

	## We may need more complex checking here.  Assume for now that 
	## everyone has it.
	AC_CHECK_HEADERS(malloc.h)

	AC_ARG_WITH(eap-ikev2-includes,
	  AS_HELP_STRING([--with-eap-ikev2-includes],
			 [Diectory to look for EAPIKEv2 include files]),
		   eap_ikev2_includes=-I$with_eap_ikev2_includes)
		   

	AC_ARG_WITH(eap-ikev2-libraries,
	  AS_HELP_STRING([--with-eap-ikev2-libraries],
			 [Diectory to look for EAPIKEv2 library file]),
		    eap_ikev2_libraries=-L$with_eap_ikev2_libraries)
	
	LDFLAGS="$eap_ikev2_libraries $OPENSSL_LIBS"
	AC_CHECK_LIB([eap-ikev2],[ikev2_set_log_callback])
	if test "x$ac_cv_lib_eap_ikev2_ikev2_set_log_callback" != "xyes"; then
		fail="$fail libeap-ikev2"
	fi

	LDFLAGS=$old_LDFLAG
	
	old_CPPFLAGS=$CPPFLAGS
	CPPFLAGS=$eap_ikev2_includes
	AC_CHECK_HEADER(EAPIKEv2/connector.h)
	if test "x$ac_cv_header_EAPIKEv2_connector_h" != "xyes"; then
		fail="$fail EAPIKEv2/connector.h"
	fi
	CPPFLAGS=$old_CPPFLAGS

	eap_ikev2_cflags="$eap_ikev2_includes"
	LDFLAGS="$LDFLAGS $openssl_libraries $eap_ikev2_libraries"
	    
	targetname=modname     # keep this!  Don't change!
else
	targetname=            # keep this!  Don't change!
	echo \*\*\* module modname is disabled.  # keep this!  Don't change!
fi

dnl  Don't change this section.
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(eap_ikev2_cflags)
AC_SUBST(eap_ikev2_ldflags)

dnl AC_CONFIG_HEADER(config.h)

AC_SUBST(targetname)  # keep this!  Don't change!
AC_OUTPUT(Makefile)  # keep this!  Don't change!
