PageRenderTime 76ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/Merlin/Main/Languages/Ruby/Libs/rbconfig.rb

https://github.com/jxnmaomao/ironruby
Ruby | 175 lines | 159 code | 2 blank | 14 comment | 1 complexity | 2c065e81db59825ac10396dc7a2c3df5 MD5 | raw file
  1. # ****************************************************************************
  2. #
  3. # Copyright (c) Microsoft Corporation.
  4. #
  5. # This source code is subject to terms and conditions of the Microsoft Public License. A
  6. # copy of the license can be found in the License.html file at the root of this distribution. If
  7. # you cannot locate the Microsoft Public License, please send an email to
  8. # ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. # by the terms of the Microsoft Public License.
  10. #
  11. # You must not remove this notice, or any other, from this software.
  12. #
  13. #
  14. # ****************************************************************************
  15. module Config
  16. RUBY_VERSION == "1.8.6" or
  17. raise "ruby lib version (1.8.6) doesn't match executable version (#{RUBY_VERSION})"
  18. # TODO: Temporary hack to locate where we are based on relative MERLIN
  19. # layout paths. We will replace this with just the path to this file when
  20. # we build out the Ruby/libs directory to contain our own private copy of
  21. # the Ruby libraries
  22. # Note that this symbol should be redefined by the packaging script for binary
  23. # layouts
  24. TOPDIR = File.dirname(__FILE__) + '/../../../../External/languages/ruby/ruby-1.8.6/'
  25. DESTDIR = TOPDIR && TOPDIR[/\A[a-z]:/i] || '' unless defined? DESTDIR
  26. CONFIG = {}
  27. CONFIG["DESTDIR"] = DESTDIR
  28. CONFIG["MAJOR"] = "1"
  29. CONFIG["MINOR"] = "8"
  30. CONFIG["TEENY"] = "6"
  31. CONFIG["PATCHLEVEL"] = "0"
  32. CONFIG["prefix"] = (TOPDIR || DESTDIR + "")
  33. CONFIG["EXEEXT"] = ".exe"
  34. # TODO: change back to ironruby
  35. CONFIG["ruby_install_name"] = "ruby"
  36. CONFIG["RUBY_INSTALL_NAME"] = "ruby"
  37. # END TODO:
  38. CONFIG["RUBY_SO_NAME"] = "msvcrt-ruby18"
  39. CONFIG["SHELL"] = "$(COMSPEC)"
  40. CONFIG["BUILD_FILE_SEPARATOR"] = "\\"
  41. CONFIG["PATH_SEPARATOR"] = ";"
  42. CONFIG["CFLAGS"] = "-MD -Zi -O2b2xg- -G6"
  43. CONFIG["CPPFLAGS"] = ""
  44. CONFIG["CXXFLAGS"] = ""
  45. CONFIG["FFLAGS"] = ""
  46. CONFIG["LDFLAGS"] = ""
  47. CONFIG["LIBS"] = "oldnames.lib user32.lib advapi32.lib ws2_32.lib "
  48. CONFIG["exec_prefix"] = "$(prefix)"
  49. CONFIG["bindir"] = "$(exec_prefix)/bin"
  50. CONFIG["sbindir"] = "$(exec_prefix)/sbin"
  51. CONFIG["libexecdir"] = "$(exec_prefix)/libexec"
  52. CONFIG["datadir"] = "$(prefix)/share"
  53. CONFIG["sysconfdir"] = "$(prefix)/etc"
  54. CONFIG["sharedstatedir"] = "$(DESTDIR)/etc"
  55. CONFIG["localstatedir"] = "$(DESTDIR)/var"
  56. CONFIG["libdir"] = "$(exec_prefix)/lib"
  57. CONFIG["includedir"] = "$(prefix)/include"
  58. CONFIG["oldincludedir"] = "/usr/include"
  59. CONFIG["infodir"] = "$(prefix)/info"
  60. CONFIG["mandir"] = "$(prefix)/man"
  61. CONFIG["build"] = "i686-pc-mswin32"
  62. CONFIG["build_alias"] = "i686-mswin32"
  63. CONFIG["build_cpu"] = "i686"
  64. CONFIG["build_vendor"] = "pc"
  65. CONFIG["build_os"] = "mswin32"
  66. CONFIG["host"] = "i686-pc-mswin32"
  67. CONFIG["host_alias"] = "i686-mswin32"
  68. CONFIG["host_cpu"] = "i686"
  69. CONFIG["host_vendor"] = "pc"
  70. CONFIG["host_os"] = "mswin32"
  71. CONFIG["target"] = "i386-pc-mswin32"
  72. CONFIG["target_alias"] = "i386-mswin32"
  73. CONFIG["target_cpu"] = "i386"
  74. CONFIG["target_vendor"] = "pc"
  75. CONFIG["target_os"] = "mswin32"
  76. CONFIG["CC"] = "cl -nologo"
  77. CONFIG["CPP"] = "cl -nologo -E"
  78. CONFIG["YACC"] = "byacc"
  79. CONFIG["RANLIB"] = ""
  80. CONFIG["AR"] = "lib -nologo"
  81. CONFIG["ARFLAGS"] = "-machine:x86 -out:"
  82. CONFIG["LN_S"] = ""
  83. CONFIG["SET_MAKE"] = ""
  84. CONFIG["CP"] = "copy > nul"
  85. CONFIG["ALLOCA"] = ""
  86. CONFIG["DEFAULT_KCODE"] = ""
  87. CONFIG["OBJEXT"] = "obj"
  88. CONFIG["XCFLAGS"] = "-DRUBY_EXPORT -I. -IC:/develop/win/ruby/ruby-1.8.6 -IC:/develop/win/ruby/ruby-1.8.6/missing"
  89. CONFIG["XLDFLAGS"] = "-stack:0x2000000"
  90. CONFIG["DLDFLAGS"] = "-link -incremental:no -debug -opt:ref -opt:icf -dll $(LIBPATH) -def:$(DEFFILE) -implib:$(*F:.so=)-$(arch).lib -pdb:$(*F:.so=)-$(arch).pdb"
  91. CONFIG["ARCH_FLAG"] = ""
  92. CONFIG["STATIC"] = ""
  93. CONFIG["CCDLFLAGS"] = ""
  94. CONFIG["LDSHARED"] = "cl -nologo -LD"
  95. CONFIG["DLEXT"] = "so"
  96. CONFIG["DLEXT2"] = "dll"
  97. CONFIG["LIBEXT"] = "lib"
  98. CONFIG["STRIP"] = ""
  99. CONFIG["EXTSTATIC"] = ""
  100. CONFIG["setup"] = "Setup"
  101. CONFIG["MINIRUBY"] = ".\\miniruby.exe "
  102. CONFIG["PREP"] = "miniruby.exe"
  103. CONFIG["RUNRUBY"] = ".\\ruby.exe \"C:/develop/win/ruby/ruby-1.8.6/runruby.rb\" --extout=\".ext\" --"
  104. CONFIG["EXTOUT"] = ".ext"
  105. CONFIG["ARCHFILE"] = ""
  106. CONFIG["RDOCTARGET"] = "install-nodoc"
  107. CONFIG["LIBRUBY_LDSHARED"] = "cl -nologo -LD"
  108. CONFIG["LIBRUBY_DLDFLAGS"] = " -def:msvcrt-ruby18.def"
  109. CONFIG["rubyw_install_name"] = "rubyw"
  110. CONFIG["RUBYW_INSTALL_NAME"] = "rubyw"
  111. CONFIG["LIBRUBY_A"] = "$(RUBY_SO_NAME)-static.lib"
  112. CONFIG["LIBRUBY_SO"] = "$(RUBY_SO_NAME).dll"
  113. CONFIG["LIBRUBY_ALIASES"] = ""
  114. CONFIG["LIBRUBY"] = "$(RUBY_SO_NAME).lib"
  115. CONFIG["LIBRUBYARG"] = "$(LIBRUBYARG_SHARED)"
  116. CONFIG["LIBRUBYARG_STATIC"] = "$(LIBRUBY_A)"
  117. CONFIG["LIBRUBYARG_SHARED"] = "$(LIBRUBY)"
  118. CONFIG["SOLIBS"] = ""
  119. CONFIG["DLDLIBS"] = ""
  120. CONFIG["ENABLE_SHARED"] = "yes"
  121. CONFIG["OUTFLAG"] = "-Fe"
  122. CONFIG["CPPOUTFILE"] = "-P"
  123. CONFIG["LIBPATHFLAG"] = " -libpath:\"%s\""
  124. CONFIG["RPATHFLAG"] = ""
  125. CONFIG["LIBARG"] = "%s.lib"
  126. CONFIG["LINK_SO"] = "$(LDSHARED) -Fe$(@) $(OBJS) $(LIBS) $(LOCAL_LIBS) $(DLDFLAGS)"
  127. CONFIG["COMPILE_C"] = "$(CC) $(INCFLAGS) $(CFLAGS) $(CPPFLAGS) -c -Tc$(<:\\=/)"
  128. CONFIG["COMPILE_CXX"] = "$(CXX) $(INCFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\\=/)"
  129. CONFIG["COMPILE_RULES"] = "{$(srcdir)}.%s{}.%s: {$(topdir)}.%s{}.%s: {$(hdrdir)}.%s{}.%s: .%s.%s:"
  130. CONFIG["RULE_SUBST"] = "{.;$(srcdir);$(topdir);$(hdrdir)}%s"
  131. CONFIG["TRY_LINK"] = "$(CC) -Feconftest $(INCFLAGS) -I$(hdrdir) $(CPPFLAGS) $(CFLAGS) $(src) $(LOCAL_LIBS) $(LIBS) -link $(LDFLAGS) $(LIBPATH) $(XLDFLAGS)"
  132. CONFIG["COMMON_LIBS"] = "m"
  133. CONFIG["COMMON_MACROS"] = "WIN32_LEAN_AND_MEAN"
  134. CONFIG["COMMON_HEADERS"] = "winsock2.h windows.h"
  135. CONFIG["DISTCLEANFILES"] = "vc*.pdb"
  136. CONFIG["EXPORT_PREFIX"] = " "
  137. CONFIG["arch"] = "i386-mswin32"
  138. CONFIG["sitearch"] = "i386-msvcrt"
  139. CONFIG["sitedir"] = "$(prefix)/lib/ruby/site_ruby"
  140. CONFIG["configure_args"] = "--with-make-prog=nmake --enable-shared --with-winsock2"
  141. CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
  142. CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
  143. CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
  144. CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
  145. CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
  146. CONFIG["topdir"] = File.dirname(__FILE__)
  147. MAKEFILE_CONFIG = {}
  148. CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
  149. def Config::expand(val, config = CONFIG)
  150. val.gsub!(/\$\$|\$\(([^()]+)\)|\$\{([^{}]+)\}/) do |var|
  151. if !(v = $1 || $2)
  152. '$'
  153. elsif key = config[v = v[/\A[^:]+(?=(?::(.*?)=(.*))?\z)/]]
  154. pat, sub = $1, $2
  155. config[v] = false
  156. Config::expand(key, config)
  157. config[v] = key
  158. key = key.gsub(/#{Regexp.quote(pat)}(?=\s|\z)/n) {sub} if pat
  159. key
  160. else
  161. var
  162. end
  163. end
  164. val
  165. end
  166. CONFIG.each_value do |val|
  167. Config::expand(val)
  168. end
  169. end
  170. RbConfig = Config # compatibility for ruby-1.9
  171. CROSS_COMPILING = nil unless defined? CROSS_COMPILING