mkmf.rb: CONFTEST
* lib/mkmf.rb (CONFTEST): constify hardcoded filename. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
05bc47773a
commit
246c66f702
37
lib/mkmf.rb
37
lib/mkmf.rb
@ -246,11 +246,12 @@ module MakeMakefile
|
|||||||
abort "mkmf.rb can't find header files for ruby at #{$hdrdir}/ruby.h"
|
abort "mkmf.rb can't find header files for ruby at #{$hdrdir}/ruby.h"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
CONFTEST = "conftest".freeze
|
||||||
|
CONFTEST_C = "#{CONFTEST}.c"
|
||||||
|
|
||||||
OUTFLAG = CONFIG['OUTFLAG']
|
OUTFLAG = CONFIG['OUTFLAG']
|
||||||
COUTFLAG = CONFIG['COUTFLAG']
|
COUTFLAG = CONFIG['COUTFLAG']
|
||||||
CPPOUTFILE = CONFIG['CPPOUTFILE']
|
CPPOUTFILE = CONFIG['CPPOUTFILE'].sub(/\bconftest\b/, CONFTEST)
|
||||||
|
|
||||||
CONFTEST_C = "conftest.c".freeze
|
|
||||||
|
|
||||||
def rm_f(*files)
|
def rm_f(*files)
|
||||||
opt = (Hash === files.last ? [files.pop] : [])
|
opt = (Hash === files.last ? [files.pop] : [])
|
||||||
@ -462,7 +463,7 @@ MSG
|
|||||||
xsystem(command, *opts)
|
xsystem(command, *opts)
|
||||||
ensure
|
ensure
|
||||||
log_src(src)
|
log_src(src)
|
||||||
MakeMakefile.rm_rf 'conftest.dSYM'
|
MakeMakefile.rm_rf "#{CONFTEST}.dSYM"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -538,7 +539,7 @@ MSG
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
try_do(src, cmd, *opts, &b)
|
try_do(src, cmd, *opts, &b)
|
||||||
end and File.executable?("conftest#{$EXEEXT}")
|
end and File.executable?(CONFTEST+$EXEEXT)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the +src+ can be compiled as a C source and linked
|
# Returns whether or not the +src+ can be compiled as a C source and linked
|
||||||
@ -554,7 +555,7 @@ MSG
|
|||||||
def try_link(src, opt="", *opts, &b)
|
def try_link(src, opt="", *opts, &b)
|
||||||
try_link0(src, opt, *opts, &b)
|
try_link0(src, opt, *opts, &b)
|
||||||
ensure
|
ensure
|
||||||
MakeMakefile.rm_f "conftest*", "c0x32*"
|
MakeMakefile.rm_f "#{CONFTEST}*", "c0x32*"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the +src+ can be compiled as a C source. +opt+ is
|
# Returns whether or not the +src+ can be compiled as a C source. +opt+ is
|
||||||
@ -568,9 +569,9 @@ MSG
|
|||||||
# [+opt+] a String which contains compiler options
|
# [+opt+] a String which contains compiler options
|
||||||
def try_compile(src, opt="", *opts, &b)
|
def try_compile(src, opt="", *opts, &b)
|
||||||
with_werror(opt, *opts) {|_opt, *_opts| try_do(src, cc_command(_opt), *_opts, &b)} and
|
with_werror(opt, *opts) {|_opt, *_opts| try_do(src, cc_command(_opt), *_opts, &b)} and
|
||||||
File.file?("conftest.#{$OBJEXT}")
|
File.file?("#{CONFTEST}.#{$OBJEXT}")
|
||||||
ensure
|
ensure
|
||||||
MakeMakefile.rm_f "conftest*"
|
MakeMakefile.rm_f "#{CONFTEST}*"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether or not the +src+ can be preprocessed with the C
|
# Returns whether or not the +src+ can be preprocessed with the C
|
||||||
@ -584,9 +585,9 @@ MSG
|
|||||||
# [+opt+] a String which contains preprocessor options
|
# [+opt+] a String which contains preprocessor options
|
||||||
def try_cpp(src, opt="", *opts, &b)
|
def try_cpp(src, opt="", *opts, &b)
|
||||||
try_do(src, cpp_command(CPPOUTFILE, opt), *opts, &b) and
|
try_do(src, cpp_command(CPPOUTFILE, opt), *opts, &b) and
|
||||||
File.file?("conftest.i")
|
File.file?("#{CONFTEST}.i")
|
||||||
ensure
|
ensure
|
||||||
MakeMakefile.rm_f "conftest*"
|
MakeMakefile.rm_f "#{CONFTEST}*"
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :try_header, (config_string('try_header') || :try_cpp)
|
alias_method :try_header, (config_string('try_header') || :try_cpp)
|
||||||
@ -700,12 +701,12 @@ int main() {printf("%"PRI_CONFTEST_PREFIX"#{neg ? 'd' : 'u'}\\n", conftest_const
|
|||||||
}
|
}
|
||||||
begin
|
begin
|
||||||
if try_link0(src, opt, &b)
|
if try_link0(src, opt, &b)
|
||||||
xpopen("./conftest") do |f|
|
xpopen("./#{CONFTEST}") do |f|
|
||||||
return Integer(f.gets)
|
return Integer(f.gets)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
MakeMakefile.rm_f "conftest*"
|
MakeMakefile.rm_f "#{CONFTEST}*"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
nil
|
nil
|
||||||
@ -800,7 +801,7 @@ SRC
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
MakeMakefile.rm_f "conftest*"
|
MakeMakefile.rm_f "#{CONFTEST}*"
|
||||||
log_src(src)
|
log_src(src)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -837,12 +838,12 @@ SRC
|
|||||||
def try_run(src, opt = "", &b)
|
def try_run(src, opt = "", &b)
|
||||||
raise "cannot run test program while cross compiling" if CROSS_COMPILING
|
raise "cannot run test program while cross compiling" if CROSS_COMPILING
|
||||||
if try_link0(src, opt, &b)
|
if try_link0(src, opt, &b)
|
||||||
xsystem("./conftest")
|
xsystem("./#{CONFTEST}")
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
MakeMakefile.rm_f "conftest*"
|
MakeMakefile.rm_f "#{CONFTEST}*"
|
||||||
end
|
end
|
||||||
|
|
||||||
def install_files(mfile, ifiles, map = nil, srcprefix = nil)
|
def install_files(mfile, ifiles, map = nil, srcprefix = nil)
|
||||||
@ -2102,7 +2103,7 @@ RULES
|
|||||||
$target = target
|
$target = target
|
||||||
libpath = $DEFLIBPATH|$LIBPATH
|
libpath = $DEFLIBPATH|$LIBPATH
|
||||||
message "creating Makefile\n"
|
message "creating Makefile\n"
|
||||||
MakeMakefile.rm_f "conftest*"
|
MakeMakefile.rm_f "#{CONFTEST}*"
|
||||||
if CONFIG["DLEXT"] == $OBJEXT
|
if CONFIG["DLEXT"] == $OBJEXT
|
||||||
for lib in libs = $libs.split
|
for lib in libs = $libs.split
|
||||||
lib.sub!(/-l(.*)/, %%"lib\\1.#{$LIBEXT}"%)
|
lib.sub!(/-l(.*)/, %%"lib\\1.#{$LIBEXT}"%)
|
||||||
@ -2547,7 +2548,7 @@ MESSAGE
|
|||||||
# Command which will compile a program in order to test linking a library
|
# Command which will compile a program in order to test linking a library
|
||||||
|
|
||||||
TRY_LINK = config_string('TRY_LINK') ||
|
TRY_LINK = config_string('TRY_LINK') ||
|
||||||
"$(CC) #{OUTFLAG}conftest#{$EXEEXT} $(INCFLAGS) $(CPPFLAGS) " \
|
"$(CC) #{OUTFLAG}#{CONFTEST}#{$EXEEXT} $(INCFLAGS) $(CPPFLAGS) " \
|
||||||
"$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
|
"$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -2598,7 +2599,7 @@ distclean-rb::
|
|||||||
distclean-so::
|
distclean-so::
|
||||||
distclean-static::
|
distclean-static::
|
||||||
distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
|
distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
|
||||||
\t\t-$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
\t\t-$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) #{CONFTEST}.* mkmf.log
|
||||||
\t\t-$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES#{sep})
|
\t\t-$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES#{sep})
|
||||||
\t\t-$(Q)$(RMDIRS) $(DISTCLEANDIRS#{sep})#{$ignore_error}
|
\t\t-$(Q)$(RMDIRS) $(DISTCLEANDIRS#{sep})#{$ignore_error}
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ class TestMkmf
|
|||||||
end
|
end
|
||||||
create_tmpsrc("#include \"#{HEADER_NAME}\"\n""void #{FUNC_NAME}(void) {}")
|
create_tmpsrc("#include \"#{HEADER_NAME}\"\n""void #{FUNC_NAME}(void) {}")
|
||||||
xsystem(cc_command)
|
xsystem(cc_command)
|
||||||
xsystem("#{CONFIG['AR']} #{config_string('ARFLAGS') || 'cru '}#{lib} conftest.#{$OBJEXT}")
|
xsystem("#{CONFIG['AR']} #{config_string('ARFLAGS') || 'cru '}#{lib} #{CONFTEST}.#{$OBJEXT}")
|
||||||
File.unlink("conftest.#{$OBJEXT}")
|
File.unlink("#{CONFTEST}.#{$OBJEXT}")
|
||||||
config_string('RANLIB') do |ranlib|
|
config_string('RANLIB') do |ranlib|
|
||||||
xsystem("#{ranlib} #{lib}")
|
xsystem("#{ranlib} #{lib}")
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user