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
|
# 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/testtask'
# Used to be rake/rdoctask. Now it's rdoc/task.
# http://stackoverflow.com/questions/2460891/how-do-i-rescue-from-a-require-no-such-file-to-load-in-ruby
begin
require 'rdoc/task'
rescue LoadError
require 'rake/rdoctask'
end
# Used to be rake/gempackagetask. Now it's rubygems/package_task. Also
# we need to use the appropriate class name below.
begin
require 'rubygems/package_task'
gempackagetask='Gem::PackageTask'
rescue LoadError
require 'rake/gempackagetask'
gempackagetask='Rake::GemPackageTask'
end
PKG_NAME='@PACKAGE_NAME@'
PKG_VERSION='@PACKAGE_VERSION@'
EXT_CONF='@abs_srcdir@/ext/hivex/extconf.rb'
MAKEFILE='@builddir@/ext/hivex/Makefile'
HIVEX_MODULE='@builddir@/ext/hivex/_hivex.so'
HIVEX_SRC='@abs_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)\"; mkdir -p @builddir@/ext/hivex; cd @builddir@/ext/hivex; @RUBY@ #{EXT_CONF} --with-_hivex-include=$top_srcdir/include --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("@builddir@/ext/hivex") 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[
"@srcdir@/README.rdoc",
"@srcdir@/lib/**/*.rb",
"@srcdir@/ext/**/*.[ch]"
]
Rake::RDocTask.new do |rd|
rd.main = "@srcdir@/README.rdoc"
rd.rdoc_dir = "doc/site/api"
rd.rdoc_files.include(RDOC_FILES)
end
Rake::RDocTask.new(:ri) do |rd|
rd.main = "@srcdir@/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", "@srcdir@/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
eval(gempackagetask).new(SPEC) do |pkg|
pkg.need_tar = true
pkg.need_zip = true
end
|