-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; \
+#
+# We only enable this check when GNU make is in use because the
+# Makefile in datapath/linux, needed to get the list of files to
+# distribute, requires GNU make extensions.
+if GNU_MAKE
+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 -vFf $(srcdir)/.non-distfiles | \
+ 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
+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
+endif
+.PHONY: dist-hook-git
+
+# Check that every .c file includes <config.h>.
+ALL_LOCAL += config-h-check
+config-h-check:
+ @cd $(srcdir); \
+ if test -e .git && (git --version) >/dev/null 2>&1 && \
+ git --no-pager grep -L '#include <config\.h>' `git ls-files | grep '\.c$$' | \
+ grep -vE '^datapath|^lib/sflow|^third-party'`; \
+ then \
+ echo "See above for list of violations of the rule that"; \
+ echo "every C source file must #include <config.h>."; \
+ exit 1; \