]> xenbits.xensource.com Git - livepatch-build-tools.git/commitdiff
livepatch-tools: add -largp option when required
authorRoger Pau Monne <roger.pau@citrix.com>
Mon, 13 Nov 2023 16:09:39 +0000 (17:09 +0100)
committerRoss Lagerwall <ross.lagerwall@citrix.com>
Wed, 15 Nov 2023 13:34:18 +0000 (13:34 +0000)
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é <roger.pau@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Makefile

index f96b150539d2f6cfb94d52475d058866331fe8b1..2f74c34333362bd6466d72222cf949ad6fa96e5a 100644 (file)
--- 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