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>
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