Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure: Use pg_config to locate the library location too #3995

Merged
merged 2 commits into from
Aug 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ endif

# If we have the postgres client library we need to link against it as well
ifeq ($(HAVE_POSTGRES),1)
LDLIBS += -lpq
LDLIBS += $(POSTGRES_LDLIBS)
endif

default: show-flags all-programs all-test-programs doc-all
Expand Down
16 changes: 13 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ CONFIG_VAR_FILE=config.vars
CONFIG_HEADER=ccan/config.h
BASE_WARNFLAGS="-Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror"

# You can set PG_CONFIG in the environment to direct configure to call
# a specific 'pg_config' binary. If you set it to an empty string, then
# PostgreSQL support will be explicitly disabled, even if a 'pg_config'
# binary exists in your PATH. If you leave it unset, then the following
# line enables the automagic detection that most users want.
: ${PG_CONFIG=pg_config}

usage_with_default()
{
if [ $# = 4 ]; then
Expand Down Expand Up @@ -230,8 +237,10 @@ fi
require 'python3-mako' "You need the mako module for python3: see doc/INSTALL.md" python3 -c 'import mako'

POSTGRES_INCLUDE=""
if command -v pg_config 2> /dev/null; then
POSTGRES_INCLUDE="-I$(pg_config --includedir)"
POSTGRES_LDLIBS=""
if command -v "${PG_CONFIG}" >/dev/null; then
POSTGRES_INCLUDE="-I$("${PG_CONFIG}" --includedir)"
POSTGRES_LDLIBS="-L$("${PG_CONFIG}" --libdir) -lpq"
fi

rm -f $CONFIG_VAR_FILE.$$
Expand Down Expand Up @@ -290,7 +299,7 @@ int main(void)
var=HAVE_POSTGRES
desc=postgres
style=DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE
link=-lpq
link=$POSTGRES_LDLIBS
code=
#include <libpq-fe.h>
#include <stdio.h>
Expand Down Expand Up @@ -360,6 +369,7 @@ add_var CWARNFLAGS "$CWARNFLAGS"
add_var CDEBUGFLAGS "$CDEBUGFLAGS"
add_var COPTFLAGS "$COPTFLAGS"
add_var POSTGRES_INCLUDE "$POSTGRES_INCLUDE"
add_var POSTGRES_LDLIBS "$POSTGRES_LDLIBS"
add_var VALGRIND "$VALGRIND"
add_var DEVELOPER "$DEVELOPER" $CONFIG_HEADER
add_var EXPERIMENTAL_FEATURES "$EXPERIMENTAL_FEATURES" $CONFIG_HEADER
Expand Down