From ad425f878e330532a62e1a65a444935d7f28a610 Mon Sep 17 00:00:00 2001 From: Roger Pau Monne Date: Mon, 13 Nov 2023 17:09:39 +0100 Subject: [PATCH] livepatch-tools: add -largp option when required MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit crate-diff-object makes use of argp library, and depending on the libc used by the system (ie: musl or BSD libc) argp is a separate library and requires the addition of -largp to the build rune. Introduce some shell logic to detect whether -largp is required for linking create-diff-object. I haven't done this as a reusable macro because I'm not sure there's much point in doing so, the only library we need to test for is argp, anything else is likely to be a mandatory library flag that doesn't require such testing (like libelf for example). Signed-off-by: Roger Pau Monné Reviewed-by: Ross Lagerwall Signed-off-by: Ross Lagerwall --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index f96b150..2f74c34 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,10 @@ LIBEXECDIR = $(DESTDIR)$(PREFIX)/libexec/livepatch-build-tools CFLAGS += -Iinsn -Wall -g LDFLAGS = -lelf +# Non GNU libc systems usually have argp as a standalone library. +LDFLAGS += $(shell if test -z "`$(CC) -largp 2>&1 | grep '\-largp'`"; \ + then echo "-largp"; fi;) + TARGETS = create-diff-object prelink CREATE_DIFF_OBJECT_OBJS = create-diff-object.o lookup.o insn/insn.o insn/inat.o common.o PRELINK_OBJS = prelink.o lookup.o insn/insn.o insn/inat.o common.o -- 2.39.5