Index: lib/mkmf.rb =================================================================== --- lib/mkmf.rb (revision 33817) +++ lib/mkmf.rb (working copy) @@ -6,6 +6,37 @@ require 'rbconfig' require 'fileutils' require 'shellwords' +# :stopdoc: +class String + # Wraps a string in escaped quotes if it contains whitespace. + def quote + /\s/ =~ self ? "\"#{self}\"" : "#{self}" + end + + # Generates a string used as cpp macro name. + def tr_cpp + strip.upcase.tr_s("^A-Z0-9_*", "_").tr_s("*", "P") + end + + def funcall_style + /\)\z/ =~ self ? dup : "#{self}()" + end + + def sans_arguments + self[/\A[^()]+/] + end +end + +class Array + # Wraps all strings in escaped quotes if they contain whitespace. + def quote + map {|s| s.quote} + end +end +# :startdoc: + +module MakeMakefile + CONFIG = RbConfig::MAKEFILE_CONFIG ORIG_LIBPATH = ENV['LIB'] @@ -75,10 +106,12 @@ $dest_prefix_pattern = (File::PATH_SEPAR def config_string(key, config = CONFIG) s = config[key] and !s.empty? and block_given? ? yield(s) : s end + module_function :config_string def dir_re(dir) Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$(?:\(target_prefix\)|\{target_prefix\}))?') end + module_function :dir_re def relative_from(path, base) dir = File.join(path, "") @@ -176,32 +209,6 @@ CPPOUTFILE = CONFIG['CPPOUTFILE'] CONFTEST_C = "conftest.c".freeze -class String - # Wraps a string in escaped quotes if it contains whitespace. - def quote - /\s/ =~ self ? "\"#{self}\"" : "#{self}" - end - - # Generates a string used as cpp macro name. - def tr_cpp - strip.upcase.tr_s("^A-Z0-9_*", "_").tr_s("*", "P") - end - - def funcall_style - /\)\z/ =~ self ? dup : "#{self}()" - end - - def sans_arguments - self[/\A[^()]+/] - end -end -class Array - # Wraps all strings in escaped quotes if they contain whitespace. - def quote - map {|s| s.quote} - end -end - def rm_f(*files) opt = (Hash === files.last ? [files.pop] : []) FileUtils.rm_f(Dir[*files.flatten], *opt) @@ -519,9 +526,7 @@ ensure rm_f "conftest*" end -class Object alias_method :try_header, (config_string('try_header') || :try_cpp) -end def cpp_include(header) if header @@ -2244,6 +2249,7 @@ end # :startdoc: + def make_makefile init_mkmf $make = with_config("make-prog", ENV["MAKE"] || "make") @@ -2272,6 +2278,7 @@ end $configure_args["--topdir"] ||= $curdir $ruby = arg_config("--ruby", File.join(RbConfig::CONFIG["bindir"], CONFIG["ruby_install_name"])) + end split = Shellwords.method(:shellwords).to_proc EXPORT_PREFIX = config_string('EXPORT_PREFIX') {|s| s.strip} @@ -2330,7 +2337,13 @@ distclean: clean distclean-so distclean- realclean: distclean " +end + +include MakeMakefile if not $extmk and /\A(extconf|makefile).rb\z/ =~ File.basename($0) END {mkmf_failed($0)} end + +make_makefile +