From 8bbd873f54366792c23c652d794151def65ce3d8 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Fran=C3=A7ois=20Beausoleil?= Date: Thu, 3 Apr 2008 09:39:24 -0400 Subject: [PATCH] New build:checkdeps task to tell the developer which dependencies are missing before attempting the build. Refactored the dependency code checking to be done once whenever any #make invocation is attempted. This allows us to dynamically select the proper make, and ensures all build and installation dependencies are managed. --- Rakefile | 8 +++++++- rakelib/rubinius.rb | 48 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/Rakefile b/Rakefile index bdf4b4b..faabc11 100644 --- a/Rakefile +++ b/Rakefile @@ -82,6 +82,7 @@ AllPreCompiled << "runtime/loader.rbc" namespace :build do task :all => %w[ + build:checkdeps build:shotgun build:platform build:rbc @@ -125,6 +126,11 @@ namespace :build do sh make('vm') end + desc "Checks that you have all required dependencies" + task :checkdeps do + check_dependencies + end + desc "Compiles shotgun (the C-code VM)" task :shotgun => %w[configure shotgun/rubinius.bin shotgun/rubinius.local.bin] @@ -167,7 +173,7 @@ end # INSTALL TASKS desc "Install rubinius as rbx" -task :install => :config_env do +task :install => %w[build:checkdeps config_env] do sh "cd shotgun; #{make "install"}" mkdir_p RBAPATH, :verbose => true diff --git a/rakelib/rubinius.rb b/rakelib/rubinius.rb index fbe9bdd..4bbd6b9 100644 --- a/rakelib/rubinius.rb +++ b/rakelib/rubinius.rb @@ -25,13 +25,51 @@ def clear_compiler ENV.delete 'RBX_PLATFORM' end -def make(args = nil) - if RUBY_PLATFORM =~ /bsd/ - gmake = 'gmake' +def check_dependencies + if ENV["MAKE"] then + `#{ENV['MAKE']} --version` rescue nil + if $?.success? then + Object.const_set("MAKE", ENV["MAKE"]) + else + abort "You specified #{ENV['MAKE']} as your make, but I could not run it. Aborting..." + end else - gmake = 'make' + # We need GNU Make, so try gmake then make + ouptut = `gmake --version` rescue nil + if $?.success? then + Object.const_set("MAKE", "gmake") + else + output = `make --version` rescue nil + if $?.success? then + Object.const_set("MAKE", "make") + else + abort "We need either gmake or make, but none found. If you have a compatible GNU make, you can set MAKE to point to it. Aborting..." + end + end + + unless output =~ /GNU Make/ + abort "We need GNU Make, but we found #{output.inspect}. If you know your make is compatible, you can set MAKE to point to it. Aborting..." + end + end + + puts "Checking build dependencies..." + missing_dependencies = [] + %w(bison git ruby gem pkg-config libtool).each do |dependency| + `#{dependency} --version >/dev/null` + missing_dependencies << dependency unless $?.success? + end + + unless missing_dependencies.empty? then + puts "\nYou are missing one or more required dependencies (which might have dependencies of their own):" + puts missing_dependencies.map {|dep| " * #{dep}"}.join("\n") + puts + exit 1 end - "#{ENV['MAKE'] || gmake} #{args}" +end + +def make(args = nil) + checkdeps unless const_defined?(:MAKE) + "#{MAKE} #{args}" end def rbx(*args) -- 1.5.3.6