- AC_CHECK_HEADERS([selinux/selinux.h],
- [SELINUX_SELINUX_H=],
- [SELINUX_SELINUX_H=selinux/selinux.h])
- AC_SUBST([SELINUX_SELINUX_H])
-
- case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in
- no:*) # already warned
- ;;
- *:no)
- AC_MSG_WARN([libselinux was found but selinux/selinux.h is missing.])
- AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.])
- esac
+ if test "$with_selinux" != no; then
+ AC_CHECK_HEADERS([selinux/selinux.h])
+
+ if test "$ac_cv_header_selinux_selinux_h" = yes; then
+ # We do have <selinux/selinux.h>, so do compile getfilecon.c
+ # and arrange to use its wrappers.
+ gl_CHECK_NEXT_HEADERS([selinux/selinux.h])
+ AC_DEFINE([getfilecon], [rpl_getfilecon],
+ [Always use our getfilecon wrapper.])
+ AC_DEFINE([lgetfilecon], [rpl_lgetfilecon],
+ [Always use our lgetfilecon wrapper.])
+ AC_DEFINE([fgetfilecon], [rpl_fgetfilecon],
+ [Always use our fgetfilecon wrapper.])
+ fi
+
+ case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in
+ no:*) # already warned
+ ;;
+ *:no)
+ AC_MSG_WARN([libselinux was found but selinux/selinux.h is missing.])
+ AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.])
+ esac
+ else
+ # Do as if <selinux/selinux.h> does not exist, even if
+ # AC_CHECK_HEADERS_ONCE has already determined that it exists.
+ AC_DEFINE([HAVE_SELINUX_SELINUX_H], [0])
+ fi