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

Re: [plt-scheme] make collection



The make collection's syntax is intended to simulate regular unix make
in Scheme and the docs assume that you are already familiar with how
those both work. If you haven't worked with the regular unix make
much or Scheme much, the docs can be quite confusing.

The idea is to explain how to generate some project you have from a
collection of source files that go through several stages of
processing. 

For example, lets say that you are writing soem project that has three
input files (that you create and maintain) called a.input, b.input, and
c.input. Further, there are two stages of processing -- first you run a
particular tool "make-output" that takes an input file and produces and
output file, and second you combine the input files into a single file
using "output".

Using make, you might write this:

a.output: a.input
	make-output a.input a.output

b.output: b.input
	make-output b.input b.output

c.output: c.input
	make-output c.input c.output

total: a.output b.output c.output
	combine a.output b.output c.output

Once you've put those above lines in a file called "Makefile", you can
issue the command:

  make total

that builds your entire project. 

The Makefile consists of several lines that tell `make' how to create
each piece. The first two lines say that a.output depends on a.input
and the command for making a.output from a.input is "make-output
a.input a.ouput".

The whole point of this exercise is that the `make' utility looks at
the file creation dates of the various files and only re-builds what is
necessary.

Make is based on building things with shell programs. If, on the other
hand, you want to build similar things with various Scheme programs,
you can use the make collection. Here's the equivalent Scheme program:

(require (lib "make.ss" "make"))

(define (make-output in out)
   ...)

(define (combine-total . args)
  ...)

(make
  (("a.ouput" ("a.input") (make-output "a.output" "a.input"))
   ("b.ouput" ("b.input") (make-output "b.output" "b.input"))
   ("c.ouput" ("c.input") (make-output "c.output" "c.input"))
   ("total" ("a.output" "b.output" "c.output") 
            (combine-total "a.output" "b.output" "c.output")))

If you were to fill in the ellipses above with calls to `system', you'd
have the exact same thing as the original Makefile.

In addition, if you use `make/proc', you can abstract over the various
make lines (for example, the a.output, b.output, and c.output lines are
very similar and it would be good to write a program to generate those
lines).

Hope that helps!

Robby


At 09 May 2002 00:11:28 +0200, "Jose A. Ortega Ruiz" wrote:
> 
> hi,
> 
> i'm new to plt scheme, and have just begun a project using mzscheme,
> version 200alpha12, on linux. to build the project (i use noweb), i'm
> using the usual Makefile processed by GNU Make. but, browsing with
> HelpDesk, i've come across the make collection. my understanding is
> that it is a make replacement written in scheme. unfortunately, i
> haven't been able to fully understand how it works from the
> documentation in HelpDesk... so, i would really appreciate some usage
> samples, or a pointer to further information.
> 
> thanks for your help,
> 
> jao