}
// Use property for binDir if available, otherwise fall back to common bin default
String binDir = SafePropertyAccessor.getProperty("jruby.bindir");
if (binDir == null) {
binDir = new NormalizedFile(normalizedHome, "bin").getPath();
}
setConfig(configHash, "bindir", binDir);
setConfig(configHash, "RUBY_INSTALL_NAME", jrubyScript());
setConfig(configHash, "ruby_install_name", jrubyScript());
setConfig(configHash, "SHELL", jrubyShell());
setConfig(configHash, "prefix", normalizedHome);
setConfig(configHash, "exec_prefix", normalizedHome);
setConfig(configHash, "host_os", getOSName());
setConfig(configHash, "host_vendor", System.getProperty("java.vendor"));
setConfig(configHash, "host_cpu", getArchitecture());
setConfig(configHash, "target_os", getOSName());
setConfig(configHash, "target_cpu", getArchitecture());
String jrubyJarFile = "jruby.jar";
URL jrubyPropertiesUrl = Ruby.getClassLoader().getResource("/org/jruby/Ruby.class");
if (jrubyPropertiesUrl != null) {
Pattern jarFile = Pattern.compile("jar:file:.*?([a-zA-Z0-9.\\-]+\\.jar)!" + "/org/jruby/Ruby.class");
Matcher jarMatcher = jarFile.matcher(jrubyPropertiesUrl.toString());
jarMatcher.find();
if (jarMatcher.matches()) {
jrubyJarFile = jarMatcher.group(1);
}
}
setConfig(configHash, "LIBRUBY", jrubyJarFile);
setConfig(configHash, "LIBRUBY_SO", jrubyJarFile);
setConfig(configHash, "LIBRUBY_SO", jrubyJarFile);
setConfig(configHash, "LIBRUBY_ALIASES", jrubyJarFile);
setConfig(configHash, "build", Constants.BUILD);
setConfig(configHash, "target", Constants.TARGET);
String libdir = SafePropertyAccessor.getProperty("jruby.lib");
if (libdir == null) {
libdir = new NormalizedFile(normalizedHome, "lib").getPath();
} else {
try {
// Our shell scripts pass in non-canonicalized paths, but even if we didn't
// anyone who did would become unhappy because Ruby apps expect no relative
// operators in the pathname (rubygems, for example).
libdir = new NormalizedFile(libdir).getCanonicalPath();
} catch (IOException e) {
libdir = new NormalizedFile(libdir).getAbsolutePath();
}
}
String rubyLibDir = new NormalizedFile(libdir, "ruby/1.8").getPath();
String siteDir = new NormalizedFile(libdir, "ruby/site_ruby").getPath();
String siteLibDir = new NormalizedFile(libdir, "ruby/site_ruby/1.8").getPath();
String siteArchDir = new NormalizedFile(libdir, "ruby/site_ruby/1.8/java").getPath();
String archDir = new NormalizedFile(libdir, "ruby/1.8/java").getPath();
String shareDir = new NormalizedFile(normalizedHome, "share").getPath();
String includeDir = new NormalizedFile(normalizedHome, "lib/native/" + getOSName()).getPath();
setConfig(configHash, "libdir", libdir);
if (runtime.is1_9()) setConfig(configHash, "rubylibprefix", libdir + "/ruby");
setConfig(configHash, "rubylibdir", rubyLibDir);
setConfig(configHash, "sitedir", siteDir);
setConfig(configHash, "sitelibdir", siteLibDir);
setConfig(configHash, "sitearch", "java");
setConfig(configHash, "sitearchdir", siteArchDir);
setConfig(configHash, "archdir", archDir);
setConfig(configHash, "topdir", archDir);
setConfig(configHash, "includedir", includeDir);
setConfig(configHash, "configure_args", "");
setConfig(configHash, "datadir", shareDir);
setConfig(configHash, "mandir", new NormalizedFile(normalizedHome, "man").getPath());
setConfig(configHash, "sysconfdir", new NormalizedFile(normalizedHome, "etc").getPath());
setConfig(configHash, "localstatedir", new NormalizedFile(normalizedHome, "var").getPath());
setConfig(configHash, "DLEXT", "jar");
if (Platform.IS_WINDOWS) {
setConfig(configHash, "EXEEXT", ".exe");
} else {
setConfig(configHash, "EXEEXT", "");
}
if (runtime.is1_9()) {
setConfig(configHash, "ridir", new NormalizedFile(shareDir, "ri").getPath());
}
// These will be used as jruby defaults for rubygems if found
String gemhome = SafePropertyAccessor.getProperty("jruby.gem.home");
String gempath = SafePropertyAccessor.getProperty("jruby.gem.path");
if (gemhome != null) setConfig(configHash, "default_gem_home", gemhome);
if (gempath != null) setConfig(configHash, "default_gem_path", gempath);
setConfig(configHash, "joda-time.version", Constants.JODA_TIME_VERSION);
setConfig(configHash, "tzdata.version", Constants.TZDATA_VERSION);
RubyHash mkmfHash = RubyHash.newHash(runtime);
setConfig(mkmfHash, "libdir", libdir);
setConfig(mkmfHash, "arch", "java");
setConfig(mkmfHash, "rubylibdir", rubyLibDir);
setConfig(mkmfHash, "sitedir", siteDir);
setConfig(mkmfHash, "sitelibdir", siteLibDir);
setConfig(mkmfHash, "sitearch", "java");
setConfig(mkmfHash, "sitearchdir", siteArchDir);
setConfig(mkmfHash, "archdir", archDir);
setConfig(mkmfHash, "topdir", archDir);
setConfig(mkmfHash, "configure_args", "");
setConfig(mkmfHash, "datadir", new NormalizedFile(normalizedHome, "share").getPath());
setConfig(mkmfHash, "mandir", new NormalizedFile(normalizedHome, "man").getPath());
setConfig(mkmfHash, "sysconfdir", new NormalizedFile(normalizedHome, "etc").getPath());
setConfig(mkmfHash, "localstatedir", new NormalizedFile(normalizedHome, "var").getPath());
setupMakefileConfig(configModule, mkmfHash);
}