summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/extconf.rb
diff options
context:
space:
mode:
authorKenta Murata <mrkn@users.noreply.github.com>2019-10-08 09:06:28 +0900
committerGitHub <noreply@github.com>2019-10-08 09:06:28 +0900
commitdd0c75fdc2104a6ba38b68d4431a572504a3bbc2 (patch)
treecea82d0d8ea56e8c7d03158f35654adb974d6bd0 /ext/bigdecimal/extconf.rb
parent59c3b1c9c843fcd2d30393791fe224e5789d1677 (diff)
Import changes from ruby/bigdecimal (#2531)
Sync to ruby/bigdecimal@92356ba71c6bd325b0ab618c634a7aecf8cdc767
Notes
Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
Diffstat (limited to 'ext/bigdecimal/extconf.rb')
-rw-r--r--ext/bigdecimal/extconf.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb
index 7a7af10a2de..b4098fdacf5 100644
--- a/ext/bigdecimal/extconf.rb
+++ b/ext/bigdecimal/extconf.rb
@@ -1,6 +1,21 @@
# frozen_string_literal: false
require 'mkmf'
+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
+
gemspec_name = gemspec_path = nil
unless ['', '../../'].any? {|dir|
gemspec_name = "#{dir}bigdecimal.gemspec"
@@ -11,11 +26,7 @@ unless ['', '../../'].any? {|dir|
abort
end
-bigdecimal_version =
- IO.readlines(gemspec_path)
- .grep(/\Abigdecimal_version\s+=\s+/)[0][/\'([\d\.]+)\'/, 1]
-
-$defs << %Q[-DRUBY_BIGDECIMAL_VERSION=\\"#{bigdecimal_version}\\"]
+check_bigdecimal_version(gemspec_path)
have_func("labs", "stdlib.h")
have_func("llabs", "stdlib.h")