Initial import
[sliver-openvswitch.git] / acinclude.m4
1 dnl =================================================================================
2 dnl Distributed under the terms of the GNU GPL version 2.
3 dnl Copyright (c) 2007 The Board of Trustees of The Leland Stanford Junior University
4 dnl =================================================================================
5
6
7 dnl --
8 dnl CHECK_LINUX(OPTION, VERSION, VARIABLE, CONDITIONAL)
9 dnl
10 dnl Configure linux kernel source tree 
11 dnl --
12 AC_DEFUN([CHECK_LINUX], [
13   AC_ARG_WITH([$1],
14               [AC_HELP_STRING([--with-$1=/path/to/linux-$3],
15                               [Specify the linux $3 kernel sources])],
16               [path="$withval"], [path=])dnl
17   if test -n "$path"; then
18     path=`eval echo "$path"`
19
20     AC_MSG_CHECKING([for $path directory])
21     if test -d "$path"; then
22         AC_MSG_RESULT([yes])
23         $4=$path
24         AC_SUBST($4)
25     else
26         AC_MSG_RESULT([no])
27         AC_ERROR([source dir $path doesn't exist])
28     fi
29
30     AC_MSG_CHECKING([for $path kernel version])
31     version=`grep '^PATCHLEVEL = ' "$path/Makefile" | sed 's/PATCHLEVEL = '//`
32     AC_MSG_RESULT([2.$version])
33     if test "2.$version" != '$3'; then
34        AC_ERROR([Linux kernel source in $path is not version $3])
35     fi
36     if ! test -e "$path"/include/linux/version.h || \
37        ! test -e "$path"/include/linux/autoconf.h; then
38         AC_MSG_ERROR([Linux kernel source in $path is not configured])
39     fi
40   fi
41   AM_CONDITIONAL($5, test -n "$path")
42 ])