Makefile: check for minimum NASM version
Check if NASM is present in the system and
if its version is above or equal the minimum version
required.
@@ -50,6 +50,29 @@ USE_YASM ?= n
YASM ?= yasm
NASM ?= nasm
+# Detect NASM version (minimum version required: 2.14)
+NASM_VERSION = $(shell nasm -v | cut -d " " -f 3)
+
+NASM_MAJOR_REQ = 2
+NASM_MINOR_REQ = 14
+
+ifeq ($(NASM_VERSION),)
+$(error "NASM is not installed! Minimum required version: $(NASM_MAJOR_REQ).$(NASM_MINOR_REQ)")
+else
+NASM_MAJOR_VER = $(shell echo $(NASM_VERSION) | cut -d "." -f 1)
+NASM_MINOR_VER = $(shell echo $(NASM_VERSION) | cut -d "." -f 2)
+NASM_GE_MAJOR = $(shell [ $(NASM_MAJOR_VER) -ge $(NASM_MAJOR_REQ) ] && echo true)
+NASM_GE_MINOR = $(shell [ $(NASM_MINOR_VER) -ge $(NASM_MINOR_REQ) ] && echo true)
+ifneq ($(NASM_GE_MAJOR),true)
+$(warning "NASM version found: $(NASM_VERSION)")
+$(error "Minimum required: $(NASM_MAJOR_REQ).$(NASM_MINOR_REQ)")
+endif
+ifneq ($(NASM_GE_MINOR),true)
+$(warning "NASM version found: $(NASM_VERSION)")
+$(error "Minimum required: $(NASM_MAJOR_REQ).$(NASM_MINOR_REQ)")
+endif
+endif
+
OBJ_DIR ?= obj
LIB_DIR ?= .
