From: Stefano Lattarini Date: Mon, 22 Apr 2013 12:53:14 +0000 (+0200) Subject: header vars: can determine whether we are running under GNU make X-Git-Tag: v1.13.1d~19^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3de27839c88bda6c755f00c7142620080b725be0;p=thirdparty%2Fautomake.git header vars: can determine whether we are running under GNU make This is mostly a preparatory patch in view of future changes. * lib/am/header-vars.am (am__is_gnu_make): New, contains shell code that determines whether we are running under GNU make. * t/make-is-gnu.sh: New test. * t/list-of-tests.mk: Add it. Signed-off-by: Stefano Lattarini --- diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am index 9fda37cbe..8295a9994 100644 --- a/lib/am/header-vars.am +++ b/lib/am/header-vars.am @@ -26,12 +26,16 @@ VPATH = @srcdir@ ## a vendor make. ## DESTDIR = +## Shell code that determines whether we are running under GNU make. +## This is somewhat of an hack, and might be improved, but is good +## enough for now. +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' + ## Shell code that determines whether make is running in "dry mode" ## ("make -n") or not. Useful in rules that invoke make recursively, ## and are thus executed also with "make -n" -- either because they ## are declared as dependencies to '.MAKE' (NetBSD make), or because ## their recipes contain the "$(MAKE)" string (GNU and Solaris make). - am__make_dryrun = \ { \ am__dry=no; \ diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk index f1e3dca81..c72a63638 100644 --- a/t/list-of-tests.mk +++ b/t/list-of-tests.mk @@ -664,8 +664,9 @@ t/makej.sh \ t/makej2.sh \ t/maken.sh \ t/maken3.sh \ -t/make-dryrun.tap \ t/makevars.sh \ +t/make-dryrun.tap \ +t/make-is-gnu.sh \ t/man.sh \ t/man2.sh \ t/man3.sh \ diff --git a/t/make-is-gnu.sh b/t/make-is-gnu.sh new file mode 100755 index 000000000..c37cc17af --- /dev/null +++ b/t/make-is-gnu.sh @@ -0,0 +1,66 @@ +#! /bin/sh +# Copyright (C) 2013 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check that $(am__is_gnu_make) can be used to correctly determine if +# we are running under GNU make. + +. test-init.sh + +if using_gmake; then + as_expected () { test $1 -eq 0 && test -f ok && test ! -e ko; } +else + as_expected () { test $1 -gt 0 && test -f ko && test ! -e ok; } +fi + +echo AC_OUTPUT >> configure.ac + +cat > Makefile.am <<'END' +all: file + $(am__is_gnu_make) +file: + if $(am__is_gnu_make); then : > ok; else : > ko; fi +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE +./configure + +st=0; $MAKE || st=$? +if using_gmake; then + test $st -eq 0 + test -f ok + test ! -e ko +else + test $st -gt 0 + test -f ko + test ! -e ok +fi + +rm -f ok ko + +$MAKE -s file >output 2>&1 +cat output +if using_gmake; then + test -f ok + test ! -e ko +else + test -f ko + test ! -e ok +fi +test ! -s output + +: