mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
Fix bugs and otherwise improve ax_check_capsicum.m4.
AU_ALIAS was removed because the new version is incompatible with the old version. It no longer checks for <sys/capability.h> separately. It's enough to test for it as part of AC_CHECK_DECL. The defines HAVE_CAPSICUM_SYS_CAPSICUM_H and HAVE_CAPSICUM_SYS_CAPABILITY_H were removed as unneeded. HAVE_SYS_CAPSICUM_H from AC_CHECK_HEADERS is enough. It no longer does a useless search for the Capsicum library if the header wasn't found. Fixed a bug in ACTION-IF-FOUND (the first argument). Specifying the argument omitted the default action but the given action wasn't used instead. AC_DEFINE([HAVE_CAPSICUM]) is now always called when Capsicum support is found. Previously it was part of the default ACTION-IF-FOUND which a custom action would override. Now the default action only prepends ${CAPSICUM_LIB} to LIBS. The documentation was updated. Since there as no serial number, "#serial 2" was added.
This commit is contained in:
parent
6e845c6a3e
commit
29a087fb5a
1 changed files with 51 additions and 52 deletions
|
@ -2,23 +2,26 @@
|
||||||
|
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
#
|
#
|
||||||
# AX_CHECK_CAPSICUM([action-if-found[, action-if-not-found]])
|
# AX_CHECK_CAPSICUM([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||||
#
|
#
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
#
|
#
|
||||||
# This macro searches for an installed Capsicum library, and if found:
|
# This macro searches for an installed Capsicum header and library,
|
||||||
# - calls one of AC_DEFINE([HAVE_CAPSICUM_SYS_CAPSICUM_H]) or
|
# and if found:
|
||||||
# AC_DEFINE([HAVE_CAPSICUM_SYS_CAPABILITY_H])
|
# - AC_DEFINE([HAVE_CAPSICUM]) is called.
|
||||||
# - sets CAPSICUM_LIB to the -l option needed to link Capsicum support.
|
# - AC_DEFINE([HAVE_SYS_CAPSICUM_H]) is called if <sys/capsicum.h>
|
||||||
|
# is present (otherwise <sys/capability.h> must be used).
|
||||||
|
# - CAPSICUM_LIB is set to the -l option needed to link Capsicum support,
|
||||||
|
# and AC_SUBST([CAPSICUM_LIB]) is called.
|
||||||
|
# - The shell commands in ACTION-IF-FOUND are run. The default
|
||||||
|
# ACTION-IF-FOUND prepends ${CAPSICUM_LIB} into LIBS. If you don't
|
||||||
|
# want to modify LIBS and don't need to run any other commands either,
|
||||||
|
# use a colon as ACTION-IF-FOUND.
|
||||||
#
|
#
|
||||||
# If either the header file or the library is not found,
|
# If Capsicum support isn't found:
|
||||||
# shell commands 'action-if-not-found' is run.
|
# - The shell commands in ACTION-IF-NOT-FOUND are run. The default
|
||||||
#
|
# ACTION-IF-NOT-FOUND calls AC_MSG_WARN to print a warning that
|
||||||
# If both header file and library are found, shell commands
|
# Capsicum support wasn't found.
|
||||||
# '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
|
# You should use autoheader to include a definition for the symbols above
|
||||||
# in a config.h file.
|
# in a config.h file.
|
||||||
|
@ -26,61 +29,57 @@
|
||||||
# Sample usage in a C/C++ source is as follows:
|
# Sample usage in a C/C++ source is as follows:
|
||||||
#
|
#
|
||||||
# #ifdef HAVE_CAPSICUM
|
# #ifdef HAVE_CAPSICUM
|
||||||
# # ifdef HAVE_CAPSICUM_SYS_CAPSICUM_H
|
# # ifdef HAVE_SYS_CAPSICUM_H
|
||||||
# # include <sys/capsicum.h>
|
# # include <sys/capsicum.h>
|
||||||
# # else
|
# # else
|
||||||
# # ifdef HAVE_CAPSICUM_SYS_CAPABILITY_H
|
# # include <sys/capability.h>
|
||||||
# # include <sys/capability.h>
|
|
||||||
# # endif
|
|
||||||
# # endif
|
# # endif
|
||||||
# #endif /* HAVE_CAPSICUM */
|
# #endif /* HAVE_CAPSICUM */
|
||||||
#
|
#
|
||||||
# LICENSE
|
# LICENSE
|
||||||
#
|
#
|
||||||
# Copyright (c) 2014 Google Inc.
|
# Copyright (c) 2014 Google Inc.
|
||||||
|
# Copyright (c) 2015 Lasse Collin <lasse.collin@tukaani.org>
|
||||||
#
|
#
|
||||||
# Copying and distribution of this file, with or without modification,
|
# Copying and distribution of this file, with or without modification,
|
||||||
# are permitted in any medium without royalty provided the copyright
|
# are permitted in any medium without royalty provided the copyright
|
||||||
# notice and this notice are preserved. This file is offered as-is,
|
# notice and this notice are preserved. This file is offered as-is,
|
||||||
# without any warranty.
|
# without any warranty.
|
||||||
|
|
||||||
AU_ALIAS([CHECK_CAPSICUM], [AX_CHECK_CAPSICUM])
|
#serial 2
|
||||||
AC_DEFUN([AX_CHECK_CAPSICUM],
|
|
||||||
[AC_CHECK_HEADERS([sys/capability.h sys/capsicum.h])
|
AC_DEFUN([AX_CHECK_CAPSICUM], [
|
||||||
capsicum_hdrfound=false
|
# On FreeBSD >= 11.x and Linux, Capsicum is uses <sys/capsicum.h>.
|
||||||
# If <sys/capsicum.h> exists (Linux, FreeBSD>=11.x), assume it is the correct header.
|
# If this header is found, it is assumed to be the right one.
|
||||||
if test "x$ac_cv_header_sys_capsicum_h" = "xyes" ; then
|
capsicum_header_found=no
|
||||||
AC_DEFINE([HAVE_CAPSICUM_SYS_CAPSICUM_H],[],[Capsicum functions declared in <sys/capsicum.h>])
|
AC_CHECK_HEADERS([sys/capsicum.h], [capsicum_header_found=yes])
|
||||||
capsicum_hdrfound=true
|
if test "$capsicum_header_found" = no ; then
|
||||||
elif test "x$ac_cv_header_sys_capability_h" = "xyes" ; then
|
# On FreeBSD 10.x Capsicum uses <sys/capability.h>. Such a header exists
|
||||||
# Just <sys/capability.h>; on FreeBSD 10.x this covers Capsicum, but on Linux it
|
# on Linux too but it describes POSIX.1e capabilities. Look for the
|
||||||
# describes POSIX.1e capabilities. So check it declares cap_rights_limit.
|
# declaration of cap_rights_limit to check if <sys/capability.h> is
|
||||||
AC_CHECK_DECL([cap_rights_limit],
|
# a Capsicum header.
|
||||||
[AC_DEFINE([HAVE_CAPSICUM_SYS_CAPABILITY_H],[],[Capsicum functions declared in <sys/capability.h>])
|
AC_CHECK_DECL([cap_rights_limit], [capsicum_header_found=yes], [],
|
||||||
capsicum_hdrfound=true],[],
|
[#include <sys/capability.h>])
|
||||||
[#include <sys/capability.h>])
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_LANG_PUSH([C])
|
capsicum_lib_found=no
|
||||||
# FreeBSD >= 10.x has Capsicum functions in libc
|
CAPSICUM_LIB=
|
||||||
capsicum_libfound=false
|
if test "$capsicum_header_found" = yes ; then
|
||||||
AC_LINK_IFELSE([AC_LANG_CALL([], [cap_rights_limit])],
|
AC_LANG_PUSH([C])
|
||||||
[capsicum_libfound=true],[])
|
# FreeBSD >= 10.x has Capsicum functions in libc.
|
||||||
# Linux has Capsicum functions in libcaprights
|
AC_LINK_IFELSE([AC_LANG_CALL([], [cap_rights_limit])],
|
||||||
AC_CHECK_LIB([caprights],[cap_rights_limit],
|
[capsicum_lib_found=yes], [])
|
||||||
[AC_SUBST([CAPSICUM_LIB],[-lcaprights])
|
# Linux has Capsicum functions in libcaprights.
|
||||||
capsicum_libfound=true],[])
|
AC_CHECK_LIB([caprights], [cap_rights_limit],
|
||||||
AC_LANG_POP([C])
|
[CAPSICUM_LIB=-lcaprights
|
||||||
|
capsicum_lib_found=yes], [])
|
||||||
|
AC_LANG_POP([C])
|
||||||
|
fi
|
||||||
|
AC_SUBST([CAPSICUM_LIB])
|
||||||
|
|
||||||
if test "$capsicum_hdrfound" = "true" && test "$capsicum_libfound" = "true"
|
if test "$capsicum_lib_found" = yes ; then
|
||||||
then
|
AC_DEFINE([HAVE_CAPSICUM], [1], [Define to 1 if Capsicum is available.])
|
||||||
# If both library and header were found, action-if-found
|
m4_default([$1], [LIBS="${CAPSICUM_LIB} $LIBS"])
|
||||||
m4_ifblank([$1],[
|
|
||||||
LIBS="${CAPSICUM_LIB} $LIBS"
|
|
||||||
AC_DEFINE([HAVE_CAPSICUM],[],[Capsicum library available])])
|
|
||||||
else
|
else
|
||||||
# If either header or library was not found, action-if-not-found
|
m4_default([$2], [AC_MSG_WARN([Capsicum support not found])])
|
||||||
m4_default([$2],[AC_MSG_WARN([Capsicum support not found])])
|
|
||||||
fi])
|
fi])
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue