make-alpha
[Top][All Lists]
Advanced

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

Re: Guile support in GNU make


From: Eli Zaretskii
Subject: Re: Guile support in GNU make
Date: Sat, 28 Jan 2012 13:50:05 +0200

> From: Paul Smith <address@hidden>
> Date: Sat, 14 Jan 2012 15:13:36 -0500
> 
> I've attached the section of the manual describing the new function and
> the default Guile implementation that's embedded into GNU make when
> Guile is compiled in.
> [...]
>    This code defines the Guile functions:
> 
>      define GUILEIO
>      ;; A simple Guile IO library for GNU make
> 
>      (define MKPORT #f)
> 
>      (define (mkopen name mode)
>        (set! MKPORT (open-file name mode))
>        #f)
> 
>      (define (mkwrite s)
>        (display s MKPORT)
>        (newline MKPORT)
>        #f)
> 
>      (define (mkclose)
>        (close-port MKPORT)
>        #f)
>      endef
> 
>      # Internalize the Guile IO functions
>      $(guile $(GUILEIO))
> 
>    Now you can use these Guile functions to create files.  Suppose you
> need to operate on a very large list, which cannot fit on the command
> line, but the utility you're using accepts the list as input as well:
> 
>      prog: $(PREREQS)
>              @$(guile (mkopen "tmp.out" "w")) \
>               $(foreach X,$^,$(guile (mkwrite "$(X)"))) \
>               $(guile (mkclose))
>              $(LINK) < tmp.out

Paul, can you please show a complete Makefile that uses the above,
which works for you?  I'm testing the CVS Make built with Guile on
MS-Windows, and I couldn't get the above to work.  With the Makefile
shown below, and files whose names are in PREREQS existing in the
current directory, the last command fails because the file tmp.out is
not there (either not created or somehow deleted by the time the last
line runs).

Did I miss something, or is there some bug in the version of Guile I'm
using?

Thanks in advance!

----------------------------------------
define GUILEIO

 (define MKPORT #f)

 (define (mkopen name mode)
   (set! MKPORT (open-file name mode))
   #f)

 (define (mkwrite s)
   (display s MKPORT)
   (newline MKPORT)
   #f)

 (define (mkclose)
   (close-port MKPORT)
   #f)
endef

# Internalize the Guile IO functions
$(guile $(GUILEIO))

PREREQS = foo bar baz whatever more noch ein mahl

prog: $(PREREQS)
        @$(guile (mkopen "tmp.out" "w")) \
        $(foreach X,$^,$(guile (mkwrite "$(X)"))) \
        $(guile (mkclose))
        cat < tmp.out



reply via email to

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