Change behavior. (require racket-makefile) and use (make <target>) instead of racket Makefile.rkt <target>
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
Racket available and only adds targets, dependencies, timestamp based rebuilds,
|
||||
phony targets, external command execution and a few cleanup helpers.
|
||||
|
||||
A makefile only defines its targets. Loading or running the file does not build
|
||||
anything by itself. Builds are started explicitly with `make`.
|
||||
|
||||
```racket
|
||||
#lang racket-makefile
|
||||
|
||||
@@ -26,6 +29,8 @@ phony targets, external command execution and a few cleanup helpers.
|
||||
(cleanup "scrbl" '("**.html" "**.js" "**.css")))
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
Install a local checkout with:
|
||||
|
||||
```text
|
||||
@@ -35,20 +40,68 @@ raco pkg install
|
||||
For a versioned archive, give the package name explicitly:
|
||||
|
||||
```text
|
||||
raco pkg install --name racket-makefile racket-makefile-0.1.1.zip
|
||||
raco pkg install --name racket-makefile racket-makefile-0.1.2.zip
|
||||
```
|
||||
|
||||
Run the default target or select one or more targets explicitly:
|
||||
## Running targets
|
||||
|
||||
Load the makefile with `-t` and evaluate a `make` expression with `-e`:
|
||||
|
||||
```text
|
||||
racket Makefile.rkt
|
||||
racket Makefile.rkt clean
|
||||
racket Makefile.rkt clean all
|
||||
racket -t Makefile.rkt -e "(make)"
|
||||
racket -t Makefile.rkt -e "(make all)"
|
||||
racket -t Makefile.rkt -e "(make clean)"
|
||||
racket -t Makefile.rkt -e "(make clean all)"
|
||||
```
|
||||
|
||||
The language adds `target`, `deps`, `phony`, `default-target`, `run`, `rm-f`,
|
||||
`rm-rf`, `cleanup`, `$target`, `$deps` and `$<`. Dependency expressions may
|
||||
also produce lists, which are automatically flattened. Everything else is
|
||||
`(make)` uses the target selected with `default-target`. If no default target is
|
||||
specified, the first declared target is used.
|
||||
|
||||
Loading the file alone only registers the targets:
|
||||
|
||||
```text
|
||||
racket -t Makefile.rkt
|
||||
```
|
||||
|
||||
No recipe is executed in that case.
|
||||
|
||||
In DrRacket, open the makefile and press **Run**. This also only loads and
|
||||
registers the targets. Then use the Interactions window:
|
||||
|
||||
```racket
|
||||
> (make)
|
||||
> (make clean)
|
||||
> (make all)
|
||||
> (make clean all)
|
||||
```
|
||||
|
||||
Bare identifiers in `make` are target names, so no quote is needed. For
|
||||
example, `(make clean)` selects the target named `clean`.
|
||||
|
||||
## Generated targets
|
||||
|
||||
Because the rest of the language is ordinary Racket, targets can be generated
|
||||
with normal definitions and loops:
|
||||
|
||||
```racket
|
||||
(define sources '("foo.c" "bar.c" "baz.c"))
|
||||
|
||||
(define objects
|
||||
(for/list ([src sources])
|
||||
(define obj (path-replace-extension src #".o"))
|
||||
(target obj
|
||||
(deps src)
|
||||
(run `(cc -c $< -o $target)))
|
||||
obj))
|
||||
|
||||
(target all
|
||||
(deps objects))
|
||||
```
|
||||
|
||||
Dependency expressions may produce lists; they are recursively flattened.
|
||||
|
||||
The language adds `target`, `deps`, `phony`, `default-target`, `make`, `run`,
|
||||
`rm-f`, `rm-rf`, `cleanup`, `$target`, `$deps` and `$<`. Everything else is
|
||||
ordinary Racket.
|
||||
|
||||
See the installed `racket-makefile` Scribble documentation for the full API.
|
||||
|
||||
Reference in New Issue
Block a user