
                                                      Mon Aug 19 16:55:22 1996


                      Building a djgpp crosscompiler
                      ==============================

0. Introduction to cross-compilers
----------------------------------
This document describes how to build a cross compiler, hosted by a unix
system, and targeting djgpp v2.

The "host" system is the (unix) system that runs the compiler tools.
The "target" system is the (msdos) system that runs the programs you create.

The usual way to configure binutils as cross tools is:
       $ configure --host=<your host> --target=<your target>

For a complete, functional crosscompiler toolchain, you need:

	binutils (assembler, linker and friends).
	a C cross-compiler.
	a C library for your target system.

A linux-hosted, djgpp-targeting gcc-2.7.2 is available as:

	ftp://sunsite.unc.ed/pub/linux/devel/msdos/gcc-2.7.2.go32.tar.gz

The C library is:

	ftp://sunsite.unc.ed/pub/linux/devel/msdos/djdev200.go32.tar.gz

1. Other documentation
----------------------
General documentation about GNU tools in a cross-configuration is available
from: ftp://ftp.cygnus.com/pub/embedded/crossgcc/

The djgpp FAQ (v2.01) has a section about crosscompilers, but they confuse
crosscompilers running on msdos, targeting something else with a
crosscompiler running on something, targeting msdos.

FYI: djcrx200.zip is a set of cross-tools hosted by msdos, targeting some
embedded system. This is not what YOU want, no matter what the FAQ says!


2. History of djgpp
-------------------
Different versions of djgpp have different object formats, so they require
seperate 'configure' targets. The current, v2 release produces executables
that have the dos-extender built into the C-library while older versions
needed a seperate GO32.EXE as the dos-extender.

This table shows the meaning of some of the targets of binutils:

 configure       djgpp     need     obj.      bfd       ld output
   target         rev.     GO32    format    vector      format
-----------------------------------------------------------------------
i386-msdos     <= 1.10     yes     a.out    i386-aout    msdos

i386-go32     1.11, 1.12   yes     coff     i386-coff    coff-i386

    -             2.x      no      coff     go32-coff    coff-go32

As you can see, it is not possible to configure a djgpp-V2 targeting
cross-compiler "out of the box", using the binutils-2.7 unix configure script.
The MS-DOS configure.bat from the same binutils however, does target djgpp
v2.x

This is where the patch "binutils-2.7.go32.diff.gz" comes in: it changes the
meaning of the i386-go32 target from djgpp v1.11 to v2.x for the unix
configure script.


3. Building the cross-binutils
------------------------------
Unpack the source archive (available from your favorite GNU mirror) and
apply the patch:

	$ tar -xzf binutils-2.7.tar.gz
	$ patch -s -p0 < binutils-2.7.go32.diff

Configure the source tree:

	$ configure --host=i486-linux --target=i386-go32 --enable-shared \
		--prefix=/usr

(The "\" indicates a linebreak, you don't have to type that)
And build it:

	$ make CFLAGS=-O2 LDFLAGS=-s

If all goes well, install it:

	$ make install

4. Final check
--------------
To verify that you just built a v2 compatible toolchain, do:

	$ i386-go32-ar

It should respond:
	i386-go32-ar: supported targets: coff-go32 a.out-i386 srec symbolsrec
	tekhex binary ihex

If it says "coff-i386" you probably did not apply the patch.
Likewise:

	$ ld --help

should output:

	i386-go32-ld: supported targets: coff-go32 a.out-i386 srec
	symbolsrec tekhex binary ihex
	i386-go32-ld: supported emulations: go32 i386aout

"coff-i386" means you're in trouble.

Enjoy your new cross-tools!

JanJaap van der Heijden  <j.j.vanderheijden@student.utwente.nl>
 