appliance: Fedora cryptsetup-luks renamed to cryptsetup.
[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='@srcdir@/ext/guestfs/extconf.rb'
28 MAKEFILE='@builddir@/ext/guestfs/Makefile'
29 GUESTFS_MODULE='@builddir@/ext/guestfs/_guestfs.so'
30 GUESTFS_SRC='@srcdir@/ext/guestfs/_guestfs.c'
31
32 CLEAN.include [ "@builddir@/ext/**/*.o", GUESTFS_MODULE,
33                 "@builddir@/ext/**/depend" ]
34
35 CLOBBER.include [ "@builddir@/config.save", "@builddir@/ext/**/mkmf.log",
36                   MAKEFILE ]
37
38 # Build locally
39
40 file MAKEFILE => EXT_CONF do |t|
41      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-_guestfs-include=$top_srcdir/src --with-_guestfs-lib=$top_builddir/src/.libs"
42          $stderr.puts "Failed to run extconf"
43          break
44      end
45 end
46 file GUESTFS_MODULE => [ MAKEFILE, GUESTFS_SRC ] do |t|
47     Dir::chdir(File::dirname(EXT_CONF)) do
48          unless sh "make"
49              $stderr.puts "make failed"
50              break
51          end
52      end
53 end
54 desc "Build the native library"
55 task :build => GUESTFS_MODULE
56
57 Rake::TestTask.new(:test) do |t|
58     t.test_files = FileList['tests/tc_*.rb']
59     t.libs = [ 'lib', 'ext/guestfs' ]
60 end
61 task :test => :build
62
63 RDOC_FILES = FileList[
64     "README.rdoc",
65     "lib/**/*.rb",
66     "ext/**/*.[ch]"
67 ]
68
69 Rake::RDocTask.new do |rd|
70     rd.main = "README.rdoc"
71     rd.rdoc_dir = "doc/site/api"
72     rd.rdoc_files.include(RDOC_FILES)
73 end
74
75 Rake::RDocTask.new(:ri) do |rd|
76     rd.main = "README.rdoc"
77     rd.rdoc_dir = "doc/ri"
78     rd.options << "--ri-system"
79     rd.rdoc_files.include(RDOC_FILES)
80 end
81
82 # Package tasks
83
84 PKG_FILES = FileList[
85   "Rakefile", "COPYING", "README", "NEWS", "README.rdoc",
86   "lib/**/*.rb",
87   "ext/**/*.[ch]", "ext/**/MANIFEST", "ext/**/extconf.rb",
88   "tests/**/*",
89   "spec/**/*"
90 ]
91
92 DIST_FILES = FileList[
93   "pkg/*.src.rpm",  "pkg/*.gem",  "pkg/*.zip", "pkg/*.tgz"
94 ]
95
96 SPEC = Gem::Specification.new do |s|
97     s.name = PKG_NAME
98     s.version = PKG_VERSION
99     s.email = "rjones@redhat.com"
100     s.homepage = "http://libguestfs.org/"
101     s.summary = "Ruby bindings for libguestfs"
102     s.files = PKG_FILES
103     s.autorequire = "guestfs"
104     s.required_ruby_version = '>= 1.8.1'
105     s.extensions = "ext/guestfs/extconf.rb"
106     s.description = <<EOF
107 Ruby bindings for libguestfs.
108 EOF
109 end
110
111 Rake::GemPackageTask.new(SPEC) do |pkg|
112     pkg.need_tar = true
113     pkg.need_zip = true
114 end