Version: 4.1

1 Overview

If you want to build Scheme modules with automatic dependency tracking, just use mzc as described in mzc: PLT Compilation and Packaging.

If you are already familiar with make, skip to the precise details of the make library in Make from Dependencies. This section contains a brief overview of make for everyone else. 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, let’s say that you are writing some 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.output

The point of using make is that it looks at the file creation dates of the various files and only re-builds what is necessary.

The make utility builds things with shell programs. If, on the other hand, you want to build similar things with various Scheme programs, you can use the make library.

Here’s the equivalent Scheme program:

  (require make)

  

  (define (make-output in out)

     ....)

  

  (define (combine-total . args)

    ....)

  

  (make

    (("a.output" ("a.input") (make-output "a.output" "a.input"))

     ("b.output" ("b.input") (make-output "b.output" "b.input"))

     ("c.output" ("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 similar, and it would be good to write a program to generate those lines).