[ovs-dev] [PATCH] Makefile: Check for undistributed files on every make, not just "make dist".

Ben Pfaff blp at nicira.com
Mon Dec 6 19:33:37 UTC 2010


It's really easy to add files to the Git repository but forget to add them
to the distributions created by "make dist".  I do this regularly, for
example.  For some time, we've had a check that runs on "make dist" to
make sure that the distribution is complete, but I still screw up because
I don't run "make dist" all that often.

This commit improves the situation, by doing the check on every "make",
instead of just on "make dist".
---
 Makefile.am          |   43 ++++++++++++++++++++++++-------------------
 datapath/Makefile.am |   10 ++++++++++
 2 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 8517b2b..75e1248 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -96,26 +96,31 @@ SUFFIXES += .in
 
 # If we're checked out from a Git repository, make sure that every
 # file that is in Git is distributed.
-dist-hook-git:
-	if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1; then    \
-	  rc=0;								      \
-	  for d in `cd $(srcdir) && git ls-files`; do			      \
-	    if test ! -e $(distdir)/$$d; then				      \
-	      case $$d in # (						      \
-	        .gitignore|*/.gitignore) ;; # (				      \
-		*)							      \
-		   if test $$rc = 0; then				      \
-		     echo "The distribution is missing the following files:"; \
-		     rc=1;						      \
-		   fi;							      \
-	           echo "$$d";						      \
-	           ;;							      \
-	      esac;							      \
-	    fi								      \
-	  done;								      \
-	  exit $$rc;							      \
+ALL_LOCAL += dist-hook-git
+dist-hook-git: distfiles
+	@if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1; then \
+	  (cd datapath && make distfiles);				    \
+	  (cat distfiles; sed 's|^|datapath/|' datapath/distfiles) |	    \
+	    sort -u > all-distfiles;					    \
+	  (cd $(srcdir) && git ls-files) | grep -v '\.gitignore$$' |	    \
+	    sort -u > all-gitfiles;					    \
+	  comm -1 -3 all-distfiles all-gitfiles > missing-distfiles;	    \
+	  if test -s missing-distfiles; then				    \
+	    echo "The distribution is missing the following files:";	    \
+	    cat missing-distfiles;					    \
+	    exit 1;							    \
+	  fi;								    \
 	fi
-DIST_HOOKS += dist-hook-git
+CLEANFILES += all-distfiles all-gitfiles missing-distfiles
+# The following is based on commands for the Automake "distdir" target.
+distfiles: Makefile
+	srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t" | sort -u > $@
+CLEANFILES += distfiles
 
 dist-hook: $(DIST_HOOKS)
 all-local: $(ALL_LOCAL)
diff --git a/datapath/Makefile.am b/datapath/Makefile.am
index 71e2dc4..1c0af40 100644
--- a/datapath/Makefile.am
+++ b/datapath/Makefile.am
@@ -10,3 +10,13 @@ AUTOMAKE_OPTIONS = -Wno-portability
 
 include Modules.mk
 include linux-2.6/Modules.mk
+
+# The following is based on commands for the Automake "distdir" target.
+distfiles: Makefile
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t" | sort -u > $@
+CLEANFILES = distfiles
-- 
1.7.1





More information about the dev mailing list