aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/groonga.rb
blob: 386e7ca998c9377ffa6d123072f553554783628b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
require "formula"

class Groonga < Formula
  homepage "http://groonga.org/"
  url "http://packages.groonga.org/source/groonga/groonga-4.0.8.tar.gz"
  sha1 "894bf426c79aaab6e3b1f19811db4634aecdc4c2"

  bottle do
    revision 1
    sha1 "d4b6e1efd8b37b8f4e39918e154c687ba0735152" => :yosemite
    sha1 "5cc89ff268fe2ba9a9129dcb0f59c992a9e6cfaf" => :mavericks
    sha1 "4f8bcf386795fc42f40526663597fb53b8b19a66" => :mountain_lion
  end

  depends_on "pkg-config" => :build
  depends_on "pcre"
  depends_on "msgpack"
  depends_on "mecab" => :optional
  depends_on "mecab-ipadic" if build.with? "mecab"
  depends_on "lz4" => :optional
  depends_on "openssl"

  depends_on "glib" if build.include? "enable-benchmark"

  option "enable-benchmark", "Enable benchmark program for developer use"

  # These patches are already merged into upstream.
  # Please remove next version of Groonga Formula.
  # pull #253 https://github.com/groonga/groonga/pull/253
  # fixed at: https://github.com/groonga/groonga/commit/c019cfbfbf5365c28ce727a46448aa6f77de8543
  # issue #254: https://github.com/groonga/groonga/issues/254
  # fixed at: https://github.com/groonga/groonga/commit/340085f132c640f03e32a7878f0bd31de9f74eaa
  # issue #264: https://github.com/groonga/groonga/issues/264
  # fixed at: https://github.com/groonga/groonga/commit/91207ecd816e873cdf7070ec7a1c5ae4870f7e6e
  patch :DATA

  def install
    args = %W[
      --prefix=#{prefix}
      --with-zlib
      --disable-zeromq
      --with-mruby
      --without-libstemmer
    ]

    args << "--enable-benchmark" if build.include? "enable-benchmark"
    args << "--with-mecab" if build.with? "mecab"
    args << "--with-lz4" if build.with? "lz4"

    # ZeroMQ is an optional dependency that will be auto-detected unless we disable it
    system "./configure", *args
    system "make"
    system "make install"
  end
end

__END__
diff --git a/lib/ii.c b/lib/ii.c
index 8f9f9a8..e82dc7f 100644
--- a/lib/ii.c
+++ b/lib/ii.c
@@ -37,6 +37,10 @@
 # include <oniguruma.h>
 #endif

+#ifndef O_DIRECT
+# define O_DIRECT 0
+#endif
+
 #define MAX_PSEG                 0x20000
 #define S_CHUNK                  (1 << GRN_II_W_CHUNK)
 #define W_SEGMENT                18
diff --git a/lib/grn.h b/lib/grn.h
index ab720ef..868133c 100644
--- a/lib/grn.h
+++ b/lib/grn.h
@@ -174,6 +174,10 @@ typedef SOCKET grn_sock;
 #  include <unistd.h>
 # endif /* HAVE_UNISTD_H */

+# ifndef __off64_t_defined
+typedef off_t off64_t;
+# endif
+
 # ifndef PATH_MAX
 #  if defined(MAXPATHLEN)
 #   define PATH_MAX MAXPATHLEN
diff --git a/lib/grn.h b/lib/grn.h
index 868133c..b7f78e2 100644
--- a/lib/grn.h
+++ b/lib/grn.h
@@ -546,7 +546,7 @@ typedef int grn_cond;
 #  define GRN_MKOSTEMP(template,flags,mode) mkostemp(template,flags)
 # else /* HAVE_MKOSTEMP */
 #  define GRN_MKOSTEMP(template,flags,mode) \
-  (mktemp(template), GRN_OPEN((template),flags,mode))
+  (mktemp(template), GRN_OPEN((template),((flags)|O_RDWR|O_CREAT|O_EXCL),mode))
 # endif /* HAVE_MKOSTEMP */

 #elif (defined(WIN32) || defined (_WIN64)) /* __GNUC__ */
@@ -579,7 +579,7 @@ typedef int grn_cond;
 # define GRN_BIT_SCAN_REV0(v,r) GRN_BIT_SCAN_REV(v,r)

 # define GRN_MKOSTEMP(template,flags,mode) \
-  (mktemp(template), GRN_OPEN((template),((flags)|O_BINARY),mode))
+  (mktemp(template), GRN_OPEN((template),((flags)|O_RDWR|O_CREAT),mode))

 #else /* __GNUC__ */

diff --git a/lib/ii.c b/lib/ii.c
index 3e48bef..2ec4949 100644
--- a/lib/ii.c
+++ b/lib/ii.c
@@ -7428,13 +7428,10 @@ grn_ii_buffer_open(grn_ctx *ctx, grn_ii *ii,
       if (ii_buffer->counters) {
         ii_buffer->block_buf = GRN_MALLOCN(grn_id, II_BUFFER_BLOCK_SIZE);
         if (ii_buffer->block_buf) {
-          int open_flags = O_WRONLY|O_CREAT;
+          int open_flags = 0;
 #ifdef WIN32
           open_flags |= O_BINARY;
 #endif
-#ifdef BSD
-          open_flags &= O_APPEND|O_DIRECT|O_SHLOCK|O_EXLOCK|O_SYNC|O_CLOEXEC;
-#endif
           snprintf(ii_buffer->tmpfpath, PATH_MAX,
                    "%sXXXXXX", grn_io_path(ii->seg));
           ii_buffer->block_buf_size = II_BUFFER_BLOCK_SIZE;