diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2015-03-31 19:20:24 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2015-03-31 19:20:24 +0300 |
commit | 6e845c6a3eddf2fde9db5a29950421dff60a43ac (patch) | |
tree | 668e47fde9857c4a8d997ed693224655637b3292 /m4 | |
parent | Bump version to 5.3.0alpha and soname to 5.3.99. (diff) | |
download | xz-6e845c6a3eddf2fde9db5a29950421dff60a43ac.tar.xz |
Add m4/ax_check_capsicum.m4 for detecting Capsicum support.
The file was loaded from this web page:
https://github.com/google/capsicum-test/blob/dev/autoconf/m4/ax_check_capsicum.m4
Thanks to Loganaden Velvindron for pointing it out for me.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/ax_check_capsicum.m4 | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/m4/ax_check_capsicum.m4 b/m4/ax_check_capsicum.m4 new file mode 100644 index 00000000..938217de --- /dev/null +++ b/m4/ax_check_capsicum.m4 @@ -0,0 +1,86 @@ +# -*- Autoconf -*- + +# SYNOPSIS +# +# AX_CHECK_CAPSICUM([action-if-found[, action-if-not-found]]) +# +# DESCRIPTION +# +# This macro searches for an installed Capsicum library, and if found: +# - calls one of AC_DEFINE([HAVE_CAPSICUM_SYS_CAPSICUM_H]) or +# AC_DEFINE([HAVE_CAPSICUM_SYS_CAPABILITY_H]) +# - sets CAPSICUM_LIB to the -l option needed to link Capsicum support. +# +# If either the header file or the library is not found, +# shell commands 'action-if-not-found' is run. +# +# If both header file and library are found, shell commands +# 'action-if-found' is run. If 'action-if-found' is not specified, the +# default action: +# - calls AC_DEFINE(HAVE_CAPSICUM) +# - prepends ${CAPSICUM_LIB} to LIBS. +# +# You should use autoheader to include a definition for the symbols above +# in a config.h file. +# +# Sample usage in a C/C++ source is as follows: +# +# #ifdef HAVE_CAPSICUM +# # ifdef HAVE_CAPSICUM_SYS_CAPSICUM_H +# # include <sys/capsicum.h> +# # else +# # ifdef HAVE_CAPSICUM_SYS_CAPABILITY_H +# # include <sys/capability.h> +# # endif +# # endif +# #endif /* HAVE_CAPSICUM */ +# +# LICENSE +# +# Copyright (c) 2014 Google Inc. +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + +AU_ALIAS([CHECK_CAPSICUM], [AX_CHECK_CAPSICUM]) +AC_DEFUN([AX_CHECK_CAPSICUM], +[AC_CHECK_HEADERS([sys/capability.h sys/capsicum.h]) +capsicum_hdrfound=false +# If <sys/capsicum.h> exists (Linux, FreeBSD>=11.x), assume it is the correct header. +if test "x$ac_cv_header_sys_capsicum_h" = "xyes" ; then + AC_DEFINE([HAVE_CAPSICUM_SYS_CAPSICUM_H],[],[Capsicum functions declared in <sys/capsicum.h>]) + capsicum_hdrfound=true +elif test "x$ac_cv_header_sys_capability_h" = "xyes" ; then + # Just <sys/capability.h>; on FreeBSD 10.x this covers Capsicum, but on Linux it + # describes POSIX.1e capabilities. So check it declares cap_rights_limit. + AC_CHECK_DECL([cap_rights_limit], + [AC_DEFINE([HAVE_CAPSICUM_SYS_CAPABILITY_H],[],[Capsicum functions declared in <sys/capability.h>]) + capsicum_hdrfound=true],[], + [#include <sys/capability.h>]) +fi + +AC_LANG_PUSH([C]) +# FreeBSD >= 10.x has Capsicum functions in libc +capsicum_libfound=false +AC_LINK_IFELSE([AC_LANG_CALL([], [cap_rights_limit])], + [capsicum_libfound=true],[]) +# Linux has Capsicum functions in libcaprights +AC_CHECK_LIB([caprights],[cap_rights_limit], + [AC_SUBST([CAPSICUM_LIB],[-lcaprights]) + capsicum_libfound=true],[]) +AC_LANG_POP([C]) + +if test "$capsicum_hdrfound" = "true" && test "$capsicum_libfound" = "true" +then + # If both library and header were found, action-if-found + m4_ifblank([$1],[ + LIBS="${CAPSICUM_LIB} $LIBS" + AC_DEFINE([HAVE_CAPSICUM],[],[Capsicum library available])]) +else + # If either header or library was not found, action-if-not-found + m4_default([$2],[AC_MSG_WARN([Capsicum support not found])]) +fi]) + + |