Building GhostScript 8.54 from source
-------------------------------------
Please note that the contents of this directory are not required for end-users
who just want to use GhostScript for RISC OS. They are only needed if you want
to compile your own version of the software instead of using the distributed
finished binary.

Using the excellent GCCSDK on a Linux system, GhostScript 8.54 can be built for
RISC OS without any source code changes. Since the build process requires
native executables to be built the build process is not 100% automatic though.

It is likely that it is not difficult to build the sources on RISC OS, too,
using gcc and UnixLib.

1. Configuring the sources
--------------------------
In a shell with GCCSDK on your PATH type
  ./configure --host arm-riscos-aof

The --host option tells the configure script that you are cross-compiling.
Without it, it checks whether it can run built executables, which is of course
not true for RISC OS executables built using GCCSDK on a Linux machine.

2. Makefile changes
-------------------
After configuring the sources the Makefile needs to be edited slightly, e.g.,
to disable features and devices we cannot support and to change the search
paths for files. The Makefile in this directory shows the end result, which you
can drop in directly. Alternatively, if you want to carry out the changes
yourself, proceed as follows:

Change the following definitions:

  bindir = '<Ghostscript$$Dir>/bin'
  datadir = '<GhostScript$$Dir>'
  gsdir = '<GhostScript$$Dir>'
  gsdatadir = $(gsdir)/$(GS_VERSION_MAJOR)_$(GS_VERSION_MINOR)
  GS_CACHE_DIR='<GhostScript$$ScrapDir>'

Changing the following is important - searching in the current directory does
not make any sense and really upsets the RISC OS version:

  SEARCH_HERE_FIRST=0

Floating point computations are very slow on RISC OS hardware, so we use
FPU_TYPE 0. Even type -1 would be appropriate but this breaks the software.

  FPU_TYPE=0

We restrict ourselves to the following features:

  FEATURE_DEVS=$(PSD)psl3.dev $(PSD)pdf.dev $(PSD)ttfont.dev $(PSD)epsf.dev $(PSD)jbig2.dev
  #$(PSD)fapi.dev $(PSD)jpx.dev $(PSD)dpsnext.dev $(GLD)pipe.dev

i.e., disable $(PSD)fapi.dev $(PSD)jpx.dev $(PSD)dpsnext.dev $(GLD)pipe.dev

You can choose to compile the initialisation files into the executable, but
that makes it almost 2MB bigger, so I left it off:

  COMPILE_INITS=0

We certainly cannot use the X11 devices, so disable them:

  #DEVICE_DEVS=$(DISPLAY_DEV) $(DD)x11.dev $(DD)x11alpha.dev $(DD)x11cmyk.dev $(DD)x11gray2.dev $(DD)x11gray4.dev $(DD)x11mono.dev

and replace them by our RISC OS sprite devices:

  DEVICE_DEVS=$(DD)spr.dev $(DD)spr1.dev $(DD)spr8m.dev $(DD)sprm.dev $(DD)spr8c.dev

We cannot use the bbox device, so disable it as follows:

  DEVICE_DEVS16=
  #$(DD)bbox.dev

If you want the GDI device (for Samsung GDI printers), then change it to:
  DEVICE_DEVS16=$(DD)gdi.dev

3. Add sources
--------------
Add gdevspr/c in this directory as src/gdevspr.c to the source tree and append
the lines in contrib+/mak to the file src/contrib.mak. If you want the GDI
device, add the lines in contrib2+/mak to the file src/contrib.mak

4. Build the native executables
-------------------------------
The build process builds utilities that are then used to build some source
files for the main GhostScript executable. Obviously, we need to build these
executables as native Linux versions, so in a shell with your standard gcc in
the PATH, type:

make obj/echogs obj/genarch obj/genconf obj/geninit

5. Build the final executable
-----------------------------
In a shell with the GCCSDK executables in your PATH, type

make

If everything goes well, you will find the final GhostScript executable as
bin/gs,ff8

Martin Wuerthner
martin@mw-software.com
