xref: /aosp_15_r20/external/ltp/m4/ltp-cap.m4 (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Workerdnl SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Workerdnl Copyright (c) Cisco Systems Inc., 2009
3*49cdfc7eSAndroid Build Coastguard Workerdnl Copyright (c) Linux Test Project, 2019
4*49cdfc7eSAndroid Build Coastguard Workerdnl Author: Ngie Cooper <[email protected]>
5*49cdfc7eSAndroid Build Coastguard Worker
6*49cdfc7eSAndroid Build Coastguard WorkerAC_DEFUN([LTP_CHECK_CAPABILITY_SUPPORT],[
7*49cdfc7eSAndroid Build Coastguard WorkerAH_TEMPLATE(HAVE_LIBCAP,
8*49cdfc7eSAndroid Build Coastguard Worker[Define to 1 if you have libcap-2 installed.])
9*49cdfc7eSAndroid Build Coastguard WorkerAC_CHECK_HEADERS([sys/capability.h],[capability_header_prefix="sys"])
10*49cdfc7eSAndroid Build Coastguard Workerif test "x$capability_header_prefix" != x; then
11*49cdfc7eSAndroid Build Coastguard Worker	AC_CHECK_LIB(cap,cap_compare,[cap_libs="-lcap"])
12*49cdfc7eSAndroid Build Coastguard Workerfi
13*49cdfc7eSAndroid Build Coastguard Workerif test "x$cap_libs" != x; then
14*49cdfc7eSAndroid Build Coastguard Worker	AC_DEFINE(HAVE_LIBCAP)
15*49cdfc7eSAndroid Build Coastguard Workerfi
16*49cdfc7eSAndroid Build Coastguard WorkerAC_SUBST(CAP_LIBS,$cap_libs)
17*49cdfc7eSAndroid Build Coastguard Worker
18*49cdfc7eSAndroid Build Coastguard WorkerAH_TEMPLATE(HAVE_NEWER_LIBCAP,
19*49cdfc7eSAndroid Build Coastguard Worker[Define to 1 if you have newer libcap-2 installed.])
20*49cdfc7eSAndroid Build Coastguard WorkerAC_COMPILE_IFELSE([AC_LANG_SOURCE([
21*49cdfc7eSAndroid Build Coastguard Worker#include <sys/capability.h>
22*49cdfc7eSAndroid Build Coastguard Worker#include <linux/types.h>
23*49cdfc7eSAndroid Build Coastguard Workerint main(void) {
24*49cdfc7eSAndroid Build Coastguard Worker	__u16 a;
25*49cdfc7eSAndroid Build Coastguard Worker	__u32 b;
26*49cdfc7eSAndroid Build Coastguard Worker	return 0;
27*49cdfc7eSAndroid Build Coastguard Worker}])],[has_newer_libcap="yes"])
28*49cdfc7eSAndroid Build Coastguard Worker
29*49cdfc7eSAndroid Build Coastguard Workerif test "x$has_newer_libcap" = xyes; then
30*49cdfc7eSAndroid Build Coastguard Worker	AC_DEFINE(HAVE_NEWER_LIBCAP)
31*49cdfc7eSAndroid Build Coastguard Workerfi
32*49cdfc7eSAndroid Build Coastguard Worker])
33