Next: Saving Executable Images, Previous: GNU configure and make, Up: Installing SCM [Contents][Index]
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.
Next: Build Options, Previous: Building SCM, Up: Building SCM [Contents][Index]
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
Next: Compiling and Linking Custom Files, Previous: Invoking Build, Up: Building SCM [Contents][Index]
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.
Previous: Build Options, Up: Building SCM [Contents][Index]
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.
Next: Saving Executable Images, Previous: GNU configure and make, Up: Installing SCM [Contents][Index]