summaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2010-04-12 18:29:09 -0700
committerRuss Allbery <rra@stanford.edu>2010-04-12 18:29:09 -0700
commit02287430d902f07de4ccd9bbfb635c388b690274 (patch)
treef2aa8ada3b02ea2d001e1c9eb6aafc4a47bd510b /ruby
parent3abd6f6842581b067c1a23ba1f9a105a0b759c2f (diff)
More Ruby binding build cleanup
Suppress strict prototype warnings for the Ruby build since the Ruby headers don't use strict prototypes. Stop passing GCC-specific warning suppression flags into the language binding build systems unless the compiler used to build remctl is GCC. This still isn't quite right, since the language bindings may use a different compiler than the main remctl build, but it should be closer than the previous behavior of using GCC flags unconditionally. Add the Ruby CFLAGS to CPPFLAGS since we override CFLAGS during the build. At least with the current Ruby build system, this should accomplish the same thing. Change the Ruby extension to be remctl (lowercase), although the class is Remctl (titlecase). The original contributed code had this right and I misunderstood what was happening. Undefine Autoconf PACKAGE_* variables that Ruby also defines before including ruby.h, and flag unused variables required by the Ruby API to suppress GCC compiler warnings.
Diffstat (limited to 'ruby')
-rw-r--r--ruby/extconf.rb.in11
-rw-r--r--ruby/remctl.c35
2 files changed, 33 insertions, 13 deletions
diff --git a/ruby/extconf.rb.in b/ruby/extconf.rb.in
index dba8cc0..8b1879b 100644
--- a/ruby/extconf.rb.in
+++ b/ruby/extconf.rb.in
@@ -14,10 +14,15 @@ old_libdir = Config::CONFIG['libdir']
require 'mkmf'
Config::MAKEFILE_CONFIG['libdir'] = '@abs_top_srcdir@/client/.libs'
-$CFLAGS << ' -I@abs_top_srcdir@ @CFLAGS@'
-$LDFLAGS << " -L@abs_top_srcdir@/client/.libs -L#{old_libdir}"
+# We add $CFLAGS to the contents of $CPPFLAGS since otherwise we lose the
+# Ruby $CFLAGS. The build system overrides CFLAGS with make warnings.
+# This is really a bug in Ruby; CFLAGS is a user variable that the user
+# should be able to set at build time without losing information.
+$INCFLAGS = "-I@abs_top_srcdir@ #{$INCFLAGS}"
+$CPPFLAGS << " #{$CFLAGS} @CPPFLAGS@"
+$LDFLAGS << " -L@abs_top_srcdir@/client/.libs -L#{old_libdir} @LDFLAGS@"
fail "Couldn't find libremctl"\
unless have_library('remctl', 'remctl_open', 'remctl.h')
-create_makefile('Remctl')
+create_makefile('remctl')
diff --git a/ruby/remctl.c b/ruby/remctl.c
index 70155b6..71b308c 100644
--- a/ruby/remctl.c
+++ b/ruby/remctl.c
@@ -27,10 +27,25 @@
#include <portable/system.h>
#include <errno.h>
-#include <ruby.h>
#include <sys/uio.h>
#include <client/remctl.h>
+#include <util/macros.h>
+
+/*
+ * The Ruby includes use a bare config.h file and don't use proper
+ * namespacing, so we have to undefine some things that we set that Ruby also
+ * sets. We don't care about any of these settings, thankfully.
+ */
+#undef PACKAGE_NAME
+#undef PACKAGE_TARNAME
+#undef PACKAGE_VERSION
+#undef PACKAGE_STRING
+#undef PACKAGE_BUGREPORT
+#include <ruby.h>
+
+/* Our public interface. */
+void Init_remctl(void);
static VALUE cRemctl, cRemctlResult, eRemctlError, eRemctlNotOpen;
@@ -89,7 +104,7 @@ rb_remctl_result_new(struct remctl_result *rr)
* Initialize a Remctl::Result object.
*/
static VALUE
-rb_remctl_result_initialize(VALUE self)
+rb_remctl_result_initialize(VALUE self UNUSED)
{
rb_define_attr(cRemctlResult, "stderr", 1, 0);
rb_define_attr(cRemctlResult, "stdout", 1, 0);
@@ -105,7 +120,7 @@ rb_remctl_result_initialize(VALUE self)
* principal.
*/
static VALUE
-rb_remctl_remctl(int argc, VALUE argv[], VALUE self)
+rb_remctl_remctl(int argc, VALUE argv[], VALUE self UNUSED)
{
VALUE vhost, vport, vprinc, vargs, tmp;
unsigned int port;
@@ -149,7 +164,7 @@ rb_remctl_remctl(int argc, VALUE argv[], VALUE self)
* of a complex connection. A value of 0 indicates the default port.
*/
static VALUE
-rb_remctl_default_port_get(VALUE self)
+rb_remctl_default_port_get(VALUE self UNUSED)
{
return rb_cvar_get(cRemctl, AAdefault_port);
}
@@ -165,7 +180,7 @@ rb_remctl_default_port_get(VALUE self)
* +ArgError+ if the port number isn't sane.
*/
static VALUE
-rb_remctl_default_port_set(VALUE self, VALUE new)
+rb_remctl_default_port_set(VALUE self UNUSED, VALUE new)
{
unsigned int port;
@@ -185,7 +200,7 @@ rb_remctl_default_port_set(VALUE self, VALUE new)
* instance of a complex connection.
*/
static VALUE
-rb_remctl_default_principal_get(VALUE self)
+rb_remctl_default_principal_get(VALUE self UNUSED)
{
return rb_cvar_get(cRemctl, AAdefault_principal);
}
@@ -198,7 +213,7 @@ rb_remctl_default_principal_get(VALUE self)
* of nil requests the library default.
*/
static VALUE
-rb_remctl_default_principal_set(VALUE self, VALUE new)
+rb_remctl_default_principal_set(VALUE self UNUSED, VALUE new)
{
rb_cvar_set(cRemctl, AAdefault_principal, StringValue(new), 0);
return rb_cvar_get(cRemctl, AAdefault_principal);
@@ -301,14 +316,14 @@ rb_remctl_command(int argc, VALUE argv[], VALUE self)
int i;
VALUE s;
- GET_REMCTL_OR_RAISE(self, rc);
+ GET_REMCTL_OR_RAISE(self, r);
iov = ALLOC_N(struct iovec, argc);
for (i = 0; i < argc; i++) {
s = StringValue(argv[i]);
iov[i].iov_base = RSTRING_PTR(s);
iov[i].iov_len = RSTRING_LEN(s);
}
- if (!remctl_commandv(rc, iov, argc))
+ if (!remctl_commandv(r, iov, argc))
rb_raise(eRemctlError, "%s", rb_str_new2(remctl_error(r)));
return Qnil;
}
@@ -405,7 +420,7 @@ rb_remctl_initialize(int argc, VALUE argv[], VALUE self)
* variables.
*/
void
-Init_Remctl(void)
+Init_remctl(void)
{
cRemctl = rb_define_class("Remctl", rb_cObject);
rb_define_singleton_method(cRemctl, "remctl", rb_remctl_remctl, -1);