Gauche:CrossCompilation
Gauche:WishListから移動。
クロスコンパイルでバイナリを作成する
YOKOTA Hiroshi(2007/11/25 13:32:03 PST): 現在の MinGW バイナリは構築時に Cygwin も必要とするなど準備が面倒なのでUnix上にクロスコンパイラを用意してそちらで構築するようにしてみました。
以下のパッチを当てて
$ ./configure --build=i686-pc-linux-gnu --host=i686-pc-mingw32msvc --prefix=/target/Gauche
等とするとクロスコンパイルでバイナリを作成します。 このパッチはなるべく汎用に書いたつもりなので他のクロスコンパイルにも使えると思います。構築にはあらかじめ構築する環境で動作するGaucheがインストールされている必要があります。
このパッチには
- クロスコンパイルに必要な修正
- クロスコンパイル用の特殊なgauche-configを作成する修正
- configure/Makefileの変数名の修正。クロスコンパイル環境では"host","target"ではなく"build","host"の方が良いので全体的に名前を入れ換える修正
- 構築時に出るコンパイラの警告を出ないようにする修正
- 新しいautoconfではaclocal.m4は自動的に上書きされるので上書きされないようにacinclude.m4に内容を移す修正
- より新しいgcc4ベースのmingw-gccでコンパイルするための修正
が含まれます。
なお、この修正では gauche-config や gauche-package にはあまり変更を加えていないので外部モジュールのクロスコンパイルはまだできません。外部モジュールのクロスコンパイルにはこれらのスクリプトをクロスコンパイル対応に書きなおす必要があります。また、記述を簡単にするためにGNU make依存の構文を使用しています。必要ならこれも修正する必要があります。
注意:現在のmingw32-runtime-3.13のsnprintf()にはバグがあり、long int変数の表示がおかしくなります。以下のパッチを当てて再構築して下さい。
--- mingw-runtime-3.13-20070825-1/mingwex/gdtoa/mingw_snprintf.c.orig 2007-08-24 19:57:04.000000000 +0900 +++ mingw-runtime-3.13-20070825-1/mingwex/gdtoa/mingw_snprintf.c 2007-11-13 20:48:53.000000000 +0900 @@ -465,7 +465,7 @@ len = LEN_LL; } else - len = LEN_LL; + len = LEN_L; goto fmtloop; case 'L': flag_ld++;
以下が本体のパッチです。
diff -ruN -x configure -x config.scm Gauche-0.8.12/acinclude.m4 Gauche-0.8.12-cross/acinclude.m4 --- Gauche-0.8.12/acinclude.m4 1970-01-01 09:00:00.000000000 +0900 +++ Gauche-0.8.12-cross/acinclude.m4 2007-11-06 15:19:21.000000000 +0900 @@ -0,0 +1,9 @@ +dnl -*- mode: autoconf -*- +dnl Autoconf user macros. +dnl This file may includes by "aclocal.m4". + +dnl Gauche custom macros +m4_include([m4/gauche.m4]) +m4_include([m4/type_socklen_t.m4]) + +dnl diff -ruN -x configure -x config.scm Gauche-0.8.12/aclocal.m4 Gauche-0.8.12-cross/aclocal.m4 --- Gauche-0.8.12/aclocal.m4 2005-09-04 20:02:28.000000000 +0900 +++ Gauche-0.8.12-cross/aclocal.m4 2007-11-03 17:03:26.000000000 +0900 @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.9.5 -*- Autoconf -*- +# generated automatically by aclocal 1.9.6 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005 Free Software Foundation, Inc. @@ -11,5 +11,4 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. -m4_include([m4/gauche.m4]) -m4_include([m4/type_socklen_t.m4]) +m4_include([acinclude.m4]) diff -ruN -x configure -x config.scm Gauche-0.8.12/configure.ac Gauche-0.8.12-cross/configure.ac --- Gauche-0.8.12/configure.ac 2007-10-30 08:00:26.000000000 +0900 +++ Gauche-0.8.12-cross/configure.ac 2007-12-03 07:48:40.000000000 +0900 @@ -142,7 +142,7 @@ dnl with gc's configure.in. case $GAUCHE_THREAD_TYPE in pthreads|default) - case "$target" in + case "$host" in *-*-linux*) AC_DEFINE(GC_LINUX_THREADS,1,[Define to use Linux threads]) AC_DEFINE(_REENTRANT,1,[Define to use reentrant libc]) @@ -198,7 +198,7 @@ ;; *) if test $GAUCHE_THREAD_TYPE = "pthreads"; then - AC_MSG_ERROR([pthread is not supported on $target]) + AC_MSG_ERROR([pthread is not supported on $host]) else GAUCHE_THREAD_TYPE=none fi @@ -247,6 +247,9 @@ AC_CHECK_PROGS(MAKEINFO, makeinfo) AC_CHECK_PROGS(GZIP_PROGRAM, gzip) +dnl for cross build +AC_CHECK_PROGS(BUILD_CC, ${build}-gcc ${build_alias}-gcc gcc cc) + dnl Safe default CFLAGS (usually -g -O2 if you're using gcc, empty otherwise). dnl If the user overrides CFLAGS during configure, which is recorded. dnl This information is used when configuring extensions. @@ -260,7 +263,7 @@ AC_HEADER_STDC AC_HEADER_TIME AC_CHECK_HEADERS(sys/time.h sys/types.h glob.h dlfcn.h getopt.h sched.h unistd.h) -AC_CHECK_HEADERS(stdint.h inttypes.h rpc/types.h) +AC_CHECK_HEADERS(stdint.h inttypes.h rpc/types.h malloc.h) AC_CHECK_HEADERS(syslog.h crypt.h) AC_CHECK_HEADERS(pty.h util.h libutil.h sys/loadavg.h) @@ -269,7 +272,7 @@ dnl =========================================================== dnl Checks processor type, for processor-specific stuff -case $target in +case $host in i?86-*) AC_DEFINE(SCM_TARGET_I386,1,[Define if uses i386 optimizations]) ;; alpha*) @@ -326,7 +329,7 @@ AC_CHECK_LIB(sunmath, isinf) dnl For Windows/MinGW, manually adds several libraries -case "$target" in +case "$host" in *mingw*) LIBS="$LIBS -lnetapi32 -lshlwapi";; *) ;; esac @@ -343,7 +346,7 @@ dnl Check for select(). HP-UX doesn't like the way configure tests dnl select() existence, so we skip the test on it. -case "$target" in +case "$host" in *-hpux*) AC_DEFINE(HAVE_SELECT, 1, [Define if you have select]) ;; *) @@ -353,7 +356,7 @@ dnl Checks for pty-related fns. It appears that recent Cygwin has them, dnl but only in a static library. That prevents us from creating DLL dnl version of gauche. Thus we explictly exclude them on cygwin. -case "$target" in +case "$host" in *cygwin*) : ;; *) @@ -366,7 +369,7 @@ dnl Note: on cygwin, libcrypt is only available as a static library, dnl and prevents libgauche.dll from building. We explicitly excludes it. dnl -case "$target" in +case "$host" in *cygwin*) : ;; *) @@ -428,9 +431,9 @@ # We put additional information, such as whether we use Framework for # darwin, in this variable. -xtarget=$target +xhost=$host -case $target in +case $host in *freebsd2*) SHLIB_SO_CFLAGS="-fpic -fPIC" SHLIB_SO_LDFLAGS="-v;ld -Bshareable -o" @@ -456,7 +459,7 @@ # -no-cpp-precomp is not related to shared library, but needed to # get src/{vm.c,char.c} compiled -skimu # [Shiro] Darwin 1.3 and later needs different flags - case $target_os in + case $host_os in darwin1.[[012]]) FLAT_NAMESPACE="" ;; *) FLAT_NAMESPACE="-flat_namespace" ;; esac @@ -467,7 +470,7 @@ if test "$ac_gauche_framework" = yes; then SHLIB_DYLIB_LDFLAGS='-framework CoreFoundation -dynamiclib -o' AC_DEFINE(GAUCHE_MACOSX_FRAMEWORK, 1, [Define 1 if building framework on MacOSX]) - xtarget="${target}-framework" + xhost="${host}-framework" else SHLIB_DYLIB_LDFLAGS="-dynamiclib -o" fi @@ -574,7 +577,7 @@ MAKEVERSLINK=: fi -AC_SUBST(xtarget) +AC_SUBST(xhost) AC_SUBST(SHLIB_SO_CFLAGS) AC_SUBST(SHLIB_SO_LDFLAGS) AC_SUBST(SHLIB_SO_SUFFIX) @@ -670,6 +673,20 @@ m4_include([ext/net/net.ac]) dnl =========================================================== +dnl Cross compiling +if test ${cross_compiling} = no ; then + # self compile + CROSS_COMPILING_yes="#" + CROSS_COMPILING_no= +else + # cross compile + CROSS_COMPILING_yes= + CROSS_COMPILING_no="#" +fi +AC_SUBST(CROSS_COMPILING_yes) +AC_SUBST(CROSS_COMPILING_no) + +dnl =========================================================== dnl Configure gc and extensions AC_CONFIG_SUBDIRS(gc) diff -ruN -x configure -x config.scm Gauche-0.8.12/doc/Makefile.in Gauche-0.8.12-cross/doc/Makefile.in --- Gauche-0.8.12/doc/Makefile.in 2007-08-20 19:15:12.000000000 +0900 +++ Gauche-0.8.12-cross/doc/Makefile.in 2007-12-03 06:58:51.000000000 +0900 @@ -2,12 +2,15 @@ VPATH = $(srcdir) top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +build = @build@ +host = @host@ MANPAGES = gosh.1 gauche-config.1 EXTRACTED = gauche-refe.texi gauche-refj.texi \ gauche-deve.texi gauche-devj.texi GENERATED = Makefile $(MANPAGES) -GOSH = ../src/gosh -q -I../src -I../lib -lgauche-init +@CROSS_COMPILING_no@GOSH = ../src/gosh -q -I../src -I../lib -lgauche-init +@CROSS_COMPILING_yes@GOSH = gosh -q -lgauche-init INSTALL = @INSTALL@ MKINSTDIR = $(top_srcdir)/mkinstalldirs MAKEINFO = @MAKEINFO@ diff -ruN -x configure -x config.scm Gauche-0.8.12/ext/Makefile.ext.in Gauche-0.8.12-cross/ext/Makefile.ext.in --- Gauche-0.8.12/ext/Makefile.ext.in 2007-09-15 12:59:47.000000000 +0900 +++ Gauche-0.8.12-cross/ext/Makefile.ext.in 2007-12-03 06:53:07.000000000 +0900 @@ -11,6 +11,7 @@ datarootdir = @datarootdir@ VPATH = $(srcdir) GAUCHE_VERSION = @GAUCHE_VERSION@ +BUILD = @build@ HOST = @host@ # These may be overridden by make invocators @@ -36,8 +37,10 @@ LINK = $(CCLD) $(CFLAGS) $(LDFLAGS) MODLINK = $(CCLD) $(CFLAGS) $(LDFLAGS) -GOSH = $(top_builddir)/src/gosh -ftest -GAUCHE_CONFIG = $(top_builddir)/src/gauche-config +@CROSS_COMPILING_no@GOSH = $(top_builddir)/src/gosh -ftest +@CROSS_COMPILING_no@GAUCHE_CONFIG = $(top_builddir)/src/gauche-config +@CROSS_COMPILING_yes@GOSH = gosh +@CROSS_COMPILING_yes@GAUCHE_CONFIG = $(top_builddir)/src/$(HOST)-gauche-config GAUCHE_INSTALL = $(GOSH) $(top_srcdir)/src/gauche-install.in GENCOMP = $(GOSH) $(top_srcdir)/src/gencomp INSTALL_TYPE = sys diff -ruN -x configure -x config.scm Gauche-0.8.12/ext/mt-random/mt-random.c Gauche-0.8.12-cross/ext/mt-random/mt-random.c --- Gauche-0.8.12/ext/mt-random/mt-random.c 2007-09-15 12:59:49.000000000 +0900 +++ Gauche-0.8.12-cross/ext/mt-random/mt-random.c 2007-11-06 16:28:01.000000000 +0900 @@ -134,7 +134,7 @@ } /* generates a random number on [0,0xffffffff]-interval */ -inline unsigned long Scm_MTGenrandU32(ScmMersenneTwister *mt) +unsigned long Scm_MTGenrandU32(ScmMersenneTwister *mt) { unsigned long y; int mti = mt->mti; diff -ruN -x configure -x config.scm Gauche-0.8.12/ext/net/net.ac Gauche-0.8.12-cross/ext/net/net.ac --- Gauche-0.8.12/ext/net/net.ac 2007-10-02 18:07:01.000000000 +0900 +++ Gauche-0.8.12-cross/ext/net/net.ac 2007-11-03 17:12:28.000000000 +0900 @@ -219,7 +219,8 @@ dnl bother checking it. case "$target" in *mingw32*) - AC_DEFINE(socklen_t, int) +dnl mingw-gcc 4.2 knows socklen_t. +dnl AC_DEFINE(socklen_t, int) LIBS="$LIBS -lws2_32" ;; *) TYPE_SOCKLEN_T;; diff -ruN -x configure -x config.scm Gauche-0.8.12/lib/Makefile.in Gauche-0.8.12-cross/lib/Makefile.in --- Gauche-0.8.12/lib/Makefile.in 2007-08-21 18:03:14.000000000 +0900 +++ Gauche-0.8.12-cross/lib/Makefile.in 2007-11-01 16:50:53.000000000 +0900 @@ -17,6 +17,8 @@ top_srcdir = @top_srcdir@ datadir = @datadir@ datarootdir = @datarootdir@ +build = @build@ +host = @host@ GAUCHE_DATA_DIR = $(datadir)/gauche SCM_INSTALL_DIR = $(GAUCHE_DATA_DIR)/@GAUCHE_VERSION@/lib @@ -101,7 +103,7 @@ # For RPM, this has to be called in the postinstall script instead of # installation script. slibcat : - if test -f $(SLIB_DIR)/require.scm; then \ + if test -f $(SLIB_DIR)/require.scm && test $(build) = $(host) ; then \ $(exec_prefix)/bin/gosh -ftest -uslib -E"require 'new-catalog" -Eexit;\ fi diff -ruN -x configure -x config.scm Gauche-0.8.12/src/Makefile.in Gauche-0.8.12-cross/src/Makefile.in --- Gauche-0.8.12/src/Makefile.in 2007-09-11 06:18:38.000000000 +0900 +++ Gauche-0.8.12-cross/src/Makefile.in 2007-12-03 07:46:27.000000000 +0900 @@ -24,7 +24,7 @@ $(COMPILE) -c $< .stub.c: - $(HOSTGOSH) ./genstub -D LIBGAUCHE_BODY $< + $(BUILD_GOSH) ./genstub -D LIBGAUCHE_BODY $< SHELL = @SHELL@ prefix = @prefix@ @@ -38,6 +38,10 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +# for cross build +build = @build@ +host = @host@ + # These may be overridden by make invocators DESTDIR = CC = @CC@ @@ -74,14 +78,18 @@ GENCOMP = $(srcdir)/gencomp -D LIBGAUCHE_BODY -# HOSTGOSH is the gosh command used to generate some of the source files. +# for cross build +BUILD_CC = @BUILD_CC@ +BUILD_CFLAGS = -O2 + +# BUILD_GOSH is the gosh command used to generate some of the source files. # We need to 'preload' some libraries from the host's environment, for # they are compiled DSO as of 0.8.6 and the ones in the build tree can # be incompatible with the host gosh. -# (NB: HOSTGOSH is only invoked building from CVS; it won't be called +# (NB: BUILD_GOSH is only invoked building from CVS; it won't be called # when building from tarball.) # We clear GAUCHE_LOAD_PATH to make sure we won't read nonstandard stuff. -HOSTGOSH = GAUCHE_LOAD_PATH="" GAUCHE_DYNLOAD_PATH="" \ +BUILD_GOSH = GAUCHE_LOAD_PATH="" GAUCHE_DYNLOAD_PATH="" \ gosh -l./preload -I$(top_srcdir)/src -I$(top_srcdir)/lib LIB_INSTALL_DIR = @libdir@ @@ -93,10 +101,10 @@ HEADER_INSTALL_DIR = $(GAUCHE_ARCH_DIR)/@GAUCHE_VERSION@/include SCM_INSTALL_DIR = $(GAUCHE_DATA_DIR)/@GAUCHE_VERSION@/lib -ARCH_INSTALL_DIR = $(GAUCHE_ARCH_DIR)/@GAUCHE_VERSION@/@target@ +ARCH_INSTALL_DIR = $(GAUCHE_ARCH_DIR)/@GAUCHE_VERSION@/@host@ SITE_SCM_DIR = $(GAUCHE_DATA_DIR)/site/lib -SITE_ARCH_DIR = $(GAUCHE_ARCH_DIR)/site/@GAUCHE_VERSION@/@target@ -ARCH = @target@ +SITE_ARCH_DIR = $(GAUCHE_ARCH_DIR)/site/@GAUCHE_VERSION@/@host@ +ARCH = @host@ # targetlib is given when we relink the final version of gosh to embed # the path to libgauche. Usually it is LIB_INSTALL_DIR, but under @@ -169,7 +177,8 @@ OBJECTS = $(libgauche_OBJECTS) $(gosh_OBJECTS) -all : libgauche.$(SOEXT) $(INSTALL_BINS) $(GENERATED_SCRIPTS) +@CROSS_COMPILING_no@all : libgauche.$(SOEXT) $(INSTALL_BINS) $(GENERATED_SCRIPTS) +@CROSS_COMPILING_yes@all : libgauche.$(SOEXT) $(INSTALL_BINS) $(GENERATED_SCRIPTS) $(host)-gauche-config gosh$(EXEEXT) : libgauche.$(SOEXT) $(gosh_OBJECTS) @rm -f gosh$(EXEEXT) @@ -189,22 +198,22 @@ intlib.c : intlib.stub genstub autoloads.c : autoloads.scm - $(HOSTGOSH) ./autoloads.scm + $(BUILD_GOSH) ./autoloads.scm builtin-syms.c gauche/builtin-syms.h : builtin-syms.scm - $(HOSTGOSH) ./builtin-syms.scm + $(BUILD_GOSH) ./builtin-syms.scm vminsn.c gauche/vminsn.h ../lib/gauche/vm/insn.scm : vminsn.scm geninsn - $(HOSTGOSH) ./geninsn + $(BUILD_GOSH) ./geninsn compile.c : compile.scm gencomp vminsn.scm - $(HOSTGOSH) $(GENCOMP) compile.scm + $(BUILD_GOSH) $(GENCOMP) compile.scm scmlib.c : scmlib.scm gencomp vminsn.scm - $(HOSTGOSH) $(GENCOMP) scmlib.scm + $(BUILD_GOSH) $(GENCOMP) scmlib.scm objlib.c : objlib.scm gencomp vminsn.scm - $(HOSTGOSH) $(GENCOMP) objlib.scm + $(BUILD_GOSH) $(GENCOMP) objlib.scm symbol.$(OBJEXT) : builtin-syms.c @@ -223,6 +232,10 @@ gauche-config$(EXEEXT) : gauche-config.$(OBJEXT) $(LINK) -o gauche-config$(EXEEXT) gauche-config.$(OBJEXT) $(LIBS) +# for cross build +$(host)-gauche-config: gauche-config.c + $(BUILD_CC) $(BUILD_CFLAGS) $(DEFS) -o $@ gauche-config.c + gauche-config.c gauche/arch.h ../lib/gauche/config.scm : genconfig $(SHELL) ./genconfig @@ -246,9 +259,9 @@ # a special build sequence when VM instruction set has been changed newinsn : - $(HOSTGOSH) -fno-inline-globals $(GENCOMP) compile.scm - $(HOSTGOSH) -fno-inline-globals $(GENCOMP) scmlib.scm - $(HOSTGOSH) -fno-inline-globals $(GENCOMP) objlib.scm + $(BUILD_GOSH) -fno-inline-globals $(GENCOMP) compile.scm + $(BUILD_GOSH) -fno-inline-globals $(GENCOMP) scmlib.scm + $(BUILD_GOSH) -fno-inline-globals $(GENCOMP) objlib.scm $(MAKE) all ./gosh -ftest $(GENCOMP) compile.scm ./gosh -ftest $(GENCOMP) scmlib.scm @@ -302,7 +315,10 @@ test-vmstack$(EXEEXT) test-arith$(EXEEXT) \ $(GENERATED_SCRIPTS) gauche-config.c \ libgauche.$(SOEXT)* *.$(OBJEXT) *~ *.a *.t *.def *.exp *.exe \ - test.log test.dir so_locations gauche/*~ gauche/arch.h + test.log test.dir so_locations gauche/*~ gauche/arch.h \ + gauche-config.in.c \ + gauche-install.in.c gauche-package.in.c gauche-cesconv.in.c \ + $(host)-gauche-config.c $(host)-gauche-config distclean : clean rm -f $(CONFIG_GENERATED) @@ -319,6 +335,8 @@ $(DESTDIR)$(BIN_INSTALL_DIR) \ $(DESTDIR)$(SITE_SCM_DIR) \ $(DESTDIR)$(SITE_ARCH_DIR) +@CROSS_COMPILING_no@GAUCHE_CONFIG = ./gauche-config +@CROSS_COMPILING_yes@GAUCHE_CONFIG = ./$(host)-gauche-config install : all relink $(MKINSTDIR) $(INSTALL_DIRS) @@ -329,7 +347,7 @@ $(INSTALL) -m 555 $(INSTALL_BINS) $(DESTDIR)$(BIN_INSTALL_DIR) $(INSTALL) -m 555 $(INSTALL_BINS) $(DESTDIR)$(ARCH_INSTALL_DIR) $(INSTALL) -m 444 $(INSTALL_SCMS) $(DESTDIR)$(SCM_INSTALL_DIR) - @case `./gauche-config --arch` in *-cygwin*|*-mingw*) \ + @case `$(GAUCHE_CONFIG) --arch` in *-cygwin*|*-mingw*) \ $(INSTALL) $(INSTALL_LIBS) $(DESTDIR)$(BIN_INSTALL_DIR);;\ esac $(POSTINSTALL) diff -ruN -x configure -x config.scm Gauche-0.8.12/src/bignum.c Gauche-0.8.12-cross/src/bignum.c --- Gauche-0.8.12/src/bignum.c 2007-09-09 04:52:36.000000000 +0900 +++ Gauche-0.8.12-cross/src/bignum.c 2007-11-06 16:00:29.000000000 +0900 @@ -71,6 +71,10 @@ # if HAVE_ALLOCA_H # include <alloca.h> # endif +# if HAVE_MALLOC_H +/* MinGW helds alloca() in "malloc.h" instead of "alloca.h" */ +# include <malloc.h> +# endif #endif #include <stdlib.h> diff -ruN -x configure -x config.scm Gauche-0.8.12/src/class.c Gauche-0.8.12-cross/src/class.c --- Gauche-0.8.12/src/class.c 2007-09-18 17:48:36.000000000 +0900 +++ Gauche-0.8.12-cross/src/class.c 2007-11-06 16:16:56.000000000 +0900 @@ -1269,7 +1269,7 @@ * (cond ((assq slot (ref class 'accessors)) => cdr) * (else (error !!!)))) */ -inline ScmSlotAccessor *Scm_GetSlotAccessor(ScmClass *klass, ScmObj slot) +static inline ScmSlotAccessor *Scm_GetSlotAccessor(ScmClass *klass, ScmObj slot) { ScmObj p = Scm_Assq(slot, klass->accessors); if (!SCM_PAIRP(p)) return NULL; diff -ruN -x configure -x config.scm Gauche-0.8.12/src/dl_win.c Gauche-0.8.12-cross/src/dl_win.c --- Gauche-0.8.12/src/dl_win.c 2007-08-25 08:55:45.000000000 +0900 +++ Gauche-0.8.12-cross/src/dl_win.c 2007-11-06 16:35:46.000000000 +0900 @@ -52,7 +52,7 @@ { char buf[80], *p; DWORD code = GetLastError(); - sprintf(buf, "error code %d", code); + snprintf(buf, sizeof(buf), "error code %ld", code); p = SCM_NEW_ATOMIC2(char *, strlen(buf)+1); strcpy(p, buf); return p; diff -ruN -x configure -x config.scm Gauche-0.8.12/src/gauche/config.h.in Gauche-0.8.12-cross/src/gauche/config.h.in --- Gauche-0.8.12/src/gauche/config.h.in 2007-08-10 15:37:10.000000000 +0900 +++ Gauche-0.8.12-cross/src/gauche/config.h.in 2007-11-06 16:06:10.000000000 +0900 @@ -167,6 +167,9 @@ /* Define to 1 if you have the <rpc/types.h> header file. */ #undef HAVE_RPC_TYPES_H +/* Define to 1 if you have the <malloc.h> header file. */ +#undef HAVE_MALLOC_H + /* Define to 1 if you have the <sched.h> header file. */ #undef HAVE_SCHED_H diff -ruN -x configure -x config.scm Gauche-0.8.12/src/genconfig.in Gauche-0.8.12-cross/src/genconfig.in --- Gauche-0.8.12/src/genconfig.in 2007-08-25 12:04:48.000000000 +0900 +++ Gauche-0.8.12-cross/src/genconfig.in 2007-11-06 15:14:04.000000000 +0900 @@ -10,11 +10,11 @@ # (cmds[]) and config.scm part (*configurations*). They should be # generated from a single source. -target=@target@ -xtarget=@xtarget@ +host=@host@ +xhost=@xhost@ gauche_version=@GAUCHE_VERSION@ -case "$xtarget" in +case "$xhost" in *mingw*|*winnt*) # On Windows we can't rely on the paths set by configure. # We find the location of the binary and calculate the prefix path @@ -50,17 +50,17 @@ gauche_incdir=`echo "$garchdir/$gauche_version/include" | $pathfix` gauche_libdir=`echo "$gdatadir/$gauche_version/lib" | $pathfix` gauche_aclocaldir=`echo "$gdatadir/$gauche_version/" | $pathfix` -gauche_archdir=`echo "$garchdir/$gauche_version/$target" | $pathfix` +gauche_archdir=`echo "$garchdir/$gauche_version/$host" | $pathfix` gauche_siteincdir=`echo "$garchdir/site/include" | $pathfix` gauche_sitelibdir=`echo "$gdatadir/site/lib" | $pathfix` -gauche_sitearchdir=`echo "$garchdir/site/$gauche_version/$target" | $pathfix` +gauche_sitearchdir=`echo "$garchdir/site/$gauche_version/$host" | $pathfix` gauche_pkgincdir=`echo '${libdir}'"/gauche/site/include" | $pathfix` gauche_pkglibdir=`echo '${datadir}'"/gauche/site/lib" | $pathfix` -gauche_pkgarchdir=`echo '${libdir}'"/gauche/site/$gauche_version/$target" | $pathfix` +gauche_pkgarchdir=`echo '${libdir}'"/gauche/site/$gauche_version/$host" | $pathfix` gauche_libs="@LIBS@" gauche_configure_args="@GAUCHE_CONFIGURE_ARGS@" -arch="$target" +arch="$host" local_incdir="@LOCAL_INC@" local_libdir="@LOCAL_LIB@" diff -ruN -x configure -x config.scm Gauche-0.8.12/src/number.c Gauche-0.8.12-cross/src/number.c --- Gauche-0.8.12/src/number.c 2007-10-02 18:56:30.000000000 +0900 +++ Gauche-0.8.12-cross/src/number.c 2007-11-26 05:38:53.000000000 +0900 @@ -2343,7 +2343,7 @@ if (s0 > s1) return 1; d = Scm_NumCmp(d0, d1); if (d == 0) return Scm_NumCmp(n0, n1); - if (s0 > 0 && s1 > 0 || s0 < 0 && s1 < 0) { + if ((s0 > 0 && s1 > 0) || (s0 < 0 && s1 < 0)) { n = Scm_NumCmp(n0, n1) * s0; if (d > 0 && n <= 0) return -s0; if (d < 0 && n >= 0) return s0; diff -ruN -x configure -x config.scm Gauche-0.8.12/src/string.c Gauche-0.8.12-cross/src/string.c --- Gauche-0.8.12/src/string.c 2007-08-29 18:38:54.000000000 +0900 +++ Gauche-0.8.12-cross/src/string.c 2007-11-06 16:45:46.000000000 +0900 @@ -1385,7 +1385,7 @@ dstr->length = 0; } -inline int Scm_DStringSize(ScmDString *dstr) +int Scm_DStringSize(ScmDString *dstr) { ScmDStringChain *chain; int size; diff -ruN -x configure -x config.scm Gauche-0.8.12/src/system.c Gauche-0.8.12-cross/src/system.c --- Gauche-0.8.12/src/system.c 2007-10-30 07:30:38.000000000 +0900 +++ Gauche-0.8.12-cross/src/system.c 2007-11-06 15:34:46.000000000 +0900 @@ -44,6 +44,7 @@ #include <string.h> #include <sys/types.h> #include <sys/stat.h> +#include <ctype.h> #include <fcntl.h> #include <math.h> #if !defined(_MSC_VER) @@ -57,6 +58,8 @@ #include <lm.h> #include <tlhelp32.h> static HANDLE *win_prepare_handles(int *fds); +static int win_wait_for_handles(HANDLE *handles, int nhandles, int options, + int *status /*out*/); #endif /* GAUCHE_WINDOWS */ #ifdef HAVE_GLOB_H @@ -622,7 +625,7 @@ flags = O_CREAT|O_EXCL|O_WRONLY; #endif /* !GAUCHE_WINDOWS */ for (numtry=0; numtry<MKSTEMP_MAX_TRIALS; numtry++) { - snprintf(suffix, 7, "%06x", seed&0xffffff); + snprintf(suffix, 7, "%06lx", seed&0xffffff); memcpy(templat+siz-6, suffix, 7); SCM_SYSCALL(fd, open(templat, flags, 0600)); if (fd >= 0) break; @@ -1688,8 +1691,6 @@ process is integer and > 0 -> wait for specific pid process is #<win:process-handle> -> wait for specified process The common op is factored out in win_wait_for_handles. */ - static int win_wait_for_handles(HANDLE *handles, int nhandles, int options, - int *status /*out*/); int r, status = 0; if (SCM_INTEGERP(process)) {
議論、コメント
Shiro(2007/11/25 14:43:19 PST): GNU makeには既に依存してるところがあったような
気もするので、この際要求してしまっても良いかと思います。
mt-random.cのScm_MTGenrandU32でinlineが削ってあるのはもしかして
inlineしたやつをextern宣言できないとかいうケースがあるんでしょうか?
まあ今見てみるとここはinlineにするほどのこともなさそうな感じなので
削ってもいいと思うんですが、一応確認。
- yokota(2007/11/25 14:59:39 PST): はい。gcc4ではinlineはC99規格に従ったものになり、基本的に"static inline"以外で使うと警告がでます。"-fgnu89-inline"または"-std=gnu89"オプションを用いるか__attribute__((gnu_inline))を用いて下さい。また、新しいautoconfで作成したconfigureは可能な限り新しい規格を使おうとするので特に指定の無い限りC99規格を使用します。
警告を防ぐには上記の他にinlineを取り除くか関数そのものをヘッダファイルに収めて関数型マクロと同じように扱うかする方法もあります。
この前の週末CVS HEADをbuildしましたがノーマルなmakeで通りましたよ。on NetBSDです。cut-sea:2007/11/25 19:13:01 PST
- Shiro(2007/11/25 21:05:02 PST): NetBSDのmakeもなんとなく拡張されてるとかいうことはありませんか。確か昔SolarisかHP-UX付属のmakeで通らなかった覚えが。 でもBSDerのことを考えると少なくともgmakeとBSDの標準makeで通るようにしといた方が良さげですね。
- yokota(2007/11/25 22:01:03 PST): BSD make はSysV互換という事で include 構文に関してのみ GNU make の形式をサポートしています。BSD make では通常は .include 構文を用います。
- yokota(2007/12/04 15:16:25 PST): BSD make でも動作するようにパッチを書きなおしました。configure.ac と各種 Makefile.in に変更を加えました。GNU makeとBSD makeは便利な拡張文法の仕様が違うので両方で動作するように変更すると便利な機能が使えなくなります。そのため configure スクリプトの動作を用いて自力で条件判断を行なっていますが、あまりやり過ぎると Makefile が読みづらくなるので、ある程度までにしておいた方が良いかと思います。
Shiro(2008/02/03 05:11:06 PST): ども。ほぼそのまま取り込ませていだたきました。 CROSS_COMPILING_yes/CROSS_COMPILING_no のところはもう一工夫したいですが、 とりあえず0.8.13に向けてテストしている時間がないので、リリース後に見直そうと 思います。
(あと、大きなパッチは検証が億劫になってしまうので、修正する機能ごとに パッチをわけていただけると助かります)
- yokota (2008/02/03 07:14:47 PST): ありがとうございます。パッチがまとまってしまっているのは使用している環境等の違いなどの理由でコンパイルが出来ない部分をあちこち修正しながら完成させたからです。今後はもう少し考えます。 CROSS_COMPILING の部分の処理の仕方は automake を参考にしています。 次は外部モジュールの構築をクロスコンパイル対応にしたいですね。
- yokota (2008/02/03 11:58:48 PST): 現在のCVS HEADには新規ファイル acinclude.m4 が不足しています。上のパッチから追加しておいて下さい。
- Shiro(2008/02/03 15:13:25 PST): あっいけね。作業中は「追加しなきゃ」と思ってたのに commitする頃は眠くて忘れてました。今追加しました。