X-Git-Url: http://git.code-monkey.de/?p=ruby-eet.git;a=blobdiff_plain;f=Rakefile;h=178c69fc060454d05f46ce2149bf0c17bfe536ce;hp=03fc22e9fccc2f2ef1a68aa762cb732a0ee46c44;hb=HEAD;hpb=06a31fdd0abfbcbb324a1c25611e59be6615f713 diff --git a/Rakefile b/Rakefile index 03fc22e..178c69f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,3 @@ -# $Id: Rakefile 32 2005-04-19 09:07:57Z tilman $ - require "rbconfig" require "rake/clean" require "rake/testtask" @@ -8,50 +6,66 @@ require "rake/packagetask" require "rake/contrib/compositepublisher" require "rake/contrib/sshpublisher" -# make sure we run at least Rake 0.5.0 -if (RAKEVERSION.split(".").map { |p| p.to_i } <=> [0, 5, 0]) < 0 - raise("Rake 0.5.0 or greater required") -end +require "rake/configuretask" +require "rake/extensiontask" PKG_NAME = "ruby-eet" PKG_VERSION = File.read("lib/eet.rb"). match(/^\s*VERSION = \"(.*)\"\s$/).captures.first +PKG_FILES = FileList[ + "AUTHORS", "COPYING", "ChangeLog", "NEWS", "README", "Rakefile", + "rake/configuretask.rb", "rake/extensiontask.rb", + "ext/ext.c", "lib/eet.rb", + "test/common.rb", "test/test_array_sub.rb", "test/test_basic.rb", + "test/test_broken_classes.rb", "test/test_chunk.rb", + "test/test_hash.rb", "test/test_list.rb", "test/test_misc.rb", + "test/test_stream.rb", "test/test_sub.rb" +] -ext_obj = "ext/ext.o" -ext_lib = "ext/eet_ext.so" +CLOBBER.include("test/*.eet") -CLOBBER.include(ext_obj, ext_lib, "test/*.eet") +task :default => [:ext] -archdir = Config::CONFIG["archdir"] -sitearchdir = Config::CONFIG["sitearchdir"] -libdir = Config::CONFIG["libdir"] -sitelibdir = Config::CONFIG["sitelibdir"] -rubylib = Config::CONFIG["LIBRUBYARG_SHARED"] -destdir = "#{ENV["DESTDIR"]}" -eet_cflags = `eet-config --cflags`.strip -eet_libs = `eet-config --libs`.strip -cflags = "#{ENV["CFLAGS"]} #{eet_cflags}" -ldflags = "#{ENV["LDFLAGS"]} #{eet_libs}" +config = Rake::ConfigureTask.new do |t| + t.tests << Rake::ConfigureTask:: + PkgConfigTest.new("eet", :is_critical => true) +end -task :default => [ext_lib] +task :ext => [:pre_ext] -rule ".o" => [".c"] do |t| - sh "cc #{cflags} -fPIC -I #{archdir} #{t.source} -c -o #{t.name}" +ext = Rake::ExtensionTask.new :ext => [:ext] do |t| + t.dir = "ext" + t.lib_name = "#{t.dir}/eet_ext.so" end -file ext_lib => ext_obj do |t| - sh "cc #{ldflags} -shared -Wl -L #{libdir} #{rubylib} " + - "#{t.prerequisites.join(" ")} -o #{t.name}" +task :pre_ext => [:configure] do + ext.link_libs << config.eet.libs + + cflags = [ + ext.env[:cflags], + config.eet.cflags + ] + + if [0xff].pack("s") == "\x00\xff" + ext.env.update(:defines => "WORDS_BIGENDIAN") + end + + ext.env.update(:cflags => cflags) end -task :install => [ext_lib] do |t| - FileUtils::Verbose.install(ext_lib, destdir + sitearchdir, - :mode => 0755) - FileUtils::Verbose.install("lib/eet.rb", destdir + sitelibdir, - :mode => 0644) +task :install => [:ext] do |t| + destdir = ENV["DESTDIR"] || "" + + ddir = destdir + Config::CONFIG["sitearchdir"] + FileUtils::Verbose.mkdir_p(ddir) unless File.directory?(ddir) + FileUtils::Verbose.install(ext.lib_name, ddir, :mode => 0755) + + ddir = destdir + Config::CONFIG["sitelibdir"] + FileUtils::Verbose.mkdir_p(ddir) unless File.directory?(ddir) + FileUtils::Verbose.install("lib/eet.rb", ddir, :mode => 0644) end -task :test => [ext_lib] +task :test => [:ext] Rake::TestTask.new do |t| t.libs = ["lib", "ext", "test"] @@ -63,19 +77,25 @@ Rake::RDocTask.new do |t| t.rdoc_dir = "doc" t.title = "Ruby-EET - EET bindings for Ruby" t.options = ["--line-numbers", "--inline-source", "--main", "README"] - t.rdoc_files.include("README", "COPYING", "AUTHORS", "ChangeLog", + t.rdoc_files.include("README", "COPYING", "AUTHORS", "NEWS", "ext/ext.c", "lib/eet.rb") end +CLOBBER.include("ChangeLog") + +file "ChangeLog" do + `git log > ChangeLog` +end + Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |t| t.need_tar_gz = true - t.package_files.include("[A-Z]*", "ext/*.c", "lib/*.rb", "test/*.rb") + t.package_files = PKG_FILES end task :publish => [:rdoc, :package] do p = Rake::CompositePublisher.new p.add(Rake::SshFreshDirPublisher.new("code-monkey.de", - "public_html/docs/" + + "public_docs/" + PKG_NAME, "doc")) p.add(Rake::SshFilePublisher.new("code-monkey.de", ".", "pkg",