summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/util/extconf.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bigdecimal/util/extconf.rb')
-rw-r--r--ext/bigdecimal/util/extconf.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/ext/bigdecimal/util/extconf.rb b/ext/bigdecimal/util/extconf.rb
new file mode 100644
index 00000000000..023b19ba7ea
--- /dev/null
+++ b/ext/bigdecimal/util/extconf.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: false
+require 'mkmf'
+
+def windows_platform?
+ /cygwin|mingw|mswin/ === RUBY_PLATFORM
+end
+
+if windows_platform?
+ library_base_name = "ruby-bigdecimal"
+ case RUBY_PLATFORM
+ when /cygwin|mingw/
+ import_library_name = "libruby-bigdecimal.a"
+ when /mswin/
+ import_library_name = "bigdecimal-$(arch).lib"
+ end
+end
+
+checking_for(checking_message("Windows")) do
+ if windows_platform?
+ if defined?($extlist)
+ build_dir = "$(TARGET_SO_DIR)../"
+ else
+ base_dir = File.expand_path('../../../..', __FILE__)
+ build_dir = File.join(base_dir, "tmp", RUBY_PLATFORM, "bigdecimal", RUBY_VERSION)
+ end
+ case RUBY_PLATFORM
+ when /cygwin|mingw/
+ $LDFLAGS << " -L#{build_dir} -L.. -L .."
+ $libs << " -l#{library_base_name}"
+ when /mswin/
+ $DLDFLAGS << " /libpath:#{build_dir} /libpath:.."
+ $libs << " #{import_library_name}"
+ end
+ true
+ else
+ false
+ end
+end
+
+create_makefile('bigdecimal/util')