make-alpha
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Guile support in GNU make


From: Paul Smith
Subject: Guile support in GNU make
Date: Tue, 20 Sep 2011 18:16:51 -0400

Hi all.

Over the last weekend I've been playing with adding (optional of course)
support for Guile as an embedded scripting language into GNU make.  It
seems to work pretty well, so far.

On the make side, there's a new function "$(guile ...)" which takes a
single argument; that argument is make-expanded then the result is
passed to Guile's evaluator.  The result is converted into a string and
used as the expansion of the function (see below for the rules for
conversion of Guile objects into strings).

On the Guile side, make registers two procedures into the Guile
namespace: (make-expand "<val>") which passes the string <val> to make's
expansion engine.  The result is returned as a Guile string object.

And, (make-eval "<val>") which passes the string <val> to make's eval
engine.  This always expands to nothing.  This is really syntactic sugar
for (make-expand "$(eval <val>)") but it seemed like it might be useful
to have a separate function.

To convert Guile objects into strings, so far I have it breaking down
like this:

#t              => "t"   (not sure about this...?)
#f              => ""
"string"        => "string"
1234            => "1234"
'symbol         => "symbol"
'(a . b)        => "a b"
'()             => ""
'(a b c d)      => "a b c d"
'(a (b c) (d))  => "a b c d"
<other-object>  => Throw an error

I'm far from a Guile guru; I haven't hacked much Lisp since I worked on
a few ELisp packages years ago, and ELisp ain't Scheme.  If you have
opinions on how you might like this to look (especially if you're
familiar with writing more complex Scheme/Guile) let me know.

I'm hoping to use this to avoid adding lots of new GNU make functions,
rather than continuing on the road to GNU make having its own new
meta-language.  I realize many people won't be thrilled with this
approach for various reasons: having to install another package, having
to write Lisp, etc.  I'm interested in discussing that too.

Finally assuming we continue with this approach, there are open
questions such as, should I load some useful modules automatically, or
just let the user initialize what they like?  What belongs in its own
module, and what's private and public?  Are there other make
capabilities that should be exported, even as syntactic sugar.  For
example, maybe a function that returns the value of a variable so you
can write
        $(guile ... (make-lookup var) ...)
instead of
        $(guile ... (make-expand (format #f "$$(~s)" var) ...)
or whatever (I told you I'm no Scheme guru! :-))  Or other things?

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]