Last active
July 3, 2023 20:25
-
-
Save davidegreenwald/fab3e11276d180bc4bf65e5bd17554f4 to your computer and use it in GitHub Desktop.
Require a version in a Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Make version management ## | |
# For Mac users: ensure we aren't using the outdated 2004 3.81 release shipped with Macs | |
# or a particularly old GNU Make | |
MAKE_REQUIRED_MAJOR_VERSION := 4 | |
MAKE_VERSION := $(shell $(MAKE) --version | head -1 | cut -d ' ' -f 3) | |
MAKE_MAJOR_VERSION := $(shell echo $(MAKE_VERSION) | cut -d '.' -f 1) | |
COMPARE_MAKE_VERSIONS := $(shell printf "$(MAKE_MAJOR_VERSION)\n$(MAKE_REQUIRED_MAJOR_VERSION)" | sort | head -1) | |
ifeq ($(MAKE_VERSION),3.81) | |
$(error Error: The Make version is 3.81. This is the 2004 version packaged with MacOS which is missing new features. Please install GNU make with brew.) | |
endif | |
# If not equal, this is because COMPARE_MAKE_VERSIONS < required version | |
ifneq ($(COMPARE_MAKE_VERSIONS),$(MAKE_REQUIRED_MAJOR_VERSION)) | |
$(error Error: The Make version is below the suggested major version $(MAKE_REQUIRED_MAJOR_VERSION) and should be upgraded. On a Mac, install/update with brew.) | |
endif | |
## Targets ## | |
all: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment