From af26d107aae62230c697c18e5d23acda2cb8f762 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 4 Nov 2008 14:10:00 -0800 Subject: [PATCH] Add build number to datapath version and --version output from programs. --- configure.ac | 1 + datapath/datapath.c | 6 ++--- datapath/linux-2.4/Kbuild.in | 15 ++++++++--- datapath/linux-2.6/Kbuild.in | 6 +++++ debian/rules | 2 +- m4/nx-build.m4 | 48 ++++++++++++++++++++++++++++++++++++ secchan/secchan.c | 5 ++-- switch/switch.c | 3 ++- tests/test-dhcp-client.c | 3 ++- utilities/dpctl.c | 3 ++- utilities/ofp-discover.c | 3 ++- utilities/ofp-kill.c | 3 ++- 12 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 m4/nx-build.m4 diff --git a/configure.ac b/configure.ac index 4501bb864..57cd2947f 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,7 @@ AC_PREREQ(2.59) AC_INIT(openflow, 0.9.0~b1, info@openflowswitch.org) +NX_BUILDNR AC_CONFIG_SRCDIR([README.hwtables]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_AUX_DIR([build-aux]) diff --git a/datapath/datapath.c b/datapath/datapath.c index 9e811797b..b7cd6233d 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -50,7 +50,7 @@ * is queriable through the switch description stats message. */ static char mfr_desc[DESC_STR_LEN] = "Nicira Networks, Inc."; static char hw_desc[DESC_STR_LEN] = "Reference Linux Kernel Module"; -static char sw_desc[DESC_STR_LEN] = VERSION; +static char sw_desc[DESC_STR_LEN] = VERSION BUILDNR; static char serial_num[SERIAL_NUM_LEN] = "None"; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) @@ -1814,8 +1814,8 @@ static int __init dp_init(void) { int err; - printk("OpenFlow "VERSION", built "__DATE__" "__TIME__", " - "protocol 0x%02x\n", OFP_VERSION); + printk("OpenFlow %s, built "__DATE__" "__TIME__", " + "protocol 0x%02x\n", VERSION BUILDNR, OFP_VERSION); err = flow_init(); if (err) diff --git a/datapath/linux-2.4/Kbuild.in b/datapath/linux-2.4/Kbuild.in index 1a6c617ab..86bfa6b22 100644 --- a/datapath/linux-2.4/Kbuild.in +++ b/datapath/linux-2.4/Kbuild.in @@ -4,6 +4,7 @@ srcdir = @abs_srcdir@ top_srcdir = @abs_top_srcdir@ KSRC = @KSRC24@ VERSION = @VERSION@ +BUILDNR = @BUILDNR@ # File Lists include $(srcdir)/../Modules.mk @@ -15,9 +16,17 @@ include @HW_TABLES@ # mechanism the kernel provides to add cflags is the EXTRA_CFLAGS variable, # which gets inserted into the build command after the internal kernel CFLAGS. # Since our stuff needs to come first, we override the variable. -OF_CFLAGS = -I$(srcdir)/compat-2.4/include -I$(srcdir)/compat-2.4/include-$(ARCH) \ - -I$(srcdir)/compat-2.4 -I$(srcdir)/.. -I$(srcdir)/../../include \ - -I$(builddir)/.. $(CFLAGS) -DVERSION=\"$(VERSION)\" +OF_CFLAGS = -I$(srcdir)/compat-2.4/include \ + -I$(srcdir)/compat-2.4/include-$(ARCH) \ + -I$(srcdir)/compat-2.4 -I$(srcdir)/.. \ + -I$(srcdir)/../../include \ + -I$(builddir)/.. $(CFLAGS) \ + -DVERSION=\"$(VERSION)\" +ifeq '$(BUILDNR)' '0' +OF_CFLAGS += -DBUILDNR=\"\" +else +OF_CFLAGS += -DBUILDNR=\"+build$(BUILDNR)\" +endif override CFLAGS := $(OF_CFLAGS) # Multipart objects diff --git a/datapath/linux-2.6/Kbuild.in b/datapath/linux-2.6/Kbuild.in index 0d2e0dd5e..07fad36a2 100644 --- a/datapath/linux-2.6/Kbuild.in +++ b/datapath/linux-2.6/Kbuild.in @@ -3,6 +3,7 @@ export builddir = @abs_builddir@ export srcdir = @abs_srcdir@ export top_srcdir = @abs_top_srcdir@ export VERSION = @VERSION@ +export BUILDNR = @BUILDNR@ include $(srcdir)/../Modules.mk include $(srcdir)/Modules.mk @@ -13,6 +14,11 @@ EXTRA_CFLAGS += -I$(srcdir)/.. EXTRA_CFLAGS += -I$(builddir)/.. EXTRA_CFLAGS += -I$(top_srcdir)/include EXTRA_CFLAGS += @SUPPORT_SNAT@ +ifeq '$(BUILDNR)' '0' +EXTRA_CFLAGS += -DBUILDNR=\"\" +else +EXTRA_CFLAGS += -DBUILDNR=\"+build$(BUILDNR)\" +endif # These include directories have to go before -I$(KSRC)/include. # NOSTDINC_FLAGS just happens to be a variable that goes in the diff --git a/debian/rules b/debian/rules index 1c8dc246e..5b25308e7 100755 --- a/debian/rules +++ b/debian/rules @@ -98,7 +98,7 @@ binary-modules: prep-deb-files dh_compress dh_fixperms dh_installdeb - dh_gencontrol -- -v$(VERSION) + dh_gencontrol dh_md5sums dh_builddeb --destdir=$(DEB_DESTDIR) diff --git a/m4/nx-build.m4 b/m4/nx-build.m4 new file mode 100644 index 000000000..d6becf442 --- /dev/null +++ b/m4/nx-build.m4 @@ -0,0 +1,48 @@ +# -*- autoconf -*- + +# Copyright (c) 2008 The Board of Trustees of The Leland Stanford +# Junior University +# +# We are making the OpenFlow specification and associated documentation +# (Software) available for public use and benefit with the expectation +# that others will use, modify and enhance the Software and contribute +# those enhancements back to the community. However, since we would +# like to make the Software available for broadest use, with as few +# restrictions as possible permission is hereby granted, free of +# charge, to any person obtaining a copy of this Software to deal in +# the Software under the copyrights without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# The name and trademarks of copyright holder(s) may NOT be used in +# advertising or publicity pertaining to the Software or any +# derivatives without specific, written prior permission. + +dnl NX_BUILDNR([NUMBER]) +dnl +dnl If NUMBER is empty, substitutes BUILDNR with 0 and sets C +dnl preprocessor variable BUILDNR to "". +dnl +dnl If NUMBER is nonempty, substitutes a Makefile variable BUILDNR +dnl with NUMBER, and sets a C preprocessor variable BUILDNR to +dnl "+buildNUMBER". +AC_DEFUN([NX_BUILDNR], + [AC_SUBST([BUILDNR], + [m4_if([$1], [], [0], [$1])]) + AC_DEFINE([BUILDNR], + [m4_if([$1], [], [""], ["+build$1"])], + [Official build number.])]) diff --git a/secchan/secchan.c b/secchan/secchan.c index f1ac6d218..35b851ff8 100644 --- a/secchan/secchan.c +++ b/secchan/secchan.c @@ -149,7 +149,7 @@ main(int argc, char *argv[]) die_if_already_running(); daemonize(); - VLOG_WARN("OpenFlow reference implementation version %s", VERSION); + VLOG_WARN("OpenFlow reference implementation version %s", VERSION BUILDNR); VLOG_WARN("OpenFlow protocol version 0x%02x", OFP_VERSION); /* Connect to datapath. */ @@ -706,7 +706,8 @@ parse_options(int argc, char *argv[], struct settings *s) usage(); case 'V': - printf("%s "VERSION" compiled "__DATE__" "__TIME__"\n", argv[0]); + printf("%s %s compiled "__DATE__" "__TIME__"\n", + program_name, VERSION BUILDNR); exit(EXIT_SUCCESS); DAEMON_OPTION_HANDLERS diff --git a/switch/switch.c b/switch/switch.c index 03f7dc0ab..525e9fa78 100644 --- a/switch/switch.c +++ b/switch/switch.c @@ -214,7 +214,8 @@ parse_options(int argc, char *argv[]) usage(); case 'V': - printf("%s "VERSION" compiled "__DATE__" "__TIME__"\n", argv[0]); + printf("%s %s compiled "__DATE__" "__TIME__"\n", + program_name, VERSION BUILDNR); exit(EXIT_SUCCESS); case 'v': diff --git a/tests/test-dhcp-client.c b/tests/test-dhcp-client.c index 039ffed8a..f8a1f4276 100644 --- a/tests/test-dhcp-client.c +++ b/tests/test-dhcp-client.c @@ -166,7 +166,8 @@ parse_options(int argc, char *argv[]) usage(); case 'V': - printf("%s "VERSION" compiled "__DATE__" "__TIME__"\n", argv[0]); + printf("%s %s compiled "__DATE__" "__TIME__"\n", + program_name, VERSION BUILDNR); exit(EXIT_SUCCESS); case 'v': diff --git a/utilities/dpctl.c b/utilities/dpctl.c index 0065cf712..e4f6a63a7 100644 --- a/utilities/dpctl.c +++ b/utilities/dpctl.c @@ -176,7 +176,8 @@ parse_options(int argc, char *argv[], struct settings *s) usage(); case 'V': - printf("%s "VERSION" compiled "__DATE__" "__TIME__"\n", argv[0]); + printf("%s %s compiled "__DATE__" "__TIME__"\n", + program_name, VERSION BUILDNR); exit(EXIT_SUCCESS); case 'v': diff --git a/utilities/ofp-discover.c b/utilities/ofp-discover.c index 402d5897c..461aa7caf 100644 --- a/utilities/ofp-discover.c +++ b/utilities/ofp-discover.c @@ -365,7 +365,8 @@ parse_options(int argc, char *argv[]) usage(); case 'V': - printf("%s "VERSION" compiled "__DATE__" "__TIME__"\n", argv[0]); + printf("%s %s compiled "__DATE__" "__TIME__"\n", + program_name, VERSION BUILDNR); exit(EXIT_SUCCESS); case 'v': diff --git a/utilities/ofp-kill.c b/utilities/ofp-kill.c index a1c1e84e5..0ad043433 100644 --- a/utilities/ofp-kill.c +++ b/utilities/ofp-kill.c @@ -182,7 +182,8 @@ parse_options(int argc, char *argv[]) usage(); case 'V': - printf("%s "VERSION" compiled "__DATE__" "__TIME__"\n", argv[0]); + printf("%s %s compiled "__DATE__" "__TIME__"\n", + program_name, VERSION BUILDNR); exit(EXIT_SUCCESS); case '?': -- 2.43.0