xref: /aosp_15_r20/external/libcap-ng/configure.ac (revision 8dd5e09d5faf27a871e8654ddaa2d2af7c696578)
1
2dnl
3define([AC_INIT_NOTICE],
4[### Generated automatically using autoconf version] AC_ACVERSION [
5### Copyright 2009-2023 Steve Grubb <[email protected]>
6###
7### Permission is hereby granted, free of charge, to any person obtaining a
8### copy of this software and associated documentation files (the "Software"),
9### to deal in the Software without restriction, including without limitation
10### the rights to use, copy, modify, merge, publish, distribute, sublicense,
11### and/or sell copies of the Software, and to permit persons to whom the
12### Software is furnished to do so, subject to the following conditions:
13###
14### The above copyright notice and this permission notice shall be included
15### in all copies or substantial portions of the Software.
16###
17### THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18### IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19### FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20### THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21### OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22### ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23### OTHER DEALINGS IN THE SOFTWARE.
24###
25### For usage, run `./configure --help'
26### For more detailed information on installation, read the file `INSTALL'.
27###
28### If configuration succeeds, status is in the file `config.status'.
29### A log of configuration tests is in `config.log'.
30])
31
32AC_REVISION($Revision: 1.3 $)dnl
33AC_INIT([libcap-ng],[0.8.5])
34AC_PREREQ([2.50])dnl
35AC_CONFIG_HEADERS([config.h])
36AC_CONFIG_MACRO_DIR([m4])
37
38echo Configuring libcap-ng $VERSION
39
40AC_CANONICAL_TARGET
41AM_INIT_AUTOMAKE
42LT_INIT
43AC_SUBST(LIBTOOL_DEPS)
44
45echo .
46echo Checking for programs
47
48AC_PROG_CC
49AC_PROG_INSTALL
50AC_PROG_AWK
51
52echo .
53echo Checking for header files
54AC_CHECK_HEADERS(linux/capability.h, [], [AC_MSG_ERROR(linux/capability.h is required in order to build libcap-ng.)])
55AC_CHECK_HEADERS(sys/xattr.h, [], [
56	AC_CHECK_HEADERS(attr/xattr.h, [], [AC_MSG_WARN(attr/xattr.h not found, disabling file system capabilities.)])
57	])
58AC_CHECK_HEADERS(linux/securebits.h, [], [])
59AC_CHECK_HEADERS(pthread.h,
60	[AC_SEARCH_LIBS(pthread_atfork, pthread)],
61	[AC_MSG_WARN(pthread.h not found, disabling pthread_atfork.)])
62AC_CHECK_HEADERS(sys/vfs.h, [
63	AC_CHECK_HEADERS(linux/magic.h, [], [AC_MSG_WARN(linux/magic.h is required in order to verify procfs.)])
64	], [AC_MSG_WARN(sys/vfs.h is required in order to verify procfs.)])
65
66AC_ARG_WITH([capability_header],
67        [AS_HELP_STRING([--with-capability_header=path : path to capability.h])],
68        [CAPABILITY_HEADER=$withval],
69        [CAPABILITY_HEADER=/usr/include/linux/capability.h])
70AC_SUBST(CAPABILITY_HEADER)
71
72ALLWARNS=""
73ALLDEBUG="-g"
74OPT="-O"
75if test x"$GCC" = x"yes"; then
76  OPT="-O2 -pipe"
77  case "$target" in
78    *linux*)
79             ALLWARNS="-W -Wall -Wundef -Wpointer-arith -Wcast-align \
80-Wwrite-strings -Waggregate-return -Wstrict-prototypes \
81-Wmissing-prototypes -Wmissing-declarations -Wredundant-decls \
82-Wnested-externs -Winline -Wfloat-equal -Wchar-subscripts"
83             ;;
84    esac
85fi
86
87ALLDEBUG="-g"
88AC_ARG_WITH(debug,
89[  --with-debug            turn on debugging [[default=no]]],
90[
91if test "x${withval}" = xyes; then
92        DEBUG="$ALLDEBUG"
93        OPT="-O"
94        AM_CONDITIONAL(DEBUG, true)
95else
96        DEBUG="-DNDEBUG"
97        AM_CONDITIONAL(DEBUG, false)
98fi
99],
100[ DEBUG="-DNDEBUG"; AM_CONDITIONAL(DEBUG, false) ])
101
102AC_MSG_CHECKING(__attr_dealloc_free support)
103AC_COMPILE_IFELSE(
104  [AC_LANG_SOURCE(
105    [[
106      #include <stdio.h>
107      extern char *test(const char *name) __attr_dealloc_free;
108      int main(void) { return 0; }]])],
109  [DEALLOC="yes"],
110  [DEALLOC="no"]
111)
112AC_MSG_RESULT($DEALLOC)
113
114AC_ARG_WITH(warn,
115[  --with-warn             turn on warnings [[default=yes]]],
116[
117if test "x${withval}" = xyes; then
118        WARNS="$ALLWARNS"
119else
120        WARNS=""
121fi
122],WARNS="$ALLWARNS")
123AC_SUBST(DEBUG)
124
125WFLAGS=""
126AC_MSG_CHECKING(for -Wformat-truncation)
127TMPCFLAGS="${CFLAGS}"
128CFLAGS="${CFLAGS} -Wformat-truncation"
129AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[WFLAGS="-Wno-format-truncation"
130	AC_MSG_RESULT(yes)],
131	[AC_MSG_RESULT(no)])
132CFLAGS="${TMPCFLAGS}"
133AC_SUBST(WFLAGS)
134
135AC_CHECK_HEADER(sys/syscall.h,
136	[AC_DEFINE([HAVE_SYSCALL_H], [1],
137	[Define to 1 if you have <sys/syscall.h>.])], [],)
138
139dnl; This is to record in the build logs what options are being taken
140AC_CHECK_DECLS([PR_CAP_AMBIENT], [], [], [[#include <sys/prctl.h>]])
141AC_CHECK_DECLS([VFS_CAP_REVISION_2], [], [], [[#include <linux/capability.h>]])
142AC_CHECK_DECLS([VFS_CAP_REVISION_3], [], [], [[#include <linux/capability.h>]])
143AC_CHECK_DECLS([CAP_EPOLLWAKEUP], [], [], [[#include <linux/capability.h>]])
144AC_CHECK_DECLS([CAP_WAKE_ALARM], [], [], [[#include <linux/capability.h>]])
145AC_CHECK_DECLS([CAP_BLOCK_SUSPEND], [], [], [[#include <linux/capability.h>]])
146AC_CHECK_DECLS([CAP_AUDIT_READ], [], [], [[#include <linux/capability.h>]])
147AC_CHECK_DECLS([CAP_PERFMON], [], [], [[#include <linux/capability.h>]])
148AC_CHECK_DECLS([CAP_BPF], [], [], [[#include <linux/capability.h>]])
149AC_CHECK_DECLS([CAP_CHECKPOINT_RESTORE], [], [], [[#include <linux/capability.h>]])
150
151dnl only build libdrop_ambient if support for ambient capabilities was found (which is normal)
152if test x"${ac_cv_have_decl_PR_CAP_AMBIENT}" = x"no" ; then
153    AC_MSG_WARN("PR_CAP_AMBIENT not available - libdrop_ambient will not be built")
154fi
155AM_CONDITIONAL(BUILD_LIBDROP_AMBIENT, test x"${ac_cv_have_decl_PR_CAP_AMBIENT}" = x"yes")
156
157AC_CHECK_PROG(swig_found, swig, yes, no)
158if test x"${swig_found}" = x"no" ; then
159	AC_MSG_WARN("Swig not found - python bindings will not be made")
160fi
161AM_CONDITIONAL(HAVE_SWIG, test x"${swig_found}" = x"yes")
162
163withval=""
164AC_MSG_CHECKING(whether to create python3 bindings)
165AC_ARG_WITH(python3,
166AS_HELP_STRING([--with-python3],[enable building python3 bindings]),
167use_python3=$withval,
168use_python3=auto)
169if test x$use_python3 = xno ; then
170	AC_MSG_RESULT(no)
171else
172	AC_MSG_RESULT(investigating)
173	AC_PATH_PROG([use_python3], [python3-config], [no])
174	if test ${use_python3} = no ; then
175		if test ${withval} = yes ; then
176			echo "Python3 bindings were selected but python3-config was not found."
177			echo "Please ensure that it's installed or pass --without-python3 to ./configure"
178			exit 1
179		fi
180		echo "Python3 bindings will NOT be built"
181	else
182	echo "Python3 bindings WILL be built"
183	use_python3=yes
184	AM_PATH_PYTHON([3.1],, [:])
185	PYTHON3_CFLAGS=`python3-config --cflags 2> /dev/null`
186	PYTHON3_LIBS=`python3-config --libs 2> /dev/null`
187	PYTHON3_INCLUDES=`python3-config --includes 2> /dev/null`
188	AC_SUBST(PYTHON3_CFLAGS)
189	AC_SUBST(PYTHON3_LIBS)
190	AC_SUBST(PYTHON3_INCLUDES)
191	fi
192fi
193AM_CONDITIONAL(USE_PYTHON3, test ${use_python3} = "yes")
194
195AC_CONFIG_FILES([Makefile src/Makefile src/libcap-ng.pc src/test/Makefile
196	bindings/Makefile
197	bindings/python3/Makefile bindings/src/Makefile
198	bindings/python3/test/Makefile utils/Makefile
199	m4/Makefile docs/Makefile])
200AC_OUTPUT
201
202echo .
203echo "
204
205  libcap-ng Version:      $VERSION
206  Target:                 $target
207  Installation prefix:    $prefix
208  PYTHON_PREFIX:          $PYTHON_PREFIX
209  Compiler:               $CC
210  Compiler flags:
211`echo $CFLAGS | fmt -w 50 | sed 's,^,                          ,'`
212  __attr_dealloc_free support:  $DEALLOC
213"
214