ref: f2cfee358f329519e913a20142d96b1e0029633c
dir: /sys/src/cmd/gs/doc/Make.htm/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>How to build Ghostscript from source code</title> <!-- $Id: Make.htm,v 1.90 2005/10/20 19:46:23 ray Exp $ --> <!-- Originally: make.txt --> <link rel="stylesheet" type="text/css" href="gs.css" title="Ghostscript Style"> </head> <body> <!-- [1.0 begin visible header] ============================================ --> <!-- [1.1 begin headline] ================================================== --> <h1>How to build Ghostscript from source code</h1> <!-- [1.1 end headline] ==================================================== --> <!-- [1.2 begin table of contents] ========================================= --> <h2>Table of contents</h2> <blockquote><ul> <li><a href="#General_overview">General overview</a> <li><a href="#Acquiring">How to acquire the source code</a> <ul> <li><a href="#Ghostscript_source">Ghostscript source code</a> <li><a href="#Third-party_libraries">Third-party library source code</a> </ul> <li><a href="#Unpack">How to unpack the source code</a> <ul> <li><a href="#Tarfiles">How to unpack compressed tar files generally</a> <li><a href="#Zipfiles">How to unpack zip files generally</a> <li><a href="#Unpack_Ghostscript">How to unpack Ghostscript itself</a> <li><a href="#Unpack_libraries">How to unpack the third-party libraries</a> </ul> <li><a href="#Bug_check">How to check for post-release bug fixes</a> <li><a href="#Makefile_overview">How to prepare the makefiles</a> <ul> <li><a href="#Preparing_makefiles">Changes for your environment</a> <li><a href="#Features_and_devices">Selecting features and devices</a> <ul> <li><a href="#Precompiled_data">Precompiled run-time data</a> <li><a href="#GNU_readline">GNU readline</a> </ul> <li><a href="#Makefile_setup">Setting up "makefile"</a> <li><a href="#Invoke_make">Invoking "make"</a> <li><a href="#Cross-compiling">Cross-compiling</a> </ul> <li><a href="#PC_build">How to build Ghostscript from source (PC version)</a> <ul> <li><a href="#Borland_build">Borland/Inprise environment</a> <li><a href="#Microsoft_build">Microsoft environment</a> <li><a href="#Microsoft_build_64">Microsoft environment 64-bit</a> <li><a href="#Self-extracting_executables">Making self-extracting executables</a> <li><a href="#Watcom_build">Watcom environment</a> <li><a href="#Cygwin32_build">Cygwin32 gcc</a> <li><a href="#IntelWin32_build">Intel C/C++ compiler</a> </ul> <li><a href="#Mac_build">How to build Ghostscript from source (MacOS version)</a> <ul> <li><a href="#MacOS">Traditional MacOS</a> <li><a href="#MacOSX">MacOS X</a> </ul> <li><a href="#Unix_build">How to build Ghostscript from source (Unix version)</a> <ul> <li><a href="#Multi_architecture_makefile">The multi-architecture makefile</a> <li><a href="#UNIX_makefile">Setting up "makefile"</a> <li><a href="#Shared_object">Shared object</a> <li><a href="#Tool_specific_issues">Tool-specific issues</a> <ul> <li><a href="#gcc_27x">gcc 2.7.*</a> <li><a href="#GNU_make">GNU make</a> </ul> <li><a href="#OS_specific_issues">OS-specific issues</a> <ul> <li><a href="#386_Unix">386 Unix</a> <li><a href="#BSDI">BSDI</a> <li><a href="#Digital_Unix">Digital Unix (Alpha)</a> <li><a href="#Linux">Linux</a> <li><a href="#NeXTSTEP">NeXTSTEP / OpenSTEP</a> <li><a href="#SCO">SCO Unix/Xenix</a> <li><a href="#SVR4">SVR4 Unix</a> <li><a href="#System_V">System V Unix platforms</a> <li><a href="#Unixware">Unixware</a> </ul> <li><a href="#Hardware_specific_issues">Hardware-specific issues</a> <ul> <li><a href="#Alpha_with_gcc">Alpha with gcc</a> <li><a href="#Apollo">H-P Apollo</a> <li><a href="#ATT_7040">AT&T 7040 R3</a> <li><a href="#Convex">Convex</a> <li><a href="#DECStations">DECStations with Ultrix</a> <li><a href="#HP_RISC">H-P RISC workstations</a> <li><a href="#Intergraph">Intergraph Clipper</a> <li><a href="#MIPS">MIPS</a> <li><a href="#NCR_3550">NCR 3550</a> <li><a href="#Pyramid">Pyramid MIServer-S</a> <li><a href="#RS6000">IBM RS/6000 with AIX</a> <li><a href="#Silicon_Graphics">Silicon Graphics</a> <li><a href="#Sun">Sun</a> <li><a href="#SunOS">SunOS</a> <li><a href="#Solaris">Solaris</a> <li><a href="#VAX_Ultrix">VAX with Ultrix</a> </ul> </ul> <li><a href="#OS2_build">How to build Ghostscript from source (OS/2 version)</a> <li><a href="#VMS_build">How to build Ghostscript from source (OpenVMS version)</a> <ul> <li><a href="#GNU_make_VMS">Building with GNU make on OpenVMS</a> <li><a href="#MMK_MMS_VMS">Building with MMK or MMS on OpenVMS</a> </ul> <li><a href="#Other_environments">Other environments</a> <ul> <li><a href="#No_multi_thread">Environments lacking multi-threading</a> <li><a href="#Plan_9">Plan 9</a> <li><a href="#QNX">QNX</a> </ul> <li><a href="#UFST_build">How to build Ghostscript with UFST</a> <li><a href="#FT_build">How to build Ghostscript with Free Type</a> </ul></blockquote> <!-- [1.2 end table of contents] =========================================== --> <!-- [1.3 begin hint] ====================================================== --> <p>For other information, see the <a href="Readme.htm">Ghostscript overview</a> and the instructions on how to <a href="Install.htm">install Ghostscript</a>. <!-- [1.3 end hint] ======================================================== --> <hr> <!-- [1.0 end visible header] ============================================== --> <!-- [2.0 begin contents] ================================================== --> <h2><a name="General_overview"></a>General overview</h2> <p> This document describes how to build a Ghostscript executable from source code. There are four major steps to building Ghostscript: <ol> <li>Acquire the compressed archive files of source code for Ghostscript and the required third-party libraries. <li>Unpack the archive files into the Ghostscript directory and correctly named subdirectories. <li>Configure the build to match your system and desired configuration options. <li>Invoke "<b><tt>make</tt></b>" to build the software. </ol> <p> 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 <a href="Install.htm">installation instructions</a>. <hr> <h2><a name="Acquiring"></a>How to acquire the source code</h2> <p> Building Ghostscript requires the Ghostscript source code itself, and also the source code for some third-party libraries that Ghostscript uses. <h3><a name="Ghostscript_source"></a>Ghostscript source code</h3> <p><a name="Authoritative_distribution_site"></a> There are two kinds of Ghostscript distributions available, called "AFPL Ghostscript" and "GPL Ghostscript"; the distinction between them is explained in the <a href="Commprod.htm">conditions for distributing Ghostscript</a>. The authoritative distribution site for AFPL Ghostscript is <blockquote> <a href="ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/" class="offsite">ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/</a>gs### </blockquote> <p> where "###" is the unpunctuated version number. GPL Ghostscript is available from the same site at <blockquote> <a href="ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/" class="offsite">ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/</a> </blockquote> <p> Ghostscript source code is packaged in two different formats: gzip-compressed tar files (*<b><tt>.tar.gz</tt></b>) and zip files (*<b><tt>.zip</tt></b>). For all versions there are gzip-compressed tar files: <blockquote> <b><tt>ghostscript-</tt></b>#.##<b><tt>.tar.gz</tt></b><br> <b><tt>ghostscript-fonts-std-</tt></b>#.##<b><tt>.tar.gz</tt></b><br> <b><tt>ghostscript-fonts-other-</tt></b>#.##<b><tt>.tar.gz</tt></b> </blockquote> <p>For recent versions of Ghostscript there are also zip files <blockquote> <b><tt>gs</tt></b>###<b><tt>src.zip</tt></b><br> <b><tt>gs</tt></b>###<b><tt>w32.exe</tt></b> </blockquote> <p> ("#.##" 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 <a href="#Unpack">unpacking the source code</a>. <h3><a name="Third-party_libraries"></a>Third-party library source code</h3> <p> To build Ghostscript you need the source code for the <a href="http://www.ijg.org/">Independent JPEG Group</a> (IJG) library, the <a href="http://www.libpng.org/pub/png/">Portable Network Graphics</a> (PNG) library, and the <a href="http://www.gzip.org/zlib/">zlib</a> compression and decompression library. The default build also expects source for the <a href="http://jbig2dec.sourceforge.net">jbig2dec</a> JBIG2 decompression library. <p> On Windows and MacOS, the .zip and .sit source archives include the appropriate source versions of these libraries, so no additional downloads are necessary. Unix tarballs may also contain appropriate library source; the configure script will tell you if it cannot find the appropriate libraries. <p> Here are authoritative distribution points for these libraries, should you need to obtain the source yourself. As elsewhere, "#" is used for version numbers. The JPEG source code is quite stable, so the reference here includes the latest version number. Versions of the zlib source are not compatible between the 1.1.x and 1.2.x series; if you wish to compile in zlib (as opposed to linking to a separately build dynamic library) you must use a 1.2.x version. <blockquote><table cellpadding=0 cellspacing=0> <tr><th colspan=3 bgcolor="#CCCC00"><hr><font size="+1">Third-party libraries: authoritative sources</font><hr> <tr> <td valign=top>JPEG <td> <td><a href="ftp://ftp.uu.net/graphics/jpeg/" class="offsite">ftp://ftp.uu.net/graphics/jpeg/</a><a href="ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz" class="offsite">jpegsrc.v6b.tar.gz</a><br> <a href="ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/" class="offsite">ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/</a><a href="ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/jpegsr6b.zip">jpegsr6b.zip</a> <tr> <td valign=top>PNG <td> <td><a href="http://www.libpng.org/pub/png/src/" class="offsite">http://www.libpng.org/pub/png/src/</a>libpng-#.#.#.tar.gz<br> <a href="http://www.libpng.org/pub/png/src/" class="offsite">http://www.libpng.org/pub/png/src/</a>lpng###.zip<br> <a href="ftp://swrinde.nde.swri.edu/pub/png/src/" class="offsite">ftp://swrinde.nde.swri.edu/pub/png/src/</a>libpng-#.#.#.tar.gz<br> <a href="ftp://swrinde.nde.swri.edu/pub/png/src/" class="offsite">ftp://swrinde.nde.swri.edu/pub/png/src/</a>lpng###.zip <tr> <td valign=top>zlib (latest) <td> <td> <a href="http://www.gzip.org/zlib/zlib-1.2.1.tar.gz" class="offsite">http://www.gzip.org/zlib/zlib-1.2.1.tar.gz</a><br> <a href="http://www.gzip.org/zlib/zlib121.zip" class="offsite">http://www.gzip.org/zlib/zlib121.zip</a><br> See the <a href="http://www.gzip.org/zlib/">official website</a> for a list of mirrors. <tr> <td valign=top>jbig2dec <td> <td> <a href="http://sourceforge.net/project/showfiles.php?group_id=28301" class="offsite">http://sourceforge.net/project/showfiles.php?group_id=28301</a><br> </table></blockquote> <p> On DOS or 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 <b><em>its own version number</em></b> that has <b><em>nothing to do with Ghostscript's version number</em></b>; 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. <hr> <h2><a name="Unpack"></a>How to unpack the source code</h2> <p> 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. <h3><a name="Tarfiles"></a>How to unpack compressed tar files generally</h3> <p> Tar (<b><tt>.tar</tt></b>) files are the <em>de facto</em> standard for archiving files on Unix (every Unix system has the <b><tt>tar</tt></b> 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 <b><tt>gzip</tt></b>, which adds the suffix "<b><tt>.gz</tt></b>" to the file name, giving "<b><tt>.tar.gz</tt></b>". <p> To unpack a compressed tar file <b><tt>MyArchive.tar.gz</tt></b> 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: <blockquote> <b><tt>gzip -d MyArchive.tar.gz</tt></b> <br><b><tt>tar -xf MyArchive.tar</tt></b> </blockquote> <p> or in a pipeline: <blockquote> <b><tt>gzip -d -c MyArchive.tar.gz | tar -xf -</tt></b> </blockquote> <p> or, if you have a program like GNU <b><tt>tar</tt></b> that can handle compressed tar files, with a single command: <blockquote> <b><tt>tar -zxf MyArchive.tar.gz</tt></b> </blockquote> <p> The <b><tt>tar</tt></b> program automatically preserves directory structure in extracting files. The Ghostscript source archive puts all files under a directory <b><tt>gs</tt></b>#.##, so using <b><tt>tar</tt></b> 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 <b><em>parent</em></b> of the gs directory <b><em>before</em></b> unpacking the files. If a subdirectory doesn't already exist, <b><tt>tar</tt></b> creates it. <p> 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 <ul> <li>set the program's options to "Use folder names" or the equivalent, and <li>check that it is extracting files into the right place. </ul> <h3><a name="Zipfiles"></a>How to unpack zip files generally</h3> <p> Zip files are the <em>de facto</em> 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. <p> One common 16-bit DOS program is <b><tt>pkunzip</tt></b>, which comes in the <b><tt>pkzip</tt></b> package. If you use this, you should ensure that you have at least version 2.04g, because with its <b><tt>-d</tt></b> switch, that version of <b><tt>pkunzip</tt></b> 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 <b><tt>unzip</tt></b>: <blockquote> <a href="http://www.info-zip.org/pub/infozip/UnZip.html" class="offsite">http://www.info-zip.org/pub/infozip/UnZip.html</a> </blockquote> <p> Unlike <b><tt>pkunzip</tt></b>, InfoZIP <b><tt>unzip</tt></b> automatically preserves the directory structure of extracted files. So if you have a zip archive <b><tt>MyArchive.zip</tt></b>: <blockquote><table cellpadding=0 cellspacing=0> <tr><th colspan=3 bgcolor="#CCCC00"><hr><font size="+1">Extracting zipped files</font><hr> <tr valign=bottom> <th align=left>Command <td> <th align=left>Preserves directory structure <tr> <td colspan=3><hr> <tr valign=top> <td><b><tt>pkunzip MyArchive.zip</tt></b> <td> <td>Does <b><em>NOT</em></b> <tr valign=top> <td><b><tt>pkunzip -d MyArchive.zip</tt></b> <td> <td><b><em>DOES</em></b> (note the <b><tt>-d</tt></b> switch) <tr valign=top> <td><b><tt>unzip MyArchive.zip</tt></b> <td> <td><b><em>DOES</em></b> </table></blockquote> <p> As with the compressed tar files, make sure you're positioned in the <b><em>parent</em></b> of the gs directory <b><em>before</em></b> unpacking the files. If a subdirectory doesn't already exist, <b><tt>zip</tt></b> or <b><tt>pkunzip -d</tt></b> creates it. <h3><a name="Unpack_Ghostscript"></a>How to unpack Ghostscript itself</h3> <p> At this point you have <a href="#Acquiring">acquired all the source code</a> and are ready to unpack it according to the preceding guidelines for <a href="#Tarfiles">tar files</a> or <a href="#Zipfiles">zip files</a>. To unpack the Ghostscript source, make the <b><em>parent</em></b> of the (new) gs directory the current directory. <blockquote><table cellpadding=0 cellspacing=0> <tr> <th align=left valign=top>2-step: <td> <td><b><tt>gzip -d ghostscript-</tt></b>#.##<b><tt>.tar.gz</tt></b><br><b><tt>tar -xf ghostscript-</tt></b>#.##<b><tt>.tar</tt></b> <tr><td> <tr> <th align=left valign=top>Pipe: <td> <td><b><tt>gzip -d -c ghostscript-</tt></b>#.##<b><tt>.tar.gz | tar -xf -</tt></b> <tr><td> <tr> <th align=left valign=top>GNU <b><tt>tar</tt></b>: <td> <td><b><tt>tar -zxf ghostscript-</tt></b>#.##<b><tt>.tar.gz</tt></b> <tr><td> <tr> <th align=left valign=top><b><tt>pkunzip</tt></b>: <td> <td><b><tt>pkunzip -d gs</tt></b>###<b><tt>sr1.zip</tt></b><br><b><tt>pkunzip -d gs</tt></b>###<b><tt>sr2.zip</tt></b><br>... <tr><td> <tr> <th align=left valign=top><tt>unzip</tt>: <td> <td><b><tt>unzip gs</tt></b>###<b><tt>src.zip</tt></b> </table></blockquote> <p> All the Ghostscript source files are now in subdirectories of the gs directory. <blockquote><table cellpadding=0 cellspacing=0> <tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1">Source subdirectories</font><hr> <tr> <th valign=bottom align=left>Subdirectory <td> <th valign=bottom align=left>Contents <tr> <td colspan=5><hr> <tr> <td><b><tt>src/</tt></b> <td> <td>C source code and makefiles <tr> <td><b><tt>lib/</tt></b> <td> <td>PostScript files and scripts used when running Ghostscript <tr> <td><b><tt>doc/</tt></b> <td> <td>Documentation <tr> <td><b><tt>man/</tt></b> <td> <td>Unix <b><tt>man</tt></b> pages <tr> <td><b><tt>examples/</tt></b> <td> <td>Sample PostScript files </table></blockquote> <h3><a name="Unpack_libraries"></a>How to unpack the third-party libraries</h3> <p> The Ghostscript makefiles expect to find the JPEG, PNG, and zlib source code in specific subdirectories of the <b><tt>gs</tt></b> directory, and this means you must pay careful attention to unpacking the source code for these packages. Use the same method for all of them, no matter how they're packaged: <ol> <li>Make the gs directory current. <li>Unpack the archive file, creating a subdirectory (which will include a version number). <li>Whatever the subdirectory's original name, rename it to the versionless name shown just below. </ol> <p> If you're uncertain how to unpack an archive, review the sections on <a href="#Tarfiles">compressed tar files</a> and <a href="#Zipfiles">zip files</a>. <blockquote><table cellpadding=0 cellspacing=0> <tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1">3d-party software subdirectories</font><hr> <tr> <th valign=bottom align=left>Package <td> <th valign=bottom align=left>Possible<br>original name <td> <th valign=bottom align=left>Rename to <tr> <td colspan=5><hr> <tr> <td>JPEG <td> <td><b><tt>./jpeg-6b</tt></b> <td> <td><b><tt>./jpeg</tt></b> <tr> <td>PNG <td> <td><b><tt>./libpng-</tt></b>#.## <td> <td><b><tt>./libpng</tt></b> <tr> <td>zlib <td> <td><b><tt>./zlib-</tt></b>#.#.# <td> <td><b><tt>./zlib</tt></b> </table></blockquote> <hr> <h2><a name="Bug_check"></a>How to check for post-release bug fixes</h2> <p> Bug information and fixes are tracked on Ghostscript Bugzilla. For more information, please visit <blockquote> <a href="http://bugs.ghostscript.com"> http://bugs.ghostscript.com</a> </blockquote> <hr> <h2><a name="Makefile_overview"></a>How to prepare the makefiles</h2> <p> 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. <p> 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: <blockquote><pre> ./configure </blockquote> 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 <a href="#Invoke_make">invoking make</a> below. Also, many common configuration options (like install location) can be set through options to the configure script. Type '<tt>./configure --help</tt>' for a complete listing. Note that the configuration option is only available with the unix .tar distributions of the source. <p> Note that if you're building Ghostscript from development source out of a repository instead of from a released source package, you should run '<tt>./autogen.sh</tt>' instead of <tt>./configure.</tt> This script takes all the same options that configure does. <p> 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. <blockquote><a name="Platform-specific_makefiles"></a><table cellpadding=0 cellspacing=0> <tr><th colspan=3 bgcolor="#CCCC00"><hr><font size="+1">Platform-specific makefiles</font><hr> <tr> <th align=left>Makefile <td> <th align=left>Used for <tr> <td colspan=3><hr> <tr> <td><b><tt>Makefile.in</tt></b> <td> <td>Template makefile for the autoconf build <tr> <td><b><tt>bcwin32.mak</tt></b> <td> <td>MS Windows with Borland/Inprise compilers <tr> <td><b><tt>msvc32.mak</tt></b> <td> <td>MS Windows with Microsoft Visual C++ version 4 to 7. <tr> <td><b><tt>openvms.mak</tt></b> <td> <td>OpenVMS <tr> <td><b><tt>os2.mak</tt></b> <td> <td>OS/2 with the gcc/emx compiler <tr> <td><b><tt>unix-gcc.mak</tt></b> <td> <td>Unix with gcc <tr> <td><b><tt>unixansi.mak</tt></b> <td> <td>Unix with ANSI C compilers other than gcc <tr> <td><b><tt>watcw32.mak</tt></b> <td> <td>MS Windows with Watcom compilers <tr> <td> <tr><th colspan=3 bgcolor="#CCCC00"><hr><font size="+1">Platform-independent makefiles</font><hr> <tr> <td><b><tt>contrib.mak</tt></b> <td> <td>Contributed device drivers <tr> <td><b><tt>devs.mak</tt></b> <td> <td>Maintained device drivers <tr> <td><b><tt>gs.mak</tt></b> <td> <td>Documentation and miscellany <tr> <td><b><tt>icclib.mak</tt></b> <td> <td>ICC color correction library <tr> <td><b><tt>ijs.mak</tt></b> <td> <td>IJS raster driver library <tr> <td><b><tt>int.mak</tt></b> <td> <td>Main makefile for the PostScript & PDF interpreter <tr> <td><b><tt>jpeg.mak</tt></b> <td> <td>JPEG library <tr> <td><b><tt>lib.mak</tt></b> <td> <td>Graphics engine <tr> <td><b><tt>libpng.mak</tt></b> <td> <td>PNG library <tr> <td><b><tt>version.mak</tt></b> <td> <td>Version and release date <tr> <td><b><tt>zlib.mak</tt></b> <td> <td>zlib library </table></blockquote> <p> 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. <h3><a name="Preparing_makefiles"></a>Changes for your environment</h3> <p> You must edit the platform-specific makefile to change any of these: <ul> <li>The name of the makefile itself (<b><tt>MAKEFILE</tt></b> macro) <li>The locations to install Ghostscript files (<b><tt>prefix</tt></b> etc.) <li>The default search paths for the initialization and font files (<b><tt>GS_LIB_DEFAULT</tt></b> macro) <li>The debugging options (<b><tt>DEBUG</tt></b> and <b><tt>TDEBUG</tt></b> macros) <li>Which optional features to include (<b><tt>FEATURE_DEVS</tt></b>) <li>Which device drivers to include (<b><tt>DEVICE_DEVS</tt></b> and <b><tt>DEVICE_DEVS</tt></b>{<em>1--20</em>} macros) <li>Default resolution parameters for some printer drivers (<b><tt>devs.mak</tt></b> or <b><tt>contrib.mak</tt></b>, whichever defines the driver) </ul> <p> The <a href="#Platform-specific_makefiles">platform-specific makefiles</a> include comments describing all these except the <b><tt>DEVICE_DEVS</tt></b> options. These are described in <b><tt>devs.mak</tt></b> and <b><tt>contrib.mak</tt></b>, even though the file that must be edited to select them is the <a href="#Platform-specific_makefiles">platform-specific makefile</a>. Check also the <b><tt>JVERSION</tt></b> and <b><tt>PVERSION</tt></b> macros in the platform-specific makefile, and adjust them if they don't match the JPEG and PNG library versions you're using: see <b><tt>jpeg.mak</tt></b> and <b><tt>libpng.mak</tt></b> for more information. <p> 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. <h3><a name="Features_and_devices"></a>Selecting features and devices</h3> <p> 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 <b><tt>gs.mak</tt></b>, and the complete list of drivers in comments at the beginning of <b><tt>devs.mak</tt></b> and <b><tt>contrib.mak</tt></b>. To find what devices a platform-specific makefile selects to include in the executable, look in it for all lines of the form <blockquote> <b><tt>FEATURE_DEVS=</tt></b><em>{list of features}</em><br> <b><tt>DEVICE_DEVS</tt></b>*<b><tt>=</tt></b><em>{list of devices}</em> </blockquote> <p> For example, if the makefile has <blockquote><b><tt> FEATURE_DEVS=$(PSD)level2.dev </tt></b></blockquote> <p> indicating that only the PostScript Level 2 facilities should be included, you might make it <blockquote><b><tt> FEATURE_DEVS=$(PSD)level2.dev $(PSD)pdf.dev </tt></b></blockquote> <p> to add the ability to interpret PDF files. (In fact, <b><tt>FEATURE_DEVS</tt></b> in the current Unix makefiles already includes <b><tt>$(PSD)pdf.dev</tt></b>.) The Unix makefile also defines <blockquote><b><tt> DEVICE_DEVS=$(DD)x11.dev </tt></b></blockquote> <p> 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. <p> You may edit the <b><tt>FEATURE_DEVS</tt></b> line to select or omit any of the features listed near the beginning of <b><tt>gs.mak</tt></b>, and the <b><tt>DEVICE_DEVS</tt></b>* lines to select or omit any of the device drivers listed near the beginning of <b><tt>devs.mak</tt></b> and <b><tt>contrib.mak</tt></b>. The first device listed in the definition of <b><tt>DEVICE_DEVS</tt></b> becomes the default device for this executable; see the usage documentation for <a href="Use.htm#Output_device">how to select an output device</a> at run time using the <a href="Use.htm#DEVICE_switch"><b><tt>-sDEVICE=</tt></b></a> switch. If you can't fit all the devices on a single line, you may add lines defining <blockquote> <b><tt>DEVICE_DEVS1=$(DD)</tt></b><em>{dev11}</em><b><tt>.dev</tt></b> ... <b><tt>$(DD)</tt></b><em>{dev1n}</em><b><tt>.dev</tt></b> <br><b><tt>DEVICE_DEVS2=$(DD)</tt></b><em>{dev21}</em><b><tt>.dev</tt></b> ... <b><tt>$(DD)</tt></b><em>{dev2n}</em><b><tt>.dev</tt></b> </blockquote> <p> etc., up to <b><tt>DEVICE_DEVS15</tt></b>. Don't use continuation lines -- on some platforms they don't work. <p> Note that if you want to include a driver named <em>xxx</em>, you must put <b><tt>$(DD)</tt></b><em>xxx</em><b><tt>.dev</tt></b> in <b><tt>DEVICE_DEVS</tt></b>*. 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 <b><tt>$(PSD)</tt></b><em>xxx</em><b><tt>.dev</tt></b>. 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 <b><tt>$(GLD)</tt></b><em>xxx</em><b><tt>.dev</tt></b>. <h4><a name="Precompiled_data"></a>Precompiled run-time data</h4> <p> 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. <p> To compile the initialization files (<b><tt>lib/gs_init.ps</tt></b>, etc.) into the executable, change the <b><tt>0</tt></b> to a <b><tt>1</tt></b> in the line <blockquote><b><tt> COMPILE_INITS=0 </tt></b></blockquote> <p> Compiled initialization includes the default font map. It is used only if Ghostscript cannot find or open the default font map file at run time. <p> To compile fonts into the executable, see <a href="Fonts.htm#Precompiling">Precompiling fonts</a>. <p> To compile threshold-array halftones into the executable, see the "Compiled halftone" section of <b><tt>int.mak</tt></b> for a sample makefile fragment, <b><tt>genht.c</tt></b> for the syntax of halftone data files, and <b><tt>lib/ht_ccsto.ps</tt></b> 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. <h4><a name="GNU_readline"></a>GNU readline</h4> <p> 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 <em>intended</em> 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 <em>distribution</em> 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. <p> 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. <p> The first Ghostscript distribution to include GPL readline support was GNU Ghostscript 6.0. Support has unfortunately been spotty since then. <p> 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. <p> 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 <a href="mailto:gnu@gnu.org">gnu@gnu.org</a>, and/or artofcode LLC, copyright holder of Ghostscript, at <a href="mailto:raph@artofcode.com">raph@artofcode.com</a>. <h3><a name="Makefile_setup"></a>Setting up "makefile"</h3> <p> After going through the steps just described to <a href="#Unpack">unpack the sources</a>, configure the build and make any desired <a href="#Preparing_makefiles">changes to the makefiles</a>, and unpack or create links to the <a href="#Unpack_libraries">third party libraries</a>, as the final step in preparing to build Ghostscript you must usually associate the name "<b><tt>makefile</tt></b>" with the correct makefile for your environment so the <b><tt>make</tt></b> command can find it. See the section on your particular platform for how to do that if necessary. <h3><a name="Invoke_make"></a>Invoking "make"</h3> <dl> <dt><b><tt>make</tt></b> <dd>Builds Ghostscript without debugging options. </dl> <dl> <dt><a name="Debugging"></a><b><tt>make debug</tt></b> <dd>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 <b><tt>-DDEBUG</tt></b> or <a href="Use.htm#Debugging"><b><tt>-Z</tt></b> command line switches</a> described in the usage documentation. </dl> <dl> <dt><b><tt>make pg</tt></b> <dd>On Unix platforms, builds with the <b><tt>-pg</tt></b> compiler switch, creating an executable for time profiling. </dl> <dl> <dt><b><tt>make begin</tt></b> <dd>On PC platforms, attempts a quick and dirty compilation of all the <b><tt>.c</tt></b> files in the current directory. See the <a href="#Make_begin">more detailed explanation</a>. </dl> <dl> <dt><b><tt>make install</tt></b> <dd>After building, installs the Ghostscript executables, support files, and documentation, but does <b><em>not</em></b> install fonts. See the <a href="Install.htm">installation documentation</a>. </dl> <dl> <dt><b><tt>make clean</tt></b> <dd>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 "<b><tt>make clean</tt></b>" deletes it. </dl> <p> <b><em>Note:</em></b> on most platforms some of these simple instructions don't quite work in one way or another. Read the section on your specific platform. <h3><a name="Cross-compiling"></a>Cross-compiling</h3> <p> If you are compiling Ghostscript on machines <b>X1</b> ... <b>X</b><em>n</em> with cross-compilers that generate code for machine <b>Y</b>, you must first perform several extra steps on some machine <b>Z</b> (not necessarily of the same type as either <b>X</b><em>i</em> or <b>Y</b>). First of all, choose a makefile appropriate for <b>Z</b> and edit it to reflect the run-time options you wish to include (<b><tt>FEATURE_DEVS</tt></b>, <b><tt>DEVICE_DEVS*</tt></b>, and any other relevant options), just as for non-cross-compilation. <p> If <b>Z</b> runs Unix, perform the following steps: <ol> <li>On <b>Z</b>, <blockquote> <b><tt>make clean</tt></b><br> <b><tt>make obj/arch.h obj/genconf obj/echogs</tt></b> </blockquote> <li>Edit <b><tt>obj/arch.h</tt></b> to reflect the architecture of <b>Y</b>. <li>On <b>Z</b>, <blockquote> <b><tt>make CC=: CCLD=:</tt></b> </blockquote> <li>Copy the files <b><tt>obj/*.h</tt></b> from <b>Z</B> to the directory on each <b>X</b><em>i</em> that will be used for compilation. <li>Extract from the file <b><tt>obj/ldt.tr</tt></b> (on <b>Z</b>) the list of <b><tt>.o</tt></b> files that will be linked: this gives the list of source files that must be compiled. <li>Do the compilations on <b>X</b><em>i</em>. </ol> <p> If <b>Z</b> runs some version of Microsoft Windows with Microsoft Visual C++, use the following steps. <em>NOTE: We have not actually tested this.</em> <ol> <li>On <b>Z</b>, <blockquote> <b><tt>nmake clean</tt></b><br> <b><tt>nmake obj\arch.h obj\genconf.exe obj\echogs.exe</tt></b> </blockquote> <li>Edit <b><tt>obj\arch.h</tt></b> to reflect the architecture of <b>Y</b>. <li>On <b>Z</b>, <blockquote> <b><tt>nmake CC=rem LINK=rem</tt></b> </blockquote> <li>Copy the files <b><tt>obj\*.h</tt></b> from <b>Z</B> to the directory on each <b>X</b><em>i</em> that will be used for compilation. <li>Extract from the file <b><tt>obj\ldt.tr</tt></b> (on <b>Z</b>) the list of <b><tt>.obj</tt></b> files that will be linked: this gives the list of source files that must be compiled. <li>Do the compilations on <b>X</b><em>i</em>. </ol> <hr> <h2><a name="PC_build"></a>How to build Ghostscript from source (PC version)</h2> <p> 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 <blockquote><table cellpadding=0 cellspacing=0> <tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1">PC makefiles</font><hr> <tr> <th align=left>Makefile <td> <th align=left>Construction tools <td> <th align=left>For environment <tr> <td colspan=5><hr> <tr> <td valign=top><b><tt>bcwin32.mak</tt></b> <td> <td valign=top><a href="#Borland_build">Borland/Inprise C++ 4.x</a> <td> <td valign=top>32-bit MS Windows 3.1 + Win32s, 95, 98, NT <tr> <td valign=top><b><tt>msvc32.mak</tt></b> <td> <td valign=top><a href="#Microsoft_build">Microsoft Visual C++ 4 to 8</a> <td> <td valign=top>MS Windows 32-bit <tr> <td valign=top><b><tt>watcw32.mak</tt></b> <td> <td valign=top><a href="#Watcom_build">Watcom C/386 or C++</a> <td> <td valign=top>MS Windows 32-bit <tr> <td valign=top><b><tt>unix-gcc.mak</tt></b> <td> <td valign=top><a href="#Cygwin32_build">Cygnus gcc</a> <td> <td valign=top><a href="http://sourceware.cygnus.com/cygwin/">Cygnus gnu-win32</a> </table></blockquote> <p> 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 <b><tt>make</tt></b> in directory <em>{dir}</em>, the default configuration generates an executable that assumes the Ghostscript initialization and font files are in directory <em>{dir}</em><b><tt>\lib</tt></b>. <p> Note that the <b><tt>make</tt></b> program supplied with each PC compiler has a different name. We refer to this program generically as <b><tt>make</tt></b> everywhere else in this document, but you will find the correct name for each compiler in the relevant section below that discusses that compiler. <p> You must have <b><tt>COMMAND.COM</tt></b> 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 <b><tt>obj</tt></b> subdirectory of the current directory) and the directory where the compiled code will be placed (normally the <b><tt>bin</tt></b> subdirectory). Then to build the Ghostscript executable all you need do is give the <b><tt>make</tt></b> command. <p><a name="Make_begin"></a> A special make target "<b><tt>begin</tt></b>" attempts to compile all the <b><tt>.c</tt></b> 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 <b><tt>.h</tt></b> file, is to do the fast compilation of everything possible, then the controlled compilation of everything that failed in the first step: <blockquote><b><tt> make begin<br> make </tt></b></blockquote> <p> <b><em>Note:</em></b> 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 <b><tt>zip</tt></b> and <b><tt>unzip</tt></b> programs, is <blockquote><table cellpadding=0 cellspacing=0> <tr> <td><b><tt>zip -l CVTEMP.zip *.bat *.c *.h *.def *.rc</tt></b> <td> <td>(Letter "l", not the digit "1") <tr> <td><b><tt>unzip -o CVTEMP.zip</tt></b> <td> <td>(Rewrite all the same files correctly) <tr> <td><b><tt>del CVTEMP.zip</tt></b> <td> <td>(Delete the temporary zip file) </table></blockquote> <h3><a name="Borland_build"></a>Borland/Inprise environment</h3> <p> 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, <b><tt>make</tt></b> utility, and linker. You also need either the Borland assembler (version 1.0 or later) or the Microsoft assembler (version 4.0 or later). <p> To create "<b><tt>makefile</tt></b>", give the command <blockquote><b><tt> echo !include "src\bcwin32.mak" >makefile </tt></b></blockquote> <p> To run the <b><tt>make</tt></b> program, give the commmand <blockquote><b><tt> make </tt></b></blockquote> <p> Besides the source files and the makefiles, you need: <blockquote><table cellpadding=0 cellspacing=0> <tr valign=top> <td>*<b><tt>.bat</tt></b> <td> <td>(a variety of batch files used in the build process) </table></blockquote> <p> 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: <ul> <li>The compiler files are in <b><tt>C:\BC</tt></b> and its subdirectories. <li>You are using the Borland assembler <b><tt>tasm</tt></b>. <li>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. </ul> <p> <b>Notes</b> <ul> <li>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. <li>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 <blockquote> <a href="ftp://ftp.borland.com/pub/borlandcpp/devsupport/patches/bc4_5/" class="offsite">ftp://ftp.borland.com/pub/borlandcpp/devsupport/patches/bc4_5/</a> </blockquote> <li>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 <blockquote> <a href="ftp://ftp.borland.com/pub/borlandcpp/devsupport/patches/bc4_5/bc45xp1.zip" class="offsite">ftp://ftp.borland.com/pub/borlandcpp/devsupport/patches/bc4_5/bc45xp1.zip</a> </blockquote> <li>Borland C++ 5.0 and 5.01 have a code generator bug that generates incorrect code for the construct <b><tt>!file_is_valid()</tt></b>. Do not attempt to compile Ghostscript with these compilers. If you want to report this bug to Borland, send them the result of compiling <b><tt>ziodev.c</tt></b> and tell them to look at the code generated for <b><tt>file_is_valid()</tt></b> and <b><tt>!file_is_valid()</tt></b>. 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.</li> <li>When building for the MS Windows Win32s environment, the make process will stop after it has created <b><tt>genarch.exe</tt></b>. You should then run "<b><tt>_genarch.bat</tt></b>", wait until <b><tt>genarch</tt></b> has finished and then exit MS Windows. Then type "<b><tt>make</tt></b>" again to restart the make process. <li>Borland C++Builder 5 and above require <strong><tt>BUILDER_VERSION</tt></strong> 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 <tt><strong>BUILDER_VERSION = 5</strong></tt></li> <li>Note that under Borland C++Builder 5, MAKE does not stop when <tt><strong>_genarch.bat</strong></tt> should be run as described above. It is necessary for the user to Abort the make by pressing Control-C. You should then run "<b><tt>_genarch.bat</tt></b>", wait until <b><tt>genarch</tt></b> has finished and then exit MS Windows. Then type "<b><tt>make</tt></b>" again to restart the make process. All targets are built succesfully if this step is ignored. <tt><strong>I don't know if the targets are correct although they seem to run OK.</strong></tt></li> <li>To prevent the compiler terminating because too many warning messages have been generated, copy the file file <tt><strong>bcc32.cfg </strong></tt>to the top level directory using the following command:</li> </ul> <h3><a name="Microsoft_build"></a>Microsoft Environment</h3> <p> 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 <a href="#IntelWin32_build">Intel C/C++ compiler</a>, which can be integrated into the Microsoft Visual C++ environment. <p>To compile Ghostscript using the Microsoft environment, you need Microsoft Visual C++ 4.0 or later with its associated "<b><tt>nmake</tt></b>" utility and linker. <h4><a name="Using_the_MS_Development_Environment"> </a>Using Microsoft Developer Studio</h4> <p>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 <b><tt>File/New</tt></b>. 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. <p> In the next dialog window, specify the build command line as <b><tt>nmake /f src/msvc32.mak DEVSTUDIO= </tt></b> Note the value for <b><tt>DEVSTUDIO</tt></b> is empty. Then select <b><tt>Finish</tt></b>. <p>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. <p>To run Ghostscript inside of Developer Studio, it is necessary to specify the name of the executable program . Select <b><tt>Project/Settings</tt></b>. Select the <b><tt>Debug</tt></b> tab. Then for <b><tt>Executable for debug session:</tt></b> specify <b><tt>bin/gswin32.exe</tt></b> <p>To use all of the features of Microsoft Developer Studio for debugging, and modifying Ghostscriptt, you need to finish the remaining steps. <p>To add the Ghostscript DLL to the project, select <b><tt>Project/Settings</tt></b>. Select the <b><tt>Debug</tt></b> tab. Change the <b><tt>Category</tt></b> to <b><tt>Additional DLLs</tt></b>. Then specify <b><tt>bin/gsdll32.dll</tt></b>. <p> To specify the Ghostscript program arguments, select <b><tt>Project/Settings</tt></b>. Select the <b><tt>Debug</tt></b> tab. Change the <b><tt>Category</tt></b> to <b><tt>General</tt></b>. Then specify the desired program arguments. For example, specifying: <b><tt>examples/tiger.eps</tt></b> will result in the tiger example file being displayed when Ghostscript is executed. . <p> 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: <blockquote><b><tt> nmake -f src/msvc32.mak DEVSTUDIO= DEBUG=1 TDEBUG=1 GS_LIB_DEFAULT="./lib/;./font;$(GSROOTDIR)/lib;$(AROOTDIR)/fonts" </tt></b></blockquote> <p>Please note the double quotes around the value for <b><tt>GS_LIB_DEFAULT</tt></b> and the addition of <b><tt>./lib;./fonts;</tt></b> to its definition. This uses the local (within the project) copy of the <b><tt>lib</tt></b> and <b><tt>fonts</tt></b> directories. This is convenient if any changes need to be made in these directories. <p> Setting <b><tt>DEBUG=1</tt></b> includes debugging features in the build: <ul> <li> It defines the C preprocessor symbol <b><tt>DEBUG</tt></b>. The latter includes tracing and self-validation code fragments into compilation. Particularly it enables the <b><tt>-Z</tt></b> and <b><tt>-T</tt></b> switches in Ghostscript. <li> It compiles code fragments for the C stack overflow checks. </ul> Code produced with this option is somewhat larger and runs somewhat slower. <p>Setting <b><tt>TDEBUG=1</tt></b> disables code optimization in the C compiler and includes symbol table information for the debugger. Code becomes substantially slower and larger. <p> An optional setting <b><tt>DEBUGSYM=1</tt></b> is only useful with <b><tt>TDEBUG=0</tt></b> for advanced developers. It includes symbol table information for the debugger in an optimized (release) build. <em> NOTE: The debug information generated for the optimized code may be significantly misleading. For general MSVC users we recommend TDEBUG=1. </em> <h4><a name="Using_the_command_line"></a>Using the command line</h4> <p>Ghostscript can be made using either the DOS shell or one one of the various command line shells made for Windows. <p>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 <b><tt>src\msvc32.mak</tt></b> find the line "<b><tt>#MSVC_VERSION=6</tt></b>" and change it to "<b><tt>MSVC_VERSION=4</tt></b>", "<b><tt>MSVC_VERSION=5</tt></b>", "<b><tt>MSVC_VERSION=7</tt></b>" or "<b><tt>MSVC_VERSION=8</tt></b>". . <p>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 <b><tt>DEVSTUDIO</tt></b>. There are several different definitions of <b><tt>DEVSTUDIO</tt></b> in src\msvc32.mak. There is one for each of the currently supported versions of Microsoft Visual C++ (4, 5, 6, 7, 7.1 and 8). <p>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 <b><tt>DEVSTUDIO</tt></b> can be changed to empty. I.e. <b><tt>DEVSTUDIO=</tt></b> <p> If PATH, LIB, and INCLUDE are not correctly set then the value for <b><tt>DEVSTUDIO</tt></b> needs to be defined. For example, for version 6.0, the default definition for the location for the Microsoft Developer Studio is: <b><tt>DEVSTUDIO=C:\Program Files\Microsoft Visual Studio </tt></b> If the path to Microsoft Developer Studio on your system differs from the default then change the appropriate definition of <b><tt>DEVSTUDIO</tt></b>. (Remember that there is a separate definition of <b><tt>DEVSTUDIO</tt></b> for each version of MSVC, so be sure to change the correct definition.) <p>To run the <b><tt>make</tt></b> program, give the command <blockquote><b><tt> nmake -f src\msvc32.mak </tt></b></blockquote> <p> Rather than changing src/msvc32.mak, these values can be specified on the make command line, I.e. <blockquote><b><tt> nmake -f src\msvc32.mak MSVC_VERSION=6 DEVSTUDIO="C:\Program Files\Microsoft Visual Studio" <br> nmake -f src\msvc32.mak MSVC_VERSION=7 DEVSTUDIO="C:\Program Files\Microsoft Visual Studio .NET" </tt></b></blockquote> <p> Note that double quotes have been added around the path for <b><tt>DEVSTUDIO</tt></b> due to the spaces in the path value. <p> This command line can also be put into a batch file. <p> You may get warning messages during compilation about <b><tt>/QI0f</tt></b> 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. <p> The Microsoft VC++ 5.0 compiler locks up when compiling <b><tt>gxi12bit.c</tt></b> with <b><tt>/O2</tt></b>. Compile this file without <b><tt>/O2</tt></b>. <p> The Microsoft VC++ 5.0 compiler produces a non-working executable if compiling without stack checking. Don't change the setting <b><tt>TDEBUG=1</tt></b> in <b><tt>msvc32.mak</tt></b>. <h3><a name="Microsoft_build_64"></a>Microsoft Environment for 64-bit</h3> Building Ghostscript for 64-bit Windows (AMD64 processor) requires Microsoft Visual Studio .NET 2005 beta on 64-bit Windows, or Microsoft Visual Studio .NET 2003 and Windows Server 2003 DDK on 32-bit Windows (cross-compile). <p> Compiling for 64-bit is similar to the <a href="#Microsoft_build">Microsoft Environment</a> instructions above, but with the addition of a WIN64 define. <h4><a name="Microsoft_64on32"></a>Cross compile on 32-bit Windows XP</h4> Microsoft Visual Studio .NET 2003 is used for 32-bit compilation of auxiliary programs used by the compile process, while Windows Server 2003 Device Driver Kit (DDK) is used for 64-bit compilation. The DDK cross compilers for the IA64 and AMD64 processors, however only AMD64 is supported by the makefile. The DDK is not installed correctly by the setup program. You need to copy <b><tt>msobj10.dll</tt></b> to the compiler directory from a nearby directory. <p> To make ghostscript use <blockquote><b><tt> nmake -f src/msvc32.mak WIN64= </tt></b></blockquote> This will fail when it tries to run genconf.exe. Move <b><tt>./obj/genconf.exe</tt></b> to 64-bit Windows, then run it <blockquote><b><tt> genconf arch.h </tt></b></blockquote> Move <b><tt>arch.h</tt></b> back to <b><tt>./obj/arch.h</tt></b>. (Alternatively, use arch.h created by a 32-bit build and change ARCH_ALIGN_PTR_MOD to 8, ARCH_ALIGN_STRUCT_MOD to 16, ARCH_SIZEOF_PTR to 8, and ARCH_CACHE1_SIZE to 4194304). Then restart the build <blockquote><b><tt> nmake -f src/msvc32.mak WIN64= </tt></b></blockquote> <p> You can also use Microsoft Visual Studio .NET 2005 beta to do a similar cross compile, but you will need to change the DEVSTUDIO path. <h4><a name="Microsoft_64on64"></a>Compile on 64-bit Windows XP</h4> To make ghostscript use <blockquote><b><tt> nmake -f src/msvc32.mak WIN64= </tt></b></blockquote> The Microsoft Visual Studio .NET 2005 beta does not have a "go live" licence. You are not permitted to distribute executables created by this compiler. <p> The makefile currently uses the cross compiler (x86_amd64) rather than the native compiler (amd64). <p> You can install Microsoft Visual Studio .NET 2003 on 64-bit Windows, but you can't install Windows Server 2003 DDK. You may be able to copy the DDK directory <b><tt>c:\winddk</tt></b> from a 32-bit system to a 64-bit system and compile GS. <h4><a name="Self-extracting_executables"></a>Making self-extracting executables</h4> <p> 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: <ul> <li><b><tt>WinZipSE</tt></b>, available from <a href="http://www.winzip.com/winzipse.html" class="offsite">http://www.winzip.com/winzipse.html</a>. This is not free. <li><b><tt>zip</tt></b>, available from <a href="http://www.info-zip.org/pub/infozip/Zip.html" class="offsite"> http://www.info-zip.org/pub/infozip/Zip.html</a>. This is free. </ul> <p> You will have to edit <b><tt>src/winint.mak</tt></b> to define <b><tt>WINZIPSE_XE</tt></b> and <b><tt>ZIP_XE</tt></b> respectively as the path names of these programs. See <a href="Release.htm">Release.htm</a> for the detailed procedure. <h3><a name="Watcom_build"></a>Watcom environment</h3> <p> To use the Watcom compiler, add to <b><tt>AUTOEXEC.BAT</tt></b> the line "<b><tt>set DOS4G=quiet</tt></b>". Check that <b><tt>AUTOEXEC.BAT</tt></b> also contains a line of the form "<b><tt>set WATCOM=</tt></b><em>{wcdir}</em>" where <em>{wcdir}</em> is the directory where you installed the Watcom tools, and that the setting of <b><tt>PATH</tt></b> includes <em>{wcdir}</em><b><tt>\binnt</tt></b> (or <b><tt>%WATCOM%\binnt</tt></b>) before <em>{wcdir}</em><b><tt>\binw</tt></b> (or <b><tt>%WATCOM%\binw</tt></b>). Then to create "<b><tt>makefile</tt></b>": <blockquote><table cellpadding=0 cellspacing=0> <tr> <th align=left>For <td> <th align=left>Give the command <tr> <td colspan=3><hr> <tr> <td>MS Windows <td> <td nowrap><b><tt>echo !include src\watcw32.mak >makefile</tt></b> </table></blockquote> <p> Before compiling, change the definition of the <b><tt>WCVERSION</tt></b> macro in the makefile (<b><tt>watcw32.mak</tt></b>) to the version of the Watcom compiler you are using. This is necessary to handle some minor incompatibilities between versions. <p> To run the <b><tt>make</tt></b> program, give the commmand <blockquote> <b><tt>wmake -u</tt></b> </blockquote> <h3><a name="Cygwin32_build"></a>Cygwin32 gcc</h3> <p> A user reports that it is possible to compile Ghostscript for MS Windows NT using the Cygwin32 gcc compiler, GNU <b><tt>make</tt></b>, and the <b><tt>unix-gcc.mak</tt></b> makefile, with only two small source code changes: <ul> <li>Add "<b><tt>b</tt></b>" to the call to <b><tt>fopen</tt></b> in <b><tt>gp_open_scratch</tt></b> <li>Mirror the <b><tt>gp_ntfs</tt></b> logic for <b><tt>gp_pathstring_not_bare</tt></b> </ul> <p> Information about this compiler and environment is at the Cygnus site: <blockquote> <a href="http://sources.redhat.com/cygwin/">http://sources.redhat.com/cygwin/</a> </blockquote> <p> Please note that Cygnus's licensing terms aren't quite as liberal about redistribution as either the GNU <a href="http://www.gnu.org/copyleft/gpl.html">General Public License</a> or the Aladdin <a href="Public.htm">Free Public License</a>, so read their license carefully if you want to redistribute the results of using their compiler. <h3><a name="IntelWin32_build"></a>Intel C/C++ environment</h3> <p> Intel provides a C/C++ compiler that is compatible with the <a href="#Microsoft_build">Microsoft Visual C++ environment</a>. 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. <p> To build Ghostscript using the Intel C/C++ compiler, you have to make the following small changes in the makefiles: <ul> <li>Find and change the second occurrence of "<b><tt>COMPILE_FULL_OPTIMIZED</tt></b>" to "<b><tt>/O2</tt></b>" in file <b><tt>msvccmd.mak</tt></b>. <li>Override "<b><tt>TDEBUG</tt></b>", "<b><tt>COMP</tt></b>", and "<b><tt>COMPAUX</tt></b>" when invoking <b><tt>nmake</tt></b>. </ul> <p> More specifically, use "<b><tt>TDEBUG=0</tt></b>" and set both "<b><tt>COMP</tt></b>" and "<b><tt>COMPAUX</tt></b>" to the full path of <b><tt>icl</tt></b> (for example "<b><tt>COMP=C:\intel\compiler45\bin\icl</tt></b>" if the Intel C/C++ compiler V4.5 was installed to <b><tt>C:\intel</tt></b>). It is suggested that you use a batch file to launch <b><tt>nmake</tt></b>, since the command line processes the "<b><tt>=</tt></b>" on its own. Also, you may need to execute <b><tt>vcvars32.bat</tt></b> and <b><tt>iccvars.bat</tt></b> to register the proper paths for the compiler, its include files and its libraries. <p> You can buy or download a 30-day evaluation version of the Intel C/C++ compiler from Intel's Software Performance Tools web site: <blockquote> <a href="http://www.intel.com/vtune/">http://www.intel.com/vtune/</a> </blockquote> <hr> <h2><a name="Mac_build"></a>How to build Ghostscript from source (MacOS version)</h2> <h3><a name="MacOS"></a>Traditional MacOS</h3> <p> The Macintosh version of Ghostscript requires the <a href="http://www.metrowerks.com/" class="offsite">Metrowerks Codewarrior</a> development suite. Download the <tt>macgs-7xx-src.sit</tt> 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. <blockquote> <a href="ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/currenti/" class="offsite">ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/current/</a> </blockquote> <p> If your system doesn't automatically unpack the source archive, you can download the free <a href="http://stuffit.com/download.html" class="offsite">Stuffit Expander</a> to open it. <p> 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 <tt>lib</tt> directory from the source archive. <p> 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. <h3><a name="MacOSX"></a>MacOS X</h3> <p> The unix source distribution (.tar.gz) builds fine on Darwin/MacOS X, albeit without a display device. You can generally just use the <tt>Makefile</tt> generated by ./configure or <tt>macosx.mak</tt> 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. <p> There is also a support for building Ghostscript as a framework. This is a special encapsulated shared library format specific to MacOS X. To build the framework, copy <tt>macosx.mak</tt> to the top-level directory, rename it to <tt>makefile</tt> and issue 'make framework' from Terminal.app. This will result in a <tt>Ghostscript.framework</tt> in the <tt>sobin</tt> directory. It must be manually copied to /Library/Frameworks/ before applications can use it. You may need to create the Frameworks/ directory on some systems. <p> Finally, there is a <tt>macos-mcp.mak</tt> makefile that can be used to set up the Codewarrior shared library component build described in the section on <a href="#MacOS">Classic MacOS</a> above. Currently this makefile is distributed only with the MacOS-specific <tt>.sit</tt> source archive, but with be included generally in future releases. <p> To set up the shlib build, download and uncompress the Ghostscript source. If the archive doesn't contain the 3rd party jpeg, png, and zlib source, you must download them as described at the beginning of this document and unpack them under the macgs-###-src directory under the specific names <tt>jpeg</tt>, <tt>zlib</tt> and <tt>libpng</tt>. You cannot use symlinks as Codewarrior will not be able to follow them for some of the needed header files. <p> Copy <tt>src/macos-mcp.mak</tt> to the top-level directory and rename it <tt>makefile</tt>. 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 <tt>ghostscript.mcp.xml</tt>. Launch Metrowerks Codewarrior, and select 'Import Project...' from the File menu, and open the xml project file. When asked, save the results as <tt>ghostscript.mcp</tt> in the same directory and you should be ready to build the shared library component. </p> 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. <hr> <h2><a name="Unix_build"></a>How to build Ghostscript from source (Unix version)</h2> <p> 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: <blockquote><pre> ./configure make </pre></blockquote> Please report any problems with this method on your system as a bug. <p> For the convenience of those already familiar with Ghostscript, the old method based on hand-edited makefiles is still supported. It may also be helpful in getting Ghostscript to build on very old platforms. This section deals exclusively with that older method and includes numerous pointers regarding legacy systems. <p> Before issuing the <b><tt>make</tt></b> command to build Ghostscript, you have to make some choices, for instance <ul> <li>which compiler to use; <li>what features and devices to include; <li>whether to use system libraries for PNG and zlib; <li>and how to handle issues for your particular platform. </ul> <p> Be sure to check the sections on <a href="#Tool_specific_issues">tool-</a>, <a href="#OS_specific_issues">OS-</a>, and <a href="#Hardware_specific_issues">hardware-</a>specific issues for notes on your particular platform and compiler. In fact, that is the <b><em>first</em></b> place to check if you build Ghostscript and it crashes or produces obviously incorrect results. <h3><a name="Multi_architecture_makefile"></a>The multi-architecture makefile</h3> <p> Especially if you are working in a Unix environment with multiple CPU types, operating systems, and/or C compilers, you may find the file <b><tt>all-arch.mak</tt></b> useful. This user-contributed file includes "wrappers" for the Unix makefiles for many different common environments. The author of this file notes: <blockquote> <p> This makefile allows you to execute <pre> make `hostname` </pre> <p> 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. <p> I don't do "make install" until I've done <pre> cd ...build-directory.../gs-x.yz cd lib ../bin/gs ../examples/tiger.eps </pre> <p> and verified that the famous tiger can be correctly displayed. Also, the "make install" step is careful to first remove any existing <b><tt>$(BINDIR)/gs</tt></b>, then install a new gs there with a hard link to gs-x.yz. <p> 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. <p> 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. </blockquote> <h3><a name="UNIX_makefile"></a>Setting up "makefile"</h3> <p> The files <b><tt>src/unix</tt></b>*<b><tt>.mak</tt></b> 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 "<b><tt>make</tt></b>", which must find the file "<b><tt>makefile</tt></b>" (or "<b><tt>Makefile</tt></b>"). If your system supports symbolic links, set up "<b><tt>makefile</tt></b>" like this. <blockquote><table cellpadding=0 cellspacing=0> <tr> <td>GNU gcc: <td> <td nowrap><b><tt>ln -s src/unix-gcc.mak makefile</tt></b> <tr> <td>Non-gcc ANSI C compiler: <td> <td nowrap><b><tt>ln -s src/unixansi.mak makefile</tt></b> </table></blockquote> <p> If your system doesn't support symbolic links, first finish all changes to the compiler-specific makefile, then make a hard link, omitting the <b><tt>-s</tt></b> switch. <p> The makefile distributed with Ghostscript selects the following devices to include in the build: <blockquote><table cellpadding=0 cellspacing=0> <tr><th colspan=3 bgcolor="#CCCC00"><hr><font size="+1">Devices included as distributed</font><hr> <tr valign=bottom> <th align=left>Type <td> <th align=left>Devices <tr> <td colspan=3><hr> <tr valign=top> <td>Display <td> <td>X Windows <tr valign=top> <td>Printers <td> <td>H-P DeskJets, LaserJets, and color DeskJets and PaintJets; Canon BubbleJets <tr valign=top> <td>File formats <td> <td>Group 3 & Group 4 fax; JPEG; PCX; PBM, PGM, PKM, & PPM; TIFF; PostScript images; PNG; distilled PDF, PostScript, and EPS; PCL XL ("PCL 6") </table></blockquote> <p> The <b><tt>unix</tt></b>*<b><tt>.mak</tt></b> 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 <b><tt>/usr/lib/libpng.</tt></b>{<b><tt>a</tt></b>,<b><tt>so</tt></b>} and <b><tt>/usr/lib/libz.</tt></b>{<b><tt>a</tt></b>,<b><tt>so</tt></b>} -- and you would rather use those copies, change the definition of <b><tt>SHARE_LIBPNG</tt></b> and <b><tt>SHARE_ZLIB</tt></b> from 0 to 1 in the relevant <b><tt>unix</tt></b>*<b><tt>.mak</tt></b> file before compiling. Note that if you do this, you will get non-debug versions of these libraries even if you selected <b><tt>DEBUG</tt></b> in the makefile. At the insistence of some users, we have also provided the ability to do this with the JPEG library (<b><tt>SHARE_JPEG</tt></b>), 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 <blockquote><b><tt> #define D_MAX_BLOCKS_IN_MCU 64 </tt></b></blockquote> <p> 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 <b><tt>/usr/include</tt></b>, you must have the source code for this library available even if you set <b><tt>SHARE_JPEG</tt></b> to 1. <p> If the X11 client header files are located in some directory which your compiler does not automatically search, you must change the <b><tt>XINCLUDE</tt></b> macro in the makefile to include a specific <b><tt>-I</tt></b> switch. See the comment preceding <b><tt>XINCLUDE</tt></b> in the makefile. <p> Currently Ghostscript is set up to compile and link in a generic Unix environment. Some Unix environments may require changing the <b><tt>LDFLAGS</tt></b> macro in the makefile; be sure to check the <a href="#Unix_build">Unix section</a> for your specific tools, operating system, and hardware. <h3><a name="Shared_object"></a>Shared object</h3> To build Ghostscript as a shared object with gcc (instead of as a single large executable) use: <pre> ln -s src/unix-gcc.mak makefile make so </pre> <p> This will build <b><tt>libgs.so</tt></b> and two programs which use the shared object, <b><tt>gsx</tt></b> which uses Gtk+ and <b><tt>gsc</tt></b> which does not. <p> Do not use <tt>make -f src/unix-gcc.mak</tt> because this will break the recursive make used in building the shared object. <p> To install the shared object and these two programs: <pre> make soinstall </pre> To delete files created by the build process: <pre> make soclean </pre> <p> For more details see <a href="../src/unix-dll.mak">unix-dll.mak</a>. <h3><a name="Tool_specific_issues"></a>Tool-specific issues</h3> <h4><a name="gcc_27x"></a>gcc 2.7.*</h4> <p> 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 <b><tt>gcc --version</tt></b> command. <p> 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. <h4><a name="GNU_make"></a>GNU make</h4> <p> Current versions of GNU <b><tt>make</tt></b> have no problems, but GNU <b><tt>make</tt></b> 3.59 can't handle the final linking step in some cases; if this happens, use the platform's standard <b><tt>make</tt></b>, typically <b><tt>/bin/make</tt></b>. <h3><a name="OS_specific_issues"></a>OS-specific issues</h3> <h4><a name="386_Unix"></a>386 Unix</h4> <ul> <li>gcc versions older than 1.38 on Intel 80386 systems do not compile Ghostscript correctly with the <b><tt>-O</tt></b> option. <li>gcc 1.39 under <b><tt>386BSD</tt></b> has a bug that causes float-to-integer conversions to compile incorrectly, rendering the executable unusable. <li>X11R5 may need "<b><tt>#include <stddef.h></tt></b>" in <b><tt>x_.h</tt></b>. <li>Also see regarding <a href="#System_V">System V</a> platforms. </ul> <h4><a name="BSDI"></a>BSDI</h4> <ul> <li>Use <b><tt>unix-gcc.mak</tt></b> and set<blockquote><b><tt> STDLIBS=-lm<br> XINCLUDE=-I/usr/X11R6/include<br> XLIBDIRS=-L/usr/X11R6/lib<br> XLIBS=Xt SM ICE Xext X11<br></tt></b></blockquote> <li>If you want to use the shared versions of the PNG and zlib libraries, set <b><tt>SHARE_LIBPNG=1</tt></b> and <b><tt>SHARE_ZLIB=1</tt></b> as discussed <a href="#UNIX_makefile">previously</a>. <li>BSD <b><tt>make</tt></b> uses a different syntax for its <b><tt>include</tt></b> directive than Ghostscript; use <b><tt>gmake</tt></b> instead. </ul> <h4><a name="Digital_Unix"></a>Digital Unix (Alpha)</h4> <ul> <li>Use <b><tt>unixansi.mak</tt></b> for all Digital Unix compilers. <li>For versions of Digital Unix before 4.0, set <p> <b><tt>CFLAGS=-std -migrate -Olimit 1000 -g3 -O2 $(XCFLAGS)<br> LDFLAGS=-lots $(XLDFLAGS)</tt></b> <p> You may be able to omit <b><tt>-g3</tt></b>. For later versions of Digital Unix, users have reported that the proper flags are <p> <b><tt>CFLAGS=-std1 -Olimit 1000 -g3 -O2 $(XCFLAGS)</tt></b> <p> again, optionally omitting the <b><tt>-g3</tt></b>. <li>If you get compiler error messages about "ANSI aliasing rules", please see the section about <a href="#VMS_build">building under OpenVMS</a> below. </ul> <h4><a name="Linux"></a>Linux</h4> <ul> <li>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 <b><tt>XLIBS</tt></b> in the makefile is set to "<b><tt>Xt SM ICE Xext X11</tt></b>" rather than "<b><tt>Xt Xext X11</tt></b>". <li>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, <b><tt>ld</tt></b> complains that some X library is not found, or that many <b><tt>Xlib</tt></b> or <b><tt>Xt</tt></b> functions are not found in the library (similar to the messages for omitting <b><tt>SM</tt></b> and <b><tt>ICE</tt></b> from <b><tt>XLIBS</tt></b>). 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><tt>-b i486-linuxaout</tt></b>" to both <b><tt>CFLAGS</tt></b> and <b><tt>LDFLAGS</tt></b>, then "<b><tt>make clean</tt></b>" followed by "<b><tt>make</tt></b>"). If this doesn't help, or if other strange things happen, contact your Linux supplier or support resource. <li>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 <b><tt>libc</tt></b> version 6 or higher. Most distributions include this, but it may be an issue on very old systems. </ul> <h4><a name="NeXTSTEP"></a>NeXTSTEP / OpenSTEP</h4> <ul> <li>If you are using a NeXTSTEP version before 3.3, please get a no-cost upgrade (along with Y2K patches) from Apple. <li>If '<tt>./configure && make</tt>' fails, then for all NeXTSTEP systems, use <b><tt>unix-gcc.mak</tt></b> and make the following changes: <ul> <li>In <b><tt>unix-aux.mak</tt></b> (and <b><tt>ugcclib.mak</tt></b>, if you are using only the library) change the definition of <b><tt>INCLUDE</tt></b> to "<b><tt>INCLUDE=/usr/include/bsd</tt></b>"; <li>in <b><tt>unix-gcc.mak</tt></b>: <ul> <li>change <b><tt>CC=gcc</tt></b> to <b><tt>CC=cc</tt></b>; <li>change the definition of <b><tt>STDLIBS</tt></b> to only <b><tt>-lm</tt></b>; <li>change <b><tt>SYNC=posync</tt></b> to <b><tt>SYNC=nosync</tt></b>; <li>add <b><tt>-D_POSIX_SOURCE</tt></b> to <b><tt>CFLAGS</tt></b> and remove <b><tt>-g</tt></b>; <li>remove <b><tt>-Wstrict-prototypes</tt></b> from <b><tt>GCFLAGS</tt></b>, and if you are using NeXTSTEP 3.3 (with gcc 2.5.8), also remove <b><tt>-Wmissing-declarations</tt></b>; </ul> <li>to the end of <b><tt>Fontmap.GS</tt></b> add the line "<b><tt>/Ohlfs /Courier ;</tt></b>". </ul> <li>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 <b><tt>XINCLUDE</tt></b> and <b><tt>XLIBDIRS</tt></b> to empty strings. </ul> <h4><a name="SCO"></a>SCO Unix/Xenix</h4> <ul> <li>See also "<a href="#386_Unix">386 Unix</a>" and "<a href="#System_V">System V Unix platforms</a>". <li>The standard cc compiler on SCO OpenServer v5 has optimizer bugs. Compile without -O. <li>The SCO Unix C compiler apparently can't handle the <b><tt>P</tt></b><em>n</em> macros in <b><tt>std.h</tt></b>. If you get strange compilation errors on SCO Unix, ask SCO for a compiler fix. <li>Meanwhile, to use gcc with SCO ODT, see <b><tt>unix-gcc.mak</tt></b> for the appropriate switch settings. <li>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. <li>If you aren't using the X11 driver, you must add <b><tt>-lsocket</tt></b> to the value of <b><tt>EXTRALIBS</tt></b> to link the date and time functions. <li>If you want to use direct frame buffer addressing instead of X Windows, include the relevant frame buffer devices (<b><tt>$(DD)ega.dev</tt></b>, <b><tt>$(DD)vga.dev</tt></b>, etc.) and change the definition of <b><tt>EGAVGA</tt></b> to <b><tt>$(EGAVGA_SCO)</tt></b> as indicated in <b><tt>devs.mak</tt></b>. <b>Note</b>: this works with SuperVGA displays only for 800x600x16 mode. <li>If the display looks "smeared", try recompiling <b><tt>gdevpcfb.c</tt></b> with <b><tt>-O0</tt></b>. <li>If Ghostscript crashes, use the <b><tt>-q</tt></b> switch or redirect console output to a file. <li>If your compiler accepts both the <b><tt>-Xt</tt></b> and <b><tt>-Xa</tt></b> switches, use <b><tt>-Xt</tt></b>. Even though this causes the compiler to use incorrect rules for computing the result types of "<b><tt><<</tt></b>" and "<b><tt>>></tt></b>", <b><tt>-Xa</tt></b> enables optimizations that produce incorrect code. <li>For SCO ODT 2.0, in addition to <b><tt>-D__SVR3</tt></b> and <b><tt>-DSYSV</tt></b>, you need to specify <b><tt>-Dsco</tt></b>, <b><tt>-DUSG</tt></b>, and <b><tt>-DMALLOC_0_RETURNS_NULL</tt></b>. For SCO ODT, you need "<b><tt>EXTRALIBS=-lX11 -lsocket -lmalloc</tt></b>", or maybe only <b><tt>-lsocket</tt></b> depending on the version), and for SCO ODT 2.0, you must also specify <b><tt>-lc_s</tt></b>. For SCO Xenix, you need "<b><tt>EXTRALIBS=-lmalloc</tt></b>". <li>For SCO OpenServer 5.0.5, add <b><tt>-L/usr/local/lib</tt></b> to <b><tt>LDFLAGS</tt></b>. <li>For all SCO systems, set "<b><tt>XINCLUDE=</tt></b>" and "<b><tt>XLIBDIRS=</tt></b>". </ul> <h4><a name="SVR4"></a>SVR4 Unix</h4> <ul> <li>You may need to set <b><tt>EXTRALIBS=-lnsl</tt></b>. <li>Do <b><em>not</em></b> change <b><tt>PLATFORM=unix_</tt></b> to <b><tt>PLATFORM=sysv_</tt></b>. <li>On SVR4 Unix platforms with dynamic linking, you may need to define <b><tt>XLIBDIR</tt></b> as the name of the directory that holds the X Windows libraries. Do <b><em>not</em></b> prefix the name with "<b><tt>-L</tt></b>". <li>For SVR4.0 systems, set <b><tt>-DSVR4</tt></b> and <b><tt>-DSVR4_0</tt></b> in the makefile; do <b><em>not</em></b> set <b><tt>-DSYSV</tt></b>. For SVR4.2 (or later) and Solaris 2.<em>n</em> systems, set only <b><tt>-DSVR4</tt></b> (<b><em>not</em></b> <b><tt>-DSVR4_0</tt></b> nor <b><tt>-DSYSV</tt></b>). </ul> <h4><a name="System_V"></a>System V Unix platforms</h4> <ul> <li>If you are using a stock System V platform that lacks <b><tt>rename</tt></b> and <b><tt>gettimeofday</tt></b>, in the makefile change "<b><tt>PLATFORM=unix_</tt></b>" to "<b><tt>PLATFORM=sysv_</tt></b>". <li>You will probably need to change the definition of <b><tt>INSTALL</tt></b> from "<b><tt>install</tt></b>" to "<b><tt>/usr/ucb/install</tt></b>". </ul> <h4><a name="Unixware"></a>Unixware</h4> <ul> <li>The standard cc compiler has optimizer bugs. Compile without <b><tt>-O</tt></b>. </ul> <h3><a name="Hardware_specific_issues"></a>Hardware-specific issues</h3> <h4><a name="Alpha_with_gcc"></a>Alpha with gcc</h4> <ul> <li>You don't have to use gcc on Alpha systems, because the bundled compiler works. <li>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. </ul> <h4><a name="Apollo"></a>H-P Apollo</h4> <ul> <li>You must run the compiler in ANSI-compatible mode (that is, set <b><tt>AK=</tt></b>{null string} in the makefile); otherwise it gives incorrect error messages for any function declared as returning a float value. <li>The H-P Apollo compiler may not compile Ghostscript correctly. If you get unexpected crashes at run time, use gcc. </ul> <h4><a name="ATT_7040"></a>AT&T 7040 R3</h4> <ul> <li>If Ghostscript crashes on startup, recompile with <b><tt>-O0</tt></b> to work around compiler bugs. </ul> <h4><a name="Convex"></a>Convex</h4> <ul> <li>Use <b><tt>unixansi.mak</tt></b>. Do not invoke optimization (<b><tt>-O1</tt></b>) because the compiler will produce incorrect code. <li>Set <b><tt>CFLAGS</tt></b> to "<b><tt>-no -fn -tm c1</tt></b>". </ul> <h4><a name="DECStations"></a>DECStations with Ultrix</h4> <ul> <li>If you get the compiler message "cfe: Fatal: _temp_19086.c: Segmentation violation" or a similar one, try compiling with the <b><tt>-oldc</tt></b> switch. <li>You may wish to set <p> <b><tt>GS_LIB_DEFAULT=$(gsdatadir):/usr/lib/DPS/outline/decwin:$(gsdatadir)/fonts</tt></b> <p> in the makefile to add the Display PostScript font directory to the font search path. <li>Set <p> <b><tt>CFLAGS="-Olimit 2500"</tt></b> <p> to make the optimizer allocate enough table space. <li>The Ultrix 4.4 C compiler compiles <b><tt>gdevm1.c</tt></b> incorrectly. Insert the following line in the makefile rule for "<b><tt>gdevm1.$(OBJ)</tt></b>" (the body of the rule is empty in the standard distribution): <p> <b><tt>$(CCC) -oldc gdevm1.c</tt></b> </ul> <h4><a name="HP_RISC"></a>H-P RISC workstations</h4> <ul> <li>HP-UX versions before 11.0 do not support POSIX threads. Set <b><tt>SYNC=nosync</tt></b> in the makefile before building. <li>Ghostscript builds on H-P machines with either GNU gcc or H-P's ANSI-capable <b><tt>cc</tt></b>. The minimal, non-ANSI-capable <b><tt>cc</tt></b> that shiped with some basic HPUX system does <em>not</em> work. If <b><tt>cc</tt></b> on your system doesn't accept the <b><tt>-Aa</tt></b> switch, then you need to get the full <b><tt>cc</tt></b> or gcc. <li>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: <ul> <li>The link step fails with a message about "<b><tt>max</tt></b>" not being defined. <li>The build succeeds, but the resulting executable fails to start up, with an error message like "Initializing... Unrecoverable error: typecheck in .registerencoding". <li>The build succeeds, but the resulting executable produces a black background on the first page of output. </ul> <li>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.) <li>On HPUX 10.*, we don't know what combinations of compiler version and switches work. It is reported that On HPUX 10.20, setting "<b><tt>CC=c89</tt></b>" and "<b><tt>CFLAGS=+O3 $(XCFLAGS)</tt></b>" works, contradicting the information in the next paragraph, but this may be dependent on the specific compiler version. <li>In either HPUX version, you need to set "<b><tt>CC=cc -Aa</tt></b>" (or use <b><tt>-Ae</tt></b> if you prefer), and set "<b><tt>CFLAGS=-D_HPUX_SOURCE -O $(XCFLAGS)</tt></b>". Higher levels of optimization than <b><tt>-O</tt></b> may work depending on your compiler revision; some users have reported success with <b><tt>+O3</tt></b>, some have not. <li>Some users have reported needing <b><tt>-DNOSYSTIME</tt></b> and <b><tt>-D_POSIX_SOURCE</tt></b> in <b><tt>CFLAGS</tt></b>, but recent tests do not show these to be necessary. <li>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 <b><tt>-O</tt></b> from <b><tt>CFLAGS</tt></b>. </ul> <h4><a name="Intergraph"></a>Intergraph Clipper</h4> <ul> <li>Recommended settings are: <p> <b><tt>XCFLAGS=-w -Q -DSYSV -D__SVR3<br> EXTRALIBS=-lbsd -lc_s<br> CC=acc -knr<br> PLATFORM=sysv_</tt></b><br> <li>You will probably need to change the value of <b><tt>XLIBS</tt></b> from "<b><tt>XLIBS=Xt X11 Xext</tt></b>" to "<b><tt>XLIBS=Xt_s X11_s Xext</tt></b>". </ul> <h4><a name="MIPS"></a>MIPS</h4> <ul> <li>There is apparently a bug in older versions of the MIPS C compiler which causes <b><tt>gxdither.c</tt></b> to compile incorrectly if optimization is enabled (<b><tt>-O</tt></b>). However, this bug is definitely fixed in MipsPRO C version 6.00; with this version, compiling with "<b><tt>-O2 -mips2</tt></b>" produces good output. </ul> <h4><a name="NCR_3550"></a>NCR 3550</h4> <ul> <li>With the NCR C Development Toolkit you must use <b><tt>-O0</tt></b>. </ul> <h4><a name="Pyramid"></a>Pyramid MIServer-S</h4> <p> See "<a href="#ATT_7040">AT&T 7040 R3</a>". <h4><a name="RS6000"></a>IBM RS/6000 with AIX</h4> <ul> <li>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 <b><tt>unixansi.mak</tt></b> with <b><tt>CC=cc</tt></b> should work. <li>You must also edit the makefile (<b><tt>unixansi.mak</tt></b>) to change <b><tt>INSTALL</tt></b> to <b><tt>/usr/ucb/install</tt></b>. <li>AIX doesn't use a separate library for multi-thread support: set <b><tt>STDLIBS=-lm</tt></b> in the makefile. <li>If <b><tt>-DSYSV</tt></b> produces a complaint about the functions <b><tt>index</tt></b> and <b><tt>rindex</tt></b> not being defined, try removing it. <li>If the xlc 1.2.1 optimizer runs out of memory, you may need to add <b><tt>-qmaxmem=4000</tt></b> to <b><tt>CFLAGS</tt></b>. <li>A user reports that the AIX C compiler shipped with AIX 3.2.5 compiles Ghostscript only if invoked with "<b><tt>c89 -D_POSIX_SOURCE</tt></b>" and <b><em>without</em></b> <b><tt>-O</tt></b>. On the other hand, another user reports successful compilation using <b><tt>unix-ansi.mak</tt></b> and the command line <p> <b><tt>make CC=c89 XCFLAGS="-DOSY_AIX -D_ALL_SOURCE -qnoro -qmaxmem=3000 -bfl" $*</tt></b><br> <li>Apparently some (but not all) releases of the C library declare the <b><tt>hypot</tt></b> function: if the declaration in <b><tt>math_.h</tt></b> produces an error message, try removing it. <li>The IBM X11R3 server is known to be buggy: use the MIT X server if possible. <li>The xlc 1.3.0.x compiler provided in AIX 3.2.5+ definitely will not compile Ghostscript correctly if <b><tt>-O</tt></b> is used on all files. A user reports that compiling <b><tt>z</tt></b>*<b><tt>.c</tt></b>, <b><tt>gsmatrix.c</tt></b>, <b><tt>gxstroke.c</tt></b> without <b><tt>-O</tt></b> is sufficient to produce a working executable:. <li>Some installations of AIX 3.2.5 have what appears to be an incorrect or inconsistent version of <b><tt>libXt.a</tt></b> in <b><tt>/usr/lpp/X11/lib</tt></b>. If linking shows <b><tt>XtShellStrings</tt></b> and <b><tt>XtStrings</tt></b> as unresolved externals, set "<b><tt>XLIBDIRS=-L/usr/lpp/X11/lib/R5 -L/usr/lpp/X11/lib</tt></b>" rather than just "<b><tt>XLIBDIRS=-L/usr/lpp/X11/lib</tt></b>". <li>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: <p> <b><tt>CC=xlc</tt></b> <br> <b><tt>XCFLAGS=-qalign=natural</tt></b> </ul> <h4> <a NAME="Silicon_Graphics"></a>Silicon Graphics</h4> <p> 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. <ul> <li> To make the optimizer allocate enough table space, set <p><b><tt>CFLAGS="-Olimit 2500"</tt></b> (for older compilers) <br><b><tt>CFLAGS="-OPT:Olimit=2500"</tt></b> (for newer compilers) <p> 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. <li> With the compiler shipped with Irix 5.2, use the <b><tt>-ansi</tt></b> option. <li> The SGI C compiler may produce warnings about "Undefined the ANSI standard library defined macro stdin/stdout/stderr". To suppress these warnings, add "<b><tt>-woff 608</tt></b>" to the definition of <b><tt>CFLAGS</tt></b>. <li> The SGI C compiler shipped with Irix 6.1 and 6.2 will not compile <b><tt>zlib/deflate.c</tt></b> properly with optimization. Compile this file separately without <b><tt>-O</tt></b>. <li> 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: <ul> <li> Compile <b><tt>idict.c</tt></b> and <b><tt>isave.c</tt></b> separately without optimization after doing a normal compile; then relink.e.g.: <p> <b><tt>cc -OPT:Olimit=2500 -I. -I./obj -o ./obj/idict.o -c ./idict.c</tt></b><br> <b><tt>cc -OPT:Olimit=2500 -I. -I./obj -o ./obj/isave.o -c ./isave.c</tt></b> <li> Set <b><tt>CFLAGS=</tt></b> (no optimization). <li> Use only <b><tt>-O2</tt></b>. Compiler produces incorrect output with <b><tt>-O3</tt></b> or "<b><tt>-Ofast=ip32 -show</tt></b>". <li> 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 <b><tt>-o32</tt></b> option. Compiling with the (default) <b><tt>-n32</tt></b> option produces non-working executables. <b><tt>-O2</tt></b> is OK (possibly except for <b><tt>idict.c</tt></b>), but not <b><tt>-O3</tt></b>. </ul> </ul> <h4><a name="Sun"></a>Sun</h4> <ul> <li>The Sun unbundled C compiler (SC1.0) doesn't compile Ghostscript properly with the <b><tt>-fast</tt></b> option: Ghostscript core-dumps in <b><tt>build_gs_font</tt></b>. With that compiler use <b><tt>-g</tt></b>, or use gcc instead. <li>The Sun version of <b><tt>dbx</tt></b> often gives up with an error message when trying to load Ghostscript. If this happens, use GNU <b><tt>gdb</tt></b> instead. (<b><tt>gdb</tt></b> is more reliable than <b><tt>dbx</tt></b> in other ways as well.) <li>A bug in some versions of <b><tt>zlib</tt></b> results in an undefined symbol <b><tt>zmemcmp</tt></b> when compiling with Sun cc. Use gcc instead. </ul> <h4><a name="SunOS"></a>SunOS</h4> <ul> <li>The <tt><b>tar</b></tt> 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 <tt><b>tar</b></tt>, such as GNU <tt><b>tar</b></tt>. <li>In SunOS 4.1.[23], you may get undefined symbols <b><tt>_get_wmShellWidgetClass</tt></b> and <b><tt>_get_applicationShellWidgetClass</tt></b> when linking. Compiling "<b><tt>-Bstatic -lXmu -Bdynamic</tt></b>" appears to work for SC1.0. For gcc, try adding <b><tt>-static</tt></b> to <b><tt>CFLAGS</tt></b>. To solve the problem if you are using OpenWindows 3.0 (X11R4-based Xt), ask Sun for patches 100512-02 and 100573-03. </ul> <h4><a name="Solaris"></a>Solaris</h4> <ul> <li>Solaris 2.2 may require setting "<b><tt>EXTRALIBS=-lsocket</tt></b>". Solaris 2.3 and later seem to require "<b><tt>EXTRALIBS=-lnsl -lsocket -lposix4</tt></b>". <li>For Solaris 2.6 (and possibly some other versions), if you set <b><tt>SHARE_LIBPNG=1</tt></b>, <b><tt>SHARE_ZLIB=1</tt></b>, or <b><tt>SHARE_JPEG=1</tt></b>, you may need to set <p> <b><tt>XLDFLAGS=-R /usr/local/</tt></b>xxx<b><tt>/lib:/usr/local/lib</tt></b> <p> using the full path names of the relevant directories. <li>Solaris 2.<em>n</em> uses <b><tt>/usr/openwin/share/include</tt></b> for the X11 libraries rather than <b><tt>/usr/local/X/include</tt></b>. <li>Solaris 2.<em>n</em> typically has Type 1 fonts in <b><tt>/usr/openwin/lib/X11/fonts/Type1/outline</tt></b>. <li>For Solaris 2.<b><tt>n</tt></b> in the makefile you must change the definition of <b><tt>INSTALL</tt></b> from "<b><tt>install -c</tt></b>" to "<b><tt>/usr/ucb/install -c</tt></b>". <li>You may need to set <b><tt>XLIBDIR</tt></b> to the directory that holds the X11 libraries, as for other SVR4 systems. Set <b><tt>-DSVR4</tt></b> in <b><tt>CFLAGS</tt></b>. <li>If you are using the SunPRO C compiler, don't use optimization level <b><tt>-xO3</tt></b>. On SPARC platforms the compiler hangs; on Intel platforms the generated code is incorrect. With this compiler on Intel, do not use the <b><tt>-native</tt></b> flag: floating point computations become unacceptably inaccurate. You can use <b><tt>-xcg92</tt></b> (SPARC V8) and <b><tt>-dalign</tt></b> for better performance. </ul> <h4><a name="VAX_Ultrix"></a>VAX with Ultrix</h4> <ul> <li>You may wish to set <p> <b><tt>GS_LIB_DEFAULT=$(gsdatadir):/usr/lib/DPS/outline/decwin:$(gsdatadir)/fonts</tt></b> <p> in the makefile to add the Display PostScript font directory to the font search path. </ul> <hr> <h2><a name="OS2_build"></a>How to build Ghostscript from source (OS/2 version)</h2> <p> <em>Note: This section was contributed by a user: please e-mail Hermann Ulrichsk�tter <<a href="mailto:ulrichsk@t-online.de">ulrichsk@t-online.de</a>> if you have questions or problems.</em> <p> 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. <ul> <li>The relevant makefile is <b><tt>os2.mak</tt></b> The gcc/emx 0.9b (or later) compiler and IBM <b><tt>NMAKE.EXE</tt></b> are required. <li>For gcc/emx versions 0.9c and later, the <b><tt>LINK386</tt></b> command must <b><em>include</em></b> "<b><tt>$(COMPBASE)\lib\end.lib</tt></b>"; version 0.9b requires <b><em>omitting</em></b> it. The current <b><tt>os2.mak</tt></b> file does include this file in the <b><tt>LINK386</tt></b> command, so if you are using 0.9b, delete this file reference before building. <li>Be sure you are using the standard OS/2 shell, <b><tt>CMD.EXE</tt></b>. Some other shells have bugs or differences that cause the makefile not to work. <li>Make sure you followed the instructions in "How to unpack the source code" and "How to unpack the third-party libraries". <li>Use jpegsrc_v6b.tar.gz, zlib-1.2.x.tar.gz and libpng-1.2.x.tar.gz. Earlier versions may not work. <li>If you wish to include support for XFree86, edit the makefile to change <b>BUILD_X11=0</b> to <b>BUILD_X11=1</b>. XFree86 for OS/2 can be obtained from <a href="http://borneo.gmd.de/~veit/os2/xf86os2.html"> http://borneo.gmd.de/~veit/os2/xf86os2.html</a> You must use emx 0.9d. </ul> <p> Before compiling or linking, execute <b><tt>md bin</tt></b> and <b><tt>md obj</tt></b> in the <b><tt>gs</tt></b> directory to create the directories for the binaries. <p> First, build the standard configuration: <ul> <li>Edit gs/src/os2.mak: find line with 'CO=-O' (Optimizer flag) and edit this line to 'CO=-O2' (-O or -O1 do not work!). <li>To start the make process, type <b><tt>nmake -f .\src\os2.mak</tt></b>, from the gs-directory. <li>One DLL and two EXEs will be produced in <b><tt>gs/bin</tt></b>: <b><tt>gsdll2.dll</tt></b> (the Ghostscript DLL), <b><tt>gsos2.exe</tt></b> (the Ghostscript executable) and <b><tt>gspmdrv.exe</tt></b> (the Presentation Manager display driver). All other newly generated files will be produced in <b><tt>gs/obj</tt></b>. </ul> <p> Now, if you wish, you can edit OS2.MAK to suit your needs, and then perform <b><tt>nmake -f .\src\os2.mak clean</tt></b> and then <b><tt>nmake -f .\src\os2.mak</tt></b>. <hr> <h2><a name="VMS_build"></a>How to build Ghostscript from source (OpenVMS version)</h2> <p>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. <p> DEC C runtime library versions 5.5 and newer have an <b><tt>exit</tt></b> 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 <b><tt>genarch</tt></b> or <b><tt>echogs</tt></b> finish executing, find the line in stdpre.h that reads <blockquote><b><tt> /*#define OLD_VMS_C*/ </tt></b></blockquote> and remove the <b><tt>/*</tt></b> and <b><tt>*/</tt></b>, changing it to <blockquote><b><tt> #define OLD_VMS_C </tt></b></blockquote> <p> 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 <a href="Use.htm#X_server_bugs">work around X server bugs</a> using X resources; also report the problem to DEC, or whomever supplied your X server. <p> 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 <a href="Use.htm">usage documentation</a> tells how to do this. <p> You can <a href="Fonts.htm#Precompiling">precompile any Type 1 font</a> into C, then compile and build it into Ghostscript, as described in the <a href="Fonts.htm">fonts documentation</a>. If you do this, then add "<b><tt>$(PSD)ccfonts.dev</tt></b>" to <b><tt>FEATURE_DEVS</tt></b> in <b><tt>OPENVMS.MAK</tt></b>: <blockquote><b><tt> $ FEATURE_DEVS = "$(PSD)psl3.dev $(PSD)pdf.dev $(PSD)dpsnext.dev $(PSD)ttfont.dev $(PSD)ccfonts.dev" </tt></b></blockquote> <p> Specify the font names with <b><tt>ccfonts1</tt></b>: <blockquote><b><tt> $ ccfonts1 = "Courier Courier_Oblique Courier_Bold Courier_BoldOblique" </tt></b></blockquote> <p> If this makes the line too long, add another line of the same form, such as <blockquote><b><tt> $ ccfonts1 = "Courier Courier_Oblique Courier_Bold Courier_BoldOblique" $ ccfonts2 = "Times_Roman Times_Italic Times_Bold Times_BoldItalic" </tt></b></blockquote> <h3><a name="GNU_make_VMS"></a>Building with GNU make on OpenVMS</h3> <p> <em>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 <a href="#MMK_MMS_VMS">below</a> for details.</em> <p> As of Ghostscript version 5.0 you can use GNU make -- with the file <b><tt>OPENVMS.MAK</tt></b> and some auxiliary <b><tt>.COM</tt></b> files -- to build Ghostscript on OpenVMS. Use the command: <blockquote> <b><tt>make -fopenvms.mak "DECWINDOWS=</tt></b><em>[</em><b><tt>1.2</tt></b><em>]</em><b><tt>"</tt></b> </blockquote> <p> That is, specify either "<b><tt>1.2</tt></b>" or nothing (blank) as the value of <b><tt>DECWINDOWS</tt></b>. In Europe and other parts of the world where ISO standard paper sizes are used, append "<b><tt>A4_PAPER=1</tt></b>" to that line to make A4 the default paper size at run time. <p> 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 <a href="http://www.gnu.org/">Free Software Foundation's</a> ftp site and its mirrors. See <blockquote> <a href="ftp://ftp.gnu.org/pub/gnu/" class="offsite">ftp://ftp.gnu.org/pub/gnu/</a> </blockquote> <h3><a name="MMK_MMS_VMS"></a>Building with MMK or MMS on OpenVMS</h3> <p> 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. <p> Building Ghostscript with MMK or MMS uses the file <b><tt>OPENVMS.MMK</tt></b> and some auxiliary <b><tt>.COM</tt></b> files. To build Ghostscript with MMK or MMS, use the command: <blockquote> <b><tt>###/descrip=[.src]openvms.mmk/macro=("DECWINDOWS1_2=</tt></b><em>{</em><b><tt>0</tt></b>,<b><tt>1</tt></b><em>}</em><b><tt>")</tt></b> </blockquote> where <b><tt>###</tt></b> is either <b><tt>mmk</tt></b> or <b><tt>mms</tt></b>. <p> Specify <b><tt>DECWINDOWS1_2=1</tt></b> for DECWINDOWS 1.2, <b><tt>DECWINDOWS1_2=0</tt></b> for other DECWINDOWS versions. In Europe and other parts of the world where ISO standard paper sizes are used, add <b><tt>,"A4_PAPER=1"</tt></b> just before the final closing parenthesis to make A4 the default paper size at run time. <p> To download MMK (source code, and VAX and Alpha executables), visit <blockquote> <a href="http://www.madgoat.com/mmk.html">http://www.madgoat.com/mmk.html</a> </blockquote> <hr> <h2><a name="Other_environments"></a>Other environments</h2> <h3><a name="No_multi_thread"></a>Environments lacking multi-threading</h3> <p> 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 <b><tt>SYNC=nosync</tt></b> 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 <b><tt>DEVICE_DEVS*</tt></b> lists of any makefile that we distribute. <h3><a name="Plan_9"></a>Plan 9</h3> <p> Use <b><tt>unix-gcc.mak</tt></b>, editing it to define <blockquote><b><tt> CC=cc GCFLAGS=-D_BSD_EXTENSION -DPlan9 </tt></b></blockquote> <p> You will also probably have to edit many path names. <h3><a name="QNX"></a>QNX</h3> <p> 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 <b><tt>/etc/config/lpsrvr</tt></b> 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. <dl> <dt><b><tt>unixansi.mak</tt></b> <dd><table cellpadding=0 cellspacing=0> <tr valign=bottom> <th align=left>Original lines <td> <th align=left>Change to <tr> <td colspan=3><hr> <tr valign=top> <td><b><tt>INSTALL = install -c<br>INSTALL_PROGRAM = $(INSTALL) -m 755<br>INSTALL_DATA = $(INSTALL) -m 644</tt></b> <td> <td><b><tt>INSTALL = cp<br>INSTALL_PROGRAM = $(INSTALL)<br>INSTALL_DATA = $(INSTALL)</tt></b> <tr> <td colspan=3><hr> <tr valign=top> <td><b><tt>datadir = $(prefix)/share</tt></b> <td> <td><b><tt>datadir = $(prefix)/lib</tt></b> <tr> <td colspan=3><hr> <tr valign=top> <td><b><tt>CFLAGS_STANDARD=-O</tt></b> <td> <td><b><tt>CFLAGS_STANDARD=-Otx -zp1 -mf</tt></b> <tr> <td colspan=3><hr> <tr valign=top> <td><b><tt>LDFLAGS=$(XLDFLAGS)</tt></b> <td> <td><b><tt>LDFLAGS=-mf -N32k $(XLDFLAGS)</tt></b> <tr> <td colspan=3><hr> <tr valign=top> <td><b><tt>EXTRALIBS=</tt></b> <td> <td><b><tt>EXTRALIBS=-lXqnx_s -lsocket</tt></b> <tr> <td colspan=3><hr> <tr valign=top> <td><b><tt>XINCLUDE=-I/usr/local/X/include</tt></b> <td> <td><b><tt>#XINCLUDE=-I/usr/local/X/include</tt></b> <tr> <td colspan=3><hr> <tr valign=top> <td><b><tt>XLIBDIRS=-L/usr/local/X/lib<br>XLIBDIR=<br>XLIBS=Xt Xext X11</tt></b> <td> <td><b><tt>#XLIBDIRS=-L/usr/local/X/lib<br>#XLIBDIR=<br>XLIBS=Xt_s Xext X11_s</tt></b> <tr> <td colspan=3><hr> </table> </dl> <dl> <dt><b><tt>gp_unifs.c</tt></b> <dd>After the line <blockquote> <b><tt>#include <sys/param.h></tt></b> </blockquote> <p> add these lines: <blockquote> <b><tt>#if defined(__QNX__)<br> #include <unix.h><br> #endif</tt></b><br> </blockquote> </dl> <dl> <dt><b><tt>gp_unix.c</tt></b> <dd>After the line <blockquote> <b><tt>#include "time.h"</tt></b> </blockquote> <p> add these lines: <blockquote> <b><tt>#if defined(__QNX__)<br> #include <sys/time.h><br> #endif</tt></b><br> </blockquote> </dl> <dl> <dt><b><tt>time_.h</tt></b> <dd>Modify the line beginning <blockquote> <b><tt># if defined(Plan9) ||</tt></b> </blockquote> <p> to begin <blockquote> <b><tt># if defined(__QNX__) || defined(Plan9) ||</tt></b> </blockquote> </dl> <dl> <dt><b><tt>/etc/config/lpsrvr</tt></b> <dd>Here is Hawkey's <b><tt>lpsrvr</tt></b> as an example. <blockquote> <pre># 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 </pre></blockquote> </dl> <h2><a name="UFST_build"></a>How to build Ghostscript with UFST</h2> <p> <em>Note: This section is only for customers who have licensed Agfa's UFST. Other users please skip this section. </em> <p> Ghostscript sources do not include UFST sources. You need to obtain them from Agfa. Ghostscript includes only some source modules that provide a bridge to UFST. <p> Ghostscript makefiles do not include any script for building UFST libraries. Refer to Agfa's manual how to build them. UFST object libraries must be built before building Ghostscript with the UFST bridge. <p> To build Ghostscript with UFST, specify additional options for "make": <dl> <dt><b><tt>UFST_BRIDGE=1</tt></b> <dd>forces the UFST bridge to build. <dt><b><tt>UFST_ROOT=path</tt></b> <dd>specifies the path to UFST root directory or folder. <dt><b><tt>UFST_CFLAGS=options</tt></b> <dd>specifies C compiler options for UFST library. Refer to Agfa's manual for information about them. <dt><b><tt>UFST_LIB_EXT=extension</tt></b> <dd>sets the file name extension for object libraries. You must use the appropriate one for your platform and linker. </dl> <p>An example for Unix/GCC : <blockquote> <tt>UFST_BRIDGE=1 UFST_ROOT=../Agfa UFST_CFLAGS=-DGCCx86 UFST_LIB_EXT=.a</tt> </blockquote> <p>For Windows/MSVC you need only specify UFST_ROOT. msvc32.mak sets the other options automatically. <p> <h2><a name="FT_build"></a>How to build Ghostscript with Free Type</h2> <p> <em>Note: This section is only for users who wish to use Ghostscript with Free Type font renderer. Other users please skip this section. </em> <p> Ghostscript sources do not include Free Type sources. You need to obtain them from Free Type group. Ghostscript includes only some source modules that provide a bridge to Free Type. <p> Ghostscript makefiles do not include any script for building Free Type libraries. Refer to Free Type manual how to build them. Free Type object libraries must be built before building Ghostscript with the Free Type bridge. <p> To build Ghostscript with Free Type, specify additional options for "make": <dl> <dt><b><tt>FT_BRIDGE=1</tt></b> <dd>forces the Free Type bridge to build. <dt><b><tt>FT_ROOT=path</tt></b> <dd>specifies the path to Free Type root directory or folder. <dt><b><tt>FT_CFLAGS=options</tt></b> <dd>specifies C compiler options for Free Type library. Refer to Free Type manual for information about them. <dt><b><tt>FT_LIB_EXT=extension</tt></b> <dd>sets the file name extension for object libraries. You must use the appropriate one for your platform and linker. </dl> <p>An example for Unix/GCC : <blockquote> <tt>FT_BRIDGE=1 FT_ROOT=../FreeType FT_CFLAGS=-DGCCx86 FT_LIB_EXT=.a</tt> </blockquote> <p>For Windows/MSVC you need only specify FT_ROOT. msvc32.mak sets the other options automatically. <p> <!-- [2.0 end contents] ==================================================== --> <!-- [3.0 begin visible trailer] =========================================== --> <hr> <p> <small>Copyright © 1996, 2000 Aladdin Enterprises. All rights reserved.</small> <p> 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 the license contained in the file LICENSE in this distribution. For more information about licensing, please refer to http://www.ghostscript.com/licensing/. For information on commercial licensing, go to http://www.artifex.com/licensing/ or contact Artifex Software, Inc., 101 Lucas Valley Road #110, San Rafael, CA 94903, U.S.A., +1(415)492-9861. <p> <small>Ghostscript version 8.53, 20 October 2005 <!-- [3.0 end visible trailer] ============================================= --> </body> </html>