diff mbox series

[v2] kbuild: respect pkg-config-provided lua -L flags

Message ID 20211209010709.724674-1-dominique.martinet@atmark-techno.com
State Accepted
Delegated to: Stefano Babic
Headers show
Series [v2] kbuild: respect pkg-config-provided lua -L flags | expand

Commit Message

Dominique MARTINET Dec. 9, 2021, 1:07 a.m. UTC
- KBUILD_LIBS was set but unused
- (pkg-config)_LIBS was also unused, replace it to get only the -L flags
- remember the -L flags in EXTRA_LDFLAGS
- also pass EXTRA_LDFLAGS to tests so they can find the lib

Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
---
v2: trivial rebase on master

This is required on alpine with lua-5.3, and can be tested by setting
CONFIG_LUAPKG="lua5.3" in .config
Using the default lua version (5.1) does not require this as liblua.so
is populated in /usr/lib then.

 Makefile       | 2 +-
 Makefile.flags | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 932330c829cd..88ece9d40099 100644
--- a/Makefile
+++ b/Makefile
@@ -495,7 +495,7 @@  acceptance-tests: swupdate ${tools-bins} FORCE
 
 PHONY += test
 test:
-	$(Q)$(MAKE) $(build)=test SWOBJS="$(swupdate-objs)" SWLIBS="$(swupdate-libs) ${swupdate-ipc-lib}" LDLIBS="$(LDLIBS)" tests
+	$(Q)$(MAKE) $(build)=test SWOBJS="$(swupdate-objs)" SWLIBS="$(swupdate-libs) ${swupdate-ipc-lib}" EXTRA_LDFLAGS="$(EXTRA_LDFLAGS)" LDLIBS="$(LDLIBS)" tests
 
 # The actual objects are generated when descending,
 # make sure no implicit rule kicks in
diff --git a/Makefile.flags b/Makefile.flags
index 019ef777de75..1a3f6e712cc2 100644
--- a/Makefile.flags
+++ b/Makefile.flags
@@ -89,7 +89,7 @@  endif
 # Usage: $(eval $(call pkg_check_modules,VARIABLE-PREFIX,MODULES))
 define pkg_check_modules
 $(1)_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags $(2))
-$(1)_LIBS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs $(2))
+$(1)_LDFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs-only-L $(2))
 $(1)_LDLIBS := $(patsubst -l%,%,$(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs-only-l $(2)))
 endef
 
@@ -112,7 +112,7 @@  ifneq ($(CONFIG_LUA),)
 LDFLAGS_swupdate += -Wl,-E
 $(eval $(call pkg_check_modules, LUABUILD, ${CONFIG_LUAPKG}))
 KBUILD_CFLAGS += $(LUABUILD_CFLAGS)
-KBUILD_LIBS += $(LUABUILD_LIBS)
+EXTRA_LDFLAGS += $(LUABUILD_LDFLAGS)
 LDLIBS += $(LUABUILD_LDLIBS)
 LUAVER :=  $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --modversion ${CONFIG_LUAPKG} | cut -d'.' -f1,2)
 endif