From 162b04061133c92f3b703c245eecfd0e0b6c5636 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 30 Mar 2005 14:45:05 +0000 Subject: * Makefile.in, */Makefile.sub, */configure.bat, cygwin/GNUmakefile.in, common.mk, configure.in, ext/extmk.rb, lib/mkmf.rb, instruby.rb, runruby.rb: backport extout. [ruby-dev:25963] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/mkmf.rb | 261 +++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 198 insertions(+), 63 deletions(-) (limited to 'lib') diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 5c4917c944..2222eb5705 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -40,7 +40,6 @@ unless defined? $configure_args end end -$srcdir = nil $libdir = CONFIG["libdir"] $rubylibdir = CONFIG["rubylibdir"] $archdir = CONFIG["archdir"] @@ -55,6 +54,8 @@ $cygwin = /cygwin/ =~ RUBY_PLATFORM $human = /human/ =~ RUBY_PLATFORM $netbsd = /netbsd/ =~ RUBY_PLATFORM $os2 = /os2/ =~ RUBY_PLATFORM +$beos = /beos/ =~ RUBY_PLATFORM +$solaris = /solaris/ =~ RUBY_PLATFORM def config_string(key, config = CONFIG) s = config[key] and !s.empty? and block_given? ? yield(s) : s @@ -73,6 +74,32 @@ INSTALL_DIRS = [ [dir_re('sitearchdir'), "$(RUBYARCHDIR)"] ] +def install_dirs(target_prefix = nil) + if $extout + dirs = [ + ['RUBYCOMMONDIR', '$(extout)'], + ['RUBYLIBDIR', '$(extout)$(target_prefix)'], + ['RUBYARCHDIR', '$(extout)/$(arch)$(target_prefix)'], + ['extout', "#$extout"], + ['extout_prefix', "#$extout_prefix"], + ] + elsif $extmk + dirs = [ + ['RUBYCOMMONDIR', '$(rubylibdir)'], + ['RUBYLIBDIR', '$(rubylibdir)$(target_prefix)'], + ['RUBYARCHDIR', '$(archdir)$(target_prefix)'], + ] + else + dirs = [ + ['RUBYCOMMONDIR', '$(sitedir)$(target_prefix)'], + ['RUBYLIBDIR', '$(sitelibdir)$(target_prefix)'], + ['RUBYARCHDIR', '$(sitearchdir)$(target_prefix)'], + ] + end + dirs << ['target_prefix', (target_prefix ? "/#{target_prefix}" : "")] + dirs +end + def map_dir(dir, map = nil) map ||= INSTALL_DIRS map.inject(dir) {|dir, (orig, new)| dir.gsub(orig, new)} @@ -290,6 +317,30 @@ def cpp_include(header) end end +def with_cppflags(flags) + cppflags = $CPPFLAGS + $CPPFLAGS = flags + ret = yield +ensure + $CPPFLAGS = cppflags unless ret +end + +def with_cflags(flags) + cflags = $CFLAGS + $CFLAGS = flags + ret = yield +ensure + $CFLAGS = cflags unless ret +end + +def with_ldflags(flags) + ldflags = $LDFLAGS + $LDFLAGS = flags + ret = yield +ensure + $LDFLAGS = ldflags unless ret +end + def try_static_assert(expr, headers = nil, opt = "", &b) headers = cpp_include(headers) try_compile(< /dev/null || true" + unless $static.nil? + mfile.print "$(STATIC_LIB): $(OBJS)\n\t" + mfile.print "$(AR) #{config_string('ARFLAGS') || 'cru '}$@ $(OBJS)" + config_string('RANLIB') do |ranlib| + mfile.print "\n\t@-#{ranlib} $(DLLIB) 2> /dev/null || true" + end end mfile.print "\n\n" if makedef @@ -1000,15 +1089,53 @@ static: $(STATIC_LIB) if File.exist?(depend) open(depend, "r") do |dfile| mfile.printf "###\n" + cont = implicit = nil + impconv = proc do + COMPILE_RULES.each {|rule| mfile.print(rule % implicit[0], implicit[1])} + implicit = nil + end + ruleconv = proc do |line| + if implicit + if /\A\t/ =~ line + implicit[1] << line + next + else + impconv[] + end + end + if m = /\A\.(\w+)\.(\w+)(?:\s*:)/.match(line) + implicit = [[m[1], m[2]], [m.post_match]] + next + elsif RULE_SUBST and /\A[$\w][^#]*:/ =~ line + line.gsub!(%r"(\s)(?!\.)([^$(){}+=:\s\/\\,]+)(?=\s|\z)") {$1 + RULE_SUBST % $2} + end + mfile.print line + end while line = dfile.gets() line.gsub!(/\.o\b/, ".#{$OBJEXT}") - if $nmake - line.gsub!(%r"(\s)([^\s\/]+\.(?:#{(SRC_EXT + ['h']).join('|')}))(?=\s|\z)", '\1{.;$(VPATH)}\2') - end line.gsub!(/\$\(hdrdir\)\/config.h/, $config_h) if $config_h - mfile.print line + if /(?:^|[^\\])(?:\\\\)*\\$/ =~ line + (cont ||= []) << line + next + elsif cont + line = (cont << line).join + cont = nil + end + ruleconv.call(line) + end + if cont + ruleconv.call(cont.join) + elsif implicit + impconv.call end end + else + headers = %w[ruby.h defines.h] + if RULE_SUBST + headers.each {|h| h.sub!(/.*/) {|*m| RULE_SUBST % m}} + end + headers << $config_h if $config_h + mfile.print "$(OBJS): ", headers.join(' '), "\n" end $makefile_created = true @@ -1044,14 +1171,17 @@ def init_mkmf(config = CONFIG) $LOCAL_LIBS = "" - $cleanfiles = [] - $distcleanfiles = [] + $cleanfiles = config_string('CLEANFILES') {|s| Shellwords.shellwords(s)} || [] + $distcleanfiles = config_string('DISTCLEANFILES') {|s| Shellwords.shellwords(s)} || [] + + $extout ||= nil + $extout_prefix ||= nil $arg_config.clear dir_config("opt") end -FailedMassage = <