Home | History | Annotate | Download | only in m4
      1 dnl Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
      2 dnl
      3 dnl This program is free software; you can redistribute it and/or
      4 dnl modify it under the terms of the GNU General Public License as
      5 dnl published by the Free Software Foundation; either version 2 of
      6 dnl the License, or (at your option) any later version.
      7 dnl
      8 dnl This program is distributed in the hope that it would be useful,
      9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
     10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11 dnl GNU General Public License for more details.
     12 dnl
     13 dnl You should have received a copy of the GNU General Public License
     14 dnl along with this program; if not, write the Free Software Foundation,
     15 dnl Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     16 dnl
     17 dnl Author: Alexey Kodanev <alexey.kodanev (a] oracle.com>
     18 dnl
     19 
     20 dnl
     21 dnl LTP_CHECK_KERNEL_DEVEL
     22 dnl ----------------------------
     23 dnl Building kernel modules
     24 dnl requires kernel-devel installed
     25 dnl
     26 
     27 AC_DEFUN([LTP_CHECK_KERNEL_DEVEL],[dnl
     28 
     29 AC_MSG_CHECKING([for kernel-devel])
     30 AC_ARG_WITH(
     31 	[linux-version],
     32 	[AC_HELP_STRING([--with-linux-version=VERSION],
     33 			[specify the Linux version to build modules for])],
     34 	[LINUX_VERSION="${withval}"],
     35 	AS_IF([test "$cross_compiling" = "no"],
     36 		[LINUX_VERSION=`uname -r`]))
     37 
     38 AC_SUBST(LINUX_VERSION)
     39 
     40 AC_ARG_WITH([linux-dir],
     41 	[AC_HELP_STRING([--with-linux-dir=DIR],
     42 			[specify path to kernel-devel directory])],
     43 	[LINUX_DIR="${withval}"],
     44 	AS_IF([test -n "$LINUX_VERSION"],
     45 		[LINUX_DIR="/lib/modules/$LINUX_VERSION/build"]))
     46 
     47 AC_SUBST(LINUX_DIR)
     48 
     49 if test -f "$LINUX_DIR/Makefile"; then
     50 	LINUX_VERSION_MAJOR=`make -C ${LINUX_DIR} -s kernelversion | cut -d. -f1`
     51 	LINUX_VERSION_PATCH=`make -C ${LINUX_DIR} -s kernelversion | cut -d. -f2`
     52 fi
     53 
     54 if test -n "$LINUX_VERSION_MAJOR" -a -n "$LINUX_VERSION_PATCH"; then
     55 	WITH_MODULES="yes"
     56 else
     57 	WITH_MODULES="no"
     58 fi
     59 
     60 AC_SUBST(LINUX_VERSION_MAJOR)
     61 AC_SUBST(LINUX_VERSION_PATCH)
     62 
     63 AC_MSG_RESULT([$WITH_MODULES])
     64 
     65 AC_ARG_WITH(
     66 	[modules],
     67 	[AC_HELP_STRING([--without-modules],
     68 			[disable auto-building kernel modules])],
     69 			[WITH_MODULES="no"],
     70 			[])
     71 
     72 AC_SUBST(WITH_MODULES)
     73 ])
     74