vlog: Check that all declared vlog modules are used, at "make" time.
authorBen Pfaff <blp@nicira.com>
Tue, 15 Jun 2010 17:25:21 +0000 (10:25 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 15 Jun 2010 17:25:21 +0000 (10:25 -0700)
Makefile.am
include/openflow/automake.mk
lib/automake.mk

index fa7b5ea2d618a6be00914685cb2eb55803a47cd3..fd6c56ccbdf3a2ae7a06fc78d803d44329a51bbc 100644 (file)
@@ -25,6 +25,7 @@ else
 AM_LDFLAGS = -export-dynamic
 endif
 
+ALL_LOCAL =
 BUILT_SOURCES =
 CLEANFILES =
 DISTCLEANFILES =
@@ -118,6 +119,7 @@ dist-hook-git:
 DIST_HOOKS += dist-hook-git
 
 dist-hook: $(DIST_HOOKS)
+all-local: $(ALL_LOCAL)
 .PHONY: $(DIST_HOOKS)
 
 include lib/automake.mk
index b8dbc71b3ba8c498c1f498c47ae89f048b561827..4b370d4f3faa5e906fb779e4b6be7818d63f8793 100644 (file)
@@ -3,14 +3,14 @@ noinst_HEADERS += \
        include/openflow/openflow.h
 
 if HAVE_PYTHON
-all-local: include/openflow/openflow.h.stamp
+ALL_LOCAL += include/openflow/openflow.h.stamp
 include/openflow/openflow.h.stamp: \
        include/openflow/openflow.h build-aux/check-structs
        $(PYTHON) $(srcdir)/build-aux/check-structs $(srcdir)/include/openflow/openflow.h
        touch $@
 DISTCLEANFILES += include/openflow/openflow.h.stamp
 
-all-local: include/openflow/nicira-ext.h.stamp
+ALL_LOCAL += include/openflow/nicira-ext.h.stamp
 include/openflow/nicira-ext.h.stamp: include/openflow/openflow.h include/openflow/nicira-ext.h build-aux/check-structs
        $(PYTHON) $(srcdir)/build-aux/check-structs $(srcdir)/include/openflow/openflow.h $(srcdir)/include/openflow/nicira-ext.h
        touch $@
index 5cc4e0fe46116398294d1411eb44e6fc614bab3b..a619d2288e8e5fbf72172af254008e3986dae922 100644 (file)
@@ -260,3 +260,31 @@ lib/coverage-counters.c: $(COVERAGE_FILES) lib/coverage-scan.pl
        (cd $(srcdir) && $(PERL) lib/coverage-scan.pl $(COVERAGE_FILES)) > $@.tmp
        mv $@.tmp $@
 EXTRA_DIST += lib/coverage-scan.pl
+
+
+# Make sure that every vlog module listed in vlog-modules.def is
+# actually used somewhere.
+ALL_LOCAL += check-for-unused-vlog-modules
+check-for-unused-vlog-modules:
+       if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1; then    \
+         cd $(srcdir);                                                       \
+         decl_vlog=`sed -n 's/^VLOG_MODULE(\([_a-z0-9]\{1,\}\)).*$$/\1/p'    \
+                    lib/vlog-modules.def |                                   \
+                     LC_ALL=C sort -u |                                              \
+                     xargs echo`;                                            \
+         used_vlog=`git grep VLM_ |                                          \
+                    sed -n 's/.*VLM_\([a-z_0-9]\{1,\}\).*/\1/p' |            \
+                    LC_ALL=C sort -u |                                       \
+                     xargs echo`;                                            \
+         rc=0;                                                               \
+         for decl in $$decl_vlog; do                                         \
+            case " $$used_vlog " in                                          \
+             *" $$decl "*) ;;                                                \
+             *) echo "vlog module $$decl is declared in lib/vlog-modules.def \
+but not used by any source file";                                            \
+                 rc=1 ;;                                                     \
+            esac                                                             \
+          done;                                                                      \
+         exit $$rc;                                                          \
+       fi
+.PHONY: check-for-unused-vlog-modules