#MIN_CONFIG
KDE_ENABLE_HIDDEN_VISIBILITY
KDE_INIT_DOXYGEN([KDE Utils API Reference], [Version $VERSION])

# Check for ECMA-335 image loader.

AC_DEFUN([KDE_CHECK_CLI],[
	AC_ARG_WITH(cli, [  --with-cli=FILE         ECMA 335 PE image loader is FILE ],
	[
		AC_MSG_CHECKING(for CLI image loader)

		if test -x "$with_cli"
		then
			CLI="$with_cli"
			AC_MSG_RESULT($CLI)
		fi
	],
	[
		AC_PATH_PROG(CLI, mono, [], $PATH:/usr/local/bin)

		if test -z "$CLI"
		then
			AC_PATH_PROG(CLI, ilrun, [], $PATH:/usr/local/bin)
		fi

		if test -z "$CLI"
		then
			AC_PATH_PROG(CLI, clix, [], $PATH:/usr/local/bin)
		fi
	])

	AC_SUBST(CLI)
])

# Pick a C# compiler.

# Check for Portable.NET's C# compiler

AC_DEFUN([KDE_CHECK_CSCC],[
	AC_ARG_WITH(cscc, [  --with-cscc=FILE        cscc executable is FILE ],
	[
		AC_MSG_CHECKING(for $with_cscc)

		if test -x $with_cscc
		then
			AC_MSG_RESULT(found)
			cscc="$with_cscc"
		else
			AC_MSG_RESULT(no)
		fi
	],
	[
		AC_PATH_PROG(cscc, cscc, [], $PATH:/usr/local/bin)
	])
])

# Check for Microsoft's C# compiler

AC_DEFUN([KDE_CHECK_CSC],[
	AC_ARG_WITH(csc, [  --with-csc=FILE         csc executable is FILE ],
	[
		AC_MSG_CHECKING(for $with_csc)

		if test -x $with_csc
		then
			AC_MSG_RESULT(found)
			csc="$with_csc"
		else
			AC_MSG_RESULT(no)
		fi
	],
	[
		AC_PATH_PROG(csc, csc.exe, [], $PATH:/usr/local/bin)

		if test -z "$csc"
		then
			AC_PATH_PROG(csc, csc, [], $PATH:/usr/local/bin)
		fi
	])
])

# Check for Mono's C# compiler

AC_DEFUN([KDE_CHECK_MCS],[
	dnl AC_REQUIRE(KDE_CHECK_CLI)
	AC_ARG_WITH(mcs, [  --with-mcs=FILE         mcs executable is FILE ],
	[
		AC_MSG_CHECKING(for $with_mcs)

		if test -f $with_mcs
		then
			AC_MSG_RESULT(found)
			mcs="$with_mcs"
		else
			AC_MSG_RESULT(no)
		fi
	],
	[
		AC_PATH_PROG(mcs, mcs, [], $PATH:/usr/local/bin)

		if test -z "$mcs"
		then
			AC_PATH_PROG(mcs, mcs.exe, [], $PATH:/usr/local/bin)
		fi
	])

])

AM_PATH_GLIB([1.2.6])
AM_PATH_GTK([1.2.6])

# check for CSANT compiler

AC_DEFUN([KDE_CHECK_CSANT],[
])

# Pick one of the available C# compilers.

AC_DEFUN([KDE_CHECK_CS_COMPILER],[
	KDE_CHECK_CSANT
	KDE_CHECK_CSCC
	KDE_CHECK_CSC
	KDE_CHECK_MCS

	AC_MSG_CHECKING(for c-sharp compiler)

	AC_ARG_WITH(cs-compiler, [  --with-cs-compiler=NAME mcs, cscc, or csc ],
	[
		if test "$with_cs_compiler" = "cscc"
		then
			CSC="$cscc"
			CSC_NAME="cscc"
		fi

		if test "$with_cs_compiler" = "csc"
		then
			CSC="$csc"
			CSC_NAME="csc"
		fi

		if test "$with_cs_compiler" = "mcs"
		then
			CSC="$mono"
			CSC_NAME="mcs"
		fi

		if test -z "$CSC_NAME"
		then
			AC_MSG_RESULT(no)
			echo "ERROR: Unknown C# compiler: $with_cs_compiler"
			exit
		else
			AC_MSG_RESULT($CSC_NAME)
		fi
	],
	[
		if test -n "$mcs"
		then
			CSC="$mcs"
			CSC_NAME="mcs"
			AC_MSG_RESULT(mcs)
		else
			if test -n "$cscc"
			then
				CSC="$cscc"
				CSC_NAME="cscc"
				AC_MSG_RESULT(cscc)
			else
				if test -n "$csc"
				then
					CSC="$csc"
					CSC_NAME="csc"
					AC_MSG_RESULT(csc)
				fi
			fi
		fi

		if test -z "$CSC_NAME"
		then
			AC_MSG_RESULT(no)
    			DO_NOT_COMPILE="$DO_NOT_COMPILE qtsharp"
		fi
	])

	AC_SUBST(CSC)
	AC_SUBST(CSC_NAME)
])

dnl
dnl Java checks
dnl

AC_DEFUN([KDE_CHECK_JAVA],
[
 AC_REQUIRE([KDE_CHECK_JAVA_DIR])
 if test "$kde_java_bindir" = "no"; then
   DO_NOT_COMPILE="$DO_NOT_COMPILE $1";
   BUILD_$1=false
 else
   BUILD_$1=true
 fi
 AM_CONDITIONAL(BUILD_$1, ${BUILD_$1})
]
)

dnl
dnl Check Perl
dnl

AC_DEFUN([KDE_CHECK_PERL],
[
  AC_ARG_VAR(PERL, full path to the perl program)
  AC_PATH_PROG(PERL, perl, "perl")
  AC_MSG_CHECKING([for Perl >= $1])
  has_wanted_perl="not found"
  if test -e "$PERL" && $PERL -e "require $1"; then
      has_wanted_perl=yes
  else
      DO_NOT_COMPILE="$DO_NOT_COMPILE $2"
  fi
  AC_MSG_RESULT($has_wanted_perl)
])

dnl remove when fixed
DO_NOT_COMPILE="$DO_NOT_COMPILE qtsharp"
