summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--common.mk4
-rw-r--r--configure.in40
-rw-r--r--template/verconf.h.in55
-rwxr-xr-xtool/shvar_to_cpp.rb25
5 files changed, 71 insertions, 58 deletions
diff --git a/ChangeLog b/ChangeLog
index f3c739c..01d3b42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu May 16 13:12:27 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * template/verconf.h.in: generate verconf.h from the template and
+ rbconfig.rb.
+
Thu May 16 05:47:18 2013 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/visitors/yaml_tree.rb: fix syntax error.
diff --git a/common.mk b/common.mk
index 48956f5..8602155 100644
--- a/common.mk
+++ b/common.mk
@@ -834,9 +834,9 @@ newline.$(OBJEXT): $(NEWLINE_C) {$(VPATH)}defines.h \
{$(VPATH)}intern.h {$(VPATH)}missing.h {$(VPATH)}st.h \
{$(VPATH)}transcode_data.h {$(VPATH)}ruby.h {$(VPATH)}config.h {$(VPATH)}subst.h
-verconf.h: verconf.in $(srcdir)/tool/shvar_to_cpp.rb $(RBCONFIG)
+verconf.h: $(srcdir)/template/verconf.h.in $(srcdir)/tool/generic_erb.rb $(RBCONFIG)
$(ECHO) creating $@
- $(Q) $(MINIRUBY) "$(srcdir)/tool/shvar_to_cpp.rb" verconf.in > $@
+ $(Q) $(MINIRUBY) "$(srcdir)/tool/generic_erb.rb" $(srcdir)/template/verconf.h.in > $@
DTRACE_DEPENDENT_OBJS = array.$(OBJEXT) \
eval.$(OBJEXT) \
diff --git a/configure.in b/configure.in
index d553608..ea248c5 100644
--- a/configure.in
+++ b/configure.in
@@ -231,8 +231,6 @@ RUBYW_BASE_NAME=`echo rubyw | sed "$program_transform_name"`
AC_SUBST(RUBY_BASE_NAME)
AC_SUBST(RUBYW_BASE_NAME)
AC_SUBST(RUBY_VERSION_NAME, '${RUBY_BASE_NAME}-${ruby_version}')
-AC_DEFINE_UNQUOTED(RUBY_BASE_NAME, "${RUBY_BASE_NAME}" !<verconf>!)
-AC_DEFINE_UNQUOTED(RUBY_VERSION_NAME, RUBY_BASE_NAME"-"RUBY_LIB_VERSION !<verconf>!)
AC_CANONICAL_TARGET
test x"$target_alias" = x &&
@@ -2833,6 +2831,8 @@ else
fi
AC_SUBST(setup)
+save_prefix="$prefix"
+save_exec_prefix="$exec_prefix"
test x"$prefix" = xNONE && prefix=$ac_default_prefix
test x"${exec_prefix}" = xNONE && exec_prefix="$prefix"
pat=`echo "${exec_prefix}" | tr -c '\012' .`'\(.*\)'
@@ -2841,6 +2841,8 @@ for var in bindir libdir; do
AS_CASE(["$val"], ["${exec_prefix}"*], [val='${exec_prefix}'"`expr \"$val\" : \"$pat\"`"])
eval $var='"$val"'
done
+prefix="$save_prefix"
+exec_prefix="$save_exec_prefix"
BTESTRUBY='$(MINIRUBY)'
if test x"$cross_compiling" = xyes; then
@@ -3534,6 +3536,8 @@ elif test -z "${ruby_version}"; then
else
RUBY_LIB_VERSION="\"${ruby_version}\""
fi
+AC_SUBST(RUBY_LIB_VERSION_STYLE)
+AC_SUBST(RUBY_LIB_VERSION)
AC_ARG_WITH(sitedir,
AS_HELP_STRING([--with-sitedir=DIR], [site libraries in DIR [[RUBY_LIB_PREFIX/site_ruby]], "no" to disable site directory]),
@@ -3566,30 +3570,7 @@ else
RUBY_EXEC_PREFIX="${exec_prefix}"
fi
-if test ${RUBY_LIB_VERSION_STYLE+set}; then
- AC_DEFINE_UNQUOTED(RUBY_LIB_VERSION_STYLE, $RUBY_LIB_VERSION_STYLE !<verconf>!)
-else
- AC_DEFINE_UNQUOTED(RUBY_LIB_VERSION, "$RUBY_LIB_VERSION" !<verconf>!)
-fi
-AC_DEFINE_UNQUOTED(RUBY_EXEC_PREFIX, "${RUBY_EXEC_PREFIX}" !<verconf>!)
-AC_DEFINE_UNQUOTED(RUBY_LIB_PREFIX, "${rubylibprefix}" !<verconf>!)
-AC_DEFINE_UNQUOTED(RUBY_ARCH_PREFIX_FOR(arch), "${rubyarchprefix}" !<verconf>!)
-AC_DEFINE_UNQUOTED(RUBY_SITEARCH_PREFIX_FOR(arch), "${rubysitearchprefix}" !<verconf>!)
-
-AC_DEFINE_UNQUOTED(RUBY_LIB, "${rubylibdir}" !<verconf>!)
-AC_DEFINE_UNQUOTED(RUBY_ARCH_LIB_FOR(arch), "${rubyarchdir}" !<verconf>!)
-if test "x$sitedir" = xno; then
- AC_DEFINE(NO_RUBY_SITE_LIB, [] !<verconf>!)
-else
- AC_DEFINE_UNQUOTED(RUBY_SITE_LIB, "${sitedir}" !<verconf>!)
- AC_DEFINE_UNQUOTED(RUBY_SITE_ARCH_LIB_FOR(arch), "${sitearchdir}" !<verconf>!)
-fi
-if test "x$vendordir" = xno; then
- AC_DEFINE(NO_RUBY_VENDOR_LIB, [] !<verconf>!)
-else
- AC_DEFINE_UNQUOTED(RUBY_VENDOR_LIB, "${vendordir}" !<verconf>!)
- AC_DEFINE_UNQUOTED(RUBY_VENDOR_ARCH_LIB_FOR(arch), "${vendorarchdir}" !<verconf>!)
-fi
+AC_SUBST(RUBY_EXEC_PREFIX)
AC_SUBST(libdirname, ${multiarch+arch}libdir)
AC_SUBST(archlibdir)dnl
@@ -3638,14 +3619,13 @@ fi
unset sitearch
AS_CASE(["$target_os"],[mingw*],[sitearch="$target_cpu-$rb_cv_msvcrt"])
-test ${sitearch+set} && AC_DEFINE_UNQUOTED(RUBY_SITEARCH, "${sitearch}" !<verconf>!)
: ${sitearch='${arch}'}
AC_ARG_WITH(search-path,
AS_HELP_STRING([--with-search-path=DIR], [specify the additional search path]),
[search_path=$withval])
if test "$search_path" != ""; then
- AC_DEFINE_UNQUOTED(RUBY_SEARCH_PATH,"$search_path" !<verconf>!)
+ AC_SUBST(RUBY_SEARCH_PATH, $search_path)
fi
AC_ARG_WITH(rubyhdrdir,
@@ -3723,12 +3703,10 @@ guard=INCLUDE_RUBY_CONFIG_H
{
echo "#ifndef $guard"
echo "#define $guard 1"
- grep -v "^#define PACKAGE_" confdefs.h | grep -v ' !<verconf>!$'
+ grep -v "^#define PACKAGE_" confdefs.h
echo "#endif /* $guard */"
} | tr -d '\015' |
${srcdir}/tool/ifchange "${config_h}" -
-sed -n 's/ !<verconf>!$//p' confdefs.h | ${srcdir}/tool/ifchange verconf.in -
-rm -f verconf.h
tr -d '\015' < largefile.h > confdefs.h
rm largefile.h
diff --git a/template/verconf.h.in b/template/verconf.h.in
new file mode 100644
index 0000000..a97cf30
--- /dev/null
+++ b/template/verconf.h.in
@@ -0,0 +1,55 @@
+% require './rbconfig'
+% C = RbConfig::MAKEFILE_CONFIG
+%
+% verconf =
+#define RUBY_BASE_NAME "${RUBY_BASE_NAME}"
+#define RUBY_VERSION_NAME RUBY_BASE_NAME"-"RUBY_LIB_VERSION
+% if C["RUBY_LIB_VERSION_STYLE"]
+#define RUBY_LIB_VERSION_STYLE ${RUBY_LIB_VERSION_STYLE}
+% else
+#define RUBY_LIB_VERSION ${RUBY_LIB_VERSION}
+% end
+#define RUBY_EXEC_PREFIX "${RUBY_EXEC_PREFIX}"
+#define RUBY_LIB_PREFIX "${rubylibprefix}"
+% unless C["sitearch"] == '$(arch)'
+#define RUBY_SITEARCH "${sitearch}"
+% 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
+% unless C["RUBY_SEARCH_PATH"] == ""
+#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"'
+% verconf.gsub!(/^(#define\s+(\S+)\s+)(.*)/) {
+% pre, name, repl = $1, $2, $3
+% pat = %["#{name}"]
+% c = C.merge(R.reject {|key, value| key == name or value.include?(pat)})
+% pre + RbConfig.expand(repl, c).gsub(/^""(?!$)|(.)""$/, '\1')
+% }
diff --git a/tool/shvar_to_cpp.rb b/tool/shvar_to_cpp.rb
deleted file mode 100755
index 79764e9..0000000
--- a/tool/shvar_to_cpp.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/ruby
-
-require './rbconfig'
-C = RbConfig::MAKEFILE_CONFIG.dup
-C["ruby_version"] = '"RUBY_LIB_VERSION"'
-C["arch"] = '"arch"'
-C["sitearch"] = '"arch"'
-C["vendorarchdir"] = '"RUBY_VENDOR_ARCH_LIB"'
-C["sitearchdir"] = '"RUBY_SITE_ARCH_LIB"'
-C["vendorlibdir"] = '"RUBY_VENDOR_LIB2"'
-C["sitelibdir"] = '"RUBY_SITE_LIB2"'
-C["vendordir"] = '"RUBY_VENDOR_LIB"'
-C["sitedir"] = '"RUBY_SITE_LIB"'
-C["rubylibdir"] = '"RUBY_LIB"'
-C["rubylibprefix"] = '"RUBY_LIB_PREFIX"'
-C["rubyarchprefix"] = '"RUBY_ARCH_PREFIX_FOR(arch)"'
-C["rubysitearchprefix"] = '"RUBY_SITEARCH_PREFIX_FOR(arch)"'
-C["exec_prefix"] = '"RUBY_EXEC_PREFIX"'
-
-verconf = File.read(ARGV[0])
-verconf.gsub!(/^(#define\s+\S+\s+)(.*)/) {
- $1 + RbConfig.expand($2, C).gsub(/^""(?!$)|(.)""$/, '\1')
-}
-
-puts verconf