From: Willy Tarreau Date: Thu, 15 Dec 2022 10:55:51 +0000 (+0100) Subject: BUILD: makefile: do not restrict Lua's prepend path to empty LUA_LIB_NAME X-Git-Tag: v2.8-dev1~52 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=447247aa8d2fc5a2b2f8168ec353958971663fcb;p=thirdparty%2Fhaproxy.git BUILD: makefile: do not restrict Lua's prepend path to empty LUA_LIB_NAME The HLUA_PREPEND_PATH and HLUA_PREPEND_CPATH settings were only applied when LUA_LIB_NAME was empty, otherwise they were silently ignored. Let's take them out of that conditional block as this makes no sense to enforce such a restriction (the main reason in fact is that this whole block is unreadable). Also take this opportunity to unfold the last two imbricated tests of LUA_LIB_NAME and put comments around certain blocks to know what "endif" matches what "if". --- diff --git a/Makefile b/Makefile index 4be54089fc..9f5b681300 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