Generated code to support previous 2 commits.
[libguestfs.git] / ruby / Rakefile.in
1 # libguestfs Ruby bindings -*- ruby -*-
2 # @configure_input@
3 # Copyright (C) 2009 Red Hat Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 require 'rake/clean'
20 require 'rake/rdoctask'
21 require 'rake/testtask'
22 require 'rake/gempackagetask'
23
24 PKG_NAME='@PACKAGE_NAME@'
25 PKG_VERSION='@PACKAGE_VERSION@'
26
27 EXT_CONF='ext/guestfs/extconf.rb'
28 MAKEFILE='ext/guestfs/Makefile'
29 GUESTFS_MODULE='ext/guestfs/_guestfs.so'
30 GUESTFS_SRC='ext/guestfs/_guestfs.c'
31
32 CLEAN.include [ "ext/**/*.o", GUESTFS_MODULE,
33                 "ext/**/depend" ]
34
35 CLOBBER.include [ "config.save", "ext/**/mkmf.log",
36                   MAKEFILE ]
37
38 # Build locally
39
40 file MAKEFILE => EXT_CONF do |t|
41     Dir::chdir(File::dirname(EXT_CONF)) do
42          unless sh "ruby #{File::basename(EXT_CONF)} --with-_guestfs-include=../../../src --with-_guestfs-lib=../../../src/.libs"
43              $stderr.puts "Failed to run extconf"
44              break
45          end
46     end
47 end
48 file GUESTFS_MODULE => [ MAKEFILE, GUESTFS_SRC ] do |t|
49     Dir::chdir(File::dirname(EXT_CONF)) do
50          unless sh "make"
51              $stderr.puts "make failed"
52              break
53          end
54      end
55 end
56 desc "Build the native library"
57 task :build => GUESTFS_MODULE
58
59 Rake::TestTask.new(:test) do |t|
60     t.test_files = FileList['tests/tc_*.rb']
61     t.libs = [ 'lib', 'ext/guestfs' ]
62 end
63 task :test => :build
64
65 Rake::RDocTask.new do |rd|
66     rd.main = "README.rdoc"
67     rd.rdoc_dir = "doc/site/api"
68     rd.rdoc_files.include("README.rdoc", "lib/**/*.rb", "ext/**/*.[ch]")
69 end
70
71 # Package tasks
72
73 PKG_FILES = FileList[
74   "Rakefile", "COPYING", "README", "NEWS", "README.rdoc",
75   "lib/**/*.rb",
76   "ext/**/*.[ch]", "ext/**/MANIFEST", "ext/**/extconf.rb",
77   "tests/**/*",
78   "spec/**/*"
79 ]
80
81 DIST_FILES = FileList[
82   "pkg/*.src.rpm",  "pkg/*.gem",  "pkg/*.zip", "pkg/*.tgz"
83 ]
84
85 SPEC = Gem::Specification.new do |s|
86     s.name = PKG_NAME
87     s.version = PKG_VERSION
88     s.email = "rjones@redhat.com"
89     s.homepage = "http://et.redhat.com/~rjones/libguestfs/"
90     s.summary = "Ruby bindings for libguestfs"
91     s.files = PKG_FILES
92     s.autorequire = "guestfs"
93     s.required_ruby_version = '>= 1.8.1'
94     s.extensions = "ext/guestfs/extconf.rb"
95     s.description = <<EOF
96 Ruby bindings for libguestfs.
97 EOF
98 end
99
100 Rake::GemPackageTask.new(SPEC) do |pkg|
101     pkg.need_tar = true
102     pkg.need_zip = true
103 end