From 9674ced520e2e54992f6e86ec056ae443e16248c Mon Sep 17 00:00:00 2001 From: Alexandre Lissy Date: Tue, 29 Sep 2020 10:52:37 +0200 Subject: [PATCH] Auto-discover lzma/bz2 linkage of libmagic --- native_client/definitions.mk | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/native_client/definitions.mk b/native_client/definitions.mk index 0fca2731..69fe4539 100644 --- a/native_client/definitions.mk +++ b/native_client/definitions.mk @@ -30,8 +30,16 @@ CXXFLAGS := LDFLAGS := SOX_CFLAGS := `pkg-config --cflags sox` ifeq ($(OS),Linux) +MAGIC_LINK_LZMA := $(shell objdump -tTC /usr/lib/`uname -m`-linux-gnu/libmagic.so | grep lzma | grep '*UND*' | wc -l) +ifneq ($(MAGIC_LINK_LZMA),0) +MAYBE_LINK_LZMA := -llzma +endif # MAGIC_LINK_LZMA +MAGIC_LINK_BZ2 := $(shell objdump -tTC /usr/lib/`uname -m`-linux-gnu/libmagic.so | grep BZ2 | grep '*UND*' | wc -l) +ifneq ($(MAGIC_LINK_BZ2),0) +MAYBE_LINK_BZ2 := -lbz2 +endif # MAGIC_LINK_BZ2 SOX_CFLAGS += -fopenmp -SOX_LDFLAGS := -Wl,-Bstatic `pkg-config --static --libs sox` -lgsm `pkg-config --static --libs libpng | cut -d' ' -f1` -lz -lmagic -lltdl -Wl,-Bdynamic -ldl +SOX_LDFLAGS := -Wl,-Bstatic `pkg-config --static --libs sox` -lgsm `pkg-config --static --libs libpng | cut -d' ' -f1` -lz -lmagic $(MAYBE_LINK_LZMA) $(MAYBE_LINK_BZ2) -lltdl -Wl,-Bdynamic -ldl else ifeq ($(OS),Darwin) LIBSOX_PATH := $(shell echo `pkg-config --libs-only-L sox | sed -e 's/^-L//'`/lib`pkg-config --libs-only-l sox | sed -e 's/^-l//'`.dylib) LIBOPUSFILE_PATH := $(shell echo `pkg-config --libs-only-L opusfile | sed -e 's/^-L//'`/lib`pkg-config --libs-only-l opusfile | sed -e 's/^-l//'`.dylib)