2011-03-10 05:11:03 +00:00
|
|
|
class BerkeleyDb < Formula
|
2015-05-19 00:00:59 +00:00
|
|
|
desc "High performance key/value database"
|
2015-08-03 12:55:31 +00:00
|
|
|
homepage "https://www.oracle.com/technology/products/berkeley-db/index.html"
|
2015-08-13 16:54:29 +00:00
|
|
|
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
|
|
|
|
|
2015-08-03 12:55:31 +00:00
|
|
|
option "with-java", "Compile with Java support."
|
2015-08-13 16:54:29 +00:00
|
|
|
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
|
2013-05-26 23:28:01 +00:00
|
|
|
# --enable-compat185 is necessary because our build shadows
|
|
|
|
# the system berkeley db 1.x
|
2013-02-11 01:33:14 +00:00
|
|
|
args = %W[
|
|
|
|
--disable-debug
|
|
|
|
--prefix=#{prefix}
|
|
|
|
--mandir=#{man}
|
|
|
|
--enable-cxx
|
2013-05-26 23:28:01 +00:00
|
|
|
--enable-compat185
|
2013-02-11 01:33:14 +00:00
|
|
|
]
|
2014-03-06 20:40:26 +00:00
|
|
|
args << "--enable-java" if build.with? "java"
|
2015-08-13 16:54:29 +00:00
|
|
|
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
|
2015-08-03 12:55:31 +00:00
|
|
|
cd "build_unix" do
|
2010-10-31 19:19:28 +00:00
|
|
|
system "../dist/configure", *args
|
2015-08-03 12:55:31 +00:00
|
|
|
system "make", "install"
|
2009-12-21 17:53:21 +00:00
|
|
|
|
|
|
|
# use the standard docs location
|
|
|
|
doc.parent.mkpath
|
2015-08-03 12:55:31 +00:00
|
|
|
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";
|
2016-10-02 05:53:52 +00:00
|
|
|
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
|