ruby-changes:29717
From: nobu <ko1@a...>
Date: Thu, 4 Jul 2013 16:03:11 +0900 (JST)
Subject: [ruby-changes:29717] nobu:r41769 (trunk): mkmf.rb: CONFTEST
nobu 2013-07-04 16:03:01 +0900 (Thu, 04 Jul 2013) New Revision: 41769 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41769 Log: mkmf.rb: CONFTEST * lib/mkmf.rb (CONFTEST): constify hardcoded filename. Modified files: trunk/lib/mkmf.rb trunk/test/mkmf/test_have_library.rb Index: lib/mkmf.rb =================================================================== --- lib/mkmf.rb (revision 41768) +++ lib/mkmf.rb (revision 41769) @@ -246,11 +246,12 @@ module MakeMakefile https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L246 abort "mkmf.rb can't find header files for ruby at #{$hdrdir}/ruby.h" end + CONFTEST = "conftest".freeze + CONFTEST_C = "#{CONFTEST}.c" + OUTFLAG = CONFIG['OUTFLAG'] COUTFLAG = CONFIG['COUTFLAG'] - CPPOUTFILE = CONFIG['CPPOUTFILE'] - - CONFTEST_C = "conftest.c".freeze + CPPOUTFILE = CONFIG['CPPOUTFILE'].sub(/\bconftest\b/, CONFTEST) def rm_f(*files) opt = (Hash === files.last ? [files.pop] : []) @@ -462,7 +463,7 @@ MSG https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L463 xsystem(command, *opts) ensure log_src(src) - MakeMakefile.rm_rf 'conftest.dSYM' + MakeMakefile.rm_rf "#{CONFTEST}.dSYM" end end @@ -538,7 +539,7 @@ MSG https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L539 end else try_do(src, cmd, *opts, &b) - end and File.executable?("conftest#{$EXEEXT}") + end and File.executable?(CONFTEST+$EXEEXT) end # Returns whether or not the +src+ can be compiled as a C source and linked @@ -554,7 +555,7 @@ MSG https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L555 def try_link(src, opt="", *opts, &b) try_link0(src, opt, *opts, &b) ensure - MakeMakefile.rm_f "conftest*", "c0x32*" + MakeMakefile.rm_f "#{CONFTEST}*", "c0x32*" end # Returns whether or not the +src+ can be compiled as a C source. +opt+ is @@ -568,9 +569,9 @@ MSG https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L569 # [+opt+] a String which contains compiler options def try_compile(src, opt="", *opts, &b) with_werror(opt, *opts) {|_opt, *_opts| try_do(src, cc_command(_opt), *_opts, &b)} and - File.file?("conftest.#{$OBJEXT}") + File.file?("#{CONFTEST}.#{$OBJEXT}") ensure - MakeMakefile.rm_f "conftest*" + MakeMakefile.rm_f "#{CONFTEST}*" end # Returns whether or not the +src+ can be preprocessed with the C @@ -584,9 +585,9 @@ MSG https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L585 # [+opt+] a String which contains preprocessor options def try_cpp(src, opt="", *opts, &b) try_do(src, cpp_command(CPPOUTFILE, opt), *opts, &b) and - File.file?("conftest.i") + File.file?("#{CONFTEST}.i") ensure - MakeMakefile.rm_f "conftest*" + MakeMakefile.rm_f "#{CONFTEST}*" end alias_method :try_header, (config_string('try_header') || :try_cpp) @@ -700,12 +701,12 @@ int main() {printf("%"PRI_CONFTEST_PREFI https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L701 } begin if try_link0(src, opt, &b) - xpopen("./conftest") do |f| + xpopen("./#{CONFTEST}") do |f| return Integer(f.gets) end end ensure - MakeMakefile.rm_f "conftest*" + MakeMakefile.rm_f "#{CONFTEST}*" end end nil @@ -800,7 +801,7 @@ SRC https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L801 end end ensure - MakeMakefile.rm_f "conftest*" + MakeMakefile.rm_f "#{CONFTEST}*" log_src(src) end @@ -837,12 +838,12 @@ SRC https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L838 def try_run(src, opt = "", &b) raise "cannot run test program while cross compiling" if CROSS_COMPILING if try_link0(src, opt, &b) - xsystem("./conftest") + xsystem("./#{CONFTEST}") else nil end ensure - MakeMakefile.rm_f "conftest*" + MakeMakefile.rm_f "#{CONFTEST}*" end def install_files(mfile, ifiles, map = nil, srcprefix = nil) @@ -2102,7 +2103,7 @@ RULES https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L2103 $target = target libpath = $DEFLIBPATH|$LIBPATH message "creating Makefile\n" - MakeMakefile.rm_f "conftest*" + MakeMakefile.rm_f "#{CONFTEST}*" if CONFIG["DLEXT"] == $OBJEXT for lib in libs = $libs.split lib.sub!(/-l(.*)/, %%"lib\\1.#{$LIBEXT}"%) @@ -2547,7 +2548,7 @@ MESSAGE https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L2548 # Command which will compile a program in order to test linking a library 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)" ## @@ -2598,7 +2599,7 @@ distclean-rb:: https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L2599 distclean-so:: distclean-static:: 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)$(RMDIRS) $(DISTCLEANDIRS#{sep})#{$ignore_error} Index: test/mkmf/test_have_library.rb =================================================================== --- test/mkmf/test_have_library.rb (revision 41768) +++ test/mkmf/test_have_library.rb (revision 41769) @@ -16,8 +16,8 @@ class TestMkmf https://github.com/ruby/ruby/blob/trunk/test/mkmf/test_have_library.rb#L16 end create_tmpsrc("#include \"#{HEADER_NAME}\"\n""void #{FUNC_NAME}(void) {}") xsystem(cc_command) - xsystem("#{CONFIG['AR']} #{config_string('ARFLAGS') || 'cru '}#{lib} conftest.#{$OBJEXT}") - File.unlink("conftest.#{$OBJEXT}") + xsystem("#{CONFIG['AR']} #{config_string('ARFLAGS') || 'cru '}#{lib} #{CONFTEST}.#{$OBJEXT}") + File.unlink("#{CONFTEST}.#{$OBJEXT}") config_string('RANLIB') do |ranlib| xsystem("#{ranlib} #{lib}") end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/