aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Sully2011-03-14 17:08:41 -0700
committerAdam Vandenberg2011-06-19 13:02:08 -0700
commit7ecea6fa0af6e03a1401437bc7782d83f0521998 (patch)
treeefb0922bc3993149b9c04d797c3c6abde31b95bc
parent79ab48c6cb5954b32eb2fe23f37f2f1a9f8509c9 (diff)
downloadhomebrew-7ecea6fa0af6e03a1401437bc7782d83f0521998.tar.bz2
Add SIGAR library.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
-rw-r--r--Library/Formula/sigar.rb73
1 files changed, 73 insertions, 0 deletions
diff --git a/Library/Formula/sigar.rb b/Library/Formula/sigar.rb
new file mode 100644
index 000000000..8e6dfc264
--- /dev/null
+++ b/Library/Formula/sigar.rb
@@ -0,0 +1,73 @@
+require 'formula'
+
+class Sigar < Formula
+ # HEAD has up to date bindings that are actually useful.
+ head 'git://github.com/hyperic/sigar.git'
+ homepage 'http://sigar.hyperic.com/'
+
+ def options
+ [
+ ["--perl", "Build Perl bindings."],
+ ["--python", "Build Python bindings."],
+ ["--ruby", "Build Ruby bindings."],
+ ]
+ end
+
+ def java_script; <<-EOS.undent
+ #!/bin/sh
+ # Runs SIGAR's REPL.
+
+ java -jar #{prefix}/sigar.jar
+ EOS
+ end
+
+ def install
+ # Build Java JAR & C library first.
+ cd "bindings/java" do
+ system "ant"
+
+ cd "sigar-bin/lib" do
+ prefix.install 'sigar.jar'
+ lib.install Dir['*.dylib']
+ end
+
+ include.install Dir['sigar-bin/include/*']
+
+ (bin+'sigar').write java_script
+ end
+
+ # Install Python bindings
+ cd "bindings/python" do
+ system "python", "setup.py", "install", "--prefix=#{prefix}"
+ end if ARGV.include? "--python"
+
+ # Install Perl bindings
+ cd "bindings/perl" do
+
+ system "perl", "Makefile.PL"
+
+ # Tweak the Makefile to install.
+ # Can't pass PREFIX, as the Sigar build system uses ARGV[0]
+ inreplace "Makefile" do |s|
+ s.change_make_var! 'PREFIX', prefix
+ s.change_make_var! 'PERLPREFIX', '$(PREFIX)'
+ s.change_make_var! 'SITEPREFIX', '$(PREFIX)'
+ s.change_make_var! 'VENDORPREFIX', '$(PREFIX)'
+ s.change_make_var! 'INSTALLPRIVLIB', "$(PERLPREFIX)\\1"
+ s.change_make_var! 'INSTALLSITELIB', "$(PERLPREFIX)\\1"
+ s.change_make_var! 'INSTALLVENDORLIB', "$(PERLPREFIX)\\1"
+ s.change_make_var! 'INSTALLARCHLIB', "$(PERLPREFIX)\\1"
+ s.change_make_var! 'INSTALLSITEARCH', "$(PERLPREFIX)\\1"
+ s.change_make_var! 'INSTALLVENDORARCH', "$(PERLPREFIX)\\1"
+ end
+
+ system "make install"
+ end if ARGV.include? "--perl"
+
+ # Install Ruby bindings
+ cd "bindings/ruby" do
+ system "ruby", "extconf.rb", "--prefix='#{prefix}'"
+ system "make install"
+ end if ARGV.include? "--ruby"
+ end
+end