From e9eed8bb86455e1a1737e6222cfe5fea633f78ec Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 22 Sep 2020 16:17:12 +0100 Subject: [PATCH] Better/faster detection for libmagic (when present) Signed-off-by: falkTX --- source/Makefile.mk | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/Makefile.mk b/source/Makefile.mk index 7f31e3326..226eccb5c 100644 --- a/source/Makefile.mk +++ b/source/Makefile.mk @@ -297,8 +297,12 @@ endif ifneq ($(WIN32),true) -# libmagic doesn't have a pkg-config file, so we need to call the compiler to test it -HAVE_LIBMAGIC = $(shell echo '\#include ' | $(CC) $(CFLAGS) -x c -w -c - -o .libmagic-tmp 2>/dev/null && echo true) +ifeq ($(shell $(PKG_CONFIG) --exists libmagic && echo true),true) +HAVE_LIBMAGIC = true +else +# old libmagic versions don't have a pkg-config file, so we need to call the compiler to test it +HAVE_LIBMAGIC = $(shell echo '\#include ' | $(CC) $(CFLAGS) -x c -w -c - -o /dev/null 2>/dev/null && echo true) +endif endif