2015-12-16 00:31:54 -05:00
|
|
|
# frozen_string_literal: false
|
2003-03-28 00:00:21 -05:00
|
|
|
require 'mkmf'
|
2008-02-09 03:51:26 -05:00
|
|
|
|
2019-10-07 20:06:28 -04:00
|
|
|
def check_bigdecimal_version(gemspec_path)
|
|
|
|
message "checking RUBY_BIGDECIMAL_VERSION... "
|
|
|
|
|
|
|
|
bigdecimal_version =
|
|
|
|
IO.readlines(gemspec_path)
|
|
|
|
.grep(/\Abigdecimal_version\s+=\s+/)[0][/\'([^\']+)\'/, 1]
|
|
|
|
|
|
|
|
version_components = bigdecimal_version.split('.')
|
|
|
|
bigdecimal_version = version_components[0, 3].join('.')
|
|
|
|
bigdecimal_version << "-#{version_components[3]}" if version_components[3]
|
|
|
|
$defs << %Q[-DRUBY_BIGDECIMAL_VERSION=\\"#{bigdecimal_version}\\"]
|
|
|
|
|
|
|
|
message "#{bigdecimal_version}\n"
|
|
|
|
end
|
|
|
|
|
2017-12-13 23:40:15 -05:00
|
|
|
gemspec_name = gemspec_path = nil
|
|
|
|
unless ['', '../../'].any? {|dir|
|
|
|
|
gemspec_name = "#{dir}bigdecimal.gemspec"
|
|
|
|
gemspec_path = File.expand_path("../#{gemspec_name}", __FILE__)
|
|
|
|
File.file?(gemspec_path)
|
|
|
|
}
|
2017-12-13 10:28:30 -05:00
|
|
|
$stderr.puts "Unable to find bigdecimal.gemspec"
|
|
|
|
abort
|
|
|
|
end
|
|
|
|
|
2019-10-07 20:06:28 -04:00
|
|
|
check_bigdecimal_version(gemspec_path)
|
2017-12-13 10:28:30 -05:00
|
|
|
|
2010-08-14 11:22:43 -04:00
|
|
|
have_func("labs", "stdlib.h")
|
|
|
|
have_func("llabs", "stdlib.h")
|
2016-12-10 02:49:15 -05:00
|
|
|
have_func("finite", "math.h")
|
|
|
|
have_func("isfinite", "math.h")
|
2010-08-14 11:22:43 -04:00
|
|
|
|
2015-01-29 09:34:43 -05:00
|
|
|
have_type("struct RRational", "ruby.h")
|
|
|
|
have_func("rb_rational_num", "ruby.h")
|
|
|
|
have_func("rb_rational_den", "ruby.h")
|
2019-10-08 21:50:59 -04:00
|
|
|
have_type("struct RComplex", "ruby.h")
|
|
|
|
have_func("rb_complex_real", "ruby.h")
|
|
|
|
have_func("rb_complex_imag", "ruby.h")
|
2016-12-10 02:49:15 -05:00
|
|
|
have_func("rb_array_const_ptr", "ruby.h")
|
|
|
|
have_func("rb_sym2str", "ruby.h")
|
2019-07-11 06:20:53 -04:00
|
|
|
have_func("rb_opts_exception_p", "ruby.h")
|
2016-12-10 02:49:15 -05:00
|
|
|
|
2018-12-20 18:29:49 -05:00
|
|
|
if File.file?(File.expand_path('../lib/bigdecimal.rb', __FILE__))
|
|
|
|
bigdecimal_rb = "$(srcdir)/lib/bigdecimal.rb"
|
|
|
|
else
|
|
|
|
bigdecimal_rb = "$(srcdir)/../../lib/bigdecimal.rb"
|
|
|
|
end
|
|
|
|
|
2017-12-13 23:40:15 -05:00
|
|
|
create_makefile('bigdecimal') {|mf|
|
2018-12-05 06:30:24 -05:00
|
|
|
mf << "GEMSPEC = #{gemspec_name}\n"
|
2018-12-20 18:29:49 -05:00
|
|
|
mf << "BIGDECIMAL_RB = #{bigdecimal_rb}\n"
|
2017-12-13 23:40:15 -05:00
|
|
|
}
|