LispBM
Building LispBM

About building LispBM

LispBM is intended to be integrated into a larger application and then building LispBM is a part of building that larger application. Currently there are no detailed instructions on how to set that up other than the examples that exists in vesc_express, BLDC. and in the LispBM REPL.

Conditional building of features

The following flags can be used when building LispBM to turn features on or off. These should be added as a -D... flag to the C compiler for the LispBM compilation units.

  • LBM64 - Builds the 64bit version of LispBM. Default is 32bit.
  • FULL_RTS_LIB - Build all the extensions in the runtime system extensions library.
  • LBM_ALWAYS_GC - Debug mode where the garbage collector is run for (most) every allocation.
  • LBM_USE_GC_PTR_REV - Use the Deutch-Schorr-Waite pointer reversal GC algorithm.
  • LBM_USE_DYN_FUNS - Add a library of functions to the dynamic loader.
  • LBM_USE_DYN_MACROS - Add a library of macros to the dynamic loader.
  • LBM_USE_DYN_DEFSTRUCT - Add the defstruct mechanism, requires LBM_USE_DYN_FUNS and LBM_USE_DYN_MACROS.
  • LBM_USE_DYN_LOOPS - Add loop macros, requires LBM_USE_DYN_MACROS.
  • LBM_USE_DYN_ARRAYS - Add additional array manipulation functions. Requires LBM_USE_DYN_MACROS and LBM_USE_DYN_LOOPS
  • LBM_USE_TIME_QUOTA - Use scheduler with time-based quotas instead of evaluator steps.

Build on Linux

Start by cloning the LispBM repository. Open a terminal and issue command

git clone https://github.com/svenssonjoel/lispBM.git

You should now have a directory called lispBM. Go into it and into the repl subdirectory.

cd lispBM
cd repl

Now, you have multiple choices on how to build the REPL. To build the 32bit version (which is most similar to what you will run on a microcontroller) issue the make command.

make

If the make command above fails, it is most likely because there are some missing dependencies.

Building the 32bit version of the repl requires 32bit libraries. If you are on an Ubuntu platform you get 32bit standard libraries by installing gcc-multilib.

In addition to gcc-multilib the REPL requires libreadline andlibpng. You need to get the 32bit versions of these libraries. On Ubuntu you can run the following commands.

sudo apt install gcc-multilib libreadline-dev:i386 libpng-dev:i386

If you were unable to install the 32bit dependencies with the command above, you may need to instruct the package manager that you are interested in 32bit packages as well.

sudo dpkg --add-architecture i386

Then retry the previous step to install the dependencies.

If installing the dependencies finished successfully, make should now work and the repl executable should be built.

Start the REPL and explore!

./repl

You should now be greeted by the LispBM REPL in a way similar to what is shown below.

Lisp REPL started! (LBM Version: 0.27.1)
Type :quit to exit.
:info for statistics.
:load [filename] to load lisp source.
#
</pre>
<p> Try to evaluate some expressions. Type <code>(+ 1 2)</code> and press enter. </p>
<pre>
Lisp REPL started! (LBM Version: 0.27.1)
Type :quit to exit.
:info for statistics.
:load [filename] to load lisp source.
# (+ 1 2)
> 3
#

When you input code at the # prompt, LispBM answers on a new line starting with >.

Alternatively the REPL can be built as a 64bit binary. Building the 64bit binary requires 64bit versions of the readline and png libraries.

On Ubuntu you get the dependcies by doing sudo apt install libreadline-dev libpng-dev. Then to build the executable you issue the following command.

make all64

Lastly, the REPL can be build with SDL (Simple Directmedia Layer) for graphical output. This is done by issueing the following command.

make sdl64

Or for 32bit.

make sdl

The REPL with SDL requires libsdl2-dev and libsdl2-image-dev libraries or the 32 bit versions (for 32bit repl binary) libsdl2-dev:i386 and libsdl2-image-dev:i386.