dnl Check for su
AC_PATH_PROG(path_su, "su", "no")
if test "$path_su" = "no"; then
    AC_MSG_WARN(su was not found)
else
    AC_DEFINE_UNQUOTED(__PATH_SU, "$path_su", [path to su])
fi

dnl Check for POSIX.1b scheduling
AC_MSG_CHECKING([POSIX.1b scheduling])
AC_TRY_LINK([
    #include <sched.h>
],
[
    sched_getscheduler(0);
],
have_rtsched="yes", have_rtsched="no")
if test "$have_rtsched" = "yes"; then
    AC_DEFINE(POSIX1B_SCHEDULING, 1, [Define if you have POSIX.1b scheduling])
    AC_MSG_RESULT(yes)
else
    AC_MSG_RESULT(no)
fi

dnl Check for initgroups()
AC_CHECK_FUNCS(initgroups)

dnl Compile in kde_bindir to safely find kdesu_stub.
if test "$exec_prefix" = "NONE"; then
    bindir_str="\"$prefix/bin\""
else
    bindir_str="\"$exec_prefix/bin\""
fi
AC_DEFINE_UNQUOTED(__KDE_BINDIR, $bindir_str, [KDE bindir])

dnl openpty stuff
AC_CHECK_HEADERS(libutil.h util.h pty.h)
AC_CHECK_LIB(util, openpty, [AC_DEFINE_UNQUOTED(HAVE_OPENPTY, 1, [Define if you have openpty in -lutil])])
AC_CHECK_FUNCS(openpty initgroups setgroups getgroups grantpt setpriority getpt unlockpt ptsname)

AH_VERBATIM(_OPENPTY,
[
/*
 * Steven Schultz <sms at to.gd-es.com> tells us :
 * BSD/OS 4.2 doesn't have a prototype for openpty in its system header files
 */
#ifdef __bsdi__
__BEGIN_DECLS
int openpty(int *, int *, char *, struct termios *, struct winsize *);
__END_DECLS
#endif
])

dnl irix pty stuff
AC_CHECK_FUNCS(_getpty)

AC_MSG_CHECKING([for struct ucred])
AC_CACHE_VAL(kde_cv_have_struct_ucred,
[
  AC_TRY_COMPILE(
  [
    #include <sys/socket.h>
  ],
  [
    struct ucred cred;
  ], kde_cv_have_struct_ucred=yes,
  kde_cv_have_struct_ucred=no)
])

AC_MSG_RESULT($kde_cv_have_struct_ucred)
if test "$kde_cv_have_struct_ucred" = yes; then
   AC_DEFINE(HAVE_STRUCT_UCRED,1, [Define if struct ucred is present from sys/socket.h])
fi
AC_CHECK_FUNCS(getpeereid)
