Roland Ver. 4.5 Technical Information Seite 145

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 212
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 144
Chapter 12: Extending GNU make 135
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)
#f
endef
# Internalize the Guile IO functions
$(guile $(GUILEIO))
If you have a significant amount of Guile support code, you might consider keeping it
in a different file (e.g., guileio.scm) and then loading it in your makefile using the guile
function:
$(guile (load "guileio.scm"))
An advantage to this method is that when editing guileio.scm, your editor will under-
stand that this file contains Scheme syntax rather than makefile syntax.
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
A more comprehensive suite of file manipulation procedures is possible of course. You
could, for example, maintain multiple output files at the same time by choosing a symbol
for each one and using it as the key to a hash table, where the value is a port, then returning
the symbol to be stored in a make variable.
12.2 Loading Dynamic Objects
Seitenansicht 144
1 2 ... 140 141 142 143 144 145 146 147 148 149 150 ... 211 212

Kommentare zu diesen Handbüchern

Keine Kommentare