2015-09-03 12:30:40 -04:00
|
|
|
% config = File.read(conffile = 'rbconfig.rb')
|
|
|
|
% config.sub!(/^(\s*)RUBY_VERSION\b.*(\sor\s*)$/, '\1true\2')
|
|
|
|
% rbconfig = Module.new {module_eval(config, conffile)}::RbConfig
|
|
|
|
% C = rbconfig::MAKEFILE_CONFIG.dup
|
2013-05-16 03:15:48 -04:00
|
|
|
% def C.[](name) str = super and (str unless str.empty?); end
|
2013-05-16 00:13:40 -04:00
|
|
|
#define RUBY_BASE_NAME "${RUBY_BASE_NAME}"
|
|
|
|
#define RUBY_VERSION_NAME RUBY_BASE_NAME"-"RUBY_LIB_VERSION
|
|
|
|
% if C["RUBY_LIB_VERSION_STYLE"]
|
2013-05-16 03:15:45 -04:00
|
|
|
#define RUBY_LIB_VERSION_STYLE ${RUBY_LIB_VERSION_STYLE}
|
2013-05-16 03:15:48 -04:00
|
|
|
% elsif !C["RUBY_LIB_VERSION"]
|
|
|
|
#define RUBY_LIB_VERSION_STYLE 3 /* full */
|
2013-05-16 00:13:40 -04:00
|
|
|
% else
|
2014-12-05 16:14:25 -05:00
|
|
|
#define RUBY_LIB_VERSION "${RUBY_LIB_VERSION}"
|
2013-05-16 00:13:40 -04:00
|
|
|
% end
|
2013-05-16 03:15:48 -04:00
|
|
|
#define RUBY_EXEC_PREFIX "<%='${RUBY_EXEC_PREFIX}' if C['RUBY_EXEC_PREFIX']%>"
|
2013-05-16 00:13:40 -04:00
|
|
|
#define RUBY_LIB_PREFIX "${rubylibprefix}"
|
2013-05-16 03:15:48 -04:00
|
|
|
% unless (sitearch = C["sitearch"]) == '$(arch)'
|
|
|
|
#define RUBY_SITEARCH "<%=sitearch%>"
|
2013-05-16 00:13:40 -04:00
|
|
|
% end
|
|
|
|
#define RUBY_ARCH_PREFIX_FOR(arch) "${rubyarchprefix}"
|
|
|
|
#define RUBY_SITEARCH_PREFIX_FOR(arch) "${rubysitearchprefix}"
|
|
|
|
#define RUBY_LIB "${rubylibdir}"
|
|
|
|
#define RUBY_ARCH_LIB_FOR(arch) "${rubyarchdir}"
|
|
|
|
% if C["sitedir"] == "no"
|
|
|
|
#define NO_RUBY_SITE_LIB 1
|
|
|
|
% else
|
|
|
|
#define RUBY_SITE_LIB "${sitedir}"
|
|
|
|
#define RUBY_SITE_ARCH_LIB_FOR(arch) "${sitearchdir}"
|
|
|
|
% end
|
|
|
|
% if C["vendordir"] == "no"
|
|
|
|
#define NO_RUBY_VENDOR_LIB 1
|
|
|
|
% else
|
|
|
|
#define RUBY_VENDOR_LIB "${vendordir}"
|
|
|
|
#define RUBY_VENDOR_ARCH_LIB_FOR(arch) "${vendorarchdir}"
|
|
|
|
% end
|
2013-05-16 03:15:48 -04:00
|
|
|
% if C["RUBY_SEARCH_PATH"]
|
2013-05-16 00:13:40 -04:00
|
|
|
#define RUBY_SEARCH_PATH "${RUBY_SEARCH_PATH}"
|
|
|
|
% end
|
|
|
|
%
|
|
|
|
% R = {}
|
|
|
|
% R["ruby_version"] = '"RUBY_LIB_VERSION"'
|
|
|
|
% R["arch"] = '"arch"'
|
|
|
|
% R["sitearch"] = '"arch"'
|
|
|
|
% R["vendorlibdir"] = '"RUBY_VENDOR_LIB2"'
|
|
|
|
% R["sitelibdir"] = '"RUBY_SITE_LIB2"'
|
|
|
|
% R["vendordir"] = '"RUBY_VENDOR_LIB"'
|
|
|
|
% R["sitedir"] = '"RUBY_SITE_LIB"'
|
|
|
|
% R["rubylibdir"] = '"RUBY_LIB"'
|
|
|
|
% R["rubylibprefix"] = '"RUBY_LIB_PREFIX"'
|
|
|
|
% R["rubyarchprefix"] = '"RUBY_ARCH_PREFIX_FOR(arch)"'
|
|
|
|
% R["rubysitearchprefix"] = '"RUBY_SITEARCH_PREFIX_FOR(arch)"'
|
|
|
|
% R["exec_prefix"] = '"RUBY_EXEC_PREFIX"'
|
2013-05-16 03:15:48 -04:00
|
|
|
% R["prefix"] = '"RUBY_EXEC_PREFIX"'
|
2015-09-03 12:30:40 -04:00
|
|
|
% exec_prefix_pat = /\A"#{Regexp.quote(rbconfig::CONFIG['exec_prefix'])}(?=\/|\z)/
|
2015-12-20 01:36:57 -05:00
|
|
|
% _erbout.gsub!(/^(#define\s+(\S+)\s+)(.*)/) {
|
2013-05-16 00:13:40 -04:00
|
|
|
% pre, name, repl = $1, $2, $3
|
|
|
|
% pat = %["#{name}"]
|
|
|
|
% c = C.merge(R.reject {|key, value| key == name or value.include?(pat)})
|
2015-09-03 12:30:40 -04:00
|
|
|
% rbconfig.expand(repl, c)
|
2013-05-16 09:35:44 -04:00
|
|
|
% repl.gsub!(/^""(?!$)|(.)""$/, '\1')
|
|
|
|
% repl.sub!(exec_prefix_pat, 'RUBY_EXEC_PREFIX"')
|
|
|
|
% pre + repl
|
2015-12-20 01:36:57 -05:00
|
|
|
% }
|