summaryrefslogtreecommitdiff
path: root/build-postgresql
diff options
context:
space:
mode:
Diffstat (limited to 'build-postgresql')
-rwxr-xr-xbuild-postgresql23
1 files changed, 23 insertions, 0 deletions
diff --git a/build-postgresql b/build-postgresql
new file mode 100755
index 0000000..fb15976
--- /dev/null
+++ b/build-postgresql
@@ -0,0 +1,23 @@
+# -*- sh -*-
+
+# Determine if pkg-config exists and knows about libpq, otherwise
+# fall back on pg_config to determine compiler and linker flags.
+if pkg-config --exists libpq >/dev/null 2>/dev/null; then
+ CFLAGS="`pkg-config --cflags libpq`"
+ LDFLAGS="`pkg-config --libs libpq`"
+else
+ CFLAGS="-I`pg_config --includedir`"
+ LDFLAGS="-L`pg_config --libdir` -Wl,-rpath `pg_config --libdir` -lpq"
+fi
+
+known_features="escape-identifier connectdb-params diag-query-position diag-schema-info"
+
+feature_flags=""
+for feature in $known_features; do
+ if "$CHICKEN_CSC" -C "$CFLAGS" -L "$LDFLAGS" "feature-tests/$feature.c" >/dev/null 2>/dev/null; then
+ feature_flags="$feature_flags -Dhas-$feature"
+ fi
+ rm -f feature-tests/$feature.o feature-tests/$feature
+done
+
+"$CHICKEN_CSC" $feature_flags -C "$CFLAGS" -L "$LDFLAGS" "$@"