* 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:
parent
1eab34576a
commit
849b1000b0
@ -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>
|
Sun Sep 22 21:49:42 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
* eval.c (call_trace_func): should not call trace function while
|
* eval.c (call_trace_func): should not call trace function while
|
||||||
|
40
configure.in
40
configure.in
@ -3,6 +3,35 @@ AC_INIT()
|
|||||||
|
|
||||||
AC_PREREQ(2.50)
|
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`
|
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]*"'`
|
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]*"'`
|
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_CC
|
||||||
AC_PROG_GCC_TRADITIONAL
|
AC_PROG_GCC_TRADITIONAL
|
||||||
|
|
||||||
echo 'foo(){}' > conftest.c
|
RUBY_CPPOUTFILE
|
||||||
if ${CPP} -o conftest.i conftest.c >/dev/null 2>&1; then
|
|
||||||
CPPOUTFILE='-o conftest.i'
|
|
||||||
else
|
|
||||||
CPPOUTFILE='> conftest.i'
|
|
||||||
fi
|
|
||||||
AC_SUBST(CPPOUTFILE)
|
|
||||||
OUTFLAG='-o '
|
OUTFLAG='-o '
|
||||||
AC_SUBST(OUTFLAG)
|
AC_SUBST(OUTFLAG)
|
||||||
|
|
||||||
|
RUBY_MINGW32
|
||||||
|
|
||||||
AC_PROG_YACC
|
AC_PROG_YACC
|
||||||
AC_CHECK_TOOL(RANLIB, ranlib, :)
|
AC_CHECK_TOOL(RANLIB, ranlib, :)
|
||||||
AC_CHECK_TOOL(AR, ar)
|
AC_CHECK_TOOL(AR, ar)
|
||||||
|
162
lib/mkmf.rb
162
lib/mkmf.rb
@ -44,6 +44,12 @@ $sitelibdir = CONFIG["sitelibdir"]
|
|||||||
$sitearchdir = CONFIG["sitearchdir"]
|
$sitearchdir = CONFIG["sitearchdir"]
|
||||||
|
|
||||||
$extmk = /extmk\.rb/ =~ $0
|
$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)
|
def dir_re(dir)
|
||||||
Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$\(target_prefix\)|\{target_prefix\})?')
|
Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$\(target_prefix\)|\{target_prefix\})?')
|
||||||
@ -73,7 +79,7 @@ end
|
|||||||
$topdir = $hdrdir
|
$topdir = $hdrdir
|
||||||
|
|
||||||
CFLAGS = CONFIG["CFLAGS"]
|
CFLAGS = CONFIG["CFLAGS"]
|
||||||
if RUBY_PLATFORM == "m68k-human"
|
if $human
|
||||||
CFLAGS.gsub!(/-c..-stack=[0-9]+ */, '')
|
CFLAGS.gsub!(/-c..-stack=[0-9]+ */, '')
|
||||||
elsif RUBY_PLATFORM =~ /-nextstep|-rhapsody|-darwin/
|
elsif RUBY_PLATFORM =~ /-nextstep|-rhapsody|-darwin/
|
||||||
CFLAGS.gsub!( /-arch\s\w*/, '' )
|
CFLAGS.gsub!( /-arch\s\w*/, '' )
|
||||||
@ -82,12 +88,10 @@ end
|
|||||||
OUTFLAG = CONFIG['OUTFLAG']
|
OUTFLAG = CONFIG['OUTFLAG']
|
||||||
CPPOUTFILE = CONFIG['CPPOUTFILE']
|
CPPOUTFILE = CONFIG['CPPOUTFILE']
|
||||||
|
|
||||||
$LINK = "#{CONFIG['CC']} #{OUTFLAG}conftest %s -I#{$hdrdir} %s #{CFLAGS} %s #{CONFIG['LDFLAGS']} %s conftest.c %s %s #{CONFIG['LIBS']}"
|
LIBPATHFLAG = $mswin ? ' -libpath:' : ' -L'
|
||||||
$CC = "#{CONFIG['CC']} -c #{CONFIG['CPPFLAGS']} %s -I#{$hdrdir} %s #{CFLAGS} %s %s conftest.c"
|
CONFTEST_C = "conftest.c"
|
||||||
$CPP = "#{CONFIG['CPP']} #{CONFIG['CPPFLAGS']} %s -I#{$hdrdir} %s #{CFLAGS} %s %s %s conftest.c"
|
|
||||||
|
|
||||||
|
$INSTALLFILES ||= nil
|
||||||
$INSTALLFILES = nil unless defined? $INSTALLFILES
|
|
||||||
|
|
||||||
def rm_f(*files)
|
def rm_f(*files)
|
||||||
targets = []
|
targets = []
|
||||||
@ -164,80 +168,84 @@ def xpopen command, *mode, &block
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def try_link0(src, opt="")
|
def log_src(src)
|
||||||
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"
|
Logging::message <<"EOM"
|
||||||
checked program was:
|
checked program was:
|
||||||
#{src}
|
/* begin */
|
||||||
|
#{src}/* end */
|
||||||
|
|
||||||
EOM
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
def try_link(src, opt="")
|
def try_link(src, opt="")
|
||||||
begin
|
|
||||||
try_link0(src, opt)
|
try_link0(src, opt)
|
||||||
ensure
|
ensure
|
||||||
rm_f "conftest*"
|
rm_f "conftest*", "c0x32*"
|
||||||
if /bccwin32/ =~ RUBY_PLATFORM
|
|
||||||
rm_f "c0x32*"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def try_compile(src, opt="")
|
def try_compile(src, opt="")
|
||||||
src = "/* begin */\n#{src}/* end */\n"
|
try_do(src, cc_command(opt))
|
||||||
cfile = open("conftest.c", "w")
|
ensure
|
||||||
cfile.print src
|
|
||||||
cfile.close
|
|
||||||
begin
|
|
||||||
xsystem(format($CC, $INCFLAGS, $CPPFLAGS, $CFLAGS, opt))
|
|
||||||
ensure
|
|
||||||
rm_f "conftest*"
|
rm_f "conftest*"
|
||||||
Logging::message <<"EOM"
|
|
||||||
checked program was:
|
|
||||||
#{src}
|
|
||||||
EOM
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def try_cpp(src, opt="")
|
def try_cpp(src, opt="")
|
||||||
src = "/* begin */\n#{src}/* end */\n"
|
try_do(src, cpp_command(CPPOUTFILE, opt))
|
||||||
cfile = open("conftest.c", "w")
|
ensure
|
||||||
cfile.print src
|
|
||||||
cfile.close
|
|
||||||
begin
|
|
||||||
xsystem(format($CPP, $INCFLAGS, $CPPFLAGS, $CFLAGS, CPPOUTFILE, opt))
|
|
||||||
ensure
|
|
||||||
rm_f "conftest*"
|
rm_f "conftest*"
|
||||||
Logging::message <<"EOM"
|
|
||||||
checked program was:
|
|
||||||
#{src}
|
|
||||||
EOM
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def egrep_cpp(pat, src, opt="")
|
def egrep_cpp(pat, src, opt="")
|
||||||
src = "/* begin */\n#{src}/* end */\n"
|
src += "\n" unless /\n\z/ =~ src
|
||||||
cfile = open("conftest.c", "w")
|
create_tmpsrc(src)
|
||||||
cfile.print src
|
xpopen(cpp_command('', opt)) do |f|
|
||||||
cfile.close
|
|
||||||
begin
|
|
||||||
xpopen(format($CPP, $INCFLAGS, $CPPFLAGS, $CFLAGS, '', opt)) do |f|
|
|
||||||
if Regexp === pat
|
if Regexp === pat
|
||||||
puts(" ruby -ne 'print if /#{pat.source}/'")
|
puts(" ruby -ne 'print if /#{pat.source}/'")
|
||||||
f.grep(pat) {|l|
|
f.grep(pat) {|l|
|
||||||
@ -256,17 +264,13 @@ def egrep_cpp(pat, src, opt="")
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
rm_f "conftest*"
|
rm_f "conftest*"
|
||||||
Logging::message <<"EOM"
|
log_src(src)
|
||||||
checked program was:
|
|
||||||
#{src}
|
|
||||||
EOM
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def macro_defined?(macro, src, opt="")
|
def macro_defined?(macro, src, opt="")
|
||||||
try_cpp(src + <<SRC, opt)
|
try_cpp(src + <<"SRC", opt)
|
||||||
#ifndef #{macro}
|
#ifndef #{macro}
|
||||||
# error
|
# error
|
||||||
#endif
|
#endif
|
||||||
@ -274,19 +278,13 @@ SRC
|
|||||||
end
|
end
|
||||||
|
|
||||||
def try_run(src, opt="")
|
def try_run(src, opt="")
|
||||||
begin
|
|
||||||
if try_link0(src, opt)
|
if try_link0(src, opt)
|
||||||
if xsystem("./conftest")
|
xsystem("./conftest")
|
||||||
true
|
|
||||||
else
|
|
||||||
false
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
rm_f "conftest*"
|
rm_f "conftest*"
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def install_files(mfile, ifiles, map = INSTALL_DIRS, srcprefix = nil)
|
def install_files(mfile, ifiles, map = INSTALL_DIRS, srcprefix = nil)
|
||||||
@ -347,7 +345,7 @@ end
|
|||||||
|
|
||||||
def have_library(lib, func="main")
|
def have_library(lib, func="main")
|
||||||
message "checking for #{func}() in -l#{lib}... "
|
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 != ""
|
if func && func != ""
|
||||||
libs = append_library($libs, lib)
|
libs = append_library($libs, lib)
|
||||||
@ -393,7 +391,7 @@ end
|
|||||||
|
|
||||||
def find_library(lib, func, *paths)
|
def find_library(lib, func, *paths)
|
||||||
message "checking for #{func}() in -l#{lib}... "
|
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
|
libpath = $LIBPATH
|
||||||
libs = append_library($libs, lib)
|
libs = append_library($libs, lib)
|
||||||
@ -415,7 +413,7 @@ end
|
|||||||
|
|
||||||
def have_func(func, header=nil)
|
def have_func(func, header=nil)
|
||||||
message "checking for #{func}()... "
|
message "checking for #{func}()... "
|
||||||
Logging::message"checking for #{func}()\n"
|
Logging::message"have_func: checking for #{func}()\n"
|
||||||
|
|
||||||
libs = $libs
|
libs = $libs
|
||||||
src =
|
src =
|
||||||
@ -454,7 +452,7 @@ end
|
|||||||
|
|
||||||
def have_header(header)
|
def have_header(header)
|
||||||
message "checking for #{header}... "
|
message "checking for #{header}... "
|
||||||
Logging::message"checking for #{header}\n"
|
Logging::message"have_header: checking for #{header}\n"
|
||||||
|
|
||||||
unless try_cpp(<<"SRC")
|
unless try_cpp(<<"SRC")
|
||||||
#include <#{header}>
|
#include <#{header}>
|
||||||
@ -469,7 +467,7 @@ end
|
|||||||
|
|
||||||
def have_struct_member(type, member, header=nil)
|
def have_struct_member(type, member, header=nil)
|
||||||
message "checking for #{type}.#{member}... "
|
message "checking for #{type}.#{member}... "
|
||||||
Logging::message "checking for #{type}.#{member}\n"
|
Logging::message "have_struct_member: checking for #{type}.#{member}\n"
|
||||||
|
|
||||||
src =
|
src =
|
||||||
if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM
|
if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM
|
||||||
@ -505,7 +503,7 @@ end
|
|||||||
|
|
||||||
def find_executable(bin, path = nil)
|
def find_executable(bin, path = nil)
|
||||||
message "checking for #{bin}... "
|
message "checking for #{bin}... "
|
||||||
Logging::message "checking for #{bin}\n"
|
Logging::message "find_executable: checking for #{bin}\n"
|
||||||
|
|
||||||
if path.nil?
|
if path.nil?
|
||||||
path = ENV['PATH'].split(Config::CONFIG['PATH_SEPARATOR'])
|
path = ENV['PATH'].split(Config::CONFIG['PATH_SEPARATOR'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user