-
Notifications
You must be signed in to change notification settings - Fork 902
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
configure: Use pg_config to locate the library location too #3995
Conversation
cf00196
to
feb4a28
Compare
Also, allow the pg_config binary to be specified through the PG_CONFIG environment variable, defaulting to 'pg_config' if unset. Explicitly setting PG_CONFIG to an empty string will forcibly disable PostgreSQL support, even if a PostgreSQL library is installed. Changelog-Fixed: build: On systems with multiple installed versions of the PostgreSQL client library, C-Lightning might link against the wrong version or fail to find the library entirely. `./configure` now uses `pg_config` to locate the library.
feb4a28
to
ace8fc2
Compare
configure
Outdated
if command -v pg_config 2> /dev/null; then | ||
POSTGRES_INCLUDE="-I$(pg_config --includedir)" | ||
POSTGRES_LDLIBS="" | ||
if command -v "${PG_CONFIG-pg_config}" >/dev/null; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, I fixed the redirection here. (command -v
prints to stdout, not stderr.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The above changes have the happy side-effect that setting
PG_CONFIG
to an empty string will now cause Configurator's test for PostgreSQL to fail, so C-Lightning will be built without PostgreSQL support, even if a PostgreSQL client library is present on the build system. (The Gentoo ebuild has been hacking the Configurator test code by inserting an#error
directive to force the test to fail when the user has requested that C-Lightning not support PostgreSQL. That hack is no longer necessary with the changes in this PR.)
This applies only to users explicitly setting it to an empty string, not the default behavior, correct? I.e., if the user has the libs installed and doesn't customize the PG_CONFIG
envvar, then postgresql support will be built in. Just want to make sure that that's still the default behavior :-)
configure
Outdated
if command -v "${PG_CONFIG-pg_config}" >/dev/null; then | ||
POSTGRES_INCLUDE="-I$("${PG_CONFIG-pg_config}" --includedir)" | ||
POSTGRES_LDLIBS="-L$("${PG_CONFIG-pg_config}" --libdir) -lpq" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could set the $PG_CONFIG
at the top of the script to avoid having to use the get-or-default construct here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've already left the computer for the night (going to bed), but I'll make this change within the day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to explicitly set it to empty if you want to forcibly disable PostgreSQL support even though you have the PostgreSQL library installed. If you leave |
(Actually you can set |
Excellent, thanks for putting my mind at ease :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack a29632d
On some systems (e.g., Gentoo), there can be multiple major versions of the PostgreSQL client library installed in parallel. There exists a separate
pg_config
andlibpq.so*
for each major version. This Pull Request adds support to C-Lightning's build system to allow the user to choose a specific version of the PostgreSQL client library to build and link against.Summary of proposed changes:
POSTGRES_LDLIBS
config variable, analogous to the existingPOSTGRES_INCLUDE
variable, and use it in place of-lpq
, both inMakefile
and in the Configurator script.configure
, allow the user to override the name ofpg_config
by setting thePG_CONFIG
environment variable. If unset, the default continues to bepg_config
, which preserves the existing behavior.PG_CONFIG
to an empty string will now cause Configurator's test for PostgreSQL to fail, so C-Lightning will be built without PostgreSQL support, even if a PostgreSQL client library is present on the build system. (The Gentoo ebuild has been hacking the Configurator test code by inserting an#error
directive to force the test to fail when the user has requested that C-Lightning not support PostgreSQL. That hack is no longer necessary with the changes in this PR.)