aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/genstats.rb
blob: 7b761caf6adc6b3097d12ab9f9896121c734933b (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
require 'formula'

class Genstats < Formula
  homepage 'http://www.vanheusden.com/genstats/'
  url 'http://www.vanheusden.com/genstats/genstats-1.0.0.tgz'
  sha1 '8ca19e5fe72f1d881bf38298e155b15f07e6bd66'

  def patches
    # fix compile errors on OS X for 1.0.0. I've emailed the author.
    DATA
  end

  def install
    # Tried to make this a patch.  Applying the patch hunk would
    # fail, even though I used "git diff | pbcopy".  Tried messing
    # with whitespace, # lines, etc.  Ugh.
    inreplace 'br.cpp' do |s|
      s.gsub! /if \(_XOPEN_VERSION >= 600\)/, 'if (_XOPEN_VERSION >= 600) && !__APPLE__'
    end

    system 'make'
    bin.install('genstats')
    man.install('genstats.1')
  end

  def test
    # TODO(dan): be more thorough
    system "genstats -h | grep folkert@vanheusden.com"
  end
end
__END__
diff --git a/br.h b/br.h
index addf8bc..dfdb5d4 100644
--- a/br.h
+++ b/br.h
@@ -8,6 +8,14 @@
 #define likely(x)       __builtin_expect((x),1)
 #define unlikely(x)     __builtin_expect((x),0)
 
+#ifdef __APPLE__
+/* See http://fixunix.com/bsd/539901-definition-off64_t.html */
+typedef off_t off64_t;
+/* See http://lists.apple.com/archives/unix-porting/2002/Jul/msg00099.html */
+#define lseek64 lseek
+#define open64 open
+#endif
+
 class buffered_reader
   {
 private: