+
dnl
define([AC_INIT_NOTICE],
[### Generated automatically using autoconf version] AC_ACVERSION [
-### Copyright 2009,2010 Steve Grubb <sgrubb@redhat.com>
+### Copyright 2009-2023 Steve Grubb <sgrubb@redhat.com>
###
### Permission is hereby granted, free of charge, to any person obtaining a
### copy of this software and associated documentation files (the "Software"),
])
AC_REVISION($Revision: 1.3 $)dnl
-AC_INIT(libcap-ng,0.6.6)
-AC_PREREQ(2.12)dnl
-AM_CONFIG_HEADER(config.h)
+AC_INIT([libcap-ng],[0.8.4])
+AC_PREREQ([2.50])dnl
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
echo Configuring libcap-ng $VERSION
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE
-AM_PROG_LIBTOOL
+LT_INIT
AC_SUBST(LIBTOOL_DEPS)
echo .
echo .
echo Checking for header files
-AC_HEADER_STDC
AC_CHECK_HEADERS(linux/capability.h, [], [AC_MSG_ERROR(linux/capability.h is required in order to build libcap-ng.)])
-AC_CHECK_HEADERS(attr/xattr.h, [], [AC_MSG_WARN(attr/xattr.h not found, disabling file system capabilities.)])
+AC_CHECK_HEADERS(sys/xattr.h, [], [
+ AC_CHECK_HEADERS(attr/xattr.h, [], [AC_MSG_WARN(attr/xattr.h not found, disabling file system capabilities.)])
+ ])
AC_CHECK_HEADERS(linux/securebits.h, [], [])
-
-AC_C_CONST
-AC_C_INLINE
-AM_PROG_CC_C_O
+AC_CHECK_HEADERS(pthread.h,
+ [AC_SEARCH_LIBS(pthread_atfork, pthread)],
+ [AC_MSG_WARN(pthread.h not found, disabling pthread_atfork.)])
+AC_CHECK_HEADERS(sys/vfs.h, [
+ AC_CHECK_HEADERS(linux/magic.h, [], [AC_MSG_WARN(linux/magic.h is required in order to verify procfs.)])
+ ], [AC_MSG_WARN(sys/vfs.h is required in order to verify procfs.)])
+
+AC_ARG_WITH([capability_header],
+ [AS_HELP_STRING([--with-capability_header=path : path to capability.h])],
+ [CAPABILITY_HEADER=$withval],
+ [CAPABILITY_HEADER=/usr/include/linux/capability.h])
+AC_SUBST(CAPABILITY_HEADER)
ALLWARNS=""
ALLDEBUG="-g"
],
[ DEBUG="-DNDEBUG"; AM_CONDITIONAL(DEBUG, false) ])
+AC_MSG_CHECKING(__attr_dealloc_free support)
+AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE(
+ [[
+ #include <stdio.h>
+ extern char *test(const char *name) __attr_dealloc_free;
+ int main(void) { return 0; }]])],
+ [DEALLOC="yes"],
+ [DEALLOC="no"]
+)
+AC_MSG_RESULT($DEALLOC)
+
AC_ARG_WITH(warn,
[ --with-warn turn on warnings [[default=yes]]],
[
],WARNS="$ALLWARNS")
AC_SUBST(DEBUG)
+WFLAGS=""
+AC_MSG_CHECKING(for -Wformat-truncation)
+TMPCFLAGS="${CFLAGS}"
+CFLAGS="${CFLAGS} -Wformat-truncation"
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[WFLAGS="-Wno-format-truncation"
+ AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)])
+CFLAGS="${TMPCFLAGS}"
+AC_SUBST(WFLAGS)
+
AC_CHECK_HEADER(sys/syscall.h,
[AC_DEFINE([HAVE_SYSCALL_H], [1],
[Define to 1 if you have <sys/syscall.h>.])], [],)
+dnl; This is to record in the build logs what options are being taken
+AC_CHECK_DECLS([PR_CAP_AMBIENT], [], [], [[#include <sys/prctl.h>]])
+AC_CHECK_DECLS([VFS_CAP_REVISION_2], [], [], [[#include <linux/capability.h>]])
+AC_CHECK_DECLS([VFS_CAP_REVISION_3], [], [], [[#include <linux/capability.h>]])
+AC_CHECK_DECLS([CAP_EPOLLWAKEUP], [], [], [[#include <linux/capability.h>]])
+AC_CHECK_DECLS([CAP_WAKE_ALARM], [], [], [[#include <linux/capability.h>]])
+AC_CHECK_DECLS([CAP_BLOCK_SUSPEND], [], [], [[#include <linux/capability.h>]])
+AC_CHECK_DECLS([CAP_AUDIT_READ], [], [], [[#include <linux/capability.h>]])
+AC_CHECK_DECLS([CAP_PERFMON], [], [], [[#include <linux/capability.h>]])
+AC_CHECK_DECLS([CAP_BPF], [], [], [[#include <linux/capability.h>]])
+AC_CHECK_DECLS([CAP_CHECKPOINT_RESTORE], [], [], [[#include <linux/capability.h>]])
+
+dnl only build libdrop_ambient if support for ambient capabilities was found (which is normal)
+if test x"${ac_cv_have_decl_PR_CAP_AMBIENT}" = x"no" ; then
+ AC_MSG_WARN("PR_CAP_AMBIENT not available - libdrop_ambient will not be built")
+fi
+AM_CONDITIONAL(BUILD_LIBDROP_AMBIENT, test x"${ac_cv_have_decl_PR_CAP_AMBIENT}" = x"yes")
+
AC_CHECK_PROG(swig_found, swig, yes, no)
if test x"${swig_found}" = x"no" ; then
AC_MSG_WARN("Swig not found - python bindings will not be made")
fi
AM_CONDITIONAL(HAVE_SWIG, test x"${swig_found}" = x"yes")
-AC_MSG_CHECKING(whether to create python bindings)
-AC_ARG_WITH(python,
-AS_HELP_STRING([--with-python],[enable building python bindings]),
-use_python=$withval,
-use_python=auto)
-if test x$use_python = xno ; then
- python_found="no"
+withval=""
+AC_MSG_CHECKING(whether to create python3 bindings)
+AC_ARG_WITH(python3,
+AS_HELP_STRING([--with-python3],[enable building python3 bindings]),
+use_python3=$withval,
+use_python3=auto)
+if test x$use_python3 = xno ; then
AC_MSG_RESULT(no)
else
-AC_MSG_RESULT(testing)
-AM_PATH_PYTHON
-if test -f /usr/include/python${am_cv_python_version}/Python.h ; then
- python_found="yes"
- AC_MSG_NOTICE(Python bindings will be built)
-else
- python_found="no"
- if test x$use_python = xyes ; then
- AC_MSG_ERROR([Python explicitly required and python headers found])
+ AC_MSG_RESULT(investigating)
+ AC_PATH_PROG([use_python3], [python3-config], [no])
+ if test ${use_python3} = no ; then
+ if test ${withval} = yes ; then
+ echo "Python3 bindings were selected but python3-config was not found."
+ echo "Please ensure that it's installed or pass --without-python3 to ./configure"
+ exit 1
+ fi
+ echo "Python3 bindings will NOT be built"
else
- AC_MSG_WARN("Python headers not found - python bindings will not be made")
+ echo "Python3 bindings WILL be built"
+ use_python3=yes
+ AC_PATH_PROG([PYTHON3], [python3], [no])
+ if test "x$PYTHON3" == "xno" ; then
+ echo "The python3 program was not found in the search path. Please ensure"
+ echo "that it is installed and its directory is included in the search path or"
+ echo "pass --without-python3 to ./configure."
+ exit 1
+ fi
+ PYTHON3_CFLAGS=`python3-config --cflags 2> /dev/null`
+ PYTHON3_LIBS=`python3-config --libs 2> /dev/null`
+ PYTHON3_INCLUDES=`python3-config --includes 2> /dev/null`
+ AC_SUBST([PYTHON3_PREFIX], ['${prefix}'])
+ PYTHON3_EXECDIR=`$PYTHON3 -c "import sysconfig; print(sysconfig.get_path('platlib'))"`
+ AC_SUBST(PYTHON3_CFLAGS)
+ AC_SUBST(PYTHON3_LIBS)
+ AC_SUBST(PYTHON3_INCLUDES)
+ AC_SUBST(py3execdir, $PYTHON3_EXECDIR)
fi
fi
-fi
-AM_CONDITIONAL(HAVE_PYTHON, test ${python_found} = "yes")
+AM_CONDITIONAL(USE_PYTHON3, test ${use_python3} = "yes")
-AC_OUTPUT(Makefile src/Makefile src/libcap-ng.pc src/test/Makefile
- bindings/Makefile bindings/python/Makefile
- bindings/python/test/Makefile utils/Makefile
- m4/Makefile docs/Makefile)
+AC_CONFIG_FILES([Makefile src/Makefile src/libcap-ng.pc src/test/Makefile
+ bindings/Makefile
+ bindings/python3/Makefile bindings/src/Makefile
+ bindings/python3/test/Makefile utils/Makefile
+ m4/Makefile docs/Makefile])
+AC_OUTPUT
echo .
echo "
libcap-ng Version: $VERSION
Target: $target
Installation prefix: $prefix
+ PYTHON3_PREFIX: $PYTHON3_PREFIX
Compiler: $CC
Compiler flags:
`echo $CFLAGS | fmt -w 50 | sed 's,^, ,'`
+ __attr_dealloc_free support: $DEALLOC
"