56 lines
1.7 KiB
Ruby
56 lines
1.7 KiB
Ruby
class Libpq < Formula
|
|
desc "Postgres C API library"
|
|
homepage "https://www.postgresql.org/docs/11/static/libpq.html"
|
|
url "https://ftp.postgresql.org/pub/source/v11.4/postgresql-11.4.tar.bz2"
|
|
sha256 "02802ddffd1590805beddd1e464dd28a46a41a5f1e1df04bab4f46663195cc8b"
|
|
|
|
bottle do
|
|
sha256 "011304ddabd15d32d88f50622c9dab9fe9d1d809ae17509093023d2b530355e0" => :mojave
|
|
sha256 "858184cb89c17a6f866279c03188324874897cb11d6bbdee108c9d46ae2747f2" => :high_sierra
|
|
sha256 "1215c53749541b90b5b39838ce7df7ae1eb0f80cd37abbb3977ef8bb6031e257" => :sierra
|
|
end
|
|
|
|
keg_only "conflicts with postgres formula"
|
|
|
|
depends_on "openssl"
|
|
|
|
def install
|
|
system "./configure", "--disable-debug",
|
|
"--prefix=#{prefix}",
|
|
"--with-openssl"
|
|
system "make"
|
|
system "make", "-C", "src/bin", "install"
|
|
system "make", "-C", "src/include", "install"
|
|
system "make", "-C", "src/interfaces", "install"
|
|
system "make", "-C", "doc", "install"
|
|
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
|