Home | History | Annotate | Download | only in m4
      1 # serial 3   -*- Autoconf -*-
      2 # Copyright (C) 2006, 2007, 2009 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.
      6 
      7 # From Jim Meyering
      8 # Provide <selinux/selinux.h>, if necessary.
      9 
     10 AC_DEFUN([gl_HEADERS_SELINUX_SELINUX_H],
     11 [
     12   AC_REQUIRE([gl_LIBSELINUX])
     13   AC_CHECK_HEADERS([selinux/selinux.h],
     14 		   [SELINUX_SELINUX_H=],
     15 		   [SELINUX_SELINUX_H=selinux/selinux.h])
     16   AC_SUBST([SELINUX_SELINUX_H])
     17 
     18   case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in
     19     no:*) # already warned
     20       ;;
     21     *:no)
     22       AC_MSG_WARN([libselinux was found but selinux/selinux.h is missing.])
     23       AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.])
     24   esac
     25 ])
     26 
     27 AC_DEFUN([gl_LIBSELINUX],
     28 [
     29   AC_REQUIRE([AC_CANONICAL_HOST])
     30   AC_REQUIRE([AC_CANONICAL_BUILD])
     31   LIB_SELINUX=
     32   gl_save_LIBS=$LIBS
     33   AC_SEARCH_LIBS([setfilecon], [selinux],
     34                  [test "$ac_cv_search_setfilecon" = "none required" ||
     35                   LIB_SELINUX=$ac_cv_search_setfilecon])
     36   AC_SUBST([LIB_SELINUX])
     37   LIBS=$gl_save_LIBS
     38 
     39   # Warn if SELinux is found but libselinux is absent;
     40   if test "$ac_cv_search_setfilecon" = no &&
     41      test "$host" = "$build" && test -d /selinux; then
     42     AC_MSG_WARN([This system supports SELinux but libselinux is missing.])
     43     AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.])
     44   fi
     45 ])
     46