Add Ruby bindings.
[hivex.git] / ruby / Rakefile.in
diff --git a/ruby/Rakefile.in b/ruby/Rakefile.in
new file mode 100644 (file)
index 0000000..da9f3f1
--- /dev/null
@@ -0,0 +1,114 @@
+# hivex Ruby bindings -*- ruby -*-
+# @configure_input@
+# Copyright (C) 2009-2011 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+require 'rake/clean'
+require 'rake/rdoctask'
+require 'rake/testtask'
+require 'rake/gempackagetask'
+
+PKG_NAME='@PACKAGE_NAME@'
+PKG_VERSION='@PACKAGE_VERSION@'
+
+EXT_CONF='@srcdir@/ext/hivex/extconf.rb'
+MAKEFILE='@builddir@/ext/hivex/Makefile'
+HIVEX_MODULE='@builddir@/ext/hivex/_hivex.so'
+HIVEX_SRC='@srcdir@/ext/hivex/_hivex.c'
+
+CLEAN.include [ "@builddir@/ext/**/*.o", HIVEX_MODULE,
+                "@builddir@/ext/**/depend" ]
+
+CLOBBER.include [ "@builddir@/config.save", "@builddir@/ext/**/mkmf.log",
+                  MAKEFILE ]
+
+# Build locally
+
+file MAKEFILE => EXT_CONF do |t|
+     unless sh "top_srcdir=$(pwd)/@top_srcdir@; top_builddir=$(pwd)/@top_builddir@; export ARCHFLAGS=\"-arch $(uname -m)\"; cd #{File::dirname(EXT_CONF)}; ruby #{File::basename(EXT_CONF)} --with-_hivex-include=$top_srcdir/lib --with-_hivex-lib=$top_builddir/lib/.libs"
+         $stderr.puts "Failed to run extconf"
+         break
+     end
+end
+file HIVEX_MODULE => [ MAKEFILE, HIVEX_SRC ] do |t|
+    Dir::chdir(File::dirname(EXT_CONF)) do
+         unless sh "make"
+             $stderr.puts "make failed"
+             break
+         end
+     end
+end
+desc "Build the native library"
+task :build => HIVEX_MODULE
+
+Rake::TestTask.new(:test) do |t|
+    t.test_files = FileList['tests/tc_*.rb']
+    t.libs = [ 'lib', 'ext/hivex' ]
+end
+task :test => :build
+
+RDOC_FILES = FileList[
+    "README.rdoc",
+    "lib/**/*.rb",
+    "ext/**/*.[ch]"
+]
+
+Rake::RDocTask.new do |rd|
+    rd.main = "README.rdoc"
+    rd.rdoc_dir = "doc/site/api"
+    rd.rdoc_files.include(RDOC_FILES)
+end
+
+Rake::RDocTask.new(:ri) do |rd|
+    rd.main = "README.rdoc"
+    rd.rdoc_dir = "doc/ri"
+    rd.options << "--ri-system"
+    rd.rdoc_files.include(RDOC_FILES)
+end
+
+# Package tasks
+
+PKG_FILES = FileList[
+  "Rakefile", "COPYING", "README", "NEWS", "README.rdoc",
+  "lib/**/*.rb",
+  "ext/**/*.[ch]", "ext/**/MANIFEST", "ext/**/extconf.rb",
+  "tests/**/*",
+  "spec/**/*"
+]
+
+DIST_FILES = FileList[
+  "pkg/*.src.rpm",  "pkg/*.gem",  "pkg/*.zip", "pkg/*.tgz"
+]
+
+SPEC = Gem::Specification.new do |s|
+    s.name = PKG_NAME
+    s.version = PKG_VERSION
+    s.email = "rjones@redhat.com"
+    s.homepage = "http://libguestfs.org/"
+    s.summary = "Ruby bindings for hivex"
+    s.files = PKG_FILES
+    s.autorequire = "hivex"
+    s.required_ruby_version = '>= 1.8.1'
+    s.extensions = "ext/hivex/extconf.rb"
+    s.description = <<EOF
+Ruby bindings for hivex.
+EOF
+end
+
+Rake::GemPackageTask.new(SPEC) do |pkg|
+    pkg.need_tar = true
+    pkg.need_zip = true
+end