aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/ganglia.rb
blob: 0edb99f26817f1f17dc908d4a1c3252c74df509a (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
require 'formula'

class Ganglia < Formula
  homepage 'http://ganglia.sourceforge.net/'
  url 'http://downloads.sourceforge.net/project/ganglia/ganglia%20monitoring%20core/3.1.7/ganglia-3.1.7.tar.gz'
  md5 '6aa5e2109c2cc8007a6def0799cf1b4c'

  depends_on 'confuse'
  depends_on 'pcre'
  depends_on 'rrdtool'

  def patches
    # fixes build on Leopard and newer, which lack kvm.h and its corresponding /dev/ node
    # Patch sent upstream: http://bugzilla.ganglia.info/cgi-bin/bugzilla/show_bug.cgi?id=258
    # Also, for some reason, having inline or static keywords in gperf generated files
    # causes missing symbol link errors - manually patch those out for now.
    DATA
  end

  if MacOS.xcode_version >= "4.3"
    depends_on "automake" => :build
    depends_on "libtool" => :build
  end

  def install
    # ENV var needed to confirm putting the config in the prefix until 3.2
    ENV['GANGLIA_ACK_SYSCONFDIR'] = '1'

    # Grab the standard autogen.sh and run it twice, to update libtool
    curl "http://buildconf.git.sourceforge.net/git/gitweb.cgi?p=buildconf/buildconf;a=blob_plain;f=autogen.sh;hb=HEAD", "-o", "autogen.sh"

    ENV['LIBTOOLIZE'] = "/usr/bin/glibtoolize" if MacOS.xcode_version < "4.3"
    ENV['PROJECT'] = "ganglia"
    system "/bin/sh ./autogen.sh --download"

    cd "libmetrics" do
      ENV['PROJECT'] = "libmetrics"
      system "/bin/sh ../autogen.sh --download"
    end

    system "./configure", "--disable-debug",
                          "--disable-dependency-tracking",
                          "--prefix=#{prefix}",
                          "--sbindir=#{bin}",
                          "--sysconfdir=#{etc}",
                          "--with-gexec",
                          "--with-gmetad",
                          "--with-libpcre=#{HOMEBREW_PREFIX}"
    system "make install"

    cd "web" do
      system "make", "conf.php"
      system "make", "version.php"
      inreplace "conf.php", "/usr/bin/rrdtool", "#{HOMEBREW_PREFIX}/bin/rrdtool"
    end

    # Generate the default config file
    system "#{bin}/gmond -t > #{etc}/gmond.conf" unless File.exists? "#{etc}/gmond.conf"

    # Install the web files
    (share+"ganglia").install "web"

    # Install man pages
    man1.install Dir['mans/*']
  end

  def caveats; <<-EOS.undent
    If you didn't have a default config file, one was created here:
      #{etc}/gmond.conf

    You might want to copy these someplace served by a PHP-capable web server:
      #{share}/ganglia/web/* to someplace
    EOS
  end
end

__END__
diff --git a/libmetrics/config.h.in b/libmetrics/config.h.in
index 1ff64b1..13087c6 100644
--- a/libmetrics/config.h.in
+++ b/libmetrics/config.h.in
@@ -152,6 +152,9 @@
 /* Define to 1 if you have the <sys/fs/s5param.h> header file. */
 #undef HAVE_SYS_FS_S5PARAM_H
 
+/* Define to 1 if you have the <kvm.h> header file. */
+#undef HAVE_KVM_H
+
 /* Define to 1 if you have the <sys/mount.h> header file. */
 #undef HAVE_SYS_MOUNT_H
 
diff --git a/libmetrics/configure.in b/libmetrics/configure.in
index 213d162..b5aa98e 100644
--- a/libmetrics/configure.in
+++ b/libmetrics/configure.in
@@ -31,7 +31,7 @@ AC_HAVE_LIBRARY(nsl)
 # Checks for header files.
 AC_HEADER_DIRENT
 AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h nlist.h paths.h stdlib.h strings.h sys/filsys.h sys/fs/s5param.h sys/mount.h sys/param.h sys/socket.h sys/statfs.h sys/statvfs.h sys/systeminfo.h sys/time.h sys/vfs.h unistd.h utmp.h sys/sockio.h])
+AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h nlist.h paths.h stdlib.h strings.h sys/filsys.h sys/fs/s5param.h sys/mount.h sys/param.h sys/socket.h sys/statfs.h sys/statvfs.h sys/systeminfo.h sys/time.h sys/vfs.h unistd.h utmp.h sys/sockio.h kvm.h])
 AC_CHECK_HEADERS([rpc/rpc.h],, 
    [AC_MSG_ERROR([your system is missing the Sun RPC (ONC/RPC) libraries])])
 
diff --git a/libmetrics/darwin/metrics.c b/libmetrics/darwin/metrics.c
index 498ed8f..bfa09a1 100644
--- a/libmetrics/darwin/metrics.c
+++ b/libmetrics/darwin/metrics.c
@@ -9,9 +9,17 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdlib.h>
 #include "interface.h"
+
+#if defined(HAVE_LIBKVM) && defined(HAVE_KVM_H)
 #include <kvm.h>
+#endif
+
 #include <sys/sysctl.h>
 
 #include <mach/mach_init.h>

diff --git a/gmetad/type_hash.c b/gmetad/type_hash.c
index 519513d..3f65efa 100644
--- a/gmetad/type_hash.c
+++ b/gmetad/type_hash.c
@@ -46,14 +46,7 @@ struct type_tag;
 #define MAX_HASH_VALUE 21
 /* maximum key range = 18, duplicates = 0 */
 
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static unsigned int
+unsigned int
 type_hash (str, len)
      register const char *str;
      register unsigned int len;
@@ -124,12 +117,6 @@ static struct type_tag types[] =
     {"double", FLOAT}
   };
 
-#ifdef __GNUC__
-__inline
-#ifdef __GNUC_STDC_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
 struct type_tag *
 in_type_list (str, len)
      register const char *str;
diff --git a/gmetad/xml_hash.c b/gmetad/xml_hash.c
index 5c21755..04910b3 100644
--- a/gmetad/xml_hash.c
+++ b/gmetad/xml_hash.c
@@ -42,13 +42,6 @@ struct xml_tag;
 #define MAX_HASH_VALUE 44
 /* maximum key range = 42, duplicates = 0 */
 
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
 static unsigned int
 xml_hash (str, len)
      register const char *str;
@@ -86,12 +79,6 @@ xml_hash (str, len)
   return len + asso_values[(unsigned char)str[len - 1]] + asso_values[(unsigned char)str[0]];
 }
 
-#ifdef __GNUC__
-__inline
-#ifdef __GNUC_STDC_INLINE__
-__attribute__ ((__gnu_inline__))
-#endif
-#endif
 struct xml_tag *
 in_xml_list (str, len)
      register const char *str;