зеркало из https://github.com/github/ruby.git
* lib/mkmf.rb ($CC): command to compile C source.
* lib/mkmf.rb (try_compile): added. * lib/mkmf.rb (egrep_cpp): use internal grep when pattern is Regexp, otherwise use external egrep command but get rid of pipe of command.com. * lib/mkmf.rb (have_func): local variable should be volatile not to be eliminated by optimization. * lib/mkmf.rb (create_makefile): link with CONFIG["LIBS"]. * lib/mkmf.rb (create_makefile): emit .SUFFIXES:. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
7881363731
Коммит
a449f78c89
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
||||||
|
Fri Sep 6 20:01:38 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
|
* lib/mkmf.rb ($CC): command to compile C source.
|
||||||
|
|
||||||
|
* lib/mkmf.rb (logging): added.
|
||||||
|
|
||||||
|
* lib/mkmf.rb (try_compile): added.
|
||||||
|
|
||||||
|
* lib/mkmf.rb (egrep_cpp): use internal grep when pattern is
|
||||||
|
Regexp, otherwise use external egrep command but get rid of
|
||||||
|
pipe of command.com.
|
||||||
|
|
||||||
|
* lib/mkmf.rb (have_func): local variable should be volatile not
|
||||||
|
to be eliminated by optimization.
|
||||||
|
|
||||||
|
* lib/mkmf.rb (create_makefile): link with CONFIG["LIBS"].
|
||||||
|
|
||||||
|
* lib/mkmf.rb (create_makefile): emit .SUFFIXES:.
|
||||||
|
|
||||||
Fri Sep 6 12:11:22 2002 Minero Aoki <aamine@loveruby.net>
|
Fri Sep 6 12:11:22 2002 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
* parse.y (rb_gc_mark_parser): should mark ALL global variables
|
* parse.y (rb_gc_mark_parser): should mark ALL global variables
|
||||||
|
|
72
lib/mkmf.rb
72
lib/mkmf.rb
|
@ -86,6 +86,7 @@ else
|
||||||
OUTFLAG = '-o '
|
OUTFLAG = '-o '
|
||||||
end
|
end
|
||||||
$LINK = "#{CONFIG['CC']} #{OUTFLAG}conftest -I#{$hdrdir} #{CFLAGS} %s %s #{CONFIG['LDFLAGS']} %s conftest.c %s %s #{CONFIG['LIBS']}"
|
$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 conftest.c"
|
||||||
|
|
||||||
def rm_f(*files)
|
def rm_f(*files)
|
||||||
|
@ -117,23 +118,41 @@ $orgerr = $stderr.dup
|
||||||
$orgout = $stdout.dup
|
$orgout = $stdout.dup
|
||||||
$extmk = /extmk\.rb/ =~ $0
|
$extmk = /extmk\.rb/ =~ $0
|
||||||
|
|
||||||
def xsystem command
|
def logging
|
||||||
Config.expand(command)
|
|
||||||
if $DEBUG
|
if $DEBUG
|
||||||
puts command
|
return yield
|
||||||
return system(command)
|
|
||||||
end
|
end
|
||||||
logfile = $extmk ? File.join($topdir, 'ext', 'extmk.log') : 'mkmf.log'
|
logfile = $extmk ? File.join($topdir, 'ext', 'extmk.log') : 'mkmf.log'
|
||||||
$log ||= open(logfile, 'w')
|
$log ||= open(logfile, 'w')
|
||||||
$stderr.reopen($log)
|
$stderr.reopen($log)
|
||||||
$stdout.reopen($log)
|
$stdout.reopen($log)
|
||||||
puts command
|
yield
|
||||||
system(command)
|
|
||||||
ensure
|
ensure
|
||||||
$stderr.reopen($orgerr)
|
$stderr.reopen($orgerr)
|
||||||
$stdout.reopen($orgout)
|
$stdout.reopen($orgout)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def xsystem command
|
||||||
|
Config.expand(command)
|
||||||
|
logging do
|
||||||
|
puts command
|
||||||
|
system(command)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def xpopen command, *mode, &block
|
||||||
|
Config.expand(command)
|
||||||
|
logging do
|
||||||
|
case mode[0]
|
||||||
|
when nil, /^r/
|
||||||
|
puts "#{command} |"
|
||||||
|
else
|
||||||
|
puts "| #{command}"
|
||||||
|
end
|
||||||
|
IO.popen(command, *mode, &block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def try_link0(src, opt="")
|
def try_link0(src, opt="")
|
||||||
cfile = open("conftest.c", "w")
|
cfile = open("conftest.c", "w")
|
||||||
cfile.print src
|
cfile.print src
|
||||||
|
@ -146,7 +165,7 @@ def try_link0(src, opt="")
|
||||||
$LIBPATH.each {|d| $LDFLAGS << " -L" + d}
|
$LIBPATH.each {|d| $LDFLAGS << " -L" + d}
|
||||||
end
|
end
|
||||||
begin
|
begin
|
||||||
xsystem(Config.expand(format($LINK, $CFLAGS, $CPPFLAGS, $LDFLAGS, opt, $LOCAL_LIBS)))
|
xsystem(format($LINK, $CFLAGS, $CPPFLAGS, $LDFLAGS, opt, $LOCAL_LIBS))
|
||||||
ensure
|
ensure
|
||||||
$LDFLAGS = ldflags
|
$LDFLAGS = ldflags
|
||||||
ENV['LIB'] = ORIG_LIBPATH if /mswin32|bccwin32/ =~ RUBY_PLATFORM
|
ENV['LIB'] = ORIG_LIBPATH if /mswin32|bccwin32/ =~ RUBY_PLATFORM
|
||||||
|
@ -164,12 +183,23 @@ def try_link(src, opt="")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def try_compile(src, opt="")
|
||||||
|
cfile = open("conftest.c", "w")
|
||||||
|
cfile.print src
|
||||||
|
cfile.close
|
||||||
|
begin
|
||||||
|
xsystem(format($CC, $CPPFLAGS, $CFLAGS, opt))
|
||||||
|
ensure
|
||||||
|
rm_f "conftest*"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def try_cpp(src, opt="")
|
def try_cpp(src, opt="")
|
||||||
cfile = open("conftest.c", "w")
|
cfile = open("conftest.c", "w")
|
||||||
cfile.print src
|
cfile.print src
|
||||||
cfile.close
|
cfile.close
|
||||||
begin
|
begin
|
||||||
xsystem(Config.expand(format($CPP, $CPPFLAGS, $CFLAGS, opt)))
|
xsystem(format($CPP, $CPPFLAGS, $CFLAGS, opt))
|
||||||
ensure
|
ensure
|
||||||
rm_f "conftest*"
|
rm_f "conftest*"
|
||||||
end
|
end
|
||||||
|
@ -180,7 +210,25 @@ def egrep_cpp(pat, src, opt="")
|
||||||
cfile.print src
|
cfile.print src
|
||||||
cfile.close
|
cfile.close
|
||||||
begin
|
begin
|
||||||
xsystem(Config.expand(format($CPP, $CPPFLAGS, $CFLAGS, opt))+"|egrep #{pat}")
|
xpopen(format($CPP, $CFLAGS, $CPPFLAGS, opt)) do |f|
|
||||||
|
if Regexp === pat
|
||||||
|
puts(" ruby -ne 'print if /#{pat.source}/'")
|
||||||
|
f.grep(pat) {|l|
|
||||||
|
puts "#{f.lineno}: #{l}"
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
else
|
||||||
|
puts(" egrep '#{pat}'")
|
||||||
|
begin
|
||||||
|
stdin = $stdin.dup
|
||||||
|
$stdin.reopen(f)
|
||||||
|
system("egrep", pat)
|
||||||
|
ensure
|
||||||
|
$stdin.reopen(stdin)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
ensure
|
ensure
|
||||||
rm_f "conftest*"
|
rm_f "conftest*"
|
||||||
end
|
end
|
||||||
|
@ -347,7 +395,7 @@ SRC
|
||||||
unless r
|
unless r
|
||||||
r = try_link(src + <<"SRC", libs)
|
r = try_link(src + <<"SRC", libs)
|
||||||
int main() { return 0; }
|
int main() { return 0; }
|
||||||
int t() { void ((*p)()); p = (void ((*)()))#{func}; return 0; }
|
int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; }
|
||||||
SRC
|
SRC
|
||||||
end
|
end
|
||||||
unless r
|
unless r
|
||||||
|
@ -478,7 +526,7 @@ def create_makefile(target, srcprefix = nil)
|
||||||
end
|
end
|
||||||
$DLDFLAGS = CONFIG["DLDFLAGS"]
|
$DLDFLAGS = CONFIG["DLDFLAGS"]
|
||||||
|
|
||||||
$libs = CONFIG["LIBRUBYARG"] + " " + $libs
|
$libs = CONFIG["LIBRUBYARG"] + " " + $libs + CONFIG["LIBS"]
|
||||||
$configure_args['--enable-shared'] or $LIBPATH |= [$topdir]
|
$configure_args['--enable-shared'] or $LIBPATH |= [$topdir]
|
||||||
$LIBPATH |= [CONFIG["libdir"]]
|
$LIBPATH |= [CONFIG["libdir"]]
|
||||||
|
|
||||||
|
@ -651,6 +699,8 @@ EOMF
|
||||||
copt = '-Tc'
|
copt = '-Tc'
|
||||||
cxxopt = '-Tp'
|
cxxopt = '-Tp'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mfile.print ".SUFFIXES: .#{SRC_EXT.join(' .')} .#{$OBJEXT}\n"
|
||||||
unless /nmake/i =~ $make
|
unless /nmake/i =~ $make
|
||||||
if /bccwin32/ =~ RUBY_PLATFORM
|
if /bccwin32/ =~ RUBY_PLATFORM
|
||||||
mfile.print "
|
mfile.print "
|
||||||
|
|
Загрузка…
Ссылка в новой задаче