Cross Compiling Ruby external modules for the Nokia 770

Greetings,

I've had several request to update my Ruby "release" for the Nokia 770
to include gems. Gems, as I understand it, requires a few external
components to be compiled into Ruby, e.g., openssl, stringio, etc.; and
of course modifying ext/Setup accordingly works flawlessly on Windows
and Linux flavors. Unfortunately, I'm having trouble making the same
mods to my Maemo cross compiled version of Ruby and I'm hoping someone
might be able to diagnose the problem I'm having (its escaping me, I'm
sorry to say :frowning: So... I've tried this several times, several
different ways all w/the same outcome. Also of note is that because
the Nokia 770 linux distro is highly pruned down, I'm compiling ruby
and the necessary external components as static, ie, non-dynamic, so
all necessary extermal libs are linked into the resultant Ruby.

Thx in advance!

Ken

Starting from a clean untar of Ruby 184, we do the following:

1) Edit ext/Setup - notice nodymaic is uncommented and only openssl and
stringio are uncommented.

option nodynamic

#Win32API
#bigdecimal
#curses
#dbm
#digest
#digest/md5
#digest/rmd160
#digest/sha1
#digest/sha2
#dl
#enumerator
#etc
#fcntl
#gdbm
#iconv
#io/wait
#nkf
#pty
openssl
#racc/cparse
#readline
#sdbm
#socket
stringio
#strscan
#syck
#syslog
#tcltklib
#tk
#win32ole
#zlib

2) ./configure --with-static-linked-ext # config finishes w/out
incident.

3) make # Ruby and openssl compile fine but when (what appear to be)
openssl dependencies begin to compile, we get the following:

<snip>
make[1]: Leaving directory `/home/ken/ruby-1.8.4/ext/digest/sha2'
compiling dl
make[1]: Entering directory `/home/ken/ruby-1.8.4/ext/dl'
gcc -g -O2 -fno-defer-pop -fno-omit-frame-pointer -I. -I../..
-I/home/ken/ruby-1.8.4 -I/home/ken/ruby-1.8.4/ext/dl -DRUBY_EXPORT
-DHAVE_DLFCN_H -DHAVE_DLOPEN -DHAVE_DLCLOSE -DHAVE_DLSYM -DHAVE_DLERROR
-I. -c sym.c
gcc -g -O2 -fno-defer-pop -fno-omit-frame-pointer -I. -I../..
-I/home/ken/ruby-1.8.4 -I/home/ken/ruby-1.8.4/ext/dl -DRUBY_EXPORT
-DHAVE_DLFCN_H -DHAVE_DLOPEN -DHAVE_DLCLOSE -DHAVE_DLSYM -DHAVE_DLERROR
-I. -c handle.c
gcc -g -O2 -fno-defer-pop -fno-omit-frame-pointer -I. -I../..
-I/home/ken/ruby-1.8.4 -I/home/ken/ruby-1.8.4/ext/dl -DRUBY_EXPORT
-DHAVE_DLFCN_H -DHAVE_DLOPEN -DHAVE_DLCLOSE -DHAVE_DLSYM -DHAVE_DLERROR
-I. -c ptr.c
gcc -g -O2 -fno-defer-pop -fno-omit-frame-pointer -I. -I../..
-I/home/ken/ruby-1.8.4 -I/home/ken/ruby-1.8.4/ext/dl -DRUBY_EXPORT
-DHAVE_DLFCN_H -DHAVE_DLOPEN -DHAVE_DLCLOSE -DHAVE_DLSYM -DHAVE_DLERROR
-I. -c dl.c
In file included from dl.c:104:
callback.func:1: error: parse error before '(' token
callback.func:1: error: parse error before ')' token
callback.func:3: error: parse error before '(' token
callback.func:3: error: parse error before ')' token
callback.func:4: error: `proc' undeclared here (not in a function)
callback.func:4: error: `argc' undeclared here (not in a function)
callback.func:4: error: `argv' undeclared here (not in a function)
callback.func:4: error: initializer element is not constant
callback.func:4: warning: data definition has no type or storage class
callback.func:6: error: parse error before "return"
callback.func:9: warning: data definition has no type or storage class
callback.func:14: error: conflicting types for `buff'
callback.func:12: error: previous declaration of `buff'

Checking out the (apparently) dynamically generated file
"callback.func", we see the following (no, this isn't a copy and past
error - the file begins on line 1 w/ "f( RSTRING(proto)->len >= 15 )".
Any idea why this file would be incomplete/corrupt? Is there another
parameter I need to perhaps pass to "configure" that pertains to
statically "building" Ruby?

f( RSTRING(proto)->len >= 15 )
    rb_raise(rb_eArgError, "too many arguments");
  rb_dl_scan_callback_args(buff, RSTRING(proto)->ptr, &argc, argv);
  retval = rb_funcall2(proc, id_call, argc, argv);

  return rb_dlptr2cptr(retval);
}

obj;
  VALUE argv[15];
  int argc;
  long buff[15];

  buff[0] = arg0;
  buff[1] = arg1;
  buff[2] = arg2;
  buff[3] = arg3;
  buff[4] = arg4;
  buff[5] = arg5;
  buff[6] = arg6;
  buff[7] = arg7;
  buff[8] = arg8;
  buff[9] = arg9;
  buff[10] = arg10;
  buff[11] = arg11;
  buff[12] = arg12;
  buff[13] = arg13;
  buff[14] = arg14;

  obj = rb_hash_aref(DLFuncTable, rb_assoc_new(INT2NUM(0),INT2NUM(0)));
proto = rb_ary_entry(obj, 0);
  proc = rb_ary_entry(obj, 1);
  Check_Type(proto, T_STRING);
  if( RSTRING(proto)->len >= 15 )
    rb_raise(rb_eArgError, "too many arguments");
  rb_dl_scan_callback_args(buff, RSTRING(proto)->ptr, &argc, argv);
  retval = rb_funcall2(proc, id_call, argc, argv);

  /* no return value */
}