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