xref: /aosp_15_r20/external/ltp/m4/ltp-kernel_devel.m4 (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Workerdnl SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Workerdnl Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
3*49cdfc7eSAndroid Build Coastguard Workerdnl Author: Alexey Kodanev <[email protected]>
4*49cdfc7eSAndroid Build Coastguard Workerdnl Building kernel modules
5*49cdfc7eSAndroid Build Coastguard Workerdnl kernel development headers installed
6*49cdfc7eSAndroid Build Coastguard Worker
7*49cdfc7eSAndroid Build Coastguard WorkerAC_DEFUN([LTP_CHECK_KERNEL_DEVEL],[
8*49cdfc7eSAndroid Build Coastguard Worker
9*49cdfc7eSAndroid Build Coastguard WorkerAC_MSG_CHECKING([for kernel-devel])
10*49cdfc7eSAndroid Build Coastguard WorkerAC_ARG_WITH(
11*49cdfc7eSAndroid Build Coastguard Worker	[linux-version],
12*49cdfc7eSAndroid Build Coastguard Worker	[AS_HELP_STRING([--with-linux-version=VERSION],
13*49cdfc7eSAndroid Build Coastguard Worker			[specify the Linux version to build modules for])],
14*49cdfc7eSAndroid Build Coastguard Worker	[LINUX_VERSION="${withval}"],
15*49cdfc7eSAndroid Build Coastguard Worker	AS_IF([test "$cross_compiling" = "no"],
16*49cdfc7eSAndroid Build Coastguard Worker		[LINUX_VERSION=`uname -r`]))
17*49cdfc7eSAndroid Build Coastguard Worker
18*49cdfc7eSAndroid Build Coastguard WorkerAC_SUBST(LINUX_VERSION)
19*49cdfc7eSAndroid Build Coastguard Worker
20*49cdfc7eSAndroid Build Coastguard WorkerAC_ARG_WITH([linux-dir],
21*49cdfc7eSAndroid Build Coastguard Worker	[AS_HELP_STRING([--with-linux-dir=DIR],
22*49cdfc7eSAndroid Build Coastguard Worker			[specify path to kernel-devel directory])],
23*49cdfc7eSAndroid Build Coastguard Worker	[LINUX_DIR="${withval}"],
24*49cdfc7eSAndroid Build Coastguard Worker	AS_IF([test -n "$LINUX_VERSION"],
25*49cdfc7eSAndroid Build Coastguard Worker		[LINUX_DIR="/lib/modules/$LINUX_VERSION/build"]))
26*49cdfc7eSAndroid Build Coastguard Worker
27*49cdfc7eSAndroid Build Coastguard WorkerAC_SUBST(LINUX_DIR)
28*49cdfc7eSAndroid Build Coastguard Worker
29*49cdfc7eSAndroid Build Coastguard Workerif test -f "$LINUX_DIR/Makefile"; then
30*49cdfc7eSAndroid Build Coastguard Worker	LINUX_VERSION_MAJOR=`make -C ${LINUX_DIR} -s kernelversion | cut -d. -f1`
31*49cdfc7eSAndroid Build Coastguard Worker	LINUX_VERSION_PATCH=`make -C ${LINUX_DIR} -s kernelversion | cut -d. -f2`
32*49cdfc7eSAndroid Build Coastguard Workerfi
33*49cdfc7eSAndroid Build Coastguard Worker
34*49cdfc7eSAndroid Build Coastguard Workerif test -n "$LINUX_VERSION_MAJOR" -a -n "$LINUX_VERSION_PATCH"; then
35*49cdfc7eSAndroid Build Coastguard Worker	WITH_MODULES="yes"
36*49cdfc7eSAndroid Build Coastguard Workerelse
37*49cdfc7eSAndroid Build Coastguard Worker	WITH_MODULES="no"
38*49cdfc7eSAndroid Build Coastguard Workerfi
39*49cdfc7eSAndroid Build Coastguard Worker
40*49cdfc7eSAndroid Build Coastguard WorkerAC_SUBST(LINUX_VERSION_MAJOR)
41*49cdfc7eSAndroid Build Coastguard WorkerAC_SUBST(LINUX_VERSION_PATCH)
42*49cdfc7eSAndroid Build Coastguard Worker
43*49cdfc7eSAndroid Build Coastguard WorkerAC_MSG_RESULT([$WITH_MODULES])
44*49cdfc7eSAndroid Build Coastguard Worker
45*49cdfc7eSAndroid Build Coastguard WorkerAC_ARG_WITH(
46*49cdfc7eSAndroid Build Coastguard Worker	[modules],
47*49cdfc7eSAndroid Build Coastguard Worker	[AS_HELP_STRING([--without-modules],
48*49cdfc7eSAndroid Build Coastguard Worker			[disable auto-building kernel modules])],
49*49cdfc7eSAndroid Build Coastguard Worker			[WITH_MODULES="no"],
50*49cdfc7eSAndroid Build Coastguard Worker			[])
51*49cdfc7eSAndroid Build Coastguard Worker
52*49cdfc7eSAndroid Build Coastguard WorkerAC_SUBST(WITH_MODULES)
53*49cdfc7eSAndroid Build Coastguard Worker])
54