[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug #50062] Variable needed to check that Makefile is run by GNU ma

From: Edward Welbourne
Subject: Re: [bug #50062] Variable needed to check that Makefile is run by GNU make?
Date: Tue, 17 Jan 2017 10:55:40 +0000

> When one wants to check that it is really GNU make that is run for a
> given Makefile

The only valid use case I can think of for this is where some particular
feature of GNU make is needed.  Generally, it is better to test *that
feature* rather than the version of make in use.  If another project
implements a compatible make, your make file shall work with that.  If
GNU make breaks that feature at a later version, your check will catch

(In the web browser world, sites that test browser version rather than
feature support, or the presence of the bug they're working round, are
the bane of smaller browsers; because they can't sensibly test every
browser, but are using browser-sniffing to decide what content to
deliver, they effectively impede adoption of new browsers.  A mis-guided
attempt to code round the defects of the most widely-used browser
effectively entrenched its monopoly for most of a decade.)

> the standard solution is to rely on $(shell make --version), or to
> read $(MAKE_VERSION). See e.g.
> http://unix.stackexchange.com/questions/218692
> The second solution is simpler and more efficient but nothing prevents
> other, non-GNU, make's to support a variable called MAKE_VERSION.

which would indeed be a sane thing for them to do - with their version
number.  It might make sense for the value of MAKE_VERSION to contain
something after the pure version number, as a separate word (so that we
can use $(firstword ...) to separate it), to indicate that it's GNU make
we're using; but I'd still discourage you from using checks on this to
decide whether to handle a given make file.  Test the feature you need,

> $(error "Sorry, you are not running GNU make. I must stop...)
> endif

which (quite apart from your missing close quote) is the wrong way to
deal with this.  Another make might be entirely as acceptable but your
make file demands I use GNU make even though the one I've got can cope
just fine with everything in your make file aside from your demand that
I use GNU make.  (Did you ever have a bank web-site that told you to use
Internet Explorer ?  Downgrade the security of your operating system and
your browser, because that's the one we know (and are insured for) the
enormous risks of, we won't let you use a more secure browser that runs
on a more secure operating system.  We know best - we're a
bank. </rant>) Browsers responded by lying in the UserAgent header:
another make can just as well define GNUMAKE_VERSION to code round your
mis-guided check.  Fortunately, so can I on make's command-line.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]