2 # configure.rake - handles all configuration and generate needed build files
5 file 'lib/rbconfig.rb' => :config_env do
9 %w[shotgun/config.mk shotgun/config.h].each do |f|
10 file f => :config_env do
15 task :configure => %w[shotgun/config.mk lib/rbconfig.rb shotgun/config.h]
17 task :config_env => %W[rakelib/configure.rake] do
18 libtool = system("which glibtool > /dev/null") ? "glibtool" : "libtool"
20 DTRACE = ENV['DTRACE']
22 PREFIX = ENV['PREFIX'] || "/usr/local"
23 RBX_RUBY_VERSION = "1.8.6"
24 RBX_RUBY_PATCHLEVEL = "111"
26 RBX_VERSION = "#{LIBVER}.0"
27 HOST = `./shotgun/config.guess`.chomp
28 BUILDREV = `git rev-list --all | head -n1`.chomp
29 CC = ENV['CC'] || 'gcc'
30 BINPATH = "#{PREFIX}/bin"
31 LIBPATH = "#{PREFIX}/lib"
32 CODEPATH = "#{PREFIX}/lib/rubinius/#{LIBVER}"
33 RBAPATH = "#{PREFIX}/lib/rubinius/#{LIBVER}/runtime"
34 EXTPATH = "#{PREFIX}/lib/rubinius/#{LIBVER}/#{HOST}"
45 DISABLE_KQUEUE = (HOST =~ /freebsd/ ? 1 : 0)
50 Dir.chdir(File.join(RUBINIUS_BASE, 'shotgun')) do
51 File.open("config.mk", "w") do |f|
52 f.puts "BUILDREV = #{BUILDREV}"
53 f.puts "ENGINE = #{ENGINE}"
54 f.puts "PREFIX = #{PREFIX}"
55 f.puts "RUBY_VERSION = #{RBX_RUBY_VERSION}"
56 f.puts "RUBY_PATCHLEVEL = #{RBX_RUBY_PATCHLEVEL}"
57 f.puts "LIBVER = #{LIBVER}"
58 f.puts "VERSION = #{RBX_VERSION}"
59 f.puts "HOST = #{HOST}"
60 f.puts "DARWIN = #{DARWIN}"
61 f.puts "DISABLE_KQUEUE = #{DISABLE_KQUEUE}"
62 f.puts "BINPATH = #{BINPATH}"
63 f.puts "LIBPATH = #{LIBPATH}"
64 f.puts "CODEPATH = #{CODEPATH}"
65 f.puts "RBAPATH = #{RBAPATH}"
66 f.puts "EXTPATH = #{EXTPATH}"
67 f.puts "BUILDREV = #{BUILDREV}"
68 f.puts "DTRACE = #{DTRACE}"
72 f.puts "MACOSX_DEPLOYMENT_TARGET=10.5"
74 f.puts "MACOSX_DEPLOYMENT_TARGET=10.4"
78 unix_date = Time.now.strftime("%m/%d/%Y")
80 File.open("config.h", "w") do |f|
81 f.puts "#define CONFIG_DARWIN #{DARWIN.to_s.inspect}"
82 f.puts "#define CONFIG_DISABLE_KQUEUE #{DISABLE_KQUEUE}"
83 f.puts "#define CONFIG_HOST #{HOST.inspect}"
84 f.puts "#define CONFIG_PREFIX #{PREFIX.inspect}"
85 f.puts "#define CONFIG_VERSION #{RBX_VERSION.inspect}"
86 f.puts "#define CONFIG_RUBY_VERSION #{RBX_RUBY_VERSION.inspect}"
87 f.puts "#define CONFIG_RELDATE #{unix_date.inspect}"
88 f.puts "#define CONFIG_RUBY_PATCHLEVEL #{RBX_RUBY_PATCHLEVEL.inspect}"
89 f.puts "#define CONFIG_CODEPATH #{CODEPATH.inspect}"
90 f.puts "#define CONFIG_RBAPATH #{RBAPATH.inspect}"
91 f.puts "#define CONFIG_EXTPATH #{EXTPATH.inspect}"
92 f.puts "#define CONFIG_BUILDREV #{BUILDREV.inspect}"
93 f.puts "#define CONFIG_ENGINE #{ENGINE.inspect}"
94 f.puts "#define CONFIG_CC #{CC.inspect}"
97 f.puts "#define CONFIG_ENABLE_DTRACE 1"
100 if system "config/run is64bit > /dev/null" then
101 f.puts "#define CONFIG_WORDSIZE 64"
102 f.puts "#define CONFIG_ENABLE_DT 0"
104 f.puts "#define CONFIG_WORDSIZE 32"
105 f.puts "#define CONFIG_ENABLE_DT 1"
108 if system "config/run isbigendian > /dev/null" then
109 f.puts "#define CONFIG_BIG_ENDIAN 1"
111 f.puts "#define CONFIG_BIG_ENDIAN 0"
118 File.open 'lib/rbconfig.rb', 'w' do |f|
120 f.puts '# This file was generated by the Rubinius rakelib/configure.rake.'
123 f.puts 'module Config'
124 f.puts ' unless defined? RUBY_ENGINE and RUBY_ENGINE == "rbx" then'
125 f.puts ' raise "Looks like you loaded the Rubinius rbconfig, but this is not Rubinius."'
128 f.puts ' prefix = File.dirname(File.dirname(__FILE__))'
130 f.puts ' CONFIG = {}'
132 f.puts ' CONFIG["prefix"] = prefix'
133 f.puts ' CONFIG["install_prefix"] = /usr/local'
134 f.puts ' CONFIG["DLEXT"] = Rubinius::LIBSUFFIX.dup'
135 f.puts ' CONFIG["EXEEXT"] = ""'
136 f.puts ' CONFIG["ruby_install_name"] = RUBY_ENGINE.dup'
137 f.puts ' CONFIG["RUBY_INSTALL_NAME"] = RUBY_ENGINE.dup'
139 f.puts ' CONFIG["exec_prefix"] = "$(prefix)"'
140 f.puts ' CONFIG["bindir"] = "$(exec_prefix)/bin"'
141 f.puts ' CONFIG["sbindir"] = "$(exec_prefix)/sbin"'
142 f.puts ' CONFIG["libexecdir"] = "$(exec_prefix)/libexec"'
143 f.puts ' CONFIG["datarootdir"] = "$(prefix)/share"'
144 f.puts ' CONFIG["datadir"] = "$(datarootdir)"'
145 f.puts ' CONFIG["sysconfdir"] = "$(prefix)/etc"'
146 f.puts ' CONFIG["sharedstatedir"] = "$(prefix)/com"'
147 f.puts ' CONFIG["localstatedir"] = "$(prefix)/var"'
148 f.puts ' CONFIG["includedir"] = "$(prefix)/include"'
149 f.puts ' CONFIG["oldincludedir"] = "/usr/include"'
150 f.puts ' CONFIG["docdir"] = "$(datarootdir)/doc/$(PACKAGE)"'
151 f.puts ' CONFIG["infodir"] = "$(datarootdir)/info"'
152 f.puts ' CONFIG["htmldir"] = "$(docdir)"'
153 f.puts ' CONFIG["dvidir"] = "$(docdir)"'
154 f.puts ' CONFIG["pdfdir"] = "$(docdir)"'
155 f.puts ' CONFIG["psdir"] = "$(docdir)"'
156 f.puts ' CONFIG["libdir"] = "$(exec_prefix)/lib"'
157 f.puts ' CONFIG["localedir"] = "$(datarootdir)/locale"'
158 f.puts ' CONFIG["mandir"] = "$(datarootdir)/man"'
159 f.puts ' CONFIG["sitedir"] = "$(libdir)/ruby/site_ruby"'
161 f.puts ' major, minor, teeny = RUBY_VERSION.split(".")'
162 f.puts ' CONFIG["MAJOR"] = "#{major}"'
163 f.puts ' CONFIG["MINOR"] = "#{minor}"'
164 f.puts ' CONFIG["TEENY"] = "#{teeny}"'
166 f.puts ' CONFIG["ruby_version"] = "$(MAJOR).$(MINOR).$(TEENY)"'
167 f.puts ' CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"'
168 f.puts ' CONFIG["archdir"] = "$(rubylibdir)/$(arch)"'
169 f.puts ' CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"'
170 f.puts ' CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"'
171 f.puts ' CONFIG["topdir"] = File.dirname(__FILE__)'
173 f.puts ' # some of these only relevant to cross-compiling'
174 f.puts ' /([^-]+)-([^-]+)-(.*)/ =~ RUBY_PLATFORM'
175 f.puts ' cpu, vendor, os = $1, $2, $3'
176 f.puts ' CONFIG["build"] = "#{cpu}-#{vendor}-#{os}"'
177 f.puts ' CONFIG["build_cpu"] = "#{cpu}"'
178 f.puts ' CONFIG["build_vendor"] = "#{vendor}"'
179 f.puts ' CONFIG["build_os"] = "#{os}"'
180 f.puts ' CONFIG["host"] = "#{cpu}-#{vendor}-#{os}"'
181 f.puts ' CONFIG["host_cpu"] = "#{cpu}"'
182 f.puts ' CONFIG["host_vendor"] = "#{vendor}"'
183 f.puts ' CONFIG["host_os"] = "#{os}"'
184 f.puts ' CONFIG["target"] = "#{cpu}-#{vendor}-#{os}"'
185 f.puts ' CONFIG["target_cpu"] = "#{cpu}"'
186 f.puts ' CONFIG["target_vendor"] = "#{vendor}"'
187 f.puts ' CONFIG["target_os"] = "#{os}"'
188 f.puts ' CONFIG["arch"] = "#{cpu}-#{os}"'
189 f.puts ' CONFIG["sitearch"] = "#{cpu}-#{os}"'
190 f.puts ' CONFIG["build_alias"] = ""'
191 f.puts ' CONFIG["host_alias"] = ""'
192 f.puts ' CONFIG["target_alias"] = ""'
194 f.puts ' CONFIG["RUBY_SO_NAME"] = "rubinius-#{Rubinius::RBX_VERSION}"'
195 f.puts ' CONFIG["sitedir"] = "$(install_prefix)/lib/rubinius"'
196 f.puts ' CONFIG["rubyhdrdir"] = "$(prefix)/shotgun/lib/subtend"'
197 f.puts ' CONFIG["wordsize"] = Rubinius::WORDSIZE'
199 # TODO: we should compose sitelibdir from existing CONFIG keys
200 f.puts " CONFIG[\"sitelibdir\"] = \"$(sitedir)/#{LIBVER}\""
202 # TODO: we need to be able to discover these, but for now, UNIXy defaults
203 f.puts ' # command line utilities'
204 f.puts ' CONFIG["SHELL"] = "/bin/sh"'
205 f.puts ' CONFIG["ECHO_C"] = ""'
206 f.puts ' CONFIG["ECHO_N"] = "-n"'
207 f.puts ' CONFIG["ECHO_T"] = ""'
208 f.puts ' CONFIG["GREP"] = "/usr/bin/grep"'
209 f.puts ' CONFIG["EGREP"] = "/usr/bin/grep -E"'
210 f.puts ' CONFIG["RM"] = "rm -f"'
211 f.puts ' CONFIG["CP"] = "cp"'
212 f.puts ' CONFIG["NROFF"] = "/usr/bin/nroff"'
213 f.puts ' CONFIG["MAKEDIRS"] = "mkdir -p"'
215 f.puts ' # compile tools'
216 f.puts ' CONFIG["CC"] = "gcc"'
217 f.puts ' CONFIG["CPP"] = "gcc -E"'
218 f.puts ' CONFIG["YACC"] = "bison -y"'
219 f.puts ' CONFIG["RANLIB"] = "ranlib"'
220 f.puts ' CONFIG["AR"] = "ar"'
221 f.puts ' CONFIG["AS"] = "as"'
222 f.puts ' CONFIG["WINDRES"] = ""'
223 f.puts ' CONFIG["DLLWRAP"] = ""'
224 f.puts ' CONFIG["OBJDUMP"] = ""'
225 f.puts ' CONFIG["LN_S"] = "ln -s"'
226 f.puts ' CONFIG["NM"] = ""'
227 f.puts ' CONFIG["INSTALL_PROGRAM"] = "$(INSTALL)"'
228 f.puts ' CONFIG["INSTALL_SCRIPT"] = "$(INSTALL)"'
229 f.puts ' CONFIG["INSTALL_DATA"] = "$(INSTALL) -m 644"'
230 f.puts ' CONFIG["STRIP"] = "strip -A -n"'
231 f.puts ' CONFIG["MANTYPE"] = "doc"'
232 f.puts ' CONFIG["MAKEFILES"] = "Makefile"'
234 # TODO: fill in these values
235 f.puts ' # compile tools flags'
236 f.puts ' CONFIG["CFLAGS"] = ""'
237 f.puts ' CONFIG["LDFLAGS"] = ""'
238 f.puts ' CONFIG["CPPFLAGS"] = ""'
239 f.puts ' CONFIG["OBJEXT"] = "o"'
240 f.puts ' CONFIG["GNU_LD"] = ""'
241 f.puts ' CONFIG["CPPOUTFILE"] = ""'
242 f.puts ' CONFIG["OUTFLAG"] = "-o "'
243 f.puts ' CONFIG["YFLAGS"] = ""'
244 f.puts ' CONFIG["ASFLAGS"] = ""'
245 f.puts ' CONFIG["DLDFLAGS"] = ""'
246 f.puts ' CONFIG["ARCH_FLAG"] = ""'
247 f.puts ' CONFIG["STATIC"] = ""'
248 f.puts ' CONFIG["CCDLFLAGS"] = ""'
249 f.puts ' CONFIG["XCFLAGS"] = ""'
250 f.puts ' CONFIG["XLDFLAGS"] = ""'
251 f.puts ' CONFIG["LIBRUBY_DLDFLAGS"] = ""'
252 f.puts ' CONFIG["rubyw_install_name"] = ""'
253 f.puts ' CONFIG["RUBYW_INSTALL_NAME"] = ""'
254 f.puts ' CONFIG["SOLIBS"] = ""'
255 f.puts ' CONFIG["DLDLIBS"] = ""'
256 f.puts ' CONFIG["ENABLE_SHARED"] = ""'
257 f.puts ' CONFIG["MAINLIBS"] = ""'
258 f.puts ' CONFIG["COMMON_LIBS"] = ""'
259 f.puts ' CONFIG["COMMON_MACROS"] = ""'
260 f.puts ' CONFIG["COMMON_HEADERS"] = ""'
261 f.puts ' CONFIG["EXPORT_PREFIX"] = ""'
262 f.puts ' CONFIG["EXTOUT"] = ".ext"'
263 f.puts ' CONFIG["ARCHFILE"] = ""'
264 f.puts ' CONFIG["RDOCTARGET"] = ""'
265 f.puts ' CONFIG["LIBRUBY_A"] = "lib$(RUBY_SO_NAME)-static.a"'
266 f.puts ' CONFIG["LIBRUBY_SO"] = "lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY)"'
267 f.puts ' CONFIG["LIBRUBY_ALIASES"] = "lib$(RUBY_SO_NAME).so"'
268 f.puts ' CONFIG["LIBRUBY"] = "$(LIBRUBY_A)"'
269 f.puts ' CONFIG["LIBRUBYARG"] = "$(LIBRUBYARG_STATIC)"'
270 f.puts ' CONFIG["LIBRUBYARG_STATIC"] = "-l$(RUBY_SO_NAME)-static"'
271 f.puts ' CONFIG["LIBRUBYARG_SHARED"] = ""'
272 f.puts ' CONFIG["configure_args"] = ""'
273 f.puts ' CONFIG["ALLOCA"] = ""'
274 f.puts ' CONFIG["DLEXT"] = "bundle"'
275 f.puts ' CONFIG["LIBEXT"] = "a"'
276 f.puts ' CONFIG["LINK_SO"] = ""'
277 f.puts ' CONFIG["LIBPATHFLAG"] = " -L%s"'
278 f.puts ' CONFIG["RPATHFLAG"] = ""'
279 f.puts ' CONFIG["LIBPATHENV"] = "DYLD_LIBRARY_PATH"'
280 f.puts ' CONFIG["TRY_LINK"] = ""'
281 f.puts ' CONFIG["EXTSTATIC"] = ""'
282 f.puts ' CONFIG["setup"] = "Setup"'
283 f.puts ' CONFIG["PATH_SEPARATOR"] = ":"'
284 f.puts ' CONFIG["PACKAGE_NAME"] = ""'
285 f.puts ' CONFIG["PACKAGE_TARNAME"] = ""'
286 f.puts ' CONFIG["PACKAGE_VERSION"] = ""'
287 f.puts ' CONFIG["PACKAGE_STRING"] = ""'
288 f.puts ' CONFIG["PACKAGE_BUGREPORT"] = ""'
290 # HACK: we need something equivalent, but I'm cheating for now - zenspider
291 f.puts ' CONFIG["LDSHARED"] = "cc -dynamic -bundle -undefined suppress -flat_namespace"'
292 f.puts ' CONFIG["LIBRUBY_LDSHARED"] = "cc -dynamic -bundle -undefined suppress -flat_namespace"'
295 # Adapted from MRI's' rbconfig.rb
297 CONFIG.each { |k,v| MAKEFILE_CONFIG[k] = v.kind_of?(String) ? v.dup : v }
299 def Config.expand(val, config = CONFIG)
300 return val unless val.kind_of? String
302 val.gsub!(/\\$\\$|\\$\\(([^()]+)\\)|\\$\\{([^{}]+)\\}/) do |var|
305 elsif key = config[v = v[/\\A[^:]+(?=(?::(.*?)=(.*))?\\z)/]]
308 Config.expand(key, config)
310 key = key.gsub(/\#{Regexp.quote(pat)}(?=\\s|\\z)/n) {sub} if pat
319 CONFIG.each_value do |val|
325 f.puts "CROSS_COMPILING = nil unless defined? CROSS_COMPILING"
326 f.puts "RbConfig = Config"