Imported Upstream version 0.8.4
[platform/upstream/libcap-ng.git] / configure.ac
1
2 dnl
3 define([AC_INIT_NOTICE],
4 [### Generated automatically using autoconf version] AC_ACVERSION [
5 ### Copyright 2009-2023 Steve Grubb <sgrubb@redhat.com>
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
32 AC_REVISION($Revision: 1.3 $)dnl
33 AC_INIT([libcap-ng],[0.8.4])
34 AC_PREREQ([2.50])dnl
35 AC_CONFIG_HEADERS([config.h])
36 AC_CONFIG_MACRO_DIR([m4])
37
38 echo Configuring libcap-ng $VERSION
39
40 AC_CANONICAL_TARGET
41 AM_INIT_AUTOMAKE
42 LT_INIT
43 AC_SUBST(LIBTOOL_DEPS)
44
45 echo .
46 echo Checking for programs
47
48 AC_PROG_CC
49 AC_PROG_INSTALL
50 AC_PROG_AWK
51
52 echo .
53 echo Checking for header files
54 AC_CHECK_HEADERS(linux/capability.h, [], [AC_MSG_ERROR(linux/capability.h is required in order to build libcap-ng.)])
55 AC_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         ])
58 AC_CHECK_HEADERS(linux/securebits.h, [], [])
59 AC_CHECK_HEADERS(pthread.h,
60         [AC_SEARCH_LIBS(pthread_atfork, pthread)],
61         [AC_MSG_WARN(pthread.h not found, disabling pthread_atfork.)])
62 AC_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
66 AC_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])
70 AC_SUBST(CAPABILITY_HEADER)
71
72 ALLWARNS=""
73 ALLDEBUG="-g"
74 OPT="-O"
75 if 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
85 fi
86
87 ALLDEBUG="-g"
88 AC_ARG_WITH(debug,
89 [  --with-debug            turn on debugging [[default=no]]],
90 [
91 if test "x${withval}" = xyes; then
92         DEBUG="$ALLDEBUG"
93         OPT="-O"
94         AM_CONDITIONAL(DEBUG, true)
95 else
96         DEBUG="-DNDEBUG"
97         AM_CONDITIONAL(DEBUG, false)
98 fi
99 ],
100 [ DEBUG="-DNDEBUG"; AM_CONDITIONAL(DEBUG, false) ])
101
102 AC_MSG_CHECKING(__attr_dealloc_free support)
103 AC_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 )
112 AC_MSG_RESULT($DEALLOC)
113
114 AC_ARG_WITH(warn,
115 [  --with-warn             turn on warnings [[default=yes]]],
116 [
117 if test "x${withval}" = xyes; then
118         WARNS="$ALLWARNS"
119 else
120         WARNS=""
121 fi
122 ],WARNS="$ALLWARNS")
123 AC_SUBST(DEBUG)
124
125 WFLAGS=""
126 AC_MSG_CHECKING(for -Wformat-truncation)
127 TMPCFLAGS="${CFLAGS}"
128 CFLAGS="${CFLAGS} -Wformat-truncation"
129 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[WFLAGS="-Wno-format-truncation"
130         AC_MSG_RESULT(yes)],
131         [AC_MSG_RESULT(no)])
132 CFLAGS="${TMPCFLAGS}"
133 AC_SUBST(WFLAGS)
134
135 AC_CHECK_HEADER(sys/syscall.h,
136         [AC_DEFINE([HAVE_SYSCALL_H], [1],
137         [Define to 1 if you have <sys/syscall.h>.])], [],)
138
139 dnl; This is to record in the build logs what options are being taken
140 AC_CHECK_DECLS([PR_CAP_AMBIENT], [], [], [[#include <sys/prctl.h>]])
141 AC_CHECK_DECLS([VFS_CAP_REVISION_2], [], [], [[#include <linux/capability.h>]])
142 AC_CHECK_DECLS([VFS_CAP_REVISION_3], [], [], [[#include <linux/capability.h>]])
143 AC_CHECK_DECLS([CAP_EPOLLWAKEUP], [], [], [[#include <linux/capability.h>]])
144 AC_CHECK_DECLS([CAP_WAKE_ALARM], [], [], [[#include <linux/capability.h>]])
145 AC_CHECK_DECLS([CAP_BLOCK_SUSPEND], [], [], [[#include <linux/capability.h>]])
146 AC_CHECK_DECLS([CAP_AUDIT_READ], [], [], [[#include <linux/capability.h>]])
147 AC_CHECK_DECLS([CAP_PERFMON], [], [], [[#include <linux/capability.h>]])
148 AC_CHECK_DECLS([CAP_BPF], [], [], [[#include <linux/capability.h>]])
149 AC_CHECK_DECLS([CAP_CHECKPOINT_RESTORE], [], [], [[#include <linux/capability.h>]])
150
151 dnl only build libdrop_ambient if support for ambient capabilities was found (which is normal)
152 if 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")
154 fi
155 AM_CONDITIONAL(BUILD_LIBDROP_AMBIENT, test x"${ac_cv_have_decl_PR_CAP_AMBIENT}" = x"yes")
156
157 AC_CHECK_PROG(swig_found, swig, yes, no)
158 if test x"${swig_found}" = x"no" ; then
159         AC_MSG_WARN("Swig not found - python bindings will not be made")
160 fi
161 AM_CONDITIONAL(HAVE_SWIG, test x"${swig_found}" = x"yes")
162
163 withval=""
164 AC_MSG_CHECKING(whether to create python3 bindings)
165 AC_ARG_WITH(python3,
166 AS_HELP_STRING([--with-python3],[enable building python3 bindings]),
167 use_python3=$withval,
168 use_python3=auto)
169 if test x$use_python3 = xno ; then
170         AC_MSG_RESULT(no)
171 else
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         AC_PATH_PROG([PYTHON3], [python3], [no])
185         if test "x$PYTHON3" == "xno" ; then
186                 echo "The python3 program was not found in the search path. Please ensure"
187                 echo "that it is installed and its directory is included in the search path or"
188                 echo "pass --without-python3 to ./configure."
189                 exit 1
190         fi
191         PYTHON3_CFLAGS=`python3-config --cflags 2> /dev/null`
192         PYTHON3_LIBS=`python3-config --libs 2> /dev/null`
193         PYTHON3_INCLUDES=`python3-config --includes 2> /dev/null`
194         AC_SUBST([PYTHON3_PREFIX], ['${prefix}'])
195         PYTHON3_EXECDIR=`$PYTHON3 -c "import sysconfig; print(sysconfig.get_path('platlib'))"`
196         AC_SUBST(PYTHON3_CFLAGS)
197         AC_SUBST(PYTHON3_LIBS)
198         AC_SUBST(PYTHON3_INCLUDES)
199         AC_SUBST(py3execdir, $PYTHON3_EXECDIR)
200         fi
201 fi
202 AM_CONDITIONAL(USE_PYTHON3, test ${use_python3} = "yes")
203
204 AC_CONFIG_FILES([Makefile src/Makefile src/libcap-ng.pc src/test/Makefile 
205         bindings/Makefile
206         bindings/python3/Makefile bindings/src/Makefile 
207         bindings/python3/test/Makefile utils/Makefile
208         m4/Makefile docs/Makefile])
209 AC_OUTPUT
210
211 echo .
212 echo "
213
214   libcap-ng Version:      $VERSION
215   Target:                 $target
216   Installation prefix:    $prefix
217   PYTHON3_PREFIX:         $PYTHON3_PREFIX
218   Compiler:               $CC
219   Compiler flags:
220 `echo $CFLAGS | fmt -w 50 | sed 's,^,                          ,'`
221   __attr_dealloc_free support:  $DEALLOC
222 "