Subject: Re: gcc and cross-compilers
From: [email-masked] (Mumit Khan)

25 Apr 1998 21:03:21 -0700
Message-ID: <[email-masked]>
References: <[email-masked]>
To: [email-masked]
Cc: [email-masked]

[email-masked] writes:
> 
> Can anyone point me towards some info on compiling gcc (under linux) as a
> cross-compiler with support for both linux and the cygwin-style binaries?
> 

Here's what I do:

Preliminaries:
=======================================================================

Step 1: Choose an installation prefix. I usually use the following
  directory instead of dumping in /usr/local since I do multiple versions
  of both the compiler and cygwin32 which may/do conflict. Let's say you 
  choose the following:
      
      prefix = /usr/local/cygwin32/b19

Step 2: Get the includes and libraries from CDK and stuff it into the
  installation tree.

      % mkdir $prefix
      % mkdir $prefix/i386-cygwin32/include
      % mkdir $prefix/i386-cygwin32/lib
  
  Copy the /Cygnus/B19/H-i386-cygwin32/i386-cygwin32/include hierarchy to
  to $prefix/i386-cygwin32/include and 
  /Cygnus/B19/H-i386-cygwin32/i386-cygwin32/lib hierarchy to
  $prefix/i386-cygwin32/lib.

  These are supplied with the CDK (b18, b19 or whatever you have), so you
  do need that. Can be done from scratch (which is what I do) of course,
  but I'll assume you're just interested in building the development
  tools, and not the whole shabang.

Build Binutils (gas, ld, etc):
=======================================================================

Step 1: Get binutils-2.9 source from one of the GNU sites.

Step 2: Configure, build and install:

      % cd /usr/local/src
      % gunzip -c /tmp/binutils-2.9.tar.gz | tar xvf -
      % cd binutils-2.9
      % mkdir binutils-2.9/XCYGWIN32
      % cd binutils-2.9/XCYGWIN32
      % ../configure --prefix=$prefix --target=i386-cygwin32 -v
      % make
      % make install

Build the compiler (this is for egcs, gcc is similar but needs a bit more
work since it doesn't come with the C++ libraries, g77 etc):
=======================================================================

Step 1: Get the egcs-1.0.2 or whatever release source code from 
  ftp://egcs.cygnus.com/pub/

Step 2: Configure, build and install:
   
   % cd /usr/local/src
   % gunzip -c /tmp/egcs-1.0.2.tar.gz | tar xvf -
   % cd egcs-1.0.2
   % mkdir XCYGWIN32
   % cd XCYGWIN32
   % ../configure --prefix=$prefix --target=i386-cygwin32 -v
   % make
   % make install 

Note 1:
  g77 build: Depending on how your local setup is, you might need to 
  modify gcc/g77/Makefile to modify HOST_CC to use gcc instead of 
  `$(CC) -b $(host)'

Note 2: 
  If you're building the snapshots, you might need to create objc runtime
  info header by hand or just create an empty one.

Now you can run the compilers (after adding $prefix/bin to path) using
i386-cygwin32-gcc etc.

=========================================================================

Hopefully I haven't missed any crucial step here. I would very much
appreciate if you would post whatever changes you actually needed to
get things done, and I'll put it up on my web page.

Regards,
Mumit

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".