]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: makefile: make sure LUA_INC and LUA_LIB are always initialized
authorWilly Tarreau <w@1wt.eu>
Thu, 15 Dec 2022 09:47:14 +0000 (10:47 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 23 Dec 2022 15:53:35 +0000 (16:53 +0100)
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.

Makefile

index 803eb1489ced07216ba4cadcbb7851a237b59660..4be54089fc0266cf804dbfbf8da571b8703ef0d5 100644 (file)
--- 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=<name> (where <name> 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)