[ovs-dev] [PATCH] datapath: Fix build with kernel header layout recently adopted by Debian.
Justin Pettit
jpettit at nicira.com
Wed Nov 18 21:00:42 UTC 2009
Yuck. Maybe we should switch to being a Windows project.
I gave it a superficial look, but it seems reasonable. Thanks for addressing this!
--Justin
On Nov 18, 2009, at 11:05 AM, Ben Pfaff wrote:
> Recent Debian kernel-header packages divide kernel headers into two
> directories: the "common" headers that are not architecture-specific,
> which go in a directory named like
> /usr/src/kernel-headers-2.6.31-1-common,
> and architecture-specific headers in a directory named, e.g.
> /usr/src/kernel-headers-2.6.31-1-686.
> OVS needs to look at the ones in the "common" directory as part of its
> configuration process, but the build directory provided on --with-l26 is
> the architecture-specific directory. We also need the
> architecture-specific directory, since it is the one that we use as part
> of the "make", so we can't simply make the user specify the common
> directory on --with-l26. Furthermore, there is no easy-to-see link
> between the two directories, except as part of the text in a Makefile,
> which is not the easiest language to parse.
>
> This commit attempts to kluge around the problem by using the Debian
> directory naming. If the build directory does not contain the headers,
> then we replace the last component of its name by "-common" and check
> for the headers there. This is not ideal, but it does solve the actual
> problem at hand.
>
> Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
> sets of headers that do not use this scheme.
> ---
> acinclude.m4 | 71 ++++++++++++++++++++++------------
> configure.ac | 2 +-
> datapath/linux-2.6/Makefile.main.in | 2 +-
> 3 files changed, 48 insertions(+), 27 deletions(-)
>
> diff --git a/acinclude.m4 b/acinclude.m4
> index 6ba647a..6115669 100644
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -14,41 +14,62 @@
> # See the License for the specific language governing permissions and
> # limitations under the License.
>
> -dnl OVS_CHECK_LINUX(OPTION, VERSION, VARIABLE, CONDITIONAL)
> +dnl OVS_CHECK_LINUX26
> dnl
> dnl Configure linux kernel source tree
> -AC_DEFUN([OVS_CHECK_LINUX], [
> - AC_ARG_WITH([$1],
> - [AC_HELP_STRING([--with-$1=/path/to/linux-$2],
> - [Specify the linux $2 kernel sources])],
> - [path="$withval"], [path=])dnl
> - if test -n "$path"; then
> - path=`eval echo "$path"`
> +AC_DEFUN([OVS_CHECK_LINUX26], [
> + AC_ARG_WITH([l26],
> + [AC_HELP_STRING([--with-l26=/path/to/linux-2.6],
> + [Specify the linux 2.6 kernel sources])],
> + [KBUILD26="$withval"], [KBUILD26=])dnl
> + if test -n "$KBUILD26"; then
> + KBUILD26=`eval echo "$KBUILD26"`
>
> - AC_MSG_CHECKING([for $path directory])
> - if test -d "$path"; then
> - AC_MSG_RESULT([yes])
> - $3=$path
> - AC_SUBST($3)
> + # The build directory is what the user provided.
> + # Make sure that it exists.
> + AC_MSG_CHECKING([for Linux 2.6 build directory])
> + if test -d "$KBUILD26"; then
> + AC_MSG_RESULT([$KBUILD26])
> + AC_SUBST(KBUILD26)
> else
> AC_MSG_RESULT([no])
> - AC_ERROR([source dir $path doesn't exist])
> + AC_ERROR([source dir $KBUILD26 doesn't exist])
> fi
>
> - AC_MSG_CHECKING([for $path kernel version])
> - patchlevel=`sed -n 's/^PATCHLEVEL = //p' "$path/Makefile"`
> - sublevel=`sed -n 's/^SUBLEVEL = //p' "$path/Makefile"`
> + # Debian breaks kernel headers into "source" header and "build" headers.
> + # We want the source headers, but $KBUILD26 gives us the "build" headers.
> + # Use heuristics to find the source headers.
> + AC_MSG_CHECKING([for Linux 2.6 source directory])
> + KSRC26=$KBUILD26
> + if test ! -e $KSRC26/include/linux/kernel.h; then
> + KSRC26=`(cd $KBUILD26 && pwd -P) | sed 's,-[[^-]]*$,-common,'`
> + if test ! -e $KSRC26/include/linux/kernel.h; then
> + AC_MSG_ERROR([cannot find source directory])
> + fi
> + fi
> + AC_MSG_RESULT([$KSRC26])
> +
> + AC_MSG_CHECKING([for kernel version])
> + patchlevel=`sed -n 's/^PATCHLEVEL = //p' "$KSRC26/Makefile"`
> + sublevel=`sed -n 's/^SUBLEVEL = //p' "$KSRC26/Makefile"`
> + if test -z "$patchlevel" || test -z "$sublevel"; then
> + AC_ERROR([cannot determine kernel version])
> + fi
> AC_MSG_RESULT([2.$patchlevel.$sublevel])
> - if test "2.$patchlevel" != '$2'; then
> - AC_ERROR([Linux kernel source in $path is not version $2])
> + if test "2.$patchlevel" != '2.6'; then
> + if test "$BUILD26" = "$KSRC26"; then
> + AC_ERROR([Linux kernel in $KBUILD26 is not version 2.6])
> + else
> + AC_ERROR([Linux kernel in build tree $KBUILD26 (source tree $KSRC26) is not version 2.6])
> + fi
> fi
> - if ! test -e "$path"/include/linux/version.h || \
> - ! test -e "$path"/include/linux/autoconf.h; then
> - AC_MSG_ERROR([Linux kernel source in $path is not configured])
> + if ! test -e "$KBUILD26"/include/linux/version.h || \
> + ! test -e "$KBUILD26"/include/linux/autoconf.h; then
> + AC_MSG_ERROR([Linux kernel source in $KBUILD26 is not configured])
> fi
> - m4_if($2, [2.6], [OVS_CHECK_LINUX26_COMPAT])
> + OVS_CHECK_LINUX26_COMPAT
> fi
> - AM_CONDITIONAL($4, test -n "$path")
> + AM_CONDITIONAL(L26_ENABLED, test -n "$KBUILD26")
> ])
>
> dnl OVS_GREP_IFELSE(FILE, REGEX, IF-MATCH, IF-NO-MATCH)
> @@ -103,7 +124,7 @@ AC_DEFUN([OVS_CHECK_LOG2_H], [
> dnl OVS_CHECK_LINUX26_COMPAT
> dnl
> dnl Runs various Autoconf checks on the Linux 2.6 kernel source in
> -dnl the directory in $KSRC26.
> +dnl the directory in $KBUILD26.
> AC_DEFUN([OVS_CHECK_LINUX26_COMPAT], [
> rm -f datapath/linux-2.6/kcompat.h.new
> mkdir -p datapath/linux-2.6
> diff --git a/configure.ac b/configure.ac
> index c8eed7c..300b21e 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -78,7 +78,7 @@ OVS_ENABLE_OPTION([-Wno-override-init])
>
> AC_ARG_VAR(KARCH, [Kernel Architecture String])
> AC_SUBST(KARCH)
> -OVS_CHECK_LINUX(l26, 2.6, KSRC26, L26_ENABLED)
> +OVS_CHECK_LINUX26
>
> AC_CONFIG_FILES([Makefile
> datapath/Makefile
> diff --git a/datapath/linux-2.6/Makefile.main.in b/datapath/linux-2.6/Makefile.main.in
> index 0005ec4..967e2f7 100644
> --- a/datapath/linux-2.6/Makefile.main.in
> +++ b/datapath/linux-2.6/Makefile.main.in
> @@ -2,7 +2,7 @@
> export builddir = @abs_builddir@
> export srcdir = @abs_srcdir@
> export top_srcdir = @abs_top_srcdir@
> -export KSRC = @KSRC26@
> +export KSRC = @KBUILD26@
> export VERSION = @VERSION@
> export BUILD_VETH = @BUILD_VETH@
>
> --
> 1.6.3.3
>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org
More information about the dev
mailing list