1 # serial 3 -*- Autoconf -*-
2 # Copyright (C) 2006-2007, 2009-2010 Free Software Foundation, Inc.
3 # This file is free software; the Free Software Foundation
4 # gives unlimited permission to copy and/or distribute it,
5 # with or without modifications, as long as this notice is preserved.
8 # Provide <selinux/selinux.h>, if necessary.
9 # If it is already present, provide wrapper functions to guard against
10 # misbehavior from getfilecon, lgetfilecon, and fgetfilecon.
12 AC_DEFUN([gl_HEADERS_SELINUX_SELINUX_H],
14 AC_REQUIRE([gl_LIBSELINUX])
15 AC_CHECK_HEADERS([selinux/selinux.h])
17 if test "$ac_cv_header_selinux_selinux_h" = yes; then
18 # We do have <selinux/selinux.h>, so do compile getfilecon.c
19 # and arrange to use its wrappers.
20 AC_LIBOBJ([getfilecon])
21 gl_CHECK_NEXT_HEADERS([selinux/selinux.h])
22 AC_DEFINE([getfilecon], [rpl_getfilecon],
23 [Always use our getfilecon wrapper.])
24 AC_DEFINE([lgetfilecon], [rpl_lgetfilecon],
25 [Always use our lgetfilecon wrapper.])
26 AC_DEFINE([fgetfilecon], [rpl_fgetfilecon],
27 [Always use our fgetfilecon wrapper.])
30 case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in
31 no:*) # already warned
34 AC_MSG_WARN([libselinux was found but selinux/selinux.h is missing.])
35 AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.])
39 AC_DEFUN([gl_LIBSELINUX],
41 AC_REQUIRE([AC_CANONICAL_HOST])
42 AC_REQUIRE([AC_CANONICAL_BUILD])
45 AC_SEARCH_LIBS([setfilecon], [selinux],
46 [test "$ac_cv_search_setfilecon" = "none required" ||
47 LIB_SELINUX=$ac_cv_search_setfilecon])
48 AC_SUBST([LIB_SELINUX])
51 # Warn if SELinux is found but libselinux is absent;
52 if test "$ac_cv_search_setfilecon" = no &&
53 test "$host" = "$build" && test -d /selinux; then
54 AC_MSG_WARN([This system supports SELinux but libselinux is missing.])
55 AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.])