homebrew-core/Formula/berkeley-db.rb

79 lines
2.6 KiB
Ruby
Raw Normal View History

2011-03-10 05:11:03 +00:00
class BerkeleyDb < Formula
desc "High performance key/value database"
homepage "https://www.oracle.com/technology/products/berkeley-db/index.html"
url "http://download.oracle.com/berkeley-db/db-6.1.26.tar.gz"
sha256 "dd1417af5443f326ee3998e40986c3c60e2a7cfb5bfa25177ef7cadb2afb13a6"
2010-10-31 19:19:28 +00:00
2014-02-24 15:11:24 +00:00
bottle do
cellar :any
2016-09-13 14:31:35 +00:00
sha256 "9aeac35b89e11e5b1eec4e5f17534523b64e05117471cb2121a58ca0f3bda5db" => :sierra
2015-09-21 13:04:04 +00:00
sha256 "70f4c1cea6a4c2f9454680988b73bb9fdc107307dafeec47e21a4539dce57b36" => :el_capitan
2015-08-14 01:41:18 +00:00
sha256 "3e4324500931e32e3a187f9790b4465efd4d249dc9ec03ff46b4209ed061e935" => :yosemite
sha256 "b2ba3aff83ee27a52115f47abc3c1767d124841ad342e63e433dfa36af064b36" => :mavericks
sha256 "8f5a87bc3336e01f8528ae8aaae24c83e8fa10e8f01ee65e8cac4af7d0786bf1" => :mountain_lion
2014-02-24 15:11:24 +00:00
end
option "with-java", "Compile with Java support."
option "with-sql", "Compile with SQL support."
deprecated_option "enable-sql" => "with-sql"
2009-09-24 02:54:00 +00:00
def install
# BerkeleyDB dislikes parallel builds
ENV.deparallelize
# --enable-compat185 is necessary because our build shadows
# the system berkeley db 1.x
args = %W[
--disable-debug
--prefix=#{prefix}
--mandir=#{man}
--enable-cxx
--enable-compat185
]
args << "--enable-java" if build.with? "java"
args << "--enable-sql" if build.with? "sql"
2010-10-31 19:19:28 +00:00
2009-09-24 02:54:00 +00:00
# BerkeleyDB requires you to build everything from the build_unix subdirectory
cd "build_unix" do
2010-10-31 19:19:28 +00:00
system "../dist/configure", *args
system "make", "install"
2009-12-21 17:53:21 +00:00
# use the standard docs location
doc.parent.mkpath
mv prefix/"docs", doc
2009-09-24 02:54:00 +00:00
end
end
2016-08-25 03:10:53 +00:00
test do
(testpath/"test.cpp").write <<-EOS.undent
#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";
2016-08-25 03:10:53 +00:00
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 (testpath/"test.db").exist?
end
2009-09-24 02:54:00 +00:00
end