From ba5da32f2aec29bf3b81f58698d412a15b34f243 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 15 Mar 2019 13:58:07 +0100 Subject: [PATCH] TT#55204 Support building against mariadb 10.3.13 Instead of hardcoding -I/usr/include/mysql for CFLAGS and -lmysqlclient for LDFLAGS, let's use mariadb_config if available (e.g. on Debian/buster), try mysql_config otherwise (e.g. on Debian/stretch) or if neither of them is available, fallback to -I/usr/include/mysql + -lmysqlclient. No longer include `m_string.h`, it was moved towards /usr/include/mariadb/server/m_string.h and is no longer compatible when used as such: | /usr/include/mariadb/server/m_string.h:89:23: error: unknown type name 'uchar'; did you mean 'char'? | extern void bmove_upp(uchar *dst,const uchar *src,size_t len); Also no longer use libmysqlclient15-dev as alternative Build-Depend, it's not available in neither stretch nor buster. While at it drop include for my_global.h, since it shouldn't be included anymore (and it doesn't seem to be relevant for us, compiling fine as-is on Debian/stretch and Debian/buster): | /usr/include/mariadb/my_global.h:3:2: warning: #warning This file should not be included by clients, include only [-Wcpp] Change-Id: I74a75ea24f72880adb8117ae5808095f03bc0edb --- Makefile | 19 +++++++++++++++++-- debian/control | 2 +- medmysql.c | 2 -- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 1c3f26b..9ccc974 100644 --- a/Makefile +++ b/Makefile @@ -7,14 +7,29 @@ CC := gcc CPPFLAGS := -DMEDIATOR_VERSION="\"$(VERSION)\"" GLIB_CFLAGS := $(shell pkg-config glib-2.0 --cflags) -CFLAGS := -I/usr/include/mysql $(GLIB_CFLAGS) -g -Wall -Wextra -O2 -D_GNU_SOURCE + +# mariadb/mysql support +ifneq ($(shell which mariadb_config),) +MYSQL_CFLAGS := $(shell mariadb_config --cflags) +MYSQL_LDFLAGS := $(shell mariadb_config --libs) +else ifneq ($(shell which mysql_config),) +MYSQL_CFLAGS := $(shell mysql_config --cflags) +MYSQL_LDFLAGS := $(shell mysql_config --libs) +else +MYSQL_CFLAGS := -I/usr/include/mysql +MYSQL_LDFLAGS := -lmysqlclient +endif + +CFLAGS := $(GLIB_CFLAGS) -g -Wall -Wextra -O2 -D_GNU_SOURCE +CFLAGS += $(MYSQL_CFLAGS) #CFLAGS += -DWITH_TIME_CALC CFLAGS += $(shell pkg-config json-c --cflags) CFLAGS += $(shell pkg-config hiredis --cflags) CFLAGS += $(shell pkg-config libsystemd --cflags) GLIB_LDFLAGS := $(shell pkg-config glib-2.0 --libs) -LDFLAGS := $(GLIB_LDFLAGS) -lmysqlclient +LDFLAGS := $(GLIB_LDFLAGS) +LDFLAGS += $(MYSQL_LDFLAGS) LDFLAGS += $(shell pkg-config json-c --libs) LDFLAGS += $(shell pkg-config hiredis --libs) LDFLAGS += $(shell pkg-config libsystemd --libs) diff --git a/debian/control b/debian/control index dc3ceb7..9ab5d9f 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: Sipwise Development Team Build-Depends: debhelper (>= 10), - default-libmysqlclient-dev | libmysqlclient15-dev, + default-libmysqlclient-dev, libglib2.0-dev, libhiredis-dev, libjson-c-dev, diff --git a/medmysql.c b/medmysql.c index c90d943..4cf5385 100644 --- a/medmysql.c +++ b/medmysql.c @@ -1,5 +1,3 @@ -#include -#include #include #include #include