This directory contains "p2c" version 1.20, a Pascal to C translator. "p2c" Copyright 1989, 1990, 1991 Free Software Foundation, Inc. Written and maintained by: Dave Gillespie 256-80 Caltech Pasadena CA 91125 daveg@csvax.cs.caltech.edu, cit-vax!daveg This program is distributed under the terms of the GNU License Agreement. See the file src/COPYING for details. The GNU License Agreement restrictions do _not_ apply to code generated by p2c, nor to the p2c run-time files "p2clib.c" and "p2c.h". QUICK INSTRUCTIONS The top-level Makefile in this directory tree knows how to build p2c and run it on some example programs. The compiled p2c will be "installed" in this directory tree rather than in public directories. (For a full public installation, see the instructions below.) Just type "make test" to build p2c and run the examples. FULL INSTALLATION INSTRUCTIONS For a complete system, you must: a) Create a home directory for p2c, such as /usr/lib/p2c. The exact location does not matter, as long as p2c knows how to find it. b) Create an include directory, such as /usr/include/p2c. If you are unable to arrange for an include directory, you can edit sys.p2crc so as not to require one, or compile translated code with a suitable -I flag. c) Install the executable "p2c" in /usr/bin or elsewhere on the standard search path. d) Install the run-time library "libp2c.a" in /usr/lib or elsewhere on the standard library search path. e) Install the Unix manual entry "p2c.1" in /usr/man/man1. If you have a "man1.Z" directory instead (for compressed man pages) you will have to edit the Makefile to use a "compress" command. f) Install the necessary files in the p2c home directory. The Makefile is initially set up to create a private version of p2c in the p2c distribution directory. Just "cd src" and "make install" to perform the above steps. This will place the p2c executable, run-time library, include directory, and man page in the "home" subdirectory of the distribution directory. The man page will be in human-readable form. To compile code that has been translated by this private version of p2c, use the command: cc -I. foo.c libp2c.a (assuming "home," i.e., HOMEDIR, is the current directory.) The "examples" subdirectory contains a few sample Pascal programs and a Makefile to translate and compile them. To install p2c for public use, edit the Makefile to indicate the correct directory names. Suggested names are included as comments. Also change MANFILE as shown to store the man page in the proper form for the "man" command. HOMEDIR default /usr/lib/p2c Home directory INCDIR default /usr/include/p2c Include directory BINDIR default /usr/bin Directory for "p2c" executable LIBDIR default /usr/lib Directory for "libp2c.a" library MANDIR default /usr/man/man1 Directory for "p2c.1" manual page Make sure the home and include directories have been created and are writable, and that the bin, lib, and man directories are writable. (You may have to be root to do this.) Recompile "p2c" with another "make install". Be sure "trans.c" is recompiled with the new value of HOMEDIR; you can ensure this by doing "make newhome" before "make install". You can always type "make" with no arguments to compile without installing. HP Pascal Workstation System users will want to copy all of ../HP/include into the new p2c include directory, and copy all of ../HP/import into the p2c home directory. You will have to write emulations for the functions you use out of these modules. (The HP directories are present in the ftp distribution only---they have been omitted from the shar'd version to save space.) Incomplete interface texts for standard Turbo units are included in turbo.imp. Turbo users will have to flesh these out and write emulations for whatever parts of the Turbo runtime library they need. If you wish to edit various system-wide configuration parameters, it is better to put them in loc.p2crc than in sys.p2crc. As an example, on a Turbo-oriented environment you may wish to add Language Turbo to the loc.p2crc file to replace the normal default (HP Pascal). PORTABILITY P2c was originally developed on a homebrew C compiler on the HP Pascal Workstation operating system. Current development takes place on HP-UX, which is System V based. The translator has also been compiled and used on Sun-3's, so presumably it is fairly portable among 32-bit Unix machines. Many parts of the code will have to be adjusted in order for p2c to work on a machine with 16-bit ints. I have never had reason or opportunity to track these down since I don't have access to such a machine. Please note that code _generated_ by p2c works with either size of int even though p2c itself does not. If your compiler supports ANSI prototypes, most of the 16-bit portability problems will go away except for possible %d/%ld sloppiness in sprintf control strings. There may be places where p2c tries to cast a pointer into an int, but I believe all such cases use longs consistently. You will have a problem if your long type is not large enough to store a pointer. Because p2c was developed to run under Unix, it is sloppy about memory allocation. Some data structures are allocated but never freed. Profiles show that the waste is not too great in most cases, but if it is a problem you may have to write a garbage collector (this shouldn't be too hard if you only run the collector after translating each procedure).