From ca170bcced750629ef65e66c6a5b1642cb3ddde0 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 15 Jun 2016 09:06:50 -0400 Subject: [PATCH] Use pkg-config to find msgpack library when available Since 0.5.8, msgpack-c has provided a pkg-config file. If it's installed, use pkg-config to get the relevant CFLAGS/LDFLAGS. Signed-off-by: James McCoy --- Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e29ad4b..40a7787 100644 --- a/Makefile +++ b/Makefile @@ -9,11 +9,17 @@ CFLAGS ?= -O0 -ggdb -Wall -Wextra -I. -Ijansson/src -Ihttp-parser LDFLAGS ?= -levent -pthread # check for MessagePack -MSGPACK_LIB=$(shell ls /usr/lib/libmsgpack.so 2>/dev/null) -ifneq ($(strip $(MSGPACK_LIB)),) +ifneq ($(findstring yes,$(shell pkg-config --exists msgpack && echo yes)),) FORMAT_OBJS += formats/msgpack.o - CFLAGS += -DMSGPACK=1 - LDFLAGS += -lmsgpack + CFLAGS += -DMSGPACK=1 $(shell pkg-config --cflags msgpack) + LDFLAGS += $(shell pkg-config --libs msgpack) +else + MSGPACK_LIB=$(shell ls /usr/lib/libmsgpack.so 2>/dev/null) + ifneq ($(strip $(MSGPACK_LIB)),) + FORMAT_OBJS += formats/msgpack.o + CFLAGS += -DMSGPACK=1 + LDFLAGS += -lmsgpack + endif endif