home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / language / gofer / Sources / original / Readme < prev   
Encoding:
Text File  |  1993-02-12  |  16.4 KB  |  401 lines

  1. -------------------------------------------------------------------------------
  2. This directory contains the source for Gofer 2.28, including both the
  3. interpreter and compiler.
  4.  
  5. The following give brief instructions for installing the system from
  6. these sources.  More detailed instructions for specific machines are
  7. given below.
  8.  
  9. You will need a directory which is available to all Gofer users on
  10. your system to store prelude files etc.  You can choose this to be
  11. whatever you like.  I'll just call it $GOFLIB here.  On Unix systems,
  12. I usually use /usr/local/lib/Gofer or a subdirectory of my home
  13. directory, Gofer/lib.  On DOS systems, I suggest C:\GOFER\LIB.
  14.  
  15. 1) Unpack the sources in a temporary directory.  Copy all of the .prelude
  16.    files (these will be .PRE files under DOS) to $GOFLIB.
  17.  
  18. 2) Edit the file prelude.h to select a particular machine type.  All but
  19.    one of the machine names should be #define'd as 0.  Set the #define
  20.    for the machine on which you wish to compile Gofer to 1.
  21.  
  22.    If appropriate, edit the Makefile as necessary to suit your system.
  23.  
  24.    If you plan to install the Gofer compiler, edit the file cmachine.c
  25.    so that the symbol GOFC_INCLUDE is set to a string containing the
  26.    pathname $GOFLIB/gofc.h -- you will see that my two suggested settings
  27.    are already set as defaults.
  28.  
  29.    Specific details for particular machine/configurations are given below.
  30.  
  31. 3) Build the system (on a Unix system, this usually means just typing
  32.    `make' and going to get a cup of something to drink ...)
  33.  
  34.    If you modify parser.y, you will need a version of yacc to create a
  35.    suitable new version of parser.c.  I've had reports that the Gofer
  36.    grammar doesn't work correctly if you use either GNU bison or Berkeley
  37.    Yacc (both have a common ancestor so it's not too surprising).  If
  38.    you have any doubts, make sure that you use the parser.c file supplied
  39.    with the source rather than letting a local version of yacc create a
  40.    new one for you.  The easiest way to do this is probably to edit the
  41.    makefile to leave out the construction of parser.c.
  42.  
  43. 4) If you are going to use the Gofer compiler:
  44.    Assuming a successful build, copy the files prelude.h and gofc.h to
  45.    $GOFLIB and edit the file gofc.h, replacing #include "prelude.h"
  46.    with something like #include "$GOFLIB/prelude.h" -- don't actually
  47.    enter the string "$GOFLIB/prelude" here, you're meant to replace
  48.    $GOFLIB by whatever directory name you chose at the beginning of
  49.    this process.  You will also need to copy the file runtime.o (or
  50.    runtime.obj, depending on your system) into $GOFLIB.
  51.  
  52. 5) You're all set.  In practice, you'll want to move the gofer and gofc
  53.    binaries to somewhere sensible (probably into $GOFLIB on a unix system,
  54.    modifying the scripts in the scripts subdirectory to point to the
  55.    appropriate executables and prelude files).  And you may want to
  56.    clean off any remaining object code files too ...
  57.  
  58. I've probably left something out here.  Please let me know if you have
  59. any trouble or spot anything that I've left out.
  60.  
  61.  
  62. ---------------------
  63. GNU READLINE (or equivalent)
  64.  
  65. Gofer can be compiled to make use of the GNU readline library.  I tried
  66. this using the readline library provided by GNU bash 1.12, although I've
  67. found that, for my simple purposes, the editline library posted in
  68. alt.sources works as well, and is a fraction of the size.
  69.  
  70. See the Makefile for more details.
  71.  
  72.  
  73. ---------------------
  74. TURBO C version 1.5 on a PC with MSDOS:
  75.  
  76. Set #define TURBOC 1  and the rest to 0 in prelude.h.  Use the supplied
  77. project files gofer.prj and gofc.prj to generate the interpreter and
  78. compiler respectively.  Before starting the compilation, make sure that
  79. you set the following command line options (all of this is intended to
  80. be carried out from within the IDE):
  81.  
  82.    Medium model,  stack check ON,  Merge duplicate strings, Jump
  83.    optimization ON,  Possibly incorrect assignment warning off.
  84.  
  85. Select project gofer.prj and make.  Select project gofc.prj and make.
  86.  
  87. In order to make the runtime library and use the compiler, I suggest
  88. creating a batch file GTCC.BAT containing:
  89.  
  90.   tcc -O -ms -IC:\TURBOC\INCLUDE -LC:\TURBOC\LIB %1 %2 %3 %4 %5 %6 %7
  91.  
  92. then use this to build the runtime system:  gtcc -c runtime.c
  93. and compile programs using:                 gofc prog.gs
  94.                                             gtcc prog.c runtime.obj
  95.  
  96. Since the PC has a fairly limited amount of memory, you may find that you
  97. need to compile a new version of the Gofer system without floating point
  98. support (or you may need to select a markscan garbage collector in place
  99. of the default twospace collector).
  100.  
  101.  
  102. ---------------------
  103. BORLAND C++ version 3.1 on a PC with MSDOS:
  104.  
  105. Set #define BCC 1  and the rest to 0 in prelude.h.  You will need to
  106. remove the project files gofer.prj and gofc.prj supplied with the
  107. Gofer source and rebuild your own project files from within the IDE.
  108. The project file for the interpreter should contain the files:
  109.  
  110.     gofer.c, input.c, static.c, type.c, compiler.c, machine.c,
  111.     storage.c, output.c and builtin.c.
  112.  
  113. The project file for the compiler should contain the files:
  114.  
  115.     gofc.c, input.c, static.c, type.c, compiler.c, cmachine.c,
  116.     storage.c and cbuiltin.c.  (output.c is not required).
  117.  
  118. Before starting the compilation, make sure that you set the following
  119. command line options (all of this is intended to be carried out from
  120. within the IDE):
  121.  
  122.    Medium model,  stack check ON,  Merge duplicate strings, No debugging
  123.    information in object files, no standard stack frames, fastest code
  124.    (or smallest, if memory is tight), source debugging - none, possibly
  125.    incorrect assignment warning off.
  126.  
  127. If you have a 386 machine or a floating point coprocessor, you will find
  128. a small benefit in setting the relevant compiler options to make use of
  129. these features too.
  130.  
  131. In order to make the runtime library and use the compiler, I suggest
  132. creating a batch file BTCC.BAT containing:
  133.  
  134.   Bcc -O -ms -IC:\BORLANDC\INCLUDE -LC:\BORLANDC\LIB %1 %2 %3 %4 %5 %6 %7
  135.  
  136. then use this to build the runtime system:  btcc -c runtime.c
  137. and compile programs using:                 gofc prog.gs
  138.                                             btcc prog.c runtime.obj
  139.  
  140. Since the PC has a fairly limited amount of memory, you may find that you
  141. need to compile a new version of the Gofer system without floating point
  142. support (or you may need to select a markscan garbage collector in place
  143. of the default twospace collector).
  144.  
  145.  
  146. ---------------------
  147. DJGPP 1.09 on MSDOS:
  148.  
  149. DJGPP is a DOS port of the GNU C compiler produced by DJ Delorie.  It
  150. requires a 386 or better, but gives you much better opportunities to
  151. make use of the resources that such machines provide.  Much larger
  152. heaps can be used, and the 32 bit code produced by DJGPP runs a lot
  153. faster than the versions produced by TURBO C or BORLAND C, even on the
  154. same machine!
  155.  
  156. DJGPP depends on the use of a DOS extender, go32.  A modified version
  157. of go32 has been produced which supports signals, allowing the Gofer
  158. interpreter to recover from a program interrupt (i.e. pressing ^C
  159. during an evaluation).  The original version of go32 was written by
  160. DJ Delorie.  Rami El Charif has modified go32 to handle signals,
  161. essential for any serious work with Gofer.  Thanks Rami!
  162.  
  163. Instructions for building the modified go32 and compiling Gofer with
  164. DJGPP 1.09 are included in the readme file in the go32sgof.zip archive
  165. in the standard Gofer distribution.
  166.  
  167.  
  168. ---------------------
  169. NEXT versions:
  170.  
  171. Set #define NEXTSTEP 1 and the rest to 0 in prelude.h.  Edit the Makefile
  172. to set the C compiler (defined by the macro CC) to cc.  (If you would
  173. prefer to use the current GNU C compiler i.e. gcc 2.x and have this
  174. installed on your system, choose #define NEXTGCC 1 instead of NEXTSTEP
  175. and set CC to gcc).  Run the make command to build gofer, gofc and runtime.o.
  176.  
  177.  
  178. ---------------------
  179. SUNOS versions:
  180.  
  181. Set #define SUNOS 1 and the rest to 0 in prelude.h.  Edit the Makefile
  182. as necessary.  I tried this on a Sun 4 using gcc, but I think it should
  183. also work on Sun 3, and with cc ...  If your site has both Sun3 and
  184. Sun4 machines, the following script may be of use:
  185.  
  186.     #!/bin/sh
  187.  
  188.     GOFER=/usr/local/lib/Gofer/prelude
  189.     export GOFER
  190.  
  191.     if (sparc) then
  192.         exec /usr/local/lib/Gofer/gofer4 $*
  193.     elif (m68k) then
  194.         exec /usr/local/lib/Gofer/gofer3 $*
  195.     else
  196.         echo I dont know how to start Gofer on your machine
  197.     fi
  198.  
  199.  
  200. ---------------------
  201. IBM OS/2 2.0 using EMX GCC:
  202.  
  203. Set #define OS2 1 and the rest to 0 in prelude.h.  The tweaks to prelude.h
  204. to get this working with OS/2 were sent to me by Bryan Scattergood this
  205. morning;  this is a last-minute update.  Thanks Bryan!
  206.  
  207.  
  208. ---------------------
  209. System V release 4 using GCC2.2:
  210.  
  211. Set #define SVR4 1 and the rest to 0 in prelude.h.  As in the case of OS/2,
  212. I received patches for SVR4 this morning from Bryan Scattergood.  Thanks
  213. again Bryan!
  214.  
  215.  
  216. ---------------------
  217. HP systems:
  218.  
  219. Set #define HPUX 1 and the rest to 0 in prelude.h.  I've had patches
  220. for HP machines from a number of people including Tom Lane, Dipankar
  221. Gupta, Rodney Brown and Jeroen Fokker and I've tried to work these into
  222. the source for 2.28.  There were occasional discrepancies between the
  223. sets of patches that I received so I sometimes had to take a `majority
  224. vote'; perhaps they were for slightly different machines?  Anyway, I
  225. hope that Gofer will compile on HP machines using these settings -- or
  226. at least be easy to patch to make it run correctly if not.  Thanks for
  227. the patches everyone!
  228.  
  229. It has now been verified that the HPUX patch version will at least compile
  230. correctly on HP series 400 workstations (68040 CPU) running HP-UX 8.0 with
  231. gcc, thanks to Kurt Olender!
  232.  
  233.  
  234. ---------------------
  235. DECstation 5000 running Ultrix 4.2 (MIPS R3000 CPU) with GCC2.3.3:
  236.  
  237. Set #define ULTRIX 1 and the rest to 0 in prelude.h.  Thanks to Kurt Olender
  238. for the patches!
  239.  
  240.  
  241. ---------------------
  242. IBM AIX on RS/6000 using GCC:
  243.  
  244. Set #define AIX 1 and the rest to 0 in prelude.h.  Thanks (again) to Kurt
  245. Olender for the patches!
  246.  
  247.  
  248. ---------------------
  249. Minix 68K:
  250.  
  251. Set #define MINIX68K 1 and the rest to 0 in prelude.h.  Rainer Orth
  252. sent me sent me some patches to make Gofer 2.23 compile and run under
  253. Minix 68k using the GNU C compiler, I believe.  I have tried to make
  254. the same changes to the latest version, but I have not verified that
  255. they work.  Some small changes may be needed -- please let me know if
  256. you try it.  Thanks Rainer!
  257.  
  258.  
  259. ---------------------
  260. Linux with gcc:
  261.  
  262. Set #define LINUX 1 and the rest to 0 in prelude.h.  Ray Bellis sent me
  263. some patches to make Gofer 2.23 compile and run under Linux using the
  264. GNU C compiler.  I have tried to make the same changes to the latest
  265. version, but I have not verified that they work.  Some small changes
  266. may be needed -- please let me know if you try it.  And thanks, Ray!
  267.  
  268.  
  269. ---------------------
  270. Acorn DesktopC and RISCOS2 or 3:
  271.  
  272. Set #define RISCOS 1  and the rest to 0 in prelude.h.  Use the file
  273. AcornMake to build the Gofer system.  Thanks to Bryan Scattergood for
  274. the patches to make Gofer compile and run under RISCOS!
  275.  
  276.  
  277. ---------------------
  278. Amiga:
  279.  
  280. Set #define AMIGA 1  and the rest to 0 in prelude.h.  Compile using
  281. gcc 2.2.2.  Thanks to Luc and Mark Duponcheel for their help in
  282. getting this to work.  One small problem remains that ^C interrupts
  283. do not currently work.  I believe this can be solved by setting an
  284. appropriate value for the #define allowBreak() macro in prelude.h,
  285. but I am not sure what definition should be used.
  286.  
  287.  
  288. ---------------------
  289. DEC Alpha with OSF/1:
  290.  
  291. Set #define ALPHA 1 and the rest to 0 in prelude.h Briefly, I tried
  292. compiling Gofer on a 64 bit DEC Alpha with a preliminary version of
  293. OSF/1.  I didn't spend long, but it seems that it is probably safest to
  294. compile without using any optimization.  Furthermore, only the
  295. interpreter can be used at the current time and integers are restricted
  296. to 32 bit quantities.  I may do something to change this one day, but
  297. it is not a high priority.  Essentially, what needs to be done is to
  298. redefine the Int type as a synonym (i.e.  typedef) for long and to
  299. replace all appropriate uses of %d in prinf strings with %ld.
  300.  
  301.  
  302. ---------------------
  303. OTHER PLATFORMS:
  304.  
  305. Gofer has been tested on other platforms and most of the code is fairly
  306. standard.  The code does however make certain assumptions about the system
  307. on which Gofer will be used.  These are summarised below as an aid
  308. to those interested in porting Gofer to other systems:
  309.  
  310. 1) For the benefit of Garbage collection from the C stack, all function
  311.    parameters and local variables are expected to have sizes which are
  312.    a multiple of sizeof(Int) (defined in prelude.h).  In other words,
  313.    you should check that:
  314.  
  315.              sizeof(FloatImpType) % sizeof(Int) == 0
  316.              sizeof(String)       % sizeof(Int) == 0
  317.              sizeof(Char)         % sizeof(Int) == 0
  318.              sizeof(Long)         % sizeof(Int) == 0
  319.              sizeof(Unsigned)     % sizeof(Int) == 0
  320.  
  321.    (These types are defined in prelude.h and storage.h)
  322.  
  323. 2) Study the comments and settings in prelude.h in order to find out how
  324.    other ports of Gofer have been produced.
  325.  
  326. 3) The words local and far are used to access non-standard extensions
  327.    in Turbo C to allow the Gofer system to overcome some of the
  328.    limitations of the PC's segmented architecture.  These should be
  329.    #defined to empty strings on most other machines with a flat address
  330.    space.
  331.  
  332. 4) The current version of the garbage collector in the Gofer interpreter
  333.    uses the C call stack as an array of Cell values to find temporary
  334.    variables that point into the heap.  This is a well-known technique
  335.    often described as `conservative garbage collection' but the
  336.    implementation in C is inherently non-portable.  Surprisingly enough
  337.    though, for almost all of the machines supported, you can make some
  338.    simple assumptions and get things to work quite nicely.  The RISCOS
  339.    code is one example where things are very different.  But for the most
  340.    part, you can treat the C stack as an array of Cell values.  As the
  341.    program runs the size of the stack changes and you need to know the
  342.    extent of the array.  The first element pushed onto the stack is
  343.    pretty much fixed, so it is the position of the stack pointer that
  344.    determines how big the stack is.
  345.  
  346.    On many machines, the stack grows downwards.  I have yet to come across
  347.    a machine where the stack grows upwards, but I have heard that this
  348.    happens on some HP systems.
  349.  
  350.    Here is the way to deal with this in the current version of the code.
  351.    In machdep.c, you will find a function gcCStack() which traverses the
  352.    stack.  To make things easier, there are three macros:
  353.  
  354.       #define StackGrowsDown  ...
  355.       #define StackGrowsUp    ...
  356.       #define GuessDirection  ...
  357.  
  358.    The first two describe the way to mark the stack on a machine in which the
  359.    stack grows either up or down respectively.  The third tries to guess
  360.    which way to do things by comparing two pointers.  Strictly speaking,
  361.    this comparison probably doesn't fall under the definition of standard C
  362.    so it may not be portable.  The current usage of these functions is as
  363.    follows:
  364.  
  365.        #if HPUX
  366.            GuessDirection;
  367.        #else
  368.            StackGrowsDown;
  369.        #endif
  370.  
  371.     Change as necessary to suit your machine (and please let me know so that
  372.     I can update the source).
  373.  
  374. Almost all of the machine dependencies in the code for Gofer are contained
  375. in the header file "prelude.h", and the program file "machdep.c".  These
  376. files contain definitions for both the TURBOC and UNIX versions described
  377. above and should be a useful guide.
  378.  
  379. I regret that I do not have time to write more substantial notes for
  380. porting Gofer at the present time.  I will however be happy to offer
  381. advice and answer other questions if you want to contact me in person
  382. at the email address below.  If you do successfully complete a port for
  383. another machine, please let me know what changes are necessary.  I know
  384. that it isn't always possible, but if you can, please try to restrict
  385. changes to the prelude.h and machdep.c files.
  386.  
  387. ---------------------
  388.  
  389. NOTE: if Gofer starts behaving unexpectedly, try recompiling
  390. without full compiler optimisation and see if the problem still occurs.
  391. If so, please get in touch with me, giving me as much information about
  392. the problem as possible, and I'll try and sort it out for you.  If you
  393. find a bug which you fix yourself, please send me details so that I can
  394. pass the fix onto to other users of Gofer.
  395.  
  396. If gofc starts behaving unexpectedly, try running the same code through
  397. the interpreter.
  398.  
  399. jones-mark@cs.yale.edu
  400. -------------------------------------------------------------------------------
  401.