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

chore(r/adbcpostgresql): Improve configure script using pg_config #1271

Merged
merged 3 commits into from
Nov 8, 2023
Merged
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
24 changes: 17 additions & 7 deletions r/adbcpostgresql/configure
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading