home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacGofer 0.22d / MacGofer Sources / Readme < prev    next >
Encoding:
Text File  |  1994-01-06  |  21.4 KB  |  516 lines  |  [TEXT/MPS ]

  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.    In particular, make sure that the CC macro is set to the name of
  24.    the compiler you will be using (this is usually either `cc' for the
  25.    standard C compiler on a system or `gcc' for the GNU C compiler).
  26.  
  27.    If you plan to install the Gofer compiler, edit the file cmachine.c
  28.    so that the symbol GOFC_INCLUDE is set to a string containing the
  29.    pathname $GOFLIB/gofc.h -- you will see that my two suggested settings
  30.    are already set as defaults.  Remember that double quote characters (")
  31.    and backslashes (\) must be escaped by a leading backslash.  For example:
  32.  
  33.     "\"/usr/local/lib/Gofer/gofc.h\""   might be used on Unix machine,
  34.     "\"\C:\\GOFER\\GOFC\\GOFC.H\""      might be approp. for a DOS machine.
  35.  
  36.    Specific details for particular machine/configurations are given below.
  37.  
  38. 3) Build the system (on a Unix system, this usually means just typing
  39.    `make' and going to get a cup of something to drink ...)
  40.  
  41.    If you modify parser.y, you will need a version of yacc to create a
  42.    suitable new version of parser.c.  I've had reports that the Gofer
  43.    grammar doesn't work correctly if you use either GNU bison or Berkeley
  44.    Yacc (both have a common ancestor so it's not too surprising).  If
  45.    you have any doubts, make sure that you use the parser.c file supplied
  46.    with the source rather than letting a local version of yacc create a
  47.    new one for you.  The easiest way to do this is probably to edit the
  48.    makefile to leave out the construction of parser.c.
  49.  
  50. 4) If you are going to use the Gofer compiler:
  51.    Assuming a successful build, copy the files prelude.h and gofc.h to
  52.    $GOFLIB and edit the file gofc.h, replacing #include "prelude.h"
  53.    with something like #include "$GOFLIB/prelude.h" -- don't actually
  54.    enter the string "$GOFLIB/prelude.h" here, you're meant to replace
  55.    $GOFLIB by whatever directory name you chose at the beginning of
  56.    this process.  You will also need to copy the file runtime.o (or
  57.    runtime.obj, depending on your system) into $GOFLIB.
  58.  
  59. 5) You're all set.  In practice, you'll want to move the gofer and gofc
  60.    binaries to somewhere sensible (probably into $GOFLIB on a unix system,
  61.    modifying the scripts in the scripts subdirectory to point to the
  62.    appropriate executables and prelude files).  And you may want to
  63.    clean off any remaining object code files too ...
  64.  
  65.    IMPORTANT: If you plan to use the shell scripts provided to operate
  66.    the Gofer compiler and you have a choice of C compilers on your
  67.    system (e.g.  GNU gcc and a vendor-supplied cc) make sure that the C
  68.    compiler mentioned in the script gofcc is the same C compiler used
  69.    (in the Makefile) to compile runtime.c.  In a similar way, make sure
  70.    that the version of gofc.h used to compile runtime.c has the same
  71.    settings as the version of gofc.h that you put in $GOFLIB.  (This is
  72.    only likely to be relevant if you install an alternative garbage
  73.    collector or change the setting on ARGCHECK.)
  74.  
  75. I've probably left something out here.  Please let me know if you have
  76. any trouble or spot anything that you think I should have mentioned!
  77.  
  78.  
  79. ---------------------
  80. GNU READLINE (or equivalent)
  81.  
  82. Gofer can be compiled to make use of the GNU readline library.  I tried
  83. this using the readline library provided by GNU bash 1.12, although I've
  84. found that, for my simple purposes, the editline library posted in
  85. alt.sources works as well, and is a fraction of the size.
  86.  
  87. See the Makefile for more details.
  88.  
  89.  
  90. ---------------------
  91. TURBO C version 1.5 on a PC with MSDOS:
  92.  
  93. Set #define TURBOC 1  and the rest to 0 in prelude.h.  Use the supplied
  94. project files gofer.prj and gofc.prj to generate the interpreter and
  95. compiler respectively.  Before starting the compilation, make sure that
  96. you set the following command line options (all of this is intended to
  97. be carried out from within the IDE):
  98.  
  99.    Medium model,  stack check ON,  Merge duplicate strings, Jump
  100.    optimization ON,  Possibly incorrect assignment warning off.
  101.  
  102. Select project gofer.prj and make.  Select project gofc.prj and make.
  103.  
  104. In order to make the runtime library and use the compiler, I suggest
  105. creating a batch file GTCC.BAT containing:
  106.  
  107.   tcc -O -ms -IC:\TURBOC\INCLUDE -LC:\TURBOC\LIB %1 %2 %3 %4 %5 %6 %7
  108.  
  109. then use this to build the runtime system:  gtcc -c runtime.c
  110. and compile programs using:                 gofc prog.gs
  111.                                             gtcc prog.c runtime.obj
  112.  
  113. Since the PC has a fairly limited amount of memory, you may find that you
  114. need to compile a new version of the Gofer system without floating point
  115. support (or you may need to select a markscan garbage collector in place
  116. of the default twospace collector).
  117.  
  118.  
  119. ---------------------
  120. BORLAND C++ version 3.1 on a PC with MSDOS:
  121.  
  122. Set #define BCC 1  and the rest to 0 in prelude.h.  You will need to
  123. remove the project files gofer.prj and gofc.prj supplied with the
  124. Gofer source and rebuild your own project files from within the IDE.
  125. The project file for the interpreter should contain the files:
  126.  
  127.     gofer.c, input.c, static.c, type.c, compiler.c, machine.c,
  128.     storage.c, output.c and builtin.c.
  129.  
  130. The project file for the compiler should contain the files:
  131.  
  132.     gofc.c, input.c, static.c, type.c, compiler.c, cmachine.c,
  133.     storage.c and cbuiltin.c.  (output.c is not required).
  134.  
  135. Before starting the compilation, make sure that you set the following
  136. command line options (all of this is intended to be carried out from
  137. within the IDE):
  138.  
  139.    Medium model,  stack check ON,  Merge duplicate strings, No debugging
  140.    information in object files, no standard stack frames, fastest code
  141.    (or smallest, if memory is tight), source debugging - none, possibly
  142.    incorrect assignment warning off.
  143.  
  144. If you have a 386 machine or a floating point coprocessor, you will find
  145. a small benefit in setting the relevant compiler options to make use of
  146. these features too.
  147.  
  148. In order to make the runtime library and use the compiler, I suggest
  149. creating a batch file BTCC.BAT containing:
  150.  
  151.   Bcc -O -ms -IC:\BORLANDC\INCLUDE -LC:\BORLANDC\LIB %1 %2 %3 %4 %5 %6 %7
  152.  
  153. then use this to build the runtime system:  btcc -c runtime.c
  154. and compile programs using:                 gofc prog.gs
  155.                                             btcc prog.c runtime.obj
  156.  
  157. Since the PC has a fairly limited amount of memory, you may find that you
  158. need to compile a new version of the Gofer system without floating point
  159. support (or you may need to select a markscan garbage collector in place
  160. of the default twospace collector).
  161.  
  162.  
  163. ---------------------
  164. Zortech C++ v3.0 for IBM PC (>=386)
  165.  
  166. Set #define ZTC 1  and the rest to 0 in prelude.h.  Compile using the
  167. makefile supplied as Makefile.ztc.  Thanks to John Lazenby for the patches
  168. to get this to work!
  169.  
  170. ---------------------
  171. DJGPP 1.09 on MSDOS:
  172.  
  173. DJGPP is a DOS port of the GNU C compiler produced by DJ Delorie.  It
  174. requires a 386 or better, but gives you much better opportunities to
  175. make use of the resources that such machines provide.  Much larger
  176. heaps can be used, and the 32 bit code produced by DJGPP runs a lot
  177. faster than the versions produced by TURBO C or BORLAND C, even on the
  178. same machine!
  179.  
  180. DJGPP depends on the use of a DOS extender, go32.  A modified version
  181. of go32 has been produced which supports signals, allowing the Gofer
  182. interpreter to recover from a program interrupt (i.e. pressing ^C
  183. during an evaluation).  The original version of go32 was written by
  184. DJ Delorie.  Rami El Charif has modified go32 to handle signals,
  185. essential for any serious work with Gofer.  Thanks Rami!
  186.  
  187. Instructions for building the modified go32 and compiling Gofer with
  188. DJGPP 1.09 are included in the readme file in the go32sgof.zip archive
  189. in the standard Gofer distribution.
  190.  
  191.  
  192. ---------------------
  193. NEXT versions:
  194.  
  195. Set #define NEXTSTEP 1 and the rest to 0 in prelude.h.  Edit the Makefile
  196. to set the C compiler (defined by the macro CC) to cc.  (If you would
  197. prefer to use the current GNU C compiler i.e. gcc 2.x and have this
  198. installed on your system, choose #define NEXTGCC 1 instead of NEXTSTEP
  199. and set CC to gcc).  Run the make command to build gofer, gofc and runtime.o.
  200.  
  201.  
  202. ---------------------
  203. SUNOS versions:
  204.  
  205. Set #define SUNOS 1 and the rest to 0 in prelude.h.  Edit the Makefile
  206. as necessary.  I tried this on a Sun 4 using gcc, but I think it should
  207. also work on Sun 3, and with cc ...  If your site has both Sun3 and
  208. Sun4 machines, the following script may be of use:
  209.  
  210.     #!/bin/sh
  211.  
  212.     GOFER=/usr/local/lib/Gofer/prelude
  213.     export GOFER
  214.  
  215.     if (sparc) then
  216.         exec /usr/local/lib/Gofer/gofer4 $*
  217.     elif (m68k) then
  218.         exec /usr/local/lib/Gofer/gofer3 $*
  219.     else
  220.         echo I dont know how to start Gofer on your machine
  221.     fi
  222.  
  223.  
  224. ---------------------
  225. IBM OS/2 2.0 using EMX GCC:
  226.  
  227. Set #define OS2 1 and the rest to 0 in prelude.h.  Thanks to
  228. Bryan Scattergood for sending the patches to get this working!
  229.  
  230.  
  231. ---------------------
  232. System V release 4 using GCC2.2:
  233.  
  234. Set #define SVR4 1 and the rest to 0 in prelude.h.  Thanks to
  235. Bryan Scattergood for sending the patches to get this working!
  236.  
  237.  
  238. ---------------------
  239. SCO Unix 3.2.4:
  240.  
  241. Set #define SVR4 1 and the rest to 0 in prelude.h.  Compile using gcc 2.2.2.
  242. Thanks to Rodney Brown!
  243.  
  244.  
  245. ---------------------
  246. Silicon Graphics with Irix:
  247.  
  248. Set #define SVR4 1 and the rest to 0 in prelude.h.  Set the makefile to
  249. use cc.  If you are running on a machine with a MIPS R4000 CPU, you might
  250. also like to add -mips2 to CFLAGS (this should not be used if you want
  251. backward compatibility with machines based on the MIPS R3000 CPU).
  252.  
  253. I think you can probably build Gofer using gcc but I haven't had the
  254. opportunity to try that myself.
  255.  
  256.  
  257. ---------------------
  258. HP systems:
  259.  
  260. Set #define HPUX 1 and the rest to 0 in prelude.h.  I've had patches
  261. for HP machines from a number of people including Tom Lane, Dipankar
  262. Gupta, Rodney Brown and Jeroen Fokker and I've tried to work these into
  263. the source for 2.28.  There were occasional discrepancies between the
  264. sets of patches that I received so I sometimes had to take a `majority
  265. vote'; perhaps they were for slightly different machines?  Anyway, I
  266. hope that Gofer will compile on HP machines using these settings -- or
  267. at least be easy to patch to make it run correctly if not.  Thanks for
  268. the patches everyone!
  269.  
  270. It has now been verified that the HPUX patch version will at least
  271. compile correctly on HP series 400 workstations (68040 CPU) running
  272. HP-UX 8.0 with gcc, thanks to Kurt Olender!
  273.  
  274. Gofer 2.28 has also been built on an H.P. Series 700 machine running
  275. HP-UX 8.07.  Gofer does not work if it is compiled using gcc (2.3.3).
  276. Use the HP C compiler (cc) in ANSI mode.   A guide to setting the
  277. macro definitions in the Makefile:
  278.  
  279.     CC        = cc
  280.     CFLAGS    = -Aa -D_HPUX_SOURCE 
  281.     LDFLAGS   = -lm
  282.     OPTFLAGS  = +O3
  283.     OPT1      = +O1
  284.  
  285. Thanks to Dave Sherratt for this information!
  286.  
  287.  
  288. ---------------------
  289. DECstation 5000 running Ultrix 4.2 (MIPS R3000 CPU) with GCC2.3.3:
  290.  
  291. Set #define ULTRIX 1 and the rest to 0 in prelude.h.  Thanks to Kurt Olender
  292. for the patches!
  293.  
  294. This release of Gofer includes a slight modification, brought to my notice
  295. by Jerry Prothero, which should also make it possible to compile Gofer using
  296. DEC's own cc compiler instead of gcc.  Thanks Jerry!
  297.  
  298.  
  299. ---------------------
  300. IBM AIX on RS/6000 using GCC:
  301.  
  302. Set #define AIX 1 and the rest to 0 in prelude.h.  Thanks (again) to Kurt
  303. Olender for the patches!
  304.  
  305.  
  306. ---------------------
  307. Minix 68K:
  308.  
  309. Set #define MINIX68K 1 and the rest to 0 in prelude.h.  Rainer Orth
  310. sent me sent me some patches to make Gofer 2.23 compile and run under
  311. Minix 68k using the GNU C compiler, I believe.  I have tried to make
  312. the same changes to the latest version, but I have not verified that
  313. they work.  Some small changes may be needed -- please let me know if
  314. you try it.  Thanks Rainer!
  315.  
  316.  
  317. ---------------------
  318. Linux with gcc:
  319.  
  320. Set #define LINUX 1 and the rest to 0 in prelude.h.  Ray Bellis sent me
  321. some patches to make Gofer 2.23 compile and run under Linux using the
  322. GNU C compiler.  I have tried to make the same changes to the latest
  323. version, but I have not verified that they work.  Some small changes
  324. may be needed -- please let me know if you try it.  And thanks, Ray!
  325.  
  326. Since 2.28 was first distributed I've had feedback from two people
  327. that have compiled Gofer to run on Linux.  Bambang Prastowo wrote
  328. to let me know that Gofer compiled without modifications (other
  329. than setting #define LINUX 1).  Eak Khoon reported that it was
  330. neccessary to comment out the #define const at the beginning of
  331. prelude.h and change prototypes in prelude.h to:
  332.    extern *getenv Args((const char *));
  333.    extern system  Args((const char *));
  334.    extern atof    Args((const char *));
  335. This may be due to the use of slightly different compilers or versions
  336. of Linux.  In any case, it should be fairly straightforward to build
  337. Gofer to run under Linux.
  338.  
  339. ---------------------
  340. Acorn DesktopC and RISCOS2 or 3:
  341.  
  342. Set #define RISCOS 1  and the rest to 0 in prelude.h.  Use the file
  343. AcornMake to build the Gofer system.  Thanks to Bryan Scattergood for
  344. the patches to make Gofer compile and run under RISCOS!
  345.  
  346.  
  347. ---------------------
  348. Amiga:
  349.  
  350. Set #define AMIGA 1  and the rest to 0 in prelude.h.  Compile using
  351. gcc 2.2.2.  Thanks to Luc and Mark Duponcheel for their help in
  352. getting this to work.  One small problem remains that ^C interrupts
  353. do not currently work.  I believe this can be solved by setting an
  354. appropriate value for the #define allowBreak() macro in prelude.h,
  355. but I am not sure what definition should be used.  Frederek Althoff
  356. has investigated this problem and believes that there may be a problem
  357. with the signal handling in the current version of gcc on the Amiga.
  358. Frederek has written a C program, included in the main distribution
  359. as amigaint.c, to try and help out.  In his words: `` All you have
  360. to do is start the program from an other shell with the process-id
  361. of gofer. To get this id, you have to use a program called "Status"
  362. (similar to "ps"). That's all. You might add this program to your
  363. distribution? This will `help' until the ^C-problem is fixed''.
  364. Thanks Frederek!
  365.  
  366.  
  367. ---------------------
  368. DEC Alpha with OSF/1:
  369.  
  370. Set #define ALPHA 1 and the rest to 0 in prelude.h.  Briefly, I tried
  371. compiling Gofer on a 64 bit DEC Alpha with a preliminary version of
  372. OSF/1.  I didn't spend long, but it seems that it is probably safest to
  373. compile without using any optimization.  Furthermore, only the
  374. interpreter can be used at the current time and integers are restricted
  375. to 32 bit quantities.  I may do something to change this one day, but
  376. it is not a high priority.  Essentially, what needs to be done is to
  377. redefine the Int type as a synonym (i.e.  typedef) for long and to
  378. replace all appropriate uses of %d in prinf strings with %ld.
  379.  
  380.  
  381. ---------------------
  382. MIPS RC6280(BSDenvironment on OS2.2):
  383. SONY machine(NWS-3870, BSD4.3- based OS NEWS OS4.2R, Mips-made risk chip):
  384.  
  385. Set #define MIPS 1 and the rest to 0 in prelude.h.  The patches for this
  386. version of Gofer were sent to me by Hiroyuki Matsuda ... thanks!  I only
  387. hope that I have correctly incorporated them into the main distribution!
  388.  
  389.  
  390. ---------------------
  391. 386bsd:
  392.  
  393. A 386bsd version of Gofer has been put together by Viren Shah.  It sounds
  394. like a rather complicated process, so I'll just quote the instructions that
  395. Viren sent me ... I haven't tried this myself:
  396.  
  397. | I used the SUNOS mode (i did try the linux mode, but that crashed
  398. | repeatedly and no amount of hacking could fix it) and the following
  399. | are the changes made by me in order to install it:
  400. | 1.> Copied malloc.h from /usr/include/g++ to current directory, namely
  401. | /usr/local/Gofer/src .
  402. | 2.> edited Makefile :
  403. |     CFLAGS : -I. -I/usr/src/sys.386bsd/sys -I/usr/include/g++
  404. | 3.> edited gofc.c to comment out #include <sys/stat.h>
  405. | 4.> copied time.h from /usr/src/include to current directory
  406. | 5.> edited Makefile :
  407. |     for .gs files the compile command is now :
  408. |      $(CC) $(CFLAGS) $(OPTFLAGS) $*.c runtime.o -o $* $(LDFLAGS)    
  409. | 6.> edited goferc script to include the -I option for the gcc compiler
  410. | Most of the above changes (not that they are very many) are probably
  411. | due to system specific problems, but I have no way of determining
  412. | that since I do not know anyone else installing Gofer on 386bsd.
  413.  
  414.  
  415. ---------------------
  416. OTHER PLATFORMS:
  417.  
  418. Gofer has been tested on other platforms and most of the code is fairly
  419. standard.  The code does however make certain assumptions about the system
  420. on which Gofer will be used.  These are summarised below as an aid
  421. to those interested in porting Gofer to other systems:
  422.  
  423. 1) For the benefit of Garbage collection from the C stack, all function
  424.    parameters and local variables are expected to have sizes which are
  425.    a multiple of sizeof(Int) (defined in prelude.h).  In other words,
  426.    you should check that:
  427.  
  428.              sizeof(FloatImpType) % sizeof(Int) == 0
  429.              sizeof(String)       % sizeof(Int) == 0
  430.              sizeof(Char)         % sizeof(Int) == 0
  431.              sizeof(Long)         % sizeof(Int) == 0
  432.              sizeof(Unsigned)     % sizeof(Int) == 0
  433.  
  434.    (These types are defined in prelude.h and storage.h)
  435.  
  436. 2) Study the comments and settings in prelude.h in order to find out how
  437.    other ports of Gofer have been produced.
  438.  
  439. 3) The words local and far are used to access non-standard extensions
  440.    in Turbo C to allow the Gofer system to overcome some of the
  441.    limitations of the PC's segmented architecture.  These should be
  442.    #defined to empty strings on most other machines with a flat address
  443.    space.
  444.  
  445. 4) The current version of the garbage collector in the Gofer interpreter
  446.    uses the C call stack as an array of Cell values to find temporary
  447.    variables that point into the heap.  This is a well-known technique
  448.    often described as `conservative garbage collection' but the
  449.    implementation in C is inherently non-portable.  Surprisingly enough
  450.    though, for almost all of the machines supported, you can make some
  451.    simple assumptions and get things to work quite nicely.  The RISCOS
  452.    code is one example where things are very different.  But for the most
  453.    part, you can treat the C stack as an array of Cell values.  As the
  454.    program runs the size of the stack changes and you need to know the
  455.    extent of the array.  The first element pushed onto the stack is
  456.    pretty much fixed, so it is the position of the stack pointer that
  457.    determines how big the stack is.
  458.  
  459.    On many machines, the stack grows downwards.  I have yet to come across
  460.    a machine where the stack grows upwards, but I have heard that this
  461.    happens on some HP systems.
  462.  
  463.    Here is the way to deal with this in the current version of the code.
  464.    In machdep.c, you will find a function gcCStack() which traverses the
  465.    stack.  To make things easier, there are three macros:
  466.  
  467.       #define StackGrowsDown  ...
  468.       #define StackGrowsUp    ...
  469.       #define GuessDirection  ...
  470.  
  471.    The first two describe the way to mark the stack on a machine in which the
  472.    stack grows either up or down respectively.  The third tries to guess
  473.    which way to do things by comparing two pointers.  Strictly speaking,
  474.    this comparison probably doesn't fall under the definition of standard C
  475.    so it may not be portable.  The current usage of these functions is as
  476.    follows:
  477.  
  478.        #if HPUX
  479.            GuessDirection;
  480.        #else
  481.            StackGrowsDown;
  482.        #endif
  483.  
  484.     Change as necessary to suit your machine (and please let me know so that
  485.     I can update the source).
  486.  
  487. Almost all of the machine dependencies in the code for Gofer are contained
  488. in the header file "prelude.h", and the program file "machdep.c".  These
  489. files contain definitions for both the TURBOC and UNIX versions described
  490. above and should be a useful guide.
  491.  
  492. I regret that I do not have time to write more substantial notes for
  493. porting Gofer at the present time.  I will however be happy to offer
  494. advice and answer other questions if you want to contact me in person
  495. at the email address below.  If you do successfully complete a port for
  496. another machine, please let me know what changes are necessary.  I know
  497. that it isn't always possible, but if you can, please try to restrict
  498. changes to the prelude.h and machdep.c files.
  499.  
  500. ---------------------
  501.  
  502. NOTE: if Gofer starts behaving unexpectedly, try recompiling
  503. without full compiler optimisation and see if the problem still occurs.
  504. If so, please get in touch with me, giving me as much information about
  505. the problem as possible, and I'll try and sort it out for you.  If you
  506. find a bug which you fix yourself, please send me details so that I can
  507. pass the fix onto to other users of Gofer.
  508.  
  509. If gofc starts behaving unexpectedly, try running the same code through
  510. the interpreter.
  511.  
  512. jones-mark@cs.yale.edu
  513. -------------------------------------------------------------------------------
  514.