		  Building GCC 1.37.1 for the Apollo
			       4-May-90
			      John Vasta

		Changes for gcc-1.40 by Christos Zoulas
			christos@ee.cornell.edu


These changes enable GCC 1.40 to be used on Apollo SR10.x systems
with some restrictions:

  1. There is no debug information at all (although DDE lets you debug
     in assembly language).

  2. The header files in /usr/apollo/include cannot be compiled,
     because of the C++-style "reference type" syntax, which is not
     implemented in GCC. All the Unix header files should compile,
     however.

  3. The compiler generates code which is link-compatible with the
     Apollo C compiler and libraries. The GNU assembler was hacked to
     produce COFF output modules. In order to use the Apollo global
     libraries, the code sections are actually put into writable data
     sections, so that the loader can relocate them (GCC doesn't
     generate code which needs no relocation, like the Apollo
     compilers). This means that program text cannot be shared, and
     loading may take slightly longer, but I don't think it will be
     noticable.


The following prerequisites are required:

  1. Running SR10.2 or later and using version 6.7 or later of the
     Apollo C compiler (it may work on earlier SR10 releases and C
     compilers, but I haven't tried it).

  2. Running in a bsd4.3 environment in order to build the GNU
     software (although the resulting binaries will work in any
     environment).

  3. Virgin distribution of GCC 1.40 (available via anonymous ftp
     from prep.ai.mit.edu in the /pub/gnu directory, as well as from
     other sites).

  4. Virgin distribution of GAS 1.38.1.

  5. Recent version of Bison (I'm using 1.14)


Here are the steps to follow:

  1. Get the required GNU software and set it up (you should have a
     gas-1.38.1-diff directory and a gcc-1.40-diff directory)

	gas-1.38.1/Makefile.diff
	gas-1.38.1/as.c.diff
	gas-1.38.1/write.c.diff
	gas-1.38.1/coff-convert.c.diff

	gcc-1.40/Makefile.diff
	gcc-1.40/c-parse.y.diff
	gcc-1.40/expr.c.diff
	gcc-1.40/config/tm-apollo68.h.diff

     If you unpacked the tar file in the directory containing the gas
     and gcc directories, then the files were overlaid and you're all
     set. Otherwise you'll need to move the files into the correct
     places.

     Patch the files in gas-1.38.1 using the files in gas-1.38.1-diffs as the
     patch input, and patch the files in gcc-1.40 using the files from
     gcc-1.40-diffs. NOTE: if you use the /usr/new/patch
     utility you should use the -p option so that it will patch files
     in subdirectories, and do the patching from the directory
     containing the gas and gcc directories. For example, if you have
     the directory /usr/local/gnu/gas-1.38.1, then do this:

	cd /usr/local/gnu
	patch -p < input.diff


  3. Build GAS:

	Make sure the gas files have been updated

	Create the following configuration links:
		m68k.h -> m-generic.h

	Run "make"

	Run "make install" (copies it to /usr/local/lib/gcc-as)

  4. Build Bison: just add `-A nansi' to the CFLAGS macro in the
     Makefile, run "make", then "make install".

  5. Build GCC:

	Make sure the gcc files have been updated

	Create configuration links by running the config.gcc script
	with the argument 'apollo68' (i.e. `config.gcc apollo68')

	Run make

	Install it with 'make install'

  6. If you want to test GCC by using it to compile itself (twice),
     then do 'make bootstrap CFLAGS=""'

Be sure to use gcc to link your programs. It makes sure that the GCC
runtime library is linked in, and that the startup file is linked in.
Using ld directly won't work, unless you explicitly link in
/usr/lib/crt0.o and /usr/local/lib/gcc-gnulib.

John Vasta                Hewlett-Packard Apollo Systems Division
vasta@apollo.hp.com       M.S. CHA-01-LT
(508) 256-6600 x6362      300 Apollo Drive, Chelmsford, MA 01824
UUCP: {decwrl!decvax, mit-eddie, attunix}!apollo!vasta
