-
-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The formula is based on libpq formula with version 15.4
- Loading branch information
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
class LibpqAT15 < Formula | ||
desc "Postgres C API library" | ||
homepage "https://www.postgresql.org/docs/15/libpq.html" | ||
url "https://ftp.postgresql.org/pub/source/v15.8/postgresql-15.8.tar.bz2" | ||
sha256 "4403515f9a69eeb3efebc98f30b8c696122bfdf895e92b3b23f5b8e769edcb6a" | ||
license "PostgreSQL" | ||
|
||
livecheck do | ||
url "https://ftp.postgresql.org/pub/source/" | ||
regex(%r{href=["']?v?(\d+(?:\.\d+)+)/?["' >]}i) | ||
end | ||
|
||
keg_only "conflicts with postgres formula" | ||
keg_only :versioned_formula | ||
|
||
# GSSAPI provided by Kerberos.framework crashes when forked. | ||
# See https://github.com/Homebrew/homebrew-core/issues/47494. | ||
depends_on "krb5" | ||
|
||
depends_on "openssl@3" | ||
|
||
uses_from_macos "zlib" | ||
|
||
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 |