わたなべです.

年越し make で cygwin のクロス環境を Linux 上に久し振りに作りました.
作ったからには Ruby も make したくなるわけで対応してみました.
基本的には
  o configure.in の host_ を target_ に置換
  o AC_CANONICAL_TARGET の追加
  o miniruby を native の ruby -rprep で代用.
    prep.rb は PLATFORM=RUBY_PLATFORM="@arch@"
  o とりあえず cygwin にだけ対応させた
と, こんな感じです.

問題もあって, AC_FUNC_GETPGRP, AC_FUNC_SETPGRP はクロス環境
に対応してないから, あらかじめ config.cache 等を使い
ac_cv_func_getpgrp_void=yes
ac_cv_func_setpgrp_void=yes
とかしておく必要があるとか, prep.rb はいくらなんでもまずそう
とか,
% env CFLAGS=-O2 CC=i586-cygwin32-gcc AR=i586-cygwin32-ar
RANLIB=i586-cygwin32-ranlib LDSHARED='i586-cygwin32-dllwrap
--as=i586-cygwin32-as --dlltool-name=i586-cygwin32-dlltool
--driver-name=i586-cygwin32-gcc --export-all -s'
NM=i586-cygwin32-nm ./configure --target=i386-cygwin --enable-shared
と, ものすごい configure になるとか(これ全部で一行ね), いろいろ.
#gcc の TARGET_FOR_AR みたいにすべきなのか.

そろそろ配布の *.rb の PLATFORM はすべて RUBY_PLATFORM に
置換したほうがいいかも.

#あーとうとう KCODE を指摘されちゃったか.

-- 
わたなべひろふみ

diff -u1r ruby-1.5.0/ChangeLog cross-ruby-1.5.0/ChangeLog --- ruby-1.5.0/ChangeLog Wed Dec 15 00:12:36 1999 +++ cross-ruby-1.5.0/ChangeLog Tue Jan 4 06:14:41 2000 @@ -1 +1,11 @@ +Tue Jan 4 06:04:14 2000 WATANABE Hirofumi <eban / os.rim.or.jp> + + * configure.in: modify for cross-compiling. + use target_* instead of host_*. + use AC_CANONICAL_TARGET. + + * Makefile.in: ditto. + + * cygwin/GNUmakefile.in: ditto. + Mon Dec 13 15:15:31 1999 Yukihiro Matsumoto <matz / netlab.co.jp> diff -u1r ruby-1.5.0/Makefile.in cross-ruby-1.5.0/Makefile.in --- ruby-1.5.0/Makefile.in Mon Nov 8 12:56:59 1999 +++ cross-ruby-1.5.0/Makefile.in Tue Jan 4 02:50:28 2000 @@ -83,4 +83,4 @@ -all: miniruby$(EXEEXT) rbconfig.rb - @./miniruby$(EXEEXT) -Xext extmk.rb @EXTSTATIC@ +all: miniruby$(EXEEXT) @PREP@ rbconfig.rb + @@MINIRUBY@ -Xext extmk.rb @EXTSTATIC@ @@ -100,3 +100,3 @@ $(LDSHARED) $(DLDFLAGS) $(SOLIBS) $(OBJS) dmyext.@OBJEXT@ -o $@ - @-./miniruby -e 'ARGV.each{|link| File.delete link if File.exist? link; \ + @-@MINIRUBY@ -e 'ARGV.each{|link| File.delete link if File.exist? link; \ File.symlink "$(LIBRUBY_SO)", link}' \ @@ -105,3 +105,3 @@ install: rbconfig.rb - ./miniruby$(EXEEXT) $(srcdir)/instruby.rb $(DESTDIR) + @MINIRUBY@ $(srcdir)/instruby.rb $(DESTDIR) @@ -109,3 +109,3 @@ @rm -f ext/extinit.c ext/extinit.@OBJEXT@ dmyext.@OBJEXT@ - @-./miniruby$(EXEEXT) -Xext extmk.rb clean 2> /dev/null || true + @-@MINIRUBY@ -Xext extmk.rb clean 2> /dev/null || true @rm -f $(PROGRAM) miniruby$(EXEEXT) @@ -125,3 +125,6 @@ rbconfig.rb: miniruby$(EXEEXT) - @./miniruby$(EXEEXT) $(srcdir)/mkconfig.rb rbconfig.rb + @@MINIRUBY@ $(srcdir)/mkconfig.rb rbconfig.rb + +prep.rb: miniruby$(EXEEXT) + @echo 'PLATFORM=RUBY_PLATFORM="@arch@"' > $@ diff -u1r ruby-1.5.0/configure.in cross-ruby-1.5.0/configure.in --- ruby-1.5.0/configure.in Wed Dec 15 00:12:37 1999 +++ cross-ruby-1.5.0/configure.in Tue Jan 4 02:33:39 2000 @@ -28,2 +28,3 @@ AC_CANONICAL_HOST +AC_CANONICAL_TARGET @@ -38,3 +39,3 @@ - case "$host_os" in + case "$target_os" in rhapsody*) @@ -138,3 +139,3 @@ dnl Checks for libraries. -case "$host_os" in +case "$target_os" in nextstep*) ;; @@ -328,3 +329,3 @@ -case "$host_os" in +case "$target_os" in linux*) @@ -353,3 +354,3 @@ with_dln_a_out=yes - host_os=${host_os}-a_out + target_os=${target_os}-a_out else @@ -372,3 +373,3 @@ if test "$GCC" = yes; then - case "$host_os" in + case "$target_os" in nextstep*) ;; @@ -380,3 +381,3 @@ netbsd*) CCDLFLAGS=-fpic - case "$host_cpu" in + case "$target_cpu" in mips*) CCDLFLAGS=-fPIC ;; @@ -387,3 +388,3 @@ else - case "$host_os" in + case "$target_os" in hpux*) CCDLFLAGS='+z';; @@ -396,3 +397,3 @@ - case "$host_os" in + case "$target_os" in hpux*) DLDFLAGS="-E" @@ -431,3 +432,3 @@ netbsd*) LDSHARED="ld -shared" - case "$host_cpu" in + case "$target_cpu" in alpha) @@ -466,3 +467,3 @@ rb_cv_dlopen=yes ;; - beos*) case "$host_cpu" in + beos*) case "$target_cpu" in powerpc*) @@ -479,3 +480,3 @@ rb_cv_dlopen=yes ;; - cygwin*) LDSHARED='dllwrap --export-all -s' + cygwin*) : ${LDSHARED='dllwrap --export-all -s'} rb_cv_dlopen=yes ;; @@ -515,3 +516,3 @@ else - case "$host_os" in + case "$target_os" in hpux*) DLEXT=sl @@ -540,3 +541,3 @@ -case "$host_os" in +case "$target_os" in linux*) @@ -561,3 +562,3 @@ -case "$host_os" in +case "$target_os" in human*) @@ -632,2 +633,12 @@ +if test x"$cross_compiling" = xyes; then + MINIRUBY='ruby -I.. -rprep' + PREP=prep.rb +else + MINIRUBY='./miniruby$(EXEEXT)' + PREP='' +fi +AC_SUBST(MINIRUBY) +AC_SUBST(PREP) + LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a' @@ -636,3 +647,3 @@ SOLIBS= -if test "$host_os" = "beos"; then +if test "$target_os" = "beos"; then LIBRUBY='$(LIBRUBY_SO)' @@ -641,3 +652,3 @@ echo creating ruby.def - case "$host_cpu" in + case "$target_cpu" in powerpc*) @@ -668,3 +679,3 @@ CFLAGS="$CFLAGS $CCDLFLAGS" - case "$host_os" in + case "$target_os" in sunos4*) @@ -685,3 +696,3 @@ LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR)' - case "$host_cpu" in + case "$target_cpu" in alpha|mipsel|mipseb|powerpc|sparc64) # ELF platforms @@ -718,2 +729,6 @@ CCDLFLAGS=-DUSEIMPORTLIB + : ${NM=nm} + AC_SUBST(NM) + : ${DLLWRAP=dllwrap} + AC_SUBST(DLLWRAP) ;; @@ -724,3 +739,3 @@ -case "$host_os" in +case "$target_os" in nextstep*) @@ -767,12 +782,12 @@ if test "$fat_binary" = yes ; then - arch="fat-${host_os}" + arch="fat-${target_os}" AC_DEFINE_UNQUOTED(RUBY_THIN_ARCHLIB, - "${RUBY_LIB_PATH}/" __ARCHITECTURE__ "-${host_os}") + "${RUBY_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}") AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB, - "${RUBY_SITE_LIB_PATH}/" __ARCHITECTURE__ "-${host_os}") - AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${host_os}") + "${RUBY_SITE_LIB_PATH}/" __ARCHITECTURE__ "-${target_os}") + AC_DEFINE_UNQUOTED(RUBY_PLATFORM, __ARCHITECTURE__ "-${target_os}") else - arch="${host_cpu}-${host_os}" + arch="${target_cpu}-${target_os}" AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "${arch}") diff -u1r ruby-1.5.0/cygwin/GNUmakefile.in cross-ruby-1.5.0/cygwin/GNUmakefile.in --- ruby-1.5.0/cygwin/GNUmakefile.in Fri Aug 13 14:45:15 1999 +++ cross-ruby-1.5.0/cygwin/GNUmakefile.in Tue Jan 4 02:25:11 2000 @@ -7,3 +7,3 @@ $(RUBYCWDLL): $(OBJS) dmyext.o - dllwrap -o $(RUBYCWDLL) --export-all --output-lib=$(LIBRUBY_SO) --dllname=$(RUBYCWDLL) -Wl,-e,__cygwin_noncygwin_dll_entry@12 --add-stdcall-alias -s $(OBJS) dmyext.o - nm --extern-only $(OBJS) dmyext.o | sed -n '/^........ [CD] _\(.*\)$$/s//#define \1 (*__imp_\1)/p' >import.h + $(LDSHARED) $(DLDFLAGS) -o $(RUBYCWDLL) --output-lib=$(LIBRUBY_SO) --dllname=$(RUBYCWDLL) -Wl,-e,__cygwin_noncygwin_dll_entry@12 --add-stdcall-alias $(OBJS) dmyext.o + @NM@ --extern-only $(OBJS) dmyext.o | sed -n '/^........ [CD] _\(.*\)$$/s//#define \1 (*__imp_\1)/p' >import.h