1 Installation instructions for Gambit-C
2 ======================================
4 [Time-stamp: <2009-06-09 17:32:05 feeley>]
7 This directory contains a release of the Gambit-C Scheme programming
8 system (see the file configure.ac for the version number). Gambit-C
9 includes a Scheme interpreter and a Scheme compiler which can be used
10 to build standalone executables. Because the compiler generates
11 portable C code it is fairly easy to port to any platform with a
15 1) Quick-install instructions
16 =============================
18 On most Unix platforms the system can be easily built, tested and
19 installed using the following commands:
26 The configure script, which was generated by the "autoconf" tool,
27 accepts many command line options that control various features.
29 It is ***highly*** recommended to use the --enable-single-host option
30 to improve the execution speed and compactness of the executables:
32 % ./configure --enable-single-host
34 By using the --enable-single-host option, the speed of the Gambit-C
35 interpreter improves by roughly a factor of 2.
37 It is also ***highly*** recommended to use the GCC compiler to build
38 the system as the source code can take advantage of some GCC
39 extensions. Notably the use of GCC's computed gotos reduces the
40 execution time by roughly 35%.
42 When using some versions of the GCC compiler it is possible to use the
43 --enable-gcc-opts option to further improve the execution speed and
44 compactness of the executables:
46 % ./configure --enable-single-host --enable-gcc-opts
48 Note that this option might degrade the execution speed, so it is best
49 to build the system both ways and see which works best for your
52 These options are not used by default because compilation is much
53 longer and requires more RAM. In fact some platforms may not have
54 enough resources to build the system this way. With
55 --enable-single-host the build takes roughly 500 megabytes and 2 to 4
56 minutes on a 2 GHz Intel Core Duo based MacBook Pro with the GCC 4.0.1
57 compiler instead of 300 megabytes and 1 to 2 minutes when
58 --enable-single-host is not used. With --enable-single-host and
59 --enable-gcc-opts the build takes roughly 2 gigabytes and over 10
62 We recommend that users build Gambit-C with GCC 3.1 or later; GCC 3.1
63 will compile C code generated by the Gambit-C compiler faster than
64 previous versions of GCC, and will generally produce faster code than
65 previous versions of GCC. For example, the interpreter is about 5%
66 faster than when it is compiled with GCC 2.95.3.
68 The compile time varies greatly from one version of GCC to the next
69 (usually a more recent version is better, but not always). This is
70 because the algorithms used to implement the optimizations performed
71 by the compiler evolve and vary in computational complexity. Since
72 the C files are so large, the compile time is very sensitive to the
73 computational complexity of the optimization algorithms.
75 Finally, in order to support installing multiple versions of Gambit,
76 it is recommended to use these options:
78 % ./configure --enable-single-host --enable-multiple-versions
81 2) Other options of the "configure" script
82 ==========================================
84 The detailed list of options accepted by the "configure" script can be
89 Most options are the same as for other autoconf generated configure
90 scripts. For example, you can select the central installation
91 directory with the option --prefix:
93 % ./configure --prefix=/Users/feeley/my-gambit
99 If the --prefix option is not used, the default is to install all
100 files in /usr/local/Gambit-C and its subdirectories, namely "bin",
101 "lib", "include", etc. The files that would normally go in these
102 subdirectories can be redirected to other directories using one of
103 the following configure options:
105 --bindir=DIR executables (gsi, gsc, ...)
106 --libdir=DIR libraries (libgambc.a, syntax-case.scm, ...)
107 --includedir=DIR C header files (gambit.h, ...)
108 --docdir=DIR documentation (gambit-c.pdf, gambit-c.html, ...)
109 --infodir=DIR info documentation (gambit-c.info, ...)
110 --datadir=DIR read-only architecture-independent data (gambit.el)
112 Note that the install target of the makefiles supports the DESTDIR
113 environment variable which allows staging an install to a specific
114 directory. The command:
116 % make install DESTDIR=/Users/feeley/stage
118 will install all the files in /Users/feeley/stage as though it was the
119 root of the filesystem. Note that the use of DESTDIR is incompatible
120 with the combination of --enable-shared and
121 --enable-absolute-shared-libs options.
123 The configure options which are specific to the Gambit-C system are:
125 --enable-single-host compile each Scheme module as a single C function
126 --enable-gcc-opts use expensive GCC optimizations
127 --enable-cplusplus compile using C++ compiler
128 --enable-shared build the Scheme runtime system as a shared library
129 --enable-debug build system so that it can be debugged
130 --enable-profile build system so that it can be profiled
131 --enable-coverage build system to accumulate coverage statistics
132 --enable-feedback1 build system to accumulate trial run data
133 --enable-feedback2 build system using trial run feedback
134 --enable-inline-jumps generate inline code for jumps
135 --enable-char-size=N Scheme character size in bytes (N = 1, 2 or 4)
136 --enable-ansi-c link only with ANSI C libraries
137 --enable-symlinks use symbolic links for installed files not in the
138 central installation directory
139 --enable-interpreter-name=INTERP
140 choose name for Gambit interpreter (default = gsi)
141 --enable-compiler-name=COMP
142 choose name for Gambit compiler (default = gsc)
143 --enable-multiple-versions
144 multiple installed versions are supported
145 --enable-absolute-shared-libs
146 shared libraries should be linked to using an
148 --enable-help-browser=BROWSER
149 use the specified browser to view documentation
150 requested through the help procedure or REPL
152 The option --enable-cplusplus should be used when applications
153 developped with the Gambit-C compiler are to be linked with code or
154 libraries written in C++. This will compile all of the Gambit-C
155 source code with a C++ compiler instead of a C compiler (this is
156 possible because the code generated by the Gambit-C compiler conforms
159 The option --enable-shared will build a shared library for the
160 Gambit-C runtime system. This is not supported on all platforms.
162 The options --enable-debug and --enable-profile are useful for
163 debugging the system.
165 The options --enable-feedback1 and --enable-feedback2 are useful for
166 building the system such that it is optimized for a particular use
167 case. The system should first be built with --enable-feedback1, then
168 one or more sample executions of the system should be performed, and
169 then finally the system should be built with --enable-feedback2. For
172 % ./configure --single-host --enable-feedback1
174 % gsc/gsc -:=. my-favorite-program.scm
175 % gsi/gsi -:=. my-favorite-program.o1
177 % ./configure --single-host --enable-feedback2
180 The option --enable-symlinks is useful when the --bindir, --libdir,
181 ... options are used. The files will actually be stored in the
182 central installation directory and symbolic links to those files will
183 be stored in the directories specified to --bindir, --libdir, ...
185 The options --enable-interpreter-name=INTERP and
186 --enable-compiler-name=COMP are useful when names different from the
187 defaults are needed (i.e. gsi and gsc respectively). These options
188 should be used only when absolutely necessary because users will
189 expect the defaults (from reading documentation, talking with users on
190 a different OS, etc). We strongly suggest that the names start with
191 gsi and gsc respectively, so that shell tab completion will help the
192 user discover the correct name.
194 The option --enable-multiple-versions allows multiple versions of
195 Gambit to be installed. When it is enabled the path of the central
196 installation directory (specified with --prefix) is automatically
197 extended with a subdirectory which is the version number, and a
198 "current" symbolic link points to the version subdirectory. All
199 symbolic links created as a result of the --enable-symlinks option
200 will refer to the files indirectly through the "current" symbolic
201 link. Switching to a different version of Gambit can be done by
202 simply redirecting the "current" symbolic link to another version
205 When --enable-shared is used, the option --enable-absolute-shared-libs
206 will install executables (for gsi and gsc) which contain references to
207 the absolute paths of the libraries. This is necessary when multiple
208 versions of Gambit are installed so that each executable refers to the
209 appropriate Gambit shared library. This is the default behavior.
210 Note that this option is incompatible with the use of DESTDIR because
211 the executables can only be linked after the Gambit shared libraries
212 are installed in their final destination.
214 By default the configure script will use the GCC compiler to build the
215 system, if it is available. To override this choice or to use special
216 C compiler flags it is possible to set the environment variables CC,
217 CFLAGS, LDFLAGS, etc in the shell or on the configure command line.
218 Object file compilation options should go in CFLAGS, link options
219 should go in LDFLAGS, and options that apply to both can be next to
220 the name of the C compiler in CC. Here are some examples.
222 - To use cc instead of gcc:
226 - On a Sun Sparc workstation, the following will use the Sun
227 Workshop C/C++ compiler and generate 64 bit executables (the heap
228 can grow beyond 4 Gbytes):
230 % ./configure CC="cc -xtarget=native -xarch=v9"
232 - On a Compaq Alpha workstation, the following will use the Compaq
233 Tru64 UNIX C/C++ compiler and generate executables that use 32 bit
234 addressing instead of the normal 64 bit addressing (the heap and
235 code will be in the lower 4 GBytes of the address space):
237 % ./configure CC=cc CFLAGS="-w -D___USE_32_BIT_ADDR" LDFLAGS=-taso
239 - By default, Gambit-C's runtime system does not restrict the size
240 of the Scheme heap. A heap overflow will only be signalled when
241 virtual memory is all used up, which can take a long time and
242 cause lots of paging. This is not ideal for an educational
243 environment where endless recursions are commonplace. The symbol
244 ___FORCE_MAX_HEAP can be defined to put a limit on the size of the
245 heap. To get a 5000 kilobyte limit (a reasonable amount for an
246 educational environment) the system could be configured with:
248 % ./configure CFLAGS="-D___FORCE_MAX_HEAP=5000"
251 3) Other "make" targets
252 =======================
254 Here is a description of the most useful "make" targets:
256 % make bootstrap Builds the system and copies the gsc
257 executable to gsc-comp in the root directory.
258 The makefiles call up gsc-comp to
259 compile the Scheme source files
260 in the system if they are modified.
261 Note that a simple "make" will also
262 copy the gsc executable to gsc-comp if
265 % make mostlyclean Removes all the files that can be
266 regenerated using basic tools
267 (C compiler, sed, etc). The feedback
268 files are not removed.
270 % make clean Removes all the files that are created
271 from a pristine distribution during
272 a "make" (object files, libraries,
275 % make bootclean Like "make clean", but also removes the
276 C files that the gsc-comp compiler can
277 create from the Scheme source files. This
278 should only be used after a successful
279 "make bootstrap". The next "make" will
280 compile the whole system from scratch,
281 including compiling the Scheme sources
284 % make realclean Like "make bootclean", but also removes all
285 the files which can be created using the
286 configure script (this includes the makefiles).
288 % make check Checks that gsi and gsc pass some
289 basic tests by running a few Scheme
290 programs with gsi and gsc.
292 % make examples Runs the programs in the "examples"
295 % make dist Creates a compressed tar file of
298 % make dist-devel Creates a compressed tar file of
299 the system including all the source code
302 % make doc Builds the documentation.
304 % make rc-setup For initial setup of source code
305 management using git. This should
306 only be performed by the Gambit maintainers.
308 % make prebuilt Builds installers for Mac OS X and Windows.
309 Note: this make target is very platform
310 specific and is intended for the Gambit
313 % make release Builds source tarball and installers.
314 Note: this make target is very platform
315 specific and is intended for the Gambit
319 4) Building on Microsoft Windows
320 ================================
322 There are several alternatives for building the system on Microsoft
325 a) Use the free MSYS/MinGW development environment (Minimalist GNU
326 for Windows, www.mingw.org). Install MinGW and MSYS, then follow
327 the instructions above (i.e. "./configure" followed by "make").
329 b) Use the free Cygwin development environment
330 (http://www.cygwin.com/). Install Cygwin, then follow the
331 instructions above (i.e. "./configure" followed by "make").
333 c) Use the Open Watcom compiler which can be obtained at no charge
334 from http://openwatcom.mirrors.pair.com/. You must perform a
335 full installation of the Open Watcom compiler in C:\WATCOM. From
336 the shell, execute the batch file "misc\openwatcom.bat".
338 d) Use the Microsoft Visual C++ 2005 Express Edition which can be
339 obtained at no charge from Microsoft at this URL:
340 http://msdn.microsoft.com/vstudio/express/downloads/default.aspx .
341 You must also install the Microsoft Platform SDK. From the
342 shell, execute the batch file "misc\vcexpress.bat".
344 e) Use Microsoft Visual Studio .NET 2003. You must unzip
345 "misc\vstudio.zip" in the Gambit distribution's root directory.
346 Then with Microsoft Visual Studio open "gambc.sln" and select
347 "Build Solution" (Ctrl+Shift+B).
350 5) If you can't build the system on your platform
351 =================================================
353 The configure script tailors the build process to your platform.
354 Although it can adapt to a wide range of platforms there are cases
355 where it is not clever enough to do it completely automatically.
357 In this case you need to modify the configure script (the file
358 "configure.ac") and/or the source code of the Gambit-C system. Most
359 of the system dependent code is located in the files
360 "include/gambit.h", "lib/os*.h" and "lib/os*.c". Never modify the C
361 files generated by the Gambit-C compiler (these files usually have a
362 name that starts or ends with an underscore).
364 If you needed to modify any file to get Gambit-C to work properly on
365 your system, please send your modifications along with your machine/OS
368 gambit@iro.umontreal.ca
370 so that it can be added to the next release.