class Libpq < Formula desc "Postgres C API library" homepage "https://www.postgresql.org/docs/10/static/libpq.html" url "https://ftp.postgresql.org/pub/source/v10.4/postgresql-10.4.tar.bz2" sha256 "1b60812310bd5756c62d93a9f93de8c28ea63b0df254f428cd1cf1a4d9020048" bottle do sha256 "86701653028d7cdde8a18e4f11cbca42015cf004c0f7a1eac6fbf0ab1e928178" => :high_sierra sha256 "fd2d8807b4825523bafd26b5cb89dfc534632535fae310fb749f4c5528c5ddce" => :sierra sha256 "14f520810ec641b992b5f65894a3944942c17d72ece4b670274debc40f3dcc58" => :el_capitan 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