1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_check_gnu_make.html
3 # ===========================================================================
11 # This macro searches for a GNU version of make. If a match is found:
13 # * The makefile variable `ifGNUmake' is set to the empty string, otherwise
14 # it is set to "#". This is useful for including a special features in a
15 # Makefile, which cannot be handled by other versions of make.
16 # * The variable `_cv_gnu_make_command` is set to the command to invoke
17 # GNU make if it exists, the empty string otherwise.
18 # * The variable `ax_cv_gnu_make_command` is set to the command to invoke
19 # GNU make by copying `_cv_gnu_make_command`, otherwise it is unset.
20 # * If GNU Make is found, its version is extracted from the output of
21 # `make --version` as the last field of a record of space-separated
22 # columns and saved into the variable `ax_check_gnu_make_version`.
24 # Here is an example of its use:
26 # Makefile.in might contain:
28 # # A failsafe way of putting a dependency rule into a makefile
30 # $(CC) -MM $(srcdir)/*.c > $(DEPEND)
32 # @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
33 # @ifGNUmake@ include $(DEPEND)
36 # Then configure.in would normally contain:
41 # Then perhaps to cause gnu make to override any other make, we could do
42 # something like this (note that GNU make always looks for GNUmakefile
45 # if ! test x$_cv_gnu_make_command = x ; then
46 # mv Makefile GNUmakefile
47 # echo .DEFAULT: > Makefile ;
48 # echo \ $_cv_gnu_make_command \$@ >> Makefile;
51 # Then, if any (well almost any) other make is called, and GNU make also
52 # exists, then the other make wraps the GNU make.
56 # Copyright (c) 2008 John Darrington <j.darrington@elvis.murdoch.edu.au>
57 # Copyright (c) 2015 Enrico M. Crisostomo <enrico.m.crisostomo@gmail.com>
59 # Copying and distribution of this file, with or without modification, are
60 # permitted in any medium without royalty provided the copyright notice
61 # and this notice are preserved. This file is offered as-is, without any
66 AC_DEFUN([AX_CHECK_GNU_MAKE],dnl
68 AC_CACHE_CHECK([for GNU make],[_cv_gnu_make_command],[dnl
69 _cv_gnu_make_command="" ;
70 dnl Search all the common names for GNU make
71 for a in "$MAKE" make gmake gnumake ; do
72 if test -z "$a" ; then continue ; fi ;
73 if "$a" --version 2> /dev/null | grep GNU 2>&1 > /dev/null ; then
74 _cv_gnu_make_command=$a ;
75 AX_CHECK_GNU_MAKE_HEADLINE=$("$a" --version 2> /dev/null | grep "GNU Make")
76 ax_check_gnu_make_version=$(echo ${AX_CHECK_GNU_MAKE_HEADLINE} | ${AWK} -F " " '{ print $(NF); }')
80 dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise
81 AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifGNUmake], ["#"])], [AS_VAR_SET([ifGNUmake], [""])])
82 AS_VAR_IF([_cv_gnu_make_command], [""], [AS_UNSET(ax_cv_gnu_make_command)], [AS_VAR_SET([ax_cv_gnu_make_command], [${_cv_gnu_make_command}])])