Portability fix for GNU make 3.79.1.
[pspp] / top / GNUmakefile
index 38dd1262fa18acfa57166a6c2837339146c2504c..8b64c49dd918a34b4d6f451ec5bbc436d8fd51bd 100644 (file)
@@ -54,13 +54,30 @@ _have-git-version-gen := \
   $(shell test -f $(srcdir)/$(_build-aux)/git-version-gen && echo yes)
 ifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL))
   _is-dist-target = $(filter-out %clean, \
-    $(filter dist% alpha beta major,$(MAKECMDGOALS)))
-  ifneq (,$(_is-dist-target))
-    _curr-ver := $(shell cd $(srcdir) && ./$(_build-aux)/git-version-gen \
-                   $(srcdir)/.tarball-version)
+    $(filter maintainer-% dist% alpha beta major,$(MAKECMDGOALS)))
+  _is-install-target = $(filter-out %check, $(filter install%,$(MAKECMDGOALS)))
+  ifneq (,$(_is-dist-target)$(_is-install-target))
+    _curr-ver := $(shell cd $(srcdir) \
+                   && $(_build-aux)/git-version-gen .tarball-version)
     ifneq ($(_curr-ver),$(VERSION))
-      $(info INFO: running autoreconf for new version string: $(_curr-ver))
-      _dummy := $(shell cd $(srcdir) && rm -rf autom4te.cache && $(_autoreconf)))
+      ifeq ($(_curr-ver),UNKNOWN)
+        $(info WARNING: unable to verify if $(VERSION) is correct version)
+      else
+       ifneq (,$(_is-install-target))
+         # GNU Coding Standards state that 'make install' should not cause
+         # recompilation after 'make all'.  But as long as changing the version
+         # string alters config.h, the cost of having 'make all' always have an
+         # up-to-date version is prohibitive.  So, as a compromise, we merely
+         # warn when installing a version string that is out of date; the user
+         # should run 'autoreconf' (or something like 'make distcheck') to
+         # fix the version, 'make all' to propagate it, then 'make install'.
+         $(info WARNING: version string $(VERSION) is out of date; run autoreconf -f to fix it)
+       else
+         $(info INFO: running autoreconf for new version string: $(_curr-ver))
+         _dummy := $(shell cd $(srcdir) && rm -rf autom4te.cache .version \
+           && $(_autoreconf))
+       endif
+      endif
     endif
   endif
 endif
@@ -68,11 +85,16 @@ endif
 else
 
 .DEFAULT_GOAL := abort-due-to-no-makefile
+srcdir = .
 
 # The package can override .DEFAULT_GOAL to run actions like autoreconf.
 -include ./cfg.mk
 include ./maint.mk
 
+ifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile)
+$(MAKECMDGOALS): abort-due-to-no-makefile
+endif
+
 abort-due-to-no-makefile:
        @echo There seems to be no Makefile in this directory.   1>&2
        @echo "You must run ./configure before running \`make'." 1>&2