Add build number to datapath version and --version output from programs.
authorBen Pfaff <blp@nicira.com>
Tue, 4 Nov 2008 22:10:00 +0000 (14:10 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 4 Nov 2008 22:10:00 +0000 (14:10 -0800)
12 files changed:
configure.ac
datapath/datapath.c
datapath/linux-2.4/Kbuild.in
datapath/linux-2.6/Kbuild.in
debian/rules
m4/nx-build.m4 [new file with mode: 0644]
secchan/secchan.c
switch/switch.c
tests/test-dhcp-client.c
utilities/dpctl.c
utilities/ofp-discover.c
utilities/ofp-kill.c

index 4501bb8..57cd294 100644 (file)
@@ -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])
index 9e81179..b7cd623 100644 (file)
@@ -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)
index 1a6c617..86bfa6b 100644 (file)
@@ -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
index 0d2e0dd..07fad36 100644 (file)
@@ -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
index 1c8dc24..5b25308 100755 (executable)
@@ -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 (file)
index 0000000..d6becf4
--- /dev/null
@@ -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.])])
index f1ac6d2..35b851f 100644 (file)
@@ -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
index 03f7dc0..525e9fa 100644 (file)
@@ -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':
index 039ffed..f8a1f42 100644 (file)
@@ -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':
index 0065cf7..e4f6a63 100644 (file)
@@ -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':
index 402d589..461aa7c 100644 (file)
@@ -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':
index a1c1e84..0ad0434 100644 (file)
@@ -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 '?':