<commit_before>require 'brewkit'

class Spidermonkey <Formula  
  @url="http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz"
  @homepage='https://developer.mozilla.org/en/SpiderMonkey'
  @md5='5571134c3863686b623ebe4e6b1f6fe6'

  depends_on 'readline'
  depends_on 'nspr'

  def patches
    DATA
  end

  def install
    ENV.j1

    # Spidermonkey hardsets the CC and CCC environment variables to cc and g++
    # but homebrew uses compiler flags that aren't available in Apple's default cc (version 4.0.1)
    # instead use the compilers chosen by homebrew and set in the CC and CXX environment variables
    inreplace "src/config/Darwin.mk", 'CC = cc', "CC = #{ENV['CC']}"
    inreplace "src/config/Darwin.mk", 'CCC = g++', "CCC = #{ENV['CXX']}"

    # aparently this flag causes the build to fail for ivanvc on 10.5 with a
    # penryn (core 2 duo) CPU. So lets be cautious here and remove it.
    ENV['CFLAGS'] = ENV['CFLAGS'].gsub(/-msse[^\s]+/, '')

    Dir.chdir "src" do
      system "make JS_DIST=#{HOMEBREW_PREFIX} JS_THREADSAFE=1 DEFINES=-DJS_C_STRINGS_ARE_UTF8 -f Makefile.ref"
      system "make JS_DIST=#{prefix} -f Makefile.ref export"
      system "ranlib #{prefix}/lib/libjs.a"
    end
  end
end


__END__
--- a/src/jsprf.c	2009-07-26 12:32:01.000000000 -0700
+++ b/src/jsprf.c	2009-07-26 12:33:12.000000000 -0700
@@ -58,6 +58,8 @@
 */
 #ifdef HAVE_VA_COPY
 #define VARARGS_ASSIGN(foo, bar)        VA_COPY(foo,bar)
+#elif defined(va_copy)
+#define VARARGS_ASSIGN(foo, bar)        va_copy(foo,bar)
 #elif defined(HAVE_VA_LIST_AS_ARRAY)
 #define VARARGS_ASSIGN(foo, bar)        foo[0] = bar[0]<commit_msg>Make Spidermonkey work with Couchdb<commit_after>require 'brewkit'

class Spidermonkey <Formula  
  url "http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz"
  homepage 'https://developer.mozilla.org/en/SpiderMonkey'
  md5 '5571134c3863686b623ebe4e6b1f6fe6'

  depends_on 'readline'

  def patches
    DATA
  end

  def install
    ENV.j1

    # Spidermonkey hardsets the CC and CCC environment variables to cc and g++
    # but homebrew uses compiler flags that aren't available in Apple's default cc (version 4.0.1)
    # instead use the compilers chosen by homebrew and set in the CC and CXX environment variables
    inreplace "src/config/Darwin.mk", 'CC = cc', "CC = #{ENV['CC']}"
    inreplace "src/config/Darwin.mk", 'CCC = g++', "CCC = #{ENV['CXX']}"

    # aparently this flag causes the build to fail for ivanvc on 10.5 with a
    # penryn (core 2 duo) CPU. So lets be cautious here and remove it.
    ENV['CFLAGS'] = ENV['CFLAGS'].gsub(/-msse[^\s]+/, '')

    Dir.chdir "src" do
      system "make DEFINES=-DJS_C_STRINGS_ARE_UTF8 -f Makefile.ref"
      system "make JS_DIST='#{prefix}' -f Makefile.ref export"
      system "ranlib #{lib}/libjs.a"
    end
  end
end


__END__
--- a/src/jsprf.c	2009-07-26 12:32:01.000000000 -0700
+++ b/src/jsprf.c	2009-07-26 12:33:12.000000000 -0700
@@ -58,6 +58,8 @@
 */
 #ifdef HAVE_VA_COPY
 #define VARARGS_ASSIGN(foo, bar)        VA_COPY(foo,bar)
+#elif defined(va_copy)
+#define VARARGS_ASSIGN(foo, bar)        va_copy(foo,bar)
 #elif defined(HAVE_VA_LIST_AS_ARRAY)
 #define VARARGS_ASSIGN(foo, bar)        foo[0] = bar[0]
{'fraction_non_alphanumeric': 0.13612238526381518, 'fraction_numerical': 0.060880424601935684, 'mean_word_length': 3.493688639551192, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '1339693', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1209, 'n_words': 310}