# How to build Ghostscript from source code

## Table of contents

> - General overview
> - How to acquire the source code
> - How to unpack the source code
>   - How to unpack compressed tar files generally
>   - How to unpack zip files generally
>   - How to unpack Ghostscript itself
> - How to check for post-release bug fixes
> - How to prepare the makefiles
>   - Changes for your environment
>   - Selecting features and devices
>     - Precompiled run-time data
>     - GNU readline
>   - Setting up "makefile"
>   - MSys/Mingw
>   - Invoking "make"
>   - Cross-compiling
> - How to build Ghostscript from source (PC version)
>   - Borland/Inprise environment
>   - Microsoft environment
>   - Microsoft environment 64-bit
>   - Microsoft environment WinRT
>   - Making self-extracting executables
>   - Watcom environment
>   - Cygwin32 gcc
>   - Intel C/C++ compiler
> - How to build Ghostscript from source (MacOS version)
>   - Traditional MacOS
>   - MacOS X
> - How to build Ghostscript from source (Unix version)
>   - The multi-architecture makefile
>   - Setting up "makefile"
>   - Shared object
>   - Tool-specific issues
>     - gcc 2.7.*
>     - make tools
>   - OS-specific issues
>     - 386 Unix
>     - BSDI
>     - Digital Unix (Alpha)
>     - Linux
>     - NeXTSTEP / OpenSTEP
>     - SCO Unix/Xenix
>     - SVR4 Unix
>     - System V Unix platforms
>     - Unixware
>   - Hardware-specific issues
>     - Alpha with gcc
>     - H-P Apollo
>     - AT&T 7040 R3
>     - Convex
>     - DECStations with Ultrix
>     - H-P RISC workstations
>     - Intergraph Clipper
>     - MIPS
>     - NCR 3550
>     - Pyramid MIServer-S
>     - IBM RS/6000 with AIX
>     - Silicon Graphics
>     - Sun
>     - SunOS
>     - Solaris
>     - VAX with Ultrix
> - How to build Ghostscript from source (OS/2 version)
> - How to build Ghostscript from source (OpenVMS version)
>   - Building with GNU make on OpenVMS
>   - Building with MMK or MMS on OpenVMS
> - Other environments
>   - Environments lacking multi-threading
>   - Plan 9
>   - QNX
> - How to build Ghostscript with UFST
> - How to build Ghostscript without FreeType

For other information, see the Ghostscript overview and the instructions on how to install Ghostscript.

## General overview

This document describes how to build a Ghostscript executable from source code. There are four major steps to building Ghostscript:

1. Acquire the compressed archive files of source code for Ghostscript.
2. Unpack the archive files into the Ghostscript directory and correctly named subdirectories.
3. Configure the build to match your system and desired configuration options.
4. Invoke "`make`" to build the software.

The remainder of this document describes each of these steps in detail. Note that some of this process is platform-dependent. After building Ghostscript you must then install it; for that, see the installation instructions.

## How to acquire the source code

Building Ghostscript requires the Ghostscript source code itself, and in some cases the source code for the third-party libraries that Ghostscript uses.

Official releases can be found under the GPL license at

> ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/

Ghostscript source code is packaged in two different formats: gzip-compressed tar files (*`.tar.gz`) and zip files (*`.zip`). For all versions there are gzip-compressed tar files:

> `ghostscript-`#.##`.tar.gz`
> `ghostscript-fonts-std-`#.##`.tar.gz`
> `ghostscript-fonts-other-`#.##`.tar.gz`

For recent versions of Ghostscript there are also zip files

> `gs`###`src.zip`
> `gs`###`w32.exe`

("#.##" and "###" are version numbers in punctuated and unpunctuated form.) Software to decompress and extract both formats is available for almost every platform for which Ghostscript is available -- including Unix, DOS, MS Windows, and VMS -- so you can choose the format most convenient for you; but it's up to you to locate that software. See the section on unpacking the source code.

On MS Windows one ordinarily uses the zip file kits, in other environments the compressed tar files, but this is simply a matter of convenience, since for the same version of the software the compressed tar file has the same contents as the zip file. Note that each of these libraries has its own version number that has nothing to do with Ghostscript's version number; you should get the highest numbered version. (If you encounter difficulties in the build process you might have to use a lower-numbered version, but don't worry about this yet.) If you're running Linux, you might check whether these libraries are already available in source form on your system, since many Linux distributors include them; but we advise you to get the highest version from the Net if you can.

## How to unpack the source code

Unfortunately there are no generally accepted standards for how to package source code into archives, so the instructions for unpacking Ghostscript are longer than they should be. We begin with a brief explanation of how to extract the two kinds of archive files.

### How to unpack compressed tar files generally

Tar (`.tar`) files are the de facto standard for archiving files on Unix (every Unix system has the `tar` program), and programs to extract their contents are also widely available for DOS, MS Windows, and VMS. To economize on space and downloading time, Ghostscript's tar files are compressed with GNU `gzip`, which adds the suffix "`.gz`" to the file name, giving "`.tar.gz`".

To unpack a compressed tar file `MyArchive.tar.gz` you must both decompress it and extract the contents. You can do this in two steps, one to decompress the file and another to unpack it:

> `gzip -d MyArchive.tar.gz`
> `tar -xf MyArchive.tar`

or in a pipeline:

> `gzip -d -c MyArchive.tar.gz | tar -xf -`

or, if you have a program like GNU `tar` that can handle compressed tar files, with a single command:

> `tar -zxf MyArchive.tar.gz`

The `tar` program automatically preserves directory structure in extracting files. The Ghostscript source archive puts all files under a directory `gs`#.##, so using `tar` to unpack a compressed archive should always properly create that directory, which we will call the "gs directory". Make sure you're positioned in the parent of the gs directory before unpacking the files. If a subdirectory doesn't already exist, `tar` creates it.

Some other programs -- under MS Windows, for instance -- can also unpack compressed tar files, but they may not automatically preserve directory structure nor even extract files into the current directory. If you use one of these, you must

- set the program's options to "Use folder names" or the equivalent, and
- check that it is extracting files into the right place.

### How to unpack zip files generally

Zip files are the de facto standard for archiving files on DOS and MS Windows, and programs to extract their contents are widely available for DOS, MS Windows, Unix, VMS, and other platforms. Zip files are at once an archive format and a compressed format, so an unzipping program decompresses and extracts archived files as a single step.

One common 16-bit DOS program is `pkunzip`, which comes in the `pkzip` package. If you use this, you should ensure that you have at least version 2.04g, because with its `-d` switch, that version of `pkunzip` preserves the directory structure of archived files when extracting them; see below. Another popular free program to unpack zip archives, available for DOS and MS Windows (16-bit and 32-bit), Unix, VMS, and other platforms, is InfoZIP `unzip`:

> http://www.info-zip.org/pub/infozip/UnZip.html

Unlike `pkunzip`, InfoZIP `unzip` automatically preserves the directory structure of extracted files. So if you have a zip archive `MyArchive.zip`:

> Extracting zipped files
> Command |  | Preserves directory structure
> `pkunzip MyArchive.zip` |  | Does NOT
> `pkunzip -d MyArchive.zip` |  | DOES (note the `-d` switch)
> `unzip MyArchive.zip` |  | DOES

As with the compressed tar files, make sure you're positioned in the parent of the gs directory before unpacking the files. If a subdirectory doesn't already exist, `zip` or `pkunzip -d` creates it.

### How to unpack Ghostscript itself

At this point you have acquired all the source code and are ready to unpack it according to the preceding guidelines for tar files or zip files. To unpack the Ghostscript source, make the parent of the (new) gs directory the current directory.

> 2-step: |  | `gzip -d ghostscript-`#.##`.tar.gz` `tar -xf ghostscript-`#.##`.tar`
> Pipe: |  | `gzip -d -c ghostscript-`#.##`.tar.gz | tar -xf -`
> GNU `tar`: |  | `tar -zxf ghostscript-`#.##`.tar.gz`
> `pkunzip`: |  | `pkunzip -d gs`###`sr1.zip` `pkunzip -d gs`###`sr2.zip` ...
> `unzip`: |  | `unzip gs`###`src.zip`

All the Ghostscript source files are now in subdirectories of the gs directory.

> Source subdirectories
> Subdirectory |  | Contents
> `base/` |  | Graphics library C source code and makefiles
> `psi/` |  | PS interpreter C source code and makefiles
> `lib/` |  | PostScript files and scripts used when running Ghostscript
> `doc/` |  | Documentation
> `man/` |  | Unix `man` pages
> `examples/` |  | Sample PostScript files

#### Luratech compressor libraries

Ghostscript has optional support for the Luratech proprietary JBIG2 and JPEG 2000 implementations. If you have the source code for these and wish the compile them into Ghostscript, the build system expects them to be in directories named `luratech/ldf_jb2` and `luratech/lwf_jp2` in the top level gs source directory, alongside the other third-party libraries. With the Luratech source directories in the expected place, the build system will automatically include them.

If you have the Luratech code but wish to build without it, on "configure" based builds you can achieve this by doing:

> `./configure --without-luratech`

On Windows, you can achieve it by adding:

> `NO_LURATECH=1`

to your nmake command line.

With either of these options, the build will fall back to the defaults for both JBIG2 and JPEG2000 decoding.

## How to check for post-release bug fixes

Bug information and fixes are tracked on Ghostscript Bugzilla. For more information, please visit

> http://bugs.ghostscript.com

## How to prepare the makefiles

The Ghostscript makefiles are very large and complex in order to deal with the diverse requirements of all the different systems where they may be used.

Ghostscript has an automatic configuration script. If you're on unix or a system that supports unix shell scripts, this is the easiest option to use. Simply type:

> `./configure`

from the top level of the ghostscript source directory. It should configure itself based on what's available on your system, warn you of any missing dependencies, and generate a Makefile. At this point you can skip to the section invoking make below. Also, many common configuration options (like install location) can be set through options to the configure script. Type '`./configure --help`' for a complete listing. Note that the configuration option is only available with the unix .tar distributions of the source.

Note that if you're building Ghostscript from development source out of a repository instead of from a released source package, you should run '`./autogen.sh`' instead of `./configure.` This script takes all the same options that configure does.

If your system doesn't support the configure script or you don't wish to use it, you can use the traditional ghostscript makefile system, editing the options by hand to match your system as described below. Fortunately, the only makefiles you're likely to want to change are relatively small ones containing platform-specific information.

> Platform-specific makefiles
> Makefile |  | Used for
> `Makefile.in` |  | Template makefile for the autoconf build
> `bcwin32.mak` |  | MS Windows with Borland/Inprise compilers
> `msvc32.mak` |  | MS Windows with Microsoft Visual C++ version 4 to 7.
> `openvms.mak` |  | OpenVMS
> `os2.mak` |  | OS/2 with the gcc/emx compiler
> `unix-gcc.mak` |  | Unix with gcc
> `unixansi.mak` |  | Unix with ANSI C compilers other than gcc
> `watcw32.mak` |  | MS Windows with Watcom compilers
> Platform-independent makefiles
> `contrib.mak` |  | Contributed device drivers
> `devs.mak` |  | Maintained device drivers
> `gs.mak` |  | Documentation and miscellany
> `icclib.mak` |  | ICC color correction library
> `ijs.mak` |  | IJS raster driver library
> `int.mak` |  | Main makefile for the PostScript & PDF interpreter
> `jpeg.mak` |  | JPEG library
> `lib.mak` |  | Graphics engine
> `libpng.mak` |  | PNG library
> `version.mak` |  | Version and release date
> `zlib.mak` |  | zlib library

Since these files change from one Ghostscript version to another, sometimes substantially, and since they all include documentation for the various options, here we don't duplicate most of that documentation: we recommend strongly that you review the entire makefile specific for your operating system and compiler before building Ghostscript.

### Building against the Luratech compression libraries

To compile Ghostscript against the proprietary Luratech JBIG2 and JPEG 2000 implementations, simply ensure that the `luratech/ldf_jb2` and `luratech/lwf_jp2` containing the Luratech code exist in the top level gs source directory, and (re-)run the configure script. The configure script will detect the presence of the directories, and apply the appropriate settings in the Makefile.

If you have the Luratech directories in place, but want Ghostscript built without it, you can run configure with the --without-luratech option, and the script will behave as if the directories did not exist.

### Changes for your environment

You must edit the platform-specific makefile to change any of these:

- The name of the makefile itself (`MAKEFILE` macro)
- The locations to install Ghostscript files (`prefix` etc.)
- The default search paths for the initialization and font files (`GS_LIB_DEFAULT` macro)
- The debugging options (`DEBUG` and `TDEBUG` macros)
- Which optional features to include (`FEATURE_DEVS`)
- Which device drivers to include (`DEVICE_DEVS` and `DEVICE_DEVS`{1--20} macros)
- Default resolution parameters for some printer drivers (`devs.mak` or `contrib.mak`, whichever defines the driver)

The platform-specific makefiles include comments describing all these except the `DEVICE_DEVS` options. These are described in `devs.mak` and `contrib.mak`, even though the file that must be edited to select them is the platform-specific makefile.

Some platform-specific options are described in the sections for individual platforms. See the "Options" section near the beginning of the relevant makefile for more information.

### Selecting features and devices

You may build Ghostscript with any of a variety of features and with any subset of the available device drivers. The complete list of features is in a comment at the beginning of `gs.mak`, and the complete list of drivers in comments at the beginning of `devs.mak` and `contrib.mak`. To find what devices a platform-specific makefile selects to include in the executable, look in it for all lines of the form

> `FEATURE_DEVS=`{list of features}
> `DEVICE_DEVS`*`=`{list of devices}

For example, if the makefile has

> `FEATURE_DEVS=$(PSD)level2.dev`

indicating that only the PostScript Level 2 facilities should be included, you might make it

> `FEATURE_DEVS=$(PSD)level2.dev $(PSD)pdf.dev`

to add the ability to interpret PDF files. (In fact, `FEATURE_DEVS` in the current Unix makefiles already includes `$(PSD)pdf.dev`.) The Unix makefile also defines

> `DEVICE_DEVS=$(DD)x11.dev`

indicating that the X Windows driver should be included, but since platform-specific makefiles as distributed normally include many of the possible features and drivers, you will probably rather remove from the makefile the features and drivers you don't want. It does no harm to include unneeded features and devices, but the resulting executable will be larger than needed.

You may edit the `FEATURE_DEVS` line to select or omit any of the features listed near the beginning of `gs.mak`, and the `DEVICE_DEVS`* lines to select or omit any of the device drivers listed near the beginning of `devs.mak` and `contrib.mak`. The first device listed in the definition of `DEVICE_DEVS` becomes the default device for this executable; see the usage documentation for how to select an output device at run time using the `-sDEVICE=` switch. If you can't fit all the devices on a single line, you may add lines defining

> `DEVICE_DEVS1=$(DD)`{dev11}`.dev` ... `$(DD)`{dev1n}`.dev`
> `DEVICE_DEVS2=$(DD)`{dev21}`.dev` ... `$(DD)`{dev2n}`.dev`

etc., up to `DEVICE_DEVS15`. Don't use continuation lines -- on some platforms they don't work.

Note that if you want to include a driver named xxx, you must put `$(DD)`xxx`.dev` in `DEVICE_DEVS`*. Similarly, if you want to include a feature related to the PostScript or PDF language interpreters (PostScript level 1 .. 3, or other language features such as the ability to read EPSF files or TrueType font files), you must represent it as `$(PSD)`xxx`.dev`. If you are linking only the graphics library -- not the language interpreter(s) -- with an application and want to include optional graphics library features such as CIE color, you represent them as `$(GLD)`xxx`.dev`.

#### Precompiled run-time data

Ghostscript normally reads a number of external data files at run time: initialization files containing PostScript code, fonts, and other resources such as halftones. By changing options in the top-level makefile for the platform, you can cause some of these files to be compiled into the executable: this simplifies installation, improves security, may reduce memory requirements, and may be essential if you are planning on putting Ghostscript into ROM.

By default, most top level make files now default to compiling the initialization files (`lib/gs_init.ps`, etc.) into the executable. To disable this, change the `1` to a `0` in the line

> `COMPILE_INITS=1`

Files are now compiled into the executable as a %rom% file system that can be searched, opened, etc. as with the normal (%os%) file system. The data is (mostly) compressed. The set of files built into the %rom% file system is specified in the `psi/psromfs.mak` file. Refer to the file `base/mkromfs.c` for a description of the parameters that control source and destination pathnames, file enumeration exclusion, compression, etc.

While fonts normally are compiled into the executable using `mkromfs` (above) from the Resource/Font/ directory, it is possible to compile Type 1 fonts into the executable using an older method that converts Type 1 fonts into C code. See Precompiling fonts.

Similarly, Halftone resources can be compiled into the executable using `mkromfs`, but also threshold-array halftones can be compiled into the executable. See the "Compiled halftone" section of `int.mak` for a sample makefile fragment, `genht.c` for the syntax of halftone data files, and `lib/ht_ccsto.ps` for a sample data file. Note that even though the data files use PostScript syntax, compiled halftones do not require the PostScript interpreter and may be used with the graphics library alone.

#### GNU readline

AFPL Ghostscript does not include an interface to GNU readline. A user contributed code for this purpose, which we spent significant time debugging and then updating to track internal architectural changes in Ghostscript. The contributor was willing to assign the copyright to Aladdin Enterprises (the copyright holder of Ghostscript at the time), and to allow the code to be distributed with the Aladdin Free Public License (AFPL) as well as the GNU License (GPL). However, even though the GPL allows linking GPLed code (such as the GNU readline library package) with non-GPLed code (such as all the rest of AFPL Ghostscript) if one doesn't distribute the result, the Free Software Foundation, creators of the GPL, have told us that in their opinion, the GPL forbids distributing non-GPLed code that is merely intended to be linked with GPLed code. We understand that FSF takes this position in order to prevent the construction of software that is partly GPLed and partly not GPLed, even though the text of the GPL does not actually forbid this (it only forbids distribution of such software). We think that FSF's position is legally questionable and not in the best interest of users, but we do not have the resources to challenge it, especially since FSF's attorney apparently supports it. Therefore, even though we added the user-contributed interface to GNU readline in internal Aladdin Ghostscript version 5.71 and had it working in version 5.93 (one of the last beta versions before the 6.0 release), we removed it from the Aladdin Ghostscript 6.0 distribution.

GPL Ghostscript distributions will include support for GNU readline. As with other GPL Ghostscript components that are not included in AFPL Ghostscript, the maintainers of Ghostscript will not attempt to run, link, or even compile this code, or keep it current across changes in the rest of Ghostscript. We will, however, welcome bug fixes or updates, and distribute them with subsequent releases of GPL Ghostscript.

The first Ghostscript distribution to include GPL readline support was GNU Ghostscript 6.0. Support has unfortunately been spotty since then.

We put considerable work into making it possible for Ghostscript to use GNU readline, including the creation and adjustment of internal software interfaces specifically to serve this purpose. In principle, we should have undone this work in AFPL Ghostscript, lest FSF object to it too as intended to facilitate linking AFPL Ghostscript with GNU readline (as the U.S. government has been said to do for code that merely provides APIs where encryption may be added). However, we are willing to take this risk rather than spend the time to undo the interface changes.

If you have comments or questions about this situation, please feel free to contact the Free Software Foundation, authors of the GPL and copyright holders of GNU readline, at gnu@gnu.org, and/or Artifex Software, Inc., copyright holder of Ghostscript, at info@artifex.com.

### Setting up "makefile"

After going through the steps just described to unpack the sources, configure the build and make any desired changes to the makefiles. As the final step in preparing to build Ghostscript you must usually associate the name "`makefile`" with the correct makefile for your environment so the `make` command can find it. See the section on your particular platform for how to do that if necessary.

On unix systems, `./configure` (or if checked out of git, `./autogen.sh`) should create a `Makefile` which works in most scenarios. Manual tempering and editing should rarely be needed nor recommended.

### Invoking "make"

`make`
  Builds Ghostscript without debugging options.

`make debug`
  Builds Ghostscript with debugging options and additional internal error checks. The program will be somewhat larger and slower, but it will behave no differently unless you actually turn on debugging options at execution time with the `-DDEBUG` or `-Z` command line switches described in the usage documentation.

`make pg`
  On Unix platforms, builds with the `-pg` compiler switch, creating an executable for time profiling.

`make begin`
  On PC platforms, attempts a quick and dirty compilation of all the `.c` files in the current directory. See the more detailed explanation.

`make install`
  After building, installs the Ghostscript executables, support files, and documentation, but does not install fonts. See the installation documentation.

`make clean`
  Deletes all the files created by the build process (relocatables, executables, and miscellaneous temporary files). If you've built an executable and want to save it, move it first to another place, because "`make clean`" deletes it.

`make so`
  On some platforms (Linux, *BSD, Darwin/Mac OS X, SunOS), it is possible to build ghostscript as a shared object library. There is a corresponding "`make soclean`" for cleaning up.

Note: on most platforms some of these simple instructions don't quite work in one way or another. Read the section on your specific platform.

Note 2: If you are attempting to build a statically linked executable, you will probably need to add libraries to the linker options (libraries that are normally pulled-in automatically by the dynamic linker). These can be added at the make command line using the "EXTRALIBS=" option. Unfortunately, the set of libraries that may be required varies greatly depending on platform and configuration, so it is not practical to offer a list here.

### Cross-compiling

If you are compiling Ghostscript on machines X1 ... X n with cross-compilers that generate code for machine Y, you must first perform several extra steps on some machine Z (not necessarily of the same type as either X i or Y). First of all, choose a makefile appropriate for Z and edit it to reflect the run-time options you wish to include (`FEATURE_DEVS`, `DEVICE_DEVS*`, and any other relevant options), just as for non-cross-compilation.

If Z runs Unix, perform the following steps:

1. On Z,

   > `make clean`
   > `make obj/arch.h obj/genconf obj/echogs`

2. Edit `obj/arch.h` to reflect the architecture of Y.
3. On Z,

   > `make CC=: CCLD=:`

4. Copy the files `obj/*.h` from Z to the directory on each X i that will be used for compilation.
5. Extract from the file `obj/ldt.tr` (on Z) the list of `.o` files that will be linked: this gives the list of source files that must be compiled.
6. Do the compilations on X i.

If Z runs some version of Microsoft Windows with Microsoft Visual C++, use the following steps. NOTE: We have not actually tested this.

1. On Z,

   > `nmake clean`
   > `nmake obj\arch.h obj\genconf.exe obj\echogs.exe`

2. Edit `obj\arch.h` to reflect the architecture of Y.
3. On Z,

   > `nmake CC=rem LINK=rem`

4. Copy the files `obj\*.h` from Z to the directory on each X i that will be used for compilation.
5. Extract from the file `obj\ldt.tr` (on Z) the list of `.obj` files that will be linked: this gives the list of source files that must be compiled.
6. Do the compilations on X i.

## How to build Ghostscript from source (PC version)

All Ghostscript builds in PC (DOS and MS Windows) environments are 32- or 64-bit: 16-bit builds are not supported. The relevant makefiles are

> PC makefiles
> Makefile |  | Construction tools |  | For environment
> `bcwin32.mak` |  | Borland/Inprise C++ 4.x |  | Windows 95, 98, NT and later
> `msvc32.mak` |  | Microsoft Visual C++ 4 to 8 |  | MS Windows 32-bit
> `watcw32.mak` |  | Watcom C/386 or C++ |  | MS Windows 32-bit
> `unix-gcc.mak` |  | Cygnus gcc |  | Cygnus gnu-win32

To build Ghostscript you need MS-DOS version 3.3 or later and Borland/Inprise C/C++ (4.0 or later); Microsoft Visual C++ (version 4.0 or later); Watcom C/386 (version 8.5 or later) or C++ (any version); or the free djgpp + go32 development system. The options in the makefiles are chosen to strike a balance between RAM consumption and likely usefulness. If you run `make` in directory {dir}, the default configuration generates an executable that assumes the Ghostscript initialization and font files are in directory {dir}`\lib`.

Note that the `make` program supplied with each PC compiler has a different name. We refer to this program generically as `make` everywhere else in this document, but you will find the correct name for each compiler in the relevant section below that discusses that compiler.

You must have `COMMAND.COM` in your path to build Ghostscript. After making the changes needed to choose features and devices to build into the executable, you must create the directory where the compiler will do its work (normally the `obj` subdirectory of the current directory) and the directory where the compiled code will be placed (normally the `bin` subdirectory). Then to build the Ghostscript executable all you need do is give the `make` command.

A special make target "`begin`" attempts to compile all the `.c` files in the current directory. Some of these compilations will fail, but the ones that succeed will go considerably faster because they don't individually pay the overhead of starting up the compiler. So a good strategy for building the executable for the first time, or after changing a widely used `.h` file, is to do the fast compilation of everything possible, then the controlled compilation of everything that failed in the first step:

> `make begin
> make`

Note: if you unpack the Ghostscript sources on a DOS or MS Windows system from a Unix tar file, the unpacked files have linefeed alone as the line terminator (the Unix convention) instead of carriage return + linefeed (the Microsoft convention), which may make the C compiler unhappy. One simple way to fix this, if you have the InfoZIP `zip` and `unzip` programs, is

> `zip -l CVTEMP.zip *.bat *.c *.h *.def *.rc` |  | (Letter "l", not the digit "1")
> `unzip -o CVTEMP.zip` |  | (Rewrite all the same files correctly)
> `del CVTEMP.zip` |  | (Delete the temporary zip file)

### Borland/Inprise environment

To compile Ghostscript with the Borland/Inprise environment (hereafter referred to as just "Borland"), you need Borland C++ (version 4.0 or later); specifically the compiler, `make` utility, and linker. You also need either the Borland assembler (version 1.0 or later) or the Microsoft assembler (version 4.0 or later).

To create "`makefile`", give the command

> `echo !include "base\bcwin32.mak" >makefile`

To run the `make` program, give the commmand (after issuing e.g. `set PATH=C:\Borland\BCC55\Bin;%PATH%` to set the appropriate `PATH`):

> `make`

Besides the source files and the makefiles, you need:

> *`.bat` |  | (a variety of batch files used in the build process)

Comments in the makefiles describe the configuration parameters. If your configuration is different from the following, you should definitely read those comments and see if you want or need to change any of this:

- The compiler files are in `C:\BC` and its subdirectories.
- You are using the Borland assembler `tasm`.
- You want an executable that will run on any 32-bit PC-compatible, regardless of processor type (80386, 80486, Pentium, or compatible) and regardless of whether a math coprocessor (80x87) is present -- an issue only with 80386 processors.

Notes

- A user reports that the Borland C++ 4.00 with patch 1-6 doesn't produce a working executable of Ghostscript 5.03. We can't test this, since we no longer have this compiler.
- Borland C++ 4.5 has a bug or bugs that cause(s) the 32-bit Windows executable to crash if you give any @-files on the command line. Among other things, this makes the uniprint driver unusable, because it references the .upp configuration files this way. This problem may possibly be fixed by one or more of the patch files on

  > ftp://ftp.borland.com/pub/borlandcpp/devsupport/patches/bc4_5/

- Borland C++ 4.52 has a bug that causes the 32-bit Windows executable to fail during startup. Borland provides a patch for this bug in

  > ftp://ftp.borland.com/pub/borlandcpp/devsupport/patches/bc4_5/bc45xp1.zip

- Borland C++ 5.0 and 5.01 have a code generator bug that generates incorrect code for the construct `!file_is_valid()`. Do not attempt to compile Ghostscript with these compilers. If you want to report this bug to Borland, send them the result of compiling `ziodev.c` and tell them to look at the code generated for `file_is_valid()` and `!file_is_valid()`. We don't know whether Borland C++ 5.02 still has this problem. The problem does not appear to exist in Borland C++Builder 4 or 5.
- Borland C++Builder 5 and above require `BUILDER_VERSION` to be set explicitly to 5 in the make file because the version of MAKE which ships with this product (Version 5.2) is the same as that shipped with Version 4.5. Therefore, there is no way to automatically establish the compiler version that is in use. Note that because a 16 bit compile does not ship with Version 5.5, conditionals have been added to prevent attempts to compile 16 bit code when `BUILDER_VERSION = 5`
- Note that under Borland C++Builder 5, MAKE does not stop when `_genarch.bat` should be run as described above. It is necessary for the user to Abort the make by pressing Control-C. You should then run "`_genarch.bat`", wait until `genarch` has finished and then exit MS Windows. Then type "`make`" again to restart the make process. All targets are built succesfully if this step is ignored. `I don't know if the targets are correct although they seem to run OK.`
- To prevent the compiler terminating because too many warning messages have been generated, copy the file `bcc32.cfg` to the `bin` directory of the compiler suite using the following command: e.g.

  > `copy base\bcc32.cfg C:\Borland\BCC55\Bin\bcc32.cfg`

- The free version of Borland C++Builder 5 does not ship with the Borland assembler `tasm32`. You may need to edit `lcms/include/lcms.h` to switch off the `USE_ASSEMBLER` default and use `USE_FLOAT` or `USE_C` instead.
- Borland `make` has a lower limit to the number of dependencies than other `make`(e.g. dependencies of `gdevp14` near line 2690 of `base/lib.mak` after the icc merge). One workaround, when using a clean/fresh source directory, is simply deleting dependencies on header files which are present and not likely to change.

### Microsoft Environment

NOTE: We have received reports that the Microsoft Visual C++ 5.0 and 6.0 compilers produce incorrect code for Ghostscript version 6.0 and later, from the same source code that compiles and runs correctly with other compilers. In spite of these reports, several members of the Artifex staff use version 6.0 of the MSVC compiler on a regular basis and we have not found any problems. You may also want to try out the Intel C/C++ compiler, which can be integrated into the Microsoft Visual C++ environment.

To compile Ghostscript using the Microsoft environment, you need Microsoft Visual C++ 4.0 or later with its associated "`nmake`" utility and linker.

#### Using Microsoft Developer Studio

Microsoft Developer Studio is the Microsoft Visual C++ integrated development environment. To use it to build Ghostscript: it is first necessary to create a new workspace/project. To create the workspace/project, open Microsoft Developer Studio and select `File/New`. In the dialog window that is opened, select 'Makefile' as the type of project. Specify a name for the project. (Microsoft does not allow special characters such as ., *, ?, /, or \ as part of project names.) Also specify the location of the master directory for your Ghostscript files. Then select OK.

In the next dialog window, specify the build command line as `nmake /f psi/msvc32.mak DEVSTUDIO=` Note the value for `DEVSTUDIO` is empty. Then select `Finish`.

At this point, it is now possible to build Ghostscript using Developer Studio. To build, press F7 or select the build icon. Note: multiple warnings will also given about things like double to float data conversions. Ignore them. We have not found a way to create a single set of sources that does not create warnings with the different compilers and operating systems supported by Ghostscript. We are working to reduce the number of the warning messages.

To run Ghostscript inside of Developer Studio, it is necessary to specify the name of the executable program . Select `Project/Settings`. Select the `Debug` tab. Then for `Executable for debug session:` specify `bin/gswin32.exe`

To use all of the features of Microsoft Developer Studio for debugging, and modifying Ghostscriptt, you need to finish the remaining steps.

To add the Ghostscript DLL to the project, select `Project/Settings`. Select the `Debug` tab. Change the `Category` to `Additional DLLs`. Then specify `bin/gsdll32.dll`.

To specify the Ghostscript program arguments, select `Project/Settings`. Select the `Debug` tab. Change the `Category` to `General`. Then specify the desired program arguments. For example, specifying: `examples/tiger.eps` will result in the tiger example file being displayed when Ghostscript is executed. .

A final note: it is possible to create a command file (build.bat) to be used for the build command line. If many different workspaces/projects are created, it is simpler to use a build batch command file rather than retyping the build command line for each new project. Here is an example used by one of Artifex's staff members. This file is one line:

> `nmake -f psi/msvc32.mak DEVSTUDIO= DEBUG=1 TDEBUG=1 GS_LIB_DEFAULT="./lib/;./font;$(GSROOTDIR)/lib;$(AROOTDIR)/fonts"`

Please note the double quotes around the value for `GS_LIB_DEFAULT` and the addition of `./lib;./fonts;` to its definition. This uses the local (within the project) copy of the `lib` and `fonts` directories. This is convenient if any changes need to be made in these directories.

Setting `DEBUG=1` includes debugging features in the build:

- It defines the C preprocessor symbol `DEBUG`. The latter includes tracing and self-validation code fragments into compilation. Particularly it enables the `-Z` and `-T` switches in Ghostscript.
- It compiles code fragments for the C stack overflow checks.

Code produced with this option is somewhat larger and runs somewhat slower.

Setting `TDEBUG=1` disables code optimization in the C compiler and includes symbol table information for the debugger. Code becomes substantially slower and larger.

An optional setting `DEBUGSYM=1` is only useful with `TDEBUG=0` for advanced developers. It includes symbol table information for the debugger in an optimized (release) build. NOTE: The debug information generated for the optimized code may be significantly misleading. For general MSVC users we recommend TDEBUG=1.

#### Using the command line

Ghostscript can be made using either the DOS shell or one one of the various command line shells made for Windows.

In order for the makefiles to work properly, two items may have to be changed. An attempt is made to select the correct version of Microsoft Visual C++ based on the version of nmake. If this doesn't work it will default to version 6.x. If you are not using version 6.x then before building, in `psi\msvc32.mak` find the line "`#MSVC_VERSION=6`" and change it to "`MSVC_VERSION=4`", "`MSVC_VERSION=5`", "`MSVC_VERSION=7`" or "`MSVC_VERSION=8`". .

In some cases the location of the Microsoft Developer Studio, needs to be changed. The location of Microsoft Developer Studio is defined by the value of `DEVSTUDIO`. There are several different definitions of `DEVSTUDIO` in psi\msvc32.mak. There is one for each of the currently supported versions of Microsoft Visual C++ (4, 5, 6, 7, 7.1 and 8).

The normal installation process for Microsoft Visual C++ includes setting the location of the Microsoft Visual C++ executables (cl.exe, link.exe, nmake.exe, rc.exe) in your PATH definition and the LIB and INCLUDE environment variables are set to point to the Microsoft Visual C++ directories. If this is true then the value for `DEVSTUDIO` can be changed to empty. I.e. `DEVSTUDIO=`

If PATH, LIB, and INCLUDE are not correctly set then the value for `DEVSTUDIO` needs to be defined. For example, for version 6.0, the default definition for the location for the Microsoft Developer Studio is: `DEVSTUDIO=C:\Program Files\Microsoft Visual Studio` If the path to Microsoft Developer Studio on your system differs from the default then change the appropriate definition of `DEVSTUDIO`. (Remember that there is a separate definition of `DEVSTUDIO` for each version of MSVC, so be sure to change the correct definition.)

To run the `make` program, give the command

> `nmake -f psi\msvc32.mak`

Rather than changing psi/msvc32.mak, these values can be specified on the make command line, I.e.

> `nmake -f psi\msvc32.mak MSVC_VERSION=6 DEVSTUDIO="C:\Program Files\Microsoft Visual Studio"
> nmake -f psi\msvc32.mak MSVC_VERSION=7 DEVSTUDIO="C:\Program Files\Microsoft Visual Studio .NET"`

Note that double quotes have been added around the path for `DEVSTUDIO` due to the spaces in the path value.

This command line can also be put into a batch file.

You may get warning messages during compilation about `/QI0f` being an undefined switch, or the message "dwmain32.def: EXETYPE not supported for platform; ignored" during linking. Multiple warnings will also given about things like double to float data conversions. Ignore them. We have not found a way to create a single set of sources that does not create warnings with the different compilers and operating systems supported by Ghostscript.

The Microsoft VC++ 5.0 compiler locks up when compiling `gxi12bit.c` with `/O2`. Compile this file without `/O2`.

The Microsoft VC++ 5.0 compiler produces a non-working executable if compiling without stack checking. Don't change the setting `TDEBUG=1` in `msvc32.mak`.

#### Building with the Luratech compression libraries

If you wish to compile Ghostscript with the Luratech JBIG2 and JPEG 2000 implementations, the source should be installed in the top-level directory of the Ghostscript source. If you have an appropriately licensed source distribution this should already have been done.

With the Luratech source in the `luratech/ldf_jb2` and `luratech/lwf_jp2` directories in the top level gs source directory, the nmake makefile will detect their presence, and use them automatically.

If you have the Luratech code in place, but wish Ghostsrcipt to be built without the Luratech decoders, you can do so by passing NO_LURATECH=1 on the nmake command line, or add the define to your Visual Studio project.

### Microsoft Environment for 64-bit

Building Ghostscript for 64-bit Windows (AMD64 processor) requires Microsoft Visual Studio .NET 2005 or Microsoft Visual Studio 2008 on 64-bit Windows. Cross compiling on 32-bit Windows is not supported. That said, see the notes at the end of this section.

Compiling for 64-bit is similar to the Microsoft Environment instructions above, but with the addition of a WIN64 define. To make ghostscript use

> `nmake -f psi/msvc.mak WIN64=`

Cross-compiling of Win64 ghostscript on 32-bit windows follows the generic cross-compiling procedure outlined above, with some additional details and convenience as follows: save `obj\arch.h`, `obj\genconf.exe`, `obj\echogs.exe`, `obj\mkromfs.exe` from a 32-bit build. In `obj\arch.h`, change ARCH_ALIGN_PTR_MOD to 8 and ARCH_SIZEOF_PTR to 8. Then adjust `psi/msvc32.mak` for compiler location (e.g. `Program Files` instead of `Program Files (x86)`) and target (`x86_amd64` instead of `amd64`). Also edit `base\lib.mak` so that `arch.h` does not depend on `genarch`, nor `gsromfs1.c` on `mkromfs`. (we don't want `genarch` to fail to regenerate a new `arch.h`, nor trigger a 64-bit `mkromfs` to build; 32-bit `echogs` and `genconf` are left alone and used when they are present). Then run `nmake -f psi/msvc32.mak WIN64=` as one would for a 64-bit build. There are some additional subtlety for packaging of installers: saving a 32-bit `make_filelist.exe` or the filelist itself, and adjusting for location of WINZIPSE and MAKENSIS.

#### Making self-extracting executables

You can build self-extracting Windows executables of Ghostscript. (This is not needed to use Ghostscript.) Currently this requires both the Borland/Inprise and the Microsoft compilers, and also two pieces of third-party software:

- `WinZipSE`, available from http://www.winzip.com/winzipse.html. This is not free.
- `zip`, available from http://www.info-zip.org/pub/infozip/Zip.html. This is free.

You will have to edit `psi/winint.mak` to define `WINZIPSE_XE` and `ZIP_XE` respectively as the path names of these programs. See Release.htm for the detailed procedure.

### Microsoft Environment for WinRT

Ghostscript can be built in the form of a win32 DLL for use within a Windows Runtime application or Windows Runtime component. Building for WinRT requires use of Microsoft Visual Studio 2012. There is a solution file that can be loaded into VS 2012, in the directory `winrt`

The WinRT application or component should include `iapi.h` from `gs/psi` and link with `gsdll32metro.lib` from `gs/debugbin` or `gs/releasebin`. Also any app using ghostscript either directly or via a component should add `gsdll32metro.dll` as "content". This inclusion of the dll is necessary so that it will be packaged with the app. If one wishes to be able to run the debugger on ghostscript then `gsdll32metro.pdb` should also be added as content.

### Watcom environment

To use the Watcom compiler, add to `AUTOEXEC.BAT` the line "`set DOS4G=quiet`". Check that `AUTOEXEC.BAT` also contains a line of the form "`set WATCOM=`{wcdir}" where {wcdir} is the directory where you installed the Watcom tools, and that the setting of `PATH` includes {wcdir}`\binnt` (or `%WATCOM%\binnt`) before {wcdir}`\binw` (or `%WATCOM%\binw`). Then to create "`makefile`":

> For |  | Give the command
> MS Windows |  | `echo !include base\watcw32.mak >makefile`

Before compiling, change the definition of the `WCVERSION` macro in the makefile (`watcw32.mak`) to the version of the Watcom compiler you are using. This is necessary to handle some minor incompatibilities between versions.

To run the `make` program, give the commmand

> `wmake -u`

### Cygwin32 gcc

It is possible to compile Ghostscript for MS Windows using the Cygwin32 gcc compiler, GNU `make`, using the "configure" generated Makefile, with only two small source code changes:

- Add "`b`" to the call to `fopen` in `gp_open_scratch`
- Mirror the `gp_ntfs` logic for `gp_pathstring_not_bare`

Information about this compiler and environment is at the Cygnus site:

> http://sources.redhat.com/cygwin/

Please note that Cygnus's licensing terms aren't quite as liberal about redistribution as either the GNU General Public License or the Aladdin Free Public License, so read their license carefully if you want to redistribute the results of using their compiler.

#### MSys/Mingw The configure build can be used to build Ghostscript on MSys/Mingw systems, but with a caveat. The msys-dvlpr adds header files into the compiler's header search paths which cause a clash, and the build will fail as a result. If you have the msys-dvlpr package installed, and until a better solution is available you can work around this by temporarily renaming the "\mingw\msys\1.0\include" directory so those headers are no longer found by the compiler.

### Intel C/C++ environment

Intel provides a C/C++ compiler that is compatible with the Microsoft Visual C++ environment. The main advantage of this compiler over MSVC 5.0 and 6.0 is that it produces working code even when all optimizations are enabled and when stack checking is disabled.

To build Ghostscript using the Intel C/C++ compiler, you have to make the following small changes in the makefiles:

- Find and change the second occurrence of "`COMPILE_FULL_OPTIMIZED`" to "`/O2`" in file `msvccmd.mak`.
- Override "`TDEBUG`", "`COMP`", and "`COMPAUX`" when invoking `nmake`.

More specifically, use "`TDEBUG=0`" and set both "`COMP`" and "`COMPAUX`" to the full path of `icl` (for example "`COMP=C:\intel\compiler45\bin\icl`" if the Intel C/C++ compiler V4.5 was installed to `C:\intel`). It is suggested that you use a batch file to launch `nmake`, since the command line processes the "`=`" on its own. Also, you may need to execute `vcvars32.bat` and `iccvars.bat` to register the proper paths for the compiler, its include files and its libraries.

You can buy or download a 30-day evaluation version of the Intel C/C++ compiler from Intel's Software Performance Tools web site:

> http://www.intel.com/vtune/

## How to build Ghostscript from source (MacOS version)

### Traditional MacOS

The Macintosh version of Ghostscript requires the Metrowerks Codewarrior development suite. Download the `macgs-7xx-src.sit` source archive from the location listed below. This includes a Codewarrior .mcp project file than can be used to build both Carbon and CFM versions of the ghostscript shared library component.

> ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/current/

If your system doesn't automatically unpack the source archive, you can download the free Stuffit Expander to open it.

This archive includes appropriate versions of the jpeg, zlib and libpng 3rd party library source for convenience. You must still download the fonts and place them in an appropriate location, along with the contents of the `lib` directory from the source archive.

Note that since this is just a library component, you will need a front-end application, such as MacGSView, to actually view or convert postscript and pdf documents.

### MacOS X

The unix source distribution (.tar.gz) builds fine on Darwin/MacOS X, albeit without a display device. You can generally just use the `Makefile` generated by `configure` as your top-level makefile and get a reasonable default build. This will allow you to use Ghostscript from the command line as a BSD-layer tool to rasterize postscript and pdf to image files, and convert between the high-level formats supported by Ghostscript. See the instructions for the unix build below for details of how to customize this build.

NOTE: If you have MacPorts (http://www.macports.org/) installed, it can "confuse" the configure script because it includes some librares which duplicate the "system" ones. This can cause missing symbol link errors. In order to resolve this, you can do:`LDFLAGS="-L/usr/lib" ./configure`. That will force the linker to search the default directory first, and thus pick up the system libraries first.

It is also possible to build "universal binaries" for MacOS X, containing `i386` and `x86_64` binaries in one file, using the `Makefile` from `configure`. This can be achieved by using the following invokation of `configure`

> `./configure CC="gcc -arch i386 -arch x86_64 -arch ppc" CPP="gcc -E"`

You can choose the combination of valid architectures (i386/x86_64/ppc) that you require.

The separate options for `CC` and `CPP` are required because some of the features used by `configure` to explore the capabilities of the preprocessor are not compatible with having multiple `-arch` options.

Building a shared library on MacOS X is the same as for other Unix-like systems, the "configure" step is done normally, and the "so" target is given to the make invocation, thus:

> `make so`

The only difference compared to other Unix-like systems is that on OS X the resulting shared library is created with the ".dylib" file name extension, instead of the more usual ".so".

Finally, there is a `macos-mcp.mak` makefile that can be used to set up the Codewarrior shared library component build described in the section on Classic MacOS above.

To set up the shlib build, download and uncompress the Ghostscript source.

Copy `base/macos-mcp.mak` to the top-level directory and rename it `makefile`. Then run 'make' in that directory, either from within Terminal.app or through Project Builder. This will set up the generated code required for the build and run a shell script to generate `ghostscript.mcp.xml`. Launch Metrowerks Codewarrior, and select 'Import Project...' from the File menu, and open the xml project file. When asked, save the results as `ghostscript.mcp` in the same directory and you should be ready to build the shared library component.

Tradtional ('PPC') applications based on the Code Fragment Manager will not be able to open the shlib linked with CarbonLib, so two targets are provided, one with carbon and one without.

## How to build Ghostscript from source (Unix version)

Ghostscript now ships with a build system for unix-like operating systems based on GNU Autoconf. In general the following should work to configure and build Ghostscript:

>     ./configure
>     make

or

>     ./configure
>     make so

for building ghostscript as a shared library. It is recommended to have the extra option `--enable-dynamic` in `./configure --enable-dynamic` which returns an error message on platforms for which shared-library support is inadequate.

Please report any problems with this method on your system as a bug.

On modern unix systems, `./configure` should create a `Makefile` which works in most scenarios. Manual tempering and editing should rarely be needed nor recommended.

Note that if you're building Ghostscript from development source out of a repository instead of from a released source package, you should run '`./autogen.sh`' instead of `./configure.` This script takes all the same options that configure does.

(deprecated; see Autoconf-based method above) For the convenience of those already familiar with Ghostscript, the old method based on hand-edited makefiles is still possible but no longer supported (and in many cases, simply do not work without substantial expert manual-editing effort). It may also be helpful in getting Ghostscript to build on very old platforms. The rest of this section deals exclusively with that older method and includes numerous pointers regarding legacy systems.

(deprecated; see Autoconf-based method above) Before issuing the `make` command to build Ghostscript, you have to make some choices, for instance

- which compiler to use;
- what features and devices to include;
- whether to use system libraries for PNG and zlib;
- and how to handle issues for your particular platform.

Be sure to check the sections on tool-, OS-, and hardware-specific issues for notes on your particular platform and compiler. In fact, that is the first place to check if you build Ghostscript and it crashes or produces obviously incorrect results.

### The multi-architecture makefile

(deprecated; see Autoconf-based method above) Especially if you are working in a Unix environment with multiple CPU types, operating systems, and/or C compilers, you may find the file `all-arch.mak` useful. This user-contributed file includes "wrappers" for the Unix makefiles for many different common environments. The author of this file notes:

> This makefile allows you to execute

>     	 make `hostname`

> on any machine on a network, without having to examine the Makefile for a specific target name. Also, some of the targets in the Makefile incorporate special changes in compiler options for certain files, to work around compiler bugs that Ghostscript has been so good at exposing. Having that special handling written down in a Makefile proves very convenient.

> I don't do "make install" until I've done

>     	cd ...build-directory.../gs-x.yz
>     	cd lib
>     	../bin/gs ../examples/tiger.eps

> and verified that the famous tiger can be correctly displayed. Also, the "make install" step is careful to first remove any existing `$(BINDIR)/gs`, then install a new gs there with a hard link to gs-x.yz.

> That way, each installation makes gs a synonym for the latest release, but earlier ones remain in place in case backtracking is needed, which I've fairly often wanted to do when investigating changed behavior, or a suspected bug.

> When I've been experimenting with a new feature, such as GNU readline support, I change the setting of GS from gs to ngs (new gs), so as not to break any existing programs by the installation of an experimental version.

### Setting up "makefile"

(deprecated; see Autoconf-based method above) The files `base/unix`*`.mak` are the makefiles for Unix platforms, and you choose one based on what compiler you use. To build Ghostscript, however, you must use the simple command "`make`", which must find the file "`makefile`" (or "`Makefile`"). If your system supports symbolic links, set up "`makefile`" like this.

> GNU gcc: |  | `ln -s base/unix-gcc.mak makefile`
> Non-gcc ANSI C compiler: |  | `ln -s base/unixansi.mak makefile`

If your system doesn't support symbolic links, first finish all changes to the compiler-specific makefile, then make a hard link, omitting the `-s` switch.

The makefile distributed with Ghostscript selects the following devices to include in the build:

> Devices included as distributed
> Type |  | Devices
> Display |  | X Windows
> Printers |  | H-P DeskJets, LaserJets, and color DeskJets and PaintJets; Canon BubbleJets
> File formats |  | Group 3 & Group 4 fax; JPEG; PCX; PBM, PGM, PKM, & PPM; TIFF; PostScript images; PNG; distilled PDF, PostScript, and EPS; PCL XL ("PCL 6")

The `unix`*`.mak` files explicitly compile and link the JPEG, PNG, and zlib libraries into the executable. If your Unix system already includes the PNG and zlib libraries -- probably in `/usr/lib/libpng.`{`a`,`so`} and `/usr/lib/libz.`{`a`,`so`} -- and you would rather use those copies, change the definition of `SHARE_LIBPNG` and `SHARE_ZLIB` from 0 to 1 in the relevant `unix`*`.mak` file before compiling. Note that if you do this, you will get non-debug versions of these libraries even if you selected `DEBUG` in the makefile. At the insistence of some users, we have also provided the ability to do this with the JPEG library (`SHARE_JPEG`), but should not use it: in order to be compatible with Adobe interpreters (which do not follow the JPEG standard exactly), Ghostscript has to compile the IJG code with the non-standard definition

> `#define D_MAX_BLOCKS_IN_MCU 64`

and since shared versions of this library will not have been compiled this way, you will get errors on some valid PostScript and PDF input files. Note also that because not all the JPEG library header files that Ghostscript uses are normally installed in `/usr/include`, you must have the source code for this library available even if you set `SHARE_JPEG` to 1.

If the X11 client header files are located in some directory which your compiler does not automatically search, you must change the `XINCLUDE` macro in the makefile to include a specific `-I` switch. See the comment preceding `XINCLUDE` in the makefile.

Currently Ghostscript is set up to compile and link in a generic Unix environment. Some Unix environments may require changing the `LDFLAGS` macro in the makefile; be sure to check the Unix section for your specific tools, operating system, and hardware.

### Shared object

(deprecated; see Autoconf-based method above) To build Ghostscript as a shared object with gcc (instead of as a single large executable) use:

    	ln -s base/unix-gcc.mak makefile
    	make so

This will build `libgs.so` and two programs which use the shared object, `gsx` which uses Gtk+ and `gsc` which does not.

Do not use `make -f base/unix-gcc.mak` because this will break the recursive make used in building the shared object.

To install the shared object and these two programs:

    	make soinstall

To delete files created by the build process:

    	make soclean

For more details see unix-dll.mak.

### Tool-specific issues

(deprecated; see Autoconf-based method above)

#### gcc 2.7.*

Some of the issues in using gcc are very specific to the particular computer, the particular version of the operating system, and the particular version of gcc available to you. You can check the version of gcc with the `gcc --version` command.

An optimizer bug in gcc versions 2.7.0, 2.7.1, and 2.7.2 causes the compiler to generate incorrect code. The makefile works around this, but we recommend that if possible you use either an earlier or a later version of gcc; for instance, gcc 2.5.8, gcc 2.6.3, 2.7.2.1 or later which don't have this bug. Note, however, that gcc has other problems on some platforms, so please read the section for your specific platform.

#### make tools

You require a make tool which supports separate directories for the derived objects (such as object files, executables and dynamically created header files) and the source files. In general, GNU make is the recommended choice, and some features (such as the building of the Linux/Unix shared library build ("make so") are only available with GNU make.

GNU make

Current versions of GNU `make` have no problems, but GNU `make` 3.59 can't handle the final linking step in some cases; if this happens, use the platform's standard `make`, typically `/bin/make`.

### OS-specific issues

#### 386 Unix

- gcc versions older than 1.38 on Intel 80386 systems do not compile Ghostscript correctly with the `-O` option.
- gcc 1.39 under `386BSD` has a bug that causes float-to-integer conversions to compile incorrectly, rendering the executable unusable.
- X11R5 may need "`#include <stddef.h>`" in `x_.h`.
- Also see regarding System V platforms.

#### BSDI

- Use `unix-gcc.mak` and set

  > `STDLIBS=-lm
  > XINCLUDE=-I/usr/X11R6/include
  > XLIBDIRS=-L/usr/X11R6/lib
  > XLIBS=Xt SM ICE Xext X11
  > `

- If you want to use the shared versions of the PNG and zlib libraries, set `SHARE_LIBPNG=1` and `SHARE_ZLIB=1` as discussed previously.
- BSD `make` uses a different syntax for its `include` directive than Ghostscript; use `gmake` instead.

#### Digital Unix (Alpha)

- Use `unixansi.mak` for all Digital Unix compilers.
- For versions of Digital Unix before 4.0, set

  `CFLAGS=-std -migrate -Olimit 1000 -g3 -O2 $(XCFLAGS)
  LDFLAGS=-lots $(XLDFLAGS)`

  You may be able to omit `-g3`. For later versions of Digital Unix, users have reported that the proper flags are

  `CFLAGS=-std1 -Olimit 1000 -g3 -O2 $(XCFLAGS)`

  again, optionally omitting the `-g3`.

- If you get compiler error messages about "ANSI aliasing rules", please see the section about building under OpenVMS below.

#### Linux

- If you build on Linux with X11 R6 or later, you may get link-time error messages about undefined references to various functions beginning with "SMC" and "ICE". If this happens, make sure that `XLIBS` in the makefile is set to "`Xt SM ICE Xext X11`" rather than "`Xt Xext X11`".
- On very old systems (circa gcc version 2.6.3), you may encounter an incompatibility in object formats (a.out vs. ELF) with the XFree86 library. Typically, `ld` complains that some X library is not found, or that many `Xlib` or `Xt` functions are not found in the library (similar to the messages for omitting `SM` and `ICE` from `XLIBS`). Or you get a message when you start Ghostscript that the program or the shared library is an unrecognized format. If this happens, edit your top-level makefile to add the switches "`-b i486-linuxaout`" to both `CFLAGS` and `LDFLAGS`, then "`make clean`" followed by "`make`"). If this doesn't help, or if other strange things happen, contact your Linux supplier or support resource.
- A few of Ghostscript's drivers are multi-threaded. None of them are in the default build. Currently the only ones are the "bmpa" series. These drivers require `libc` version 6 or higher. Most distributions include this, but it may be an issue on very old systems.

#### NeXTSTEP / OpenSTEP

- If you are using a NeXTSTEP version before 3.3, please get a no-cost upgrade (along with Y2K patches) from Apple.
- If '`./configure && make`' fails, then for all NeXTSTEP systems, use `unix-gcc.mak` and make the following changes:
  - In `unix-aux.mak` (and `ugcclib.mak`, if you are using only the library) change the definition of `INCLUDE` to "`INCLUDE=/usr/include/bsd`";
  - in `unix-gcc.mak`:
    - change `CC=gcc` to `CC=cc`;
    - change the definition of `STDLIBS` to only `-lm`;
    - change `SYNC=posync` to `SYNC=nosync`;
    - add `-D_POSIX_SOURCE` to `CFLAGS` and remove `-g`;
    - remove `-Wstrict-prototypes` from `GCFLAGS`, and if you are using NeXTSTEP 3.3 (with gcc 2.5.8), also remove `-Wmissing-declarations`;
  - to the end of `Fontmap.GS` add the line "`/Ohlfs /Courier ;`".
- If you are running the Pencom co-Xist X server (development version), the X headers and libraries are in the default places, so change the makefile definitions of `XINCLUDE` and `XLIBDIRS` to empty strings.

#### SCO Unix/Xenix

- See also "386 Unix" and "System V Unix platforms".
- The standard cc compiler on SCO OpenServer v5 has optimizer bugs. Compile without -O.
- The SCO Unix C compiler apparently can't handle the `P` n macros in `std.h`. If you get strange compilation errors on SCO Unix, ask SCO for a compiler fix.
- Meanwhile, to use gcc with SCO ODT, see `unix-gcc.mak` for the appropriate switch settings.
- Because of a bug in SCO's floating point emulator, gcc 2.3.3 produces code that causes crashes on machines without hardware floating point. Use a different compiler on these machines.
- If you aren't using the X11 driver, you must add `-lsocket` to the value of `EXTRALIBS` to link the date and time functions.
- If you want to use direct frame buffer addressing instead of X Windows, include the relevant frame buffer devices (`$(DD)ega.dev`, `$(DD)vga.dev`, etc.) and change the definition of `EGAVGA` to `$(EGAVGA_SCO)` as indicated in `devs.mak`. Note: this works with SuperVGA displays only for 800x600x16 mode.
- If the display looks "smeared", try recompiling `gdevpcfb.c` with `-O0`.
- If Ghostscript crashes, use the `-q` switch or redirect console output to a file.
- If your compiler accepts both the `-Xt` and `-Xa` switches, use `-Xt`. Even though this causes the compiler to use incorrect rules for computing the result types of "`<<`" and "`>>`", `-Xa` enables optimizations that produce incorrect code.
- For SCO ODT 2.0, in addition to `-D__SVR3` and `-DSYSV`, you need to specify `-Dsco`, `-DUSG`, and `-DMALLOC_0_RETURNS_NULL`. For SCO ODT, you need "`EXTRALIBS=-lX11 -lsocket -lmalloc`", or maybe only `-lsocket` depending on the version), and for SCO ODT 2.0, you must also specify `-lc_s`. For SCO Xenix, you need "`EXTRALIBS=-lmalloc`".
- For SCO OpenServer 5.0.5, add `-L/usr/local/lib` to `LDFLAGS`.
- For all SCO systems, set "`XINCLUDE=`" and "`XLIBDIRS=`".

#### SVR4 Unix

- You may need to set `EXTRALIBS=-lnsl`.
- Do not change `PLATFORM=unix_` to `PLATFORM=sysv_`.
- On SVR4 Unix platforms with dynamic linking, you may need to define `XLIBDIR` as the name of the directory that holds the X Windows libraries. Do not prefix the name with "`-L`".
- For SVR4.0 systems, set `-DSVR4` and `-DSVR4_0` in the makefile; do not set `-DSYSV`. For SVR4.2 (or later) and Solaris 2.n systems, set only `-DSVR4` (not `-DSVR4_0` nor `-DSYSV`).

#### System V Unix platforms

- If you are using a stock System V platform that lacks `rename` and `gettimeofday`, in the makefile change "`PLATFORM=unix_`" to "`PLATFORM=sysv_`".
- You will probably need to change the definition of `INSTALL` from "`install`" to "`/usr/ucb/install`".

#### Unixware

- The standard cc compiler has optimizer bugs. Compile without `-O`.

### Hardware-specific issues

#### Alpha with gcc

- You don't have to use gcc on Alpha systems, because the bundled compiler works.
- The Alpha code generator in gcc 2.7.2.1 is broken. gcc 2.5.8 and 2.6.3 are probably usable. Versions before 2.5.0 are believed not to work. We suggest you use a recent version.

#### H-P Apollo

- You must run the compiler in ANSI-compatible mode (that is, set `AK=`{null string} in the makefile); otherwise it gives incorrect error messages for any function declared as returning a float value.
- The H-P Apollo compiler may not compile Ghostscript correctly. If you get unexpected crashes at run time, use gcc.

#### AT&T 7040 R3

- If Ghostscript crashes on startup, recompile with `-O0` to work around compiler bugs.

#### Convex

- Use `unixansi.mak`. Do not invoke optimization (`-O1`) because the compiler will produce incorrect code.
- Set `CFLAGS` to "`-no -fn -tm c1`".

#### DECStations with Ultrix

- If you get the compiler message "cfe: Fatal: _temp_19086.c: Segmentation violation" or a similar one, try compiling with the `-oldc` switch.
- You may wish to set

  `GS_LIB_DEFAULT=$(gsdatadir):/usr/lib/DPS/outline/decwin:$(gsdatadir)/fonts`

  in the makefile to add the Display PostScript font directory to the font search path.

- Set

  `CFLAGS="-Olimit 2500"`

  to make the optimizer allocate enough table space.

- The Ultrix 4.4 C compiler compiles `gdevm1.c` incorrectly. Insert the following line in the makefile rule for "`gdevm1.$(OBJ)`" (the body of the rule is empty in the standard distribution):

  `$(CCC) -oldc gdevm1.c`

#### H-P RISC workstations

- HP-UX versions before 11.0 do not support POSIX threads. Set `SYNC=nosync` in the makefile before building.
- Ghostscript builds on H-P machines with either GNU gcc or H-P's ANSI-capable `cc`. The minimal, non-ANSI-capable `cc` that shiped with some basic HPUX system does not work. If `cc` on your system doesn't accept the `-Aa` switch, then you need to get the full `cc` or gcc.
- If you use H-P's compiler, be sure you have upgraded to a recent release. Many bizarre symptoms have been reported trying to build Ghostscript with older, buggier compilers, for example:
  - The link step fails with a message about "`max`" not being defined.
  - The build succeeds, but the resulting executable fails to start up, with an error message like "Initializing... Unrecoverable error: typecheck in .registerencoding".
  - The build succeeds, but the resulting executable produces a black background on the first page of output.
- It is reported that On HPUX 9.* you need at least compiler patch PHSS_5723 and dld.sl patch PHSS_5734 to build Ghostscript. (As of late 1997, those patches are long obsolete; the current patches are compiler PHSS_10357 and dld.sl PHSS_11246. It is unknown whether current Ghostscript releases work with compiler/dld.sl versions older than these.)
- On HPUX 10.*, we don't know what combinations of compiler version and switches work. It is reported that On HPUX 10.20, setting "`CC=c89`" and "`CFLAGS=+O3 $(XCFLAGS)`" works, contradicting the information in the next paragraph, but this may be dependent on the specific compiler version.
- In either HPUX version, you need to set "`CC=cc -Aa`" (or use `-Ae` if you prefer), and set "`CFLAGS=-D_HPUX_SOURCE -O $(XCFLAGS)`". Higher levels of optimization than `-O` may work depending on your compiler revision; some users have reported success with `+O3`, some have not.
- Some users have reported needing `-DNOSYSTIME` and `-D_POSIX_SOURCE` in `CFLAGS`, but recent tests do not show these to be necessary.
- If you use gcc, it's a good idea to have a recent release -- at the very least 2.7.2.1 or later.You may be able to get a working executable with an older gcc by removing `-O` from `CFLAGS`.

#### Intergraph Clipper

- Recommended settings are:

  `XCFLAGS=-w -Q -DSYSV -D__SVR3
  EXTRALIBS=-lbsd -lc_s
  CC=acc -knr
  PLATFORM=sysv_`

- You will probably need to change the value of `XLIBS` from "`XLIBS=Xt X11 Xext`" to "`XLIBS=Xt_s X11_s Xext`".

#### MIPS

- There is apparently a bug in older versions of the MIPS C compiler which causes `gxdither.c` to compile incorrectly if optimization is enabled (`-O`). However, this bug is definitely fixed in MipsPRO C version 6.00; with this version, compiling with "`-O2 -mips2`" produces good output.

#### NCR 3550

- With the NCR C Development Toolkit you must use `-O0`.

#### Pyramid MIServer-S

See "AT&T 7040 R3".

#### IBM RS/6000 with AIX

- Many versions of the AIX C compiler have bugs that have prevented Ghostscript from compiling and linking properly. We believe that the current Ghostscript release works around these bugs, and that `unixansi.mak` with `CC=cc` should work.
- You must also edit the makefile (`unixansi.mak`) to change `INSTALL` to `/usr/ucb/install`.
- AIX doesn't use a separate library for multi-thread support: set `STDLIBS=-lm` in the makefile.
- If `-DSYSV` produces a complaint about the functions `index` and `rindex` not being defined, try removing it.
- If the xlc 1.2.1 optimizer runs out of memory, you may need to add `-qmaxmem=4000` to `CFLAGS`.
- A user reports that the AIX C compiler shipped with AIX 3.2.5 compiles Ghostscript only if invoked with "`c89 -D_POSIX_SOURCE`" and without `-O`. On the other hand, another user reports successful compilation using `unix-ansi.mak` and the command line

  `make CC=c89 XCFLAGS="-DOSY_AIX -D_ALL_SOURCE -qnoro -qmaxmem=3000 -bfl" $*`

- Apparently some (but not all) releases of the C library declare the `hypot` function: if the declaration in `math_.h` produces an error message, try removing it.
- The IBM X11R3 server is known to be buggy: use the MIT X server if possible.
- The xlc 1.3.0.x compiler provided in AIX 3.2.5+ definitely will not compile Ghostscript correctly if `-O` is used on all files. A user reports that compiling `z`*`.c`, `gsmatrix.c`, `gxstroke.c` without `-O` is sufficient to produce a working executable:.
- Some installations of AIX 3.2.5 have what appears to be an incorrect or inconsistent version of `libXt.a` in `/usr/lpp/X11/lib`. If linking shows `XtShellStrings` and `XtStrings` as unresolved externals, set "`XLIBDIRS=-L/usr/lpp/X11/lib/R5 -L/usr/lpp/X11/lib`" rather than just "`XLIBDIRS=-L/usr/lpp/X11/lib`".
- Ghostscript has been successfully compiled and runs under AIX 4.3.3 and the IBM C compiler version 5. The following changes were required in unixansi.mak:

  `CC=xlc`
  `XCFLAGS=-qalign=natural`

#### Silicon Graphics

Users have had a lot of problems with the MIPSpro compilers on SGI systems. We recommend using gcc. If you do choose to use the MIPSpro compiler, please read the following carefully.

- To make the optimizer allocate enough table space, set

  `CFLAGS="-Olimit 2500"` (for older compilers)
  `CFLAGS="-OPT:Olimit=2500"` (for newer compilers)

  MIPSpro compiler version 3.19 is "older", and 7.1 is "newer"; we aren't sure at what point in between the latter syntax was introduced.

- With the compiler shipped with Irix 5.2, use the `-ansi` option.
- The SGI C compiler may produce warnings about "Undefined the ANSI standard library defined macro stdin/stdout/stderr". To suppress these warnings, add "`-woff 608`" to the definition of `CFLAGS`.
- The SGI C compiler shipped with Irix 6.1 and 6.2 will not compile `zlib/deflate.c` properly with optimization. Compile this file separately without `-O`.
- With IRIX 6.5.x and the MIPSpro 7.x compilers there have been reports about incorrect output and binaries that cause segmentation faults. Various solutions have been suggested and you may want to try them in this order, until you get a working binary:
  - Compile `idict.c` and `isave.c` separately without optimization after doing a normal compile; then relink.e.g.:

    `cc -OPT:Olimit=2500 -I. -I./obj -o ./obj/idict.o -c ./idict.c`
    `cc -OPT:Olimit=2500 -I. -I./obj -o ./obj/isave.o -c ./isave.c`

  - Set `CFLAGS=` (no optimization).
  - Use only `-O2`. Compiler produces incorrect output with `-O3` or "`-Ofast=ip32 -show`".
  - Irix 6.5.1m with MIPSpro compiler 7.2.1.1m, Irix 6.5.3m with MIPSpro compiler 7.2.1, and probably other 6.5x / 7.2x combinations require compiling with the `-o32` option. Compiling with the (default) `-n32` option produces non-working executables. `-O2` is OK (possibly except for `idict.c`), but not `-O3`.

#### Sun

- The Sun unbundled C compiler (SC1.0) doesn't compile Ghostscript properly with the `-fast` option: Ghostscript core-dumps in `build_gs_font`. With that compiler use `-g`, or use gcc instead.
- The Sun version of `dbx` often gives up with an error message when trying to load Ghostscript. If this happens, use GNU `gdb` instead. (`gdb` is more reliable than `dbx` in other ways as well.)
- A bug in some versions of `zlib` results in an undefined symbol `zmemcmp` when compiling with Sun cc. Use gcc instead.

#### SunOS

- The `tar` program provided with SunOS 4.1.3 may not be able to unpack the archives in the standard Ghostscript distribution. Get a more recent version of `tar`, such as GNU `tar`.
- In SunOS 4.1.[23], you may get undefined symbols `_get_wmShellWidgetClass` and `_get_applicationShellWidgetClass` when linking. Compiling "`-Bstatic -lXmu -Bdynamic`" appears to work for SC1.0. For gcc, try adding `-static` to `CFLAGS`. To solve the problem if you are using OpenWindows 3.0 (X11R4-based Xt), ask Sun for patches 100512-02 and 100573-03.

#### Solaris

- Solaris 2.2 may require setting "`EXTRALIBS=-lsocket`". Solaris 2.3 and later seem to require "`EXTRALIBS=-lnsl -lsocket -lposix4`".
- For Solaris 2.6 (and possibly some other versions), if you set `SHARE_LIBPNG=1`, `SHARE_ZLIB=1`, or `SHARE_JPEG=1`, you may need to set

  `XLDFLAGS=-R /usr/local/`xxx`/lib:/usr/local/lib`

  using the full path names of the relevant directories.

- Solaris 2.n uses `/usr/openwin/share/include` for the X11 libraries rather than `/usr/local/X/include`.
- Solaris 2.n typically has Type 1 fonts in `/usr/openwin/lib/X11/fonts/Type1/outline`.
- For Solaris 2.`n` in the makefile you must change the definition of `INSTALL` from "`install -c`" to "`/usr/ucb/install -c`".
- You may need to set `XLIBDIR` to the directory that holds the X11 libraries, as for other SVR4 systems. Set `-DSVR4` in `CFLAGS`.
- If you are using the SunPRO C compiler, don't use optimization level `-xO3`. On SPARC platforms the compiler hangs; on Intel platforms the generated code is incorrect. With this compiler on Intel, do not use the `-native` flag: floating point computations become unacceptably inaccurate. You can use `-xcg92` (SPARC V8) and `-dalign` for better performance.
- One user reported compiling from source on a Linux NFS mounted volume failed. Compiling from a local volume was the workaround.

#### VAX with Ultrix

- You may wish to set

  `GS_LIB_DEFAULT=$(gsdatadir):/usr/lib/DPS/outline/decwin:$(gsdatadir)/fonts`

  in the makefile to add the Display PostScript font directory to the font search path.

## How to build Ghostscript from source (OS/2 version)

Note: This section was contributed by a user: please e-mail Hermann Ulrichskötter <ulrichsk@t-online.de> if you have questions or problems.

The following instructions are for building with emx 0.9d/Fix2. Be warned that with this version of gcc/emx, compiler optimization flags '-O' or '-O1' will produce non-working output.

- The relevant makefile is `os2.mak` The gcc/emx 0.9b (or later) compiler and IBM `NMAKE.EXE` are required.
- For gcc/emx versions 0.9c and later, the `LINK386` command must include "`$(COMPBASE)\lib\end.lib`"; version 0.9b requires omitting it. The current `os2.mak` file does include this file in the `LINK386` command, so if you are using 0.9b, delete this file reference before building.
- Be sure you are using the standard OS/2 shell, `CMD.EXE`. Some other shells have bugs or differences that cause the makefile not to work.
- Make sure you followed the instructions in "How to unpack the source code".
- If you wish to include support for XFree86, edit the makefile to change BUILD_X11=0 to BUILD_X11=1. XFree86 for OS/2 can be obtained from http://borneo.gmd.de/~veit/os2/xf86os2.html You must use emx 0.9d.

Before compiling or linking, execute `md bin` and `md obj` in the `gs` directory to create the directories for the binaries.

First, build the standard configuration:

- Edit gs/base/os2.mak: find line with 'CO=-O' (Optimizer flag) and edit this line to 'CO=-O2' (-O or -O1 do not work!).
- To start the make process, type `nmake -f .\base\os2.mak`, from the gs-directory.
- One DLL and two EXEs will be produced in `gs/bin`: `gsdll2.dll` (the Ghostscript DLL), `gsos2.exe` (the Ghostscript executable) and `gspmdrv.exe` (the Presentation Manager display driver). All other newly generated files will be produced in `gs/obj`.

Now, if you wish, you can edit OS2.MAK to suit your needs, and then perform `nmake -f .\base\os2.mak clean` and then `nmake -f .\base\os2.mak`.

## How to build Ghostscript from source (OpenVMS version)

The DECC6.2-003 compiler has an optimization problem that may lead to warnings about the "ANSI aliasing rules". DEC (Compaq) can provide a fix for this problem. The DECC6.2-006 compiler apparently does not have the problem.

DEC C runtime library versions 5.5 and newer have an `exit` function that is compatible with all other C systems, but some older ones don't. If you get error messages from VMS when auxiliary programs such as `genarch` or `echogs` finish executing, find the line in stdpre.h that reads

> `/*#define OLD_VMS_C*/`

and remove the `/*` and `*/`, changing it to

> `#define OLD_VMS_C`

Some versions of DEC's X server have bugs that produce broad bands of color where dither patterns should appear, or characters displayed white on top of black rectangles or not displayed at all. If this happens, consult the usage documentation for how to work around X server bugs using X resources; also report the problem to DEC, or whomever supplied your X server.

You may also wish to turn off the use of a backing pixmap with Ghostscript, either to work around X server memory limitations or bugs, or to obtain faster displaying at the expense of no redrawing when a Ghostscript window is restored from an icon or exposed after being occluded by another window. Again, the usage documentation tells how to do this.

You can precompile any Type 1 font into C, then compile and build it into Ghostscript, as described in the fonts documentation. If you do this, then add "`$(PSD)ccfonts.dev`" to `FEATURE_DEVS` in `OPENVMS.MAK`:

> `$ FEATURE_DEVS = "$(PSD)psl3.dev $(PSD)pdf.dev $(PSD)dpsnext.dev $(PSD)ttfont.dev $(PSD)ccfonts.dev"`

Specify the font names with `ccfonts1`:

> `$ ccfonts1 = "Courier Courier_Oblique Courier_Bold Courier_BoldOblique"`

If this makes the line too long, add another line of the same form, such as

> `$ ccfonts1 = "Courier Courier_Oblique Courier_Bold Courier_BoldOblique" $ ccfonts2 = "Times_Roman Times_Italic Times_Bold Times_BoldItalic"`

### Building with GNU make on OpenVMS

Note: GNU make on OpenVMS apparently has bugs that make it stop with an error when building Ghostscript version 5.80 or later. Until further notice, use MMS or MMK for building Ghostscript on OpenVMS. See below for details.

As of Ghostscript version 5.0 you can use GNU make -- with the file `OPENVMS.MAK` and some auxiliary `.COM` files -- to build Ghostscript on OpenVMS. Use the command:

> `make -fopenvms.mak "DECWINDOWS=`[`1.2`]`"`

That is, specify either "`1.2`" or nothing (blank) as the value of `DECWINDOWS`. In Europe and other parts of the world where ISO standard paper sizes are used, append "`A4_PAPER=1`" to that line to make A4 the default paper size at run time.

If you haven't a prebuilt copy of GNU make, you'll have to build it yourself; as of Version 3.76 (but not earlier) it is said to build properly under OpenVMS on both VAX and Alpha. The kit is available at the Free Software Foundation's ftp site and its mirrors. See

> ftp://ftp.gnu.org/pub/gnu/

### Building with MMK or MMS on OpenVMS

As of Ghostscript version 5.68 you can use MMK or MMS to build Ghostscript on OpenVMS. MMS is a utility available from Compaq (Digital); MMK is a free program largely compatible with MMS.

Building Ghostscript with MMK or MMS uses the file `OPENVMS.MMK` and some auxiliary `.COM` files. To build Ghostscript with MMK or MMS, use the command:

> `###/descrip=[.src]openvms.mmk/macro=("DECWINDOWS1_2=`{`0`,`1`}`")`

where `###` is either `mmk` or `mms`.

Specify `DECWINDOWS1_2=1` for DECWINDOWS 1.2, `DECWINDOWS1_2=0` for other DECWINDOWS versions. In Europe and other parts of the world where ISO standard paper sizes are used, add `,"A4_PAPER=1"` just before the final closing parenthesis to make A4 the default paper size at run time.

To download MMK (source code, and VAX and Alpha executables), visit

> http://www.madgoat.com/mmk.html

## Other environments

### Environments lacking multi-threading

All environments mentioned here by name have multi-threading capability. However, if your environment doesn't, you can remove all need for multi-threading by setting `SYNC=nosync` in the top-level makefile. Note that you will not be able to use any so-called "async" drivers (drivers that overlap interpretation and rasterization) if you do this. No such drivers are in the `DEVICE_DEVS*` lists of any makefile that we distribute.

### Plan 9

Use `unix-gcc.mak`, editing it to define

> `CC=cc GCFLAGS=-D_BSD_EXTENSION -DPlan9`

You will also probably have to edit many path names.

### QNX

David J. Hawkey Jr. writes that he built Ghostscript 4.03 and 5.0 under QNX 4.22, 4.23, and 4.24 using Watcom C 10.6 and that "it works quite well, after figuring out the `/etc/config/lpsrvr` directives, except for color printing to my HP DeskJet some-number-or-another". Here is a concise presentation of changes based on the ones he made for Ghostscript 4.03.

`unixansi.mak`

  Original lines |  | Change to
  `INSTALL = install -c INSTALL_PROGRAM = $(INSTALL) -m 755 INSTALL_DATA = $(INSTALL) -m 644` |  | `INSTALL = cp INSTALL_PROGRAM = $(INSTALL) INSTALL_DATA = $(INSTALL)`
  `datadir = $(prefix)/share` |  | `datadir = $(prefix)/lib`
  `CFLAGS_STANDARD=-O` |  | `CFLAGS_STANDARD=-Otx -zp1 -mf`
  `LDFLAGS=$(XLDFLAGS)` |  | `LDFLAGS=-mf -N32k $(XLDFLAGS)`
  `EXTRALIBS=` |  | `EXTRALIBS=-lXqnx_s -lsocket`
  `XINCLUDE=-I/usr/local/X/include` |  | `#XINCLUDE=-I/usr/local/X/include`
  `XLIBDIRS=-L/usr/local/X/lib XLIBDIR= XLIBS=Xt Xext X11` |  | `#XLIBDIRS=-L/usr/local/X/lib #XLIBDIR= XLIBS=Xt_s Xext X11_s`

`gp_unifs.c`
  After the line

  > `#include <sys/param.h>`

  add these lines:

  > `#if defined(__QNX__)
  > #include <unix.h>
  > #endif`

`gp_unix.c`
  After the line

  > `#include "time.h"`

  add these lines:

  > `#if defined(__QNX__)
  > #include <sys/time.h>
  > #endif`

`time_.h`
  Modify the line beginning

  > `# if defined(Plan9) ||`

  to begin

  > `# if defined(__QNX__) || defined(Plan9) ||`

`/etc/config/lpsrvr`
  Here is Hawkey's `lpsrvr` as an example.

  >     # lpsrvr
  >     #
  >     # Defines the print queues and their devices
  >     #
  >     # Queues

  >     # ink-jet: Ghostscript interpreter for mono DeskJet - LaserJet works
  >     #          better than DeskJet!

  >     [ij-monops]
  >             ta=lpt1
  >             co=/usr/local/bin/gs -q -sDEVICE=laserjet -sOutputFile=- -dNOPAUSE $(spfile) quit.ps | cat > $(device)

  >     # Devices

  >     [-lpt1]
  >             dv=/dev/par1

  >     [-lpt2]
  >             dv=/dev/par2

## How to build Ghostscript with UFST

Note: This section is only for customers who have a Monotype Imaging UFST license. Other users please skip this section.

Ghostscript sources do not include UFST sources. You need to obtain them separately. The Ghostscript distributed source include only some source modules that provide a bridge to UFST.

Ghostscript makefiles do not include any script for building UFST libraries automatically. If you received the UFST source from Artifex, for Unix/Linux type platforms, please refer to the "readme.artifex" text file in the top UFST directory.

On Windows with Microsoft Visual Studio©, with UFST 5.x and 6.x, you can use the "demo" solution supplied by Monotype Imaging and build the subprojects "fco_lib", "if_lib", "ps_lib" and "tt_lib", and those will create the UFST libraries that the Ghostscript build system requires.

For other systems, please refer to UFST manual how to build on them.

UFST object libraries must be built before building Ghostscript with the UFST bridge.

To build Ghostscript with UFST, specify additional options for "make":

`UFST_BRIDGE=1`
  forces the UFST bridge to build.
`UFST_ROOT=path`
  specifies the path to UFST root directory or folder.
`UFST_CFLAGS=options`
  specifies C compiler options for UFST library. Refer to UFST manual for information about them.
`UFST_LIB_EXT=extension`
  sets the file name extension for object libraries. You must use the appropriate one for your platform and linker.

An example for Unix/GCC :

> `UFST_BRIDGE=1 UFST_ROOT=../ufst UFST_CFLAGS=-DGCCx86 UFST_LIB_EXT=.a`

Starting with Ghostscript 9.x (Summer 2010), the above options are conveniently inserted in the `Makefile` with (this also automatically disable the freetype bridge):

> `./configure --with-ufst=../ufst`

For Windows/MSVC you need only specify UFST_ROOT. msvc32.mak sets the other options automatically.

## How to build Ghostscript without FreeType

This configuration is now deprecated and essentially unsupported, and this section (along with this option) will be removed in a future release. To return a build to the pre-Freetype font scaler with the autoconf build (Linux, MacOS X, Solaris, etc.), pass the `--disable-freetype` to the configure script.

For Windows/MSVC you need to define FT_BRIGE=0 on the nmake command line. For example:

>     nmake -f psi\msvc32.mak FT_BRIDGE=0

In a prebuilt binary (that is, one with FAPI/Freetype enabled by default, you can still revert to the AFS at run time by passing Ghostscript the `-dDisableFAPI=true` to revert to the older behavior, just in case a serious regression happens that cannot be resolved in a timely manner. Again, it is intended that this option will be removed in a future release.

Copyright © 2000-2006 Artifex Software, Inc. All rights reserved.

This software is provided AS-IS with no warranty, either express or implied. This software is distributed under license and may not be copied, modified or distributed except as expressly authorized under the terms of that license. Refer to licensing information at http://www.artifex.com/ or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.

Ghostscript version 9.15, 22 September 2014