Another simplistic solution, with SCons

SCons is a program designed to replace make and autotools. SCons being a new tool is built with all the knowledge of what problem really this kind of tool should be solving, while make and autotools were built while discovering the real problem. It is natural to expect SCons to have a better design that covers the big picture.

It uses only one configuration file to perform all the tasks, a SConstruct, instead of a lot like Makefile, a configure, and all those .in, .am,, etc. I’ve found SCons also easier to extend than autotools to support new compilers. Which is why I made: SCons Erlang, SCons Chicken, and some other scons than I never released. SCons is developed in Python, so are SCons extensions and the SConstruct file is really a Python module in disguise. It isn’t Lisp, but it is nicer than those special languages like make’s.

Enough presentation, this is another chapter in the let’s solve Lisp’s greatest problem series (The problem with Lisp, Solving Lisp’s problem: a simplistic solution with make) let’s get to it.

We’ll use the same hello-world.lisp as before:

(defun main ()
  (format t "Hello world!~%"))


This time we make a SConstruct file containing:

clBuilder = Builder(action = "cl-launch --output $TARGET --file $SOURCE", src_suffix = ".lisp")

env = Environment(BUILDERS = {"CommonLisp" : clBuilder})


and then we just compile:

$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl-launch --output hello-world --file hello-world.lisp
scons: done building targets.

and here we have our executable program:

$ ./hello-world
Hello world!

You could say that we are not doing more than in the make post. But we are, look at this:

$ scons -c
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Cleaning targets ...
Removed hello-world
scons: done cleaning targets.

That means SCons already knows that some file was automatically generated, so it knows how to clean up. There’s another advantage: the first line is really what does the job, you could put it in a .py file and ship it and offer a reusable way of building Lisp programs. This simplistic example still misses configure-like behaviour, like finding where cl-launch is, and maybe running it with different parameters for different architectures (if that’s needed at all). It also misses a way to offer the user the hundreds of switches and knows that cl-launch provides, just take a look at the output of “cl-launch –help” on its web site.

You may also like:

Leave a Reply

Hi, I'm Pablo, this is my web site. You can follow me or connect with me:

Or get new content delivered directly to your inbox.

Join 4,025 other subscribers

I'm writing a book

Stack of copies of How to Hire and Manage Remote Teams

How to Hire and Manage Remote Teams, where I distill all the techniques I've been using to build and manage distributed teams for the past 10 years.

I write about:

announcement blogging book book review book reviews books building Sano Business C# Clojure ClojureScript Common Lisp database Debian Esperanto Git history idea Java Kubuntu Lisp music Non-Fiction OpenID programming Python Rails rant re-frame release Ruby Ruby on Rails Sano science science fiction security self-help Star Trek startups technology Ubuntu video web Windows WordPress

I've been writing for a while:

%d bloggers like this: