This manual is for SCM (version 5f4, January 2024), an implementation of the algorithmic language Scheme.
Copyright © 1990-2007 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License.”
SCM is a portable Scheme implementation written in C. SCM provides a machine independent platform for [JACAL], a symbolic algebra system. SCM supports and requires the SLIB Scheme library. SCM, SLIB, and JACAL are GNU projects.
logand, logor, logxor,
lognot, ash, logcount, integer-length,
bit-extract, defmacro, macroexpand,
macroexpand1, gentemp, defvar, force-output,
software-type, get-decoded-time,
get-internal-run-time, get-internal-real-time,
delete-file, rename-file, copy-tree, acons,
and eval.
Char-code-limit, most-positive-fixnum,
most-negative-fixnum, and internal-time-units-per-second
constants. slib:features and *load-pathname* variables.
verbose function).
Restart, quit, and exec.
Most of SCM.
Arrays, gsubrs, compiled closures, records, Ecache, syntax-rules
macros, and safeports.
Real and Complex functions. Fast mixed type arithmetics.
Syntax checking and memoization of special forms by evaluator. Storage allocation strategy and parameters.
Siod, written by George Carrette, was the starting point for SCM. The major innovations taken from Siod are the evaluator’s use of the C-stack and being able to garbage collect off the C-stack (see Garbage Collection).
There are many other contributors to SCM. They are acknowledged in the file ChangeLog, a log of changes that have been made to scm.
Authors have assigned their SCM copyrights to:
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Paradigm Associates Inc not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission.
PARADIGM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL PARADIGM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
gjc@paradigm.com
Phone: 617-492-6079
Paradigm Associates Inc 29 Putnam Ave, Suite 6 Cambridge, MA 02138
Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. http://fsf.org/ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
The purpose of this License is to make a manual, textbook, or other functional and useful document free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.
This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.
We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.
This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you”. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.
A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.
A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.
The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.
The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.
A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not “Transparent” is called “Opaque”.
Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.
The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work’s title, preceding the beginning of the body of the text.
The “publisher” means any person or entity that distributes copies of the Document to the public.
A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition.
The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.
You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly display copies.
If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document’s license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.
You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:
If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version’s license notice. These titles must be distinct from any other section titles.
You may add a section Entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties—for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.
You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled “History” in the various original documents, forming one section Entitled “History”; likewise combine any sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You must delete all sections Entitled “Endorsements.”
You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.
A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation’s users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document’s Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.
Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.
If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “History”, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.
You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it.
The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Document.
“Massive Multiauthor Collaboration Site” (or “MMC Site”) means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A “Massive Multiauthor Collaboration” (or “MMC”) contained in the site means any set of copyrightable works thus published on the MMC site.
“CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization.
“Incorporate” means to publish or republish a Document, in whole or in part, as part of another Document.
An MMC is “eligible for relicensing” if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing.
To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:
Copyright (C) year your name. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''.
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the “with…Texts.” line with this:
with the Invariant Sections being list their titles, with
the Front-Cover Texts being list, and with the Back-Cover Texts
being list.
If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.
If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.
IEEE Standard 1178-1990. IEEE Standard for the Scheme Programming Language. IEEE, New York, 1991.
William Clinger and Jonathan Rees, Editors. Revised(4) Report on the Algorithmic Language Scheme. ACM Lisp Pointers Volume IV, Number 3 (July-September 1991), pp. 1-55.
Richard Kelsey and William Clinger and Jonathan (Rees, editors) Revised(5) Report on the Algorithmic Language Scheme. Higher-Order and Symbolic Computation Volume 11, Number 1 (1998), pp. 7-105, and ACM SIGPLAN Notices 33(9), September 1998.
William Clinger Hygienic Macros Through Explicit Renaming Lisp Pointers Volume IV, Number 4 (December 1991), pp 17-23.
Harold Abelson and Gerald Jay Sussman with Julie Sussman. Structure and Interpretation of Computer Programs. MIT Press, Cambridge, 1985.
Brian Harvey and Matthew Wright. Simply Scheme: Introducing Computer Science MIT Press, 1994 ISBN 0-262-08226-8
$B8$;tBg(B(Dai Inukai) $BF~Lg(BScheme 1999$BG/(B12$B7n=iHG(B ISBN4-87966-954-7
Todd R. Eigenschink, Dave Love, and Aubrey Jaffer. SLIB, The Portable Scheme Library. Version 2c8, June 2000.
Aubrey Jaffer. JACAL Symbolic Mathematics System. Version 1b0, Sep 1999.
Documentation of scm extensions (beyond Scheme standards).
Documentation on the internal representation and how to extend or
include scm in other programs.
Documentation of the Xlib - SCM Language X Interface.
SCM runs on a wide variety of platforms. “Distributions” is the starting point for all platforms. The process described in “GNU configure and make” will work on most Unix and GNU/Linux platforms. If it works for you, then you may skip the later sections of “Installing SCM”.
The SCM homepage contains links to precompiled binaries and source distributions.
Downloads and instructions for installing the precompiled binaries are at http://people.csail.mit.edu/jaffer/SCM#QuickStart.
If there is no precompiled binary for your platform, you may be able to build from the source distribution. The rest of these instructions deal with building and installing SCM and SLIB from sources.
Download (both SCM and SLIB of) either the last release or current development snapshot from http://people.csail.mit.edu/jaffer/SCM#BuildFromSource.
Unzip both the SCM and SLIB zips. For example, if you are working in /usr/local/src/, this will create directories /usr/local/src/scm/ and /usr/local/src/slib/.
scm/configure and slib/configure are Shell scripts which create the files scm/config.status and slib/config.status on Unix and MinGW systems.
The config.status files are used (included) by the Makefile to
control where the packages will be installed by make install.
With GNU shell (bash) and utilities, the following commands should
build and install SCM and SLIB:
bash$ (cd slib; ./configure --prefix=/usr/local/) bash$ (cd scm > ./configure --prefix=/usr/local/ > make scmlit > sudo make all > sudo make install) bash$ (cd slib; sudo make install)
If the install commands worked, skip to Testing.
If configure doesn’t work on your system, make scm/config.status and slib/config.status be empty files.
For additional help on using the configure script, run ‘./configure --help’.
‘make all’ will attempt to create a dumped executable (see Saving Executable Images), which has very small startup latency. If that fails, it will try to compile an ordinary ‘scm’ executable.
Note that the compilation output may contain error messages; be concerned only if the ‘make install’ transcripts contain errors.
‘sudo’ runs the command after it as user root. On recent GNU/Linux systems, dumping requires that ‘make all’ be run as user root; hence the use of ‘sudo’.
‘make install’ requires root privileges if you are installing to standard Unix locations as specified to (or defaulted by) ‘./configure’. Note that this is independent of whether you did ‘sudo make all’ or ‘make all’.
The SCM distribution Makefile contains rules for making scmlit, a “bare-bones” version of SCM sufficient for running build. build is a Scheme program used to compile (or create scripts to compile) full featured versions of SCM (see Building SCM). To create scmlit, run ‘make scmlit’ in the scm/ directory.
Makefiles are not portable to the majority of platforms. If you need to compile SCM without ‘scmlit’, there are several ways to proceed:
If you didn’t create scmlit using ‘make scmlit’, then you must create a file named scm/require.scm. For most installations, scm/require.scm can just be copied from scm/requires.scm, which is part of the SCM distribution.
If, when executing ‘scmlit’ or ‘scm’, you get a message like:
ERROR: "LOAD couldn't find file " "/usr/local/src/scm/require"
then create a file require.scm in the SCM implementation-vicinity (this is the same directory as where the file Init5f4.scm is). require.scm should have the contents:
(define (library-vicinity) "/usr/local/lib/slib/")
where the pathname string /usr/local/lib/slib/ is to be replaced by the pathname into which you unzipped (or installed) SLIB.
Alternatively, you can set the (shell) environment variable
SCHEME_LIBRARY_PATH to the pathname of the SLIB directory
(see Environment Variables).
If set, this environment variable overrides scm/require.scm.
Absolute pathnames are recommended here; if you use a relative pathname, SLIB can get confused when the working directory is changed (see chmod). The way to specify a relative pathname is to append it to the implementation-vicinity, which is absolute:
(define library-vicinity
(let ((lv (string-append (implementation-vicinity) "../slib/")))
(lambda () lv)))
Each of the following four ‘make’ targets creates an executable named scm. Each target takes its build options from a file with an ‘.opt’ suffix. If that options file doesn’t exist, making that target will create the file with the ‘-F’ features: cautious, bignums, arrays, inexact, engineering-notation, and dynamic-linking. Once that ‘.opt’ file exists, you can edit it to your taste and it will be preserved.
make scm4Produces a R4RS executable named scm lacking hygienic macros (but with defmacro). The build options are taken from scm4.opt. If build or the executable fails, try removing ‘dynamic-linking’ from scm4.opt.
make scm5R5RS; like ‘make scm4’ but with ‘-F macro’. The build options are taken from scm5.opt. If build or the executable fails, try removing ‘dynamic-linking’ from scm5.opt.
make dscm4Produces a R4RS executable named udscm4, which it starts and dumps to a low startup latency executable named scm. The build options are taken from udscm4.opt.
If the build fails, then ‘build scm4’ instead. If the dumped executable fails to run, then send me a bug report (and use ‘build scm4’ until the problem with dump is corrected).
make dscm5Like ‘make dscm4’ but with ‘-F macro’. The build options are taken from udscm5.opt.
If the build fails, then ‘build scm5’ instead. If the dumped executable fails to run, then send me a bug report (and use ‘build scm5’ until the problem with dump is corrected).
If the above builds fail because of ‘-F dynamic-linking’, then (because they can’t be dynamically linked) you will likely want to add some other features to the build’s ‘.opt’ file. See the ‘-F’ build option in Build Options.
If dynamic-linking is working, then you will likely want to compile most of the modules as DLLs. The build options for compiling DLLs are in dlls.opt.
make x.soThe Xlib module;
SCM Language X Interface in Xlibscm.
make myturtleCreates a DLL named turtlegr.so which is a simple graphics API.
make wbscm.soThe wb module;
B-tree database implementation in wb.
Compiling this requires that wb source be in a peer directory to scm.
make dllsCompiles all the distributed library modules, but not wbscm.so. Many of the module compiles are recursively invoked in such a way that failure of one (which could be due to a system library not being installed) doesn’t cause the top-level ‘make dlls’ to fail. If ‘make dlls’ fails as a whole, it is time to submit a bug report (see Reporting Problems).
The file build loads the file build.scm, which constructs a relational database of how to compile and link SCM executables. build.scm has information for the platforms which SCM has been ported to (of which I have been notified). Some of this information is old, incorrect, or incomplete. Send corrections and additions to agj@alum.mit.edu.
This section teaches how to use build, a Scheme program for creating compilation scripts to produce SCM executables and library modules. The options accepted by ‘build’ are documented in Build Options.
Use the any method if you encounter problems with the other two methods (MS-DOS, Unix).
From the SCM source directory, type ‘build’ followed by up to 9 command line arguments.
From the SCM source directory, type ‘./build’ followed by command line arguments.
From the SCM source directory, start ‘scm’ or ‘scmlit’ and
type (load "build"). Alternatively, start ‘scm’ or
‘scmlit’ with the command line argument ‘-ilbuild’.
This method will also work for MS-DOS and Unix.
After loading various SLIB modules, the program will print:
type (b "build <command-line>") to build type (b*) to enter build command loop
The ‘b*’ procedure enters into a build shell where you can enter commands (with or without the ‘build’). Blank lines are ignored. To create a build script with all defaults type ‘build’.
If the build-shell encouters an error, you can reenter the build-shell by typing ‘(b*)’. To exit scm type ‘(quit)’.
Here is a transcript of an interactive (b*) build-shell.
bash$ scmlit SCM version 5e7, Copyright (C) 1990-2006 Free Software Foundation. SCM comes with ABSOLUTELY NO WARRANTY; for details type `(terms)'. This is free software, and you are welcome to redistribute it under certain conditions; type `(terms)' for details. > (load "build") ;loading build ; loading /home/jaffer/slib/getparam ; loading /home/jaffer/slib/coerce ... ; done loading build.scm type (b "build <command-line>") to build type (b*) to enter build command loop ;done loading build #<unspecified> > (b*) ;loading /home/jaffer/slib/comparse ;done loading /home/jaffer/slib/comparse.scm build> -t exe #! /bin/sh # unix (linux) script created by SLIB/batch Wed Oct 26 17:14:23 2011 # [-p linux] # ================ Write file with C defines rm -f scmflags.h echo '#define IMPLINIT "Init5e7.scm"'>>scmflags.h echo '#define BIGNUMS'>>scmflags.h echo '#define FLOATS'>>scmflags.h echo '#define ARRAYS'>>scmflags.h # ================ Compile C source files gcc -c continue.c scm.c scmmain.c findexec.c script.c time.c repl.c scl.c eval.c sys.c subr.c debug.c unif.c rope.c # ================ Link C object files gcc -rdynamic -o scm continue.o scm.o scmmain.o findexec.o script.o time.o repl.o scl.o eval.o sys.o subr.o debug.o unif.o rope.o -lm -lc "scm" build> -t exe -w myscript.sh "scm" build> (quit)
No compilation was done. The ‘-t exe’ command shows the compile script. The ‘-t exe -w myscript.sh’ line creates a file myscript.sh containing the compile script. To actually compile and link it, type ‘./myscript.sh’.
Invoking build without the ‘-F’ option will build or create a
shell script with the arrays, inexact, and
bignums options as defaults. Invoking ‘build’ with
‘-F lit -o scmlit’ will make a script for compiling
‘scmlit’.
bash$ ./build -| #! /bin/sh # unix (linux) script created by SLIB/batch # ================ Write file with C defines rm -f scmflags.h echo '#define IMPLINIT "Init5f4.scm"'>>scmflags.h echo '#define BIGNUMS'>>scmflags.h echo '#define FLOATS'>>scmflags.h echo '#define ARRAYS'>>scmflags.h # ================ Compile C source files gcc -O2 -c continue.c scm.c scmmain.c findexec.c script.c time.c repl.c scl.c eval.c sys.c subr.c debug.c unif.c rope.c # ================ Link C object files gcc -rdynamic -o scm continue.o scm.o scmmain.o findexec.o script.o time.o repl.o scl.o eval.o sys.o subr.o debug.o unif.o rope.o -lm -lc
To cross compile for another platform, invoke build with the ‘-p’ or ‘--platform=’ option. This will create a script for the platform named in the ‘-p’ or ‘--platform=’ option.
bash$ ./build -o scmlit -p darwin -F lit -| #! /bin/sh # unix (darwin) script created by SLIB/batch # ================ Write file with C defines rm -f scmflags.h echo '#define IMPLINIT "Init5f4.scm"'>>scmflags.h # ================ Compile C source files cc -O3 -c continue.c scm.c scmmain.c findexec.c script.c time.c repl.c scl.c eval.c sys.c subr.c debug.c unif.c rope.c # ================ Link C object files mv -f scmlit scmlit~ cc -o scmlit continue.o scm.o scmmain.o findexec.o script.o time.o repl.o scl.o eval.o sys.o subr.o debug.o unif.o rope.o
The options to build specify what, where, and how to build a SCM program or dynamically linked module. These options are unrelated to the SCM command line options.
specifies that the compilation should be for a computer/operating-system combination called platform-name. Note The case of platform-name is distinguised. The current platform-names are all lower-case.
The platforms defined by table platform in build.scm are:
Table: platform name processor operating-system compiler #f processor-family operating-system #f symbol processor-family operating-system symbol symbol symbol symbol symbol ================= ================= ================= ================= *unknown* *unknown* unix cc acorn-unixlib acorn *unknown* cc aix powerpc aix cc alpha-elf alpha unix cc alpha-linux alpha linux gcc amiga-aztec m68000 amiga cc amiga-dice-c m68000 amiga dcc amiga-gcc m68000 amiga gcc amiga-sas m68000 amiga lc atari-st-gcc m68000 atari-st gcc atari-st-turbo-c m68000 atari-st tcc borland-c i8086 ms-dos bcc darwin powerpc unix cc djgpp i386 ms-dos gcc freebsd *unknown* unix cc gcc *unknown* unix gcc gnu-win32 i386 unix gcc highc i386 ms-dos hc386 hp-ux hp-risc hp-ux cc irix mips irix gcc linux *unknown* linux gcc linux-aout i386 linux gcc linux-ia64 ia64 linux gcc microsoft-c i8086 ms-dos cl microsoft-c-nt i386 ms-dos cl microsoft-quick-c i8086 ms-dos qcl ms-dos i8086 ms-dos cc netbsd *unknown* unix gcc openbsd *unknown* unix gcc os/2-cset i386 os/2 icc os/2-emx i386 os/2 gcc osf1 alpha unix cc plan9-8 i386 plan9 8c sunos sparc sunos cc svr4 *unknown* unix cc svr4-gcc-sun-ld sparc sunos gcc turbo-c i8086 ms-dos tcc unicos cray unicos cc unix *unknown* unix cc vms vax vms cc vms-gcc vax vms gcc watcom-9.0 i386 ms-dos wcc386p
specifies that the build options contained in pathname be spliced into the argument list at this point. The use of option files can separate functional features from platform-specific ones.
The Makefile calls out builds with the options in ‘.opt’ files:
Options for Makefile targets dlls, myturtle, and x.so.
Options for udgdbscm and gdbscm.
Options for libscm.a.
Options for pgscm, which instruments C functions.
Options for targets udscm4 and dscm4 (scm).
Options for targets udscm5 and dscm5 (scm).
The Makefile creates options files it depends on only if they do not already exist.
specifies that the compilation should produce an executable or object name of filename. The default is ‘scm’. Executable suffixes will be added if neccessary, e.g. ‘scm’ ⇒ ‘scm.exe’.
specifies that the libname should be linked with the executable produced. If compile flags or include directories (‘-I’) are needed, they are automatically supplied for compilations. The ‘c’ library is always included. SCM features specify any libraries they need; so you shouldn’t need this option often.
specifies that the definition should be made in any C source compilations. If compile flags or include directories (‘-I’) are needed, they are automatically supplied for compilations. SCM features specify any flags they need; so you shouldn’t need this option often.
specifies that that flag will be put on compiler command-lines.
specifies that that flag will be put on linker command-lines.
specifies that pathname should be the default location of the SCM initialization file Init5f4.scm. SCM tries several likely locations before resorting to pathname (see File-System Habitat). If not specified, the current directory (where build is building) is used.
specifies that the C source files pathname … are to be compiled.
specifies that the object files pathname … are to be linked.
specifies that the C functions call … are to be invoked during initialization.
specifies in general terms what sort of thing to build. The choices are:
executable program.
library module.
archived dynamically linked library object files.
dynamically linked library object file.
The default is to build an executable.
specifies how to build. The default is to create a batch file for the host system. The SLIB file batch.scm knows how to create batch files for:
This option executes the compilation and linking commands through the
use of the system procedure.
This option outputs Scheme code.
specifies where to write the build script. The default is to display it
on (current-output-port).
specifies to build the given features into the executable. The defined features are:
Alias for ARRAYS
array-map! and array-for-each (arrays must also be featured).
Use if you want arrays, uniform-arrays and uniform-vectors.
Large precision integers.
Treating strings as byte-vectors.
Byte/number conversions
Define this for extra checking of interrupt masking and some simple checks for proper use of malloc and free. This is for debugging C code in sys.c, eval.c, repl.c and makes the interpreter several times slower than usual.
Normally, the number of arguments arguments to interpreted closures (from LAMBDA) are checked if the function part of a form is not a symbol or only the first time the form is executed if the function part is a symbol. defining ‘reckless’ disables any checking. If you want to have SCM always check the number of arguments to interpreted closures define feature ‘cautious’.
If you only need straight stack continuations, executables compile with this feature will run faster and use less storage than not having it. Machines with unusual stacks need this. Also, if you incorporate new C code into scm which uses VMS system services or library routines (which need to unwind the stack in an ordrly manner) you may need to use this feature.
Use if you want to use compiled closures.
For the curses screen management package.
Turns on the features ‘cautious’ and
‘careful-interrupt-masking’; uses
-g flags for debugging SCM source code.
Sequence comparison
SCM normally converts references to local variables to ILOCs, which make programs run faster. If SCM is badly broken, try using this option to disable the MEMOIZE_LOCALS feature.
Convert a running scheme program into an executable file.
Be able to load compiled files while running.
interface to the editline or GNU readline library.
Use if you want floats to display in engineering notation (exponents always multiples of 3) instead of scientific notation.
make_gsubr for arbitrary (< 11) arguments to C functions.
Commonly available I/O extensions: exec, line I/O, file positioning, file delete and rename, and directory functions.
Use if you want floating point numbers.
Lightweight – no features
C level support for hygienic and referentially transparent macros (syntax-rules macros).
Client connections to the mysql databases.
Use if you want segments of unused heap to not be freed up after garbage collection. This may increase time in GC for *very* large working sets.
No features
Posix functions available on all Unix-like systems. fork and process functions, user and group IDs, file permissions, and link.
If your scheme code runs without any errors you can disable almost all error checking by compiling all files with ‘reckless’.
The Record package provides a facility for user to define their own record data types. See SLIB for documentation.
String regular expression matching.
These procedures were specified in the Revised^2 Report on Scheme but not in R4RS.
Use if you want to run code from:
Harold Abelson and Gerald Jay Sussman with Julie Sussman. Structure and Interpretation of Computer Programs. The MIT Press, Cambridge, Massachusetts, USA, 1985.
Differences from R5RS are:
Use if you want all inexact real numbers to be single precision. This only has an effect if SINGLES is also defined (which is the default). This does not affect complex numbers.
BSD socket interface. Socket addr functions require inexacts or bignums for 32-bit precision.
Use if you want the ticks and ticks-interrupt functions.
Turtle graphics calls for both Borland-C and X11 from sjm@ee.tut.fi.
Those unix features which have not made it into the Posix specs: nice, acct, lstat, readlink, symlink, mknod and sync.
WB database with relational wrapper.
no-comment
Microsoft Windows executable.
Alias for Xlib feature.
Interface to Xlib graphics routines.
A correspondent asks:
How can we link in our own c files to the SCM interpreter so that we can add our own functionality? (e.g. we have a bunch of tcp functions we want access to). Would this involve changing build.scm or the Makefile or both?
(see Changing Scm has instructions describing the C code format). Suppose a C file foo.c has functions you wish to add to SCM. To compile and link your file at compile time, use the ‘-c’ and ‘-i’ options to build:
bash$ ./build -c foo.c -i init_foo
-|
#! /bin/sh
rm -f scmflags.h
echo '#define IMPLINIT "/home/jaffer/scm/Init5f4.scm"'>>scmflags.h
echo '#define COMPILED_INITS init_foo();'>>scmflags.h
echo '#define BIGNUMS'>>scmflags.h
echo '#define FLOATS'>>scmflags.h
echo '#define ARRAYS'>>scmflags.h
gcc -O2 -c continue.c scm.c findexec.c script.c time.c repl.c scl.c \
eval.c sys.c subr.c unif.c rope.c foo.c
gcc -rdynamic -o scm continue.o scm.o findexec.o script.o time.o \
repl.o scl.o eval.o sys.o subr.o unif.o rope.o foo.o -lm -lc
To make a dynamically loadable object file use the -t dll option:
bash$ ./build -t dll -c foo.c -| #! /bin/sh rm -f scmflags.h echo '#define IMPLINIT "/home/jaffer/scm/Init5f4.scm"'>>scmflags.h echo '#define BIGNUMS'>>scmflags.h echo '#define FLOATS'>>scmflags.h echo '#define ARRAYS'>>scmflags.h echo '#define DLL'>>scmflags.h gcc -O2 -fpic -c foo.c gcc -shared -o foo.so foo.o -lm -lc
Once foo.c compiles correctly (and your SCM build supports
dynamic-loading), you can load the compiled file with the Scheme command
(load "./foo.so"). See Configure Module Catalog for how to
add a compiled dll file to SLIB’s catalog.
In SCM, the ability to save running program images is called dump
(see Dump). In order to make dump available to SCM, build
with feature ‘dump’. dumped executables are compatible with
dynamic linking.
Most of the code for dump is taken from emacs-19.34/src/unex*.c. No modifications to the emacs source code were required to use unexelf.c. Dump has not been ported to all platforms. If unexec.c or unexelf.c don’t work for you, try using the appropriate unex*.c file from emacs.
The ‘dscm4’ and ‘dscm5’ targets in the SCM Makefile save images from udscm4 and udscm5 executables respectively.
Address space layout randomization interferes with dump.
Here are the fixes for various operating-systems:
Remove the ‘#’ from the line ‘#SETARCH = setarch i386’ in the Makefile.
http://jamesthornton.com/writing/emacs-compile.html [For FC3] combreloc has become the default for recent GNU ld, which breaks the unexec/undump on all versions of both Emacs and XEmacs...
Override by adding the following to udscm5.opt: ‘--linker-options="-z nocombreloc"’
http://www.opensubscriber.com/message/emacs-devel@gnu.org/1007118.html
mentions the exec-shield feature. Kernels later than 2.6.11 must do (as root):
echo 0 > /proc/sys/kernel/randomize_va_space
before dumping. Makefile has this randomize_va_space stuffing scripted for targets ‘dscm4’ and ‘dscm5’. You must either set randomize_va_space to 0 or run as root to dump.
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/Manpages/man1/dyld.1.html
The dynamic linker uses the following environment variables. They affect any program that uses the dynamic linker.
DYLD_NO_PIE
Causes dyld to not randomize the load addresses of images in a process where the main executable was built position independent. This can be helpful when trying to reproduce and debug a problem in a PIE.
Once scmlit, scm, and dlls have been built, these
commands will install them to the locations specified when you ran
‘./configure’:
bash$ (cd scm; make install) bash$ (cd slib; make install)
Note that installation to system directories (like ‘/usr/bin/’) will require that those commands be run as root:
bash$ (cd scm; sudo make install) bash$ (cd slib; sudo make install)