-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
40 lines (28 loc) · 825 Bytes
/
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
.PHONY: all test dependencies targets
SOURCES := $(shell find . -type f -name '*.go')
PEGS := $(shell find . -type f -name '*.peg')
TARGETS := \
linux-386 \
linux-amd64 \
darwin-amd64
TARGET_DIR := target
PROGRAMS := $(foreach target,$(TARGETS),$(TARGET_DIR)/logan-$(target))
GENERATED_PEGS := $(PEGS:.peg=.peg.go)
all: parsers test targets
dependencies:
go get -v
parsers: $(GENERATED_PEGS)
test: dependencies
find . -type d -not -path '*/.git*' -a -not -path '*/target*' -a -not -path '*/docs*' | \
xargs -n 1 go test
logan: $(SOURCES)
go build -v .
$(TARGET_DIR):
mkdir -p $(TARGET_DIR)
targets: $(TARGET_DIR) $(PROGRAMS)
$(PROGRAMS): $(SOURCES)
GOOS=$$(echo "$@" | xargs basename | cut -d- -f2) \
GOARCH=$$(echo "$@" | xargs basename | cut -d- -f3) \
go build -v -o "$@" .
%.peg.go: %.peg
peg $<