public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] configure: add configure checks to compile kernel modules
@ 2013-06-13 13:28 Alexey Kodanev
  2013-06-17 17:11 ` chrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Kodanev @ 2013-06-13 13:28 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko, Alexey Kodanev

There're new configure options added to tune modules building process.
New m4 function tries to determine if kernel-devel package is available
and sets makefile's variables (WITH_MODULES, ...) accordingly.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 configure.ac                 |    1 +
 include/mk/config.mk.default |    6 +++
 include/mk/config.mk.in      |    6 +++
 m4/ltp-kernel_devel.m4       |   82 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100644 m4/ltp-kernel_devel.m4

diff --git a/configure.ac b/configure.ac
index f217f50..f0fc6b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -167,5 +167,6 @@ LTP_CHECK_MADVISE
 LTP_CHECK_ACL_SUPPORT
 LTP_CHECK_FS_IOC_FLAGS
 LTP_CHECK_MREMAP_FIXED
+LTP_CHECK_KERNEL_DEVEL
 
 AC_OUTPUT
diff --git a/include/mk/config.mk.default b/include/mk/config.mk.default
index bd364a6..a84f42a 100644
--- a/include/mk/config.mk.default
+++ b/include/mk/config.mk.default
@@ -73,4 +73,10 @@ LDFLAGS			+= $(WLDFLAGS)
 CFLAGS			+= $(DEBUG_CFLAGS) $(OPT_CFLAGS) $(WCFLAGS)
 CXXFLAGS		+= $(DEBUG_CXXFLAGS) $(OPT_CXXFLAGS) $(WCXXFLAGS)
 
+LINUX_VERSION		:=
+LINUX_DIR		:=
+LINUX_VERSION_MAJOR	:=
+LINUX_PATCHLEVEL	:=
+WITH_MODULES		:= no
+
 export datarootdir includedir libdir mandir prefix
diff --git a/include/mk/config.mk.in b/include/mk/config.mk.in
index b835c86..71a8d8e 100644
--- a/include/mk/config.mk.in
+++ b/include/mk/config.mk.in
@@ -75,6 +75,12 @@ LDFLAGS			+= $(WLDFLAGS)
 CFLAGS			+= $(DEBUG_CFLAGS) $(OPT_CFLAGS) $(WCFLAGS)
 CXXFLAGS		+= $(DEBUG_CXXFLAGS) $(OPT_CXXFLAGS) $(WCXXFLAGS)
 
+LINUX_VERSION		:= @LINUX_VERSION@
+LINUX_DIR		:= @LINUX_DIR@
+LINUX_VERSION_MAJOR	:= @LINUX_VERSION_MAJOR@
+LINUX_PATCHLEVEL	:= @LINUX_PATCHLEVEL@
+WITH_MODULES		:= @WITH_MODULES@
+
 ifeq ($(strip $(prefix)),)
 $(error you are using $$(prefix) incorrectly -- set it to $(abs_top_srcdir) if you want to build in the source tree)
 endif
diff --git a/m4/ltp-kernel_devel.m4 b/m4/ltp-kernel_devel.m4
new file mode 100644
index 0000000..2015ea9
--- /dev/null
+++ b/m4/ltp-kernel_devel.m4
@@ -0,0 +1,82 @@
+dnl Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
+dnl
+dnl This program is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU General Public License as
+dnl published by the Free Software Foundation; either version 2 of
+dnl the License, or (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it would be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write the Free Software Foundation,
+dnl Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+dnl
+dnl Author: Alexey Kodanev <alexey.kodanev@oracle.com>
+dnl
+
+dnl
+dnl LTP_CHECK_KERNEL_DEVEL
+dnl ----------------------------
+dnl Building kernel modules
+dnl requires kernel-devel installed
+dnl
+
+AC_DEFUN([LTP_CHECK_KERNEL_DEVEL],[dnl
+
+AC_MSG_CHECKING([for kernel-devel])
+AC_ARG_WITH(
+	[linux-version],
+	[AC_HELP_STRING([--with-linux-version=VERSION],
+			[specify the Linux version to build modules for])],
+	[LINUX_VERSION="${withval}"],
+	AS_IF([test "$cross_compiling" = "no"],
+		[LINUX_VERSION=`uname -r`]))
+
+AC_SUBST(LINUX_VERSION)
+
+AC_ARG_WITH([linux-dir],
+	[AC_HELP_STRING([--with-linux-dir=DIR],
+			[specify path to kernel-devel directory])],
+	[LINUX_DIR="${withval}"],
+	AS_IF([test -n "$LINUX_VERSION"],
+		[LINUX_DIR="/lib/modules/$LINUX_VERSION/build"]))
+
+AC_SUBST(LINUX_DIR)
+
+if test -f "$LINUX_DIR/Makefile"; then
+	LINUX_VERSION_MAJOR=`sed -n '0,/^VERSION = [[0-9]]*/s,\
+^VERSION = ,,p' ${LINUX_DIR}/Makefile`
+
+	LINUX_PATCHLEVEL=`sed -n '0,/^PATCHLEVEL = [[0-9]]*/s,\
+^PATCHLEVEL = ,,p' ${LINUX_DIR}/Makefile`
+fi
+
+if [[ -n "$LINUX_VERSION_MAJOR" -a -n "$LINUX_PATCHLEVEL" ]]; then
+	WITH_MODULES="yes"
+else
+	WITH_MODULES="no"
+	if test -n "$LINUX_VERSION"; then
+		LINUX_VERSION_MAJOR=`echo "$LINUX_VERSION" | \
+sed -n 's/\([[0-9]]\).*$/\1/p'`
+		LINUX_PATCHLEVEL=`echo "$LINUX_VERSION" | \
+sed -n 's/^[[0-9]]*.\([[0-9]]\).*$/\1/p'`
+	fi
+fi
+
+AC_SUBST(LINUX_VERSION_MAJOR)
+AC_SUBST(LINUX_PATCHLEVEL)
+
+AC_MSG_RESULT([$WITH_MODULES])
+
+AC_ARG_WITH(
+	[modules],
+	[AC_HELP_STRING([--without-modules],
+			[disable auto-building kernel modules])],
+			[WITH_MODULES="no"],
+			[])
+
+AC_SUBST(WITH_MODULES)
+])
-- 
1.7.1


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-06-19 10:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-13 13:28 [LTP] [PATCH v2] configure: add configure checks to compile kernel modules Alexey Kodanev
2013-06-17 17:11 ` chrubis
     [not found]   ` <51C01086.1020207@oracle.com>
     [not found]     ` <51C177A3.4020301@oracle.com>
2013-06-19 10:53       ` chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox