@@ -98,20 +98,32 @@ def asplode lib
98
98
$CFLAGS << gcc_flags
99
99
end
100
100
101
- if libdir = rpath_dir [ %r{(-L)?(/[^ ]+)} , 2 ]
102
- rpath_flags = " -Wl,-rpath,#{ libdir } "
103
- if RbConfig ::CONFIG [ "RPATHFLAG" ] . to_s . empty? && try_link ( 'int main() {return 0;}' , rpath_flags )
104
- # Usually Ruby sets RPATHFLAG the right way for each system, but not on OS X.
105
- warn "-----\n Setting rpath to #{ libdir } \n -----"
106
- $LDFLAGS << rpath_flags
107
- else
108
- if RbConfig ::CONFIG [ "RPATHFLAG" ] . to_s . empty?
109
- # If we got here because try_link failed, warn the user
110
- warn "-----\n Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load\n -----"
101
+ case explicit_rpath = with_config ( 'mysql-rpath' )
102
+ when true
103
+ abort "-----\n Option --with-mysql-rpath must have an argument\n -----"
104
+ when false
105
+ warn "-----\n Option --with-mysql-rpath has been disabled at your request\n -----"
106
+ when String
107
+ # The user gave us a value so use it
108
+ rpath_flags = " -Wl,-rpath,#{ explicit_rpath } "
109
+ warn "-----\n Setting mysql rpath to #{ explicit_rpath } \n -----"
110
+ $LDFLAGS << rpath_flags
111
+ else
112
+ if libdir = rpath_dir [ %r{(-L)?(/[^ ]+)} , 2 ]
113
+ rpath_flags = " -Wl,-rpath,#{ libdir } "
114
+ if RbConfig ::CONFIG [ "RPATHFLAG" ] . to_s . empty? && try_link ( 'int main() {return 0;}' , rpath_flags )
115
+ # Usually Ruby sets RPATHFLAG the right way for each system, but not on OS X.
116
+ warn "-----\n Setting rpath to #{ libdir } \n -----"
117
+ $LDFLAGS << rpath_flags
118
+ else
119
+ if RbConfig ::CONFIG [ "RPATHFLAG" ] . to_s . empty?
120
+ # If we got here because try_link failed, warn the user
121
+ warn "-----\n Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load\n -----"
122
+ end
123
+ # Make sure that LIBPATH gets set if we didn't explicitly set the rpath.
124
+ warn "-----\n Setting libpath to #{ libdir } \n -----"
125
+ $LIBPATH << libdir unless $LIBPATH. include? ( libdir )
111
126
end
112
- # Make sure that LIBPATH gets set if we didn't explicitly set the rpath.
113
- warn "-----\n Setting libpath to #{ libdir } \n -----"
114
- $LIBPATH << libdir unless $LIBPATH. include? ( libdir )
115
127
end
116
128
end
117
129
0 commit comments