[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Add native ruby binding to Subversion distribution

From: Yoshiki Hayashi <yoshiki_at_xemacs.org>
Date: 2001-11-13 13:27:56 CET

I've been extremely busy last two weeks but now I can spare
some time to Subversion again.

Yoshiki Hayashi <yoshiki@xemacs.org> writes:

> > >...
> > > +AC_SUBST(LDFLAGS)
> >
> > We need to watch out here, as I mentioned before.
>
> Yeah, this will be removed when we resolved -lpthread issue.

This issue is not resolved yet but here's the revised patch.
This does not contain -lpthread hack so you cannot build
Ruby binding if your apr picks up pthread.

The difference between this patch and previous patch are:

  -lpthread to LDFLAG is removed

  DSO target is renamed to svn_ruby from Ruby_Svn to allow
  name with multiple underscore. This way, simple
  string.index can find DSO name.

  MODULE in Makefile.in is renamed to LINK_DSO

Makefile.in

(RUBY_INCLUDES, ruby_moddir): New var.
(COMPILE_RUBY_MOD, LINK_DSO): New var.
(INSTAL_RUBY_MOD, RUBY): New var.

gen-make.py

* Use $(LINK_DSO) to link when target type is dso.
* Add new 'ruby-mod' custom rule to compile Ruby module.
* Add new target type dso. It is similar to lib but has
  different target name convention and link command.

build.conf

* New target svn_ruby.

configure.in

* Include new helper macro from svn-ruby.m4
* Call AC_LIBTOOL_DLOPEN to check whether the system
  supports dlopen.
* Call SVN_FIND_RUBY to determine if it can/should build
  Ruby binding.
* (BUILD_RULES, INSTALL_RULES): Add Ruby rule when
  Berkeley DB is present. Fs binding depends on it.

svn-ruby.m4

New file.

(SVN_FIND_RUBY): New function. If --enable-ruby-binding is
  given and correct inperter is found, add rules to build
  and install Ruby binding.

rb-config.m4

New file.

Return the location of header file or install directory
depending on the command line argument.

Index: ./Makefile.in
===================================================================
--- ./.svn/text-base/Makefile.in Mon Nov 5 13:35:17 2001
+++ ./Makefile.in Tue Nov 13 20:41:39 2001
@@ -56,18 +56,23 @@
 APACHE_INCLUDES = @APACHE_INCLUDES@
 APACHE_TARGET = @APACHE_TARGET@
 
+RUBY_INCLUDES = @RUBY_INCLUDES@
+ruby_moddir = @ruby_moddir@
+
 MKDIR = @MKDIR@
 
 CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
-LDFLAGS =
+LDFLAGS = @LDFLAGS@
 
 COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES)
 LT_COMPILE = $(LIBTOOL) $(LTFLAGS) --mode=compile $(COMPILE) -o $@ -c $<
 
 COMPILE_APACHE_MOD = $(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) $(CFLAGS) $(APACHE_INCLUDES) $(INCLUDES) -o $@ -c $<
+COMPILE_RUBY_MOD = $(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) $(CFLAGS) $(RUBY_INCLUDES) $(INCLUDES) -o $@ -c $<
 
 LINK = $(LIBTOOL) $(LTFLAGS) --mode=link $(LT_LDFLAGS) $(COMPILE) $(LDFLAGS) -rpath $(libdir)
+LINK_DSO = $(LIBTOOL) $(LTFLAGS) $(LT_LDFLAGS) $(COMPILE) -module -avoid-version $(LDFLAGS) -rpath $(libdir)
 
 INSTALL = @INSTALL@
 INSTALL_LIB = $(LIBTOOL) --mode=install $(INSTALL)
@@ -78,8 +83,10 @@
 INSTALL_MOD_SHARED = @APXS@ -i -a
 INSTALL_MOD_STATIC = $(INSTALL) -m 644
 INSTALL_DATA = $(INSTALL) -m 644
+INSTALL_RUBY_MOD = $(INSTALL_LIB)
 
 PYTHON = @PYTHON@
+RUBY = @RUBY@
 
 all: external-all local-all
 clean: external-clean local-clean
Index: ./gen-make.py
===================================================================
--- ./.svn/text-base/gen-make.py Mon Nov 5 13:36:51 2001
+++ ./gen-make.py Tue Nov 13 21:06:59 2001
@@ -123,6 +123,11 @@
     for info in string.split(parser.get(target, 'infopages')):
       infopages.append(info)
 
+ if parser.get(target, 'type') == 'dso':
+ link = '$(LINK_DSO)'
+ else:
+ link = '$(LINK)'
+
     targ_varname = string.replace(target, '-', '_')
     ldflags = parser.get(target, 'link-flags')
     add_deps = parser.get(target, 'add-deps')
@@ -130,11 +135,11 @@
     ofile.write('%s_DEPS = %s %s\n'
                 '%s_OBJECTS = %s\n'
                 '%s: $(%s_DEPS)\n'
- '\tcd %s && $(LINK) -o %s %s $(%s_OBJECTS) %s $(LIBS)\n\n'
+ '\tcd %s && %s -o %s %s $(%s_OBJECTS) %s $(LIBS)\n\n'
                 % (targ_varname, string.join(objects + deps), add_deps,
                    targ_varname, objnames,
                    tpath, targ_varname,
- path, tfile, ldflags, targ_varname, string.join(libs)))
+ path, link, tfile, ldflags, targ_varname, string.join(libs)))
 
     custom = parser.get(target, 'custom')
     if custom == 'apache-mod':
@@ -145,6 +150,14 @@
           ofile.write('%s%s: %s\n\t$(COMPILE_APACHE_MOD)\n'
                       % (src[:-2], objext, src))
       ofile.write('\n')
+ elif custom == 'ruby-mod':
+ # special build, needing Ruby includes
+ ofile.write('# build these special -- use RUBY_INCLUDES\n')
+ for src in sources:
+ if src[-2:] == '.c':
+ ofile.write('%s%s: %s\n\t$(COMPILE_RUBY_MOD)\n'
+ % (src[:-2], objext, src))
+ ofile.write('\n')
 
   for g_name, g_targets in install.items():
     target_names = [ ]
@@ -314,6 +327,15 @@
         install = 'lib'
     elif type == 'doc':
       pass
+ elif type == 'dso':
+ # dso target name is separated with underscore, like svn_ruby.
+ # First part is the name of DSO.
+ # Second part is to uniquely distinguish makefile target.
+ # In above case, target will be svn_ruby_DEPS, svn_ruby_OBJECTS
+ # and svn.la.
+ tname = name[:string.index(name, '_')]
+ tfile = tname + '.la'
+ self.objext = '.lo'
     else:
       raise GenMakeError('ERROR: unknown build type: ' + type)
 
@@ -338,6 +360,7 @@
 _default_sources = {
   'lib' : '*.c',
   'exe' : '*.c',
+ 'dso' : '*.c',
   'doc' : '*.texi',
   }
 
Index: ./build.conf
===================================================================
--- ./.svn/text-base/build.conf Tue Nov 13 20:29:53 2001
+++ ./build.conf Tue Nov 13 21:02:44 2001
@@ -154,6 +154,14 @@
 # there are some .c files included by others, so *.c isn't appropriate
 sources = hashtable.c xmlparse.c xmlrole.c xmltok.c
 
+[svn_ruby]
+type = dso
+path = subversion/bindings/ruby
+libs = libsvn_client libsvn_wc libsvn_ra libsvn_repos libsvn_fs
+ libsvn_delta libsvn_subr $(SVN_APR_LIBS)
+custom = ruby-mod
+install = ruby-mod
+
 # ----------------------------------------------------------------------------
 #
 # TESTING TARGETS
Index: ./configure.in
===================================================================
--- ./.svn/text-base/configure.in Mon Nov 5 13:35:25 2001
+++ ./configure.in Tue Nov 13 20:48:34 2001
@@ -31,6 +31,7 @@
 sinclude(ac-helpers/svn-macros.m4)
 sinclude(ac-helpers/neon.m4)
 sinclude(ac-helpers/apr.m4)
+sinclude(ac-helpers/svn-ruby.m4)
 
 dnl Grab the libtool macros
 sinclude(ac-helpers/libtool.m4)
@@ -95,6 +96,7 @@
 
 dnl Check for libtool -- we'll definitely need it for all our shared libs!
 echo "configuring libtool now"
+AC_LIBTOOL_DLOPEN
 AC_PROG_LIBTOOL
 
 NEON_WANTED="`sed -n '/NEON_WANTED=/s/.*=//p' $srcdir/buildcheck.sh`"
@@ -103,6 +105,10 @@
 dnl find Apache
 SVN_FIND_APACHE
 
+dnl find Ruby
+
+SVN_FIND_RUBY
+
 dnl Check for libraries --------------------
 
 dnl AC_CHECK_LIB() calls go here, if we ever need any
@@ -119,8 +125,8 @@
 INSTALL_RULES="install-lib install-bin install-include install-docs"
 BUILD_RULES="lib bin test"
 if test "$svn_lib_berkeley_db" = "yes"; then
- BUILD_RULES="lib fs-lib bin fs-bin $BUILD_APACHE_RULE test fs-test"
- INSTALL_RULES="install-lib install-fs-lib install-bin install-fs-bin $INSTALL_APACHE_RULE install-include install-docs"
+ BUILD_RULES="lib fs-lib bin fs-bin $BUILD_APACHE_RULE $BUILD_RUBY_RULE test fs-test"
+ INSTALL_RULES="install-lib install-fs-lib install-bin install-fs-bin $INSTALL_APACHE_RULE $INSTALL_RUBY_RULE install-include install-docs"
   FS_TEST_DEPS="\$(FS_TEST_DEPS)"
   FS_TEST_PROGRAMS="\$(FS_TEST_PROGRAMS)"
 fi

AC_DEFUN(SVN_FIND_RUBY,[

AC_ARG_ENABLE(ruby-binding,
[ --enable-ruby-binding Turn on native Ruby binding support],
[
  if test "$enableval" = "yes"; then
    ruby_binding="yes"
  fi
])

AC_PATH_PROG(RUBY, ruby)
if test "$ruby_binding" = "yes"; then
  if test "$RUBY" = ""; then
    AC_MSG_ERROR(Unable to find ruby interpreter)
  fi
  if test "$enable_shared" = "no"; then
    AC_MSG_ERROR(Ruby binding requires shared library)
  fi
  AC_MSG_CHECKING(for Ruby header)
  ruby_header="`$RUBY ${abs_srcdir}/ac-helpers/rb-config.rb include`"
  if test "$ruby_header" = ""; then
    AC_MSG_ERROR([no - Unable to locate ruby.h])
  else
    AC_MSG_RESULT($ruby_header)
    RUBY_INCLUDES="-I$ruby_header"
    BUILD_RUBY_RULE=ruby-mod
    INSTALL_RUBY_RULE=install-ruby-mod
    ruby_moddir="`$RUBY ${abs_srcdir}/ac-helpers/rb-config.rb site-install`"
  fi
fi
AC_SUBST(RUBY_INCLUDES)
AC_SUBST(BUILD_RUBY_RULE)
AC_SUBST(INSTALL_RUBY_RULE)
AC_SUBST(ruby_moddir)

])

begin
  require 'rbconfig'
rescue LoadError
  exit 1
end

command = ARGV.shift

if command == 'include' then
  if File.exists?(File.join(Config::CONFIG['archdir'], 'ruby.h')) then
    print Config::CONFIG['archdir']
  end
elsif command == 'site-install' then
  print Config::CONFIG['sitearchdir']
end

-- 
Yoshiki Hayashi

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:48 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.