ruby-dm 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ext/extconf.rb ADDED
@@ -0,0 +1,123 @@
1
+ require 'pp'
2
+ require 'mkmf'
3
+
4
+
5
+ if ENV['MAINTAINER_MODE']
6
+ $stderr.puts "Maintainer mode enabled."
7
+ $CFLAGS <<
8
+ ' -Wall' <<
9
+ ' -g3' <<
10
+ ' -DDEBUG' <<
11
+ ' -pedantic'
12
+ $LDFLAGS <<
13
+ ' -g3'
14
+ end
15
+
16
+ if enable_config("windows-cross")
17
+ # Avoid dependency to external libgcc.dll on x86-mingw32
18
+ $LDFLAGS << " -static-libgcc"
19
+ # Don't use pg_config for cross build, but --with-pg-* path options
20
+ dir_config 'dm'
21
+ end
22
+
23
+ if ENV['DM_HOME']
24
+ if /mswin|mingw/ =~ RUBY_PLATFORM
25
+ incdir = ENV['DM_HOME'] + "\\include"
26
+ libdir = ENV['DM_HOME'] + "\\bin"
27
+ else
28
+ incdir = ENV['DM_HOME'] + '/include'
29
+ libdir = ENV['DM_HOME'] + '/bin'
30
+ end
31
+ dlldir = libdir
32
+ dir_config('dm',incdir,libdir)
33
+ # Try to use runtime path linker option, even if RbConfig doesn't know about it.
34
+ # The rpath option is usually set implicit by dir_config(), but so far not
35
+ # on MacOS-X.
36
+ if dlldir && RbConfig::CONFIG["RPATHFLAG"].to_s.empty?
37
+ append_ldflags "-Wl,-rpath,#{dlldir.quote}"
38
+ end
39
+
40
+ if /mswin/ =~ RUBY_PLATFORM
41
+ $libs = append_library($libs, 'ws2_32')
42
+ end
43
+
44
+ else
45
+ # Native build
46
+ incdir, libdir = dir_config 'dm'
47
+ dlldir = libdir
48
+
49
+ # Try to use runtime path linker option, even if RbConfig doesn't know about it.
50
+ # The rpath option is usually set implicit by dir_config(), but so far not
51
+ # on MacOS-X.
52
+ if dlldir && RbConfig::CONFIG["RPATHFLAG"].to_s.empty?
53
+ append_ldflags "-Wl,-rpath,#{dlldir.quote}"
54
+ end
55
+
56
+ if /mswin/ =~ RUBY_PLATFORM
57
+ $libs = append_library($libs, 'ws2_32')
58
+ end
59
+ end
60
+
61
+ $stderr.puts "Using dpi from #{dlldir}"
62
+
63
+ File.write("dm_lib_path.rb", <<-EOT)
64
+ module Dm
65
+ DM_LIB_PATH = #{dlldir.inspect}
66
+ end
67
+ EOT
68
+ $INSTALLFILES = {
69
+ "./dm_lib_path.rb" => "$(RUBYLIBDIR)/dm/"
70
+ }
71
+
72
+ if RUBY_VERSION >= '2.3.0' && /solaris/ =~ RUBY_PLATFORM
73
+ append_cppflags( '-D__EXTENSIONS__' )
74
+ end
75
+
76
+ begin
77
+ find_header( 'DPI.h' ) or abort "Can't find the DPI.h header"
78
+ find_header( 'DPIext.h' ) or abort "Can't find the DPIext.h header"
79
+ find_header( 'DPItypes.h' ) or abort "Can't find the DPItypes.h header"
80
+
81
+ abort "Can't find the DM library (dpi)" unless
82
+ have_library( 'dmdpi', 'dpi_login' ) ||
83
+ have_library( 'libdmdpi', 'dpi_login' )
84
+
85
+ rescue SystemExit
86
+ $stderr.puts <<-EOT
87
+ *****************************************************************************
88
+
89
+ Unable to find dm library.
90
+
91
+ pelease set library paths manually with:
92
+ gem install dm -- --with-dm-include=/path/to/DPI.h/ --with-pg-lib=/path/to/libdmdpi.so/
93
+
94
+ EOT
95
+ raise
96
+ end
97
+
98
+ if /mingw/ =~ RUBY_PLATFORM && RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
99
+ # Work around: https://sourceware.org/bugzilla/show_bug.cgi?id=22504
100
+ checking_for "workaround gcc version with link issue" do
101
+ `#{RbConfig::MAKEFILE_CONFIG['CC']} --version`.chomp =~ /\s(\d+)\.\d+\.\d+(\s|$)/ &&
102
+ $1.to_i >= 6 &&
103
+ have_library(':dmdpi.lib') # Prefer linking to libpq.lib over libpq.dll if available
104
+ end
105
+ end
106
+
107
+ have_func 'timegm'
108
+ have_func 'rb_gc_adjust_memory_usage' # since ruby-2.4
109
+ have_func 'rb_gc_mark_movable' # since ruby-2.7
110
+ have_func 'rb_io_wait' # since ruby-3.0
111
+ have_func 'rb_io_descriptor' # since ruby-3.1
112
+
113
+ # unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
114
+ have_header 'unistd.h'
115
+ have_header 'inttypes.h'
116
+ have_header('ruby/fiber/scheduler.h') if RUBY_PLATFORM=~/mingw|mswin/
117
+ checking_for "C99 variable length arrays" do
118
+ $defs.push( "-DHAVE_VARIABLE_LENGTH_ARRAYS" ) if try_compile('void test_vla(int l){ int vla[l]; }')
119
+ end
120
+
121
+ create_header()
122
+ create_makefile( "dm/dm_ext" )
123
+