From 7d1591aec9aac734415287c03c5c905309408186 Mon Sep 17 00:00:00 2001 From: Mikio Hara Date: Wed, 23 Sep 2009 13:25:04 -0700 Subject: [PATCH] Add debian new kernel module build style support Please run configure as ./configure --with-l26=/lib/modules/`uname -r` instead of ./configure --with-l26=/lib/modules/`uname -r`/build --- .gitmodules | 3 -- INSTALL | 4 +- Makefile.am | 13 ------ acinclude.m4 | 72 ++++++++--------------------- boot.sh | 54 +--------------------- configure.ac | 7 +-- datapath/hwtable_nf2/README | 3 +- datapath/linux-2.6/Makefile.main.in | 8 ++-- regress/INSTALL | 2 +- 9 files changed, 31 insertions(+), 135 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 57d67d1..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "ext"] - path = ext - url = ../openflowext diff --git a/INSTALL b/INSTALL index 9c3cca1..979e403 100644 --- a/INSTALL +++ b/INSTALL @@ -227,7 +227,7 @@ argument to the configure script, as described under step 1 in that section. Specify the location on --with-l26 for Linux 2.6. For example, to build for a running instance of Linux 2.6: - % ./configure --with-l26=/lib/modules/`uname -r`/build + % ./configure --with-l26=/lib/modules/`uname -r` If you wish to build OpenFlow for an architecture other than the architecture used for compilation, you may specify the kernel @@ -245,7 +245,7 @@ switching table is in a directory named datapath/hwtable-foomatic, you could compile support for it with the running Linux 2.6 kernel like so: - % ./configure --with-l26=/lib/modules/`uname -r`/build \ + % ./configure --with-l26=/lib/modules/`uname -r` \ --enable-hw-tables=foomatic For more information about hardware table modules, please read diff --git a/Makefile.am b/Makefile.am index e2cf2d1..f429dc5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,20 +4,9 @@ AUTOMAKE_OPTIONS = foreign -Wno-syntax subdir-objects ACLOCAL_AMFLAGS = -I m4 SUBDIRS = datapath -if HAVE_DPKG_BUILDPACKAGE -distcheck-hook: - cd $(srcdir) && dpkg-buildpackage -rfakeroot -us -uc - cd $(srcdir) && fakeroot ./debian/rules clean -else -distcheck-hook: -endif - AM_CPPFLAGS = $(SSL_CFLAGS) AM_CPPFLAGS += -I $(top_srcdir)/include AM_CPPFLAGS += -I $(top_srcdir)/lib -if HAVE_EXT -AM_CPPFLAGS += -I $(top_srcdir)/ext/include -endif AM_CFLAGS = -Wstrict-prototypes @@ -66,5 +55,3 @@ include udatapath/automake.mk include tests/automake.mk include include/automake.mk include third-party/automake.mk -include debian/automake.mk -include ext.mk diff --git a/acinclude.m4 b/acinclude.m4 index c9c9f7a..dd7ef8c 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -38,35 +38,42 @@ dnl Configure linux kernel source tree AC_DEFUN([OFP_CHECK_LINUX], [ AC_ARG_WITH([$1], [AC_HELP_STRING([--with-$1=/path/to/linux-$2], - [Specify the linux $2 kernel sources])], + [Specify the linux $2 kernel module build envrionment and sources])], [path="$withval"], [path=])dnl if test -n "$path"; then path=`eval echo "$path"` AC_MSG_CHECKING([for $path directory]) - if test -d "$path"; then - AC_MSG_RESULT([yes]) - $3=$path - AC_SUBST($3) + if test -d "$path" && test -d "$path/build" ; then + AC_MSG_RESULT([yes]) + if test -d "$path/source" ; then + $3=$path/build + $4=$path/source + else + $3=$path/build + $4=$path/build + fi + AC_SUBST($3) + AC_SUBST($4) else - AC_MSG_RESULT([no]) - AC_ERROR([source dir $path doesn't exist]) + AC_MSG_RESULT([no]) + AC_ERROR([source dir $path 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"` + patchlevel=`sed -n 's/^PATCHLEVEL = //p' "$KBLD26/Makefile"` + sublevel=`sed -n 's/^SUBLEVEL = //p' "$KBLD26/Makefile"` AC_MSG_RESULT([2.$patchlevel.$sublevel]) if test "2.$patchlevel" != '$2'; then AC_ERROR([Linux kernel source in $path is not version $2]) 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 $KBLD26/include/linux/version.h || \ + ! test -e $KBLD26/include/linux/autoconf.h; then + AC_MSG_ERROR([Linux kernel source in $path is not configured]) fi m4_if($2, [2.6], [OFP_CHECK_LINUX26_COMPAT]) fi - AM_CONDITIONAL($4, test -n "$path") + AM_CONDITIONAL($5, test -n "$path") ]) dnl OFP_GREP_IFELSE(FILE, REGEX, IF-MATCH, IF-NO-MATCH) @@ -173,45 +180,6 @@ AC_DEFUN([OFP_CHECK_IF_PACKET], [Define to 1 if net/if_packet.h is available.]) fi]) -dnl Enable OpenFlow extension submodule. -AC_DEFUN([OFP_ENABLE_EXT], - [AC_ARG_ENABLE([ext], - AS_HELP_STRING([--enable-ext], - [use OpenFlow extensions - (default is yes if "ext" dir exists)])) - case "${enable_ext}" in - (yes) - HAVE_EXT=yes - ;; - (no) - HAVE_EXT=no - ;; - (*) - if test -e "$srcdir/ext/automake.mk"; then - HAVE_EXT=yes - else - HAVE_EXT=no - fi - ;; - esac - if test $HAVE_EXT = yes; then - if test -e "$srcdir/ext/automake.mk"; then - : - else - AC_MSG_ERROR([cannot configure extensions without "ext" directory]) - fi - AC_DEFINE([HAVE_EXT], [1], - [Whether the OpenFlow extensions submodule is available]) - fi - AM_CONDITIONAL([HAVE_EXT], [test $HAVE_EXT = yes])]) - -dnl Checks for dpkg-buildpackage. If this is available then we check -dnl that the Debian packaging is functional at "make distcheck" time. -AC_DEFUN([OFP_CHECK_DPKG_BUILDPACKAGE], - [AC_CHECK_PROG([HAVE_DPKG_BUILDPACKAGE], [dpkg-buildpackage], [yes], [no]) - AM_CONDITIONAL([HAVE_DPKG_BUILDPACKAGE], - [test $HAVE_DPKG_BUILDPACKAGE = yes])]) - dnl ---------------------------------------------------------------------- dnl These macros are from GNU PSPP, with the following original license: dnl Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. diff --git a/boot.sh b/boot.sh index ae2b366..f19b76b 100755 --- a/boot.sh +++ b/boot.sh @@ -1,55 +1,3 @@ #! /bin/sh -set -e - -have_ext=$(if test -e ext/automake.mk; then echo yes; else echo no; fi) -for opt -do - case $opt in - (--enable-ext) have_ext=yes ;; - (--disable-ext) have_ext=no ;; - (--help) cat < debian/automake.mk - -# Enable or disable ext. -if test "$have_ext" = yes; then - echo 'Enabling openflowext...' - echo 'include ext/automake.mk' > ext.mk - echo 'm4_include([ext/configure.m4])' > ext.m4 - cat debian/control.in ext/debian/control.in > debian/control - for d in $(cd ext/debian && git ls-files --exclude-from=debian/dontlink) - do - test -e debian/$d || ln -s ../ext/debian/$d debian/$d - if ! fgrep -q $d debian/.gitignore; then - echo "Adding $d to debian/.gitignore" - (cat debian/.gitignore && printf '/%s' "$d") \ - | LC_ALL=C sort > tmp$$ \ - && mv tmp$$ debian/.gitignore - fi - done -else - echo 'Disabling openflowext...' - echo '# This file intentionally left blank.' > ext.mk - echo '# This file intentionally left blank.' > ext.m4 - cat debian/control.in > debian/control -fi - -# Bootstrap configure system from .ac/.am files -autoreconf --install -I config --force +autoreconf --install --force diff --git a/configure.ac b/configure.ac index b3402e6..f1c58c7 100644 --- a/configure.ac +++ b/configure.ac @@ -60,9 +60,7 @@ AC_CHECK_FUNCS([strsignal]) AC_ARG_VAR(KARCH, [Kernel Architecture String]) AC_SUBST(KARCH) -OFP_CHECK_LINUX(l26, 2.6, KSRC26, L26_ENABLED) - -OFP_CHECK_DPKG_BUILDPACKAGE +OFP_CHECK_LINUX(l26, 2.6, KBLD26, KSRC26, L26_ENABLED) OFP_ENABLE_OPTION([-Wall]) OFP_ENABLE_OPTION([-Wno-sign-compare]) @@ -80,9 +78,6 @@ OFP_ENABLE_OPTION([-Wmissing-prototypes]) OFP_ENABLE_OPTION([-Wmissing-field-initializers]) OFP_ENABLE_OPTION([-Wno-override-init]) -OFP_ENABLE_EXT -m4_include([ext.m4]) - AC_CONFIG_FILES([Makefile datapath/Makefile datapath/linux-2.6/Kbuild diff --git a/datapath/hwtable_nf2/README b/datapath/hwtable_nf2/README index 1e87b1c..da700f0 100644 --- a/datapath/hwtable_nf2/README +++ b/datapath/hwtable_nf2/README @@ -14,8 +14,7 @@ Installation First build OpenFlow ensuring you include the directive to build the openflow_netfpga2 hardware table in your configure statement: - % ./configure --with-l26=/lib/modules/`uname -r`/build - --enable-hw-tables=nf2 + % ./configure --with-l26=/lib/modules/`uname -r` --enable-hw-tables=nf2 To get debugging output from the NetFPGA hardware table uncomment the following line from within /datapath/hwtable_nf2/nf2_flowtable.h, then recompile: diff --git a/datapath/linux-2.6/Makefile.main.in b/datapath/linux-2.6/Makefile.main.in index ddf32ab..e68722b 100644 --- a/datapath/linux-2.6/Makefile.main.in +++ b/datapath/linux-2.6/Makefile.main.in @@ -1,8 +1,10 @@ # -*- makefile -*- + export builddir = @abs_builddir@ export srcdir = @abs_srcdir@ export top_srcdir = @abs_top_srcdir@ export KSRC = @KSRC26@ +export KBLD = @KBLD26@ export VERSION = @VERSION@ export BUILD_VETH = @BUILD_VETH@ @@ -33,7 +35,7 @@ else KOBJ := $(KSRC) endif -ifneq ($(shell grep -c 'PATCHLEVEL = 6' $(KSRC)/Makefile),1) +ifneq ($(shell grep -c 'PATCHLEVEL = 6' $(KSRC)/Makefile), 1) $(error Linux kernel source in $(KSRC) not 2.6) endif @@ -42,13 +44,13 @@ ifeq (,$(wildcard $(VERSION_FILE))) $(error Linux kernel source not configured - missing version.h) endif -CONFIG_FILE := $(KSRC)/include/linux/autoconf.h +CONFIG_FILE := $(KBLD)/include/linux/autoconf.h ifeq (,$(wildcard $(CONFIG_FILE))) $(error Linux kernel source not configured - missing autoconf.h) endif default: - $(MAKE) -C $(KSRC) M=$(builddir) modules + $(MAKE) -C $(KBLD) M=$(builddir) modules endif # Much of the kernel build system in this file is derived from Intel's diff --git a/regress/INSTALL b/regress/INSTALL index 42ceb86..5eda932 100644 --- a/regress/INSTALL +++ b/regress/INSTALL @@ -106,7 +106,7 @@ Download and untar OpenFlow v0.8.1 tar xzf openflow-v0.8.1.tar.gz Build OpenFlow user-space and kernel-space switches: cd openflow-v0.8.1 - ./configure --with-l26=/lib/modules/`uname -r`/build + ./configure --with-l26=/lib/modules/`uname -r` make sudo make install Now, download and untar the OpenFlow Test Suite: