1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* configure.in (RUBY_MINGW32): new macro. check for the MinGW

compiler envionment.
* lib/mkmf.rb: refactoring.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eban 2002-09-23 11:01:49 +00:00
parent 1eab34576a
commit 849b1000b0
3 changed files with 144 additions and 113 deletions

View file

@ -1,3 +1,10 @@
Mon Sep 23 19:57:52 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* configure.in (RUBY_MINGW32): new macro. check for the MinGW
compiler envionment.
* lib/mkmf.rb: refactoring.
Sun Sep 22 21:49:42 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* eval.c (call_trace_func): should not call trace function while

View file

@ -3,6 +3,35 @@ AC_INIT()
AC_PREREQ(2.50)
AC_DEFUN(RUBY_MINGW32,
[case "$host_os" in
cygwin*)
AC_CACHE_CHECK(for mingw32 environment, rb_cv_mingw32,
[AC_TRY_CPP([
#ifndef __MINGW32__
# error
#endif
], rb_cv_mingw32=yes,rb_cv_mingw32=no)
rm -f conftest*])
test "$rb_cv_mingw32" = yes && target_os="mingw32"
;;
esac])
AC_DEFUN(RUBY_CPPOUTFILE,
[AC_CACHE_CHECK(whether ${CPP} accepts -o, rb_cv_cppoutfile,
[cppflags=$CPPFLAGS
CPPFLAGS='-o conftest.i'
AC_TRY_CPP([], rb_cv_cppoutfile=yes, rb_cv_cppoutfile=no)
if test "$rb_cv_cppoutfile" = yes; then
CPPOUTFILE=$CPPFLAGS
else
CPPOUTFILE='> conftest.i'
fi
CPPFLAGS=$cppflags
AC_SUBST(CPPOUTFILE)
rm -f conftest*])
])
rb_version=`grep RUBY_VERSION $srcdir/version.h`
MAJOR=`expr "$rb_version" : '#define RUBY_VERSION "\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*"'`
MINOR=`expr "$rb_version" : '#define RUBY_VERSION "[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*"'`
@ -98,16 +127,13 @@ fi
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL
echo 'foo(){}' > conftest.c
if ${CPP} -o conftest.i conftest.c >/dev/null 2>&1; then
CPPOUTFILE='-o conftest.i'
else
CPPOUTFILE='> conftest.i'
fi
AC_SUBST(CPPOUTFILE)
RUBY_CPPOUTFILE
OUTFLAG='-o '
AC_SUBST(OUTFLAG)
RUBY_MINGW32
AC_PROG_YACC
AC_CHECK_TOOL(RANLIB, ranlib, :)
AC_CHECK_TOOL(AR, ar)

View file

@ -44,6 +44,12 @@ $sitelibdir = CONFIG["sitelibdir"]
$sitearchdir = CONFIG["sitearchdir"]
$extmk = /extmk\.rb/ =~ $0
$mswin = /mswin/ =~ RUBY_PLATFORM
$bccwin = /bccwin/ =~ RUBY_PLATFORM
$mingw = /mingw/ =~ RUBY_PLATFORM
$cygwin = /cygwin/ =~ RUBY_PLATFORM
$human = /human/ =~ RUBY_PLATFORM
$netbsd = /netbsd/ =~ RUBY_PLATFORM
def dir_re(dir)
Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$\(target_prefix\)|\{target_prefix\})?')
@ -73,7 +79,7 @@ end
$topdir = $hdrdir
CFLAGS = CONFIG["CFLAGS"]
if RUBY_PLATFORM == "m68k-human"
if $human
CFLAGS.gsub!(/-c..-stack=[0-9]+ */, '')
elsif RUBY_PLATFORM =~ /-nextstep|-rhapsody|-darwin/
CFLAGS.gsub!( /-arch\s\w*/, '' )
@ -82,12 +88,10 @@ end
OUTFLAG = CONFIG['OUTFLAG']
CPPOUTFILE = CONFIG['CPPOUTFILE']
$LINK = "#{CONFIG['CC']} #{OUTFLAG}conftest %s -I#{$hdrdir} %s #{CFLAGS} %s #{CONFIG['LDFLAGS']} %s conftest.c %s %s #{CONFIG['LIBS']}"
$CC = "#{CONFIG['CC']} -c #{CONFIG['CPPFLAGS']} %s -I#{$hdrdir} %s #{CFLAGS} %s %s conftest.c"
$CPP = "#{CONFIG['CPP']} #{CONFIG['CPPFLAGS']} %s -I#{$hdrdir} %s #{CFLAGS} %s %s %s conftest.c"
LIBPATHFLAG = $mswin ? ' -libpath:' : ' -L'
CONFTEST_C = "conftest.c"
$INSTALLFILES = nil unless defined? $INSTALLFILES
$INSTALLFILES ||= nil
def rm_f(*files)
targets = []
@ -164,109 +168,109 @@ def xpopen command, *mode, &block
end
end
def try_link0(src, opt="")
src = "/* begin */\n#{src}/* end */\n"
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
ldflags = $LDFLAGS
if /mswin32|bccwin32/ =~ RUBY_PLATFORM and !$LIBPATH.empty?
ENV['LIB'] = ($LIBPATH + [ORIG_LIBPATH]).compact.join(';')
else
$LDFLAGS = ldflags.dup
$LIBPATH.each {|d| $LDFLAGS << " -L" + d}
end
begin
xsystem(format($LINK, $INCFLAGS, $CPPFLAGS, $CFLAGS, $LDFLAGS, opt, $LOCAL_LIBS))
ensure
$LDFLAGS = ldflags
ENV['LIB'] = ORIG_LIBPATH if /mswin32|bccwin32/ =~ RUBY_PLATFORM
Logging::message <<"EOM"
def log_src(src)
Logging::message <<"EOM"
checked program was:
#{src}
/* begin */
#{src}/* end */
EOM
end
def create_tmpsrc(src)
open(CONFTEST_C, "w") do |cfile|
cfile.print src
end
end
def try_do(src, command)
src += "\n" unless /\n\z/ =~ src
create_tmpsrc(src)
xsystem(command)
ensure
log_src(src)
end
def link_command(ldflags, opt="")
# ldflags = "-link " + ldflags if $mswin
"$(CC) #{OUTFLAG}conftest #$INCFLAGS -I#{$hdrdir} " \
"#$CPPFLAGS $(CFLAGS) #$CFLAGS #{CONFTEST_C} #{opt} " \
"#$LOCAL_LIBS $(LIBS) #{ldflags} $(LDFLAGS) #$LDFLAGS"
end
def cc_command(opt="")
"$(CC) -c $(CPPFLAGS) #$INCFLAGS -I#{$hdrdir} " \
"#$CPPFLAGS $(CFLAGS) #$CFLAGS #{opt} #{CONFTEST_C}"
end
def cpp_command(outfile, opt="")
"$(CPP) $(CPPFLAGS) #$INCFLAGS -I#{$hdrdir} " \
"#$CPPFLAGS $(CFLAGS) #$CFLAGS #{outfile} #{opt} #{CONFTEST_C}"
end
def libpathflag
if $mswin
ENV['LIB'] = ($LIBPATH + [ORIG_LIBPATH]).join(';')
yield ""
ENV['LIB'] = ORIG_LIBPATH
else
yield $LIBPATH.map{|x| %Q[#{LIBPATHFLAG}"#{x}"]}.join
end
end
def try_link0(src, opt="")
libpathflag do |flag|
try_do(src, link_command(flag, opt))
end
end
def try_link(src, opt="")
begin
try_link0(src, opt)
ensure
rm_f "conftest*"
if /bccwin32/ =~ RUBY_PLATFORM
rm_f "c0x32*"
end
end
try_link0(src, opt)
ensure
rm_f "conftest*", "c0x32*"
end
def try_compile(src, opt="")
src = "/* begin */\n#{src}/* end */\n"
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
begin
xsystem(format($CC, $INCFLAGS, $CPPFLAGS, $CFLAGS, opt))
ensure
rm_f "conftest*"
Logging::message <<"EOM"
checked program was:
#{src}
EOM
end
try_do(src, cc_command(opt))
ensure
rm_f "conftest*"
end
def try_cpp(src, opt="")
src = "/* begin */\n#{src}/* end */\n"
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
begin
xsystem(format($CPP, $INCFLAGS, $CPPFLAGS, $CFLAGS, CPPOUTFILE, opt))
ensure
rm_f "conftest*"
Logging::message <<"EOM"
checked program was:
#{src}
EOM
end
try_do(src, cpp_command(CPPOUTFILE, opt))
ensure
rm_f "conftest*"
end
def egrep_cpp(pat, src, opt="")
src = "/* begin */\n#{src}/* end */\n"
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
begin
xpopen(format($CPP, $INCFLAGS, $CPPFLAGS, $CFLAGS, '', 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
src += "\n" unless /\n\z/ =~ src
create_tmpsrc(src)
xpopen(cpp_command('', 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
ensure
rm_f "conftest*"
Logging::message <<"EOM"
checked program was:
#{src}
EOM
end
ensure
rm_f "conftest*"
log_src(src)
end
def macro_defined?(macro, src, opt="")
try_cpp(src + <<SRC, opt)
try_cpp(src + <<"SRC", opt)
#ifndef #{macro}
# error
#endif
@ -274,19 +278,13 @@ SRC
end
def try_run(src, opt="")
begin
if try_link0(src, opt)
if xsystem("./conftest")
true
else
false
end
else
nil
end
ensure
rm_f "conftest*"
if try_link0(src, opt)
xsystem("./conftest")
else
nil
end
ensure
rm_f "conftest*"
end
def install_files(mfile, ifiles, map = INSTALL_DIRS, srcprefix = nil)
@ -347,7 +345,7 @@ end
def have_library(lib, func="main")
message "checking for #{func}() in -l#{lib}... "
Logging::message"checking for #{func}() in -l#{lib}\n"
Logging::message"have_library: checking for #{func}() in -l#{lib}\n"
if func && func != ""
libs = append_library($libs, lib)
@ -393,7 +391,7 @@ end
def find_library(lib, func, *paths)
message "checking for #{func}() in -l#{lib}... "
Logging::message"checking for #{func}() in -l#{lib}\n"
Logging::message"find_library: checking for #{func}() in -l#{lib}\n"
libpath = $LIBPATH
libs = append_library($libs, lib)
@ -415,7 +413,7 @@ end
def have_func(func, header=nil)
message "checking for #{func}()... "
Logging::message"checking for #{func}()\n"
Logging::message"have_func: checking for #{func}()\n"
libs = $libs
src =
@ -454,7 +452,7 @@ end
def have_header(header)
message "checking for #{header}... "
Logging::message"checking for #{header}\n"
Logging::message"have_header: checking for #{header}\n"
unless try_cpp(<<"SRC")
#include <#{header}>
@ -469,7 +467,7 @@ end
def have_struct_member(type, member, header=nil)
message "checking for #{type}.#{member}... "
Logging::message "checking for #{type}.#{member}\n"
Logging::message "have_struct_member: checking for #{type}.#{member}\n"
src =
if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM
@ -505,7 +503,7 @@ end
def find_executable(bin, path = nil)
message "checking for #{bin}... "
Logging::message "checking for #{bin}\n"
Logging::message "find_executable: checking for #{bin}\n"
if path.nil?
path = ENV['PATH'].split(Config::CONFIG['PATH_SEPARATOR'])