configure.ac: rewrite PostgreSQL detection using pg_config #2018
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Copy of nagios-plugins/nagios-plugins#787 :)
PostgreSQL installs a pg_config program that spits out its "include" and "library" paths when called with --includedir and --libdir, respectively. Using this we can simplify the detection of PostgreSQL, since in theory the problem is reduced to that of finding pg_config.
This commit replaces the existing PostgreSQL detection with a more straightforward search for pg_config. The change is backwards- compatible, in the sense that --with-pgsql=foo will still find the postgres installation in "foo," except now it will do so through foo/bin/pg_config rather than foo/include and foo/lib.
This solves a rare problem: on systems where only one version of postgres is allowed, or on systems where multiple versions exist but a "default" version can be chosen, the most likely path for postgres is --with-pgsql=/usr. With the current implementation, this leads to -I/usr/include being added to CPPFLAGS, which is fine, and -L/usr/lib being added to LDFLAGS, which is not. On some of those same systems, /usr/lib is for 32-bit libraries while /usr/lib64 is the "normal" (64-bit) library path. So as a result of detecting postgres under /usr, the linker is pointed to the wrong set of libraries. This is known to crash lld (the LLVM linker).