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