Avoid a deadlock when a trace is interrupted by the user with a ctrl-C.
[gambit-c.git] / INSTALL.txt
blob8020aa47bd51d113c9f2797fbd02c566037c454b
1                 Installation instructions for Gambit-C
2                 ======================================
4               [Time-stamp: <2009-02-11 11:12:55 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
12 decent C compiler.
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:
21   % ./configure
22   % make bootstrap
23   % make check
24   % sudo make install
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
50 version of GCC.
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
60 minutes.
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
85 obtained with:
87   % ./configure --help
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
94   % make install
95   % ~/my-gambit/bin/gsi
96   Gambit v4.4.0
97   ...
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-feedback1      build system to accumulate trial run data
132   --enable-feedback2      build system using trial run feedback
133   --enable-inline-jumps   generate inline code for jumps
134   --enable-char-size=N    Scheme character size in bytes (N = 1, 2 or 4)
135   --enable-ansi-c         link only with ANSI C libraries
136   --enable-symlinks       use symbolic links for installed files not in the
137                           central installation directory
138   --enable-multiple-versions
139                           multiple installed versions are supported
140   --enable-absolute-shared-libs
141                           shared libraries should be linked to using an
142                           absolute path
143   --enable-help-browser=BROWSER
144                           use the specified browser to view documentation
145                           requested through the help procedure or REPL
147 The option --enable-cplusplus should be used when applications
148 developped with the Gambit-C compiler are to be linked with code or
149 libraries written in C++.  This will compile all of the Gambit-C
150 source code with a C++ compiler instead of a C compiler (this is
151 possible because the code generated by the Gambit-C compiler conforms
152 both to C and C++).
154 The option --enable-shared will build a shared library for the
155 Gambit-C runtime system.  This is not supported on all platforms.
157 The option --enable-debug and --enable-profile, --enable-feedback1, and
158 --enable-feedback2 are useful for debugging the system.
160 The option --enable-symlinks is useful when the --bindir, --libdir,
161 ... options are used.  The files will actually be stored in the
162 central installation directory and symbolic links to those files will
163 be stored in the directories specified to --bindir, --libdir, ...
165 The option --enable-multiple-versions allows multiple versions of
166 Gambit to be installed.  When it is enabled the path of the central
167 installation directory (specified with --prefix) is automatically
168 extended with a subdirectory which is the version number, and a
169 "current" symbolic link points to the version subdirectory.  All
170 symbolic links created as a result of the --enable-symlinks option
171 will refer to the files indirectly through the "current" symbolic
172 link.  Switching to a different version of Gambit can be done by
173 simply redirecting the "current" symbolic link to another version
174 subdirectory.
176 When --enable-shared is used, the option --enable-absolute-shared-libs
177 will install executables (for gsi and gsc) which contain references to
178 the absolute paths of the libraries.  This is necessary when multiple
179 versions of Gambit are installed so that each executable refers to the
180 appropriate Gambit shared library.  This is the default behavior.
181 Note that this option is incompatible with the use of DESTDIR because
182 the executables can only be linked after the Gambit shared libraries
183 are installed in their final destination.
185 By default the configure script will use the GCC compiler to build the
186 system, if it is available.  To override this choice or to use special
187 C compiler flags it is possible to set the environment variables CC,
188 CFLAGS, LDFLAGS, etc in the shell or on the configure command line.
189 Object file compilation options should go in CFLAGS, link options
190 should go in LDFLAGS, and options that apply to both can be next to
191 the name of the C compiler in CC.  Here are some examples.
193   - To use cc instead of gcc:
195       % ./configure CC=cc
197   - On a Sun Sparc workstation, the following will use the Sun
198     Workshop C/C++ compiler and generate 64 bit executables (the heap
199     can grow beyond 4 Gbytes):
201       % ./configure CC="cc -xtarget=native -xarch=v9"
203   - On a Compaq Alpha workstation, the following will use the Compaq
204     Tru64 UNIX C/C++ compiler and generate executables that use 32 bit
205     addressing instead of the normal 64 bit addressing (the heap and
206     code will be in the lower 4 GBytes of the address space):
208       % ./configure CC=cc CFLAGS="-w -D___USE_32_BIT_ADDR" LDFLAGS=-taso
210   - By default, Gambit-C's runtime system does not restrict the size
211     of the Scheme heap.  A heap overflow will only be signalled when
212     virtual memory is all used up, which can take a long time and
213     cause lots of paging.  This is not ideal for an educational
214     environment where endless recursions are commonplace.  The symbol
215     ___FORCE_MAX_HEAP can be defined to put a limit on the size of the
216     heap.  To get a 5000 kilobyte limit (a reasonable amount for an
217     educational environment) the system could be configured with:
219       % ./configure CFLAGS="-D___FORCE_MAX_HEAP=5000"
222 3) Other "make" targets
223 =======================
225 Here is a description of the most useful "make" targets:
227   % make bootstrap           Builds the system and copies the gsc
228                              executable to gsc-comp in the root directory.
229                              The makefiles call up gsc-comp to
230                              compile the Scheme source files
231                              in the system if they are modified.
233   % make mostlyclean         Removes all the files that can be
234                              regenerated using standard tools
235                              (C compiler, TeX, etc).  The C files
236                              generated by gsc, and the gsi and
237                              gsc executables are not removed.
239   % make clean               Removes all the files that can be
240                              regenerated by a "make" (object files,
241                              C files generated by gsc, etc) **except**
242                              gsi and gsc.  This is useful to
243                              bootstrap from the Scheme sources
244                              after gsc has been built with an
245                              initial "make bootstrap".
247   % make realclean           Like "make clean", but also removes
248                              gsi and gsc, and all the makefiles
249                              generated by the configure script.
251   % make check               Checks that gsi and gsc pass some
252                              basic tests by running a few Scheme
253                              programs with gsi and gsc.
255   % make examples            Runs the programs in the "examples"
256                              subdirectory.
258   % make dist                Creates a compressed tar file of
259                              the system.
261   % make dist-devel          Creates a compressed tar file of
262                              the system including all the source code
263                              management files.
265   % make doc                 Builds the documentation.
267   % make rc-setup            For initial setup of source code
268                              management using git.  This should
269                              only be performed by the Gambit maintainers.
271   % make prebuilt            Builds installers for Mac OS X and Windows.
272                              Note: this make target is very platform
273                              specific and is intended for the Gambit
274                              maintainers.
276   % make release             Builds source tarball and installers.
277                              Note: this make target is very platform
278                              specific and is intended for the Gambit
279                              maintainers.
282 4) Building on Microsoft Windows
283 ================================
285 There are several alternatives for building the system on Microsoft
286 Windows:
288   a) Use the free MSYS/MinGW development environment (Minimalist GNU
289      for Windows, www.mingw.org).  Install MinGW and MSYS, then follow
290      the instructions above (i.e. "./configure" followed by "make").
292   b) Use the free Cygwin development environment
293      (http://www.cygwin.com/).  Install Cygwin, then follow the
294      instructions above (i.e. "./configure" followed by "make").
296   c) Use the Open Watcom compiler which can be obtained at no charge
297      from http://openwatcom.mirrors.pair.com/.  You must perform a
298      full installation of the Open Watcom compiler in C:\WATCOM.  From
299      the shell, execute the batch file "misc\openwatcom.bat".
301   d) Use the Microsoft Visual C++ 2005 Express Edition which can be
302      obtained at no charge from Microsoft at this URL:
303      http://msdn.microsoft.com/vstudio/express/downloads/default.aspx .
304      You must also install the Microsoft Platform SDK.  From the
305      shell, execute the batch file "misc\vcexpress.bat".
307   e) Use Microsoft Visual Studio .NET 2003.  You must unzip
308      "misc\vstudio.zip" in the Gambit distribution's root directory.
309      Then with Microsoft Visual Studio open "gambc.sln" and select
310      "Build Solution" (Ctrl+Shift+B).
313 5) If you can't build the system on your platform
314 =================================================
316 The configure script tailors the build process to your platform.
317 Although it can adapt to a wide range of platforms there are cases
318 where it is not clever enough to do it completely automatically.
320 In this case you need to modify the configure script (the file
321 "configure.ac") and/or the source code of the Gambit-C system.  Most
322 of the system dependent code is located in the files
323 "include/gambit.h", "lib/os*.h" and "lib/os*.c".  Never modify the C
324 files generated by the Gambit-C compiler (these files usually have a
325 name that starts or ends with an underscore).
327 If you needed to modify any file to get Gambit-C to work properly on
328 your system, please send your modifications along with your machine/OS
329 specification to
331   gambit@iro.umontreal.ca
333 so that it can be added to the next release.