You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by pa...@apache.org on 2023/11/08 19:14:07 UTC
(arrow-adbc) branch main updated: chore(r/adbcpostgresql): Improve configure script using pg_config (#1271)
This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 20b71b45 chore(r/adbcpostgresql): Improve configure script using pg_config (#1271)
20b71b45 is described below
commit 20b71b45a0efd9915f2090873accd17c72d6971b
Author: Dewey Dunnington <de...@voltrondata.com>
AuthorDate: Wed Nov 8 15:14:01 2023 -0400
chore(r/adbcpostgresql): Improve configure script using pg_config (#1271)
Closes #1268.
The configure script now falls back on `pg_config`. Barring an
intervention like setting the PKG_CONFIG_PATH in advance, this method
gets used on MacOS M1 (libpq installed via homebrew) and archlinux. I
also checked recent ubuntu, fedora, and alpine, all of which appear to
use pkg-config to pick up the include/libs location.
---
r/adbcpostgresql/configure | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/r/adbcpostgresql/configure b/r/adbcpostgresql/configure
index 2369855c..a08dfc91 100755
--- a/r/adbcpostgresql/configure
+++ b/r/adbcpostgresql/configure
@@ -22,36 +22,46 @@
# ADBC repo into this package. If the file doesn't exist, we're installing
# from a pre-built tarball.
if [ -f bootstrap.R ]; then
- $R_HOME/bin/Rscript bootstrap.R
+ "$R_HOME/bin/Rscript" bootstrap.R
fi
# Include and library flags
+PKG_CPPFLAGS="$PKG_CPPFLAGS"
PKG_LIBS="$PKG_LIBS"
# Check for pkg-config
HAS_PKG_CONFIG=""
-pkg-config libpq --exists
-if [ $? -eq 0 ]; then
+if pkg-config libpq --exists >/dev/null 2>&1 ; then
HAS_PKG_CONFIG=true
fi
+# Check for pg_config
+HAS_PG_CONFIG=""
+if pg_config >/dev/null 2>&1 ; then
+ HAS_PG_CONFIG=true
+fi
+
echo "Checking for --configure-vars INCLUDE_DIR or LIB_DIR"
if [ "$INCLUDE_DIR" ] || [ "$LIB_DIR" ]; then
echo "Found --configure-vars INCLUDE_DIR and/or LIB_DIR"
PKG_CPPFLAGS="-I$INCLUDE_DIR $PKG_CPPFLAGS"
PKG_LIBS="-L$LIB_DIR $PKG_LIBS"
elif [ ! -z "$HAS_PKG_CONFIG" ]; then
- echo "Using pkg-config libpq"
+ echo "Using pkg-config libpq to locate libpq headers/libs"
PKG_CPPFLAGS="`pkg-config libpq --cflags` $PKG_CPPFLAGS"
- PKG_LIBS="`pkg-config libpq --libs` -lpq $PKG_LIBS"
+ PKG_LIBS="`pkg-config libpq --libs` $PKG_LIBS"
+elif [ ! -z "$HAS_PG_CONFIG" ]; then
+ echo "Using pg_config to locate libpq headers/libs"
+ PKG_CPPFLAGS="-I`pg_config --includedir` $PKG_CPPFLAGS"
+ PKG_LIBS="-L`pg_config --libdir` -lpq $PKG_LIBS"
else
- echo "INCLUDE_DIR/LIB_DIR and pkg-config not found; trying PKG_LIBS=-lpq"
+ echo "INCLUDE_DIR/LIB_DIR, pkg-config, and pg_config not found; trying PKG_LIBS=-lpq"
PKG_LIBS="-lpq"
fi
echo "Testing R CMD SHLIB with $PKG_CPPFLAGS $PKG_LIBS"
PKG_CPPFLAGS="$PKG_CPPFLAGS" PKG_LIBS="$PKG_LIBS" \
- $R_HOME/bin/R CMD SHLIB tools/test.c -o compile_test >compile_test.log 2>&1
+ "$R_HOME/bin/R" CMD SHLIB tools/test.c -o compile_test >compile_test.log 2>&1
if [ $? -ne 0 ]; then
echo "Test compile failed"