328267.notvwxz6.asia/howto/cygwin/cygwin-cross-howto.html   search  
Building cross compilers for Cygwin

Home Page: http://www.xraylith.wisc.edu/~khan/software/gnu-win32/
Author: Mumit Khan
Created: Fri Feb 19 11:56:42 1999

This howto provides step-by-step instructions on building Unix hosted cross compilers for i585-cygwin32 (Cygwin) target. The instructions shown here have been tested on a i686-pc-linux-gnu host, but should work on any host that is well supported by GNU binutils and EGCS compiler.


TOC:
  - Building CROSS Cygwin B20+ tools
  - Building CROSS egcs-1.1.1 for Cygwin b20+
  - Building NATIVE B20+ tools using CROSS tools just built.
  - Building NATIVE egcs-1.1.1 tools using CROSS tools just built.

Last Modified: Wed Feb 17 21:56:13 CST 1999

============ Building CROSS Cygwin B20+ tools

Step 1: build the entire b20.1 cross-toolchain before you start with
  egcs-1.1.1

1. Download the b20.1 source tree:

  ftp://sourceware.cygnus.com/pub/cygwin/latest/dev-src.tar.bz2

2. unpack, configure and build:

  $ mkdir /usr/local/src/cygwin-b20
  $ cd /usr/local/src/cygwin-b20
  $ bunzip2 -c /tmp/dev-src.tar.bz2 | tar -xf -
  [ this will unpack everything under src subdirectory ]
  $ mkdir CROSS
  $ cd CROSS
  $ ../src/configure --prefix=/usr/local/cygb20 --target=i586-cygwin32 -v
  $ make > make.log 2>&1
  [ the '2>&1' depends on your shell of course. check for errors . If OK ]
  $ make install > install.log 2>&1

============ Building CROSS egcs-1.1.1 for Cygwin b20+

1. Download sources and patches:

 ftp://egcs.cygnus.com/pub/egcs/releases/egcs-1.1.1/egcs-1.1.1.tar.bz2
 ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/cygwin/egcs-1.1.1/patches/
    Get the egcs-1.1.1-x86-win32-patches.tar.gz

2. Unpack, patch, prep:

  $ cd /usr/local/src
  $ bunzip2 -c /tmp/egcs-1.1.1.tar.bz2 | tar -xf -

  Now patch time. If you look inside egcs-1.1.1-x86-win32-patches.tar.gz,
  you'll see the actual patch file -- egcs-1.1.1-x86-win32.diff. This
  is the file you need.

  $ tar zxvf egcs-1.1.1-x86-win32-patches.tar.gz egcs-1.1.1-x86-win32.diff
  $ mv egcs-1.1.1-x86-win32.diff /tmp

  $ cd egcs-1.1.1
  $ patch -p1 -s < /tmp/egcs-1.1.1-x86-win32.diff

3. Now build and install.

  $ mkdir CROSS
  $ cd CROSS
  $ ../configure --prefix=/usr/local/cygb20 --target=i586-cygwin32 -v
  $ cd gcc; make installdirs; cd ..
  [ this step is important, otherwise libobjc, libstdc++ etc will fail ]
  $ make > make.log 2>&1
  [ the '2>&1' depends on your shell of course. check for errors . If OK ]
  $ make install > install.log 2>&1

After you're done, add it to path (if you're using a bourne-shell
compatible, otherwise use csh syntax).

  $ export PATH=$PATH:/usr/local/cygb20/bin
  $ i586-cygwin32-gcc -v
  [ should report egcs-1.1.1 etc ]

All the binaries for i586-cygwin32 target are prefixed with i586-cygwin32-
prefix.

============ Building NATIVE B20+ tools using CROSS tools just built.

Now if you want to build native tools on eg., a i686-pc-linux-gnu box with
the same pathnames that Cygnus uses:

  $ cd /usr/local/src/cygwin-b20
  $ mkdir NATIVE
  $ cd NATIVE
  $ ../src/configure --prefix=/Cygnus/cygwin-b20 \
    --exec-prefix=/Cygnus/cygwin-b20/H-i586-cygwin32 \
    --target=i586-cygwin32 --host=i586-cygwin32 \
    --build=i686-pc-linux-gnu -v
  $ make > make.log 2>&1
  [ check for errors . If OK ]

============ Building NATIVE egcs-1.1.1 tools using CROSS tools just built.

Now if you want to build native tools on eg., a i686-pc-linux-gnu box with
the same pathnames that Cygnus uses:

  $ cd /usr/local/src/egcs-1.1.1
  $ mkdir NATIVE
  $ cd NATIVE
  $ ../configure --prefix=/Cygnus/cygwin-b20 \
    --exec-prefix=/Cygnus/cygwin-b20/H-i586-cygwin32 \
    --target=i586-cygwin32 --host=i586-cygwin32 \
    --build=i686-pc-linux-gnu -v
  $ make > make.log 2>&1
  [ check for errors . If OK ]

Now of course, you may want to install it to a *DIFFERENT* location
than /Cygnus/cygwin-b20 on your Unix host before creating an archive
to copy to a Cygwin box. Let's say you first install it to /tmp/cygwin.

  $ make prefix=/tmp/cygwin exec_prefix=/tmp/cygwin/H-i586-cygwin32 \
    install > install.log 2>&1
  $ cd /tmp/cygwin
  $ tar zcvf /tmp/dev-cygwin-b20.tar.gz .

Copy /tmp/dev-cygwin-b20.tar.gz to your Cygwin box and unpack:

  [win32]$ cd /Cygnus/cygwin-b20
  [win32]$ tar zxvf /tmp/dev-cygwin-b20.tar.gz

The patches you added to egcs-1.1.1 also makes these binaries work no
matter where you install them (provided your Cygnus installation is
in /Cygnus/cygwin-b20):

  [win32]$ mkdir /usr/local/egcs-1.1.1
  [win32]$ cd /usr/local/egcs-1.1.1
  [win32]$ tar zxvf /tmp/dev-cygwin-b20.tar.gz

===== THE END

For more information about Cygwin, see Cygnus's cygwin project page:
  http://sourceware.cygnus.com/cygwin/

Latest version of this documentation, and other information related to
GNU tools on various types of windows32 system, is available from my
gnu-win32 page:
  http://www.xraylith.wisc.edu/~khan/software/gnu-win32/

Last Modified: Wed Feb 17 21:56:13 CST 1999
Mumit Khan <[email protected]>


  webmaster     delorie software   privacy  
  Copyright © 1999     Updated Feb 1999