diff --git a/Formula/berkeley-db4.rb b/Formula/berkeley-db@4.rb similarity index 59% rename from Formula/berkeley-db4.rb rename to Formula/berkeley-db@4.rb index 132c2f81071..3bbc0107705 100644 --- a/Formula/berkeley-db4.rb +++ b/Formula/berkeley-db@4.rb @@ -1,4 +1,4 @@ -class BerkeleyDb4 < Formula +class BerkeleyDbAT4 < 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-4.8.30.tar.gz" @@ -13,7 +13,7 @@ class BerkeleyDb4 < Formula sha256 "04fc8d3b03381d87b3852ac1756dd144a10e7ac47444fa3e81dec0fc8ea33d25" => :mountain_lion end - keg_only "BDB 4.8.30 is provided for software that doesn't compile against newer versions." + keg_only :versioned_formula # Fix build under Xcode 4.6 patch :DATA @@ -22,10 +22,12 @@ class BerkeleyDb4 < Formula # BerkeleyDB dislikes parallel builds ENV.deparallelize - args = ["--disable-debug", - "--prefix=#{prefix}", - "--mandir=#{man}", - "--enable-cxx"] + 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 @@ -37,6 +39,38 @@ class BerkeleyDb4 < Formula mv prefix+"docs", doc end end + + test do + (testpath/"test.cpp").write <<-EOS.undent + #include + #include + #include + 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(project), strlen(project) + 1); + Dbt stored_data(const_cast(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 end __END__ @@ -52,13 +86,13 @@ index 0034dcc..50b8b74 100644 + __atomic_compare_exchange_db((p), (o), (n)) static inline int __atomic_inc(db_atomic_t *p) { - int temp; + int temp; @@ -176,7 +176,7 @@ static inline int __atomic_dec(db_atomic_t *p) * http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html * which configure could be changed to use. */ -static inline int __atomic_compare_exchange( +static inline int __atomic_compare_exchange_db( - db_atomic_t *p, atomic_value_t oldval, atomic_value_t newval) + db_atomic_t *p, atomic_value_t oldval, atomic_value_t newval) { - atomic_value_t was; + atomic_value_t was; diff --git a/formula_renames.json b/formula_renames.json index 53e99f426cf..1247c55c0cc 100644 --- a/formula_renames.json +++ b/formula_renames.json @@ -10,6 +10,7 @@ "autoconf264": "autoconf@264", "automake112": "automake@112", "beanstalk": "beanstalkd", + "berkeley-db4": "berkeley-db@4", "cloog-ppl015": "cloog@0.15", "cloog018": "cloog", "commonmark": "cmark",