Top Level Namespace
Defined Under Namespace
Classes: DBM, DBMError, String
Instance Method Summary collapse
- #convertible_int(type, headers = nil, opts = nil, &b) ⇒ Object
- #have_func(func, headers = nil, opt = "", &b) ⇒ Object
- #have_header(header, preheaders = nil, opt = "", &b) ⇒ Object
- #have_library(lib, func = nil, headers = nil, opt = "", &b) ⇒ Object
-
#have_libvar(var, headers = nil, opt = "", &b) ⇒ Object
END BACKPORTED FROM 2.0.
- #have_var(var, headers = nil, opt = "", &b) ⇒ Object
- #rm_f(*files) ⇒ Object
- #try_cpp(src, opt = "", *opts, &b) ⇒ Object (also: #try_header)
- #try_func(func, libs, headers = nil, opt = "", &b) ⇒ Object
- #try_libvar(var, headers = nil, opt = "", &b) ⇒ Object
- #try_var(var, headers = nil, opt = "", &b) ⇒ Object
Instance Method Details
#convertible_int(type, headers = nil, opts = nil, &b) ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'extconf.rb', line 176 def convertible_int(type, headers = nil, opts = nil, &b) type, macname = *type checking_for("convertible type of #{type}", STRING_OR_FAILED_FORMAT) do if UNIVERSAL_INTS.include?(type) type else typedef, member, prelude = typedef_expr(type, headers, &b) if member prelude << "static rbcv_typedef_ rbcv_var;" compat = UNIVERSAL_INTS.find {|t| try_static_assert("sizeof(rbcv_var.#{member}) == sizeof(#{t})", [prelude], opts, &b) } else next unless signed = try_signedness(typedef, member, [prelude]) u = "unsigned " if signed > 0 prelude << "extern rbcv_typedef_ foo();" compat = UNIVERSAL_INTS.find {|t| try_compile([prelude, "extern #{u}#{t} foo();"].join("\n"), opts, :werror=>true, &b) } end if compat macname ||= type.sub(/_(?=t\z)/, '').tr_cpp conv = (compat == "long long" ? "LL" : compat.upcase) compat = "#{u}#{compat}" typename = type.tr_cpp $defs.push(format("-DSIZEOF_%s=SIZEOF_%s", typename, compat.tr_cpp)) $defs.push(format("-DTYPEOF_%s=%s", typename, compat.quote)) $defs.push(format("-DPRI_%s_PREFIX=PRI_%s_PREFIX", macname, conv)) conv = (u ? "U" : "") + conv $defs.push(format("-D%s2NUM=%s2NUM", macname, conv)) $defs.push(format("-DNUM2%s=NUM2%s", macname, conv)) compat end end end end |
#have_func(func, headers = nil, opt = "", &b) ⇒ Object
135 136 137 138 139 140 141 142 143 144 |
# File 'extconf.rb', line 135 def have_func(func, headers = nil, opt = "", &b) checking_for (func.funcall_style, headers, opt) do if try_func(func, $libs, headers, opt, &b) $defs << "-DHAVE_#{func.sans_arguments.tr_cpp}" true else false end end end |
#have_header(header, preheaders = nil, opt = "", &b) ⇒ Object
165 166 167 168 169 170 171 172 173 174 |
# File 'extconf.rb', line 165 def have_header(header, preheaders = nil, opt = "", &b) checking_for header do if try_header(cpp_include(preheaders)+cpp_include(header), opt, &b) $defs.push(format("-DHAVE_%s", header.tr_cpp)) true else false end end end |
#have_library(lib, func = nil, headers = nil, opt = "", &b) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'extconf.rb', line 117 def have_library(lib, func = nil, headers = nil, opt = "", &b) func = "main" if !func or func.empty? lib = with_config(lib+'lib', lib) checking_for (func.funcall_style, LIBARG%lib, opt) do if COMMON_LIBS.include?(lib) true else libs = append_library($libs, lib) if try_func(func, libs, headers, opt, &b) $libs = libs true else false end end end end |
#have_libvar(var, headers = nil, opt = "", &b) ⇒ Object
END BACKPORTED FROM 2.0
214 215 216 217 218 |
# File 'extconf.rb', line 214 def have_libvar(var, headers = nil, opt = "", &b) checking_for ([*var].compact.join(' '), headers, opt) do try_libvar(var, headers, opt, &b) end end |
#have_var(var, headers = nil, opt = "", &b) ⇒ Object
146 147 148 149 150 151 152 153 154 155 |
# File 'extconf.rb', line 146 def have_var(var, headers = nil, opt = "", &b) checking_for (var, headers, opt) do if try_var(var, headers, opt, &b) $defs.push(format("-DHAVE_%s", var.tr_cpp)) true else false end end end |
#rm_f(*files) ⇒ Object
64 65 66 67 |
# File 'extconf.rb', line 64 def rm_f(*files) opt = (Hash === files.last ? [files.pop] : []) FileUtils.rm_f(Dir[*files.flatten], *opt) end |
#try_cpp(src, opt = "", *opts, &b) ⇒ Object Also known as: try_header
157 158 159 160 161 |
# File 'extconf.rb', line 157 def try_cpp(src, opt="", *opts, &b) try_do(src, cpp_command(CPPOUTFILE, opt), *opts, &b) ensure rm_f "conftest*" end |
#try_func(func, libs, headers = nil, opt = "", &b) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'extconf.rb', line 69 def try_func(func, libs, headers = nil, opt = "", &b) headers = cpp_include(headers) case func when /^&/ decltype = proc {|x|"const volatile void *#{x}"} when /\)$/ call = func else call = "#{func}()" decltype = proc {|x| "void ((*#{x})())"} end if opt and !opt.empty? [[:to_str], [:join, " "], [:to_s]].each do |meth, *args| if opt.respond_to?(meth) break opt = opt.send(meth, *args) end end opt = "#{opt} #{libs}" else opt = libs end decltype && try_link(<<"SRC", opt, &b) or call && try_link(<<"SRC", opt, &b) #{headers} /*top*/ #{MAIN_DOES_NOTHING} extern int t(void); int t(void) { #{call}; return 0; } SRC end |
#try_libvar(var, headers = nil, opt = "", &b) ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'extconf.rb', line 220 def try_libvar(var, headers = nil, opt = "", &b) var, type = *var if try_link(<<"SRC", opt, &b) #{cpp_include(headers)} /*top*/ int main(int argc, char *argv[]) { typedef #{type || 'int'} conftest_type; extern conftest_type #{var}; conftest_type *conftest_var = &#{var}; return 0; } SRC $defs.push(format("-DHAVE_LIBVAR_%s", var.tr_cpp)) true else false end end |
#try_var(var, headers = nil, opt = "", &b) ⇒ Object
106 107 108 109 110 111 112 113 114 115 |
# File 'extconf.rb', line 106 def try_var(var, headers = nil, opt = "", &b) headers = cpp_include(headers) try_compile(<<"SRC", opt, &b) #{headers} /*top*/ #{MAIN_DOES_NOTHING} extern int t(void); int t(void) { const volatile void *volatile p; p = &(&#{var})[0]; return 0; } SRC end |