You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
3.3 KiB

  1. # ===========================================================================
  2. # http://www.gnu.org/software/autoconf-archive/ax_check_gnu_make.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CHECK_GNU_MAKE()
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro searches for a GNU version of make. If a match is found:
  12. #
  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`.
  23. #
  24. # Here is an example of its use:
  25. #
  26. # Makefile.in might contain:
  27. #
  28. # # A failsafe way of putting a dependency rule into a makefile
  29. # $(DEPEND):
  30. # $(CC) -MM $(srcdir)/*.c > $(DEPEND)
  31. #
  32. # @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
  33. # @ifGNUmake@ include $(DEPEND)
  34. # @ifGNUmake@ endif
  35. #
  36. # Then configure.in would normally contain:
  37. #
  38. # AX_CHECK_GNU_MAKE()
  39. # AC_OUTPUT(Makefile)
  40. #
  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
  43. # first):
  44. #
  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;
  49. # fi
  50. #
  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.
  53. #
  54. # LICENSE
  55. #
  56. # Copyright (c) 2008 John Darrington <j.darrington@elvis.murdoch.edu.au>
  57. # Copyright (c) 2015 Enrico M. Crisostomo <enrico.m.crisostomo@gmail.com>
  58. #
  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
  62. # warranty.
  63. #serial 8
  64. AC_DEFUN([AX_CHECK_GNU_MAKE],dnl
  65. [AC_PROG_AWK
  66. AC_CACHE_CHECK([for GNU make],[_cv_gnu_make_command],[dnl
  67. _cv_gnu_make_command="" ;
  68. dnl Search all the common names for GNU make
  69. for a in "$MAKE" make gmake gnumake ; do
  70. if test -z "$a" ; then continue ; fi ;
  71. if "$a" --version 2> /dev/null | grep GNU 2>&1 > /dev/null ; then
  72. _cv_gnu_make_command=$a ;
  73. AX_CHECK_GNU_MAKE_HEADLINE=$("$a" --version 2> /dev/null | grep "GNU Make")
  74. ax_check_gnu_make_version=$(echo ${AX_CHECK_GNU_MAKE_HEADLINE} | ${AWK} -F " " '{ print $(NF); }')
  75. break ;
  76. fi
  77. done ;])
  78. dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise
  79. AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifGNUmake], ["#"])], [AS_VAR_SET([ifGNUmake], [""])])
  80. 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}])])
  81. AC_SUBST([ifGNUmake])
  82. ])