test defs: backport optimized 'using_gmake' implementation
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 14 Jan 2012 09:32:13 +0000 (10:32 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 14 Jan 2012 09:32:13 +0000 (10:32 +0100)
* tests/defs.in (using_gmake): Backport optimized, result-caching
implementation from master.

tests/defs.in

index 0ee53c2..31426f2 100644 (file)
@@ -493,13 +493,30 @@ is_newest ()
 # using_gmake
 # -----------
 # Return success if $MAKE is GNU make, return failure otherwise.
+# Caches the result for speed reasons.
 using_gmake ()
 {
-  # Use --version AND -v, because SGI Make doesn't fail on --version.
-  # Also grep for GNU because newer versions of FreeBSD make do
-  # not complain about `--version' (they seem to silently ignore it).
-  $MAKE --version -v | grep GNU
+  case $am__using_gmake in
+    yes)
+      return 0;;
+    no)
+      return 1;;
+    '')
+      # Use --version AND -v, because SGI Make doesn't fail on --version.
+      # Also grep for GNU because newer versions of FreeBSD make do
+      # not complain about `--version' (they seem to silently ignore it).
+      if $MAKE --version -v | grep GNU; then
+        am__using_gmake=yes
+        return 0
+      else
+        am__using_gmake=no
+        return 1
+      fi;;
+    *)
+      fatal_ "invalid value for \$am__using_gmake: '$am__using_gmake'";;
+  esac
 }
+am__using_gmake="" # Avoid interferences from the environment.
 
 # AUTOMAKE_run status [options...]
 # --------------------------------