I know GNU Make is by far the most commonly used, but I'm looking for a way to verify that GNU Make is the actual make program that is being used. Is there a special variable I can print from within the Makefile like:

@echo "$(MAKE_VERSION)"

What if I have both GNU Make and another variant installed?

which make


$(MAKE) --version

works here. My output is:

make --version
GNU Make 3.82
Built for i686-pc-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
| improve this answer | |
  • 1
    This may well result in an error on systems where make is not GNU make. – Kusalananda Dec 7 '18 at 15:19

From the GNU make manual:

By default, when make looks for the makefile, it tries the following names, in order: GNUmakefile, makefile and Makefile.

So if you name your make file GNUmakefile, then you should be guaranteed that it will only be read by GNU make and not by any other make.

| improve this answer | |

from here the only way I found doing that into a makefile is

  ifeq (3.81,$(firstword $(sort $(MAKE_VERSION) 3.81)))
    # stuff that requires make-3.81 or higher
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.