@@ -94,43 +94,14 @@ def asplode lib
94
94
$CFLAGS << gcc_flags
95
95
end
96
96
97
- case explicit_rpath = with_config ( 'mysql-rpath' )
98
- when true
99
- abort "-----\n Option --with-mysql-rpath must have an argument\n -----"
100
- when false
101
- warn "-----\n Option --with-mysql-rpath has been disabled at your request\n -----"
102
- when String
103
- # The user gave us a value so use it
104
- rpath_flags = " -Wl,-rpath,#{ explicit_rpath } "
105
- warn "-----\n Setting mysql rpath to #{ explicit_rpath } \n -----"
106
- $LDFLAGS << rpath_flags
107
- else
108
- if libdir = rpath_dir [ %r{(-L)?(/[^ ]+)} , 2 ]
109
- rpath_flags = " -Wl,-rpath,#{ libdir } "
110
- if RbConfig ::CONFIG [ "RPATHFLAG" ] . to_s . empty? && try_link ( 'int main() {return 0;}' , rpath_flags )
111
- # Usually Ruby sets RPATHFLAG the right way for each system, but not on OS X.
112
- warn "-----\n Setting rpath to #{ libdir } \n -----"
113
- $LDFLAGS << rpath_flags
114
- else
115
- if RbConfig ::CONFIG [ "RPATHFLAG" ] . to_s . empty?
116
- # If we got here because try_link failed, warn the user
117
- warn "-----\n Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load\n -----"
118
- end
119
- # Make sure that LIBPATH gets set if we didn't explicitly set the rpath.
120
- warn "-----\n Setting libpath to #{ libdir } \n -----"
121
- $LIBPATH << libdir unless $LIBPATH. include? ( libdir )
122
- end
123
- end
124
- end
125
-
126
97
if RUBY_PLATFORM =~ /mswin|mingw/
127
98
# Build libmysql.a interface link library
128
99
require 'rake'
129
100
130
101
# Build libmysql.a interface link library
131
102
# Use rake to rebuild only if these files change
132
103
deffile = File . expand_path ( '../../../support/libmysql.def' , __FILE__ )
133
- libfile = File . expand_path ( File . join ( libdir , 'libmysql.lib' ) )
104
+ libfile = File . expand_path ( File . join ( rpath_dir , 'libmysql.lib' ) )
134
105
file 'libmysql.a' => [ deffile , libfile ] do |t |
135
106
when_writing 'building libmysql.a' do
136
107
sh 'dlltool' , '--kill-at' ,
@@ -149,7 +120,7 @@ def asplode lib
149
120
150
121
# Vendor libmysql.dll
151
122
vendordll = File . expand_path ( '../../../vendor/libmysql.dll' , __FILE__ )
152
- dllfile = File . expand_path ( File . join ( libdir , 'libmysql.dll' ) )
123
+ dllfile = File . expand_path ( File . join ( rpath_dir , 'libmysql.dll' ) )
153
124
file vendordll => dllfile do |t |
154
125
when_writing 'copying libmysql.dll' do
155
126
cp dllfile , vendordll
@@ -164,6 +135,35 @@ def asplode lib
164
135
# Let's do it!
165
136
Rake ::Task [ vendordll ] . invoke
166
137
end
138
+ else
139
+ case explicit_rpath = with_config ( 'mysql-rpath' )
140
+ when true
141
+ abort "-----\n Option --with-mysql-rpath must have an argument\n -----"
142
+ when false
143
+ warn "-----\n Option --with-mysql-rpath has been disabled at your request\n -----"
144
+ when String
145
+ # The user gave us a value so use it
146
+ rpath_flags = " -Wl,-rpath,#{ explicit_rpath } "
147
+ warn "-----\n Setting mysql rpath to #{ explicit_rpath } \n -----"
148
+ $LDFLAGS << rpath_flags
149
+ else
150
+ if libdir = rpath_dir [ %r{(-L)?(/[^ ]+)} , 2 ]
151
+ rpath_flags = " -Wl,-rpath,#{ libdir } "
152
+ if RbConfig ::CONFIG [ "RPATHFLAG" ] . to_s . empty? && try_link ( 'int main() {return 0;}' , rpath_flags )
153
+ # Usually Ruby sets RPATHFLAG the right way for each system, but not on OS X.
154
+ warn "-----\n Setting rpath to #{ libdir } \n -----"
155
+ $LDFLAGS << rpath_flags
156
+ else
157
+ if RbConfig ::CONFIG [ "RPATHFLAG" ] . to_s . empty?
158
+ # If we got here because try_link failed, warn the user
159
+ warn "-----\n Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load\n -----"
160
+ end
161
+ # Make sure that LIBPATH gets set if we didn't explicitly set the rpath.
162
+ warn "-----\n Setting libpath to #{ libdir } \n -----"
163
+ $LIBPATH << libdir unless $LIBPATH. include? ( libdir )
164
+ end
165
+ end
166
+ end
167
167
end
168
168
169
169
create_makefile ( 'mysql2/mysql2' )
0 commit comments