ext/extconf.rb in ruby-vpi-20.0.0 vs ext/extconf.rb in ruby-vpi-21.0.0

- old
+ new

@@ -1,24 +1,31 @@ -# Generates a makefile for buiding the extension. +# Generates a makefile for buiding the C extension. #-- # Copyright 2006 Suraj N. Kurapati # See the file named LICENSE for details. require 'mkmf' -# check for POSIX threads library - hasPthread = have_library('pthread', 'pthread_create') - # check for ruby library require 'rbconfig' - rubyLibArgs = Config::CONFIG.values.grep(/^-lruby/) + # possible names under which Ruby library is installed + rubyLibNames = Config::CONFIG.values.join(' '). + scan(/-l(ruby\S*)/).flatten.uniq - rubyLibNames = rubyLibArgs.map {|a| a.sub /^-l/, ''} - rubyLibNames.unshift 'ruby' # try most common name first - rubyLibNames.uniq! + # possible places where Ruby library is installed + rubyLibPaths = Config::CONFIG.values.join(' '). + scan(/-L(\S+)/).flatten. + select {|f| File.exist? f } - hasRuby = rubyLibNames.inject(false) do |verdict, name| - verdict ||= have_library(name, 'ruby_init') + RUBY_FUNC = 'ruby_init' + + hasRuby = rubyLibNames.any? do |libName| + have_library(libName, RUBY_FUNC) or + + rubyLibPaths.any? do |libPath| + have_library(libName, RUBY_FUNC, libPath) + end end -hasPthread && hasRuby && create_makefile('ruby-vpi') +# generate the makefile +create_makefile 'ruby-vpi' if hasRuby