How to tell whether GNU make is being used in a makefile?

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
Asked By: tarabyte



$(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 <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Answered By: Rolazaro Azeveires

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.

Answered By: Digital Trauma

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
Answered By: Philippe Gachoud
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.