From 62dc8dc110ce64fdd32eaf56026afcda59ac2319 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 30 Aug 2019 13:47:52 +0200 Subject: [PATCH] make: Add configuration detection and linking of libpq If we have the client library for postgres configure will define HAVE_POSTGRES the same way it already handled libsqlite3 an we start linking against it. Signed-off-by: Christian Decker --- Makefile | 5 +++++ configure | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Makefile b/Makefile index c6f03043b..6e05ee20c 100644 --- a/Makefile +++ b/Makefile @@ -201,6 +201,11 @@ else LDLIBS = -L/usr/local/lib -lm -lgmp -lsqlite3 -lz $(COVFLAGS) endif +# If we have the postgres client library we need to link against it as well +ifeq ($(HAVE_POSTGRES),1) +LDLIBS += -lpq +endif + default: all-programs all-test-programs ccan/config.h: config.vars configure ccan/tools/configurator/configurator.c diff --git a/configure b/configure index 1d22c4704..85066278c 100755 --- a/configure +++ b/configure @@ -273,6 +273,20 @@ int main(void) return 0; } /*END*/ +var=HAVE_POSTGRES +desc=postgres +style=DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE +link=-lpq +code= +#include +#include + +int main(void) +{ + printf("libpq version %d\n", PQlibVersion()); + return 0; +} +/*END*/ var=HAVE_GCC desc=compiler is GCC style=OUTSIDE_MAIN