diff options
Diffstat (limited to 'ext/bigdecimal/extconf.rb')
-rw-r--r-- | ext/bigdecimal/extconf.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb index dccf2d2d83..4bef91eafe 100644 --- a/ext/bigdecimal/extconf.rb +++ b/ext/bigdecimal/extconf.rb @@ -1,6 +1,22 @@ # frozen_string_literal: false require 'mkmf' +case +when File.file?(File.expand_path('../bigdecimal.gemspec', __FILE__)) + gemspec_path = File.expand_path('../bigdecimal.gemspec', __FILE__) +when File.file?(File.expand_path('../../../bigdecimal.gemspec', __FILE__)) + gemspec_path = File.expand_path('../../../bigdecimal.gemspec', __FILE__) +else + $stderr.puts "Unable to find bigdecimal.gemspec" + abort +end + +bigdecimal_version = + IO.readlines(gemspec_path) + .grep(/\Abigdecimal_version\s+=\s+/)[0][/\'([\d\.]+)\'/, 1] + +$defs << %Q[-DRUBY_BIGDECIMAL_VERSION=\\"#{bigdecimal_version}\\"] + alias __have_macro__ have_macro have_func("labs", "stdlib.h") |