After much confusion and many false starts, I've finally managed to
construct a set of cross-compiler tools for compiling Cygwin programs
on a Linux system, and I've also made some changes to Octave's
configure script and Makefiles so that cross compiling will work.
Details can be found in the script below, which I've used to build the
cross tools. At the end, it prints out a message explaining what else
needs to be done by hand to complete the cross build of Octave.
I'm posting the script here in case anyone else wants to give this a
try. I downloaded the CVS version of Cygwin after failing to get the
results I wanted with several other combinations of compilers and
Once I had the working cross compiler, I tried to use it to build
ncurses and readline libraries, but gave up after I failed to build
ncurses. Simply copying these libraries from a working Cygwin sytem
seemed to be a much easier solution.
With these tools on my 1.4GHz Athlon system it takes about 25 minutes
to do a complete build vs. about 45 minutes to do the same build using
Windows+Cygwin running under vmware on the same hardware. With gcc
2.95 on the Linux system doing a native build, it only takes about 12
minutes. For comparison, I just tried a native Linux build with
gcc-3.2, and it takes about 20 minutes, so it seems that gcc-3.2 is
considerably slower than gcc-2.95, and even slower when it is doing a
cross compile. Hmm.
## Get a copy of the following sources before starting:
$topdir/$binutils_src/configure --target=$target --prefix=$prefix
make all install
## Fix PATH:
## Copy include files from newlib and winsup to cross dir:
for d in newlib/libc winsup/cygwin ; do
for f in `find include -name '*.h'` ; do
if [ ! -d $dest ]; then mkdir $dest ; fi
if [ -f $inctop/$f ]; then echo $f ; else cp $f $dest ; fi
## Patch $prefix/$target/include/sys/errno.h. The modified version of
## the errno file will be overwritten after building.
This should detect $target-gcc, $target-g++, etc. as cross-compiler
tools if you still have $prefix/bin in your path.
Octave's build process also compiles and runs a few C/C++ programs on
the build system that are used for constructing documentation files.
Since these programs must run on the build system, they can't be
compiled by the cross compiler. The rules to compile them use
$(BUILD_CC) and $(BUILD_CXX) instead of $(CC) and $(CXX). By default,
configure will set BUILD_CC=gcc and BUILD_CXX=g++, so it should work
without having to set those variables by hand if gcc and g++ are
available on the build system to compile programs that are needed
during the build process (but not to run on the host system).