X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=acinclude.m4;h=648132a2a5b4bce308ad7a59a47d00d5acaf1fb3;hb=b063d9f06e6bb005193a219bcb9f0a74dfdf7882;hp=61d15552decc734746e54f60bf348ad8dcc1e575;hpb=8a2d6596f2cb43c097957ed6e003eb5225dd5003;p=openvswitch diff --git a/acinclude.m4 b/acinclude.m4 index 61d15552..648132a2 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -57,6 +57,8 @@ AC_DEFUN([OVS_CHECK_LINUX], [ elif test X"$with_l26_source" != X; then KSRC=$with_l26_source AC_MSG_WARN([--with-l26-source is deprecated, please use --with-linux-source instead]) + else + KSRC= fi elif test X"$with_linux_source" != X || test X"$with_l26_source" != X; then AC_MSG_ERROR([Linux source directory may not be specified without Linux build directory]) @@ -91,7 +93,7 @@ AC_DEFUN([OVS_CHECK_LINUX], [ *) KSRC=`pwd`/$KSRC ;; esac if test ! -e $KSRC/include/linux/kernel.h; then - AC_MSG_ERROR([$KSRC is not a kernel source directory)]) + AC_MSG_ERROR([$KSRC is not a kernel source directory]) fi else KSRC=$KBUILD @@ -112,17 +114,27 @@ AC_DEFUN([OVS_CHECK_LINUX], [ AC_MSG_RESULT([$KSRC]) AC_MSG_CHECKING([for kernel version]) + version=`sed -n 's/^VERSION = //p' "$KSRC/Makefile"` patchlevel=`sed -n 's/^PATCHLEVEL = //p' "$KSRC/Makefile"` sublevel=`sed -n 's/^SUBLEVEL = //p' "$KSRC/Makefile"` - if test -z "$patchlevel" || test -z "$sublevel"; then + if test X"$version" = X || test X"$patchlevel" = X; then AC_ERROR([cannot determine kernel version]) + elif test X"$sublevel" = X; then + kversion=$version.$patchlevel + else + kversion=$version.$patchlevel.$sublevel fi - AC_MSG_RESULT([2.$patchlevel.$sublevel]) - if test "2.$patchlevel" != '2.6'; then + AC_MSG_RESULT([$kversion]) + + if test "$version" -ge 3; then + : # Linux 3.x + elif test "$version" = 2 && test "$patchlevel" -ge 6; then + : # Linux 2.6.x + else if test "$KBUILD" = "$KSRC"; then - AC_ERROR([Linux kernel in $KBUILD is not version 2.6]) + AC_ERROR([Linux kernel in $KBUILD is version $kversion, but version 2.6 or later is required]) else - AC_ERROR([Linux kernel in build tree $KBUILD (source tree $KSRC) is not version 2.6]) + AC_ERROR([Linux kernel in build tree $KBUILD (source tree $KSRC) is version $kversion, but version 2.6 or later is required]) fi fi if test ! -e "$KBUILD"/include/linux/version.h || \ @@ -168,7 +180,7 @@ dnl OVS_DEFINE(NAME) dnl dnl Defines NAME to 1 in kcompat.h. AC_DEFUN([OVS_DEFINE], [ - echo '#define $1 1' >> datapath/linux-2.6/kcompat.h.new + echo '#define $1 1' >> datapath/linux/kcompat.h.new ]) AC_DEFUN([OVS_CHECK_LOG2_H], [ @@ -186,9 +198,9 @@ dnl dnl Runs various Autoconf checks on the Linux 2.6 kernel source in dnl the directory in $KBUILD. AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ - rm -f datapath/linux-2.6/kcompat.h.new - mkdir -p datapath/linux-2.6 - : > datapath/linux-2.6/kcompat.h.new + rm -f datapath/linux/kcompat.h.new + mkdir -p datapath/linux + : > datapath/linux/kcompat.h.new OVS_GREP_IFELSE([$KSRC/arch/x86/include/asm/checksum_32.h], [src_err,], [OVS_DEFINE([HAVE_CSUM_COPY_DBG])]) @@ -242,18 +254,16 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_get_be16]) OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_find_nested]) - OVS_GREP_IFELSE([$KSRC/include/linux/if_link.h], [rtnl_link_stats64]) - OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [ADD_ALL_VLANS_CMD], [OVS_DEFINE([HAVE_VLAN_BUG_WORKAROUND])]) OVS_CHECK_LOG2_H - if cmp -s datapath/linux-2.6/kcompat.h.new \ - datapath/linux-2.6/kcompat.h >/dev/null 2>&1; then - rm datapath/linux-2.6/kcompat.h.new + if cmp -s datapath/linux/kcompat.h.new \ + datapath/linux/kcompat.h >/dev/null 2>&1; then + rm datapath/linux/kcompat.h.new else - mv datapath/linux-2.6/kcompat.h.new datapath/linux-2.6/kcompat.h + mv datapath/linux/kcompat.h.new datapath/linux/kcompat.h fi ]) @@ -397,10 +407,30 @@ EOF fi]) AS_IF([test $ovs_cv_gnu_make_if = yes], [$1], [$2])]) +dnl OVS_CHECK_SPARSE_TARGET +dnl +dnl The "cgcc" script from "sparse" isn't very good at detecting the +dnl target for which the code is being built. This helps it out. +AC_DEFUN([OVS_CHECK_SPARSE_TARGET], + [AC_CACHE_CHECK( + [target hint for cgcc], + [ac_cv_sparse_target], + [AS_CASE([`$CC -dumpmachine 2>/dev/null`], + [i?86-* | athlon-*], [ac_cv_sparse_target=x86], + [x86_64-*], [ac_cv_sparse_target=x86_64], + [ac_cv_sparse_target=other])]) + AS_CASE([$ac_cv_sparse_target], + [x86], [SPARSEFLAGS= CGCCFLAGS=-target=i86], + [x86_64], [SPARSEFLAGS=-m64 CGCCFLAGS=-target=x86_64], + [SPARSEFLAGS= CGCCFLAGS=]) + AC_SUBST([SPARSEFLAGS]) + AC_SUBST([CGCCFLAGS])]) + dnl OVS_ENABLE_SPARSE AC_DEFUN([OVS_ENABLE_SPARSE], - [OVS_MAKE_HAS_IF( + [AC_REQUIRE([OVS_CHECK_SPARSE_TARGET]) + OVS_MAKE_HAS_IF( [AC_CONFIG_COMMANDS_PRE( [: ${SPARSE=sparse} AC_SUBST([SPARSE]) - CC='$(if $(C),REAL_CC="'"$CC"'" CHECK="$(SPARSE) -I $(top_srcdir)/include/sparse" cgcc,'"$CC"')'])])]) + CC='$(if $(C),REAL_CC="'"$CC"'" CHECK="$(SPARSE) -I $(top_srcdir)/include/sparse $(SPARSEFLAGS)" cgcc $(CGCCFLAGS),'"$CC"')'])])])