Installing CPC ************** CPC can be compiled using either CMU Common Lisp (CMUCL) or Haible-Stoll CLISP. For casual use, CLISP is preferable as it is much smaller than CMUCL. On the other hand, CMUCL is somewhat faster than CLISP. 1. Install your favourite Common Lisp implementation and ASDF. On Debian GNU/Linux, just do one of $ apt-get install cmucl cl-asdf or $ apt-get install clisp cl-asdf For other systems, CMUCL can be found on http://www.cons.org/cmucl/ CLISP on http://www.cons.org/clisp/ and ASDF on http://www.cliki.net/asdf 2. Install the CL-Yacc parser. On recent versions of Debian GNU/Linux, just do $ apt-get install cl-yacc For other systems, it can be found on http://www.pps.jussieu.fr/~jch/software/cl-yacc/ Untar CL-Yacc somewhere, then link the ``yacc.asd'' file into the cpc directory. 3. Dump a CPC core. If using CMUCL, do $ lisp -load dump-cpc.lisp If using CLISP, do $ clisp dump-cpc.lisp This will create a file ``/tmp/cpc.core'' or ``/tmp/cpc.mem'', which you should copy to /usr/local/lib. 4. Edit the cpc script and all Makefiles If you are using CMUCL, the scripts are already set up. If you are using CLISP, edit the beginning of the files ``cpc'', ``runtime/Makefile'' and ``samples/Makefile'' as indicated. 5. Build and install the runtime $ cd runtime $ make all $ su -c 'make install' $ cd .. 6. Try out the samples $ cd samples $ make all Compiling CPC programs ********************** In order to compile a CPC program, you may either use the script ``cpc'', or suitable Makefile rules. 1. The ``cpc'' script The ``cpc'' script accepts the following options: -g, -O, -c, -o: as for the C compiler; -t: uses a different call strategy that assumes the C compiler can eliminate tail calls. This doesn't appear to work well. 2. Using CPC from makefiles In order to use cpc from makefiles, use the following rules: .SUFFIXES: .cpc .cpi .cpc.cpi: $(CC) -E -P $(CFLAGS) -D__extension__= -D'__attribute__(x)=' - \ <$< >$@ .cpi.c: $(CPC) $< $@ If using CLISP, the latter rule becomes .cpi.c: $(CPC) $< $@ 3. Using the Lisp REPL It is also possible to run the translator from the Lisp REPL; this is probably only useful when working on CPC itself. Load the ``cpc'' system, then switch to the CPC package and use the function CONVERT-FILE. > (asdf:oos 'asdf:load-op :cpc) > (in-package cpc) > (convert-file "samples/tcat.cpc.i" "samples/tcat.cpc.i.c") The input to CONVERT-FILE should be already preprocessed, and the output file compiled by a C compiler. The function CONVERT-FILE takes a number of keyword arguments; see ``cpc-main.lisp'' for details. Juliusz Chroboczek