require 'rbconfig' c = RbConfig::CONFIG def system!(cmd) puts cmd system(cmd) or raise end ver = '1.4.6' core = "xapian-core-#{ver}" bindings = "xapian-bindings-#{ver}" xapian_config = "#{__dir__}/#{core}/xapian-config" prefix = ENV['PREFIX'] || File.dirname(__dir__) puts "prefix = #{prefix}" #ENV['LDFLAGS'] = "-R#{prefix}/lib" docdir = File.join(prefix, "share/doc/xapian") namespace :build do task :core do Dir.chdir core do system! "./configure --prefix=#{prefix} --exec-prefix=#{prefix}" system! "make all install" # Alternatively to only install libraries # system! "cp -r .libs/* ../lib/" end end task :bindings do Dir.chdir bindings do ENV['RUBY'] ||= "#{c['bindir']}/#{c['RUBY_INSTALL_NAME']}" ENV['XAPIAN_CONFIG'] = xapian_config system! "./configure --prefix=#{prefix} --exec-prefix=#{prefix} --with-ruby" system! "make all" system! "cp -LR ./ruby/.libs/_xapian.* #{prefix}/lib" system! "cp ./ruby/xapian.rb #{prefix}/lib" end end desc 'Remove sources files and strip libraries' task :cleanup do system! "rm -rfv #{core} #{bindings} ../include" system! "strip --strip-unneeded ../lib/_xapian.so ../lib/libxapian.so" # we could use globbing but xapian-config is a shell script and make # strip fail %w[copydatabase quest simpleexpand simpleindex simplesearch xapian-check xapian-compact xapian-delve xapian-metadata xapian-progsrv xapian-replicate xapian-replicate-server xapian-tcpsrv].each do |bin| system! "strip --strip-all ../bin/#{bin}" end end task :all => [:core, :bindings, :cleanup] end task :extract do [core,bindings].each do |x| system! "tar -xvf #{x}.tar.xz" end end task :default => [:extract, 'build:all']