From: Willy Tarreau Date: Thu, 15 Dec 2022 09:47:14 +0000 (+0100) Subject: BUILD: makefile: make sure LUA_INC and LUA_LIB are always initialized X-Git-Tag: v2.8-dev1~53 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=2a3a882fe20508c021944f7623928dd75a52ab5a;p=thirdparty%2Fhaproxy.git BUILD: makefile: make sure LUA_INC and LUA_LIB are always initialized While LUA_INC is sometimes set in the makefile (only when LUA_LIB_NAME is not set), LUA_LIB is never pre-initialized and faces the risk of being accidently inherited from the environment. Let's make sure both are properly reset first when not explicitly set. For this we always set LUA_INC based on the autodetection if it's not set, and always pre-initialize LUA_LIB to empty. This also helps make that block slightly less difficult to understand. --- diff --git a/Makefile b/Makefile index 803eb1489c..4be54089fc 100644 --- a/Makefile +++ b/Makefile @@ -596,21 +596,20 @@ OPTIONS_OBJS += src/quic_conn.o src/mux_quic.o src/h3.o src/xprt_quic.o \ endif ifneq ($(USE_LUA),) -check_lua_lib = $(shell echo "int main(){}" | $(CC) -o /dev/null -x c - $(2) -l$(1) 2>/dev/null && echo $(1)) check_lua_inc = $(shell if [ -d $(2)$(1) ]; then echo $(2)$(1); fi;) - +LUA_INC := $(firstword $(foreach lib,lua5.4 lua54 lua5.3 lua53 lua,$(call check_lua_inc,$(lib),"/usr/include/"))) OPTIONS_CFLAGS += $(if $(LUA_INC),-I$(LUA_INC)) + +check_lua_lib = $(shell echo "int main(){}" | $(CC) -o /dev/null -x c - $(2) -l$(1) 2>/dev/null && echo $(1)) +LUA_LIB = LUA_LD_FLAGS := -Wl,$(if $(EXPORT_SYMBOL),$(EXPORT_SYMBOL),--export-dynamic) $(if $(LUA_LIB),-L$(LUA_LIB)) + 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)))) 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 -LUA_INC := $(firstword $(foreach lib,lua5.4 lua54 lua5.3 lua53 lua,$(call check_lua_inc,$(lib),"/usr/include/"))) -ifneq ($(LUA_INC),) -OPTIONS_CFLAGS += -I$(LUA_INC) -endif ifneq ($(HLUA_PREPEND_PATH),) OPTIONS_CFLAGS += -DHLUA_PREPEND_PATH=$(HLUA_PREPEND_PATH) BUILD_OPTIONS += HLUA_PREPEND_PATH=$(HLUA_PREPEND_PATH)