homebrew-core/Formula/berkeley-db@4.rb
2018-09-30 11:27:59 +02:00

76 lines
2.3 KiB
Ruby

class BerkeleyDbAT4 < Formula
desc "High performance key/value database"
homepage "https://www.oracle.com/technology/products/berkeley-db/index.html"
url "https://download.oracle.com/berkeley-db/db-4.8.30.tar.gz"
sha256 "e0491a07cdb21fb9aa82773bbbedaeb7639cbd0e7f96147ab46141e0045db72a"
bottle do
cellar :any
rebuild 1
sha256 "cb0243107a7db2e935f10533d1e9b34f12681861125e208463b240572b86507d" => :mojave
sha256 "03f1fc49446d69741f764d7e7388a6006fc5cdb2a0a710b1389b5b662b25e9b7" => :high_sierra
sha256 "93b2d7980cba62914bcce0a631a8f28212a17e2cfdce1f41db3d47ec3da37fde" => :sierra
end
keg_only :versioned_formula
# Fix build with recent clang
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/4c55b1/berkeley-db%404/clang.diff"
sha256 "86111b0965762f2c2611b302e4a95ac8df46ad24925bbb95a1961542a1542e40"
end
def install
# BerkeleyDB dislikes parallel builds
ENV.deparallelize
args = %W[
--disable-debug
--prefix=#{prefix}
--mandir=#{man}
--enable-cxx
]
# BerkeleyDB requires you to build everything from the build_unix subdirectory
cd "build_unix" do
system "../dist/configure", *args
system "make", "install"
# use the standard docs location
doc.parent.mkpath
mv prefix+"docs", doc
end
end
test do
(testpath/"test.cpp").write <<~EOS
#include <assert.h>
#include <string.h>
#include <db_cxx.h>
int main() {
Db db(NULL, 0);
assert(db.open(NULL, "test.db", NULL, DB_BTREE, DB_CREATE, 0) == 0);
const char *project = "Homebrew";
const char *stored_description = "The missing package manager for macOS";
Dbt key(const_cast<char *>(project), strlen(project) + 1);
Dbt stored_data(const_cast<char *>(stored_description), strlen(stored_description) + 1);
assert(db.put(NULL, &key, &stored_data, DB_NOOVERWRITE) == 0);
Dbt returned_data;
assert(db.get(NULL, &key, &returned_data, 0) == 0);
assert(strcmp(stored_description, (const char *)(returned_data.get_data())) == 0);
assert(db.close(0) == 0);
}
EOS
flags = %W[
-I#{include}
-L#{lib}
-ldb_cxx
]
system ENV.cxx, "test.cpp", "-o", "test", *flags
system "./test"
assert_predicate testpath/"test.db", :exist?
end
end