
    Setting up a ppc-morphos cross compiler under AmigaOS
    -----------------------------------------------------


1) If you don't have a GeekGadget environment:

Make a GeekGadget directory somewhere, and assign GG: to it.

   1> makedir some_volume:GeekGadgets
   1> assign GG: some_volume:GeekGadgets

Make a GG:bin directory, and add it to your path, or add it to
your c: assign.

   1> makedir GG:bin
   1> path GG:bin add


2) Unarchive the ppc-morphos-binutils-2.9.1-bin.tgz and
   ppc-morphos-gcc-2.95.3-bin.tgz in GG:

   1> cd GG:
   1> tar xzf  some_dir/ppc-morphos-binutils-2.9.1-bin.tgz
   1> tar xzf  some_dir/ppc-morphos-gcc-2.95.3-bin.tgz

 Warning 1:
 ----------
If you are unarchiving on a filesystem that doesn't support
hard-links (e.g. SFS), you will have error messages and will
need to make the links by hand (or replace them with copies).
You need to have:
  gg:ppc-morphos/bin/as     ->  gg:bin/ppc-morphos-as
  gg:ppc-morphos/bin/ar     ->  gg:bin/ppc-morphos-ar
  gg:ppc-morphos/bin/ld     ->  gg:bin/ppc-morphos-ld
  gg:ppc-morphos/bin/nm     ->  gg:bin/ppc-morphos-nm
  gg:ppc-morphos/bin/ranlib ->  gg:bin/ppc-morphos-ranlib
  gg:ppc-morphos/bin/strip  ->  gg:bin/ppc-morphos-strip
  gg:lib/gcc-lib/ppc-morphos/2.95.3/libstdc++.a
             ->  gg:ppc-morphos/lib/libstdc++.a.2.10.0
  gg:lib/gcc-lib/ppc-morphos/2.95.3/libb32/libstdc++.a
             ->  gg:ppc-morphos/lib/libb32/libstdc++.a.2.10.0
where "->" means "link to" or "copy of".

 Warning 2:
 ----------
If using soft links, you have to specify the full path of the
destination, not just a relative one.

 Warning 3:
 ----------
If using soft links under SFS, you need at least SFS version 1.62.


3) Copy the contents of the emulinclude/includegcc directory
to GG:ppc-morphos/sys-include

    1> copy somepath/emulinclude/includegcc GG:ppc-morphos/sys-include all


4) Copy the lib directory from the developer morphos archive to
GG:ppc-morphos/lib and GG:ppc-morphos/lib/libnix

    1> copy somepath/lib/libamiga.a GG:ppc-morphos/lib
    1> copy somepath/lib/libamigastubs.a GG:ppc-morphos/lib
    1> copy somepath/lib/libsyscall.a GG:ppc-morphos/lib
    1> copy somepath/lib/libstring.a GG:ppc-morphos/lib
    1> copy somepath/lib/libstringio.a GG:ppc-morphos/lib

    1> copy somepath/lib/startup.o GG:ppc-morphos/lib/libnix
    1> copy somepath/lib/__nocommandline.o GG:ppc-morphos/lib/libnix
    1> copy somepath/lib/libc.a GG:ppc-morphos/lib/libnix


5) Get the ixemul-dev.tgz archive from the native MorphOS tools,
and copy its include directory to GG:ppc-morphos/include and
its lib directory to GG:ppc-morphos/lib.

    1> copy somepath/include GG:ppc-morphos/include all
    1> copy somepath/lib GG:ppc-morphos/lib all



    Usage
    -----

To compile 'hello.c' to 'hello' using ixemul:

   1> ppc-morphos-gcc -o hello hello.c

To compile 'hello.c' to 'hello' using libnix:

   1> ppc-morphos-gcc -noixemul -o hello hello.c

To strip debugging informations and symbols from an executable file:

   1> ppc-morphos-strip hello

To compile and link separately:

   1> ppc-morphos-gcc -c hello1.c
   1> ppc-morphos-gcc -c hello2.c
   1> ppc-morphos-gcc -o hello hello1.o hello2.o

(the last step can be replaced by a direct call to ppc-morphos-ld,
but unlike with ppc-amigaos-ld, do *not* use the -r option with it,
unless you really want pre-linkage.)


* Some useful options:

   -O, -O2, -O3 to optimize (-O3 make files bigger, be careful)

   -mcpu=604e, -mcpu=603e to optimize for a cpu. Files optimized
for one processor still work on others.

   -mmultiple allows using ppc's 'lmw' and 'stmw' instructions,
which make the executable smaller.

   -mbaserel32 to use r13-relative data addressing (ixemul only)

   -mresident32 to build 'pure' executables (ixemul only).

   -mstackcheck to add stack checking (ixemul only).

   -mstackextend to add automatic stack extension (ixemul only).

   -v to view the exact commands executed by gcc, and its include
search path. Useful to find out installation problems.


* Predefined symbols:

__PPC__, __powerpc__, __MORPHOS__

__603e__ if compiled with -mcpu=603e
__604e__ if compiled with -mcpu=604e

__amigaos__, amigaos, amiga, AMIGA, MCH_AMIGA for compatibility


* Some remarks:

1) This compiler uses the natural ppc alignment, i.e. in
   struct S
   {
     short a;
     long b;
   };

the offset of 'b' is 4, and not 2 as with 68k compilers. You can
force the alignment to be 2 by defining S as follow:

  struct S
  {
    short a;
    long b __attribute__((aligned(2)));
  } __attribute__((packed));

or even better by:

  #pragma pack(2)
   struct S
   {
     short a;
     long b;
   };
  #pragma pack()
 
Usually you shouldn't care about that, except in interfaces with
external libraries, or for binary compatibility if you read/write
such structures from/to files.

Attn: floats and doubles must _never_ have an alignment lower than 4.

2) -mstrict-align should not be used anymore.

3) The diff file on which this release was build can be found at:
   http://www.morphos.de/meanmachine/files/gcc-2.95.3.diffs.bz2

4) This version is a slightly modified version from the last
   version released on the morphos.de homepage.
   This compiler supports now __stackext and also the newly
   introduced __attribute__((varargs68k)) statements.
   So it is fully compatible with the "release/cisc" version of the
   cross-compiler environment also avaible to MOS directly.

   See http://zapek.meanmachine.ch/morphos/morphos.html for examples
   on how to port your AmigaOS applications.

Have phun
and keep up the good work

Jens Langner <Jens.Langner@htw-dresden.de>
June 2002