85 lines
2.7 KiB
Ruby
85 lines
2.7 KiB
Ruby
class Libpq < Formula
|
|
desc "Postgres C API library"
|
|
homepage "https://www.postgresql.org/docs/14/libpq.html"
|
|
url "https://ftp.postgresql.org/pub/source/v14.1/postgresql-14.1.tar.bz2"
|
|
sha256 "4d3c101ea7ae38982f06bdc73758b53727fb6402ecd9382006fa5ecc7c2ca41f"
|
|
license "PostgreSQL"
|
|
|
|
livecheck do
|
|
formula "postgresql"
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_monterey: "df5750dc70c75e87ce8c56cee8a6e69e235a7174bce2690e28d6acd334d35af3"
|
|
sha256 arm64_big_sur: "2460f75b48fc53f44f713d5ed25d467640a4748a718be493686ebadab3edb642"
|
|
sha256 monterey: "532a3f3f7adc2626d9d61cb2a9a2a3361a6786b877285dbd94b345af4c59b100"
|
|
sha256 big_sur: "f59b9bbc8109a4ae60356c487f5b0d719a3344a576f4416a5accaa5a10cb701d"
|
|
sha256 catalina: "c368ca974a8ada78aa6d9a46947e235d03b10f7ee75e1686acfc3129400f8c7f"
|
|
sha256 x86_64_linux: "4b005f6761a252304c2ff5934a59570c78e912b37df7813869e00a3ac0ff62b8"
|
|
end
|
|
|
|
keg_only "conflicts with postgres formula"
|
|
|
|
# GSSAPI provided by Kerberos.framework crashes when forked.
|
|
# See https://github.com/Homebrew/homebrew-core/issues/47494.
|
|
depends_on "krb5"
|
|
|
|
depends_on "openssl@1.1"
|
|
|
|
on_linux do
|
|
depends_on "readline"
|
|
end
|
|
|
|
def install
|
|
system "./configure", "--disable-debug",
|
|
"--prefix=#{prefix}",
|
|
"--with-gssapi",
|
|
"--with-openssl",
|
|
"--libdir=#{opt_lib}",
|
|
"--includedir=#{opt_include}"
|
|
dirs = %W[
|
|
libdir=#{lib}
|
|
includedir=#{include}
|
|
pkgincludedir=#{include}/postgresql
|
|
includedir_server=#{include}/postgresql/server
|
|
includedir_internal=#{include}/postgresql/internal
|
|
]
|
|
system "make"
|
|
system "make", "-C", "src/bin", "install", *dirs
|
|
system "make", "-C", "src/include", "install", *dirs
|
|
system "make", "-C", "src/interfaces", "install", *dirs
|
|
system "make", "-C", "src/common", "install", *dirs
|
|
system "make", "-C", "src/port", "install", *dirs
|
|
system "make", "-C", "doc", "install", *dirs
|
|
end
|
|
|
|
test do
|
|
(testpath/"libpq.c").write <<~EOS
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <libpq-fe.h>
|
|
|
|
int main()
|
|
{
|
|
const char *conninfo;
|
|
PGconn *conn;
|
|
|
|
conninfo = "dbname = postgres";
|
|
|
|
conn = PQconnectdb(conninfo);
|
|
|
|
if (PQstatus(conn) != CONNECTION_OK) // This should always fail
|
|
{
|
|
printf("Connection to database attempted and failed");
|
|
PQfinish(conn);
|
|
exit(0);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
EOS
|
|
system ENV.cc, "libpq.c", "-L#{lib}", "-I#{include}", "-lpq", "-o", "libpqtest"
|
|
assert_equal "Connection to database attempted and failed", shell_output("./libpqtest")
|
|
end
|
|
end
|