<commit_before>require 'formula'

class Couchdb <Formula
  @url='http://apache.abdaal.com/couchdb/0.10.1/apache-couchdb-0.10.1.tar.gz'
  @homepage='http://couchdb.apache.org/'
  @md5='a34dae8bf402299e378d7e8c13b7ba46'

  depends_on 'spidermonkey'
  depends_on 'icu4c'
  depends_on 'erlang'

  def install
    system "./configure", "--prefix=#{prefix}",
                          "--localstatedir=#{var}",
                          "--sysconfdir=#{etc}",
                          "--with-erlang=#{HOMEBREW_PREFIX}/lib/erlang/usr/include"
    system "make"
    system "make install"

    couchjs = "#{prefix}/lib/couchdb/bin/couchjs"
    system "chmod 755 #{couchjs}"

    (var+'lib'+'couchdb').mkpath
    (var+'log'+'couchdb').mkpath
  end
end<commit_msg>Force Couchdb to find Spidermonkey and Erlang<commit_after>require 'formula'

class Couchdb <Formula
  @url='http://apache.abdaal.com/couchdb/0.10.1/apache-couchdb-0.10.1.tar.gz'
  @homepage='http://couchdb.apache.org/'
  @md5='a34dae8bf402299e378d7e8c13b7ba46'

  depends_on 'spidermonkey'
  depends_on 'icu4c'
  depends_on 'erlang'

  def patches; DATA end

  def install
    system "./configure", "--prefix=#{prefix}",
                          "--localstatedir=#{var}",
                          "--sysconfdir=#{etc}"
    system "make"
    system "make install"

    (prefix+"lib/couchdb/bin/couchjs").chmod 0755
    (var+'lib'+'couchdb').mkpath
    (var+'log'+'couchdb').mkpath
  end
end


# this patch because couchdb doesn't try to find where spidermonkey or erlang
# are installed it just adds a bunch of paths and hopes for the best. However
# for users who install Homebrew somewhere that is non standard, this breaks
__END__
diff --git a/configure b/configure
index edb6438..472cd2c 100755
--- a/configure
+++ b/configure
@@ -11240,10 +11240,7 @@ if test "${with_erlang+set}" = set; then :
 
 else
 
-    ERLANG_FLAGS="-I${libdir}/erlang/usr/include"
-    ERLANG_FLAGS="$ERLANG_FLAGS -I/usr/lib/erlang/usr/include"
-    ERLANG_FLAGS="$ERLANG_FLAGS -I/usr/local/lib/erlang/usr/include"
-    ERLANG_FLAGS="$ERLANG_FLAGS -I/opt/local/lib/erlang/usr/include"
+    ERLANG_FLAGS="-I$(dirname $(dirname $(which erl)))/lib/erlang/usr/include"
 
 fi
 
@@ -11257,13 +11257,7 @@ if test "${with_js_include+set}" = set; then :
 
 else
 
-    JS_FLAGS="-I/usr/include"
-    JS_FLAGS="$JS_FLAGS -I/usr/include/js"
-    JS_FLAGS="$JS_FLAGS -I/usr/include/mozjs"
-    JS_FLAGS="$JS_FLAGS -I/usr/local/include"
-    JS_FLAGS="$JS_FLAGS -I/opt/local/include"
-    JS_FLAGS="$JS_FLAGS -I/usr/local/include/js"
-    JS_FLAGS="$JS_FLAGS -I/opt/local/include/js"
+    JS_FLAGS="-I`js-config --includedir`/js"
 
 fi
 
{'fraction_non_alphanumeric': 0.1612781954887218, 'fraction_numerical': 0.039473684210526314, 'mean_word_length': 3.1064814814814814, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4467009', 'n_tokens_mistral': 1072, 'n_tokens_neox': 999, 'n_words': 171}