/
rbconfig.rb
249 lines (229 loc) · 8.83 KB
/
rbconfig.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
require 'rubinius/build_config'
module RbConfig
unless defined? RUBY_ENGINE and RUBY_ENGINE == "rbx" then
raise "Looks like you loaded the Rubinius rbconfig, but this is not Rubinius."
end
prefix = File.dirname(File.dirname(__FILE__))
CONFIG = {}
CONFIG["prefix"] = prefix
CONFIG["install_prefix"] = ''
CONFIG["DLEXT"] = Rubinius::LIBSUFFIX[1..-1]
CONFIG["EXEEXT"] = ""
CONFIG["ruby_install_name"] = RUBY_ENGINE.dup
CONFIG["RUBY_INSTALL_NAME"] = RUBY_ENGINE.dup
CONFIG["exec_prefix"] = "$(prefix)"
CONFIG["bindir"] = Rubinius::BUILD_CONFIG[:bindir]
CONFIG["sbindir"] = "$(exec_prefix)/sbin"
CONFIG["libexecdir"] = "$(exec_prefix)/libexec"
CONFIG["datarootdir"] = "$(prefix)/share"
CONFIG["datadir"] = "$(datarootdir)"
CONFIG["sysconfdir"] = "$(prefix)/etc"
CONFIG["sharedstatedir"] = "$(prefix)/com"
CONFIG["localstatedir"] = "$(prefix)/var"
CONFIG["includedir"] = "$(prefix)/include"
CONFIG["oldincludedir"] = "/usr/include"
CONFIG["docdir"] = "$(datarootdir)/doc/$(PACKAGE)"
CONFIG["infodir"] = "$(datarootdir)/info"
CONFIG["htmldir"] = "$(docdir)"
CONFIG["dvidir"] = "$(docdir)"
CONFIG["pdfdir"] = "$(docdir)"
CONFIG["psdir"] = "$(docdir)"
CONFIG["libdir"] = "$(exec_prefix)/lib"
CONFIG["localedir"] = "$(datarootdir)/locale"
CONFIG["mandir"] = "$(datarootdir)/man"
major, minor, teeny = RUBY_VERSION.split(".")
CONFIG["MAJOR"] = major
CONFIG["MINOR"] = minor
CONFIG["TEENY"] = teeny
CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
CONFIG["RUBY_SO_NAME"] = "rubinius-#{Rubinius::VERSION}"
case
when Rubinius.ruby18?
CONFIG["rubyhdrdir"] = "#{Rubinius::HDR18_PATH}"
when Rubinius.ruby19?
CONFIG["rubyhdrdir"] = "#{Rubinius::HDR19_PATH}"
when Rubinius.ruby20?
CONFIG["rubyhdrdir"] = "#{Rubinius::HDR20_PATH}"
else
raise Exception, "no C-API header directory defined"
end
CONFIG["LIBS"] = ""
sitedir = Rubinius::SITE_PATH
sitelibdir = sitedir
arch = "#{Rubinius::CPU}-#{Rubinius::OS}"
CONFIG["sitedir"] = sitedir
CONFIG["sitelibdir"] = sitelibdir
CONFIG["arch"] = arch
CONFIG["sitearch"] = arch
CONFIG["rubylibdir"] = sitelibdir
CONFIG["archdir"] = "#{sitelibdir}/#{arch}"
CONFIG["sitearchdir"] = "#{sitelibdir}/#{arch}"
CONFIG["topdir"] = File.dirname(__FILE__)
# some of these only relevant to cross-compiling
cpu = Rubinius::CPU
vendor = Rubinius::VENDOR
os = Rubinius::OS
CONFIG["build"] = "#{cpu}-#{vendor}-#{os}"
CONFIG["build_cpu"] = "#{cpu}"
CONFIG["build_vendor"] = "#{vendor}"
CONFIG["build_os"] = "#{os}"
CONFIG["host"] = "#{cpu}-#{vendor}-#{os}"
CONFIG["host_cpu"] = "#{cpu}"
CONFIG["host_vendor"] = "#{vendor}"
CONFIG["host_os"] = "#{os}"
CONFIG["target"] = "#{cpu}-#{vendor}-#{os}"
CONFIG["target_cpu"] = "#{cpu}"
CONFIG["target_vendor"] = "#{vendor}"
CONFIG["target_os"] = "#{os}"
CONFIG["build_alias"] = ""
CONFIG["host_alias"] = ""
CONFIG["target_alias"] = ""
# command line utilities
CONFIG["SHELL"] = "/bin/sh"
CONFIG["ECHO_C"] = ""
CONFIG["ECHO_N"] = "-n"
CONFIG["ECHO_T"] = ""
CONFIG["GREP"] = "/usr/bin/grep"
CONFIG["EGREP"] = "/usr/bin/grep -E"
CONFIG["RM"] = "rm -f"
CONFIG["CP"] = "cp"
CONFIG["NROFF"] = "/usr/bin/nroff"
CONFIG["MAKEDIRS"] = "mkdir -p"
# compile tools
CONFIG["CC"] = Rubinius::BUILD_CONFIG[:cc]
CONFIG["CXX"] = Rubinius::BUILD_CONFIG[:cxx]
CONFIG["CPP"] = "#{Rubinius::BUILD_CONFIG[:cc]} -E"
CONFIG["YACC"] = "bison -y"
CONFIG["RANLIB"] = "ranlib"
CONFIG["AR"] = "ar"
CONFIG["AS"] = "as"
CONFIG["WINDRES"] = ""
CONFIG["DLLWRAP"] = ""
CONFIG["OBJDUMP"] = ""
CONFIG["LN_S"] = "ln -s"
CONFIG["NM"] = ""
CONFIG["INSTALL"] = "install -c"
CONFIG["INSTALL_PROGRAM"] = "$(INSTALL)"
CONFIG["INSTALL_SCRIPT"] = "$(INSTALL)"
CONFIG["INSTALL_DATA"] = "$(INSTALL) -m 644"
CONFIG["STRIP"] = "strip -A -n"
CONFIG["MANTYPE"] = "doc"
CONFIG["MAKEFILES"] = "Makefile"
# compile tools flags
# since we hardcode using gcc, and this flag is only
# used by mkmf to compile extensions, be sure PIC is in
# there
CONFIG["CFLAGS"] = "-ggdb3 -fPIC"
CONFIG["LDFLAGS"] = ""
if ENV['DEV']
CONFIG["CFLAGS"] << " -O0"
else
CONFIG["CFLAGS"] << " -O2"
end
if include_dirs = Rubinius::BUILD_CONFIG[:include_dirs]
include_dirs.each do |include_dir|
CONFIG["CFLAGS"] << " -I#{include_dir}"
end
end
if lib_dirs = Rubinius::BUILD_CONFIG[:lib_dirs]
lib_dirs.each do |lib_dir|
CONFIG["LDFLAGS"] << " -L#{lib_dir}"
end
end
if user = Rubinius::BUILD_CONFIG[:user_cflags]
CONFIG["CFLAGS"] << " #{user}" unless user.empty?
end
if user = Rubinius::BUILD_CONFIG[:user_ldflags]
CONFIG["LDFLAGS"] << " #{user}" unless user.empty?
end
CONFIG["CPPFLAGS"] = ""
if user = Rubinius::BUILD_CONFIG[:user_cppflags]
CONFIG["CPPFLAGS"] << " #{user}" unless user.empty?
end
CONFIG["OBJEXT"] = "o"
CONFIG["GNU_LD"] = ""
CONFIG["CPPOUTFILE"] = "-o conftest.i"
CONFIG["OUTFLAG"] = "-o "
CONFIG["COUTFLAG"] = "-o "
CONFIG["OUTFLAG"] = "-o "
CONFIG["YFLAGS"] = ""
CONFIG["ASFLAGS"] = ""
CONFIG["DLDFLAGS"] = ""
CONFIG["ARCH_FLAG"] = ""
CONFIG["STATIC"] = ""
CONFIG["CCDLFLAGS"] = " -fPIC"
CONFIG["XCFLAGS"] = ""
CONFIG["XLDFLAGS"] = ""
CONFIG["LIBRUBY_DLDFLAGS"] = ""
CONFIG["rubyw_install_name"] = ""
CONFIG["RUBYW_INSTALL_NAME"] = ""
CONFIG["SOLIBS"] = ""
CONFIG["DLDLIBS"] = ""
CONFIG["ENABLE_SHARED"] = ""
CONFIG["MAINLIBS"] = ""
CONFIG["COMMON_LIBS"] = ""
CONFIG["COMMON_MACROS"] = ""
CONFIG["COMMON_HEADERS"] = ""
CONFIG["EXPORT_PREFIX"] = ""
CONFIG["EXTOUT"] = ".ext"
CONFIG["ARCHFILE"] = ""
CONFIG["RDOCTARGET"] = ""
CONFIG["LIBRUBY_A"] = ""
CONFIG["LIBRUBY_SO"] = "lib$(RUBY_SO_NAME).$(DLEXT)"
CONFIG["LIBRUBY_ALIASES"] = "lib$(RUBY_SO_NAME).$(DLEXT)"
CONFIG["LIBRUBY"] = "$(LIBRUBY_SO)"
CONFIG["LIBRUBYARG"] = "$(LIBRUBYARG_STATIC)"
CONFIG["LIBRUBYARG_STATIC"] = ""
CONFIG["LIBRUBYARG_SHARED"] = ""
CONFIG["configure_args"] = ""
CONFIG["ALLOCA"] = ""
CONFIG["LIBEXT"] = "a"
CONFIG["LINK_SO"] = ""
CONFIG["LIBPATHFLAG"] = " -L%s"
CONFIG["RPATHFLAG"] = ""
CONFIG["LIBPATHENV"] = "DYLD_LIBRARY_PATH"
CONFIG["TRY_LINK"] = ""
CONFIG["EXTSTATIC"] = ""
CONFIG["setup"] = "Setup"
CONFIG["PATH_SEPARATOR"] = ":"
CONFIG["PACKAGE_NAME"] = ""
CONFIG["PACKAGE_TARNAME"] = ""
CONFIG["PACKAGE_VERSION"] = ""
CONFIG["PACKAGE_STRING"] = ""
CONFIG["PACKAGE_BUGREPORT"] = ""
CONFIG["LDSHARED"] = Rubinius::LDSHARED
CONFIG["LIBRUBY_LDSHARED"] = Rubinius::LDSHARED
# absolute path to ruby executable (pulled directly from MRI's mkconfig.rb)
def RbConfig.ruby
File.join(
RbConfig::CONFIG["bindir"],
RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]
)
end
# Adapted from MRI's' rbconfig.rb
MAKEFILE_CONFIG = {}
CONFIG.each { |k,v| MAKEFILE_CONFIG[k] = v.kind_of?(String) ? v.dup : v }
def RbConfig.expand(val, config = CONFIG)
return val unless val.kind_of? String
val.gsub!(/\$\$|\$\(([^()]+)\)|\$\{([^{}]+)\}/) do |var|
if !(v = $1 || $2)
'$'
elsif key = config[v = v[/\A[^:]+(?=(?::(.*?)=(.*))?\z)/]]
pat, sub = $1, $2
config[v] = false
RbConfig.expand(key, config)
config[v] = key
key = key.gsub(/#{Regexp.quote(pat)}(?=\s|\z)/n) {sub} if pat
key
else
var
end
end
val
end
CONFIG.each_value do |val|
RbConfig.expand(val)
end
end
CROSS_COMPILING = nil unless defined? CROSS_COMPILING
Config = RbConfig