I recently stated what I believe is the biggest problem with Lisp, you can’t make programs with it. In my quest, my first solution is a very simplistic Makefile that does the job using cl-launch, a very interesting program that can turn a Common Lisp program into a Bash script. Other solutions are likely to use cl-launch as well.

So, we’ll play with this little program:

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

(main)

Very trivial indeed. And to “compile it”, we’d use this trivial Makefile:

%: %.lisp
        cl-launch --output $@ --file $&<

hello-world: hello-world.lisp

All we have to do now is run make:

$ make
cl-launch --output hello-world --file hello-world.lisp

And we now have a runable hello-world:

$ ./hello-world
Hello world!

It run! it worked! it’s portable! Isn’t it great?

Obviously all the logic is hidden inside cl-launch (thank you Fare Rideau). The problems with this simple solution is that using only make makes programs harder to port and package for different distributions and operating systems. That’s why the autotools where invented. Remember those days when to compile something we had to open a Makefile and set up variables? well, this simplistic solution is going back to those days. We can do better, I hope I can do better.

Now, for the curious, this is how the hello-world script looks like (I’d say its quite remarkable):

#!/bin/sh
#| CL-LAUNCH 2.03 CONFIGURATION
SOFTWARE_FILE=.
SOFTWARE_SYSTEM=
SOFTWARE_INIT_FORMS=
SYSTEMS_PATHS=
INCLUDE_PATH=/usr/share/common-lisp/source/cl-launch
LISPS="cmucl sbcl clisp ecl openmcl gclcvs allegro lisp gcl"
WRAPPER_CODE=
DUMP=
RESTART=
IMAGE_BASE=
IMAGE_DIR=
IMAGE=

# END OF CL-LAUNCH CONFIGURATION
# This file was generated by CL-Launch 2.03
# This file was automatically generated and contains parts of CL-Launch
#
PROG=""
. /usr/share/common-lisp/source/cl-launch/wrapper.sh

launch_self "$@"

ABORT

# |#

(load "/usr/share/common-lisp/source/cl-launch/header.lisp" :verbose nil :print nil)

;;;; CL-LAUNCH LISP INITIALIZATION CODE

#-cl-launched
(cl-launch::run :load :self)

;;;; END OF CL-LAUNCH LISP INITIALIZATION CODE

;;; 65bcc57c2179aad145614ec328ce5ba8 SOFTWARE WRAPPED BY CL-LAUNCH BEGINS HERE:

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

(main)

Leave a Reply

If you want to work with me or hire me? Contact me

You can follow me or connect with me:

Or get new content delivered directly to your inbox.

Join 5,038 other subscribers

I wrote 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 ham radio history idea Java Kubuntu Lisp management Non-Fiction OpenID programming Python Radio Society of Great Britain Rails rant re-frame release Ruby Ruby on Rails Sano science science fiction security self-help Star Trek technology Ubuntu web Windows WordPress

I've been writing for a while:

Mastodon

%d bloggers like this: