From ca170bcced750629ef65e66c6a5b1642cb3ddde0 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 15 Jun 2016 09:06:50 -0400 Subject: [PATCH 1/3] 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 From 7526080ac6f1c08584688ac568da9ce25024cf59 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 15 Jun 2016 09:26:20 -0400 Subject: [PATCH 2/3] Use msgpack_pack_v4raw(_body) with new msgpack-c versions In msgpack-c's 1.0.0 release, the code was changed to be compatible with the v5 msgpack spec, specifically separating out the STR and BIN types as replacements for the old RAW type. While the STR type is likely the right replacement type to use, it does introduce a str 8 variant that wasn't present for the old RAW type. For better compatibility, the msgpack_pack_v4raw functions were added to directly map to the old functionality. Signed-off-by: James McCoy --- formats/msgpack.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/formats/msgpack.c b/formats/msgpack.c index dc1ab0c..a3abc8b 100644 --- a/formats/msgpack.c +++ b/formats/msgpack.c @@ -8,6 +8,18 @@ #include #include +/* msgpack-c versions >= 1.0 changed to support the v5 msgpack spec. + * As part of doing this, the (un)pack_raw functions were replaced with + * more explicit (un)pack_str and (un)pack_bin. 1.2.0 introduced the + * (un)pack_v4raw functions to retain compatibility. + */ +#if defined(MSGPACK_VERSION_MAJOR) && defined(MSGPACK_VERSION_MINOR) \ + && MSGPACK_VERSION_MAJOR > 1 \ + || (MSGPACK_VERSION_MAJOR == 1 && MSGPACK_VERSION_MINOR >= 2) +#define msgpack_pack_raw msgpack_pack_v4raw +#define msgpack_pack_raw_body msgpack_pack_v4raw_body +#endif + struct msg_out { char *p; size_t sz; From 2a8908bdcf89b1cc8a332033bc9f8971b82438a3 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 21 Jul 2016 23:30:32 -0400 Subject: [PATCH 3/3] Find libmsgpackc in Multi-Arch library paths The msgpack library may be present in /usr/lib or /usr/lib/$arch, but only the former is being searched. Check both places and fix the library name to use the C lib (libmsgpackc) rather than the C++ lib (libmsgpack). Signed-off-by: James McCoy --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 40a7787..11bd9cd 100644 --- a/Makefile +++ b/Makefile @@ -14,11 +14,11 @@ ifneq ($(findstring yes,$(shell pkg-config --exists msgpack && echo yes)),) 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) + MSGPACK_LIB=$(shell ls /usr/lib/libmsgpackc.so /usr/lib/*/libmsgpackc.so 2>/dev/null) ifneq ($(strip $(MSGPACK_LIB)),) FORMAT_OBJS += formats/msgpack.o CFLAGS += -DMSGPACK=1 - LDFLAGS += -lmsgpack + LDFLAGS += -lmsgpackc endif endif