forked from pointlander/peg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
74 lines (60 loc) · 2.12 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Copyright 2010 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
peg: peg.peg.go main.go
go build
peg.peg.go: bootstrap
cmd/peg-bootstrap/peg-bootstrap <peg.peg >peg.peg.go
go build
./peg -inline -switch peg.peg
# Use peg-bootstrap to compile peg from peg.peg
.PHONY: bootstrap
bootstrap: cmd/peg-bootstrap/peg-bootstrap
bootstrap/bootstrap: bootstrap/main.go tree/peg.go
cd bootstrap; go build
# peg0 <- bootstrap.peg.go from bootstrap/main.go
# peg0 accepts inputs compiled from main.go matching bootstrap.peg
cmd/peg-bootstrap/peg0: cmd/peg-bootstrap/main.go bootstrap/bootstrap
cd cmd/peg-bootstrap/ && \
rm -f *.peg.go && \
../../bootstrap/bootstrap && \
go build -o peg0
# peg1 <- bootstrap.peg.go from peg0 + bootstrap.peg
# peg1 accepts inputs compiled from bootstrap.peg
cmd/peg-bootstrap/peg1: cmd/peg-bootstrap/peg0 cmd/peg-bootstrap/bootstrap.peg
cd cmd/peg-bootstrap/ && \
rm -f *.peg.go && \
./peg0 <bootstrap.peg >peg1.peg.go && \
go build -o peg1
# peg2 <- peg.bootstrap.peg.go from peg1 + peg.bootstrap.peg
# peg2 accepts inputs compiled from peg.bootstrap.peg matching peg.peg
cmd/peg-bootstrap/peg2: cmd/peg-bootstrap/peg1 cmd/peg-bootstrap/peg.bootstrap.peg
cd cmd/peg-bootstrap/ && \
rm -f *.peg.go && \
./peg1 <peg.bootstrap.peg >peg2.peg.go && \
go build -o peg2
# peg3 <- peg.peg.go from peg2 + peg.peg
# peg3 accepts inputs compiled from peg.peg
cmd/peg-bootstrap/peg3: cmd/peg-bootstrap/peg2 peg.peg
cd cmd/peg-bootstrap/ && \
rm -f *.peg.go && \
./peg2 <../../peg.peg >peg3.peg.go && \
go build -o peg3
cmd/peg-bootstrap/peg-bootstrap: cmd/peg-bootstrap/peg3
cd cmd/peg-bootstrap/ && \
rm -f *.peg.go && \
./peg3 <../../peg.peg >peg-bootstrap.peg.go && \
go build -o peg-bootstrap
.PHONY:clean
clean:
rm -f bootstrap/bootstrap peg cmd/peg-bootstrap/{*peg.go,peg{[0-3],-bootstrap}}
.PHONY:test
test: peg fmt
go test
.PHONY:fmt
fmt:
# fail if any files don't match gofmt
gofmt -l -s {*,*/*,*/*/*}.go | awk ' { exit 1 } '
.PHONY:bench
bench:
go test -benchmem -bench .