Blame m4/ax_check_gnu_make.m4

Packit Service 4684c1
# ===========================================================================
Packit Service 4684c1
#    https://www.gnu.org/software/autoconf-archive/ax_check_gnu_make.html
Packit Service 4684c1
# ===========================================================================
Packit Service 4684c1
#
Packit Service 4684c1
# SYNOPSIS
Packit Service 4684c1
#
Packit Service 4684c1
#   AX_CHECK_GNU_MAKE([run-if-true],[run-if-false])
Packit Service 4684c1
#
Packit Service 4684c1
# DESCRIPTION
Packit Service 4684c1
#
Packit Service 4684c1
#   This macro searches for a GNU version of make. If a match is found:
Packit Service 4684c1
#
Packit Service 4684c1
#     * The makefile variable `ifGNUmake' is set to the empty string, otherwise
Packit Service 4684c1
#       it is set to "#". This is useful for including a special features in a
Packit Service 4684c1
#       Makefile, which cannot be handled by other versions of make.
Packit Service 4684c1
#     * The makefile variable `ifnGNUmake' is set to #, otherwise
Packit Service 4684c1
#       it is set to the empty string. This is useful for including a special
Packit Service 4684c1
#       features in a Makefile, which can be handled
Packit Service 4684c1
#       by other versions of make or to specify else like clause.
Packit Service 4684c1
#     * The variable `_cv_gnu_make_command` is set to the command to invoke
Packit Service 4684c1
#       GNU make if it exists, the empty string otherwise.
Packit Service 4684c1
#     * The variable `ax_cv_gnu_make_command` is set to the command to invoke
Packit Service 4684c1
#       GNU make by copying `_cv_gnu_make_command`, otherwise it is unset.
Packit Service 4684c1
#     * If GNU Make is found, its version is extracted from the output of
Packit Service 4684c1
#       `make --version` as the last field of a record of space-separated
Packit Service 4684c1
#       columns and saved into the variable `ax_check_gnu_make_version`.
Packit Service 4684c1
#     * Additionally if GNU Make is found, run shell code run-if-true
Packit Service 4684c1
#       else run shell code run-if-false.
Packit Service 4684c1
#
Packit Service 4684c1
#   Here is an example of its use:
Packit Service 4684c1
#
Packit Service 4684c1
#   Makefile.in might contain:
Packit Service 4684c1
#
Packit Service 4684c1
#     # A failsafe way of putting a dependency rule into a makefile
Packit Service 4684c1
#     $(DEPEND):
Packit Service 4684c1
#             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
Packit Service 4684c1
#
Packit Service 4684c1
#     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
Packit Service 4684c1
#     @ifGNUmake@ include $(DEPEND)
Packit Service 4684c1
#     @ifGNUmake@ else
Packit Service 4684c1
#     fallback code
Packit Service 4684c1
#     @ifGNUmake@ endif
Packit Service 4684c1
#
Packit Service 4684c1
#   Then configure.in would normally contain:
Packit Service 4684c1
#
Packit Service 4684c1
#     AX_CHECK_GNU_MAKE()
Packit Service 4684c1
#     AC_OUTPUT(Makefile)
Packit Service 4684c1
#
Packit Service 4684c1
#   Then perhaps to cause gnu make to override any other make, we could do
Packit Service 4684c1
#   something like this (note that GNU make always looks for GNUmakefile
Packit Service 4684c1
#   first):
Packit Service 4684c1
#
Packit Service 4684c1
#     if  ! test x$_cv_gnu_make_command = x ; then
Packit Service 4684c1
#             mv Makefile GNUmakefile
Packit Service 4684c1
#             echo .DEFAULT: > Makefile ;
Packit Service 4684c1
#             echo \  $_cv_gnu_make_command \$@ >> Makefile;
Packit Service 4684c1
#     fi
Packit Service 4684c1
#
Packit Service 4684c1
#   Then, if any (well almost any) other make is called, and GNU make also
Packit Service 4684c1
#   exists, then the other make wraps the GNU make.
Packit Service 4684c1
#
Packit Service 4684c1
# LICENSE
Packit Service 4684c1
#
Packit Service 4684c1
#   Copyright (c) 2008 John Darrington <j.darrington@elvis.murdoch.edu.au>
Packit Service 4684c1
#   Copyright (c) 2015 Enrico M. Crisostomo <enrico.m.crisostomo@gmail.com>
Packit Service 4684c1
#
Packit Service 4684c1
#   Copying and distribution of this file, with or without modification, are
Packit Service 4684c1
#   permitted in any medium without royalty provided the copyright notice
Packit Service 4684c1
#   and this notice are preserved. This file is offered as-is, without any
Packit Service 4684c1
#   warranty.
Packit Service 4684c1
Packit Service 4684c1
#serial 11
Packit Service 4684c1
Packit Service 4684c1
AC_DEFUN([AX_CHECK_GNU_MAKE],dnl
Packit Service 4684c1
  [AC_PROG_AWK
Packit Service 4684c1
  AC_CACHE_CHECK([for GNU make],[_cv_gnu_make_command],[dnl
Packit Service 4684c1
    _cv_gnu_make_command="" ;
Packit Service 4684c1
dnl Search all the common names for GNU make
Packit Service 4684c1
    for a in "$MAKE" make gmake gnumake ; do
Packit Service 4684c1
      if test -z "$a" ; then continue ; fi ;
Packit Service 4684c1
      if "$a" --version 2> /dev/null | grep GNU 2>&1 > /dev/null ; then
Packit Service 4684c1
        _cv_gnu_make_command=$a ;
Packit Service 4684c1
        AX_CHECK_GNU_MAKE_HEADLINE=$("$a" --version 2> /dev/null | grep "GNU Make")
Packit Service 4684c1
        ax_check_gnu_make_version=$(echo ${AX_CHECK_GNU_MAKE_HEADLINE} | ${AWK} -F " " '{ print $(NF); }')
Packit Service 4684c1
        break ;
Packit Service 4684c1
      fi
Packit Service 4684c1
    done ;])
Packit Service 4684c1
dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise
Packit Service 4684c1
  AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifGNUmake], ["#"])],   [AS_VAR_SET([ifGNUmake], [""])])
Packit Service 4684c1
  AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifnGNUmake], [""])],   [AS_VAR_SET([ifGNUmake], ["#"])])
Packit Service 4684c1
  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}])])
Packit Service 4684c1
  AS_VAR_IF([_cv_gnu_make_command], [""],[$2],[$1])
Packit Service 4684c1
  AC_SUBST([ifGNUmake])
Packit Service 4684c1
  AC_SUBST([ifnGNUmake])
Packit Service 4684c1
])