I have a makefile that gives a non-obvious failure when an older version of gmake is used. I’d like to have a rule that checks the version is at least version 3.82 or later. I’ve gotten as far as the following rule, but the comparison is brittle, I really want a comparison allowing for later versions too:
GMAKE_VERSION := $(shell gmake --version | head -n 1 | sed 's/GNU Make //')
.PHONY: testMake
testMake:
@if [ "$(GMAKE_VERSION)" != "3.82" ]; \
then \
echo >&2 "Unexpected gmakefile version " \
"$(GMAKE_VERSION), expecting 3.82 or later."; \
false; \
fi
What GNU makefile rule can ensure the version of make is at least v3.82?
Here is how I would implement it:
The check is based on testing
.FEATURESbuilt-in variable. From GNU Make 3.82 NEWS file: