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.5/postgresql-11.5.tar.bz2" sha256 "7fdf23060bfc715144cbf2696cf05b0fa284ad3eb21f0c378591c6bca99ad180" bottle do sha256 "1a907a4d7efd94e4a144eed844ba3ba9960bcf9be91b4487b162a88c51a47859" => :mojave sha256 "1490874d3e2d69e815c93ec84d02f1bb41e93a866c8f1acf9f8e436be5ea5d1f" => :high_sierra sha256 "fdeda7b2483d3eb87c077a8ea80ca43c779eb1d2da75955f75401da2e5764765" => :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 #include #include 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