From 864f63792d06e71f224e903c937d7d03bbab31ba Mon Sep 17 00:00:00 2001 From: Louie Lu Date: Mon, 24 Oct 2016 17:51:08 +0800 Subject: [PATCH] Makefile: detect lua version is less then 5.3 for bitop Testing on Lua 5.3.2, when compiling, it will throw an exception "jit-x86.dasc:4: error: cannot load module: dynasm/dasm_x86.lua:31: module 'bit' not found" According to Lua Bitop website, Bitop only support Lua 5.1/5.2. (http://bitop.luajit.org/) "Lua BitOp is a C extension module for Lua 5.1/5.2 which adds bitwise operations on numbers." When detect lua version is greater then 5.2, it will change specific lua version to 5.2. --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 116e98a..d7bc664 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,16 @@ BIN = interpreter \ CROSS_COMPILE = arm-linux-gnueabihf- QEMU_ARM = qemu-arm -L /usr/arm-linux-gnueabihf LUA = lua +LUAVERSION_MAJOR = $(shell $(LUA) -v | cut -d' ' -f2 | cut -d'.' -f1) +LUAVERSION_MINOR = $(shell $(LUA) -v | cut -d' ' -f2 | cut -d'.' -f2) + +# Checking lua version is less then 5.3. +# if not, change to lua 5.2 +ifeq ($(LUAVERSION_MAJOR), 5) +ifeq ($(shell test $(LUAVERSION_MINOR) -gt 2; echo $$?), 0) + LUA = lua5.2 +endif +endif all: $(BIN)