diff --git a/Makefile b/Makefile index 4be54089f..9f5b68130 100644 --- a/Makefile +++ b/Makefile @@ -604,25 +604,29 @@ check_lua_lib = $(shell echo "int main(){}" | $(CC) -o /dev/null -x c - $(2) -l$ LUA_LIB = LUA_LD_FLAGS := -Wl,$(if $(EXPORT_SYMBOL),$(EXPORT_SYMBOL),--export-dynamic) $(if $(LUA_LIB),-L$(LUA_LIB)) +# Try to automatically detect the Lua library if not set ifeq ($(LUA_LIB_NAME),) -# Try to automatically detect the Lua library LUA_LIB_NAME := $(firstword $(foreach lib,lua5.4 lua54 lua5.3 lua53 lua,$(call check_lua_lib,$(lib),$(LUA_LD_FLAGS)))) +endif + +# Lua lib name must be set now (forced/detected above) ifeq ($(LUA_LIB_NAME),) $(error unable to automatically detect the Lua library name, you can enforce its name with LUA_LIB_NAME= (where can be lua5.4, lua54, lua, ...)) endif + ifneq ($(HLUA_PREPEND_PATH),) OPTIONS_CFLAGS += -DHLUA_PREPEND_PATH=$(HLUA_PREPEND_PATH) BUILD_OPTIONS += HLUA_PREPEND_PATH=$(HLUA_PREPEND_PATH) -endif +endif # HLUA_PREPEND_PATH + ifneq ($(HLUA_PREPEND_CPATH),) OPTIONS_CFLAGS += -DHLUA_PREPEND_CPATH=$(HLUA_PREPEND_CPATH) BUILD_OPTIONS += HLUA_PREPEND_CPATH=$(HLUA_PREPEND_CPATH) -endif -endif +endif # HLUA_PREPEND_CPATH OPTIONS_LDFLAGS += $(LUA_LD_FLAGS) -l$(LUA_LIB_NAME) -lm OPTIONS_OBJS += src/hlua.o src/hlua_fcn.o -endif +endif # USE_LUA ifneq ($(USE_PROMEX),) OPTIONS_OBJS += addons/promex/service-prometheus.o