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 <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2019-08-30 13:47:52 +02:00 committed by Rusty Russell
parent 27790832a5
commit 62dc8dc110
2 changed files with 19 additions and 0 deletions

View file

@ -201,6 +201,11 @@ else
LDLIBS = -L/usr/local/lib -lm -lgmp -lsqlite3 -lz $(COVFLAGS) LDLIBS = -L/usr/local/lib -lm -lgmp -lsqlite3 -lz $(COVFLAGS)
endif 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 default: all-programs all-test-programs
ccan/config.h: config.vars configure ccan/tools/configurator/configurator.c ccan/config.h: config.vars configure ccan/tools/configurator/configurator.c

14
configure vendored
View file

@ -273,6 +273,20 @@ int main(void)
return 0; return 0;
} }
/*END*/ /*END*/
var=HAVE_POSTGRES
desc=postgres
style=DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE
link=-lpq
code=
#include <postgresql/libpq-fe.h>
#include <stdio.h>
int main(void)
{
printf("libpq version %d\n", PQlibVersion());
return 0;
}
/*END*/
var=HAVE_GCC var=HAVE_GCC
desc=compiler is GCC desc=compiler is GCC
style=OUTSIDE_MAIN style=OUTSIDE_MAIN