source: project/wiki/make @ 9449

Last change on this file since 9449 was 9449, checked in by sjamaan, 12 years ago

Add wikified 'make' docs

File size: 4.8 KB
Line 
1[[tags: egg]]
2
3== make
4
5[[toc:]]
6
7=== Description
8
9A control structure that provides basic {{makefile}} operations in
10Scheme.
11
12=== Author
13
14This implementation has been taken from
15[[http://www.plt-scheme.org|PLT]] and minimally modified by
16[[felix winkelmann]] to work with Chicken.
17
18=== Requirements
19
20None
21
22=== Download
23
24[[http://www.call-with-current-continuation.org/eggs/make.egg|make.egg]]
25
26=== Documentation
27
28This library provides a Scheme version of the standard unix
29{{make}} utility. Its syntax is intended to simulate regular
30unix make in Scheme.
31
32The idea is to explain how to generate some project you have from a
33collection of source files that go through several stages of
34processing.
35
36For example, let's say that you are writing soem project that has
37three input files (that you create and maintain) called {{a.input}},
38{{b.input}}, and {{c.input}}. Further, there are two stages of
39processing -- first you run a particular tool {{make-output}} that takes
40an input file and produces and output file, and second you combine the
41input files into a single file using {{output}}. Using {{make}}, you might
42write this:
43
44  a.output: a.input
45        make-output a.input a.output
46  b.output: b.input
47        make-output b.input b.output
48  c.output: c.input
49        make-output c.input c.output
50  total: a.output b.output c.output
51        combine a.output b.output c.output
52
53Once you've put those above lines in a file called {{Makefile}}, you can
54issue the command:
55
56  make total
57
58that builds your entire project. The Makefile consists of several
59lines that tell `make' how to create each piece. The first two lines
60say that a.output depends on a.input and the command for making
61{{a.output}} from {{a.input}} is
62
63  make-output a.input a.ouput
64
65The point of this exercise is that the {{make}} utility looks
66at the file creation dates of the various files and only
67re-builds what is necessary.  Make is based on building
68things with shell programs. If, on the other hand, you want
69to build similar things with various Scheme programs, you
70can use the make collection.
71
72Here's the equivalent Scheme program: 
73
74<enscript highlight=scheme>
75(require-for-syntax 'make)
76
77(define (make-output in out)
78   ...)
79
80(define (combine-total . args)
81  ...)
82
83(make
84  (("a.output" ("a.input") (make-output "a.output" "a.input"))
85   ("b.output" ("b.input") (make-output "b.output" "b.input"))
86   ("c.output" ("c.input") (make-output "c.output" "c.input"))
87   ("total" ("a.output" "b.output" "c.output")
88            (combine-total "a.output" "b.output" "c.output")) )
89  "total")
90</enscript>
91
92If you were to fill in the ellipses above with calls to {{system}},
93you'd have the exact same thing as the original Makefile. In addition,
94if you use {{make/proc}}, you can abstract over the various make lines
95(for example, the {{a.output}}, {{b.output}}, and {{c.output}} lines
96are very similar and it would be good to write a program to generate
97those lines).
98                             
99<macro>(make ((TARGET (DEPEND ...) COMMAND ...) ...) ARGV)</macro>
100
101Expands to
102
103  (make/proc
104    (list (list TARGET (list DEPEND ...) (lambda () COMMAND ...)) ...)
105    ARGV)
106
107<procedure>(make/proc SPEC ARGV)</procedure>
108
109Performs a make according to {{SPEC}} and using {{ARGV}} selecting one
110or more targets.  {{ARGV}} can either be a string or a vector or list
111of strings.
112
113{{SPEC}} is a {{MAKE-SPEC}}:
114
115  MAKE-SPEC = (list-of MAKE-LINE)
116  MAKE-LINE = (list TARGET (list-of DEPEND-STRING) COMMAND-THUNK)
117  TARGET = (union string (list-of string)) ; either a string or a list of strings
118  DEPEND-STRING = string
119  COMMAND-THUNK = (-> void)
120
121To make a target, {{MAKE/PROC}} is first called on each of the
122target's dependencies. If a target is not in the spec and it exists,
123then the target is considered made. If a target is older than any of
124its dependencies, the corresponding {{COMMAND-THUNK}} is invoked. The
125{{COMMAND-THUNK}} is optional; a {{MAKE-LINE}} without a
126{{COMMAND-THUNK}} is useful as a target for making a number of other
127targets (the dependencies).
128
129<parameter>make-print-checking</parameter>
130
131If {{#f}}, make only prints when it is making a target. Otherwise, it
132prints when it is checking the dependancies of a target. Defaultly
133{{#t}}.
134
135<parameter>make-print-dep-no-line</parameter>
136
137If {{#f}}, make only prints {{"checking..."}}  lines for dependancies
138that have a corresponding make line.  Defaultly {{#f}}.
139
140<parameter>make-print-reasons</parameter>
141
142If {{#t}}, make prints the reason for each dependancy that
143fires. Defaultly {{#t}}.
144
145=== Changelog
146
147* 1.3 Accepts lists in addition to vectors for target list
148* 1.2 Adapted to new setup scheme
149* 1.1 Removed unused reference to {{directory-exists?}}. The file {{make/syntax.scm}} wasn't needed.
150* 1.0 Initial release
151
152=== License
153
154  PLT Software
155  Copyright (c) 1995-2002 PLT
156 
157  PLT software is distributed under the GNU Lesser General Public
158  License (LGPL).
Note: See TracBrowser for help on using the repository browser.