check_gnu_make.m4 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # ===========================================================================
  2. # http://autoconf-archive.cryp.to/check_gnu_make.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # CHECK_GNU_MAKE()
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro searches for a GNU version of make. If a match is found, the
  12. # makefile variable `ifGNUmake' is set to the empty string, otherwise it
  13. # is set to "#". This is useful for including a special features in a
  14. # Makefile, which cannot be handled by other versions of make. The
  15. # variable _cv_gnu_make_command is set to the command to invoke GNU make
  16. # if it exists, the empty string otherwise.
  17. #
  18. # Here is an example of its use:
  19. #
  20. # Makefile.in might contain:
  21. #
  22. # # A failsafe way of putting a dependency rule into a makefile
  23. # $(DEPEND):
  24. # $(CC) -MM $(srcdir)/*.c > $(DEPEND)
  25. #
  26. # @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
  27. # @ifGNUmake@ include $(DEPEND)
  28. # @ifGNUmake@ endif
  29. #
  30. # Then configure.in would normally contain:
  31. #
  32. # CHECK_GNU_MAKE()
  33. # AC_OUTPUT(Makefile)
  34. #
  35. # Then perhaps to cause gnu make to override any other make, we could do
  36. # something like this (note that GNU make always looks for GNUmakefile
  37. # first):
  38. #
  39. # if ! test x$_cv_gnu_make_command = x ; then
  40. # mv Makefile GNUmakefile
  41. # echo .DEFAULT: > Makefile ;
  42. # echo \ $_cv_gnu_make_command \$@ >> Makefile;
  43. # fi
  44. #
  45. # Then, if any (well almost any) other make is called, and GNU make also
  46. # exists, then the other make wraps the GNU make.
  47. #
  48. # LAST MODIFICATION
  49. #
  50. # 2008-04-12
  51. #
  52. # COPYLEFT
  53. #
  54. # Copyright (c) 2008 John Darrington <j.darrington@elvis.murdoch.edu.au>
  55. #
  56. # Copying and distribution of this file, with or without modification, are
  57. # permitted in any medium without royalty provided the copyright notice
  58. # and this notice are preserved.
  59. AC_DEFUN(
  60. [CHECK_GNU_MAKE], [ AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command,
  61. _cv_gnu_make_command='' ;
  62. dnl Search all the common names for GNU make
  63. for a in "$MAKE" make gmake gnumake ; do
  64. if test -z "$a" ; then continue ; fi ;
  65. if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null ) ; then
  66. _cv_gnu_make_command=$a ;
  67. break;
  68. fi
  69. done ;
  70. ) ;
  71. dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise
  72. if test "x$_cv_gnu_make_command" != "x" ; then
  73. ifGNUmake='' ;
  74. else
  75. ifGNUmake='#' ;
  76. AC_MSG_RESULT("Not found");
  77. fi
  78. AC_SUBST(ifGNUmake)
  79. ] )