From 4f26f3b8902a59ec27070f8cf1fd038561894f4d Mon Sep 17 00:00:00 2001 From: eban Date: Sun, 8 Sep 2002 09:08:15 +0000 Subject: * configure.in: modify program_prefix only if specified --program-prefix. * configure.in: don't generate ext/extmk.rb. * Makefile.in: execute directly $(srcdir)/ext/extmk.rb. remove -Cext option, "Dir::chdir 'ext'" in ext/extmk.rb. * {win32,bccwin32}/Makefile.sub: ditto. * instruby.rb: ditto. * ext/extmk.rb: renamed from ext/extmk.rb.in. * lib/mkmf.rb (module Logging): create log files (mkmf.log) in each extension module directories. * ext/extmk.rb: ditto. * lib/mkmf.rb (macro_defined?): new method. * ext/.cvsignore: remove extmk.rb. * ext/*/.cvsignore: add "*.def". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/mkmf.rb | 62 +++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 22 deletions(-) (limited to 'lib') diff --git a/lib/mkmf.rb b/lib/mkmf.rb index ff00be2451..68b324a825 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -80,14 +80,18 @@ end if /mswin32/ =~ RUBY_PLATFORM OUTFLAG = '-Fe' + CPPOUTFILE = '-P' elsif /bccwin32/ =~ RUBY_PLATFORM OUTFLAG = '-o' + CPPOUTFILE = '-oconftest.i' else OUTFLAG = '-o ' + CPPOUTFILE = '-o conftest.i' end + $LINK = "#{CONFIG['CC']} #{OUTFLAG}conftest -I#{$hdrdir} #{CFLAGS} %s %s #{CONFIG['LDFLAGS']} %s conftest.c %s %s #{CONFIG['LIBS']}" $CC = "#{CONFIG['CC']} -c #{CONFIG['CPPFLAGS']} %s -I#{$hdrdir} #{CFLAGS} %s %s conftest.c" -$CPP = "#{CONFIG['CPP']} #{CONFIG['CPPFLAGS']} %s -I#{$hdrdir} #{CFLAGS} %s %s conftest.c" +$CPP = "#{CONFIG['CPP']} #{CONFIG['CPPFLAGS']} %s -I#{$hdrdir} #{CFLAGS} %s %s %s conftest.c" def rm_f(*files) targets = [] @@ -113,28 +117,34 @@ def older(file1, file2) return false end -$log = nil -$orgerr = $stderr.dup -$orgout = $stdout.dup -$extmk = /extmk\.rb/ =~ $0 +module Logging + @log = nil + @logfile = 'mkmf.log' + @orgerr = $stderr.dup + @orgout = $stdout.dup -def logging - if $DEBUG - return yield + def self::open + @log ||= File::open(@logfile, 'w') + $stderr.reopen(@log) + $stdout.reopen(@log) + yield + ensure + $stderr.reopen(@orgerr) + $stdout.reopen(@orgout) + end + + def self::logfile file + @logfile = file + if @log and not @log.closed? + @log.close + @log = nil + end end - logfile = $extmk ? File.join($topdir, 'ext', 'extmk.log') : 'mkmf.log' - $log ||= open(logfile, 'w') - $stderr.reopen($log) - $stdout.reopen($log) - yield -ensure - $stderr.reopen($orgerr) - $stdout.reopen($orgout) end def xsystem command Config.expand(command) - logging do + Logging::open do puts command system(command) end @@ -142,7 +152,7 @@ end def xpopen command, *mode, &block Config.expand(command) - logging do + Logging::open do case mode[0] when nil, /^r/ puts "#{command} |" @@ -194,12 +204,20 @@ def try_compile(src, opt="") end end +def macro_defined?(macro, src, opt="") + try_cpp(src + <